From 363963c2fefb8b002aac3cebe368b853ebfad675 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 25 Jun 2021 19:30:07 +0100 Subject: staging: rtl8188eu: remove set but unused variable from rtw_get_sec_ie Remove set but unused variable 'sec_idx' from the rtw_get_sec_ie function inside core/rtw_ieee80211.c, to fix a kernel test robot warning introduced by recent removal of erroneous debug statements. Reported-by: kernel test robot Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210625183007.7065-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c index e431914db008..ce82b866c633 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c @@ -465,7 +465,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { - u8 authmode, sec_idx; + u8 authmode; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; @@ -473,8 +473,6 @@ void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie cnt = _TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_; - sec_idx = 0; - while (cnt < in_len) { authmode = in_ie[cnt]; -- cgit v1.2.3 From ac5951a6e3d50cfa861ea83baa2ec15d994389cb Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 25 Jun 2021 20:16:58 +0100 Subject: staging: rtl8188eu: remove rtw_wx_set_rate handler function Remove rtw_wx_set_rate handler function, which currently handles the SIOCSIWRATE wext ioctl. This function (although containing a lot of code) set nothing outside its own local variables, and did nothing other than call a now removed debugging statement repeatedly. Removing it and leaving its associated entry in rtw_handlers as NULL is therefore the better option. Removing this function also fixes a kernel test robot warning. Reported-by: kernel test robot Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210625191658.1299-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 75 -------------------------- 1 file changed, 75 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index b958a8d882b0..d4dce8ef0322 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1262,80 +1262,6 @@ static int rtw_wx_get_essid(struct net_device *dev, return 0; } -static int rtw_wx_set_rate(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - int i; - u8 datarates[NumRates]; - u32 target_rate = wrqu->bitrate.value; - u32 fixed = wrqu->bitrate.fixed; - u32 ratevalue = 0; - u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; - - if (target_rate == -1) { - ratevalue = 11; - goto set_rate; - } - target_rate /= 100000; - - switch (target_rate) { - case 10: - ratevalue = 0; - break; - case 20: - ratevalue = 1; - break; - case 55: - ratevalue = 2; - break; - case 60: - ratevalue = 3; - break; - case 90: - ratevalue = 4; - break; - case 110: - ratevalue = 5; - break; - case 120: - ratevalue = 6; - break; - case 180: - ratevalue = 7; - break; - case 240: - ratevalue = 8; - break; - case 360: - ratevalue = 9; - break; - case 480: - ratevalue = 10; - break; - case 540: - ratevalue = 11; - break; - default: - ratevalue = 11; - break; - } - -set_rate: - - for (i = 0; i < NumRates; i++) { - if (ratevalue == mpdatarate[i]) { - datarates[i] = mpdatarate[i]; - if (fixed == 0) - break; - } else { - datarates[i] = 0xff; - } - } - - return 0; -} - static int rtw_wx_get_rate(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -2715,7 +2641,6 @@ static iw_handler rtw_handlers[] = { IW_HANDLER(SIOCSIWESSID, rtw_wx_set_essid), IW_HANDLER(SIOCGIWESSID, rtw_wx_get_essid), IW_HANDLER(SIOCGIWNICKN, rtw_wx_get_nick), - IW_HANDLER(SIOCSIWRATE, rtw_wx_set_rate), IW_HANDLER(SIOCGIWRATE, rtw_wx_get_rate), IW_HANDLER(SIOCSIWRTS, rtw_wx_set_rts), IW_HANDLER(SIOCGIWRTS, rtw_wx_get_rts), -- cgit v1.2.3 From e7ca5907d1e00dfa639cae8864db56eca906738d Mon Sep 17 00:00:00 2001 From: Jan Gruber Date: Mon, 5 Jul 2021 09:21:25 +0200 Subject: staging: rtl8188eu: remove unnecessary braces This commit fixes the following checkpatch.pl warning: WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Jan Gruber Link: https://lore.kernel.org/r/20210705072125.199810-1-j4n6ru@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index b7e2692c35f3..f8519bfec020 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -379,9 +379,8 @@ static int rtw_usb_if1_init(struct usb_interface *pusb_intf) /* step 6. Tell the network stack we exist */ err = register_netdev(pnetdev); - if (err) { + if (err) goto free_hal_data; - } pr_debug("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n" , padapter->bDriverStopped -- cgit v1.2.3 From f0deefa679af621c51453b114b6977151b62cd39 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Wed, 30 Jun 2021 07:56:47 +0100 Subject: staging: r8188eu: Fix while-loop that iterates only once The while-loop only iterates once becase the post increment test of count being non-zero is false on the first iteration because count is zero. Fix this by using a for-loop instead. Static analysis found the issue on the count > POLLING_LLT_THRESHOLD check always being false since the loop currently just iterates once. Thanks to David Laight for suggesting using for-loop instead to improve the readability of the fix. Signed-off-by: Colin Ian King Link: https://lore.kernel.org/r/20210630065647.5641-1-colin.king@canonical.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index d1086699f952..1c6365832247 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -168,14 +168,14 @@ void rtw_hal_notch_filter(struct adapter *adapter, bool enable) static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) { s32 status = _SUCCESS; - s32 count = 0; + s32 count; u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); u16 LLTReg = REG_LLT_INIT; usb_write32(padapter, LLTReg, value); /* polling */ - do { + for (count = 0; ; count++) { value = usb_read32(padapter, LLTReg); if (_LLT_OP_VALUE(value) == _LLT_NO_ACTIVE) break; @@ -185,7 +185,7 @@ static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) break; } udelay(5); - } while (count++); + } return status; } -- cgit v1.2.3 From f9b9e0baec52706ae9c1c6cafeecdf88c187bab5 Mon Sep 17 00:00:00 2001 From: Bryan Brattlof Date: Tue, 29 Jun 2021 14:02:52 +0000 Subject: staging: rtl8723bs: remove custom endian conversion macros The rtw_cpu_to_leXX() and rtw_leXX_to_cpu() family of macros are unnecessary and should be removed. Signed-off-by: Bryan Brattlof Link: https://lore.kernel.org/r/20210629135824.47749-1-hello@bryanbrattlof.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_io.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_io.c b/drivers/staging/rtl8723bs/core/rtw_io.c index 856e23398c03..4d3c30ec93b5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_io.c +++ b/drivers/staging/rtl8723bs/core/rtw_io.c @@ -28,11 +28,6 @@ jackson@realtek.com.tw #include #include -#define rtw_le16_to_cpu(val) val -#define rtw_le32_to_cpu(val) val -#define rtw_cpu_to_le16(val) val -#define rtw_cpu_to_le32(val) val - u8 rtw_read8(struct adapter *adapter, u32 addr) { /* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */ @@ -47,7 +42,6 @@ u8 rtw_read8(struct adapter *adapter, u32 addr) u16 rtw_read16(struct adapter *adapter, u32 addr) { - u16 r_val; /* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */ struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); @@ -55,13 +49,11 @@ u16 rtw_read16(struct adapter *adapter, u32 addr) _read16 = pintfhdl->io_ops._read16; - r_val = _read16(pintfhdl, addr); - return rtw_le16_to_cpu(r_val); + return _read16(pintfhdl, addr); } u32 rtw_read32(struct adapter *adapter, u32 addr) { - u32 r_val; /* struct io_queue *pio_queue = (struct io_queue *)adapter->pio_queue; */ struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = &(pio_priv->intf); @@ -69,8 +61,7 @@ u32 rtw_read32(struct adapter *adapter, u32 addr) _read32 = pintfhdl->io_ops._read32; - r_val = _read32(pintfhdl, addr); - return rtw_le32_to_cpu(r_val); + return _read32(pintfhdl, addr); } -- cgit v1.2.3 From b658acbf64ae38b8fca982c2929ccc0bf4eb1ea2 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Thu, 15 Jul 2021 16:57:00 +0200 Subject: staging: rtl8723bs: fix wpa_set_auth_algs() function fix authentication algorithm constants. wpa_set_auth_algs() function contains some conditional statements masking the checked value with the wrong constants. This produces some unintentional dead code. Mask the value with the right macros. Fixes: 5befa937e8da ("staging: rtl8723bs: Fix IEEE80211 authentication algorithm constants.") Reported-by: Colin Ian King Tested-on: Lenovo Ideapad MiiX 300-10IBY Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/20210715145700.9427-1-fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index f95000df8942..965558516cbd 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -349,16 +349,16 @@ static int wpa_set_auth_algs(struct net_device *dev, u32 value) struct adapter *padapter = rtw_netdev_priv(dev); int ret = 0; - if ((value & WLAN_AUTH_SHARED_KEY) && (value & WLAN_AUTH_OPEN)) { + if ((value & IW_AUTH_ALG_SHARED_KEY) && (value & IW_AUTH_ALG_OPEN_SYSTEM)) { padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; - } else if (value & WLAN_AUTH_SHARED_KEY) { + } else if (value & IW_AUTH_ALG_SHARED_KEY) { padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; - } else if (value & WLAN_AUTH_OPEN) { + } else if (value & IW_AUTH_ALG_OPEN_SYSTEM) { /* padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; */ if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) { padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; -- cgit v1.2.3 From 5402cc178c5ddcac871456eacbf8bc5ad72d41e9 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:42 +0200 Subject: staging: rtl8723bs: add get_channel cfg80211 implementation add get_channel cfg80211 implementation to let userspace programs rely on nl80211 protocol to display channel information. Old iw dev output: phy#0 Interface wlan0 ifindex 2 wdev 0x1 addr 34:c3:d2:73:eb:c7 ssid Fabio type managed txpower 12.00 dBm Fixed output: phy#0 Interface wlan0 ifindex 2 wdev 0x1 addr 34:c3:d2:73:eb:c7 ssid Fabio type managed new--> channel 11 (2462 MHz), width: 20 MHz, center1: 2462 Mhz txpower 12.00 dBm Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/2f00479d8369b82b590291bb0edf27bc3041b0f0.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 53 ++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index fd747c8d920e..d198d10ec272 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2100,7 +2100,58 @@ void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, unsigned char cfg80211_del_sta(ndev, da, GFP_ATOMIC); } +static u8 rtw_get_chan_type(struct adapter *adapter) +{ + struct mlme_ext_priv *mlme_ext = &adapter->mlmeextpriv; + + switch (mlme_ext->cur_bwmode) { + case CHANNEL_WIDTH_20: + if (IsSupportedHT(adapter->registrypriv.wireless_mode)) + return NL80211_CHAN_HT20; + else + return NL80211_CHAN_NO_HT; + case CHANNEL_WIDTH_40: + if (mlme_ext->cur_ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + return NL80211_CHAN_HT40PLUS; + else + return NL80211_CHAN_HT40MINUS; + default: + return NL80211_CHAN_HT20; + } + return NL80211_CHAN_HT20; +} + +static int cfg80211_rtw_get_channel(struct wiphy *wiphy, struct wireless_dev *wdev, + struct cfg80211_chan_def *chandef) +{ + struct adapter *adapter = wiphy_to_adapter(wiphy); + struct registry_priv *registrypriv = &adapter->registrypriv; + enum nl80211_channel_type chan_type; + struct ieee80211_channel *chan = NULL; + int channel; + int freq; + + if (!adapter->rtw_wdev) + return -ENODEV; + + channel = rtw_get_oper_ch(adapter); + if (!channel) + return -ENODATA; + + freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); + + chan = ieee80211_get_channel(adapter->rtw_wdev->wiphy, freq); + + if (registrypriv->ht_enable) { + chan_type = rtw_get_chan_type(adapter); + cfg80211_chandef_create(chandef, chan, chan_type); + } else { + cfg80211_chandef_create(chandef, chan, NL80211_CHAN_NO_HT); + } + + return 0; +} static netdev_tx_t rtw_cfg80211_monitor_if_xmit_entry(struct sk_buff *skb, struct net_device *ndev) { @@ -2838,7 +2889,7 @@ static struct cfg80211_ops rtw_cfg80211_ops = { .set_pmksa = cfg80211_rtw_set_pmksa, .del_pmksa = cfg80211_rtw_del_pmksa, .flush_pmksa = cfg80211_rtw_flush_pmksa, - + .get_channel = cfg80211_rtw_get_channel, .add_virtual_intf = cfg80211_rtw_add_virtual_intf, .del_virtual_intf = cfg80211_rtw_del_virtual_intf, -- cgit v1.2.3 From 309f3cd3d7f439ff62197469c4a4132aecce11b8 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:43 +0200 Subject: staging: rtl8723bs: convert IsSupportedHT to snake_case convert IsSupportedHT to snake case is_supported_ht. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/d3e115f3a553db07a52cc51b71d04de9c383f697.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 2 +- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index bd5056507f53..fcbbdbe5448b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -554,7 +554,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) short_GI = query_ra_short_GI(psta); - if (IsSupportedHT(psta->wireless_mode)) { + if (is_supported_ht(psta->wireless_mode)) { rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); max_rate = rtw_mcs_rate(rf_type, diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index c06b74f6569a..56c5cb318fdf 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -55,7 +55,7 @@ u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta) if (cur_rf_type == RF_1T1R) { rf_type = RF_1T1R; - } else if (IsSupportedHT(psta->wireless_mode)) { + } else if (is_supported_ht(psta->wireless_mode)) { if (psta->ra_mask & 0xfff00000) rf_type = RF_2T2R; } diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 378c21595e05..8eb0557a077a 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -167,7 +167,7 @@ enum network_type { #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false) -#define IsSupportedHT(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false) +#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false) struct ieee_param { u32 cmd; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index d198d10ec272..368e575c24af 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2106,7 +2106,7 @@ static u8 rtw_get_chan_type(struct adapter *adapter) switch (mlme_ext->cur_bwmode) { case CHANNEL_WIDTH_20: - if (IsSupportedHT(adapter->registrypriv.wireless_mode)) + if (is_supported_ht(adapter->registrypriv.wireless_mode)) return NL80211_CHAN_HT20; else return NL80211_CHAN_NO_HT; -- cgit v1.2.3 From 2c02bce1dfe62bb64f223960575bf2f7c77f8eba Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:44 +0200 Subject: staging: rtl8723bs: fix camel case issue fix following post commit hook checkpatch issue: CHECK: Avoid CamelCase: 45: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:170: +#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false) Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/a708b2b9902bedf5bd0466b05516a4c5b4f43723.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 8eb0557a077a..b2c1a7dafcee 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -167,7 +167,7 @@ enum network_type { #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) #define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false) -#define is_supported_ht(NetType) (((NetType) & (WIRELESS_11_24N)) ? true : false) +#define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false) struct ieee_param { u32 cmd; -- cgit v1.2.3 From 7fc806fff7f7787a3bf2a83a41d6c99e361ab5bb Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:45 +0200 Subject: staging: rtl8723bs: fix camel case name in macro IsLegacyOnly() fix camel case name in macro IsLegacyOnly() Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/52656190cefed1b0f9a2dd6dcb080adf2ca0a89b.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 3b0573885dce..8ec8f283893b 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -401,7 +401,7 @@ static u8 halbtcoutsrc_Get(void *pBtcContext, u8 getType, void *pOutBuf) break; case BTC_GET_U4_WIFI_BW: - if (IsLegacyOnly(mlmeext->cur_wireless_mode)) + if (is_legacy_only(mlmeext->cur_wireless_mode)) *pU4Tmp = BTC_WIFI_BW_LEGACY; else if (pHalData->CurrentChannelBW == CHANNEL_WIDTH_20) *pU4Tmp = BTC_WIFI_BW_HT20; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index b2c1a7dafcee..ea1800de3ef8 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -154,7 +154,7 @@ enum network_type { #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) -#define IsLegacyOnly(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG))) +#define is_legacy_only(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG))) #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -- cgit v1.2.3 From bea76a2ab83e4eaac338823727bacbc08d147c69 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:46 +0200 Subject: staging: rtl8723bs: fix camel case in argument of macro is_legacy_only fix camel case in argument of macro is_legacy_only Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/404028e00ca4a32bfaed753d5927d9b673e6058d.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index ea1800de3ef8..343d077d9c76 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -154,7 +154,7 @@ enum network_type { #define SUPPORTED_24G_NETTYPE_MSK (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) -#define is_legacy_only(NetType) ((NetType) == ((NetType) & (WIRELESS_11BG))) +#define is_legacy_only(net_type) ((net_type) == ((net_type) & (WIRELESS_11BG))) #define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -- cgit v1.2.3 From 198e84ae5941765725ee4a299df8e5290eafa83c Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:47 +0200 Subject: staging: rtl8723bs: fix camel case name in macro IsSupported24G fix camel case name in macro IsSupported24G Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/fd5e1873f72e7d5f72b6f4bf801ede882e9df4e2.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +- drivers/staging/rtl8723bs/hal/hal_com.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index c128d462c6c7..af7d133bce94 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -343,7 +343,7 @@ static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_c if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) return chanset_size; - if (IsSupported24G(padapter->registrypriv.wireless_mode)) { + if (is_supported_24g(padapter->registrypriv.wireless_mode)) { b2_4GBand = true; if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index eebd48438733..d18537fde4ed 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -149,7 +149,7 @@ bool HAL_IsLegalChannel(struct adapter *Adapter, u32 Channel) bool bLegalChannel = true; if ((Channel <= 14) && (Channel >= 1)) { - if (IsSupported24G(Adapter->registrypriv.wireless_mode) == false) + if (is_supported_24g(Adapter->registrypriv.wireless_mode) == false) bLegalChannel = false; } else { bLegalChannel = false; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 343d077d9c76..2fa6ced333a0 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -156,9 +156,9 @@ enum network_type { #define is_legacy_only(net_type) ((net_type) == ((net_type) & (WIRELESS_11BG))) -#define IsSupported24G(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) +#define is_supported_24g(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsEnableHWCCK(NetType) IsSupported24G(NetType) +#define IsEnableHWCCK(NetType) is_supported_24g(NetType) #define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false) #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) -- cgit v1.2.3 From 202f7148c3a187cff57875b15eef7b0352db00bb Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:48 +0200 Subject: staging: rtl8723bs: fix post-commit camel case issues fix the following post-commit camel case issues: CHECK: Avoid CamelCase: 33: FILE: drivers/staging/rtl8723bs/hal/hal_com.c:152: + if (is_supported_24g(Adapter-> registrypriv.wireless_mode) == false) CHECK: Avoid CamelCase: 46: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:159: +#define is_supported_24g(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) CHECK: Avoid CamelCase: 49: FILE: drivers/staging/rtl8723bs/include/ieee80211.h:161: +#define IsEnableHWCCK(NetType) is_supported_24g(NetType) Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/6fd6d3266b5119330e15006ae610cb49b767bc59.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com.c | 4 ++-- drivers/staging/rtl8723bs/include/ieee80211.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index d18537fde4ed..4a112989899a 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -144,12 +144,12 @@ u8 hal_com_config_channel_plan( return chnlPlan; } -bool HAL_IsLegalChannel(struct adapter *Adapter, u32 Channel) +bool HAL_IsLegalChannel(struct adapter *adapter, u32 Channel) { bool bLegalChannel = true; if ((Channel <= 14) && (Channel >= 1)) { - if (is_supported_24g(Adapter->registrypriv.wireless_mode) == false) + if (is_supported_24g(adapter->registrypriv.wireless_mode) == false) bLegalChannel = false; } else { bLegalChannel = false; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 2fa6ced333a0..f29b7a92d9ac 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -156,9 +156,9 @@ enum network_type { #define is_legacy_only(net_type) ((net_type) == ((net_type) & (WIRELESS_11BG))) -#define is_supported_24g(NetType) ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) +#define is_supported_24g(net_type) ((net_type) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsEnableHWCCK(NetType) is_supported_24g(NetType) +#define IsEnableHWCCK(net_type) is_supported_24g(net_type) #define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false) #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) -- cgit v1.2.3 From a13d275b9b482a73c2224b99b08cdda4b73f5d64 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:49 +0200 Subject: staging: rtl8723bs: remove unused macros in include/ieee80211.h remove unused macros in include/ieee80211.h Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/c50cba3974772347888bd55085b1e5e44ef0687d.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/ieee80211.h | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index f29b7a92d9ac..9fa79146c39a 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -158,15 +158,7 @@ enum network_type { #define is_supported_24g(net_type) ((net_type) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsEnableHWCCK(net_type) is_supported_24g(net_type) -#define IsEnableHWOFDM(NetType) (((NetType) & (WIRELESS_11G|WIRELESS_11_24N)) ? true : false) - -#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) -#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) -#define IsSupportedRxHT(NetType) IsEnableHWOFDM(NetType) - #define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) -#define IsSupportedTxOFDM(NetType) (((NetType) & (WIRELESS_11G) ? true : false) #define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false) struct ieee_param { -- cgit v1.2.3 From ef35b7a88d46738cc13299103eacfa4d14c741a1 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:50 +0200 Subject: staging: rtl8723bs: fix camel case name in macro IsSupportedTxCCK fix camel case name in macro IsSupportedTxCCK Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/65aec26a3c25f1e756e33bf5f7f5af0cd3b105df.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 2 +- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index a6fcb5e9d637..da67adde2ebd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -402,7 +402,7 @@ void update_bmc_sta(struct adapter *padapter) supportRateNum, pcur_network->Configuration.DSConfig ); - if (IsSupportedTxCCK(network_type)) { + if (is_supported_tx_cck(network_type)) { network_type = WIRELESS_11B; } else if (network_type == WIRELESS_INVALID) { /* error handling */ diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 56c5cb318fdf..08f9ba9bf7ff 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1661,7 +1661,7 @@ void update_wireless_mode(struct adapter *padapter) void update_sta_basic_rate(struct sta_info *psta, u8 wireless_mode) { - if (IsSupportedTxCCK(wireless_mode)) { + if (is_supported_tx_cck(wireless_mode)) { /* Only B, B/G, and B/G/N AP could use CCK rate */ memcpy(psta->bssrateset, rtw_basic_rate_cck, 4); psta->bssratelen = 4; diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 9fa79146c39a..07cff4c490a0 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -158,7 +158,7 @@ enum network_type { #define is_supported_24g(net_type) ((net_type) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsSupportedTxCCK(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) +#define is_supported_tx_cck(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) #define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false) struct ieee_param { -- cgit v1.2.3 From 8655e695ac648287c432e2048a73decc552b019c Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 17 Jul 2021 16:56:51 +0200 Subject: staging: rtl8723bs: fix camel case argument name in macro is_supported_tx_cck fix camel case argument name in is_supported_tx_cck Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/f38fbb1388a54c78602750ecb86d0716d1aaf66b.1626533647.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 07cff4c490a0..b3a9bcce4c44 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -158,7 +158,7 @@ enum network_type { #define is_supported_24g(net_type) ((net_type) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define is_supported_tx_cck(NetType) (((NetType) & (WIRELESS_11B)) ? true : false) +#define is_supported_tx_cck(net_type) (((net_type) & (WIRELESS_11B)) ? true : false) #define is_supported_ht(net_type) (((net_type) & (WIRELESS_11_24N)) ? true : false) struct ieee_param { -- cgit v1.2.3 From 552fd002bdb520af3a8bedf1ee36185cf5e2c52f Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Tue, 20 Jul 2021 23:58:26 +0100 Subject: staging: rtl8188eu: move hal/mac_cfg.c and rename function and array Move source file hal/mac_cfg.c to the 'core' driver directory, and also rename its array from array_MAC_REG_8188E to array_MAC_REG, as well as renaming the function rtl88eu_phy_mac_config to phy_mac_config. Also modify single call-site for this function to reflect new name. This file contains no code which touches the adapter's HalData structure, and is a good candidate for therefore moving out of 'hal'. Also, no need for these signatures to include the model number as this driver only supports RTL8188eu. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210720225826.454516-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/Makefile | 2 +- drivers/staging/rtl8188eu/core/mac_cfg.c | 120 ++++++++++++++++++++++++++++ drivers/staging/rtl8188eu/hal/mac_cfg.c | 120 ---------------------------- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 +- drivers/staging/rtl8188eu/include/phy.h | 2 +- 5 files changed, 123 insertions(+), 123 deletions(-) create mode 100644 drivers/staging/rtl8188eu/core/mac_cfg.c delete mode 100644 drivers/staging/rtl8188eu/hal/mac_cfg.c (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile index 28b936e8be0a..2799ec5a7fda 100644 --- a/drivers/staging/rtl8188eu/Makefile +++ b/drivers/staging/rtl8188eu/Makefile @@ -1,5 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 r8188eu-y := \ + core/mac_cfg.o \ core/rtw_ap.o \ core/rtw_cmd.o \ core/rtw_efuse.o \ @@ -18,7 +19,6 @@ r8188eu-y := \ core/rtw_wlan_util.o \ core/rtw_xmit.o \ hal/fw.o \ - hal/mac_cfg.o \ hal/bb_cfg.o \ hal/rf_cfg.o \ hal/pwrseqcmd.o \ diff --git a/drivers/staging/rtl8188eu/core/mac_cfg.c b/drivers/staging/rtl8188eu/core/mac_cfg.c new file mode 100644 index 000000000000..a94c6ad472c5 --- /dev/null +++ b/drivers/staging/rtl8188eu/core/mac_cfg.c @@ -0,0 +1,120 @@ +// SPDX-License-Identifier: GPL-2.0 +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + ******************************************************************************/ + +#include "odm_precomp.h" +#include "phy.h" + +/* MAC_REG.TXT */ + +static u32 array_MAC_REG[] = { + 0x026, 0x00000041, + 0x027, 0x00000035, + 0x428, 0x0000000A, + 0x429, 0x00000010, + 0x430, 0x00000000, + 0x431, 0x00000001, + 0x432, 0x00000002, + 0x433, 0x00000004, + 0x434, 0x00000005, + 0x435, 0x00000006, + 0x436, 0x00000007, + 0x437, 0x00000008, + 0x438, 0x00000000, + 0x439, 0x00000000, + 0x43A, 0x00000001, + 0x43B, 0x00000002, + 0x43C, 0x00000004, + 0x43D, 0x00000005, + 0x43E, 0x00000006, + 0x43F, 0x00000007, + 0x440, 0x0000005D, + 0x441, 0x00000001, + 0x442, 0x00000000, + 0x444, 0x00000015, + 0x445, 0x000000F0, + 0x446, 0x0000000F, + 0x447, 0x00000000, + 0x458, 0x00000041, + 0x459, 0x000000A8, + 0x45A, 0x00000072, + 0x45B, 0x000000B9, + 0x460, 0x00000066, + 0x461, 0x00000066, + 0x480, 0x00000008, + 0x4C8, 0x000000FF, + 0x4C9, 0x00000008, + 0x4CC, 0x000000FF, + 0x4CD, 0x000000FF, + 0x4CE, 0x00000001, + 0x4D3, 0x00000001, + 0x500, 0x00000026, + 0x501, 0x000000A2, + 0x502, 0x0000002F, + 0x503, 0x00000000, + 0x504, 0x00000028, + 0x505, 0x000000A3, + 0x506, 0x0000005E, + 0x507, 0x00000000, + 0x508, 0x0000002B, + 0x509, 0x000000A4, + 0x50A, 0x0000005E, + 0x50B, 0x00000000, + 0x50C, 0x0000004F, + 0x50D, 0x000000A4, + 0x50E, 0x00000000, + 0x50F, 0x00000000, + 0x512, 0x0000001C, + 0x514, 0x0000000A, + 0x516, 0x0000000A, + 0x525, 0x0000004F, + 0x550, 0x00000010, + 0x551, 0x00000010, + 0x559, 0x00000002, + 0x55D, 0x000000FF, + 0x605, 0x00000030, + 0x608, 0x0000000E, + 0x609, 0x0000002A, + 0x620, 0x000000FF, + 0x621, 0x000000FF, + 0x622, 0x000000FF, + 0x623, 0x000000FF, + 0x624, 0x000000FF, + 0x625, 0x000000FF, + 0x626, 0x000000FF, + 0x627, 0x000000FF, + 0x652, 0x00000020, + 0x63C, 0x0000000A, + 0x63D, 0x0000000A, + 0x63E, 0x0000000E, + 0x63F, 0x0000000E, + 0x640, 0x00000040, + 0x66E, 0x00000005, + 0x700, 0x00000021, + 0x701, 0x00000043, + 0x702, 0x00000065, + 0x703, 0x00000087, + 0x708, 0x00000021, + 0x709, 0x00000043, + 0x70A, 0x00000065, + 0x70B, 0x00000087, +}; + +bool phy_mac_config(struct adapter *adapt) +{ + u32 i; + u32 arraylength; + u32 *ptrarray; + + arraylength = ARRAY_SIZE(array_MAC_REG); + ptrarray = array_MAC_REG; + + for (i = 0; i < arraylength; i += 2) + usb_write8(adapt, ptrarray[i], (u8)ptrarray[i + 1]); + + usb_write8(adapt, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); + return true; +} diff --git a/drivers/staging/rtl8188eu/hal/mac_cfg.c b/drivers/staging/rtl8188eu/hal/mac_cfg.c deleted file mode 100644 index 370aa5cc55a7..000000000000 --- a/drivers/staging/rtl8188eu/hal/mac_cfg.c +++ /dev/null @@ -1,120 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" -#include "phy.h" - -/* MAC_REG.TXT */ - -static u32 array_MAC_REG_8188E[] = { - 0x026, 0x00000041, - 0x027, 0x00000035, - 0x428, 0x0000000A, - 0x429, 0x00000010, - 0x430, 0x00000000, - 0x431, 0x00000001, - 0x432, 0x00000002, - 0x433, 0x00000004, - 0x434, 0x00000005, - 0x435, 0x00000006, - 0x436, 0x00000007, - 0x437, 0x00000008, - 0x438, 0x00000000, - 0x439, 0x00000000, - 0x43A, 0x00000001, - 0x43B, 0x00000002, - 0x43C, 0x00000004, - 0x43D, 0x00000005, - 0x43E, 0x00000006, - 0x43F, 0x00000007, - 0x440, 0x0000005D, - 0x441, 0x00000001, - 0x442, 0x00000000, - 0x444, 0x00000015, - 0x445, 0x000000F0, - 0x446, 0x0000000F, - 0x447, 0x00000000, - 0x458, 0x00000041, - 0x459, 0x000000A8, - 0x45A, 0x00000072, - 0x45B, 0x000000B9, - 0x460, 0x00000066, - 0x461, 0x00000066, - 0x480, 0x00000008, - 0x4C8, 0x000000FF, - 0x4C9, 0x00000008, - 0x4CC, 0x000000FF, - 0x4CD, 0x000000FF, - 0x4CE, 0x00000001, - 0x4D3, 0x00000001, - 0x500, 0x00000026, - 0x501, 0x000000A2, - 0x502, 0x0000002F, - 0x503, 0x00000000, - 0x504, 0x00000028, - 0x505, 0x000000A3, - 0x506, 0x0000005E, - 0x507, 0x00000000, - 0x508, 0x0000002B, - 0x509, 0x000000A4, - 0x50A, 0x0000005E, - 0x50B, 0x00000000, - 0x50C, 0x0000004F, - 0x50D, 0x000000A4, - 0x50E, 0x00000000, - 0x50F, 0x00000000, - 0x512, 0x0000001C, - 0x514, 0x0000000A, - 0x516, 0x0000000A, - 0x525, 0x0000004F, - 0x550, 0x00000010, - 0x551, 0x00000010, - 0x559, 0x00000002, - 0x55D, 0x000000FF, - 0x605, 0x00000030, - 0x608, 0x0000000E, - 0x609, 0x0000002A, - 0x620, 0x000000FF, - 0x621, 0x000000FF, - 0x622, 0x000000FF, - 0x623, 0x000000FF, - 0x624, 0x000000FF, - 0x625, 0x000000FF, - 0x626, 0x000000FF, - 0x627, 0x000000FF, - 0x652, 0x00000020, - 0x63C, 0x0000000A, - 0x63D, 0x0000000A, - 0x63E, 0x0000000E, - 0x63F, 0x0000000E, - 0x640, 0x00000040, - 0x66E, 0x00000005, - 0x700, 0x00000021, - 0x701, 0x00000043, - 0x702, 0x00000065, - 0x703, 0x00000087, - 0x708, 0x00000021, - 0x709, 0x00000043, - 0x70A, 0x00000065, - 0x70B, 0x00000087, -}; - -bool rtl88eu_phy_mac_config(struct adapter *adapt) -{ - u32 i; - u32 arraylength; - u32 *ptrarray; - - arraylength = ARRAY_SIZE(array_MAC_REG_8188E); - ptrarray = array_MAC_REG_8188E; - - for (i = 0; i < arraylength; i += 2) - usb_write8(adapt, ptrarray[i], (u8)ptrarray[i + 1]); - - usb_write8(adapt, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); - return true; -} diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 05c67e7d23ad..2a47e9b444d5 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -684,7 +684,7 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) } rtl8188e_InitializeFirmwareVars(Adapter); - rtl88eu_phy_mac_config(Adapter); + phy_mac_config(Adapter); rtl88eu_phy_bb_config(Adapter); diff --git a/drivers/staging/rtl8188eu/include/phy.h b/drivers/staging/rtl8188eu/include/phy.h index 40901d6dcaf5..8ee13eb68a5a 100644 --- a/drivers/staging/rtl8188eu/include/phy.h +++ b/drivers/staging/rtl8188eu/include/phy.h @@ -5,7 +5,7 @@ #define index_mapping_NUM_88E 15 #define AVG_THERMAL_NUM_88E 4 -bool rtl88eu_phy_mac_config(struct adapter *adapt); +bool phy_mac_config(struct adapter *adapt); bool rtl88eu_phy_rf_config(struct adapter *adapt); bool rtl88eu_phy_bb_config(struct adapter *adapt); -- cgit v1.2.3 From d2785a198b7c484f8e36ad2fd147c2a7ba243922 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:01 +0200 Subject: staging: rtl8188eu: merge two functions All that rtw_hal_read_chip_info does is call _ReadPROMContent. Merge the two functions. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-1-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 2a47e9b444d5..3c9a2c99c0d4 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -990,25 +990,18 @@ static void readAdapterInfo_8188EU(struct adapter *adapt) Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); } -static void _ReadPROMContent(struct adapter *Adapter) +void rtw_hal_read_chip_info(struct adapter *Adapter) { struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); - u8 eeValue; + u8 eeValue = usb_read8(Adapter, REG_9346CR); - /* check system boot selection */ - eeValue = usb_read8(Adapter, REG_9346CR); - eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; - eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; + eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; + eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; Hal_InitPGData88E(Adapter); readAdapterInfo_8188EU(Adapter); } -void rtw_hal_read_chip_info(struct adapter *Adapter) -{ - _ReadPROMContent(Adapter); -} - #define GPIO_DEBUG_PORT_NUM 0 static void rtl8192cu_trigger_gpio_0(struct adapter *adapt) { -- cgit v1.2.3 From ba21a3acd4be4d68f7c87821b6491e333268c4d7 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:02 +0200 Subject: staging: rtl8188eu: remove the "trigger gpio 0" hal variable The hal variable to trigger gpio 0 seems to be a leftover from debugging code that was removed. An empty function is called when this variable is written to. Remove the empty function and the variable itself. It should be safe to remove an entry from the hw_variables enum as this enum is used only within the rtl8188eu driver. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 8 -------- drivers/staging/rtl8188eu/include/hal_intf.h | 1 - 2 files changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 3c9a2c99c0d4..b53d1c21f556 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1002,11 +1002,6 @@ void rtw_hal_read_chip_info(struct adapter *Adapter) readAdapterInfo_8188EU(Adapter); } -#define GPIO_DEBUG_PORT_NUM 0 -static void rtl8192cu_trigger_gpio_0(struct adapter *adapt) -{ -} - static void ResumeTxBeacon(struct adapter *adapt) { struct hal_data_8188e *haldata = adapt->HalData; @@ -1550,9 +1545,6 @@ void rtw_hal_set_hwreg(struct adapter *Adapter, u8 variable, u8 *val) } } break; - case HW_VAR_TRIGGER_GPIO_0: - rtl8192cu_trigger_gpio_0(Adapter); - break; case HW_VAR_RPT_TIMER_SETTING: { u16 min_rpt_time = (*(u16 *)val); diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 2e3e933781eb..2eb4f1fa75bb 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -74,7 +74,6 @@ enum hw_variables { HW_VAR_TDLS_RS_RCR, HW_VAR_TDLS_DONE_CH_SEN, HW_VAR_INITIAL_GAIN, - HW_VAR_TRIGGER_GPIO_0, HW_VAR_BT_SET_COEXIST, HW_VAR_BT_ISSUE_DELBA, HW_VAR_CURRENT_ANTENNA, -- cgit v1.2.3 From 2ad449a187efe6bb1661dcc04b86afc94519f747 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:03 +0200 Subject: staging: rtl8188eu: remove RTL871X_HCI_TYPE enum This enum is not used and can be removed. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-3-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_intf.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 2eb4f1fa75bb..2a00d2df95d4 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -11,13 +11,6 @@ #include #include -enum RTL871X_HCI_TYPE { - RTW_PCIE = BIT(0), - RTW_USB = BIT(1), - RTW_SDIO = BIT(2), - RTW_GSPI = BIT(3), -}; - enum _CHIP_TYPE { NULL_CHIP_TYPE, RTL8712_8188S_8191S_8192S, -- cgit v1.2.3 From a9dc3f67dcff95864fcc4140b9d478c9135db300 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:04 +0200 Subject: staging: rtl8188eu: remove _CHIP_TYPE enum This enum is not used and can be removed. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-4-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_intf.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 2a00d2df95d4..c74249fc200f 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -11,16 +11,6 @@ #include #include -enum _CHIP_TYPE { - NULL_CHIP_TYPE, - RTL8712_8188S_8191S_8192S, - RTL8188C_8192C, - RTL8192D, - RTL8723A, - RTL8188E, - MAX_CHIP_TYPE -}; - enum hw_variables { HW_VAR_MEDIA_STATUS, HW_VAR_MEDIA_STATUS1, -- cgit v1.2.3 From 264d3064642d1125c5e8fd15d7f60f0639607983 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:05 +0200 Subject: staging: rtl8188eu: remove struct eeprom_priv's EepromOrEfuse This setting is used only in one place. There's no need to store it in a global struct. While at it, merge the two-line Hal_InitPGData88E function and its only caller. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-5-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 6 ------ drivers/staging/rtl8188eu/hal/usb_halinit.c | 5 +++-- drivers/staging/rtl8188eu/include/hal_intf.h | 2 -- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 3 --- 4 files changed, 3 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 1c6365832247..2afef26ddb56 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -228,12 +228,6 @@ s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) return status; } -void Hal_InitPGData88E(struct adapter *padapter) -{ - if (!is_boot_from_eeprom(padapter)) - EFUSE_ShadowMapUpdate(padapter); -} - void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo) { struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index b53d1c21f556..1f3c10aafd5d 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -995,10 +995,11 @@ void rtw_hal_read_chip_info(struct adapter *Adapter) struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); u8 eeValue = usb_read8(Adapter, REG_9346CR); - eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; - Hal_InitPGData88E(Adapter); + if (eeValue & BOOT_FROM_EEPROM) + EFUSE_ShadowMapUpdate(Adapter); + readAdapterInfo_8188EU(Adapter); } diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index c74249fc200f..4d4e0a259050 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -131,8 +131,6 @@ enum hardware_type { #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) -#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) - void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level); u32 rtl8188eu_hal_deinit(struct adapter *Adapter); u32 rtl8188eu_hal_init(struct adapter *Adapter); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 2c16d3f33e1c..f585cbe21a6f 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -196,8 +196,6 @@ struct hal_data_8188e { u8 bTXPowerDataReadFromEEPORM; u8 EEPROMThermalMeter; - bool EepromOrEfuse; - u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; u8 Index24G_BW40_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; /* If only one tx, only BW20 and OFDM are used. */ @@ -298,7 +296,6 @@ void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy); /* EFuse */ -void Hal_InitPGData88E(struct adapter *padapter); void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo); void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail); -- cgit v1.2.3 From dff70f7fbed361b6b5dbffe7607a3c515bfef009 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:06 +0200 Subject: staging: rtl8188eu: remove efuse write support This driver does not need write access to the rtl1888eu chip's efuses. Remove the code to set the voltages for writing the efuses. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-6-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_efuse.c | 32 +++--------------------------- 1 file changed, 3 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c index 80673a73c119..0b821df58b77 100644 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ b/drivers/staging/rtl8188eu/core/rtw_efuse.c @@ -16,18 +16,8 @@ #define REG_EFUSE_CTRL 0x0030 #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ -enum{ - VOLTAGE_V25 = 0x03, - LDOE25_SHIFT = 28, - }; - -/* - * When we want to enable write operation, we should change to pwr on state. - * When we stop write, we should switch to 500k mode and disable LDO 2.5V. - */ -static void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) +static void efuse_power_switch(struct adapter *pAdapter, u8 pwrstate) { - u8 tempval; u16 tmpv16; if (pwrstate) { @@ -52,22 +42,8 @@ static void efuse_power_switch(struct adapter *pAdapter, u8 write, u8 pwrstate) tmpv16 |= (LOADER_CLK_EN | ANA8M); usb_write16(pAdapter, REG_SYS_CLKR, tmpv16); } - - if (write) { - /* Enable LDO 2.5V before read/write action */ - tempval = usb_read8(pAdapter, EFUSE_TEST + 3); - tempval &= 0x0F; - tempval |= (VOLTAGE_V25 << 4); - usb_write8(pAdapter, EFUSE_TEST + 3, (tempval | 0x80)); - } } else { usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - - if (write) { - /* Disable LDO 2.5V after read/write action */ - tempval = usb_read8(pAdapter, EFUSE_TEST + 3); - usb_write8(pAdapter, EFUSE_TEST + 3, (tempval & 0x7F)); - } } } @@ -857,11 +833,9 @@ void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) /* Read All Efuse content */ static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 *Efuse) { - efuse_power_switch(pAdapter, false, true); - + efuse_power_switch(pAdapter, true); efuse_ReadEFuse(pAdapter, 0, EFUSE_MAP_LEN_88E, Efuse); - - efuse_power_switch(pAdapter, false, false); + efuse_power_switch(pAdapter, false); } /* Transfer current EFUSE content to shadow init and modify map. */ -- cgit v1.2.3 From 9d326c02ef0ee693c87c7af3ef1c69e9e1467a61 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:07 +0200 Subject: staging: rtl8188eu: remove unused power flows and transitions The driver defines a couple of "flows" to move the chip into a certain power state. Each flow is a sequence of "transitions". This patch removes flows and transitions which are not used. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-7-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/pwrseq.c | 52 ----------- drivers/staging/rtl8188eu/include/pwrseq.h | 112 ----------------------- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 6 -- 3 files changed, 170 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/pwrseq.c b/drivers/staging/rtl8188eu/hal/pwrseq.c index f7890a8f4673..80bf9692844f 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseq.c +++ b/drivers/staging/rtl8188eu/hal/pwrseq.c @@ -17,13 +17,6 @@ struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END }; -/* 3Radio off Array */ -struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_ACT_TO_CARDEMU - RTL8188E_TRANS_END -}; - /* 3Card Disable Array */ struct wl_pwr_cfg rtl8188E_card_disable_flow [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + @@ -34,43 +27,6 @@ struct wl_pwr_cfg rtl8188E_card_disable_flow RTL8188E_TRANS_END }; -/* 3 Card Enable Array */ -struct wl_pwr_cfg rtl8188E_card_enable_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_CARDDIS_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_ACT - RTL8188E_TRANS_END -}; - -/* 3Suspend Array */ -struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_ACT_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_SUS - RTL8188E_TRANS_END -}; - -/* 3 Resume Array */ -struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_SUS_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_ACT - RTL8188E_TRANS_END -}; - -/* 3HWPDN Array */ -struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_ACT_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_PDN - RTL8188E_TRANS_END -}; - /* 3 Enter LPS */ struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS] = { @@ -78,11 +34,3 @@ struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_ACT_TO_LPS RTL8188E_TRANS_END }; - -/* 3 Leave LPS */ -struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS + - RTL8188E_TRANS_END_STEPS] = { - /* FW behavior */ - RTL8188E_TRANS_LPS_TO_ACT - RTL8188E_TRANS_END -}; diff --git a/drivers/staging/rtl8188eu/include/pwrseq.h b/drivers/staging/rtl8188eu/include/pwrseq.h index c4b76064476f..caa6bf71da77 100644 --- a/drivers/staging/rtl8188eu/include/pwrseq.h +++ b/drivers/staging/rtl8188eu/include/pwrseq.h @@ -20,27 +20,12 @@ * 4: LPS--Low Power State * 5: SUS--Suspend * - * The transition from different states are defined below - * TRANS_CARDEMU_TO_ACT - * TRANS_ACT_TO_CARDEMU - * TRANS_CARDEMU_TO_SUS - * TRANS_SUS_TO_CARDEMU - * TRANS_CARDEMU_TO_PDN - * TRANS_ACT_TO_LPS - * TRANS_LPS_TO_ACT - * - * TRANS_END - * * PWR SEQ Version: rtl8188E_PwrSeq_V09.h */ #define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10 #define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10 -#define RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS 10 -#define RTL8188E_TRANS_SUS_TO_CARDEMU_STEPS 10 #define RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS 10 -#define RTL8188E_TRANS_PDN_TO_CARDEMU_STEPS 10 #define RTL8188E_TRANS_ACT_TO_LPS_STEPS 15 -#define RTL8188E_TRANS_LPS_TO_ACT_STEPS 15 #define RTL8188E_TRANS_END_STEPS 1 #define RTL8188E_TRANS_CARDEMU_TO_ACT \ @@ -81,30 +66,6 @@ {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, BIT(1), 0}, \ /*wait till 0x04[9] = 0 polling until return 0 to disable*/ -#define RTL8188E_TRANS_CARDEMU_TO_SUS \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)}, \ - /* 0x04[12:11] = 2b'01enable WL suspend */ \ - {0x0007, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, BIT(7)}, \ - /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */\ - {0x0041, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), 0}, \ - /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ - {0xfe10, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ - /*Set USB suspend enable local register 0xfe10[4]=1 */ - -#define RTL8188E_TRANS_SUS_TO_CARDEMU \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(3) | BIT(4), 0}, \ - /*0x04[12:11] = 2b'01enable WL suspend*/ - #define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ /* format * { offset, cut_msk, cmd, msk, @@ -122,35 +83,6 @@ {0xfe10, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ /*Set USB suspend enable local register 0xfe10[4]=1 */ -#define RTL8188E_TRANS_CARDDIS_TO_CARDEMU \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(3) | BIT(4), 0}, \ - /*0x04[12:11] = 2b'01enable WL suspend*/ - -#define RTL8188E_TRANS_CARDEMU_TO_PDN \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(0), 0}, \ - /* 0x04[16] = 0*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ - /* 0x04[15] = 1*/ - -#define RTL8188E_TRANS_PDN_TO_CARDEMU \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(7), 0}, \ - /* 0x04[15] = 0*/ - /* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ #define RTL8188E_TRANS_ACT_TO_LPS \ /* format @@ -178,31 +110,6 @@ {0x0553, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(5), BIT(5)}, \ /*Respond TxOK to scheduler*/ -#define RTL8188E_TRANS_LPS_TO_ACT \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0xFE58, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0x84}, \ - /*USB RPWM*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, \ - /*Delay*/ \ - {0x0008, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), 0}, \ - /* 0x08[4] = 0 switch TSF to 40M */ \ - {0x0109, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, BIT(7), 0}, \ - /* Polling 0x109[7]=0 TSF in 40M */ \ - {0x0029, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(6) | BIT(7), 0}, \ - /* 0x29[7:6] = 2b'00 enable BB clock */ \ - {0x0101, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(1), BIT(1)}, \ - /* 0x101[1] = 1 */ \ - {0x0100, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0xFF}, \ - /* 0x100[7:0] = 0xFF enable WMAC TRX */ \ - {0x0002, PWR_CUT_ALL_MSK, \ - PWR_CMD_WRITE, BIT(1) | BIT(0), BIT(1) | BIT(0)}, \ - /* 0x02[1:0] = 2b'11 enable BB macro */ \ - {0x0522, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ - #define RTL8188E_TRANS_END \ /* format * { offset, cut_msk, cmd, msk, @@ -213,30 +120,11 @@ extern struct wl_pwr_cfg rtl8188E_power_on_flow [RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_radio_off_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_END_STEPS]; extern struct wl_pwr_cfg rtl8188E_card_disable_flow [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_card_enable_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + - RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_suspend_flow[ - RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + - RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_resume_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + - RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_hwpdn_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS]; extern struct wl_pwr_cfg rtl8188E_enter_lps_flow [RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_leave_lps_flow - [RTL8188E_TRANS_LPS_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; #endif /* __HAL8188EPWRSEQ_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index f585cbe21a6f..e508b4b9ef7f 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -22,14 +22,8 @@ /* RTL8188E Power Configuration CMDs for USB/SDIO interfaces */ #define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow -#define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow #define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow -#define Rtl8188E_NIC_ENABLE_FLOW rtl8188E_card_enable_flow -#define Rtl8188E_NIC_SUSPEND_FLOW rtl8188E_suspend_flow -#define Rtl8188E_NIC_RESUME_FLOW rtl8188E_resume_flow -#define Rtl8188E_NIC_PDN_FLOW rtl8188E_hwpdn_flow #define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow -#define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow #define DRVINFO_SZ 4 /* unit is 8bytes */ #define PageNum_128(_Len) (u32)(((_Len) >> 7) + ((_Len) & 0x7F ? 1 : 0)) -- cgit v1.2.3 From a5efd7bd83b4a7d044e415c2d3ccf3a7c81b72b1 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:08 +0200 Subject: staging: rtl8188eu: remove constant function parameter The rtl88eu_pwrseqcmdparsing function takes a parameter to restrict commands to certain power cut versions of the rtl8188eu chipset. This mechanism is not used, the callers always select all versions. Remove the power cut parameter. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-8-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 82 +++++++++++++-------------- drivers/staging/rtl8188eu/hal/usb_halinit.c | 9 +-- drivers/staging/rtl8188eu/include/pwrseqcmd.h | 4 +- 3 files changed, 42 insertions(+), 53 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c index cec2ff879f5d..f2b973b377dd 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c @@ -11,8 +11,7 @@ /* This routine deals with the Power Configuration CMDs parsing * for RTL8723/RTL8188E Series IC. */ -u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, - struct wl_pwr_cfg pwrseqcmd[]) +u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcmd[]) { struct wl_pwr_cfg pwrcfgcmd; u8 poll_bit = false; @@ -25,53 +24,48 @@ u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, do { pwrcfgcmd = pwrseqcmd[aryidx]; - /* Only Handle the command whose CUT is matched */ - if (GET_PWR_CFG_CUT_MASK(pwrcfgcmd) & cut_vers) { - switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { - case PWR_CMD_READ: - break; - case PWR_CMD_WRITE: - offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); + switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { + case PWR_CMD_READ: + break; + case PWR_CMD_WRITE: + offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); - /* Read the value from system register */ - value = usb_read8(padapter, offset); - - value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); - value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & - GET_PWR_CFG_MASK(pwrcfgcmd)); + /* Read the value from system register */ + value = usb_read8(padapter, offset); - /* Write the value back to system register */ - usb_write8(padapter, offset, value); - break; - case PWR_CMD_POLLING: - poll_bit = false; - offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); - do { - value = usb_read8(padapter, offset); - value &= GET_PWR_CFG_MASK(pwrcfgcmd); + value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); + value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); - if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & - GET_PWR_CFG_MASK(pwrcfgcmd))) - poll_bit = true; - else - udelay(10); + /* Write the value back to system register */ + usb_write8(padapter, offset, value); + break; + case PWR_CMD_POLLING: + poll_bit = false; + offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); + do { + value = usb_read8(padapter, offset); + value &= GET_PWR_CFG_MASK(pwrcfgcmd); - if (poll_count++ > max_poll_count) - return false; - } while (!poll_bit); - break; - case PWR_CMD_DELAY: - if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); + if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) + poll_bit = true; else - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); - break; - case PWR_CMD_END: - /* When this command is parsed, end the process */ - return true; - default: - break; - } + udelay(10); + + if (poll_count++ > max_poll_count) + return false; + } while (!poll_bit); + break; + case PWR_CMD_DELAY: + if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); + else + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); + break; + case PWR_CMD_END: + /* When this command is parsed, end the process */ + return true; + default: + break; } aryidx++;/* Add Array Index */ diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 1f3c10aafd5d..1d7d5037ce89 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -88,8 +88,7 @@ u32 rtw_hal_power_on(struct adapter *adapt) if (adapt->HalData->bMacPwrCtrlOn) return _SUCCESS; - if (!rtl88eu_pwrseqcmdparsing(adapt, PWR_CUT_ALL_MSK, - Rtl8188E_NIC_PWR_ON_FLOW)) + if (!rtl88eu_pwrseqcmdparsing(adapt, Rtl8188E_NIC_PWR_ON_FLOW)) return _FAIL; /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ @@ -830,8 +829,7 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) usb_write8(Adapter, REG_CR, 0x0); /* Run LPS WL RFOFF flow */ - rtl88eu_pwrseqcmdparsing(Adapter, PWR_CUT_ALL_MSK, - Rtl8188E_NIC_LPS_ENTER_FLOW); + rtl88eu_pwrseqcmdparsing(Adapter, Rtl8188E_NIC_LPS_ENTER_FLOW); /* 2. 0x1F[7:0] = 0 turn off RF */ @@ -852,8 +850,7 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) usb_write8(Adapter, REG_32K_CTRL, val8 & (~BIT(0))); /* Card disable power action flow */ - rtl88eu_pwrseqcmdparsing(Adapter, PWR_CUT_ALL_MSK, - Rtl8188E_NIC_DISABLE_FLOW); + rtl88eu_pwrseqcmdparsing(Adapter, Rtl8188E_NIC_DISABLE_FLOW); /* Reset MCU IO Wrapper */ val8 = usb_read8(Adapter, REG_RSV_CTRL + 1); diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h index 05f117e2a105..e364ee450beb 100644 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ b/drivers/staging/rtl8188eu/include/pwrseqcmd.h @@ -41,12 +41,10 @@ struct wl_pwr_cfg { }; #define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset -#define GET_PWR_CFG_CUT_MASK(__PWR_CMD) __PWR_CMD.cut_msk #define GET_PWR_CFG_CMD(__PWR_CMD) __PWR_CMD.cmd #define GET_PWR_CFG_MASK(__PWR_CMD) __PWR_CMD.msk #define GET_PWR_CFG_VALUE(__PWR_CMD) __PWR_CMD.value -u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, u8 cut_vers, - struct wl_pwr_cfg pwrcfgCmd[]); +u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, struct wl_pwr_cfg pwrcfgCmd[]); #endif -- cgit v1.2.3 From d950b477df6190d1cf2b5458b515fea84411d530 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:09 +0200 Subject: staging: rtl8188eu: remove PWR_CMD_READ None of the power flows and transitions includes a read command. PWR_CMD_READ can be removed. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-9-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 2 -- drivers/staging/rtl8188eu/include/pwrseqcmd.h | 1 - 2 files changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c index f2b973b377dd..cab774e31c60 100644 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c @@ -25,8 +25,6 @@ u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcm pwrcfgcmd = pwrseqcmd[aryidx]; switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { - case PWR_CMD_READ: - break; case PWR_CMD_WRITE: offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h index e364ee450beb..a5eb95fc58b9 100644 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ b/drivers/staging/rtl8188eu/include/pwrseqcmd.h @@ -10,7 +10,6 @@ #include /* The value of cmd: 4 bits */ -#define PWR_CMD_READ 0x00 #define PWR_CMD_WRITE 0x01 #define PWR_CMD_POLLING 0x02 #define PWR_CMD_DELAY 0x03 -- cgit v1.2.3 From 1126df74797609e12587e2bbcc7155f50f53af25 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 18 Jul 2021 19:36:10 +0200 Subject: staging: rtl8188eu: remove cut_mask field from wl_pwr_cfg We're no longer matching power transitions and commands against a power cut version mask. The cut_mask field from struct wl_pwr_cfg can be removed. It was set to PWR_CUT_ALL_MSK for all remaining commands. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210718173610.894-10-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/pwrseq.h | 56 +++++++++++++-------------- drivers/staging/rtl8188eu/include/pwrseqcmd.h | 1 - 2 files changed, 28 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/pwrseq.h b/drivers/staging/rtl8188eu/include/pwrseq.h index caa6bf71da77..5a7b4206d240 100644 --- a/drivers/staging/rtl8188eu/include/pwrseq.h +++ b/drivers/staging/rtl8188eu/include/pwrseq.h @@ -34,21 +34,21 @@ * }, * comment here */ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, BIT(1), BIT(1)}, \ + {0x0006, PWR_CMD_POLLING, BIT(1), BIT(1)}, \ /* wait till 0x04[17] = 1 power ready*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(0) | BIT(1), 0}, \ + {0x0002, PWR_CMD_WRITE, BIT(0) | BIT(1), 0}, \ /* 0x02[1:0] = 0 reset BB*/ \ - {0x0026, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ + {0x0026, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ /*0x24[23] = 2b'01 schmit trigger */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(7), 0}, \ + {0x0005, PWR_CMD_WRITE, BIT(7), 0}, \ /* 0x04[15] = 0 disable HWPDN (control by DRV)*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4) | BIT(3), 0}, \ + {0x0005, PWR_CMD_WRITE, BIT(4) | BIT(3), 0}, \ /*0x04[12:11] = 2b'00 disable WL suspend*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(0), BIT(0)}, \ + {0x0005, PWR_CMD_WRITE, BIT(0), BIT(0)}, \ /*0x04[8] = 1 polling until return 0*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, BIT(0), 0}, \ + {0x0005, PWR_CMD_POLLING, BIT(0), 0}, \ /*wait till 0x04[8] = 0*/ \ - {0x0023, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), 0}, \ + {0x0023, PWR_CMD_WRITE, BIT(4), 0}, \ /*LDO normal mode*/ #define RTL8188E_TRANS_ACT_TO_CARDEMU \ @@ -57,13 +57,13 @@ * }, * comments here */ \ - {0x001F, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0}, \ + {0x001F, PWR_CMD_WRITE, 0xFF, 0}, \ /*0x1F[7:0] = 0 turn off RF*/ \ - {0x0023, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ + {0x0023, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ /*LDO Sleep mode*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(1), BIT(1)}, \ + {0x0005, PWR_CMD_WRITE, BIT(1), BIT(1)}, \ /*0x04[9] = 1 turn off MAC by HW state machine*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, BIT(1), 0}, \ + {0x0005, PWR_CMD_POLLING, BIT(1), 0}, \ /*wait till 0x04[9] = 0 polling until return 0 to disable*/ #define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ @@ -72,15 +72,15 @@ * value }, * comments here */ \ - {0x0026, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ + {0x0026, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ /*0x24[23] = 2b'01 schmit trigger */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)}, \ + {0x0005, PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)}, \ /*0x04[12:11] = 2b'01 enable WL suspend*/ \ - {0x0007, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0}, \ + {0x0007, PWR_CMD_WRITE, 0xFF, 0}, \ /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */\ - {0x0041, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), 0}, \ + {0x0041, PWR_CMD_WRITE, BIT(4), 0}, \ /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ - {0xfe10, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ + {0xfe10, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ /*Set USB suspend enable local register 0xfe10[4]=1 */ /* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ @@ -90,24 +90,24 @@ * value }, * comments here */ \ - {0x0522, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/ \ - {0x05F8, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, 0xFF, 0}, \ + {0x0522, PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/ \ + {0x05F8, PWR_CMD_POLLING, 0xFF, 0}, \ /*Should be zero if no packet is transmitting*/ \ - {0x05F9, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, 0xFF, 0}, \ + {0x05F9, PWR_CMD_POLLING, 0xFF, 0}, \ /*Should be zero if no packet is transmitting*/ \ - {0x05FA, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, 0xFF, 0}, \ + {0x05FA, PWR_CMD_POLLING, 0xFF, 0}, \ /*Should be zero if no packet is transmitting*/ \ - {0x05FB, PWR_CUT_ALL_MSK, PWR_CMD_POLLING, 0xFF, 0}, \ + {0x05FB, PWR_CMD_POLLING, 0xFF, 0}, \ /*Should be zero if no packet is transmitting*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(0), 0}, \ + {0x0002, PWR_CMD_WRITE, BIT(0), 0}, \ /*CCK and OFDM are disabled,and clock are gated*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US}, \ + {0x0002, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US}, \ /*Delay 1us*/ \ - {0x0100, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, 0xFF, 0x3F}, \ + {0x0100, PWR_CMD_WRITE, 0xFF, 0x3F}, \ /*Reset MAC TRX*/ \ - {0x0101, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(1), 0}, \ + {0x0101, PWR_CMD_WRITE, BIT(1), 0}, \ /*check if removed later*/\ - {0x0553, PWR_CUT_ALL_MSK, PWR_CMD_WRITE, BIT(5), BIT(5)}, \ + {0x0553, PWR_CMD_WRITE, BIT(5), BIT(5)}, \ /*Respond TxOK to scheduler*/ #define RTL8188E_TRANS_END \ @@ -116,7 +116,7 @@ * value }, * comments here */ \ - {0xFFFF, PWR_CUT_ALL_MSK, PWR_CMD_END, 0, 0}, + {0xFFFF, PWR_CMD_END, 0, 0}, extern struct wl_pwr_cfg rtl8188E_power_on_flow [RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h index a5eb95fc58b9..bfa0405cccde 100644 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ b/drivers/staging/rtl8188eu/include/pwrseqcmd.h @@ -33,7 +33,6 @@ enum pwrseq_cmd_delat_unit { struct wl_pwr_cfg { u16 offset; - u8 cut_msk; u8 cmd:4; u8 msk; u8 value; -- cgit v1.2.3 From a0d38df6d043f6cfb8ab5f5cec8ae0090ac748e5 Mon Sep 17 00:00:00 2001 From: Nishal Kulkarni Date: Sat, 26 Jun 2021 17:00:21 +0530 Subject: staging: qlge: Remove unnecessary parentheses around references This patch fixes checkpatch.pl warning: CHECK: Unnecessary parentheses around mpi_coredump->mpi_global_header Signed-off-by: Nishal Kulkarni Link: https://lore.kernel.org/r/YNcPzWXkKkmip95x@nishal-pc Signed-off-by: Greg Kroah-Hartman --- drivers/staging/qlge/qlge_dbg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/qlge/qlge_dbg.c b/drivers/staging/qlge/qlge_dbg.c index 37e593f0fd82..66d28358342f 100644 --- a/drivers/staging/qlge/qlge_dbg.c +++ b/drivers/staging/qlge/qlge_dbg.c @@ -733,7 +733,7 @@ int qlge_core_dump(struct qlge_adapter *qdev, struct qlge_mpi_coredump *mpi_core } /* Insert the global header */ - memset(&(mpi_coredump->mpi_global_header), 0, + memset(&mpi_coredump->mpi_global_header, 0, sizeof(struct mpi_coredump_global_header)); mpi_coredump->mpi_global_header.cookie = MPI_COREDUMP_COOKIE; mpi_coredump->mpi_global_header.header_size = @@ -1221,7 +1221,7 @@ static void qlge_gen_reg_dump(struct qlge_adapter *qdev, { int i, status; - memset(&(mpi_coredump->mpi_global_header), 0, + memset(&mpi_coredump->mpi_global_header, 0, sizeof(struct mpi_coredump_global_header)); mpi_coredump->mpi_global_header.cookie = MPI_COREDUMP_COOKIE; mpi_coredump->mpi_global_header.header_size = -- cgit v1.2.3 From 1be059994b29df1344a9b105d64a41476470910d Mon Sep 17 00:00:00 2001 From: Jan Gruber Date: Mon, 5 Jul 2021 19:21:01 +0200 Subject: staging: rtl8188eu: remove unnecessary logging This commit fixes the following checkpatch.pl issues: + pr_debug("===> %s\n", __func__); WARNING: Unnecessary ftrace-like logging - prefer using ftrace 158: FILE: drivers/staging/rtl8188eu/os_dep/usb_intf.c:158: WARNING: Unnecessary ftrace-like logging - prefer using ftrace 177: FILE: drivers/staging/rtl8188eu/os_dep/usb_intf.c:177: + pr_debug("<=== %s\n", __func__); and removes another line of unnecessary logging, which was not identified by checkpatch.pl in an automated manner. Signed-off-by: Jan Gruber Link: https://lore.kernel.org/r/20210705172101.239899-1-j4n6ru@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/usb_intf.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c index f8519bfec020..1bf7b2c35c34 100644 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c @@ -155,7 +155,6 @@ void usb_intf_stop(struct adapter *padapter) static void rtw_dev_unload(struct adapter *padapter) { if (padapter->bup) { - pr_debug("===> %s\n", __func__); padapter->bDriverStopped = true; if (padapter->xmitpriv.ack_tx) rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP); @@ -173,8 +172,6 @@ static void rtw_dev_unload(struct adapter *padapter) padapter->bup = false; } - - pr_debug("<=== %s\n", __func__); } static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) @@ -454,8 +451,6 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); struct adapter *padapter = dvobj->if1; - pr_debug("+%s\n", __func__); - if (!pusb_intf->unregistering) padapter->bSurpriseRemoved = true; -- cgit v1.2.3 From 8266d91560867540088022428970974074de740a Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Mon, 5 Jul 2021 09:43:07 +0200 Subject: staging: rtl8712: Remove some unused #define and enum These #define and the enum WIFI_REG_DOMAIN are unused. They can be removed. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/6d5b505e7de20fdaba1831557baee1daf4656845.1625470822.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/wifi.h | 48 ------------------------------------------ 1 file changed, 48 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/wifi.h b/drivers/staging/rtl8712/wifi.h index 577a95c62d6c..b8acb9c7395d 100644 --- a/drivers/staging/rtl8712/wifi.h +++ b/drivers/staging/rtl8712/wifi.h @@ -20,26 +20,10 @@ #define WLAN_HDR_A3_LEN 24 #define WLAN_HDR_A3_QOS_LEN 26 -#define P80211CAPTURE_VERSION 0x80211001 - enum WIFI_FRAME_TYPE { WIFI_QOS_DATA_TYPE = (BIT(7) | BIT(3)), /*!< QoS Data */ }; -enum WIFI_REG_DOMAIN { - DOMAIN_FCC = 1, - DOMAIN_IC = 2, - DOMAIN_ETSI = 3, - DOMAIN_SPAIN = 4, - DOMAIN_FRANCE = 5, - DOMAIN_MKK = 6, - DOMAIN_ISRAEL = 7, - DOMAIN_MKK1 = 8, - DOMAIN_MKK2 = 9, - DOMAIN_MKK3 = 10, - DOMAIN_MAX -}; - #define SetToDs(pbuf) ({ \ *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS); \ }) @@ -194,46 +178,14 @@ static inline unsigned char *get_hdr_bssid(unsigned char *pframe) return sa; } -/*----------------------------------------------------------------------------- - * Below is for the security related definition - *----------------------------------------------------------------------------- - */ -#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ -#define _ASOCRSP_IE_OFFSET_ 6 -#define _REASOCREQ_IE_OFFSET_ 10 -#define _REASOCRSP_IE_OFFSET_ 6 -#define _PROBEREQ_IE_OFFSET_ 0 -#define _PROBERSP_IE_OFFSET_ 12 -#define _AUTH_IE_OFFSET_ 6 -#define _DEAUTH_IE_OFFSET_ 0 -#define _BEACON_IE_OFFSET_ 12 - -#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ - /* --------------------------------------------------------------------------- * Below is the fixed elements... * --------------------------------------------------------------------------- */ -#define _AUTH_ALGM_NUM_ 2 -#define _AUTH_SEQ_NUM_ 2 #define _BEACON_ITERVAL_ 2 #define _CAPABILITY_ 2 -#define _CURRENT_APADDR_ 6 -#define _LISTEN_INTERVAL_ 2 -#define _RSON_CODE_ 2 -#define _ASOC_ID_ 2 -#define _STATUS_CODE_ 2 #define _TIMESTAMP_ 8 -#define AUTH_ODD_TO 0 -#define AUTH_EVEN_TO 1 - -/*----------------------------------------------------------------------------- - * Below is the definition for 802.11i / 802.1x - *------------------------------------------------------------------------------ - */ -#define _IEEE8021X_MGT_ 1 /*WPA */ -#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ /*----------------------------------------------------------------------------- * Below is the definition for WMM -- cgit v1.2.3 From 39630204a96aebdb29634b5f4aea6518e2b97eca Mon Sep 17 00:00:00 2001 From: Alexander Greyling Date: Sun, 11 Jul 2021 00:08:15 +0200 Subject: staging: rtl8712: Fix alignment This patch fixes the checkpatch.pl issue: CHECK: Alignment should match open parenthesis. Signed-off-by: Alexander Greyling Link: https://lore.kernel.org/r/20210710220815.GA1654486@alexlaptop Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/osdep_service.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/osdep_service.h b/drivers/staging/rtl8712/osdep_service.h index e939c4a954b3..d33ddffb7ad9 100644 --- a/drivers/staging/rtl8712/osdep_service.h +++ b/drivers/staging/rtl8712/osdep_service.h @@ -46,7 +46,7 @@ struct __queue { } while (0) static inline u32 end_of_queue_search(struct list_head *head, - struct list_head *plist) + struct list_head *plist) { return (head == plist); } -- cgit v1.2.3 From d2c57736c430a3fa2c5de2146642eb41f8fe6ca7 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sat, 17 Jul 2021 17:51:45 +0200 Subject: staging/rtl8712: Remove all strcpy() uses in favor of strscpy() strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210717155145.15041-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/os_intfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/os_intfs.c b/drivers/staging/rtl8712/os_intfs.c index 2214aca09730..9502f6aa5306 100644 --- a/drivers/staging/rtl8712/os_intfs.c +++ b/drivers/staging/rtl8712/os_intfs.c @@ -203,7 +203,7 @@ struct net_device *r8712_init_netdev(void) if (!pnetdev) return NULL; if (dev_alloc_name(pnetdev, ifname) < 0) { - strcpy(ifname, "wlan%d"); + strscpy(ifname, "wlan%d", sizeof(ifname)); dev_alloc_name(pnetdev, ifname); } padapter = netdev_priv(pnetdev); -- cgit v1.2.3 From df00609821bf17f50a75a446266d19adb8339d84 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Wed, 14 Jul 2021 12:13:46 +0200 Subject: staging: board: Fix uninitialized spinlock when attaching genpd On Armadillo-800-EVA with CONFIG_DEBUG_SPINLOCK=y: BUG: spinlock bad magic on CPU#0, swapper/1 lock: lcdc0_device+0x10c/0x308, .magic: 00000000, .owner: /-1, .owner_cpu: 0 CPU: 0 PID: 1 Comm: swapper Not tainted 5.11.0-rc5-armadillo-00036-gbbca04be7a80-dirty #287 Hardware name: Generic R8A7740 (Flattened Device Tree) [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [] (show_stack) from [] (do_raw_spin_lock+0x20/0x94) [] (do_raw_spin_lock) from [] (dev_pm_get_subsys_data+0x8c/0x11c) [] (dev_pm_get_subsys_data) from [] (genpd_add_device+0x78/0x2b8) [] (genpd_add_device) from [] (of_genpd_add_device+0x34/0x4c) [] (of_genpd_add_device) from [] (board_staging_register_device+0x11c/0x148) [] (board_staging_register_device) from [] (board_staging_register_devices+0x24/0x28) of_genpd_add_device() is called before platform_device_register(), as it needs to attach the genpd before the device is probed. But the spinlock is only initialized when the device is registered. Fix this by open-coding the spinlock initialization, cfr. device_pm_init_common() in the internal drivers/base code, and in the SuperH early platform code. Signed-off-by: Geert Uytterhoeven Link: https://lore.kernel.org/r/57783ece7ddae55f2bda2f59f452180bff744ea0.1626257398.git.geert+renesas@glider.be Signed-off-by: Greg Kroah-Hartman --- drivers/staging/board/board.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/board/board.c b/drivers/staging/board/board.c index cb6feb34dd40..f980af037345 100644 --- a/drivers/staging/board/board.c +++ b/drivers/staging/board/board.c @@ -136,6 +136,7 @@ int __init board_staging_register_clock(const struct board_staging_clk *bsc) static int board_staging_add_dev_domain(struct platform_device *pdev, const char *domain) { + struct device *dev = &pdev->dev; struct of_phandle_args pd_args; struct device_node *np; @@ -148,7 +149,11 @@ static int board_staging_add_dev_domain(struct platform_device *pdev, pd_args.np = np; pd_args.args_count = 0; - return of_genpd_add_device(&pd_args, &pdev->dev); + /* Initialization similar to device_pm_init_common() */ + spin_lock_init(&dev->power.lock); + dev->power.early_init = true; + + return of_genpd_add_device(&pd_args, dev); } #else static inline int board_staging_add_dev_domain(struct platform_device *pdev, -- cgit v1.2.3 From 571e5894a06dabce193dcee2ad023bd58160838b Mon Sep 17 00:00:00 2001 From: Diego Roux Date: Thu, 15 Jul 2021 21:49:00 -0500 Subject: staging: bcm2835-audio: Enclose complex macro value in parentheses This patch fixes the checkpatch.pl error: ERROR: Macros with complex values should be enclosed in parentheses Signed-off-by: Diego Roux Link: https://lore.kernel.org/r/20210716024909.39411-1-me@diegoroux04.dynv6.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-audio/bcm2835.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h index 1b36475872d6..51066ac8eea5 100644 --- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h +++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.h @@ -22,7 +22,7 @@ enum { /* macros for alsa2chip and chip2alsa, instead of functions */ // convert alsa to chip volume (defined as macro rather than function call) -#define alsa2chip(vol) (uint)(-(((vol) << 8) / 100)) +#define alsa2chip(vol) ((uint)(-(((vol) << 8) / 100))) // convert chip to alsa volume #define chip2alsa(vol) -(((vol) * 100) >> 8) -- cgit v1.2.3 From b82d45a9a6de363dd80704c9a6d9f5313e6099ab Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 17 Jul 2021 11:58:12 +0200 Subject: staging: hi6421-spmi-pmic: rename spmi_device struct Let's not call a pointer to spmi_device as pdev, as it is something else. Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/758e98d7f59d739b68b33723a02aca8b9464f8da.1626515862.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index 35ef3d4c760b..dd7ff63214d3 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -213,9 +213,9 @@ static const struct regmap_config regmap_config = { .fast_io = true }; -static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) +static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) { - struct device *dev = &pdev->dev; + struct device *dev = &sdev->dev; struct device_node *np = dev->of_node; struct hi6421_spmi_pmic *ddata; unsigned int virq; @@ -225,7 +225,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) if (!ddata) return -ENOMEM; - ddata->regmap = devm_regmap_init_spmi_ext(pdev, ®map_config); + ddata->regmap = devm_regmap_init_spmi_ext(sdev, ®map_config); if (IS_ERR(ddata->regmap)) return PTR_ERR(ddata->regmap); @@ -281,9 +281,9 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *pdev) return ret; } - dev_set_drvdata(&pdev->dev, ddata); + dev_set_drvdata(&sdev->dev, ddata); - ret = devm_mfd_add_devices(&pdev->dev, PLATFORM_DEVID_NONE, + ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE, hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs), NULL, 0, NULL); if (ret < 0) -- cgit v1.2.3 From f81d992182570d56db642344fa89a7e1777dbc80 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 17 Jul 2021 11:58:13 +0200 Subject: staging: hi6421-spmi-pmic: rename GPIO IRQ OF node Instead of using the standard name ("gpios"), use "interrupts". Suggested-by: Rob Herring Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/8b2cad1e9b9904c6a2aaea8786d5e5a39f09ac19.1626515862.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 18 ++++++------------ .../staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 8 +++----- include/linux/mfd/hi6421-spmi-pmic.h | 1 - 3 files changed, 9 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index dd7ff63214d3..61cbd2e62f68 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -218,6 +218,7 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) struct device *dev = &sdev->dev; struct device_node *np = dev->of_node; struct hi6421_spmi_pmic *ddata; + struct platform_device *pdev; unsigned int virq; int ret, i; @@ -233,21 +234,14 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) ddata->dev = dev; - ddata->gpio = of_get_gpio(np, 0); - if (ddata->gpio < 0) - return ddata->gpio; + pdev = container_of(dev, struct platform_device, dev); - if (!gpio_is_valid(ddata->gpio)) - return -EINVAL; - - ret = devm_gpio_request_one(dev, ddata->gpio, GPIOF_IN, "pmic"); - if (ret < 0) { - dev_err(dev, "Failed to request gpio%d\n", ddata->gpio); - return ret; + ddata->irq = platform_get_irq(pdev, 0); + if (ddata->irq < 0) { + dev_err(dev, "Error %d when getting IRQs\n", ddata->irq); + return ddata->irq; } - ddata->irq = gpio_to_irq(ddata->gpio); - hi6421_spmi_pmic_irq_init(ddata); ddata->irqs = devm_kzalloc(dev, PMIC_IRQ_LIST_MAX * sizeof(int), GFP_KERNEL); diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index 8e355cddd437..5a3b1cbfd639 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -34,9 +34,7 @@ properties: interrupt-controller: true - gpios: - maxItems: 1 - description: GPIO used for IRQs + interrupts: true regulators: type: object @@ -63,7 +61,6 @@ additionalProperties: false examples: - | - /* pmic properties */ pmic: pmic@0 { compatible = "hisilicon,hi6421-spmi"; @@ -71,7 +68,8 @@ examples: #interrupt-cells = <2>; interrupt-controller; - gpios = <&gpio28 0 0>; + interrupt-parent = <&gpio28>; + interrupts = <0 0>; regulators { #address-cells = <1>; diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h index 2660226138b8..254430c897d6 100644 --- a/include/linux/mfd/hi6421-spmi-pmic.h +++ b/include/linux/mfd/hi6421-spmi-pmic.h @@ -22,7 +22,6 @@ struct hi6421_spmi_pmic { spinlock_t lock; struct irq_domain *domain; int irq; - int gpio; unsigned int *irqs; struct regmap *regmap; }; -- cgit v1.2.3 From 49bd5091a81218cb196be4ccd9db4360412450fa Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 17 Jul 2021 11:58:14 +0200 Subject: staging: hi6421-spmi-pmic: add a missing dot at copyright The Huawei's copyright is missing a dot at the end. Add it, in order to make it similar to the other two copyrights. Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/8e280ebe4e577e6c2d919346868f0d27f98ebd49.1626515862.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index 61cbd2e62f68..0ffd8b7fecf5 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -4,7 +4,7 @@ * * Copyright (c) 2013 Linaro Ltd. * Copyright (c) 2011 Hisilicon. - * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd + * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd. */ #include -- cgit v1.2.3 From bb3b6552a5b0679b55c43d49621597e54668f089 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 17 Jul 2021 11:58:15 +0200 Subject: staging: hikey9xx: split hi6421v600 irq into a separate driver Per MFD subsystem requirements, split the IRQ part of the driver into a separate one with just the IRQ handling code and the powerkey support. Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/709e01c9ffafe6cd0ecb23336b44f9bcde2b5bc2.1626515862.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/misc/Kconfig | 10 + drivers/misc/Makefile | 1 + drivers/misc/hi6421v600-irq.c | 307 +++++++++++++++++++++ drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 239 +--------------- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 2 +- include/linux/mfd/hi6421-spmi-pmic.h | 4 - 6 files changed, 322 insertions(+), 241 deletions(-) create mode 100644 drivers/misc/hi6421v600-irq.c (limited to 'drivers/staging') diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index f4fb5c52b863..29294c52d5af 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -208,6 +208,16 @@ config CS5535_CLOCK_EVENT_SRC MFGPTs have a better resolution and max interval than the generic PIT, and are suitable for use as high-res timers. +config HI6421V600_IRQ + tristate "HiSilicon Hi6421v600 IRQ and powerkey" + depends on OF + depends on SPMI + select MFD_CORE + select REGMAP_SPMI + help + This driver provides IRQ handling for Hi6421v600, used on + some Kirin chipsets, like the one at Hikey 970. + config HP_ILO tristate "Channel interface driver for the HP iLO processor" depends on PCI diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index e92a56d4442f..f91cab8c3d55 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -57,3 +57,4 @@ obj-$(CONFIG_HABANA_AI) += habanalabs/ obj-$(CONFIG_UACCE) += uacce/ obj-$(CONFIG_XILINX_SDFEC) += xilinx_sdfec.o obj-$(CONFIG_HISI_HIKEY_USB) += hisi_hikey_usb.o +obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o diff --git a/drivers/misc/hi6421v600-irq.c b/drivers/misc/hi6421v600-irq.c new file mode 100644 index 000000000000..08535e97ff43 --- /dev/null +++ b/drivers/misc/hi6421v600-irq.c @@ -0,0 +1,307 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device driver for irqs in HISI PMIC IC + * + * Copyright (c) 2013 Linaro Ltd. + * Copyright (c) 2011 Hisilicon. + * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +struct hi6421v600_irq { + struct device *dev; + struct irq_domain *domain; + int irq; + unsigned int *irqs; + struct regmap *regmap; + + /* Protect IRQ mask changes */ + spinlock_t lock; +}; + +enum hi6421v600_irq_list { + OTMP = 0, + VBUS_CONNECT, + VBUS_DISCONNECT, + ALARMON_R, + HOLD_6S, + HOLD_1S, + POWERKEY_UP, + POWERKEY_DOWN, + OCP_SCP_R, + COUL_R, + SIM0_HPD_R, + SIM0_HPD_F, + SIM1_HPD_R, + SIM1_HPD_F, + + PMIC_IRQ_LIST_MAX +}; + +#define HISI_IRQ_BANK_SIZE 2 + +/* + * IRQ number for the power key button and mask for both UP and DOWN IRQs + */ +#define HISI_POWERKEY_IRQ_NUM 0 +#define HISI_IRQ_POWERKEY_UP_DOWN (BIT(POWERKEY_DOWN) | BIT(POWERKEY_UP)) + +/* + * Registers for IRQ address and IRQ mask bits + * + * Please notice that we need to regmap a larger region, as other + * registers are used by the irqs. + * See drivers/irq/hi6421-irq.c. + */ +#define SOC_PMIC_IRQ_MASK_0_ADDR 0x0202 +#define SOC_PMIC_IRQ0_ADDR 0x0212 + +/* + * The IRQs are mapped as: + * + * ====================== ============= ============ ===== + * IRQ MASK REGISTER IRQ REGISTER BIT + * ====================== ============= ============ ===== + * OTMP 0x0202 0x212 bit 0 + * VBUS_CONNECT 0x0202 0x212 bit 1 + * VBUS_DISCONNECT 0x0202 0x212 bit 2 + * ALARMON_R 0x0202 0x212 bit 3 + * HOLD_6S 0x0202 0x212 bit 4 + * HOLD_1S 0x0202 0x212 bit 5 + * POWERKEY_UP 0x0202 0x212 bit 6 + * POWERKEY_DOWN 0x0202 0x212 bit 7 + * + * OCP_SCP_R 0x0203 0x213 bit 0 + * COUL_R 0x0203 0x213 bit 1 + * SIM0_HPD_R 0x0203 0x213 bit 2 + * SIM0_HPD_F 0x0203 0x213 bit 3 + * SIM1_HPD_R 0x0203 0x213 bit 4 + * SIM1_HPD_F 0x0203 0x213 bit 5 + * ====================== ============= ============ ===== + * + * Each mask register contains 8 bits. The ancillary macros below + * convert a number from 0 to 14 into a register address and a bit mask + */ +#define HISI_IRQ_MASK_REG(irq_data) (SOC_PMIC_IRQ_MASK_0_ADDR + \ + (irqd_to_hwirq(irq_data) / BITS_PER_BYTE)) +#define HISI_IRQ_MASK_BIT(irq_data) BIT(irqd_to_hwirq(irq_data) & (BITS_PER_BYTE - 1)) +#define HISI_8BITS_MASK 0xff + +static irqreturn_t hi6421v600_irq_handler(int irq, void *__priv) +{ + struct hi6421v600_irq *priv = __priv; + unsigned long pending; + unsigned int in; + int i, offset; + + for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) { + regmap_read(priv->regmap, SOC_PMIC_IRQ0_ADDR + i, &in); + + /* Mark pending IRQs as handled */ + regmap_write(priv->regmap, SOC_PMIC_IRQ0_ADDR + i, in); + + pending = in & HISI_8BITS_MASK; + + if (i == HISI_POWERKEY_IRQ_NUM && + (pending & HISI_IRQ_POWERKEY_UP_DOWN) == HISI_IRQ_POWERKEY_UP_DOWN) { + /* + * If both powerkey down and up IRQs are received, + * handle them at the right order + */ + generic_handle_irq(priv->irqs[POWERKEY_DOWN]); + generic_handle_irq(priv->irqs[POWERKEY_UP]); + pending &= ~HISI_IRQ_POWERKEY_UP_DOWN; + } + + if (!pending) + continue; + + for_each_set_bit(offset, &pending, BITS_PER_BYTE) { + generic_handle_irq(priv->irqs[offset + i * BITS_PER_BYTE]); + } + } + + return IRQ_HANDLED; +} + +static void hi6421v600_irq_mask(struct irq_data *d) +{ + struct hi6421v600_irq *priv = irq_data_get_irq_chip_data(d); + unsigned long flags; + unsigned int data; + u32 offset; + + offset = HISI_IRQ_MASK_REG(d); + + spin_lock_irqsave(&priv->lock, flags); + + regmap_read(priv->regmap, offset, &data); + data |= HISI_IRQ_MASK_BIT(d); + regmap_write(priv->regmap, offset, data); + + spin_unlock_irqrestore(&priv->lock, flags); +} + +static void hi6421v600_irq_unmask(struct irq_data *d) +{ + struct hi6421v600_irq *priv = irq_data_get_irq_chip_data(d); + u32 data, offset; + unsigned long flags; + + offset = HISI_IRQ_MASK_REG(d); + + spin_lock_irqsave(&priv->lock, flags); + + regmap_read(priv->regmap, offset, &data); + data &= ~HISI_IRQ_MASK_BIT(d); + regmap_write(priv->regmap, offset, data); + + spin_unlock_irqrestore(&priv->lock, flags); +} + +static struct irq_chip hi6421v600_pmu_irqchip = { + .name = "hi6421v600-irq", + .irq_mask = hi6421v600_irq_mask, + .irq_unmask = hi6421v600_irq_unmask, + .irq_disable = hi6421v600_irq_mask, + .irq_enable = hi6421v600_irq_unmask, +}; + +static int hi6421v600_irq_map(struct irq_domain *d, unsigned int virq, + irq_hw_number_t hw) +{ + struct hi6421v600_irq *priv = d->host_data; + + irq_set_chip_and_handler_name(virq, &hi6421v600_pmu_irqchip, + handle_simple_irq, "hi6421v600"); + irq_set_chip_data(virq, priv); + irq_set_irq_type(virq, IRQ_TYPE_NONE); + + return 0; +} + +static const struct irq_domain_ops hi6421v600_domain_ops = { + .map = hi6421v600_irq_map, + .xlate = irq_domain_xlate_twocell, +}; + +static void hi6421v600_irq_init(struct hi6421v600_irq *priv) +{ + int i; + unsigned int pending; + + /* Mask all IRQs */ + for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) + regmap_write(priv->regmap, SOC_PMIC_IRQ_MASK_0_ADDR + i, + HISI_8BITS_MASK); + + /* Mark all IRQs as handled */ + for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) { + regmap_read(priv->regmap, SOC_PMIC_IRQ0_ADDR + i, &pending); + regmap_write(priv->regmap, SOC_PMIC_IRQ0_ADDR + i, + HISI_8BITS_MASK); + } +} + +static int hi6421v600_irq_probe(struct platform_device *pdev) +{ + struct device *pmic_dev = pdev->dev.parent; + struct device_node *np = pmic_dev->of_node; + struct platform_device *pmic_pdev; + struct device *dev = &pdev->dev; + struct hi6421v600_irq *priv; + struct hi6421_spmi_pmic *pmic; + unsigned int virq; + int i, ret; + + /* + * This driver is meant to be called by hi6421-spmi-core, + * which should first set drvdata. If this doesn't happen, hit + * a warn on and return. + */ + pmic = dev_get_drvdata(pmic_dev); + if (WARN_ON(!pmic)) + return -ENODEV; + + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv->dev = dev; + priv->regmap = pmic->regmap; + + spin_lock_init(&priv->lock); + + pmic_pdev = container_of(pmic_dev, struct platform_device, dev); + + priv->irq = platform_get_irq(pmic_pdev, 0); + if (priv->irq < 0) { + dev_err(dev, "Error %d when getting IRQs\n", priv->irq); + return priv->irq; + } + + platform_set_drvdata(pdev, priv); + + hi6421v600_irq_init(priv); + + priv->irqs = devm_kzalloc(dev, PMIC_IRQ_LIST_MAX * sizeof(int), GFP_KERNEL); + if (!priv->irqs) + return -ENOMEM; + + priv->domain = irq_domain_add_simple(np, PMIC_IRQ_LIST_MAX, 0, + &hi6421v600_domain_ops, priv); + if (!priv->domain) { + dev_err(dev, "Failed to create IRQ domain\n"); + return -ENODEV; + } + + for (i = 0; i < PMIC_IRQ_LIST_MAX; i++) { + virq = irq_create_mapping(priv->domain, i); + if (!virq) { + dev_err(dev, "Failed to map H/W IRQ\n"); + return -ENODEV; + } + priv->irqs[i] = virq; + } + + ret = devm_request_threaded_irq(dev, + priv->irq, hi6421v600_irq_handler, + NULL, + IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND, + "pmic", priv); + if (ret < 0) { + dev_err(dev, "Failed to start IRQ handling thread: error %d\n", + ret); + return ret; + } + + return 0; +} + +static const struct platform_device_id hi6421v600_irq_table[] = { + { .name = "hi6421v600-irq" }, + {}, +}; +MODULE_DEVICE_TABLE(platform, hi6421v600_irq_table); + +static struct platform_driver hi6421v600_irq_driver = { + .id_table = hi6421v600_irq_table, + .driver = { + .name = "hi6421v600-irq", + }, + .probe = hi6421v600_irq_probe, +}; +module_platform_driver(hi6421v600_irq_driver); + +MODULE_DESCRIPTION("HiSilicon Hi6421v600 IRQ driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c index 0ffd8b7fecf5..4f136826681b 100644 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c @@ -7,205 +7,19 @@ * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd. */ -#include -#include -#include #include #include #include -#include #include +#include #include #include -enum hi6421_spmi_pmic_irq_list { - OTMP = 0, - VBUS_CONNECT, - VBUS_DISCONNECT, - ALARMON_R, - HOLD_6S, - HOLD_1S, - POWERKEY_UP, - POWERKEY_DOWN, - OCP_SCP_R, - COUL_R, - SIM0_HPD_R, - SIM0_HPD_F, - SIM1_HPD_R, - SIM1_HPD_F, - - PMIC_IRQ_LIST_MAX -}; - -#define HISI_IRQ_BANK_SIZE 2 - -/* - * IRQ number for the power key button and mask for both UP and DOWN IRQs - */ -#define HISI_POWERKEY_IRQ_NUM 0 -#define HISI_IRQ_POWERKEY_UP_DOWN (BIT(POWERKEY_DOWN) | BIT(POWERKEY_UP)) - -/* - * Registers for IRQ address and IRQ mask bits - * - * Please notice that we need to regmap a larger region, as other - * registers are used by the regulators. - * See drivers/regulator/hi6421-regulator.c. - */ -#define SOC_PMIC_IRQ_MASK_0_ADDR 0x0202 -#define SOC_PMIC_IRQ0_ADDR 0x0212 - -/* - * The IRQs are mapped as: - * - * ====================== ============= ============ ===== - * IRQ MASK REGISTER IRQ REGISTER BIT - * ====================== ============= ============ ===== - * OTMP 0x0202 0x212 bit 0 - * VBUS_CONNECT 0x0202 0x212 bit 1 - * VBUS_DISCONNECT 0x0202 0x212 bit 2 - * ALARMON_R 0x0202 0x212 bit 3 - * HOLD_6S 0x0202 0x212 bit 4 - * HOLD_1S 0x0202 0x212 bit 5 - * POWERKEY_UP 0x0202 0x212 bit 6 - * POWERKEY_DOWN 0x0202 0x212 bit 7 - * - * OCP_SCP_R 0x0203 0x213 bit 0 - * COUL_R 0x0203 0x213 bit 1 - * SIM0_HPD_R 0x0203 0x213 bit 2 - * SIM0_HPD_F 0x0203 0x213 bit 3 - * SIM1_HPD_R 0x0203 0x213 bit 4 - * SIM1_HPD_F 0x0203 0x213 bit 5 - * ====================== ============= ============ ===== - * - * Each mask register contains 8 bits. The ancillary macros below - * convert a number from 0 to 14 into a register address and a bit mask - */ -#define HISI_IRQ_MASK_REG(irq_data) (SOC_PMIC_IRQ_MASK_0_ADDR + \ - (irqd_to_hwirq(irq_data) / BITS_PER_BYTE)) -#define HISI_IRQ_MASK_BIT(irq_data) BIT(irqd_to_hwirq(irq_data) & (BITS_PER_BYTE - 1)) -#define HISI_8BITS_MASK 0xff - static const struct mfd_cell hi6421v600_devs[] = { + { .name = "hi6421v600-irq", }, { .name = "hi6421v600-regulator", }, }; -static irqreturn_t hi6421_spmi_irq_handler(int irq, void *priv) -{ - struct hi6421_spmi_pmic *ddata = (struct hi6421_spmi_pmic *)priv; - unsigned long pending; - unsigned int in; - int i, offset; - - for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) { - regmap_read(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i, &in); - - /* Mark pending IRQs as handled */ - regmap_write(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i, in); - - pending = in & HISI_8BITS_MASK; - - if (i == HISI_POWERKEY_IRQ_NUM && - (pending & HISI_IRQ_POWERKEY_UP_DOWN) == HISI_IRQ_POWERKEY_UP_DOWN) { - /* - * If both powerkey down and up IRQs are received, - * handle them at the right order - */ - generic_handle_irq(ddata->irqs[POWERKEY_DOWN]); - generic_handle_irq(ddata->irqs[POWERKEY_UP]); - pending &= ~HISI_IRQ_POWERKEY_UP_DOWN; - } - - if (!pending) - continue; - - for_each_set_bit(offset, &pending, BITS_PER_BYTE) { - generic_handle_irq(ddata->irqs[offset + i * BITS_PER_BYTE]); - } - } - - return IRQ_HANDLED; -} - -static void hi6421_spmi_irq_mask(struct irq_data *d) -{ - struct hi6421_spmi_pmic *ddata = irq_data_get_irq_chip_data(d); - unsigned long flags; - unsigned int data; - u32 offset; - - offset = HISI_IRQ_MASK_REG(d); - - spin_lock_irqsave(&ddata->lock, flags); - - regmap_read(ddata->regmap, offset, &data); - data |= HISI_IRQ_MASK_BIT(d); - regmap_write(ddata->regmap, offset, data); - - spin_unlock_irqrestore(&ddata->lock, flags); -} - -static void hi6421_spmi_irq_unmask(struct irq_data *d) -{ - struct hi6421_spmi_pmic *ddata = irq_data_get_irq_chip_data(d); - u32 data, offset; - unsigned long flags; - - offset = HISI_IRQ_MASK_REG(d); - - spin_lock_irqsave(&ddata->lock, flags); - - regmap_read(ddata->regmap, offset, &data); - data &= ~HISI_IRQ_MASK_BIT(d); - regmap_write(ddata->regmap, offset, data); - - spin_unlock_irqrestore(&ddata->lock, flags); -} - -static struct irq_chip hi6421_spmi_pmu_irqchip = { - .name = "hi6421v600-irq", - .irq_mask = hi6421_spmi_irq_mask, - .irq_unmask = hi6421_spmi_irq_unmask, - .irq_disable = hi6421_spmi_irq_mask, - .irq_enable = hi6421_spmi_irq_unmask, -}; - -static int hi6421_spmi_irq_map(struct irq_domain *d, unsigned int virq, - irq_hw_number_t hw) -{ - struct hi6421_spmi_pmic *ddata = d->host_data; - - irq_set_chip_and_handler_name(virq, &hi6421_spmi_pmu_irqchip, - handle_simple_irq, "hi6421v600"); - irq_set_chip_data(virq, ddata); - irq_set_irq_type(virq, IRQ_TYPE_NONE); - - return 0; -} - -static const struct irq_domain_ops hi6421_spmi_domain_ops = { - .map = hi6421_spmi_irq_map, - .xlate = irq_domain_xlate_twocell, -}; - -static void hi6421_spmi_pmic_irq_init(struct hi6421_spmi_pmic *ddata) -{ - int i; - unsigned int pending; - - /* Mask all IRQs */ - for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) - regmap_write(ddata->regmap, SOC_PMIC_IRQ_MASK_0_ADDR + i, - HISI_8BITS_MASK); - - /* Mark all IRQs as handled */ - for (i = 0; i < HISI_IRQ_BANK_SIZE; i++) { - regmap_read(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i, &pending); - regmap_write(ddata->regmap, SOC_PMIC_IRQ0_ADDR + i, - HISI_8BITS_MASK); - } -} - static const struct regmap_config regmap_config = { .reg_bits = 16, .val_bits = BITS_PER_BYTE, @@ -216,12 +30,8 @@ static const struct regmap_config regmap_config = { static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) { struct device *dev = &sdev->dev; - struct device_node *np = dev->of_node; + int ret; struct hi6421_spmi_pmic *ddata; - struct platform_device *pdev; - unsigned int virq; - int ret, i; - ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); if (!ddata) return -ENOMEM; @@ -230,51 +40,8 @@ static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) if (IS_ERR(ddata->regmap)) return PTR_ERR(ddata->regmap); - spin_lock_init(&ddata->lock); - ddata->dev = dev; - pdev = container_of(dev, struct platform_device, dev); - - ddata->irq = platform_get_irq(pdev, 0); - if (ddata->irq < 0) { - dev_err(dev, "Error %d when getting IRQs\n", ddata->irq); - return ddata->irq; - } - - hi6421_spmi_pmic_irq_init(ddata); - - ddata->irqs = devm_kzalloc(dev, PMIC_IRQ_LIST_MAX * sizeof(int), GFP_KERNEL); - if (!ddata->irqs) - return -ENOMEM; - - ddata->domain = irq_domain_add_simple(np, PMIC_IRQ_LIST_MAX, 0, - &hi6421_spmi_domain_ops, ddata); - if (!ddata->domain) { - dev_err(dev, "Failed to create IRQ domain\n"); - return -ENODEV; - } - - for (i = 0; i < PMIC_IRQ_LIST_MAX; i++) { - virq = irq_create_mapping(ddata->domain, i); - if (!virq) { - dev_err(dev, "Failed to map H/W IRQ\n"); - return -ENODEV; - } - ddata->irqs[i] = virq; - } - - ret = devm_request_threaded_irq(dev, - ddata->irq, hi6421_spmi_irq_handler, - NULL, - IRQF_TRIGGER_LOW | IRQF_SHARED | IRQF_NO_SUSPEND, - "pmic", ddata); - if (ret < 0) { - dev_err(dev, "Failed to start IRQ handling thread: error %d\n", - ret); - return ret; - } - dev_set_drvdata(&sdev->dev, ddata); ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE, diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index 5a3b1cbfd639..63f49080001d 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -63,7 +63,7 @@ examples: - | pmic: pmic@0 { - compatible = "hisilicon,hi6421-spmi"; + compatible = "hisilicon,hi6421v600-spmi"; reg = <0 0>; #interrupt-cells = <2>; diff --git a/include/linux/mfd/hi6421-spmi-pmic.h b/include/linux/mfd/hi6421-spmi-pmic.h index 254430c897d6..e5b8dbf828b6 100644 --- a/include/linux/mfd/hi6421-spmi-pmic.h +++ b/include/linux/mfd/hi6421-spmi-pmic.h @@ -19,10 +19,6 @@ struct hi6421_spmi_pmic { struct resource *res; struct device *dev; void __iomem *regs; - spinlock_t lock; - struct irq_domain *domain; - int irq; - unsigned int *irqs; struct regmap *regmap; }; -- cgit v1.2.3 From 334201d503d5903f38f6e804263fc291ce8f451a Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Sat, 17 Jul 2021 11:58:17 +0200 Subject: staging: hisilicon,hi6421-spmi-pmic.yaml: fix patternProperties The regex at the patternProperties is wrong, although this was not reported as the DT schema was not enforcing properties. Fix it. Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/46b2f30df235481cb1404913380e45706dfd8253.1626515862.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml index 63f49080001d..cedf9d99a34b 100644 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml @@ -39,6 +39,8 @@ properties: regulators: type: object + additionalProperties: false + properties: '#address-cells': const: 1 @@ -47,11 +49,13 @@ properties: const: 0 patternProperties: - '^ldo[0-9]+@[0-9a-f]$': + '^(ldo|LDO)[0-9]+$': type: object $ref: "/schemas/regulator/regulator.yaml#" + unevaluatedProperties: false + required: - compatible - reg -- cgit v1.2.3 From 9bd9e0de1cf5b89c4854be505ac0a418ddcc01bf Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 23 Jul 2021 09:40:06 +0200 Subject: mfd: hi6421-spmi-pmic: move driver from staging This driver is ready for mainstream. So, move it out of staging. Acked-by: Lee Jones Signed-off-by: Mauro Carvalho Chehab Link: https://lore.kernel.org/r/dd150f3ffa19c2dda0171f7dbe1dd63cce2a7af5.1627025657.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman --- .../bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml | 136 +++++++++++++++++++++ MAINTAINERS | 7 ++ drivers/mfd/Kconfig | 16 +++ drivers/mfd/Makefile | 1 + drivers/mfd/hi6421-spmi-pmic.c | 72 +++++++++++ drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/hikey9xx/Kconfig | 19 --- drivers/staging/hikey9xx/Makefile | 3 - drivers/staging/hikey9xx/TODO | 5 - drivers/staging/hikey9xx/hi6421-spmi-pmic.c | 72 ----------- .../hikey9xx/hisilicon,hi6421-spmi-pmic.yaml | 136 --------------------- 12 files changed, 232 insertions(+), 238 deletions(-) create mode 100644 Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml create mode 100644 drivers/mfd/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/Kconfig delete mode 100644 drivers/staging/hikey9xx/Makefile delete mode 100644 drivers/staging/hikey9xx/TODO delete mode 100644 drivers/staging/hikey9xx/hi6421-spmi-pmic.c delete mode 100644 drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml (limited to 'drivers/staging') diff --git a/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml new file mode 100644 index 000000000000..cedf9d99a34b --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml @@ -0,0 +1,136 @@ +# SPDX-License-Identifier: GPL-2.0 +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/hisilicon,hi6421-spmi-pmic.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: HiSilicon 6421v600 SPMI PMIC + +maintainers: + - Mauro Carvalho Chehab + +description: | + HiSilicon 6421v600 should be connected inside a MIPI System Power Management + (SPMI) bus. It provides interrupts and power supply. + + The GPIO and interrupt settings are represented as part of the top-level PMIC + node. + + The SPMI controller part is provided by + Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml + +properties: + $nodename: + pattern: "pmic@[0-9a-f]" + + compatible: + const: hisilicon,hi6421v600-spmi + + reg: + maxItems: 1 + + '#interrupt-cells': + const: 2 + + interrupt-controller: true + + interrupts: true + + regulators: + type: object + + additionalProperties: false + + properties: + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + + patternProperties: + '^(ldo|LDO)[0-9]+$': + type: object + + $ref: "/schemas/regulator/regulator.yaml#" + + unevaluatedProperties: false + +required: + - compatible + - reg + - regulators + +additionalProperties: false + +examples: + - | + + pmic: pmic@0 { + compatible = "hisilicon,hi6421v600-spmi"; + reg = <0 0>; + + #interrupt-cells = <2>; + interrupt-controller; + interrupt-parent = <&gpio28>; + interrupts = <0 0>; + + regulators { + #address-cells = <1>; + #size-cells = <0>; + + ldo3: LDO3 { + regulator-name = "ldo3"; + regulator-min-microvolt = <1500000>; + regulator-max-microvolt = <2000000>; + regulator-boot-on; + }; + + ldo4: LDO4 { + regulator-name = "ldo4"; + regulator-min-microvolt = <1725000>; + regulator-max-microvolt = <1900000>; + regulator-boot-on; + }; + + ldo9: LDO9 { + regulator-name = "ldo9"; + regulator-min-microvolt = <1750000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + }; + + ldo15: LDO15 { + regulator-name = "ldo15"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-always-on; + }; + + ldo16: LDO16 { + regulator-name = "ldo16"; + regulator-min-microvolt = <1800000>; + regulator-max-microvolt = <3000000>; + regulator-boot-on; + }; + + ldo17: LDO17 { + regulator-name = "ldo17"; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3300000>; + }; + + ldo33: LDO33 { + regulator-name = "ldo33"; + regulator-min-microvolt = <2500000>; + regulator-max-microvolt = <3300000>; + regulator-boot-on; + }; + + ldo34: LDO34 { + regulator-name = "ldo34"; + regulator-min-microvolt = <2600000>; + regulator-max-microvolt = <3300000>; + }; + }; + }; diff --git a/MAINTAINERS b/MAINTAINERS index 6c8be735cc91..09e0dfed01a9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8433,6 +8433,13 @@ S: Maintained F: Documentation/devicetree/bindings/spmi/hisilicon,hisi-spmi-controller.yaml F: drivers/spmi/hisi-spmi-controller.c +HISILICON SPMI PMIC DRIVER FOR HIKEY 6421v600 +M: Mauro Carvalho Chehab +L: linux-kernel@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml +F: drivers/mfd/hi6421-spmi-pmic.c + HISILICON STAGING DRIVERS FOR HIKEY 960/970 M: Mauro Carvalho Chehab S: Maintained diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 6a3fd2d75f96..01bb42f0ca0b 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -510,6 +510,22 @@ config MFD_HI6421_PMIC menus in order to enable them. We communicate with the Hi6421 via memory-mapped I/O. +config MFD_HI6421_SPMI + tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC" + depends on OF + depends on SPMI + select MFD_CORE + select REGMAP_SPMI + help + Add support for HiSilicon Hi6421v600 SPMI PMIC. Hi6421 includes + multi-functions, such as regulators, RTC, codec, Coulomb counter, + etc. + + This driver includes core APIs _only_. You have to select + individual components like voltage regulators under corresponding + menus in order to enable them. + We communicate with the Hi6421v600 via a SPMI bus. + config MFD_HI655X_PMIC tristate "HiSilicon Hi655X series PMU/Codec IC" depends on ARCH_HISI || COMPILE_TEST diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 8116c19d5fd4..570b9ffb34d0 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -231,6 +231,7 @@ obj-$(CONFIG_MFD_IPAQ_MICRO) += ipaq-micro.o obj-$(CONFIG_MFD_IQS62X) += iqs62x.o obj-$(CONFIG_MFD_MENF21BMC) += menf21bmc.o obj-$(CONFIG_MFD_HI6421_PMIC) += hi6421-pmic-core.o +obj-$(CONFIG_MFD_HI6421_SPMI) += hi6421-spmi-pmic.o obj-$(CONFIG_MFD_HI655X_PMIC) += hi655x-pmic.o obj-$(CONFIG_MFD_DLN2) += dln2.o obj-$(CONFIG_MFD_RT4831) += rt4831.o diff --git a/drivers/mfd/hi6421-spmi-pmic.c b/drivers/mfd/hi6421-spmi-pmic.c new file mode 100644 index 000000000000..4f136826681b --- /dev/null +++ b/drivers/mfd/hi6421-spmi-pmic.c @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Device driver for regulators in HISI PMIC IC + * + * Copyright (c) 2013 Linaro Ltd. + * Copyright (c) 2011 Hisilicon. + * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd. + */ + +#include +#include +#include +#include +#include +#include +#include + +static const struct mfd_cell hi6421v600_devs[] = { + { .name = "hi6421v600-irq", }, + { .name = "hi6421v600-regulator", }, +}; + +static const struct regmap_config regmap_config = { + .reg_bits = 16, + .val_bits = BITS_PER_BYTE, + .max_register = 0xffff, + .fast_io = true +}; + +static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) +{ + struct device *dev = &sdev->dev; + int ret; + struct hi6421_spmi_pmic *ddata; + ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); + if (!ddata) + return -ENOMEM; + + ddata->regmap = devm_regmap_init_spmi_ext(sdev, ®map_config); + if (IS_ERR(ddata->regmap)) + return PTR_ERR(ddata->regmap); + + ddata->dev = dev; + + dev_set_drvdata(&sdev->dev, ddata); + + ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE, + hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs), + NULL, 0, NULL); + if (ret < 0) + dev_err(dev, "Failed to add child devices: %d\n", ret); + + return ret; +} + +static const struct of_device_id pmic_spmi_id_table[] = { + { .compatible = "hisilicon,hi6421-spmi" }, + { } +}; +MODULE_DEVICE_TABLE(of, pmic_spmi_id_table); + +static struct spmi_driver hi6421_spmi_pmic_driver = { + .driver = { + .name = "hi6421-spmi-pmic", + .of_match_table = pmic_spmi_id_table, + }, + .probe = hi6421_spmi_pmic_probe, +}; +module_spmi_driver(hi6421_spmi_pmic_driver); + +MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver"); +MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index c8eaae6412bb..03ee99d98945 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -102,6 +102,4 @@ source "drivers/staging/qlge/Kconfig" source "drivers/staging/wfx/Kconfig" -source "drivers/staging/hikey9xx/Kconfig" - endif # STAGING diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 818b6f964369..9a4c0e6f34d5 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -41,4 +41,3 @@ obj-$(CONFIG_XIL_AXIS_FIFO) += axis-fifo/ obj-$(CONFIG_FIELDBUS_DEV) += fieldbus/ obj-$(CONFIG_QLGE) += qlge/ obj-$(CONFIG_WFX) += wfx/ -obj-y += hikey9xx/ diff --git a/drivers/staging/hikey9xx/Kconfig b/drivers/staging/hikey9xx/Kconfig deleted file mode 100644 index 9f53df9068fe..000000000000 --- a/drivers/staging/hikey9xx/Kconfig +++ /dev/null @@ -1,19 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -# to be placed at drivers/mfd -config MFD_HI6421_SPMI - tristate "HiSilicon Hi6421v600 SPMI PMU/Codec IC" - depends on HAS_IOMEM - depends on OF - depends on SPMI - select MFD_CORE - select REGMAP_SPMI - help - Add support for HiSilicon Hi6421v600 SPMI PMIC. Hi6421 includes - multi-functions, such as regulators, RTC, codec, Coulomb counter, - etc. - - This driver includes core APIs _only_. You have to select - individual components like voltage regulators under corresponding - menus in order to enable them. - We communicate with the Hi6421v600 via a SPMI bus. diff --git a/drivers/staging/hikey9xx/Makefile b/drivers/staging/hikey9xx/Makefile deleted file mode 100644 index e3108d7dd849..000000000000 --- a/drivers/staging/hikey9xx/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 - -obj-$(CONFIG_MFD_HI6421_SPMI) += hi6421-spmi-pmic.o diff --git a/drivers/staging/hikey9xx/TODO b/drivers/staging/hikey9xx/TODO deleted file mode 100644 index 65e7996a3066..000000000000 --- a/drivers/staging/hikey9xx/TODO +++ /dev/null @@ -1,5 +0,0 @@ -ToDo list: - -- Port other drivers needed by Hikey 960/970; -- Test drivers on Hikey 960; -- Validate device tree bindings. diff --git a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c b/drivers/staging/hikey9xx/hi6421-spmi-pmic.c deleted file mode 100644 index 4f136826681b..000000000000 --- a/drivers/staging/hikey9xx/hi6421-spmi-pmic.c +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Device driver for regulators in HISI PMIC IC - * - * Copyright (c) 2013 Linaro Ltd. - * Copyright (c) 2011 Hisilicon. - * Copyright (c) 2020-2021 Huawei Technologies Co., Ltd. - */ - -#include -#include -#include -#include -#include -#include -#include - -static const struct mfd_cell hi6421v600_devs[] = { - { .name = "hi6421v600-irq", }, - { .name = "hi6421v600-regulator", }, -}; - -static const struct regmap_config regmap_config = { - .reg_bits = 16, - .val_bits = BITS_PER_BYTE, - .max_register = 0xffff, - .fast_io = true -}; - -static int hi6421_spmi_pmic_probe(struct spmi_device *sdev) -{ - struct device *dev = &sdev->dev; - int ret; - struct hi6421_spmi_pmic *ddata; - ddata = devm_kzalloc(dev, sizeof(*ddata), GFP_KERNEL); - if (!ddata) - return -ENOMEM; - - ddata->regmap = devm_regmap_init_spmi_ext(sdev, ®map_config); - if (IS_ERR(ddata->regmap)) - return PTR_ERR(ddata->regmap); - - ddata->dev = dev; - - dev_set_drvdata(&sdev->dev, ddata); - - ret = devm_mfd_add_devices(&sdev->dev, PLATFORM_DEVID_NONE, - hi6421v600_devs, ARRAY_SIZE(hi6421v600_devs), - NULL, 0, NULL); - if (ret < 0) - dev_err(dev, "Failed to add child devices: %d\n", ret); - - return ret; -} - -static const struct of_device_id pmic_spmi_id_table[] = { - { .compatible = "hisilicon,hi6421-spmi" }, - { } -}; -MODULE_DEVICE_TABLE(of, pmic_spmi_id_table); - -static struct spmi_driver hi6421_spmi_pmic_driver = { - .driver = { - .name = "hi6421-spmi-pmic", - .of_match_table = pmic_spmi_id_table, - }, - .probe = hi6421_spmi_pmic_probe, -}; -module_spmi_driver(hi6421_spmi_pmic_driver); - -MODULE_DESCRIPTION("HiSilicon Hi6421v600 SPMI PMIC driver"); -MODULE_LICENSE("GPL v2"); diff --git a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml b/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml deleted file mode 100644 index cedf9d99a34b..000000000000 --- a/drivers/staging/hikey9xx/hisilicon,hi6421-spmi-pmic.yaml +++ /dev/null @@ -1,136 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -%YAML 1.2 ---- -$id: http://devicetree.org/schemas/mfd/hisilicon,hi6421-spmi-pmic.yaml# -$schema: http://devicetree.org/meta-schemas/core.yaml# - -title: HiSilicon 6421v600 SPMI PMIC - -maintainers: - - Mauro Carvalho Chehab - -description: | - HiSilicon 6421v600 should be connected inside a MIPI System Power Management - (SPMI) bus. It provides interrupts and power supply. - - The GPIO and interrupt settings are represented as part of the top-level PMIC - node. - - The SPMI controller part is provided by - Documentation/devicetree/bindings/mfd/hisilicon,hi6421-spmi-pmic.yaml - -properties: - $nodename: - pattern: "pmic@[0-9a-f]" - - compatible: - const: hisilicon,hi6421v600-spmi - - reg: - maxItems: 1 - - '#interrupt-cells': - const: 2 - - interrupt-controller: true - - interrupts: true - - regulators: - type: object - - additionalProperties: false - - properties: - '#address-cells': - const: 1 - - '#size-cells': - const: 0 - - patternProperties: - '^(ldo|LDO)[0-9]+$': - type: object - - $ref: "/schemas/regulator/regulator.yaml#" - - unevaluatedProperties: false - -required: - - compatible - - reg - - regulators - -additionalProperties: false - -examples: - - | - - pmic: pmic@0 { - compatible = "hisilicon,hi6421v600-spmi"; - reg = <0 0>; - - #interrupt-cells = <2>; - interrupt-controller; - interrupt-parent = <&gpio28>; - interrupts = <0 0>; - - regulators { - #address-cells = <1>; - #size-cells = <0>; - - ldo3: LDO3 { - regulator-name = "ldo3"; - regulator-min-microvolt = <1500000>; - regulator-max-microvolt = <2000000>; - regulator-boot-on; - }; - - ldo4: LDO4 { - regulator-name = "ldo4"; - regulator-min-microvolt = <1725000>; - regulator-max-microvolt = <1900000>; - regulator-boot-on; - }; - - ldo9: LDO9 { - regulator-name = "ldo9"; - regulator-min-microvolt = <1750000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - }; - - ldo15: LDO15 { - regulator-name = "ldo15"; - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3000000>; - regulator-always-on; - }; - - ldo16: LDO16 { - regulator-name = "ldo16"; - regulator-min-microvolt = <1800000>; - regulator-max-microvolt = <3000000>; - regulator-boot-on; - }; - - ldo17: LDO17 { - regulator-name = "ldo17"; - regulator-min-microvolt = <2500000>; - regulator-max-microvolt = <3300000>; - }; - - ldo33: LDO33 { - regulator-name = "ldo33"; - regulator-min-microvolt = <2500000>; - regulator-max-microvolt = <3300000>; - regulator-boot-on; - }; - - ldo34: LDO34 { - regulator-name = "ldo34"; - regulator-min-microvolt = <2600000>; - regulator-max-microvolt = <3300000>; - }; - }; - }; -- cgit v1.2.3 From 2d4c39b32361a7044eed1906e9a6d42ac1ebfabc Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:08 +0200 Subject: staging: rtl8723bs: simplify function selecting channel group simplify function Hal_GetChnlGroup8723B(). It returns an unused and unnecessary bool value telling which band the device works on. Since we work only on 2.4Ghz band and the useful return value is the second function argument we convert the return type to void. remove 5Ghz dead code either (for channel > 14). Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/a5536788004c44fe819c0eab0d19504824af46cd.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 62 +++++------------------ 1 file changed, 12 insertions(+), 50 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 059d3050acc6..bd0e9f05eb5c 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2061,56 +2061,18 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter) return ret; } -static bool Hal_GetChnlGroup8723B(u8 Channel, u8 *pGroup) -{ - bool bIn24G = true; - - if (Channel <= 14) { - bIn24G = true; - - if (1 <= Channel && Channel <= 2) - *pGroup = 0; - else if (3 <= Channel && Channel <= 5) - *pGroup = 1; - else if (6 <= Channel && Channel <= 8) - *pGroup = 2; - else if (9 <= Channel && Channel <= 11) - *pGroup = 3; - else if (12 <= Channel && Channel <= 14) - *pGroup = 4; - } else { - bIn24G = false; - - if (36 <= Channel && Channel <= 42) - *pGroup = 0; - else if (44 <= Channel && Channel <= 48) - *pGroup = 1; - else if (50 <= Channel && Channel <= 58) - *pGroup = 2; - else if (60 <= Channel && Channel <= 64) - *pGroup = 3; - else if (100 <= Channel && Channel <= 106) - *pGroup = 4; - else if (108 <= Channel && Channel <= 114) - *pGroup = 5; - else if (116 <= Channel && Channel <= 122) - *pGroup = 6; - else if (124 <= Channel && Channel <= 130) - *pGroup = 7; - else if (132 <= Channel && Channel <= 138) - *pGroup = 8; - else if (140 <= Channel && Channel <= 144) - *pGroup = 9; - else if (149 <= Channel && Channel <= 155) - *pGroup = 10; - else if (157 <= Channel && Channel <= 161) - *pGroup = 11; - else if (165 <= Channel && Channel <= 171) - *pGroup = 12; - else if (173 <= Channel && Channel <= 177) - *pGroup = 13; - } - return bIn24G; +static void Hal_GetChnlGroup8723B(u8 Channel, u8 *pGroup) +{ + if (1 <= Channel && Channel <= 2) + *pGroup = 0; + else if (3 <= Channel && Channel <= 5) + *pGroup = 1; + else if (6 <= Channel && Channel <= 8) + *pGroup = 2; + else if (9 <= Channel && Channel <= 11) + *pGroup = 3; + else if (12 <= Channel && Channel <= 14) + *pGroup = 4; } void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent) -- cgit v1.2.3 From 1a0b06bff50f96b5436337e95a08d7f48564a4c0 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:09 +0200 Subject: staging: rtl8723bs: fix camel case inside function fix camel case inside function Hal_GetChnlGroup8723B() Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/831b5f56cc6df8885ac61837fe53f63e021b289b.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index bd0e9f05eb5c..246a5362a54f 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2061,18 +2061,18 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter) return ret; } -static void Hal_GetChnlGroup8723B(u8 Channel, u8 *pGroup) -{ - if (1 <= Channel && Channel <= 2) - *pGroup = 0; - else if (3 <= Channel && Channel <= 5) - *pGroup = 1; - else if (6 <= Channel && Channel <= 8) - *pGroup = 2; - else if (9 <= Channel && Channel <= 11) - *pGroup = 3; - else if (12 <= Channel && Channel <= 14) - *pGroup = 4; +static void Hal_GetChnlGroup8723B(u8 channel, u8 *group) +{ + if (1 <= channel && channel <= 2) + *group = 0; + else if (3 <= channel && channel <= 5) + *group = 1; + else if (6 <= channel && channel <= 8) + *group = 2; + else if (9 <= channel && channel <= 11) + *group = 3; + else if (12 <= channel && channel <= 14) + *group = 4; } void Hal_InitPGData(struct adapter *padapter, u8 *PROMContent) -- cgit v1.2.3 From ce9299678fa1638ffdcbdde96aaf7c19ce43e04a Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:10 +0200 Subject: staging: rtl8723bs: convert function name to snake case convert Hal_GetChnlGroup8723B() function name to snake case. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/78bbc5cb8531bc03eccfa2f67ee71979cbfbf12e.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 246a5362a54f..a680fc1d4bea 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2061,7 +2061,7 @@ s32 rtl8723b_InitLLTTable(struct adapter *padapter) return ret; } -static void Hal_GetChnlGroup8723B(u8 channel, u8 *group) +static void hal_get_chnl_group_8723b(u8 channel, u8 *group) { if (1 <= channel && channel <= 2) *group = 0; @@ -2235,7 +2235,7 @@ void Hal_EfuseParseTxPowerInfo_8723B( for (ch = 0 ; ch < CHANNEL_MAX_NUMBER; ch++) { u8 group = 0; - Hal_GetChnlGroup8723B(ch+1, &group); + hal_get_chnl_group_8723b(ch+1, &group); if (ch == 14-1) { pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][5]; -- cgit v1.2.3 From 0a1d0ebec6c74d043c3c7707b1c14388ab7c02a9 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:11 +0200 Subject: staging: rtl8723bs: add spaces around operator fix the following post-commit hook checkpatch warning: CHECK: spaces preferred around that '+' (ctx:VxV) 29: FILE: drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c:2238: + hal_get_chnl_group_8723b(ch+1, &group); Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/e9f65e7600a3c935ef9c310e782790e04cc1f17f.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index a680fc1d4bea..d9a2d3e6a56f 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2235,7 +2235,7 @@ void Hal_EfuseParseTxPowerInfo_8723B( for (ch = 0 ; ch < CHANNEL_MAX_NUMBER; ch++) { u8 group = 0; - hal_get_chnl_group_8723b(ch+1, &group); + hal_get_chnl_group_8723b(ch + 1, &group); if (ch == 14-1) { pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][5]; -- cgit v1.2.3 From ddd7c8b0033ba01a0ee605697f12a33fd31e6fca Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:12 +0200 Subject: staging: rtl8723bs: remove 5Ghz code blocks remove 5 Ghz code blocks, related to networks working over channel numbers above 14. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/c64443b92ce1a60f568db153842a62e3244a8c3a.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 7 ++----- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 20 +++----------------- 2 files changed, 5 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index af7d133bce94..2df8ed649519 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3708,7 +3708,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); if ((p == NULL) || (len == 0)) {/* non-HT */ - if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14)) + if (pbss_network->Configuration.DSConfig <= 0) continue; ICS[0][pbss_network->Configuration.DSConfig] = 1; @@ -5428,10 +5428,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) { struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); - if (pnetwork->Configuration.DSConfig > 14) { - if ((pregpriv->bw_mode >> 4) > CHANNEL_WIDTH_20) - cbw40_enable = 1; - } else { + if (pnetwork->Configuration.DSConfig <= 14) { if ((pregpriv->bw_mode & 0x0f) > CHANNEL_WIDTH_20) cbw40_enable = 1; } diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 965558516cbd..8af81c4ff8db 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -129,14 +129,7 @@ static char *translate_scan(struct adapter *padapter, else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pnetwork->network.Configuration.DSConfig > 14) { - if (vht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11AC"); - else if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); - } else { + if (pnetwork->network.Configuration.DSConfig <= 14) { if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); else @@ -683,7 +676,7 @@ static int rtw_wx_get_name(struct net_device *dev, struct adapter *padapter = rtw_netdev_priv(dev); u32 ht_ielen = 0; char *p; - u8 ht_cap = false, vht_cap = false; + u8 ht_cap = false; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; NDIS_802_11_RATES_EX *prates = NULL; @@ -707,14 +700,7 @@ static int rtw_wx_get_name(struct net_device *dev, else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pcur_bss->Configuration.DSConfig > 14) { - if (vht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11AC"); - else if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); - } else { + if (pcur_bss->Configuration.DSConfig <= 14) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); else -- cgit v1.2.3 From 2a62ff13132a22a754d042b2230117bbea0af477 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:13 +0200 Subject: staging: rtl8723bs: remove commented out condition remove commented out condition checking channel > 14. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/83762719c0c13ac8b78612a32db26e691eef17d1.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 8af81c4ff8db..060cdd7b2925 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -159,7 +159,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); } - if (pnetwork->network.Configuration.DSConfig < 1 /*|| pnetwork->network.Configuration.DSConfig > 14*/) + if (pnetwork->network.Configuration.DSConfig < 1) pnetwork->network.Configuration.DSConfig = 1; /* Add frequency/channel */ -- cgit v1.2.3 From d3fcee1b78a533c256077f1300dd236801397cf7 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:14 +0200 Subject: staging: rtl8723bs: fix camel case in struct wlan_bssid_ex fix camel case in struct wlan_bssid_ex. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/561065e95ff38f0dbedf030c3acf0498396a1759.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 124 +++++------ drivers/staging/rtl8723bs/core/rtw_cmd.c | 50 ++--- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 52 ++--- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 12 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 216 +++++++++---------- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 248 +++++++++++----------- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 58 ++--- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 2 +- drivers/staging/rtl8723bs/hal/hal_com.c | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 22 +- drivers/staging/rtl8723bs/include/rtw_mlme.h | 6 +- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 30 +-- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 64 +++--- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 104 ++++----- 14 files changed, 495 insertions(+), 495 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index da67adde2ebd..6adefdbb7407 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -56,7 +56,7 @@ static void update_BCNTIM(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; - unsigned char *pie = pnetwork_mlmeext->IEs; + unsigned char *pie = pnetwork_mlmeext->ies; /* update TIM IE */ u8 *p, *dst_ie, *premainder_ie = NULL, *pbackup_remainder_ie = NULL; @@ -68,7 +68,7 @@ static void update_BCNTIM(struct adapter *padapter) p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen, - pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_ + pnetwork_mlmeext->ie_length - _FIXED_IE_LENGTH_ ); if (p && tim_ielen > 0) { tim_ielen += 2; @@ -77,7 +77,7 @@ static void update_BCNTIM(struct adapter *padapter) tim_ie_offset = (signed int)(p - pie); - remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; + remainder_ielen = pnetwork_mlmeext->ie_length - tim_ie_offset - tim_ielen; /* append TIM IE from dst_ie offset */ dst_ie = p; @@ -91,7 +91,7 @@ static void update_BCNTIM(struct adapter *padapter) p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &tmp_len, - (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) + (pnetwork_mlmeext->ie_length - _BEACON_IE_OFFSET_) ); if (p) offset += tmp_len + 2; @@ -99,7 +99,7 @@ static void update_BCNTIM(struct adapter *padapter) /* get supported rates len */ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &tmp_len, - (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_) + (pnetwork_mlmeext->ie_length - _BEACON_IE_OFFSET_) ); if (p) offset += tmp_len + 2; @@ -109,7 +109,7 @@ static void update_BCNTIM(struct adapter *padapter) premainder_ie = pie + offset; - remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen; + remainder_ielen = pnetwork_mlmeext->ie_length - offset - tim_ielen; /* append TIM IE from offset */ dst_ie = pie + offset; @@ -161,7 +161,7 @@ static void update_BCNTIM(struct adapter *padapter) } offset = (uint)(dst_ie - pie); - pnetwork_mlmeext->IELength = offset + remainder_ielen; + pnetwork_mlmeext->ie_length = offset + remainder_ielen; } static u8 chk_sta_is_alive(struct sta_info *psta) @@ -340,7 +340,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) shortGIrate = query_ra_short_GI(psta); - if (pcur_network->Configuration.DSConfig > 14) { + if (pcur_network->configuration.DSConfig > 14) { sta_band |= WIRELESS_INVALID; } else { if (tx_ra_bitmap & 0xffff000) @@ -397,16 +397,16 @@ void update_bmc_sta(struct adapter *padapter) /* psta->dot118021XPrivacy = _NO_PRIVACY_;//!!! remove it, because it has been set before this. */ /* prepare for add_RATid */ - supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates); - network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates, + supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->supported_rates); + network_type = rtw_check_network_type((u8 *)&pcur_network->supported_rates, supportRateNum, - pcur_network->Configuration.DSConfig + pcur_network->configuration.DSConfig ); if (is_supported_tx_cck(network_type)) { network_type = WIRELESS_11B; } else if (network_type == WIRELESS_INVALID) { /* error handling */ - if (pcur_network->Configuration.DSConfig > 14) + if (pcur_network->configuration.DSConfig > 14) network_type = WIRELESS_INVALID; else network_type = WIRELESS_11B; @@ -572,8 +572,8 @@ static void update_ap_info(struct adapter *padapter, struct sta_info *psta) psta->wireless_mode = pmlmeext->cur_wireless_mode; - psta->bssratelen = rtw_get_rateset_len(pnetwork->SupportedRates); - memcpy(psta->bssrateset, pnetwork->SupportedRates, psta->bssratelen); + psta->bssratelen = rtw_get_rateset_len(pnetwork->supported_rates); + memcpy(psta->bssrateset, pnetwork->supported_rates, psta->bssratelen); /* HT related cap */ if (phtpriv_ap->ht_option) { @@ -656,16 +656,16 @@ void start_bss_network(struct adapter *padapter) struct HT_info_element *pht_info = NULL; u8 cbw40_enable = 0; - bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; - cur_channel = pnetwork->Configuration.DSConfig; + bcn_interval = (u16)pnetwork->configuration.BeaconPeriod; + cur_channel = pnetwork->configuration.DSConfig; cur_bwmode = CHANNEL_WIDTH_20; cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; /* check if there is wps ie, */ /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ - if (!rtw_get_wps_ie(pnetwork->IEs + _FIXED_IE_LENGTH_, - pnetwork->IELength - _FIXED_IE_LENGTH_, NULL, NULL)) + if (!rtw_get_wps_ie(pnetwork->ies + _FIXED_IE_LENGTH_, + pnetwork->ie_length - _FIXED_IE_LENGTH_, NULL, NULL)) pmlmeext->bstart_bss = true; /* todo: update wmm, ht cap */ @@ -694,7 +694,7 @@ void start_bss_network(struct adapter *padapter) Set_MSR(padapter, _HW_STATE_AP_); /* Set BSSID REG */ - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->mac_address); /* Set EDCA param reg */ acparm = 0x002F3217; /* VO */ @@ -734,10 +734,10 @@ void start_bss_network(struct adapter *padapter) } /* set channel, bwmode */ - p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fix_ie)), + p = rtw_get_ie((pnetwork->ies + sizeof(struct ndis_802_11_fix_ie)), WLAN_EID_HT_OPERATION, &ie_len, - (pnetwork->IELength - sizeof(struct ndis_802_11_fix_ie)) + (pnetwork->ie_length - sizeof(struct ndis_802_11_fix_ie)) ); if (p && ie_len) { pht_info = (struct HT_info_element *)(p + 2); @@ -780,14 +780,14 @@ void start_bss_network(struct adapter *padapter) pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; /* let pnetwork_mlmeext == pnetwork_mlme. */ - memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); + memcpy(pnetwork_mlmeext, pnetwork, pnetwork->length); /* update cur_wireless_mode */ update_wireless_mode(padapter); /* update RRSR after set channel and bandwidth */ - UpdateBrateTbl(padapter, pnetwork->SupportedRates); - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + UpdateBrateTbl(padapter, pnetwork->supported_rates); + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->supported_rates); /* update capability after cur_wireless_mode updated */ update_capinfo( @@ -827,7 +827,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; - u8 *ie = pbss_network->IEs; + u8 *ie = pbss_network->ies; if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return _FAIL; @@ -835,23 +835,23 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (len < 0 || len > MAX_IE_SZ) return _FAIL; - pbss_network->IELength = len; + pbss_network->ie_length = len; memset(ie, 0, MAX_IE_SZ); - memcpy(ie, pbuf, pbss_network->IELength); + memcpy(ie, pbuf, pbss_network->ie_length); - if (pbss_network->InfrastructureMode != Ndis802_11APMode) + if (pbss_network->infrastructure_mode != Ndis802_11APMode) return _FAIL; - pbss_network->Rssi = 0; + pbss_network->rssi = 0; - memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pbss_network->mac_address, myid(&(padapter->eeprompriv)), ETH_ALEN); /* beacon interval */ p = rtw_get_beacon_interval_from_ie(ie);/* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ - /* pbss_network->Configuration.BeaconPeriod = le16_to_cpu(*(unsigned short*)p); */ - pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p); + /* pbss_network->configuration.BeaconPeriod = le16_to_cpu(*(unsigned short*)p); */ + pbss_network->configuration.BeaconPeriod = get_unaligned_le16(p); /* capability */ /* cap = *(unsigned short *)rtw_get_capability_from_ie(ie); */ @@ -863,26 +863,26 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { - memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); - pbss_network->Ssid.SsidLength = ie_len; + memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(pbss_network->ssid.Ssid, (p + 2), ie_len); + pbss_network->ssid.SsidLength = ie_len; } /* channel */ channel = 0; - pbss_network->Configuration.Length = 0; + pbss_network->configuration.Length = 0; p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) channel = *(p + 2); - pbss_network->Configuration.DSConfig = channel; + pbss_network->configuration.DSConfig = channel; memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ @@ -890,7 +890,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p != NULL) { memcpy(supportRate, p + 2, ie_len); @@ -902,7 +902,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, &ie_len, - pbss_network->IELength - _BEACON_IE_OFFSET_ + pbss_network->ie_length - _BEACON_IE_OFFSET_ ); if (p != NULL) { memcpy(supportRate + supportRateNum, p + 2, ie_len); @@ -911,23 +911,23 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) network_type = rtw_check_network_type(supportRate, supportRateNum, channel); - rtw_set_supported_rate(pbss_network->SupportedRates, network_type); + rtw_set_supported_rate(pbss_network->supported_rates, network_type); /* parsing ERP_IE */ p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) ERP_IE_handler(padapter, (struct ndis_80211_var_ie *)p); /* update privacy/security */ if (cap & BIT(4)) - pbss_network->Privacy = 1; + pbss_network->privacy = 1; else - pbss_network->Privacy = 0; + pbss_network->privacy = 0; psecuritypriv->wpa_psk = 0; @@ -939,7 +939,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { if (rtw_parse_wpa2_ie( @@ -969,7 +969,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) + (pbss_network->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2)) ); if ((p) && (!memcmp(p + 2, OUI1, 4))) { if (rtw_parse_wpa_ie( @@ -1005,7 +1005,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2)) + (pbss_network->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2)) ); if ((p) && !memcmp(p + 2, WMM_PARA_IE, 6)) { pmlmepriv->qospriv.qos_option = 1; @@ -1032,7 +1032,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { u8 rf_type = 0; @@ -1095,23 +1095,23 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, - (pbss_network->IELength - _BEACON_IE_OFFSET_) + (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) pHT_info_ie = p; switch (network_type) { case WIRELESS_11B: - pbss_network->NetworkTypeInUse = Ndis802_11DS; + pbss_network->network_type_in_use = Ndis802_11DS; break; case WIRELESS_11G: case WIRELESS_11BG: case WIRELESS_11G_24N: case WIRELESS_11BG_24N: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + pbss_network->network_type_in_use = Ndis802_11OFDM24; break; default: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + pbss_network->network_type_in_use = Ndis802_11OFDM24; break; } @@ -1138,7 +1138,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) HT_info_handler(padapter, (struct ndis_80211_var_ie *)pHT_info_ie); } - pbss_network->Length = get_wlan_bssid_ex_sz( + pbss_network->length = get_wlan_bssid_ex_sz( (struct wlan_bssid_ex *)pbss_network ); @@ -1147,9 +1147,9 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) rtw_startbss_cmd(padapter, RTW_CMDF_WAIT_ACK); /* alloc sta_info for ap itself */ - psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); + psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->mac_address); if (!psta) { - psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); + psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->mac_address); if (psta == NULL) return _FAIL; } @@ -1405,7 +1405,7 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); - unsigned char *p, *ie = pnetwork->IEs; + unsigned char *p, *ie = pnetwork->ies; u32 len = 0; if (!pmlmeinfo->ERP_enable) @@ -1416,7 +1416,7 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, - (pnetwork->IELength - _BEACON_IE_OFFSET_) + (pnetwork->ie_length - _BEACON_IE_OFFSET_) ); if (p && len > 0) { struct ndis_80211_var_ie *pIE = (struct ndis_80211_var_ie *)p; @@ -1469,8 +1469,8 @@ static void update_bcn_wps_ie(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); - unsigned char *ie = pnetwork->IEs; - u32 ielen = pnetwork->IELength; + unsigned char *ie = pnetwork->ies; + u32 ielen = pnetwork->ie_length; pwps_ie = rtw_get_wps_ie( ie + _FIXED_IE_LENGTH_, @@ -1506,8 +1506,8 @@ static void update_bcn_wps_ie(struct adapter *padapter) if (pbackup_remainder_ie) memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen); - /* update IELength */ - pnetwork->IELength = wps_offset + (wps_ielen + 2) + remainder_ielen; + /* update ie_length */ + pnetwork->ie_length = wps_offset + (wps_ielen + 2) + remainder_ielen; } kfree(pbackup_remainder_ie); diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 04956ccf485c..865b42699335 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -656,7 +656,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter) pcmd->rsp = NULL; pcmd->rspsz = 0; - pdev_network->Length = pcmd->cmdsz; + pdev_network->length = pcmd->cmdsz; res = rtw_enqueue_cmd(pcmdpriv, pcmd); @@ -722,7 +722,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) struct security_priv *psecuritypriv = &padapter->securitypriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.InfrastructureMode; + enum ndis_802_11_network_infrastructure ndis_network_mode = pnetwork->network.infrastructure_mode; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); u32 tmp_len; @@ -733,7 +733,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) res = _FAIL; goto exit; } - /* for IEs is fix buf size */ + /* for ies is fix buf size */ t_len = sizeof(struct wlan_bssid_ex); @@ -762,32 +762,32 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); - psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; + psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->ie_length; - if ((psecnetwork->IELength-12) < (256-1)) - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); + if ((psecnetwork->ie_length-12) < (256-1)) + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->ies[12], psecnetwork->ie_length-12); else - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->ies[12], (256-1)); - psecnetwork->IELength = 0; + psecnetwork->ie_length = 0; /* Added by Albert 2009/02/18 */ /* If the driver wants to use the bssid to create the connection. */ /* If not, we have to copy the connecting AP's MAC address to it so that */ /* the driver just has the bssid information for PMKIDList searching. */ if (pmlmepriv->assoc_by_bssid == false) - memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN); + memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.mac_address[0], ETH_ALEN); - psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength); + psecnetwork->ie_length = rtw_restruct_sec_ie(padapter, &pnetwork->network.ies[0], &psecnetwork->ies[0], pnetwork->network.ie_length); pqospriv->qos_option = 0; if (pregistrypriv->wmm_enable) { - tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength); + tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.ies[0], &psecnetwork->ies[0], pnetwork->network.ie_length, psecnetwork->ie_length); - if (psecnetwork->IELength != tmp_len) { - psecnetwork->IELength = tmp_len; + if (psecnetwork->ie_length != tmp_len) { + psecnetwork->ie_length = tmp_len; pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */ } else { pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */ @@ -795,7 +795,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) } phtpriv->ht_option = false; - ptmp = rtw_get_ie(&pnetwork->network.IEs[12], WLAN_EID_HT_CAPABILITY, &tmp_len, pnetwork->network.IELength-12); + ptmp = rtw_get_ie(&pnetwork->network.ies[12], WLAN_EID_HT_CAPABILITY, &tmp_len, pnetwork->network.ie_length-12); if (pregistrypriv->ht_enable && ptmp && tmp_len > 0) { /* Added by Albert 2010/06/23 */ /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ @@ -805,18 +805,18 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { rtw_ht_use_default_setting(padapter); - rtw_build_wmm_ie_ht(padapter, &psecnetwork->IEs[12], &psecnetwork->IELength); + rtw_build_wmm_ie_ht(padapter, &psecnetwork->ies[12], &psecnetwork->ie_length); /* rtw_restructure_ht_ie */ - rtw_restructure_ht_ie(padapter, &pnetwork->network.IEs[12], &psecnetwork->IEs[0], - pnetwork->network.IELength-12, &psecnetwork->IELength, - pnetwork->network.Configuration.DSConfig); + rtw_restructure_ht_ie(padapter, &pnetwork->network.ies[12], &psecnetwork->ies[0], + pnetwork->network.ie_length-12, &psecnetwork->ie_length, + pnetwork->network.configuration.DSConfig); } } - rtw_append_exented_cap(padapter, &psecnetwork->IEs[0], &psecnetwork->IELength); + rtw_append_exented_cap(padapter, &psecnetwork->ies[0], &psecnetwork->ie_length); - pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.IEs, pnetwork->network.IELength); + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.ies, pnetwork->network.ie_length); pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */ @@ -1973,9 +1973,9 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); + psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->mac_address); if (!psta) { - psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); + psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->mac_address); if (!psta) goto createbss_cmd_fail; } @@ -1995,8 +1995,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); } - pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); - memcpy(&(pwlan->network), pnetwork, pnetwork->Length); + pnetwork->length = get_wlan_bssid_ex_sz(pnetwork); + memcpy(&(pwlan->network), pnetwork, pnetwork->length); /* pwlan->fixed = true; */ /* list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); */ @@ -2005,7 +2005,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork))); /* reset DSConfig */ - /* tgt_network->network.Configuration.DSConfig = (u32)rtw_ch2freq(pnetwork->Configuration.DSConfig); */ + /* tgt_network->network.configuration.DSConfig = (u32)rtw_ch2freq(pnetwork->configuration.DSConfig); */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 0f0fcd9dc652..fb15c9531ba8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -253,25 +253,25 @@ exit: return ret; } -void rtw_set_supported_rate(u8 *SupportedRates, uint mode) +void rtw_set_supported_rate(u8 *supported_rates, uint mode) { - memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); switch (mode) { case WIRELESS_11B: - memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); + memcpy(supported_rates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); break; case WIRELESS_11G: - memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); + memcpy(supported_rates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); break; case WIRELESS_11BG: case WIRELESS_11G_24N: case WIRELESS_11_24N: case WIRELESS_11BG_24N: - memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); - memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); + memcpy(supported_rates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); + memcpy(supported_rates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); break; } } @@ -291,14 +291,14 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) u8 wireless_mode; int sz = 0, rateLen; struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; - u8 *ie = pdev_network->IEs; + u8 *ie = pdev_network->ies; /* timestamp will be inserted by hardware */ sz += 8; ie += sz; /* beacon interval : 2bytes */ - *(__le16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */ + *(__le16 *)ie = cpu_to_le16((u16)pdev_network->configuration.BeaconPeriod);/* BCN_INTERVAL; */ sz += 2; ie += 2; @@ -310,38 +310,38 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) if (pregistrypriv->preamble == PREAMBLE_SHORT) *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); - if (pdev_network->Privacy) + if (pdev_network->privacy) *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); sz += 2; ie += 2; /* SSID */ - ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->ssid.SsidLength, pdev_network->ssid.Ssid, &sz); /* supported rates */ wireless_mode = pregistrypriv->wireless_mode; - rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); + rtw_set_supported_rate(pdev_network->supported_rates, wireless_mode); - rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); + rateLen = rtw_get_rateset_len(pdev_network->supported_rates); if (rateLen > 8) { - ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); - /* ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->supported_rates, &sz); + /* ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->supported_rates + 8), &sz); */ } else { - ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->supported_rates, &sz); } /* DS parameter set */ - ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); + ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&(pdev_network->configuration.DSConfig), &sz); /* IBSS Parameter Set */ - ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); + ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&(pdev_network->configuration.ATIMWindow), &sz); if (rateLen > 8) { - ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); + ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->supported_rates + 8), &sz); } /* HT Cap. */ @@ -350,7 +350,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) /* todo: */ } - /* pdev_network->IELength = sz; update IELength */ + /* pdev_network->ie_length = sz; update ie_length */ /* return _SUCCESS; */ @@ -1030,7 +1030,7 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; - pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length-12); if (pbuf && (wpa_ielen > 0)) { if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { @@ -1040,7 +1040,7 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) ret = _SUCCESS; } } else { - pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa2_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length-12); if (pbuf && (wpa_ielen > 0)) { if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { @@ -1067,15 +1067,15 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) unsigned char *p; __le16 le_cap; - memcpy((u8 *)&le_cap, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); + memcpy((u8 *)&le_cap, rtw_get_capability_from_ie(pnetwork->network.ies), 2); cap = le16_to_cpu(le_cap); if (cap & WLAN_CAPABILITY_PRIVACY) { bencrypt = 1; - pnetwork->network.Privacy = 1; + pnetwork->network.privacy = 1; } else { pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; } - rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); + rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, NULL, &rsn_len, NULL, &wpa_len); if (rsn_len > 0) { pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; @@ -1089,7 +1089,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) /* get bwmode and ch_offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(pht_cap->cap_info); @@ -1097,7 +1097,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index fcbbdbe5448b..662e63f764cd 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -93,9 +93,9 @@ u8 rtw_do_join(struct adapter *padapter) pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; - pibss = padapter->registrypriv.dev_network.MacAddress; + pibss = padapter->registrypriv.dev_network.mac_address; - memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(padapter); @@ -158,7 +158,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) goto release_mlme_lock; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { - if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { + if (!memcmp(&pmlmepriv->cur_network.network.mac_address, bssid, ETH_ALEN)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { @@ -354,7 +354,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; - enum ndis_802_11_network_infrastructure *pold_state = &(cur_network->network.InfrastructureMode); + enum ndis_802_11_network_infrastructure *pold_state = &(cur_network->network.infrastructure_mode); if (*pold_state != networktype) { if (*pold_state == Ndis802_11APMode) { @@ -562,8 +562,8 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) short_GI, psta->htpriv.ht_cap.mcs.rx_mask); } else { - while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { - rate = pcur_bss->SupportedRates[i]&0x7F; + while ((pcur_bss->supported_rates[i] != 0) && (pcur_bss->supported_rates[i] != 0xFF)) { + rate = pcur_bss->supported_rates[i]&0x7F; if (rate > max_rate) max_rate = rate; i++; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 2dd75e007239..c994f6335bdc 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -23,7 +23,7 @@ int rtw_init_mlme_priv(struct adapter *padapter) pmlmepriv->pscanned = NULL; pmlmepriv->fw_state = WIFI_STATION_STATE; /* Must sync with rtw_wdev_alloc() */ /* wdev->iftype = NL80211_IFTYPE_STATION */ - pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; + pmlmepriv->cur_network.network.infrastructure_mode = Ndis802_11AutoUnknown; pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ spin_lock_init(&pmlmepriv->lock); @@ -245,7 +245,7 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) list_for_each(plist, phead) { pnetwork = list_entry(plist, struct wlan_network, list); - if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) + if (!memcmp(addr, pnetwork->network.mac_address, ETH_ALEN)) break; } @@ -313,7 +313,7 @@ u16 rtw_get_capability(struct wlan_bssid_ex *bss) { __le16 val; - memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2); + memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->ies), 2); return le16_to_cpu(val); } @@ -363,10 +363,10 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) struct security_priv *psecuritypriv = &adapter->securitypriv; if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && - (pnetwork->network.Privacy == 0)) + (pnetwork->network.privacy == 0)) ret = false; else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && - (pnetwork->network.Privacy == 1)) + (pnetwork->network.privacy == 1)) ret = false; else ret = true; @@ -377,8 +377,8 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { - return (a->Ssid.SsidLength == b->Ssid.SsidLength) - && !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); + return (a->ssid.SsidLength == b->ssid.SsidLength) + && !memcmp(a->ssid.Ssid, b->ssid.Ssid, a->ssid.SsidLength); } int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 feature) @@ -389,16 +389,16 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 fea if (rtw_bug_check(dst, src, &s_cap, &d_cap) == false) return false; - memcpy((u8 *)&tmps, rtw_get_capability_from_ie(src->IEs), 2); - memcpy((u8 *)&tmpd, rtw_get_capability_from_ie(dst->IEs), 2); + memcpy((u8 *)&tmps, rtw_get_capability_from_ie(src->ies), 2); + memcpy((u8 *)&tmpd, rtw_get_capability_from_ie(dst->ies), 2); s_cap = le16_to_cpu(tmps); d_cap = le16_to_cpu(tmpd); - return (src->Ssid.SsidLength == dst->Ssid.SsidLength) && - /* (src->Configuration.DSConfig == dst->Configuration.DSConfig) && */ - ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN))) && - ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength))) && + return (src->ssid.SsidLength == dst->ssid.SsidLength) && + /* (src->configuration.DSConfig == dst->configuration.DSConfig) && */ + ((!memcmp(src->mac_address, dst->mac_address, ETH_ALEN))) && + ((!memcmp(src->ssid.Ssid, dst->ssid.Ssid, src->ssid.SsidLength))) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && ((s_cap & WLAN_CAPABILITY_ESS) == @@ -450,9 +450,9 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, struct adapter *padapter, bool update_ie) { - long rssi_ori = dst->Rssi; + long rssi_ori = dst->rssi; - u8 sq_smp = src->PhyInfo.SignalQuality; + u8 sq_smp = src->phy_info.SignalQuality; u8 ss_final; u8 sq_final; @@ -465,19 +465,19 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, sq_final = padapter->recvpriv.signal_qual; /* the rssi value here is undecorated, and will be used for antenna diversity */ if (sq_smp != 101) /* from the right channel */ - rssi_final = (src->Rssi+dst->Rssi*4)/5; + rssi_final = (src->rssi+dst->rssi*4)/5; else rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; - sq_final = ((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; - rssi_final = (src->Rssi+dst->Rssi*4)/5; + ss_final = ((u32)(src->phy_info.SignalStrength)+(u32)(dst->phy_info.SignalStrength)*4)/5; + sq_final = ((u32)(src->phy_info.SignalQuality)+(u32)(dst->phy_info.SignalQuality)*4)/5; + rssi_final = (src->rssi+dst->rssi*4)/5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ - ss_final = dst->PhyInfo.SignalStrength; - sq_final = dst->PhyInfo.SignalQuality; - rssi_final = dst->Rssi; + ss_final = dst->phy_info.SignalStrength; + sq_final = dst->phy_info.SignalQuality; + rssi_final = dst->rssi; } } @@ -488,9 +488,9 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); } - dst->PhyInfo.SignalStrength = ss_final; - dst->PhyInfo.SignalQuality = sq_final; - dst->Rssi = rssi_final; + dst->phy_info.SignalStrength = ss_final; + dst->phy_info.SignalQuality = sq_final; + dst->rssi = rssi_final; } static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) @@ -503,11 +503,11 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex &(pmlmepriv->cur_network.network)); if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && (is_same_network(&(pmlmepriv->cur_network.network), pnetwork, 0))) { - /* if (pmlmepriv->cur_network.network.IELength<= pnetwork->IELength) */ + /* if (pmlmepriv->cur_network.network.ie_length<= pnetwork->ie_length) */ { update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); - rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fix_ie), - pmlmepriv->cur_network.network.IELength); + rtw_update_protection(adapter, (pmlmepriv->cur_network.network.ies) + sizeof(struct ndis_802_11_fix_ie), + pmlmepriv->cur_network.network.ie_length); } } } @@ -568,8 +568,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork->join_res = 0; /* bss info not receiving from the right channel */ - if (pnetwork->network.PhyInfo.SignalQuality == 101) - pnetwork->network.PhyInfo.SignalQuality = 0; + if (pnetwork->network.phy_info.SignalQuality == 101) + pnetwork->network.phy_info.SignalQuality = 0; } else { /* Otherwise just pull from the free list */ @@ -579,14 +579,14 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t goto exit; bssid_ex_sz = get_wlan_bssid_ex_sz(target); - target->Length = bssid_ex_sz; + target->length = bssid_ex_sz; memcpy(&(pnetwork->network), target, bssid_ex_sz); pnetwork->last_scanned = jiffies; /* bss info not receiving from the right channel */ - if (pnetwork->network.PhyInfo.SignalQuality == 101) - pnetwork->network.PhyInfo.SignalQuality = 0; + if (pnetwork->network.phy_info.SignalQuality == 101) + pnetwork->network.phy_info.SignalQuality = 0; list_add_tail(&(pnetwork->list), &(queue->queue)); @@ -601,7 +601,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork->last_scanned = jiffies; /* target.Reserved[0]== 1, means that scanned network is a bcn frame. */ - if ((pnetwork->network.IELength > target->IELength) && (target->Reserved[0] == 1)) + if ((pnetwork->network.ie_length > target->ie_length) && (target->Reserved[0] == 1)) update_ie = false; /* probe resp(3) > beacon(1) > probe req(2) */ @@ -654,10 +654,10 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor int bselected = true; desired_encmode = psecuritypriv->ndisencryptstatus; - privacy = pnetwork->network.Privacy; + privacy = pnetwork->network.privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) + if (rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -671,7 +671,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor bselected = false; if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) { - p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pnetwork->network.IELength - _BEACON_IE_OFFSET_)); + p = rtw_get_ie(pnetwork->network.ies + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, (pnetwork->network.ie_length - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) bselected = true; else @@ -683,7 +683,7 @@ int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwor bselected = false; if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + if (pnetwork->network.infrastructure_mode != pmlmepriv->cur_network.network.infrastructure_mode) bselected = false; } @@ -711,14 +711,14 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* update IBSS_network 's timestamp */ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { - if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + if (!memcmp(&(pmlmepriv->cur_network.network.mac_address), pnetwork->mac_address, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; - memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + memcpy(pmlmepriv->cur_network.network.ies, pnetwork->ies, 8); spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); - ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); + ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->mac_address); if (ibss_wlan) { - memcpy(ibss_wlan->network.IEs, pnetwork->IEs, 8); + memcpy(ibss_wlan->network.ies, pnetwork->ies, 8); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); goto exit; } @@ -728,8 +728,8 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* lock pmlmepriv->lock when you accessing network_q */ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { - if (pnetwork->Ssid.Ssid[0] == 0) - pnetwork->Ssid.SsidLength = 0; + if (pnetwork->ssid.Ssid[0] == 0) + pnetwork->ssid.SsidLength = 0; rtw_add_network(adapter, pnetwork); } @@ -766,12 +766,12 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) } else { u8 ret = _SUCCESS; struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); - u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + u8 *pibss = adapter->registrypriv.dev_network.mac_address; /* pmlmepriv->fw_state ^= _FW_UNDER_SURVEY;because don't set assoc_timer */ _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(adapter); rtw_generate_random_ibss(pibss); @@ -818,7 +818,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && check_fwstate(pmlmepriv, _FW_LINKED)) { if (rtw_select_roaming_candidate(pmlmepriv) == _SUCCESS) { - receive_disconnect(adapter, pmlmepriv->cur_network.network.MacAddress + receive_disconnect(adapter, pmlmepriv->cur_network.network.mac_address , WLAN_REASON_ACTIVE_ROAM); } } @@ -882,7 +882,7 @@ static void find_network(struct adapter *adapter) struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.mac_address); if (pwlan) pwlan->fixed = false; @@ -905,7 +905,7 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_AP_STATE)) { struct sta_info *psta; - psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); + psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.mac_address); spin_lock_bh(&(pstapriv->sta_hash_lock)); rtw_free_stainfo(adapter, psta); @@ -1025,9 +1025,9 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); + psta = rtw_get_stainfo(pstapriv, pnetwork->network.mac_address); if (!psta) - psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); + psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.mac_address); if (psta) { /* update ptarget_sta */ @@ -1036,8 +1036,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str update_sta_info(padapter, psta); /* update station supportRate */ - psta->bssratelen = rtw_get_rateset_len(pnetwork->network.SupportedRates); - memcpy(psta->bssrateset, pnetwork->network.SupportedRates, psta->bssratelen); + psta->bssratelen = rtw_get_rateset_len(pnetwork->network.supported_rates); + memcpy(psta->bssrateset, pnetwork->network.supported_rates, psta->bssratelen); rtw_hal_update_sta_rate_mask(padapter, psta); psta->wireless_mode = pmlmeext->cur_wireless_mode; @@ -1111,24 +1111,24 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net struct wlan_network *cur_network = &(pmlmepriv->cur_network); /* why not use ptarget_wlan?? */ - memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); - /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ - cur_network->network.IELength = ptarget_wlan->network.IELength; - memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ); + memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.length); + /* some ies in pnetwork is wrong, so we should use ptarget_wlan ies */ + cur_network->network.ie_length = ptarget_wlan->network.ie_length; + memcpy(&cur_network->network.ies[0], &ptarget_wlan->network.ies[0], MAX_IE_SZ); cur_network->aid = pnetwork->join_res; rtw_set_signal_stat_timer(&padapter->recvpriv); - padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; - padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; - /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); + padapter->recvpriv.signal_strength = ptarget_wlan->network.phy_info.SignalStrength; + padapter->recvpriv.signal_qual = ptarget_wlan->network.phy_info.SignalQuality; + /* the ptarget_wlan->network.rssi is raw data, we use ptarget_wlan->network.phy_info.SignalStrength instead (has scaled) */ + padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.phy_info.SignalStrength); rtw_set_signal_stat_timer(&padapter->recvpriv); /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ - switch (pnetwork->network.InfrastructureMode) { + switch (pnetwork->network.infrastructure_mode) { case Ndis802_11Infrastructure: if (pmlmepriv->fw_state&WIFI_UNDER_WPS) @@ -1145,10 +1145,10 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net break; } - rtw_update_protection(padapter, (cur_network->network.IEs) + sizeof(struct ndis_802_11_fix_ie), - (cur_network->network.IELength)); + rtw_update_protection(padapter, (cur_network->network.ies) + sizeof(struct ndis_802_11_fix_ie), + (cur_network->network.ie_length)); - rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength, (u8) cur_network->network.Configuration.DSConfig); + rtw_update_ht_cap(padapter, cur_network->network.ies, cur_network->network.ie_length, (u8) cur_network->network.configuration.DSConfig); } /* Notes: the function could be > passive_level (the same context as Rx tasklet) */ @@ -1172,10 +1172,10 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) rtw_get_encrypt_decrypt_from_registrypriv(adapter); - the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); + the_same_macaddr = !memcmp(pnetwork->network.mac_address, cur_network->network.mac_address, ETH_ALEN); - pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); - if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) + pnetwork->network.length = get_wlan_bssid_ex_sz(&pnetwork->network); + if (pnetwork->network.length > sizeof(struct wlan_bssid_ex)) return; spin_lock_bh(&pmlmepriv->lock); @@ -1190,17 +1190,17 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) /* s1. find ptarget_wlan */ if (check_fwstate(pmlmepriv, _FW_LINKED)) { if (the_same_macaddr) { - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.mac_address); } else { - pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.mac_address); if (pcur_wlan) pcur_wlan->fixed = false; - pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.mac_address); if (pcur_sta) rtw_free_stainfo(adapter, pcur_sta); - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.mac_address); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { if (ptarget_wlan) ptarget_wlan->fixed = true; @@ -1390,7 +1390,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { if (adapter->stapriv.asoc_sta_count == 2) { spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.mac_address); pmlmepriv->cur_network_scanned = ptarget_wlan; if (ptarget_wlan) ptarget_wlan->fixed = true; @@ -1470,7 +1470,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); /* remove the network entry in scanned_queue */ - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.mac_address); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(adapter, pwlan); @@ -1491,7 +1491,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); /* free old ibss network */ /* pwlan = rtw_find_network(&pmlmepriv->scanned_queue, pstadel->macaddr); */ - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.mac_address); if (pwlan) { pwlan->fixed = false; rtw_free_network_nolock(adapter, pwlan); @@ -1499,11 +1499,11 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); /* re-create ibss */ pdev_network = &(adapter->registrypriv.dev_network); - pibss = adapter->registrypriv.dev_network.MacAddress; + pibss = adapter->registrypriv.dev_network.mac_address; memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); - memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); rtw_update_registrypriv_dev_network(adapter); @@ -1722,7 +1722,7 @@ static int rtw_check_roaming_candidate(struct mlme_priv *mlme /* got specific addr to roam */ if (!is_zero_mac_addr(mlme->roam_tgt_addr)) { - if (!memcmp(mlme->roam_tgt_addr, competitor->network.MacAddress, ETH_ALEN)) + if (!memcmp(mlme->roam_tgt_addr, competitor->network.mac_address, ETH_ALEN)) goto update; else goto exit; @@ -1730,10 +1730,10 @@ static int rtw_check_roaming_candidate(struct mlme_priv *mlme if (jiffies_to_msecs(jiffies - competitor->last_scanned) >= mlme->roam_scanr_exp_ms) goto exit; - if (competitor->network.Rssi - mlme->cur_network_scanned->network.Rssi < mlme->roam_rssi_diff_th) + if (competitor->network.rssi - mlme->cur_network_scanned->network.rssi < mlme->roam_rssi_diff_th) goto exit; - if (*candidate && (*candidate)->network.Rssi >= competitor->network.Rssi) + if (*candidate && (*candidate)->network.rssi >= competitor->network.rssi) goto exit; update: @@ -1775,7 +1775,7 @@ int rtw_select_roaming_candidate(struct mlme_priv *mlme) } else { mlme->roam_network = candidate; - if (!memcmp(candidate->network.MacAddress, mlme->roam_tgt_addr, ETH_ALEN)) + if (!memcmp(candidate->network.mac_address, mlme->roam_tgt_addr, ETH_ALEN)) eth_zero_addr(mlme->roam_tgt_addr); } @@ -1799,14 +1799,14 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme /* check bssid, if needed */ if (mlme->assoc_by_bssid) { - if (memcmp(competitor->network.MacAddress, mlme->assoc_bssid, ETH_ALEN)) + if (memcmp(competitor->network.mac_address, mlme->assoc_bssid, ETH_ALEN)) goto exit; } /* check ssid, if needed */ if (mlme->assoc_ssid.Ssid[0] && mlme->assoc_ssid.SsidLength) { - if (competitor->network.Ssid.SsidLength != mlme->assoc_ssid.SsidLength - || memcmp(competitor->network.Ssid.Ssid, mlme->assoc_ssid.Ssid, mlme->assoc_ssid.SsidLength) + if (competitor->network.ssid.SsidLength != mlme->assoc_ssid.SsidLength + || memcmp(competitor->network.ssid.Ssid, mlme->assoc_ssid.Ssid, mlme->assoc_ssid.SsidLength) ) goto exit; } @@ -1821,7 +1821,7 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme goto exit; } - if (*candidate == NULL || (*candidate)->network.Rssi < competitor->network.Rssi) { + if (*candidate == NULL || (*candidate)->network.rssi < competitor->network.rssi) { *candidate = competitor; updated = true; } @@ -2001,7 +2001,7 @@ exit: return res; } -/* adjust IEs for rtw_joinbss_cmd in WMM */ +/* adjust ies for rtw_joinbss_cmd in WMM */ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len) { unsigned int ielength = 0; @@ -2148,16 +2148,16 @@ void rtw_init_registrypriv_dev_network(struct adapter *adapter) struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; u8 *myhwaddr = myid(peepriv); - memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); + memcpy(pdev_network->mac_address, myhwaddr, ETH_ALEN); - memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); - pdev_network->Configuration.Length = sizeof(struct ndis_802_11_conf); - pdev_network->Configuration.BeaconPeriod = 100; - pdev_network->Configuration.FHConfig.Length = 0; - pdev_network->Configuration.FHConfig.HopPattern = 0; - pdev_network->Configuration.FHConfig.HopSet = 0; - pdev_network->Configuration.FHConfig.DwellTime = 0; + pdev_network->configuration.Length = sizeof(struct ndis_802_11_conf); + pdev_network->configuration.BeaconPeriod = 100; + pdev_network->configuration.FHConfig.Length = 0; + pdev_network->configuration.FHConfig.HopPattern = 0; + pdev_network->configuration.FHConfig.HopSet = 0; + pdev_network->configuration.FHConfig.DwellTime = 0; } void rtw_update_registrypriv_dev_network(struct adapter *adapter) @@ -2169,45 +2169,45 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; /* struct xmit_priv *pxmitpriv = &adapter->xmitpriv; */ - pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0) ; /* adhoc no 802.1x */ + pdev_network->privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0) ; /* adhoc no 802.1x */ - pdev_network->Rssi = 0; + pdev_network->rssi = 0; switch (pregistrypriv->wireless_mode) { case WIRELESS_11B: - pdev_network->NetworkTypeInUse = (Ndis802_11DS); + pdev_network->network_type_in_use = (Ndis802_11DS); break; case WIRELESS_11G: case WIRELESS_11BG: case WIRELESS_11_24N: case WIRELESS_11G_24N: case WIRELESS_11BG_24N: - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + pdev_network->network_type_in_use = (Ndis802_11OFDM24); break; default: /* TODO */ break; } - pdev_network->Configuration.DSConfig = (pregistrypriv->channel); + pdev_network->configuration.DSConfig = (pregistrypriv->channel); - if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) - pdev_network->Configuration.ATIMWindow = (0); + if (cur_network->network.infrastructure_mode == Ndis802_11IBSS) + pdev_network->configuration.ATIMWindow = (0); - pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode); + pdev_network->infrastructure_mode = (cur_network->network.infrastructure_mode); /* 1. Supported rates */ /* 2. IE */ - /* rtw_set_supported_rate(pdev_network->SupportedRates, pregistrypriv->wireless_mode) ; will be called in rtw_generate_ie */ + /* rtw_set_supported_rate(pdev_network->supported_rates, pregistrypriv->wireless_mode) ; will be called in rtw_generate_ie */ sz = rtw_generate_ie(pregistrypriv); - pdev_network->IELength = sz; + pdev_network->ie_length = sz; - pdev_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + pdev_network->length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); - /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ - /* pdev_network->IELength = cpu_to_le32(sz); */ + /* notes: translate ie_length & length after assign the length to cmdsz in createbss_cmd(); */ + /* pdev_network->ie_length = cpu_to_le32(sz); */ } void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) @@ -2648,7 +2648,7 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) int do_join_r; if (0 < rtw_to_roam(padapter)) { - memcpy(&pmlmepriv->assoc_ssid, &cur_network->network.Ssid, sizeof(struct ndis_802_11_ssid)); + memcpy(&pmlmepriv->assoc_ssid, &cur_network->network.ssid, sizeof(struct ndis_802_11_ssid)); pmlmepriv->assoc_by_bssid = false; diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 2df8ed649519..e22301c01f40 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -538,7 +538,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) if (is_valid_p2p_probereq) goto _issue_probersp; - if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) + if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->ssid.Ssid, cur->ssid.SsidLength)) || (ielen == 0 && pmlmeinfo->hidden_ssid_mode) ) return _SUCCESS; @@ -634,7 +634,7 @@ unsigned int OnBeacon(struct adapter *padapter, union recv_frame *precv_frame) netdev_dbg(padapter->pnetdev, "ap has changed, disconnect now\n "); receive_disconnect(padapter, - pmlmeinfo->network.MacAddress, 0); + pmlmeinfo->network.mac_address, 0); return _SUCCESS; } /* update WMM, ERP in the beacon */ @@ -1022,10 +1022,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) goto OnAssocReqFail; } else { /* check if ssid match */ - if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + if (memcmp((void *)(p+2), cur->ssid.Ssid, cur->ssid.SsidLength)) status = WLAN_STATUS_CHALLENGE_FAIL; - if (ie_len != cur->Ssid.SsidLength) + if (ie_len != cur->ssid.SsidLength) status = WLAN_STATUS_CHALLENGE_FAIL; } @@ -1457,7 +1457,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ - UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); + UpdateBrateTbl(padapter, pmlmeinfo->network.supported_rates); report_assoc_result: if (res > 0) { @@ -2181,12 +2181,12 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) { int len_diff; - memcpy(pframe, cur_network->IEs, cur_network->IELength); + memcpy(pframe, cur_network->ies, cur_network->ie_length); len_diff = update_hidden_ssid(pframe+_BEACON_IE_OFFSET_, - cur_network->IELength-_BEACON_IE_OFFSET_, + cur_network->ie_length-_BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); - pframe += (cur_network->IELength+len_diff); - pattrib->pktlen += (cur_network->IELength+len_diff); + pframe += (cur_network->ie_length+len_diff); + pattrib->pktlen += (cur_network->ie_length+len_diff); } { @@ -2217,34 +2217,34 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->ies)), 2); pframe += 2; pattrib->pktlen += 2; /* capability info: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->ies)), 2); pframe += 2; pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.SsidLength, cur_network->ssid.Ssid, &pattrib->pktlen); /* supported rates... */ - rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + rate_len = rtw_get_rateset_len(cur_network->supported_rates); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->supported_rates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.DSConfig), &pattrib->pktlen); /* if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) */ { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ + /* ATIMWindow = cur->configuration.ATIMWindow; */ ATIMWindow = 0; pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); @@ -2255,7 +2255,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) { - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->supported_rates + 8), &pattrib->pktlen); } @@ -2314,7 +2314,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pwlanhdr = (struct ieee80211_hdr *)pframe; mac = myid(&(padapter->eeprompriv)); - bssid = cur_network->MacAddress; + bssid = cur_network->mac_address; fctrl = &(pwlanhdr->frame_control); *(fctrl) = 0; @@ -2331,24 +2331,24 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe += pattrib->hdrlen; - if (cur_network->IELength > MAX_IE_SZ) + if (cur_network->ie_length > MAX_IE_SZ) return; if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + pwps_ie = rtw_get_wps_ie(cur_network->ies+_FIXED_IE_LENGTH_, cur_network->ie_length-_FIXED_IE_LENGTH_, NULL, &wps_ielen); /* inerset & update wps_probe_resp_ie */ if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) { uint wps_offset, remainder_ielen; u8 *premainder_ie; - wps_offset = (uint)(pwps_ie - cur_network->IEs); + wps_offset = (uint)(pwps_ie - cur_network->ies); premainder_ie = pwps_ie + wps_ielen; - remainder_ielen = cur_network->IELength - wps_offset - wps_ielen; + remainder_ielen = cur_network->ie_length - wps_offset - wps_ielen; - memcpy(pframe, cur_network->IEs, wps_offset); + memcpy(pframe, cur_network->ies, wps_offset); pframe += wps_offset; pattrib->pktlen += wps_offset; @@ -2365,12 +2365,12 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pattrib->pktlen += remainder_ielen; } } else { - memcpy(pframe, cur_network->IEs, cur_network->IELength); - pframe += cur_network->IELength; - pattrib->pktlen += cur_network->IELength; + memcpy(pframe, cur_network->ies, cur_network->ie_length); + pframe += cur_network->ie_length; + pattrib->pktlen += cur_network->ie_length; } - /* retrieve SSID IE from cur_network->Ssid */ + /* retrieve SSID IE from cur_network->ssid */ { u8 *ssid_ie; signed int ssid_ielen; @@ -2385,9 +2385,9 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_); - ssid_ielen_diff = cur_network->Ssid.SsidLength - ssid_ielen; + ssid_ielen_diff = cur_network->ssid.SsidLength - ssid_ielen; - if (ssid_ie && cur_network->Ssid.SsidLength) { + if (ssid_ie && cur_network->ssid.SsidLength) { uint remainder_ielen; u8 *remainder_ie; @@ -2403,8 +2403,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p memcpy(buf, remainder_ie, remainder_ielen); memcpy(remainder_ie+ssid_ielen_diff, buf, remainder_ielen); - *(ssid_ie+1) = cur_network->Ssid.SsidLength; - memcpy(ssid_ie+2, cur_network->Ssid.Ssid, cur_network->Ssid.SsidLength); + *(ssid_ie+1) = cur_network->ssid.SsidLength; + memcpy(ssid_ie+2, cur_network->ssid.Ssid, cur_network->ssid.SsidLength); pframe += ssid_ielen_diff; pattrib->pktlen += ssid_ielen_diff; @@ -2418,14 +2418,14 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->ies)), 2); pframe += 2; pattrib->pktlen += 2; /* capability info: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->ies)), 2); pframe += 2; pattrib->pktlen += 2; @@ -2433,20 +2433,20 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.SsidLength, cur_network->ssid.Ssid, &pattrib->pktlen); /* supported rates... */ - rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + rate_len = rtw_get_rateset_len(cur_network->supported_rates); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->supported_rates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.DSConfig), &pattrib->pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ + /* ATIMWindow = cur->configuration.ATIMWindow; */ ATIMWindow = 0; pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); @@ -2457,7 +2457,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) { - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->supported_rates + 8), &pattrib->pktlen); } @@ -2748,7 +2748,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); - u8 *ie = pnetwork->IEs; + u8 *ie = pnetwork->ies; __le16 lestatus, le_tmp; pmgntframe = alloc_mgtxmitframe(pxmitpriv); @@ -2807,7 +2807,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* FILL HT CAP INFO IE */ /* p = hostapd_eid_ht_capabilities_info(hapd, p); */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); @@ -2816,7 +2816,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* FILL HT ADD INFO IE */ /* p = hostapd_eid_ht_operation(hapd, p); */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); @@ -2831,7 +2831,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; for (pbuf = ie + _BEACON_IE_OFFSET_; ; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2))); if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { memcpy(pframe, pbuf, ie_len+2); pframe += (ie_len+2); @@ -2910,7 +2910,7 @@ void issue_assocreq(struct adapter *padapter) pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); /* caps */ - memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.IEs), 2); + memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.ies), 2); pframe += 2; pattrib->pktlen += 2; @@ -2923,7 +2923,7 @@ void issue_assocreq(struct adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.ssid.SsidLength, pmlmeinfo->network.ssid.Ssid, &(pattrib->pktlen)); /* supported rate & extended supported rate */ @@ -2938,27 +2938,27 @@ void issue_assocreq(struct adapter *padapter) /* */ for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - if (pmlmeinfo->network.SupportedRates[i] == 0) + if (pmlmeinfo->network.supported_rates[i] == 0) break; } for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - if (pmlmeinfo->network.SupportedRates[i] == 0) + if (pmlmeinfo->network.supported_rates[i] == 0) break; /* Check if the AP's supported rates are also supported by STA. */ for (j = 0; j < sta_bssrate_len; j++) { /* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */ - if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK) + if ((pmlmeinfo->network.supported_rates[i] | IEEE80211_BASIC_RATE_MASK) == (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) break; } if (j != sta_bssrate_len) /* the rate is supported by STA */ - bssrate[index++] = pmlmeinfo->network.SupportedRates[i]; + bssrate[index++] = pmlmeinfo->network.supported_rates[i]; } bssrate_len = index; @@ -2977,8 +2977,8 @@ void issue_assocreq(struct adapter *padapter) pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &(pattrib->pktlen)); /* vendor specific IE, such as WPA, WMM, WPS */ - for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i); + for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.ie_length;) { + pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.ies + i); switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: @@ -3540,7 +3540,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch le_tmp = cpu_to_le16(BA_timeout_value); pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); - /* if ((psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress)) != NULL) */ + /* if ((psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.mac_address)) != NULL) */ psta = rtw_get_stainfo(pstapriv, raddr); if (psta) { start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; @@ -3705,13 +3705,13 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; - p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(pbss_network->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->ie_length - _FIXED_IE_LENGTH_); if ((p == NULL) || (len == 0)) {/* non-HT */ - if (pbss_network->Configuration.DSConfig <= 0) + if (pbss_network->configuration.DSConfig <= 0) continue; - ICS[0][pbss_network->Configuration.DSConfig] = 1; + ICS[0][pbss_network->configuration.DSConfig] = 1; if (ICS[0][0] == 0) ICS[0][0] = 1; @@ -3987,19 +3987,19 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str } } - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + bssid->length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; /* below is to copy the information element */ - bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + bssid->ie_length = len; + memcpy(bssid->ies, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->ie_length); /* get the signal strength */ - bssid->Rssi = precv_frame->u.hdr.attrib.phy_info.RecvSignalPower; /* in dBM.raw data */ - bssid->PhyInfo.SignalQuality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ + bssid->rssi = precv_frame->u.hdr.attrib.phy_info.RecvSignalPower; /* in dBM.raw data */ + bssid->phy_info.SignalQuality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ + bssid->phy_info.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ - p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_SSID, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SSID, &len, bssid->ie_length - ie_offset); if (!p) return _FAIL; @@ -4007,83 +4007,83 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str if (len > NDIS_802_11_LENGTH_SSID) return _FAIL; - memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); - bssid->Ssid.SsidLength = *(p + 1); + memcpy(bssid->ssid.Ssid, (p + 2), *(p + 1)); + bssid->ssid.SsidLength = *(p + 1); } else - bssid->Ssid.SsidLength = 0; + bssid->ssid.SsidLength = 0; - memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + memset(bssid->supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); /* checking rate info... */ i = 0; - p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_SUPP_RATES, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SUPP_RATES, &len, bssid->ie_length - ie_offset); if (p) { if (len > NDIS_802_11_LENGTH_RATES_EX) return _FAIL; - memcpy(bssid->SupportedRates, (p + 2), len); + memcpy(bssid->supported_rates, (p + 2), len); i = len; } - p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_EXT_SUPP_RATES, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_EXT_SUPP_RATES, &len, bssid->ie_length - ie_offset); if (p) { if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) return _FAIL; - memcpy(bssid->SupportedRates + i, (p + 2), len); + memcpy(bssid->supported_rates + i, (p + 2), len); } - bssid->NetworkTypeInUse = Ndis802_11OFDM24; + bssid->network_type_in_use = Ndis802_11OFDM24; - if (bssid->IELength < 12) + if (bssid->ie_length < 12) return _FAIL; /* Checking for DSConfig */ - p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_DS_PARAMS, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - ie_offset); - bssid->Configuration.DSConfig = 0; - bssid->Configuration.Length = 0; + bssid->configuration.DSConfig = 0; + bssid->configuration.Length = 0; if (p) { - bssid->Configuration.DSConfig = *(p + 2); + bssid->configuration.DSConfig = *(p + 2); } else { /* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ - p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_HT_OPERATION, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - ie_offset); if (p) { struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); - bssid->Configuration.DSConfig = HT_info->primary_channel; + bssid->configuration.DSConfig = HT_info->primary_channel; } else { /* use current channel */ - bssid->Configuration.DSConfig = rtw_get_oper_ch(padapter); + bssid->configuration.DSConfig = rtw_get_oper_ch(padapter); } } - memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->IEs), 2); - bssid->Configuration.BeaconPeriod = le32_to_cpu(le32_tmp); + memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->ies), 2); + bssid->configuration.BeaconPeriod = le32_to_cpu(le32_tmp); val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); if (val16 & BIT(0)) { - bssid->InfrastructureMode = Ndis802_11Infrastructure; - memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN); + bssid->infrastructure_mode = Ndis802_11Infrastructure; + memcpy(bssid->mac_address, GetAddr2Ptr(pframe), ETH_ALEN); } else { - bssid->InfrastructureMode = Ndis802_11IBSS; - memcpy(bssid->MacAddress, GetAddr3Ptr(pframe), ETH_ALEN); + bssid->infrastructure_mode = Ndis802_11IBSS; + memcpy(bssid->mac_address, GetAddr3Ptr(pframe), ETH_ALEN); } if (val16 & BIT(4)) - bssid->Privacy = 1; + bssid->privacy = 1; else - bssid->Privacy = 0; + bssid->privacy = 0; - bssid->Configuration.ATIMWindow = 0; + bssid->configuration.ATIMWindow = 0; /* 20/40 BSS Coexistence check */ if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - p = rtw_get_ie(bssid->IEs + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - ie_offset); + p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->ie_length - ie_offset); if (p && len > 0) { struct HT_caps_element *pHT_caps; @@ -4096,8 +4096,8 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str } /* mark bss info receiving from nearby channel as SignalQuality 101 */ - if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter)) - bssid->PhyInfo.SignalQuality = 101; + if (bssid->configuration.DSConfig != rtw_get_oper_ch(padapter)) + bssid->phy_info.SignalQuality = 101; return _SUCCESS; } @@ -4111,7 +4111,7 @@ void start_create_ibss(struct adapter *padapter) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); - pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeext->cur_channel = (u8)pnetwork->configuration.DSConfig; pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); /* update wireless mode */ @@ -4141,7 +4141,7 @@ void start_create_ibss(struct adapter *padapter) report_join_res(padapter, -1); pmlmeinfo->state = WIFI_FW_NULL_STATE; } else { - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.mac_address); join_type = 0; rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); @@ -4187,7 +4187,7 @@ void start_clnt_join(struct adapter *padapter) /* For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */ { /* To avoid connecting to AP fail during resume process, change retry count from 5 to 1 */ - issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 1, 100); + issue_deauth_ex(padapter, pnetwork->mac_address, WLAN_REASON_DEAUTH_LEAVING, 1, 100); } /* here wait for receiving the beacon to start auth */ @@ -4302,7 +4302,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid u8 noc; /* number of channel */ u8 j, k; - ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_COUNTRY, &len, bssid->IELength - _FIXED_IE_LENGTH_); + ie = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_COUNTRY, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (!ie) return; if (len < 6) @@ -4409,7 +4409,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid } /* If channel is used by AP, set channel scan type to active */ - channel = bssid->Configuration.DSConfig; + channel = bssid->configuration.DSConfig; chplan_new = pmlmeext->channel_set; i = 0; while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { @@ -4866,7 +4866,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* update IOT-related issue */ update_IOT_info(padapter); - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->supported_rates); /* BCN interval */ rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); @@ -4883,7 +4883,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* Set cur_channel&cur_bwmode&cur_ch_offset */ set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); + psta = rtw_get_stainfo(pstapriv, cur_network->mac_address); if (psta) { /* only for infra. mode */ pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; @@ -5047,7 +5047,7 @@ void linked_status_chk(struct adapter *padapter) /* Marked by Kurt 20130715 */ /* For WiDi 3.5 and latered on, they don't ask WiDi sink to do roaming, so we could not check rx limit that strictly. */ /* todo: To check why we under miracast session, rx_chk would be false */ - psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); + psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.mac_address); if (psta) { if (chk_ap_is_alive(padapter, psta) == false) rx_chk = _FAIL; @@ -5058,9 +5058,9 @@ void linked_status_chk(struct adapter *padapter) { if (rx_chk != _SUCCESS) { if (pmlmeext->retry == 0) { - issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress, 0, 0, 0, 0); - issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress, 0, 0, 0, 0); - issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress, 0, 0, 0, 0); + issue_probereq_ex(padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address, 0, 0, 0, 0); + issue_probereq_ex(padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address, 0, 0, 0, 0); + issue_probereq_ex(padapter, &pmlmeinfo->network.ssid, pmlmeinfo->network.mac_address, 0, 0, 0, 0); } } @@ -5075,7 +5075,7 @@ void linked_status_chk(struct adapter *padapter) netdev_dbg(padapter->pnetdev, FUNC_ADPT_FMT " disconnect or roaming\n", FUNC_ADPT_ARG(padapter)); - receive_disconnect(padapter, pmlmeinfo->network.MacAddress + receive_disconnect(padapter, pmlmeinfo->network.mac_address , WLAN_REASON_EXPIRATION_CHK); return; } @@ -5090,7 +5090,7 @@ void linked_status_chk(struct adapter *padapter) pmlmeinfo->link_count = 0; } - } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.MacAddress)) != NULL) */ + } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.mac_address)) != NULL) */ } else if (is_client_associated_to_ibss(padapter)) { /* linked IBSS mode */ /* for each assoc list entry to check the rx pkt counter */ @@ -5301,7 +5301,7 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) } /* below is for ad-hoc master */ - if (pparm->network.InfrastructureMode == Ndis802_11IBSS) { + if (pparm->network.infrastructure_mode == Ndis802_11IBSS) { rtw_joinbss_reset(padapter); pmlmeext->cur_bwmode = CHANNEL_WIDTH_20; @@ -5328,13 +5328,13 @@ u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) /* clear CAM */ flush_all_cam_entry(padapter); - memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); - pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, ie_length)); + pnetwork->ie_length = ((struct wlan_bssid_ex *)pbuf)->ie_length; - if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + if (pnetwork->ie_length > MAX_IE_SZ)/* Check pbuf->ie_length */ return H2C_PARAMETERS_ERROR; - memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); + memcpy(pnetwork->ies, ((struct wlan_bssid_ex *)pbuf)->ies, pnetwork->ie_length); start_create_ibss(padapter); @@ -5361,7 +5361,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* check already connecting to AP or not */ if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { if (pmlmeinfo->state & WIFI_FW_STATION_STATE) { - issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 1, 100); + issue_deauth_ex(padapter, pnetwork->mac_address, WLAN_REASON_DEAUTH_LEAVING, 1, 100); } pmlmeinfo->state = WIFI_FW_NULL_STATE; @@ -5393,23 +5393,23 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* pmlmeinfo->assoc_AP_vendor = HT_IOT_PEER_MAX; */ pmlmeinfo->VHT_enable = 0; - memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); - pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, ie_length)); + pnetwork->ie_length = ((struct wlan_bssid_ex *)pbuf)->ie_length; - if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + if (pnetwork->ie_length > MAX_IE_SZ)/* Check pbuf->ie_length */ return H2C_PARAMETERS_ERROR; - memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); + memcpy(pnetwork->ies, ((struct wlan_bssid_ex *)pbuf)->ies, pnetwork->ie_length); - pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeext->cur_channel = (u8)pnetwork->configuration.DSConfig; pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); /* Check AP vendor to move rtw_joinbss_cmd() */ - /* pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->IEs, pnetwork->IELength); */ + /* pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->ies, pnetwork->ie_length); */ /* sizeof(struct ndis_802_11_fix_ie) */ - for (i = _FIXED_IE_LENGTH_; i < pnetwork->IELength;) { - pIE = (struct ndis_80211_var_ie *)(pnetwork->IEs + i); + for (i = _FIXED_IE_LENGTH_; i < pnetwork->ie_length;) { + pIE = (struct ndis_80211_var_ie *)(pnetwork->ies + i); switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ @@ -5428,7 +5428,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) { struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); - if (pnetwork->Configuration.DSConfig <= 14) { + if (pnetwork->configuration.DSConfig <= 14) { if ((pregpriv->bw_mode & 0x0f) > CHANNEL_WIDTH_20) cbw40_enable = 1; } @@ -5473,7 +5473,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) /* initialgain = 0x1E; */ /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.mac_address); join_type = 0; rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); rtw_hal_set_hwreg(padapter, HW_VAR_DO_IQK, NULL); @@ -5498,7 +5498,7 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) u8 val8; if (is_client_associated_to_ap(padapter)) { - issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); + issue_deauth_ex(padapter, pnetwork->mac_address, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); } if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { @@ -5819,10 +5819,10 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) memcpy(&(ptxBeacon_parm->network), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); - len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, - ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, + len_diff = update_hidden_ssid(ptxBeacon_parm->network.ies+_BEACON_IE_OFFSET_, + ptxBeacon_parm->network.ie_length-_BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); - ptxBeacon_parm->network.IELength += len_diff; + ptxBeacon_parm->network.ie_length += len_diff; init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon)); diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 08f9ba9bf7ff..dfdeec2d0763 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -390,14 +390,14 @@ void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigne inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) { - return pnetwork->MacAddress; + return pnetwork->mac_address; } u16 get_beacon_interval(struct wlan_bssid_ex *bss) { __le16 val; - memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2); + memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->ies), 2); return le16_to_cpu(val); } @@ -964,7 +964,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ /* update ap's stainfo */ - psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); + psta = rtw_get_stainfo(pstapriv, cur_network->mac_address); if (psta) { struct ht_priv *phtpriv_sta = &psta->htpriv; @@ -1208,7 +1208,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (len > MAX_IE_SZ) return _FAIL; - if (memcmp(cur_network->network.MacAddress, pbssid, 6)) + if (memcmp(cur_network->network.mac_address, pbssid, 6)) return true; bssid = rtw_zmalloc(sizeof(struct wlan_bssid_ex)); @@ -1225,15 +1225,15 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (subtype == WIFI_BEACON) bssid->Reserved[0] = 1; - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + bssid->length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; /* below is to copy the information element */ - bssid->IELength = len; - memcpy(bssid->IEs, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->IELength); + bssid->ie_length = len; + memcpy(bssid->ies, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->ie_length); /* check bw and channel offset */ /* parsing HT_CAP_IE */ - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); ht_cap_info = le16_to_cpu(pht_cap->cap_info); @@ -1241,7 +1241,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) ht_cap_info = 0; } /* parsing HT_INFO_IE */ - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); ht_info_infos_0 = pht_info->infos[0]; @@ -1260,12 +1260,12 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } /* Checking for channel */ - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p) { bcn_channel = *(p + 2); } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ - rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, - &len, bssid->IELength - _FIXED_IE_LENGTH_); + rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, + &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (pht_info) bcn_channel = pht_info->primary_channel; else /* we don't find channel IE, so don't check it */ @@ -1277,52 +1277,52 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* checking SSID */ ssid_len = 0; - p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &len, bssid->IELength - _FIXED_IE_LENGTH_); + p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &len, bssid->ie_length - _FIXED_IE_LENGTH_); if (p) { ssid_len = *(p + 1); if (ssid_len > NDIS_802_11_LENGTH_SSID) ssid_len = 0; } - memcpy(bssid->Ssid.Ssid, (p + 2), ssid_len); - bssid->Ssid.SsidLength = ssid_len; + memcpy(bssid->ssid.Ssid, (p + 2), ssid_len); + bssid->ssid.SsidLength = ssid_len; - if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || - bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) - if (bssid->Ssid.Ssid[0] != '\0' && - bssid->Ssid.SsidLength != 0) /* not hidden ssid */ + if (memcmp(bssid->ssid.Ssid, cur_network->network.ssid.Ssid, 32) || + bssid->ssid.SsidLength != cur_network->network.ssid.SsidLength) + if (bssid->ssid.Ssid[0] != '\0' && + bssid->ssid.SsidLength != 0) /* not hidden ssid */ goto _mismatch; /* check encryption info */ val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); if (val16 & BIT(4)) - bssid->Privacy = 1; + bssid->privacy = 1; else - bssid->Privacy = 0; + bssid->privacy = 0; - if (cur_network->network.Privacy != bssid->Privacy) + if (cur_network->network.privacy != bssid->privacy) goto _mismatch; - rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len); + rtw_get_sec_ie(bssid->ies, bssid->ie_length, NULL, &rsn_len, NULL, &wpa_len); if (rsn_len > 0) encryp_protocol = ENCRYP_PROTOCOL_WPA2; else if (wpa_len > 0) encryp_protocol = ENCRYP_PROTOCOL_WPA; else - if (bssid->Privacy) + if (bssid->privacy) encryp_protocol = ENCRYP_PROTOCOL_WEP; if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) goto _mismatch; if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { - pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + pbuf = rtw_get_wpa_ie(&bssid->ies[12], &wpa_ielen, bssid->ie_length-12); if (pbuf && (wpa_ielen > 0)) { rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x); } else { - pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + pbuf = rtw_get_wpa2_ie(&bssid->ies[12], &wpa_ielen, bssid->ie_length-12); if (pbuf && (wpa_ielen > 0)) rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, @@ -1405,8 +1405,8 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.IELength;) { - pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.IEs + i); + for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.ie_length;) { + pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.ies + i); switch (pIE->ElementID) { case WLAN_EID_VENDOR_SPECIFIC: @@ -1629,7 +1629,7 @@ void update_wireless_mode(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); - unsigned char *rate = cur_network->SupportedRates; + unsigned char *rate = cur_network->supported_rates; if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) pmlmeinfo->HT_enable = 1; diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 8ec8f283893b..472005537b1b 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -580,7 +580,7 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf) struct wlan_bssid_ex *cur_network; cur_network = &padapter->mlmeextpriv.mlmext_info.network; - psta = rtw_get_stainfo(&padapter->stapriv, cur_network->MacAddress); + psta = rtw_get_stainfo(&padapter->stapriv, cur_network->mac_address); rtw_hal_update_ra_mask(psta, 0); } break; diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 4a112989899a..0df2b9b61cf8 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -923,7 +923,7 @@ u8 GetHalDefVar( pmlmepriv = &adapter->mlmepriv; pstapriv = &adapter->stapriv; - psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); + psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.mac_address); if (psta) *((int *)value) = psta->rssi_stat.UndecoratedSmoothedPWDB; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 2b7077bb52df..772760f34fd8 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -136,20 +136,20 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) pktlen += 8; /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->ies)), 2); pframe += 2; pktlen += 2; /* capability info: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->ies)), 2); pframe += 2; pktlen += 2; if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fix_ie); - memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fix_ie), pktlen); + pktlen += cur_network->ie_length - sizeof(struct ndis_802_11_fix_ie); + memcpy(pframe, cur_network->ies+sizeof(struct ndis_802_11_fix_ie), pktlen); goto _ConstructBeacon; } @@ -157,19 +157,19 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.SsidLength, cur_network->ssid.Ssid, &pktlen); /* supported rates... */ - rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); + rate_len = rtw_get_rateset_len(cur_network->supported_rates); + pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->supported_rates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.DSConfig), &pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ + /* ATIMWindow = cur->configuration.ATIMWindow; */ ATIMWindow = 0; pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pktlen); } @@ -180,7 +180,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* EXTERNDED SUPPORTED RATE */ if (rate_len > 8) - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->supported_rates + 8), &pktlen); /* todo:HT for adhoc */ @@ -247,7 +247,7 @@ static void ConstructNullFunctionData( if (bForcePowerSave) SetPwrMgt(fctrl); - switch (cur_network->network.InfrastructureMode) { + switch (cur_network->network.infrastructure_mode) { case Ndis802_11Infrastructure: SetToDs(fctrl); memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); diff --git a/drivers/staging/rtl8723bs/include/rtw_mlme.h b/drivers/staging/rtl8723bs/include/rtw_mlme.h index 5deb73fe3885..c94fa7d8d5a9 100644 --- a/drivers/staging/rtl8723bs/include/rtw_mlme.h +++ b/drivers/staging/rtl8723bs/include/rtw_mlme.h @@ -445,9 +445,9 @@ extern signed int rtw_set_key(struct adapter *adapter, struct security_priv *pse extern signed int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv); static inline u8 *get_bssid(struct mlme_priv *pmlmepriv) -{ /* if sta_mode:pmlmepriv->cur_network.network.MacAddress => bssid */ - /* if adhoc_mode:pmlmepriv->cur_network.network.MacAddress => ibss mac address */ - return pmlmepriv->cur_network.network.MacAddress; +{ /* if sta_mode:pmlmepriv->cur_network.network.mac_address => bssid */ + /* if adhoc_mode:pmlmepriv->cur_network.network.mac_address => ibss mac address */ + return pmlmepriv->cur_network.network.mac_address; } static inline signed int check_fwstate(struct mlme_priv *pmlmepriv, signed int state) diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index a45990bed80c..891bd2fca652 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -75,9 +75,9 @@ struct ndis_80211_var_ie { * sizeof (NDIS_802_11_MAC_ADDRESS) + 2 + * sizeof (struct ndis_802_11_ssid) + sizeof (u32) + * sizeof (long) + sizeof (enum ndis_802_11_network_type) + - * sizeof (struct ndis_802_11_conf) + sizeof (NDIS_802_11_RATES_EX) + IELength + * sizeof (struct ndis_802_11_conf) + sizeof (NDIS_802_11_RATES_EX) + ie_length * - * Except for IELength, all other fields are fixed length. Therefore, we can + * Except for ie_length, all other fields are fixed length. Therefore, we can * define a macro to present the partial sum. */ enum ndis_802_11_authentication_mode { @@ -174,24 +174,24 @@ struct wlan_bcn_info { * struct wlan_bssid_ex and get_wlan_bssid_ex_sz() */ struct wlan_bssid_ex { - u32 Length; - NDIS_802_11_MAC_ADDRESS MacAddress; + u32 length; + NDIS_802_11_MAC_ADDRESS mac_address; u8 Reserved[2];/* 0]: IS beacon frame */ - struct ndis_802_11_ssid Ssid; - u32 Privacy; - long Rssi;/* in dBM, raw data , get from PHY) */ - enum ndis_802_11_network_type NetworkTypeInUse; - struct ndis_802_11_conf Configuration; - enum ndis_802_11_network_infrastructure InfrastructureMode; - NDIS_802_11_RATES_EX SupportedRates; - struct wlan_phy_info PhyInfo; - u32 IELength; - u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and capability information) */ + struct ndis_802_11_ssid ssid; + u32 privacy; + long rssi;/* in dBM, raw data , get from PHY) */ + enum ndis_802_11_network_type network_type_in_use; + struct ndis_802_11_conf configuration; + enum ndis_802_11_network_infrastructure infrastructure_mode; + NDIS_802_11_RATES_EX supported_rates; + struct wlan_phy_info phy_info; + u32 ie_length; + u8 ies[MAX_IE_SZ]; /* timestamp, beacon interval, and capability information) */ } __packed; static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) { - return (sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->IELength); + return (sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->ie_length); } struct wlan_network { diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 368e575c24af..015f68553164 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -231,14 +231,14 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl struct wiphy *wiphy = wdev->wiphy; struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - bssinf_len = pnetwork->network.IELength + sizeof(struct ieee80211_hdr_3addr); + bssinf_len = pnetwork->network.ie_length + sizeof(struct ieee80211_hdr_3addr); if (bssinf_len > MAX_BSSINFO_LEN) goto exit; { u16 wapi_len = 0; - if (rtw_get_wapi_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &wapi_len) > 0) + if (rtw_get_wapi_ie(pnetwork->network.ies, pnetwork->network.ie_length, NULL, &wapi_len) > 0) { if (wapi_len > 0) goto exit; @@ -250,13 +250,13 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl if (adapter_wdev_data(padapter)->scan_request) { u8 *psr = NULL, sr = 0; - struct ndis_802_11_ssid *pssid = &pnetwork->network.Ssid; + struct ndis_802_11_ssid *pssid = &pnetwork->network.ssid; struct cfg80211_scan_request *request = adapter_wdev_data(padapter)->scan_request; struct cfg80211_ssid *ssids = request->ssids; u32 wpsielen = 0; u8 *wpsie = NULL; - wpsie = rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wpsielen); + wpsie = rtw_get_wps_ie(pnetwork->network.ies+_FIXED_IE_LENGTH_, pnetwork->network.ie_length-_FIXED_IE_LENGTH_, NULL, &wpsielen); if (wpsie && wpsielen > 0) psr = rtw_get_wps_attr_content(wpsie, wpsielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); @@ -278,7 +278,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl /* spin_unlock_bh(&pwdev_priv->scan_req_lock); */ - channel = pnetwork->network.Configuration.DSConfig; + channel = pnetwork->network.configuration.DSConfig; freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); notify_channel = ieee80211_get_channel(wiphy, freq); @@ -290,7 +290,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) { notify_signal = 100*translate_percentage_to_dbm(padapter->recvpriv.signal_strength);/* dbm */ } else { - notify_signal = 100*translate_percentage_to_dbm(pnetwork->network.PhyInfo.SignalStrength);/* dbm */ + notify_signal = 100*translate_percentage_to_dbm(pnetwork->network.phy_info.SignalStrength);/* dbm */ } buf = kzalloc(MAX_BSSINFO_LEN, GFP_ATOMIC); @@ -313,15 +313,15 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl SetFrameSubType(pbuf, WIFI_PROBERSP); } - memcpy(pwlanhdr->addr2, pnetwork->network.MacAddress, ETH_ALEN); - memcpy(pwlanhdr->addr3, pnetwork->network.MacAddress, ETH_ALEN); + memcpy(pwlanhdr->addr2, pnetwork->network.mac_address, ETH_ALEN); + memcpy(pwlanhdr->addr3, pnetwork->network.mac_address, ETH_ALEN); pbuf += sizeof(struct ieee80211_hdr_3addr); len = sizeof(struct ieee80211_hdr_3addr); - memcpy(pbuf, pnetwork->network.IEs, pnetwork->network.IELength); - len += pnetwork->network.IELength; + memcpy(pbuf, pnetwork->network.ies, pnetwork->network.ie_length); + len += pnetwork->network.ie_length; *((__le64 *)pbuf) = cpu_to_le64(notify_timestamp); @@ -355,12 +355,12 @@ int rtw_cfg80211_check_bss(struct adapter *padapter) if (!(pnetwork) || !(padapter->rtw_wdev)) return false; - freq = rtw_ieee80211_channel_to_frequency(pnetwork->Configuration.DSConfig, NL80211_BAND_2GHZ); + freq = rtw_ieee80211_channel_to_frequency(pnetwork->configuration.DSConfig, NL80211_BAND_2GHZ); notify_channel = ieee80211_get_channel(padapter->rtw_wdev->wiphy, freq); bss = cfg80211_get_bss(padapter->rtw_wdev->wiphy, notify_channel, - pnetwork->MacAddress, pnetwork->Ssid.Ssid, - pnetwork->Ssid.SsidLength, + pnetwork->mac_address, pnetwork->ssid.Ssid, + pnetwork->ssid.SsidLength, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); cfg80211_put_bss(padapter->rtw_wdev->wiphy, bss); @@ -374,7 +374,7 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter) struct wlan_network *cur_network = &(pmlmepriv->cur_network); struct wireless_dev *pwdev = padapter->rtw_wdev; struct wiphy *wiphy = pwdev->wiphy; - int freq = (int)cur_network->network.Configuration.DSConfig; + int freq = (int)cur_network->network.configuration.DSConfig; struct ieee80211_channel *chan; if (pwdev->iftype != NL80211_IFTYPE_ADHOC) @@ -398,8 +398,8 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter) rtw_warn_on(1); return; } - if (!memcmp(&(scanned->network.Ssid), &(pnetwork->Ssid), sizeof(struct ndis_802_11_ssid)) - && !memcmp(scanned->network.MacAddress, pnetwork->MacAddress, sizeof(NDIS_802_11_MAC_ADDRESS)) + if (!memcmp(&(scanned->network.ssid), &(pnetwork->ssid), sizeof(struct ndis_802_11_ssid)) + && !memcmp(scanned->network.mac_address, pnetwork->mac_address, sizeof(NDIS_802_11_MAC_ADDRESS)) ) rtw_cfg80211_inform_bss(padapter, scanned); else @@ -413,7 +413,7 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter) } /* notify cfg80211 that device joined an IBSS */ chan = ieee80211_get_channel(wiphy, freq); - cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.MacAddress, chan, GFP_ATOMIC); + cfg80211_ibss_joined(padapter->pnetdev, cur_network->network.mac_address, chan, GFP_ATOMIC); } void rtw_cfg80211_indicate_connect(struct adapter *padapter) @@ -440,8 +440,8 @@ void rtw_cfg80211_indicate_connect(struct adapter *padapter) goto check_bss; } - if (!memcmp(scanned->network.MacAddress, pnetwork->MacAddress, sizeof(NDIS_802_11_MAC_ADDRESS)) - && !memcmp(&(scanned->network.Ssid), &(pnetwork->Ssid), sizeof(struct ndis_802_11_ssid)) + if (!memcmp(scanned->network.mac_address, pnetwork->mac_address, sizeof(NDIS_802_11_MAC_ADDRESS)) + && !memcmp(&(scanned->network.ssid), &(pnetwork->ssid), sizeof(struct ndis_802_11_ssid)) ) rtw_cfg80211_inform_bss(padapter, scanned); else @@ -458,7 +458,7 @@ check_bss: struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; u32 freq; - u16 channel = cur_network->network.Configuration.DSConfig; + u16 channel = cur_network->network.configuration.DSConfig; struct cfg80211_roam_info roam_info = {}; freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); @@ -466,7 +466,7 @@ check_bss: notify_channel = ieee80211_get_channel(wiphy, freq); roam_info.channel = notify_channel; - roam_info.bssid = cur_network->network.MacAddress; + roam_info.bssid = cur_network->network.mac_address; roam_info.req_ie = pmlmepriv->assoc_req+sizeof(struct ieee80211_hdr_3addr)+2; roam_info.req_ie_len = @@ -479,7 +479,7 @@ check_bss: } else { - cfg80211_connect_result(padapter->pnetdev, cur_network->network.MacAddress + cfg80211_connect_result(padapter->pnetdev, cur_network->network.mac_address , pmlmepriv->assoc_req+sizeof(struct ieee80211_hdr_3addr)+2 , pmlmepriv->assoc_req_len-sizeof(struct ieee80211_hdr_3addr)-2 , pmlmepriv->assoc_rsp+sizeof(struct ieee80211_hdr_3addr)+6 @@ -1113,7 +1113,7 @@ static int cfg80211_rtw_get_station(struct wiphy *wiphy, { struct wlan_network *cur_network = &(pmlmepriv->cur_network); - if (memcmp((u8 *)mac, cur_network->network.MacAddress, ETH_ALEN)) { + if (memcmp((u8 *)mac, cur_network->network.mac_address, ETH_ALEN)) { ret = -ENOENT; goto exit; } @@ -1241,8 +1241,8 @@ void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnet struct wlan_bssid_ex *select_network = &pnetwork->network; bss = cfg80211_get_bss(wiphy, NULL/*notify_channel*/, - select_network->MacAddress, select_network->Ssid.Ssid, - select_network->Ssid.SsidLength, 0/*WLAN_CAPABILITY_ESS*/, + select_network->mac_address, select_network->ssid.Ssid, + select_network->ssid.SsidLength, 0/*WLAN_CAPABILITY_ESS*/, 0/*WLAN_CAPABILITY_ESS*/); if (bss) { @@ -1266,8 +1266,8 @@ void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter) pnetwork = list_entry(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0 - && true == rtw_validate_ssid(&(pnetwork->network.Ssid)) + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.DSConfig) >= 0 + && true == rtw_validate_ssid(&(pnetwork->network.ssid)) ) { /* ev =translate_scan(padapter, a, pnetwork, ev, stop); */ @@ -2435,7 +2435,7 @@ static int rtw_add_beacon(struct adapter *adapter, const u8 *head, size_t head_l /* check wps ie if inclued */ rtw_get_wps_ie(pbuf + _FIXED_IE_LENGTH_, len - _FIXED_IE_LENGTH_, NULL, &wps_ielen); - /* pbss_network->IEs will not include p2p_ie, wfd ie */ + /* pbss_network->ies will not include p2p_ie, wfd ie */ rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, P2P_OUI, 4); rtw_ies_remove_ie(pbuf, &len, _BEACON_IE_OFFSET_, WLAN_EID_VENDOR_SPECIFIC, WFD_OUI, 4); @@ -2466,10 +2466,10 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, struct wlan_bssid_ex *pbss_network = &adapter->mlmepriv.cur_network.network; struct wlan_bssid_ex *pbss_network_ext = &adapter->mlmeextpriv.mlmext_info.network; - memcpy(pbss_network->Ssid.Ssid, (void *)settings->ssid, settings->ssid_len); - pbss_network->Ssid.SsidLength = settings->ssid_len; - memcpy(pbss_network_ext->Ssid.Ssid, (void *)settings->ssid, settings->ssid_len); - pbss_network_ext->Ssid.SsidLength = settings->ssid_len; + memcpy(pbss_network->ssid.Ssid, (void *)settings->ssid, settings->ssid_len); + pbss_network->ssid.SsidLength = settings->ssid_len; + memcpy(pbss_network_ext->ssid.Ssid, (void *)settings->ssid, settings->ssid_len); + pbss_network_ext->ssid.SsidLength = settings->ssid_len; } return ret; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 060cdd7b2925..bda02f4f74db 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -54,9 +54,9 @@ void rtw_indicate_wx_assoc_event(struct adapter *padapter) wrqu.ap_addr.sa_family = ARPHRD_ETHER; if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) - memcpy(wrqu.ap_addr.sa_data, pnetwork->MacAddress, ETH_ALEN); + memcpy(wrqu.ap_addr.sa_data, pnetwork->mac_address, ETH_ALEN); else - memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN); + memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.mac_address, ETH_ALEN); netdev_dbg(padapter->pnetdev, "assoc success\n"); } @@ -92,20 +92,20 @@ static char *translate_scan(struct adapter *padapter, iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN); + memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.mac_address, ETH_ALEN); start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - iwe.u.data.length = min((u16)pnetwork->network.Ssid.SsidLength, (u16)32); - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); + iwe.u.data.length = min((u16)pnetwork->network.ssid.SsidLength, (u16)32); + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.Ssid); /* parsing HT_CAP_IE */ if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ - p = rtw_get_ie(&pnetwork->network.IEs[0], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.IELength); + p = rtw_get_ie(&pnetwork->network.ies[0], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length); } else { - p = rtw_get_ie(&pnetwork->network.IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.IELength-12); + p = rtw_get_ie(&pnetwork->network.ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length-12); } if (p && ht_ielen > 0) { struct ieee80211_ht_cap *pht_capie; @@ -118,18 +118,18 @@ static char *translate_scan(struct adapter *padapter, /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; - if (rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates)) { + if (rtw_is_cckratesonly_included((u8 *)&pnetwork->network.supported_rates)) { if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); - } else if (rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates)) { + } else if (rtw_is_cckrates_included((u8 *)&pnetwork->network.supported_rates)) { if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pnetwork->network.Configuration.DSConfig <= 14) { + if (pnetwork->network.configuration.DSConfig <= 14) { if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); else @@ -146,7 +146,7 @@ static char *translate_scan(struct adapter *padapter, __le16 le_tmp; iwe.cmd = SIOCGIWMODE; - memcpy((u8 *)&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); + memcpy((u8 *)&le_tmp, rtw_get_capability_from_ie(pnetwork->network.ies), 2); cap = le16_to_cpu(le_tmp); } @@ -159,14 +159,14 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); } - if (pnetwork->network.Configuration.DSConfig < 1) - pnetwork->network.Configuration.DSConfig = 1; + if (pnetwork->network.configuration.DSConfig < 1) + pnetwork->network.configuration.DSConfig = 1; /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; - iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000; + iwe.u.freq.m = rtw_ch2freq(pnetwork->network.configuration.DSConfig) * 100000; iwe.u.freq.e = 1; - iwe.u.freq.i = pnetwork->network.Configuration.DSConfig; + iwe.u.freq.i = pnetwork->network.configuration.DSConfig; start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); /* Add encryption capability */ @@ -176,7 +176,7 @@ static char *translate_scan(struct adapter *padapter, else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.Ssid); /*Add basic and extended rates */ max_rate = 0; @@ -185,8 +185,8 @@ static char *translate_scan(struct adapter *padapter, return start; p = custom; p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - while (pnetwork->network.SupportedRates[i] != 0) { - rate = pnetwork->network.SupportedRates[i]&0x7F; + while (pnetwork->network.supported_rates[i] != 0) { + rate = pnetwork->network.supported_rates[i]&0x7F; if (rate > max_rate) max_rate = rate; p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), @@ -216,7 +216,7 @@ static char *translate_scan(struct adapter *padapter, u8 wpa_ie[255], rsn_ie[255]; u16 wpa_len = 0, rsn_len = 0; u8 *p; - rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); + rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len); buf = kzalloc(MAX_WPA_IE_LEN*2, GFP_ATOMIC); if (!buf) @@ -272,14 +272,14 @@ static char *translate_scan(struct adapter *padapter, uint wps_ielen = 0; u8 *ie_ptr; - total_ielen = pnetwork->network.IELength - ie_offset; + total_ielen = pnetwork->network.ie_length - ie_offset; if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ - ie_ptr = pnetwork->network.IEs; - total_ielen = pnetwork->network.IELength; + ie_ptr = pnetwork->network.ies; + total_ielen = pnetwork->network.ie_length; } else { /* Beacon or Probe Respones */ - ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_; - total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_; + ie_ptr = pnetwork->network.ies + _FIXED_IE_LENGTH_; + total_ielen = pnetwork->network.ie_length - _FIXED_IE_LENGTH_; } while (cnt < total_ielen) { @@ -303,8 +303,8 @@ static char *translate_scan(struct adapter *padapter, ss = padapter->recvpriv.signal_strength; sq = padapter->recvpriv.signal_qual; } else { - ss = pnetwork->network.PhyInfo.SignalStrength; - sq = pnetwork->network.PhyInfo.SignalQuality; + ss = pnetwork->network.phy_info.SignalStrength; + sq = pnetwork->network.phy_info.SignalQuality; } @@ -683,11 +683,11 @@ static int rtw_wx_get_name(struct net_device *dev, if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->IEs[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->IELength-12); + p = rtw_get_ie(&pcur_bss->ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->ie_length-12); if (p && ht_ielen > 0) ht_cap = true; - prates = &pcur_bss->SupportedRates; + prates = &pcur_bss->supported_rates; if (rtw_is_cckratesonly_included((u8 *)prates)) { if (ht_cap) @@ -700,7 +700,7 @@ static int rtw_wx_get_name(struct net_device *dev, else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pcur_bss->Configuration.DSConfig <= 14) { + if (pcur_bss->configuration.DSConfig <= 14) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); else @@ -708,7 +708,7 @@ static int rtw_wx_get_name(struct net_device *dev, } } } else { - /* prates = &padapter->registrypriv.dev_network.SupportedRates; */ + /* prates = &padapter->registrypriv.dev_network.supported_rates; */ /* snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); */ snprintf(wrqu->name, IFNAMSIZ, "unassociated"); } @@ -731,10 +731,10 @@ static int rtw_wx_get_freq(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ - wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; + /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->configuration.DSConfig-1] * 100000; */ + wrqu->freq.m = rtw_ch2freq(pcur_bss->configuration.DSConfig) * 100000; wrqu->freq.e = 1; - wrqu->freq.i = pcur_bss->Configuration.DSConfig; + wrqu->freq.i = pcur_bss->configuration.DSConfig; } else { wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; @@ -1044,12 +1044,12 @@ static int rtw_wx_set_wap(struct net_device *dev, pnetwork = list_entry(pmlmepriv->pscanned, struct wlan_network, list); - dst_bssid = pnetwork->network.MacAddress; + dst_bssid = pnetwork->network.mac_address; src_bssid = temp->sa_data; if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { - if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.infrastructure_mode)) { ret = -1; spin_unlock_bh(&queue->lock); goto exit; @@ -1090,7 +1090,7 @@ static int rtw_wx_get_wap(struct net_device *dev, if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) { - memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); + memcpy(wrqu->ap_addr.sa_data, pcur_bss->mac_address, ETH_ALEN); } else { eth_zero_addr(wrqu->ap_addr.sa_data); } @@ -1290,8 +1290,8 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, pnetwork = list_entry(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0 - && true == rtw_validate_ssid(&(pnetwork->network.Ssid))) { + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.DSConfig) >= 0 + && true == rtw_validate_ssid(&(pnetwork->network.ssid))) { ev = translate_scan(padapter, a, pnetwork, ev, stop); } @@ -1365,16 +1365,16 @@ static int rtw_wx_set_essid(struct net_device *dev, pnetwork = list_entry(pmlmepriv->pscanned, struct wlan_network, list); - dst_ssid = pnetwork->network.Ssid.Ssid; + dst_ssid = pnetwork->network.ssid.Ssid; if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && - (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { + (pnetwork->network.ssid.SsidLength == ndis_ssid.SsidLength)) { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + if (pnetwork->network.infrastructure_mode != pmlmepriv->cur_network.network.infrastructure_mode) continue; } - if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode) == false) { + if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.infrastructure_mode) == false) { ret = -1; spin_unlock_bh(&queue->lock); goto exit; @@ -1410,11 +1410,11 @@ static int rtw_wx_get_essid(struct net_device *dev, if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - len = pcur_bss->Ssid.SsidLength; + len = pcur_bss->ssid.SsidLength; wrqu->essid.length = len; - memcpy(extra, pcur_bss->Ssid.Ssid, len); + memcpy(extra, pcur_bss->ssid.Ssid, len); wrqu->essid.flags = 1; } else { @@ -2229,15 +2229,15 @@ static int rtw_get_ap_info(struct net_device *dev, } - if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */ + if (!memcmp(bssid, pnetwork->network.mac_address, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */ - pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length-12); if (pbuf && (wpa_ielen > 0)) { pdata->flags = 1; break; } - pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa2_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length-12); if (pbuf && (wpa_ielen > 0)) { pdata->flags = 2; break; @@ -2473,7 +2473,7 @@ static int rtw_dbg_port(struct net_device *dev, } break; case 0x7a: - receive_disconnect(padapter, pmlmeinfo->network.MacAddress + receive_disconnect(padapter, pmlmeinfo->network.mac_address , WLAN_REASON_EXPIRATION_CHK); break; case 0x7F: @@ -3530,10 +3530,10 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, memcpy(ssid, ssid_ie+2, ssid_len); ssid[ssid_len] = 0x0; - memcpy(pbss_network->Ssid.Ssid, (void *)ssid, ssid_len); - pbss_network->Ssid.SsidLength = ssid_len; - memcpy(pbss_network_ext->Ssid.Ssid, (void *)ssid, ssid_len); - pbss_network_ext->Ssid.SsidLength = ssid_len; + memcpy(pbss_network->ssid.Ssid, (void *)ssid, ssid_len); + pbss_network->ssid.SsidLength = ssid_len; + memcpy(pbss_network_ext->ssid.Ssid, (void *)ssid, ssid_len); + pbss_network_ext->ssid.SsidLength = ssid_len; } return ret; -- cgit v1.2.3 From d8b322b60da60f3d5957565d5db0d1dc18fe727b Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:15 +0200 Subject: staging: rtl8723bs: fix camel case in struct ndis_802_11_conf fix camel case in struct ndis_802_11_conf Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/90317df66de1476515bf46477ac097a73f35cf81.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 18 ++++++------ drivers/staging/rtl8723bs/core/rtw_cmd.c | 6 ++-- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 6 ++-- drivers/staging/rtl8723bs/core/rtw_mlme.c | 20 ++++++------- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 34 +++++++++++------------ drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 10 +++---- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 10 +++---- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 20 ++++++------- 9 files changed, 63 insertions(+), 63 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 6adefdbb7407..f821863c845d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -340,7 +340,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) shortGIrate = query_ra_short_GI(psta); - if (pcur_network->configuration.DSConfig > 14) { + if (pcur_network->configuration.ds_config > 14) { sta_band |= WIRELESS_INVALID; } else { if (tx_ra_bitmap & 0xffff000) @@ -400,13 +400,13 @@ void update_bmc_sta(struct adapter *padapter) supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->supported_rates); network_type = rtw_check_network_type((u8 *)&pcur_network->supported_rates, supportRateNum, - pcur_network->configuration.DSConfig + pcur_network->configuration.ds_config ); if (is_supported_tx_cck(network_type)) { network_type = WIRELESS_11B; } else if (network_type == WIRELESS_INVALID) { /* error handling */ - if (pcur_network->configuration.DSConfig > 14) + if (pcur_network->configuration.ds_config > 14) network_type = WIRELESS_INVALID; else network_type = WIRELESS_11B; @@ -656,8 +656,8 @@ void start_bss_network(struct adapter *padapter) struct HT_info_element *pht_info = NULL; u8 cbw40_enable = 0; - bcn_interval = (u16)pnetwork->configuration.BeaconPeriod; - cur_channel = pnetwork->configuration.DSConfig; + bcn_interval = (u16)pnetwork->configuration.beacon_period; + cur_channel = pnetwork->configuration.ds_config; cur_bwmode = CHANNEL_WIDTH_20; cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; @@ -850,8 +850,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* beacon interval */ p = rtw_get_beacon_interval_from_ie(ie);/* ie + 8; 8: TimeStamp, 2: Beacon Interval 2:Capability */ - /* pbss_network->configuration.BeaconPeriod = le16_to_cpu(*(unsigned short*)p); */ - pbss_network->configuration.BeaconPeriod = get_unaligned_le16(p); + /* pbss_network->configuration.beacon_period = le16_to_cpu(*(unsigned short*)p); */ + pbss_network->configuration.beacon_period = get_unaligned_le16(p); /* capability */ /* cap = *(unsigned short *)rtw_get_capability_from_ie(ie); */ @@ -873,7 +873,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* channel */ channel = 0; - pbss_network->configuration.Length = 0; + pbss_network->configuration.length = 0; p = rtw_get_ie( ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, @@ -882,7 +882,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if (p && ie_len > 0) channel = *(p + 2); - pbss_network->configuration.DSConfig = channel; + pbss_network->configuration.ds_config = channel; memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 865b42699335..33d8ca8be08e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -810,7 +810,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) /* rtw_restructure_ht_ie */ rtw_restructure_ht_ie(padapter, &pnetwork->network.ies[12], &psecnetwork->ies[0], pnetwork->network.ie_length-12, &psecnetwork->ie_length, - pnetwork->network.configuration.DSConfig); + pnetwork->network.configuration.ds_config); } } @@ -2004,8 +2004,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) /* copy pdev_network information to pmlmepriv->cur_network */ memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork))); - /* reset DSConfig */ - /* tgt_network->network.configuration.DSConfig = (u32)rtw_ch2freq(pnetwork->configuration.DSConfig); */ + /* reset ds_config */ + /* tgt_network->network.configuration.ds_config = (u32)rtw_ch2freq(pnetwork->configuration.ds_config); */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index fb15c9531ba8..b133c3738dc9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -298,7 +298,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) ie += sz; /* beacon interval : 2bytes */ - *(__le16 *)ie = cpu_to_le16((u16)pdev_network->configuration.BeaconPeriod);/* BCN_INTERVAL; */ + *(__le16 *)ie = cpu_to_le16((u16)pdev_network->configuration.beacon_period);/* BCN_INTERVAL; */ sz += 2; ie += 2; @@ -334,11 +334,11 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) } /* DS parameter set */ - ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&(pdev_network->configuration.DSConfig), &sz); + ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&(pdev_network->configuration.ds_config), &sz); /* IBSS Parameter Set */ - ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&(pdev_network->configuration.ATIMWindow), &sz); + ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&(pdev_network->configuration.atim_window), &sz); if (rateLen > 8) { ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->supported_rates + 8), &sz); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index c994f6335bdc..f189cd6c11ac 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -396,7 +396,7 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 fea d_cap = le16_to_cpu(tmpd); return (src->ssid.SsidLength == dst->ssid.SsidLength) && - /* (src->configuration.DSConfig == dst->configuration.DSConfig) && */ + /* (src->configuration.ds_config == dst->configuration.ds_config) && */ ((!memcmp(src->mac_address, dst->mac_address, ETH_ALEN))) && ((!memcmp(src->ssid.Ssid, dst->ssid.Ssid, src->ssid.SsidLength))) && ((s_cap & WLAN_CAPABILITY_IBSS) == @@ -1148,7 +1148,7 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net rtw_update_protection(padapter, (cur_network->network.ies) + sizeof(struct ndis_802_11_fix_ie), (cur_network->network.ie_length)); - rtw_update_ht_cap(padapter, cur_network->network.ies, cur_network->network.ie_length, (u8) cur_network->network.configuration.DSConfig); + rtw_update_ht_cap(padapter, cur_network->network.ies, cur_network->network.ie_length, (u8) cur_network->network.configuration.ds_config); } /* Notes: the function could be > passive_level (the same context as Rx tasklet) */ @@ -2152,12 +2152,12 @@ void rtw_init_registrypriv_dev_network(struct adapter *adapter) memcpy(&pdev_network->ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); - pdev_network->configuration.Length = sizeof(struct ndis_802_11_conf); - pdev_network->configuration.BeaconPeriod = 100; - pdev_network->configuration.FHConfig.Length = 0; - pdev_network->configuration.FHConfig.HopPattern = 0; - pdev_network->configuration.FHConfig.HopSet = 0; - pdev_network->configuration.FHConfig.DwellTime = 0; + pdev_network->configuration.length = sizeof(struct ndis_802_11_conf); + pdev_network->configuration.beacon_period = 100; + pdev_network->configuration.fh_config.Length = 0; + pdev_network->configuration.fh_config.HopPattern = 0; + pdev_network->configuration.fh_config.HopSet = 0; + pdev_network->configuration.fh_config.DwellTime = 0; } void rtw_update_registrypriv_dev_network(struct adapter *adapter) @@ -2189,10 +2189,10 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) break; } - pdev_network->configuration.DSConfig = (pregistrypriv->channel); + pdev_network->configuration.ds_config = (pregistrypriv->channel); if (cur_network->network.infrastructure_mode == Ndis802_11IBSS) - pdev_network->configuration.ATIMWindow = (0); + pdev_network->configuration.atim_window = (0); pdev_network->infrastructure_mode = (cur_network->network.infrastructure_mode); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index e22301c01f40..537b60f7b7db 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -2237,7 +2237,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->supported_rates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.ds_config), &pattrib->pktlen); /* if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) */ { @@ -2440,7 +2440,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->supported_rates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.ds_config), &pattrib->pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; @@ -3708,10 +3708,10 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) p = rtw_get_ie(pbss_network->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->ie_length - _FIXED_IE_LENGTH_); if ((p == NULL) || (len == 0)) {/* non-HT */ - if (pbss_network->configuration.DSConfig <= 0) + if (pbss_network->configuration.ds_config <= 0) continue; - ICS[0][pbss_network->configuration.DSConfig] = 1; + ICS[0][pbss_network->configuration.ds_config] = 1; if (ICS[0][0] == 0) ICS[0][0] = 1; @@ -4038,14 +4038,14 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str if (bssid->ie_length < 12) return _FAIL; - /* Checking for DSConfig */ + /* Checking for ds_config */ p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - ie_offset); - bssid->configuration.DSConfig = 0; - bssid->configuration.Length = 0; + bssid->configuration.ds_config = 0; + bssid->configuration.length = 0; if (p) { - bssid->configuration.DSConfig = *(p + 2); + bssid->configuration.ds_config = *(p + 2); } else { /* In 5G, some ap do not have DSSET IE */ /* checking HT info for channel */ @@ -4053,14 +4053,14 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str if (p) { struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); - bssid->configuration.DSConfig = HT_info->primary_channel; + bssid->configuration.ds_config = HT_info->primary_channel; } else { /* use current channel */ - bssid->configuration.DSConfig = rtw_get_oper_ch(padapter); + bssid->configuration.ds_config = rtw_get_oper_ch(padapter); } } memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->ies), 2); - bssid->configuration.BeaconPeriod = le32_to_cpu(le32_tmp); + bssid->configuration.beacon_period = le32_to_cpu(le32_tmp); val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); @@ -4077,7 +4077,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str else bssid->privacy = 0; - bssid->configuration.ATIMWindow = 0; + bssid->configuration.atim_window = 0; /* 20/40 BSS Coexistence check */ if ((pregistrypriv->wifi_spec == 1) && (false == pmlmeinfo->bwmode_updated)) { @@ -4096,7 +4096,7 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str } /* mark bss info receiving from nearby channel as SignalQuality 101 */ - if (bssid->configuration.DSConfig != rtw_get_oper_ch(padapter)) + if (bssid->configuration.ds_config != rtw_get_oper_ch(padapter)) bssid->phy_info.SignalQuality = 101; return _SUCCESS; @@ -4111,7 +4111,7 @@ void start_create_ibss(struct adapter *padapter) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); - pmlmeext->cur_channel = (u8)pnetwork->configuration.DSConfig; + pmlmeext->cur_channel = (u8)pnetwork->configuration.ds_config; pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); /* update wireless mode */ @@ -4409,7 +4409,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid } /* If channel is used by AP, set channel scan type to active */ - channel = bssid->configuration.DSConfig; + channel = bssid->configuration.ds_config; chplan_new = pmlmeext->channel_set; i = 0; while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { @@ -5401,7 +5401,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) memcpy(pnetwork->ies, ((struct wlan_bssid_ex *)pbuf)->ies, pnetwork->ie_length); - pmlmeext->cur_channel = (u8)pnetwork->configuration.DSConfig; + pmlmeext->cur_channel = (u8)pnetwork->configuration.ds_config; pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); /* Check AP vendor to move rtw_joinbss_cmd() */ @@ -5428,7 +5428,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) { struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); - if (pnetwork->configuration.DSConfig <= 14) { + if (pnetwork->configuration.ds_config <= 14) { if ((pregpriv->bw_mode & 0x0f) > CHANNEL_WIDTH_20) cbw40_enable = 1; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 772760f34fd8..2e68ed841f6d 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -164,7 +164,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, ((rate_len > 8) ? 8 : rate_len), cur_network->supported_rates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.DSConfig), &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&(cur_network->configuration.ds_config), &pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 891bd2fca652..6bdda580cef5 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -44,11 +44,11 @@ struct ndis_802_11_conf_fh { ODI Handler will convert the channel number to freq. number. */ struct ndis_802_11_conf { - u32 Length; /* Length of structure */ - u32 BeaconPeriod; /* units are Kusec */ - u32 ATIMWindow; /* units are Kusec */ - u32 DSConfig; /* Frequency, units are kHz */ - struct ndis_802_11_conf_fh FHConfig; + u32 length; /* Length of structure */ + u32 beacon_period; /* units are Kusec */ + u32 atim_window; /* units are Kusec */ + u32 ds_config; /* Frequency, units are kHz */ + struct ndis_802_11_conf_fh fh_config; }; enum ndis_802_11_network_infrastructure { diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 015f68553164..4e6eba240161 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -278,7 +278,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl /* spin_unlock_bh(&pwdev_priv->scan_req_lock); */ - channel = pnetwork->network.configuration.DSConfig; + channel = pnetwork->network.configuration.ds_config; freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); notify_channel = ieee80211_get_channel(wiphy, freq); @@ -355,7 +355,7 @@ int rtw_cfg80211_check_bss(struct adapter *padapter) if (!(pnetwork) || !(padapter->rtw_wdev)) return false; - freq = rtw_ieee80211_channel_to_frequency(pnetwork->configuration.DSConfig, NL80211_BAND_2GHZ); + freq = rtw_ieee80211_channel_to_frequency(pnetwork->configuration.ds_config, NL80211_BAND_2GHZ); notify_channel = ieee80211_get_channel(padapter->rtw_wdev->wiphy, freq); bss = cfg80211_get_bss(padapter->rtw_wdev->wiphy, notify_channel, @@ -374,7 +374,7 @@ void rtw_cfg80211_ibss_indicate_connect(struct adapter *padapter) struct wlan_network *cur_network = &(pmlmepriv->cur_network); struct wireless_dev *pwdev = padapter->rtw_wdev; struct wiphy *wiphy = pwdev->wiphy; - int freq = (int)cur_network->network.configuration.DSConfig; + int freq = (int)cur_network->network.configuration.ds_config; struct ieee80211_channel *chan; if (pwdev->iftype != NL80211_IFTYPE_ADHOC) @@ -458,7 +458,7 @@ check_bss: struct wiphy *wiphy = pwdev->wiphy; struct ieee80211_channel *notify_channel; u32 freq; - u16 channel = cur_network->network.configuration.DSConfig; + u16 channel = cur_network->network.configuration.ds_config; struct cfg80211_roam_info roam_info = {}; freq = rtw_ieee80211_channel_to_frequency(channel, NL80211_BAND_2GHZ); @@ -1266,7 +1266,7 @@ void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter) pnetwork = list_entry(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.DSConfig) >= 0 + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.ds_config) >= 0 && true == rtw_validate_ssid(&(pnetwork->network.ssid)) ) { diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index bda02f4f74db..f3e447023a2d 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -129,7 +129,7 @@ static char *translate_scan(struct adapter *padapter, else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pnetwork->network.configuration.DSConfig <= 14) { + if (pnetwork->network.configuration.ds_config <= 14) { if (ht_cap) snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); else @@ -159,14 +159,14 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); } - if (pnetwork->network.configuration.DSConfig < 1) - pnetwork->network.configuration.DSConfig = 1; + if (pnetwork->network.configuration.ds_config < 1) + pnetwork->network.configuration.ds_config = 1; /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; - iwe.u.freq.m = rtw_ch2freq(pnetwork->network.configuration.DSConfig) * 100000; + iwe.u.freq.m = rtw_ch2freq(pnetwork->network.configuration.ds_config) * 100000; iwe.u.freq.e = 1; - iwe.u.freq.i = pnetwork->network.configuration.DSConfig; + iwe.u.freq.i = pnetwork->network.configuration.ds_config; start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); /* Add encryption capability */ @@ -700,7 +700,7 @@ static int rtw_wx_get_name(struct net_device *dev, else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pcur_bss->configuration.DSConfig <= 14) { + if (pcur_bss->configuration.ds_config <= 14) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); else @@ -731,10 +731,10 @@ static int rtw_wx_get_freq(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->configuration.DSConfig-1] * 100000; */ - wrqu->freq.m = rtw_ch2freq(pcur_bss->configuration.DSConfig) * 100000; + /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->configuration.ds_config-1] * 100000; */ + wrqu->freq.m = rtw_ch2freq(pcur_bss->configuration.ds_config) * 100000; wrqu->freq.e = 1; - wrqu->freq.i = pcur_bss->configuration.DSConfig; + wrqu->freq.i = pcur_bss->configuration.ds_config; } else { wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; @@ -1290,7 +1290,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, pnetwork = list_entry(plist, struct wlan_network, list); /* report network only if the current channel set contains the channel to which this network belongs */ - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.DSConfig) >= 0 + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.ds_config) >= 0 && true == rtw_validate_ssid(&(pnetwork->network.ssid))) { ev = translate_scan(padapter, a, pnetwork, ev, stop); -- cgit v1.2.3 From 81ec005b92a8a5083499257cb89a9f1ddc947e8c Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:16 +0200 Subject: staging: rtl8723bs: remove struct ndis_802_11_conf_fh all members of struct ndis_802_11_conf_fh fh_config in struct ndis_802_11_conf are set to zero and their values are never used. So remove struct ndis_802_11_conf_fh. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/9c203ab5fe8a36b96f1f24e1fbf1a08ea0fa82af.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 4 ---- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 8 -------- 2 files changed, 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index f189cd6c11ac..624bafd44ceb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2154,10 +2154,6 @@ void rtw_init_registrypriv_dev_network(struct adapter *adapter) pdev_network->configuration.length = sizeof(struct ndis_802_11_conf); pdev_network->configuration.beacon_period = 100; - pdev_network->configuration.fh_config.Length = 0; - pdev_network->configuration.fh_config.HopPattern = 0; - pdev_network->configuration.fh_config.HopSet = 0; - pdev_network->configuration.fh_config.DwellTime = 0; } void rtw_update_registrypriv_dev_network(struct adapter *adapter) diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 6bdda580cef5..e5ab3cacfa91 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -32,13 +32,6 @@ enum ndis_802_11_network_type { Ndis802_11NetworkTypeMax /* not a real type, defined as an upper bound */ }; -struct ndis_802_11_conf_fh { - u32 Length; /* Length of structure */ - u32 HopPattern; /* As defined by 802.11, MSB set */ - u32 HopSet; /* to one if non-802.11 */ - u32 DwellTime; /* units are Kusec */ -}; - /* FW will only save the channel number in DSConfig. ODI Handler will convert the channel number to freq. number. @@ -48,7 +41,6 @@ struct ndis_802_11_conf { u32 beacon_period; /* units are Kusec */ u32 atim_window; /* units are Kusec */ u32 ds_config; /* Frequency, units are kHz */ - struct ndis_802_11_conf_fh fh_config; }; enum ndis_802_11_network_infrastructure { -- cgit v1.2.3 From 6994aa430368ed0264205c045701908c6ad2dc3a Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:17 +0200 Subject: staging: rtl8723bs: fix camel case in struct ndis_802_11_ssid fix camel case in struct ndis_802_11_ssid all over the driver. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/e7c4cc09840e112d59ed7dcf8465f1916f95b819.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 4 +-- drivers/staging/rtl8723bs/core/rtw_cmd.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 2 +- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 8 ++--- drivers/staging/rtl8723bs/core/rtw_mlme.c | 18 +++++------ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 38 +++++++++++------------ drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 12 +++---- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 2 +- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 4 +-- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 32 +++++++++---------- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 38 +++++++++++------------ drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 +-- 12 files changed, 82 insertions(+), 82 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index f821863c845d..b7e1d7817595 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -867,8 +867,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) ); if (p && ie_len > 0) { memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(pbss_network->ssid.Ssid, (p + 2), ie_len); - pbss_network->ssid.SsidLength = ie_len; + memcpy(pbss_network->ssid.ssid, (p + 2), ie_len); + pbss_network->ssid.ssid_length = ie_len; } /* channel */ diff --git a/drivers/staging/rtl8723bs/core/rtw_cmd.c b/drivers/staging/rtl8723bs/core/rtw_cmd.c index 33d8ca8be08e..d494c06dab96 100644 --- a/drivers/staging/rtl8723bs/core/rtw_cmd.c +++ b/drivers/staging/rtl8723bs/core/rtw_cmd.c @@ -567,7 +567,7 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int i; for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { - if (ssid[i].SsidLength) { + if (ssid[i].ssid_length) { memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid)); psurveyPara->ssid_num++; } diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index b133c3738dc9..57a75e1f9a56 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -317,7 +317,7 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) ie += 2; /* SSID */ - ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->ssid.SsidLength, pdev_network->ssid.Ssid, &sz); + ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->ssid.ssid_length, pdev_network->ssid.ssid, &sz); /* supported rates */ wireless_mode = pregistrypriv->wireless_mode; diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 662e63f764cd..03a7da84bf23 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -27,7 +27,7 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) { u8 ret = true; - if (ssid->SsidLength > 32) { + if (ssid->ssid_length > 32) { ret = false; goto exit; } @@ -207,7 +207,7 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) struct wlan_network *pnetwork = &pmlmepriv->cur_network; netdev_dbg(padapter->pnetdev, "set ssid [%s] fw_state = 0x%08x\n", - ssid->Ssid, get_fwstate(pmlmepriv)); + ssid->ssid, get_fwstate(pmlmepriv)); if (padapter->hw_init_completed == false) { status = _FAIL; @@ -222,8 +222,8 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) goto release_mlme_lock; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { - if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && - (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { + if ((pmlmepriv->assoc_ssid.ssid_length == ssid->ssid_length) && + (!memcmp(&pmlmepriv->assoc_ssid.ssid, ssid->ssid, ssid->ssid_length))) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { if (rtw_is_same_ibss(padapter, pnetwork) == false) { /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 624bafd44ceb..f9c3525ffb57 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -377,8 +377,8 @@ int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) inline int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) { - return (a->ssid.SsidLength == b->ssid.SsidLength) - && !memcmp(a->ssid.Ssid, b->ssid.Ssid, a->ssid.SsidLength); + return (a->ssid.ssid_length == b->ssid.ssid_length) + && !memcmp(a->ssid.ssid, b->ssid.ssid, a->ssid.ssid_length); } int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 feature) @@ -395,10 +395,10 @@ int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst, u8 fea s_cap = le16_to_cpu(tmps); d_cap = le16_to_cpu(tmpd); - return (src->ssid.SsidLength == dst->ssid.SsidLength) && + return (src->ssid.ssid_length == dst->ssid.ssid_length) && /* (src->configuration.ds_config == dst->configuration.ds_config) && */ ((!memcmp(src->mac_address, dst->mac_address, ETH_ALEN))) && - ((!memcmp(src->ssid.Ssid, dst->ssid.Ssid, src->ssid.SsidLength))) && + ((!memcmp(src->ssid.ssid, dst->ssid.ssid, src->ssid.ssid_length))) && ((s_cap & WLAN_CAPABILITY_IBSS) == (d_cap & WLAN_CAPABILITY_IBSS)) && ((s_cap & WLAN_CAPABILITY_ESS) == @@ -728,8 +728,8 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* lock pmlmepriv->lock when you accessing network_q */ if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { - if (pnetwork->ssid.Ssid[0] == 0) - pnetwork->ssid.SsidLength = 0; + if (pnetwork->ssid.ssid[0] == 0) + pnetwork->ssid.ssid_length = 0; rtw_add_network(adapter, pnetwork); } @@ -1804,9 +1804,9 @@ static int rtw_check_join_candidate(struct mlme_priv *mlme } /* check ssid, if needed */ - if (mlme->assoc_ssid.Ssid[0] && mlme->assoc_ssid.SsidLength) { - if (competitor->network.ssid.SsidLength != mlme->assoc_ssid.SsidLength - || memcmp(competitor->network.ssid.Ssid, mlme->assoc_ssid.Ssid, mlme->assoc_ssid.SsidLength) + if (mlme->assoc_ssid.ssid[0] && mlme->assoc_ssid.ssid_length) { + if (competitor->network.ssid.ssid_length != mlme->assoc_ssid.ssid_length + || memcmp(competitor->network.ssid.ssid, mlme->assoc_ssid.ssid, mlme->assoc_ssid.ssid_length) ) goto exit; } diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 537b60f7b7db..97d4c425b29b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -538,7 +538,7 @@ unsigned int OnProbeReq(struct adapter *padapter, union recv_frame *precv_frame) if (is_valid_p2p_probereq) goto _issue_probersp; - if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->ssid.Ssid, cur->ssid.SsidLength)) + if ((ielen != 0 && false == !memcmp((void *)(p+2), (void *)cur->ssid.ssid, cur->ssid.ssid_length)) || (ielen == 0 && pmlmeinfo->hidden_ssid_mode) ) return _SUCCESS; @@ -1022,10 +1022,10 @@ unsigned int OnAssocReq(struct adapter *padapter, union recv_frame *precv_frame) goto OnAssocReqFail; } else { /* check if ssid match */ - if (memcmp((void *)(p+2), cur->ssid.Ssid, cur->ssid.SsidLength)) + if (memcmp((void *)(p+2), cur->ssid.ssid, cur->ssid.ssid_length)) status = WLAN_STATUS_CHALLENGE_FAIL; - if (ie_len != cur->ssid.SsidLength) + if (ie_len != cur->ssid.ssid_length) status = WLAN_STATUS_CHALLENGE_FAIL; } @@ -2230,7 +2230,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.SsidLength, cur_network->ssid.Ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->supported_rates); @@ -2385,9 +2385,9 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p ssid_ie = rtw_get_ie(ies+_FIXED_IE_LENGTH_, WLAN_EID_SSID, &ssid_ielen, (pframe-ies)-_FIXED_IE_LENGTH_); - ssid_ielen_diff = cur_network->ssid.SsidLength - ssid_ielen; + ssid_ielen_diff = cur_network->ssid.ssid_length - ssid_ielen; - if (ssid_ie && cur_network->ssid.SsidLength) { + if (ssid_ie && cur_network->ssid.ssid_length) { uint remainder_ielen; u8 *remainder_ie; @@ -2403,8 +2403,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p memcpy(buf, remainder_ie, remainder_ielen); memcpy(remainder_ie+ssid_ielen_diff, buf, remainder_ielen); - *(ssid_ie+1) = cur_network->ssid.SsidLength; - memcpy(ssid_ie+2, cur_network->ssid.Ssid, cur_network->ssid.SsidLength); + *(ssid_ie+1) = cur_network->ssid.ssid_length; + memcpy(ssid_ie+2, cur_network->ssid.ssid, cur_network->ssid.ssid_length); pframe += ssid_ielen_diff; pattrib->pktlen += ssid_ielen_diff; @@ -2433,7 +2433,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.SsidLength, cur_network->ssid.Ssid, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->supported_rates); @@ -2530,7 +2530,7 @@ static int _issue_probereq(struct adapter *padapter, pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pssid->ssid_length, pssid->ssid, &(pattrib->pktlen)); else pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &(pattrib->pktlen)); @@ -2923,7 +2923,7 @@ void issue_assocreq(struct adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.ssid.SsidLength, pmlmeinfo->network.ssid.Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.ssid.ssid_length, pmlmeinfo->network.ssid.ssid, &(pattrib->pktlen)); /* supported rate & extended supported rate */ @@ -3876,7 +3876,7 @@ void site_survey(struct adapter *padapter) int i; for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { - if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { + if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { /* IOT issue, When wifi_spec is not set, send one probe req without WPS IE. */ if (padapter->registrypriv.wifi_spec) issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); @@ -4007,10 +4007,10 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str if (len > NDIS_802_11_LENGTH_SSID) return _FAIL; - memcpy(bssid->ssid.Ssid, (p + 2), *(p + 1)); - bssid->ssid.SsidLength = *(p + 1); + memcpy(bssid->ssid.ssid, (p + 2), *(p + 1)); + bssid->ssid.ssid_length = *(p + 1); } else - bssid->ssid.SsidLength = 0; + bssid->ssid.ssid_length = 0; memset(bssid->supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); @@ -5589,11 +5589,11 @@ u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) pmlmeext->sitesurvey_res.channel_idx = 0; for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { - if (pparm->ssid[i].SsidLength) { - memcpy(pmlmeext->sitesurvey_res.ssid[i].Ssid, pparm->ssid[i].Ssid, IW_ESSID_MAX_SIZE); - pmlmeext->sitesurvey_res.ssid[i].SsidLength = pparm->ssid[i].SsidLength; + if (pparm->ssid[i].ssid_length) { + memcpy(pmlmeext->sitesurvey_res.ssid[i].ssid, pparm->ssid[i].ssid, IW_ESSID_MAX_SIZE); + pmlmeext->sitesurvey_res.ssid[i].ssid_length = pparm->ssid[i].ssid_length; } else { - pmlmeext->sitesurvey_res.ssid[i].SsidLength = 0; + pmlmeext->sitesurvey_res.ssid[i].ssid_length = 0; } } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index dfdeec2d0763..f9042f1dadb5 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1283,13 +1283,13 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (ssid_len > NDIS_802_11_LENGTH_SSID) ssid_len = 0; } - memcpy(bssid->ssid.Ssid, (p + 2), ssid_len); - bssid->ssid.SsidLength = ssid_len; + memcpy(bssid->ssid.ssid, (p + 2), ssid_len); + bssid->ssid.ssid_length = ssid_len; - if (memcmp(bssid->ssid.Ssid, cur_network->network.ssid.Ssid, 32) || - bssid->ssid.SsidLength != cur_network->network.ssid.SsidLength) - if (bssid->ssid.Ssid[0] != '\0' && - bssid->ssid.SsidLength != 0) /* not hidden ssid */ + if (memcmp(bssid->ssid.ssid, cur_network->network.ssid.ssid, 32) || + bssid->ssid.ssid_length != cur_network->network.ssid.ssid_length) + if (bssid->ssid.ssid[0] != '\0' && + bssid->ssid.ssid_length != 0) /* not hidden ssid */ goto _mismatch; /* check encryption info */ diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 2e68ed841f6d..853fe758c4a9 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -157,7 +157,7 @@ static void ConstructBeacon(struct adapter *padapter, u8 *pframe, u32 *pLength) /* below for ad-hoc mode */ /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.SsidLength, cur_network->ssid.Ssid, &pktlen); + pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pktlen); /* supported rates... */ rate_len = rtw_get_rateset_len(cur_network->supported_rates); diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index e5ab3cacfa91..331578129644 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -20,8 +20,8 @@ typedef unsigned char NDIS_802_11_RATES[NDIS_802_11_LENGTH_RATES]; /* typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; /* Set of 16 data rates */ struct ndis_802_11_ssid { - u32 SsidLength; - u8 Ssid[32]; + u32 ssid_length; + u8 ssid[32]; }; enum ndis_802_11_network_type { diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 4e6eba240161..17628704d428 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -266,8 +266,8 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl if (request->n_ssids == 1 && request->n_channels == 1) /* it means under processing WPS */ { if (ssids[0].ssid_len != 0 && - (pssid->SsidLength != ssids[0].ssid_len || - memcmp(pssid->Ssid, ssids[0].ssid, ssids[0].ssid_len))) + (pssid->ssid_length != ssids[0].ssid_len || + memcmp(pssid->ssid, ssids[0].ssid, ssids[0].ssid_len))) { if (psr) *psr = 0; /* clear sr */ @@ -359,8 +359,8 @@ int rtw_cfg80211_check_bss(struct adapter *padapter) notify_channel = ieee80211_get_channel(padapter->rtw_wdev->wiphy, freq); bss = cfg80211_get_bss(padapter->rtw_wdev->wiphy, notify_channel, - pnetwork->mac_address, pnetwork->ssid.Ssid, - pnetwork->ssid.SsidLength, + pnetwork->mac_address, pnetwork->ssid.ssid, + pnetwork->ssid.ssid_length, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS); cfg80211_put_bss(padapter->rtw_wdev->wiphy, bss); @@ -1241,8 +1241,8 @@ void rtw_cfg80211_unlink_bss(struct adapter *padapter, struct wlan_network *pnet struct wlan_bssid_ex *select_network = &pnetwork->network; bss = cfg80211_get_bss(wiphy, NULL/*notify_channel*/, - select_network->mac_address, select_network->ssid.Ssid, - select_network->ssid.SsidLength, 0/*WLAN_CAPABILITY_ESS*/, + select_network->mac_address, select_network->ssid.ssid, + select_network->ssid.ssid_length, 0/*WLAN_CAPABILITY_ESS*/, 0/*WLAN_CAPABILITY_ESS*/); if (bss) { @@ -1398,8 +1398,8 @@ static int cfg80211_rtw_scan(struct wiphy *wiphy /* parsing request ssids, n_ssids */ for (i = 0; i < request->n_ssids && i < RTW_SSID_SCAN_AMOUNT; i++) { - memcpy(ssid[i].Ssid, ssids[i].ssid, ssids[i].ssid_len); - ssid[i].SsidLength = ssids[i].ssid_len; + memcpy(ssid[i].ssid, ssids[i].ssid, ssids[i].ssid_len); + ssid[i].ssid_length = ssids[i].ssid_len; } /* parsing channels, n_channels */ @@ -1730,8 +1730,8 @@ static int cfg80211_rtw_join_ibss(struct wiphy *wiphy, struct net_device *ndev, } memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); - ndis_ssid.SsidLength = params->ssid_len; - memcpy(ndis_ssid.Ssid, (u8 *)params->ssid, params->ssid_len); + ndis_ssid.ssid_length = params->ssid_len; + memcpy(ndis_ssid.ssid, (u8 *)params->ssid, params->ssid_len); psecuritypriv->ndisencryptstatus = Ndis802_11EncryptionDisabled; psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; @@ -1822,8 +1822,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, } memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); - ndis_ssid.SsidLength = sme->ssid_len; - memcpy(ndis_ssid.Ssid, (u8 *)sme->ssid, sme->ssid_len); + ndis_ssid.ssid_length = sme->ssid_len; + memcpy(ndis_ssid.ssid, (u8 *)sme->ssid, sme->ssid_len); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { ret = -EBUSY; @@ -2466,10 +2466,10 @@ static int cfg80211_rtw_start_ap(struct wiphy *wiphy, struct net_device *ndev, struct wlan_bssid_ex *pbss_network = &adapter->mlmepriv.cur_network.network; struct wlan_bssid_ex *pbss_network_ext = &adapter->mlmeextpriv.mlmext_info.network; - memcpy(pbss_network->ssid.Ssid, (void *)settings->ssid, settings->ssid_len); - pbss_network->ssid.SsidLength = settings->ssid_len; - memcpy(pbss_network_ext->ssid.Ssid, (void *)settings->ssid, settings->ssid_len); - pbss_network_ext->ssid.SsidLength = settings->ssid_len; + memcpy(pbss_network->ssid.ssid, (void *)settings->ssid, settings->ssid_len); + pbss_network->ssid.ssid_length = settings->ssid_len; + memcpy(pbss_network_ext->ssid.ssid, (void *)settings->ssid, settings->ssid_len); + pbss_network_ext->ssid.ssid_length = settings->ssid_len; } return ret; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index f3e447023a2d..95aef62ecfb8 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -98,8 +98,8 @@ static char *translate_scan(struct adapter *padapter, /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - iwe.u.data.length = min((u16)pnetwork->network.ssid.SsidLength, (u16)32); - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.Ssid); + iwe.u.data.length = min((u16)pnetwork->network.ssid.ssid_length, (u16)32); + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); /* parsing HT_CAP_IE */ if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ @@ -176,7 +176,7 @@ static char *translate_scan(struct adapter *padapter, else iwe.u.data.flags = IW_ENCODE_DISABLED; iwe.u.data.length = 0; - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.Ssid); + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); /*Add basic and extended rates */ max_rate = 0; @@ -1177,8 +1177,8 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); - memcpy(ssid[0].Ssid, req->essid, len); - ssid[0].SsidLength = len; + memcpy(ssid[0].ssid, req->essid, len); + ssid[0].ssid_length = len; spin_lock_bh(&pmlmepriv->lock); @@ -1209,8 +1209,8 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, sec_len = *(pos++); len -= 1; if (sec_len > 0 && sec_len <= len) { - ssid[ssid_index].SsidLength = sec_len; - memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + ssid[ssid_index].ssid_length = sec_len; + memcpy(ssid[ssid_index].ssid, pos, ssid[ssid_index].ssid_length); ssid_index++; } @@ -1355,9 +1355,9 @@ static int rtw_wx_set_essid(struct net_device *dev, len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); - ndis_ssid.SsidLength = len; - memcpy(ndis_ssid.Ssid, extra, len); - src_ssid = ndis_ssid.Ssid; + ndis_ssid.ssid_length = len; + memcpy(ndis_ssid.ssid, extra, len); + src_ssid = ndis_ssid.ssid; spin_lock_bh(&queue->lock); phead = get_list_head(queue); @@ -1365,10 +1365,10 @@ static int rtw_wx_set_essid(struct net_device *dev, pnetwork = list_entry(pmlmepriv->pscanned, struct wlan_network, list); - dst_ssid = pnetwork->network.ssid.Ssid; + dst_ssid = pnetwork->network.ssid.ssid; - if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && - (pnetwork->network.ssid.SsidLength == ndis_ssid.SsidLength)) { + if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.ssid_length)) && + (pnetwork->network.ssid.ssid_length == ndis_ssid.ssid_length)) { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { if (pnetwork->network.infrastructure_mode != pmlmepriv->cur_network.network.infrastructure_mode) continue; @@ -1410,11 +1410,11 @@ static int rtw_wx_get_essid(struct net_device *dev, if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - len = pcur_bss->ssid.SsidLength; + len = pcur_bss->ssid.ssid_length; wrqu->essid.length = len; - memcpy(extra, pcur_bss->ssid.Ssid, len); + memcpy(extra, pcur_bss->ssid.ssid, len); wrqu->essid.flags = 1; } else { @@ -3530,10 +3530,10 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, memcpy(ssid, ssid_ie+2, ssid_len); ssid[ssid_len] = 0x0; - memcpy(pbss_network->ssid.Ssid, (void *)ssid, ssid_len); - pbss_network->ssid.SsidLength = ssid_len; - memcpy(pbss_network_ext->ssid.Ssid, (void *)ssid, ssid_len); - pbss_network_ext->ssid.SsidLength = ssid_len; + memcpy(pbss_network->ssid.ssid, (void *)ssid, ssid_len); + pbss_network->ssid.ssid_length = ssid_len; + memcpy(pbss_network_ext->ssid.ssid, (void *)ssid, ssid_len); + pbss_network_ext->ssid.ssid_length = ssid_len; } return ret; diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 648456b992bb..b042df319c98 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -205,8 +205,8 @@ static void loadparam(struct adapter *padapter, struct net_device *pnetdev) /* registry_par->hci = (u8)hci; */ registry_par->network_mode = (u8)rtw_network_mode; - memcpy(registry_par->ssid.Ssid, "ANY", 3); - registry_par->ssid.SsidLength = 3; + memcpy(registry_par->ssid.ssid, "ANY", 3); + registry_par->ssid.ssid_length = 3; registry_par->channel = (u8)rtw_channel; registry_par->wireless_mode = (u8)rtw_wireless_mode; -- cgit v1.2.3 From 631f42e9079382583831326f8db5fad6e10e36ee Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:18 +0200 Subject: staging: rtl8723bs: fix camel case in struct wlan_phy_info fix camel case in struct wlan_phy_info all over the driver. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/caadcfc157d62b633fd757d5696c1abce5ef9ae9.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 30 +++++++++++------------ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 +++--- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 8 +++--- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 4 +-- 5 files changed, 26 insertions(+), 26 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index f9c3525ffb57..a0c19253095d 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -452,7 +452,7 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, { long rssi_ori = dst->rssi; - u8 sq_smp = src->phy_info.SignalQuality; + u8 sq_smp = src->phy_info.signal_quality; u8 ss_final; u8 sq_final; @@ -470,13 +470,13 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rssi_final = rssi_ori; } else { if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->phy_info.SignalStrength)+(u32)(dst->phy_info.SignalStrength)*4)/5; - sq_final = ((u32)(src->phy_info.SignalQuality)+(u32)(dst->phy_info.SignalQuality)*4)/5; + ss_final = ((u32)(src->phy_info.signal_strength)+(u32)(dst->phy_info.signal_strength)*4)/5; + sq_final = ((u32)(src->phy_info.signal_quality)+(u32)(dst->phy_info.signal_quality)*4)/5; rssi_final = (src->rssi+dst->rssi*4)/5; } else { /* bss info not receiving from the right channel, use the original RX signal infos */ - ss_final = dst->phy_info.SignalStrength; - sq_final = dst->phy_info.SignalQuality; + ss_final = dst->phy_info.signal_strength; + sq_final = dst->phy_info.signal_quality; rssi_final = dst->rssi; } @@ -488,8 +488,8 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); } - dst->phy_info.SignalStrength = ss_final; - dst->phy_info.SignalQuality = sq_final; + dst->phy_info.signal_strength = ss_final; + dst->phy_info.signal_quality = sq_final; dst->rssi = rssi_final; } @@ -568,8 +568,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork->join_res = 0; /* bss info not receiving from the right channel */ - if (pnetwork->network.phy_info.SignalQuality == 101) - pnetwork->network.phy_info.SignalQuality = 0; + if (pnetwork->network.phy_info.signal_quality == 101) + pnetwork->network.phy_info.signal_quality = 0; } else { /* Otherwise just pull from the free list */ @@ -585,8 +585,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork->last_scanned = jiffies; /* bss info not receiving from the right channel */ - if (pnetwork->network.phy_info.SignalQuality == 101) - pnetwork->network.phy_info.SignalQuality = 0; + if (pnetwork->network.phy_info.signal_quality == 101) + pnetwork->network.phy_info.signal_quality = 0; list_add_tail(&(pnetwork->list), &(queue->queue)); @@ -1120,10 +1120,10 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net rtw_set_signal_stat_timer(&padapter->recvpriv); - padapter->recvpriv.signal_strength = ptarget_wlan->network.phy_info.SignalStrength; - padapter->recvpriv.signal_qual = ptarget_wlan->network.phy_info.SignalQuality; - /* the ptarget_wlan->network.rssi is raw data, we use ptarget_wlan->network.phy_info.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.phy_info.SignalStrength); + padapter->recvpriv.signal_strength = ptarget_wlan->network.phy_info.signal_strength; + padapter->recvpriv.signal_qual = ptarget_wlan->network.phy_info.signal_quality; + /* the ptarget_wlan->network.rssi is raw data, we use ptarget_wlan->network.phy_info.signal_strength instead (has scaled) */ + padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.phy_info.signal_strength); rtw_set_signal_stat_timer(&padapter->recvpriv); diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 97d4c425b29b..5942e51b23b6 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3995,8 +3995,8 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str /* get the signal strength */ bssid->rssi = precv_frame->u.hdr.attrib.phy_info.RecvSignalPower; /* in dBM.raw data */ - bssid->phy_info.SignalQuality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ - bssid->phy_info.SignalStrength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ + bssid->phy_info.signal_quality = precv_frame->u.hdr.attrib.phy_info.SignalQuality;/* in percentage */ + bssid->phy_info.signal_strength = precv_frame->u.hdr.attrib.phy_info.SignalStrength;/* in percentage */ /* checking SSID */ p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SSID, &len, bssid->ie_length - ie_offset); @@ -4095,9 +4095,9 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str pmlmepriv->num_sta_no_ht++; } - /* mark bss info receiving from nearby channel as SignalQuality 101 */ + /* mark bss info receiving from nearby channel as signal_quality 101 */ if (bssid->configuration.ds_config != rtw_get_oper_ch(padapter)) - bssid->phy_info.SignalQuality = 101; + bssid->phy_info.signal_quality = 101; return _SUCCESS; } diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 331578129644..4e6d0b8e17a6 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -143,10 +143,10 @@ struct ndis_802_11_wep { #endif struct wlan_phy_info { - u8 SignalStrength;/* in percentage) */ - u8 SignalQuality;/* in percentage) */ - u8 Optimum_antenna; /* for Antenna diversity */ - u8 Reserved_0; + u8 signal_strength;/* in percentage) */ + u8 signal_quality;/* in percentage) */ + u8 optimum_antenna; /* for Antenna diversity */ + u8 reserved_0; }; struct wlan_bcn_info { diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 17628704d428..bcd8d03a35a0 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -290,7 +290,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) { notify_signal = 100*translate_percentage_to_dbm(padapter->recvpriv.signal_strength);/* dbm */ } else { - notify_signal = 100*translate_percentage_to_dbm(pnetwork->network.phy_info.SignalStrength);/* dbm */ + notify_signal = 100*translate_percentage_to_dbm(pnetwork->network.phy_info.signal_strength);/* dbm */ } buf = kzalloc(MAX_BSSINFO_LEN, GFP_ATOMIC); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 95aef62ecfb8..8c44db696b52 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -303,8 +303,8 @@ static char *translate_scan(struct adapter *padapter, ss = padapter->recvpriv.signal_strength; sq = padapter->recvpriv.signal_qual; } else { - ss = pnetwork->network.phy_info.SignalStrength; - sq = pnetwork->network.phy_info.SignalQuality; + ss = pnetwork->network.phy_info.signal_strength; + sq = pnetwork->network.phy_info.signal_quality; } -- cgit v1.2.3 From d7361874468f9b963d0263223c299f0afd7e51a7 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:19 +0200 Subject: staging: rtl8723bs: fix camel case in struct wlan_bcn_info fix camel case in struct wlan_bcn_info all over the driver. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/52c74cf0183da44f2ddaac2607e4b7ccaf9abd91.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 28 ++++++++++++------------- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 16 +++++++------- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 57a75e1f9a56..b7ad4a11a7b7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1034,9 +1034,9 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) if (pbuf && (wpa_ielen > 0)) { if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { - pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; - pnetwork->BcnInfo.group_cipher = group_cipher; - pnetwork->BcnInfo.is_8021x = is8021x; + pnetwork->bcn_info.pairwise_cipher = pairwise_cipher; + pnetwork->bcn_info.group_cipher = group_cipher; + pnetwork->bcn_info.is_8021x = is8021x; ret = _SUCCESS; } } else { @@ -1044,9 +1044,9 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) if (pbuf && (wpa_ielen > 0)) { if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { - pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; - pnetwork->BcnInfo.group_cipher = group_cipher; - pnetwork->BcnInfo.is_8021x = is8021x; + pnetwork->bcn_info.pairwise_cipher = pairwise_cipher; + pnetwork->bcn_info.group_cipher = group_cipher; + pnetwork->bcn_info.is_8021x = is8021x; ret = _SUCCESS; } } @@ -1073,17 +1073,17 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) bencrypt = 1; pnetwork->network.privacy = 1; } else { - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; + pnetwork->bcn_info.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; } rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, NULL, &rsn_len, NULL, &wpa_len); if (rsn_len > 0) { - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; + pnetwork->bcn_info.encryp_protocol = ENCRYP_PROTOCOL_WPA2; } else if (wpa_len > 0) { - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA; + pnetwork->bcn_info.encryp_protocol = ENCRYP_PROTOCOL_WPA; } else { if (bencrypt) - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; + pnetwork->bcn_info.encryp_protocol = ENCRYP_PROTOCOL_WEP; } rtw_get_cipher_info(pnetwork); @@ -1092,17 +1092,17 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_cap = (struct ieee80211_ht_cap *)(p + 2); - pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(pht_cap->cap_info); + pnetwork->bcn_info.ht_cap_info = le16_to_cpu(pht_cap->cap_info); } else { - pnetwork->BcnInfo.ht_cap_info = 0; + pnetwork->bcn_info.ht_cap_info = 0; } /* parsing HT_INFO_IE */ p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); if (p && len > 0) { pht_info = (struct HT_info_element *)(p + 2); - pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; + pnetwork->bcn_info.ht_info_infos_0 = pht_info->infos[0]; } else { - pnetwork->BcnInfo.ht_info_infos_0 = 0; + pnetwork->bcn_info.ht_info_infos_0 = 0; } } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index f9042f1dadb5..efd0cbbde389 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1248,12 +1248,12 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } else { ht_info_infos_0 = 0; } - if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || - ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { + if (ht_cap_info != cur_network->bcn_info.ht_cap_info || + ((ht_info_infos_0&0x03) != (cur_network->bcn_info.ht_info_infos_0&0x03))) { { /* bcn_info_update */ - cur_network->BcnInfo.ht_cap_info = ht_cap_info; - cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; + cur_network->bcn_info.ht_cap_info = ht_cap_info; + cur_network->bcn_info.ht_info_infos_0 = ht_info_infos_0; /* to do : need to check that whether modify related register of BB or not */ } /* goto _mismatch; */ @@ -1313,7 +1313,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (bssid->privacy) encryp_protocol = ENCRYP_PROTOCOL_WEP; - if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) + if (cur_network->bcn_info.encryp_protocol != encryp_protocol) goto _mismatch; if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { @@ -1329,11 +1329,11 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) &pairwise_cipher, &is_8021x); } - if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || - group_cipher != cur_network->BcnInfo.group_cipher) + if (pairwise_cipher != cur_network->bcn_info.pairwise_cipher || + group_cipher != cur_network->bcn_info.group_cipher) goto _mismatch; - if (is_8021x != cur_network->BcnInfo.is_8021x) + if (is_8021x != cur_network->bcn_info.is_8021x) goto _mismatch; } diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 4e6d0b8e17a6..8c9d78c35650 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -194,7 +194,7 @@ struct wlan_network { int aid; /* will only be valid when a BSS is joinned. */ int join_res; struct wlan_bssid_ex network; /* must be the last item */ - struct wlan_bcn_info BcnInfo; + struct wlan_bcn_info bcn_info; }; enum { -- cgit v1.2.3 From 61ba4fae0a5d81d826810a32c0b30df319d1a925 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:20 +0200 Subject: staging: rtl8723bs: fix camel case in IE structures fix camel case in IE structures all over the driver. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/c1b36466fb5e17aa0dbbcdf6dfef3a82f9739c00.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 20 +++++++++--------- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 28 ++++++++++++------------- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 10 ++++----- 3 files changed, 29 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 5942e51b23b6..07986eeafe08 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -1428,7 +1428,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { pIE = (struct ndis_80211_var_ie *)(pframe + i); - switch (pIE->ElementID) { + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC: if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ WMM_param_handler(padapter, pIE); @@ -1450,7 +1450,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, union recv_frame *precv_frame) break; } - i += (pIE->Length + 2); + i += (pIE->length + 2); } pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); @@ -2980,12 +2980,12 @@ void issue_assocreq(struct adapter *padapter) for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.ie_length;) { pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.ies + i); - switch (pIE->ElementID) { + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || (!memcmp(pIE->data, WMM_OUI, 4)) || (!memcmp(pIE->data, WPS_OUI, 4))) { - vs_ie_length = pIE->Length; + vs_ie_length = pIE->length; if ((!padapter->registrypriv.wifi_spec) && (!memcmp(pIE->data, WPS_OUI, 4))) { /* Commented by Kurt 20110629 * In some older APs, WPS handshake @@ -3001,26 +3001,26 @@ void issue_assocreq(struct adapter *padapter) break; case WLAN_EID_RSN: - pframe = rtw_set_ie(pframe, WLAN_EID_RSN, pIE->Length, pIE->data, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_RSN, pIE->length, pIE->data, &(pattrib->pktlen)); break; case WLAN_EID_HT_CAPABILITY: if (padapter->mlmepriv.htpriv.ht_option) { if (!(is_ap_in_tkip(padapter))) { memcpy(&(pmlmeinfo->HT_caps), pIE->data, sizeof(struct HT_caps_element)); - pframe = rtw_set_ie(pframe, WLAN_EID_HT_CAPABILITY, pIE->Length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_HT_CAPABILITY, pIE->length, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); } } break; case WLAN_EID_EXT_CAPABILITY: if (padapter->mlmepriv.htpriv.ht_option) - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_CAPABILITY, pIE->Length, pIE->data, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, WLAN_EID_EXT_CAPABILITY, pIE->length, pIE->data, &(pattrib->pktlen)); break; default: break; } - i += (pIE->Length + 2); + i += (pIE->length + 2); } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) @@ -5411,7 +5411,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) for (i = _FIXED_IE_LENGTH_; i < pnetwork->ie_length;) { pIE = (struct ndis_80211_var_ie *)(pnetwork->ies + i); - switch (pIE->ElementID) { + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ if (!memcmp(pIE->data, WMM_OUI, 4)) WMM_param_handler(padapter, pIE); @@ -5457,7 +5457,7 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) break; } - i += (pIE->Length + 2); + i += (pIE->length + 2); } /* check channel, bandwidth, offset and switch */ diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index efd0cbbde389..2a2a8634beb7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -909,7 +909,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ if (phtpriv->ht_option == false) return; - if (pIE->Length > sizeof(struct HT_info_element)) + if (pIE->length > sizeof(struct HT_info_element)) return; pHT_info = (struct HT_info_element *)pIE->data; @@ -1001,7 +1001,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) pmlmeinfo->HT_caps_enable = 1; - for (i = 0; i < (pIE->Length); i++) { + for (i = 0; i < (pIE->length); i++) { if (i != 2) { /* Commented by Albert 2010/07/12 */ /* Got the endian issue here. */ @@ -1075,11 +1075,11 @@ void HT_info_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) if (phtpriv->ht_option == false) return; - if (pIE->Length > sizeof(struct HT_info_element)) + if (pIE->length > sizeof(struct HT_info_element)) return; pmlmeinfo->HT_info_enable = 1; - memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); + memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->length); } void HTOnAssocRsp(struct adapter *padapter) @@ -1117,11 +1117,11 @@ void ERP_IE_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - if (pIE->Length > 1) + if (pIE->length > 1) return; pmlmeinfo->ERP_enable = 1; - memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length); + memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->length); } void VCS_update(struct adapter *padapter, struct sta_info *psta) @@ -1369,10 +1369,10 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru for (i = 0; i < len;) { pIE = (struct ndis_80211_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); - switch (pIE->ElementID) { + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC: /* to update WMM parameter set while receiving beacon */ - if (!memcmp(pIE->data, WMM_PARA_OUI, 6) && pIE->Length == WLAN_WMM_LEN) /* WMM */ + if (!memcmp(pIE->data, WMM_PARA_OUI, 6) && pIE->length == WLAN_WMM_LEN) /* WMM */ if (WMM_param_handler(padapter, pIE)) report_wmm_edca_update(padapter); @@ -1392,7 +1392,7 @@ void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, stru break; } - i += (pIE->Length + 2); + i += (pIE->length + 2); } } @@ -1408,7 +1408,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) for (i = sizeof(struct ndis_802_11_fix_ie); i < pmlmeinfo->network.ie_length;) { pIE = (struct ndis_80211_var_ie *)(pmlmeinfo->network.ies + i); - switch (pIE->ElementID) { + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) return true; @@ -1424,7 +1424,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) break; } - i += (pIE->Length + 2); + i += (pIE->length + 2); } return false; @@ -1480,7 +1480,7 @@ static u32 get_realtek_assoc_AP_vender(struct ndis_80211_var_ie *pIE) { u32 Vender = HT_IOT_PEER_REALTEK; - if (pIE->Length >= 5) { + if (pIE->length >= 5) { if (pIE->data[4] == 1) /* if (pIE->data[5] & RT_HT_CAP_USE_LONG_PREAMBLE) */ /* bssDesc->BssHT.RT2RT_HT_Mode |= RT_HT_CAP_USE_LONG_PREAMBLE; */ @@ -1511,7 +1511,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) for (i = sizeof(struct ndis_802_11_fix_ie); i < len;) { pIE = (struct ndis_80211_var_ie *)(pframe + i); - switch (pIE->ElementID) { + switch (pIE->element_id) { case WLAN_EID_VENDOR_SPECIFIC: if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) return HT_IOT_PEER_ATHEROS; @@ -1536,7 +1536,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) break; } - i += (pIE->Length + 2); + i += (pIE->length + 2); } return HT_IOT_PEER_UNKNOWN; diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 8c9d78c35650..1915b524fd2d 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -52,14 +52,14 @@ enum ndis_802_11_network_infrastructure { }; struct ndis_802_11_fix_ie { - u8 Timestamp[8]; - u16 BeaconInterval; - u16 Capabilities; + u8 time_stamp[8]; + u16 beacon_interval; + u16 capabilities; }; struct ndis_80211_var_ie { - u8 ElementID; - u8 Length; + u8 element_id; + u8 length; u8 data[]; }; -- cgit v1.2.3 From bc512e8873cae7894dffcd94451df96dd70d931d Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:21 +0200 Subject: staging: rtl8723bs: remove unused struct ndis_802_11_ai_reqfi remove unused struct ndis_802_11_ai_reqfi. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/00ed84b66a0a325cb1a09ad6e2d2c0fa19686a88.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 1915b524fd2d..f0977b15c81e 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -107,12 +107,6 @@ enum { #define NDIS_802_11_AI_RESFI_STATUSCODE 2 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4 -struct ndis_802_11_ai_reqfi { - u16 Capabilities; - u16 ListenInterval; - NDIS_802_11_MAC_ADDRESS CurrentAPAddress; -}; - struct ndis_801_11_ai_resfi { u16 Capabilities; u16 StatusCode; -- cgit v1.2.3 From 2ddaf7cf4d895a681f9009498a8c41ff4282c7cd Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:22 +0200 Subject: staging: rtl8723bs: remove unused struct ndis_801_11_ai_resfi remove unused struct ndis_801_11_ai_resfi. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/23f5764080f84e3704654b11db455e4d5ad499bb.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index f0977b15c81e..b101a3ac40ff 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -107,12 +107,6 @@ enum { #define NDIS_802_11_AI_RESFI_STATUSCODE 2 #define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4 -struct ndis_801_11_ai_resfi { - u16 Capabilities; - u16 StatusCode; - u16 AssociationId; -}; - /* Key mapping keys require a BSSID */ struct ndis_802_11_wep { -- cgit v1.2.3 From f133717efc6f28052667daf682e99ffd4b3d7588 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 21 Jul 2021 15:37:23 +0200 Subject: staging: rtl8723bs: fix camel case in struct ndis_802_11_wep fix camel case in struct ndis_802_11_wep all over the driver. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/d3a1407e1bcb07d423dfa0c9bd33021a59bc0b61.1626874164.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 8 ++-- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 8 ++-- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 12 ++--- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 54 +++++++++++------------ 4 files changed, 41 insertions(+), 41 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 03a7da84bf23..8914ef3d33c8 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -494,14 +494,14 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) struct security_priv *psecuritypriv = &(padapter->securitypriv); u8 ret = _SUCCESS; - keyid = wep->KeyIndex & 0x3fffffff; + keyid = wep->key_index & 0x3fffffff; if (keyid >= 4) { ret = false; goto exit; } - switch (wep->KeyLength) { + switch (wep->key_length) { case 5: psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; break; @@ -513,9 +513,9 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) break; } - memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); + memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->key_material), wep->key_length); - psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; + psecuritypriv->dot11DefKeylen[keyid] = wep->key_length; psecuritypriv->dot11PrivacyKeyIndex = keyid; diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index b101a3ac40ff..530c95275c1e 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -110,10 +110,10 @@ enum { /* Key mapping keys require a BSSID */ struct ndis_802_11_wep { - u32 Length; /* Length of this structure */ - u32 KeyIndex; /* 0 is the per-client key, 1-N are the global keys */ - u32 KeyLength; /* length of key in bytes */ - u8 KeyMaterial[16];/* variable length depending on above field */ + u32 length; /* Length of this structure */ + u32 key_index; /* 0 is the per-client key, 1-N are the global keys */ + u32 key_length; /* length of key in bytes */ + u8 key_material[16];/* variable length depending on above field */ }; /* mask for authentication/integrity fields */ diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index bcd8d03a35a0..dc23470fcdef 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -1874,7 +1874,7 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material); pwep = rtw_malloc(wep_total_len); if (pwep == NULL) { ret = -ENOMEM; @@ -1883,8 +1883,8 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; + pwep->key_length = wep_key_len; + pwep->length = wep_total_len; if (wep_key_len == 13) { padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; @@ -1895,10 +1895,10 @@ static int cfg80211_rtw_connect(struct wiphy *wiphy, struct net_device *ndev, goto exit; } - pwep->KeyIndex = wep_key_idx; - pwep->KeyIndex |= 0x80000000; + pwep->key_index = wep_key_idx; + pwep->key_index |= 0x80000000; - memcpy(pwep->KeyMaterial, (void *)sme->key, pwep->KeyLength); + memcpy(pwep->key_material, (void *)sme->key, pwep->key_length); if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) ret = -EOPNOTSUPP; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 8c44db696b52..1383f84a4425 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -411,15 +411,15 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material); pwep = kzalloc(wep_total_len, GFP_KERNEL); if (!pwep) { ret = -ENOMEM; goto exit; } - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; + pwep->key_length = wep_key_len; + pwep->length = wep_total_len; if (wep_key_len == 13) { padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; @@ -430,10 +430,10 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, goto exit; } - pwep->KeyIndex = wep_key_idx; - pwep->KeyIndex |= 0x80000000; + pwep->key_index = wep_key_idx; + pwep->key_index |= 0x80000000; - memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); + memcpy(pwep->key_material, param->u.crypt.key, pwep->key_length); if (param->u.crypt.set_tx) { if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) @@ -447,8 +447,8 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, goto exit; } - memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->key_material, pwep->key_length); + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->key_length; rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0, true); } @@ -1667,15 +1667,15 @@ static int rtw_wx_set_enc(struct net_device *dev, padapter->securitypriv.ndisauthtype = authmode; } - wep.KeyIndex = key; + wep.key_index = key; if (erq->length > 0) { - wep.KeyLength = erq->length <= 5 ? 5 : 13; + wep.key_length = erq->length <= 5 ? 5 : 13; - wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + wep.length = wep.key_length + FIELD_OFFSET(struct ndis_802_11_wep, key_material); } else { - wep.KeyLength = 0; + wep.key_length = 0; - if (keyindex_provided == 1) { /* set key_id only, no given KeyMaterial(erq->length == 0). */ + if (keyindex_provided == 1) { /* set key_id only, no given key_material(erq->length == 0). */ padapter->securitypriv.dot11PrivacyKeyIndex = key; switch (padapter->securitypriv.dot11DefKeylen[key]) { @@ -1696,9 +1696,9 @@ static int rtw_wx_set_enc(struct net_device *dev, } - wep.KeyIndex |= 0x80000000; + wep.key_index |= 0x80000000; - memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); + memcpy(wep.key_material, keybuf, wep.key_length); if (rtw_set_802_11_add_wep(padapter, &wep) == false) { if (rf_on == pwrpriv->rf_pwrstate) @@ -2974,19 +2974,19 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, key_material); pwep = kzalloc(wep_total_len, GFP_KERNEL); if (!pwep) goto exit; - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; + pwep->key_length = wep_key_len; + pwep->length = wep_total_len; } - pwep->KeyIndex = wep_key_idx; + pwep->key_index = wep_key_idx; - memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); + memcpy(pwep->key_material, param->u.crypt.key, pwep->key_length); if (param->u.crypt.set_tx) { psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; @@ -2994,7 +2994,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (pwep->KeyLength == 13) { + if (pwep->key_length == 13) { psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; psecuritypriv->dot118021XGrpPrivacy = _WEP104_; } @@ -3002,20 +3002,20 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; - memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->key_material, pwep->key_length); - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->key_length; - rtw_ap_set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx, 1); + rtw_ap_set_wep_key(padapter, pwep->key_material, pwep->key_length, wep_key_idx, 1); } else { /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ /* psecuritypriv->dot11PrivacyKeyIndex =keyid", but can rtw_set_key to cam */ - memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->key_material, pwep->key_length); - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->key_length; - rtw_ap_set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx, 0); + rtw_ap_set_wep_key(padapter, pwep->key_material, pwep->key_length, wep_key_idx, 0); } goto exit; -- cgit v1.2.3 From 35c83e29639e5a4ed28d9a77c381a553f723d9f2 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Wed, 21 Jul 2021 13:28:29 +0200 Subject: staging: rtl8188eu: Remove unused iw_operation_mode[] Remove unused iw_operation_mode array. Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210721112829.17317-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index d4dce8ef0322..eef8ed71cdef 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -46,11 +46,6 @@ static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; -static const char * const iw_operation_mode[] = { - "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", - "Secondary", "Monitor" -}; - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; -- cgit v1.2.3 From 0104c061a880471c6cc66a65c932b74138e04e14 Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Thu, 22 Jul 2021 12:14:51 +0530 Subject: staging: rtl8188eu: remove unnecessary blank lines in core/rtw_ap.c This commit fixes some checkpatch checks for blank lines before and after braces in drivers/staging/rtl8188eu/core/rtw_ap.c Signed-off-by: Benjamin Philip Link: https://lore.kernel.org/r/20210722064451.10331-1-benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index b817aa8b9de4..a2aeb78733d5 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -381,7 +381,6 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) /* set ra_id, init_rate */ psta->raid = raid; psta->init_rate = init_rate; - } } @@ -453,7 +452,6 @@ static void update_bmc_sta(struct adapter *padapter) spin_lock_bh(&psta->lock); psta->state = _FW_LINKED; spin_unlock_bh(&psta->lock); - } } @@ -1140,7 +1138,6 @@ static void update_bcn_wps_ie(struct adapter *padapter) static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) { - if (!memcmp(WPS_OUI, oui, 4)) update_bcn_wps_ie(padapter); } -- cgit v1.2.3 From 66c1c64ea89d98f971201f3172674ded735642c0 Mon Sep 17 00:00:00 2001 From: Jignesh Patel Date: Fri, 23 Jul 2021 15:15:16 +0530 Subject: staging: rtl8188eu: Line over 100 characters Break lines into multiple lines to respect 100 character width limit. Reported by checkpatch.pl Signed-off-by: Jignesh Patel Link: https://lore.kernel.org/r/20210723094524.8811-1-jigs0101@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_ap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c index a2aeb78733d5..309e7ab59331 100644 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ b/drivers/staging/rtl8188eu/core/rtw_ap.c @@ -254,9 +254,12 @@ void expire_timeout_chk(struct adapter *padapter) updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); } else { - /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ + /* TODO: Aging mechanism to digest frames in + * sleep_q to avoid running out of xmitframe + */ if (psta->sleepq_len > (NR_XMITFRAME / pstapriv->asoc_list_cnt) && - padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME / pstapriv->asoc_list_cnt / 2)) + padapter->xmitpriv.free_xmitframe_cnt < + (NR_XMITFRAME / pstapriv->asoc_list_cnt / 2)) wakeup_sta_to_xmit(padapter, psta); } } -- cgit v1.2.3 From 56315e55119c0ea57e142b6efb7c31208628ad86 Mon Sep 17 00:00:00 2001 From: Christophe JAILLET Date: Wed, 21 Jul 2021 10:45:11 +0200 Subject: staging: ks7010: Fix the initialization of the 'sleep_status' structure 'sleep_status' has 3 atomic_t members. Initialize the 3 of them instead of initializing only 2 of them and setting 0 twice to the same variable. Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/d2e52a33a9beab41879551d0ae2fdfc99970adab.1626856991.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks7010_sdio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c index cbc0032c1604..98d759e7cc95 100644 --- a/drivers/staging/ks7010/ks7010_sdio.c +++ b/drivers/staging/ks7010/ks7010_sdio.c @@ -939,9 +939,9 @@ static void ks7010_private_init(struct ks_wlan_private *priv, memset(&priv->wstats, 0, sizeof(priv->wstats)); /* sleep mode */ + atomic_set(&priv->sleepstatus.status, 0); atomic_set(&priv->sleepstatus.doze_request, 0); atomic_set(&priv->sleepstatus.wakeup_request, 0); - atomic_set(&priv->sleepstatus.wakeup_request, 0); trx_device_init(priv); hostif_init(priv); -- cgit v1.2.3 From fa8db3989362866ea1beb1314fc4e86f373a6425 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sat, 17 Jul 2021 18:05:12 +0200 Subject: staging/most: Remove all strcpy() uses in favor of strscpy() strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210717160512.16176-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/most/video/video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/most/video/video.c b/drivers/staging/most/video/video.c index 90933d78c332..b7858e47145f 100644 --- a/drivers/staging/most/video/video.c +++ b/drivers/staging/most/video/video.c @@ -258,7 +258,7 @@ static int vidioc_enum_fmt_vid_cap(struct file *file, void *priv, if (f->index) return -EINVAL; - strcpy(f->description, "MPEG"); + strscpy(f->description, "MPEG", sizeof(f->description)); f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE; f->flags = V4L2_FMT_FLAG_COMPRESSED; f->pixelformat = V4L2_PIX_FMT_MPEG; @@ -306,7 +306,7 @@ static int vidioc_enum_input(struct file *file, void *priv, if (input->index >= V4L2_CMP_MAX_INPUT) return -EINVAL; - strcpy(input->name, "MOST Video"); + strscpy(input->name, "MOST Video", sizeof(input->name)); input->type |= V4L2_INPUT_TYPE_CAMERA; input->audioset = 0; -- cgit v1.2.3 From c10fe0cc3ec4089d5da21faa732d74a40efbc07a Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sat, 17 Jul 2021 17:20:32 +0200 Subject: staging/wlan-ng: Remove all strcpy() uses in favor of strscpy() strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210717152032.10164-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2fw.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/prism2fw.c b/drivers/staging/wlan-ng/prism2fw.c index 94800c007162..02a2191d5c4d 100644 --- a/drivers/staging/wlan-ng/prism2fw.c +++ b/drivers/staging/wlan-ng/prism2fw.c @@ -296,7 +296,7 @@ static int prism2_fwapply(const struct ihex_binrec *rfptr, memset(&getmsg, 0, sizeof(getmsg)); getmsg.msgcode = DIDMSG_DOT11REQ_MIBGET; getmsg.msglen = sizeof(getmsg); - strcpy(getmsg.devname, wlandev->name); + strscpy(getmsg.devname, wlandev->name, sizeof(getmsg.devname)); getmsg.mibattribute.did = DIDMSG_DOT11REQ_MIBGET_MIBATTRIBUTE; getmsg.mibattribute.status = P80211ENUM_msgitem_status_data_ok; @@ -786,7 +786,7 @@ static int read_cardpda(struct pda *pda, struct wlandevice *wlandev) /* set up the msg */ msg->msgcode = DIDMSG_P2REQ_READPDA; msg->msglen = sizeof(msg); - strcpy(msg->devname, wlandev->name); + strscpy(msg->devname, wlandev->name, sizeof(msg->devname)); msg->pda.did = DIDMSG_P2REQ_READPDA_PDA; msg->pda.len = HFA384x_PDA_LEN_MAX; msg->pda.status = P80211ENUM_msgitem_status_no_value; @@ -1017,7 +1017,7 @@ static int writeimage(struct wlandevice *wlandev, struct imgchunk *fchunk, } /* Initialize the messages */ - strcpy(rstmsg->devname, wlandev->name); + strscpy(rstmsg->devname, wlandev->name, sizeof(rstmsg->devname)); rstmsg->msgcode = DIDMSG_P2REQ_RAMDL_STATE; rstmsg->msglen = sizeof(*rstmsg); rstmsg->enable.did = DIDMSG_P2REQ_RAMDL_STATE_ENABLE; @@ -1030,7 +1030,7 @@ static int writeimage(struct wlandevice *wlandev, struct imgchunk *fchunk, rstmsg->exeaddr.len = sizeof(u32); rstmsg->resultcode.len = sizeof(u32); - strcpy(rwrmsg->devname, wlandev->name); + strscpy(rwrmsg->devname, wlandev->name, sizeof(rwrmsg->devname)); rwrmsg->msgcode = DIDMSG_P2REQ_RAMDL_WRITE; rwrmsg->msglen = sizeof(*rwrmsg); rwrmsg->addr.did = DIDMSG_P2REQ_RAMDL_WRITE_ADDR; -- cgit v1.2.3 From eeacf4cce0b183c2cf61a9c1ea6db7a0ab9c2600 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 23 Jul 2021 21:26:19 +0200 Subject: staging: rtl8188eu: Replace a custom function with crc32_le() Use crc32_le() in place of the custom getcrc32(). Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210723192620.10669-2-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 45 +++++++++++---------------- 1 file changed, 19 insertions(+), 26 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 1b2cb6196463..7001f24f118d 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -11,6 +11,7 @@ #include #include #include +#include /* WEP related ===== */ @@ -111,21 +112,6 @@ static void crc32_init(void) bcrc32initialized = 1; } -static __le32 getcrc32(u8 *buf, int len) -{ - u8 *p; - u32 crc; - - if (bcrc32initialized == 0) - crc32_init(); - - crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ - - for (p = buf; len > 0; ++p, --len) - crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); - return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ -} - /* Need to consider the fragment situation */ void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { @@ -564,7 +550,10 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) u32 pnh; u8 rc4key[16]; u8 ttkey[16]; - u8 crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; u8 hw_hdr_offset = 0; struct arc4context mycontext; int curfragnum, length; @@ -609,17 +598,18 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; - *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc, 4); + arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); } else { length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; - *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); + arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc, 4); + arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)round_up((size_t)(pframe), 4); @@ -639,7 +629,10 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe) u32 pnh; u8 rc4key[16]; u8 ttkey[16]; - u8 crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; struct arc4context mycontext; int length; u8 *pframe, *payload, *iv, *prwskey; @@ -682,12 +675,12 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe) arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - *((__le32 *)crc) = getcrc32(payload, length - 4); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length - 4)); - if (crc[3] != payload[length - 1] || - crc[2] != payload[length - 2] || - crc[1] != payload[length - 3] || - crc[0] != payload[length - 4]) + if (crc.f1[3] != payload[length - 1] || + crc.f1[2] != payload[length - 2] || + crc.f1[1] != payload[length - 3] || + crc.f1[0] != payload[length - 4]) res = _FAIL; } else { res = _FAIL; -- cgit v1.2.3 From 51f59d684b0c65563ad16e5e179ad021a05951c5 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 23 Jul 2021 21:26:20 +0200 Subject: staging: rtl8188eu: Remove no more used functions and variables Remove the functions and variables from rtw_security.c that are no more necessary since the patch that replaces getcrc32() with crc32_le(). Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210723192620.10669-3-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_security.c | 36 --------------------------- 1 file changed, 36 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c index 7001f24f118d..7185c1ae2ab8 100644 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ b/drivers/staging/rtl8188eu/core/rtw_security.c @@ -76,42 +76,6 @@ static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); } -static int bcrc32initialized; -static u32 crc32_table[256]; - -static u8 crc32_reverseBit(u8 data) -{ - return (u8)((data << 7) & 0x80) | ((data << 5) & 0x40) | ((data << 3) & 0x20) | - ((data << 1) & 0x10) | ((data >> 1) & 0x08) | ((data >> 3) & 0x04) | - ((data >> 5) & 0x02) | ((data >> 7) & 0x01); -} - -static void crc32_init(void) -{ - int i, j; - u32 c; - u8 *p = (u8 *)&c, *p1; - u8 k; - - if (bcrc32initialized == 1) - return; - - c = 0x12340000; - - for (i = 0; i < 256; ++i) { - k = crc32_reverseBit((u8)i); - for (c = ((u32)k) << 24, j = 8; j > 0; --j) - c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); - p1 = (u8 *)&crc32_table[i]; - - p1[0] = crc32_reverseBit(p[3]); - p1[1] = crc32_reverseBit(p[2]); - p1[2] = crc32_reverseBit(p[1]); - p1[3] = crc32_reverseBit(p[0]); - } - bcrc32initialized = 1; -} - /* Need to consider the fragment situation */ void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) { -- cgit v1.2.3 From 1f0873da312d0a7686d628fcab91c0606ffab893 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 26 Jul 2021 11:10:14 +0200 Subject: staging: rtl8188eu: remove blank lines Remove unnecessary blank lines reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210726091014.21405-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 1 - drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 1 - drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 1 - 3 files changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c index 25653ebfaafd..b1fe30e9a2b4 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c @@ -4723,7 +4723,6 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; break; } - } } break; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 2afef26ddb56..6cf87312bc36 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -455,7 +455,6 @@ void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool Auto hal_com_get_channel_plan(hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF, padapter->registrypriv.channel_plan, RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail); - } void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c index eef8ed71cdef..fddc8dd6632f 100644 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c @@ -1207,7 +1207,6 @@ static int rtw_wx_set_essid(struct net_device *dev, if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.ssid_length)) && (pnetwork->network.ssid.ssid_length == ndis_ssid.ssid_length)) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) continue; -- cgit v1.2.3 From 2490e3230245fd0fd3726ec06f3947ca81d0b761 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 26 Jul 2021 11:21:29 +0200 Subject: staging: rtl8188eu: remove braces from single line if blocks Remove braces from single line if blocks to clear checkpatch warnings. WARNING: braces {} are not necessary for single statement blocks Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210726092129.30334-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_cmd.c | 3 +-- drivers/staging/rtl8188eu/core/rtw_mlme.c | 3 +-- drivers/staging/rtl8188eu/core/rtw_xmit.c | 3 +-- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 3 +-- drivers/staging/rtl8188eu/hal/usb_halinit.c | 6 ++---- 5 files changed, 6 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c index eb89a52aa4e3..56ece839c9ca 100644 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ b/drivers/staging/rtl8188eu/core/rtw_cmd.c @@ -1159,9 +1159,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); if (!psta) { psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); - if (!psta) { + if (!psta) goto createbss_cmd_fail; - } } rtw_indicate_connect(padapter); diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 71d205f3d73d..0d334aba9a3f 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c @@ -953,9 +953,8 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) rtw_indicate_connect(adapter); - } /* s5. Cancel assoc_timer */ del_timer_sync(&pmlmepriv->assoc_timer); diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c index d5fc59417ec6..c77ebd18f40c 100644 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ b/drivers/staging/rtl8188eu/core/rtw_xmit.c @@ -1124,9 +1124,8 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) list_del_init(&pxmitbuf->list); pxmitpriv->free_xmitbuf_cnt--; pxmitbuf->priv_data = NULL; - if (pxmitbuf->sctx) { + if (pxmitbuf->sctx) rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); - } } spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index 6cf87312bc36..a67615708745 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -510,7 +510,6 @@ void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool Aut else pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; - if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) { + if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; - } } diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 1d7d5037ce89..3e8f7315d377 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -641,9 +641,8 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) } status = rtw_hal_power_on(Adapter); - if (status == _FAIL) { + if (status == _FAIL) goto exit; - } /* Save target channel */ haldata->CurrentChannel = 6;/* default set to 6 */ @@ -696,9 +695,8 @@ u32 rtl8188eu_hal_init(struct adapter *Adapter) _InitTxBufferBoundary(Adapter, txpktbuf_bndy); status = InitLLTTable(Adapter, txpktbuf_bndy); - if (status == _FAIL) { + if (status == _FAIL) goto exit; - } /* Get Rx PHY status in order to report RSSI and others. */ _InitDriverInfoSize(Adapter, DRVINFO_SZ); -- cgit v1.2.3 From 2d9f8c5ae660ba1303d155fc9462de39da440494 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:45 +0200 Subject: staging: rtl8188eu: remove unused defines Now that power cut mask is not used any more, we can also remove the defines for power cut masks. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-1-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/pwrseqcmd.h | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h index bfa0405cccde..bbf4f302c9f4 100644 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ b/drivers/staging/rtl8188eu/include/pwrseqcmd.h @@ -15,17 +15,6 @@ #define PWR_CMD_DELAY 0x03 #define PWR_CMD_END 0x04 -/* The value of cut_msk: 8 bits */ -#define PWR_CUT_TESTCHIP_MSK BIT(0) -#define PWR_CUT_A_MSK BIT(1) -#define PWR_CUT_B_MSK BIT(2) -#define PWR_CUT_C_MSK BIT(3) -#define PWR_CUT_D_MSK BIT(4) -#define PWR_CUT_E_MSK BIT(5) -#define PWR_CUT_F_MSK BIT(6) -#define PWR_CUT_G_MSK BIT(7) -#define PWR_CUT_ALL_MSK 0xFF - enum pwrseq_cmd_delat_unit { PWRSEQ_DELAY_US, PWRSEQ_DELAY_MS, -- cgit v1.2.3 From 20a55e6c707a24de7fa4dfcd393c4a73272465d5 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:46 +0200 Subject: staging: rtl8188eu: remove HW_VAR_MEDIA_STATUS1 The "HAL layer variable" HW_VAR_MEDIA_STATUS1 is not used in this driver. Remove its define and the code for setting a value. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 9 --------- drivers/staging/rtl8188eu/include/hal_intf.h | 1 - 2 files changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 3e8f7315d377..c3de69ee6841 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1133,15 +1133,6 @@ void rtw_hal_set_hwreg(struct adapter *Adapter, u8 variable, u8 *val) usb_write8(Adapter, MSR, val8); } break; - case HW_VAR_MEDIA_STATUS1: - { - u8 val8; - - val8 = usb_read8(Adapter, MSR) & 0x03; - val8 |= *((u8 *)val) << 2; - usb_write8(Adapter, MSR, val8); - } - break; case HW_VAR_SET_OPMODE: hw_var_set_opmode(Adapter, variable, val); break; diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 4d4e0a259050..e2ce71db3fa1 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -13,7 +13,6 @@ enum hw_variables { HW_VAR_MEDIA_STATUS, - HW_VAR_MEDIA_STATUS1, HW_VAR_SET_OPMODE, HW_VAR_MAC_ADDR, HW_VAR_BSSID, -- cgit v1.2.3 From bb3462f46462e4d5a66170e3b0c63c1a44c6011d Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:47 +0200 Subject: staging: rtl8188eu: remove HW_VAR_TXPAUSE The "HAL layer variable" HW_VAR_TXPAUSE is not used in this driver. Remove its define and the code for setting and for reading a value. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-3-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 6 ------ drivers/staging/rtl8188eu/include/hal_intf.h | 1 - 2 files changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index c3de69ee6841..bc5dcef8c356 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -1176,9 +1176,6 @@ void rtw_hal_set_hwreg(struct adapter *Adapter, u8 variable, u8 *val) usb_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); } break; - case HW_VAR_TXPAUSE: - usb_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); - break; case HW_VAR_BCN_FUNC: hw_var_set_bcn_func(Adapter, variable, val); break; @@ -1611,9 +1608,6 @@ void rtw_hal_get_hwreg(struct adapter *Adapter, u8 variable, u8 *val) case HW_VAR_BASIC_RATE: *((u16 *)(val)) = Adapter->HalData->BasicRateSet; fallthrough; - case HW_VAR_TXPAUSE: - val[0] = usb_read8(Adapter, REG_TXPAUSE); - break; case HW_VAR_BCN_VALID: /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ val[0] = (BIT(0) & usb_read8(Adapter, REG_TDECTRL + 2)) ? true : false; diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index e2ce71db3fa1..ad0a6bd5f510 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -18,7 +18,6 @@ enum hw_variables { HW_VAR_BSSID, HW_VAR_INIT_RTS_RATE, HW_VAR_BASIC_RATE, - HW_VAR_TXPAUSE, HW_VAR_BCN_FUNC, HW_VAR_CORRECT_TSF, HW_VAR_CHECK_BSSID, -- cgit v1.2.3 From 3e04209f341052b4a885d20dd1c81f409bcf82b6 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:48 +0200 Subject: staging: rtl8188eu: simplify Hal_EfuseParseMACAddr_8188EU The hwinfo and AutoLoadFail parameters can be obtained from struct adapter, there's no need to pass them as separate function parameters. Use memcpy instead of bytewise copy if we have to fall back to the hard-coded mac address. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-4-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index bc5dcef8c356..61b9f39c4121 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -950,19 +950,16 @@ static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool } } -static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) +static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt) { - u16 i; - u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; + u8 sMacAddr[] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); + u8 *hwinfo = eeprom->efuse_eeprom_data; - if (AutoLoadFail) { - for (i = 0; i < 6; i++) - eeprom->mac_addr[i] = sMacAddr[i]; - } else { - /* Read Permanent MAC address */ + if (eeprom->bautoload_fail_flag) + memcpy(eeprom->mac_addr, sMacAddr, sizeof(sMacAddr)); + else memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); - } } static void readAdapterInfo_8188EU(struct adapter *adapt) @@ -972,7 +969,7 @@ static void readAdapterInfo_8188EU(struct adapter *adapt) /* parse the eeprom/efuse content */ Hal_EfuseParseIDCode88E(adapt, eeprom->efuse_eeprom_data); Hal_EfuseParsePIDVID_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_EfuseParseMACAddr_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseMACAddr_8188EU(adapt); Hal_ReadPowerSavingMode88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); Hal_ReadTxPowerInfo88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); -- cgit v1.2.3 From c51a9ea6b4d00fbd212a96391ca494fb6c926e38 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:49 +0200 Subject: staging: rtl8188eu: remove an unused enum The hal_intf_ps_func enum is not used. Remove it. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-5-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_intf.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index ad0a6bd5f510..8aa4ebd6440f 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -105,11 +105,6 @@ enum hal_odm_variable { HAL_ODM_WIFI_DISPLAY_STATE, }; -enum hal_intf_ps_func { - HAL_USB_SELECT_SUSPEND, - HAL_MAX_ID, -}; - enum rt_eeprom_type { EEPROM_93C46, EEPROM_93C56, -- cgit v1.2.3 From b5b6cf1a2643f28c77a13d1c13678cb44cd552a6 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:50 +0200 Subject: staging: rtl8188eu: remove another unused enum The rt_eeprom_type enum is not used. Remove it. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-6-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_intf.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 8aa4ebd6440f..4328431d6015 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -105,12 +105,6 @@ enum hal_odm_variable { HAL_ODM_WIFI_DISPLAY_STATE, }; -enum rt_eeprom_type { - EEPROM_93C46, - EEPROM_93C56, - EEPROM_BOOT_EFUSE, -}; - #define RF_CHANGE_BY_INIT 0 #define RF_CHANGE_BY_IPS BIT(28) #define RF_CHANGE_BY_PS BIT(29) -- cgit v1.2.3 From fc9336eb526c28b92c8e89b735582a3af7af2431 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:51 +0200 Subject: staging: rtl8188eu: remove a bunch of unused defines Only RF_CHANGE_BY_PS is used by this driver, the other RF_CHANGE_BY_... defines can be removed. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-7-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_intf.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 4328431d6015..8396659f6acb 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -105,11 +105,7 @@ enum hal_odm_variable { HAL_ODM_WIFI_DISPLAY_STATE, }; -#define RF_CHANGE_BY_INIT 0 -#define RF_CHANGE_BY_IPS BIT(28) #define RF_CHANGE_BY_PS BIT(29) -#define RF_CHANGE_BY_HW BIT(30) -#define RF_CHANGE_BY_SW BIT(31) enum hardware_type { HARDWARE_TYPE_RTL8188EU, -- cgit v1.2.3 From 448390332cfb2b033f632f6ec054cdd645a023dc Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:52 +0200 Subject: staging: rtl8188eu: remove yet another unused enum The hardware_type enum is not used. Remove it. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-8-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/include/hal_intf.h | 5 ----- 1 file changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h index 8396659f6acb..12a585c0d0f2 100644 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ b/drivers/staging/rtl8188eu/include/hal_intf.h @@ -107,11 +107,6 @@ enum hal_odm_variable { #define RF_CHANGE_BY_PS BIT(29) -enum hardware_type { - HARDWARE_TYPE_RTL8188EU, - HARDWARE_TYPE_MAX, -}; - #define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level); -- cgit v1.2.3 From 55937c27cd438a832922f93be2fdd17bdd1b05ed Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:53 +0200 Subject: staging: rtl8188eu: remove unused _HAL_INTF_C_ define This define can be removed. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-9-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/hal_intf.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c index f09620c54e69..3e132e00c81c 100644 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ b/drivers/staging/rtl8188eu/hal/hal_intf.c @@ -5,7 +5,6 @@ * ******************************************************************************/ -#define _HAL_INTF_C_ #include uint rtw_hal_init(struct adapter *adapt) -- cgit v1.2.3 From e79942ec2ccbbc26b6a66861377810f9f6db3f4c Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:54 +0200 Subject: staging: rtl8188eu: remove write-only power struct component pwrpriv->bFwCurrentInPSMode is initialized and updated but nobody reads its value. Remove this write-only component. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-10-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 3 --- drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 3 --- drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 1 - 3 files changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c index cbb34b920ab9..f1af49af1105 100644 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c @@ -335,7 +335,6 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ if (ps_mode == PS_MODE_ACTIVE) { if (PS_RDY_CHECK(padapter)) { - pwrpriv->bFwCurrentInPSMode = true; pwrpriv->pwr_mode = ps_mode; pwrpriv->smart_ps = smart_ps; pwrpriv->bcn_ant_mode = bcn_ant_mode; @@ -461,8 +460,6 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE); - pwrctrlpriv->bFwCurrentInPSMode = false; - pwrctrlpriv->rpwm = 0; pwrctrlpriv->cpwm = PS_STATE_S4; diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c index a67615708745..7bf807e317d1 100644 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c @@ -95,9 +95,6 @@ void _8051Reset88E(struct adapter *padapter) void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) { - /* Init Fw LPS related. */ - padapter->pwrctrlpriv.bFwCurrentInPSMode = false; - /* Init H2C counter. by tynli. 2009.12.09. */ padapter->HalData->LastHMEBoxNum = 0; } diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h index 4345dc0c7cf9..78febd3605c7 100644 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h @@ -174,7 +174,6 @@ struct pwrctrl_priv { bool bLeisurePs; u8 LpsIdleCount; u8 power_mgnt; - u8 bFwCurrentInPSMode; u32 DelayLPSLastTimeStamp; u8 btcoex_rfon; s32 pnp_current_pwr_state; -- cgit v1.2.3 From bd4680034d1fcb292761bb52a33143827025cac2 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:55 +0200 Subject: staging: rtl8188eu: remove two write-only hal components RegTxPause and RegBcnCtrlVal from struct hal_data_8188e are set but never read. Remove them. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-11-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 -- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 3 --- 2 files changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 61b9f39c4121..f50fdb537203 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -563,8 +563,6 @@ static void _InitBeaconParameters(struct adapter *Adapter) /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ usb_write16(Adapter, REG_BCNTCFG, 0x660F); - haldata->RegBcnCtrlVal = usb_read8(Adapter, REG_BCN_CTRL); - haldata->RegTxPause = usb_read8(Adapter, REG_TXPAUSE); haldata->RegFwHwTxQCtrl = usb_read8(Adapter, REG_FWHW_TXQ_CTRL + 2); haldata->RegReg542 = usb_read8(Adapter, REG_TBTT_PROHIBIT + 2); haldata->RegCR_1 = usb_read8(Adapter, REG_CR + 1); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index e508b4b9ef7f..9aba67233c24 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -230,9 +230,6 @@ struct hal_data_8188e { /* for host message to fw */ u8 LastHMEBoxNum; - u8 RegTxPause; - /* Beacon function related global variable. */ - u32 RegBcnCtrlVal; u8 RegFwHwTxQCtrl; u8 RegReg542; u8 RegCR_1; -- cgit v1.2.3 From f3946501899998c02f2444a6fbfa5ec46fbe3a86 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:56 +0200 Subject: staging: rtl8188eu: remove unused IntrMask The IntrMask array is set but never read. Remove it. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-12-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 2 -- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 1 - 2 files changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index f50fdb537203..49e49db2f2da 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -118,11 +118,9 @@ static void _InitInterrupt(struct adapter *Adapter) /* HIMR - */ imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E; usb_write32(Adapter, REG_HIMR_88E, imr); - Adapter->HalData->IntrMask[0] = imr; imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E; usb_write32(Adapter, REG_HIMRE_88E, imr_ex); - Adapter->HalData->IntrMask[1] = imr_ex; /* REG_USB_SPECIAL_OPTION - BIT(4) */ /* 0; Use interrupt endpoint to upload interrupt pkt */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 9aba67233c24..7d95943fc05e 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -262,7 +262,6 @@ struct hal_data_8188e { /* Interrupt relatd register information. */ u32 IntArray[3];/* HISR0,HISR1,HSISR */ - u32 IntrMask[3]; u8 C2hArray[16]; u8 UsbTxAggMode; u8 UsbTxAggDescNum; -- cgit v1.2.3 From 99e7a944281e21edff48bab0bbe16a793246c5d8 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:57 +0200 Subject: staging: rtl8188eu: remove write-only HwRxPageSize HwRxPageSize from struct hal_data_8188e is set but never read. Remove the component and the code to initialise it. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-13-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 20 -------------------- drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 1 - drivers/staging/rtl8188eu/include/rtl8188e_spec.h | 4 ---- 3 files changed, 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c index 49e49db2f2da..2de5564e8cd7 100644 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ b/drivers/staging/rtl8188eu/hal/usb_halinit.c @@ -515,26 +515,6 @@ static void usb_AggSettingRxUpdate(struct adapter *Adapter) /* TODO: */ break; } - - switch (PBP_128) { - case PBP_128: - haldata->HwRxPageSize = 128; - break; - case PBP_64: - haldata->HwRxPageSize = 64; - break; - case PBP_256: - haldata->HwRxPageSize = 256; - break; - case PBP_512: - haldata->HwRxPageSize = 512; - break; - case PBP_1024: - haldata->HwRxPageSize = 1024; - break; - default: - break; - } } /* usb_AggSettingRxUpdate */ static void InitUsbAggregationSetting(struct adapter *Adapter) diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h index 7d95943fc05e..3e697a3321e1 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h @@ -265,7 +265,6 @@ struct hal_data_8188e { u8 C2hArray[16]; u8 UsbTxAggMode; u8 UsbTxAggDescNum; - u16 HwRxPageSize; /* Hardware setting */ enum usb_rx_agg_mode UsbRxAggMode; u8 UsbRxAggBlockCount; /* USB Block count. Block size is diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h index fe0871bbb95f..c7be0a1d70b9 100644 --- a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h @@ -803,11 +803,7 @@ So the following defines for 92C is not entire!!!!!! #define _PSRX(x) (x) #define _PSTX(x) ((x) << 4) -#define PBP_64 0x0 #define PBP_128 0x1 -#define PBP_256 0x2 -#define PBP_512 0x3 -#define PBP_1024 0x4 /* 2 TX/RXDMA */ #define RXDMA_ARBBW_EN BIT(0) -- cgit v1.2.3 From e17c7d42cd33a6744b0fd0bb33a1308094b73457 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Mon, 26 Jul 2021 21:53:54 +0200 Subject: staging: rtl8188eu: simplify rtl88eu_phy_iq_calibrate The boolean is2t variable in rtl88eu_phy_iq_calibrate is always false. Remove some code that's unused in this case. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210726195354.28548-1-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 65 ++----------------------------------- 1 file changed, 3 insertions(+), 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 256f87b9d630..fcac885b6581 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -703,53 +703,6 @@ static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], } } -static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], - u8 final_candidate, bool txonly) -{ - u32 oldval_1, x, tx1_a, reg; - s32 y, tx1_c; - - if (final_candidate == 0xFF) { - return; - } else if (iqkok) { - oldval_1 = (phy_query_bb_reg(adapt, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; - - x = result[final_candidate][4]; - if ((x & 0x00000200) != 0) - x = x | 0xFFFFFC00; - tx1_a = (x * oldval_1) >> 8; - phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, 0x3FF, tx1_a); - - phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(27), - ((x * oldval_1 >> 7) & 0x1)); - - y = result[final_candidate][5]; - if ((y & 0x00000200) != 0) - y = y | 0xFFFFFC00; - - tx1_c = (y * oldval_1) >> 8; - - phy_set_bb_reg(adapt, rOFDM0_XDTxAFE, 0xF0000000, - ((tx1_c & 0x3C0) >> 6)); - phy_set_bb_reg(adapt, rOFDM0_XBTxIQImbalance, 0x003F0000, - (tx1_c & 0x3F)); - phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(25), - ((y * oldval_1 >> 7) & 0x1)); - - if (txonly) - return; - - reg = result[final_candidate][6]; - phy_set_bb_reg(adapt, rOFDM0_XBRxIQImbalance, 0x3FF, reg); - - reg = result[final_candidate][7] & 0x3F; - phy_set_bb_reg(adapt, rOFDM0_XBRxIQImbalance, 0xFC00, reg); - - reg = (result[final_candidate][7] >> 6) & 0xF; - phy_set_bb_reg(adapt, rOFDM0_AGCRSSITable, 0x0000F000, reg); - } -} - static void save_adda_registers(struct adapter *adapt, const u32 *addareg, u32 *backup, u32 register_num) { @@ -1150,8 +1103,8 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) struct odm_dm_struct *dm_odm = &adapt->HalData->odmpriv; s32 result[4][8]; u8 i, final; - bool pathaok, pathbok; - s32 reg_e94, reg_e9c, reg_ea4, reg_eb4, reg_ebc, reg_ec4; + bool pathaok; + s32 reg_e94, reg_e9c, reg_ea4, reg_eb4, reg_ebc; bool is12simular, is13simular, is23simular; u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, @@ -1159,9 +1112,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, rOFDM0_RxIQExtAnta}; - bool is2t; - - is2t = false; if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) return; @@ -1178,13 +1128,12 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) final = 0xff; pathaok = false; - pathbok = false; is12simular = false; is23simular = false; is13simular = false; for (i = 0; i < 3; i++) { - phy_iq_calibrate(adapt, result, i, is2t); + phy_iq_calibrate(adapt, result, i, false); if (i == 1) { is12simular = simularity_compare(adapt, result, 0, 1); @@ -1214,7 +1163,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) reg_ea4 = result[i][2]; reg_eb4 = result[i][4]; reg_ebc = result[i][5]; - reg_ec4 = result[i][6]; } if (final != 0xff) { @@ -1227,9 +1175,7 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) dm_odm->RFCalibrateInfo.RegE9C = reg_e9c; dm_odm->RFCalibrateInfo.RegEB4 = reg_eb4; dm_odm->RFCalibrateInfo.RegEBC = reg_ebc; - reg_ec4 = result[final][6]; pathaok = true; - pathbok = true; } else { dm_odm->RFCalibrateInfo.RegE94 = 0x100; dm_odm->RFCalibrateInfo.RegEB4 = 0x100; @@ -1239,11 +1185,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) if (reg_e94 != 0) patha_fill_iqk(adapt, pathaok, result, final, (reg_ea4 == 0)); - if (is2t) { - if (reg_eb4 != 0) - pathb_fill_iqk(adapt, pathbok, result, final, - (reg_ec4 == 0)); - } if (final < 4) { for (i = 0; i < IQK_Matrix_REG_NUM; i++) -- cgit v1.2.3 From a70a91b01db1ae821cd939152ffe2b613fb70404 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:58:59 +0200 Subject: staging: rtl8188eu: simplify phy_iq_calibrate phy_iq_calibrate's is2t parameter is always false. Remove some code that would be called only for is2t == true. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-15-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 91 +++---------------------------------- 1 file changed, 6 insertions(+), 85 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index fcac885b6581..643d846f572c 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -625,38 +625,6 @@ static u8 phy_path_a_rx_iqk(struct adapter *adapt, bool configPathB) return result; } -static u8 phy_path_b_iqk(struct adapter *adapt) -{ - u32 regeac, regeb4, regebc, regec4, regecc; - u8 result = 0x00; - - /* One shot, path B LOK & IQK */ - phy_set_bb_reg(adapt, rIQK_AGC_Cont, bMaskDWord, 0x00000002); - phy_set_bb_reg(adapt, rIQK_AGC_Cont, bMaskDWord, 0x00000000); - - mdelay(IQK_DELAY_TIME_88E); - - regeac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); - regeb4 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_B, bMaskDWord); - regebc = phy_query_bb_reg(adapt, rTx_Power_After_IQK_B, bMaskDWord); - regec4 = phy_query_bb_reg(adapt, rRx_Power_Before_IQK_B_2, bMaskDWord); - regecc = phy_query_bb_reg(adapt, rRx_Power_After_IQK_B_2, bMaskDWord); - - if (!(regeac & BIT(31)) && - (((regeb4 & 0x03FF0000) >> 16) != 0x142) && - (((regebc & 0x03FF0000) >> 16) != 0x42)) - result |= 0x01; - else - return result; - - if (!(regeac & BIT(30)) && - (((regec4 & 0x03FF0000) >> 16) != 0x132) && - (((regecc & 0x03FF0000) >> 16) != 0x36)) - result |= 0x02; - - return result; -} - static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) { @@ -774,13 +742,6 @@ static void mac_setting_calibration(struct adapter *adapt, const u32 *mac_reg, usb_write8(adapt, mac_reg[i], (u8)(backup[i] & (~BIT(5)))); } -static void path_a_standby(struct adapter *adapt) -{ - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x0); - phy_set_bb_reg(adapt, 0x840, bMaskDWord, 0x00010000); - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); -} - static void pi_mode_switch(struct adapter *adapt, bool pi_mode) { u32 mode; @@ -865,11 +826,11 @@ static bool simularity_compare(struct adapter *adapt, s32 resulta[][8], } static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], - u8 t, bool is2t) + u8 t) { struct odm_dm_struct *dm_odm = &adapt->HalData->odmpriv; u32 i; - u8 path_a_ok, path_b_ok; + u8 path_a_ok; static const u32 adda_reg[IQK_ADDA_REG_NUM] = { rFPGA0_XCD_SwitchControl, rBlue_Tooth, rRx_Wait_CCA, rTx_CCK_RFON, @@ -909,7 +870,7 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); } - path_adda_on(adapt, adda_reg, true, is2t); + path_adda_on(adapt, adda_reg, true, false); if (t == 0) dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, BIT(8)); @@ -930,13 +891,6 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], phy_set_bb_reg(adapt, rFPGA0_XA_RFInterfaceOE, BIT(10), 0x00); phy_set_bb_reg(adapt, rFPGA0_XB_RFInterfaceOE, BIT(10), 0x00); - if (is2t) { - phy_set_bb_reg(adapt, rFPGA0_XA_LSSIParameter, bMaskDWord, - 0x00010000); - phy_set_bb_reg(adapt, rFPGA0_XB_LSSIParameter, bMaskDWord, - 0x00010000); - } - /* MAC settings */ mac_setting_calibration(adapt, iqk_mac_reg, dm_odm->RFCalibrateInfo.IQK_MAC_backup); @@ -945,16 +899,13 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], /* AP or IQK */ phy_set_bb_reg(adapt, rConfig_AntA, bMaskDWord, 0x0f600000); - if (is2t) - phy_set_bb_reg(adapt, rConfig_AntB, bMaskDWord, 0x0f600000); - /* IQ calibration setting */ phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, 0x01007c00); phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x81004800); for (i = 0; i < retry_count; i++) { - path_a_ok = phy_path_a_iqk(adapt, is2t); + path_a_ok = phy_path_a_iqk(adapt, false); if (path_a_ok == 0x01) { result[t][0] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord) & 0x3FF0000) >> 16; @@ -965,7 +916,7 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], } for (i = 0; i < retry_count; i++) { - path_a_ok = phy_path_a_rx_iqk(adapt, is2t); + path_a_ok = phy_path_a_rx_iqk(adapt, false); if (path_a_ok == 0x03) { result[t][2] = (phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord) & 0x3FF0000) >> 16; @@ -975,33 +926,6 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], } } - if (is2t) { - path_a_standby(adapt); - - /* Turn Path B ADDA on */ - path_adda_on(adapt, adda_reg, false, is2t); - - for (i = 0; i < retry_count; i++) { - path_b_ok = phy_path_b_iqk(adapt); - if (path_b_ok == 0x03) { - result[t][4] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_B, - bMaskDWord) & 0x3FF0000) >> 16; - result[t][5] = (phy_query_bb_reg(adapt, rTx_Power_After_IQK_B, - bMaskDWord) & 0x3FF0000) >> 16; - result[t][6] = (phy_query_bb_reg(adapt, rRx_Power_Before_IQK_B_2, - bMaskDWord) & 0x3FF0000) >> 16; - result[t][7] = (phy_query_bb_reg(adapt, rRx_Power_After_IQK_B_2, - bMaskDWord) & 0x3FF0000) >> 16; - break; - } else if (i == (retry_count - 1) && path_b_ok == 0x01) { /* Tx IQK OK */ - result[t][4] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_B, - bMaskDWord) & 0x3FF0000) >> 16; - result[t][5] = (phy_query_bb_reg(adapt, rTx_Power_After_IQK_B, - bMaskDWord) & 0x3FF0000) >> 16; - } - } - } - /* Back to BB mode, load original value */ phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0); @@ -1027,9 +951,6 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], /* Restore RX initial gain */ phy_set_bb_reg(adapt, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3); - if (is2t) - phy_set_bb_reg(adapt, rFPGA0_XB_LSSIParameter, - bMaskDWord, 0x00032ed3); /* load 0xe30 IQC default value */ phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); @@ -1133,7 +1054,7 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) is13simular = false; for (i = 0; i < 3; i++) { - phy_iq_calibrate(adapt, result, i, false); + phy_iq_calibrate(adapt, result, i); if (i == 1) { is12simular = simularity_compare(adapt, result, 0, 1); -- cgit v1.2.3 From b973e25ef6a8f2b7d9bbd0875530a586a0c67087 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:59:00 +0200 Subject: staging: rtl8188eu: simplify path_adda_on path_adda_on's is2t parameter is always false. Remove some code that would be called only for is2t == true. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-16-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 643d846f572c..a6181b94395e 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -711,19 +711,13 @@ static void reload_mac_registers(struct adapter *adapt, const u32 *mac_reg, usb_write32(adapt, mac_reg[i], backup[i]); } -static void path_adda_on(struct adapter *adapt, const u32 *adda_reg, - bool is_path_a_on, bool is2t) +static void path_adda_on(struct adapter *adapt, const u32 *adda_reg, bool is_path_a_on) { u32 path_on; u32 i; - if (!is2t) { - path_on = 0x0bdb25a0; - phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, 0x0b1b25a0); - } else { - path_on = is_path_a_on ? 0x04db25a4 : 0x0b1b25a4; - phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, path_on); - } + path_on = 0x0bdb25a0; + phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, 0x0b1b25a0); for (i = 1; i < IQK_ADDA_REG_NUM; i++) phy_set_bb_reg(adapt, adda_reg[i], bMaskDWord, path_on); @@ -870,7 +864,7 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); } - path_adda_on(adapt, adda_reg, true, false); + path_adda_on(adapt, adda_reg, true); if (t == 0) dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, BIT(8)); -- cgit v1.2.3 From 5b2bd53d9041fe07ec97712aa9c0765f6a688e30 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:59:01 +0200 Subject: staging: rtl8188eu: simplify phy_lc_calibrate phy_lc_calibrate's is2t parameter is always false. Remove some code that would be called only for is2t == true. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-17-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 20 +++----------------- 1 file changed, 3 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index a6181b94395e..2887559b9031 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -952,10 +952,10 @@ static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], } } -static void phy_lc_calibrate(struct adapter *adapt, bool is2t) +static void phy_lc_calibrate(struct adapter *adapt) { u8 tmpreg; - u32 rf_a_mode = 0, rf_b_mode = 0, lc_cal; + u32 rf_a_mode = 0, lc_cal; /* Check continuous TX and Packet TX */ tmpreg = usb_read8(adapt, 0xd03); @@ -971,20 +971,10 @@ static void phy_lc_calibrate(struct adapter *adapt, bool is2t) rf_a_mode = rtw_hal_read_rfreg(adapt, RF_PATH_A, RF_AC, bMask12Bits); - /* Path-B */ - if (is2t) - rf_b_mode = rtw_hal_read_rfreg(adapt, RF_PATH_B, RF_AC, - bMask12Bits); - /* 2. Set RF mode = standby mode */ /* Path-A */ phy_set_rf_reg(adapt, RF_PATH_A, RF_AC, bMask12Bits, (rf_a_mode & 0x8FFFF) | 0x10000); - - /* Path-B */ - if (is2t) - phy_set_rf_reg(adapt, RF_PATH_B, RF_AC, bMask12Bits, - (rf_b_mode & 0x8FFFF) | 0x10000); } /* 3. Read RF reg18 */ @@ -1003,10 +993,6 @@ static void phy_lc_calibrate(struct adapter *adapt, bool is2t) usb_write8(adapt, 0xd03, tmpreg); phy_set_rf_reg(adapt, RF_PATH_A, RF_AC, bMask12Bits, rf_a_mode); - /* Path-B */ - if (is2t) - phy_set_rf_reg(adapt, RF_PATH_B, RF_AC, bMask12Bits, - rf_b_mode); } else { /* Deal with Packet TX case */ usb_write8(adapt, REG_TXPAUSE, 0x00); @@ -1126,7 +1112,7 @@ void rtl88eu_phy_lc_calibrate(struct adapter *adapt) dm_odm->RFCalibrateInfo.bLCKInProgress = true; - phy_lc_calibrate(adapt, false); + phy_lc_calibrate(adapt); dm_odm->RFCalibrateInfo.bLCKInProgress = false; } -- cgit v1.2.3 From a4fccfcfe7d5488a071665ea98f7c88b8ea3aa19 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sun, 25 Jul 2021 17:59:02 +0200 Subject: staging: rtl8188eu: remove unused IQKMatrixRegSetting array The IQKMatrixRegSetting array in struct odm_rf_cal is initialised but never used. Remove it. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210725155902.32433-18-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8188eu/hal/phy.c | 6 ------ drivers/staging/rtl8188eu/include/odm.h | 7 ------- 2 files changed, 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c index 2887559b9031..9067f23a23ff 100644 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ b/drivers/staging/rtl8188eu/hal/phy.c @@ -1087,12 +1087,6 @@ void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) patha_fill_iqk(adapt, pathaok, result, final, (reg_ea4 == 0)); - if (final < 4) { - for (i = 0; i < IQK_Matrix_REG_NUM; i++) - dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[0].Value[0][i] = result[final][i]; - dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[0].bIQKDone = true; - } - save_adda_registers(adapt, iqk_bb_reg_92c, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); } diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h index 98402cfb1168..9cd612414ab9 100644 --- a/drivers/staging/rtl8188eu/include/odm.h +++ b/drivers/staging/rtl8188eu/include/odm.h @@ -241,7 +241,6 @@ struct odm_rate_adapt { #define HP_THERMAL_NUM 8 #define AVG_THERMAL_NUM 8 -#define IQK_Matrix_REG_NUM 8 #define IQK_Matrix_Settings_NUM (1 + 24 + 21) #define DM_Type_ByFWi 0 @@ -565,11 +564,6 @@ struct odm_ra_info { u8 PTSmoothFactor; }; -struct ijk_matrix_regs_set { - bool bIQKDone; - s32 Value[1][IQK_Matrix_REG_NUM]; -}; - struct odm_rf_cal { /* for tx power tracking */ u32 RegA24; /* for TempCCK */ @@ -613,7 +607,6 @@ struct odm_rf_cal { u8 ThermalValue_HP[HP_THERMAL_NUM]; u8 ThermalValue_HP_index; - struct ijk_matrix_regs_set IQKMatrixRegSetting[IQK_Matrix_Settings_NUM]; u8 Delta_IQK; u8 Delta_LCK; -- cgit v1.2.3 From cf79ee6eb0d7d5f45ad58c395ee855e2e1bbc9b2 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Fri, 23 Jul 2021 19:32:16 +0200 Subject: staging/rtl8192e: Remove all strcpy() uses strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). It is also dangerous a strcpy() followed by a strcat(). In this case, refactor the code using scnprintf() and avoid this combination. Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210723173216.12157-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtllib_softmac.c | 3 ++- drivers/staging/rtl8192e/rtllib_softmac_wx.c | 18 +++++++----------- 3 files changed, 10 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c index b626ac45db80..358b629d2cc6 100644 --- a/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +++ b/drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c @@ -2167,7 +2167,7 @@ rtl92e_init_variables(struct net_device *dev) { struct r8192_priv *priv = rtllib_priv(dev); - strcpy(priv->nick, "rtl8192E"); + strscpy(priv->nick, "rtl8192E", sizeof(priv->nick)); priv->rtllib->softmac_features = IEEE_SOFTMAC_SCAN | IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | diff --git a/drivers/staging/rtl8192e/rtllib_softmac.c b/drivers/staging/rtl8192e/rtllib_softmac.c index 25b3d3950a3c..d2726d01c757 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac.c +++ b/drivers/staging/rtl8192e/rtllib_softmac.c @@ -2582,7 +2582,8 @@ static void rtllib_start_ibss_wq(void *data) mutex_lock(&ieee->wx_mutex); if (ieee->current_network.ssid_len == 0) { - strcpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID); + strscpy(ieee->current_network.ssid, RTLLIB_DEFAULT_TX_ESSID, + sizeof(ieee->current_network.ssid)); ieee->current_network.ssid_len = strlen(RTLLIB_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } diff --git a/drivers/staging/rtl8192e/rtllib_softmac_wx.c b/drivers/staging/rtl8192e/rtllib_softmac_wx.c index f89799d43b1b..57a6d1130b6a 100644 --- a/drivers/staging/rtl8192e/rtllib_softmac_wx.c +++ b/drivers/staging/rtl8192e/rtllib_softmac_wx.c @@ -539,18 +539,14 @@ int rtllib_wx_set_rawtx(struct rtllib_device *ieee, } EXPORT_SYMBOL(rtllib_wx_set_rawtx); -int rtllib_wx_get_name(struct rtllib_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) +int rtllib_wx_get_name(struct rtllib_device *ieee, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - strcpy(wrqu->name, "802.11"); - - if (ieee->modulation & RTLLIB_CCK_MODULATION) - strcat(wrqu->name, "b"); - if (ieee->modulation & RTLLIB_OFDM_MODULATION) - strcat(wrqu->name, "g"); - if (ieee->mode & (IEEE_N_24G | IEEE_N_5G)) - strcat(wrqu->name, "n"); + const char *b = ieee->modulation & RTLLIB_CCK_MODULATION ? "b" : ""; + const char *g = ieee->modulation & RTLLIB_OFDM_MODULATION ? "g" : ""; + const char *n = ieee->mode & (IEEE_N_24G | IEEE_N_5G) ? "n" : ""; + + scnprintf(wrqu->name, sizeof(wrqu->name), "802.11%s%s%s", b, g, n); return 0; } EXPORT_SYMBOL(rtllib_wx_get_name); -- cgit v1.2.3 From 3c6675363de5aa168c23431cf90db455c1901b6e Mon Sep 17 00:00:00 2001 From: Len Baker Date: Fri, 23 Jul 2021 16:51:22 +0200 Subject: staging/ks7010: Remove all strcpy() uses in favor of strscpy() strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210723145122.5746-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/ks7010/ks_wlan_net.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c index 09e7b4cd0138..631ad769c3d5 100644 --- a/drivers/staging/ks7010/ks_wlan_net.c +++ b/drivers/staging/ks7010/ks_wlan_net.c @@ -158,13 +158,13 @@ static int ks_wlan_get_name(struct net_device *dev, /* for SLEEP MODE */ if (priv->dev_state < DEVICE_STATE_READY) - strcpy(cwrq->name, "NOT READY!"); + strscpy(cwrq->name, "NOT READY!", sizeof(cwrq->name)); else if (priv->reg.phy_type == D_11B_ONLY_MODE) - strcpy(cwrq->name, "IEEE 802.11b"); + strscpy(cwrq->name, "IEEE 802.11b", sizeof(cwrq->name)); else if (priv->reg.phy_type == D_11G_ONLY_MODE) - strcpy(cwrq->name, "IEEE 802.11g"); + strscpy(cwrq->name, "IEEE 802.11g", sizeof(cwrq->name)); else - strcpy(cwrq->name, "IEEE 802.11b/g"); + strscpy(cwrq->name, "IEEE 802.11b/g", sizeof(cwrq->name)); return 0; } @@ -1808,8 +1808,8 @@ static int ks_wlan_get_firmware_version(struct net_device *dev, { struct ks_wlan_private *priv = netdev_priv(dev); - strcpy(extra, priv->firmware_version); dwrq->length = priv->version_size + 1; + strscpy(extra, priv->firmware_version, dwrq->length); return 0; } -- cgit v1.2.3 From 246f920cb731950bea4501dc68ab2f8ad66e8b8d Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sun, 18 Jul 2021 13:32:07 +0200 Subject: staging/rtl8192u: Remove all strcpy() uses in favor of strscpy() strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210718113207.10045-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index ab885353f668..1a193f900779 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -2226,7 +2226,8 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) mutex_lock(&ieee->wx_mutex); if (ieee->current_network.ssid_len == 0) { - strcpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID); + strscpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, + sizeof(ieee->current_network.ssid)); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } -- cgit v1.2.3 From 14127269cd516fac7c1711accededddf3f2c7ab3 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:26 -0400 Subject: staging: vt6655: remove filename from baseband.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for baseband.h. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-1-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/baseband.h b/drivers/staging/vt6655/baseband.h index 9354ce724446..0a30afaa7cc3 100644 --- a/drivers/staging/vt6655/baseband.h +++ b/drivers/staging/vt6655/baseband.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: baseband.h - * * Purpose: Implement functions to access baseband * * Author: Jerry Chen -- cgit v1.2.3 From cae9546ac9f160573029dea6e6bec8d8aed471b8 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:27 -0400 Subject: staging: vt6655: remove filename from baseband.c This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for baseband.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-2-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/baseband.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/baseband.c b/drivers/staging/vt6655/baseband.c index d89163299172..f73f3fad3e05 100644 --- a/drivers/staging/vt6655/baseband.c +++ b/drivers/staging/vt6655/baseband.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: baseband.c - * * Purpose: Implement functions to access baseband * * Author: Kyle Hsu -- cgit v1.2.3 From 51f42c766563061d935d5921f3c660bde45a60d1 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:28 -0400 Subject: staging: vt6655: remove filename from card.c This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for card.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-3-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/card.c b/drivers/staging/vt6655/card.c index 29086189c53a..3ef3a6e0e6e1 100644 --- a/drivers/staging/vt6655/card.c +++ b/drivers/staging/vt6655/card.c @@ -3,7 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: card.c * Purpose: Provide functions to setup NIC operation mode * Functions: * s_vSafeResetTx - Rest Tx -- cgit v1.2.3 From 065dddf31e5a45f67e6de1a18bd3353b4b216327 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:29 -0400 Subject: staging: vt6655: remove filename from card.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for card.h. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-4-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/card.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/card.h b/drivers/staging/vt6655/card.h index 568a2ddd6588..09e7f3f1cbed 100644 --- a/drivers/staging/vt6655/card.h +++ b/drivers/staging/vt6655/card.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: card.h - * * Purpose: Provide functions to setup NIC operation mode * * Author: Tevin Chen -- cgit v1.2.3 From ec32e0776f43f0965be2c9c6195d2871d129509f Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:30 -0400 Subject: staging: vt6655: remove filename from channel.c This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for channel.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-5-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/channel.c b/drivers/staging/vt6655/channel.c index cf46ee63681a..52b6538a201a 100644 --- a/drivers/staging/vt6655/channel.c +++ b/drivers/staging/vt6655/channel.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: channel.c - * */ #include "baseband.h" -- cgit v1.2.3 From 646ce5315f5806d3ac04a47915e4a90ee7c7bd6b Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:31 -0400 Subject: staging: vt6655: remove filename from channel.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for channel.h. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-6-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/channel.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/channel.h b/drivers/staging/vt6655/channel.h index 0d2709607456..78b2d82317e5 100644 --- a/drivers/staging/vt6655/channel.h +++ b/drivers/staging/vt6655/channel.h @@ -3,7 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: channel.h */ #ifndef _CHANNEL_H_ -- cgit v1.2.3 From f0d52cd214984144ad9500b4a3feff21d6e403d8 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:32 -0400 Subject: staging: vt6655: remove filename from device_cfg.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for device_cfg.h, and adds an empty line after the top description comment to match the style of the other vt6655 files. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-7-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_cfg.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/device_cfg.h b/drivers/staging/vt6655/device_cfg.h index 04db6a8d3db3..db0304f6e21c 100644 --- a/drivers/staging/vt6655/device_cfg.h +++ b/drivers/staging/vt6655/device_cfg.h @@ -3,14 +3,13 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: device_cfg.h - * * Purpose: Driver configuration header * Author: Lyndon Chen * * Date: Dec 17, 2002 * */ + #ifndef __DEVICE_CONFIG_H #define __DEVICE_CONFIG_H -- cgit v1.2.3 From 0e9e3f6170d633a26c3701eaf6a366ac65a1c4e7 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:33 -0400 Subject: staging: vt6655: remove filename from device_main.c This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for device_main.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-8-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_main.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c index 979165445d88..d40c2ac14928 100644 --- a/drivers/staging/vt6655/device_main.c +++ b/drivers/staging/vt6655/device_main.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: device_main.c - * * Purpose: driver entry for initial, open, close, tx and rx. * * Author: Lyndon Chen -- cgit v1.2.3 From eee245f5d707f4be2c8592790f15128116a60c3e Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:34 -0400 Subject: staging: vt6655: remove filename from dpc.c This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for dpc.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-9-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/dpc.c b/drivers/staging/vt6655/dpc.c index 52214a30e9b6..2d06cecc0307 100644 --- a/drivers/staging/vt6655/dpc.c +++ b/drivers/staging/vt6655/dpc.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: dpc.c - * * Purpose: handle dpc rx functions * * Author: Lyndon Chen -- cgit v1.2.3 From 82bcc3174af2472c10d9feeef8ceea32d54d9ef3 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:35 -0400 Subject: staging: vt6655: remove filename from dpc.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for dpc.h. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-10-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/dpc.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/dpc.h b/drivers/staging/vt6655/dpc.h index eac67794cc49..40364c0ab7f6 100644 --- a/drivers/staging/vt6655/dpc.h +++ b/drivers/staging/vt6655/dpc.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: dpc.h - * * Purpose: * * Author: Jerry Chen -- cgit v1.2.3 From 692b3e44b7afe2c3c348cd20edfa0a5336f13b54 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:36 -0400 Subject: staging: vt6655: remove filename from key.c This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for key.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-11-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/key.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/key.c b/drivers/staging/vt6655/key.c index 94665ddc36a5..20881cf2f394 100644 --- a/drivers/staging/vt6655/key.c +++ b/drivers/staging/vt6655/key.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: key.c - * * Purpose: Implement functions for 802.11i Key management * * Author: Jerry Chen -- cgit v1.2.3 From 56bfb9bc6cd1e4e91ce4376018e361223b737353 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:37 -0400 Subject: staging: vt6655: remove filename from key.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for key.h. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-12-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/key.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/key.h b/drivers/staging/vt6655/key.h index 9347776fa3a5..d88da9dfb5c3 100644 --- a/drivers/staging/vt6655/key.h +++ b/drivers/staging/vt6655/key.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: key.h - * * Purpose: Implement functions for 802.11i Key management * * Author: Jerry Chen -- cgit v1.2.3 From 290262b9198d9731e285315056ff4c087f6d92d4 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:38 -0400 Subject: staging: vt6655: kernel style cleanup of mac.c This patch removes from mac.c the file name and an ftrace-like pr_debug per checkpatch's two warnings. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-13-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/mac.c b/drivers/staging/vt6655/mac.c index f5ae7f1f5689..9721c2234bf2 100644 --- a/drivers/staging/vt6655/mac.c +++ b/drivers/staging/vt6655/mac.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: mac.c - * * Purpose: MAC routines * * Author: Tevin Chen @@ -775,7 +773,6 @@ void MACvSetKeyEntry(struct vnt_private *priv, unsigned short wKeyCtl, if (byLocalID <= 1) return; - pr_debug("%s\n", __func__); offset = MISCFIFO_KEYETRY0; offset += (uEntryIdx * MISCFIFO_KEYENTRYSIZE); -- cgit v1.2.3 From ed0b62a568d13c8418a930bb4b36cbfc52f8f39b Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:39 -0400 Subject: staging: vt6655: remove filename from mac.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for mac.c. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-14-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/mac.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/mac.h b/drivers/staging/vt6655/mac.h index 6e2bd16ef384..9797eddaea01 100644 --- a/drivers/staging/vt6655/mac.h +++ b/drivers/staging/vt6655/mac.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: mac.h - * * Purpose: MAC routines * * Author: Tevin Chen -- cgit v1.2.3 From 050cbd980e6bc882b8c2a6e954ada48cbd5ce5c2 Mon Sep 17 00:00:00 2001 From: Lucas Henneman Date: Fri, 23 Jul 2021 10:43:40 -0400 Subject: staging: vt6655: remove filename from upc.h This patch resolves checkpatch's warning, "It's generally not useful to have the filename in the file" for upc.h. Signed-off-by: Lucas Henneman Link: https://lore.kernel.org/r/20210723144340.15787-15-lucas.henneman@linaro.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/upc.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/upc.h b/drivers/staging/vt6655/upc.h index 8608693ae9c3..b374db5fca81 100644 --- a/drivers/staging/vt6655/upc.h +++ b/drivers/staging/vt6655/upc.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: upc.h - * * Purpose: Macros to access device * * Author: Tevin Chen -- cgit v1.2.3 From 2a4d15a4ae98e27ed59a70c1c25483d24507171b Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Wed, 21 Jul 2021 21:50:49 +0530 Subject: staging: vchiq: Refactor vchiq cdev code Move the vchiq cdev initialization code to its own function for better code organization. Call the initialization function during probe, thus shifting the whole cdev creation logic (which was earlier split in vchiq_probe() and vchiq_driver_init()) to vchiq_probe(). Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/c0e538eb0644292a52267d39edd85ab2af9f9a4e.1626882325.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 142 +++++++++++++-------- 1 file changed, 92 insertions(+), 50 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index b5aac862a298..3a0724fe25ea 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -2134,6 +2134,81 @@ vchiq_fops = { .read = vchiq_read }; +/** + * vchiq_register_chrdev - Register the char driver for vchiq + * and create the necessary class and + * device files in userspace. + * @parent The parent of the char device. + * + * Returns 0 on success else returns the error code. + */ +static int vchiq_register_chrdev(struct device *parent) +{ + struct device *vchiq_dev; + int ret; + + vchiq_class = class_create(THIS_MODULE, DEVICE_NAME); + if (IS_ERR(vchiq_class)) { + pr_err("Failed to create vchiq class\n"); + ret = PTR_ERR(vchiq_class); + goto error_exit; + } + + ret = alloc_chrdev_region(&vchiq_devid, 0, 1, DEVICE_NAME); + if (ret) { + pr_err("vchiq: Failed to allocate vchiq's chrdev region\n"); + goto alloc_region_error; + } + + cdev_init(&vchiq_cdev, &vchiq_fops); + vchiq_cdev.owner = THIS_MODULE; + ret = cdev_add(&vchiq_cdev, vchiq_devid, 1); + if (ret) { + vchiq_log_error(vchiq_arm_log_level, + "Unable to register vchiq char device"); + goto cdev_add_error; + } + + vchiq_dev = device_create(vchiq_class, parent, vchiq_devid, NULL, + DEVICE_NAME); + if (IS_ERR(vchiq_dev)) { + vchiq_log_error(vchiq_arm_log_level, + "Failed to create vchiq char device node"); + ret = PTR_ERR(vchiq_dev); + goto device_create_error; + } + + vchiq_log_info(vchiq_arm_log_level, + "vchiq char dev initialised successfully - device %d.%d", + MAJOR(vchiq_devid), MINOR(vchiq_devid)); + + return 0; + +device_create_error: + cdev_del(&vchiq_cdev); + +cdev_add_error: + unregister_chrdev_region(vchiq_devid, 1); + +alloc_region_error: + class_destroy(vchiq_class); + +error_exit: + return ret; +} + +/** + * vchiq_deregister_chrdev - Deregister and cleanup the vchiq char + * driver and device files + */ +static void vchiq_deregister_chrdev(void) +{ + device_destroy(vchiq_class, vchiq_devid); + cdev_del(&vchiq_cdev); + unregister_chrdev_region(vchiq_devid, 1); + class_destroy(vchiq_class); +} + /* * Autosuspend related functionality */ @@ -2644,7 +2719,6 @@ static int vchiq_probe(struct platform_device *pdev) struct device_node *fw_node; const struct of_device_id *of_id; struct vchiq_drvdata *drvdata; - struct device *vchiq_dev; int err; of_id = of_match_node(vchiq_of_match, pdev->dev.of_node); @@ -2670,38 +2744,31 @@ static int vchiq_probe(struct platform_device *pdev) if (err) goto failed_platform_init; - cdev_init(&vchiq_cdev, &vchiq_fops); - vchiq_cdev.owner = THIS_MODULE; - err = cdev_add(&vchiq_cdev, vchiq_devid, 1); - if (err) { - vchiq_log_error(vchiq_arm_log_level, - "Unable to register device"); - goto failed_platform_init; - } - - vchiq_dev = device_create(vchiq_class, &pdev->dev, vchiq_devid, NULL, - "vchiq"); - if (IS_ERR(vchiq_dev)) { - err = PTR_ERR(vchiq_dev); - goto failed_device_create; - } - vchiq_debugfs_init(); vchiq_log_info(vchiq_arm_log_level, - "vchiq: initialised - version %d (min %d), device %d.%d", - VCHIQ_VERSION, VCHIQ_VERSION_MIN, - MAJOR(vchiq_devid), MINOR(vchiq_devid)); + "vchiq: platform initialised - version %d (min %d)", + VCHIQ_VERSION, VCHIQ_VERSION_MIN); + + /* + * Simply exit on error since the function handles cleanup in + * cases of failure. + */ + err = vchiq_register_chrdev(&pdev->dev); + if (err) { + vchiq_log_warning(vchiq_arm_log_level, + "Failed to initialize vchiq cdev"); + goto error_exit; + } bcm2835_camera = vchiq_register_child(pdev, "bcm2835-camera"); bcm2835_audio = vchiq_register_child(pdev, "bcm2835_audio"); return 0; -failed_device_create: - cdev_del(&vchiq_cdev); failed_platform_init: - vchiq_log_warning(vchiq_arm_log_level, "could not load vchiq"); + vchiq_log_warning(vchiq_arm_log_level, "could not initialize vchiq platform"); +error_exit: return err; } @@ -2710,8 +2777,7 @@ static int vchiq_remove(struct platform_device *pdev) platform_device_unregister(bcm2835_audio); platform_device_unregister(bcm2835_camera); vchiq_debugfs_deinit(); - device_destroy(vchiq_class, vchiq_devid); - cdev_del(&vchiq_cdev); + vchiq_deregister_chrdev(); return 0; } @@ -2729,31 +2795,9 @@ static int __init vchiq_driver_init(void) { int ret; - vchiq_class = class_create(THIS_MODULE, DEVICE_NAME); - if (IS_ERR(vchiq_class)) { - pr_err("Failed to create vchiq class\n"); - return PTR_ERR(vchiq_class); - } - - ret = alloc_chrdev_region(&vchiq_devid, 0, 1, DEVICE_NAME); - if (ret) { - pr_err("Failed to allocate vchiq's chrdev region\n"); - goto class_destroy; - } - ret = platform_driver_register(&vchiq_driver); - if (ret) { + if (ret) pr_err("Failed to register vchiq driver\n"); - goto region_unregister; - } - - return 0; - -region_unregister: - unregister_chrdev_region(vchiq_devid, 1); - -class_destroy: - class_destroy(vchiq_class); return ret; } @@ -2762,8 +2806,6 @@ module_init(vchiq_driver_init); static void __exit vchiq_driver_exit(void) { platform_driver_unregister(&vchiq_driver); - unregister_chrdev_region(vchiq_devid, 1); - class_destroy(vchiq_class); } module_exit(vchiq_driver_exit); -- cgit v1.2.3 From c405028f471d6a7fd694cda34a9135345f80d88b Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Wed, 21 Jul 2021 21:50:50 +0530 Subject: staging: vchiq: Move certain declarations to vchiq_arm.h Move certain declarations from vchiq_arm.c to vchiq_arm.h to allow code sharing. This will be useful when we eventually separate the vchiq char driver code from platform code, into its own file. Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/8abcbd9fb3227e2a78ccc4a1186c8c0801061a68.1626882325.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 68 ++------------------ .../vc04_services/interface/vchiq_arm/vchiq_arm.h | 73 ++++++++++++++++++++++ 2 files changed, 79 insertions(+), 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3a0724fe25ea..3152466086f3 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -38,12 +38,6 @@ #undef MODULE_PARAM_PREFIX #define MODULE_PARAM_PREFIX DEVICE_NAME "." -/* Some per-instance constants */ -#define MAX_COMPLETIONS 128 -#define MAX_SERVICES 64 -#define MAX_ELEMENTS 8 -#define MSG_QUEUE_SIZE 128 - #define KEEPALIVE_VER 1 #define KEEPALIVE_VER_MIN KEEPALIVE_VER @@ -51,62 +45,12 @@ int vchiq_arm_log_level = VCHIQ_LOG_DEFAULT; int vchiq_susp_log_level = VCHIQ_LOG_ERROR; -struct user_service { - struct vchiq_service *service; - void __user *userdata; - struct vchiq_instance *instance; - char is_vchi; - char dequeue_pending; - char close_pending; - int message_available_pos; - int msg_insert; - int msg_remove; - struct completion insert_event; - struct completion remove_event; - struct completion close_event; - struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; -}; - -struct bulk_waiter_node { - struct bulk_waiter bulk_waiter; - int pid; - struct list_head list; -}; - -struct vchiq_instance { - struct vchiq_state *state; - struct vchiq_completion_data_kernel completions[MAX_COMPLETIONS]; - int completion_insert; - int completion_remove; - struct completion insert_event; - struct completion remove_event; - struct mutex completion_mutex; - - int connected; - int closing; - int pid; - int mark; - int use_close_delivered; - int trace; - - struct list_head bulk_waiter_list; - struct mutex bulk_waiter_list_mutex; - - struct vchiq_debugfs_node debugfs_node; -}; - -struct dump_context { - char __user *buf; - size_t actual; - size_t space; - loff_t offset; -}; +DEFINE_SPINLOCK(msg_queue_spinlock); +struct vchiq_state g_state; static struct cdev vchiq_cdev; static dev_t vchiq_devid; -static struct vchiq_state g_state; static struct class *vchiq_class; -static DEFINE_SPINLOCK(msg_queue_spinlock); static struct platform_device *bcm2835_camera; static struct platform_device *bcm2835_audio; @@ -199,7 +143,7 @@ failed: } EXPORT_SYMBOL(vchiq_initialise); -static void free_bulk_waiter(struct vchiq_instance *instance) +void free_bulk_waiter(struct vchiq_instance *instance) { struct bulk_waiter_node *waiter, *next; @@ -561,7 +505,7 @@ add_completion(struct vchiq_instance *instance, enum vchiq_reason reason, return VCHIQ_SUCCESS; } -static enum vchiq_status +enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata) { @@ -2142,7 +2086,7 @@ vchiq_fops = { * * Returns 0 on success else returns the error code. */ -static int vchiq_register_chrdev(struct device *parent) +int vchiq_register_chrdev(struct device *parent) { struct device *vchiq_dev; int ret; @@ -2201,7 +2145,7 @@ error_exit: * vchiq_deregister_chrdev - Deregister and cleanup the vchiq char * driver and device files */ -static void vchiq_deregister_chrdev(void) +void vchiq_deregister_chrdev(void) { device_destroy(vchiq_class, vchiq_devid); cdev_del(&vchiq_cdev); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index c7d2cf1f2e68..2453971b6b78 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -14,6 +14,12 @@ #include "vchiq_core.h" #include "vchiq_debugfs.h" +/* Some per-instance constants */ +#define MAX_COMPLETIONS 128 +#define MAX_SERVICES 64 +#define MAX_ELEMENTS 8 +#define MSG_QUEUE_SIZE 128 + enum USE_TYPE_E { USE_TYPE_SERVICE, USE_TYPE_VCHIQ @@ -58,9 +64,63 @@ struct vchiq_drvdata { struct rpi_firmware *fw; }; +struct user_service { + struct vchiq_service *service; + void __user *userdata; + struct vchiq_instance *instance; + char is_vchi; + char dequeue_pending; + char close_pending; + int message_available_pos; + int msg_insert; + int msg_remove; + struct completion insert_event; + struct completion remove_event; + struct completion close_event; + struct vchiq_header *msg_queue[MSG_QUEUE_SIZE]; +}; + +struct bulk_waiter_node { + struct bulk_waiter bulk_waiter; + int pid; + struct list_head list; +}; + +struct vchiq_instance { + struct vchiq_state *state; + struct vchiq_completion_data_kernel completions[MAX_COMPLETIONS]; + int completion_insert; + int completion_remove; + struct completion insert_event; + struct completion remove_event; + struct mutex completion_mutex; + + int connected; + int closing; + int pid; + int mark; + int use_close_delivered; + int trace; + + struct list_head bulk_waiter_list; + struct mutex bulk_waiter_list_mutex; + + struct vchiq_debugfs_node debugfs_node; +}; + +struct dump_context { + char __user *buf; + size_t actual; + size_t space; + loff_t offset; +}; + extern int vchiq_arm_log_level; extern int vchiq_susp_log_level; +extern spinlock_t msg_queue_spinlock; +extern struct vchiq_state g_state; + int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state); @@ -114,4 +174,17 @@ vchiq_instance_get_trace(struct vchiq_instance *instance); extern void vchiq_instance_set_trace(struct vchiq_instance *instance, int trace); +extern void +vchiq_deregister_chrdev(void); + +extern int +vchiq_register_chrdev(struct device *parent); + +extern enum vchiq_status +service_callback(enum vchiq_reason reason, struct vchiq_header *header, + unsigned int handle, void *bulk_userdata); + +extern void +free_bulk_waiter(struct vchiq_instance *instance); + #endif /* VCHIQ_ARM_H */ -- cgit v1.2.3 From f05916281fd75db2fe32294e26c04d666c762370 Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Wed, 21 Jul 2021 21:50:51 +0530 Subject: staging: vchiq: Move vchiq char driver to its own file Split the initialization code of vchiq char driver and device files from that of vchiq platform. The char driver code now resides in vchiq_dev.c and the platform code resides in the original vchiq_arm.c file. This commit focuses on separating the code into different files while maintaining the same functionality. It does not completely decouple them as the cdev init code is still called from the platform's vchiq_probe() function. Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/ed53690e217f631b746aad0585fccaa6fb1453c1.1626882325.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Makefile | 1 + .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 1619 ++------------------ .../vc04_services/interface/vchiq_arm/vchiq_dev.c | 1440 +++++++++++++++++ 3 files changed, 1540 insertions(+), 1520 deletions(-) create mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index e21e73ae3cc6..db28be341239 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -7,6 +7,7 @@ vchiq-objs := \ interface/vchiq_arm/vchiq_2835_arm.o \ interface/vchiq_arm/vchiq_debugfs.o \ interface/vchiq_arm/vchiq_connected.o \ + interface/vchiq_arm/vchiq_dev.o \ obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 3152466086f3..0f2de571eba7 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -48,9 +48,6 @@ int vchiq_susp_log_level = VCHIQ_LOG_ERROR; DEFINE_SPINLOCK(msg_queue_spinlock); struct vchiq_state g_state; -static struct cdev vchiq_cdev; -static dev_t vchiq_devid; -static struct class *vchiq_class; static struct platform_device *bcm2835_camera; static struct platform_device *bcm2835_audio; @@ -62,29 +59,6 @@ static struct vchiq_drvdata bcm2836_drvdata = { .cache_line_size = 64, }; -static const char *const ioctl_names[] = { - "CONNECT", - "SHUTDOWN", - "CREATE_SERVICE", - "REMOVE_SERVICE", - "QUEUE_MESSAGE", - "QUEUE_BULK_TRANSMIT", - "QUEUE_BULK_RECEIVE", - "AWAIT_COMPLETION", - "DEQUEUE_MESSAGE", - "GET_CLIENT_ID", - "GET_CONFIG", - "CLOSE_SERVICE", - "USE_SERVICE", - "RELEASE_SERVICE", - "SET_SERVICE_OPTION", - "DUMP_PHYS_MEM", - "LIB_VERSION", - "CLOSE_DELIVERED" -}; - -static_assert(ARRAY_SIZE(ioctl_names) == (VCHIQ_IOC_MAX + 1)); - static enum vchiq_status vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir); @@ -616,1543 +590,148 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, bulk_userdata); } -static void -user_service_free(void *userdata) -{ - kfree(userdata); -} - -static void close_delivered(struct user_service *user_service) -{ - vchiq_log_info(vchiq_arm_log_level, - "%s(handle=%x)", - __func__, user_service->service->handle); - - if (user_service->close_pending) { - /* Allow the underlying service to be culled */ - vchiq_service_put(user_service->service); - - /* Wake the user-thread blocked in close_ or remove_service */ - complete(&user_service->close_event); - - user_service->close_pending = 0; - } -} - -struct vchiq_io_copy_callback_context { - struct vchiq_element *element; - size_t element_offset; - unsigned long elements_to_go; -}; - -static ssize_t vchiq_ioc_copy_element_data(void *context, void *dest, - size_t offset, size_t maxsize) +int vchiq_dump(void *dump_context, const char *str, int len) { - struct vchiq_io_copy_callback_context *cc = context; - size_t total_bytes_copied = 0; - size_t bytes_this_round; - - while (total_bytes_copied < maxsize) { - if (!cc->elements_to_go) - return total_bytes_copied; - - if (!cc->element->size) { - cc->elements_to_go--; - cc->element++; - cc->element_offset = 0; - continue; - } - - bytes_this_round = min(cc->element->size - cc->element_offset, - maxsize - total_bytes_copied); + struct dump_context *context = (struct dump_context *)dump_context; + int copy_bytes; - if (copy_from_user(dest + total_bytes_copied, - cc->element->data + cc->element_offset, - bytes_this_round)) - return -EFAULT; + if (context->actual >= context->space) + return 0; - cc->element_offset += bytes_this_round; - total_bytes_copied += bytes_this_round; + if (context->offset > 0) { + int skip_bytes = min_t(int, len, context->offset); - if (cc->element_offset == cc->element->size) { - cc->elements_to_go--; - cc->element++; - cc->element_offset = 0; - } + str += skip_bytes; + len -= skip_bytes; + context->offset -= skip_bytes; + if (context->offset > 0) + return 0; } + copy_bytes = min_t(int, len, context->space - context->actual); + if (copy_bytes == 0) + return 0; + if (copy_to_user(context->buf + context->actual, str, + copy_bytes)) + return -EFAULT; + context->actual += copy_bytes; + len -= copy_bytes; - return maxsize; -} - -static int -vchiq_ioc_queue_message(unsigned int handle, struct vchiq_element *elements, - unsigned long count) -{ - struct vchiq_io_copy_callback_context context; - enum vchiq_status status = VCHIQ_SUCCESS; - unsigned long i; - size_t total_size = 0; - - context.element = elements; - context.element_offset = 0; - context.elements_to_go = count; + /* + * If the terminating NUL is included in the length, then it + * marks the end of a line and should be replaced with a + * carriage return. + */ + if ((len == 0) && (str[copy_bytes - 1] == '\0')) { + char cr = '\n'; - for (i = 0; i < count; i++) { - if (!elements[i].data && elements[i].size != 0) + if (copy_to_user(context->buf + context->actual - 1, + &cr, 1)) return -EFAULT; - - total_size += elements[i].size; - } - - status = vchiq_queue_message(handle, vchiq_ioc_copy_element_data, - &context, total_size); - - if (status == VCHIQ_ERROR) - return -EIO; - else if (status == VCHIQ_RETRY) - return -EINTR; - return 0; -} - -static int vchiq_ioc_create_service(struct vchiq_instance *instance, - struct vchiq_create_service *args) -{ - struct user_service *user_service = NULL; - struct vchiq_service *service; - enum vchiq_status status = VCHIQ_SUCCESS; - struct vchiq_service_params_kernel params; - int srvstate; - - user_service = kmalloc(sizeof(*user_service), GFP_KERNEL); - if (!user_service) - return -ENOMEM; - - if (args->is_open) { - if (!instance->connected) { - kfree(user_service); - return -ENOTCONN; - } - srvstate = VCHIQ_SRVSTATE_OPENING; - } else { - srvstate = instance->connected ? - VCHIQ_SRVSTATE_LISTENING : VCHIQ_SRVSTATE_HIDDEN; - } - - params = (struct vchiq_service_params_kernel) { - .fourcc = args->params.fourcc, - .callback = service_callback, - .userdata = user_service, - .version = args->params.version, - .version_min = args->params.version_min, - }; - service = vchiq_add_service_internal(instance->state, ¶ms, - srvstate, instance, - user_service_free); - if (!service) { - kfree(user_service); - return -EEXIST; - } - - user_service->service = service; - user_service->userdata = args->params.userdata; - user_service->instance = instance; - user_service->is_vchi = (args->is_vchi != 0); - user_service->dequeue_pending = 0; - user_service->close_pending = 0; - user_service->message_available_pos = instance->completion_remove - 1; - user_service->msg_insert = 0; - user_service->msg_remove = 0; - init_completion(&user_service->insert_event); - init_completion(&user_service->remove_event); - init_completion(&user_service->close_event); - - if (args->is_open) { - status = vchiq_open_service_internal(service, instance->pid); - if (status != VCHIQ_SUCCESS) { - vchiq_remove_service(service->handle); - return (status == VCHIQ_RETRY) ? - -EINTR : -EIO; - } } - args->handle = service->handle; - return 0; } -static int vchiq_ioc_dequeue_message(struct vchiq_instance *instance, - struct vchiq_dequeue_message *args) +int vchiq_dump_platform_instances(void *dump_context) { - struct user_service *user_service; - struct vchiq_service *service; - struct vchiq_header *header; - int ret; - - DEBUG_INITIALISE(g_state.local) - DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - service = find_service_for_instance(instance, args->handle); - if (!service) - return -EINVAL; - - user_service = (struct user_service *)service->base.userdata; - if (user_service->is_vchi == 0) { - ret = -EINVAL; - goto out; - } - - spin_lock(&msg_queue_spinlock); - if (user_service->msg_remove == user_service->msg_insert) { - if (!args->blocking) { - spin_unlock(&msg_queue_spinlock); - DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - ret = -EWOULDBLOCK; - goto out; - } - user_service->dequeue_pending = 1; - ret = 0; - do { - spin_unlock(&msg_queue_spinlock); - DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); - if (wait_for_completion_interruptible( - &user_service->insert_event)) { - vchiq_log_info(vchiq_arm_log_level, - "DEQUEUE_MESSAGE interrupted"); - ret = -EINTR; - break; - } - spin_lock(&msg_queue_spinlock); - } while (user_service->msg_remove == user_service->msg_insert); + struct vchiq_state *state = vchiq_get_state(); + char buf[80]; + int len; + int i; - if (ret) - goto out; - } + /* + * There is no list of instances, so instead scan all services, + * marking those that have been dumped. + */ - if (WARN_ON_ONCE((int)(user_service->msg_insert - - user_service->msg_remove) < 0)) { - spin_unlock(&msg_queue_spinlock); - ret = -EINVAL; - goto out; - } + rcu_read_lock(); + for (i = 0; i < state->unused_service; i++) { + struct vchiq_service *service; + struct vchiq_instance *instance; - header = user_service->msg_queue[user_service->msg_remove & - (MSG_QUEUE_SIZE - 1)]; - user_service->msg_remove++; - spin_unlock(&msg_queue_spinlock); + service = rcu_dereference(state->services[i]); + if (!service || service->base.callback != service_callback) + continue; - complete(&user_service->remove_event); - if (!header) { - ret = -ENOTCONN; - } else if (header->size <= args->bufsize) { - /* Copy to user space if msgbuf is not NULL */ - if (!args->buf || (copy_to_user(args->buf, - header->data, header->size) == 0)) { - ret = header->size; - vchiq_release_message(service->handle, header); - } else { - ret = -EFAULT; - } - } else { - vchiq_log_error(vchiq_arm_log_level, - "header %pK: bufsize %x < size %x", - header, args->bufsize, header->size); - WARN(1, "invalid size\n"); - ret = -EMSGSIZE; + instance = service->instance; + if (instance) + instance->mark = 0; } - DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); -out: - vchiq_service_put(service); - return ret; -} - -static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, - struct vchiq_queue_bulk_transfer *args, - enum vchiq_bulk_dir dir, - enum vchiq_bulk_mode __user *mode) -{ - struct vchiq_service *service; - struct bulk_waiter_node *waiter = NULL; - bool found = false; - void *userdata; - int status = 0; - int ret; - - service = find_service_for_instance(instance, args->handle); - if (!service) - return -EINVAL; + rcu_read_unlock(); - if (args->mode == VCHIQ_BULK_MODE_BLOCKING) { - waiter = kzalloc(sizeof(*waiter), GFP_KERNEL); - if (!waiter) { - ret = -ENOMEM; - goto out; - } + for (i = 0; i < state->unused_service; i++) { + struct vchiq_service *service; + struct vchiq_instance *instance; + int err; - userdata = &waiter->bulk_waiter; - } else if (args->mode == VCHIQ_BULK_MODE_WAITING) { - mutex_lock(&instance->bulk_waiter_list_mutex); - list_for_each_entry(waiter, &instance->bulk_waiter_list, - list) { - if (waiter->pid == current->pid) { - list_del(&waiter->list); - found = true; - break; - } - } - mutex_unlock(&instance->bulk_waiter_list_mutex); - if (!found) { - vchiq_log_error(vchiq_arm_log_level, - "no bulk_waiter found for pid %d", - current->pid); - ret = -ESRCH; - goto out; + rcu_read_lock(); + service = rcu_dereference(state->services[i]); + if (!service || service->base.callback != service_callback) { + rcu_read_unlock(); + continue; } - vchiq_log_info(vchiq_arm_log_level, - "found bulk_waiter %pK for pid %d", waiter, - current->pid); - userdata = &waiter->bulk_waiter; - } else { - userdata = args->userdata; - } - status = vchiq_bulk_transfer(args->handle, NULL, args->data, args->size, - userdata, args->mode, dir); - - if (!waiter) { - ret = 0; - goto out; - } - - if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || - !waiter->bulk_waiter.bulk) { - if (waiter->bulk_waiter.bulk) { - /* Cancel the signal when the transfer completes. */ - spin_lock(&bulk_waiter_spinlock); - waiter->bulk_waiter.bulk->userdata = NULL; - spin_unlock(&bulk_waiter_spinlock); + instance = service->instance; + if (!instance || instance->mark) { + rcu_read_unlock(); + continue; } - kfree(waiter); - ret = 0; - } else { - const enum vchiq_bulk_mode mode_waiting = - VCHIQ_BULK_MODE_WAITING; - waiter->pid = current->pid; - mutex_lock(&instance->bulk_waiter_list_mutex); - list_add(&waiter->list, &instance->bulk_waiter_list); - mutex_unlock(&instance->bulk_waiter_list_mutex); - vchiq_log_info(vchiq_arm_log_level, - "saved bulk_waiter %pK for pid %d", - waiter, current->pid); + rcu_read_unlock(); - ret = put_user(mode_waiting, mode); + len = snprintf(buf, sizeof(buf), + "Instance %pK: pid %d,%s completions %d/%d", + instance, instance->pid, + instance->connected ? " connected, " : + "", + instance->completion_insert - + instance->completion_remove, + MAX_COMPLETIONS); + err = vchiq_dump(dump_context, buf, len + 1); + if (err) + return err; + instance->mark = 1; } -out: - vchiq_service_put(service); - if (ret) - return ret; - else if (status == VCHIQ_ERROR) - return -EIO; - else if (status == VCHIQ_RETRY) - return -EINTR; return 0; } -/* read a user pointer value from an array pointers in user space */ -static inline int vchiq_get_user_ptr(void __user **buf, void __user *ubuf, int index) +int vchiq_dump_platform_service_state(void *dump_context, + struct vchiq_service *service) { - int ret; - - if (in_compat_syscall()) { - compat_uptr_t ptr32; - compat_uptr_t __user *uptr = ubuf; - - ret = get_user(ptr32, uptr + index); - if (ret) - return ret; - - *buf = compat_ptr(ptr32); - } else { - uintptr_t ptr, __user *uptr = ubuf; - - ret = get_user(ptr, uptr + index); - - if (ret) - return ret; - - *buf = (void __user *)ptr; - } + struct user_service *user_service = + (struct user_service *)service->base.userdata; + char buf[80]; + int len; - return 0; -} + len = scnprintf(buf, sizeof(buf), " instance %pK", service->instance); -struct vchiq_completion_data32 { - enum vchiq_reason reason; - compat_uptr_t header; - compat_uptr_t service_userdata; - compat_uptr_t bulk_userdata; -}; + if ((service->base.callback == service_callback) && + user_service->is_vchi) { + len += scnprintf(buf + len, sizeof(buf) - len, + ", %d/%d messages", + user_service->msg_insert - user_service->msg_remove, + MSG_QUEUE_SIZE); -static int vchiq_put_completion(struct vchiq_completion_data __user *buf, - struct vchiq_completion_data *completion, - int index) -{ - struct vchiq_completion_data32 __user *buf32 = (void __user *)buf; - - if (in_compat_syscall()) { - struct vchiq_completion_data32 tmp = { - .reason = completion->reason, - .header = ptr_to_compat(completion->header), - .service_userdata = ptr_to_compat(completion->service_userdata), - .bulk_userdata = ptr_to_compat(completion->bulk_userdata), - }; - if (copy_to_user(&buf32[index], &tmp, sizeof(tmp))) - return -EFAULT; - } else { - if (copy_to_user(&buf[index], completion, sizeof(*completion))) - return -EFAULT; + if (user_service->dequeue_pending) + len += scnprintf(buf + len, sizeof(buf) - len, + " (dequeue pending)"); } - return 0; + return vchiq_dump(dump_context, buf, len + 1); } -static int vchiq_ioc_await_completion(struct vchiq_instance *instance, - struct vchiq_await_completion *args, - int __user *msgbufcountp) +struct vchiq_state * +vchiq_get_state(void) { - int msgbufcount; - int remove; - int ret; - - DEBUG_INITIALISE(g_state.local) - - DEBUG_TRACE(AWAIT_COMPLETION_LINE); - if (!instance->connected) { - return -ENOTCONN; - } - - mutex_lock(&instance->completion_mutex); - - DEBUG_TRACE(AWAIT_COMPLETION_LINE); - while ((instance->completion_remove == instance->completion_insert) - && !instance->closing) { - int rc; - - DEBUG_TRACE(AWAIT_COMPLETION_LINE); - mutex_unlock(&instance->completion_mutex); - rc = wait_for_completion_interruptible( - &instance->insert_event); - mutex_lock(&instance->completion_mutex); - if (rc) { - DEBUG_TRACE(AWAIT_COMPLETION_LINE); - vchiq_log_info(vchiq_arm_log_level, - "AWAIT_COMPLETION interrupted"); - ret = -EINTR; - goto out; - } - } - DEBUG_TRACE(AWAIT_COMPLETION_LINE); - - msgbufcount = args->msgbufcount; - remove = instance->completion_remove; - - for (ret = 0; ret < args->count; ret++) { - struct vchiq_completion_data_kernel *completion; - struct vchiq_completion_data user_completion; - struct vchiq_service *service; - struct user_service *user_service; - struct vchiq_header *header; - - if (remove == instance->completion_insert) - break; - completion = &instance->completions[ - remove & (MAX_COMPLETIONS - 1)]; - - /* - * A read memory barrier is needed to stop - * prefetch of a stale completion record - */ - rmb(); - - service = completion->service_userdata; - user_service = service->base.userdata; - - memset(&user_completion, 0, sizeof(user_completion)); - user_completion = (struct vchiq_completion_data) { - .reason = completion->reason, - .service_userdata = user_service->userdata, - }; - - header = completion->header; - if (header) { - void __user *msgbuf; - int msglen; - - msglen = header->size + sizeof(struct vchiq_header); - /* This must be a VCHIQ-style service */ - if (args->msgbufsize < msglen) { - vchiq_log_error(vchiq_arm_log_level, - "header %pK: msgbufsize %x < msglen %x", - header, args->msgbufsize, msglen); - WARN(1, "invalid message size\n"); - if (ret == 0) - ret = -EMSGSIZE; - break; - } - if (msgbufcount <= 0) - /* Stall here for lack of a buffer for the message. */ - break; - /* Get the pointer from user space */ - msgbufcount--; - if (vchiq_get_user_ptr(&msgbuf, args->msgbufs, - msgbufcount)) { - if (ret == 0) - ret = -EFAULT; - break; - } - - /* Copy the message to user space */ - if (copy_to_user(msgbuf, header, msglen)) { - if (ret == 0) - ret = -EFAULT; - break; - } - - /* Now it has been copied, the message can be released. */ - vchiq_release_message(service->handle, header); - - /* The completion must point to the msgbuf. */ - user_completion.header = msgbuf; - } - - if ((completion->reason == VCHIQ_SERVICE_CLOSED) && - !instance->use_close_delivered) - vchiq_service_put(service); - - /* - * FIXME: address space mismatch, does bulk_userdata - * actually point to user or kernel memory? - */ - user_completion.bulk_userdata = completion->bulk_userdata; - - if (vchiq_put_completion(args->buf, &user_completion, ret)) { - if (ret == 0) - ret = -EFAULT; - break; - } - - /* - * Ensure that the above copy has completed - * before advancing the remove pointer. - */ - mb(); - remove++; - instance->completion_remove = remove; - } - - if (msgbufcount != args->msgbufcount) { - if (put_user(msgbufcount, msgbufcountp)) - ret = -EFAULT; - } -out: - if (ret) - complete(&instance->remove_event); - mutex_unlock(&instance->completion_mutex); - DEBUG_TRACE(AWAIT_COMPLETION_LINE); - - return ret; -} - -static long -vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - struct vchiq_instance *instance = file->private_data; - enum vchiq_status status = VCHIQ_SUCCESS; - struct vchiq_service *service = NULL; - long ret = 0; - int i, rc; - - vchiq_log_trace(vchiq_arm_log_level, - "%s - instance %pK, cmd %s, arg %lx", - __func__, instance, - ((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) && - (_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ? - ioctl_names[_IOC_NR(cmd)] : "", arg); - - switch (cmd) { - case VCHIQ_IOC_SHUTDOWN: - if (!instance->connected) - break; - - /* Remove all services */ - i = 0; - while ((service = next_service_by_instance(instance->state, - instance, &i))) { - status = vchiq_remove_service(service->handle); - vchiq_service_put(service); - if (status != VCHIQ_SUCCESS) - break; - } - service = NULL; - - if (status == VCHIQ_SUCCESS) { - /* Wake the completion thread and ask it to exit */ - instance->closing = 1; - complete(&instance->insert_event); - } - - break; - - case VCHIQ_IOC_CONNECT: - if (instance->connected) { - ret = -EINVAL; - break; - } - rc = mutex_lock_killable(&instance->state->mutex); - if (rc) { - vchiq_log_error(vchiq_arm_log_level, - "vchiq: connect: could not lock mutex for state %d: %d", - instance->state->id, rc); - ret = -EINTR; - break; - } - status = vchiq_connect_internal(instance->state, instance); - mutex_unlock(&instance->state->mutex); - - if (status == VCHIQ_SUCCESS) - instance->connected = 1; - else - vchiq_log_error(vchiq_arm_log_level, - "vchiq: could not connect: %d", status); - break; - - case VCHIQ_IOC_CREATE_SERVICE: { - struct vchiq_create_service __user *argp; - struct vchiq_create_service args; - - argp = (void __user *)arg; - if (copy_from_user(&args, argp, sizeof(args))) { - ret = -EFAULT; - break; - } - - ret = vchiq_ioc_create_service(instance, &args); - if (ret < 0) - break; - - if (put_user(args.handle, &argp->handle)) { - vchiq_remove_service(args.handle); - ret = -EFAULT; - } - } break; - - case VCHIQ_IOC_CLOSE_SERVICE: - case VCHIQ_IOC_REMOVE_SERVICE: { - unsigned int handle = (unsigned int)arg; - struct user_service *user_service; - - service = find_service_for_instance(instance, handle); - if (!service) { - ret = -EINVAL; - break; - } - - user_service = service->base.userdata; - - /* - * close_pending is false on first entry, and when the - * wait in vchiq_close_service has been interrupted. - */ - if (!user_service->close_pending) { - status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ? - vchiq_close_service(service->handle) : - vchiq_remove_service(service->handle); - if (status != VCHIQ_SUCCESS) - break; - } - - /* - * close_pending is true once the underlying service - * has been closed until the client library calls the - * CLOSE_DELIVERED ioctl, signalling close_event. - */ - if (user_service->close_pending && - wait_for_completion_interruptible( - &user_service->close_event)) - status = VCHIQ_RETRY; - break; - } - - case VCHIQ_IOC_USE_SERVICE: - case VCHIQ_IOC_RELEASE_SERVICE: { - unsigned int handle = (unsigned int)arg; - - service = find_service_for_instance(instance, handle); - if (service) { - ret = (cmd == VCHIQ_IOC_USE_SERVICE) ? - vchiq_use_service_internal(service) : - vchiq_release_service_internal(service); - if (ret) { - vchiq_log_error(vchiq_susp_log_level, - "%s: cmd %s returned error %ld for service %c%c%c%c:%03d", - __func__, - (cmd == VCHIQ_IOC_USE_SERVICE) ? - "VCHIQ_IOC_USE_SERVICE" : - "VCHIQ_IOC_RELEASE_SERVICE", - ret, - VCHIQ_FOURCC_AS_4CHARS( - service->base.fourcc), - service->client_id); - } - } else { - ret = -EINVAL; - } - } break; - - case VCHIQ_IOC_QUEUE_MESSAGE: { - struct vchiq_queue_message args; - - if (copy_from_user(&args, (const void __user *)arg, - sizeof(args))) { - ret = -EFAULT; - break; - } - - service = find_service_for_instance(instance, args.handle); - - if (service && (args.count <= MAX_ELEMENTS)) { - /* Copy elements into kernel space */ - struct vchiq_element elements[MAX_ELEMENTS]; - - if (copy_from_user(elements, args.elements, - args.count * sizeof(struct vchiq_element)) == 0) - ret = vchiq_ioc_queue_message(args.handle, elements, - args.count); - else - ret = -EFAULT; - } else { - ret = -EINVAL; - } - } break; - - case VCHIQ_IOC_QUEUE_BULK_TRANSMIT: - case VCHIQ_IOC_QUEUE_BULK_RECEIVE: { - struct vchiq_queue_bulk_transfer args; - struct vchiq_queue_bulk_transfer __user *argp; - - enum vchiq_bulk_dir dir = - (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT) ? - VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; - - argp = (void __user *)arg; - if (copy_from_user(&args, argp, sizeof(args))) { - ret = -EFAULT; - break; - } - - ret = vchiq_irq_queue_bulk_tx_rx(instance, &args, - dir, &argp->mode); - } break; - - case VCHIQ_IOC_AWAIT_COMPLETION: { - struct vchiq_await_completion args; - struct vchiq_await_completion __user *argp; - - argp = (void __user *)arg; - if (copy_from_user(&args, argp, sizeof(args))) { - ret = -EFAULT; - break; - } - - ret = vchiq_ioc_await_completion(instance, &args, - &argp->msgbufcount); - } break; - - case VCHIQ_IOC_DEQUEUE_MESSAGE: { - struct vchiq_dequeue_message args; - - if (copy_from_user(&args, (const void __user *)arg, - sizeof(args))) { - ret = -EFAULT; - break; - } - - ret = vchiq_ioc_dequeue_message(instance, &args); - } break; - - case VCHIQ_IOC_GET_CLIENT_ID: { - unsigned int handle = (unsigned int)arg; - - ret = vchiq_get_client_id(handle); - } break; - - case VCHIQ_IOC_GET_CONFIG: { - struct vchiq_get_config args; - struct vchiq_config config; - - if (copy_from_user(&args, (const void __user *)arg, - sizeof(args))) { - ret = -EFAULT; - break; - } - if (args.config_size > sizeof(config)) { - ret = -EINVAL; - break; - } - - vchiq_get_config(&config); - if (copy_to_user(args.pconfig, &config, args.config_size)) { - ret = -EFAULT; - break; - } - } break; - - case VCHIQ_IOC_SET_SERVICE_OPTION: { - struct vchiq_set_service_option args; - - if (copy_from_user(&args, (const void __user *)arg, - sizeof(args))) { - ret = -EFAULT; - break; - } - - service = find_service_for_instance(instance, args.handle); - if (!service) { - ret = -EINVAL; - break; - } - - ret = vchiq_set_service_option(args.handle, args.option, - args.value); - } break; - - case VCHIQ_IOC_LIB_VERSION: { - unsigned int lib_version = (unsigned int)arg; - - if (lib_version < VCHIQ_VERSION_MIN) - ret = -EINVAL; - else if (lib_version >= VCHIQ_VERSION_CLOSE_DELIVERED) - instance->use_close_delivered = 1; - } break; - - case VCHIQ_IOC_CLOSE_DELIVERED: { - unsigned int handle = (unsigned int)arg; - - service = find_closed_service_for_instance(instance, handle); - if (service) { - struct user_service *user_service = - (struct user_service *)service->base.userdata; - close_delivered(user_service); - } else { - ret = -EINVAL; - } - } break; - - default: - ret = -ENOTTY; - break; - } - - if (service) - vchiq_service_put(service); - - if (ret == 0) { - if (status == VCHIQ_ERROR) - ret = -EIO; - else if (status == VCHIQ_RETRY) - ret = -EINTR; - } - - if ((status == VCHIQ_SUCCESS) && (ret < 0) && (ret != -EINTR) && - (ret != -EWOULDBLOCK)) - vchiq_log_info(vchiq_arm_log_level, - " ioctl instance %pK, cmd %s -> status %d, %ld", - instance, - (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? - ioctl_names[_IOC_NR(cmd)] : - "", - status, ret); - else - vchiq_log_trace(vchiq_arm_log_level, - " ioctl instance %pK, cmd %s -> status %d, %ld", - instance, - (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? - ioctl_names[_IOC_NR(cmd)] : - "", - status, ret); - - return ret; -} - -#if defined(CONFIG_COMPAT) - -struct vchiq_service_params32 { - int fourcc; - compat_uptr_t callback; - compat_uptr_t userdata; - short version; /* Increment for non-trivial changes */ - short version_min; /* Update for incompatible changes */ -}; - -struct vchiq_create_service32 { - struct vchiq_service_params32 params; - int is_open; - int is_vchi; - unsigned int handle; /* OUT */ -}; - -#define VCHIQ_IOC_CREATE_SERVICE32 \ - _IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service32) - -static long -vchiq_compat_ioctl_create_service(struct file *file, unsigned int cmd, - struct vchiq_create_service32 __user *ptrargs32) -{ - struct vchiq_create_service args; - struct vchiq_create_service32 args32; - long ret; - - if (copy_from_user(&args32, ptrargs32, sizeof(args32))) - return -EFAULT; - - args = (struct vchiq_create_service) { - .params = { - .fourcc = args32.params.fourcc, - .callback = compat_ptr(args32.params.callback), - .userdata = compat_ptr(args32.params.userdata), - .version = args32.params.version, - .version_min = args32.params.version_min, - }, - .is_open = args32.is_open, - .is_vchi = args32.is_vchi, - .handle = args32.handle, - }; - - ret = vchiq_ioc_create_service(file->private_data, &args); - if (ret < 0) - return ret; - - if (put_user(args.handle, &ptrargs32->handle)) { - vchiq_remove_service(args.handle); - return -EFAULT; - } - - return 0; -} - -struct vchiq_element32 { - compat_uptr_t data; - unsigned int size; -}; - -struct vchiq_queue_message32 { - unsigned int handle; - unsigned int count; - compat_uptr_t elements; -}; - -#define VCHIQ_IOC_QUEUE_MESSAGE32 \ - _IOW(VCHIQ_IOC_MAGIC, 4, struct vchiq_queue_message32) - -static long -vchiq_compat_ioctl_queue_message(struct file *file, - unsigned int cmd, - struct vchiq_queue_message32 __user *arg) -{ - struct vchiq_queue_message args; - struct vchiq_queue_message32 args32; - struct vchiq_service *service; - int ret; - - if (copy_from_user(&args32, arg, sizeof(args32))) - return -EFAULT; - - args = (struct vchiq_queue_message) { - .handle = args32.handle, - .count = args32.count, - .elements = compat_ptr(args32.elements), - }; - - if (args32.count > MAX_ELEMENTS) - return -EINVAL; - - service = find_service_for_instance(file->private_data, args.handle); - if (!service) - return -EINVAL; - - if (args32.elements && args32.count) { - struct vchiq_element32 element32[MAX_ELEMENTS]; - struct vchiq_element elements[MAX_ELEMENTS]; - unsigned int count; - - if (copy_from_user(&element32, args.elements, - sizeof(element32))) { - vchiq_service_put(service); - return -EFAULT; - } - - for (count = 0; count < args32.count; count++) { - elements[count].data = - compat_ptr(element32[count].data); - elements[count].size = element32[count].size; - } - ret = vchiq_ioc_queue_message(args.handle, elements, - args.count); - } else { - ret = -EINVAL; - } - vchiq_service_put(service); - - return ret; -} - -struct vchiq_queue_bulk_transfer32 { - unsigned int handle; - compat_uptr_t data; - unsigned int size; - compat_uptr_t userdata; - enum vchiq_bulk_mode mode; -}; - -#define VCHIQ_IOC_QUEUE_BULK_TRANSMIT32 \ - _IOWR(VCHIQ_IOC_MAGIC, 5, struct vchiq_queue_bulk_transfer32) -#define VCHIQ_IOC_QUEUE_BULK_RECEIVE32 \ - _IOWR(VCHIQ_IOC_MAGIC, 6, struct vchiq_queue_bulk_transfer32) - -static long -vchiq_compat_ioctl_queue_bulk(struct file *file, - unsigned int cmd, - struct vchiq_queue_bulk_transfer32 __user *argp) -{ - struct vchiq_queue_bulk_transfer32 args32; - struct vchiq_queue_bulk_transfer args; - enum vchiq_bulk_dir dir = (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT32) ? - VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; - - if (copy_from_user(&args32, argp, sizeof(args32))) - return -EFAULT; - - args = (struct vchiq_queue_bulk_transfer) { - .handle = args32.handle, - .data = compat_ptr(args32.data), - .size = args32.size, - .userdata = compat_ptr(args32.userdata), - .mode = args32.mode, - }; - - return vchiq_irq_queue_bulk_tx_rx(file->private_data, &args, - dir, &argp->mode); -} - -struct vchiq_await_completion32 { - unsigned int count; - compat_uptr_t buf; - unsigned int msgbufsize; - unsigned int msgbufcount; /* IN/OUT */ - compat_uptr_t msgbufs; -}; - -#define VCHIQ_IOC_AWAIT_COMPLETION32 \ - _IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion32) - -static long -vchiq_compat_ioctl_await_completion(struct file *file, - unsigned int cmd, - struct vchiq_await_completion32 __user *argp) -{ - struct vchiq_await_completion args; - struct vchiq_await_completion32 args32; - - if (copy_from_user(&args32, argp, sizeof(args32))) - return -EFAULT; - - args = (struct vchiq_await_completion) { - .count = args32.count, - .buf = compat_ptr(args32.buf), - .msgbufsize = args32.msgbufsize, - .msgbufcount = args32.msgbufcount, - .msgbufs = compat_ptr(args32.msgbufs), - }; - - return vchiq_ioc_await_completion(file->private_data, &args, - &argp->msgbufcount); -} - -struct vchiq_dequeue_message32 { - unsigned int handle; - int blocking; - unsigned int bufsize; - compat_uptr_t buf; -}; - -#define VCHIQ_IOC_DEQUEUE_MESSAGE32 \ - _IOWR(VCHIQ_IOC_MAGIC, 8, struct vchiq_dequeue_message32) - -static long -vchiq_compat_ioctl_dequeue_message(struct file *file, - unsigned int cmd, - struct vchiq_dequeue_message32 __user *arg) -{ - struct vchiq_dequeue_message32 args32; - struct vchiq_dequeue_message args; - - if (copy_from_user(&args32, arg, sizeof(args32))) - return -EFAULT; - - args = (struct vchiq_dequeue_message) { - .handle = args32.handle, - .blocking = args32.blocking, - .bufsize = args32.bufsize, - .buf = compat_ptr(args32.buf), - }; - - return vchiq_ioc_dequeue_message(file->private_data, &args); -} - -struct vchiq_get_config32 { - unsigned int config_size; - compat_uptr_t pconfig; -}; - -#define VCHIQ_IOC_GET_CONFIG32 \ - _IOWR(VCHIQ_IOC_MAGIC, 10, struct vchiq_get_config32) - -static long -vchiq_compat_ioctl_get_config(struct file *file, - unsigned int cmd, - struct vchiq_get_config32 __user *arg) -{ - struct vchiq_get_config32 args32; - struct vchiq_config config; - void __user *ptr; - - if (copy_from_user(&args32, arg, sizeof(args32))) - return -EFAULT; - if (args32.config_size > sizeof(config)) - return -EINVAL; - - vchiq_get_config(&config); - ptr = compat_ptr(args32.pconfig); - if (copy_to_user(ptr, &config, args32.config_size)) - return -EFAULT; - - return 0; -} - -static long -vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) -{ - void __user *argp = compat_ptr(arg); - - switch (cmd) { - case VCHIQ_IOC_CREATE_SERVICE32: - return vchiq_compat_ioctl_create_service(file, cmd, argp); - case VCHIQ_IOC_QUEUE_MESSAGE32: - return vchiq_compat_ioctl_queue_message(file, cmd, argp); - case VCHIQ_IOC_QUEUE_BULK_TRANSMIT32: - case VCHIQ_IOC_QUEUE_BULK_RECEIVE32: - return vchiq_compat_ioctl_queue_bulk(file, cmd, argp); - case VCHIQ_IOC_AWAIT_COMPLETION32: - return vchiq_compat_ioctl_await_completion(file, cmd, argp); - case VCHIQ_IOC_DEQUEUE_MESSAGE32: - return vchiq_compat_ioctl_dequeue_message(file, cmd, argp); - case VCHIQ_IOC_GET_CONFIG32: - return vchiq_compat_ioctl_get_config(file, cmd, argp); - default: - return vchiq_ioctl(file, cmd, (unsigned long)argp); - } -} - -#endif - -static int vchiq_open(struct inode *inode, struct file *file) -{ - struct vchiq_state *state = vchiq_get_state(); - struct vchiq_instance *instance; - - vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); - - if (!state) { - vchiq_log_error(vchiq_arm_log_level, - "vchiq has no connection to VideoCore"); - return -ENOTCONN; - } - - instance = kzalloc(sizeof(*instance), GFP_KERNEL); - if (!instance) - return -ENOMEM; - - instance->state = state; - instance->pid = current->tgid; - - vchiq_debugfs_add_instance(instance); - - init_completion(&instance->insert_event); - init_completion(&instance->remove_event); - mutex_init(&instance->completion_mutex); - mutex_init(&instance->bulk_waiter_list_mutex); - INIT_LIST_HEAD(&instance->bulk_waiter_list); - - file->private_data = instance; - - return 0; -} - -static int vchiq_release(struct inode *inode, struct file *file) -{ - struct vchiq_instance *instance = file->private_data; - struct vchiq_state *state = vchiq_get_state(); - struct vchiq_service *service; - int ret = 0; - int i; - - vchiq_log_info(vchiq_arm_log_level, "%s: instance=%lx", __func__, - (unsigned long)instance); - - if (!state) { - ret = -EPERM; - goto out; - } - - /* Ensure videocore is awake to allow termination. */ - vchiq_use_internal(instance->state, NULL, USE_TYPE_VCHIQ); - - mutex_lock(&instance->completion_mutex); - - /* Wake the completion thread and ask it to exit */ - instance->closing = 1; - complete(&instance->insert_event); - - mutex_unlock(&instance->completion_mutex); - - /* Wake the slot handler if the completion queue is full. */ - complete(&instance->remove_event); - - /* Mark all services for termination... */ - i = 0; - while ((service = next_service_by_instance(state, instance, &i))) { - struct user_service *user_service = service->base.userdata; - - /* Wake the slot handler if the msg queue is full. */ - complete(&user_service->remove_event); - - vchiq_terminate_service_internal(service); - vchiq_service_put(service); - } - - /* ...and wait for them to die */ - i = 0; - while ((service = next_service_by_instance(state, instance, &i))) { - struct user_service *user_service = service->base.userdata; - - wait_for_completion(&service->remove_event); - - if (WARN_ON(service->srvstate != VCHIQ_SRVSTATE_FREE)) { - vchiq_service_put(service); - break; - } - - spin_lock(&msg_queue_spinlock); - - while (user_service->msg_remove != user_service->msg_insert) { - struct vchiq_header *header; - int m = user_service->msg_remove & (MSG_QUEUE_SIZE - 1); - - header = user_service->msg_queue[m]; - user_service->msg_remove++; - spin_unlock(&msg_queue_spinlock); - - if (header) - vchiq_release_message(service->handle, header); - spin_lock(&msg_queue_spinlock); - } - - spin_unlock(&msg_queue_spinlock); - - vchiq_service_put(service); - } - - /* Release any closed services */ - while (instance->completion_remove != instance->completion_insert) { - struct vchiq_completion_data_kernel *completion; - struct vchiq_service *service; - - completion = &instance->completions[ - instance->completion_remove & (MAX_COMPLETIONS - 1)]; - service = completion->service_userdata; - if (completion->reason == VCHIQ_SERVICE_CLOSED) { - struct user_service *user_service = - service->base.userdata; - - /* Wake any blocked user-thread */ - if (instance->use_close_delivered) - complete(&user_service->close_event); - vchiq_service_put(service); - } - instance->completion_remove++; - } - - /* Release the PEER service count. */ - vchiq_release_internal(instance->state, NULL); - - free_bulk_waiter(instance); - - vchiq_debugfs_remove_instance(instance); - - kfree(instance); - file->private_data = NULL; - -out: - return ret; -} - -int vchiq_dump(void *dump_context, const char *str, int len) -{ - struct dump_context *context = (struct dump_context *)dump_context; - int copy_bytes; - - if (context->actual >= context->space) - return 0; - - if (context->offset > 0) { - int skip_bytes = min_t(int, len, context->offset); - - str += skip_bytes; - len -= skip_bytes; - context->offset -= skip_bytes; - if (context->offset > 0) - return 0; - } - copy_bytes = min_t(int, len, context->space - context->actual); - if (copy_bytes == 0) - return 0; - if (copy_to_user(context->buf + context->actual, str, - copy_bytes)) - return -EFAULT; - context->actual += copy_bytes; - len -= copy_bytes; - - /* - * If the terminating NUL is included in the length, then it - * marks the end of a line and should be replaced with a - * carriage return. - */ - if ((len == 0) && (str[copy_bytes - 1] == '\0')) { - char cr = '\n'; - - if (copy_to_user(context->buf + context->actual - 1, - &cr, 1)) - return -EFAULT; - } - return 0; -} - -int vchiq_dump_platform_instances(void *dump_context) -{ - struct vchiq_state *state = vchiq_get_state(); - char buf[80]; - int len; - int i; - - /* - * There is no list of instances, so instead scan all services, - * marking those that have been dumped. - */ - - rcu_read_lock(); - for (i = 0; i < state->unused_service; i++) { - struct vchiq_service *service; - struct vchiq_instance *instance; - - service = rcu_dereference(state->services[i]); - if (!service || service->base.callback != service_callback) - continue; - - instance = service->instance; - if (instance) - instance->mark = 0; - } - rcu_read_unlock(); - - for (i = 0; i < state->unused_service; i++) { - struct vchiq_service *service; - struct vchiq_instance *instance; - int err; - - rcu_read_lock(); - service = rcu_dereference(state->services[i]); - if (!service || service->base.callback != service_callback) { - rcu_read_unlock(); - continue; - } - - instance = service->instance; - if (!instance || instance->mark) { - rcu_read_unlock(); - continue; - } - rcu_read_unlock(); - - len = snprintf(buf, sizeof(buf), - "Instance %pK: pid %d,%s completions %d/%d", - instance, instance->pid, - instance->connected ? " connected, " : - "", - instance->completion_insert - - instance->completion_remove, - MAX_COMPLETIONS); - err = vchiq_dump(dump_context, buf, len + 1); - if (err) - return err; - instance->mark = 1; - } - return 0; -} - -int vchiq_dump_platform_service_state(void *dump_context, - struct vchiq_service *service) -{ - struct user_service *user_service = - (struct user_service *)service->base.userdata; - char buf[80]; - int len; - - len = scnprintf(buf, sizeof(buf), " instance %pK", service->instance); - - if ((service->base.callback == service_callback) && - user_service->is_vchi) { - len += scnprintf(buf + len, sizeof(buf) - len, - ", %d/%d messages", - user_service->msg_insert - user_service->msg_remove, - MSG_QUEUE_SIZE); - - if (user_service->dequeue_pending) - len += scnprintf(buf + len, sizeof(buf) - len, - " (dequeue pending)"); - } - - return vchiq_dump(dump_context, buf, len + 1); -} - -static ssize_t -vchiq_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) -{ - struct dump_context context; - int err; - - context.buf = buf; - context.actual = 0; - context.space = count; - context.offset = *ppos; - - err = vchiq_dump_state(&context, &g_state); - if (err) - return err; - - *ppos += context.actual; - - return context.actual; -} - -struct vchiq_state * -vchiq_get_state(void) -{ - - if (!g_state.remote) - pr_err("%s: g_state.remote == NULL\n", __func__); - else if (g_state.remote->initialised != 1) - pr_notice("%s: g_state.remote->initialised != 1 (%d)\n", - __func__, g_state.remote->initialised); + if (!g_state.remote) + pr_err("%s: g_state.remote == NULL\n", __func__); + else if (g_state.remote->initialised != 1) + pr_notice("%s: g_state.remote->initialised != 1 (%d)\n", + __func__, g_state.remote->initialised); return (g_state.remote && (g_state.remote->initialised == 1)) ? &g_state : NULL; } -static const struct file_operations -vchiq_fops = { - .owner = THIS_MODULE, - .unlocked_ioctl = vchiq_ioctl, -#if defined(CONFIG_COMPAT) - .compat_ioctl = vchiq_compat_ioctl, -#endif - .open = vchiq_open, - .release = vchiq_release, - .read = vchiq_read -}; - -/** - * vchiq_register_chrdev - Register the char driver for vchiq - * and create the necessary class and - * device files in userspace. - * @parent The parent of the char device. - * - * Returns 0 on success else returns the error code. - */ -int vchiq_register_chrdev(struct device *parent) -{ - struct device *vchiq_dev; - int ret; - - vchiq_class = class_create(THIS_MODULE, DEVICE_NAME); - if (IS_ERR(vchiq_class)) { - pr_err("Failed to create vchiq class\n"); - ret = PTR_ERR(vchiq_class); - goto error_exit; - } - - ret = alloc_chrdev_region(&vchiq_devid, 0, 1, DEVICE_NAME); - if (ret) { - pr_err("vchiq: Failed to allocate vchiq's chrdev region\n"); - goto alloc_region_error; - } - - cdev_init(&vchiq_cdev, &vchiq_fops); - vchiq_cdev.owner = THIS_MODULE; - ret = cdev_add(&vchiq_cdev, vchiq_devid, 1); - if (ret) { - vchiq_log_error(vchiq_arm_log_level, - "Unable to register vchiq char device"); - goto cdev_add_error; - } - - vchiq_dev = device_create(vchiq_class, parent, vchiq_devid, NULL, - DEVICE_NAME); - if (IS_ERR(vchiq_dev)) { - vchiq_log_error(vchiq_arm_log_level, - "Failed to create vchiq char device node"); - ret = PTR_ERR(vchiq_dev); - goto device_create_error; - } - - vchiq_log_info(vchiq_arm_log_level, - "vchiq char dev initialised successfully - device %d.%d", - MAJOR(vchiq_devid), MINOR(vchiq_devid)); - - return 0; - -device_create_error: - cdev_del(&vchiq_cdev); - -cdev_add_error: - unregister_chrdev_region(vchiq_devid, 1); - -alloc_region_error: - class_destroy(vchiq_class); - -error_exit: - return ret; -} - -/** - * vchiq_deregister_chrdev - Deregister and cleanup the vchiq char - * driver and device files - */ -void vchiq_deregister_chrdev(void) -{ - device_destroy(vchiq_class, vchiq_devid); - cdev_del(&vchiq_cdev); - unregister_chrdev_region(vchiq_devid, 1); - class_destroy(vchiq_class); -} - /* * Autosuspend related functionality */ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c new file mode 100644 index 000000000000..bf1a88c9d1ee --- /dev/null +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_dev.c @@ -0,0 +1,1440 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* + * Copyright (c) 2014 Raspberry Pi (Trading) Ltd. All rights reserved. + * Copyright (c) 2010-2012 Broadcom. All rights reserved. + */ + +#include +#include +#include +#include +#include + +#include "vchiq_core.h" +#include "vchiq_ioctl.h" +#include "vchiq_arm.h" +#include "vchiq_debugfs.h" + +#define DEVICE_NAME "vchiq" + +static struct cdev vchiq_cdev; +static dev_t vchiq_devid; +static struct class *vchiq_class; + +static const char *const ioctl_names[] = { + "CONNECT", + "SHUTDOWN", + "CREATE_SERVICE", + "REMOVE_SERVICE", + "QUEUE_MESSAGE", + "QUEUE_BULK_TRANSMIT", + "QUEUE_BULK_RECEIVE", + "AWAIT_COMPLETION", + "DEQUEUE_MESSAGE", + "GET_CLIENT_ID", + "GET_CONFIG", + "CLOSE_SERVICE", + "USE_SERVICE", + "RELEASE_SERVICE", + "SET_SERVICE_OPTION", + "DUMP_PHYS_MEM", + "LIB_VERSION", + "CLOSE_DELIVERED" +}; + +static_assert(ARRAY_SIZE(ioctl_names) == (VCHIQ_IOC_MAX + 1)); + +static void +user_service_free(void *userdata) +{ + kfree(userdata); +} + +static void close_delivered(struct user_service *user_service) +{ + vchiq_log_info(vchiq_arm_log_level, + "%s(handle=%x)", + __func__, user_service->service->handle); + + if (user_service->close_pending) { + /* Allow the underlying service to be culled */ + vchiq_service_put(user_service->service); + + /* Wake the user-thread blocked in close_ or remove_service */ + complete(&user_service->close_event); + + user_service->close_pending = 0; + } +} + +struct vchiq_io_copy_callback_context { + struct vchiq_element *element; + size_t element_offset; + unsigned long elements_to_go; +}; + +static ssize_t vchiq_ioc_copy_element_data(void *context, void *dest, + size_t offset, size_t maxsize) +{ + struct vchiq_io_copy_callback_context *cc = context; + size_t total_bytes_copied = 0; + size_t bytes_this_round; + + while (total_bytes_copied < maxsize) { + if (!cc->elements_to_go) + return total_bytes_copied; + + if (!cc->element->size) { + cc->elements_to_go--; + cc->element++; + cc->element_offset = 0; + continue; + } + + bytes_this_round = min(cc->element->size - cc->element_offset, + maxsize - total_bytes_copied); + + if (copy_from_user(dest + total_bytes_copied, + cc->element->data + cc->element_offset, + bytes_this_round)) + return -EFAULT; + + cc->element_offset += bytes_this_round; + total_bytes_copied += bytes_this_round; + + if (cc->element_offset == cc->element->size) { + cc->elements_to_go--; + cc->element++; + cc->element_offset = 0; + } + } + + return maxsize; +} + +static int +vchiq_ioc_queue_message(unsigned int handle, struct vchiq_element *elements, + unsigned long count) +{ + struct vchiq_io_copy_callback_context context; + enum vchiq_status status = VCHIQ_SUCCESS; + unsigned long i; + size_t total_size = 0; + + context.element = elements; + context.element_offset = 0; + context.elements_to_go = count; + + for (i = 0; i < count; i++) { + if (!elements[i].data && elements[i].size != 0) + return -EFAULT; + + total_size += elements[i].size; + } + + status = vchiq_queue_message(handle, vchiq_ioc_copy_element_data, + &context, total_size); + + if (status == VCHIQ_ERROR) + return -EIO; + else if (status == VCHIQ_RETRY) + return -EINTR; + return 0; +} + +static int vchiq_ioc_create_service(struct vchiq_instance *instance, + struct vchiq_create_service *args) +{ + struct user_service *user_service = NULL; + struct vchiq_service *service; + enum vchiq_status status = VCHIQ_SUCCESS; + struct vchiq_service_params_kernel params; + int srvstate; + + user_service = kmalloc(sizeof(*user_service), GFP_KERNEL); + if (!user_service) + return -ENOMEM; + + if (args->is_open) { + if (!instance->connected) { + kfree(user_service); + return -ENOTCONN; + } + srvstate = VCHIQ_SRVSTATE_OPENING; + } else { + srvstate = instance->connected ? + VCHIQ_SRVSTATE_LISTENING : VCHIQ_SRVSTATE_HIDDEN; + } + + params = (struct vchiq_service_params_kernel) { + .fourcc = args->params.fourcc, + .callback = service_callback, + .userdata = user_service, + .version = args->params.version, + .version_min = args->params.version_min, + }; + service = vchiq_add_service_internal(instance->state, ¶ms, + srvstate, instance, + user_service_free); + if (!service) { + kfree(user_service); + return -EEXIST; + } + + user_service->service = service; + user_service->userdata = args->params.userdata; + user_service->instance = instance; + user_service->is_vchi = (args->is_vchi != 0); + user_service->dequeue_pending = 0; + user_service->close_pending = 0; + user_service->message_available_pos = instance->completion_remove - 1; + user_service->msg_insert = 0; + user_service->msg_remove = 0; + init_completion(&user_service->insert_event); + init_completion(&user_service->remove_event); + init_completion(&user_service->close_event); + + if (args->is_open) { + status = vchiq_open_service_internal(service, instance->pid); + if (status != VCHIQ_SUCCESS) { + vchiq_remove_service(service->handle); + return (status == VCHIQ_RETRY) ? + -EINTR : -EIO; + } + } + args->handle = service->handle; + + return 0; +} + +static int vchiq_ioc_dequeue_message(struct vchiq_instance *instance, + struct vchiq_dequeue_message *args) +{ + struct user_service *user_service; + struct vchiq_service *service; + struct vchiq_header *header; + int ret; + + DEBUG_INITIALISE(g_state.local) + DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); + service = find_service_for_instance(instance, args->handle); + if (!service) + return -EINVAL; + + user_service = (struct user_service *)service->base.userdata; + if (user_service->is_vchi == 0) { + ret = -EINVAL; + goto out; + } + + spin_lock(&msg_queue_spinlock); + if (user_service->msg_remove == user_service->msg_insert) { + if (!args->blocking) { + spin_unlock(&msg_queue_spinlock); + DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); + ret = -EWOULDBLOCK; + goto out; + } + user_service->dequeue_pending = 1; + ret = 0; + do { + spin_unlock(&msg_queue_spinlock); + DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); + if (wait_for_completion_interruptible( + &user_service->insert_event)) { + vchiq_log_info(vchiq_arm_log_level, + "DEQUEUE_MESSAGE interrupted"); + ret = -EINTR; + break; + } + spin_lock(&msg_queue_spinlock); + } while (user_service->msg_remove == user_service->msg_insert); + + if (ret) + goto out; + } + + if (WARN_ON_ONCE((int)(user_service->msg_insert - + user_service->msg_remove) < 0)) { + spin_unlock(&msg_queue_spinlock); + ret = -EINVAL; + goto out; + } + + header = user_service->msg_queue[user_service->msg_remove & + (MSG_QUEUE_SIZE - 1)]; + user_service->msg_remove++; + spin_unlock(&msg_queue_spinlock); + + complete(&user_service->remove_event); + if (!header) { + ret = -ENOTCONN; + } else if (header->size <= args->bufsize) { + /* Copy to user space if msgbuf is not NULL */ + if (!args->buf || (copy_to_user(args->buf, + header->data, header->size) == 0)) { + ret = header->size; + vchiq_release_message(service->handle, header); + } else { + ret = -EFAULT; + } + } else { + vchiq_log_error(vchiq_arm_log_level, + "header %pK: bufsize %x < size %x", + header, args->bufsize, header->size); + WARN(1, "invalid size\n"); + ret = -EMSGSIZE; + } + DEBUG_TRACE(DEQUEUE_MESSAGE_LINE); +out: + vchiq_service_put(service); + return ret; +} + +static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance, + struct vchiq_queue_bulk_transfer *args, + enum vchiq_bulk_dir dir, + enum vchiq_bulk_mode __user *mode) +{ + struct vchiq_service *service; + struct bulk_waiter_node *waiter = NULL; + bool found = false; + void *userdata; + int status = 0; + int ret; + + service = find_service_for_instance(instance, args->handle); + if (!service) + return -EINVAL; + + if (args->mode == VCHIQ_BULK_MODE_BLOCKING) { + waiter = kzalloc(sizeof(*waiter), GFP_KERNEL); + if (!waiter) { + ret = -ENOMEM; + goto out; + } + + userdata = &waiter->bulk_waiter; + } else if (args->mode == VCHIQ_BULK_MODE_WAITING) { + mutex_lock(&instance->bulk_waiter_list_mutex); + list_for_each_entry(waiter, &instance->bulk_waiter_list, + list) { + if (waiter->pid == current->pid) { + list_del(&waiter->list); + found = true; + break; + } + } + mutex_unlock(&instance->bulk_waiter_list_mutex); + if (!found) { + vchiq_log_error(vchiq_arm_log_level, + "no bulk_waiter found for pid %d", + current->pid); + ret = -ESRCH; + goto out; + } + vchiq_log_info(vchiq_arm_log_level, + "found bulk_waiter %pK for pid %d", waiter, + current->pid); + userdata = &waiter->bulk_waiter; + } else { + userdata = args->userdata; + } + + status = vchiq_bulk_transfer(args->handle, NULL, args->data, args->size, + userdata, args->mode, dir); + + if (!waiter) { + ret = 0; + goto out; + } + + if ((status != VCHIQ_RETRY) || fatal_signal_pending(current) || + !waiter->bulk_waiter.bulk) { + if (waiter->bulk_waiter.bulk) { + /* Cancel the signal when the transfer completes. */ + spin_lock(&bulk_waiter_spinlock); + waiter->bulk_waiter.bulk->userdata = NULL; + spin_unlock(&bulk_waiter_spinlock); + } + kfree(waiter); + ret = 0; + } else { + const enum vchiq_bulk_mode mode_waiting = + VCHIQ_BULK_MODE_WAITING; + waiter->pid = current->pid; + mutex_lock(&instance->bulk_waiter_list_mutex); + list_add(&waiter->list, &instance->bulk_waiter_list); + mutex_unlock(&instance->bulk_waiter_list_mutex); + vchiq_log_info(vchiq_arm_log_level, + "saved bulk_waiter %pK for pid %d", + waiter, current->pid); + + ret = put_user(mode_waiting, mode); + } +out: + vchiq_service_put(service); + if (ret) + return ret; + else if (status == VCHIQ_ERROR) + return -EIO; + else if (status == VCHIQ_RETRY) + return -EINTR; + return 0; +} + +/* read a user pointer value from an array pointers in user space */ +static inline int vchiq_get_user_ptr(void __user **buf, void __user *ubuf, int index) +{ + int ret; + + if (in_compat_syscall()) { + compat_uptr_t ptr32; + compat_uptr_t __user *uptr = ubuf; + + ret = get_user(ptr32, uptr + index); + if (ret) + return ret; + + *buf = compat_ptr(ptr32); + } else { + uintptr_t ptr, __user *uptr = ubuf; + + ret = get_user(ptr, uptr + index); + + if (ret) + return ret; + + *buf = (void __user *)ptr; + } + + return 0; +} + +struct vchiq_completion_data32 { + enum vchiq_reason reason; + compat_uptr_t header; + compat_uptr_t service_userdata; + compat_uptr_t bulk_userdata; +}; + +static int vchiq_put_completion(struct vchiq_completion_data __user *buf, + struct vchiq_completion_data *completion, + int index) +{ + struct vchiq_completion_data32 __user *buf32 = (void __user *)buf; + + if (in_compat_syscall()) { + struct vchiq_completion_data32 tmp = { + .reason = completion->reason, + .header = ptr_to_compat(completion->header), + .service_userdata = ptr_to_compat(completion->service_userdata), + .bulk_userdata = ptr_to_compat(completion->bulk_userdata), + }; + if (copy_to_user(&buf32[index], &tmp, sizeof(tmp))) + return -EFAULT; + } else { + if (copy_to_user(&buf[index], completion, sizeof(*completion))) + return -EFAULT; + } + + return 0; +} + +static int vchiq_ioc_await_completion(struct vchiq_instance *instance, + struct vchiq_await_completion *args, + int __user *msgbufcountp) +{ + int msgbufcount; + int remove; + int ret; + + DEBUG_INITIALISE(g_state.local) + + DEBUG_TRACE(AWAIT_COMPLETION_LINE); + if (!instance->connected) { + return -ENOTCONN; + } + + mutex_lock(&instance->completion_mutex); + + DEBUG_TRACE(AWAIT_COMPLETION_LINE); + while ((instance->completion_remove == instance->completion_insert) + && !instance->closing) { + int rc; + + DEBUG_TRACE(AWAIT_COMPLETION_LINE); + mutex_unlock(&instance->completion_mutex); + rc = wait_for_completion_interruptible( + &instance->insert_event); + mutex_lock(&instance->completion_mutex); + if (rc) { + DEBUG_TRACE(AWAIT_COMPLETION_LINE); + vchiq_log_info(vchiq_arm_log_level, + "AWAIT_COMPLETION interrupted"); + ret = -EINTR; + goto out; + } + } + DEBUG_TRACE(AWAIT_COMPLETION_LINE); + + msgbufcount = args->msgbufcount; + remove = instance->completion_remove; + + for (ret = 0; ret < args->count; ret++) { + struct vchiq_completion_data_kernel *completion; + struct vchiq_completion_data user_completion; + struct vchiq_service *service; + struct user_service *user_service; + struct vchiq_header *header; + + if (remove == instance->completion_insert) + break; + + completion = &instance->completions[ + remove & (MAX_COMPLETIONS - 1)]; + + /* + * A read memory barrier is needed to stop + * prefetch of a stale completion record + */ + rmb(); + + service = completion->service_userdata; + user_service = service->base.userdata; + + memset(&user_completion, 0, sizeof(user_completion)); + user_completion = (struct vchiq_completion_data) { + .reason = completion->reason, + .service_userdata = user_service->userdata, + }; + + header = completion->header; + if (header) { + void __user *msgbuf; + int msglen; + + msglen = header->size + sizeof(struct vchiq_header); + /* This must be a VCHIQ-style service */ + if (args->msgbufsize < msglen) { + vchiq_log_error(vchiq_arm_log_level, + "header %pK: msgbufsize %x < msglen %x", + header, args->msgbufsize, msglen); + WARN(1, "invalid message size\n"); + if (ret == 0) + ret = -EMSGSIZE; + break; + } + if (msgbufcount <= 0) + /* Stall here for lack of a buffer for the message. */ + break; + /* Get the pointer from user space */ + msgbufcount--; + if (vchiq_get_user_ptr(&msgbuf, args->msgbufs, + msgbufcount)) { + if (ret == 0) + ret = -EFAULT; + break; + } + + /* Copy the message to user space */ + if (copy_to_user(msgbuf, header, msglen)) { + if (ret == 0) + ret = -EFAULT; + break; + } + + /* Now it has been copied, the message can be released. */ + vchiq_release_message(service->handle, header); + + /* The completion must point to the msgbuf. */ + user_completion.header = msgbuf; + } + + if ((completion->reason == VCHIQ_SERVICE_CLOSED) && + !instance->use_close_delivered) + vchiq_service_put(service); + + /* + * FIXME: address space mismatch, does bulk_userdata + * actually point to user or kernel memory? + */ + user_completion.bulk_userdata = completion->bulk_userdata; + + if (vchiq_put_completion(args->buf, &user_completion, ret)) { + if (ret == 0) + ret = -EFAULT; + break; + } + + /* + * Ensure that the above copy has completed + * before advancing the remove pointer. + */ + mb(); + remove++; + instance->completion_remove = remove; + } + + if (msgbufcount != args->msgbufcount) { + if (put_user(msgbufcount, msgbufcountp)) + ret = -EFAULT; + } +out: + if (ret) + complete(&instance->remove_event); + mutex_unlock(&instance->completion_mutex); + DEBUG_TRACE(AWAIT_COMPLETION_LINE); + + return ret; +} + +static long +vchiq_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + struct vchiq_instance *instance = file->private_data; + enum vchiq_status status = VCHIQ_SUCCESS; + struct vchiq_service *service = NULL; + long ret = 0; + int i, rc; + + vchiq_log_trace(vchiq_arm_log_level, + "%s - instance %pK, cmd %s, arg %lx", + __func__, instance, + ((_IOC_TYPE(cmd) == VCHIQ_IOC_MAGIC) && + (_IOC_NR(cmd) <= VCHIQ_IOC_MAX)) ? + ioctl_names[_IOC_NR(cmd)] : "", arg); + + switch (cmd) { + case VCHIQ_IOC_SHUTDOWN: + if (!instance->connected) + break; + + /* Remove all services */ + i = 0; + while ((service = next_service_by_instance(instance->state, + instance, &i))) { + status = vchiq_remove_service(service->handle); + vchiq_service_put(service); + if (status != VCHIQ_SUCCESS) + break; + } + service = NULL; + + if (status == VCHIQ_SUCCESS) { + /* Wake the completion thread and ask it to exit */ + instance->closing = 1; + complete(&instance->insert_event); + } + + break; + + case VCHIQ_IOC_CONNECT: + if (instance->connected) { + ret = -EINVAL; + break; + } + rc = mutex_lock_killable(&instance->state->mutex); + if (rc) { + vchiq_log_error(vchiq_arm_log_level, + "vchiq: connect: could not lock mutex for state %d: %d", + instance->state->id, rc); + ret = -EINTR; + break; + } + status = vchiq_connect_internal(instance->state, instance); + mutex_unlock(&instance->state->mutex); + + if (status == VCHIQ_SUCCESS) + instance->connected = 1; + else + vchiq_log_error(vchiq_arm_log_level, + "vchiq: could not connect: %d", status); + break; + + case VCHIQ_IOC_CREATE_SERVICE: { + struct vchiq_create_service __user *argp; + struct vchiq_create_service args; + + argp = (void __user *)arg; + if (copy_from_user(&args, argp, sizeof(args))) { + ret = -EFAULT; + break; + } + + ret = vchiq_ioc_create_service(instance, &args); + if (ret < 0) + break; + + if (put_user(args.handle, &argp->handle)) { + vchiq_remove_service(args.handle); + ret = -EFAULT; + } + } break; + + case VCHIQ_IOC_CLOSE_SERVICE: + case VCHIQ_IOC_REMOVE_SERVICE: { + unsigned int handle = (unsigned int)arg; + struct user_service *user_service; + + service = find_service_for_instance(instance, handle); + if (!service) { + ret = -EINVAL; + break; + } + + user_service = service->base.userdata; + + /* + * close_pending is false on first entry, and when the + * wait in vchiq_close_service has been interrupted. + */ + if (!user_service->close_pending) { + status = (cmd == VCHIQ_IOC_CLOSE_SERVICE) ? + vchiq_close_service(service->handle) : + vchiq_remove_service(service->handle); + if (status != VCHIQ_SUCCESS) + break; + } + + /* + * close_pending is true once the underlying service + * has been closed until the client library calls the + * CLOSE_DELIVERED ioctl, signalling close_event. + */ + if (user_service->close_pending && + wait_for_completion_interruptible( + &user_service->close_event)) + status = VCHIQ_RETRY; + break; + } + + case VCHIQ_IOC_USE_SERVICE: + case VCHIQ_IOC_RELEASE_SERVICE: { + unsigned int handle = (unsigned int)arg; + + service = find_service_for_instance(instance, handle); + if (service) { + ret = (cmd == VCHIQ_IOC_USE_SERVICE) ? + vchiq_use_service_internal(service) : + vchiq_release_service_internal(service); + if (ret) { + vchiq_log_error(vchiq_susp_log_level, + "%s: cmd %s returned error %ld for service %c%c%c%c:%03d", + __func__, + (cmd == VCHIQ_IOC_USE_SERVICE) ? + "VCHIQ_IOC_USE_SERVICE" : + "VCHIQ_IOC_RELEASE_SERVICE", + ret, + VCHIQ_FOURCC_AS_4CHARS( + service->base.fourcc), + service->client_id); + } + } else { + ret = -EINVAL; + } + } break; + + case VCHIQ_IOC_QUEUE_MESSAGE: { + struct vchiq_queue_message args; + + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { + ret = -EFAULT; + break; + } + + service = find_service_for_instance(instance, args.handle); + + if (service && (args.count <= MAX_ELEMENTS)) { + /* Copy elements into kernel space */ + struct vchiq_element elements[MAX_ELEMENTS]; + + if (copy_from_user(elements, args.elements, + args.count * sizeof(struct vchiq_element)) == 0) + ret = vchiq_ioc_queue_message(args.handle, elements, + args.count); + else + ret = -EFAULT; + } else { + ret = -EINVAL; + } + } break; + + case VCHIQ_IOC_QUEUE_BULK_TRANSMIT: + case VCHIQ_IOC_QUEUE_BULK_RECEIVE: { + struct vchiq_queue_bulk_transfer args; + struct vchiq_queue_bulk_transfer __user *argp; + + enum vchiq_bulk_dir dir = + (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT) ? + VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; + + argp = (void __user *)arg; + if (copy_from_user(&args, argp, sizeof(args))) { + ret = -EFAULT; + break; + } + + ret = vchiq_irq_queue_bulk_tx_rx(instance, &args, + dir, &argp->mode); + } break; + + case VCHIQ_IOC_AWAIT_COMPLETION: { + struct vchiq_await_completion args; + struct vchiq_await_completion __user *argp; + + argp = (void __user *)arg; + if (copy_from_user(&args, argp, sizeof(args))) { + ret = -EFAULT; + break; + } + + ret = vchiq_ioc_await_completion(instance, &args, + &argp->msgbufcount); + } break; + + case VCHIQ_IOC_DEQUEUE_MESSAGE: { + struct vchiq_dequeue_message args; + + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { + ret = -EFAULT; + break; + } + + ret = vchiq_ioc_dequeue_message(instance, &args); + } break; + + case VCHIQ_IOC_GET_CLIENT_ID: { + unsigned int handle = (unsigned int)arg; + + ret = vchiq_get_client_id(handle); + } break; + + case VCHIQ_IOC_GET_CONFIG: { + struct vchiq_get_config args; + struct vchiq_config config; + + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { + ret = -EFAULT; + break; + } + if (args.config_size > sizeof(config)) { + ret = -EINVAL; + break; + } + + vchiq_get_config(&config); + if (copy_to_user(args.pconfig, &config, args.config_size)) { + ret = -EFAULT; + break; + } + } break; + + case VCHIQ_IOC_SET_SERVICE_OPTION: { + struct vchiq_set_service_option args; + + if (copy_from_user(&args, (const void __user *)arg, + sizeof(args))) { + ret = -EFAULT; + break; + } + + service = find_service_for_instance(instance, args.handle); + if (!service) { + ret = -EINVAL; + break; + } + + ret = vchiq_set_service_option(args.handle, args.option, + args.value); + } break; + + case VCHIQ_IOC_LIB_VERSION: { + unsigned int lib_version = (unsigned int)arg; + + if (lib_version < VCHIQ_VERSION_MIN) + ret = -EINVAL; + else if (lib_version >= VCHIQ_VERSION_CLOSE_DELIVERED) + instance->use_close_delivered = 1; + } break; + + case VCHIQ_IOC_CLOSE_DELIVERED: { + unsigned int handle = (unsigned int)arg; + + service = find_closed_service_for_instance(instance, handle); + if (service) { + struct user_service *user_service = + (struct user_service *)service->base.userdata; + close_delivered(user_service); + } else { + ret = -EINVAL; + } + } break; + + default: + ret = -ENOTTY; + break; + } + + if (service) + vchiq_service_put(service); + + if (ret == 0) { + if (status == VCHIQ_ERROR) + ret = -EIO; + else if (status == VCHIQ_RETRY) + ret = -EINTR; + } + + if ((status == VCHIQ_SUCCESS) && (ret < 0) && (ret != -EINTR) && + (ret != -EWOULDBLOCK)) + vchiq_log_info(vchiq_arm_log_level, + " ioctl instance %pK, cmd %s -> status %d, %ld", + instance, + (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? + ioctl_names[_IOC_NR(cmd)] : + "", + status, ret); + else + vchiq_log_trace(vchiq_arm_log_level, + " ioctl instance %pK, cmd %s -> status %d, %ld", + instance, + (_IOC_NR(cmd) <= VCHIQ_IOC_MAX) ? + ioctl_names[_IOC_NR(cmd)] : + "", + status, ret); + + return ret; +} + +#if defined(CONFIG_COMPAT) + +struct vchiq_service_params32 { + int fourcc; + compat_uptr_t callback; + compat_uptr_t userdata; + short version; /* Increment for non-trivial changes */ + short version_min; /* Update for incompatible changes */ +}; + +struct vchiq_create_service32 { + struct vchiq_service_params32 params; + int is_open; + int is_vchi; + unsigned int handle; /* OUT */ +}; + +#define VCHIQ_IOC_CREATE_SERVICE32 \ + _IOWR(VCHIQ_IOC_MAGIC, 2, struct vchiq_create_service32) + +static long +vchiq_compat_ioctl_create_service(struct file *file, unsigned int cmd, + struct vchiq_create_service32 __user *ptrargs32) +{ + struct vchiq_create_service args; + struct vchiq_create_service32 args32; + long ret; + + if (copy_from_user(&args32, ptrargs32, sizeof(args32))) + return -EFAULT; + + args = (struct vchiq_create_service) { + .params = { + .fourcc = args32.params.fourcc, + .callback = compat_ptr(args32.params.callback), + .userdata = compat_ptr(args32.params.userdata), + .version = args32.params.version, + .version_min = args32.params.version_min, + }, + .is_open = args32.is_open, + .is_vchi = args32.is_vchi, + .handle = args32.handle, + }; + + ret = vchiq_ioc_create_service(file->private_data, &args); + if (ret < 0) + return ret; + + if (put_user(args.handle, &ptrargs32->handle)) { + vchiq_remove_service(args.handle); + return -EFAULT; + } + + return 0; +} + +struct vchiq_element32 { + compat_uptr_t data; + unsigned int size; +}; + +struct vchiq_queue_message32 { + unsigned int handle; + unsigned int count; + compat_uptr_t elements; +}; + +#define VCHIQ_IOC_QUEUE_MESSAGE32 \ + _IOW(VCHIQ_IOC_MAGIC, 4, struct vchiq_queue_message32) + +static long +vchiq_compat_ioctl_queue_message(struct file *file, + unsigned int cmd, + struct vchiq_queue_message32 __user *arg) +{ + struct vchiq_queue_message args; + struct vchiq_queue_message32 args32; + struct vchiq_service *service; + int ret; + + if (copy_from_user(&args32, arg, sizeof(args32))) + return -EFAULT; + + args = (struct vchiq_queue_message) { + .handle = args32.handle, + .count = args32.count, + .elements = compat_ptr(args32.elements), + }; + + if (args32.count > MAX_ELEMENTS) + return -EINVAL; + + service = find_service_for_instance(file->private_data, args.handle); + if (!service) + return -EINVAL; + + if (args32.elements && args32.count) { + struct vchiq_element32 element32[MAX_ELEMENTS]; + struct vchiq_element elements[MAX_ELEMENTS]; + unsigned int count; + + if (copy_from_user(&element32, args.elements, + sizeof(element32))) { + vchiq_service_put(service); + return -EFAULT; + } + + for (count = 0; count < args32.count; count++) { + elements[count].data = + compat_ptr(element32[count].data); + elements[count].size = element32[count].size; + } + ret = vchiq_ioc_queue_message(args.handle, elements, + args.count); + } else { + ret = -EINVAL; + } + vchiq_service_put(service); + + return ret; +} + +struct vchiq_queue_bulk_transfer32 { + unsigned int handle; + compat_uptr_t data; + unsigned int size; + compat_uptr_t userdata; + enum vchiq_bulk_mode mode; +}; + +#define VCHIQ_IOC_QUEUE_BULK_TRANSMIT32 \ + _IOWR(VCHIQ_IOC_MAGIC, 5, struct vchiq_queue_bulk_transfer32) +#define VCHIQ_IOC_QUEUE_BULK_RECEIVE32 \ + _IOWR(VCHIQ_IOC_MAGIC, 6, struct vchiq_queue_bulk_transfer32) + +static long +vchiq_compat_ioctl_queue_bulk(struct file *file, + unsigned int cmd, + struct vchiq_queue_bulk_transfer32 __user *argp) +{ + struct vchiq_queue_bulk_transfer32 args32; + struct vchiq_queue_bulk_transfer args; + enum vchiq_bulk_dir dir = (cmd == VCHIQ_IOC_QUEUE_BULK_TRANSMIT32) ? + VCHIQ_BULK_TRANSMIT : VCHIQ_BULK_RECEIVE; + + if (copy_from_user(&args32, argp, sizeof(args32))) + return -EFAULT; + + args = (struct vchiq_queue_bulk_transfer) { + .handle = args32.handle, + .data = compat_ptr(args32.data), + .size = args32.size, + .userdata = compat_ptr(args32.userdata), + .mode = args32.mode, + }; + + return vchiq_irq_queue_bulk_tx_rx(file->private_data, &args, + dir, &argp->mode); +} + +struct vchiq_await_completion32 { + unsigned int count; + compat_uptr_t buf; + unsigned int msgbufsize; + unsigned int msgbufcount; /* IN/OUT */ + compat_uptr_t msgbufs; +}; + +#define VCHIQ_IOC_AWAIT_COMPLETION32 \ + _IOWR(VCHIQ_IOC_MAGIC, 7, struct vchiq_await_completion32) + +static long +vchiq_compat_ioctl_await_completion(struct file *file, + unsigned int cmd, + struct vchiq_await_completion32 __user *argp) +{ + struct vchiq_await_completion args; + struct vchiq_await_completion32 args32; + + if (copy_from_user(&args32, argp, sizeof(args32))) + return -EFAULT; + + args = (struct vchiq_await_completion) { + .count = args32.count, + .buf = compat_ptr(args32.buf), + .msgbufsize = args32.msgbufsize, + .msgbufcount = args32.msgbufcount, + .msgbufs = compat_ptr(args32.msgbufs), + }; + + return vchiq_ioc_await_completion(file->private_data, &args, + &argp->msgbufcount); +} + +struct vchiq_dequeue_message32 { + unsigned int handle; + int blocking; + unsigned int bufsize; + compat_uptr_t buf; +}; + +#define VCHIQ_IOC_DEQUEUE_MESSAGE32 \ + _IOWR(VCHIQ_IOC_MAGIC, 8, struct vchiq_dequeue_message32) + +static long +vchiq_compat_ioctl_dequeue_message(struct file *file, + unsigned int cmd, + struct vchiq_dequeue_message32 __user *arg) +{ + struct vchiq_dequeue_message32 args32; + struct vchiq_dequeue_message args; + + if (copy_from_user(&args32, arg, sizeof(args32))) + return -EFAULT; + + args = (struct vchiq_dequeue_message) { + .handle = args32.handle, + .blocking = args32.blocking, + .bufsize = args32.bufsize, + .buf = compat_ptr(args32.buf), + }; + + return vchiq_ioc_dequeue_message(file->private_data, &args); +} + +struct vchiq_get_config32 { + unsigned int config_size; + compat_uptr_t pconfig; +}; + +#define VCHIQ_IOC_GET_CONFIG32 \ + _IOWR(VCHIQ_IOC_MAGIC, 10, struct vchiq_get_config32) + +static long +vchiq_compat_ioctl_get_config(struct file *file, + unsigned int cmd, + struct vchiq_get_config32 __user *arg) +{ + struct vchiq_get_config32 args32; + struct vchiq_config config; + void __user *ptr; + + if (copy_from_user(&args32, arg, sizeof(args32))) + return -EFAULT; + if (args32.config_size > sizeof(config)) + return -EINVAL; + + vchiq_get_config(&config); + ptr = compat_ptr(args32.pconfig); + if (copy_to_user(ptr, &config, args32.config_size)) + return -EFAULT; + + return 0; +} + +static long +vchiq_compat_ioctl(struct file *file, unsigned int cmd, unsigned long arg) +{ + void __user *argp = compat_ptr(arg); + + switch (cmd) { + case VCHIQ_IOC_CREATE_SERVICE32: + return vchiq_compat_ioctl_create_service(file, cmd, argp); + case VCHIQ_IOC_QUEUE_MESSAGE32: + return vchiq_compat_ioctl_queue_message(file, cmd, argp); + case VCHIQ_IOC_QUEUE_BULK_TRANSMIT32: + case VCHIQ_IOC_QUEUE_BULK_RECEIVE32: + return vchiq_compat_ioctl_queue_bulk(file, cmd, argp); + case VCHIQ_IOC_AWAIT_COMPLETION32: + return vchiq_compat_ioctl_await_completion(file, cmd, argp); + case VCHIQ_IOC_DEQUEUE_MESSAGE32: + return vchiq_compat_ioctl_dequeue_message(file, cmd, argp); + case VCHIQ_IOC_GET_CONFIG32: + return vchiq_compat_ioctl_get_config(file, cmd, argp); + default: + return vchiq_ioctl(file, cmd, (unsigned long)argp); + } +} + +#endif + +static int vchiq_open(struct inode *inode, struct file *file) +{ + struct vchiq_state *state = vchiq_get_state(); + struct vchiq_instance *instance; + + vchiq_log_info(vchiq_arm_log_level, "vchiq_open"); + + if (!state) { + vchiq_log_error(vchiq_arm_log_level, + "vchiq has no connection to VideoCore"); + return -ENOTCONN; + } + + instance = kzalloc(sizeof(*instance), GFP_KERNEL); + if (!instance) + return -ENOMEM; + + instance->state = state; + instance->pid = current->tgid; + + vchiq_debugfs_add_instance(instance); + + init_completion(&instance->insert_event); + init_completion(&instance->remove_event); + mutex_init(&instance->completion_mutex); + mutex_init(&instance->bulk_waiter_list_mutex); + INIT_LIST_HEAD(&instance->bulk_waiter_list); + + file->private_data = instance; + + return 0; +} + +static int vchiq_release(struct inode *inode, struct file *file) +{ + struct vchiq_instance *instance = file->private_data; + struct vchiq_state *state = vchiq_get_state(); + struct vchiq_service *service; + int ret = 0; + int i; + + vchiq_log_info(vchiq_arm_log_level, "%s: instance=%lx", __func__, + (unsigned long)instance); + + if (!state) { + ret = -EPERM; + goto out; + } + + /* Ensure videocore is awake to allow termination. */ + vchiq_use_internal(instance->state, NULL, USE_TYPE_VCHIQ); + + mutex_lock(&instance->completion_mutex); + + /* Wake the completion thread and ask it to exit */ + instance->closing = 1; + complete(&instance->insert_event); + + mutex_unlock(&instance->completion_mutex); + + /* Wake the slot handler if the completion queue is full. */ + complete(&instance->remove_event); + + /* Mark all services for termination... */ + i = 0; + while ((service = next_service_by_instance(state, instance, &i))) { + struct user_service *user_service = service->base.userdata; + + /* Wake the slot handler if the msg queue is full. */ + complete(&user_service->remove_event); + + vchiq_terminate_service_internal(service); + vchiq_service_put(service); + } + + /* ...and wait for them to die */ + i = 0; + while ((service = next_service_by_instance(state, instance, &i))) { + struct user_service *user_service = service->base.userdata; + + wait_for_completion(&service->remove_event); + + if (WARN_ON(service->srvstate != VCHIQ_SRVSTATE_FREE)) { + vchiq_service_put(service); + break; + } + + spin_lock(&msg_queue_spinlock); + + while (user_service->msg_remove != user_service->msg_insert) { + struct vchiq_header *header; + int m = user_service->msg_remove & (MSG_QUEUE_SIZE - 1); + + header = user_service->msg_queue[m]; + user_service->msg_remove++; + spin_unlock(&msg_queue_spinlock); + + if (header) + vchiq_release_message(service->handle, header); + spin_lock(&msg_queue_spinlock); + } + + spin_unlock(&msg_queue_spinlock); + + vchiq_service_put(service); + } + + /* Release any closed services */ + while (instance->completion_remove != instance->completion_insert) { + struct vchiq_completion_data_kernel *completion; + struct vchiq_service *service; + + completion = &instance->completions[ + instance->completion_remove & (MAX_COMPLETIONS - 1)]; + service = completion->service_userdata; + if (completion->reason == VCHIQ_SERVICE_CLOSED) { + struct user_service *user_service = + service->base.userdata; + + /* Wake any blocked user-thread */ + if (instance->use_close_delivered) + complete(&user_service->close_event); + vchiq_service_put(service); + } + instance->completion_remove++; + } + + /* Release the PEER service count. */ + vchiq_release_internal(instance->state, NULL); + + free_bulk_waiter(instance); + + vchiq_debugfs_remove_instance(instance); + + kfree(instance); + file->private_data = NULL; + +out: + return ret; +} + +static ssize_t +vchiq_read(struct file *file, char __user *buf, size_t count, loff_t *ppos) +{ + struct dump_context context; + int err; + + context.buf = buf; + context.actual = 0; + context.space = count; + context.offset = *ppos; + + err = vchiq_dump_state(&context, &g_state); + if (err) + return err; + + *ppos += context.actual; + + return context.actual; +} + +static const struct file_operations +vchiq_fops = { + .owner = THIS_MODULE, + .unlocked_ioctl = vchiq_ioctl, +#if defined(CONFIG_COMPAT) + .compat_ioctl = vchiq_compat_ioctl, +#endif + .open = vchiq_open, + .release = vchiq_release, + .read = vchiq_read +}; + +/** + * vchiq_register_chrdev - Register the char driver for vchiq + * and create the necessary class and + * device files in userspace. + * @parent The parent of the char device. + * + * Returns 0 on success else returns the error code. + */ +int vchiq_register_chrdev(struct device *parent) +{ + struct device *vchiq_dev; + int ret; + + vchiq_class = class_create(THIS_MODULE, DEVICE_NAME); + if (IS_ERR(vchiq_class)) { + pr_err("Failed to create vchiq class\n"); + ret = PTR_ERR(vchiq_class); + goto error_exit; + } + + ret = alloc_chrdev_region(&vchiq_devid, 0, 1, DEVICE_NAME); + if (ret) { + pr_err("vchiq: Failed to allocate vchiq's chrdev region\n"); + goto alloc_region_error; + } + + cdev_init(&vchiq_cdev, &vchiq_fops); + vchiq_cdev.owner = THIS_MODULE; + ret = cdev_add(&vchiq_cdev, vchiq_devid, 1); + if (ret) { + vchiq_log_error(vchiq_arm_log_level, + "Unable to register vchiq char device"); + goto cdev_add_error; + } + + vchiq_dev = device_create(vchiq_class, parent, vchiq_devid, NULL, + DEVICE_NAME); + if (IS_ERR(vchiq_dev)) { + vchiq_log_error(vchiq_arm_log_level, + "Failed to create vchiq char device node"); + ret = PTR_ERR(vchiq_dev); + goto device_create_error; + } + + vchiq_log_info(vchiq_arm_log_level, + "vchiq char dev initialised successfully - device %d.%d", + MAJOR(vchiq_devid), MINOR(vchiq_devid)); + + return 0; + +device_create_error: + cdev_del(&vchiq_cdev); + +cdev_add_error: + unregister_chrdev_region(vchiq_devid, 1); + +alloc_region_error: + class_destroy(vchiq_class); + +error_exit: + return ret; +} + +/** + * vchiq_deregister_chrdev - Deregister and cleanup the vchiq char + * driver and device files + */ +void vchiq_deregister_chrdev(void) +{ + device_destroy(vchiq_class, vchiq_devid); + cdev_del(&vchiq_cdev); + unregister_chrdev_region(vchiq_devid, 1); + class_destroy(vchiq_class); +} -- cgit v1.2.3 From 2b5930fb3dc06d86149071f9dc8b6992cac1c3aa Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Wed, 21 Jul 2021 21:50:52 +0530 Subject: staging: vchiq: Make creation of vchiq cdev optional Before this commit, vchiq cdev (/dev/vchiq) was always created during platform initialization. Introduce a new Kconfig option CONFIG_VCHIQ_CDEV which determines if the cdev will be created or not. Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/846c424dd4aae14d1cc28c8f30877a06e2b7dd10.1626882325.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Kconfig | 10 ++++++++++ drivers/staging/vc04_services/Makefile | 5 ++++- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h | 9 +++++++++ 3 files changed, 23 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig index 4b886293f198..63caa6818d37 100644 --- a/drivers/staging/vc04_services/Kconfig +++ b/drivers/staging/vc04_services/Kconfig @@ -19,6 +19,16 @@ config BCM2835_VCHIQ Defaults to Y when the Broadcom Videocore services are included in the build, N otherwise. +if BCM2835_VCHIQ + +config VCHIQ_CDEV + bool "VCHIQ Character Driver" + help + Enable the creation of VCHIQ character driver to help + communicate with the Videocore platform. + +endif + source "drivers/staging/vc04_services/bcm2835-audio/Kconfig" source "drivers/staging/vc04_services/bcm2835-camera/Kconfig" diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index db28be341239..0a04338fc962 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -7,7 +7,10 @@ vchiq-objs := \ interface/vchiq_arm/vchiq_2835_arm.o \ interface/vchiq_arm/vchiq_debugfs.o \ interface/vchiq_arm/vchiq_connected.o \ - interface/vchiq_arm/vchiq_dev.o \ + +ifdef CONFIG_VCHIQ_CDEV +vchiq-objs += interface/vchiq_arm/vchiq_dev.o +endif obj-$(CONFIG_SND_BCM2835) += bcm2835-audio/ obj-$(CONFIG_VIDEO_BCM2835) += bcm2835-camera/ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h index 2453971b6b78..e8e39a154c74 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h @@ -174,12 +174,21 @@ vchiq_instance_get_trace(struct vchiq_instance *instance); extern void vchiq_instance_set_trace(struct vchiq_instance *instance, int trace); +#if IS_ENABLED(CONFIG_VCHIQ_CDEV) + extern void vchiq_deregister_chrdev(void); extern int vchiq_register_chrdev(struct device *parent); +#else + +static inline void vchiq_deregister_chrdev(void) { } +static inline int vchiq_register_chrdev(struct device *parent) { return 0; } + +#endif /* IS_ENABLED(CONFIG_VCHIQ_CDEV) */ + extern enum vchiq_status service_callback(enum vchiq_reason reason, struct vchiq_header *header, unsigned int handle, void *bulk_userdata); -- cgit v1.2.3 From 7b9148dcb74a004a4df10df3af9239a46dfc2b2f Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Wed, 21 Jul 2021 21:50:53 +0530 Subject: staging: vchiq: Combine vchiq platform code into single file Combine the vchiq platform initialization code into a single file by merging vchiq_2835_arm.c into vchiq_arm.c Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/647cad50aa3306d1a49bacff76eaa3130fb363f4.1626882325.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Makefile | 1 - .../interface/vchiq_arm/vchiq_2835_arm.c | 564 --------------------- .../vc04_services/interface/vchiq_arm/vchiq_arm.c | 535 +++++++++++++++++++ 3 files changed, 535 insertions(+), 565 deletions(-) delete mode 100644 drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Makefile b/drivers/staging/vc04_services/Makefile index 0a04338fc962..1fd191e2e2a5 100644 --- a/drivers/staging/vc04_services/Makefile +++ b/drivers/staging/vc04_services/Makefile @@ -4,7 +4,6 @@ obj-$(CONFIG_BCM2835_VCHIQ) += vchiq.o vchiq-objs := \ interface/vchiq_arm/vchiq_core.o \ interface/vchiq_arm/vchiq_arm.o \ - interface/vchiq_arm/vchiq_2835_arm.o \ interface/vchiq_arm/vchiq_debugfs.o \ interface/vchiq_arm/vchiq_connected.o \ diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c deleted file mode 100644 index 30d6f1a404ba..000000000000 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c +++ /dev/null @@ -1,564 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause -/* Copyright (c) 2010-2012 Broadcom. All rights reserved. */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32) - -#include "vchiq_arm.h" -#include "vchiq_connected.h" -#include "vchiq_pagelist.h" - -#define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2) - -#define VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX 0 -#define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX 1 - -#define BELL0 0x00 -#define BELL2 0x08 - -#define ARM_DS_ACTIVE BIT(2) - -struct vchiq_2835_state { - int inited; - struct vchiq_arm_state arm_state; -}; - -struct vchiq_pagelist_info { - struct pagelist *pagelist; - size_t pagelist_buffer_size; - dma_addr_t dma_addr; - enum dma_data_direction dma_dir; - unsigned int num_pages; - unsigned int pages_need_release; - struct page **pages; - struct scatterlist *scatterlist; - unsigned int scatterlist_mapped; -}; - -static void __iomem *g_regs; -/* This value is the size of the L2 cache lines as understood by the - * VPU firmware, which determines the required alignment of the - * offsets/sizes in pagelists. - * - * Modern VPU firmware looks for a DT "cache-line-size" property in - * the VCHIQ node and will overwrite it with the actual L2 cache size, - * which the kernel must then respect. That property was rejected - * upstream, so we have to use the VPU firmware's compatibility value - * of 32. - */ -static unsigned int g_cache_line_size = 32; -static unsigned int g_fragments_size; -static char *g_fragments_base; -static char *g_free_fragments; -static struct semaphore g_free_fragments_sema; -static struct device *g_dev; - -static DEFINE_SEMAPHORE(g_free_fragments_mutex); - -static irqreturn_t -vchiq_doorbell_irq(int irq, void *dev_id); - -static struct vchiq_pagelist_info * -create_pagelist(char *buf, char __user *ubuf, size_t count, unsigned short type); - -static void -free_pagelist(struct vchiq_pagelist_info *pagelistinfo, - int actual); - -int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) -{ - struct device *dev = &pdev->dev; - struct vchiq_drvdata *drvdata = platform_get_drvdata(pdev); - struct rpi_firmware *fw = drvdata->fw; - struct vchiq_slot_zero *vchiq_slot_zero; - void *slot_mem; - dma_addr_t slot_phys; - u32 channelbase; - int slot_mem_size, frag_mem_size; - int err, irq, i; - - /* - * VCHI messages between the CPU and firmware use - * 32-bit bus addresses. - */ - err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); - - if (err < 0) - return err; - - g_cache_line_size = drvdata->cache_line_size; - g_fragments_size = 2 * g_cache_line_size; - - /* Allocate space for the channels in coherent memory */ - slot_mem_size = PAGE_ALIGN(TOTAL_SLOTS * VCHIQ_SLOT_SIZE); - frag_mem_size = PAGE_ALIGN(g_fragments_size * MAX_FRAGMENTS); - - slot_mem = dmam_alloc_coherent(dev, slot_mem_size + frag_mem_size, - &slot_phys, GFP_KERNEL); - if (!slot_mem) { - dev_err(dev, "could not allocate DMA memory\n"); - return -ENOMEM; - } - - WARN_ON(((unsigned long)slot_mem & (PAGE_SIZE - 1)) != 0); - - vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size); - if (!vchiq_slot_zero) - return -EINVAL; - - vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX] = - (int)slot_phys + slot_mem_size; - vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX] = - MAX_FRAGMENTS; - - g_fragments_base = (char *)slot_mem + slot_mem_size; - - g_free_fragments = g_fragments_base; - for (i = 0; i < (MAX_FRAGMENTS - 1); i++) { - *(char **)&g_fragments_base[i*g_fragments_size] = - &g_fragments_base[(i + 1)*g_fragments_size]; - } - *(char **)&g_fragments_base[i * g_fragments_size] = NULL; - sema_init(&g_free_fragments_sema, MAX_FRAGMENTS); - - err = vchiq_init_state(state, vchiq_slot_zero); - if (err) - return err; - - g_regs = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(g_regs)) - return PTR_ERR(g_regs); - - irq = platform_get_irq(pdev, 0); - if (irq <= 0) - return irq; - - err = devm_request_irq(dev, irq, vchiq_doorbell_irq, IRQF_IRQPOLL, - "VCHIQ doorbell", state); - if (err) { - dev_err(dev, "failed to register irq=%d\n", irq); - return err; - } - - /* Send the base address of the slots to VideoCore */ - channelbase = slot_phys; - err = rpi_firmware_property(fw, RPI_FIRMWARE_VCHIQ_INIT, - &channelbase, sizeof(channelbase)); - if (err || channelbase) { - dev_err(dev, "failed to set channelbase\n"); - return err ? : -ENXIO; - } - - g_dev = dev; - vchiq_log_info(vchiq_arm_log_level, - "vchiq_init - done (slots %pK, phys %pad)", - vchiq_slot_zero, &slot_phys); - - vchiq_call_connected_callbacks(); - - return 0; -} - -int -vchiq_platform_init_state(struct vchiq_state *state) -{ - struct vchiq_2835_state *platform_state; - - state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); - if (!state->platform_state) - return -ENOMEM; - - platform_state = (struct vchiq_2835_state *)state->platform_state; - - platform_state->inited = 1; - vchiq_arm_init_state(state, &platform_state->arm_state); - - return 0; -} - -struct vchiq_arm_state* -vchiq_platform_get_arm_state(struct vchiq_state *state) -{ - struct vchiq_2835_state *platform_state; - - platform_state = (struct vchiq_2835_state *)state->platform_state; - - WARN_ON_ONCE(!platform_state->inited); - - return &platform_state->arm_state; -} - -void -remote_event_signal(struct remote_event *event) -{ - wmb(); - - event->fired = 1; - - dsb(sy); /* data barrier operation */ - - if (event->armed) - writel(0, g_regs + BELL2); /* trigger vc interrupt */ -} - -int -vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, - void __user *uoffset, int size, int dir) -{ - struct vchiq_pagelist_info *pagelistinfo; - - pagelistinfo = create_pagelist(offset, uoffset, size, - (dir == VCHIQ_BULK_RECEIVE) - ? PAGELIST_READ - : PAGELIST_WRITE); - - if (!pagelistinfo) - return -ENOMEM; - - bulk->data = pagelistinfo->dma_addr; - - /* - * Store the pagelistinfo address in remote_data, - * which isn't used by the slave. - */ - bulk->remote_data = pagelistinfo; - - return 0; -} - -void -vchiq_complete_bulk(struct vchiq_bulk *bulk) -{ - if (bulk && bulk->remote_data && bulk->actual) - free_pagelist((struct vchiq_pagelist_info *)bulk->remote_data, - bulk->actual); -} - -int vchiq_dump_platform_state(void *dump_context) -{ - char buf[80]; - int len; - - len = snprintf(buf, sizeof(buf), - " Platform: 2835 (VC master)"); - return vchiq_dump(dump_context, buf, len + 1); -} - -/* - * Local functions - */ - -static irqreturn_t -vchiq_doorbell_irq(int irq, void *dev_id) -{ - struct vchiq_state *state = dev_id; - irqreturn_t ret = IRQ_NONE; - unsigned int status; - - /* Read (and clear) the doorbell */ - status = readl(g_regs + BELL0); - - if (status & ARM_DS_ACTIVE) { /* Was the doorbell rung? */ - remote_event_pollall(state); - ret = IRQ_HANDLED; - } - - return ret; -} - -static void -cleanup_pagelistinfo(struct vchiq_pagelist_info *pagelistinfo) -{ - if (pagelistinfo->scatterlist_mapped) { - dma_unmap_sg(g_dev, pagelistinfo->scatterlist, - pagelistinfo->num_pages, pagelistinfo->dma_dir); - } - - if (pagelistinfo->pages_need_release) - unpin_user_pages(pagelistinfo->pages, pagelistinfo->num_pages); - - dma_free_coherent(g_dev, pagelistinfo->pagelist_buffer_size, - pagelistinfo->pagelist, pagelistinfo->dma_addr); -} - -/* There is a potential problem with partial cache lines (pages?) - * at the ends of the block when reading. If the CPU accessed anything in - * the same line (page?) then it may have pulled old data into the cache, - * obscuring the new data underneath. We can solve this by transferring the - * partial cache lines separately, and allowing the ARM to copy into the - * cached area. - */ - -static struct vchiq_pagelist_info * -create_pagelist(char *buf, char __user *ubuf, - size_t count, unsigned short type) -{ - struct pagelist *pagelist; - struct vchiq_pagelist_info *pagelistinfo; - struct page **pages; - u32 *addrs; - unsigned int num_pages, offset, i, k; - int actual_pages; - size_t pagelist_size; - struct scatterlist *scatterlist, *sg; - int dma_buffers; - dma_addr_t dma_addr; - - if (count >= INT_MAX - PAGE_SIZE) - return NULL; - - if (buf) - offset = (uintptr_t)buf & (PAGE_SIZE - 1); - else - offset = (uintptr_t)ubuf & (PAGE_SIZE - 1); - num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE); - - if (num_pages > (SIZE_MAX - sizeof(struct pagelist) - - sizeof(struct vchiq_pagelist_info)) / - (sizeof(u32) + sizeof(pages[0]) + - sizeof(struct scatterlist))) - return NULL; - - pagelist_size = sizeof(struct pagelist) + - (num_pages * sizeof(u32)) + - (num_pages * sizeof(pages[0]) + - (num_pages * sizeof(struct scatterlist))) + - sizeof(struct vchiq_pagelist_info); - - /* Allocate enough storage to hold the page pointers and the page - * list - */ - pagelist = dma_alloc_coherent(g_dev, pagelist_size, &dma_addr, - GFP_KERNEL); - - vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, pagelist); - - if (!pagelist) - return NULL; - - addrs = pagelist->addrs; - pages = (struct page **)(addrs + num_pages); - scatterlist = (struct scatterlist *)(pages + num_pages); - pagelistinfo = (struct vchiq_pagelist_info *) - (scatterlist + num_pages); - - pagelist->length = count; - pagelist->type = type; - pagelist->offset = offset; - - /* Populate the fields of the pagelistinfo structure */ - pagelistinfo->pagelist = pagelist; - pagelistinfo->pagelist_buffer_size = pagelist_size; - pagelistinfo->dma_addr = dma_addr; - pagelistinfo->dma_dir = (type == PAGELIST_WRITE) ? - DMA_TO_DEVICE : DMA_FROM_DEVICE; - pagelistinfo->num_pages = num_pages; - pagelistinfo->pages_need_release = 0; - pagelistinfo->pages = pages; - pagelistinfo->scatterlist = scatterlist; - pagelistinfo->scatterlist_mapped = 0; - - if (buf) { - unsigned long length = count; - unsigned int off = offset; - - for (actual_pages = 0; actual_pages < num_pages; - actual_pages++) { - struct page *pg = - vmalloc_to_page((buf + - (actual_pages * PAGE_SIZE))); - size_t bytes = PAGE_SIZE - off; - - if (!pg) { - cleanup_pagelistinfo(pagelistinfo); - return NULL; - } - - if (bytes > length) - bytes = length; - pages[actual_pages] = pg; - length -= bytes; - off = 0; - } - /* do not try and release vmalloc pages */ - } else { - actual_pages = pin_user_pages_fast( - (unsigned long)ubuf & PAGE_MASK, - num_pages, - type == PAGELIST_READ, - pages); - - if (actual_pages != num_pages) { - vchiq_log_info(vchiq_arm_log_level, - "%s - only %d/%d pages locked", - __func__, actual_pages, num_pages); - - /* This is probably due to the process being killed */ - if (actual_pages > 0) - unpin_user_pages(pages, actual_pages); - cleanup_pagelistinfo(pagelistinfo); - return NULL; - } - /* release user pages */ - pagelistinfo->pages_need_release = 1; - } - - /* - * Initialize the scatterlist so that the magic cookie - * is filled if debugging is enabled - */ - sg_init_table(scatterlist, num_pages); - /* Now set the pages for each scatterlist */ - for (i = 0; i < num_pages; i++) { - unsigned int len = PAGE_SIZE - offset; - - if (len > count) - len = count; - sg_set_page(scatterlist + i, pages[i], len, offset); - offset = 0; - count -= len; - } - - dma_buffers = dma_map_sg(g_dev, - scatterlist, - num_pages, - pagelistinfo->dma_dir); - - if (dma_buffers == 0) { - cleanup_pagelistinfo(pagelistinfo); - return NULL; - } - - pagelistinfo->scatterlist_mapped = 1; - - /* Combine adjacent blocks for performance */ - k = 0; - for_each_sg(scatterlist, sg, dma_buffers, i) { - u32 len = sg_dma_len(sg); - u32 addr = sg_dma_address(sg); - - /* Note: addrs is the address + page_count - 1 - * The firmware expects blocks after the first to be page- - * aligned and a multiple of the page size - */ - WARN_ON(len == 0); - WARN_ON(i && (i != (dma_buffers - 1)) && (len & ~PAGE_MASK)); - WARN_ON(i && (addr & ~PAGE_MASK)); - if (k > 0 && - ((addrs[k - 1] & PAGE_MASK) + - (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT)) - == (addr & PAGE_MASK)) - addrs[k - 1] += ((len + PAGE_SIZE - 1) >> PAGE_SHIFT); - else - addrs[k++] = (addr & PAGE_MASK) | - (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1); - } - - /* Partial cache lines (fragments) require special measures */ - if ((type == PAGELIST_READ) && - ((pagelist->offset & (g_cache_line_size - 1)) || - ((pagelist->offset + pagelist->length) & - (g_cache_line_size - 1)))) { - char *fragments; - - if (down_interruptible(&g_free_fragments_sema)) { - cleanup_pagelistinfo(pagelistinfo); - return NULL; - } - - WARN_ON(!g_free_fragments); - - down(&g_free_fragments_mutex); - fragments = g_free_fragments; - WARN_ON(!fragments); - g_free_fragments = *(char **) g_free_fragments; - up(&g_free_fragments_mutex); - pagelist->type = PAGELIST_READ_WITH_FRAGMENTS + - (fragments - g_fragments_base) / g_fragments_size; - } - - return pagelistinfo; -} - -static void -free_pagelist(struct vchiq_pagelist_info *pagelistinfo, - int actual) -{ - struct pagelist *pagelist = pagelistinfo->pagelist; - struct page **pages = pagelistinfo->pages; - unsigned int num_pages = pagelistinfo->num_pages; - - vchiq_log_trace(vchiq_arm_log_level, "%s - %pK, %d", - __func__, pagelistinfo->pagelist, actual); - - /* - * NOTE: dma_unmap_sg must be called before the - * cpu can touch any of the data/pages. - */ - dma_unmap_sg(g_dev, pagelistinfo->scatterlist, - pagelistinfo->num_pages, pagelistinfo->dma_dir); - pagelistinfo->scatterlist_mapped = 0; - - /* Deal with any partial cache lines (fragments) */ - if (pagelist->type >= PAGELIST_READ_WITH_FRAGMENTS) { - char *fragments = g_fragments_base + - (pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) * - g_fragments_size; - int head_bytes, tail_bytes; - - head_bytes = (g_cache_line_size - pagelist->offset) & - (g_cache_line_size - 1); - tail_bytes = (pagelist->offset + actual) & - (g_cache_line_size - 1); - - if ((actual >= 0) && (head_bytes != 0)) { - if (head_bytes > actual) - head_bytes = actual; - - memcpy((char *)kmap(pages[0]) + - pagelist->offset, - fragments, - head_bytes); - kunmap(pages[0]); - } - if ((actual >= 0) && (head_bytes < actual) && - (tail_bytes != 0)) { - memcpy((char *)kmap(pages[num_pages - 1]) + - ((pagelist->offset + actual) & - (PAGE_SIZE - 1) & ~(g_cache_line_size - 1)), - fragments + g_cache_line_size, - tail_bytes); - kunmap(pages[num_pages - 1]); - } - - down(&g_free_fragments_mutex); - *(char **)fragments = g_free_fragments; - g_free_fragments = fragments; - up(&g_free_fragments_mutex); - up(&g_free_fragments_sema); - } - - /* Need to mark all the pages dirty. */ - if (pagelist->type != PAGELIST_WRITE && - pagelistinfo->pages_need_release) { - unsigned int i; - - for (i = 0; i < num_pages; i++) - set_page_dirty(pages[i]); - } - - cleanup_pagelistinfo(pagelistinfo); -} diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 0f2de571eba7..b25369a13452 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -25,15 +25,32 @@ #include #include #include +#include +#include +#include #include #include "vchiq_core.h" #include "vchiq_ioctl.h" #include "vchiq_arm.h" #include "vchiq_debugfs.h" +#include "vchiq_connected.h" +#include "vchiq_pagelist.h" #define DEVICE_NAME "vchiq" +#define TOTAL_SLOTS (VCHIQ_SLOT_ZERO_SLOTS + 2 * 32) + +#define MAX_FRAGMENTS (VCHIQ_NUM_CURRENT_BULKS * 2) + +#define VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX 0 +#define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX 1 + +#define BELL0 0x00 +#define BELL2 0x08 + +#define ARM_DS_ACTIVE BIT(2) + /* Override the default prefix, which would be vchiq_arm (from the filename) */ #undef MODULE_PARAM_PREFIX #define MODULE_PARAM_PREFIX DEVICE_NAME "." @@ -59,10 +76,528 @@ static struct vchiq_drvdata bcm2836_drvdata = { .cache_line_size = 64, }; +struct vchiq_2835_state { + int inited; + struct vchiq_arm_state arm_state; +}; + +struct vchiq_pagelist_info { + struct pagelist *pagelist; + size_t pagelist_buffer_size; + dma_addr_t dma_addr; + enum dma_data_direction dma_dir; + unsigned int num_pages; + unsigned int pages_need_release; + struct page **pages; + struct scatterlist *scatterlist; + unsigned int scatterlist_mapped; +}; + +static void __iomem *g_regs; +/* This value is the size of the L2 cache lines as understood by the + * VPU firmware, which determines the required alignment of the + * offsets/sizes in pagelists. + * + * Modern VPU firmware looks for a DT "cache-line-size" property in + * the VCHIQ node and will overwrite it with the actual L2 cache size, + * which the kernel must then respect. That property was rejected + * upstream, so we have to use the VPU firmware's compatibility value + * of 32. + */ +static unsigned int g_cache_line_size = 32; +static unsigned int g_fragments_size; +static char *g_fragments_base; +static char *g_free_fragments; +static struct semaphore g_free_fragments_sema; +static struct device *g_dev; + +static DEFINE_SEMAPHORE(g_free_fragments_mutex); + static enum vchiq_status vchiq_blocking_bulk_transfer(unsigned int handle, void *data, unsigned int size, enum vchiq_bulk_dir dir); +static irqreturn_t +vchiq_doorbell_irq(int irq, void *dev_id) +{ + struct vchiq_state *state = dev_id; + irqreturn_t ret = IRQ_NONE; + unsigned int status; + + /* Read (and clear) the doorbell */ + status = readl(g_regs + BELL0); + + if (status & ARM_DS_ACTIVE) { /* Was the doorbell rung? */ + remote_event_pollall(state); + ret = IRQ_HANDLED; + } + + return ret; +} + +static void +cleanup_pagelistinfo(struct vchiq_pagelist_info *pagelistinfo) +{ + if (pagelistinfo->scatterlist_mapped) { + dma_unmap_sg(g_dev, pagelistinfo->scatterlist, + pagelistinfo->num_pages, pagelistinfo->dma_dir); + } + + if (pagelistinfo->pages_need_release) + unpin_user_pages(pagelistinfo->pages, pagelistinfo->num_pages); + + dma_free_coherent(g_dev, pagelistinfo->pagelist_buffer_size, + pagelistinfo->pagelist, pagelistinfo->dma_addr); +} + +/* There is a potential problem with partial cache lines (pages?) + * at the ends of the block when reading. If the CPU accessed anything in + * the same line (page?) then it may have pulled old data into the cache, + * obscuring the new data underneath. We can solve this by transferring the + * partial cache lines separately, and allowing the ARM to copy into the + * cached area. + */ + +static struct vchiq_pagelist_info * +create_pagelist(char *buf, char __user *ubuf, + size_t count, unsigned short type) +{ + struct pagelist *pagelist; + struct vchiq_pagelist_info *pagelistinfo; + struct page **pages; + u32 *addrs; + unsigned int num_pages, offset, i, k; + int actual_pages; + size_t pagelist_size; + struct scatterlist *scatterlist, *sg; + int dma_buffers; + dma_addr_t dma_addr; + + if (count >= INT_MAX - PAGE_SIZE) + return NULL; + + if (buf) + offset = (uintptr_t)buf & (PAGE_SIZE - 1); + else + offset = (uintptr_t)ubuf & (PAGE_SIZE - 1); + num_pages = DIV_ROUND_UP(count + offset, PAGE_SIZE); + + if (num_pages > (SIZE_MAX - sizeof(struct pagelist) - + sizeof(struct vchiq_pagelist_info)) / + (sizeof(u32) + sizeof(pages[0]) + + sizeof(struct scatterlist))) + return NULL; + + pagelist_size = sizeof(struct pagelist) + + (num_pages * sizeof(u32)) + + (num_pages * sizeof(pages[0]) + + (num_pages * sizeof(struct scatterlist))) + + sizeof(struct vchiq_pagelist_info); + + /* Allocate enough storage to hold the page pointers and the page + * list + */ + pagelist = dma_alloc_coherent(g_dev, pagelist_size, &dma_addr, + GFP_KERNEL); + + vchiq_log_trace(vchiq_arm_log_level, "%s - %pK", __func__, pagelist); + + if (!pagelist) + return NULL; + + addrs = pagelist->addrs; + pages = (struct page **)(addrs + num_pages); + scatterlist = (struct scatterlist *)(pages + num_pages); + pagelistinfo = (struct vchiq_pagelist_info *) + (scatterlist + num_pages); + + pagelist->length = count; + pagelist->type = type; + pagelist->offset = offset; + + /* Populate the fields of the pagelistinfo structure */ + pagelistinfo->pagelist = pagelist; + pagelistinfo->pagelist_buffer_size = pagelist_size; + pagelistinfo->dma_addr = dma_addr; + pagelistinfo->dma_dir = (type == PAGELIST_WRITE) ? + DMA_TO_DEVICE : DMA_FROM_DEVICE; + pagelistinfo->num_pages = num_pages; + pagelistinfo->pages_need_release = 0; + pagelistinfo->pages = pages; + pagelistinfo->scatterlist = scatterlist; + pagelistinfo->scatterlist_mapped = 0; + + if (buf) { + unsigned long length = count; + unsigned int off = offset; + + for (actual_pages = 0; actual_pages < num_pages; + actual_pages++) { + struct page *pg = + vmalloc_to_page((buf + + (actual_pages * PAGE_SIZE))); + size_t bytes = PAGE_SIZE - off; + + if (!pg) { + cleanup_pagelistinfo(pagelistinfo); + return NULL; + } + + if (bytes > length) + bytes = length; + pages[actual_pages] = pg; + length -= bytes; + off = 0; + } + /* do not try and release vmalloc pages */ + } else { + actual_pages = pin_user_pages_fast( + (unsigned long)ubuf & PAGE_MASK, + num_pages, + type == PAGELIST_READ, + pages); + + if (actual_pages != num_pages) { + vchiq_log_info(vchiq_arm_log_level, + "%s - only %d/%d pages locked", + __func__, actual_pages, num_pages); + + /* This is probably due to the process being killed */ + if (actual_pages > 0) + unpin_user_pages(pages, actual_pages); + cleanup_pagelistinfo(pagelistinfo); + return NULL; + } + /* release user pages */ + pagelistinfo->pages_need_release = 1; + } + + /* + * Initialize the scatterlist so that the magic cookie + * is filled if debugging is enabled + */ + sg_init_table(scatterlist, num_pages); + /* Now set the pages for each scatterlist */ + for (i = 0; i < num_pages; i++) { + unsigned int len = PAGE_SIZE - offset; + + if (len > count) + len = count; + sg_set_page(scatterlist + i, pages[i], len, offset); + offset = 0; + count -= len; + } + + dma_buffers = dma_map_sg(g_dev, + scatterlist, + num_pages, + pagelistinfo->dma_dir); + + if (dma_buffers == 0) { + cleanup_pagelistinfo(pagelistinfo); + return NULL; + } + + pagelistinfo->scatterlist_mapped = 1; + + /* Combine adjacent blocks for performance */ + k = 0; + for_each_sg(scatterlist, sg, dma_buffers, i) { + u32 len = sg_dma_len(sg); + u32 addr = sg_dma_address(sg); + + /* Note: addrs is the address + page_count - 1 + * The firmware expects blocks after the first to be page- + * aligned and a multiple of the page size + */ + WARN_ON(len == 0); + WARN_ON(i && (i != (dma_buffers - 1)) && (len & ~PAGE_MASK)); + WARN_ON(i && (addr & ~PAGE_MASK)); + if (k > 0 && + ((addrs[k - 1] & PAGE_MASK) + + (((addrs[k - 1] & ~PAGE_MASK) + 1) << PAGE_SHIFT)) + == (addr & PAGE_MASK)) + addrs[k - 1] += ((len + PAGE_SIZE - 1) >> PAGE_SHIFT); + else + addrs[k++] = (addr & PAGE_MASK) | + (((len + PAGE_SIZE - 1) >> PAGE_SHIFT) - 1); + } + + /* Partial cache lines (fragments) require special measures */ + if ((type == PAGELIST_READ) && + ((pagelist->offset & (g_cache_line_size - 1)) || + ((pagelist->offset + pagelist->length) & + (g_cache_line_size - 1)))) { + char *fragments; + + if (down_interruptible(&g_free_fragments_sema)) { + cleanup_pagelistinfo(pagelistinfo); + return NULL; + } + + WARN_ON(!g_free_fragments); + + down(&g_free_fragments_mutex); + fragments = g_free_fragments; + WARN_ON(!fragments); + g_free_fragments = *(char **) g_free_fragments; + up(&g_free_fragments_mutex); + pagelist->type = PAGELIST_READ_WITH_FRAGMENTS + + (fragments - g_fragments_base) / g_fragments_size; + } + + return pagelistinfo; +} + +static void +free_pagelist(struct vchiq_pagelist_info *pagelistinfo, + int actual) +{ + struct pagelist *pagelist = pagelistinfo->pagelist; + struct page **pages = pagelistinfo->pages; + unsigned int num_pages = pagelistinfo->num_pages; + + vchiq_log_trace(vchiq_arm_log_level, "%s - %pK, %d", + __func__, pagelistinfo->pagelist, actual); + + /* + * NOTE: dma_unmap_sg must be called before the + * cpu can touch any of the data/pages. + */ + dma_unmap_sg(g_dev, pagelistinfo->scatterlist, + pagelistinfo->num_pages, pagelistinfo->dma_dir); + pagelistinfo->scatterlist_mapped = 0; + + /* Deal with any partial cache lines (fragments) */ + if (pagelist->type >= PAGELIST_READ_WITH_FRAGMENTS) { + char *fragments = g_fragments_base + + (pagelist->type - PAGELIST_READ_WITH_FRAGMENTS) * + g_fragments_size; + int head_bytes, tail_bytes; + + head_bytes = (g_cache_line_size - pagelist->offset) & + (g_cache_line_size - 1); + tail_bytes = (pagelist->offset + actual) & + (g_cache_line_size - 1); + + if ((actual >= 0) && (head_bytes != 0)) { + if (head_bytes > actual) + head_bytes = actual; + + memcpy((char *)kmap(pages[0]) + + pagelist->offset, + fragments, + head_bytes); + kunmap(pages[0]); + } + if ((actual >= 0) && (head_bytes < actual) && + (tail_bytes != 0)) { + memcpy((char *)kmap(pages[num_pages - 1]) + + ((pagelist->offset + actual) & + (PAGE_SIZE - 1) & ~(g_cache_line_size - 1)), + fragments + g_cache_line_size, + tail_bytes); + kunmap(pages[num_pages - 1]); + } + + down(&g_free_fragments_mutex); + *(char **)fragments = g_free_fragments; + g_free_fragments = fragments; + up(&g_free_fragments_mutex); + up(&g_free_fragments_sema); + } + + /* Need to mark all the pages dirty. */ + if (pagelist->type != PAGELIST_WRITE && + pagelistinfo->pages_need_release) { + unsigned int i; + + for (i = 0; i < num_pages; i++) + set_page_dirty(pages[i]); + } + + cleanup_pagelistinfo(pagelistinfo); +} + +int vchiq_platform_init(struct platform_device *pdev, struct vchiq_state *state) +{ + struct device *dev = &pdev->dev; + struct vchiq_drvdata *drvdata = platform_get_drvdata(pdev); + struct rpi_firmware *fw = drvdata->fw; + struct vchiq_slot_zero *vchiq_slot_zero; + void *slot_mem; + dma_addr_t slot_phys; + u32 channelbase; + int slot_mem_size, frag_mem_size; + int err, irq, i; + + /* + * VCHI messages between the CPU and firmware use + * 32-bit bus addresses. + */ + err = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(32)); + + if (err < 0) + return err; + + g_cache_line_size = drvdata->cache_line_size; + g_fragments_size = 2 * g_cache_line_size; + + /* Allocate space for the channels in coherent memory */ + slot_mem_size = PAGE_ALIGN(TOTAL_SLOTS * VCHIQ_SLOT_SIZE); + frag_mem_size = PAGE_ALIGN(g_fragments_size * MAX_FRAGMENTS); + + slot_mem = dmam_alloc_coherent(dev, slot_mem_size + frag_mem_size, + &slot_phys, GFP_KERNEL); + if (!slot_mem) { + dev_err(dev, "could not allocate DMA memory\n"); + return -ENOMEM; + } + + WARN_ON(((unsigned long)slot_mem & (PAGE_SIZE - 1)) != 0); + + vchiq_slot_zero = vchiq_init_slots(slot_mem, slot_mem_size); + if (!vchiq_slot_zero) + return -EINVAL; + + vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX] = + (int)slot_phys + slot_mem_size; + vchiq_slot_zero->platform_data[VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX] = + MAX_FRAGMENTS; + + g_fragments_base = (char *)slot_mem + slot_mem_size; + + g_free_fragments = g_fragments_base; + for (i = 0; i < (MAX_FRAGMENTS - 1); i++) { + *(char **)&g_fragments_base[i*g_fragments_size] = + &g_fragments_base[(i + 1)*g_fragments_size]; + } + *(char **)&g_fragments_base[i * g_fragments_size] = NULL; + sema_init(&g_free_fragments_sema, MAX_FRAGMENTS); + + err = vchiq_init_state(state, vchiq_slot_zero); + if (err) + return err; + + g_regs = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(g_regs)) + return PTR_ERR(g_regs); + + irq = platform_get_irq(pdev, 0); + if (irq <= 0) + return irq; + + err = devm_request_irq(dev, irq, vchiq_doorbell_irq, IRQF_IRQPOLL, + "VCHIQ doorbell", state); + if (err) { + dev_err(dev, "failed to register irq=%d\n", irq); + return err; + } + + /* Send the base address of the slots to VideoCore */ + channelbase = slot_phys; + err = rpi_firmware_property(fw, RPI_FIRMWARE_VCHIQ_INIT, + &channelbase, sizeof(channelbase)); + if (err || channelbase) { + dev_err(dev, "failed to set channelbase\n"); + return err ? : -ENXIO; + } + + g_dev = dev; + vchiq_log_info(vchiq_arm_log_level, + "vchiq_init - done (slots %pK, phys %pad)", + vchiq_slot_zero, &slot_phys); + + vchiq_call_connected_callbacks(); + + return 0; +} + +int +vchiq_platform_init_state(struct vchiq_state *state) +{ + struct vchiq_2835_state *platform_state; + + state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL); + if (!state->platform_state) + return -ENOMEM; + + platform_state = (struct vchiq_2835_state *)state->platform_state; + + platform_state->inited = 1; + vchiq_arm_init_state(state, &platform_state->arm_state); + + return 0; +} + +struct vchiq_arm_state* +vchiq_platform_get_arm_state(struct vchiq_state *state) +{ + struct vchiq_2835_state *platform_state; + + platform_state = (struct vchiq_2835_state *)state->platform_state; + + WARN_ON_ONCE(!platform_state->inited); + + return &platform_state->arm_state; +} + +void +remote_event_signal(struct remote_event *event) +{ + wmb(); + + event->fired = 1; + + dsb(sy); /* data barrier operation */ + + if (event->armed) + writel(0, g_regs + BELL2); /* trigger vc interrupt */ +} + +int +vchiq_prepare_bulk_data(struct vchiq_bulk *bulk, void *offset, + void __user *uoffset, int size, int dir) +{ + struct vchiq_pagelist_info *pagelistinfo; + + pagelistinfo = create_pagelist(offset, uoffset, size, + (dir == VCHIQ_BULK_RECEIVE) + ? PAGELIST_READ + : PAGELIST_WRITE); + + if (!pagelistinfo) + return -ENOMEM; + + bulk->data = pagelistinfo->dma_addr; + + /* + * Store the pagelistinfo address in remote_data, + * which isn't used by the slave. + */ + bulk->remote_data = pagelistinfo; + + return 0; +} + +void +vchiq_complete_bulk(struct vchiq_bulk *bulk) +{ + if (bulk && bulk->remote_data && bulk->actual) + free_pagelist((struct vchiq_pagelist_info *)bulk->remote_data, + bulk->actual); +} + +int vchiq_dump_platform_state(void *dump_context) +{ + char buf[80]; + int len; + + len = snprintf(buf, sizeof(buf), + " Platform: 2835 (VC master)"); + return vchiq_dump(dump_context, buf, len + 1); +} + #define VCHIQ_INIT_RETRIES 10 int vchiq_initialise(struct vchiq_instance **instance_out) { -- cgit v1.2.3 From cfdafb7608b4cf159aec510114be7a364347ca0f Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Mon, 26 Jul 2021 18:45:01 +0530 Subject: staging: sm750fb: Rename maxH to max_h in lynx_cursor The struct lynx_cursor has a member named maxH. This name is CamelCase and is frowned upon. This commit renames it to max_h and makes the necessary changes for the module to build. This change also fixes the following checkpatch CHECK: CHECK: Avoid CamelCase: 116: FILE: drivers/staging/sm750fb/sm750.c:116: + fbcursor->image.height > cursor->maxH || Signed-off-by: Benjamin Philip Link: https://lore.kernel.org/r/692211000786d76aa41bc24d4ee06b5868d82771.1627304144.git.benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 6 +++--- drivers/staging/sm750fb/sm750.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index c237a8f8eb59..ee9ee2857f00 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -113,7 +113,7 @@ static int lynxfb_ops_cursor(struct fb_info *info, struct fb_cursor *fbcursor) cursor = &crtc->cursor; if (fbcursor->image.width > cursor->maxW || - fbcursor->image.height > cursor->maxH || + fbcursor->image.height > cursor->max_h || fbcursor->image.depth > 1) { return -ENXIO; } @@ -723,8 +723,8 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) 0x800f0 + (int)crtc->channel * 0x140; pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio); - crtc->cursor.maxH = crtc->cursor.maxW = 64; - crtc->cursor.size = crtc->cursor.maxH * crtc->cursor.maxW * 2 / 8; + crtc->cursor.max_h = crtc->cursor.maxW = 64; + crtc->cursor.size = crtc->cursor.max_h * crtc->cursor.maxW * 2 / 8; crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset; memset_io(crtc->cursor.vstart, 0, crtc->cursor.size); diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 23eefd019ec9..5556208f7178 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -123,7 +123,7 @@ struct lynx_cursor { int size; /* hardware limitation */ int maxW; - int maxH; + int max_h; /* base virtual address and offset of cursor image */ char __iomem *vstart; int offset; -- cgit v1.2.3 From 39f9137268ee3df0047706df4e9b7357a40ffc98 Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Mon, 26 Jul 2021 18:45:02 +0530 Subject: staging: sm750fb: Rename maxW to max_w in lynx_cursor The struct lynx_cursor has a member named maxW. This name is CamelCase and is frowned upon. This commit renames it to max_w and makes the necessary changes for the module to build. This change also fixes the following checkpatch CHECK: CHECK: Avoid CamelCase: 115: FILE: drivers/staging/sm750fb/sm750.c:115: + if (fbcursor->image.width > cursor->maxW || Signed-off-by: Benjamin Philip Link: https://lore.kernel.org/r/c0c84569b155df7b510a505a86863987836e192d.1627304144.git.benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 6 +++--- drivers/staging/sm750fb/sm750.h | 2 +- drivers/staging/sm750fb/sm750_cursor.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index ee9ee2857f00..4f5f68e6aa60 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -112,7 +112,7 @@ static int lynxfb_ops_cursor(struct fb_info *info, struct fb_cursor *fbcursor) crtc = &par->crtc; cursor = &crtc->cursor; - if (fbcursor->image.width > cursor->maxW || + if (fbcursor->image.width > cursor->max_w || fbcursor->image.height > cursor->max_h || fbcursor->image.depth > 1) { return -ENXIO; @@ -723,8 +723,8 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) 0x800f0 + (int)crtc->channel * 0x140; pr_info("crtc->cursor.mmio = %p\n", crtc->cursor.mmio); - crtc->cursor.max_h = crtc->cursor.maxW = 64; - crtc->cursor.size = crtc->cursor.max_h * crtc->cursor.maxW * 2 / 8; + crtc->cursor.max_h = crtc->cursor.max_w = 64; + crtc->cursor.size = crtc->cursor.max_h * crtc->cursor.max_w * 2 / 8; crtc->cursor.vstart = sm750_dev->pvMem + crtc->cursor.offset; memset_io(crtc->cursor.vstart, 0, crtc->cursor.size); diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 5556208f7178..8271cf7c89f3 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -122,7 +122,7 @@ struct lynx_cursor { int h; int size; /* hardware limitation */ - int maxW; + int max_w; int max_h; /* base virtual address and offset of cursor image */ char __iomem *vstart; diff --git a/drivers/staging/sm750fb/sm750_cursor.c b/drivers/staging/sm750fb/sm750_cursor.c index bbbef27cb329..43e6f52c2551 100644 --- a/drivers/staging/sm750fb/sm750_cursor.c +++ b/drivers/staging/sm750fb/sm750_cursor.c @@ -97,7 +97,7 @@ void sm750_hw_cursor_setData(struct lynx_cursor *cursor, u16 rop, count = pitch * cursor->h; /* in byte */ - offset = cursor->maxW * 2 / 8; + offset = cursor->max_w * 2 / 8; data = 0; pstart = cursor->vstart; @@ -147,7 +147,7 @@ void sm750_hw_cursor_setData2(struct lynx_cursor *cursor, u16 rop, count = pitch * cursor->h; /* in byte */ - offset = cursor->maxW * 2 / 8; + offset = cursor->max_w * 2 / 8; data = 0; pstart = cursor->vstart; -- cgit v1.2.3 From 15865124feed880978b79839c756ef6cbb4ec6b3 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 28 Jul 2021 00:22:14 +0100 Subject: staging: r8188eu: introduce new core dir for RTL8188eu driver This patchset is split in order to keep the file sizes down. This core directory is part of the newer/better driver from GitHub modified by Larry Finger. Import this as the basis for all future work going forward. Suggested-by: Larry Finger Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210727232219.2948-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 1976 ++++++ drivers/staging/r8188eu/core/rtw_br_ext.c | 1184 ++++ drivers/staging/r8188eu/core/rtw_cmd.c | 2206 +++++++ drivers/staging/r8188eu/core/rtw_debug.c | 943 +++ drivers/staging/r8188eu/core/rtw_efuse.c | 872 +++ drivers/staging/r8188eu/core/rtw_ieee80211.c | 1625 +++++ drivers/staging/r8188eu/core/rtw_io.c | 323 + drivers/staging/r8188eu/core/rtw_ioctl_set.c | 1118 ++++ drivers/staging/r8188eu/core/rtw_iol.c | 209 + drivers/staging/r8188eu/core/rtw_led.c | 1705 ++++++ drivers/staging/r8188eu/core/rtw_mlme.c | 2354 ++++++++ drivers/staging/r8188eu/core/rtw_mlme_ext.c | 8407 ++++++++++++++++++++++++++ drivers/staging/r8188eu/core/rtw_mp.c | 1000 +++ drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 1352 +++++ drivers/staging/r8188eu/core/rtw_p2p.c | 2068 +++++++ drivers/staging/r8188eu/core/rtw_pwrctrl.c | 655 ++ drivers/staging/r8188eu/core/rtw_recv.c | 2252 +++++++ drivers/staging/r8188eu/core/rtw_rf.c | 88 + drivers/staging/r8188eu/core/rtw_security.c | 1757 ++++++ drivers/staging/r8188eu/core/rtw_sreset.c | 79 + drivers/staging/r8188eu/core/rtw_sta_mgt.c | 609 ++ drivers/staging/r8188eu/core/rtw_wlan_util.c | 1690 ++++++ drivers/staging/r8188eu/core/rtw_xmit.c | 2370 ++++++++ 23 files changed, 36842 insertions(+) create mode 100644 drivers/staging/r8188eu/core/rtw_ap.c create mode 100644 drivers/staging/r8188eu/core/rtw_br_ext.c create mode 100644 drivers/staging/r8188eu/core/rtw_cmd.c create mode 100644 drivers/staging/r8188eu/core/rtw_debug.c create mode 100644 drivers/staging/r8188eu/core/rtw_efuse.c create mode 100644 drivers/staging/r8188eu/core/rtw_ieee80211.c create mode 100644 drivers/staging/r8188eu/core/rtw_io.c create mode 100644 drivers/staging/r8188eu/core/rtw_ioctl_set.c create mode 100644 drivers/staging/r8188eu/core/rtw_iol.c create mode 100644 drivers/staging/r8188eu/core/rtw_led.c create mode 100644 drivers/staging/r8188eu/core/rtw_mlme.c create mode 100644 drivers/staging/r8188eu/core/rtw_mlme_ext.c create mode 100644 drivers/staging/r8188eu/core/rtw_mp.c create mode 100644 drivers/staging/r8188eu/core/rtw_mp_ioctl.c create mode 100644 drivers/staging/r8188eu/core/rtw_p2p.c create mode 100644 drivers/staging/r8188eu/core/rtw_pwrctrl.c create mode 100644 drivers/staging/r8188eu/core/rtw_recv.c create mode 100644 drivers/staging/r8188eu/core/rtw_rf.c create mode 100644 drivers/staging/r8188eu/core/rtw_security.c create mode 100644 drivers/staging/r8188eu/core/rtw_sreset.c create mode 100644 drivers/staging/r8188eu/core/rtw_sta_mgt.c create mode 100644 drivers/staging/r8188eu/core/rtw_wlan_util.c create mode 100644 drivers/staging/r8188eu/core/rtw_xmit.c (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c new file mode 100644 index 000000000000..ba475a4933ec --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -0,0 +1,1976 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_AP_C_ + +#include +#include +#include +#include + +#ifdef CONFIG_88EU_AP_MODE + +void init_mlme_ap_info(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + spin_lock_init(&pmlmepriv->bcn_update_lock); + + /* for ACL */ + _rtw_init_queue(&pacl_list->acl_node_q); + + start_ap_mode(padapter); +} + +void free_mlme_ap_info(struct adapter *padapter) +{ + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmlmepriv->update_bcn = false; + pmlmeext->bstart_bss = false; + + rtw_sta_flush(padapter); + + pmlmeinfo->state = _HW_STATE_NOLINK_; + + /* free_assoc_sta_resources */ + rtw_free_all_stainfo(padapter); + + /* free bc/mc sta_info */ + psta = rtw_get_bcmc_stainfo(padapter); + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(padapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); +} + +static void update_BCNTIM(struct adapter *padapter) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); + unsigned char *pie = pnetwork_mlmeext->IEs; + + /* update TIM IE */ + if (true) { + u8 *p, *dst_ie, *premainder_ie = NULL; + u8 *pbackup_remainder_ie = NULL; + __le16 tim_bitmap_le; + uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; + + tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); + + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); + if (p != NULL && tim_ielen > 0) { + tim_ielen += 2; + premainder_ie = p+tim_ielen; + tim_ie_offset = (int)(p - pie); + remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; + /* append TIM IE from dst_ie offset */ + dst_ie = p; + } else { + tim_ielen = 0; + + /* calculate head_len */ + offset = _FIXED_IE_LENGTH_; + offset += pnetwork_mlmeext->Ssid.SsidLength + 2; + + /* get supported rates len */ + p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) + offset += tmp_len+2; + + /* DS Parameter Set IE, len = 3 */ + offset += 3; + + premainder_ie = pie + offset; + + remainder_ielen = pnetwork_mlmeext->IELength - offset - tim_ielen; + + /* append TIM IE from offset */ + dst_ie = pie + offset; + } + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + *dst_ie++ = _TIM_IE_; + + if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) + tim_ielen = 5; + else + tim_ielen = 4; + + *dst_ie++ = tim_ielen; + + *dst_ie++ = 0;/* DTIM count */ + *dst_ie++ = 1;/* DTIM period */ + + if (pstapriv->tim_bitmap&BIT(0))/* for bc/mc frames */ + *dst_ie++ = BIT(0);/* bitmap ctrl */ + else + *dst_ie++ = 0; + + if (tim_ielen == 4) { + *dst_ie++ = *(u8 *)&tim_bitmap_le; + } else if (tim_ielen == 5) { + memcpy(dst_ie, &tim_bitmap_le, 2); + dst_ie += 2; + } + + /* copy remainder IE */ + if (pbackup_remainder_ie) { + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); + } + offset = (uint)(dst_ie - pie); + pnetwork_mlmeext->IELength = offset + remainder_ielen; + } + + set_tx_beacon_cmd(padapter); +} + +void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index, u8 *data, u8 len) +{ + struct ndis_802_11_var_ie *pIE; + u8 bmatch = false; + u8 *pie = pnetwork->IEs; + u8 *p = NULL, *dst_ie = NULL, *premainder_ie = NULL; + u8 *pbackup_remainder_ie = NULL; + u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0; + + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i); + + if (pIE->ElementID > index) { + break; + } else if (pIE->ElementID == index) { /* already exist the same IE */ + p = (u8 *)pIE; + ielen = pIE->Length; + bmatch = true; + break; + } + p = (u8 *)pIE; + ielen = pIE->Length; + i += (pIE->Length + 2); + } + + if (p != NULL && ielen > 0) { + ielen += 2; + + premainder_ie = p+ielen; + + ie_offset = (int)(p - pie); + + remainder_ielen = pnetwork->IELength - ie_offset - ielen; + + if (bmatch) + dst_ie = p; + else + dst_ie = (p+ielen); + } + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + *dst_ie++ = index; + *dst_ie++ = len; + + memcpy(dst_ie, data, len); + dst_ie += len; + + /* copy remainder IE */ + if (pbackup_remainder_ie) { + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); + } + + offset = (uint)(dst_ie - pie); + pnetwork->IELength = offset + remainder_ielen; +} + +void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index) +{ + u8 *p, *dst_ie = NULL, *premainder_ie = NULL; + u8 *pbackup_remainder_ie = NULL; + uint offset, ielen, ie_offset, remainder_ielen = 0; + u8 *pie = pnetwork->IEs; + + p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, + pnetwork->IELength - _FIXED_IE_LENGTH_); + if (p != NULL && ielen > 0) { + ielen += 2; + + premainder_ie = p+ielen; + + ie_offset = (int)(p - pie); + + remainder_ielen = pnetwork->IELength - ie_offset - ielen; + + dst_ie = p; + } + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie && premainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + /* copy remainder IE */ + if (pbackup_remainder_ie) { + memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); + + kfree(pbackup_remainder_ie); + } + + offset = (uint)(dst_ie - pie); + pnetwork->IELength = offset + remainder_ielen; +} + +static u8 chk_sta_is_alive(struct sta_info *psta) +{ + u8 ret = false; + + if ((psta->sta_stats.last_rx_data_pkts + psta->sta_stats.last_rx_ctrl_pkts) == + (psta->sta_stats.rx_data_pkts + psta->sta_stats.rx_ctrl_pkts)) + ; + else + ret = true; + + sta_update_last_rx_pkts(psta); + + return ret; +} + +void expire_timeout_chk(struct adapter *padapter) +{ + struct list_head *phead, *plist; + u8 updated = 0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 chk_alive_num = 0; + char chk_alive_list[NUM_STA]; + int i; + + spin_lock_bh(&pstapriv->auth_list_lock); + + phead = &pstapriv->auth_list; + plist = phead->next; + + /* check auth_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, auth_list); + plist = plist->next; + + if (psta->expire_to > 0) { + psta->expire_to--; + if (psta->expire_to == 0) { + list_del_init(&psta->auth_list); + pstapriv->auth_list_cnt--; + + DBG_88E("auth expire %6ph\n", + psta->hwaddr); + + spin_unlock_bh(&pstapriv->auth_list_lock); + + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(padapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + + spin_lock_bh(&pstapriv->auth_list_lock); + } + } + + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + psta = NULL; + + spin_lock_bh(&pstapriv->asoc_list_lock); + + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* check asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + plist = plist->next; + + if (chk_sta_is_alive(psta) || !psta->expire_to) { + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + psta->under_exist_checking = 0; + } else { + psta->expire_to--; + } + + if (psta->expire_to <= 0) { + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (padapter->registrypriv.wifi_spec == 1) { + psta->expire_to = pstapriv->expire_to; + continue; + } + + if (psta->state & WIFI_SLEEP_STATE) { + if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) { + /* to check if alive by another methods if station is at ps mode. */ + psta->expire_to = pstapriv->expire_to; + psta->state |= WIFI_STA_ALIVE_CHK_STATE; + + /* to update bcn with tim_bitmap for this station */ + pstapriv->tim_bitmap |= BIT(psta->aid); + update_beacon(padapter, _TIM_IE_, NULL, false); + + if (!pmlmeext->active_keep_alive_check) + continue; + } + } + if (pmlmeext->active_keep_alive_check) { + int stainfo_offset; + + stainfo_offset = rtw_stainfo_offset(pstapriv, psta); + if (stainfo_offset_valid(stainfo_offset)) + chk_alive_list[chk_alive_num++] = stainfo_offset; + continue; + } + + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + + DBG_88E("asoc expire %pM, state = 0x%x\n", (psta->hwaddr), psta->state); + updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + } else { + /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ + if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) && + padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME/pstapriv->asoc_list_cnt/2)) { + DBG_88E("%s sta:%pM, sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__, + (psta->hwaddr), psta->sleepq_len, + padapter->xmitpriv.free_xmitframe_cnt, + pstapriv->asoc_list_cnt); + wakeup_sta_to_xmit(padapter, psta); + } + } + } + + spin_unlock_bh(&pstapriv->asoc_list_lock); + + if (chk_alive_num) { + u8 backup_oper_channel = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + /* switch to correct channel of current network before issue keep-alive frames */ + if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { + backup_oper_channel = rtw_get_oper_ch(padapter); + SelectChannel(padapter, pmlmeext->cur_channel); + } + + /* issue null data to check sta alive*/ + for (i = 0; i < chk_alive_num; i++) { + int ret = _FAIL; + + psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]); + + if (psta->state & WIFI_SLEEP_STATE) + ret = issue_nulldata(padapter, psta->hwaddr, 0, 1, 50); + else + ret = issue_nulldata(padapter, psta->hwaddr, 0, 3, 50); + + psta->keep_alive_trycnt++; + if (ret == _SUCCESS) { + DBG_88E("asoc check, sta(%pM) is alive\n", (psta->hwaddr)); + psta->expire_to = pstapriv->expire_to; + psta->keep_alive_trycnt = 0; + continue; + } else if (psta->keep_alive_trycnt <= 3) { + DBG_88E("ack check for asoc expire, keep_alive_trycnt =%d\n", psta->keep_alive_trycnt); + psta->expire_to = 1; + continue; + } + + psta->keep_alive_trycnt = 0; + + DBG_88E("asoc expire %pM, state = 0x%x\n", (psta->hwaddr), psta->state); + spin_lock_bh(&pstapriv->asoc_list_lock); + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + spin_unlock_bh(&pstapriv->asoc_list_lock); + } + + if (backup_oper_channel > 0) /* back to the original operation channel */ + SelectChannel(padapter, backup_oper_channel); + } + + associated_clients_update(padapter, updated); +} + +void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) +{ + int i; + u8 rf_type; + u32 init_rate = 0; + unsigned char sta_band = 0, raid, shortGIrate = false; + unsigned char limit; + unsigned int tx_ra_bitmap = 0; + struct ht_priv *psta_ht = NULL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + + if (psta) + psta_ht = &psta->htpriv; + else + return; + + if (!(psta->state & _FW_LINKED)) + return; + + /* b/g mode ra_bitmap */ + for (i = 0; i < sizeof(psta->bssrateset); i++) { + if (psta->bssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + /* n mode ra_bitmap */ + if (psta_ht->ht_option) { + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if (rf_type == RF_2T2R) + limit = 16;/* 2R */ + else + limit = 8;/* 1R */ + + for (i = 0; i < limit; i++) { + if (psta_ht->ht_cap.mcs.rx_mask[i/8] & BIT(i%8)) + tx_ra_bitmap |= BIT(i+12); + } + + /* max short GI rate */ + shortGIrate = psta_ht->sgi; + } + + if (pcur_network->Configuration.DSConfig > 14) { + /* 5G band */ + if (tx_ra_bitmap & 0xffff000) + sta_band |= WIRELESS_11_5N | WIRELESS_11A; + else + sta_band |= WIRELESS_11A; + } else { + if (tx_ra_bitmap & 0xffff000) + sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B; + else if (tx_ra_bitmap & 0xff0) + sta_band |= WIRELESS_11G | WIRELESS_11B; + else + sta_band |= WIRELESS_11B; + } + + psta->wireless_mode = sta_band; + + raid = networktype_to_raid(sta_band); + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + + if (psta->aid < NUM_STA) { + u8 arg = 0; + + arg = psta->mac_id&0x1f; + + arg |= BIT(7);/* support entry 2~31 */ + + if (shortGIrate) + arg |= BIT(5); + + tx_ra_bitmap |= ((raid<<28)&0xf0000000); + + DBG_88E("%s => mac_id:%d , raid:%d , bitmap = 0x%x, arg = 0x%x\n", + __func__ , psta->mac_id, raid , tx_ra_bitmap, arg); + + /* bitmap[0:27] = tx_rate_bitmap */ + /* bitmap[28:31]= Rate Adaptive id */ + /* arg[0:4] = macid */ + /* arg[5] = Short GI */ + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); + + if (shortGIrate) + init_rate |= BIT(6); + + /* set ra_id, init_rate */ + psta->raid = raid; + psta->init_rate = init_rate; + + } else { + DBG_88E("station aid %d exceed the max number\n", psta->aid); + } +} + +void update_bmc_sta(struct adapter *padapter) +{ + u32 init_rate = 0; + unsigned char network_type, raid; + int i, supportRateNum = 0; + unsigned int tx_ra_bitmap = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); + + if (psta) { + psta->aid = 0;/* default set to 0 */ + psta->mac_id = psta->aid + 1; + + psta->qos_option = 0; + psta->htpriv.ht_option = false; + + psta->ieee8021x_blocked = 0; + + memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + /* prepare for add_RATid */ + supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates); + network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates, supportRateNum, 1); + + memcpy(psta->bssrateset, &pcur_network->SupportedRates, supportRateNum); + psta->bssratelen = supportRateNum; + + /* b/g mode ra_bitmap */ + for (i = 0; i < supportRateNum; i++) { + if (psta->bssrateset[i]) + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + } + + if (pcur_network->Configuration.DSConfig > 14) { + /* force to A mode. 5G doesn't support CCK rates */ + network_type = WIRELESS_11A; + tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */ + } else { + /* force to b mode */ + network_type = WIRELESS_11B; + tx_ra_bitmap = 0xf; + } + + raid = networktype_to_raid(network_type); + init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + + /* ap mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + + { + u8 arg = 0; + + arg = psta->mac_id&0x1f; + arg |= BIT(7); + tx_ra_bitmap |= ((raid<<28)&0xf0000000); + DBG_88E("update_bmc_sta, mask = 0x%x, arg = 0x%x\n", tx_ra_bitmap, arg); + + /* bitmap[0:27] = tx_rate_bitmap */ + /* bitmap[28:31]= Rate Adaptive id */ + /* arg[0:4] = macid */ + /* arg[5] = Short GI */ + rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, 0); + } + /* set ra_id, init_rate */ + psta->raid = raid; + psta->init_rate = init_rate; + + rtw_sta_media_status_rpt(padapter, psta, 1); + + spin_lock_bh(&psta->lock); + psta->state = _FW_LINKED; + spin_unlock_bh(&psta->lock); + + } else { + DBG_88E("add_RATid_bmc_sta error!\n"); + } +} + +/* notes: */ +/* AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode */ +/* MAC_ID = AID+1 for sta in ap/adhoc mode */ +/* MAC_ID = 1 for bc/mc for sta/ap/adhoc */ +/* MAC_ID = 0 for bssid for sta/ap/adhoc */ +/* CAM_ID = 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ + +void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + struct ht_priv *phtpriv_sta = &psta->htpriv; + u16 sta_cap_info; + u16 ap_cap_info; + + psta->mac_id = psta->aid+1; + DBG_88E("%s\n", __func__); + + /* ap mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->ieee8021x_blocked = true; + else + psta->ieee8021x_blocked = false; + + /* update sta's cap */ + + /* ERP */ + VCS_update(padapter, psta); + /* HT related cap */ + if (phtpriv_sta->ht_option) { + /* check if sta supports rx ampdu */ + phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; + sta_cap_info = le16_to_cpu(phtpriv_sta->ht_cap.cap_info); + ap_cap_info = le16_to_cpu(phtpriv_ap->ht_cap.cap_info); + + /* check if sta support s Short GI */ + if ((sta_cap_info & ap_cap_info) & + (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) + phtpriv_sta->sgi = true; + + /* bwmode */ + if ((sta_cap_info & ap_cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) { + phtpriv_sta->bwmode = pmlmeext->cur_bwmode; + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + } + psta->qos_option = true; + } else { + phtpriv_sta->ampdu_enable = false; + phtpriv_sta->sgi = false; + phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + + /* Rx AMPDU */ + send_delba(padapter, 0, psta->hwaddr);/* recipient */ + + /* TX AMPDU */ + send_delba(padapter, 1, psta->hwaddr);/* originator */ + phtpriv_sta->agg_enable_bitmap = 0x0;/* reset */ + phtpriv_sta->candidate_tid_bitmap = 0x0;/* reset */ + + /* todo: init other variables */ + + memset((void *)&psta->sta_stats, 0, sizeof(struct stainfo_stats)); + + spin_lock_bh(&psta->lock); + psta->state |= _FW_LINKED; + spin_unlock_bh(&psta->lock); +} + +static void update_hw_ht_param(struct adapter *padapter) +{ + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_88E("%s\n", __func__); + + /* handle A-MPDU parameter field */ + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; + + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); + + /* */ + /* Config SM Power Save setting */ + /* */ + pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2; + if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) + DBG_88E("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); +} + +static void start_bss_network(struct adapter *padapter, u8 *pbuf) +{ + u8 *p; + u8 val8, cur_channel, cur_bwmode, cur_ch_offset; + u16 bcn_interval; + u32 acparm; + int ie_len; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); + struct HT_info_element *pht_info = NULL; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; + cur_channel = pnetwork->Configuration.DSConfig; + cur_bwmode = HT_CHANNEL_WIDTH_20; + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + /* check if there is wps ie, */ + /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ + /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ + if (!rtw_get_wps_ie(pnetwork->IEs+_FIXED_IE_LENGTH_, pnetwork->IELength-_FIXED_IE_LENGTH_, NULL, NULL)) + pmlmeext->bstart_bss = true; + + /* todo: update wmm, ht cap */ + if (pmlmepriv->qospriv.qos_option) + pmlmeinfo->WMM_enable = true; + if (pmlmepriv->htpriv.ht_option) { + pmlmeinfo->WMM_enable = true; + pmlmeinfo->HT_enable = true; + + update_hw_ht_param(padapter); + } + + if (pmlmepriv->cur_network.join_res != true) { /* setting only at first time */ + /* WEP Key will be set before this function, do not clear CAM. */ + if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && + (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) + flush_all_cam_entry(padapter); /* clear CAM */ + } + + /* set MSR to AP_Mode */ + Set_MSR(padapter, _HW_STATE_AP_); + + /* Set BSSID REG */ + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress); + + /* Set EDCA param reg */ + acparm = 0x002F3217; /* VO */ + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); + acparm = 0x005E4317; /* VI */ + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); + acparm = 0x005ea42b; + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); + acparm = 0x0000A444; /* BK */ + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); + + /* Set Security */ + val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* Beacon Control related register */ + rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&bcn_interval)); + + UpdateBrateTbl(padapter, pnetwork->SupportedRates); + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); + + if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ + /* turn on all dynamic functions */ + Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + } + /* set channel, bwmode */ + p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fixed_ie))); + if (p && ie_len) { + pht_info = (struct HT_info_element *)(p+2); + + if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { + /* switch to the 40M Hz mode */ + cur_bwmode = HT_CHANNEL_WIDTH_40; + switch (pht_info->infos[0] & 0x3) { + case 1: + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case 3: + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + } + } + /* TODO: need to judge the phy parameters on concurrent mode for single phy */ + set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); + + DBG_88E("CH =%d, BW =%d, offset =%d\n", cur_channel, cur_bwmode, cur_ch_offset); + + /* */ + pmlmeext->cur_channel = cur_channel; + pmlmeext->cur_bwmode = cur_bwmode; + pmlmeext->cur_ch_offset = cur_ch_offset; + pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; + + /* update cur_wireless_mode */ + update_wireless_mode(padapter); + + /* udpate capability after cur_wireless_mode updated */ + update_capinfo(padapter, rtw_get_capability((struct wlan_bssid_ex *)pnetwork)); + + /* let pnetwork_mlmeext == pnetwork_mlme. */ + memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); + +#ifdef CONFIG_88EU_P2P + memcpy(pwdinfo->p2p_group_ssid, pnetwork->Ssid.Ssid, pnetwork->Ssid.SsidLength); + pwdinfo->p2p_group_ssid_len = pnetwork->Ssid.SsidLength; +#endif /* CONFIG_88EU_P2P */ + + if (pmlmeext->bstart_bss) { + update_beacon(padapter, _TIM_IE_, NULL, false); + + /* issue beacon frame */ + if (send_beacon(padapter) == _FAIL) + DBG_88E("issue_beacon, fail!\n"); + } + + /* update bc/mc sta_info */ + update_bmc_sta(padapter); +} + +int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) +{ + int ret = _SUCCESS; + u8 *p; + u8 *pHT_caps_ie = NULL; + u8 *pHT_info_ie = NULL; + struct sta_info *psta = NULL; + u16 cap, ht_cap = false; + uint ie_len = 0; + int group_cipher, pairwise_cipher; + u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; + int supportRateNum = 0; + u8 OUI1[] = {0x00, 0x50, 0xf2, 0x01}; + u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; + u8 *ie = pbss_network->IEs; + + /* SSID */ + /* Supported rates */ + /* DS Params */ + /* WLAN_EID_COUNTRY */ + /* ERP Information element */ + /* Extended supported rates */ + /* WPA/WPA2 */ + /* Wi-Fi Wireless Multimedia Extensions */ + /* ht_capab, ht_oper */ + /* WPS IE */ + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return _FAIL; + + if (len > MAX_IE_SZ) + return _FAIL; + + pbss_network->IELength = len; + + memset(ie, 0, MAX_IE_SZ); + + memcpy(ie, pbuf, pbss_network->IELength); + + if (pbss_network->InfrastructureMode != Ndis802_11APMode) + return _FAIL; + + pbss_network->Rssi = 0; + + memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + + /* beacon interval */ + p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p); + + /* capability */ + cap = get_unaligned_le16(ie); + + /* SSID */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) { + memset(&pbss_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(pbss_network->Ssid.Ssid, (p + 2), ie_len); + pbss_network->Ssid.SsidLength = ie_len; + } + + /* channel */ + channel = 0; + pbss_network->Configuration.Length = 0; + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _DSSET_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + channel = *(p + 2); + + pbss_network->Configuration.DSConfig = channel; + + memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); + /* get supported rates */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p != NULL) { + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + } + + /* get ext_supported rates */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); + if (p != NULL) { + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + } + + network_type = rtw_check_network_type(supportRate, supportRateNum, channel); + + rtw_set_supported_rate(pbss_network->SupportedRates, network_type); + + /* parsing ERP_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + ERP_IE_handler(padapter, (struct ndis_802_11_var_ie *)p); + + /* update privacy/security */ + if (cap & BIT(4)) + pbss_network->Privacy = 1; + else + pbss_network->Privacy = 0; + + psecuritypriv->wpa_psk = 0; + + /* wpa2 */ + group_cipher = 0; + pairwise_cipher = 0; + psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) { + if (rtw_parse_wpa2_ie(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ + psecuritypriv->wpa_psk |= BIT(1); + + psecuritypriv->wpa2_group_cipher = group_cipher; + psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; + } + } + /* wpa */ + ie_len = 0; + group_cipher = 0; + pairwise_cipher = 0; + psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; + psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; + for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { + p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if ((p) && (!memcmp(p+2, OUI1, 4))) { + if (rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, + &pairwise_cipher, NULL) == _SUCCESS) { + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ + + psecuritypriv->wpa_psk |= BIT(0); + + psecuritypriv->wpa_group_cipher = group_cipher; + psecuritypriv->wpa_pairwise_cipher = pairwise_cipher; + } + break; + } + if ((p == NULL) || (ie_len == 0)) + break; + } + + /* wmm */ + ie_len = 0; + pmlmepriv->qospriv.qos_option = 0; + if (pregistrypriv->wmm_enable) { + for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { + pmlmepriv->qospriv.qos_option = 1; + + *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ + + /* disable all ACM bits since the WMM admission control is not supported */ + *(p + 10) &= ~BIT(4); /* BE */ + *(p + 14) &= ~BIT(4); /* BK */ + *(p + 18) &= ~BIT(4); /* VI */ + *(p + 22) &= ~BIT(4); /* VO */ + break; + } + + if ((p == NULL) || (ie_len == 0)) + break; + } + } + /* parsing HT_CAP_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) { + u8 rf_type; + struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p+2); + + pHT_caps_ie = p; + ht_cap = true; + network_type |= WIRELESS_11_24N; + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || + (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + else + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + + /* set Max Rx AMPDU size to 64K */ + pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); + + if(rf_type == RF_1T1R) { + pht_cap->mcs.rx_mask[0] = 0xff; + pht_cap->mcs.rx_mask[1] = 0x0; + } + memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len); + } + + /* parsing HT_INFO_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, + (pbss_network->IELength - _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + pHT_info_ie = p; + switch (network_type) { + case WIRELESS_11B: + pbss_network->NetworkTypeInUse = Ndis802_11DS; + break; + case WIRELESS_11G: + case WIRELESS_11BG: + case WIRELESS_11G_24N: + case WIRELESS_11BG_24N: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + break; + case WIRELESS_11A: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; + break; + default: + pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; + break; + } + + pmlmepriv->cur_network.network_type = network_type; + + pmlmepriv->htpriv.ht_option = false; + + if ((psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) || + (psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) { + /* todo: */ + /* ht_cap = false; */ + } + + /* ht_cap */ + if (pregistrypriv->ht_enable && ht_cap) { + pmlmepriv->htpriv.ht_option = true; + pmlmepriv->qospriv.qos_option = 1; + + if (pregistrypriv->ampdu_enable == 1) + pmlmepriv->htpriv.ampdu_enable = true; + HT_caps_handler(padapter, (struct ndis_802_11_var_ie *)pHT_caps_ie); + + HT_info_handler(padapter, (struct ndis_802_11_var_ie *)pHT_info_ie); + } + + pbss_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pbss_network); + + /* issue beacon to start bss network */ + start_bss_network(padapter, (u8 *)pbss_network); + + /* alloc sta_info for ap itself */ + psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if (!psta) { + psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); + if (psta == NULL) + return _FAIL; + } + + /* fix bug of flush_cam_entry at STOP AP mode */ + psta->state |= WIFI_AP_STATE; + rtw_indicate_connect(padapter); + pmlmepriv->cur_network.join_res = true;/* for check if already set beacon */ + return ret; +} + +void rtw_set_macaddr_acl(struct adapter *padapter, int mode) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + DBG_88E("%s, mode =%d\n", __func__, mode); + + pacl_list->mode = mode; +} + +int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) +{ + struct list_head *plist, *phead; + u8 added = false; + int i, ret = 0; + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); + + if ((NUM_ACL-1) < pacl_list->num) + return -1; + + spin_lock_bh(&pacl_node_q->lock); + + phead = get_list_head(pacl_node_q); + plist = phead->next; + + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; + + if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (paclnode->valid) { + added = true; + DBG_88E("%s, sta has been added\n", __func__); + break; + } + } + } + + spin_unlock_bh(&pacl_node_q->lock); + + if (added) + return ret; + + spin_lock_bh(&pacl_node_q->lock); + + for (i = 0; i < NUM_ACL; i++) { + paclnode = &pacl_list->aclnode[i]; + + if (!paclnode->valid) { + INIT_LIST_HEAD(&paclnode->list); + + memcpy(paclnode->addr, addr, ETH_ALEN); + + paclnode->valid = true; + + list_add_tail(&paclnode->list, get_list_head(pacl_node_q)); + + pacl_list->num++; + + break; + } + } + + DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); + + spin_unlock_bh(&pacl_node_q->lock); + + return ret; +} + +int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) +{ + struct list_head *plist, *phead; + int ret = 0; + struct rtw_wlan_acl_node *paclnode; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); + + spin_lock_bh(&pacl_node_q->lock); + + phead = get_list_head(pacl_node_q); + plist = phead->next; + + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; + + if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { + if (paclnode->valid) { + paclnode->valid = false; + + list_del_init(&paclnode->list); + + pacl_list->num--; + } + } + } + + spin_unlock_bh(&pacl_node_q->lock); + + DBG_88E("%s, acl_num =%d\n", __func__, pacl_list->num); + return ret; +} + +static void update_bcn_fixed_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_erpinfo_ie(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + unsigned char *p, *ie = pnetwork->IEs; + u32 len = 0; + + DBG_88E("%s, ERP_enable =%d\n", __func__, pmlmeinfo->ERP_enable); + + if (!pmlmeinfo->ERP_enable) + return; + + /* parsing ERP_IE */ + p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _ERPINFO_IE_, &len, + (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if (p && len > 0) { + struct ndis_802_11_var_ie *pIE = (struct ndis_802_11_var_ie *)p; + + if (pmlmepriv->num_sta_non_erp == 1) + pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION; + else + pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION); + + if (pmlmepriv->num_sta_no_short_preamble > 0) + pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE; + else + pIE->data[0] &= ~(RTW_ERP_INFO_BARKER_PREAMBLE_MODE); + + ERP_IE_handler(padapter, pIE); + } +} + +static void update_bcn_htcap_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_htinfo_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_rsn_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_wpa_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_wmm_ie(struct adapter *padapter) +{ + DBG_88E("%s\n", __func__); +} + +static void update_bcn_wps_ie(struct adapter *padapter) +{ + u8 *pwps_ie = NULL, *pwps_ie_src; + u8 *premainder_ie, *pbackup_remainder_ie = NULL; + uint wps_ielen = 0, wps_offset, remainder_ielen; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + unsigned char *ie = pnetwork->IEs; + u32 ielen = pnetwork->IELength; + + DBG_88E("%s\n", __func__); + + pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + if (pwps_ie == NULL || wps_ielen == 0) + return; + + wps_offset = (uint)(pwps_ie-ie); + + premainder_ie = pwps_ie + wps_ielen; + + remainder_ielen = ielen - wps_offset - wps_ielen; + + if (remainder_ielen > 0) { + pbackup_remainder_ie = rtw_malloc(remainder_ielen); + if (pbackup_remainder_ie) + memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); + } + + pwps_ie_src = pmlmepriv->wps_beacon_ie; + if (pwps_ie_src == NULL) + return; + + wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ + if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); + pwps_ie += (wps_ielen+2); + + if (pbackup_remainder_ie) + memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen); + + /* update IELength */ + pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen; + } + + if (pbackup_remainder_ie) + kfree(pbackup_remainder_ie); +} + +static void update_bcn_p2p_ie(struct adapter *padapter) +{ +} + +static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) +{ + DBG_88E("%s\n", __func__); + + if (!memcmp(RTW_WPA_OUI, oui, 4)) + update_bcn_wpa_ie(padapter); + else if (!memcmp(WMM_OUI, oui, 4)) + update_bcn_wmm_ie(padapter); + else if (!memcmp(WPS_OUI, oui, 4)) + update_bcn_wps_ie(padapter); + else if (!memcmp(P2P_OUI, oui, 4)) + update_bcn_p2p_ie(padapter); + else + DBG_88E("unknown OUI type!\n"); +} + +void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) +{ + struct mlme_priv *pmlmepriv; + struct mlme_ext_priv *pmlmeext; + + if (!padapter) + return; + + pmlmepriv = &(padapter->mlmepriv); + pmlmeext = &(padapter->mlmeextpriv); + + if (!pmlmeext->bstart_bss) + return; + + spin_lock_bh(&pmlmepriv->bcn_update_lock); + + switch (ie_id) { + case 0xFF: + update_bcn_fixed_ie(padapter);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ + break; + case _TIM_IE_: + update_BCNTIM(padapter); + break; + case _ERPINFO_IE_: + update_bcn_erpinfo_ie(padapter); + break; + case _HT_CAPABILITY_IE_: + update_bcn_htcap_ie(padapter); + break; + case _RSN_IE_2_: + update_bcn_rsn_ie(padapter); + break; + case _HT_ADD_INFO_IE_: + update_bcn_htinfo_ie(padapter); + break; + case _VENDOR_SPECIFIC_IE_: + update_bcn_vendor_spec_ie(padapter, oui); + break; + default: + break; + } + + pmlmepriv->update_bcn = true; + + spin_unlock_bh(&pmlmepriv->bcn_update_lock); + + if (tx) + set_tx_beacon_cmd(padapter); +} + +/* +op_mode +Set to 0 (HT pure) under the followign conditions + - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or + - all STAs in the BSS are 20 MHz HT in 20 MHz BSS +Set to 1 (HT non-member protection) if there may be non-HT STAs + in both the primary and the secondary channel +Set to 2 if only HT STAs are associated in BSS, + however and at least one 20 MHz HT STA is associated +Set to 3 (HT mixed mode) when one or more non-HT STAs are associated + (currently non-GF HT station is considered as non-HT STA also) +*/ +static int rtw_ht_operation_update(struct adapter *padapter) +{ + u16 cur_op_mode, new_op_mode; + int op_mode_changes = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; + + if (pmlmepriv->htpriv.ht_option) + return 0; + + DBG_88E("%s current operation mode = 0x%X\n", + __func__, pmlmepriv->ht_op_mode); + + if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + pmlmepriv->num_sta_ht_no_gf) { + pmlmepriv->ht_op_mode |= + HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + op_mode_changes++; + } else if ((pmlmepriv->ht_op_mode & + HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && + pmlmepriv->num_sta_ht_no_gf == 0) { + pmlmepriv->ht_op_mode &= + ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; + op_mode_changes++; + } + + if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { + pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + op_mode_changes++; + } else if ((pmlmepriv->ht_op_mode & + HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && + (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { + pmlmepriv->ht_op_mode &= + ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; + op_mode_changes++; + } + + /* Note: currently we switch to the MIXED op mode if HT non-greenfield + * station is associated. Probably it's a theoretical case, since + * it looks like all known HT STAs support greenfield. + */ + new_op_mode = 0; + if (pmlmepriv->num_sta_no_ht || + (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) + new_op_mode = OP_MODE_MIXED; + else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & + IEEE80211_HT_CAP_SUP_WIDTH) && + pmlmepriv->num_sta_ht_20mhz) + new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; + else if (pmlmepriv->olbc_ht) + new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; + else + new_op_mode = OP_MODE_PURE; + + cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK; + if (cur_op_mode != new_op_mode) { + pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK; + pmlmepriv->ht_op_mode |= new_op_mode; + op_mode_changes++; + } + + DBG_88E("%s new operation mode = 0x%X changes =%d\n", + __func__, pmlmepriv->ht_op_mode, op_mode_changes); + + return op_mode_changes; +} + +void associated_clients_update(struct adapter *padapter, u8 updated) +{ + /* update associcated stations cap. */ + if (updated) { + struct list_head *phead, *plist; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + spin_lock_bh(&pstapriv->asoc_list_lock); + + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* check asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + + plist = plist->next; + + VCS_update(padapter, psta); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + } +} + +/* called > TSR LEVEL for USB or SDIO Interface*/ +void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) +{ + u8 beacon_updated = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { + if (!psta->no_short_preamble_set) { + psta->no_short_preamble_set = 1; + + pmlmepriv->num_sta_no_short_preamble++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 1)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } else { + if (psta->no_short_preamble_set) { + psta->no_short_preamble_set = 0; + + pmlmepriv->num_sta_no_short_preamble--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_preamble == 0)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } + + if (psta->flags & WLAN_STA_NONERP) { + if (!psta->nonerp_set) { + psta->nonerp_set = 1; + + pmlmepriv->num_sta_non_erp++; + + if (pmlmepriv->num_sta_non_erp == 1) { + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + } else { + if (psta->nonerp_set) { + psta->nonerp_set = 0; + + pmlmepriv->num_sta_non_erp--; + + if (pmlmepriv->num_sta_non_erp == 0) { + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + } + + if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT)) { + if (!psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 1; + + pmlmepriv->num_sta_no_short_slot_time++; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 1)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } else { + if (psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 0; + + pmlmepriv->num_sta_no_short_slot_time--; + + if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && + (pmlmepriv->num_sta_no_short_slot_time == 0)) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + } + + if (psta->flags & WLAN_STA_HT) { + u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); + + DBG_88E("HT: STA %pM HT Capabilities Info: 0x%04x\n", + (psta->hwaddr), ht_capab); + + if (psta->no_ht_set) { + psta->no_ht_set = 0; + pmlmepriv->num_sta_no_ht--; + } + + if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) { + if (!psta->no_ht_gf_set) { + psta->no_ht_gf_set = 1; + pmlmepriv->num_sta_ht_no_gf++; + } + DBG_88E("%s STA %pM - no greenfield, num of non-gf stations %d\n", + __func__, (psta->hwaddr), + pmlmepriv->num_sta_ht_no_gf); + } + + if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) { + if (!psta->ht_20mhz_set) { + psta->ht_20mhz_set = 1; + pmlmepriv->num_sta_ht_20mhz++; + } + DBG_88E("%s STA %pM - 20 MHz HT, num of 20MHz HT STAs %d\n", + __func__, (psta->hwaddr), + pmlmepriv->num_sta_ht_20mhz); + } + } else { + if (!psta->no_ht_set) { + psta->no_ht_set = 1; + pmlmepriv->num_sta_no_ht++; + } + if (pmlmepriv->htpriv.ht_option) { + DBG_88E("%s STA %pM - no HT, num of non-HT stations %d\n", + __func__, (psta->hwaddr), + pmlmepriv->num_sta_no_ht); + } + } + + if (rtw_ht_operation_update(padapter) > 0) { + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + } + + /* update associcated stations cap. */ + associated_clients_update(padapter, beacon_updated); + + DBG_88E("%s, updated =%d\n", __func__, beacon_updated); +} + +u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) +{ + u8 beacon_updated = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + if (!psta) + return beacon_updated; + + if (psta->no_short_preamble_set) { + psta->no_short_preamble_set = 0; + pmlmepriv->num_sta_no_short_preamble--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B && + pmlmepriv->num_sta_no_short_preamble == 0) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + + if (psta->nonerp_set) { + psta->nonerp_set = 0; + pmlmepriv->num_sta_non_erp--; + if (pmlmepriv->num_sta_non_erp == 0) { + beacon_updated = true; + update_beacon(padapter, _ERPINFO_IE_, NULL, true); + } + } + + if (psta->no_short_slot_time_set) { + psta->no_short_slot_time_set = 0; + pmlmepriv->num_sta_no_short_slot_time--; + if (pmlmeext->cur_wireless_mode > WIRELESS_11B && + pmlmepriv->num_sta_no_short_slot_time == 0) { + beacon_updated = true; + update_beacon(padapter, 0xFF, NULL, true); + } + } + + if (psta->no_ht_gf_set) { + psta->no_ht_gf_set = 0; + pmlmepriv->num_sta_ht_no_gf--; + } + + if (psta->no_ht_set) { + psta->no_ht_set = 0; + pmlmepriv->num_sta_no_ht--; + } + + if (psta->ht_20mhz_set) { + psta->ht_20mhz_set = 0; + pmlmepriv->num_sta_ht_20mhz--; + } + + if (rtw_ht_operation_update(padapter) > 0) { + update_beacon(padapter, _HT_CAPABILITY_IE_, NULL, false); + update_beacon(padapter, _HT_ADD_INFO_IE_, NULL, true); + } + + /* update associcated stations cap. */ + + DBG_88E("%s, updated =%d\n", __func__, beacon_updated); + + return beacon_updated; +} + +u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, + bool active, u16 reason) +{ + u8 beacon_updated = false; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (!psta) + return beacon_updated; + + /* tear down Rx AMPDU */ + send_delba(padapter, 0, psta->hwaddr);/* recipient */ + + /* tear down TX AMPDU */ + send_delba(padapter, 1, psta->hwaddr);/* originator */ + psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ + psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ + + if (active) + issue_deauth(padapter, psta->hwaddr, reason); + + /* clear cam entry / key */ + rtw_clearstakey_cmd(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), true); + + spin_lock_bh(&psta->lock); + psta->state &= ~_FW_LINKED; + spin_unlock_bh(&psta->lock); + + rtw_indicate_sta_disassoc_event(padapter, psta); + + report_del_sta_event(padapter, psta->hwaddr, reason); + + beacon_updated = bss_cap_update_on_sta_leave(padapter, psta); + + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(padapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + + return beacon_updated; +} + +int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) +{ + struct list_head *phead, *plist; + int ret = 0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return ret; + + DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), new_ch, ch_offset); + + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* for each sta in asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + plist = plist->next; + + issue_action_spct_ch_switch(padapter, psta->hwaddr, new_ch, ch_offset); + psta->expire_to = ((pstapriv->expire_to * 2) > 5) ? 5 : (pstapriv->expire_to * 2); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + issue_action_spct_ch_switch(padapter, bc_addr, new_ch, ch_offset); + + return ret; +} + +int rtw_sta_flush(struct adapter *padapter) +{ + struct list_head *phead, *plist; + int ret = 0; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return ret; + + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* free sta asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + + plist = plist->next; + + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + + ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); + + associated_clients_update(padapter, true); + + return ret; +} + +/* called > TSR LEVEL for USB or SDIO Interface*/ +void sta_info_update(struct adapter *padapter, struct sta_info *psta) +{ + int flags = psta->flags; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + /* update wmm cap. */ + if (WLAN_STA_WME&flags) + psta->qos_option = 1; + else + psta->qos_option = 0; + + if (pmlmepriv->qospriv.qos_option == 0) + psta->qos_option = 0; + + /* update 802.11n ht cap. */ + if (WLAN_STA_HT&flags) { + psta->htpriv.ht_option = true; + psta->qos_option = 1; + } else { + psta->htpriv.ht_option = false; + } + + if (!pmlmepriv->htpriv.ht_option) + psta->htpriv.ht_option = false; + + update_sta_info_apmode(padapter, psta); +} + +/* called >= TSR LEVEL for USB or SDIO Interface*/ +void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) +{ + if (psta->state & _FW_LINKED) { + /* add ratid */ + add_RATid(padapter, psta, 0);/* DM_RATR_STA_INIT */ + } +} + +void start_ap_mode(struct adapter *padapter) +{ + int i; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + + pmlmepriv->update_bcn = false; + + pmlmeext->bstart_bss = false; + + pmlmepriv->num_sta_non_erp = 0; + + pmlmepriv->num_sta_no_short_slot_time = 0; + + pmlmepriv->num_sta_no_short_preamble = 0; + + pmlmepriv->num_sta_ht_no_gf = 0; + pmlmepriv->num_sta_no_ht = 0; + pmlmepriv->num_sta_ht_20mhz = 0; + + pmlmepriv->olbc = false; + + pmlmepriv->olbc_ht = false; + + pmlmepriv->ht_op_mode = 0; + + for (i = 0; i < NUM_STA; i++) + pstapriv->sta_aid[i] = NULL; + + pmlmepriv->wps_beacon_ie = NULL; + pmlmepriv->wps_probe_resp_ie = NULL; + pmlmepriv->wps_assoc_resp_ie = NULL; + + pmlmepriv->p2p_beacon_ie = NULL; + pmlmepriv->p2p_probe_resp_ie = NULL; + + /* for ACL */ + INIT_LIST_HEAD(&(pacl_list->acl_node_q.queue)); + pacl_list->num = 0; + pacl_list->mode = 0; + for (i = 0; i < NUM_ACL; i++) { + INIT_LIST_HEAD(&pacl_list->aclnode[i].list); + pacl_list->aclnode[i].valid = false; + } +} + +void stop_ap_mode(struct adapter *padapter) +{ + struct list_head *phead, *plist; + struct rtw_wlan_acl_node *paclnode; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + pmlmepriv->update_bcn = false; + pmlmeext->bstart_bss = false; + + /* reset and init security priv , this can refine with rtw_reset_securitypriv */ + memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + + /* for ACL */ + spin_lock_bh(&pacl_node_q->lock); + phead = get_list_head(pacl_node_q); + plist = phead->next; + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; + + if (paclnode->valid) { + paclnode->valid = false; + + list_del_init(&paclnode->list); + + pacl_list->num--; + } + } + spin_unlock_bh(&pacl_node_q->lock); + + DBG_88E("%s, free acl_node_queue, num =%d\n", __func__, pacl_list->num); + + rtw_sta_flush(padapter); + + /* free_assoc_sta_resources */ + rtw_free_all_stainfo(padapter); + + psta = rtw_get_bcmc_stainfo(padapter); + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(padapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + + rtw_init_bcmc_stainfo(padapter); + + rtw_free_mlme_priv_ie_data(pmlmepriv); +} + +#endif /* CONFIG_88EU_AP_MODE */ diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c new file mode 100644 index 000000000000..1236f50dc22f --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -0,0 +1,1184 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_BR_EXT_C_ + +#include +#include +#include +#include +#include +#include + +#include +#include "rtw_br_ext.h" +#include +#include + +#ifndef csum_ipv6_magic +#include +#endif + +#include +#include +#include +#include + +#define NAT25_IPV4 01 +#define NAT25_IPV6 02 +#define NAT25_IPX 03 +#define NAT25_APPLE 04 +#define NAT25_PPPOE 05 + +#define RTL_RELAY_TAG_LEN (ETH_ALEN) +#define TAG_HDR_LEN 4 + +#define MAGIC_CODE 0x8186 +#define MAGIC_CODE_LEN 2 +#define WAIT_TIME_PPPOE 5 /* waiting time for pppoe server in sec */ + +/*----------------------------------------------------------------- + How database records network address: + 0 1 2 3 4 5 6 7 8 9 10 + |----|----|----|----|----|----|----|----|----|----|----| + IPv4 |type| | IP addr | + IPX |type| Net addr | Node addr | + IPX |type| Net addr |Sckt addr| + Apple |type| Network |node| + PPPoE |type| SID | AC MAC | +-----------------------------------------------------------------*/ + +/* Find a tag in pppoe frame and return the pointer */ +static inline unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) +{ + unsigned char *cur_ptr, *start_ptr; + unsigned short tagLen, tagType; + + start_ptr = cur_ptr = (unsigned char *)ph->tag; + while ((cur_ptr - start_ptr) < ntohs(ph->length)) { + /* prevent un-alignment access */ + tagType = (unsigned short)((cur_ptr[0] << 8) + cur_ptr[1]); + tagLen = (unsigned short)((cur_ptr[2] << 8) + cur_ptr[3]); + if (tagType == type) + return cur_ptr; + cur_ptr = cur_ptr + TAG_HDR_LEN + tagLen; + } + return NULL; +} + +static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) +{ + struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); + int data_len; + + data_len = tag->tag_len + TAG_HDR_LEN; + if (skb_tailroom(skb) < data_len) { + _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n"); + return -1; + } + + skb_put(skb, data_len); + /* have a room for new tag */ + memmove(((unsigned char *)ph->tag + data_len), (unsigned char *)ph->tag, ntohs(ph->length)); + ph->length = htons(ntohs(ph->length) + data_len); + memcpy((unsigned char *)ph->tag, tag, data_len); + return data_len; +} + +static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len) +{ + int tail_len; + unsigned long end, tail; + + if ((src+len) > skb_tail_pointer(skb) || skb->len < len) + return -1; + + tail = (unsigned long)skb_tail_pointer(skb); + end = (unsigned long)src+len; + if (tail < end) + return -1; + + tail_len = (int)(tail-end); + if (tail_len > 0) + memmove(src, src+len, tail_len); + + skb_trim(skb, skb->len-len); + return 0; +} + +static inline unsigned long __nat25_timeout(struct adapter *priv) +{ + unsigned long timeout; + + timeout = jiffies - NAT25_AGEING_TIME*HZ; + + return timeout; +} + +static inline int __nat25_has_expired(struct adapter *priv, + struct nat25_network_db_entry *fdb) +{ + if (time_before_eq(fdb->ageing_timer, __nat25_timeout(priv))) + return 1; + + return 0; +} + +static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, + unsigned int *ipAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPV4; + memcpy(networkAddr+7, (unsigned char *)ipAddr, 4); +} + +static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, + unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPX; + memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr+5, ipxNodeAddr, 6); +} + +static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, + unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPX; + memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); +} + +static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, + unsigned short *network, unsigned char *node) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_APPLE; + memcpy(networkAddr+1, (unsigned char *)network, 2); + networkAddr[3] = *node; +} + +static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, + unsigned char *ac_mac, unsigned short *sid) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_PPPOE; + memcpy(networkAddr+1, (unsigned char *)sid, 2); + memcpy(networkAddr+3, (unsigned char *)ac_mac, 6); +} + +static void __nat25_generate_ipv6_network_addr(unsigned char *networkAddr, + unsigned int *ipAddr) +{ + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); + + networkAddr[0] = NAT25_IPV6; + memcpy(networkAddr+1, (unsigned char *)ipAddr, 16); +} + +static unsigned char *scan_tlv(unsigned char *data, int len, unsigned char tag, unsigned char len8b) +{ + while (len > 0) { + if (*data == tag && *(data+1) == len8b && len >= len8b*8) + return data+2; + + len -= (*(data+1))*8; + data += (*(data+1))*8; + } + return NULL; +} + +static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char *replace_mac) +{ + struct icmp6hdr *icmphdr = (struct icmp6hdr *)data; + unsigned char *mac; + + if (icmphdr->icmp6_type == NDISC_ROUTER_SOLICITATION) { + if (len >= 8) { + mac = scan_tlv(&data[8], len-8, 1, 1); + if (mac) { + _DEBUG_INFO("Router Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_ROUTER_ADVERTISEMENT) { + if (len >= 16) { + mac = scan_tlv(&data[16], len-16, 1, 1); + if (mac) { + _DEBUG_INFO("Router Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_SOLICITATION) { + if (len >= 24) { + mac = scan_tlv(&data[24], len-24, 1, 1); + if (mac) { + _DEBUG_INFO("Neighbor Solicitation, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_NEIGHBOUR_ADVERTISEMENT) { + if (len >= 24) { + mac = scan_tlv(&data[24], len-24, 2, 1); + if (mac) { + _DEBUG_INFO("Neighbor Advertisement, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } else if (icmphdr->icmp6_type == NDISC_REDIRECT) { + if (len >= 40) { + mac = scan_tlv(&data[40], len-40, 2, 1); + if (mac) { + _DEBUG_INFO("Redirect, replace MAC From: %02x:%02x:%02x:%02x:%02x:%02x, To: %02x:%02x:%02x:%02x:%02x:%02x\n", + mac[0], mac[1], mac[2], mac[3], mac[4], mac[5], + replace_mac[0], replace_mac[1], replace_mac[2], replace_mac[3], replace_mac[4], replace_mac[5]); + memcpy(mac, replace_mac, 6); + return 1; + } + } + } + return 0; +} + +static inline int __nat25_network_hash(unsigned char *networkAddr) +{ + if (networkAddr[0] == NAT25_IPV4) { + unsigned long x; + + x = networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_IPX) { + unsigned long x; + + x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ + networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_APPLE) { + unsigned long x; + + x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_PPPOE) { + unsigned long x; + + x = networkAddr[0] ^ networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ networkAddr[6] ^ networkAddr[7] ^ networkAddr[8]; + + return x & (NAT25_HASH_SIZE - 1); + } else if (networkAddr[0] == NAT25_IPV6) { + unsigned long x; + + x = networkAddr[1] ^ networkAddr[2] ^ networkAddr[3] ^ networkAddr[4] ^ networkAddr[5] ^ + networkAddr[6] ^ networkAddr[7] ^ networkAddr[8] ^ networkAddr[9] ^ networkAddr[10] ^ + networkAddr[11] ^ networkAddr[12] ^ networkAddr[13] ^ networkAddr[14] ^ networkAddr[15] ^ + networkAddr[16]; + + return x & (NAT25_HASH_SIZE - 1); + } else { + unsigned long x = 0; + int i; + + for (i = 0; i < MAX_NETWORK_ADDR_LEN; i++) + x ^= networkAddr[i]; + + return x & (NAT25_HASH_SIZE - 1); + } +} + +static inline void __network_hash_link(struct adapter *priv, + struct nat25_network_db_entry *ent, int hash) +{ + /* Caller must spin_lock already! */ + ent->next_hash = priv->nethash[hash]; + if (ent->next_hash != NULL) + ent->next_hash->pprev_hash = &ent->next_hash; + priv->nethash[hash] = ent; + ent->pprev_hash = &priv->nethash[hash]; +} + +static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) +{ + /* Caller must spin_lock already! */ + *(ent->pprev_hash) = ent->next_hash; + if (ent->next_hash != NULL) + ent->next_hash->pprev_hash = ent->pprev_hash; + ent->next_hash = NULL; + ent->pprev_hash = NULL; +} + +static int __nat25_db_network_lookup_and_replace(struct adapter *priv, + struct sk_buff *skb, unsigned char *networkAddr) +{ + struct nat25_network_db_entry *db; + + spin_lock_bh(&priv->br_ext_lock); + + db = priv->nethash[__nat25_network_hash(networkAddr)]; + while (db != NULL) { + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { + if (!__nat25_has_expired(priv, db)) { + /* replace the destination mac address */ + memcpy(skb->data, db->macAddr, ETH_ALEN); + atomic_inc(&db->use_count); + + DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" + "%02x%02x%02x%02x%02x%02x\n", + db->macAddr[0], + db->macAddr[1], + db->macAddr[2], + db->macAddr[3], + db->macAddr[4], + db->macAddr[5], + db->networkAddr[0], + db->networkAddr[1], + db->networkAddr[2], + db->networkAddr[3], + db->networkAddr[4], + db->networkAddr[5], + db->networkAddr[6], + db->networkAddr[7], + db->networkAddr[8], + db->networkAddr[9], + db->networkAddr[10], + db->networkAddr[11], + db->networkAddr[12], + db->networkAddr[13], + db->networkAddr[14], + db->networkAddr[15], + db->networkAddr[16]); + } + spin_unlock_bh(&priv->br_ext_lock); + return 1; + } + db = db->next_hash; + } + spin_unlock_bh(&priv->br_ext_lock); + return 0; +} + +static void __nat25_db_network_insert(struct adapter *priv, + unsigned char *macAddr, unsigned char *networkAddr) +{ + struct nat25_network_db_entry *db; + int hash; + + spin_lock_bh(&priv->br_ext_lock); + hash = __nat25_network_hash(networkAddr); + db = priv->nethash[hash]; + while (db != NULL) { + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { + memcpy(db->macAddr, macAddr, ETH_ALEN); + db->ageing_timer = jiffies; + spin_unlock_bh(&priv->br_ext_lock); + return; + } + db = db->next_hash; + } + db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); + if (db == NULL) { + spin_unlock_bh(&priv->br_ext_lock); + return; + } + memcpy(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN); + memcpy(db->macAddr, macAddr, ETH_ALEN); + atomic_set(&db->use_count, 1); + db->ageing_timer = jiffies; + + __network_hash_link(priv, db, hash); + + spin_unlock_bh(&priv->br_ext_lock); +} + +static void __nat25_db_print(struct adapter *priv) +{ +} + +/* + * NAT2.5 interface + */ + +void nat25_db_cleanup(struct adapter *priv) +{ + int i; + + spin_lock_bh(&priv->br_ext_lock); + + for (i = 0; i < NAT25_HASH_SIZE; i++) { + struct nat25_network_db_entry *f; + f = priv->nethash[i]; + while (f != NULL) { + struct nat25_network_db_entry *g; + + g = f->next_hash; + if (priv->scdb_entry == f) { + memset(priv->scdb_mac, 0, ETH_ALEN); + memset(priv->scdb_ip, 0, 4); + priv->scdb_entry = NULL; + } + __network_hash_unlink(f); + kfree(f); + f = g; + } + } + spin_unlock_bh(&priv->br_ext_lock); +} + +void nat25_db_expire(struct adapter *priv) +{ + int i; + + spin_lock_bh(&priv->br_ext_lock); + + for (i = 0; i < NAT25_HASH_SIZE; i++) { + struct nat25_network_db_entry *f; + f = priv->nethash[i]; + + while (f != NULL) { + struct nat25_network_db_entry *g; + g = f->next_hash; + + if (__nat25_has_expired(priv, f)) { + if (atomic_dec_and_test(&f->use_count)) { + if (priv->scdb_entry == f) { + memset(priv->scdb_mac, 0, ETH_ALEN); + memset(priv->scdb_ip, 0, 4); + priv->scdb_entry = NULL; + } + __network_hash_unlink(f); + kfree(f); + } + } + f = g; + } + } + spin_unlock_bh(&priv->br_ext_lock); +} + +int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) +{ + unsigned short protocol; + unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; + unsigned int tmp; + + if (skb == NULL) + return -1; + + if ((method <= NAT25_MIN) || (method >= NAT25_MAX)) + return -1; + + protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); + + /*---------------------------------------------------*/ + /* Handle IP frame */ + /*---------------------------------------------------*/ + if (protocol == ETH_P_IP) { + struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); + + if (((unsigned char *)(iph) + (iph->ihl<<2)) >= (skb->data + ETH_HLEN + skb->len)) { + DEBUG_WARN("NAT25: malformed IP packet !\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + /* some multicast with source IP is all zero, maybe other case is illegal */ + /* in class A, B, C, host address is all zero or all one is illegal */ + if (iph->saddr == 0) + return 0; + tmp = be32_to_cpu(iph->saddr); + DEBUG_INFO("NAT25: Insert IP, SA =%08x, DA =%08x\n", tmp, iph->daddr); + __nat25_generate_ipv4_network_addr(networkAddr, &tmp); + /* record source IP address and , source mac address into db */ + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup IP, SA =%08x, DA =%08x\n", iph->saddr, iph->daddr); + tmp = be32_to_cpu(iph->daddr); + __nat25_generate_ipv4_network_addr(networkAddr, &tmp); + + if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) { + if (*((unsigned char *)&iph->daddr + 3) == 0xff) { + /* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */ + DEBUG_INFO("NAT25: Set DA as boardcast\n"); + memset(skb->data, 0xff, ETH_ALEN); + } else { + /* forward unknow IP packet to upper TCP/IP */ + DEBUG_INFO("NAT25: Replace DA with BR's MAC\n"); + if ((*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0) { + printk("Re-init netdev_br_init() due to br_mac == 0!\n"); + netdev_br_init(priv->pnetdev); + } + memcpy(skb->data, priv->br_mac, ETH_ALEN); + } + } + return 0; + default: + return -1; + } + } else if (protocol == ETH_P_ARP) { + /*---------------------------------------------------*/ + /* Handle ARP frame */ + /*---------------------------------------------------*/ + struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN); + unsigned char *arp_ptr = (unsigned char *)(arp + 1); + unsigned int *sender, *target; + + if (arp->ar_pro != __constant_htons(ETH_P_IP)) { + DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", be16_to_cpu(arp->ar_pro)); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return 0; /* skb_copy for all ARP frame */ + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert ARP, MAC =%02x%02x%02x%02x%02x%02x\n", arp_ptr[0], + arp_ptr[1], arp_ptr[2], arp_ptr[3], arp_ptr[4], arp_ptr[5]); + + /* change to ARP sender mac address to wlan STA address */ + memcpy(arp_ptr, GET_MY_HWADDR(priv), ETH_ALEN); + arp_ptr += arp->ar_hln; + sender = (unsigned int *)arp_ptr; + __nat25_generate_ipv4_network_addr(networkAddr, sender); + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup ARP\n"); + + arp_ptr += arp->ar_hln; + sender = (unsigned int *)arp_ptr; + arp_ptr += (arp->ar_hln + arp->ar_pln); + target = (unsigned int *)arp_ptr; + __nat25_generate_ipv4_network_addr(networkAddr, target); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + /* change to ARP target mac address to Lookup result */ + arp_ptr = (unsigned char *)(arp + 1); + arp_ptr += (arp->ar_hln + arp->ar_pln); + memcpy(arp_ptr, skb->data, ETH_ALEN); + return 0; + default: + return -1; + } + } else if ((protocol == ETH_P_IPX) || + (protocol <= ETH_FRAME_LEN)) { + /*---------------------------------------------------*/ + /* Handle IPX and Apple Talk frame */ + /*---------------------------------------------------*/ + unsigned char ipx_header[2] = {0xFF, 0xFF}; + struct ipxhdr *ipx = NULL; + struct elapaarp *ea = NULL; + struct ddpehdr *ddp = NULL; + unsigned char *framePtr = skb->data + ETH_HLEN; + + if (protocol == ETH_P_IPX) { + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet II)\n"); + ipx = (struct ipxhdr *)framePtr; + } else if (protocol <= ETH_FRAME_LEN) { + if (!memcmp(ipx_header, framePtr, 2)) { + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.3)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { + unsigned char ipx_8022_type = 0xE0; + unsigned char snap_8022_type = 0xAA; + + if (*framePtr == snap_8022_type) { + unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */ + unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */ + unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */ + + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet SNAP)\n"); + ipx = (struct ipxhdr *)framePtr; + } else if (!memcmp(aarp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ea = (struct elapaarp *)framePtr; + } else if (!memcmp(ddp_snap_id, framePtr, 5)) { + framePtr += 5; /* eliminate the SNAP header */ + + ddp = (struct ddpehdr *)framePtr; + } else { + DEBUG_WARN("NAT25: Protocol = Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], + framePtr[1], framePtr[2], framePtr[3], framePtr[4]); + return -1; + } + } else if (*framePtr == ipx_8022_type) { + framePtr += 3; /* eliminate the 802.2 header */ + + if (!memcmp(ipx_header, framePtr, 2)) { + DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.2)\n"); + ipx = (struct ipxhdr *)framePtr; + } else { + return -1; + } + } else { + return -1; + } + } + } else { + return -1; + } + + /* IPX */ + if (ipx != NULL) { + switch (method) { + case NAT25_CHECK: + if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) + DEBUG_INFO("NAT25: Check IPX skb_copy\n"); + return 0; + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert IPX, Dest =%08x,%02x%02x%02x%02x%02x%02x,%04x Source =%08x,%02x%02x%02x%02x%02x%02x,%04x\n", + ipx->ipx_dest.net, + ipx->ipx_dest.node[0], + ipx->ipx_dest.node[1], + ipx->ipx_dest.node[2], + ipx->ipx_dest.node[3], + ipx->ipx_dest.node[4], + ipx->ipx_dest.node[5], + ipx->ipx_dest.sock, + ipx->ipx_source.net, + ipx->ipx_source.node[0], + ipx->ipx_source.node[1], + ipx->ipx_source.node[2], + ipx->ipx_source.node[3], + ipx->ipx_source.node[4], + ipx->ipx_source.node[5], + ipx->ipx_source.sock); + + if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { + DEBUG_INFO("NAT25: Use IPX Net, and Socket as network addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); + + /* change IPX source node addr to wlan STA address */ + memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); + } else { + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); + } + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) { + DEBUG_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); + + __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* replace IPX destination node addr with Lookup destination MAC addr */ + memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); + } else { + __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + } + return 0; + default: + return -1; + } + } else if (ea != NULL) { + /* Sanity check fields. */ + if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { + DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + return 0; + case NAT25_INSERT: + /* change to AARP source mac address to wlan STA address */ + memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); + + DEBUG_INFO("NAT25: Insert AARP, Source =%d,%d Destination =%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); + + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup AARP, Source =%d,%d Destination =%d,%d\n", + ea->pa_src_net, + ea->pa_src_node, + ea->pa_dst_net, + ea->pa_dst_node); + + __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); + + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + + /* change to AARP destination mac address to Lookup result */ + memcpy(ea->hw_dst, skb->data, ETH_ALEN); + return 0; + default: + return -1; + } + } else if (ddp != NULL) { + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert DDP, Source =%d,%d Destination =%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); + + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup DDP, Source =%d,%d Destination =%d,%d\n", + ddp->deh_snet, + ddp->deh_snode, + ddp->deh_dnet, + ddp->deh_dnode); + __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + return 0; + default: + return -1; + } + } + + return -1; + } else if ((protocol == ETH_P_PPP_DISC) || + (protocol == ETH_P_PPP_SES)) { + /*---------------------------------------------------*/ + /* Handle PPPoE frame */ + /*---------------------------------------------------*/ + struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); + unsigned short *pMagic; + + switch (method) { + case NAT25_CHECK: + if (ph->sid == 0) + return 0; + return 1; + case NAT25_INSERT: + if (ph->sid == 0) { /* Discovery phase according to tag */ + if (ph->code == PADI_CODE || ph->code == PADR_CODE) { + if (priv->ethBrExtInfo.addPPPoETag) { + struct pppoe_tag *tag, *pOldTag; + unsigned char tag_buf[40]; + int old_tag_len = 0; + + tag = (struct pppoe_tag *)tag_buf; + pOldTag = (struct pppoe_tag *)__nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); + if (pOldTag) { /* if SID existed, copy old value and delete it */ + old_tag_len = ntohs(pOldTag->tag_len); + if (old_tag_len+TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN > sizeof(tag_buf)) { + DEBUG_ERR("SID tag length too long!\n"); + return -1; + } + + memcpy(tag->tag_data+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN, + pOldTag->tag_data, old_tag_len); + + if (skb_pull_and_merge(skb, (unsigned char *)pOldTag, TAG_HDR_LEN+old_tag_len) < 0) { + DEBUG_ERR("call skb_pull_and_merge() failed in PADI/R packet!\n"); + return -1; + } + ph->length = htons(ntohs(ph->length)-TAG_HDR_LEN-old_tag_len); + } + + tag->tag_type = PTT_RELAY_SID; + tag->tag_len = htons(MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN+old_tag_len); + + /* insert the magic_code+client mac in relay tag */ + pMagic = (unsigned short *)tag->tag_data; + *pMagic = htons(MAGIC_CODE); + memcpy(tag->tag_data+MAGIC_CODE_LEN, skb->data+ETH_ALEN, ETH_ALEN); + + /* Add relay tag */ + if (__nat25_add_pppoe_tag(skb, tag) < 0) + return -1; + + DEBUG_INFO("NAT25: Insert PPPoE, forward %s packet\n", + (ph->code == PADI_CODE ? "PADI" : "PADR")); + } else { /* not add relay tag */ + if (priv->pppoe_connection_in_progress && + memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) { + DEBUG_ERR("Discard PPPoE packet due to another PPPoE connection is in progress!\n"); + return -2; + } + + if (priv->pppoe_connection_in_progress == 0) + memcpy(priv->pppoe_addr, skb->data+ETH_ALEN, ETH_ALEN); + + priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; + } + } else { + return -1; + } + } else { /* session phase */ + DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name); + + __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid)); + + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + + __nat25_db_print(priv); + + if (!priv->ethBrExtInfo.addPPPoETag && + priv->pppoe_connection_in_progress && + !memcmp(skb->data+ETH_ALEN, priv->pppoe_addr, ETH_ALEN)) + priv->pppoe_connection_in_progress = 0; + } + return 0; + case NAT25_LOOKUP: + if (ph->code == PADO_CODE || ph->code == PADS_CODE) { + if (priv->ethBrExtInfo.addPPPoETag) { + struct pppoe_tag *tag; + unsigned char *ptr; + unsigned short tagType, tagLen; + int offset = 0; + + ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); + if (ptr == NULL) { + DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n"); + return -1; + } + + tag = (struct pppoe_tag *)ptr; + tagType = (unsigned short)((ptr[0] << 8) + ptr[1]); + tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]); + + if ((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) { + DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen); + return -1; + } + + pMagic = (unsigned short *)tag->tag_data; + if (ntohs(*pMagic) != MAGIC_CODE) { + DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n", + (ph->code == PADO_CODE ? "PADO" : "PADS")); + return -1; + } + + memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN); + + if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN) + offset = TAG_HDR_LEN; + + if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) { + DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n"); + return -1; + } + ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset)); + if (offset > 0) + tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN); + + DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n", + (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name); + } else { /* not add relay tag */ + if (!priv->pppoe_connection_in_progress) { + DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n"); + return -1; + } + memcpy(skb->data, priv->pppoe_addr, ETH_ALEN); + priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; + } + } else { + if (ph->sid != 0) { + DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name); + __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid)); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + __nat25_db_print(priv); + } else { + return -1; + } + } + return 0; + default: + return -1; + } + } else if (protocol == 0x888e) { + /*---------------------------------------------------*/ + /* Handle EAP frame */ + /*---------------------------------------------------*/ + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + return 0; + case NAT25_LOOKUP: + return 0; + default: + return -1; + } + } else if ((protocol == 0xe2ae) || (protocol == 0xe2af)) { + /*---------------------------------------------------*/ + /* Handle C-Media proprietary frame */ + /*---------------------------------------------------*/ + switch (method) { + case NAT25_CHECK: + return -1; + case NAT25_INSERT: + return 0; + case NAT25_LOOKUP: + return 0; + default: + return -1; + } + } else if (protocol == ETH_P_IPV6) { + /*------------------------------------------------*/ + /* Handle IPV6 frame */ + /*------------------------------------------------*/ + struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + ETH_HLEN); + + if (sizeof(*iph) >= (skb->len - ETH_HLEN)) { + DEBUG_WARN("NAT25: malformed IPv6 packet !\n"); + return -1; + } + + switch (method) { + case NAT25_CHECK: + if (skb->data[0] & 1) + return 0; + return -1; + case NAT25_INSERT: + DEBUG_INFO("NAT25: Insert IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x," + " DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", + iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], + iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], + iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], + iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); + + if (memcmp(&iph->saddr, "\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0\x0", 16)) { + __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->saddr); + __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); + __nat25_db_print(priv); + + if (iph->nexthdr == IPPROTO_ICMPV6 && + skb->len > (ETH_HLEN + sizeof(*iph) + 4)) { + if (update_nd_link_layer_addr(skb->data + ETH_HLEN + sizeof(*iph), + skb->len - ETH_HLEN - sizeof(*iph), GET_MY_HWADDR(priv))) { + struct icmp6hdr *hdr = (struct icmp6hdr *)(skb->data + ETH_HLEN + sizeof(*iph)); + hdr->icmp6_cksum = 0; + hdr->icmp6_cksum = csum_ipv6_magic(&iph->saddr, &iph->daddr, + iph->payload_len, + IPPROTO_ICMPV6, + csum_partial((__u8 *)hdr, iph->payload_len, 0)); + } + } + } + return 0; + case NAT25_LOOKUP: + DEBUG_INFO("NAT25: Lookup IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x, DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", + iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], + iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], + iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], + iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); + __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr); + __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); + return 0; + default: + return -1; + } + } + return -1; +} + +int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb) +{ + if (!(skb->data[0] & 1)) { + int is_vlan_tag = 0, i, retval = 0; + unsigned short vlan_hdr = 0; + unsigned short protocol; + + protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); + if (protocol == ETH_P_8021Q) { + is_vlan_tag = 1; + vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2)); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2)); + skb_pull(skb, 4); + } + + if (!priv->ethBrExtInfo.nat25_disable) { + spin_lock_bh(&priv->br_ext_lock); + /* + * This function look up the destination network address from + * the NAT2.5 database. Return value = -1 means that the + * corresponding network protocol is NOT support. + */ + if (!priv->ethBrExtInfo.nat25sc_disable && + (be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && + !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) { + memcpy(skb->data, priv->scdb_mac, ETH_ALEN); + + spin_unlock_bh(&priv->br_ext_lock); + } else { + spin_unlock_bh(&priv->br_ext_lock); + + retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); + } + } else { + if (((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && + !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) || + ((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_ARP) && + !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) { + /* for traffic to upper TCP/IP */ + retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); + } + } + + if (is_vlan_tag) { + skb_push(skb, 4); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); + *((__be16 *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr; + } + + if (retval == -1) { + /* DEBUG_ERR("NAT25: Lookup fail!\n"); */ + return -1; + } + } + + return 0; +} + +#define SERVER_PORT 67 +#define CLIENT_PORT 68 +#define DHCP_MAGIC 0x63825363 +#define BROADCAST_FLAG 0x8000 + +struct dhcpMessage { + u_int8_t op; + u_int8_t htype; + u_int8_t hlen; + u_int8_t hops; + u_int32_t xid; + u_int16_t secs; + u_int16_t flags; + u_int32_t ciaddr; + u_int32_t yiaddr; + u_int32_t siaddr; + u_int32_t giaddr; + u_int8_t chaddr[16]; + u_int8_t sname[64]; + u_int8_t file[128]; + u_int32_t cookie; + u_int8_t options[308]; /* 312 - cookie */ +}; + +void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) +{ + if (skb == NULL) + return; + + if (!priv->ethBrExtInfo.dhcp_bcst_disable) { + __be16 protocol = *((__be16 *)(skb->data + 2 * ETH_ALEN)); + + if (protocol == __constant_htons(ETH_P_IP)) { /* IP */ + struct iphdr *iph = (struct iphdr *)(skb->data + ETH_HLEN); + + if (iph->protocol == IPPROTO_UDP) { /* UDP */ + struct udphdr *udph = (struct udphdr *)((size_t)iph + (iph->ihl << 2)); + + if ((udph->source == __constant_htons(CLIENT_PORT)) && + (udph->dest == __constant_htons(SERVER_PORT))) { /* DHCP request */ + struct dhcpMessage *dhcph = + (struct dhcpMessage *)((size_t)udph + sizeof(struct udphdr)); + u32 cookie = be32_to_cpu((__be32)dhcph->cookie); + + if (cookie == DHCP_MAGIC) { /* match magic word */ + if (!(dhcph->flags & htons(BROADCAST_FLAG))) { + /* if not broadcast */ + register int sum = 0; + + DEBUG_INFO("DHCP: change flag of DHCP request to broadcast.\n"); + /* or BROADCAST flag */ + dhcph->flags |= htons(BROADCAST_FLAG); + /* recalculate checksum */ + sum = ~(udph->check) & 0xffff; + sum += be16_to_cpu(dhcph->flags); + while (sum >> 16) + sum = (sum & 0xffff) + (sum >> 16); + udph->check = ~sum; + } + } + } + } + } + } +} + +void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, + unsigned char *ipAddr) +{ + unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; + struct nat25_network_db_entry *db; + int hash; + + __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr); + hash = __nat25_network_hash(networkAddr); + db = priv->nethash[hash]; + while (db != NULL) { + if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { + return (void *)db; + } + + db = db->next_hash; + } + + return NULL; +} diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c new file mode 100644 index 000000000000..3b76634f2090 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -0,0 +1,2206 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_CMD_C_ + +#include +#include +#include +#include +#include +#include +#include + +/* +Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. +No irqsave is necessary. +*/ + +int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) +{ + int res = _SUCCESS; + + sema_init(&(pcmdpriv->cmd_queue_sema), 0); + /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ + sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0); + + _rtw_init_queue(&(pcmdpriv->cmd_queue)); + + /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ + + pcmdpriv->cmd_seq = 1; + + pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, + GFP_KERNEL); + + if (pcmdpriv->cmd_allocated_buf == NULL) { + res = _FAIL; + goto exit; + } + + pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); + + pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL); + + if (pcmdpriv->rsp_allocated_buf == NULL) { + res = _FAIL; + goto exit; + } + + pcmdpriv->rsp_buf = pcmdpriv->rsp_allocated_buf + 4 - ((size_t)(pcmdpriv->rsp_allocated_buf) & 3); + + pcmdpriv->cmd_issued_cnt = 0; + pcmdpriv->cmd_done_cnt = 0; + pcmdpriv->rsp_cnt = 0; +exit: + + return res; +} + +static void c2h_wk_callback(struct work_struct *work); + +int _rtw_init_evt_priv(struct evt_priv *pevtpriv) +{ + int res = _SUCCESS; + + /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ + ATOMIC_SET(&pevtpriv->event_seq, 0); + pevtpriv->evt_done_cnt = 0; + + _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); + pevtpriv->c2h_wk_alive = false; + pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); + + return res; +} + +void rtw_free_evt_priv(struct evt_priv *pevtpriv) +{ + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+rtw_free_evt_priv\n")); + + _cancel_workitem_sync(&pevtpriv->c2h_wk); + while (pevtpriv->c2h_wk_alive) + rtw_msleep_os(10); + + while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { + void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); + if (c2h != NULL && c2h != (void *)pevtpriv) + kfree(c2h); + } + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-rtw_free_evt_priv\n")); + +} + +void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) +{ + + if (pcmdpriv) { + _rtw_spinlock_free(&(pcmdpriv->cmd_queue.lock)); + + if (pcmdpriv->cmd_allocated_buf) + kfree(pcmdpriv->cmd_allocated_buf); + + if (pcmdpriv->rsp_allocated_buf) + kfree(pcmdpriv->rsp_allocated_buf); + } + +} + +/* +Calling Context: + +rtw_enqueue_cmd can only be called between kernel thread, +since only spin_lock is used. + +ISR/Call-Back functions can't call this sub-function. + +*/ + +int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) +{ + unsigned long flags; + + if (obj == NULL) + goto exit; + + spin_lock_irqsave(&queue->lock, flags); + + list_add_tail(&obj->list, &queue->queue); + + spin_unlock_irqrestore(&queue->lock, flags); + +exit: + + return _SUCCESS; +} + +struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) +{ + struct cmd_obj *obj; + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + if (list_empty(&(queue->queue))) { + obj = NULL; + } else { + obj = container_of((&(queue->queue))->next, struct cmd_obj, list); + rtw_list_delete(&obj->list); + } + + spin_unlock_irqrestore(&queue->lock, flags); + + return obj; +} + +u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) +{ + u32 res; + + res = _rtw_init_cmd_priv (pcmdpriv); + + return res; +} + +u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) +{ + int res; + + res = _rtw_init_evt_priv(pevtpriv); + + return res; +} + +void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) +{ + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); + _rtw_free_cmd_priv(pcmdpriv); + +} + +static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) +{ + u8 bAllow = false; /* set to true to allow enqueuing cmd when hw_init_completed is false */ + + /* To decide allow or not */ + if ((pcmdpriv->padapter->pwrctrlpriv.bHWPwrPindetect) && + (!pcmdpriv->padapter->registrypriv.usbss_enable)) { + if (cmd_obj->cmdcode == GEN_CMD_CODE(_Set_Drv_Extra)) { + struct drvextra_cmd_parm *pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)cmd_obj->parmbuf; + if (pdrvextra_cmd_parm->ec_id == POWER_SAVING_CTRL_WK_CID) + bAllow = true; + } + } + + if (cmd_obj->cmdcode == GEN_CMD_CODE(_SetChannelPlan)) + bAllow = true; + + if ((!pcmdpriv->padapter->hw_init_completed && !bAllow) || + !pcmdpriv->cmdthd_running) /* com_thread not running */ + return _FAIL; + return _SUCCESS; +} + +u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) +{ + int res = _FAIL; + struct adapter *padapter = pcmdpriv->padapter; + + if (cmd_obj == NULL) + goto exit; + + cmd_obj->padapter = padapter; + + res = rtw_cmd_filter(pcmdpriv, cmd_obj); + if (_FAIL == res) { + rtw_free_cmd_obj(cmd_obj); + goto exit; + } + + res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); + + if (res == _SUCCESS) + up(&pcmdpriv->cmd_queue_sema); + +exit: + + return res; +} + +struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv) +{ + struct cmd_obj *cmd_obj; + + cmd_obj = _rtw_dequeue_cmd(&pcmdpriv->cmd_queue); + + return cmd_obj; +} + +void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv) +{ + + pcmdpriv->cmd_done_cnt++; + /* up(&(pcmdpriv->cmd_done_sema)); */ + +} + +void rtw_free_cmd_obj(struct cmd_obj *pcmd) +{ + + if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) { + /* free parmbuf in cmd_obj */ + kfree(pcmd->parmbuf); + } + + if (pcmd->rsp != NULL) { + if (pcmd->rspsz != 0) { + /* free rsp in cmd_obj */ + kfree(pcmd->rsp); + } + } + + /* free cmd_obj */ + kfree(pcmd); + +} + +int rtw_cmd_thread(void *context) +{ + u8 ret; + struct cmd_obj *pcmd; + u8 *pcmdbuf; + u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf); + void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd); + struct adapter *padapter = (struct adapter *)context; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + + thread_enter("RTW_CMD_THREAD"); + + pcmdbuf = pcmdpriv->cmd_buf; + + pcmdpriv->cmdthd_running = true; + up(&pcmdpriv->terminate_cmdthread_sema); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n")); + + while (1) { + if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL) + break; + + if (padapter->bDriverStopped || + padapter->bSurpriseRemoved) { + DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); + break; + } +_next: + if (padapter->bDriverStopped || + padapter->bSurpriseRemoved) { + DBG_88E("%s: DriverStopped(%d) SurpriseRemoved(%d) break at line %d\n", + __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, __LINE__); + break; + } + + pcmd = rtw_dequeue_cmd(pcmdpriv); + if (!pcmd) + continue; + + if (_FAIL == rtw_cmd_filter(pcmdpriv, pcmd)) { + pcmd->res = H2C_DROPPED; + goto post_process; + } + + pcmdpriv->cmd_issued_cnt++; + + pcmd->cmdsz = _RND4((pcmd->cmdsz));/* _RND4 */ + + memcpy(pcmdbuf, pcmd->parmbuf, pcmd->cmdsz); + + if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) { + cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; + + if (cmd_hdl) { + ret = cmd_hdl(pcmd->padapter, pcmdbuf); + pcmd->res = ret; + } + + pcmdpriv->cmd_seq++; + } else { + pcmd->res = H2C_PARAMETERS_ERROR; + } + + cmd_hdl = NULL; + +post_process: + + /* call callback function for post-processed */ + if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { + pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; + if (pcmd_callback == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); + rtw_free_cmd_obj(pcmd); + } else { + /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ + pcmd_callback(pcmd->padapter, pcmd);/* need conider that free cmd_obj in rtw_cmd_callback */ + } + } else { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode)); + rtw_free_cmd_obj(pcmd); + } + + flush_signals_thread(); + + goto _next; + } + pcmdpriv->cmdthd_running = false; + + /* free all cmd_obj resources */ + do { + pcmd = rtw_dequeue_cmd(pcmdpriv); + if (pcmd == NULL) + break; + + /* DBG_88E("%s: leaving... drop cmdcode:%u\n", __func__, pcmd->cmdcode); */ + + rtw_free_cmd_obj(pcmd); + } while (1); + + up(&pcmdpriv->terminate_cmdthread_sema); + + thread_exit(); +} + +u8 rtw_setstandby_cmd(struct adapter *padapter, uint action) +{ + struct cmd_obj *ph2c; + struct usb_suspend_parm *psetusbsuspend; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 ret = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + ret = _FAIL; + goto exit; + } + + psetusbsuspend = kzalloc(sizeof(struct usb_suspend_parm), GFP_ATOMIC); + if (psetusbsuspend == NULL) { + kfree(ph2c); + ret = _FAIL; + goto exit; + } + + psetusbsuspend->action = action; + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetusbsuspend, GEN_CMD_CODE(_SetUsbSuspend)); + + ret = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return ret; +} + +/* +rtw_sitesurvey_cmd(~) + ### NOTE:#### (!!!!) + MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock +*/ +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, + struct rtw_ieee80211_channel *ch, int ch_num) +{ + u8 res = _FAIL; + struct cmd_obj *ph2c; + struct sitesurvey_parm *psurveyPara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); + } + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1); + } + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) + return _FAIL; + + psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); + if (psurveyPara == NULL) { + kfree(ph2c); + return _FAIL; + } + + rtw_free_network_queue(padapter, false); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("%s: flush network queue\n", __func__)); + + init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); + + /* psurveyPara->bsslimit = 48; */ + psurveyPara->scan_mode = pmlmepriv->scan_mode; + + /* prepare ssid list */ + if (ssid) { + int i; + for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { + if (ssid[i].SsidLength) { + memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid)); + psurveyPara->ssid_num++; + if (0) + DBG_88E(FUNC_ADPT_FMT" ssid:(%s, %d)\n", FUNC_ADPT_ARG(padapter), + psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength); + } + } + } + + /* prepare channel list */ + if (ch) { + int i; + for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { + if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) { + memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); + psurveyPara->ch_num++; + if (0) + DBG_88E(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), + psurveyPara->ch[i].hw_value); + } + } + } + + set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + + if (res == _SUCCESS) { + pmlmepriv->scan_start_time = jiffies; + + _set_timer(&pmlmepriv->scan_to_timer, SCANNING_TIMEOUT); + + rtw_led_control(padapter, LED_CTL_SITE_SURVEY); + + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + } else { + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + } + + return res; +} + +u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) +{ + struct cmd_obj *ph2c; + struct setdatarate_parm *pbsetdataratepara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pbsetdataratepara = kzalloc(sizeof(struct setdatarate_parm), GFP_ATOMIC); + if (pbsetdataratepara == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pbsetdataratepara, GEN_CMD_CODE(_SetDataRate)); + pbsetdataratepara->mac_id = 5; + memcpy(pbsetdataratepara->datarates, rateset, NumRates); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset) +{ + struct cmd_obj *ph2c; + struct setbasicrate_parm *pssetbasicratepara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pssetbasicratepara = kzalloc(sizeof(struct setbasicrate_parm), GFP_ATOMIC); + + if (pssetbasicratepara == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pssetbasicratepara, _SetBasicRate_CMD_); + + memcpy(pssetbasicratepara->basicrates, rateset, NumRates); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +/* +unsigned char rtw_setphy_cmd(unsigned char *adapter) + +1. be called only after rtw_update_registrypriv_dev_network(~) or mp testing program +2. for AdHoc/Ap mode or mp mode? + +*/ +u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch) +{ + struct cmd_obj *ph2c; + struct setphy_parm *psetphypara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + psetphypara = kzalloc(sizeof(struct setphy_parm), GFP_ATOMIC); + + if (psetphypara == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetphypara, _SetPhy_CMD_); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("CH =%d, modem =%d", ch, modem)); + + psetphypara->modem = modem; + psetphypara->rfchannel = ch; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_setbbreg_cmd(struct adapter *padapter, u8 offset, u8 val) +{ + struct cmd_obj *ph2c; + struct writeBB_parm *pwritebbparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pwritebbparm = kzalloc(sizeof(struct writeBB_parm), GFP_ATOMIC); + + if (pwritebbparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pwritebbparm, GEN_CMD_CODE(_SetBBReg)); + + pwritebbparm->offset = offset; + pwritebbparm->value = val; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_getbbreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) +{ + struct cmd_obj *ph2c; + struct readBB_parm *prdbbparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + prdbbparm = kzalloc(sizeof(struct readBB_parm), GFP_ATOMIC); + + if (prdbbparm == NULL) { + kfree(ph2c); + return _FAIL; + } + + INIT_LIST_HEAD(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_GetBBReg); + ph2c->parmbuf = (unsigned char *)prdbbparm; + ph2c->cmdsz = sizeof(struct readBB_parm); + ph2c->rsp = pval; + ph2c->rspsz = sizeof(struct readBB_rsp); + + prdbbparm->offset = offset; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_setrfreg_cmd(struct adapter *padapter, u8 offset, u32 val) +{ + struct cmd_obj *ph2c; + struct writeRF_parm *pwriterfparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pwriterfparm = kzalloc(sizeof(struct writeRF_parm), GFP_ATOMIC); + + if (pwriterfparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, pwriterfparm, GEN_CMD_CODE(_SetRFReg)); + + pwriterfparm->offset = offset; + pwriterfparm->value = val; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_getrfreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) +{ + struct cmd_obj *ph2c; + struct readRF_parm *prdrfparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + prdrfparm = kzalloc(sizeof(struct readRF_parm), GFP_ATOMIC); + if (prdrfparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + INIT_LIST_HEAD(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_GetRFReg); + ph2c->parmbuf = (unsigned char *)prdrfparm; + ph2c->cmdsz = sizeof(struct readRF_parm); + ph2c->rsp = pval; + ph2c->rspsz = sizeof(struct readRF_rsp); + + prdrfparm->offset = offset; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +void rtw_getbbrfreg_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + + + kfree(pcmd->parmbuf); + kfree(pcmd); + + if (padapter->registrypriv.mp_mode == 1) + padapter->mppriv.workparam.bcompleted = true; + +} + +void rtw_readtssi_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + + + kfree(pcmd->parmbuf); + kfree(pcmd); + + if (padapter->registrypriv.mp_mode == 1) + padapter->mppriv.workparam.bcompleted = true; + +} + +u8 rtw_createbss_cmd(struct adapter *padapter) +{ + struct cmd_obj *pcmd; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; + u8 res = _SUCCESS; + + rtw_led_control(padapter, LED_CTL_START_TO_LINK); + + if (pmlmepriv->assoc_ssid.SsidLength == 0) + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + else + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } + + INIT_LIST_HEAD(&pcmd->list); + pcmd->cmdcode = _CreateBss_CMD_; + pcmd->parmbuf = (unsigned char *)pdev_network; + pcmd->cmdsz = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + pdev_network->Length = pcmd->cmdsz; + res = rtw_enqueue_cmd(pcmdpriv, pcmd); +exit: + + return res; +} + +u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, unsigned int sz) +{ + struct cmd_obj *pcmd; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } + + INIT_LIST_HEAD(&pcmd->list); + pcmd->cmdcode = GEN_CMD_CODE(_CreateBss); + pcmd->parmbuf = pbss; + pcmd->cmdsz = sz; + pcmd->rsp = NULL; + pcmd->rspsz = 0; + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); + +exit: + + return res; +} + +u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) +{ + u8 res = _SUCCESS; + uint t_len = 0; + struct wlan_bssid_ex *psecnetwork; + struct cmd_obj *pcmd; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + enum ndis_802_11_network_infra ndis_network_mode = pnetwork->network.InfrastructureMode; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + rtw_led_control(padapter, LED_CTL_START_TO_LINK); + + if (pmlmepriv->assoc_ssid.SsidLength == 0) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n")); + } else { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); + } + + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (pcmd == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); + goto exit; + } + /* for IEs is fix buf size */ + t_len = sizeof(struct wlan_bssid_ex); + + /* for hidden ap to set fw_state here */ + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { + switch (ndis_network_mode) { + case Ndis802_11IBSS: + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + break; + case Ndis802_11Infrastructure: + set_fwstate(pmlmepriv, WIFI_STATION_STATE); + break; + case Ndis802_11APMode: + case Ndis802_11AutoUnknown: + case Ndis802_11InfrastructureMax: + break; + } + } + + psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; + if (psecnetwork == NULL) { + if (pcmd != NULL) + kfree(pcmd); + + res = _FAIL; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd :psecnetwork == NULL!!!\n")); + + goto exit; + } + + memset(psecnetwork, 0, t_len); + + memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); + + psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; + + if ((psecnetwork->IELength-12) < (256-1)) { + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); + } else { + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); + } + + psecnetwork->IELength = 0; + /* Added by Albert 2009/02/18 */ + /* If the the driver wants to use the bssid to create the connection. */ + /* If not, we have to copy the connecting AP's MAC address to it so that */ + /* the driver just has the bssid information for PMKIDList searching. */ + + if (!pmlmepriv->assoc_by_bssid) + memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN); + + psecnetwork->IELength = rtw_restruct_sec_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength); + + pqospriv->qos_option = 0; + + if (pregistrypriv->wmm_enable) { + u32 tmp_len; + + tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], pnetwork->network.IELength, psecnetwork->IELength); + + if (psecnetwork->IELength != tmp_len) { + psecnetwork->IELength = tmp_len; + pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */ + } else { + pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */ + } + } + + phtpriv->ht_option = false; + if (pregistrypriv->ht_enable) { + /* Added by Albert 2010/06/23 */ + /* For the WEP mode, we will use the bg mode to do the connection to avoid some IOT issue. */ + /* Especially for Realtek 8192u SoftAP. */ + if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) && + (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) && + (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { + /* rtw_restructure_ht_ie */ + rtw_restructure_ht_ie(padapter, &pnetwork->network.IEs[0], &psecnetwork->IEs[0], + pnetwork->network.IELength, &psecnetwork->IELength); + } + } + + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.IEs, pnetwork->network.IELength); + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_TENDA) + padapter->pwrctrlpriv.smart_ps = 0; + else + padapter->pwrctrlpriv.smart_ps = padapter->registrypriv.smart_ps; + + DBG_88E("%s: smart_ps =%d\n", __func__, padapter->pwrctrlpriv.smart_ps); + + pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */ + + INIT_LIST_HEAD(&pcmd->list); + pcmd->cmdcode = _JoinBss_CMD_;/* GEN_CMD_CODE(_JoinBss) */ + pcmd->parmbuf = (unsigned char *)psecnetwork; + pcmd->rsp = NULL; + pcmd->rspsz = 0; + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); + +exit: + + return res; +} + +u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue) /* for sta_mode */ +{ + struct cmd_obj *cmdobj = NULL; + struct disconnect_parm *param = NULL; + struct cmd_priv *cmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); + + /* prepare cmd parameter */ + param = kzalloc(sizeof(*param), GFP_ATOMIC); + if (param == NULL) { + res = _FAIL; + goto exit; + } + param->deauth_timeout_ms = deauth_timeout_ms; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC); + if (cmdobj == NULL) { + res = _FAIL; + kfree(param); + goto exit; + } + init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); + res = rtw_enqueue_cmd(cmdpriv, cmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != disconnect_hdl(padapter, (u8 *)param)) + res = _FAIL; + kfree(param); + } + +exit: + + return res; +} + +u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype) +{ + struct cmd_obj *ph2c; + struct setopmode_parm *psetop; + + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (ph2c == NULL) { + res = false; + goto exit; + } + psetop = kzalloc(sizeof(struct setopmode_parm), GFP_KERNEL); + + if (psetop == NULL) { + kfree(ph2c); + res = false; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); + psetop->mode = (u8)networktype; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) +{ + struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct sta_info *sta = (struct sta_info *)psta; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); + if (psetstakey_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_KERNEL); + if (psetstakey_rsp == NULL) { + kfree(ph2c); + kfree(psetstakey_para); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + ph2c->rsp = (u8 *)psetstakey_rsp; + ph2c->rspsz = sizeof(struct set_stakey_rsp); + + memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm; + else + GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); + + if (unicast_key) + memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); + else + memcpy(&psetstakey_para->key, &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16); + + /* jeff: set this because at least sw key is ready */ + padapter->securitypriv.busetkipkey = true; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct set_stakey_rsp *psetstakey_rsp = NULL; + struct sta_info *sta = (struct sta_info *)psta; + u8 res = _SUCCESS; + + if (!enqueue) { + clear_cam_entry(padapter, entry); + } else { + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), + GFP_ATOMIC); + if (psetstakey_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), + GFP_ATOMIC); + if (psetstakey_rsp == NULL) { + kfree(ph2c); + kfree(psetstakey_para); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + ph2c->rsp = (u8 *)psetstakey_rsp; + ph2c->rspsz = sizeof(struct set_stakey_rsp); + + memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); + + psetstakey_para->algorithm = _NO_PRIVACY_; + + psetstakey_para->id = entry; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } +exit: + + return res; +} + +u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_table) +{ + struct cmd_obj *ph2c; + struct setratable_parm *psetrttblparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + psetrttblparm = kzalloc(sizeof(struct setratable_parm), GFP_KERNEL); + + if (psetrttblparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); + + memcpy(psetrttblparm, prate_table, sizeof(struct setratable_parm)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval) +{ + struct cmd_obj *ph2c; + struct getratable_parm *pgetrttblparm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + pgetrttblparm = kzalloc(sizeof(struct getratable_parm), GFP_KERNEL); + + if (pgetrttblparm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + +/* init_h2fwcmd_w_parm_no_rsp(ph2c, psetrttblparm, GEN_CMD_CODE(_SetRaTable)); */ + + INIT_LIST_HEAD(&ph2c->list); + ph2c->cmdcode = GEN_CMD_CODE(_GetRaTable); + ph2c->parmbuf = (unsigned char *)pgetrttblparm; + ph2c->cmdsz = sizeof(struct getratable_parm); + ph2c->rsp = (u8 *)pval; + ph2c->rspsz = sizeof(struct getratable_rsp); + + pgetrttblparm->rsvd = 0x0; + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr) +{ + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct cmd_obj *ph2c; + struct set_assocsta_parm *psetassocsta_para; + struct set_stakey_rsp *psetassocsta_rsp = NULL; + + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetassocsta_para = kzalloc(sizeof(struct set_assocsta_parm), GFP_ATOMIC); + if (psetassocsta_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + psetassocsta_rsp = kzalloc(sizeof(struct set_assocsta_rsp), GFP_ATOMIC); + if (psetassocsta_rsp == NULL) { + kfree(ph2c); + kfree(psetassocsta_para); + return _FAIL; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetassocsta_para, _SetAssocSta_CMD_); + ph2c->rsp = (u8 *)psetassocsta_rsp; + ph2c->rspsz = sizeof(struct set_assocsta_rsp); + + memcpy(psetassocsta_para->addr, mac_addr, ETH_ALEN); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; + } + +u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) +{ + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct cmd_obj *ph2c; + struct addBaReq_parm *paddbareq_parm; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL); + if (paddbareq_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + paddbareq_parm->tid = tid; + memcpy(paddbareq_parm->addr, addr, ETH_ALEN); + + init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, GEN_CMD_CODE(_AddBAReq)); + + /* DBG_88E("rtw_addbareq_cmd, tid =%d\n", tid); */ + + /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID; + pdrvextra_cmd_parm->type_size = 0; + pdrvextra_cmd_parm->pbuf = (u8 *)padapter; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + /* rtw_enqueue_cmd(pcmdpriv, ph2c); */ + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue) +{ + struct cmd_obj *pcmdobj; + struct set_ch_parm *set_ch_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + + DBG_88E(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), ch, bw, ch_offset); + + /* check input parameter */ + + /* prepare cmd parameter */ + set_ch_parm = kzalloc(sizeof(*set_ch_parm), GFP_ATOMIC); + if (set_ch_parm == NULL) { + res = _FAIL; + goto exit; + } + set_ch_parm->ch = ch; + set_ch_parm->bw = bw; + set_ch_parm->ch_offset = ch_offset; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (pcmdobj == NULL) { + kfree(set_ch_parm); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, set_ch_parm, GEN_CMD_CODE(_SetChannel)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != set_ch_hdl(padapter, (u8 *)set_ch_parm)) + res = _FAIL; + + kfree(set_ch_parm); + } + + /* do something based on res... */ + +exit: + + DBG_88E(FUNC_NDEV_FMT" res:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), res); + + return res; +} + +u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) +{ + struct cmd_obj *pcmdobj; + struct SetChannelPlan_param *setChannelPlan_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n")); + + /* check input parameter */ + if (!rtw_is_channel_plan_valid(chplan)) { + res = _FAIL; + goto exit; + } + + /* prepare cmd parameter */ + setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param), + GFP_KERNEL); + if (setChannelPlan_param == NULL) { + res = _FAIL; + goto exit; + } + setChannelPlan_param->channel_plan = chplan; + + if (enqueue) { + /* need enqueue, prepare cmd_obj and enqueue */ + pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (pcmdobj == NULL) { + kfree(setChannelPlan_param); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, GEN_CMD_CODE(_SetChannelPlan)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + } else { + /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ + if (H2C_SUCCESS != set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param)) + res = _FAIL; + + kfree(setChannelPlan_param); + } + + /* do something based on res... */ + if (res == _SUCCESS) + padapter->mlmepriv.ChannelPlan = chplan; + +exit: + + return res; +} + +u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) +{ + struct cmd_obj *pcmdobj; + struct LedBlink_param *ledBlink_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); + + pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (pcmdobj == NULL) { + res = _FAIL; + goto exit; + } + + ledBlink_param = kzalloc(sizeof(struct LedBlink_param), GFP_ATOMIC); + if (ledBlink_param == NULL) { + kfree(pcmdobj); + res = _FAIL; + goto exit; + } + + ledBlink_param->pLed = pLed; + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, ledBlink_param, GEN_CMD_CODE(_LedBlink)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + +exit: + + return res; +} + +u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) +{ + struct cmd_obj *pcmdobj; + struct SetChannelSwitch_param *setChannelSwitch_param; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_csa_cmd\n")); + + pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (pcmdobj == NULL) { + res = _FAIL; + goto exit; + } + + setChannelSwitch_param = kzalloc(sizeof(struct SetChannelSwitch_param), + GFP_ATOMIC); + if (setChannelSwitch_param == NULL) { + kfree(pcmdobj); + res = _FAIL; + goto exit; + } + + setChannelSwitch_param->new_ch_no = new_ch_no; + + init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelSwitch_param, GEN_CMD_CODE(_SetChannelSwitch)); + res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); + +exit: + + return res; +} + +u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option) +{ + return _SUCCESS; +} + +static void traffic_status_watchdog(struct adapter *padapter) +{ + u8 bEnterPS; + u8 bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false; + u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false, bHigherBusyTxTraffic = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + /* */ + /* Determine if our traffic is busy now */ + /* */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100 || + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100) { + bBusyTraffic = true; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) + bRxBusyTraffic = true; + else + bTxBusyTraffic = true; + } + + /* Higher Tx/Rx data. */ + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 || + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) { + bHigherBusyTraffic = true; + + if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) + bHigherBusyRxTraffic = true; + else + bHigherBusyTxTraffic = true; + } + + /* check traffic for powersaving. */ + if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || + (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) + bEnterPS = false; + else + bEnterPS = true; + + /* LeisurePS only work in infra mode. */ + if (bEnterPS) + LPS_Enter(padapter); + else + LPS_Leave(padapter); + } else { + LPS_Leave(padapter); + } + + pmlmepriv->LinkDetectInfo.NumRxOkInPeriod = 0; + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod = 0; + pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; + pmlmepriv->LinkDetectInfo.bBusyTraffic = bBusyTraffic; + pmlmepriv->LinkDetectInfo.bTxBusyTraffic = bTxBusyTraffic; + pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; + pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic; +} + +static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) +{ + struct mlme_priv *pmlmepriv; + + padapter = (struct adapter *)pbuf; + pmlmepriv = &(padapter->mlmepriv); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + expire_timeout_chk(padapter); +#endif + + rtw_hal_sreset_xmit_status_check(padapter); + + linked_status_chk(padapter); + traffic_status_watchdog(padapter); + + rtw_hal_dm_watchdog(padapter); +} + +static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 mstatus; + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + return; + + switch (lps_ctrl_type) { + case LPS_CTRL_SCAN: + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + /* connect */ + LPS_Leave(padapter); + } + break; + case LPS_CTRL_JOINBSS: + LPS_Leave(padapter); + break; + case LPS_CTRL_CONNECT: + mstatus = 1;/* connect */ + /* Reset LPS Setting */ + padapter->pwrctrlpriv.LpsIdleCount = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + break; + case LPS_CTRL_DISCONNECT: + mstatus = 0;/* disconnect */ + LPS_Leave(padapter); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); + break; + case LPS_CTRL_SPECIAL_PACKET: + /* DBG_88E("LPS_CTRL_SPECIAL_PACKET\n"); */ + pwrpriv->DelayLPSLastTimeStamp = jiffies; + LPS_Leave(padapter); + break; + case LPS_CTRL_LEAVE: + LPS_Leave(padapter); + break; + default: + break; + } + +} + +u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + /* struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; */ + u8 res = _SUCCESS; + + /* if (!pwrctrlpriv->bLeisurePs) */ + /* return res; */ + + if (enqueue) { + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), + GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = LPS_CTRL_WK_CID; + pdrvextra_cmd_parm->type_size = lps_ctrl_type; + pdrvextra_cmd_parm->pbuf = NULL; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } else { + lps_ctrl_wk_hdl(padapter, lps_ctrl_type); + } + +exit: + + return res; +} + +static void rpt_timer_setting_wk_hdl(struct adapter *padapter, u16 min_time) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_RPT_TIMER_SETTING, (u8 *)(&min_time)); +} + +u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), + GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = RTP_TIMER_CFG_WK_CID; + pdrvextra_cmd_parm->type_size = min_time; + pdrvextra_cmd_parm->pbuf = NULL; + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + + return res; +} + +static void antenna_select_wk_hdl(struct adapter *padapter, u8 antenna) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); +} + +u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 support_ant_div; + u8 res = _SUCCESS; + + rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); + if (!support_ant_div) + return res; + + if (enqueue) { + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), + GFP_KERNEL); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = ANT_SELECT_WK_CID; + pdrvextra_cmd_parm->type_size = antenna; + pdrvextra_cmd_parm->pbuf = NULL; + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } else { + antenna_select_wk_hdl(padapter, antenna); + } +exit: + + return res; +} + +static void power_saving_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) +{ + rtw_ps_processor(padapter); +} + +#ifdef CONFIG_88EU_P2P +u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return res; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = P2P_PROTO_WK_CID; + pdrvextra_cmd_parm->type_size = intCmdType; /* As the command tppe. */ + pdrvextra_cmd_parm->pbuf = NULL; /* Must be NULL here */ + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} +#endif /* CONFIG_88EU_P2P */ + +u8 rtw_ps_cmd(struct adapter *padapter) +{ + struct cmd_obj *ppscmd; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + u8 res = _SUCCESS; + + ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ppscmd == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ppscmd); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID; + pdrvextra_cmd_parm->pbuf = NULL; + init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ppscmd); + +exit: + + return res; +} + +#ifdef CONFIG_88EU_AP_MODE + +static void rtw_chk_hi_queue_hdl(struct adapter *padapter) +{ + int cnt = 0; + struct sta_info *psta_bmc; + struct sta_priv *pstapriv = &padapter->stapriv; + + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (!psta_bmc) + return; + + if (psta_bmc->sleepq_len == 0) { + u8 val = 0; + + /* while ((rtw_read32(padapter, 0x414)&0x00ffff00)!= 0) */ + /* while ((rtw_read32(padapter, 0x414)&0x0000ff00)!= 0) */ + + rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + + while (!val) { + rtw_msleep_os(100); + + cnt++; + + if (cnt > 10) + break; + + rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); + } + + if (cnt <= 10) { + pstapriv->tim_bitmap &= ~BIT(0); + pstapriv->sta_dz_bitmap &= ~BIT(0); + + update_beacon(padapter, _TIM_IE_, NULL, false); + } else { /* re check again */ + rtw_chk_hi_queue_cmd(padapter); + } + } +} + +u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID; + pdrvextra_cmd_parm->type_size = 0; + pdrvextra_cmd_parm->pbuf = NULL; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); +exit: + return res; +} +#endif + +u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = C2H_WK_CID; + pdrvextra_cmd_parm->type_size = c2h_evt ? 16 : 0; + pdrvextra_cmd_parm->pbuf = c2h_evt; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +static s32 c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h_id_filter filter) +{ + s32 ret = _FAIL; + u8 buf[16]; + + if (!c2h_evt) { + /* No c2h event in cmd_obj, read c2h event before handling*/ + if (c2h_evt_read(adapter, buf) == _SUCCESS) { + c2h_evt = (struct c2h_evt_hdr *)buf; + + if (filter && filter(c2h_evt->id) == false) + goto exit; + + ret = rtw_hal_c2h_handler(adapter, c2h_evt); + } + } else { + if (filter && filter(c2h_evt->id) == false) + goto exit; + + ret = rtw_hal_c2h_handler(adapter, c2h_evt); + } +exit: + return ret; +} + +static void c2h_wk_callback(struct work_struct *work) +{ + struct evt_priv *evtpriv = container_of(work, struct evt_priv, c2h_wk); + struct adapter *adapter = container_of(evtpriv, struct adapter, evtpriv); + struct c2h_evt_hdr *c2h_evt; + c2h_id_filter ccx_id_filter = rtw_hal_c2h_id_filter_ccx(adapter); + + evtpriv->c2h_wk_alive = true; + + while (!rtw_cbuf_empty(evtpriv->c2h_queue)) { + if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { + /* This C2H event is read, clear it */ + c2h_evt_clear(adapter); + } else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) { + /* This C2H event is not read, read & clear now */ + if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) + continue; + } + + /* Special pointer to trigger c2h_evt_clear only */ + if ((void *)c2h_evt == (void *)evtpriv) + continue; + + if (!c2h_evt_exist(c2h_evt)) { + kfree(c2h_evt); + continue; + } + + if (ccx_id_filter(c2h_evt->id) == true) { + /* Handle CCX report here */ + rtw_hal_c2h_handler(adapter, c2h_evt); + kfree(c2h_evt); + } else { +#ifdef CONFIG_88EU_P2P + /* Enqueue into cmd_thread for others */ + rtw_c2h_wk_cmd(adapter, (u8 *)c2h_evt); +#endif + } + } + + evtpriv->c2h_wk_alive = false; +} + +u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct drvextra_cmd_parm *pdrvextra_cmd; + + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf; + + switch (pdrvextra_cmd->ec_id) { + case DYNAMIC_CHK_WK_CID: + dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); + break; + case POWER_SAVING_CTRL_WK_CID: + power_saving_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); + break; + case LPS_CTRL_WK_CID: + lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); + break; + case RTP_TIMER_CFG_WK_CID: + rpt_timer_setting_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; + case ANT_SELECT_WK_CID: + antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; +#ifdef CONFIG_88EU_P2P + case P2P_PS_WK_CID: + p2p_ps_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; + case P2P_PROTO_WK_CID: + /* Commented by Albert 2011/07/01 */ + /* I used the type_size as the type command */ + p2p_protocol_wk_hdl(padapter, pdrvextra_cmd->type_size); + break; +#endif +#ifdef CONFIG_88EU_AP_MODE + case CHECK_HIQ_WK_CID: + rtw_chk_hi_queue_hdl(padapter); + break; +#endif /* CONFIG_88EU_AP_MODE */ + case C2H_WK_CID: + c2h_evt_hdl(padapter, (struct c2h_evt_hdr *)pdrvextra_cmd->pbuf, NULL); + break; + default: + break; + } + + if (pdrvextra_cmd->pbuf && pdrvextra_cmd->type_size > 0) + kfree(pdrvextra_cmd->pbuf); + + return H2C_SUCCESS; +} + +void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (pcmd->res == H2C_DROPPED) { + /* TODO: cancel timer and do timeout handler directly... */ + /* need to make timeout handlerOS independent */ + _set_timer(&pmlmepriv->scan_to_timer, 1); + } else if (pcmd->res != H2C_SUCCESS) { + _set_timer(&pmlmepriv->scan_to_timer, 1); + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n.")); + } + + /* free cmd */ + rtw_free_cmd_obj(pcmd); + +} +void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (pcmd->res != H2C_SUCCESS) { + spin_lock_bh(&pmlmepriv->lock); + set_fwstate(pmlmepriv, _FW_LINKED); + spin_unlock_bh(&pmlmepriv->lock); + + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ***Error: disconnect_cmd_callback Fail ***\n.")); + return; + } else /* clear bridge database */ + nat25_db_cleanup(padapter); + + /* free cmd */ + rtw_free_cmd_obj(pcmd); +} + +void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (pcmd->res == H2C_DROPPED) { + /* TODO: cancel timer and do timeout handler directly... */ + /* need to make timeout handlerOS independent */ + _set_timer(&pmlmepriv->assoc_timer, 1); + } else if (pcmd->res != H2C_SUCCESS) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("********Error:rtw_select_and_join_from_scanned_queue Wait Sema Fail ************\n")); + _set_timer(&pmlmepriv->assoc_timer, 1); + } + + rtw_free_cmd_obj(pcmd); +} + +void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + u8 timer_cancelled; + struct sta_info *psta = NULL; + struct wlan_network *pwlan = NULL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; + struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + + if ((pcmd->res != H2C_SUCCESS)) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n.")); + _set_timer(&pmlmepriv->assoc_timer, 1); + } + + _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); + + spin_lock_bh(&pmlmepriv->lock); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); + if (!psta) { + psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); + if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); + goto createbss_cmd_fail ; + } + } + + rtw_indicate_connect(padapter); + } else { + + pwlan = _rtw_alloc_network(pmlmepriv); + spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + if (pwlan == NULL) { + pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); + if (pwlan == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n")); + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + goto createbss_cmd_fail; + } + pwlan->last_scanned = jiffies; + } else { + list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); + } + + pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); + memcpy(&(pwlan->network), pnetwork, pnetwork->Length); + + memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork))); + + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + /* we will set _FW_LINKED when there is one more sat to join us (rtw_stassoc_event_callback) */ + } + +createbss_cmd_fail: + + spin_unlock_bh(&pmlmepriv->lock); + + rtw_free_cmd_obj(pcmd); + +} + +void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp); + struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); + + if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); + goto exit; + } +exit: + rtw_free_cmd_obj(pcmd); + +} + +void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf); + struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); + struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); + + if (psta == NULL) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); + goto exit; + } + + psta->aid = passocsta_rsp->cam_id; + psta->mac_id = passocsta_rsp->cam_id; + + spin_lock_bh(&pmlmepriv->lock); + + if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)) + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + set_fwstate(pmlmepriv, _FW_LINKED); + spin_unlock_bh(&pmlmepriv->lock); + +exit: + rtw_free_cmd_obj(pcmd); + +} diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c new file mode 100644 index 000000000000..47e5f7cf8453 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -0,0 +1,943 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_DEBUG_C_ + +#include +#include + +int proc_get_drv_version(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + int len = 0; + + len += snprintf(page + len, count - len, "%s\n", DRIVERVERSION); + + *eof = 1; + return len; +} + +int proc_get_write_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + *eof = 1; + return 0; +} + +int proc_set_write_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 addr, val, len; + + if (count < 3) { + DBG_88E("argument size is less than 3\n"); + return -EFAULT; + } + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%x %x %x", &addr, &val, &len); + + if (num != 3) { + DBG_88E("invalid write_reg parameter!\n"); + return count; + } + switch (len) { + case 1: + rtw_write8(padapter, addr, (u8)val); + break; + case 2: + rtw_write16(padapter, addr, (u16)val); + break; + case 4: + rtw_write32(padapter, addr, val); + break; + default: + DBG_88E("error write length =%d", len); + break; + } + } + return count; +} + +static u32 proc_get_read_addr = 0xeeeeeeee; +static u32 proc_get_read_len = 0x4; + +int proc_get_read_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + int len = 0; + + if (proc_get_read_addr == 0xeeeeeeee) { + *eof = 1; + return len; + } + + switch (proc_get_read_len) { + case 1: + len += snprintf(page + len, count - len, "rtw_read8(0x%x)=0x%x\n", proc_get_read_addr, rtw_read8(padapter, proc_get_read_addr)); + break; + case 2: + len += snprintf(page + len, count - len, "rtw_read16(0x%x)=0x%x\n", proc_get_read_addr, rtw_read16(padapter, proc_get_read_addr)); + break; + case 4: + len += snprintf(page + len, count - len, "rtw_read32(0x%x)=0x%x\n", proc_get_read_addr, rtw_read32(padapter, proc_get_read_addr)); + break; + default: + len += snprintf(page + len, count - len, "error read length=%d\n", proc_get_read_len); + break; + } + + *eof = 1; + return len; +} + +int proc_set_read_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + char tmp[16]; + u32 addr, len; + + if (count < 2) { + DBG_88E("argument size is less than 2\n"); + return -EFAULT; + } + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%x %x", &addr, &len); + + if (num != 2) { + DBG_88E("invalid read_reg parameter!\n"); + return count; + } + + proc_get_read_addr = addr; + + proc_get_read_len = len; + } + + return count; +} + +int proc_get_fwstate(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + + len += snprintf(page + len, count - len, "fwstate=0x%x\n", get_fwstate(pmlmepriv)); + + *eof = 1; + return len; +} + +int proc_get_sec_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct security_priv *psecuritypriv = &padapter->securitypriv; + + int len = 0; + + len += snprintf(page + len, count - len, "auth_alg=0x%x, enc_alg=0x%x, auth_type=0x%x, enc_type=0x%x\n", + psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, + psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); + + *eof = 1; + return len; +} + +int proc_get_mlmext_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + int len = 0; + + len += snprintf(page + len, count - len, "pmlmeinfo->state=0x%x\n", pmlmeinfo->state); + + *eof = 1; + return len; +} + +int proc_get_qos_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + + len += snprintf(page + len, count - len, "qos_option=%d\n", pmlmepriv->qospriv.qos_option); + + *eof = 1; + return len; +} + +int proc_get_ht_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + int len = 0; + len += snprintf(page + len, count - len, "ht_option=%d\n", pmlmepriv->htpriv.ht_option); + *eof = 1; + return len; +} + +int proc_get_rf_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + int len = 0; + + len += snprintf(page + len, count - len, "cur_ch=%d, cur_bw=%d, cur_ch_offet=%d\n", + pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + *eof = 1; + return len; +} + +int proc_get_ap_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct sta_info *psta; + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct sta_priv *pstapriv = &padapter->stapriv; + int len = 0; + + psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (psta) { + int i; + struct recv_reorder_ctrl *preorder_ctrl; + + len += snprintf(page + len, count - len, "SSID=%s\n", cur_network->network.Ssid.Ssid); + len += snprintf(page + len, count - len, "sta's macaddr:%pM\n", psta->hwaddr); + len += snprintf(page + len, count - len, "cur_channel=%d, cur_bwmode=%d, cur_ch_offset=%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); + len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + if (preorder_ctrl->enable) + len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", i, preorder_ctrl->indicate_seq); + } + } else { + len += snprintf(page + len, count - len, "can't get sta's macaddr, cur_network's macaddr: %pM\n", cur_network->network.MacAddress); + } + + *eof = 1; + return len; +} + +int proc_get_adapter_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + + len += snprintf(page + len, count - len, "bSurpriseRemoved=%d, bDriverStopped=%d\n", + padapter->bSurpriseRemoved, padapter->bDriverStopped); + + *eof = 1; + return len; +} + +int proc_get_trx_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct recv_priv *precvpriv = &padapter->recvpriv; + int len = 0; + + len += snprintf(page + len, count - len, "free_xmitbuf_cnt=%d, free_xmitframe_cnt=%d, free_ext_xmitbuf_cnt=%d, free_recvframe_cnt=%d\n", + pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt, precvpriv->free_recvframe_cnt); + len += snprintf(page + len, count - len, "rx_urb_pending_cn=%d\n", precvpriv->rx_pending_cnt); + + *eof = 1; + return len; +} + +int proc_get_mac_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_mac_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + memset(page, 0, count); + for (i = 0x300; i < 0x600; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_mac_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); + + for (i = 0x600; i < 0x800; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for (i = 0x800; i < 0xB00; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for (i = 0xB00; i < 0xE00; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_bb_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1; + + len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); + for (i = 0xE00; i < 0x1000; i += 4) { + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x", i); + len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 1; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0; i < 0xC0; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 1; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0xC0; i < 0x100; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 2; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0; i < 0xC0; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + + *eof = 1; + return len; +} + +int proc_get_rf_reg_dump4(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + int i, j = 1, path; + u32 value; + + len += snprintf(page + len, count - len, "\n======= RF REG =======\n"); + path = 2; + len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); + for (i = 0xC0; i < 0x100; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + len += snprintf(page + len, count - len, "0x%02x ", i); + len += snprintf(page + len, count - len, " 0x%08x ", value); + if ((j++)%4 == 0) + len += snprintf(page + len, count - len, "\n"); + } + *eof = 1; + return len; +} + +int proc_get_rx_signal(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int len = 0; + + len = snprintf(page + len, count, + "rssi:%d\n" + "rxpwdb:%d\n" + "signal_strength:%u\n" + "signal_qual:%u\n" + "noise:%u\n", + padapter->recvpriv.rssi, + padapter->recvpriv.rxpwdb, + padapter->recvpriv.signal_strength, + padapter->recvpriv.signal_qual, + padapter->recvpriv.noise + ); + + *eof = 1; + return len; +} + +int proc_set_rx_signal(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 is_signal_dbg; + s32 signal_strength; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%u %u", &is_signal_dbg, &signal_strength); + is_signal_dbg = is_signal_dbg == 0 ? 0 : 1; + if (is_signal_dbg && num != 2) + return count; + + signal_strength = signal_strength > 100 ? 100 : signal_strength; + signal_strength = signal_strength < 0 ? 0 : signal_strength; + + padapter->recvpriv.is_signal_dbg = is_signal_dbg; + padapter->recvpriv.signal_strength_dbg = signal_strength; + + if (is_signal_dbg) + DBG_88E("set %s %u\n", "DBG_SIGNAL_STRENGTH", signal_strength); + else + DBG_88E("set %s\n", "HW_SIGNAL_STRENGTH"); + } + return count; +} + +int proc_get_ht_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->ht_enable + ); + *eof = 1; + return len; +} + +int proc_set_ht_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + s32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->ht_enable = mode; + pr_info("ht_enable=%d\n", pregpriv->ht_enable); + } + } + + return count; +} + +int proc_get_cbw40_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->cbw40_enable + ); + + *eof = 1; + return len; +} + +int proc_set_cbw40_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + s32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->cbw40_enable = mode; + pr_info("cbw40_enable=%d\n", mode); + } + } + return count; +} + +int proc_get_ampdu_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->ampdu_enable + ); + + *eof = 1; + return len; +} + +int proc_set_ampdu_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + s32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->ampdu_enable = mode; + pr_info("ampdu_enable=%d\n", mode); + } + } + return count; +} + +int proc_get_two_path_rssi(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + int len = 0; + + if (padapter) + len += snprintf(page + len, count - len, + "%d %d\n", + padapter->recvpriv.RxRssi[0], + padapter->recvpriv.RxRssi[1] + ); + + *eof = 1; + return len; +} + +int proc_get_rx_stbc(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + + int len = 0; + + if (pregpriv) + len += snprintf(page + len, count - len, + "%d\n", + pregpriv->rx_stbc + ); + + *eof = 1; + return len; +} + +int proc_set_rx_stbc(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct registry_priv *pregpriv = &padapter->registrypriv; + char tmp[32]; + u32 mode = 0; + + if (count < 1) + return -EFAULT; + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + if (pregpriv) { + pregpriv->rx_stbc = mode; + printk("rx_stbc=%d\n", mode); + } + } + return count; +} + +int proc_get_rssi_disp(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + *eof = 1; + return 0; +} + +int proc_set_rssi_disp(struct file *file, const char __user *buffer, + unsigned long count, void *data) +{ + struct net_device *dev = (struct net_device *)data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + char tmp[32]; + u32 enable = 0; + + if (count < 1) { + DBG_88E("argument size is less than 1\n"); + return -EFAULT; + } + + if (buffer && !copy_from_user(tmp, buffer, sizeof(tmp))) { + int num = sscanf(tmp, "%x", &enable); + + if (num != 1) { + DBG_88E("invalid set_rssi_disp parameter!\n"); + return count; + } + + if (enable) { + DBG_88E("Turn On Rx RSSI Display Function\n"); + padapter->bRxRSSIDisplay = enable ; + } else { + DBG_88E("Turn Off Rx RSSI Display Function\n"); + padapter->bRxRSSIDisplay = 0; + } + } + return count; +} + +#ifdef CONFIG_88EU_AP_MODE + +int proc_get_all_sta_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct sta_info *psta; + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct sta_priv *pstapriv = &padapter->stapriv; + int i, j; + struct list_head *plist, *phead; + struct recv_reorder_ctrl *preorder_ctrl; + int len = 0; + + len += snprintf(page + len, count - len, "sta_dz_bitmap=0x%x, tim_bitmap=0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); + + spin_lock_bh(&pstapriv->sta_hash_lock); + + for (i = 0; i < NUM_STA; i++) { + phead = &(pstapriv->sta_hash[i]); + plist = phead->next; + + while (phead != plist) { + psta = container_of(plist, struct sta_info, hash_list); + + plist = plist->next; + + len += snprintf(page + len, count - len, "sta's macaddr: %pM\n", psta->hwaddr); + len += snprintf(page + len, count - len, "rtsen=%d, cts2slef=%d\n", psta->rtsen, psta->cts2self); + len += snprintf(page + len, count - len, "state=0x%x, aid=%d, macid=%d, raid=%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + len += snprintf(page + len, count - len, "qos_en=%d, ht_en=%d, init_rate=%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + len += snprintf(page + len, count - len, "bwmode=%d, ch_offset=%d, sgi=%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + len += snprintf(page + len, count - len, "ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + len += snprintf(page + len, count - len, "agg_enable_bitmap=%x, candidate_tid_bitmap=%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + len += snprintf(page + len, count - len, "sleepq_len=%d\n", psta->sleepq_len); + len += snprintf(page + len, count - len, "capability=0x%x\n", psta->capability); + len += snprintf(page + len, count - len, "flags=0x%x\n", psta->flags); + len += snprintf(page + len, count - len, "wpa_psk=0x%x\n", psta->wpa_psk); + len += snprintf(page + len, count - len, "wpa2_group_cipher=0x%x\n", psta->wpa2_group_cipher); + len += snprintf(page + len, count - len, "wpa2_pairwise_cipher=0x%x\n", psta->wpa2_pairwise_cipher); + len += snprintf(page + len, count - len, "qos_info=0x%x\n", psta->qos_info); + len += snprintf(page + len, count - len, "dot118021XPrivacy=0x%x\n", psta->dot118021XPrivacy); + + for (j = 0; j < 16; j++) { + preorder_ctrl = &psta->recvreorder_ctrl[j]; + if (preorder_ctrl->enable) + len += snprintf(page + len, count - len, "tid=%d, indicate_seq=%d\n", j, preorder_ctrl->indicate_seq); + } + } + } + spin_unlock_bh(&pstapriv->sta_hash_lock); + + *eof = 1; + return len; +} +#endif + +int proc_get_best_channel(char *page, char **start, + off_t offset, int count, + int *eof, void *data) +{ + struct net_device *dev = data; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + int len = 0; + u32 i, best_channel_24G = 1, best_channel_5G = 36, index_24G = 0, index_5G = 0; + + for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { + if (pmlmeext->channel_set[i].ChannelNum == 1) + index_24G = i; + if (pmlmeext->channel_set[i].ChannelNum == 36) + index_5G = i; + } + + for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { + /* 2.4G */ + if (pmlmeext->channel_set[i].ChannelNum == 6) { + if (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_24G].rx_count) { + index_24G = i; + best_channel_24G = pmlmeext->channel_set[i].ChannelNum; + } + } + + /* 5G */ + if (pmlmeext->channel_set[i].ChannelNum >= 36 && + pmlmeext->channel_set[i].ChannelNum < 140) { + /* Find primary channel */ + if (((pmlmeext->channel_set[i].ChannelNum - 36) % 8 == 0) && + (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) { + index_5G = i; + best_channel_5G = pmlmeext->channel_set[i].ChannelNum; + } + } + + if (pmlmeext->channel_set[i].ChannelNum >= 149 && + pmlmeext->channel_set[i].ChannelNum < 165) { + /* find primary channel */ + if (((pmlmeext->channel_set[i].ChannelNum - 149) % 8 == 0) && + (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) { + index_5G = i; + best_channel_5G = pmlmeext->channel_set[i].ChannelNum; + } + } + /* debug */ + len += snprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n", + pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count); + } + + len += snprintf(page + len, count - len, "best_channel_5G = %d\n", best_channel_5G); + len += snprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G); + + *eof = 1; + return len; +} diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c new file mode 100644 index 000000000000..53b73f442699 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -0,0 +1,872 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_EFUSE_C_ + +#include +#include +#include + +/*------------------------Define local variable------------------------------*/ +u8 fakeEfuseBank; +u32 fakeEfuseUsedBytes; +u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE] = {0}; +u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN] = {0}; +u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN] = {0}; + +u32 BTEfuseUsedBytes; +u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; + +u32 fakeBTEfuseUsedBytes; +u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; +/*------------------------Define local variable------------------------------*/ + +/* */ +#define REG_EFUSE_CTRL 0x0030 +#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ +/* */ + +bool +Efuse_Read1ByteFromFakeContent( + struct adapter *pAdapter, + u16 Offset, + u8 *Value); +bool +Efuse_Read1ByteFromFakeContent( + struct adapter *pAdapter, + u16 Offset, + u8 *Value) +{ + if (Offset >= EFUSE_MAX_HW_SIZE) + return false; + if (fakeEfuseBank == 0) + *Value = fakeEfuseContent[Offset]; + else + *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset]; + return true; +} + +static bool +Efuse_Write1ByteToFakeContent( + struct adapter *pAdapter, + u16 Offset, + u8 Value) +{ + if (Offset >= EFUSE_MAX_HW_SIZE) + return false; + if (fakeEfuseBank == 0) { + fakeEfuseContent[Offset] = Value; + } else { + fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value; + } + return true; +} + +/*----------------------------------------------------------------------------- + * Function: Efuse_PowerSwitch + * + * Overview: When we want to enable write operation, we should change to + * pwr on state. When we stop write, we should switch to 500k mode + * and disable LDO 2.5V. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/17/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void +Efuse_PowerSwitch( + struct adapter *pAdapter, + u8 write, + u8 PwrState) +{ + pAdapter->HalFunc.EfusePowerSwitch(pAdapter, write, PwrState); +} + +/*----------------------------------------------------------------------------- + * Function: efuse_GetCurrentSize + * + * Overview: Get current efuse size!!! + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/16/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +u16 +Efuse_GetCurrentSize( + struct adapter *pAdapter, + u8 efuseType, + bool pseudo) +{ + u16 ret = 0; + + ret = pAdapter->HalFunc.EfuseGetCurrentSize(pAdapter, efuseType, pseudo); + + return ret; +} + +/* 11/16/2008 MH Add description. Get current efuse area enabled word!!. */ +u8 +Efuse_CalculateWordCnts(u8 word_en) +{ + u8 word_cnts = 0; + if (!(word_en & BIT(0))) + word_cnts++; /* 0 : write enable */ + if (!(word_en & BIT(1))) + word_cnts++; + if (!(word_en & BIT(2))) + word_cnts++; + if (!(word_en & BIT(3))) + word_cnts++; + return word_cnts; +} + +/* */ +/* Description: */ +/* Execute E-Fuse read byte operation. */ +/* Referred from SD1 Richard. */ +/* */ +/* Assumption: */ +/* 1. Boot from E-Fuse and successfully auto-load. */ +/* 2. PASSIVE_LEVEL (USB interface) */ +/* */ +/* Created by Roger, 2008.10.21. */ +/* */ +void +ReadEFuseByte( + struct adapter *Adapter, + u16 _offset, + u8 *pbuf, + bool pseudo) +{ + u32 value32; + u8 readbyte; + u16 retry; + + if (pseudo) { + Efuse_Read1ByteFromFakeContent(Adapter, _offset, pbuf); + return; + } + + /* Write Address */ + rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); + readbyte = rtw_read8(Adapter, EFUSE_CTRL+2); + rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); + + /* Write bit 32 0 */ + readbyte = rtw_read8(Adapter, EFUSE_CTRL+3); + rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f)); + + /* Check bit 32 read-ready */ + retry = 0; + value32 = rtw_read32(Adapter, EFUSE_CTRL); + while (!(((value32 >> 24) & 0xff) & 0x80) && (retry < 10000)) { + value32 = rtw_read32(Adapter, EFUSE_CTRL); + retry++; + } + + /* 20100205 Joseph: Add delay suggested by SD1 Victor. */ + /* This fix the problem that Efuse read error in high temperature condition. */ + /* Designer says that there shall be some delay after ready bit is set, or the */ + /* result will always stay on last data we read. */ + rtw_udelay_os(50); + value32 = rtw_read32(Adapter, EFUSE_CTRL); + + *pbuf = (u8)(value32 & 0xff); +} + +/* */ +/* Description: */ +/* 1. Execute E-Fuse read byte operation according as map offset and */ +/* save to E-Fuse table. */ +/* 2. Referred from SD1 Richard. */ +/* */ +/* Assumption: */ +/* 1. Boot from E-Fuse and successfully auto-load. */ +/* 2. PASSIVE_LEVEL (USB interface) */ +/* */ +/* Created by Roger, 2008.10.21. */ +/* */ +/* 2008/12/12 MH 1. Reorganize code flow and reserve bytes. and add description. */ +/* 2. Add efuse utilization collect. */ +/* 2008/12/22 MH Read Efuse must check if we write section 1 data again!!! Sec1 */ +/* write addr must be after sec5. */ +/* */ + +static void efuse_ReadEFuse(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool pseudo) +{ + Adapter->HalFunc.ReadEFuse(Adapter, efuseType, _offset, _size_byte, pbuf, pseudo); +} + +void EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool pseudo + ) +{ + pAdapter->HalFunc.EFUSEGetEfuseDefinition(pAdapter, efuseType, type, pOut, pseudo); +} + +/*----------------------------------------------------------------------------- + * Function: EFUSE_Read1Byte + * + * Overview: Copy from WMAC fot EFUSE read 1 byte. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 09/23/2008 MHC Copy from WMAC. + * + *---------------------------------------------------------------------------*/ +u8 EFUSE_Read1Byte(struct adapter *Adapter, u16 Address) +{ + u8 data; + u8 Bytetemp = {0x00}; + u8 temp = {0x00}; + u32 k = 0; + u16 contentLen = 0; + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); + + if (Address < contentLen) { /* E-fuse 512Byte */ + /* Write E-fuse Register address bit0~7 */ + temp = Address & 0xFF; + rtw_write8(Adapter, EFUSE_CTRL+1, temp); + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2); + /* Write E-fuse Register address bit8~9 */ + temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); + rtw_write8(Adapter, EFUSE_CTRL+2, temp); + + /* Write 0x30[31]= 0 */ + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + temp = Bytetemp & 0x7F; + rtw_write8(Adapter, EFUSE_CTRL+3, temp); + + /* Wait Write-ready (0x30[31]= 1) */ + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + while (!(Bytetemp & 0x80)) { + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + k++; + if (k == 1000) { + k = 0; + break; + } + } + data = rtw_read8(Adapter, EFUSE_CTRL); + return data; + } else { + return 0xFF; + } + +} /* EFUSE_Read1Byte */ + +/* 11/16/2008 MH Read one byte from real Efuse. */ +u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data, bool pseudo) +{ + u8 tmpidx = 0; + u8 result; + + if (pseudo) { + result = Efuse_Read1ByteFromFakeContent(pAdapter, addr, data); + return result; + } + /* -----------------e-fuse reg ctrl --------------------------------- */ + /* address */ + rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr & 0xff)); + rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) & 0x03)) | + (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC)); + + rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ + + while (!(0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + tmpidx++; + if (tmpidx < 100) { + *data = rtw_read8(pAdapter, EFUSE_CTRL); + result = true; + } else { + *data = 0xff; + result = false; + } + return result; +} + +/* 11/16/2008 MH Write one byte to reald Efuse. */ +u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data, bool pseudo) +{ + u8 tmpidx = 0; + u8 result; + + if (pseudo) { + result = Efuse_Write1ByteToFakeContent(pAdapter, addr, data); + return result; + } + + /* -----------------e-fuse reg ctrl --------------------------------- */ + /* address */ + rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); + rtw_write8(pAdapter, EFUSE_CTRL+2, + (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC) | + (u8)((addr>>8) & 0x03)); + rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */ + + rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ + + while ((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + tmpidx++; + + if (tmpidx < 100) + result = true; + else + result = false; + + return result; +} + +int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool pseudo) +{ + int ret = 0; + + ret = pAdapter->HalFunc.Efuse_PgPacketRead(pAdapter, offset, data, pseudo); + + return ret; +} + +int Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool pseudo) +{ + int ret; + + ret = pAdapter->HalFunc.Efuse_PgPacketWrite(pAdapter, offset, word_en, data, pseudo); + + return ret; +} + +static int Efuse_PgPacketWrite_BT(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool pseudo) +{ + int ret; + + ret = pAdapter->HalFunc.Efuse_PgPacketWrite_BT(pAdapter, offset, word_en, data, pseudo); + + return ret; +} + +/*----------------------------------------------------------------------------- + * Function: efuse_WordEnableDataRead + * + * Overview: Read allowed word in current efuse section data. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/16/2008 MHC Create Version 0. + * 11/21/2008 MHC Fix Write bug when we only enable late word. + * + *---------------------------------------------------------------------------*/ +void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) +{ + if (!(word_en&BIT(0))) { + targetdata[0] = sourdata[0]; + targetdata[1] = sourdata[1]; + } + if (!(word_en&BIT(1))) { + targetdata[2] = sourdata[2]; + targetdata[3] = sourdata[3]; + } + if (!(word_en&BIT(2))) { + targetdata[4] = sourdata[4]; + targetdata[5] = sourdata[5]; + } + if (!(word_en&BIT(3))) { + targetdata[6] = sourdata[6]; + targetdata[7] = sourdata[7]; + } +} + +u8 Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool pseudo) +{ + u8 ret = 0; + + ret = pAdapter->HalFunc.Efuse_WordEnableDataWrite(pAdapter, efuse_addr, word_en, data, pseudo); + + return ret; +} + +static u8 efuse_read8(struct adapter *padapter, u16 address, u8 *value) +{ + return efuse_OneByteRead(padapter, address, value, false); +} + +static u8 efuse_write8(struct adapter *padapter, u16 address, u8 *value) +{ + return efuse_OneByteWrite(padapter, address, *value, false); +} + +/* + * read/wirte raw efuse data + */ +u8 rtw_efuse_access(struct adapter *padapter, u8 write, u16 start_addr, u16 cnts, u8 *data) +{ + int i = 0; + u16 real_content_len = 0, max_available_size = 0; + u8 res = _FAIL ; + u8 (*rw8)(struct adapter *, u16, u8*); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&real_content_len, false); + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + + if (start_addr > real_content_len) + return _FAIL; + + if (write) { + if ((start_addr + cnts) > max_available_size) + return _FAIL; + rw8 = &efuse_write8; + } else { + rw8 = &efuse_read8; + } + + Efuse_PowerSwitch(padapter, write, true); + + /* e-fuse one byte read / write */ + for (i = 0; i < cnts; i++) { + if (start_addr >= real_content_len) { + res = _FAIL; + break; + } + + res = rw8(padapter, start_addr++, data++); + if (_FAIL == res) + break; + } + + Efuse_PowerSwitch(padapter, write, false); + + return res; +} +/* */ +u16 efuse_GetMaxSize(struct adapter *padapter) +{ + u16 max_size; + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, false); + return max_size; +} +/* */ +u8 efuse_GetCurrentSize(struct adapter *padapter, u16 *size) +{ + Efuse_PowerSwitch(padapter, false, true); + *size = Efuse_GetCurrentSize(padapter, EFUSE_WIFI, false); + Efuse_PowerSwitch(padapter, false, false); + + return _SUCCESS; +} +/* */ +u8 rtw_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + Efuse_PowerSwitch(padapter, false, true); + + efuse_ReadEFuse(padapter, EFUSE_WIFI, addr, cnts, data, false); + + Efuse_PowerSwitch(padapter, false, false); + + return _SUCCESS; +} + +u8 rtw_BT_efuse_map_read(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + Efuse_PowerSwitch(padapter, false, true); + + efuse_ReadEFuse(padapter, EFUSE_BT, addr, cnts, data, false); + + Efuse_PowerSwitch(padapter, false, false); + + return _SUCCESS; +} +/* */ +u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u8 offset, word_en; + u8 *map; + u8 newdata[PGPKT_DATA_SIZE + 1]; + s32 i, idx; + u8 ret = _SUCCESS; + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + map = rtw_zmalloc(mapLen); + if (map == NULL) + return _FAIL; + + ret = rtw_efuse_map_read(padapter, 0, mapLen, map); + if (ret == _FAIL) + goto exit; + + Efuse_PowerSwitch(padapter, true, true); + + offset = (addr >> 3); + word_en = 0xF; + memset(newdata, 0xFF, PGPKT_DATA_SIZE + 1); + i = addr & 0x7; /* index of one package */ + idx = 0; /* data index */ + + if (i & 0x1) { + /* odd start */ + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i-1] = map[addr+idx-1]; + newdata[i] = data[idx]; + } + i++; + idx++; + } + do { + for (; i < PGPKT_DATA_SIZE; i += 2) { + if (cnts == idx) + break; + if ((cnts - idx) == 1) { + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = map[addr+idx+1]; + } + idx++; + break; + } else { + if ((data[idx] != map[addr+idx]) || + (data[idx+1] != map[addr+idx+1])) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = data[idx + 1]; + } + idx += 2; + } + if (idx == cnts) + break; + } + + if (word_en != 0xF) { + ret = Efuse_PgPacketWrite(padapter, offset, word_en, newdata, false); + DBG_88E("offset=%x\n", offset); + DBG_88E("word_en=%x\n", word_en); + + for (i = 0; i < PGPKT_DATA_SIZE; i++) + DBG_88E("data=%x \t", newdata[i]); + if (ret == _FAIL) + break; + } + + if (idx == cnts) + break; + + offset++; + i = 0; + word_en = 0xF; + memset(newdata, 0xFF, PGPKT_DATA_SIZE); + } while (1); + + Efuse_PowerSwitch(padapter, true, false); +exit: + kfree(map); + return ret; +} + +/* */ +u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) +{ + u8 offset, word_en; + u8 *map; + u8 newdata[PGPKT_DATA_SIZE + 1]; + s32 i, idx; + u8 ret = _SUCCESS; + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, false); + + if ((addr + cnts) > mapLen) + return _FAIL; + + map = rtw_zmalloc(mapLen); + if (map == NULL) + return _FAIL; + + ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map); + if (ret == _FAIL) + goto exit; + + Efuse_PowerSwitch(padapter, true, true); + + offset = (addr >> 3); + word_en = 0xF; + memset(newdata, 0xFF, PGPKT_DATA_SIZE + 1); + i = addr & 0x7; /* index of one package */ + idx = 0; /* data index */ + + if (i & 0x1) { + /* odd start */ + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i-1] = map[addr+idx-1]; + newdata[i] = data[idx]; + } + i++; + idx++; + } + do { + for (; i < PGPKT_DATA_SIZE; i += 2) { + if (cnts == idx) + break; + if ((cnts - idx) == 1) { + if (data[idx] != map[addr+idx]) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = map[addr+idx+1]; + } + idx++; + break; + } else { + if ((data[idx] != map[addr+idx]) || + (data[idx+1] != map[addr+idx+1])) { + word_en &= ~BIT(i >> 1); + newdata[i] = data[idx]; + newdata[i+1] = data[idx + 1]; + } + idx += 2; + } + if (idx == cnts) + break; + } + + if (word_en != 0xF) { + DBG_88E("%s: offset=%#X\n", __func__, offset); + DBG_88E("%s: word_en=%#X\n", __func__, word_en); + DBG_88E("%s: data=", __func__); + for (i = 0; i < PGPKT_DATA_SIZE; i++) + DBG_88E("0x%02X ", newdata[i]); + DBG_88E("\n"); + + ret = Efuse_PgPacketWrite_BT(padapter, offset, word_en, newdata, false); + if (ret == _FAIL) + break; + } + + if (idx == cnts) + break; + + offset++; + i = 0; + word_en = 0xF; + memset(newdata, 0xFF, PGPKT_DATA_SIZE); + } while (1); + + Efuse_PowerSwitch(padapter, true, false); + +exit: + + kfree(map); + + return ret; +} + +/*----------------------------------------------------------------------------- + * Function: efuse_ShadowRead1Byte + * efuse_ShadowRead2Byte + * efuse_ShadowRead4Byte + * + * Overview: Read from efuse init map by one/two/four bytes !!!!! + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/12/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void +efuse_ShadowRead1Byte( + struct adapter *pAdapter, + u16 Offset, + u8 *Value) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + + *Value = pEEPROM->efuse_eeprom_data[Offset]; + +} /* EFUSE_ShadowRead1Byte */ + +/* Read Two Bytes */ +static void +efuse_ShadowRead2Byte( + struct adapter *pAdapter, + u16 Offset, + u16 *Value) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + + *Value = pEEPROM->efuse_eeprom_data[Offset]; + *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; + +} /* EFUSE_ShadowRead2Byte */ + +/* Read Four Bytes */ +static void +efuse_ShadowRead4Byte( + struct adapter *pAdapter, + u16 Offset, + u32 *Value) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + + *Value = pEEPROM->efuse_eeprom_data[Offset]; + *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; + *Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16; + *Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24; + +} /* efuse_ShadowRead4Byte */ + +/*----------------------------------------------------------------------------- + * Function: Efuse_ReadAllMap + * + * Overview: Read All Efuse content + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/11/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 efuseType, u8 *Efuse, bool pseudo) +{ + u16 mapLen = 0; + + Efuse_PowerSwitch(pAdapter, false, true); + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + + efuse_ReadEFuse(pAdapter, efuseType, 0, mapLen, Efuse, pseudo); + + Efuse_PowerSwitch(pAdapter, false, false); +} + +/*----------------------------------------------------------------------------- + * Function: EFUSE_ShadowMapUpdate + * + * Overview: Transfer current EFUSE content to shadow init and modify map. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/13/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void EFUSE_ShadowMapUpdate( + struct adapter *pAdapter, + u8 efuseType, + bool pseudo) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); + u16 mapLen = 0; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_MAP_LEN, (void *)&mapLen, pseudo); + + if (pEEPROM->bautoload_fail_flag) + memset(pEEPROM->efuse_eeprom_data, 0xFF, mapLen); + else + Efuse_ReadAllMap(pAdapter, efuseType, pEEPROM->efuse_eeprom_data, pseudo); +} /* EFUSE_ShadowMapUpdate */ + +/*----------------------------------------------------------------------------- + * Function: EFUSE_ShadowRead + * + * Overview: Read from efuse init map !!!!! + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/12/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +void EFUSE_ShadowRead(struct adapter *pAdapter, u8 Type, u16 Offset, u32 *Value) +{ + if (Type == 1) + efuse_ShadowRead1Byte(pAdapter, Offset, (u8 *)Value); + else if (Type == 2) + efuse_ShadowRead2Byte(pAdapter, Offset, (u16 *)Value); + else if (Type == 4) + efuse_ShadowRead4Byte(pAdapter, Offset, (u32 *)Value); + +} /* EFUSE_ShadowRead */ diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c new file mode 100644 index 000000000000..7159ce4c1acd --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -0,0 +1,1625 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _IEEE80211_C + +#include +#include +#include +#include +#include +#include + +u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; +u16 RTW_WPA_VERSION = 1; +u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 }; +u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 }; +u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 }; +u8 WPA_CIPHER_SUITE_NONE[] = { 0x00, 0x50, 0xf2, 0 }; +u8 WPA_CIPHER_SUITE_WEP40[] = { 0x00, 0x50, 0xf2, 1 }; +u8 WPA_CIPHER_SUITE_TKIP[] = { 0x00, 0x50, 0xf2, 2 }; +u8 WPA_CIPHER_SUITE_WRAP[] = { 0x00, 0x50, 0xf2, 3 }; +u8 WPA_CIPHER_SUITE_CCMP[] = { 0x00, 0x50, 0xf2, 4 }; +u8 WPA_CIPHER_SUITE_WEP104[] = { 0x00, 0x50, 0xf2, 5 }; + +u16 RSN_VERSION_BSD = 1; +u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x0f, 0xac, 1 }; +u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x0f, 0xac, 2 }; +u8 RSN_CIPHER_SUITE_NONE[] = { 0x00, 0x0f, 0xac, 0 }; +u8 RSN_CIPHER_SUITE_WEP40[] = { 0x00, 0x0f, 0xac, 1 }; +u8 RSN_CIPHER_SUITE_TKIP[] = { 0x00, 0x0f, 0xac, 2 }; +u8 RSN_CIPHER_SUITE_WRAP[] = { 0x00, 0x0f, 0xac, 3 }; +u8 RSN_CIPHER_SUITE_CCMP[] = { 0x00, 0x0f, 0xac, 4 }; +u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 }; +/* */ +/* for adhoc-master to generate ie and provide supported-rate to fw */ +/* */ + +static u8 WIFI_CCKRATES[] = { + (IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK), + (IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK), + (IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK), + (IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK) + }; + +static u8 WIFI_OFDMRATES[] = { + (IEEE80211_OFDM_RATE_6MB), + (IEEE80211_OFDM_RATE_9MB), + (IEEE80211_OFDM_RATE_12MB), + (IEEE80211_OFDM_RATE_18MB), + (IEEE80211_OFDM_RATE_24MB), + IEEE80211_OFDM_RATE_36MB, + IEEE80211_OFDM_RATE_48MB, + IEEE80211_OFDM_RATE_54MB + }; + +int rtw_get_bit_value_from_ieee_value(u8 val) +{ + unsigned char dot11_rate_table[] = { + 2, 4, 11, 22, 12, 18, 24, 36, 48, + 72, 96, 108, 0}; /* last element must be zero!! */ + + int i = 0; + while (dot11_rate_table[i] != 0) { + if (dot11_rate_table[i] == val) + return BIT(i); + i++; + } + return 0; +} + +uint rtw_is_cckrates_included(u8 *rate) +{ + u32 i = 0; + + while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; + i++; + } + return false; +} + +uint rtw_is_cckratesonly_included(u8 *rate) +{ + u32 i = 0; + + while (rate[i] != 0) { + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + return false; + i++; + } + + return true; +} + +int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) +{ + if (channel > 14) { + if ((rtw_is_cckrates_included(rate)) == true) + return WIRELESS_INVALID; + else + return WIRELESS_11A; + } else { /* could be pure B, pure G, or B/G */ + if ((rtw_is_cckratesonly_included(rate)) == true) + return WIRELESS_11B; + else if ((rtw_is_cckrates_included(rate)) == true) + return WIRELESS_11BG; + else + return WIRELESS_11G; + } +} + +u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, unsigned char *source, + unsigned int *frlen) +{ + memcpy((void *)pbuf, (void *)source, len); + *frlen = *frlen + len; + return pbuf + len; +} + +/* rtw_set_ie will update frame length */ +u8 *rtw_set_ie +( + u8 *pbuf, + int index, + uint len, + u8 *source, + uint *frlen /* frame length */ +) +{ + + *pbuf = (u8)index; + + *(pbuf + 1) = (u8)len; + + if (len > 0) + memcpy((void *)(pbuf + 2), (void *)source, len); + + *frlen = *frlen + (len + 2); + + return pbuf + len + 2; +} + +inline u8 *rtw_set_ie_ch_switch (u8 *buf, u32 *buf_len, u8 ch_switch_mode, + u8 new_ch, u8 ch_switch_cnt) +{ + u8 ie_data[3]; + + ie_data[0] = ch_switch_mode; + ie_data[1] = new_ch; + ie_data[2] = ch_switch_cnt; + return rtw_set_ie(buf, WLAN_EID_CHANNEL_SWITCH, 3, ie_data, buf_len); +} + +inline u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset) +{ + if (ch_offset == SCN) + return HAL_PRIME_CHNL_OFFSET_DONT_CARE; + else if (ch_offset == SCA) + return HAL_PRIME_CHNL_OFFSET_UPPER; + else if (ch_offset == SCB) + return HAL_PRIME_CHNL_OFFSET_LOWER; + + return HAL_PRIME_CHNL_OFFSET_DONT_CARE; +} + +inline u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset) +{ + if (ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + return SCN; + else if (ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + return SCB; + else if (ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + return SCA; + + return SCN; +} + +inline u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, u8 secondary_ch_offset) +{ + return rtw_set_ie(buf, WLAN_EID_SECONDARY_CHANNEL_OFFSET, 1, &secondary_ch_offset, buf_len); +} + +inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, + u8 flags, u16 reason, u16 precedence) +{ + u8 ie_data[6]; + + ie_data[0] = ttl; + ie_data[1] = flags; + *(u16 *)(ie_data+2) = cpu_to_le16(reason); + *(u16 *)(ie_data+4) = cpu_to_le16(precedence); + + return rtw_set_ie(buf, 0x118, 6, ie_data, buf_len); +} + +/*---------------------------------------------------------------------------- +index: the information element id index, limit is the limit for search +-----------------------------------------------------------------------------*/ +u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit) +{ + int tmp, i; + u8 *p; + + if (limit < 1) { + + return NULL; + } + + p = pbuf; + i = 0; + *len = 0; + while (1) { + if (*p == index) { + *len = *(p + 1); + return p; + } else { + tmp = *(p + 1); + p += (tmp + 2); + i += (tmp + 2); + } + if (i >= limit) + break; + } + + return NULL; +} + +/** + * rtw_get_ie_ex - Search specific IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @eid: Element ID to match + * @oui: OUI to match + * @oui_len: OUI length + * @ie: If not NULL and the specific IE is found, the IE will be copied to the buf starting from the specific IE + * @ielen: If not NULL and the specific IE is found, will set to the length of the entire IE + * + * Returns: The address of the specific IE found, or NULL + */ +u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, uint *ielen) +{ + uint cnt; + u8 *target_ie = NULL; + + if (ielen) + *ielen = 0; + + if (!in_ie || in_len <= 0) + return target_ie; + + cnt = 0; + + while (cnt < in_len) { + if (eid == in_ie[cnt] && (!oui || !memcmp(&in_ie[cnt+2], oui, oui_len))) { + target_ie = &in_ie[cnt]; + + if (ie) + memcpy(ie, &in_ie[cnt], in_ie[cnt+1]+2); + + if (ielen) + *ielen = in_ie[cnt+1]+2; + + break; + } else { + cnt += in_ie[cnt+1]+2; /* goto next */ + } + } + return target_ie; +} + +/** + * rtw_ies_remove_ie - Find matching IEs and remove + * @ies: Address of IEs to search + * @ies_len: Pointer of length of ies, will update to new length + * @offset: The offset to start scarch + * @eid: Element ID to match + * @oui: OUI to match + * @oui_len: OUI length + * + * Returns: _SUCCESS: ies is updated, _FAIL: not updated + */ +int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, u8 eid, u8 *oui, u8 oui_len) +{ + int ret = _FAIL; + u8 *target_ie; + u32 target_ielen; + u8 *start; + uint search_len; + + if (!ies || !ies_len || *ies_len <= offset) + goto exit; + + start = ies + offset; + search_len = *ies_len - offset; + + while (1) { + target_ie = rtw_get_ie_ex(start, search_len, eid, oui, oui_len, NULL, &target_ielen); + if (target_ie && target_ielen) { + u8 buf[MAX_IE_SZ] = {0}; + u8 *remain_ies = target_ie + target_ielen; + uint remain_len = search_len - (remain_ies - start); + + memcpy(buf, remain_ies, remain_len); + memcpy(target_ie, buf, remain_len); + *ies_len = *ies_len - target_ielen; + ret = _SUCCESS; + + start = target_ie; + search_len = remain_len; + } else { + break; + } + } +exit: + return ret; +} + +void rtw_set_supported_rate(u8 *SupportedRates, uint mode) +{ + + memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + + switch (mode) { + case WIRELESS_11B: + memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); + break; + case WIRELESS_11G: + case WIRELESS_11A: + case WIRELESS_11_5N: + case WIRELESS_11A_5N:/* Todo: no basic rate for ofdm ? */ + memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); + break; + case WIRELESS_11BG: + case WIRELESS_11G_24N: + case WIRELESS_11_24N: + case WIRELESS_11BG_24N: + memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); + memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); + break; + } + +} + +uint rtw_get_rateset_len(u8 *rateset) +{ + uint i = 0; + + while (1) { + if ((rateset[i]) == 0) + break; + if (i > 12) + break; + i++; + } + + return i; +} + +int rtw_generate_ie(struct registry_priv *pregistrypriv) +{ + u8 wireless_mode; + int sz = 0, rateLen; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + u8 *ie = pdev_network->IEs; + + /* timestamp will be inserted by hardware */ + sz += 8; + ie += sz; + + /* beacon interval : 2bytes */ + *(__le16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */ + sz += 2; + ie += 2; + + /* capability info */ + *(u16 *)ie = 0; + + *(__le16 *)ie |= cpu_to_le16(cap_IBSS); + + if (pregistrypriv->preamble == PREAMBLE_SHORT) + *(__le16 *)ie |= cpu_to_le16(cap_ShortPremble); + + if (pdev_network->Privacy) + *(__le16 *)ie |= cpu_to_le16(cap_Privacy); + + sz += 2; + ie += 2; + + /* SSID */ + ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); + + /* supported rates */ + if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) { + if (pdev_network->Configuration.DSConfig > 14) + wireless_mode = WIRELESS_11A_5N; + else + wireless_mode = WIRELESS_11BG_24N; + } else { + wireless_mode = pregistrypriv->wireless_mode; + } + + rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); + + rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); + + if (rateLen > 8) { + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, 8, pdev_network->SupportedRates, &sz); + /* ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ + } else { + ie = rtw_set_ie(ie, _SUPPORTEDRATES_IE_, rateLen, pdev_network->SupportedRates, &sz); + } + + /* DS parameter set */ + ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); + + /* IBSS Parameter Set */ + + ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); + + if (rateLen > 8) + ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); + + return sz; +} + +unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) +{ + int len; + u16 val16; + __le16 le_tmp; + unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; + u8 *pbuf = pie; + int limit_new = limit; + + while (1) { + pbuf = rtw_get_ie(pbuf, _WPA_IE_ID_, &len, limit_new); + + if (pbuf) { + /* check if oui matches... */ + if (memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type))) + goto check_next_ie; + + /* check version... */ + memcpy((u8 *)&le_tmp, (pbuf + 6), sizeof(val16)); + + val16 = le16_to_cpu(le_tmp); + if (val16 != 0x0001) + goto check_next_ie; + *wpa_ie_len = *(pbuf + 1); + return pbuf; + } else { + *wpa_ie_len = 0; + return NULL; + } + +check_next_ie: + limit_new = limit - (pbuf - pie) - 2 - len; + if (limit_new <= 0) + break; + pbuf += (2 + len); + } + *wpa_ie_len = 0; + return NULL; +} + +unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit) +{ + + return rtw_get_ie(pie, _WPA2_IE_ID_, rsn_ie_len, limit); +} + +int rtw_get_wpa_cipher_suite(u8 *s) +{ + if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN)) + return WPA_CIPHER_NONE; + if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN)) + return WPA_CIPHER_WEP40; + if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN)) + return WPA_CIPHER_TKIP; + if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN)) + return WPA_CIPHER_CCMP; + if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN)) + return WPA_CIPHER_WEP104; + + return 0; +} + +int rtw_get_wpa2_cipher_suite(u8 *s) +{ + if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN)) + return WPA_CIPHER_NONE; + if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN)) + return WPA_CIPHER_WEP40; + if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN)) + return WPA_CIPHER_TKIP; + if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN)) + return WPA_CIPHER_CCMP; + if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN)) + return WPA_CIPHER_WEP104; + + return 0; +} + +int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) +{ + int i, ret = _SUCCESS; + int left, count; + u8 *pos; + u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; + + if (wpa_ie_len <= 0) { + /* No WPA IE - fail silently */ + return _FAIL; + } + + if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || + (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) + return _FAIL; + + pos = wpa_ie; + + pos += 8; + left = wpa_ie_len - 8; + + /* group_cipher */ + if (left >= WPA_SELECTOR_LEN) { + *group_cipher = rtw_get_wpa_cipher_suite(pos); + pos += WPA_SELECTOR_LEN; + left -= WPA_SELECTOR_LEN; + } else if (left > 0) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); + return _FAIL; + } + + /* pairwise_cipher */ + if (left >= 2) { + count = get_unaligned_le16(pos); + pos += 2; + left -= 2; + + if (count == 0 || left < count * WPA_SELECTOR_LEN) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " + "count %u left %u", __func__, count, left)); + return _FAIL; + } + + for (i = 0; i < count; i++) { + *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos); + + pos += WPA_SELECTOR_LEN; + left -= WPA_SELECTOR_LEN; + } + } else if (left == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + return _FAIL; + } + + if (is_8021x) { + if (left >= 6) { + pos += 2; + if (!memcmp(pos, SUITE_1X, 4)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); + *is_8021x = 1; + } + } + } + + return ret; +} + +int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) +{ + int i, ret = _SUCCESS; + int left, count; + u8 *pos; + u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01}; + + if (rsn_ie_len <= 0) { + /* No RSN IE - fail silently */ + return _FAIL; + } + + if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) + return _FAIL; + + pos = rsn_ie; + pos += 4; + left = rsn_ie_len - 4; + + /* group_cipher */ + if (left >= RSN_SELECTOR_LEN) { + *group_cipher = rtw_get_wpa2_cipher_suite(pos); + + pos += RSN_SELECTOR_LEN; + left -= RSN_SELECTOR_LEN; + + } else if (left > 0) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); + return _FAIL; + } + + /* pairwise_cipher */ + if (left >= 2) { + count = get_unaligned_le16(pos); + pos += 2; + left -= 2; + + if (count == 0 || left < count * RSN_SELECTOR_LEN) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " + "count %u left %u", __func__, count, left)); + return _FAIL; + } + + for (i = 0; i < count; i++) { + *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos); + + pos += RSN_SELECTOR_LEN; + left -= RSN_SELECTOR_LEN; + } + + } else if (left == 1) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); + + return _FAIL; + } + + if (is_8021x) { + if (left >= 6) { + pos += 2; + if (!memcmp(pos, SUITE_1X, 4)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); + *is_8021x = 1; + } + } + } + return ret; +} + +int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) +{ + u8 authmode, sec_idx, i; + u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; + uint cnt; + + /* Search required WPA or WPA2 IE and copy to sec_ie[] */ + + cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); + + sec_idx = 0; + + while (cnt < in_len) { + authmode = in_ie[cnt]; + + if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", + sec_idx, in_ie[cnt+1]+2)); + + if (wpa_ie) { + memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2); + + for (i = 0; i < (in_ie[cnt+1]+2); i += 8) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", + wpa_ie[i], wpa_ie[i+1], wpa_ie[i+2], wpa_ie[i+3], wpa_ie[i+4], + wpa_ie[i+5], wpa_ie[i+6], wpa_ie[i+7])); + } + } + + *wpa_len = in_ie[cnt+1]+2; + cnt += in_ie[cnt+1]+2; /* get next */ + } else { + if (authmode == _WPA2_IE_ID_) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", + sec_idx, in_ie[cnt+1]+2)); + + if (rsn_ie) { + memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt+1]+2); + + for (i = 0; i < (in_ie[cnt+1]+2); i += 8) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", + rsn_ie[i], rsn_ie[i+1], rsn_ie[i+2], rsn_ie[i+3], rsn_ie[i+4], + rsn_ie[i+5], rsn_ie[i+6], rsn_ie[i+7])); + } + } + + *rsn_len = in_ie[cnt+1]+2; + cnt += in_ie[cnt+1]+2; /* get next */ + } else { + cnt += in_ie[cnt+1]+2; /* get next */ + } + } + } + + return *rsn_len + *wpa_len; +} + +u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) +{ + u8 match = false; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if (ie_ptr == NULL) + return match; + + eid = ie_ptr[0]; + + if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { + *wps_ielen = ie_ptr[1]+2; + match = true; + } + return match; +} + +/** + * rtw_get_wps_ie - Search WPS IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @wps_ie: If not NULL and WPS IE is found, WPS IE will be copied to the buf starting from wps_ie + * @wps_ielen: If not NULL and WPS IE is found, will set to the length of the entire WPS IE + * + * Returns: The address of the WPS IE found, or NULL + */ +u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) +{ + uint cnt; + u8 *wpsie_ptr = NULL; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if (wps_ielen) + *wps_ielen = 0; + + if (!in_ie || in_len <= 0) + return wpsie_ptr; + + cnt = 0; + + while (cnt < in_len) { + eid = in_ie[cnt]; + + if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { + wpsie_ptr = &in_ie[cnt]; + + if (wps_ie) + memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); + + if (wps_ielen) + *wps_ielen = in_ie[cnt+1]+2; + + cnt += in_ie[cnt+1]+2; + + break; + } else { + cnt += in_ie[cnt+1]+2; /* goto next */ + } + } + return wpsie_ptr; +} + +/** + * rtw_get_wps_attr - Search a specific WPS attribute from a given WPS IE + * @wps_ie: Address of WPS IE to search + * @wps_ielen: Length limit from wps_ie + * @target_attr_id: The attribute ID of WPS attribute to search + * @buf_attr: If not NULL and the WPS attribute is found, WPS attribute will be copied to the buf starting from buf_attr + * @len_attr: If not NULL and the WPS attribute is found, will set to the length of the entire WPS attribute + * + * Returns: the address of the specific WPS attribute found, or NULL + */ +u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr) +{ + u8 *attr_ptr = NULL; + u8 *target_attr_ptr = NULL; + u8 wps_oui[4] = {0x00, 0x50, 0xF2, 0x04}; + + if (len_attr) + *len_attr = 0; + + if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || + (memcmp(wps_ie + 2, wps_oui , 4))) + return attr_ptr; + + /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ + attr_ptr = wps_ie + 6; /* goto first attr */ + + while (attr_ptr - wps_ie < wps_ielen) { + /* 4 = 2(Attribute ID) + 2(Length) */ + u16 attr_id = RTW_GET_BE16(attr_ptr); + u16 attr_data_len = RTW_GET_BE16(attr_ptr + 2); + u16 attr_len = attr_data_len + 4; + + if (attr_id == target_attr_id) { + target_attr_ptr = attr_ptr; + if (buf_attr) + memcpy(buf_attr, attr_ptr, attr_len); + if (len_attr) + *len_attr = attr_len; + break; + } else { + attr_ptr += attr_len; /* goto next */ + } + } + return target_attr_ptr; +} + +/** + * rtw_get_wps_attr_content - Search a specific WPS attribute content from a given WPS IE + * @wps_ie: Address of WPS IE to search + * @wps_ielen: Length limit from wps_ie + * @target_attr_id: The attribute ID of WPS attribute to search + * @buf_content: If not NULL and the WPS attribute is found, WPS attribute content will be copied to the buf starting from buf_content + * @len_content: If not NULL and the WPS attribute is found, will set to the length of the WPS attribute content + * + * Returns: the address of the specific WPS attribute content found, or NULL + */ +u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content) +{ + u8 *attr_ptr; + u32 attr_len; + + if (len_content) + *len_content = 0; + + attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len); + + if (attr_ptr && attr_len) { + if (buf_content) + memcpy(buf_content, attr_ptr+4, attr_len-4); + + if (len_content) + *len_content = attr_len-4; + + return attr_ptr+4; + } + + return NULL; +} + +static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, + struct rtw_ieee802_11_elems *elems, + int show_errors) +{ + unsigned int oui; + + /* first 3 bytes in vendor specific information element are the IEEE + * OUI of the vendor. The following byte is used a vendor specific + * sub-type. */ + if (elen < 4) { + if (show_errors) { + DBG_88E("short vendor specific information element ignored (len=%lu)\n", + (unsigned long) elen); + } + return -1; + } + + oui = RTW_GET_BE24(pos); + switch (oui) { + case OUI_MICROSOFT: + /* Microsoft/Wi-Fi information elements are further typed and + * subtyped */ + switch (pos[3]) { + case 1: + /* Microsoft OUI (00:50:F2) with OUI Type 1: + * real WPA information element */ + elems->wpa_ie = pos; + elems->wpa_ie_len = elen; + break; + case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ + if (elen < 5) { + DBG_88E("short WME information element ignored (len=%lu)\n", + (unsigned long) elen); + return -1; + } + switch (pos[4]) { + case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: + case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: + elems->wme = pos; + elems->wme_len = elen; + break; + case WME_OUI_SUBTYPE_TSPEC_ELEMENT: + elems->wme_tspec = pos; + elems->wme_tspec_len = elen; + break; + default: + DBG_88E("unknown WME information element ignored (subtype=%d len=%lu)\n", + pos[4], (unsigned long) elen); + return -1; + } + break; + case 4: + /* Wi-Fi Protected Setup (WPS) IE */ + elems->wps_ie = pos; + elems->wps_ie_len = elen; + break; + default: + DBG_88E("Unknown Microsoft information element ignored (type=%d len=%lu)\n", + pos[3], (unsigned long) elen); + return -1; + } + break; + + case OUI_BROADCOM: + switch (pos[3]) { + case VENDOR_HT_CAPAB_OUI_TYPE: + elems->vendor_ht_cap = pos; + elems->vendor_ht_cap_len = elen; + break; + default: + DBG_88E("Unknown Broadcom information element ignored (type=%d len=%lu)\n", + pos[3], (unsigned long) elen); + return -1; + } + break; + default: + DBG_88E("unknown vendor specific information element ignored (vendor OUI %02x:%02x:%02x len=%lu)\n", + pos[0], pos[1], pos[2], (unsigned long) elen); + return -1; + } + return 0; +} + +/** + * ieee802_11_parse_elems - Parse information elements in management frames + * @start: Pointer to the start of IEs + * @len: Length of IE buffer in octets + * @elems: Data structure for parsed elements + * @show_errors: Whether to show parsing errors in debug log + * Returns: Parsing result + */ +enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, + struct rtw_ieee802_11_elems *elems, + int show_errors) +{ + uint left = len; + u8 *pos = start; + int unknown = 0; + + memset(elems, 0, sizeof(*elems)); + + while (left >= 2) { + u8 id, elen; + + id = *pos++; + elen = *pos++; + left -= 2; + + if (elen > left) { + if (show_errors) { + DBG_88E("IEEE 802.11 element parse failed (id=%d elen=%d left=%lu)\n", + id, elen, (unsigned long) left); + } + return ParseFailed; + } + + switch (id) { + case WLAN_EID_SSID: + elems->ssid = pos; + elems->ssid_len = elen; + break; + case WLAN_EID_SUPP_RATES: + elems->supp_rates = pos; + elems->supp_rates_len = elen; + break; + case WLAN_EID_FH_PARAMS: + elems->fh_params = pos; + elems->fh_params_len = elen; + break; + case WLAN_EID_DS_PARAMS: + elems->ds_params = pos; + elems->ds_params_len = elen; + break; + case WLAN_EID_CF_PARAMS: + elems->cf_params = pos; + elems->cf_params_len = elen; + break; + case WLAN_EID_TIM: + elems->tim = pos; + elems->tim_len = elen; + break; + case WLAN_EID_IBSS_PARAMS: + elems->ibss_params = pos; + elems->ibss_params_len = elen; + break; + case WLAN_EID_CHALLENGE: + elems->challenge = pos; + elems->challenge_len = elen; + break; + case WLAN_EID_ERP_INFO: + elems->erp_info = pos; + elems->erp_info_len = elen; + break; + case WLAN_EID_EXT_SUPP_RATES: + elems->ext_supp_rates = pos; + elems->ext_supp_rates_len = elen; + break; + case WLAN_EID_VENDOR_SPECIFIC: + if (rtw_ieee802_11_parse_vendor_specific(pos, elen, elems, show_errors)) + unknown++; + break; + case WLAN_EID_RSN: + elems->rsn_ie = pos; + elems->rsn_ie_len = elen; + break; + case WLAN_EID_PWR_CAPABILITY: + elems->power_cap = pos; + elems->power_cap_len = elen; + break; + case WLAN_EID_SUPPORTED_CHANNELS: + elems->supp_channels = pos; + elems->supp_channels_len = elen; + break; + case WLAN_EID_MOBILITY_DOMAIN: + elems->mdie = pos; + elems->mdie_len = elen; + break; + case WLAN_EID_FAST_BSS_TRANSITION: + elems->ftie = pos; + elems->ftie_len = elen; + break; + case WLAN_EID_TIMEOUT_INTERVAL: + elems->timeout_int = pos; + elems->timeout_int_len = elen; + break; + case WLAN_EID_HT_CAP: + elems->ht_capabilities = pos; + elems->ht_capabilities_len = elen; + break; + case WLAN_EID_HT_OPERATION: + elems->ht_operation = pos; + elems->ht_operation_len = elen; + break; + default: + unknown++; + if (!show_errors) + break; + DBG_88E("IEEE 802.11 element parse ignored unknown element (id=%d elen=%d)\n", + id, elen); + break; + } + left -= elen; + pos += elen; + } + if (left) + return ParseFailed; + return unknown ? ParseUnknown : ParseOK; +} + +u8 key_char2num(u8 ch) +{ + if ((ch >= '0') && (ch <= '9')) + return ch - '0'; + else if ((ch >= 'a') && (ch <= 'f')) + return ch - 'a' + 10; + else if ((ch >= 'A') && (ch <= 'F')) + return ch - 'A' + 10; + else + return 0xff; +} + +u8 str_2char2num(u8 hch, u8 lch) +{ + return (key_char2num(hch) * 10) + key_char2num(lch); +} + +u8 key_2char2num(u8 hch, u8 lch) +{ + return (key_char2num(hch) << 4) | key_char2num(lch); +} + +void rtw_macaddr_cfg(u8 *mac_addr) +{ + u8 mac[ETH_ALEN]; + if (mac_addr == NULL) + return; + + if (rtw_initmac) { /* Users specify the mac address */ + int jj, kk; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + mac[jj] = key_2char2num(rtw_initmac[kk], rtw_initmac[kk + 1]); + memcpy(mac_addr, mac, ETH_ALEN); + } else { /* Use the mac address stored in the Efuse */ + memcpy(mac, mac_addr, ETH_ALEN); + } + + if (((mac[0] == 0xff) && (mac[1] == 0xff) && (mac[2] == 0xff) && + (mac[3] == 0xff) && (mac[4] == 0xff) && (mac[5] == 0xff)) || + ((mac[0] == 0x0) && (mac[1] == 0x0) && (mac[2] == 0x0) && + (mac[3] == 0x0) && (mac[4] == 0x0) && (mac[5] == 0x0))) { + mac[0] = 0x00; + mac[1] = 0xe0; + mac[2] = 0x4c; + mac[3] = 0x87; + mac[4] = 0x00; + mac[5] = 0x00; + /* use default mac addresss */ + memcpy(mac_addr, mac, ETH_ALEN); + DBG_88E("MAC Address from efuse error, assign default one !!!\n"); + } + + DBG_88E("rtw_macaddr_cfg MAC Address = %pM\n", (mac_addr)); +} + +void dump_ies(u8 *buf, u32 buf_len) +{ + u8 *pos = (u8 *)buf; + u8 id, len; + + while (pos-buf <= buf_len) { + id = *pos; + len = *(pos+1); + + DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); + #ifdef CONFIG_88EU_P2P + dump_p2p_ie(pos, len); + #endif + dump_wps_ie(pos, len); + + pos += (2 + len); + } +} + +void dump_wps_ie(u8 *ie, u32 ie_len) +{ + u8 *pos = (u8 *)ie; + u16 id; + u16 len; + u8 *wps_ie; + uint wps_ielen; + + wps_ie = rtw_get_wps_ie(ie, ie_len, NULL, &wps_ielen); + if (wps_ie != ie || wps_ielen == 0) + return; + + pos += 6; + while (pos-ie < ie_len) { + id = RTW_GET_BE16(pos); + len = RTW_GET_BE16(pos + 2); + DBG_88E("%s ID:0x%04x, LEN:%u\n", __func__, id, len); + pos += (4+len); + } +} + +#ifdef CONFIG_88EU_P2P +void dump_p2p_ie(u8 *ie, u32 ie_len) +{ + u8 *pos = (u8 *)ie; + u8 id; + u16 len; + u8 *p2p_ie; + uint p2p_ielen; + + p2p_ie = rtw_get_p2p_ie(ie, ie_len, NULL, &p2p_ielen); + if (p2p_ie != ie || p2p_ielen == 0) + return; + + pos += 6; + while (pos-ie < ie_len) { + id = *pos; + len = get_unaligned_le16(pos+1); + DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); + pos += (3+len); + } +} + +/** + * rtw_get_p2p_ie - Search P2P IE from a series of IEs + * @in_ie: Address of IEs to search + * @in_len: Length limit from in_ie + * @p2p_ie: If not NULL and P2P IE is found, P2P IE will be copied to the buf starting from p2p_ie + * @p2p_ielen: If not NULL and P2P IE is found, will set to the length of the entire P2P IE + * + * Returns: The address of the P2P IE found, or NULL + */ +u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) +{ + uint cnt = 0; + u8 *p2p_ie_ptr; + u8 eid, p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; + + if (p2p_ielen != NULL) + *p2p_ielen = 0; + + while (cnt < in_len) { + eid = in_ie[cnt]; + if ((in_len < 0) || (cnt > MAX_IE_SZ)) { + dump_stack(); + return NULL; + } + if ((eid == _VENDOR_SPECIFIC_IE_) && !memcmp(&in_ie[cnt+2], p2p_oui, 4)) { + p2p_ie_ptr = in_ie + cnt; + + if (p2p_ie != NULL) + memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); + if (p2p_ielen != NULL) + *p2p_ielen = in_ie[cnt + 1] + 2; + return p2p_ie_ptr; + } else { + cnt += in_ie[cnt + 1] + 2; /* goto next */ + } + } + return NULL; +} + +/** + * rtw_get_p2p_attr - Search a specific P2P attribute from a given P2P IE + * @p2p_ie: Address of P2P IE to search + * @p2p_ielen: Length limit from p2p_ie + * @target_attr_id: The attribute ID of P2P attribute to search + * @buf_attr: If not NULL and the P2P attribute is found, P2P attribute will be copied to the buf starting from buf_attr + * @len_attr: If not NULL and the P2P attribute is found, will set to the length of the entire P2P attribute + * + * Returns: the address of the specific WPS attribute found, or NULL + */ +u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_attr, u32 *len_attr) +{ + u8 *attr_ptr = NULL; + u8 *target_attr_ptr = NULL; + u8 p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; + + if (len_attr) + *len_attr = 0; + + if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || + memcmp(p2p_ie + 2, p2p_oui , 4)) + return attr_ptr; + + /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ + attr_ptr = p2p_ie + 6; /* goto first attr */ + + while (attr_ptr - p2p_ie < p2p_ielen) { + /* 3 = 1(Attribute ID) + 2(Length) */ + u8 attr_id = *attr_ptr; + u16 attr_data_len = get_unaligned_le16(attr_ptr + 1); + u16 attr_len = attr_data_len + 3; + + if (attr_id == target_attr_id) { + target_attr_ptr = attr_ptr; + + if (buf_attr) + memcpy(buf_attr, attr_ptr, attr_len); + if (len_attr) + *len_attr = attr_len; + break; + } else { + attr_ptr += attr_len; /* goto next */ + } + } + return target_attr_ptr; +} + +/** + * rtw_get_p2p_attr_content - Search a specific P2P attribute content from a given P2P IE + * @p2p_ie: Address of P2P IE to search + * @p2p_ielen: Length limit from p2p_ie + * @target_attr_id: The attribute ID of P2P attribute to search + * @buf_content: If not NULL and the P2P attribute is found, P2P attribute content will be copied to the buf starting from buf_content + * @len_content: If not NULL and the P2P attribute is found, will set to the length of the P2P attribute content + * + * Returns: the address of the specific P2P attribute content found, or NULL + */ +u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_content, uint *len_content) +{ + u8 *attr_ptr; + u32 attr_len; + + if (len_content) + *len_content = 0; + + attr_ptr = rtw_get_p2p_attr(p2p_ie, p2p_ielen, target_attr_id, NULL, &attr_len); + + if (attr_ptr && attr_len) { + if (buf_content) + memcpy(buf_content, attr_ptr+3, attr_len-3); + + if (len_content) + *len_content = attr_len-3; + + return attr_ptr+3; + } + + return NULL; +} + +u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, u8 *pdata_attr) +{ + u32 a_len; + + *pbuf = attr_id; + + /* u16*)(pbuf + 1) = cpu_to_le16(attr_len); */ + RTW_PUT_LE16(pbuf + 1, attr_len); + + if (pdata_attr) + memcpy(pbuf + 3, pdata_attr, attr_len); + + a_len = attr_len + 3; + + return a_len; +} + +static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id) +{ + u8 *target_attr; + u32 target_attr_len; + uint ielen = ielen_ori; + + while (1) { + target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len); + if (target_attr && target_attr_len) { + u8 *next_attr = target_attr+target_attr_len; + uint remain_len = ielen-(next_attr-ie); + + memset(target_attr, 0, target_attr_len); + memcpy(target_attr, next_attr, remain_len); + memset(target_attr+remain_len, 0, target_attr_len); + *(ie+1) -= target_attr_len; + ielen -= target_attr_len; + } else { + break; + } + } + return ielen; +} + +void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id) +{ + u8 *p2p_ie; + uint p2p_ielen, p2p_ielen_ori; + + p2p_ie = rtw_get_p2p_ie(bss_ex->IEs+_FIXED_IE_LENGTH_, bss_ex->IELength-_FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori); + if (p2p_ie) { + p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id); + if (p2p_ielen != p2p_ielen_ori) { + u8 *next_ie_ori = p2p_ie+p2p_ielen_ori; + u8 *next_ie = p2p_ie+p2p_ielen; + uint remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs); + + memcpy(next_ie, next_ie_ori, remain_len); + memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen); + bss_ex->IELength -= p2p_ielen_ori-p2p_ielen; + } + } +} + +#endif /* CONFIG_88EU_P2P */ + +/* Baron adds to avoid FreeBSD warning */ +int ieee80211_is_empty_essid(const char *essid, int essid_len) +{ + /* Single white space is for Linksys APs */ + if (essid_len == 1 && essid[0] == ' ') + return 1; + + /* Otherwise, if the entire essid is 0, we assume it is hidden */ + while (essid_len) { + essid_len--; + if (essid[essid_len] != '\0') + return 0; + } + + return 1; +} + +int ieee80211_get_hdrlen(u16 fc) +{ + int hdrlen = 24; + + switch (WLAN_FC_GET_TYPE(fc)) { + case RTW_IEEE80211_FTYPE_DATA: + if (fc & RTW_IEEE80211_STYPE_QOS_DATA) + hdrlen += 2; + if ((fc & RTW_IEEE80211_FCTL_FROMDS) && (fc & RTW_IEEE80211_FCTL_TODS)) + hdrlen += 6; /* Addr4 */ + break; + case RTW_IEEE80211_FTYPE_CTL: + switch (WLAN_FC_GET_STYPE(fc)) { + case RTW_IEEE80211_STYPE_CTS: + case RTW_IEEE80211_STYPE_ACK: + hdrlen = 10; + break; + default: + hdrlen = 16; + break; + } + break; + } + + return hdrlen; +} + +static int rtw_get_cipher_info(struct wlan_network *pnetwork) +{ + u32 wpa_ielen; + unsigned char *pbuf; + int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; + int ret = _FAIL; + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + + if (pbuf && (wpa_ielen > 0)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; + pnetwork->BcnInfo.group_cipher = group_cipher; + pnetwork->BcnInfo.is_8021x = is8021x; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d, is_8021x is %d", + __func__, pnetwork->BcnInfo.pairwise_cipher, pnetwork->BcnInfo.is_8021x)); + ret = _SUCCESS; + } + } else { + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + + if (pbuf && (wpa_ielen > 0)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n")); + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE OK!!!\n")); + pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; + pnetwork->BcnInfo.group_cipher = group_cipher; + pnetwork->BcnInfo.is_8021x = is8021x; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d," + "pnetwork->group_cipher is %d, is_8021x is %d", __func__, pnetwork->BcnInfo.pairwise_cipher, + pnetwork->BcnInfo.group_cipher, pnetwork->BcnInfo.is_8021x)); + ret = _SUCCESS; + } + } + } + + return ret; +} + +void rtw_get_bcn_info(struct wlan_network *pnetwork) +{ + unsigned short cap = 0; + u8 bencrypt = 0; + __le16 le_tmp; + u16 wpa_len = 0, rsn_len = 0; + struct HT_info_element *pht_info = NULL; + struct ieee80211_ht_cap *pht_cap = NULL; + unsigned int len; + unsigned char *p; + + memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); + cap = le16_to_cpu(le_tmp); + if (cap & WLAN_CAPABILITY_PRIVACY) { + bencrypt = 1; + pnetwork->network.Privacy = 1; + } else { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; + } + rtw_get_sec_ie(pnetwork->network.IEs , pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + + if (rsn_len > 0) { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; + } else if (wpa_len > 0) { + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA; + } else { + if (bencrypt) + pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; + } + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", + pnetwork->BcnInfo.encryp_protocol)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", + pnetwork->BcnInfo.encryp_protocol)); + rtw_get_cipher_info(pnetwork); + + /* get bwmode and ch_offset */ + /* parsing HT_CAP_IE */ + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_cap = (struct ieee80211_ht_cap *)(p + 2); + pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(pht_cap->cap_info); + } else { + pnetwork->BcnInfo.ht_cap_info = 0; + } + /* parsing HT_INFO_IE */ + p = rtw_get_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, pnetwork->network.IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_info = (struct HT_info_element *)(p + 2); + pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; + } else { + pnetwork->BcnInfo.ht_info_infos_0 = 0; + } +} + +/* show MCS rate, unit: 100Kbps */ +u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char *MCS_rate) +{ + u16 max_rate = 0; + + if (rf_type == RF_1T1R) { + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650); + else if (MCS_rate[0] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585); + else if (MCS_rate[0] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); + else if (MCS_rate[0] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); + else if (MCS_rate[0] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); + else if (MCS_rate[0] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195); + else if (MCS_rate[0] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); + else if (MCS_rate[0] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65); + } else { + if (MCS_rate[1]) { + if (MCS_rate[1] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 3000 : 2700) : ((short_GI_20) ? 1444 : 1300); + else if (MCS_rate[1] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 2700 : 2430) : ((short_GI_20) ? 1300 : 1170); + else if (MCS_rate[1] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 2400 : 2160) : ((short_GI_20) ? 1156 : 1040); + else if (MCS_rate[1] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1800 : 1620) : ((short_GI_20) ? 867 : 780); + else if (MCS_rate[1] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); + else if (MCS_rate[1] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); + else if (MCS_rate[1] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); + else if (MCS_rate[1] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); + } else { + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650); + else if (MCS_rate[0] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585); + else if (MCS_rate[0] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); + else if (MCS_rate[0] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); + else if (MCS_rate[0] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); + else if (MCS_rate[0] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195); + else if (MCS_rate[0] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); + else if (MCS_rate[0] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65); + } + } + return max_rate; +} + +int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action) +{ + const u8 *frame_body = frame + sizeof(struct rtw_ieee80211_hdr_3addr); + u16 fc; + u8 c, a = 0; + + fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl); + + if ((fc & (RTW_IEEE80211_FCTL_FTYPE|RTW_IEEE80211_FCTL_STYPE)) != + (RTW_IEEE80211_FTYPE_MGMT|RTW_IEEE80211_STYPE_ACTION)) + return false; + + c = frame_body[0]; + + switch (c) { + case RTW_WLAN_CATEGORY_P2P: /* vendor-specific */ + break; + default: + a = frame_body[1]; + } + + if (category) + *category = c; + if (action) + *action = a; + + return true; +} + +static const char *_action_public_str[] = { + "ACT_PUB_BSSCOEXIST", + "ACT_PUB_DSE_ENABLE", + "ACT_PUB_DSE_DEENABLE", + "ACT_PUB_DSE_REG_LOCATION", + "ACT_PUB_EXT_CHL_SWITCH", + "ACT_PUB_DSE_MSR_REQ", + "ACT_PUB_DSE_MSR_RPRT", + "ACT_PUB_MP", + "ACT_PUB_DSE_PWR_CONSTRAINT", + "ACT_PUB_VENDOR", + "ACT_PUB_GAS_INITIAL_REQ", + "ACT_PUB_GAS_INITIAL_RSP", + "ACT_PUB_GAS_COMEBACK_REQ", + "ACT_PUB_GAS_COMEBACK_RSP", + "ACT_PUB_TDLS_DISCOVERY_RSP", + "ACT_PUB_LOCATION_TRACK", + "ACT_PUB_RSVD", +}; + +const char *action_public_str(u8 action) +{ + action = (action >= ACT_PUBLIC_MAX) ? ACT_PUBLIC_MAX : action; + return _action_public_str[action]; +} diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c new file mode 100644 index 000000000000..db593503e26e --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -0,0 +1,323 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* + +The purpose of rtw_io.c + +a. provides the API + +b. provides the protocol engine + +c. provides the software interface between caller and the hardware interface + +Compiler Flag Option: + +USB: + a. USE_ASYNC_IRP: Both sync/async operations are provided. + +Only sync read/rtw_write_mem operations are provided. + +jackson@realtek.com.tw + +*/ + +#define _RTW_IO_C_ +#include +#include +#include +#include +#include + +#define rtw_le16_to_cpu(val) le16_to_cpu(val) +#define rtw_le32_to_cpu(val) le32_to_cpu(val) +#define rtw_cpu_to_le16(val) cpu_to_le16(val) +#define rtw_cpu_to_le32(val) cpu_to_le32(val) + +u8 _rtw_read8(struct adapter *adapter, u32 addr) +{ + u8 r_val; + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); + + + _read8 = pintfhdl->io_ops._read8; + r_val = _read8(pintfhdl, addr); + + return r_val; +} + +u16 _rtw_read16(struct adapter *adapter, u32 addr) +{ + u16 r_val; + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); + + _read16 = pintfhdl->io_ops._read16; + + r_val = _read16(pintfhdl, addr); + + return r_val; +} + +u32 _rtw_read32(struct adapter *adapter, u32 addr) +{ + u32 r_val; + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); + + _read32 = pintfhdl->io_ops._read32; + + r_val = _read32(pintfhdl, addr); + + return r_val; +} + +int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int ret; + + _write8 = pintfhdl->io_ops._write8; + + ret = _write8(pintfhdl, addr, val); + + + return RTW_STATUS_CODE(ret); +} + +int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int ret; + + _write16 = pintfhdl->io_ops._write16; + + ret = _write16(pintfhdl, addr, val); + + + return RTW_STATUS_CODE(ret); +} +int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + int ret; + + _write32 = pintfhdl->io_ops._write32; + + ret = _write32(pintfhdl, addr, val); + + + return RTW_STATUS_CODE(ret); +} + +int _rtw_writeN(struct adapter *adapter, u32 addr , u32 length , u8 *pdata) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_priv->intf)); + int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); + int ret; + + _writeN = pintfhdl->io_ops._writeN; + + ret = _writeN(pintfhdl, addr, length, pdata); + + + return RTW_STATUS_CODE(ret); +} +int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int ret; + + _write8_async = pintfhdl->io_ops._write8_async; + + ret = _write8_async(pintfhdl, addr, val); + + + return RTW_STATUS_CODE(ret); +} + +int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int ret; + + _write16_async = pintfhdl->io_ops._write16_async; + ret = _write16_async(pintfhdl, addr, val); + + return RTW_STATUS_CODE(ret); +} + +int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val) +{ + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + int ret; + + _write32_async = pintfhdl->io_ops._write32_async; + ret = _write32_async(pintfhdl, addr, val); + + return RTW_STATUS_CODE(ret); +} + +void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { + RT_TRACE(_module_rtl871x_io_c_, _drv_info_, + ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + adapter->bDriverStopped, adapter->bSurpriseRemoved)); + return; + } + _read_mem = pintfhdl->io_ops._read_mem; + _read_mem(pintfhdl, addr, cnt, pmem); + +} + +void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + + + _write_mem = pintfhdl->io_ops._write_mem; + + _write_mem(pintfhdl, addr, cnt, pmem); + + +} + +void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { + RT_TRACE(_module_rtl871x_io_c_, _drv_info_, + ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + adapter->bDriverStopped, adapter->bSurpriseRemoved)); + return; + } + + _read_port = pintfhdl->io_ops._read_port; + + _read_port(pintfhdl, addr, cnt, pmem); + + +} + +void _rtw_read_port_cancel(struct adapter *adapter) +{ + void (*_read_port_cancel)(struct intf_hdl *pintfhdl); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _read_port_cancel = pintfhdl->io_ops._read_port_cancel; + + if (_read_port_cancel) + _read_port_cancel(pintfhdl); +} + +u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) +{ + u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + u32 ret = _SUCCESS; + + + + _write_port = pintfhdl->io_ops._write_port; + + ret = _write_port(pintfhdl, addr, cnt, pmem); + + + + return ret; +} + +u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem, int timeout_ms) +{ + int ret = _SUCCESS; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pmem; + struct submit_ctx sctx; + + rtw_sctx_init(&sctx, timeout_ms); + pxmitbuf->sctx = &sctx; + + ret = _rtw_write_port(adapter, addr, cnt, pmem); + + if (ret == _SUCCESS) + ret = rtw_sctx_wait(&sctx); + + return ret; +} + +void _rtw_write_port_cancel(struct adapter *adapter) +{ + void (*_write_port_cancel)(struct intf_hdl *pintfhdl); + struct io_priv *pio_priv = &adapter->iopriv; + struct intf_hdl *pintfhdl = &(pio_priv->intf); + + _write_port_cancel = pintfhdl->io_ops._write_port_cancel; + + if (_write_port_cancel) + _write_port_cancel(pintfhdl); +} + +int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct _io_ops *pops)) +{ + struct io_priv *piopriv = &padapter->iopriv; + struct intf_hdl *pintf = &piopriv->intf; + + if (set_intf_ops == NULL) + return _FAIL; + + piopriv->padapter = padapter; + pintf->padapter = padapter; + pintf->pintf_dev = adapter_to_dvobj(padapter); + + set_intf_ops(&pintf->io_ops); + + return _SUCCESS; +} diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c new file mode 100644 index 000000000000..78974325d8bd --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -0,0 +1,1118 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_IOCTL_SET_C_ + +#include +#include +#include +#include + +#include +#include + +extern void indicate_wx_scan_complete_event(struct adapter *padapter); + +#define IS_MAC_ADDRESS_BROADCAST(addr) \ +(\ + ((addr[0] == 0xff) && (addr[1] == 0xff) && \ + (addr[2] == 0xff) && (addr[3] == 0xff) && \ + (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ +) + +u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) +{ + u8 i; + u8 ret = true; + + if (ssid->SsidLength > 32) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); + ret = false; + goto exit; + } + + for (i = 0; i < ssid->SsidLength; i++) { + /* wifi, printable ascii code must be supported */ + if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has nonprintabl ascii\n")); + ret = false; + break; + } + } + +exit: + + return ret; +} + +u8 rtw_do_join(struct adapter *padapter) +{ + struct list_head *plist, *phead; + u8 *pibss = NULL; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + u8 ret = _SUCCESS; + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + phead = get_list_head(queue); + plist = phead->next; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); + + pmlmepriv->cur_network.join_res = -2; + + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + + pmlmepriv->pscanned = plist; + + pmlmepriv->to_join = true; + + if (list_empty(&queue->queue)) { + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */ + /* we try to issue sitesurvey firstly */ + + if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || + pmlmepriv->to_roaming > 0) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n.")); + /* submit site_survey_cmd */ + ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); + if (_SUCCESS != ret) { + pmlmepriv->to_join = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); + } + } else { + pmlmepriv->to_join = false; + ret = _FAIL; + } + + goto exit; + } else { + int select_ret; + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); + if (select_ret == _SUCCESS) { + pmlmepriv->to_join = false; + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + } else { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + /* submit createbss_cmd to change to a ADHOC_MASTER */ + + /* pmlmepriv->lock has been acquired by caller... */ + struct wlan_bssid_ex *pdev_network = &(padapter->registrypriv.dev_network); + + pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + + pibss = padapter->registrypriv.dev_network.MacAddress; + + memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + + rtw_update_registrypriv_dev_network(padapter); + + rtw_generate_random_ibss(pibss); + + if (rtw_createbss_cmd(padapter) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n ")); + ret = false; + goto exit; + } + pmlmepriv->to_join = false; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n ")); + } else { + /* can't associate ; reset under-linking */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + + /* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */ + /* we try to issue sitesurvey firstly */ + if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || + pmlmepriv->to_roaming > 0) { + ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); + if (_SUCCESS != ret) { + pmlmepriv->to_join = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n.")); + } + } else { + ret = _FAIL; + pmlmepriv->to_join = false; + } + } + } + } + +exit: + + return ret; +} + +u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) +{ + u8 status = _SUCCESS; + u32 cur_time = 0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + DBG_88E_LEVEL(_drv_info_, "set bssid:%pM\n", bssid); + + if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && + bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) || + (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && + bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) { + status = _FAIL; + goto exit; + } + + spin_lock_bh(&pmlmepriv->lock); + + DBG_88E("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) + goto handle_tkip_countermeasure; + else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) + goto release_mlme_lock; + + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); + + if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) + goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", (bssid))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", (pmlmepriv->cur_network.network.MacAddress))); + + rtw_disassoc_cmd(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); + + rtw_free_assoc_resources(padapter, 1); + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } + } + } + +handle_tkip_countermeasure: + /* should we add something here...? */ + + if (padapter->securitypriv.btkip_countermeasure) { + cur_time = jiffies; + + if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { + padapter->securitypriv.btkip_countermeasure = false; + padapter->securitypriv.btkip_countermeasure_time = 0; + } else { + status = _FAIL; + goto release_mlme_lock; + } + } + + memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); + pmlmepriv->assoc_by_bssid = true; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) + pmlmepriv->to_join = true; + else + status = rtw_do_join(padapter); + +release_mlme_lock: + spin_unlock_bh(&pmlmepriv->lock); + +exit: + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_bssid: status=%d\n", status)); + + return status; +} + +u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) +{ + u8 status = _SUCCESS; + u32 cur_time = 0; + + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *pnetwork = &pmlmepriv->cur_network; + + DBG_88E_LEVEL(_drv_info_, "set ssid [%s] fw_state=0x%08x\n", + ssid->Ssid, get_fwstate(pmlmepriv)); + + if (!padapter->hw_init_completed) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("set_ssid: hw_init_completed == false =>exit!!!\n")); + status = _FAIL; + goto exit; + } + + spin_lock_bh(&pmlmepriv->lock); + + DBG_88E("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + goto handle_tkip_countermeasure; + } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + goto release_mlme_lock; + } + + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); + + if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && + (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Set SSID is the same ssid, fw_state = 0x%08x\n", + get_fwstate(pmlmepriv))); + + if (!rtw_is_same_ibss(padapter, pnetwork)) { + /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ + rtw_disassoc_cmd(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); + + rtw_free_assoc_resources(padapter, 1); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } + } else { + goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ + } + } else { + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); + } + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); + + rtw_disassoc_cmd(padapter, 0, true); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); + + rtw_free_assoc_resources(padapter, 1); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + } + } + } + +handle_tkip_countermeasure: + + if (padapter->securitypriv.btkip_countermeasure) { + cur_time = jiffies; + + if ((cur_time - padapter->securitypriv.btkip_countermeasure_time) > 60 * HZ) { + padapter->securitypriv.btkip_countermeasure = false; + padapter->securitypriv.btkip_countermeasure_time = 0; + } else { + status = _FAIL; + goto release_mlme_lock; + } + } + + memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); + pmlmepriv->assoc_by_bssid = false; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + pmlmepriv->to_join = true; + } else { + status = rtw_do_join(padapter); + } + +release_mlme_lock: + spin_unlock_bh(&pmlmepriv->lock); + +exit: + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("-rtw_set_802_11_ssid: status =%d\n", status)); + + return status; +} + +u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, + enum ndis_802_11_network_infra networktype) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; + enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, + ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", + *pold_state, networktype, get_fwstate(pmlmepriv))); + + if (*pold_state != networktype) { + spin_lock_bh(&pmlmepriv->lock); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!")); + /* DBG_88E("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */ + + if (*pold_state == Ndis802_11APMode) { + /* change to other mode from Ndis802_11APMode */ + cur_network->join_res = -1; + +#ifdef CONFIG_88EU_AP_MODE + stop_ap_mode(padapter); +#endif + } + + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (*pold_state == Ndis802_11IBSS)) + rtw_disassoc_cmd(padapter, 0, true); + + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + rtw_free_assoc_resources(padapter, 1); + + if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */ + } + + *pold_state = networktype; + + _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE); + + switch (networktype) { + case Ndis802_11IBSS: + set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); + break; + case Ndis802_11Infrastructure: + set_fwstate(pmlmepriv, WIFI_STATION_STATE); + break; + case Ndis802_11APMode: + set_fwstate(pmlmepriv, WIFI_AP_STATE); +#ifdef CONFIG_88EU_AP_MODE + start_ap_mode(padapter); +#endif + break; + case Ndis802_11AutoUnknown: + case Ndis802_11InfrastructureMax: + break; + } + spin_unlock_bh(&pmlmepriv->lock); + } + + return true; +} + +u8 rtw_set_802_11_disassociate(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + spin_lock_bh(&pmlmepriv->lock); + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect\n")); + + rtw_disassoc_cmd(padapter, 0, true); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); + rtw_pwr_wakeup(padapter); + } + + spin_unlock_bh(&pmlmepriv->lock); + + return true; +} + +u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 res = true; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); + + if (padapter == NULL) { + res = false; + goto exit; + } + if (!padapter->hw_init_completed) { + res = false; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n === rtw_set_802_11_bssid_list_scan:hw_init_completed == false ===\n")); + goto exit; + } + + if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || + (pmlmepriv->LinkDetectInfo.bBusyTraffic)) { + /* Scan or linking is in progress, do nothing. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv))); + res = true; + + if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n")); + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy == true\n\n")); + } + } else { + if (rtw_is_scan_deny(padapter)) { + DBG_88E(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter)); + indicate_wx_scan_complete_event(padapter); + return _SUCCESS; + } + + spin_lock_bh(&pmlmepriv->lock); + + res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num, NULL, 0); + + spin_unlock_bh(&pmlmepriv->lock); + } +exit: + + return res; +} + +u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_auth_mode authmode) +{ + struct security_priv *psecuritypriv = &padapter->securitypriv; + int res; + u8 ret; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); + + psecuritypriv->ndisauthtype = authmode; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_authentication_mode:psecuritypriv->ndisauthtype=%d", + psecuritypriv->ndisauthtype)); + + if (psecuritypriv->ndisauthtype > 3) + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + + res = rtw_set_auth(padapter, psecuritypriv); + + if (res == _SUCCESS) + ret = true; + else + ret = false; + + return ret; +} + +u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) +{ + int keyid, res; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + u8 ret = _SUCCESS; + + keyid = wep->KeyIndex & 0x3fffffff; + + if (keyid >= 4) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n")); + ret = false; + goto exit; + } + + switch (wep->KeyLength) { + case 5: + psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 5\n")); + break; + case 13: + psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n")); + break; + default: + psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!= 5 or 13\n")); + break; + } + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_wep:befor memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", + wep->KeyLength, wep->KeyIndex, keyid)); + + memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); + + psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; + + psecuritypriv->dot11PrivacyKeyIndex = keyid; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n", + psecuritypriv->dot11DefKey[keyid].skey[0], + psecuritypriv->dot11DefKey[keyid].skey[1], + psecuritypriv->dot11DefKey[keyid].skey[2], + psecuritypriv->dot11DefKey[keyid].skey[3], + psecuritypriv->dot11DefKey[keyid].skey[4], + psecuritypriv->dot11DefKey[keyid].skey[5], + psecuritypriv->dot11DefKey[keyid].skey[6], + psecuritypriv->dot11DefKey[keyid].skey[7], + psecuritypriv->dot11DefKey[keyid].skey[8], + psecuritypriv->dot11DefKey[keyid].skey[9], + psecuritypriv->dot11DefKey[keyid].skey[10], + psecuritypriv->dot11DefKey[keyid].skey[11], + psecuritypriv->dot11DefKey[keyid].skey[12])); + + res = rtw_set_key(padapter, psecuritypriv, keyid, 1); + + if (res == _FAIL) + ret = false; +exit: + + return ret; +} + +u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) +{ + u8 ret = _SUCCESS; + + if (keyindex >= 0x80000000 || padapter == NULL) { + ret = false; + goto exit; + } else { + int res; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + if (keyindex < 4) { + memset(&psecuritypriv->dot11DefKey[keyindex], 0, 16); + res = rtw_set_key(padapter, psecuritypriv, keyindex, 0); + psecuritypriv->dot11DefKeylen[keyindex] = 0; + if (res == _FAIL) + ret = _FAIL; + } else { + ret = _FAIL; + } + } +exit: + + return ret; +} + +u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) +{ + uint encryptionalgo; + u8 *pbssid; + struct sta_info *stainfo; + u8 bgroup = false; + u8 bgrouptkey = false;/* can be removed later */ + u8 ret = _SUCCESS; + + if (((key->KeyIndex & 0x80000000) == 0) && ((key->KeyIndex & 0x40000000) > 0)) { + /* It is invalid to clear bit 31 and set bit 30. If the miniport driver encounters this combination, */ + /* it must fail the request and return NDIS_STATUS_INVALID_DATA. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_key: ((key->KeyIndex & 0x80000000)==0)[=%d]", + (int)(key->KeyIndex & 0x80000000) == 0)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_key:((key->KeyIndex & 0x40000000)>0)[=%d]", + (int)(key->KeyIndex & 0x40000000) > 0)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, + ("rtw_set_802_11_add_key: key->KeyIndex=%d\n", + (int)key->KeyIndex)); + ret = _FAIL; + goto exit; + } + + if (key->KeyIndex & 0x40000000) { + /* Pairwise key */ + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Pairwise key +++++\n")); + + pbssid = get_bssid(&padapter->mlmepriv); + stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); + + if ((stainfo != NULL) && (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("OID_802_11_ADD_KEY:(stainfo!=NULL)&&(Adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)\n")); + encryptionalgo = stainfo->dot118021XPrivacy; + } else { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: stainfo == NULL)||(Adapter->securitypriv.dot11AuthAlgrthm!= dot11AuthAlgrthm_8021X)\n")); + encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; + } + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (encryptionalgo==%d)!\n", + encryptionalgo)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11PrivacyAlgrthm==%d)!\n", + padapter->securitypriv.dot11PrivacyAlgrthm)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11AuthAlgrthm==%d)!\n", + padapter->securitypriv.dot11AuthAlgrthm)); + + if ((stainfo != NULL)) + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("rtw_set_802_11_add_key: (stainfo->dot118021XPrivacy==%d)!\n", + stainfo->dot118021XPrivacy)); + + if (key->KeyIndex & 0x000000FF) { + /* The key index is specified in the lower 8 bits by values of zero to 255. */ + /* The key index should be set to zero for a Pairwise key, and the driver should fail with */ + /* NDIS_STATUS_INVALID_DATA if the lower 8 bits is not zero */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, (" key->KeyIndex & 0x000000FF.\n")); + ret = _FAIL; + goto exit; + } + + /* check BSSID */ + if (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == true) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MacAddr_isBcst(key->BSSID)\n")); + ret = false; + goto exit; + } + + /* Check key length for TKIP. */ + if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("TKIP KeyLength:0x%x != 32\n", key->KeyLength)); + ret = _FAIL; + goto exit; + } + + /* Check key length for AES. */ + if ((encryptionalgo == _AES_) && (key->KeyLength != 16)) { + /* For our supplicant, EAPPkt9x.vxd, cannot differentiate TKIP and AES case. */ + if (key->KeyLength == 32) { + key->KeyLength = 16; + } else { + ret = _FAIL; + goto exit; + } + } + + /* Check key length for WEP. For NDTEST, 2005.01.27, by rcnjko. */ + if ((encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_) && + (key->KeyLength != 5 && key->KeyLength != 13)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("WEP KeyLength:0x%x != 5 or 13\n", key->KeyLength)); + ret = _FAIL; + goto exit; + } + + bgroup = false; + + /* Check the pairwise key. Added by Annie, 2005-07-06. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Pairwise Key set]\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + + } else { + /* Group key - KeyIndex(BIT30 == 0) */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Group key +++++\n")); + + /* when add wep key through add key and didn't assigned encryption type before */ + if ((padapter->securitypriv.ndisauthtype <= 3) && + (padapter->securitypriv.dot118021XGrpPrivacy == 0)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("keylen =%d(Adapter->securitypriv.dot11PrivacyAlgrthm=%x )padapter->securitypriv.dot118021XGrpPrivacy(%x)\n", + key->KeyLength, padapter->securitypriv.dot11PrivacyAlgrthm, + padapter->securitypriv.dot118021XGrpPrivacy)); + switch (key->KeyLength) { + case 5: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", + padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); + break; + case 13: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", + padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); + break; + default: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", + padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); + break; + } + + encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + (" Adapter->securitypriv.dot11PrivacyAlgrthm=%x\n", + padapter->securitypriv.dot11PrivacyAlgrthm)); + + } else { + encryptionalgo = padapter->securitypriv.dot118021XGrpPrivacy; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("(Adapter->securitypriv.dot11PrivacyAlgrthm=%x)encryptionalgo(%x)=padapter->securitypriv.dot118021XGrpPrivacy(%x)keylen=%d\n", + padapter->securitypriv.dot11PrivacyAlgrthm, encryptionalgo, + padapter->securitypriv.dot118021XGrpPrivacy, key->KeyLength)); + } + + if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) == true) && (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == false)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + (" IBSS but BSSID is not Broadcast Address.\n")); + ret = _FAIL; + goto exit; + } + + /* Check key length for TKIP */ + if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + (" TKIP GTK KeyLength:%u != 32\n", key->KeyLength)); + ret = _FAIL; + goto exit; + } else if (encryptionalgo == _AES_ && (key->KeyLength != 16 && key->KeyLength != 32)) { + /* Check key length for AES */ + /* For NDTEST, we allow keylen = 32 in this case. 2005.01.27, by rcnjko. */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("<=== SetInfo, OID_802_11_ADD_KEY: AES GTK KeyLength:%u != 16 or 32\n", + key->KeyLength)); + ret = _FAIL; + goto exit; + } + + /* Change the key length for EAPPkt9x.vxd. Added by Annie, 2005-11-03. */ + if ((encryptionalgo == _AES_) && (key->KeyLength == 32)) { + key->KeyLength = 16; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("AES key length changed: %u\n", key->KeyLength)); + } + + if (key->KeyIndex & 0x8000000) {/* error ??? 0x8000_0000 */ + bgrouptkey = true; + } + + if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE)) && + (check_fwstate(&padapter->mlmepriv, _FW_LINKED))) + bgrouptkey = true; + bgroup = true; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Group Key set]\n")); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")) ; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)) ; + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); + } + + /* If WEP encryption algorithm, just call rtw_set_802_11_add_wep(). */ + if ((padapter->securitypriv.dot11AuthAlgrthm != dot11AuthAlgrthm_8021X) && + (encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_)) { + u32 keyindex; + u32 len = FIELD_OFFSET(struct ndis_802_11_key, KeyMaterial) + key->KeyLength; + struct ndis_802_11_wep *wep = &padapter->securitypriv.ndiswep; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ WEP key +++++\n")); + + wep->Length = len; + keyindex = key->KeyIndex&0x7fffffff; + wep->KeyIndex = keyindex ; + wep->KeyLength = key->KeyLength; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY:Before memcpy\n")); + + memcpy(wep->KeyMaterial, key->KeyMaterial, key->KeyLength); + memcpy(&(padapter->securitypriv.dot11DefKey[keyindex].skey[0]), key->KeyMaterial, key->KeyLength); + + padapter->securitypriv.dot11DefKeylen[keyindex] = key->KeyLength; + padapter->securitypriv.dot11PrivacyKeyIndex = keyindex; + + ret = rtw_set_802_11_add_wep(padapter, wep); + goto exit; + } + if (key->KeyIndex & 0x20000000) { + /* SetRSC */ + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ SetRSC+++++\n")); + if (bgroup) { + unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; + memcpy(&padapter->securitypriv.dot11Grprxpn, &keysrc, 8); + } else { + unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; + memcpy(&padapter->securitypriv.dot11Grptxpn, &keysrc, 8); + } + } + + /* Indicate this key idx is used for TX */ + /* Save the key in KeyMaterial */ + if (bgroup) { /* Group transmit key */ + int res; + + if (bgrouptkey) + padapter->securitypriv.dot118021XGrpKeyid = (u8)key->KeyIndex; + if ((key->KeyIndex&0x3) == 0) { + ret = _FAIL; + goto exit; + } + memset(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], 0, 16); + memset(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); + memset(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], 0, 16); + + if ((key->KeyIndex & 0x10000000)) { + memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); + memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); + } else { + memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); + memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], + padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, + ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); + } + + /* set group key by index */ + memcpy(&padapter->securitypriv.dot118021XGrpKey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial, key->KeyLength); + + key->KeyIndex = key->KeyIndex & 0x03; + + padapter->securitypriv.binstallGrpkey = true; + + padapter->securitypriv.bcheck_grpkey = false; + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("reset group key")); + + res = rtw_set_key(padapter, &padapter->securitypriv, key->KeyIndex, 1); + + if (res == _FAIL) + ret = _FAIL; + + goto exit; + + } else { /* Pairwise Key */ + u8 res; + + pbssid = get_bssid(&padapter->mlmepriv); + stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); + + if (stainfo != NULL) { + memset(&stainfo->dot118021x_UncstKey, 0, 16);/* clear keybuffer */ + + memcpy(&stainfo->dot118021x_UncstKey, key->KeyMaterial, 16); + + if (encryptionalgo == _TKIP_) { + padapter->securitypriv.busetkipkey = false; + + /* _set_timer(&padapter->securitypriv.tkip_timer, 50); */ + + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n========== _set_timer\n")); + + /* if TKIP, save the Receive/Transmit MIC key in KeyMaterial[128-255] */ + if ((key->KeyIndex & 0x10000000)) { + memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 16, 8); + memcpy(&stainfo->dot11tkiprxmickey, key->KeyMaterial + 24, 8); + + } else { + memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 24, 8); + memcpy(&stainfo->dot11tkiprxmickey, key->KeyMaterial + 16, 8); + } + } + + /* Set key to CAM through H2C command */ + if (bgrouptkey) { /* never go to here */ + res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, false); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(group)\n")); + } else { + res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, true); + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(unicast)\n")); + } + if (!res) + ret = _FAIL; + } + } +exit: + + return ret; +} + +u8 rtw_set_802_11_remove_key(struct adapter *padapter, struct ndis_802_11_remove_key *key) +{ + u8 *pbssid; + struct sta_info *stainfo; + u8 bgroup = (key->KeyIndex & 0x4000000) > 0 ? false : true; + u8 keyIndex = (u8)key->KeyIndex & 0x03; + u8 ret = _SUCCESS; + + if ((key->KeyIndex & 0xbffffffc) > 0) { + ret = _FAIL; + goto exit; + } + + if (bgroup) { + /* clear group key by index */ + + memset(&padapter->securitypriv.dot118021XGrpKey[keyIndex], 0, 16); + + /* \todo Send a H2C Command to Firmware for removing this Key in CAM Entry. */ + } else { + pbssid = get_bssid(&padapter->mlmepriv); + stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); + if (stainfo) { + /* clear key by BSSID */ + memset(&stainfo->dot118021x_UncstKey, 0, 16); + + /* \todo Send a H2C Command to Firmware for disable this Key in CAM Entry. */ + } else { + ret = _FAIL; + goto exit; + } + } +exit: + + return ret; +} + +/* +* rtw_get_cur_max_rate - +* @adapter: pointer to struct adapter structure +* +* Return 0 or 100Kbps +*/ +u16 rtw_get_cur_max_rate(struct adapter *adapter) +{ + int i = 0; + u8 *p; + u16 rate = 0, max_rate = 0; + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + struct ieee80211_ht_cap *pht_capie; + u8 rf_type = 0; + u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0; + u16 mcs_rate = 0; + u32 ht_ielen = 0; + + if (adapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) + return 0; + } + + if ((!check_fwstate(pmlmepriv, _FW_LINKED)) && + (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + return 0; + + if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { + p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + if (p && ht_ielen > 0) { + pht_capie = (struct ieee80211_ht_cap *)(p+2); + + memcpy(&mcs_rate , pht_capie->mcs.rx_mask, 2); + + /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */ + bw_40MHz = (pmlmeext->cur_bwmode && (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo->HT_info.infos[0])) ? 1 : 0; + + short_GI_20 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_20) ? 1 : 0; + short_GI_40 = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & IEEE80211_HT_CAP_SGI_40) ? 1 : 0; + + rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + max_rate = rtw_mcs_rate( + rf_type, + bw_40MHz & (pregistrypriv->cbw40_enable), + short_GI_20, + short_GI_40, + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate + ); + } + } else { + while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { + rate = pcur_bss->SupportedRates[i]&0x7F; + if (rate > max_rate) + max_rate = rate; + i++; + } + + max_rate = max_rate*10/2; + } + + return max_rate; +} + +/* +* rtw_set_scan_mode - +* @adapter: pointer to struct adapter structure +* @scan_mode: +* +* Return _SUCCESS or _FAIL +*/ +int rtw_set_scan_mode(struct adapter *adapter, enum rt_scan_type scan_mode) +{ + if (scan_mode != SCAN_ACTIVE && scan_mode != SCAN_PASSIVE) + return _FAIL; + + adapter->mlmepriv.scan_mode = scan_mode; + + return _SUCCESS; +} + +/* +* rtw_set_channel_plan - +* @adapter: pointer to struct adapter structure +* @channel_plan: +* +* Return _SUCCESS or _FAIL +*/ +int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan) +{ + /* handle by cmd_thread to sync with scan operation */ + return rtw_set_chplan_cmd(adapter, channel_plan, 1); +} + +/* +* rtw_set_country - +* @adapter: pointer to struct adapter structure +* @country_code: string of country code +* +* Return _SUCCESS or _FAIL +*/ +int rtw_set_country(struct adapter *adapter, const char *country_code) +{ + int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G; + + DBG_88E("%s country_code:%s\n", __func__, country_code); + + /* TODO: should have a table to match country code and RT_CHANNEL_DOMAIN */ + /* TODO: should consider 2-character and 3-character country code */ + if (0 == strcmp(country_code, "US")) + channel_plan = RT_CHANNEL_DOMAIN_FCC; + else if (0 == strcmp(country_code, "EU")) + channel_plan = RT_CHANNEL_DOMAIN_ETSI; + else if (0 == strcmp(country_code, "JP")) + channel_plan = RT_CHANNEL_DOMAIN_MKK; + else if (0 == strcmp(country_code, "CN")) + channel_plan = RT_CHANNEL_DOMAIN_CHINA; + else + DBG_88E("%s unknown country_code:%s\n", __func__, country_code); + + return rtw_set_channel_plan(adapter, channel_plan); +} diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c new file mode 100644 index 000000000000..e6fdd32f9a3f --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -0,0 +1,209 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include + +struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) +{ + struct xmit_frame *xmit_frame; + struct xmit_buf *xmitbuf; + struct pkt_attrib *pattrib; + struct xmit_priv *pxmitpriv = &(adapter->xmitpriv); + + xmit_frame = rtw_alloc_xmitframe(pxmitpriv); + if (xmit_frame == NULL) { + DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__); + goto exit; + } + + xmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (xmitbuf == NULL) { + DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__); + rtw_free_xmitframe(pxmitpriv, xmit_frame); + xmit_frame = NULL; + goto exit; + } + + xmit_frame->frame_tag = MGNT_FRAMETAG; + xmit_frame->pxmitbuf = xmitbuf; + xmit_frame->buf_addr = xmitbuf->pbuf; + xmitbuf->priv_data = xmit_frame; + + pattrib = &xmit_frame->attrib; + update_mgntframe_attrib(adapter, pattrib); + pattrib->qsel = 0x10;/* Beacon */ + pattrib->subtype = WIFI_BEACON; + pattrib->pktlen = 0; + pattrib->last_txcmdsz = 0; +exit: + return xmit_frame; +} + +int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len) +{ + struct pkt_attrib *pattrib = &xmit_frame->attrib; + u16 buf_offset; + u32 ori_len; + + buf_offset = TXDESC_OFFSET; + ori_len = buf_offset+pattrib->pktlen; + + /* check if the io_buf can accommodate new cmds */ + if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) { + DBG_88E("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n", + __func__ , ori_len + cmd_len + 8, MAX_XMITBUF_SZ); + return _FAIL; + } + + memcpy(xmit_frame->buf_addr + buf_offset + pattrib->pktlen, IOL_cmds, cmd_len); + pattrib->pktlen += cmd_len; + pattrib->last_txcmdsz += cmd_len; + + return _SUCCESS; +} + +bool rtw_IOL_applied(struct adapter *adapter) +{ + if (1 == adapter->registrypriv.fw_iol) + return true; + + if ((2 == adapter->registrypriv.fw_iol) && (!adapter_to_dvobj(adapter)->ishighspeed)) + return true; + return false; +} + +int rtw_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) +{ + return rtw_hal_iol_cmd(adapter, xmit_frame, max_wating_ms, bndy_cnt); +} + +int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary) +{ + return _SUCCESS; +} + +int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, u8 value, u8 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_WB_REG, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(addr); + cmd.data = cpu_to_le32(value); + + if (mask != 0xFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, u16 value, u16 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_WW_REG, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(addr); + cmd.data = cpu_to_le32(value); + + if (mask != 0xFFFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, u32 value, u32 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_WD_REG, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(addr); + cmd.data = cpu_to_le32(value); + + if (mask != 0xFFFFFFFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, u32 value, u32 mask) +{ + struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16((rf_path<<8) | ((addr) & 0xFF)); + cmd.data = cpu_to_le32(value); + + if (mask != 0x000FFFFF) { + cmd.length = 12; + cmd.mask = cpu_to_le32(mask); + } + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, cmd.length); +} + +int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us) +{ + struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0}; + cmd.address = cpu_to_le16(us); + + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); +} + +int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms) +{ + struct ioreg_cfg cmd = {4, IOREG_CMD_DELAY_US, 0x0, 0x0, 0x0}; + + cmd.address = cpu_to_le16(ms); + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); +} + +int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame) +{ + struct ioreg_cfg cmd = {4, IOREG_CMD_END, cpu_to_le16(0xFFFF), cpu_to_le32(0xFF), 0x0}; + + return rtw_IOL_append_cmds(xmit_frame, (u8 *)&cmd, 4); +} + +u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame) +{ + u8 is_cmd_bndy = false; + if (((pxmit_frame->attrib.pktlen+32)%256) + 8 >= 256) { + rtw_IOL_append_END_cmd(pxmit_frame); + pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen+32)/256)+1)*256); + + pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen; + is_cmd_bndy = true; + } + return is_cmd_bndy; +} + +void rtw_IOL_cmd_buf_dump(struct adapter *Adapter, int buf_len, u8 *pbuf) +{ + int i; + int j = 1; + + pr_info("###### %s ######\n", __func__); + for (i = 0; i < buf_len; i++) { + printk("%02x-", *(pbuf+i)); + + if (j%32 == 0) + printk("\n"); + j++; + } + printk("\n"); + pr_info("=============ioreg_cmd len=%d===============\n", buf_len); +} diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c new file mode 100644 index 000000000000..6422dc57853a --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -0,0 +1,1705 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include +#include "rtw_led.h" + +/* */ +/* Description: */ +/* Callback function of LED BlinkTimer, */ +/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ +/* */ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +void BlinkTimerCallback(struct timer_list *t) +#else +void BlinkTimerCallback(void *data) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct LED_871x *pLed = from_timer(pLed, t, BlinkTimer); +#else + struct LED_871x *pLed = (struct LED_871x *)data; +#endif + struct adapter *padapter = pLed->padapter; + + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) + return; + + _set_workitem(&(pLed->BlinkWorkItem)); +} + +/* */ +/* Description: */ +/* Callback function of LED BlinkWorkItem. */ +/* We dispatch acture LED blink action according to LedStrategy. */ +/* */ +void BlinkWorkItemCallback(struct work_struct *work) +{ + struct LED_871x *pLed = container_of(work, struct LED_871x, BlinkWorkItem); + BlinkHandler(pLed); +} + +/* */ +/* Description: */ +/* Reset status of LED_871x object. */ +/* */ +void ResetLedStatus(struct LED_871x *pLed) +{ + pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ + pLed->bLedOn = false; /* true if LED is ON, false if LED is OFF. */ + + pLed->bLedBlinkInProgress = false; /* true if it is blinking, false o.w.. */ + pLed->bLedWPSBlinkInProgress = false; + + pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */ + pLed->BlinkingLedState = LED_UNKNOWN; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */ + + pLed->bLedNoLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; + pLed->bLedStartToLinkBlinkInProgress = false; + pLed->bLedScanBlinkInProgress = false; +} + +/*Description: */ +/* Initialize an LED_871x object. */ +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_871x LedPin) +{ + pLed->padapter = padapter; + pLed->LedPin = LedPin; + + ResetLedStatus(pLed); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + timer_setup(&pLed->BlinkTimer, BlinkTimerCallback, 0); +#else + _init_timer(&(pLed->BlinkTimer), padapter->pnetdev, BlinkTimerCallback, pLed); +#endif + _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed); +} + +/* */ +/* Description: */ +/* DeInitialize an LED_871x object. */ +/* */ +void DeInitLed871x(struct LED_871x *pLed) +{ + _cancel_workitem_sync(&(pLed->BlinkWorkItem)); + _cancel_timer_ex(&(pLed->BlinkTimer)); + ResetLedStatus(pLed); +} + +/* */ +/* Description: */ +/* Implementation of LED blinking behavior. */ +/* It toggle off LED and schedule corresponding timer if necessary. */ +/* */ + +static void SwLedBlink(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + /* Determine if we shall change LED state again. */ + pLed->BlinkTimes--; + switch (pLed->CurrLedState) { + case LED_BLINK_NORMAL: + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + break; + case LED_BLINK_StartToBlink: + if (check_fwstate(pmlmepriv, _FW_LINKED) && check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + bStopBlinking = true; + if (check_fwstate(pmlmepriv, _FW_LINKED) && + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + bStopBlinking = true; + else if (pLed->BlinkTimes == 0) + bStopBlinking = true; + break; + case LED_BLINK_WPS: + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + break; + default: + bStopBlinking = true; + break; + } + + if (bStopBlinking) { + /* if (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ + if (0) { + SwLedOff(padapter, pLed); + } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { + SwLedOn(padapter, pLed); + } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) { + SwLedOff(padapter, pLed); + } + pLed->BlinkTimes = 0; + pLed->bLedBlinkInProgress = false; + } else { + /* Assign LED state to toggle. */ + if (pLed->BlinkingLedState == RTW_LED_ON) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + + /* Schedule a timer to toggle LED state. */ + switch (pLed->CurrLedState) { + case LED_BLINK_NORMAL: + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_BLINK_SLOWLY: + case LED_BLINK_StartToBlink: + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + break; + case LED_BLINK_WPS: + if (pLed->BlinkingLedState == RTW_LED_ON) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + else + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + break; + default: + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + break; + } + } +} + +static void SwLedBlink1(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + ResetLedStatus(pLed); + return; + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SLOWLY: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_NORMAL: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->BlinkTimes = 0; + pLed->bLedBlinkInProgress = false; + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) + bStopBlinking = false; + else + bStopBlinking = true; + + if (bStopBlinking) { + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } + break; + default: + break; + } +} + +static void SwLedBlink2(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); + + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + default: + break; + } +} + +static void SwLedBlink3(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + if (pLed->CurrLedState != LED_BLINK_WPS_STOP) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else if (check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + break; + case LED_BLINK_WPS_STOP: /* WPS success */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + bStopBlinking = false; + } else { + bStopBlinking = true; + } + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + pLed->bLedWPSBlinkInProgress = false; + } + break; + default: + break; + } +} + +static void SwLedBlink4(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed1 = &(ledpriv->SwLed1); + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) { + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + SwLedOff(padapter, pLed1); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SLOWLY: + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_BLINK_StartToBlink: + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = false; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + pLed->bLedNoLinkBlinkInProgress = false; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_WPS: + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + case LED_BLINK_WPS_STOP: /* WPS authentication fail */ + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) { + if (pLed->bLedOn) + pLed->BlinkTimes = 1; + else + bStopBlinking = true; + } + + if (bStopBlinking) { + pLed->BlinkTimes = 10; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + break; + default: + break; + } + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); +} + +static void SwLedBlink5(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + u8 bStopBlinking = false; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + switch (pLed->CurrLedState) { + case LED_BLINK_SCAN: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + + pLed->bLedScanBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + } + break; + case LED_BLINK_TXRX: + pLed->BlinkTimes--; + if (pLed->BlinkTimes == 0) + bStopBlinking = true; + + if (bStopBlinking) { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedOn) + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (!pLed->bLedOn) + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + + pLed->bLedBlinkInProgress = false; + } else { + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { + SwLedOff(padapter, pLed); + } else { + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + } + break; + + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); +} + +static void SwLedBlink6(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + + /* Change LED according to BlinkingLedState specified. */ + if (pLed->BlinkingLedState == RTW_LED_ON) { + SwLedOn(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); + } else { + SwLedOff(padapter, pLed); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); +} + + /* ALPHA, added by chiyoko, 20090106 */ +static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed = &(ledpriv->SwLed0); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!pLed->bLedNoLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + if (!pLed->bLedLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_NORMAL; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + ; + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed->BlinkTimer)); + else + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS_FAIL: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); +} + + /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ +static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_SITE_SURVEY: + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS: + pLed->bLedWPSBlinkInProgress = false; + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + break; + case LED_CTL_STOP_WPS_FAIL: + pLed->bLedWPSBlinkInProgress = false; + if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { + SwLedOff(padapter, pLed); + } else { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); + } + break; + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!IS_LED_BLINKING(pLed)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); +} + + /* COREGA, added by chiyoko, 20090316 */ + static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_SITE_SURVEY: + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if ((!pLed->bLedBlinkInProgress) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_LINK: + if (IS_LED_WPS_BLINKING(pLed)) + return; + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_STOP_WPS: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } else { + pLed->bLedWPSBlinkInProgress = true; + } + + pLed->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_STOP_WPS_FAIL: + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_START_TO_LINK: + case LED_CTL_NO_LINK: + if (!IS_LED_BLINKING(pLed)) { + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), 0); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + _set_timer(&(pLed->BlinkTimer), 0); + break; + default: + break; + } + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, + ("CurrLedState %d\n", pLed->CurrLedState)); +} + + /* Edimax-Belkin, added by chiyoko, 20090413 */ +static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + struct LED_871x *pLed1 = &(ledpriv->SwLed1); + + switch (LedAction) { + case LED_CTL_START_TO_LINK: + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + + if (!pLed->bLedStartToLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + + pLed->bLedStartToLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_StartToBlink; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + } + break; + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + /* LED1 settings */ + if (LedAction == LED_CTL_LINK) { + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + } + + if (!pLed->bLedNoLinkBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + } + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (IS_LED_WPS_BLINKING(pLed)) + return; + + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) + return; + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_START_WPS: /* wait until xinpin finish */ + case LED_CTL_START_WPS_BOTTON: + if (pLed1->bLedWPSBlinkInProgress) { + pLed1->bLedWPSBlinkInProgress = false; + _cancel_timer_ex(&(pLed1->BlinkTimer)); + + pLed1->BlinkingLedState = RTW_LED_OFF; + pLed1->CurrLedState = RTW_LED_OFF; + + if (pLed1->bLedOn) + _set_timer(&(pLed->BlinkTimer), 0); + } + + if (!pLed->bLedWPSBlinkInProgress) { + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + pLed->bLedWPSBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_WPS; + if (pLed->bLedOn) { + pLed->BlinkingLedState = RTW_LED_OFF; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + } else { + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + } + } + break; + case LED_CTL_STOP_WPS: /* WPS connect success */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + + break; + case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + + /* LED1 settings */ + if (pLed1->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed1->BlinkTimer)); + else + pLed1->bLedWPSBlinkInProgress = true; + pLed1->CurrLedState = LED_BLINK_WPS_STOP; + if (pLed1->bLedOn) + pLed1->BlinkingLedState = RTW_LED_OFF; + else + pLed1->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + pLed->bLedNoLinkBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SLOWLY; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + + /* LED1 settings */ + if (pLed1->bLedWPSBlinkInProgress) + _cancel_timer_ex(&(pLed1->BlinkTimer)); + else + pLed1->bLedWPSBlinkInProgress = true; + pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; + pLed1->BlinkTimes = 10; + if (pLed1->bLedOn) + pLed1->BlinkingLedState = RTW_LED_OFF; + else + pLed1->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedNoLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedNoLinkBlinkInProgress = false; + } + if (pLed->bLedLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedLinkBlinkInProgress = false; + } + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + if (pLed->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedWPSBlinkInProgress = false; + } + if (pLed->bLedScanBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedScanBlinkInProgress = false; + } + if (pLed->bLedStartToLinkBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedStartToLinkBlinkInProgress = false; + } + if (pLed1->bLedWPSBlinkInProgress) { + _cancel_timer_ex(&(pLed1->BlinkTimer)); + pLed1->bLedWPSBlinkInProgress = false; + } + pLed1->BlinkingLedState = LED_UNKNOWN; + SwLedOff(padapter, pLed); + SwLedOff(padapter, pLed1); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); +} + + /* Sercomm-Belkin, added by chiyoko, 20090415 */ +static void +SwLedControlMode5( + struct adapter *padapter, + enum LED_CTL_MODE LedAction +) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct LED_871x *pLed = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_NO_LINK: + case LED_CTL_LINK: /* solid blue */ + pLed->CurrLedState = RTW_LED_ON; + pLed->BlinkingLedState = RTW_LED_ON; + + _set_timer(&(pLed->BlinkTimer), 0); + break; + case LED_CTL_SITE_SURVEY: + if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { + } else if (!pLed->bLedScanBlinkInProgress) { + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + pLed->bLedScanBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_SCAN; + pLed->BlinkTimes = 24; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + } + break; + case LED_CTL_TX: + case LED_CTL_RX: + if (!pLed->bLedBlinkInProgress) { + if (pLed->CurrLedState == LED_BLINK_SCAN) + return; + pLed->bLedBlinkInProgress = true; + pLed->CurrLedState = LED_BLINK_TXRX; + pLed->BlinkTimes = 2; + if (pLed->bLedOn) + pLed->BlinkingLedState = RTW_LED_OFF; + else + pLed->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + } + break; + case LED_CTL_POWER_OFF: + pLed->CurrLedState = RTW_LED_OFF; + pLed->BlinkingLedState = RTW_LED_OFF; + + if (pLed->bLedBlinkInProgress) { + _cancel_timer_ex(&(pLed->BlinkTimer)); + pLed->bLedBlinkInProgress = false; + } + SwLedOff(padapter, pLed); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); +} + + /* WNC-Corega, added by chiyoko, 20090902 */ +static void +SwLedControlMode6( + struct adapter *padapter, + enum LED_CTL_MODE LedAction +) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct LED_871x *pLed0 = &(ledpriv->SwLed0); + + switch (LedAction) { + case LED_CTL_POWER_ON: + case LED_CTL_LINK: + case LED_CTL_NO_LINK: + _cancel_timer_ex(&(pLed0->BlinkTimer)); + pLed0->CurrLedState = RTW_LED_ON; + pLed0->BlinkingLedState = RTW_LED_ON; + _set_timer(&(pLed0->BlinkTimer), 0); + break; + case LED_CTL_POWER_OFF: + SwLedOff(padapter, pLed0); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); +} + +/* */ +/* Description: */ +/* Handler function of LED Blinking. */ +/* We dispatch acture LED blink action according to LedStrategy. */ +/* */ +void BlinkHandler(struct LED_871x *pLed) +{ + struct adapter *padapter = pLed->padapter; + struct led_priv *ledpriv = &(padapter->ledpriv); + + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) + return; + + switch (ledpriv->LedStrategy) { + case SW_LED_MODE0: + SwLedBlink(pLed); + break; + case SW_LED_MODE1: + SwLedBlink1(pLed); + break; + case SW_LED_MODE2: + SwLedBlink2(pLed); + break; + case SW_LED_MODE3: + SwLedBlink3(pLed); + break; + case SW_LED_MODE4: + SwLedBlink4(pLed); + break; + case SW_LED_MODE5: + SwLedBlink5(pLed); + break; + case SW_LED_MODE6: + SwLedBlink6(pLed); + break; + default: + break; + } +} + +void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + struct registry_priv *registry_par; + + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || + (!padapter->hw_init_completed)) + return; + + if (!ledpriv->bRegUseLed) + return; + + registry_par = &padapter->registrypriv; + if (!registry_par->led_enable) + return; + + if ((padapter->pwrctrlpriv.rf_pwrstate != rf_on && + padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) && + (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || + LedAction == LED_CTL_SITE_SURVEY || + LedAction == LED_CTL_LINK || + LedAction == LED_CTL_NO_LINK || + LedAction == LED_CTL_POWER_ON)) + return; + + switch (ledpriv->LedStrategy) { + case SW_LED_MODE0: + break; + case SW_LED_MODE1: + SwLedControlMode1(padapter, LedAction); + break; + case SW_LED_MODE2: + SwLedControlMode2(padapter, LedAction); + break; + case SW_LED_MODE3: + SwLedControlMode3(padapter, LedAction); + break; + case SW_LED_MODE4: + SwLedControlMode4(padapter, LedAction); + break; + case SW_LED_MODE5: + SwLedControlMode5(padapter, LedAction); + break; + case SW_LED_MODE6: + SwLedControlMode6(padapter, LedAction); + break; + default: + break; + } + + RT_TRACE(_module_rtl8712_led_c_, _drv_info_, + ("LedStrategy:%d, LedAction %d\n", + ledpriv->LedStrategy, LedAction)); +} diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c new file mode 100644 index 000000000000..a30c2bd69313 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -0,0 +1,2354 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MLME_C_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +extern unsigned char MCS_rate_2R[16]; +extern unsigned char MCS_rate_1R[16]; + +void rtw_set_roaming(struct adapter *adapter, u8 to_roaming) +{ + if (to_roaming == 0) + adapter->mlmepriv.to_join = false; + adapter->mlmepriv.to_roaming = to_roaming; +} + +u8 rtw_to_roaming(struct adapter *adapter) +{ + return adapter->mlmepriv.to_roaming; +} + +int _rtw_init_mlme_priv (struct adapter *padapter) +{ + int i; + u8 *pbuf; + struct wlan_network *pnetwork; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int res = _SUCCESS; + + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + + pmlmepriv->nic_hdl = (u8 *)padapter; + + pmlmepriv->pscanned = NULL; + pmlmepriv->fw_state = 0; + pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; + pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ + + spin_lock_init(&(pmlmepriv->lock)); + _rtw_init_queue(&(pmlmepriv->free_bss_pool)); + _rtw_init_queue(&(pmlmepriv->scanned_queue)); + + set_scanned_network_val(pmlmepriv, 0); + + memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); + + pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); + + if (pbuf == NULL) { + res = _FAIL; + goto exit; + } + pmlmepriv->free_bss_buf = pbuf; + + pnetwork = (struct wlan_network *)pbuf; + + for (i = 0; i < MAX_BSS_CNT; i++) { + INIT_LIST_HEAD(&(pnetwork->list)); + + list_add_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); + + pnetwork++; + } + + /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ + + rtw_clear_scan_deny(padapter); + + rtw_init_mlme_timer(padapter); + +exit: + + return res; +} + +static void rtw_mfree_mlme_priv_lock (struct mlme_priv *pmlmepriv) +{ + _rtw_spinlock_free(&pmlmepriv->lock); + _rtw_spinlock_free(&(pmlmepriv->free_bss_pool.lock)); + _rtw_spinlock_free(&(pmlmepriv->scanned_queue.lock)); +} + +#if defined (CONFIG_88EU_AP_MODE) +static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) +{ + kfree(*ppie); + *plen = 0; + *ppie = NULL; +} + +void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) +{ + rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len); + + rtw_free_mlme_ie_data(&pmlmepriv->p2p_beacon_ie, &pmlmepriv->p2p_beacon_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_req_ie, &pmlmepriv->p2p_probe_req_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_probe_resp_ie, &pmlmepriv->p2p_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_go_probe_resp_ie, &pmlmepriv->p2p_go_probe_resp_ie_len); + rtw_free_mlme_ie_data(&pmlmepriv->p2p_assoc_req_ie, &pmlmepriv->p2p_assoc_req_ie_len); +} +#else +void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) +{ +} +#endif + +void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +{ + + rtw_free_mlme_priv_ie_data(pmlmepriv); + + if (pmlmepriv) { + rtw_mfree_mlme_priv_lock (pmlmepriv); + + if (pmlmepriv->free_bss_buf) { + rtw_vmfree(pmlmepriv->free_bss_buf, MAX_BSS_CNT * sizeof(struct wlan_network)); + } + } + +} + +int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork) +{ + + if (pnetwork == NULL) + goto exit; + + spin_lock_bh(&queue->lock); + + list_add_tail(&pnetwork->list, &queue->queue); + + spin_unlock_bh(&queue->lock); + +exit: + + return _SUCCESS; +} + +struct wlan_network *_rtw_dequeue_network(struct __queue *queue) +{ + struct wlan_network *pnetwork; + + spin_lock_bh(&queue->lock); + + if (list_empty(&queue->queue)) { + pnetwork = NULL; + } else { + pnetwork = container_of((&queue->queue)->next, struct wlan_network, list); + + list_del_init(&(pnetwork->list)); + } + + spin_unlock_bh(&queue->lock); + + return pnetwork; +} + +struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *free_queue) */ +{ + struct wlan_network *pnetwork; + struct __queue *free_queue = &pmlmepriv->free_bss_pool; + struct list_head *plist = NULL; + + spin_lock_bh(&free_queue->lock); + + if (list_empty(&free_queue->queue)) { + pnetwork = NULL; + goto exit; + } + plist = (&(free_queue->queue))->next; + + pnetwork = container_of(plist , struct wlan_network, list); + + list_del_init(&pnetwork->list); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("_rtw_alloc_network: ptr=%p\n", plist)); + pnetwork->network_type = 0; + pnetwork->fixed = false; + pnetwork->last_scanned = jiffies; + pnetwork->aid = 0; + pnetwork->join_res = 0; + + pmlmepriv->num_of_scanned++; + +exit: + spin_unlock_bh(&free_queue->lock); + + return pnetwork; +} + +void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall) +{ + u32 curr_time, delta_time; + u32 lifetime = SCANQUEUE_LIFETIME; + struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + + if (pnetwork == NULL) + return; + + if (pnetwork->fixed) + return; + curr_time = jiffies; + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + lifetime = 1; + if (!isfreeall) { + delta_time = (curr_time - pnetwork->last_scanned)/HZ; + if (delta_time < lifetime)/* unit:sec */ + return; + } + spin_lock_bh(&free_queue->lock); + list_del_init(&(pnetwork->list)); + list_add_tail(&(pnetwork->list), &(free_queue->queue)); + pmlmepriv->num_of_scanned--; + spin_unlock_bh(&free_queue->lock); +} + +void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) +{ + struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + + if (pnetwork == NULL) + return; + if (pnetwork->fixed) + return; + list_del_init(&(pnetwork->list)); + list_add_tail(&(pnetwork->list), get_list_head(free_queue)); + pmlmepriv->num_of_scanned--; +} + +/* + return the wlan_network with the matching addr + + Shall be calle under atomic context... to avoid possible racing condition... +*/ +struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) +{ + struct list_head *phead, *plist; + struct wlan_network *pnetwork = NULL; + u8 zero_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + + if (!memcmp(zero_addr, addr, ETH_ALEN)) { + pnetwork = NULL; + goto exit; + } + phead = get_list_head(scanned_queue); + plist = phead->next; + + while (plist != phead) { + pnetwork = container_of(plist, struct wlan_network , list); + if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) + break; + plist = plist->next; + } + if (plist == phead) + pnetwork = NULL; +exit: + + return pnetwork; +} + +void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) +{ + struct list_head *phead, *plist; + struct wlan_network *pnetwork; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *scanned_queue = &pmlmepriv->scanned_queue; + + spin_lock_bh(&scanned_queue->lock); + + phead = get_list_head(scanned_queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + + plist = plist->next; + + _rtw_free_network(pmlmepriv, pnetwork, isfreeall); + } + spin_unlock_bh(&scanned_queue->lock); + +} + +int rtw_if_up(struct adapter *padapter) +{ + int res; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved || + (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + padapter->bDriverStopped, padapter->bSurpriseRemoved)); + res = false; + } else { + res = true; + } + + return res; +} + +void rtw_generate_random_ibss(u8 *pibss) +{ + u32 curtime = jiffies; + + pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ + pibss[1] = 0x11; + pibss[2] = 0x87; + pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ + pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + + return; +} + +u8 *rtw_get_capability_from_ie(u8 *ie) +{ + return ie + 8 + 2; +} + +u16 rtw_get_capability(struct wlan_bssid_ex *bss) +{ + __le16 val; + + memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->IEs), 2); + + return le16_to_cpu(val); +} + +u8 *rtw_get_timestampe_from_ie(u8 *ie) +{ + return ie + 0; +} + +u8 *rtw_get_beacon_interval_from_ie(u8 *ie) +{ + return ie + 8; +} + +int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +{ + int res; + + res = _rtw_init_mlme_priv(padapter);/* (pmlmepriv); */ + + return res; +} + +void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +{ + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); + _rtw_free_mlme_priv (pmlmepriv); + +} + +static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) +{ + struct wlan_network *pnetwork; + + pnetwork = _rtw_alloc_network(pmlmepriv); + + return pnetwork; +} + +static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork) +{ + + _rtw_free_network_nolock(pmlmepriv, pnetwork); + +} + +void rtw_free_network_queue(struct adapter *dev, u8 isfreeall) +{ + + _rtw_free_network_queue(dev, isfreeall); + +} + +/* + return the wlan_network with the matching addr + + Shall be calle under atomic context... to avoid possible racing condition... +*/ +struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) +{ + struct wlan_network *pnetwork = _rtw_find_network(scanned_queue, addr); + + return pnetwork; +} + +int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) +{ + int ret = true; + struct security_priv *psecuritypriv = &adapter->securitypriv; + + if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && + (pnetwork->network.Privacy == 0)) + ret = false; + else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && + (pnetwork->network.Privacy == 1)) + ret = false; + else + ret = true; + return ret; +} + +static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) +{ + return (a->Ssid.SsidLength == b->Ssid.SsidLength) && + !memcmp(a->Ssid.Ssid, b->Ssid.Ssid, a->Ssid.SsidLength); +} + +int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) +{ + u16 s_cap, d_cap; + __le16 le_scap, le_dcap; + + memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->IEs), 2); + memcpy((u8 *)&le_dcap, rtw_get_capability_from_ie(dst->IEs), 2); + + s_cap = le16_to_cpu(le_scap); + d_cap = le16_to_cpu(le_dcap); + + return ((src->Ssid.SsidLength == dst->Ssid.SsidLength) && + ((!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN))) && + ((!memcmp(src->Ssid.Ssid, dst->Ssid.Ssid, src->Ssid.SsidLength))) && + ((s_cap & WLAN_CAPABILITY_IBSS) == + (d_cap & WLAN_CAPABILITY_IBSS)) && + ((s_cap & WLAN_CAPABILITY_BSS) == + (d_cap & WLAN_CAPABILITY_BSS))); +} + +struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) +{ + struct list_head *plist, *phead; + struct wlan_network *pwlan = NULL; + struct wlan_network *oldest = NULL; + + phead = get_list_head(scanned_queue); + + plist = phead->next; + + while (1) { + if (phead == plist) + break; + + pwlan = container_of(plist, struct wlan_network, list); + + if (!pwlan->fixed) { + if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) + oldest = pwlan; + } + + plist = plist->next; + } + + return oldest; +} + +void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, + struct adapter *padapter, bool update_ie) +{ + long rssi_ori = dst->Rssi; + u8 sq_smp = src->PhyInfo.SignalQuality; + u8 ss_final; + u8 sq_final; + long rssi_final; + + rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ + + /* The rule below is 1/5 for sample value, 4/5 for history value */ + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src)) { + /* Take the recvpriv's value for the connected AP*/ + ss_final = padapter->recvpriv.signal_strength; + sq_final = padapter->recvpriv.signal_qual; + /* the rssi value here is undecorated, and will be used for antenna diversity */ + if (sq_smp != 101) /* from the right channel */ + rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5; + else + rssi_final = rssi_ori; + } else { +// if (sq_smp != 101) { /* from the right channel */ + ss_final = (u32)dst->PhyInfo.SignalStrength; //((u32)(src->PhyInfo.SignalStrength)+(u32)(dst->PhyInfo.SignalStrength)*4)/5; + sq_final = (u32)dst->PhyInfo.SignalQuality; //((u32)(src->PhyInfo.SignalQuality)+(u32)(dst->PhyInfo.SignalQuality)*4)/5; + rssi_final = dst->Rssi; //(src->Rssi+dst->Rssi*4)/5; +// } else { +// /* bss info not receiving from the right channel, use the original RX signal infos */ +// ss_final = dst->PhyInfo.SignalStrength; +// sq_final = dst->PhyInfo.SignalQuality; +// rssi_final = dst->Rssi; +// } + } + if (update_ie) { + dst->Reserved[0] = src->Reserved[0]; + dst->Reserved[1] = src->Reserved[1]; + memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); + } + dst->PhyInfo.SignalStrength = ss_final; + dst->PhyInfo.SignalQuality = sq_final; + dst->Rssi = rssi_final; + +} + +static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) +{ + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + + if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && + (is_same_network(&(pmlmepriv->cur_network.network), pnetwork))) { + update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); + rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), + pmlmepriv->cur_network.network.IELength); + } + +} + +/* +Caller must hold pmlmepriv->lock first. +*/ +void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target) +{ + struct list_head *plist, *phead; + u32 bssid_ex_sz; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + struct wlan_network *oldest = NULL; + + spin_lock_bh(&queue->lock); + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + + if (is_same_network(&(pnetwork->network), target)) + break; + if ((oldest == ((struct wlan_network *)0)) || + time_after(oldest->last_scanned, pnetwork->last_scanned)) + oldest = pnetwork; + plist = plist->next; + } + /* If we didn't find a match, then get a new network slot to initialize + * with this beacon's information */ + if (phead == plist) { + if (list_empty(&(pmlmepriv->free_bss_pool.queue))) { + /* If there are no more slots, expire the oldest */ + pnetwork = oldest; + + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); + memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target)); + /* variable initialize */ + pnetwork->fixed = false; + pnetwork->last_scanned = jiffies; + + pnetwork->network_type = 0; + pnetwork->aid = 0; + pnetwork->join_res = 0; + + /* bss info not receiving from the right channel */ + if (pnetwork->network.PhyInfo.SignalQuality == 101) + pnetwork->network.PhyInfo.SignalQuality = 0; + } else { + /* Otherwise just pull from the free list */ + + pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ + + if (pnetwork == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); + goto exit; + } + + bssid_ex_sz = get_wlan_bssid_ex_sz(target); + target->Length = bssid_ex_sz; + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); + memcpy(&(pnetwork->network), target, bssid_ex_sz); + + pnetwork->last_scanned = jiffies; + + /* bss info not receiving from the right channel */ + if (pnetwork->network.PhyInfo.SignalQuality == 101) + pnetwork->network.PhyInfo.SignalQuality = 0; + list_add_tail(&(pnetwork->list), &(queue->queue)); + } + } else { + /* we have an entry and we are going to update it. But this entry may + * be already expired. In this case we do the same as we found a new + * net and call the new_net handler + */ + bool update_ie = true; + + pnetwork->last_scanned = jiffies; + + /* target.Reserved[0]== 1, means that scanned network is a bcn frame. */ + /* probe resp(3) > beacon(1) > probe req(2) */ + if ((target->Reserved[0] != 2) && + (target->Reserved[0] >= pnetwork->network.Reserved[0])) + update_ie = true; + else + update_ie = false; + update_network(&(pnetwork->network), target, adapter, update_ie); + } + +exit: + spin_unlock_bh(&queue->lock); + +} + +static void rtw_add_network(struct adapter *adapter, + struct wlan_bssid_ex *pnetwork) +{ + +#if defined(CONFIG_88EU_P2P) + rtw_wlan_bssid_ex_remove_p2p_attr(pnetwork, P2P_ATTR_GROUP_INFO); +#endif + update_current_network(adapter, pnetwork); + rtw_update_scanned_network(adapter, pnetwork); + +} + +/* select the desired network based on the capability of the (i)bss. */ +/* check items: (1) security */ +/* (2) network_type */ +/* (3) WMM */ +/* (4) HT */ +/* (5) others */ +static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwork) +{ + struct security_priv *psecuritypriv = &adapter->securitypriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u32 desired_encmode; + u32 privacy; + + /* u8 wps_ie[512]; */ + uint wps_ielen; + + int bselected = true; + + desired_encmode = psecuritypriv->ndisencryptstatus; + privacy = pnetwork->network.Privacy; + + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL) + return true; + else + return false; + } + if (adapter->registrypriv.wifi_spec == 1) { /* for correct flow of 8021X to do.... */ + u8 *p = NULL; + uint ie_len = 0; + + if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) + bselected = false; + if (psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPA2PSK) { + p = rtw_get_ie(pnetwork->network.IEs + _BEACON_IE_OFFSET_, + _RSN_IE_2_, &ie_len, + (pnetwork->network.IELength - + _BEACON_IE_OFFSET_)); + if (p && ie_len > 0) + bselected = true; + else + bselected = false; + } + } + + if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) { + DBG_88E("desired_encmode: %d, privacy: %d\n", desired_encmode, privacy); + bselected = false; + } + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + bselected = false; + } + + return bselected; +} + +/* TODO: Perry: For Power Management */ +void rtw_atimdone_event_callback(struct adapter *adapter , u8 *pbuf) +{ + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); + + return; +} + +void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) +{ + u32 len; + struct wlan_bssid_ex *pnetwork; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + + pnetwork = (struct wlan_bssid_ex *)pbuf; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid=%s\n", pnetwork->Ssid.Ssid)); + + len = get_wlan_bssid_ex_sz(pnetwork); + if (len > (sizeof(struct wlan_bssid_ex))) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n****rtw_survey_event_callback: return a wrong bss ***\n")); + return; + } + spin_lock_bh(&pmlmepriv->lock); + + /* update IBSS_network 's timestamp */ + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { + if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + struct wlan_network *ibss_wlan = NULL; + + memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); + if (ibss_wlan) { + memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + goto exit; + } + spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + } + } + + /* lock pmlmepriv->lock when you accessing network_q */ + if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { + if (pnetwork->Ssid.Ssid[0] == 0) + pnetwork->Ssid.SsidLength = 0; + rtw_add_network(adapter, pnetwork); + } + +exit: + + spin_unlock_bh(&pmlmepriv->lock); + + return; +} + +void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) +{ + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_ext_priv *pmlmeext; + u8 timer_cancelled = 0; + + spin_lock_bh(&pmlmepriv->lock); + + if (pmlmepriv->wps_probe_req_ie) { + pmlmepriv->wps_probe_req_ie_len = 0; + kfree(pmlmepriv->wps_probe_req_ie); + pmlmepriv->wps_probe_req_ie = NULL; + } + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { + timer_cancelled = 1; + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + } else { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status=%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); + } + + spin_unlock_bh(&pmlmepriv->lock); + + if (timer_cancelled) + _cancel_timer(&pmlmepriv->scan_to_timer, &timer_cancelled); + + spin_lock_bh(&pmlmepriv->lock); + rtw_set_signal_stat_timer(&adapter->recvpriv); + + if (pmlmepriv->to_join) { + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + + if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + } else { + struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); + u8 *pibss = adapter->registrypriv.dev_network.MacAddress; + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); + + memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + + rtw_update_registrypriv_dev_network(adapter); + rtw_generate_random_ibss(pibss); + + pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; + + if (rtw_createbss_cmd(adapter) != _SUCCESS) + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error=>rtw_createbss_cmd status FAIL\n")); + pmlmepriv->to_join = false; + } + } + } else { + int s_ret; + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + pmlmepriv->to_join = false; + s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); + if (_SUCCESS == s_ret) { + _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); + } else if (s_ret == 2) { /* there is no need to wait for join */ + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + rtw_indicate_connect(adapter); + } else { + DBG_88E("try_to_join, but select scanning queue fail, to_roaming:%d\n", + pmlmepriv->to_roaming); + if (rtw_to_roaming(adapter) != 0) { + if (--pmlmepriv->to_roaming == 0 || + _SUCCESS != rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0)) { + rtw_set_roaming(adapter, 0); + rtw_free_assoc_resources(adapter, 1); + rtw_indicate_disconnect(adapter); + } else { + pmlmepriv->to_join = true; + } + } else { + rtw_indicate_disconnect(adapter); + } + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + } + } + + indicate_wx_scan_complete_event(adapter); + + spin_unlock_bh(&pmlmepriv->lock); + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0); + + rtw_os_xmit_schedule(adapter); + + pmlmeext = &adapter->mlmeextpriv; + +} + +void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) +{ +} + +void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf) +{ +} + +static void free_scanqueue(struct mlme_priv *pmlmepriv) +{ + struct __queue *free_queue = &pmlmepriv->free_bss_pool; + struct __queue *scan_queue = &pmlmepriv->scanned_queue; + struct list_head *plist, *phead, *ptemp; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); + spin_lock_bh(&scan_queue->lock); + spin_lock_bh(&free_queue->lock); + + phead = get_list_head(scan_queue); + plist = phead->next; + + while (plist != phead) { + ptemp = plist->next; + list_del_init(plist); + list_add_tail(plist, &free_queue->queue); + plist = ptemp; + pmlmepriv->num_of_scanned--; + } + + spin_unlock_bh(&free_queue->lock); + spin_unlock_bh(&scan_queue->lock); +} + +/* +*rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock +*/ +void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) +{ + struct wlan_network *pwlan = NULL; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("tgt_network->network.MacAddress=%pM ssid=%s\n", + tgt_network->network.MacAddress, tgt_network->network.Ssid.Ssid)); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE)) { + struct sta_info *psta; + + psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); + + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(adapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + } + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) { + struct sta_info *psta; + + rtw_free_all_stainfo(adapter); + + psta = rtw_get_bcmc_stainfo(adapter); + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(adapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + + rtw_init_bcmc_stainfo(adapter); + } + + if (lock_scanned_queue) + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + if (pwlan) + pwlan->fixed = false; + else + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_assoc_resources:pwlan==NULL\n\n")); + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))) + rtw_free_network_nolock(pmlmepriv, pwlan); + + if (lock_scanned_queue) + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + pmlmepriv->key_mask = 0; + +} + +/* +*rtw_indicate_connect: the caller has to lock pmlmepriv->lock +*/ +void rtw_indicate_connect(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect\n")); + + pmlmepriv->to_join = false; + + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + set_fwstate(pmlmepriv, _FW_LINKED); + + rtw_led_control(padapter, LED_CTL_LINK); + + rtw_os_indicate_connect(padapter); + } + + pmlmepriv->to_roaming = 0; + + rtw_set_scan_deny(padapter, 3000); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); + +} + +/* +*rtw_indicate_disconnect: the caller has to lock pmlmepriv->lock +*/ +void rtw_indicate_disconnect(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n")); + + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); + + if (pmlmepriv->to_roaming > 0) + _clr_fwstate_(pmlmepriv, _FW_LINKED); + + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || + (pmlmepriv->to_roaming <= 0)) { + rtw_os_indicate_disconnect(padapter); + + _clr_fwstate_(pmlmepriv, _FW_LINKED); + rtw_led_control(padapter, LED_CTL_NO_LINK); + rtw_clear_scan_deny(padapter); + } + p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); + + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1); + +} + +inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) +{ + rtw_os_indicate_scan_done(padapter, aborted); +} + +void rtw_scan_abort(struct adapter *adapter) +{ + u32 start; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv); + + start = jiffies; + pmlmeext->scan_abort = true; + while (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) && + rtw_get_passing_time_ms(start) <= 200) { + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + break; + DBG_88E(FUNC_NDEV_FMT"fw_state=_FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + rtw_msleep_os(20); + } + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { + if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) + DBG_88E(FUNC_NDEV_FMT"waiting for scan_abort time out!\n", FUNC_NDEV_ARG(adapter->pnetdev)); + rtw_indicate_scan_done(adapter, true); + } + pmlmeext->scan_abort = false; +} + +static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, struct wlan_network *pnetwork) +{ + int i; + struct sta_info *bmc_sta, *psta = NULL; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_priv *pstapriv = &padapter->stapriv; + + psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); + if (psta == NULL) + psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); + + if (psta) { /* update ptarget_sta */ + DBG_88E("%s\n", __func__); + psta->aid = pnetwork->join_res; + psta->mac_id = 0; + /* sta mode */ + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); + /* security related */ + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + padapter->securitypriv.binstallGrpkey = false; + padapter->securitypriv.busetkipkey = false; + padapter->securitypriv.bgrpkey_handshake = false; + psta->ieee8021x_blocked = true; + psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype)); + memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype)); + memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype)); + memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48)); + memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48)); + } + /* Commented by Albert 2012/07/21 */ + /* When doing the WPS, the wps_ie_len won't equal to 0 */ + /* And the Wi-Fi driver shouldn't allow the data packet to be tramsmitted. */ + if (padapter->securitypriv.wps_ie_len != 0) { + psta->ieee8021x_blocked = true; + padapter->securitypriv.wps_ie_len = 0; + } + /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ + /* if A-MPDU Rx is enabled, resetting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ + /* todo: check if AP can send A-MPDU packets */ + for (i = 0; i < 16; i++) { + /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + preorder_ctrl = &psta->recvreorder_ctrl[i]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + } + bmc_sta = rtw_get_bcmc_stainfo(padapter); + if (bmc_sta) { + for (i = 0; i < 16; i++) { + /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ + preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ + } + } + /* misc. */ + update_sta_info(padapter, psta); + } + return psta; +} + +/* pnetwork: returns from rtw_joinbss_event_callback */ +/* ptarget_wlan: found from scanned_queue */ +static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + + DBG_88E("%s\n", __func__); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("\nfw_state:%x, BSSID:%pM\n", + get_fwstate(pmlmepriv), pnetwork->network.MacAddress)); + + /* why not use ptarget_wlan?? */ + memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); + /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ + cur_network->network.IELength = ptarget_wlan->network.IELength; + memcpy(&cur_network->network.IEs[0], &ptarget_wlan->network.IEs[0], MAX_IE_SZ); + + cur_network->aid = pnetwork->join_res; + + rtw_set_signal_stat_timer(&padapter->recvpriv); + padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; + padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; + /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ + padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); + rtw_set_signal_stat_timer(&padapter->recvpriv); + + /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ + switch (pnetwork->network.InfrastructureMode) { + case Ndis802_11Infrastructure: + if (pmlmepriv->fw_state&WIFI_UNDER_WPS) + pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + else + pmlmepriv->fw_state = WIFI_STATION_STATE; + break; + case Ndis802_11IBSS: + pmlmepriv->fw_state = WIFI_ADHOC_STATE; + break; + default: + pmlmepriv->fw_state = WIFI_NULL_STATE; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); + break; + } + + rtw_update_protection(padapter, (cur_network->network.IEs) + + sizeof(struct ndis_802_11_fixed_ie), + (cur_network->network.IELength)); + rtw_update_ht_cap(padapter, cur_network->network.IEs, cur_network->network.IELength); +} + +/* Notes: the function could be > passive_level (the same context as Rx tasklet) */ +/* pnetwork: returns from rtw_joinbss_event_callback */ +/* ptarget_wlan: found from scanned_queue */ +/* if join_res > 0, for (fw_state == WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist. */ +/* if join_res > 0, for (fw_state == WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */ +/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan != NULL). */ + +void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) +{ + u8 timer_cancelled; + struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; + unsigned int the_same_macaddr = false; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res=%d\n", pnetwork->join_res)); + + rtw_get_encrypt_decrypt_from_registrypriv(adapter); + + if (pmlmepriv->assoc_ssid.SsidLength == 0) + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); + else + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); + + the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); + + pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); + if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + return; + } + + spin_lock_bh(&pmlmepriv->lock); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nrtw_joinbss_event_callback!! spin_lock_init\n")); + + if (pnetwork->join_res > 0) { + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { + /* s1. find ptarget_wlan */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + if (the_same_macaddr) { + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + } else { + pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + if (pcur_wlan) + pcur_wlan->fixed = false; + + pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (pcur_sta) { + spin_lock_bh(&pstapriv->sta_hash_lock); + rtw_free_stainfo(adapter, pcur_sta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + } + + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; + } + } + } else { + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (ptarget_wlan) + ptarget_wlan->fixed = true; + } + } + + /* s2. update cur_network */ + if (ptarget_wlan) { + rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); + } else { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't find ptarget_wlan when joinbss_event callback\n")); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + goto ignore_joinbss_callback; + } + + /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); + if (ptarget_sta == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + goto ignore_joinbss_callback; + } + } + + /* s4. indicate connect */ + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + pmlmepriv->cur_network_scanned = ptarget_wlan; + rtw_indicate_connect(adapter); + } else { + /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); + } + + /* s5. Cancle assoc_timer */ + _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancle assoc_timer\n")); + + } else { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv))); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + goto ignore_joinbss_callback; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + } else if (pnetwork->join_res == -4) { + rtw_reset_securitypriv(adapter); + _set_timer(&pmlmepriv->assoc_timer, 1); + + if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", get_fwstate(pmlmepriv))); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + } else { /* if join_res < 0 (join fails), then try again */ + _set_timer(&pmlmepriv->assoc_timer, 1); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + } + +ignore_joinbss_callback: + spin_unlock_bh(&pmlmepriv->lock); +} + +void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) +{ + struct wlan_network *pnetwork = (struct wlan_network *)pbuf; + + mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); + + rtw_os_xmit_schedule(adapter); + +} + +static u8 search_max_mac_id(struct adapter *padapter) +{ + u8 mac_id; +#if defined (CONFIG_88EU_AP_MODE) + u8 aid; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; +#endif + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + +#if defined (CONFIG_88EU_AP_MODE) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { + if (pstapriv->sta_aid[aid-1] != NULL) + break; + } + mac_id = aid + 1; + } else +#endif + {/* adhoc id = 31~2 */ + for (mac_id = (NUM_STA-1); mac_id >= IBSS_START_MAC_ID; mac_id--) { + if (pmlmeinfo->FW_sta_info[mac_id].status == 1) + break; + } + } + return mac_id; +} + +/* FOR AP , AD-HOC mode */ +void rtw_sta_media_status_rpt(struct adapter *adapter,struct sta_info *psta, + u32 mstatus) +{ + u16 media_status_rpt; + u8 macid; + + if (psta == NULL) + return; + + macid = search_max_mac_id(adapter); + rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); + /* MACID|OPMODE:1 connect */ + media_status_rpt = (u16)((psta->mac_id<<8) | mstatus); + rtw_hal_set_hwreg(adapter,HW_VAR_H2C_MEDIA_STATUS_RPT, + (u8 *)&media_status_rpt); +} + +void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) +{ + struct sta_info *psta; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *ptarget_wlan = NULL; + + if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) + return; + +#if defined (CONFIG_88EU_AP_MODE) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); + if (psta) + rtw_indicate_sta_assoc_event(adapter, psta); + return; + } +#endif + /* for AD-HOC mode */ + psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); + if (psta != NULL) { + /* the sta have been in sta_info_queue => do nothing */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); + return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ + } + psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); + if (psta == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); + return; + } + /* to do: init sta_info variable */ + psta->qos_option = 0; + psta->mac_id = (uint)pstassoc->cam_id; + DBG_88E("%s\n", __func__); + /* for ad-hoc mode */ + rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, true); + rtw_sta_media_status_rpt(adapter, psta, 1); + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) + psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; + psta->ieee8021x_blocked = false; + spin_lock_bh(&pmlmepriv->lock); + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) { + if (adapter->stapriv.asoc_sta_count == 2) { + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); + pmlmepriv->cur_network_scanned = ptarget_wlan; + if (ptarget_wlan) + ptarget_wlan->fixed = true; + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + rtw_indicate_connect(adapter); + } + } + spin_unlock_bh(&pmlmepriv->lock); + mlmeext_sta_add_event_callback(adapter, psta); +} + +void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) +{ + int mac_id = -1; + struct sta_info *psta; + struct wlan_network *pwlan = NULL; + struct wlan_bssid_ex *pdev_network = NULL; + u8 *pibss = NULL; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct stadel_event *pstadel = (struct stadel_event *)pbuf; + struct sta_priv *pstapriv = &adapter->stapriv; + struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + + psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); + if (psta) + mac_id = psta->mac_id; + else + mac_id = pstadel->mac_id; + + DBG_88E("%s(mac_id=%d)=%pM\n", __func__, mac_id, pstadel->macaddr); + + if (mac_id >= 0) { + u16 media_status; + media_status = (mac_id<<8)|0; /* MACID|OPMODE:0 means disconnect */ + /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ + rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + } + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + return; + + mlmeext_sta_del_event_callback(adapter); + + spin_lock_bh(&pmlmepriv->lock); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + if(adapter->registrypriv.wifi_spec == 1) + rtw_set_roaming(adapter, 0); /* don't roam */ + else if (rtw_to_roaming(adapter) > 0) + pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ + else if (rtw_to_roaming(adapter) == 0) + rtw_set_roaming(adapter, + adapter->registrypriv.max_roaming_times); + + if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK) + rtw_set_roaming(adapter, 0); /* don't roam */ + + rtw_free_uc_swdec_pending_queue(adapter); + + rtw_free_assoc_resources(adapter, 1); + rtw_indicate_disconnect(adapter); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + /* remove the network entry in scanned_queue */ + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + if (pwlan) { + pwlan->fixed = false; + rtw_free_network_nolock(pmlmepriv, pwlan); + } + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + _rtw_roaming(adapter, tgt_network); + } + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + spin_lock_bh(&(pstapriv->sta_hash_lock)); + rtw_free_stainfo(adapter, psta); + spin_unlock_bh(&pstapriv->sta_hash_lock); + + if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + /* free old ibss network */ + pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); + if (pwlan) { + pwlan->fixed = false; + rtw_free_network_nolock(pmlmepriv, pwlan); + } + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + /* re-create ibss */ + pdev_network = &(adapter->registrypriv.dev_network); + pibss = adapter->registrypriv.dev_network.MacAddress; + + memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); + + memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); + + rtw_update_registrypriv_dev_network(adapter); + + rtw_generate_random_ibss(pibss); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { + set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); + _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); + } + + if (rtw_createbss_cmd(adapter) != _SUCCESS) + RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error=>stadel_event_callback: rtw_createbss_cmd status FAIL***\n ")); + } + } + spin_unlock_bh(&pmlmepriv->lock); + +} + +void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) +{ + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); + +} + +/* +* _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss +* @adapter: pointer to struct adapter structure +*/ +void _rtw_join_timeout_handler (struct adapter *adapter) +{ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + int do_join_r; + + DBG_88E("%s, fw_state=%x\n", __func__, get_fwstate(pmlmepriv)); + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + return; + + spin_lock_bh(&pmlmepriv->lock); + + if (rtw_to_roaming(adapter) > 0) { /* join timeout caused by roaming */ + while (1) { + pmlmepriv->to_roaming--; + if (rtw_to_roaming(adapter) != 0) { /* try another */ + DBG_88E("%s try another roaming\n", __func__); + do_join_r = rtw_do_join(adapter); + if (_SUCCESS != do_join_r) { + DBG_88E("%s roaming do_join return %d\n", __func__ , do_join_r); + continue; + } + break; + } else { + DBG_88E("%s We've try roaming but fail\n", __func__); + rtw_indicate_disconnect(adapter); + break; + } + } + } else { + rtw_indicate_disconnect(adapter); + free_scanqueue(pmlmepriv);/* */ + } + spin_unlock_bh(&pmlmepriv->lock); + +} + +/* +* rtw_scan_timeout_handler - Timeout/Faliure handler for CMD SiteSurvey +* @adapter: pointer to struct adapter structure +*/ +void rtw_scan_timeout_handler (struct adapter *adapter) +{ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + DBG_88E(FUNC_ADPT_FMT" fw_state=%x\n", FUNC_ADPT_ARG(adapter), get_fwstate(pmlmepriv)); + spin_lock_bh(&pmlmepriv->lock); + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); + spin_unlock_bh(&pmlmepriv->lock); + rtw_indicate_scan_done(adapter, true); +} + +static void rtw_auto_scan_handler(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + /* auto site survey per 60sec */ + if (pmlmepriv->scan_interval > 0) { + pmlmepriv->scan_interval--; + if (pmlmepriv->scan_interval == 0) { + DBG_88E("%s\n", __func__); + rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + } + } +} + +void rtw_dynamic_check_timer_handlder(struct adapter *adapter) +{ + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct registry_priv *pregistrypriv = &adapter->registrypriv; + + if (!adapter) + return; + if (!adapter->hw_init_completed) + return; + if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved)) + return; + if (adapter->net_closed) + return; + rtw_dynamic_chk_wk_cmd(adapter); + + if (pregistrypriv->wifi_spec == 1) { +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) +#endif + { + /* auto site survey */ + rtw_auto_scan_handler(adapter); + } + } + + rcu_read_lock(); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + if (rcu_dereference(adapter->pnetdev->rx_handler_data) && +#else + if (rcu_dereference(adapter->pnetdev->br_port) && +#endif + (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true)) { + /* expire NAT2.5 entry */ + nat25_db_expire(adapter); + + if (adapter->pppoe_connection_in_progress > 0) { + adapter->pppoe_connection_in_progress--; + } + + /* due to rtw_dynamic_check_timer_handlder() is called every 2 seconds */ + if (adapter->pppoe_connection_in_progress > 0) { + adapter->pppoe_connection_in_progress--; + } + } + + rcu_read_unlock(); +} + +#define RTW_SCAN_RESULT_EXPIRE 2000 + +/* +* Select a new join candidate from the original @param candidate and @param competitor +* @return true: candidate is updated +* @return false: candidate is not updated +*/ +static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv + , struct wlan_network **candidate, struct wlan_network *competitor) +{ + int updated = false; + struct adapter *adapter = container_of(pmlmepriv, struct adapter, mlmepriv); + + /* check bssid, if needed */ + if (pmlmepriv->assoc_by_bssid) { + if (memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) + goto exit; + } + + /* check ssid, if needed */ + if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { + if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength || + memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength)) + goto exit; + } + + if (rtw_is_desired_network(adapter, competitor) == false) + goto exit; + + if(rtw_to_roaming(adapter) > 0) { + if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= RTW_SCAN_RESULT_EXPIRE || + is_same_ess(&competitor->network, &pmlmepriv->cur_network.network) == false) + goto exit; + } + + if (*candidate == NULL || (*candidate)->network.Rssi < competitor->network.Rssi) { + *candidate = competitor; + updated = true; + } + if (updated) { + DBG_88E("[by_bssid:%u][assoc_ssid:%s]new candidate: %s(%pM rssi:%d\n", + pmlmepriv->assoc_by_bssid, + pmlmepriv->assoc_ssid.Ssid, + (*candidate)->network.Ssid.Ssid, + (*candidate)->network.MacAddress, + (int)(*candidate)->network.Rssi); + DBG_88E("[to_roaming:%u]\n",rtw_to_roaming(adapter)); + } + +exit: + return updated; +} + +/* +Calling context: +The caller of the sub-routine will be in critical section... +The caller must hold the following spinlock +pmlmepriv->lock +*/ + +int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) +{ + int ret; + struct list_head *phead; + struct adapter *adapter; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + struct wlan_network *candidate = NULL; + u8 supp_ant_div = false; + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + phead = get_list_head(queue); + adapter = (struct adapter *)pmlmepriv->nic_hdl; + pmlmepriv->pscanned = phead->next; + while (phead != pmlmepriv->pscanned) { + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); + if (pnetwork == NULL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork==NULL)\n", __func__)); + ret = _FAIL; + goto exit; + } + pmlmepriv->pscanned = pmlmepriv->pscanned->next; + rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); + } + if (candidate == NULL) { + DBG_88E("%s: return _FAIL(candidate==NULL)\n", __func__); + ret = _FAIL; + goto exit; + } else { + DBG_88E("%s: candidate: %s(%pM ch:%u)\n", __func__, + candidate->network.Ssid.Ssid, candidate->network.MacAddress, + candidate->network.Configuration.DSConfig); + } + + /* check for situation of _FW_LINKED */ + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + DBG_88E("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); + + rtw_disassoc_cmd(adapter, 0, true); + rtw_indicate_disconnect(adapter); + rtw_free_assoc_resources(adapter, 0); + } + + rtw_hal_get_def_var(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(supp_ant_div)); + if (supp_ant_div) { + u8 cur_ant; + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(cur_ant)); + DBG_88E("#### Opt_Ant_(%s), cur_Ant(%s)\n", + (2 == candidate->network.PhyInfo.Optimum_antenna) ? "A" : "B", + (2 == cur_ant) ? "A" : "B" + ); + } + + ret = rtw_joinbss_cmd(adapter, candidate); + +exit: + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + return ret; +} + +int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) +{ + struct cmd_obj *pcmd; + struct setauth_parm *psetauthparm; + struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + int res = _SUCCESS; + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; /* try again */ + goto exit; + } + + psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); + if (psetauthparm == NULL) { + kfree(pcmd); + res = _FAIL; + goto exit; + } + memset(psetauthparm, 0, sizeof(struct setauth_parm)); + psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; + pcmd->cmdcode = _SetAuth_CMD_; + pcmd->parmbuf = (unsigned char *)psetauthparm; + pcmd->cmdsz = (sizeof(struct setauth_parm)); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + INIT_LIST_HEAD(&pcmd->list); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("after enqueue set_auth_cmd, auth_mode=%x\n", + psecuritypriv->dot11AuthAlgrthm)); + res = rtw_enqueue_cmd(pcmdpriv, pcmd); +exit: + + return res; +} + +int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, int keyid, u8 set_tx) +{ + u8 keylen; + struct cmd_obj *pcmd; + struct setkey_parm *psetkeyparm; + struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + int res = _SUCCESS; + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; /* try again */ + goto exit; + } + psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { + kfree(pcmd); + res = _FAIL; + goto exit; + } + + memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key: psetkeyparm->algorithm=(unsigned char)psecuritypriv->dot118021XGrpPrivacy=%d\n", + psetkeyparm->algorithm)); + } else { + psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key: psetkeyparm->algorithm=(u8)psecuritypriv->dot11PrivacyAlgrthm=%d\n", + psetkeyparm->algorithm)); + } + psetkeyparm->keyid = (u8)keyid;/* 0~3 */ + psetkeyparm->set_tx = set_tx; + pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); + DBG_88E("==> rtw_set_key algorithm(%x), keyid(%x), key_mask(%x)\n", + psetkeyparm->algorithm, psetkeyparm->keyid, pmlmepriv->key_mask); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key: psetkeyparm->algorithm=%d psetkeyparm->keyid=(u8)keyid=%d\n", + psetkeyparm->algorithm, keyid)); + + switch (psetkeyparm->algorithm) { + case _WEP40_: + keylen = 5; + memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + break; + case _WEP104_: + keylen = 13; + memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + break; + case _TKIP_: + keylen = 16; + memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); + psetkeyparm->grpkey = 1; + break; + case _AES_: + keylen = 16; + memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); + psetkeyparm->grpkey = 1; + break; + default: + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", + psecuritypriv->dot11PrivacyAlgrthm)); + res = _FAIL; + goto exit; + } + pcmd->cmdcode = _SetKey_CMD_; + pcmd->parmbuf = (u8 *)psetkeyparm; + pcmd->cmdsz = (sizeof(struct setkey_parm)); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + INIT_LIST_HEAD(&pcmd->list); + res = rtw_enqueue_cmd(pcmdpriv, pcmd); +exit: + + return res; +} + +/* adjust IEs for rtw_joinbss_cmd in WMM */ +int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len) +{ + unsigned int ielength = 0; + unsigned int i, j; + + i = 12; /* after the fixed IE */ + while (i < in_len) { + ielength = initial_out_len; + + if (in_ie[i] == 0xDD && in_ie[i+2] == 0x00 && in_ie[i+3] == 0x50 && in_ie[i+4] == 0xF2 && in_ie[i+5] == 0x02 && i+5 < in_len) { + /* WMM element ID and OUI */ + /* Append WMM IE to the last index of out_ie */ + + for (j = i; j < i + 9; j++) { + out_ie[ielength] = in_ie[j]; + ielength++; + } + out_ie[initial_out_len + 1] = 0x07; + out_ie[initial_out_len + 6] = 0x00; + out_ie[initial_out_len + 8] = 0x00; + break; + } + i += (in_ie[i+1]+2); /* to the next IE element */ + } + return ielength; +} + +/* */ +/* Ported from 8185: IsInPreAuthKeyList(). (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) */ +/* Added by Annie, 2006-05-07. */ +/* */ +/* Search by BSSID, */ +/* Return Value: */ +/* -1 :if there is no pre-auth key in the table */ +/* >= 0 :if there is pre-auth key, and return the entry id */ +/* */ +/* */ + +static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) +{ + struct security_priv *psecuritypriv = &Adapter->securitypriv; + int i = 0; + + do { + if ((psecuritypriv->PMKIDList[i].bUsed) && + (!memcmp(psecuritypriv->PMKIDList[i].Bssid, bssid, ETH_ALEN))) { + break; + } else { + i++; + /* continue; */ + } + + } while (i < NUM_PMKID_CACHE); + + if (i == NUM_PMKID_CACHE) { + i = -1;/* Could not find. */ + } else { + /* There is one Pre-Authentication Key for the specific BSSID. */ + } + return i; +} + +/* */ +/* Check the RSN IE length */ +/* If the RSN IE length <= 20, the RSN IE didn't include the PMKID information */ +/* 0-11th element in the array are the fixed IE */ +/* 12th element in the array is the IE */ +/* 13th element in the array is the IE length */ +/* */ + +static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie_len) +{ + struct security_priv *psecuritypriv = &Adapter->securitypriv; + + if (ie[13] <= 20) { + /* The RSN IE didn't include the PMK ID, append the PMK information */ + ie[ie_len] = 1; + ie_len++; + ie[ie_len] = 0; /* PMKID count = 0x0100 */ + ie_len++; + memcpy(&ie[ie_len], &psecuritypriv->PMKIDList[iEntry].PMKID, 16); + + ie_len += 16; + ie[13] += 18;/* PMKID length = 2+16 */ + } + return ie_len; +} + +int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) +{ + u8 authmode; + uint ielength; + int iEntry; + + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct security_priv *psecuritypriv = &adapter->securitypriv; + uint ndisauthmode = psecuritypriv->ndisauthtype; + uint ndissecuritytype = psecuritypriv->ndisencryptstatus; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("+rtw_restruct_sec_ie: ndisauthmode=%d ndissecuritytype=%d\n", + ndisauthmode, ndissecuritytype)); + + /* copy fixed ie only */ + memcpy(out_ie, in_ie, 12); + ielength = 12; + if ((ndisauthmode == Ndis802_11AuthModeWPA) || + (ndisauthmode == Ndis802_11AuthModeWPAPSK)) + authmode = _WPA_IE_ID_; + if ((ndisauthmode == Ndis802_11AuthModeWPA2) || + (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) + authmode = _WPA2_IE_ID_; + + if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { + memcpy(out_ie+ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); + + ielength += psecuritypriv->wps_ie_len; + } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { + /* copy RSN or SSN */ + memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1]+2); + ielength += psecuritypriv->supplicant_ie[1]+2; + rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie); + } + + iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); + if (iEntry < 0) { + return ielength; + } else { + if (authmode == _WPA2_IE_ID_) + ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); + } + + return ielength; +} + +void rtw_init_registrypriv_dev_network(struct adapter *adapter) +{ + struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct eeprom_priv *peepriv = &adapter->eeprompriv; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + u8 *myhwaddr = myid(peepriv); + + memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); + + memcpy(&pdev_network->Ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); + + pdev_network->Configuration.Length = sizeof(struct ndis_802_11_config); + pdev_network->Configuration.BeaconPeriod = 100; + pdev_network->Configuration.FHConfig.Length = 0; + pdev_network->Configuration.FHConfig.HopPattern = 0; + pdev_network->Configuration.FHConfig.HopSet = 0; + pdev_network->Configuration.FHConfig.DwellTime = 0; + +} + +void rtw_update_registrypriv_dev_network(struct adapter *adapter) +{ + int sz = 0; + struct registry_priv *pregistrypriv = &adapter->registrypriv; + struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; + struct security_priv *psecuritypriv = &adapter->securitypriv; + struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; + + pdev_network->Privacy = (psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0); /* adhoc no 802.1x */ + + pdev_network->Rssi = 0; + + switch (pregistrypriv->wireless_mode) { + case WIRELESS_11B: + pdev_network->NetworkTypeInUse = (Ndis802_11DS); + break; + case WIRELESS_11G: + case WIRELESS_11BG: + case WIRELESS_11_24N: + case WIRELESS_11G_24N: + case WIRELESS_11BG_24N: + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + break; + case WIRELESS_11A: + case WIRELESS_11A_5N: + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); + break; + case WIRELESS_11ABGN: + if (pregistrypriv->channel > 14) + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); + else + pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); + break; + default: + /* TODO */ + break; + } + + pdev_network->Configuration.DSConfig = (pregistrypriv->channel); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("pregistrypriv->channel=%d, pdev_network->Configuration.DSConfig=0x%x\n", + pregistrypriv->channel, pdev_network->Configuration.DSConfig)); + + if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) + pdev_network->Configuration.ATIMWindow = (0); + + pdev_network->InfrastructureMode = (cur_network->network.InfrastructureMode); + + /* 1. Supported rates */ + /* 2. IE */ + + sz = rtw_generate_ie(pregistrypriv); + pdev_network->IELength = sz; + pdev_network->Length = get_wlan_bssid_ex_sz((struct wlan_bssid_ex *)pdev_network); + + /* notes: translate IELength & Length after assign the Length to cmdsz in createbss_cmd(); */ + /* pdev_network->IELength = cpu_to_le32(sz); */ + +} + +void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) +{ + +} + +/* the function is at passive_level */ +void rtw_joinbss_reset(struct adapter *padapter) +{ + u8 threshold; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + /* todo: if you want to do something io/reg/hw setting before join_bss, please add code here */ + pmlmepriv->num_FortyMHzIntolerant = 0; + + pmlmepriv->num_sta_no_ht = 0; + + phtpriv->ampdu_enable = false;/* reset to disabled */ + + /* TH = 1 => means that invalidate usb rx aggregation */ + /* TH = 0 => means that validate usb rx aggregation, use init value. */ + if (phtpriv->ht_option) { + if (padapter->registrypriv.wifi_spec == 1) + threshold = 1; + else + threshold = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + } else { + threshold = 1; + rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); + } +} + +/* the function is >= passive_level */ +unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len) +{ + u32 ielen, out_len; + enum ht_cap_ampdu_factor max_rx_ampdu_factor; + unsigned char *p; + struct ieee80211_ht_cap ht_capie; + unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + u32 rx_packet_offset, max_recvbuf_sz; + + phtpriv->ht_option = false; + + p = rtw_get_ie(in_ie+12, _HT_CAPABILITY_IE_, &ielen, in_len-12); + + if (p && ielen > 0) { + if (pqospriv->qos_option == 0) { + out_len = *pout_len; + rtw_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + _WMM_IE_Length_, WMM_IE, pout_len); + + pqospriv->qos_option = 1; + } + + out_len = *pout_len; + + memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); + + ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH | + IEEE80211_HT_CAP_SGI_20 | + IEEE80211_HT_CAP_SGI_40 | + IEEE80211_HT_CAP_TX_STBC | + IEEE80211_HT_CAP_DSSSCCK40); + + rtw_hal_get_def_var(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); + rtw_hal_get_def_var(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz); + + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + + rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); + ht_capie.ampdu_params_info = (max_rx_ampdu_factor&0x03); + + if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + else + ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + + rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, + sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); + + phtpriv->ht_option = true; + + p = rtw_get_ie(in_ie+12, _HT_ADD_INFO_IE_, &ielen, in_len-12); + if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { + out_len = *pout_len; + rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2 , pout_len); + } + } + return phtpriv->ht_option; +} + +/* the function is > passive_level (in critical_section) */ +void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) +{ + u8 *p, max_ampdu_sz; + int len; + struct ieee80211_ht_cap *pht_capie; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (!phtpriv->ht_option) + return; + + if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable)) + return; + + DBG_88E("+rtw_update_ht_cap()\n"); + + /* maybe needs check if ap supports rx ampdu. */ + if ((!phtpriv->ampdu_enable) && (pregistrypriv->ampdu_enable == 1)) { + if (pregistrypriv->wifi_spec == 1) + phtpriv->ampdu_enable = false; + else + phtpriv->ampdu_enable = true; + } else if (pregistrypriv->ampdu_enable == 2) { + phtpriv->ampdu_enable = true; + } + + /* check Max Rx A-MPDU Size */ + len = 0; + p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); + if (p && len > 0) { + pht_capie = (struct ieee80211_ht_cap *)(p+2); + max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); + max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ + phtpriv->rx_ampdu_maxlen = max_ampdu_sz; + } + len = 0; + p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); + + /* update cur_bwmode & cur_ch_offset */ + if ((pregistrypriv->cbw40_enable) && + (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & BIT(1)) && + (pmlmeinfo->HT_info.infos[0] & BIT(2))) { + int i; + u8 rf_type; + + padapter->HalFunc.GetHwRegHandler(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + /* update the MCS rates */ + for (i = 0; i < 16; i++) { + if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i]; + else + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i]; + } + /* switch to the 40M Hz mode according to the AP */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; + switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) { + case HT_EXTCHNL_OFFSET_UPPER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case HT_EXTCHNL_OFFSET_LOWER: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + } + + /* Config SM Power Save setting */ + pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & 0x0C) >> 2; + if (pmlmeinfo->SM_PS == WLAN_HT_CAP_SM_PS_STATIC) + DBG_88E("%s(): WLAN_HT_CAP_SM_PS_STATIC\n", __func__); + + /* Config current HT Protection mode. */ + pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; +} + +void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + u8 issued; + int priority; + struct sta_info *psta = NULL; + struct ht_priv *phtpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + s32 bmcst = IS_MCAST(pattrib->ra); + + if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)) + return; + + priority = pattrib->priority; + + if (pattrib->psta) + psta = pattrib->psta; + else + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); + + if (psta == NULL) + return; + + phtpriv = &psta->htpriv; + + if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { + issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; + issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; + + if (0 == issued) { + DBG_88E("rtw_issue_addbareq_cmd, p=%d\n", priority); + psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); + rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra); + } + } +} + +void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + spin_lock_bh(&pmlmepriv->lock); + _rtw_roaming(padapter, tgt_network); + spin_unlock_bh(&pmlmepriv->lock); +} +void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int do_join_r; + + struct wlan_network *pnetwork; + + if (tgt_network != NULL) + pnetwork = tgt_network; + else + pnetwork = &pmlmepriv->cur_network; + + if (0 < rtw_to_roaming(padapter)) { + DBG_88E("roaming from %s(%pM length:%d\n", + pnetwork->network.Ssid.Ssid, pnetwork->network.MacAddress, + pnetwork->network.Ssid.SsidLength); + memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); + + pmlmepriv->assoc_by_bssid = false; + + while (1) { + do_join_r = rtw_do_join(padapter); + if (_SUCCESS == do_join_r) { + break; + } else { + DBG_88E("roaming do_join return %d\n", do_join_r); + pmlmepriv->to_roaming--; + + if (0 < pmlmepriv->to_roaming) { + continue; + } else { + DBG_88E("%s(%d) -to roaming fail, indicate_disconnect\n", __func__, __LINE__); + rtw_indicate_disconnect(padapter); + break; + } + } + } + } +} diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c new file mode 100644 index 000000000000..6c420d5238a8 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -0,0 +1,8407 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MLME_EXT_C_ + +#include +#include +#include +#include +#include +#include +#include + +static struct mlme_handler mlme_sta_tbl[] = { + {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, + {WIFI_ASSOCRSP, "OnAssocRsp", &OnAssocRsp}, + {WIFI_REASSOCREQ, "OnReAssocReq", &OnAssocReq}, + {WIFI_REASSOCRSP, "OnReAssocRsp", &OnAssocRsp}, + {WIFI_PROBEREQ, "OnProbeReq", &OnProbeReq}, + {WIFI_PROBERSP, "OnProbeRsp", &OnProbeRsp}, + + /*---------------------------------------------------------- + below 2 are reserved + -----------------------------------------------------------*/ + {0, "DoReserved", &DoReserved}, + {0, "DoReserved", &DoReserved}, + {WIFI_BEACON, "OnBeacon", &OnBeacon}, + {WIFI_ATIM, "OnATIM", &OnAtim}, + {WIFI_DISASSOC, "OnDisassoc", &OnDisassoc}, + {WIFI_AUTH, "OnAuth", &OnAuthClient}, + {WIFI_DEAUTH, "OnDeAuth", &OnDeAuth}, + {WIFI_ACTION, "OnAction", &OnAction}, +}; + +static struct action_handler OnAction_tbl[] = { + {RTW_WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct}, + {RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction_qos}, + {RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction_dls}, + {RTW_WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction_back}, + {RTW_WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public}, + {RTW_WLAN_CATEGORY_RADIO_MEASUREMENT, "ACTION_RADIO_MEASUREMENT", &DoReserved}, + {RTW_WLAN_CATEGORY_FT, "ACTION_FT", &DoReserved}, + {RTW_WLAN_CATEGORY_HT, "ACTION_HT", &OnAction_ht}, + {RTW_WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved}, + {RTW_WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction_wmm}, + {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p}, +}; + +static u8 null_addr[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; + +/************************************************** +OUI definitions for the vendor specific IE +***************************************************/ +unsigned char RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; +unsigned char WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; +unsigned char WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; +unsigned char P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; +unsigned char WFD_OUI[] = {0x50, 0x6F, 0x9A, 0x0A}; + +unsigned char WMM_INFO_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; +unsigned char WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + +unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; +unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; + +extern unsigned char REALTEK_96B_IE[]; + +/******************************************************** +MCS rate definitions +*********************************************************/ +unsigned char MCS_rate_2R[16] = {0xff, 0xff, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; +unsigned char MCS_rate_1R[16] = {0xff, 0x00, 0x0, 0x0, 0x01, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; + +/******************************************************** +ChannelPlan definitions +*********************************************************/ +static struct rt_channel_plan_2g RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = { + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /* 0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, /* 0x03, RT_CHANNEL_DOMAIN_2G_MIKK1 */ + {{10, 11, 12, 13}, 4}, /* 0x04, RT_CHANNEL_DOMAIN_2G_ETSI2 */ + {{}, 0}, /* 0x05, RT_CHANNEL_DOMAIN_2G_NULL */ +}; + +static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { + /* 0x00 ~ 0x1F , Old Define ===== */ + {0x02}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */ + {0x02}, /* 0x01, RT_CHANNEL_DOMAIN_IC */ + {0x01}, /* 0x02, RT_CHANNEL_DOMAIN_ETSI */ + {0x01}, /* 0x03, RT_CHANNEL_DOMAIN_SPAIN */ + {0x01}, /* 0x04, RT_CHANNEL_DOMAIN_FRANCE */ + {0x03}, /* 0x05, RT_CHANNEL_DOMAIN_MKK */ + {0x03}, /* 0x06, RT_CHANNEL_DOMAIN_MKK1 */ + {0x01}, /* 0x07, RT_CHANNEL_DOMAIN_ISRAEL */ + {0x03}, /* 0x08, RT_CHANNEL_DOMAIN_TELEC */ + {0x03}, /* 0x09, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN */ + {0x00}, /* 0x0A, RT_CHANNEL_DOMAIN_WORLD_WIDE_13 */ + {0x02}, /* 0x0B, RT_CHANNEL_DOMAIN_TAIWAN */ + {0x01}, /* 0x0C, RT_CHANNEL_DOMAIN_CHINA */ + {0x02}, /* 0x0D, RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO */ + {0x02}, /* 0x0E, RT_CHANNEL_DOMAIN_KOREA */ + {0x02}, /* 0x0F, RT_CHANNEL_DOMAIN_TURKEY */ + {0x01}, /* 0x10, RT_CHANNEL_DOMAIN_JAPAN */ + {0x02}, /* 0x11, RT_CHANNEL_DOMAIN_FCC_NO_DFS */ + {0x01}, /* 0x12, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ + {0x00}, /* 0x13, RT_CHANNEL_DOMAIN_WORLD_WIDE_5G */ + {0x02}, /* 0x14, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS */ + {0x00}, /* 0x15, RT_CHANNEL_DOMAIN_ETSI_NO_DFS */ + {0x00}, /* 0x16, RT_CHANNEL_DOMAIN_KOREA_NO_DFS */ + {0x03}, /* 0x17, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ + {0x05}, /* 0x18, RT_CHANNEL_DOMAIN_PAKISTAN_NO_DFS */ + {0x02}, /* 0x19, RT_CHANNEL_DOMAIN_TAIWAN2_NO_DFS */ + {0x00}, /* 0x1A, */ + {0x00}, /* 0x1B, */ + {0x00}, /* 0x1C, */ + {0x00}, /* 0x1D, */ + {0x00}, /* 0x1E, */ + {0x05}, /* 0x1F, RT_CHANNEL_DOMAIN_WORLD_WIDE_ONLY_5G */ + /* 0x20 ~ 0x7F , New Define ===== */ + {0x00}, /* 0x20, RT_CHANNEL_DOMAIN_WORLD_NULL */ + {0x01}, /* 0x21, RT_CHANNEL_DOMAIN_ETSI1_NULL */ + {0x02}, /* 0x22, RT_CHANNEL_DOMAIN_FCC1_NULL */ + {0x03}, /* 0x23, RT_CHANNEL_DOMAIN_MKK1_NULL */ + {0x04}, /* 0x24, RT_CHANNEL_DOMAIN_ETSI2_NULL */ + {0x02}, /* 0x25, RT_CHANNEL_DOMAIN_FCC1_FCC1 */ + {0x00}, /* 0x26, RT_CHANNEL_DOMAIN_WORLD_ETSI1 */ + {0x03}, /* 0x27, RT_CHANNEL_DOMAIN_MKK1_MKK1 */ + {0x00}, /* 0x28, RT_CHANNEL_DOMAIN_WORLD_KCC1 */ + {0x00}, /* 0x29, RT_CHANNEL_DOMAIN_WORLD_FCC2 */ + {0x00}, /* 0x2A, */ + {0x00}, /* 0x2B, */ + {0x00}, /* 0x2C, */ + {0x00}, /* 0x2D, */ + {0x00}, /* 0x2E, */ + {0x00}, /* 0x2F, */ + {0x00}, /* 0x30, RT_CHANNEL_DOMAIN_WORLD_FCC3 */ + {0x00}, /* 0x31, RT_CHANNEL_DOMAIN_WORLD_FCC4 */ + {0x00}, /* 0x32, RT_CHANNEL_DOMAIN_WORLD_FCC5 */ + {0x00}, /* 0x33, RT_CHANNEL_DOMAIN_WORLD_FCC6 */ + {0x02}, /* 0x34, RT_CHANNEL_DOMAIN_FCC1_FCC7 */ + {0x00}, /* 0x35, RT_CHANNEL_DOMAIN_WORLD_ETSI2 */ + {0x00}, /* 0x36, RT_CHANNEL_DOMAIN_WORLD_ETSI3 */ + {0x03}, /* 0x37, RT_CHANNEL_DOMAIN_MKK1_MKK2 */ + {0x03}, /* 0x38, RT_CHANNEL_DOMAIN_MKK1_MKK3 */ + {0x02}, /* 0x39, RT_CHANNEL_DOMAIN_FCC1_NCC1 */ + {0x00}, /* 0x3A, */ + {0x00}, /* 0x3B, */ + {0x00}, /* 0x3C, */ + {0x00}, /* 0x3D, */ + {0x00}, /* 0x3E, */ + {0x00}, /* 0x3F, */ + {0x02}, /* 0x40, RT_CHANNEL_DOMAIN_FCC1_NCC2 */ + {0x03}, /* 0x41, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G */ +}; + +static struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = {0x03}; /* use the conbination for max channel numbers */ + +/* + * Search the @param channel_num in given @param channel_set + * @ch_set: the given channel set + * @ch: the given channel number + * + * return the index of channel_num in channel_set, -1 if not found + */ +int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch) +{ + int i; + for (i = 0; ch_set[i].ChannelNum != 0; i++) { + if (ch == ch_set[i].ChannelNum) + break; + } + + if (i >= ch_set[i].ChannelNum) + return -1; + return i; +} + +/**************************************************************************** + +Following are the initialization functions for WiFi MLME + +*****************************************************************************/ + +int init_hw_mlme_ext(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + return _SUCCESS; +} + +static void init_mlme_ext_priv_value(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char mixed_datarate[NumRates] = { + _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, + _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, + _48M_RATE_, _54M_RATE_, 0xff + }; + unsigned char mixed_basicrate[NumRates] = { + _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, + _12M_RATE_, _24M_RATE_, 0xff, + }; + + ATOMIC_SET(&pmlmeext->event_seq, 0); + pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ + + pmlmeext->cur_channel = padapter->registrypriv.channel; + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeext->retry = 0; + + pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode; + + memcpy(pmlmeext->datarate, mixed_datarate, NumRates); + memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates); + + pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB; + + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + pmlmeext->sitesurvey_res.channel_idx = 0; + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->scan_abort = false; + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + pmlmeinfo->reauth_count = 0; + pmlmeinfo->reassoc_count = 0; + pmlmeinfo->link_count = 0; + pmlmeinfo->auth_seq = 0; + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + pmlmeinfo->key_index = 0; + pmlmeinfo->iv = 0; + + pmlmeinfo->enc_algo = _NO_PRIVACY_; + pmlmeinfo->authModeToggle = 0; + + memset(pmlmeinfo->chg_txt, 0, 128); + + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + pmlmeinfo->preamble_mode = PREAMBLE_AUTO; + + pmlmeinfo->dialogToken = 0; + + pmlmeext->action_public_rxseq = 0xffff; + pmlmeext->action_public_dialog_token = 0xff; +} + +static int has_channel(struct rt_channel_info *channel_set, + u8 chanset_size, + u8 chan) { + int i; + + for (i = 0; i < chanset_size; i++) { + if (channel_set[i].ChannelNum == chan) + return 1; + } + return 0; +} + +static void init_channel_list(struct adapter *padapter, struct rt_channel_info *channel_set, + u8 chanset_size, + struct p2p_channels *channel_list) { + struct p2p_oper_class_map op_class[] = { + { IEEE80211G, 81, 1, 13, 1, BW20 }, + { IEEE80211G, 82, 14, 14, 1, BW20 }, + { -1, 0, 0, 0, 0, BW20 } + }; + + int cla, op; + + cla = 0; + + for (op = 0; op_class[op].op_class; op++) { + u8 ch; + struct p2p_oper_class_map *o = &op_class[op]; + struct p2p_reg_class *reg = NULL; + + for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { + if (!has_channel(channel_set, chanset_size, ch)) { + continue; + } + + if ((0 == padapter->registrypriv.ht_enable) && (8 == o->inc)) + continue; + + if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && + ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) + continue; + + if (reg == NULL) { + reg = &channel_list->reg_class[cla]; + cla++; + reg->reg_class = o->op_class; + reg->channels = 0; + } + reg->channel[reg->channels] = ch; + reg->channels++; + } + } + channel_list->reg_classes = cla; +} + +static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, struct rt_channel_info *channel_set) +{ + u8 index, chanset_size = 0; + u8 b2_4GBand = false; + u8 Index2G = 0; + + memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); + + if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) { + DBG_88E("ChannelPlan ID %x error !!!!!\n", ChannelPlan); + return chanset_size; + } + + if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { + b2_4GBand = true; + if (RT_CHANNEL_DOMAIN_REALTEK_DEFINE == ChannelPlan) + Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; + else + Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; + } + + if (b2_4GBand) { + for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { + channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; + + if ((RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN == ChannelPlan) ||/* Channel 1~11 is active, and 12~14 is passive */ + (RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G == ChannelPlan)) { + if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else if (RT_CHANNEL_DOMAIN_WORLD_WIDE_13 == ChannelPlan || + RT_CHANNEL_DOMAIN_2G_WORLD == Index2G) {/* channel 12~13, passive scan */ + if (channel_set[chanset_size].ChannelNum <= 11) + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + else + channel_set[chanset_size].ScanType = SCAN_PASSIVE; + } else { + channel_set[chanset_size].ScanType = SCAN_ACTIVE; + } + + chanset_size++; + } + } + return chanset_size; +} + +int init_mlme_ext_priv(struct adapter *padapter) +{ + int res = _SUCCESS; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmlmeext->padapter = padapter; + + init_mlme_ext_priv_value(padapter); + pmlmeinfo->bAcceptAddbaReq = pregistrypriv->bAcceptAddbaReq; + + init_mlme_ext_timer(padapter); + +#ifdef CONFIG_88EU_AP_MODE + init_mlme_ap_info(padapter); +#endif + + pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set); + init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->mlmeext_init = true; + + pmlmeext->active_keep_alive_check = true; + + return res; +} + +void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) +{ + struct adapter *padapter = pmlmeext->padapter; + + if (!padapter) + return; + + if (padapter->bDriverStopped) { + _cancel_timer_ex(&pmlmeext->survey_timer); + _cancel_timer_ex(&pmlmeext->link_timer); + /* _cancel_timer_ex(&pmlmeext->ADDBA_timer); */ + } +} + +static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptable, struct recv_frame *precv_frame) +{ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->rx_data; + + if (ptable->func) { + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + return; + ptable->func(padapter, precv_frame); + } +} + +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) +{ + int index; + struct mlme_handler *ptable; +#ifdef CONFIG_88EU_AP_MODE + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; +#endif /* CONFIG_88EU_AP_MODE */ + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + u8 *pframe = precv_frame->rx_data; + struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", + GetFrameType(pframe), GetFrameSubType(pframe))); + + if (GetFrameType(pframe) != WIFI_MGT_TYPE) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); + return; + } + + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && + memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) + return; + + ptable = mlme_sta_tbl; + + index = GetFrameSubType(pframe) >> 4; + + if (index > 13) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type=%d\n", index)); + return; + } + ptable += index; + + if (psta != NULL) { + if (GetRetry(pframe)) { + if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum) { + /* drop the duplicate management frame */ + DBG_88E("Drop duplicate management frame with seq_num=%d.\n", precv_frame->attrib.seq_num); + return; + } + } + psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; + } + +#ifdef CONFIG_88EU_AP_MODE + switch (GetFrameSubType(pframe)) { + case WIFI_AUTH: + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + ptable->func = &OnAuth; + else + ptable->func = &OnAuthClient; + /* fall through */ + case WIFI_ASSOCREQ: + case WIFI_REASSOCREQ: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + case WIFI_PROBEREQ: + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + _mgt_dispatcher(padapter, ptable, precv_frame); + else + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + case WIFI_BEACON: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + case WIFI_ACTION: + _mgt_dispatcher(padapter, ptable, precv_frame); + break; + default: + _mgt_dispatcher(padapter, ptable, precv_frame); + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + rtw_hostapd_mlme_rx(padapter, precv_frame); + break; + } +#else + _mgt_dispatcher(padapter, ptable, precv_frame); +#endif +} + +#ifdef CONFIG_88EU_P2P +static u32 p2p_listen_state_process(struct adapter *padapter, unsigned char *da) +{ + bool response = true; + + /* do nothing if the device name is empty */ + if (!padapter->wdinfo.device_name_len) + response = false; + + if (response) + issue_probersp_p2p(padapter, da); + + return _SUCCESS; +} +#endif /* CONFIG_88EU_P2P */ + +/**************************************************************************** + +Following are the callback functions for each subtype of the management frames + +*****************************************************************************/ + +unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int ielen; + unsigned char *p; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + u8 is_valid_p2p_probereq = false; + +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 wifi_test_chk_rate = 1; + + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE) && + !rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT) && + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH) && + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN)) { + /* mcs_rate = 0 -> CCK 1M rate */ + /* mcs_rate = 1 -> CCK 2M rate */ + /* mcs_rate = 2 -> CCK 5.5M rate */ + /* mcs_rate = 3 -> CCK 11M rate */ + /* In the P2P mode, the driver should not support the CCK rate */ + + /* Commented by Kurt 2012/10/16 */ + /* IOT issue: Google Nexus7 use 1M rate to send p2p_probe_req after GO nego completed and Nexus7 is client */ + if (wifi_test_chk_rate == 1) { + is_valid_p2p_probereq = process_probe_req_p2p_ie(pwdinfo, pframe, len); + if (is_valid_p2p_probereq) { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { + /* FIXME */ + report_survey_event(padapter, precv_frame); + p2p_listen_state_process(padapter, get_sa(pframe)); + + return _SUCCESS; + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) + goto _continue; + } + } + } + +_continue: +#endif /* CONFIG_88EU_P2P */ + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + return _SUCCESS; + + if (!check_fwstate(pmlmepriv, _FW_LINKED) && + !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) + return _SUCCESS; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + /* check (wildcard) SSID */ + if (p != NULL) { + if (is_valid_p2p_probereq) + goto _issue_probersp; + + if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || + (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) + return _SUCCESS; + +_issue_probersp: + + if (check_fwstate(pmlmepriv, _FW_LINKED) && + (pmlmepriv->cur_network.join_res || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) + issue_probersp(padapter, get_sa(pframe), is_valid_p2p_probereq); + } + return _SUCCESS; +} + +unsigned int OnProbeRsp(struct adapter *padapter, struct recv_frame *precv_frame) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 *pframe = precv_frame->rx_data; +#endif + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { + if (pwdinfo->tx_prov_disc_info.benable) { + if (!memcmp(pwdinfo->tx_prov_disc_info.peerIFAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + pwdinfo->tx_prov_disc_info.benable = false; + issue_p2p_provision_request(padapter, + pwdinfo->tx_prov_disc_info.ssid.Ssid, + pwdinfo->tx_prov_disc_info.ssid.SsidLength, + pwdinfo->tx_prov_disc_info.peerDevAddr); + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + pwdinfo->tx_prov_disc_info.benable = false; + issue_p2p_provision_request(padapter, NULL, 0, + pwdinfo->tx_prov_disc_info.peerDevAddr); + } + } + } + return _SUCCESS; + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { + if (pwdinfo->nego_req_info.benable) { + DBG_88E("[%s] P2P State is GONEGO ING!\n", __func__); + if (!memcmp(pwdinfo->nego_req_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + pwdinfo->nego_req_info.benable = false; + issue_p2p_GO_request(padapter, pwdinfo->nego_req_info.peerDevAddr); + } + } + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { + if (pwdinfo->invitereq_info.benable) { + DBG_88E("[%s] P2P_STATE_TX_INVITE_REQ!\n", __func__); + if (!memcmp(pwdinfo->invitereq_info.peer_macaddr, GetAddr2Ptr(pframe), ETH_ALEN)) { + pwdinfo->invitereq_info.benable = false; + issue_p2p_invitation_request(padapter, pwdinfo->invitereq_info.peer_macaddr); + } + } + } +#endif + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + + return _SUCCESS; +} + +unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) +{ + int cam_idx; + struct sta_info *psta; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + struct wlan_bssid_ex *pbss; + int ret = _SUCCESS; + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + report_survey_event(padapter, precv_frame); + return _SUCCESS; + } + + if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + /* we should update current network before auth, or some IE is wrong */ + pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); + if (pbss) { + if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { + update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); + rtw_get_bcn_info(&(pmlmepriv->cur_network)); + } + kfree(pbss); + } + + /* check the vendor of the assoc AP */ + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe+sizeof(struct rtw_ieee80211_hdr_3addr), len-sizeof(struct rtw_ieee80211_hdr_3addr)); + + /* update TSF Value */ + update_TSF(pmlmeext, pframe, len); + + /* start auth */ + start_clnt_auth(padapter); + + return _SUCCESS; + } + + if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta != NULL) { + ret = rtw_check_bcn_info(padapter, pframe, len); + if (!ret) { + DBG_88E_LEVEL(_drv_info_, "ap has changed, disconnect now\n "); + receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 0); + return _SUCCESS; + } + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, pframe, len, psta); + process_p2p_ps_ie(padapter, (pframe + WLAN_HDR_A3_LEN), (len - WLAN_HDR_A3_LEN)); + } + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta != NULL) { + /* update WMM, ERP in the beacon */ + /* todo: the timer is used instead of the number of the beacon received */ + if ((sta_rx_pkts(psta) & 0xf) == 0) + update_beacon_info(padapter, pframe, len, psta); + } else { + /* allocate a new CAM entry for IBSS station */ + cam_idx = allocate_fw_sta_entry(padapter); + if (cam_idx == NUM_STA) + goto _END_ONBEACON_; + + /* get supported rate */ + if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { + pmlmeinfo->FW_sta_info[cam_idx].status = 0; + goto _END_ONBEACON_; + } + + /* update TSF Value */ + update_TSF(pmlmeext, pframe, len); + + /* report sta add event */ + report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); + } + } + } + +_END_ONBEACON_: + + return _SUCCESS; +} + +unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned int auth_mode, ie_len; + u16 seq; + unsigned char *sa, *p; + u16 algorithm; + int status; + static struct sta_info stat; + struct sta_info *pstat = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return _FAIL; + + DBG_88E("+OnAuth\n"); + + sa = GetAddr2Ptr(pframe); + + auth_mode = psecuritypriv->dot11AuthAlgrthm; + seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + 2)); + algorithm = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("auth alg=%x, seq=%X\n", algorithm, seq); + + if (auth_mode == 2 && psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ && + psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) + auth_mode = 0; + + if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */ + (algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */ + DBG_88E("auth rejected due to bad alg [alg=%d, auth_mib=%d] %02X%02X%02X%02X%02X%02X\n", + algorithm, auth_mode, sa[0], sa[1], sa[2], sa[3], sa[4], sa[5]); + + status = _STATS_NO_SUPP_ALG_; + + goto auth_fail; + } + + if (!rtw_access_ctrl(padapter, sa)) { + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat = rtw_get_stainfo(pstapriv, sa); + if (pstat == NULL) { + /* allocate a new one */ + DBG_88E("going to alloc stainfo for sa=%pM\n", sa); + pstat = rtw_alloc_stainfo(pstapriv, sa); + if (pstat == NULL) { + DBG_88E(" Exceed the upper limit of supported clients...\n"); + status = _STATS_UNABLE_HANDLE_STA_; + goto auth_fail; + } + + pstat->state = WIFI_FW_AUTH_NULL; + pstat->auth_seq = 0; + } else { + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&pstat->asoc_list)) { + list_del_init(&pstat->asoc_list); + pstapriv->asoc_list_cnt--; + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + if (seq == 1) { + /* TODO: STA re_auth and auth timeout */ + } + } + + spin_lock_bh(&pstapriv->auth_list_lock); + if (list_empty(&pstat->auth_list)) { + list_add_tail(&pstat->auth_list, &pstapriv->auth_list); + pstapriv->auth_list_cnt++; + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + if (pstat->auth_seq == 0) + pstat->expire_to = pstapriv->auth_to; + + if ((pstat->auth_seq + 1) != seq) { + DBG_88E("(1)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + + if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { + if (seq == 1) { + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_SUCCESS; + pstat->expire_to = pstapriv->assoc_to; + pstat->authalg = algorithm; + } else { + DBG_88E("(2)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + } else { /* shared system or auto authentication */ + if (seq == 1) { + /* prepare for the challenging txt... */ + + pstat->state &= ~WIFI_FW_AUTH_NULL; + pstat->state |= WIFI_FW_AUTH_STATE; + pstat->authalg = algorithm; + pstat->auth_seq = 2; + } else if (seq == 3) { + /* checking for challenging txt... */ + DBG_88E("checking for challenging txt...\n"); + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_ , _CHLGETXT_IE_, (int *)&ie_len, + len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); + + if ((p == NULL) || (ie_len <= 0)) { + DBG_88E("auth rejected because challenge failure!(1)\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + + if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) { + pstat->state &= (~WIFI_FW_AUTH_STATE); + pstat->state |= WIFI_FW_AUTH_SUCCESS; + /* challenging txt is correct... */ + pstat->expire_to = pstapriv->assoc_to; + } else { + DBG_88E("auth rejected because challenge failure!\n"); + status = _STATS_CHALLENGE_FAIL_; + goto auth_fail; + } + } else { + DBG_88E("(3)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", + seq, pstat->auth_seq+1); + status = _STATS_OUT_OF_AUTH_SEQ_; + goto auth_fail; + } + } + + /* Now, we are going to issue_auth... */ + pstat->auth_seq = seq + 1; + +#ifdef CONFIG_88EU_AP_MODE + issue_auth(padapter, pstat, (unsigned short)(_STATS_SUCCESSFUL_)); +#endif + + if (pstat->state & WIFI_FW_AUTH_SUCCESS) + pstat->auth_seq = 0; + + return _SUCCESS; + +auth_fail: + + if (pstat) + rtw_free_stainfo(padapter , pstat); + + pstat = &stat; + memset((char *)pstat, '\0', sizeof(stat)); + pstat->auth_seq = 2; + memcpy(pstat->hwaddr, sa, 6); + +#ifdef CONFIG_88EU_AP_MODE + issue_auth(padapter, pstat, (unsigned short)status); +#endif + +#endif + return _FAIL; +} + +unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int seq, len, status, offset; + unsigned char *p; + unsigned int go2asoc = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; + + DBG_88E("%s\n", __func__); + + /* check A1 matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + return _SUCCESS; + + if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) + return _SUCCESS; + + offset = (GetPrivacy(pframe)) ? 4 : 0; + + seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2)); + status = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4)); + + if (status != 0) { + DBG_88E("clnt auth fail, status: %d\n", status); + if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; + else + pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; + } + + set_link_timer(pmlmeext, 1); + goto authclnt_fail; + } + + if (seq == 2) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { + /* legendary shared system */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, + pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); + + if (p == NULL) + goto authclnt_fail; + + memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); + pmlmeinfo->auth_seq = 3; + issue_auth(padapter, NULL, 0); + set_link_timer(pmlmeext, REAUTH_TO); + + return _SUCCESS; + } else { + /* open system */ + go2asoc = 1; + } + } else if (seq == 4) { + if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) + go2asoc = 1; + else + goto authclnt_fail; + } else { + /* this is also illegal */ + goto authclnt_fail; + } + + if (go2asoc) { + DBG_88E_LEVEL(_drv_info_, "auth success, start assoc\n"); + start_clnt_assoc(padapter); + return _SUCCESS; + } +authclnt_fail: + return _FAIL; +} + +unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + u16 capab_info; + struct rtw_ieee802_11_elems elems; + struct sta_info *pstat; + unsigned char reassoc, *p, *pos, *wpa_ie; + unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; + int i, ie_len, wpa_ie_len, left; + unsigned char supportRate[16]; + int supportRateNum; + unsigned short status = _STATS_SUCCESSFUL_; + unsigned short frame_type, ie_offset = 0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 p2p_status_code = P2P_STATUS_SUCCESS; + u8 *p2pie; + u32 p2pielen = 0; +#endif /* CONFIG_88EU_P2P */ + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + return _FAIL; + + frame_type = GetFrameSubType(pframe); + if (frame_type == WIFI_ASSOCREQ) { + reassoc = 0; + ie_offset = _ASOCREQ_IE_OFFSET_; + } else { /* WIFI_REASSOCREQ */ + reassoc = 1; + ie_offset = _REASOCREQ_IE_OFFSET_; + } + + if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset) { + DBG_88E("handle_assoc(reassoc=%d) - too short payload (len=%lu)" + "\n", reassoc, (unsigned long)pkt_len); + return _FAIL; + } + + pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (pstat == (struct sta_info *)NULL) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } + + capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN); + + left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); + pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); + + DBG_88E("%s\n", __func__); + + /* check if this stat has been successfully authenticated/assocated */ + if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) { + if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) { + status = _RSON_CLS2_; + goto asoc_class2_error; + } else { + pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } + } else { + pstat->state &= (~WIFI_FW_AUTH_SUCCESS); + pstat->state |= WIFI_FW_ASSOC_STATE; + } + pstat->capability = capab_info; + /* now parse all ieee802_11 ie to point to elems */ + if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed || + !elems.ssid) { + DBG_88E("STA %pM sent invalid association request\n", + pstat->hwaddr); + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } + + /* now we should check all the fields... */ + /* checking SSID */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p == NULL) + status = _STATS_FAILURE_; + + if (ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ + status = _STATS_FAILURE_; + } else { + /* check if ssid match */ + if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + status = _STATS_FAILURE_; + + if (ie_len != cur->Ssid.SsidLength) + status = _STATS_FAILURE_; + } + + if (_STATS_SUCCESSFUL_ != status) + goto OnAssocReqFail; + + /* check if the supported rate is ok */ + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p == NULL) { + DBG_88E("Rx a sta assoc-req which supported rate is empty!\n"); + /* use our own rate set as statoin used */ + /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ + /* supportRateNum = AP_BSSRATE_LEN; */ + + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } else { + memcpy(supportRate, p+2, ie_len); + supportRateNum = ie_len; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_ , &ie_len, + pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (supportRateNum <= sizeof(supportRate)) { + memcpy(supportRate+supportRateNum, p+2, ie_len); + supportRateNum += ie_len; + } + } + } + + /* todo: mask supportRate between AP & STA -> move to update raid */ + /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */ + + /* update station supportRate */ + pstat->bssratelen = supportRateNum; + memcpy(pstat->bssrateset, supportRate, supportRateNum); + UpdateBrateTblForSoftAP(pstat->bssrateset, pstat->bssratelen); + + /* check RSN/WPA/WPS */ + pstat->dot8021xalg = 0; + pstat->wpa_psk = 0; + pstat->wpa_group_cipher = 0; + pstat->wpa2_group_cipher = 0; + pstat->wpa_pairwise_cipher = 0; + pstat->wpa2_pairwise_cipher = 0; + memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); + if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) { + int group_cipher = 0, pairwise_cipher = 0; + + wpa_ie = elems.rsn_ie; + wpa_ie_len = elems.rsn_ie_len; + + if (rtw_parse_wpa2_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(1); + + pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + + if (!pstat->wpa2_group_cipher) + status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + + if (!pstat->wpa2_pairwise_cipher) + status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + } else { + status = WLAN_STATUS_INVALID_IE; + } + } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) { + int group_cipher = 0, pairwise_cipher = 0; + + wpa_ie = elems.wpa_ie; + wpa_ie_len = elems.wpa_ie_len; + + if (rtw_parse_wpa_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + pstat->dot8021xalg = 1;/* psk, todo:802.1x */ + pstat->wpa_psk |= BIT(0); + + pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + + if (!pstat->wpa_group_cipher) + status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; + + if (!pstat->wpa_pairwise_cipher) + status = WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID; + } else { + status = WLAN_STATUS_INVALID_IE; + } + } else { + wpa_ie = NULL; + wpa_ie_len = 0; + } + + if (_STATS_SUCCESSFUL_ != status) + goto OnAssocReqFail; + + pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); + if (wpa_ie == NULL) { + if (elems.wps_ie) { + DBG_88E("STA included WPS IE in " + "(Re)Association Request - assume WPS is " + "used\n"); + pstat->flags |= WLAN_STA_WPS; + /* wpabuf_free(sta->wps_ie); */ + /* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */ + /* elems.wps_ie_len - 4); */ + } else { + DBG_88E("STA did not include WPA/RSN IE " + "in (Re)Association Request - possible WPS " + "use\n"); + pstat->flags |= WLAN_STA_MAYBE_WPS; + } + + /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ + /* that the selected registrar of AP is _FLASE */ + if ((psecuritypriv->wpa_psk > 0) && (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) { + if (pmlmepriv->wps_beacon_ie) { + u8 selected_registrar = 0; + + rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar, NULL); + + if (!selected_registrar) { + DBG_88E("selected_registrar is false , or AP is not ready to do WPS\n"); + + status = _STATS_UNABLE_HANDLE_STA_; + + goto OnAssocReqFail; + } + } + } + } else { + int copy_len; + + if (psecuritypriv->wpa_psk == 0) { + DBG_88E("STA %pM: WPA/RSN IE in association " + "request, but AP don't support WPA/RSN\n", pstat->hwaddr); + + status = WLAN_STATUS_INVALID_IE; + + goto OnAssocReqFail; + } + + if (elems.wps_ie) { + DBG_88E("STA included WPS IE in " + "(Re)Association Request - WPS is " + "used\n"); + pstat->flags |= WLAN_STA_WPS; + copy_len = 0; + } else { + copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)) : (wpa_ie_len+2); + } + if (copy_len > 0) + memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + } + /* check if there is WMM IE & support WWM-PS */ + pstat->flags &= ~WLAN_STA_WME; + pstat->qos_option = 0; + pstat->qos_info = 0; + pstat->has_legacy_ac = true; + pstat->uapsd_vo = 0; + pstat->uapsd_vi = 0; + pstat->uapsd_be = 0; + pstat->uapsd_bk = 0; + if (pmlmepriv->qospriv.qos_option) { + p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; + for (;;) { + p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); + if (p != NULL) { + if (!memcmp(p+2, WMM_IE, 6)) { + pstat->flags |= WLAN_STA_WME; + + pstat->qos_option = 1; + pstat->qos_info = *(p+8); + + pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + + if ((pstat->qos_info&0xf) != 0xf) + pstat->has_legacy_ac = true; + else + pstat->has_legacy_ac = false; + + if (pstat->qos_info&0xf) { + if (pstat->qos_info&BIT(0)) + pstat->uapsd_vo = BIT(0)|BIT(1); + else + pstat->uapsd_vo = 0; + + if (pstat->qos_info&BIT(1)) + pstat->uapsd_vi = BIT(0)|BIT(1); + else + pstat->uapsd_vi = 0; + + if (pstat->qos_info&BIT(2)) + pstat->uapsd_bk = BIT(0)|BIT(1); + else + pstat->uapsd_bk = 0; + + if (pstat->qos_info&BIT(3)) + pstat->uapsd_be = BIT(0)|BIT(1); + else + pstat->uapsd_be = 0; + } + break; + } + } else { + break; + } + p = p + ie_len + 2; + } + } + + /* save HT capabilities in the sta object */ + memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); + if (elems.ht_capabilities && elems.ht_capabilities_len >= sizeof(struct ieee80211_ht_cap)) { + pstat->flags |= WLAN_STA_HT; + + pstat->flags |= WLAN_STA_WME; + + memcpy(&pstat->htpriv.ht_cap, elems.ht_capabilities, sizeof(struct ieee80211_ht_cap)); + } else { + pstat->flags &= ~WLAN_STA_HT; + } + if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags&WLAN_STA_HT)) { + status = _STATS_FAILURE_; + goto OnAssocReqFail; + } + + if ((pstat->flags & WLAN_STA_HT) && + ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || + (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { + DBG_88E("HT: %pM tried to " + "use TKIP with HT association\n", pstat->hwaddr); + + /* status = WLAN_STATUS_CIPHER_REJECTED_PER_POLICY; */ + /* goto OnAssocReqFail; */ + } + + pstat->flags |= WLAN_STA_NONERP; + for (i = 0; i < pstat->bssratelen; i++) { + if ((pstat->bssrateset[i] & 0x7f) > 22) { + pstat->flags &= ~WLAN_STA_NONERP; + break; + } + } + + if (pstat->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) + pstat->flags |= WLAN_STA_SHORT_PREAMBLE; + else + pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE; + + if (status != _STATS_SUCCESSFUL_) + goto OnAssocReqFail; + +#ifdef CONFIG_88EU_P2P + pstat->is_p2p_device = false; + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + ie_offset , pkt_len - WLAN_HDR_A3_LEN - ie_offset , NULL, &p2pielen); + if (p2pie) { + pstat->is_p2p_device = true; + p2p_status_code = (u8)process_assoc_req_p2p_ie(pwdinfo, pframe, pkt_len, pstat); + if (p2p_status_code > 0) { + pstat->p2p_status_code = p2p_status_code; + status = _STATS_CAP_FAIL_; + goto OnAssocReqFail; + } + } + } + pstat->p2p_status_code = p2p_status_code; +#endif /* CONFIG_88EU_P2P */ + + /* TODO: identify_proprietary_vendor_ie(); */ + /* Realtek proprietary IE */ + /* identify if this is Broadcom sta */ + /* identify if this is ralink sta */ + /* Customer proprietary IE */ + + /* get a unique AID */ + if (pstat->aid > 0) { + DBG_88E(" old AID %d\n", pstat->aid); + } else { + for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++) + if (pstapriv->sta_aid[pstat->aid - 1] == NULL) + break; + + /* if (pstat->aid > NUM_STA) { */ + if (pstat->aid > pstapriv->max_num_sta) { + pstat->aid = 0; + + DBG_88E(" no room for more AIDs\n"); + + status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; + + goto OnAssocReqFail; + } else { + pstapriv->sta_aid[pstat->aid - 1] = pstat; + DBG_88E("allocate new AID=(%d)\n", pstat->aid); + } + } + + pstat->state &= (~WIFI_FW_ASSOC_STATE); + pstat->state |= WIFI_FW_ASSOC_SUCCESS; + + spin_lock_bh(&pstapriv->auth_list_lock); + if (!list_empty(&pstat->auth_list)) { + list_del_init(&pstat->auth_list); + pstapriv->auth_list_cnt--; + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + spin_lock_bh(&pstapriv->asoc_list_lock); + if (list_empty(&pstat->asoc_list)) { + pstat->expire_to = pstapriv->expire_to; + list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list); + pstapriv->asoc_list_cnt++; + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + /* now the station is qualified to join our BSS... */ + if (pstat && (pstat->state & WIFI_FW_ASSOC_SUCCESS) && (_STATS_SUCCESSFUL_ == status)) { +#ifdef CONFIG_88EU_AP_MODE + /* 1 bss_cap_update & sta_info_update */ + bss_cap_update_on_sta_join(padapter, pstat); + sta_info_update(padapter, pstat); + + /* issue assoc rsp before notify station join event. */ + if (frame_type == WIFI_ASSOCREQ) + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + else + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); + + /* 2 - report to upper layer */ + DBG_88E("indicate_sta_join_event to upper layer - hostapd\n"); + rtw_indicate_sta_assoc_event(padapter, pstat); + + /* 3-(1) report sta add event */ + report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); +#endif + } + + return _SUCCESS; + +asoc_class2_error: + +#ifdef CONFIG_88EU_AP_MODE + issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); +#endif + + return _FAIL; + +OnAssocReqFail: + +#ifdef CONFIG_88EU_AP_MODE + pstat->aid = 0; + if (frame_type == WIFI_ASSOCREQ) + issue_asocrsp(padapter, status, pstat, WIFI_ASSOCRSP); + else + issue_asocrsp(padapter, status, pstat, WIFI_REASSOCRSP); +#endif + +#endif /* CONFIG_88EU_AP_MODE */ + + return _FAIL; +} + +unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame) +{ + uint i; + int res; + unsigned short status; + struct ndis_802_11_var_ie *pIE; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */ + u8 *pframe = precv_frame->rx_data; + uint pkt_len = precv_frame->len; + + DBG_88E("%s\n", __func__); + + /* check A1 matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + return _SUCCESS; + + if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) + return _SUCCESS; + + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) + return _SUCCESS; + + _cancel_timer_ex(&pmlmeext->link_timer); + + /* status */ + status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); + if (status > 0) { + DBG_88E("assoc reject, status code: %d\n", status); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + res = -4; + goto report_assoc_result; + } + + /* get capabilities */ + pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + /* set slot time */ + pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; + + /* AID */ + pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); + res = pmlmeinfo->aid; + + /* following are moved to join event callback function */ + /* to handle HT, WMM, rate adaptive, update MAC reg */ + /* for not to handle the synchronous IO in the tasklet */ + for (i = (6 + WLAN_HDR_A3_LEN); i < pkt_len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ + WMM_param_handler(padapter, pIE); + break; + case _HT_CAPABILITY_IE_: /* HT caps */ + HT_caps_handler(padapter, pIE); + break; + case _HT_EXTRA_INFO_IE_: /* HT info */ + HT_info_handler(padapter, pIE); + break; + case _ERPINFO_IE_: + ERP_IE_handler(padapter, pIE); + default: + break; + } + + i += (pIE->Length + 2); + } + + pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + + /* Update Basic Rate Table for spec, 2010-12-28 , by thomas */ + UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); + +report_assoc_result: + if (res > 0) { + rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); + } else { + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + } + + report_join_res(padapter, res); + + return _SUCCESS; +} + +unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned short reason; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + /* check A3 */ + if (!(!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + return _SUCCESS; + +#ifdef CONFIG_88EU_P2P + if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); + } +#endif /* CONFIG_88EU_P2P */ + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("%s Reason code(%d)\n", __func__, reason); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E_LEVEL(_drv_always_, "ap recv deauth reason code(%d) sta:%pM\n", + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta) { + u8 updated = 0; + + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + associated_clients_update(padapter, updated); + } + + return _SUCCESS; + } else +#endif + { + int ignore_received_deauth = 0; + + /* Before sending the auth frame to start the STA/GC mode connection with AP/GO, + * we will send the deauth first. + * However, the Win8.1 with BRCM Wi-Fi will send the deauth with reason code 6 to us after receieving our deauth. + * Added the following code to avoid this case. + */ + if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) || + (pmlmeinfo->state & WIFI_FW_ASSOC_STATE )) { + if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) { + ignore_received_deauth = 1; + } else if (WLAN_REASON_PREV_AUTH_NOT_VALID == reason) { + // TODO: 802.11r + ignore_received_deauth = 1; + } + } + + DBG_88E_LEVEL(_drv_always_, "sta recv deauth reason code(%d) sta:%pM, ignore = %d\n", + reason, GetAddr3Ptr(pframe), ignore_received_deauth); + + if (!ignore_received_deauth) + receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; +} + +unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame) +{ + u16 reason; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + /* check A3 */ + if (!(!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + return _SUCCESS; + +#ifdef CONFIG_88EU_P2P + if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); + } +#endif /* CONFIG_88EU_P2P */ + + reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); + + DBG_88E("%s Reason code(%d)\n", __func__, reason); + +#ifdef CONFIG_88EU_AP_MODE + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr2Ptr(pframe)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + if (psta) { + u8 updated = 0; + + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, false, reason); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + associated_clients_update(padapter, updated); + } + + return _SUCCESS; + } else +#endif + { + DBG_88E_LEVEL(_drv_always_, "ap recv disassoc reason code(%d) sta:%pM\n", + reason, GetAddr3Ptr(pframe)); + + receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); + } + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + return _SUCCESS; +} + +unsigned int OnAtim(struct adapter *padapter, struct recv_frame *precv_frame) +{ + DBG_88E("%s\n", __func__); + return _SUCCESS; +} + +unsigned int on_action_spct(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = (u8 *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + u8 category; + u8 action; + + DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); + + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + + if (!psta) + goto exit; + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_SPECTRUM_MGMT) + goto exit; + + action = frame_body[1]; + switch (action) { + case RTW_WLAN_ACTION_SPCT_MSR_REQ: + case RTW_WLAN_ACTION_SPCT_MSR_RPRT: + case RTW_WLAN_ACTION_SPCT_TPC_REQ: + case RTW_WLAN_ACTION_SPCT_TPC_RPRT: + break; + case RTW_WLAN_ACTION_SPCT_CHL_SWITCH: + break; + default: + break; + } + +exit: + return ret; +} + +unsigned int OnAction_qos(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_dls(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_frame) +{ + u8 *addr; + struct sta_info *psta = NULL; + struct recv_reorder_ctrl *preorder_ctrl; + unsigned char *frame_body; + unsigned char category, action; + unsigned short tid, status, reason_code = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 *pframe = precv_frame->rx_data; + struct sta_priv *pstapriv = &padapter->stapriv; + /* check RA matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + return _SUCCESS; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) + return _SUCCESS; + + addr = GetAddr2Ptr(pframe); + psta = rtw_get_stainfo(pstapriv, addr); + + if (psta == NULL) + return _SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + if (category == RTW_WLAN_CATEGORY_BACK) { /* representing Block Ack */ + if (!pmlmeinfo->HT_enable) + return _SUCCESS; + action = frame_body[1]; + DBG_88E("%s, action=%d\n", __func__, action); + switch (action) { + case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ + memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); + process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); + + if (pmlmeinfo->bAcceptAddbaReq) + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); + else + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 37);/* reject ADDBA Req */ + break; + case RTW_WLAN_ACTION_ADDBA_RESP: /* ADDBA response */ + status = get_unaligned_le16(&frame_body[3]); + tid = ((frame_body[5] >> 2) & 0x7); + if (status == 0) { /* successful */ + DBG_88E("agg_enable for TID=%d\n", tid); + psta->htpriv.agg_enable_bitmap |= 1 << tid; + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); + } else { + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + } + break; + case RTW_WLAN_ACTION_DELBA: /* DELBA */ + if ((frame_body[3] & BIT(3)) == 0) { + psta->htpriv.agg_enable_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); + psta->htpriv.candidate_tid_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); + reason_code = get_unaligned_le16(&frame_body[4]); + } else if ((frame_body[3] & BIT(3)) == BIT(3)) { + tid = (frame_body[3] >> 4) & 0x0F; + preorder_ctrl = &psta->recvreorder_ctrl[tid]; + preorder_ctrl->enable = false; + preorder_ctrl->indicate_seq = 0xffff; + } + DBG_88E("%s(): DELBA: %x(%x)\n", __func__, pmlmeinfo->agg_enable_bitmap, reason_code); + /* todo: how to notify the host while receiving DELETE BA */ + break; + default: + break; + } + } + return _SUCCESS; +} + +#ifdef CONFIG_88EU_P2P + +static int get_reg_classes_full_count(struct p2p_channels *channel_list) +{ + int cnt = 0; + int i; + + for (i = 0; i < channel_list->reg_classes; i++) { + cnt += channel_list->reg_class[i].channels; + } + + return cnt; +} + +void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_NEGO_REQ; + u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; + u8 wpsielen = 0, p2pielen = 0; + u16 len_channellist_attr = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In\n", __func__); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pwdinfo->negotiation_dialog_token = 1; /* Initialize the dialog value */ + pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &(pattrib->pktlen)); + + /* WPS Section */ + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* Device Password ID */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + + if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); + else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); + else if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); + + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110306 */ + /* According to the P2P Specification, the group negoitation request frame should contain 9 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Group Owner Intent */ + /* 3. Configuration Timeout */ + /* 4. Listen Channel */ + /* 5. Extended Listen Timing */ + /* 6. Intended P2P Interface Address */ + /* 7. Channel List */ + /* 8. P2P Device Info */ + /* 9. Operating Channel */ + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; + else + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; + + /* Group Owner Intent */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + /* Todo the tie breaker bit. */ + p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + /* Listen Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->listen_channel; /* listening channel number */ + + /* Extended Listen Timing ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Intended P2P Interface Address */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)(pmlmeext->channel_list.reg_classes) + + get_reg_classes_full_count(&pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame_body, uint len, u8 result) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_NEGO_RESP; + u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + uint wpsielen = 0; + u16 wps_devicepassword_id = 0x0000; + __be16 be_tmp; + uint wps_devicepassword_id_len = 0; + u16 len_channellist_attr = 0; + + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In, result=%d\n", __func__, result); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pwdinfo->negotiation_dialog_token = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ + pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); + + /* Commented by Albert 20110328 */ + /* Try to get the device password ID from the WPS IE of group negotiation request frame */ + /* WiFi Direct test plan 5.1.15 */ + rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, wpsie, &wpsielen); + rtw_get_wps_attr_content(wpsie, wpsielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); + wps_devicepassword_id = be16_to_cpu(be_tmp); + + memset(wpsie, 0x00, 255); + wpsielen = 0; + + /* WPS Section */ + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* Device Password ID */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + if (wps_devicepassword_id == WPS_DPID_USER_SPEC) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); + else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_USER_SPEC); + else + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_PBC); + wpsielen += 2; + + /* Commented by Kurt 20120113 */ + /* If some device wants to do p2p handshake without sending prov_disc_req */ + /* We have to get peer_req_cm from here. */ + if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { + if (wps_devicepassword_id == WPS_DPID_USER_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); + else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); + else + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20100908 */ + /* According to the P2P Specification, the group negoitation response frame should contain 9 P2P attributes */ + /* 1. Status */ + /* 2. P2P Capability */ + /* 3. Group Owner Intent */ + /* 4. Configuration Timeout */ + /* 5. Operating Channel */ + /* 6. Intended P2P Interface Address */ + /* 7. Channel List */ + /* 8. Device Info */ + /* 9. Group ID (Only GO) */ + + /* ToDo: */ + + /* P2P Status */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_STATUS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = result; + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + /* Commented by Albert 2011/03/08 */ + /* According to the P2P specification */ + /* if the sending device will be client, the P2P Capability should be reserved of group negotiation response frame */ + p2pie[p2pielen++] = 0; + } else { + /* Be group owner or meet the error case */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + } + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) { + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; + } else { + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; + } + + /* Group Owner Intent */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GO_INTENT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + if (pwdinfo->peer_intent & 0x01) { + /* Peer's tie breaker bit is 1, our tie breaker bit should be 0 */ + p2pie[p2pielen++] = (pwdinfo->intent << 1); + } else { + /* Peer's tie breaker bit is 0, our tie breaker bit should be 1 */ + p2pie[p2pielen++] = ((pwdinfo->intent << 1) | BIT(0)); + } + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + + /* Intended P2P Interface Address */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INTENTED_IF_ADDR; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + + get_reg_classes_full_count(&pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Group ID Attribute */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); + p2pielen += 2; + + /* Value: */ + /* p2P Device Address */ + memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* SSID */ + memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + p2pielen += pwdinfo->nego_ssidlen; + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + return; +} + +static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_NEGO_CONF; + u8 p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In\n", __func__); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110306 */ + /* According to the P2P Specification, the group negoitation request frame should contain 5 P2P attributes */ + /* 1. Status */ + /* 2. P2P Capability */ + /* 3. Operating Channel */ + /* 4. Channel List */ + /* 5. Group ID (if this WiFi is GO) */ + + /* P2P Status */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_STATUS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = result; + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN | P2P_GRPCAP_PERSISTENT_GROUP; + else + p2pie[p2pielen++] = P2P_GRPCAP_CROSS_CONN; + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + p2pie[p2pielen++] = pwdinfo->peer_operating_ch; + } else { + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* Use the listen channel as the operating channel */ + } + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(pwdinfo->channel_list_attr_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len); + p2pielen += pwdinfo->channel_list_attr_len; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Group ID Attribute */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + pwdinfo->nego_ssidlen); + p2pielen += 2; + + /* Value: */ + /* p2P Device Address */ + memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* SSID */ + memcpy(p2pie + p2pielen, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + p2pielen += pwdinfo->nego_ssidlen; + } + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + pattrib->last_txcmdsz = pattrib->pktlen; + dump_mgntframe(padapter, pmgntframe); + return; +} + +void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_INVIT_REQ; + u8 p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + u8 dialogToken = 3; + u16 len_channellist_attr = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20101011 */ + /* According to the P2P Specification, the P2P Invitation request frame should contain 7 P2P attributes */ + /* 1. Configuration Timeout */ + /* 2. Invitation Flags */ + /* 3. Operating Channel (Only GO) */ + /* 4. P2P Group BSSID (Should be included if I am the GO) */ + /* 5. Channel List */ + /* 6. P2P Group ID */ + /* 7. P2P Device Info */ + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + /* Invitation Flags */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INVITATION_FLAGS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = P2P_INVITATION_FLAGS_PERSISTENT; + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->invitereq_info.operating_ch; /* operating channel number */ + + if (!memcmp(myid(&padapter->eeprompriv), pwdinfo->invitereq_info.go_bssid, ETH_ALEN)) { + /* P2P Group BSSID */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address for GO */ + memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); + p2pielen += ETH_ALEN; + } + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + + get_reg_classes_full_count(&pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + + /* P2P Group ID */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(6 + pwdinfo->invitereq_info.ssidlen); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address for GO */ + memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_bssid, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* SSID */ + memcpy(p2pie + p2pielen, pwdinfo->invitereq_info.go_ssid, pwdinfo->invitereq_info.ssidlen); + p2pielen += pwdinfo->invitereq_info.ssidlen; + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialogToken, u8 status_code) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_INVIT_RESP; + u8 p2pie[255] = { 0x00 }; + u8 p2pielen = 0; + u16 len_channellist_attr = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* P2P IE Section. */ + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20101005 */ + /* According to the P2P Specification, the P2P Invitation response frame should contain 5 P2P attributes */ + /* 1. Status */ + /* 2. Configuration Timeout */ + /* 3. Operating Channel (Only GO) */ + /* 4. P2P Group BSSID (Only GO) */ + /* 5. Channel List */ + + /* P2P Status */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_STATUS; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0001); + p2pielen += 2; + + /* Value: */ + /* When status code is P2P_STATUS_FAIL_INFO_UNAVAILABLE. */ + /* Sent the event receiving the P2P Invitation Req frame to DMP UI. */ + /* DMP had to compare the MAC address to find out the profile. */ + /* So, the WiFi driver will send the P2P_STATUS_FAIL_INFO_UNAVAILABLE to NB. */ + /* If the UI found the corresponding profile, the WiFi driver sends the P2P Invitation Req */ + /* to NB to rebuild the persistent group. */ + p2pie[p2pielen++] = status_code; + + /* Configuration Timeout */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CONF_TIMEOUT; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P GO */ + p2pie[p2pielen++] = 200; /* 2 seconds needed to be the P2P Client */ + + if (status_code == P2P_STATUS_SUCCESS) { + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* The P2P Invitation request frame asks this Wi-Fi device to be the P2P GO */ + /* In this case, the P2P Invitation response frame should carry the two more P2P attributes. */ + /* First one is operating channel attribute. */ + /* Second one is P2P Group BSSID attribute. */ + + /* Operating Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + + /* P2P Group BSSID */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_BSSID; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(ETH_ALEN); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address for GO */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + } + + /* Channel List */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CH_LIST; + + /* Length: */ + /* Country String(3) */ + /* + (Operating Class (1) + Number of Channels(1)) * Operation Classes (?) */ + /* + number of channels in all classes */ + len_channellist_attr = 3 + + (1 + 1) * (u16)pmlmeext->channel_list.reg_classes + + get_reg_classes_full_count(&pmlmeext->channel_list); + + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(len_channellist_attr); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Channel Entry List */ + { + int i, j; + for (j = 0; j < pmlmeext->channel_list.reg_classes; j++) { + /* Operating Class */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].reg_class; + + /* Number of Channels */ + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channels; + + /* Channel List */ + for (i = 0; i < pmlmeext->channel_list.reg_class[j].channels; i++) { + p2pie[p2pielen++] = pmlmeext->channel_list.reg_class[j].channel[i]; + } + } + } + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) +{ + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + u8 dialogToken = 1; + u8 oui_subtype = P2P_PROVISION_DISC_REQ; + u8 wpsie[100] = { 0x00 }; + u8 wpsielen = 0; + __be32 p2poui = cpu_to_be32(P2POUI); + u32 p2pielen = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + DBG_88E("[%s] In\n", __func__); + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, pdev_raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, pdev_raddr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + p2pielen = build_prov_disc_request_p2p_ie(pwdinfo, pframe, pssid, ussidlen, pdev_raddr); + + pframe += p2pielen; + pattrib->pktlen += p2pielen; + + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* Config Method */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->tx_prov_disc_info.wps_config_method_request); + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profileinfo) +{ + u8 i, match_result = 0; + + DBG_88E("[%s] peermac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + peermacaddr[0], peermacaddr[1], peermacaddr[2], peermacaddr[3], peermacaddr[4], peermacaddr[5]); + + for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { + DBG_88E("[%s] profileinfo_mac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + profileinfo->peermac[0], profileinfo->peermac[1], profileinfo->peermac[2], profileinfo->peermac[3], profileinfo->peermac[4], profileinfo->peermac[5]); + if (!memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) { + match_result = 1; + DBG_88E("[%s] Match!\n", __func__); + break; + } + } + return match_result; +} + +void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned char *mac; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + u16 beacon_interval = 100; + u16 capInfo = 0; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 wpsie[255] = { 0x00 }; + u32 wpsielen = 0, p2pielen = 0; + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + + /* Use the device address for BSSID field. */ + memcpy(pwlanhdr->addr3, mac, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(fctrl, WIFI_PROBERSP); + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = pattrib->hdrlen; + pframe += pattrib->hdrlen; + + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; + + /* beacon interval: 2 bytes */ + memcpy(pframe, (unsigned char *)&beacon_interval, 2); + pframe += 2; + pattrib->pktlen += 2; + + /* capability info: 2 bytes */ + /* ESS and IBSS bits must be 0 (defined in the 3.1.2.1.1 of WiFi Direct Spec) */ + capInfo |= cap_ShortPremble; + capInfo |= cap_ShortSlot; + + memcpy(pframe, (unsigned char *)&capInfo, 2); + pframe += 2; + pattrib->pktlen += 2; + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, 7, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); + + /* supported rates... */ + /* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&pwdinfo->listen_channel, &pattrib->pktlen); + + /* Todo: WPS IE */ + /* Noted by Albert 20100907 */ + /* According to the WPS specification, all the WPS attribute is presented by Big Endian. */ + + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + /* WiFi Simple Config State */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SIMPLE_CONF_STATE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_WSC_STATE_NOT_CONFIG; /* Not Configured. */ + + /* Response Type */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_RESP_TYPE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_RESPONSE_TYPE_8021X; + + /* UUID-E */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); + wpsielen += 0x10; + + /* Manufacturer */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MANUFACTURER); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0007); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, "Realtek", 7); + wpsielen += 7; + + /* Model Name */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NAME); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0006); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, "8188EU", 6); + wpsielen += 6; + + /* Model Number */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_MODEL_NUMBER); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = 0x31; /* character 1 */ + + /* Serial Number */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_SERIAL_NUMBER); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(ETH_ALEN); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, "123456" , ETH_ALEN); + wpsielen += ETH_ALEN; + + /* Primary Device Type */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008); + wpsielen += 2; + + /* Value: */ + /* Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + wpsielen += 2; + + /* OUI */ + *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* Sub Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + wpsielen += 2; + + /* Device Name */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len); + wpsielen += 2; + + /* Value: */ + if (pwdinfo->device_name_len) { + memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len); + wpsielen += pwdinfo->device_name_len; + } + + /* Config Method */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + p2pielen = build_probe_resp_p2p_ie(pwdinfo, pframe); + pframe += p2pielen; + pattrib->pktlen += p2pielen; + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned char *mac; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; + u16 wpsielen = 0, p2pielen = 0; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if (da) { + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr3, da, ETH_ALEN); + } else { + if ((pwdinfo->p2p_info.scan_op_ch_only) || (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { + /* This two flags will be set when this is only the P2P client mode. */ + memcpy(pwlanhdr->addr1, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->p2p_peer_interface_addr, ETH_ALEN); + } else { + /* broadcast probe request frame */ + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); + } + } + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_PROBEREQ); + + pframe += sizeof (struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) + pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &(pattrib->pktlen)); + else + pframe = rtw_set_ie(pframe, _SSID_IE_, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &(pattrib->pktlen)); + + /* Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); + + /* WPS IE */ + /* Noted by Albert 20110221 */ + /* According to the WPS specification, all the WPS attribute is presented by Big Endian. */ + + wpsielen = 0; + /* WPS OUI */ + *(__be32 *)(wpsie) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* WPS version */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_VER1); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0001); + wpsielen += 2; + + /* Value: */ + wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ + + if (pmlmepriv->wps_probe_req_ie == NULL) { + /* UUID-E */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0010); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, myid(&padapter->eeprompriv), ETH_ALEN); + wpsielen += 0x10; + + /* Config Method */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->supported_wps_cm); + wpsielen += 2; + } + + /* Device Name */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(pwdinfo->device_name_len); + wpsielen += 2; + + /* Value: */ + memcpy(wpsie + wpsielen, pwdinfo->device_name, pwdinfo->device_name_len); + wpsielen += pwdinfo->device_name_len; + + /* Primary Device Type */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0008); + wpsielen += 2; + + /* Value: */ + /* Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_CID_RTK_WIDI); + wpsielen += 2; + + /* OUI */ + *(__be32 *)(wpsie + wpsielen) = cpu_to_be32(WPSOUI); + wpsielen += 4; + + /* Sub Category ID */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_PDT_SCID_RTK_DMP); + wpsielen += 2; + + /* Device Password ID */ + /* Type: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_DEVICE_PWID); + wpsielen += 2; + + /* Length: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(0x0002); + wpsielen += 2; + + /* Value: */ + *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_DPID_REGISTRAR_SPEC); /* Registrar-specified */ + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110221 */ + /* According to the P2P Specification, the probe request frame should contain 5 P2P attributes */ + /* 1. P2P Capability */ + /* 2. P2P Device ID if this probe request wants to find the specific P2P device */ + /* 3. Listen Channel */ + /* 4. Extended Listen Timing */ + /* 5. Operating Channel if this WiFi is working as the group owner now */ + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + + /* Listen Channel */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_LISTEN_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->listen_channel; /* listen channel */ + + /* Extended Listen Timing */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Operating Channel (if this WiFi is working as the group owner now) */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_OPERATING_CH; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0005); + p2pielen += 2; + + /* Value: */ + /* Country String */ + p2pie[p2pielen++] = 'X'; + p2pie[p2pielen++] = 'X'; + + /* The third byte should be set to 0x04. */ + /* Described in the "Operating Channel Attribute" section. */ + p2pie[p2pielen++] = 0x04; + + /* Operating Class */ + p2pie[p2pielen++] = 0x51; /* Copy from SD7 */ + + /* Channel Number */ + p2pie[p2pielen++] = pwdinfo->operating_channel; /* operating channel number */ + } + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + + if (pmlmepriv->wps_probe_req_ie != NULL) { + /* WPS IE */ + memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); + pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; + pframe += pmlmepriv->wps_probe_req_ie_len; + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +inline void issue_probereq_p2p(struct adapter *adapter, u8 *da) +{ + _issue_probereq_p2p(adapter, da, false); +} + +int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = jiffies; + + do { + ret = _issue_probereq_p2p(adapter, da, wait_ms > 0 ? true : false); + + i++; + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(adapter), da, rtw_get_oper_ch(adapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(adapter), rtw_get_oper_ch(adapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +#endif /* CONFIG_88EU_P2P */ + +static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) +{ + struct adapter *adapter = recv_frame->adapter; + struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); + u8 *frame = recv_frame->rx_data; + u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | + (recv_frame->attrib.frag_num & 0xf); + + if (GetRetry(frame)) { + if (token >= 0) { + if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token)) { + DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x, token:%d\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq, token); + return _FAIL; + } + } else { + if (seq_ctrl == mlmeext->action_public_rxseq) { + DBG_88E(FUNC_ADPT_FMT" seq_ctrl = 0x%x, rxseq = 0x%x\n", + FUNC_ADPT_ARG(adapter), seq_ctrl, mlmeext->action_public_rxseq); + return _FAIL; + } + } + } + + mlmeext->action_public_rxseq = seq_ctrl; + + if (token >= 0) + mlmeext->action_public_dialog_token = token; + + return _SUCCESS; +} + +static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) +{ + u8 *pframe = precv_frame->rx_data; + u8 *frame_body; + u8 dialogToken = 0; +#ifdef CONFIG_88EU_P2P + struct adapter *padapter = precv_frame->adapter; + uint len = precv_frame->len; + u8 *p2p_ie; + u32 p2p_ielen; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 result = P2P_STATUS_SUCCESS; + u8 empty_addr[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; +#endif /* CONFIG_88EU_P2P */ + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[7]; + + if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) + return _FAIL; + +#ifdef CONFIG_88EU_P2P + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + /* Do nothing if the driver doesn't enable the P2P function. */ + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) + return _SUCCESS; + + len -= sizeof(struct rtw_ieee80211_hdr_3addr); + + switch (frame_body[6]) { /* OUI Subtype */ + case P2P_GO_NEGO_REQ: + DBG_88E("[%s] Got GO Nego Req Frame\n", __func__); + memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) { + /* Commented by Albert 20110526 */ + /* In this case, this means the previous nego fail doesn't be reset yet. */ + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + /* Restore the previous p2p state */ + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + DBG_88E("[%s] Restore the previous p2p state to %d\n", __func__, rtw_p2p_state(pwdinfo)); + } + + /* Commented by Kurt 20110902 */ + /* Add if statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + + /* Commented by Kurt 20120113 */ + /* Get peer_dev_addr here if peer doesn't issue prov_disc frame. */ + if (!memcmp(pwdinfo->rx_prov_disc_info.peerDevAddr, empty_addr, ETH_ALEN)) + memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); + + result = process_p2p_group_negotation_req(pwdinfo, frame_body, len); + issue_p2p_GO_response(padapter, GetAddr2Ptr(pframe), frame_body, len, result); + + /* Commented by Albert 20110718 */ + /* No matter negotiating or negotiation failure, the driver should set up the restore P2P state timer. */ + _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); + break; + case P2P_GO_NEGO_RESP: + DBG_88E("[%s] Got GO Nego Resp Frame\n", __func__); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { + /* Commented by Albert 20110425 */ + /* The restore timer is enabled when issuing the nego request frame of rtw_p2p_connect function. */ + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + pwdinfo->nego_req_info.benable = false; + result = process_p2p_group_negotation_resp(pwdinfo, frame_body, len); + issue_p2p_GO_confirm(pwdinfo->padapter, GetAddr2Ptr(pframe), result); + if (P2P_STATUS_SUCCESS == result) { + if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) { + pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch; + pwdinfo->p2p_info.scan_op_ch_only = 1; + _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH); + } + } + /* Reset the dialog token for group negotiation frames. */ + pwdinfo->negotiation_dialog_token = 1; + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) + _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); + } else { + DBG_88E("[%s] Skipped GO Nego Resp Frame (p2p_state != P2P_STATE_GONEGO_ING)\n", __func__); + } + break; + case P2P_GO_NEGO_CONF: + DBG_88E("[%s] Got GO Nego Confirm Frame\n", __func__); + result = process_p2p_group_negotation_confirm(pwdinfo, frame_body, len); + if (P2P_STATUS_SUCCESS == result) { + if (rtw_p2p_role(pwdinfo) == P2P_ROLE_CLIENT) { + pwdinfo->p2p_info.operation_ch[0] = pwdinfo->peer_operating_ch; + pwdinfo->p2p_info.scan_op_ch_only = 1; + _set_timer(&pwdinfo->reset_ch_sitesurvey2, P2P_RESET_SCAN_CH); + } + } + break; + case P2P_INVIT_REQ: + /* Added by Albert 2010/10/05 */ + /* Received the P2P Invite Request frame. */ + + DBG_88E("[%s] Got invite request frame!\n", __func__); + p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); + if (p2p_ie) { + /* Parse the necessary information from the P2P Invitation Request frame. */ + /* For example: The MAC address of sending this P2P Invitation Request frame. */ + u32 attr_contentlen = 0; + u8 status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + struct group_id_info group_id; + u8 invitation_flag = 0; + + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INVITATION_FLAGS, &invitation_flag, &attr_contentlen); + if (attr_contentlen) { + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_BSSID, pwdinfo->p2p_peer_interface_addr, &attr_contentlen); + /* Commented by Albert 20120510 */ + /* Copy to the pwdinfo->p2p_peer_interface_addr. */ + /* So that the WFD UI (or Sigma) can get the peer interface address by using the following command. */ + /* #> iwpriv wlan0 p2p_get peer_ifa */ + /* After having the peer interface address, the sigma can find the correct conf file for wpa_supplicant. */ + + if (attr_contentlen) { + DBG_88E("[%s] GO's BSSID = %.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], + pwdinfo->p2p_peer_interface_addr[2], pwdinfo->p2p_peer_interface_addr[3], + pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); + } + + if (invitation_flag & P2P_INVITATION_FLAGS_PERSISTENT) { + /* Re-invoke the persistent group. */ + + memset(&group_id, 0x00, sizeof(struct group_id_info)); + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); + if (attr_contentlen) { + if (!memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { + /* The p2p device sending this p2p invitation request wants this Wi-Fi device to be the persistent GO. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_GO); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + status_code = P2P_STATUS_SUCCESS; + } else { + /* The p2p device sending this p2p invitation request wants to be the persistent GO. */ + if (is_matched_in_profilelist(pwdinfo->p2p_peer_interface_addr, &pwdinfo->profileinfo[0])) { + u8 operatingch_info[5] = { 0x00 }; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, (u32)operatingch_info[4])) { + /* The operating channel is acceptable for this device. */ + pwdinfo->rx_invitereq_info.operation_ch[0] = operatingch_info[4]; + pwdinfo->rx_invitereq_info.scan_op_ch_only = 1; + _set_timer(&pwdinfo->reset_ch_sitesurvey, P2P_RESET_SCAN_CH); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + status_code = P2P_STATUS_SUCCESS; + } else { + /* The operating channel isn't supported by this device. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + status_code = P2P_STATUS_FAIL_NO_COMMON_CH; + _set_timer(&pwdinfo->restore_p2p_state_timer, 3000); + } + } else { + /* Commented by Albert 20121130 */ + /* Intel will use the different P2P IE to store the operating channel information */ + /* Workaround for Intel WiDi 3.5 */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_MATCH); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + status_code = P2P_STATUS_SUCCESS; + } + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); + status_code = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; + } + } + } else { + DBG_88E("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + } else { + /* Received the invitation to join a P2P group. */ + + memset(&group_id, 0x00, sizeof(struct group_id_info)); + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, (u8 *)&group_id, &attr_contentlen); + if (attr_contentlen) { + if (!memcmp(group_id.go_device_addr, myid(&padapter->eeprompriv), ETH_ALEN)) { + /* In this case, the GO can't be myself. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_DISMATCH); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } else { + /* The p2p device sending this p2p invitation request wants to join an existing P2P group */ + /* Commented by Albert 2012/06/28 */ + /* In this case, this Wi-Fi device should use the iwpriv command to get the peer device address. */ + /* The peer device address should be the destination address for the provisioning discovery request. */ + /* Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */ + /* The peer interface address should be the address for WPS mac address */ + memcpy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr , ETH_ALEN); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN); + status_code = P2P_STATUS_SUCCESS; + } + } else { + DBG_88E("[%s] P2P Group ID Attribute NOT FOUND!\n", __func__); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + } + } else { + DBG_88E("[%s] P2P Invitation Flags Attribute NOT FOUND!\n", __func__); + status_code = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + + DBG_88E("[%s] status_code = %d\n", __func__, status_code); + + pwdinfo->inviteresp_info.token = frame_body[7]; + issue_p2p_invitation_response(padapter, GetAddr2Ptr(pframe), pwdinfo->inviteresp_info.token, status_code); + } + break; + case P2P_INVIT_RESP: { + u8 attr_content = 0x00; + u32 attr_contentlen = 0; + + DBG_88E("[%s] Got invite response frame!\n", __func__); + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); + if (p2p_ie) { + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); + + if (attr_contentlen == 1) { + DBG_88E("[%s] Status = %d\n", __func__, attr_content); + pwdinfo->invitereq_info.benable = false; + + if (attr_content == P2P_STATUS_SUCCESS) { + if (!memcmp(pwdinfo->invitereq_info.go_bssid, myid(&padapter->eeprompriv), ETH_ALEN)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_OK); + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); + } + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); + } + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL); + } + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_INVITE_RESP_FAIL)) + _set_timer(&pwdinfo->restore_p2p_state_timer, 5000); + break; + } + case P2P_DEVDISC_REQ: + process_p2p_devdisc_req(pwdinfo, pframe, len); + break; + case P2P_DEVDISC_RESP: + process_p2p_devdisc_resp(pwdinfo, pframe, len); + break; + case P2P_PROVISION_DISC_REQ: + DBG_88E("[%s] Got Provisioning Discovery Request Frame\n", __func__); + process_p2p_provdisc_req(pwdinfo, pframe, len); + memcpy(pwdinfo->rx_prov_disc_info.peerDevAddr, GetAddr2Ptr(pframe), ETH_ALEN); + + /* 20110902 Kurt */ + /* Add the following statement to avoid receiving duplicate prov disc req. such that pre_p2p_state would be covered. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ)) + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_REQ); + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); + break; + case P2P_PROVISION_DISC_RESP: + /* Commented by Albert 20110707 */ + /* Should we check the pwdinfo->tx_prov_disc_info.bsent flag here?? */ + DBG_88E("[%s] Got Provisioning Discovery Response Frame\n", __func__); + /* Commented by Albert 20110426 */ + /* The restore timer is enabled when issuing the provisioing request frame in rtw_p2p_prov_disc function. */ + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_PROVISION_DIS_RSP); + process_p2p_provdisc_resp(pwdinfo, pframe); + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); + break; + } +#endif /* CONFIG_88EU_P2P */ + + return _SUCCESS; +} + +static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + + if (!memcmp(frame_body + 2, P2P_OUI, 4)) { + ret = on_action_public_p2p(precv_frame); + } + + return ret; +} + +static unsigned int on_action_public_default(struct recv_frame *precv_frame, u8 action) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + u8 token; + + token = frame_body[2]; + + if (rtw_action_public_decache(precv_frame, token) == _FAIL) + goto exit; + + ret = _SUCCESS; + +exit: + return ret; +} + +unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv_frame) +{ + unsigned int ret = _FAIL; + u8 *pframe = precv_frame->rx_data; + u8 *frame_body = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + u8 category, action; + + /* check RA matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + goto exit; + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_PUBLIC) + goto exit; + + action = frame_body[1]; + switch (action) { + case ACT_PUBLIC_VENDOR: + ret = on_action_public_vendor(precv_frame); + break; + default: + ret = on_action_public_default(precv_frame, action); + break; + } + +exit: + return ret; +} + +unsigned int OnAction_ht(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_wmm(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_P2P + u8 *frame_body; + u8 category, OUI_Subtype; + u8 *pframe = precv_frame->rx_data; + uint len = precv_frame->len; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("%s\n", __func__); + + /* check RA matches or not */ + if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + return _SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + if (category != RTW_WLAN_CATEGORY_P2P) + return _SUCCESS; + + if (be32_to_cpu(*((__be32 *)(frame_body + 1))) != P2POUI) + return _SUCCESS; + + len -= sizeof(struct rtw_ieee80211_hdr_3addr); + OUI_Subtype = frame_body[5]; + + switch (OUI_Subtype) { + case P2P_NOTICE_OF_ABSENCE: + break; + case P2P_PRESENCE_REQUEST: + process_p2p_presence_req(pwdinfo, pframe, len); + break; + case P2P_PRESENCE_RESPONSE: + break; + case P2P_GO_DISC_REQUEST: + break; + default: + break; + } +#endif /* CONFIG_88EU_P2P */ + return _SUCCESS; +} + +unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) +{ + int i; + unsigned char category; + struct action_handler *ptable; + unsigned char *frame_body; + u8 *pframe = precv_frame->rx_data; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + category = frame_body[0]; + + for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + ptable = &OnAction_tbl[i]; + if (category == ptable->num) + ptable->func(padapter, precv_frame); + } + return _SUCCESS; +} + +unsigned int DoReserved(struct adapter *padapter, struct recv_frame *precv_frame) +{ + return _SUCCESS; +} + +struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) +{ + struct xmit_frame *pmgntframe; + struct xmit_buf *pxmitbuf; + + pmgntframe = rtw_alloc_xmitframe(pxmitpriv); + if (pmgntframe == NULL) { + DBG_88E("%s, alloc xmitframe fail\n", __func__); + return NULL; + } + + pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv); + if (pxmitbuf == NULL) { + DBG_88E("%s, alloc xmitbuf fail\n", __func__); + rtw_free_xmitframe(pxmitpriv, pmgntframe); + return NULL; + } + pmgntframe->frame_tag = MGNT_FRAMETAG; + pmgntframe->pxmitbuf = pxmitbuf; + pmgntframe->buf_addr = pxmitbuf->pbuf; + pxmitbuf->priv_data = pmgntframe; + return pmgntframe; +} + +/**************************************************************************** + +Following are some TX fuctions for WiFi MLME + +*****************************************************************************/ + +void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + pmlmeext->tx_rate = rate; + DBG_88E("%s(): rate = %x\n", __func__, rate); +} + +void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); + + pattrib->hdrlen = 24; + pattrib->nr_frags = 1; + pattrib->priority = 7; + pattrib->mac_id = 0; + pattrib->qsel = 0x12; + + pattrib->pktlen = 0; + + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + pattrib->raid = 6;/* b mode */ + else + pattrib->raid = 5;/* a/g mode */ + + pattrib->encrypt = _NO_PRIVACY_; + pattrib->bswenc = false; + + pattrib->qos_en = false; + pattrib->ht_en = false; + pattrib->bwmode = HT_CHANNEL_WIDTH_20; + pattrib->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pattrib->sgi = false; + + pattrib->seqnum = pmlmeext->mgnt_seq; + + pattrib->retry_ctrl = true; +} + +void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe) +{ + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return; + + rtw_hal_mgnt_xmit(padapter, pmgntframe); +} + +s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntframe, int timeout_ms) +{ + s32 ret = _FAIL; + struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; + struct submit_ctx sctx; + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return ret; + + rtw_sctx_init(&sctx, timeout_ms); + pxmitbuf->sctx = &sctx; + + ret = rtw_hal_mgnt_xmit(padapter, pmgntframe); + + if (ret == _SUCCESS) + ret = rtw_sctx_wait(&sctx); + + return ret; +} + +s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe) +{ + s32 ret = _FAIL; + u32 timeout_ms = 500;/* 500ms */ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return -1; + + _enter_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + pxmitpriv->ack_tx = true; + + pmgntframe->ack_report = 1; + if (rtw_hal_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) { + ret = rtw_ack_tx_wait(pxmitpriv, timeout_ms); + } + + pxmitpriv->ack_tx = false; + _exit_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); + + return ret; +} + +static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) +{ + u8 *ssid_ie; + int ssid_len_ori; + int len_diff = 0; + + ssid_ie = rtw_get_ie(ies, WLAN_EID_SSID, &ssid_len_ori, ies_len); + + if (ssid_ie && ssid_len_ori > 0) { + switch (hidden_ssid_mode) { + case 1: { + u8 *next_ie = ssid_ie + 2 + ssid_len_ori; + u32 remain_len = 0; + + remain_len = ies_len - (next_ie - ies); + + ssid_ie[1] = 0; + memcpy(ssid_ie+2, next_ie, remain_len); + len_diff -= ssid_len_ori; + + break; + } + case 2: + memset(&ssid_ie[2], 0, ssid_len_ori); + break; + default: + break; + } + } + + return len_diff; +} + +void issue_beacon(struct adapter *padapter, int timeout_ms) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned int rate_len; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) { + DBG_88E("%s, alloc mgnt frame fail\n", __func__); + return; + } +#if defined (CONFIG_88EU_AP_MODE) + spin_lock_bh(&pmlmepriv->bcn_update_lock); +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + pattrib->qsel = 0x10; + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); + + SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); + /* pmlmeext->mgnt_seq++; */ + SetFrameSubType(pframe, WIFI_BEACON); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { +#ifdef CONFIG_88EU_P2P + /* for P2P : Primary Device Type & Device Name */ + u32 wpsielen = 0, insert_len = 0; + u8 *wpsie = NULL; + wpsie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wpsielen); + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wpsie && wpsielen > 0) { + uint wps_offset, remainder_ielen; + u8 *premainder_ie, *pframe_wscie; + + wps_offset = (uint)(wpsie - cur_network->IEs); + premainder_ie = wpsie + wpsielen; + remainder_ielen = cur_network->IELength - wps_offset - wpsielen; + pframe_wscie = pframe + wps_offset; + memcpy(pframe, cur_network->IEs, wps_offset+wpsielen); + pframe += (wps_offset + wpsielen); + pattrib->pktlen += (wps_offset + wpsielen); + + /* now pframe is end of wsc ie, insert Primary Device Type & Device Name */ + /* Primary Device Type */ + /* Type: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_PRIMARY_DEV_TYPE); + insert_len += 2; + + /* Length: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(0x0008); + insert_len += 2; + + /* Value: */ + /* Category ID */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + insert_len += 2; + + /* OUI */ + *(__be32 *)(pframe + insert_len) = cpu_to_be32(WPSOUI); + insert_len += 4; + + /* Sub Category ID */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + insert_len += 2; + + /* Device Name */ + /* Type: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + insert_len += 2; + + /* Length: */ + *(__be16 *)(pframe + insert_len) = cpu_to_be16(pwdinfo->device_name_len); + insert_len += 2; + + /* Value: */ + memcpy(pframe + insert_len, pwdinfo->device_name, pwdinfo->device_name_len); + insert_len += pwdinfo->device_name_len; + + /* update wsc ie length */ + *(pframe_wscie+1) = (wpsielen-2) + insert_len; + + /* pframe move to end */ + pframe += insert_len; + pattrib->pktlen += insert_len; + + /* copy remainder_ie to pframe */ + memcpy(pframe, premainder_ie, remainder_ielen); + pframe += remainder_ielen; + pattrib->pktlen += remainder_ielen; + } else +#endif /* CONFIG_88EU_P2P */ + { + int len_diff; + memcpy(pframe, cur_network->IEs, cur_network->IELength); + len_diff = update_hidden_ssid( + pframe+_BEACON_IE_OFFSET_ + , cur_network->IELength-_BEACON_IE_OFFSET_ + , pmlmeinfo->hidden_ssid_mode + ); + pframe += (cur_network->IELength+len_diff); + pattrib->pktlen += (cur_network->IELength+len_diff); + } + + { + u8 *wps_ie; + uint wps_ielen; + u8 sr = 0; + wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof (struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, + pattrib->pktlen-sizeof (struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); + if (wps_ie && wps_ielen > 0) + rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); + if (sr != 0) + set_fwstate(pmlmepriv, WIFI_UNDER_WPS); + else + _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); + } + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + u32 len; + len = build_beacon_p2p_ie(pwdinfo, pframe); + + pframe += len; + pattrib->pktlen += len; + } +#endif /* CONFIG_88EU_P2P */ + + goto _issue_bcn; + } + + /* below for ad-hoc mode */ + + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; + + /* beacon interval: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* capability info: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + + { + u8 erpinfo = 0; + u32 ATIMWindow; + /* IBSS Parameter Set... */ + ATIMWindow = 0; + pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + + /* ERP IE */ + pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + } + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + /* todo:HT for adhoc */ +_issue_bcn: + +#if defined (CONFIG_88EU_AP_MODE) + pmlmepriv->update_bcn = false; + + spin_unlock_bh(&pmlmepriv->bcn_update_lock); +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + + if ((pattrib->pktlen + TXDESC_SIZE) > 512) { + DBG_88E("beacon frame too large\n"); + return; + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + /* DBG_88E("issue bcn_sz=%d\n", pattrib->last_txcmdsz); */ + if (timeout_ms > 0) + dump_mgntframe_and_wait(padapter, pmgntframe, timeout_ms); + else + dump_mgntframe(padapter, pmgntframe); +} + +void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p_probereq) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned char *mac, *bssid; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); +#if defined (CONFIG_88EU_AP_MODE) + u8 *pwps_ie; + uint wps_ielen; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; +#endif /* if defined (CONFIG_88EU_AP_MODE) */ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + unsigned int rate_len; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) { + DBG_88E("%s, alloc mgnt frame fail\n", __func__); + return; + } + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + bssid = cur_network->MacAddress; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(fctrl, WIFI_PROBERSP); + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = pattrib->hdrlen; + pframe += pattrib->hdrlen; + + if (cur_network->IELength > MAX_IE_SZ) + return; + +#if defined(CONFIG_88EU_AP_MODE) + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + + /* inerset & update wps_probe_resp_ie */ + if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + uint wps_offset, remainder_ielen; + u8 *premainder_ie; + + wps_offset = (uint)(pwps_ie - cur_network->IEs); + + premainder_ie = pwps_ie + wps_ielen; + + remainder_ielen = cur_network->IELength - wps_offset - wps_ielen; + + memcpy(pframe, cur_network->IEs, wps_offset); + pframe += wps_offset; + pattrib->pktlen += wps_offset; + + wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */ + if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) { + memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); + pframe += wps_ielen+2; + pattrib->pktlen += wps_ielen+2; + } + + if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + memcpy(pframe, premainder_ie, remainder_ielen); + pframe += remainder_ielen; + pattrib->pktlen += remainder_ielen; + } + } else { + memcpy(pframe, cur_network->IEs, cur_network->IELength); + pframe += cur_network->IELength; + pattrib->pktlen += cur_network->IELength; + } + } else +#endif + { + /* timestamp will be inserted by hardware */ + pframe += 8; + pattrib->pktlen += 8; + + /* beacon interval: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* capability info: 2 bytes */ + + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* below for ad-hoc mode */ + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pattrib->pktlen); + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + u8 erpinfo = 0; + u32 ATIMWindow; + /* IBSS Parameter Set... */ + /* ATIMWindow = cur->Configuration.ATIMWindow; */ + ATIMWindow = 0; + pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); + + /* ERP IE */ + pframe = rtw_set_ie(pframe, _ERPINFO_IE_, 1, &erpinfo, &pattrib->pktlen); + } + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); + /* todo:HT for adhoc */ + } + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && is_valid_p2p_probereq) { + u32 len; + len = build_probe_resp_p2p_ie(pwdinfo, pframe); + + pframe += len; + pattrib->pktlen += len; + } +#endif /* CONFIG_88EU_P2P */ + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned char *mac; + unsigned char bssrate[NumRates]; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + int bssrate_len = 0; + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(padapter->eeprompriv)); + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if (da) { + /* unicast probe request frame */ + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr3, da, ETH_ALEN); + } else { + /* broadcast probe request frame */ + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, bc_addr, ETH_ALEN); + } + + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_PROBEREQ); + + pframe += sizeof (struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + + if (pssid) + pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); + else + pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &(pattrib->pktlen)); + + get_rate_set(padapter, bssrate, &bssrate_len); + + if (bssrate_len > 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + } else { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); + } + + /* add wps_ie for wps2.0 */ + if (pmlmepriv->wps_probe_req_ie_len > 0 && pmlmepriv->wps_probe_req_ie) { + memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); + pframe += pmlmepriv->wps_probe_req_ie_len; + pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +inline void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da) +{ + _issue_probereq(padapter, pssid, da, false); +} + +int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, + int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = jiffies; + + do { + ret = _issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +/* if psta == NULL, indiate we are station(client) now... */ +void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short status) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned int val32; + u16 val16; +#ifdef CONFIG_88EU_AP_MODE + __le16 le_val16; +#endif + int use_shared_key = 0; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_AUTH); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + if (psta) {/* for AP mode */ +#ifdef CONFIG_88EU_AP_MODE + + memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + /* setting auth algo number */ + val16 = (u16)psta->authalg; + + if (status != _STATS_SUCCESSFUL_) + val16 = 0; + + if (val16) { + le_val16 = cpu_to_le16(val16); + use_shared_key = 1; + } else { + le_val16 = 0; + } + + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + + /* setting auth seq number */ + val16 = (u16)psta->auth_seq; + le_val16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + + /* setting status code... */ + val16 = status; + le_val16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + + /* added challenging text... */ + if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); +#endif + } else { + __le32 le_tmp32; + __le16 le_tmp16; + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + + /* setting auth algo number */ + val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/* 0:OPEN System, 1:Shared key */ + if (val16) + use_shared_key = 1; + + /* setting IV for auth seq #3 */ + if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { + val32 = ((pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30)); + le_tmp32 = cpu_to_le32(val32); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&le_tmp32, &(pattrib->pktlen)); + + pattrib->iv_len = 4; + } + + le_tmp16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + + /* setting auth seq number */ + val16 = pmlmeinfo->auth_seq; + le_tmp16 = cpu_to_le16(val16); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + + /* setting status code... */ + le_tmp16 = cpu_to_le16(status); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + + /* then checking to see if sending challenging text... */ + if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); + + SetPrivacy(fctrl); + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pattrib->encrypt = _WEP40_; + + pattrib->icv_len = 4; + + pattrib->pktlen += pattrib->icv_len; + } + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + rtw_wep_encrypt(padapter, (u8 *)pmgntframe); + DBG_88E("%s\n", __func__); + dump_mgntframe(padapter, pmgntframe); + + return; +} + +void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) +{ +#ifdef CONFIG_88EU_AP_MODE + struct xmit_frame *pmgntframe; + struct rtw_ieee80211_hdr *pwlanhdr; + struct pkt_attrib *pattrib; + unsigned char *pbuf, *pframe; + unsigned short val; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + u8 *ie = pnetwork->IEs; + __le16 lestatus, leval; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + DBG_88E("%s\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr, ETH_ALEN); + memcpy((void *)GetAddr2Ptr(pwlanhdr), myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy((void *)GetAddr3Ptr(pwlanhdr), get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + if ((pkt_type == WIFI_ASSOCRSP) || (pkt_type == WIFI_REASSOCRSP)) + SetFrameSubType(pwlanhdr, pkt_type); + else + return; + + pattrib->hdrlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen += pattrib->hdrlen; + pframe += pattrib->hdrlen; + + /* capability */ + val = *(unsigned short *)rtw_get_capability_from_ie(ie); + + pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_ , (unsigned char *)&val, &(pattrib->pktlen)); + + lestatus = cpu_to_le16(status); + pframe = rtw_set_fixed_ie(pframe , _STATUS_CODE_ , (unsigned char *)&lestatus, &(pattrib->pktlen)); + + leval = cpu_to_le16(pstat->aid | BIT(14) | BIT(15)); + pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_ , (unsigned char *)&leval, &(pattrib->pktlen)); + + if (pstat->bssratelen <= 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); + } else { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); + } + + if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { + uint ie_len = 0; + + /* FILL HT CAP INFO IE */ + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if (pbuf && ie_len > 0) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); + pattrib->pktlen += (ie_len+2); + } + + /* FILL HT ADD INFO IE */ + pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); + if (pbuf && ie_len > 0) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); + pattrib->pktlen += (ie_len+2); + } + } + + /* FILL WMM IE */ + if ((pstat->flags & WLAN_STA_WME) && (pmlmepriv->qospriv.qos_option)) { + uint ie_len = 0; + unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; + + for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { + pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); + if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { + memcpy(pframe, pbuf, ie_len+2); + pframe += (ie_len+2); + pattrib->pktlen += (ie_len+2); + break; + } + + if ((pbuf == NULL) || (ie_len == 0)) + break; + } + } + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); + + /* add WPS IE ie for wps 2.0 */ + if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { + memcpy(pframe, pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len); + + pframe += pmlmepriv->wps_assoc_resp_ie_len; + pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len; + } + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && (pstat->is_p2p_device)) { + u32 len; + + len = build_assoc_resp_p2p_ie(pwdinfo, pframe, pstat->p2p_status_code); + + pframe += len; + pattrib->pktlen += len; + } +#endif /* CONFIG_88EU_P2P */ + pattrib->last_txcmdsz = pattrib->pktlen; + dump_mgntframe(padapter, pmgntframe); +#endif +} + +void issue_assocreq(struct adapter *padapter) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe, *p; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + __le16 le_tmp; + unsigned int i, j, ie_len, index = 0; + unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; + struct ndis_802_11_var_ie *pIE; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int bssrate_len = 0, sta_bssrate_len = 0; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 p2pie[255] = { 0x00 }; + u16 p2pielen = 0; +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ASSOCREQ); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* caps */ + + memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.IEs), 2); + + pframe += 2; + pattrib->pktlen += 2; + + /* listen interval */ + /* todo: listen interval for power saving */ + le_tmp = cpu_to_le16(3); + memcpy(pframe , (unsigned char *)&le_tmp, 2); + pframe += 2; + pattrib->pktlen += 2; + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); + + /* supported rate & extended supported rate */ + + /* Check if the AP's supported rates are also supported by STA. */ + get_rate_set(padapter, sta_bssrate, &sta_bssrate_len); + + if (pmlmeext->cur_channel == 14)/* for JAPAN, channel 14 can only uses B Mode(CCK) */ + sta_bssrate_len = 4; + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + if (pmlmeinfo->network.SupportedRates[i] == 0) + break; + DBG_88E("network.SupportedRates[%d]=%02X\n", i, pmlmeinfo->network.SupportedRates[i]); + } + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + if (pmlmeinfo->network.SupportedRates[i] == 0) + break; + + /* Check if the AP's supported rates are also supported by STA. */ + for (j = 0; j < sta_bssrate_len; j++) { + /* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */ + if ((pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK) + == (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) + break; + } + + if (j == sta_bssrate_len) { + /* the rate is not supported by STA */ + DBG_88E("%s(): the rate[%d]=%02X is not supported by STA!\n", __func__, i, pmlmeinfo->network.SupportedRates[i]); + } else { + /* the rate is supported by STA */ + bssrate[index++] = pmlmeinfo->network.SupportedRates[i]; + } + } + + bssrate_len = index; + DBG_88E("bssrate_len=%d\n", bssrate_len); + + if (bssrate_len == 0) { + rtw_free_xmitbuf(pxmitpriv, pmgntframe->pxmitbuf); + rtw_free_xmitframe(pxmitpriv, pmgntframe); + goto exit; /* don't connect to AP if no joint supported rate */ + } + + if (bssrate_len > 8) { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + } else { + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); + } + + /* RSN */ + p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); + if (p != NULL) + pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, (p + 2), &(pattrib->pktlen)); + + /* HT caps */ + if (padapter->mlmepriv.htpriv.ht_option) { + p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_CAPABILITY_IE_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); + if ((p != NULL) && (!(is_ap_in_tkip(padapter)))) { + memcpy(&(pmlmeinfo->HT_caps), (p + 2), sizeof(struct HT_caps_element)); + + /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ + if (pregpriv->cbw40_enable == 0) + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info &= cpu_to_le16(~(BIT(6) | BIT(1))); + else + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(BIT(1)); + + /* todo: disable SM power save mode */ + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x000c); + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + switch (rf_type) { + case RF_1T1R: + if (pregpriv->rx_stbc) + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ + memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_1R, 16); + break; + case RF_2T2R: + case RF_1T2R: + default: + if ((pregpriv->rx_stbc == 0x3) ||/* enable for 2.4/5 GHz */ + ((pmlmeext->cur_wireless_mode & WIRELESS_11_24N) && (pregpriv->rx_stbc == 0x1)) || /* enable for 2.4GHz */ + (pregpriv->wifi_spec == 1)) { + DBG_88E("declare supporting RX STBC\n"); + pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info |= cpu_to_le16(0x0200);/* RX STBC two spatial stream */ + } + memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_2R, 16); + break; + } + pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len , (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + } + } + + /* vendor specific IE, such as WPA, WMM, WPS */ + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || + (!memcmp(pIE->data, WMM_OUI, 4)) || + (!memcmp(pIE->data, WPS_OUI, 4))) { + if (!padapter->registrypriv.wifi_spec) { + /* Commented by Kurt 20110629 */ + /* In some older APs, WPS handshake */ + /* would be fail if we append vender extensions informations to AP */ + if (!memcmp(pIE->data, WPS_OUI, 4)) + pIE->Length = 14; + } + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &(pattrib->pktlen)); + } + break; + default: + break; + } + i += (pIE->Length + 2); + } + + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); + +#ifdef CONFIG_88EU_P2P + + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && !rtw_p2p_chk_state(pwdinfo, P2P_STATE_IDLE)) { + /* Should add the P2P IE in the association request frame. */ + /* P2P OUI */ + + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20101109 */ + /* According to the P2P Specification, the association request frame should contain 3 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Extended Listen Timing */ + /* 3. Device Info */ + /* Commented by Albert 20110516 */ + /* 4. P2P Interface */ + + /* P2P Capability */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + + /* Extended Listen Timing */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0xFFFF); + p2pielen += 2; + + /* Device Info */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, myid(&padapter->eeprompriv), ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + if ((pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PEER_DISPLAY_PIN) || + (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_SELF_DISPLAY_PIN)) + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); + else + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + *(__be32 *)(p2pie + p2pielen) = cpu_to_be32(WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + *(__be16 *)(p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + /* P2P Interface */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_INTERFACE; + + /* Length: */ + *(__le16 *)(p2pie + p2pielen) = cpu_to_le16(0x000D); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); /* P2P Device Address */ + p2pielen += ETH_ALEN; + + p2pie[p2pielen++] = 1; /* P2P Interface Address Count */ + + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); /* P2P Interface Address List */ + p2pielen += ETH_ALEN; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); + } + +#endif /* CONFIG_88EU_P2P */ + + pattrib->last_txcmdsz = pattrib->pktlen; + dump_mgntframe(padapter, pmgntframe); + + ret = _SUCCESS; + +exit: + if (ret == _SUCCESS) + rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); + else + rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + + return; +} + +/* when wait_ack is ture, this function shoule be called at process context */ +static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + + if (!padapter) + goto exit; + + pxmitpriv = &(padapter->xmitpriv); + pmlmeext = &(padapter->mlmeextpriv); + pmlmeinfo = &(pmlmeext->mlmext_info); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + pattrib->retry_ctrl = false; + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + SetFrDs(fctrl); + else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + SetToDs(fctrl); + + if (power_mode) + SetPwrMgt(fctrl); + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_DATA_NULL); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pattrib->last_txcmdsz = pattrib->pktlen; + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +/* when wait_ms > 0 , this function shoule be called at process context */ +/* da == NULL for station mode */ +int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int power_mode, int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = jiffies; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* da == NULL, assum it's null data for sta to ap*/ + if (da == NULL) + da = get_my_bssid(&(pmlmeinfo->network)); + + do { + ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +/* when wait_ack is ture, this function shoule be called at process context */ +static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int wait_ack) +{ + int ret = _FAIL; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + unsigned short *qc; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_88E("%s\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + pattrib->hdrlen += 2; + pattrib->qos_en = true; + pattrib->eosp = 1; + pattrib->ack_policy = 0; + pattrib->mdata = 0; + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + SetFrDs(fctrl); + else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + SetToDs(fctrl); + + if (pattrib->mdata) + SetMData(fctrl); + + qc = (unsigned short *)(pframe + pattrib->hdrlen - 2); + + SetPriority(qc, tid); + + SetEOSP(qc, pattrib->eosp); + + SetAckpolicy(qc, pattrib->ack_policy); + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr_qos); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos); + + pattrib->last_txcmdsz = pattrib->pktlen; + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +/* when wait_ms > 0 , this function shoule be called at process context */ +/* da == NULL for station mode */ +int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int try_cnt, int wait_ms) +{ + int ret; + int i = 0; + u32 start = jiffies; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* da == NULL, assum it's null data for sta to ap*/ + if (da == NULL) + da = get_my_bssid(&(pmlmeinfo->network)); + + do { + ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason, u8 wait_ack) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int ret = _FAIL; + __le16 le_tmp; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + +#ifdef CONFIG_88EU_P2P + if (!(rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) && (pwdinfo->rx_invitereq_info.scan_op_ch_only)) { + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _set_timer(&pwdinfo->reset_ch_sitesurvey, 10); + } +#endif /* CONFIG_88EU_P2P */ + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + pattrib->retry_ctrl = false; + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_DEAUTH); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + le_tmp = cpu_to_le16(reason); + pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_ , (unsigned char *)&le_tmp, &(pattrib->pktlen)); + + pattrib->last_txcmdsz = pattrib->pktlen; + + if (wait_ack) { + ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); + } else { + dump_mgntframe(padapter, pmgntframe); + ret = _SUCCESS; + } + +exit: + return ret; +} + +int issue_deauth(struct adapter *padapter, unsigned char *da, unsigned short reason) +{ + DBG_88E("%s to %pM\n", __func__, da); + return _issue_deauth(padapter, da, reason, false); +} + +int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int try_cnt, + int wait_ms) +{ + int ret; + int i = 0; + u32 start = jiffies; + + do { + ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false); + + i++; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + break; + + if (i < try_cnt && wait_ms > 0 && ret == _FAIL) + rtw_msleep_os(wait_ms); + } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); + + if (ret != _FAIL) { + ret = _SUCCESS; + goto exit; + } + + if (try_cnt && wait_ms) { + if (da) + DBG_88E(FUNC_ADPT_FMT" to %pM, ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), da, rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + else + DBG_88E(FUNC_ADPT_FMT", ch:%u%s, %d/%d in %u ms\n", + FUNC_ADPT_ARG(padapter), rtw_get_oper_ch(padapter), + ret == _SUCCESS ? ", acked" : "", i, try_cnt, rtw_get_passing_time_ms(start)); + } +exit: + return ret; +} + +void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + DBG_88E(FUNC_NDEV_FMT" ra =%pM, ch:%u, offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), ra, new_ch, ch_offset); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, ra, ETH_ALEN); /* RA */ + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); /* TA */ + memcpy(pwlanhdr->addr3, ra, ETH_ALEN); /* DA = RA */ + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* category, action */ + { + u8 category, action; + category = RTW_WLAN_CATEGORY_SPECTRUM_MGMT; + action = RTW_WLAN_ACTION_SPCT_CHL_SWITCH; + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + } + + pframe = rtw_set_ie_ch_switch (pframe, &(pattrib->pktlen), 0, new_ch, 0); + pframe = rtw_set_ie_secondary_ch_offset(pframe, &(pattrib->pktlen), + hal_ch_offset_to_secondary_ch_offset(ch_offset)); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned char action, unsigned short status) +{ + u8 category = RTW_WLAN_CATEGORY_BACK; + u16 start_seq; + u16 BA_para_set; + u16 reason_code; + u16 BA_timeout_value; + __le16 le_tmp; + u16 BA_starting_seqctrl = 0; + enum ht_cap_ampdu_factor max_rx_ampdu_factor; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + u8 *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + struct registry_priv *pregpriv = &padapter->registrypriv; + + DBG_88E("%s, category=%d, action=%d, status=%d\n", __func__, category, action, status); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + /* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */ + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + + if (category == 3) { + switch (action) { + case 0: /* ADDBA req */ + do { + pmlmeinfo->dialogToken++; + } while (pmlmeinfo->dialogToken == 0); + pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->dialogToken), &(pattrib->pktlen)); + + BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */ + le_tmp = cpu_to_le16(BA_para_set); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + BA_timeout_value = 5000;/* 5ms */ + le_tmp = cpu_to_le16(BA_timeout_value); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + psta = rtw_get_stainfo(pstapriv, raddr); + if (psta != NULL) { + start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; + + DBG_88E("BA_starting_seqctrl=%d for TID=%d\n", start_seq, status & 0x07); + + psta->BA_starting_seqctrl[status & 0x07] = start_seq; + + BA_starting_seqctrl = start_seq << 4; + } + le_tmp = cpu_to_le16(BA_starting_seqctrl); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + break; + case 1: /* ADDBA rsp */ + pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->ADDBA_req.dialog_token), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&status), &(pattrib->pktlen)); + BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f; + rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); + switch (max_rx_ampdu_factor) { + case MAX_AMPDU_FACTOR_64K: + BA_para_set |= 0x1000; /* 64 buffer size */ + break; + case MAX_AMPDU_FACTOR_32K: + BA_para_set |= 0x0800; /* 32 buffer size */ + break; + case MAX_AMPDU_FACTOR_16K: + BA_para_set |= 0x0400; /* 16 buffer size */ + break; + case MAX_AMPDU_FACTOR_8K: + BA_para_set |= 0x0200; /* 8 buffer size */ + break; + default: + BA_para_set |= 0x1000; /* 64 buffer size */ + break; + } + + if (pregpriv->ampdu_amsdu == 0)/* disabled */ + BA_para_set = BA_para_set & ~BIT(0); + else if (pregpriv->ampdu_amsdu == 1)/* enabled */ + BA_para_set = BA_para_set | BIT(0); + le_tmp = cpu_to_le16(BA_para_set); + + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(pmlmeinfo->ADDBA_req.BA_timeout_value)), &(pattrib->pktlen)); + break; + case 2:/* DELBA */ + BA_para_set = (status & 0x1F) << 3; + le_tmp = cpu_to_le16(BA_para_set); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + + reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */ + le_tmp = cpu_to_le16(reason_code); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + break; + default: + break; + } + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +static void issue_action_BSSCoexistPacket(struct adapter *padapter) +{ + struct list_head *plist, *phead; + unsigned char category, action; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct wlan_network *pnetwork = NULL; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct __queue *queue = &(pmlmepriv->scanned_queue); + u8 InfoContent[16] = {0}; + u8 ICS[8][15]; + if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) + return; + + if (pmlmeinfo->bwmode_updated) + return; + + DBG_88E("%s\n", __func__); + + category = RTW_WLAN_CATEGORY_PUBLIC; + action = ACT_PUBLIC_BSSCOEXIST; + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + + /* */ + if (pmlmepriv->num_FortyMHzIntolerant > 0) { + u8 iedata = 0; + + iedata |= BIT(2);/* 20 MHz BSS Width Request */ + + pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &(pattrib->pktlen)); + } + + /* */ + memset(ICS, 0, sizeof(ICS)); + if (pmlmepriv->num_sta_no_ht > 0) { + int i; + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + int len; + u8 *p; + struct wlan_bssid_ex *pbss_network; + + pnetwork = container_of(plist, struct wlan_network, list); + + plist = plist->next; + + pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; + + p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); + if ((p == NULL) || (len == 0)) { /* non-HT */ + if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14)) + continue; + + ICS[0][pbss_network->Configuration.DSConfig] = 1; + + if (ICS[0][0] == 0) + ICS[0][0] = 1; + } + } + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + for (i = 0; i < 8; i++) { + if (ICS[i][0] == 1) { + int j, k = 0; + + InfoContent[k] = i; + /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ + k++; + + for (j = 1; j <= 14; j++) { + if (ICS[i][j] == 1) { + if (k < 16) { + InfoContent[k] = j; /* channel number */ + /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ + k++; + } + } + } + + pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &(pattrib->pktlen)); + } + } + } + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + /* struct recv_reorder_ctrl *preorder_ctrl; */ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u16 tid; + + if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) + return _SUCCESS; + + psta = rtw_get_stainfo(pstapriv, addr); + if (psta == NULL) + return _SUCCESS; + + if (initiator == 0) { /* recipient */ + for (tid = 0; tid < MAXTID; tid++) { + if (psta->recvreorder_ctrl[tid].enable) { + DBG_88E("rx agg disable tid(%d)\n", tid); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + psta->recvreorder_ctrl[tid].enable = false; + psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; + } + } + } else if (initiator == 1) { /* originator */ + for (tid = 0; tid < MAXTID; tid++) { + if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { + DBG_88E("tx agg disable tid(%d)\n", tid); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + psta->htpriv.agg_enable_bitmap &= ~BIT(tid); + psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); + } + } + } + + return _SUCCESS; +} + +unsigned int send_beacon(struct adapter *padapter) +{ + u8 bxmitok = false; + int issue = 0; + int poll = 0; + + u32 start = jiffies; + + rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); + do { + issue_beacon(padapter, 100); + issue++; + do { + rtw_yield_os(); + rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); + poll++; + } while ((poll%10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + } while (!bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return _FAIL; + if (!bxmitok) { + DBG_88E("%s fail! %u ms\n", __func__, rtw_get_passing_time_ms(start)); + return _FAIL; + } else { + u32 passing_time = rtw_get_passing_time_ms(start); + + if (passing_time > 100 || issue > 3) + DBG_88E("%s success, issue:%d, poll:%d, %u ms\n", __func__, issue, poll, rtw_get_passing_time_ms(start)); + return _SUCCESS; + } +} + +/**************************************************************************** + +Following are some utitity fuctions for WiFi MLME + +*****************************************************************************/ + +void site_survey(struct adapter *padapter) +{ + unsigned char survey_channel = 0, val8; + enum rt_scan_type ScanType = SCAN_PASSIVE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u32 initialgain = 0; + +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { + if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { + survey_channel = pwdinfo->rx_invitereq_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; + } else { + survey_channel = pwdinfo->p2p_info.operation_ch[pmlmeext->sitesurvey_res.channel_idx]; + } + ScanType = SCAN_ACTIVE; + } else if (rtw_p2p_findphase_ex_is_social(pwdinfo)) { + /* Commented by Albert 2011/06/03 */ + /* The driver is in the find phase, it should go through the social channel. */ + int ch_set_idx; + survey_channel = pwdinfo->social_chan[pmlmeext->sitesurvey_res.channel_idx]; + ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, survey_channel); + if (ch_set_idx >= 0) + ScanType = pmlmeext->channel_set[ch_set_idx].ScanType; + else + ScanType = SCAN_ACTIVE; + } else +#endif /* CONFIG_88EU_P2P */ + { + struct rtw_ieee80211_channel *ch; + if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { + ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; + survey_channel = ch->hw_value; + ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE; + } + } + + if (survey_channel != 0) { + /* PAUSE 4-AC Queue when site_survey */ + /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + /* val8 |= 0x0f; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + if (pmlmeext->sitesurvey_res.channel_idx == 0) + set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + else + SelectChannel(padapter, survey_channel); + + if (ScanType == SCAN_ACTIVE) { /* obey the channel plan setting... */ + #ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || + rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) { + issue_probereq_p2p(padapter, NULL); + issue_probereq_p2p(padapter, NULL); + issue_probereq_p2p(padapter, NULL); + } else + #endif /* CONFIG_88EU_P2P */ + { + int i; + for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { + if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { + /* todo: to issue two probe req??? */ + issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + /* rtw_msleep_os(SURVEY_TO>>1); */ + issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + } + } + + if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { + /* todo: to issue two probe req??? */ + issue_probereq(padapter, NULL, NULL); + /* rtw_msleep_os(SURVEY_TO>>1); */ + issue_probereq(padapter, NULL, NULL); + } + } + } + + set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); + } else { + /* channel number is 0 or this channel is not valid. */ + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) { + if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { + /* Set the find_phase_state_exchange_cnt to P2P_FINDPHASE_EX_CNT. */ + /* This will let the following flow to run the scanning end. */ + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); + } + } + + if (rtw_p2p_findphase_ex_is_needed(pwdinfo)) { + /* Set the P2P State to the listen state of find phase and set the current channel to the listen channel */ + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_LISTEN); + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + + initialgain = 0xff; /* restore RX GAIN */ + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* turn on dynamic functions */ + Restore_DM_Func_Flag(padapter); + /* Switch_DM_Func(padapter, DYNAMIC_FUNC_DIG|DYNAMIC_FUNC_HP|DYNAMIC_FUNC_SS, true); */ + + _set_timer(&pwdinfo->find_phase_timer, (u32)((u32)(pwdinfo->listen_dwell) * 100)); + } else +#endif /* CONFIG_88EU_P2P */ + { + /* 20100721:Interrupt scan operation here. */ + /* For SW antenna diversity before link, it needs to switch to another antenna and scan again. */ + /* It compares the scan result and select beter one to do connection. */ + if (rtw_hal_antdiv_before_linked(padapter)) { + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->sitesurvey_res.channel_idx = -1; + pmlmeext->chan_scan_time = SURVEY_TO / 2; + set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); + return; + } +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_SCAN) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH)) + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); +#endif /* CONFIG_88EU_P2P */ + + pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; + + /* switch back to the original channel */ + +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + else + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); +#endif /* CONFIG_88EU_P2P */ + + /* flush 4-AC Queue after site_survey */ + /* val8 = 0; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ + + /* config MSR */ + Set_MSR(padapter, (pmlmeinfo->state & 0x3)); + + initialgain = 0xff; /* restore RX GAIN */ + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + /* turn on dynamic functions */ + Restore_DM_Func_Flag(padapter); + /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ + + if (is_client_associated_to_ap(padapter)) + issue_nulldata(padapter, NULL, 0, 3, 500); + + val8 = 0; /* survey done */ + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + + report_surveydone_event(padapter); + + pmlmeext->chan_scan_time = SURVEY_TO; + pmlmeext->sitesurvey_res.state = SCAN_DISABLE; + + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + issue_action_BSSCoexistPacket(padapter); + } + } + return; +} + +/* collect bss info from Beacon and Probe request/response frames. */ +u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, struct wlan_bssid_ex *bssid) +{ + int i; + u32 len; + u8 *p; + u16 val16, subtype; + u8 *pframe = precv_frame->rx_data; + u32 packet_len = precv_frame->len; + u8 ie_offset; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + __le32 le32_tmp; + + len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); + + if (len > MAX_IE_SZ) + return _FAIL; + + memset(bssid, 0, sizeof(struct wlan_bssid_ex)); + + subtype = GetFrameSubType(pframe); + + if (subtype == WIFI_BEACON) { + bssid->Reserved[0] = 1; + ie_offset = _BEACON_IE_OFFSET_; + } else { + /* FIXME : more type */ + if (subtype == WIFI_PROBEREQ) { + ie_offset = _PROBEREQ_IE_OFFSET_; + bssid->Reserved[0] = 2; + } else if (subtype == WIFI_PROBERSP) { + ie_offset = _PROBERSP_IE_OFFSET_; + bssid->Reserved[0] = 3; + } else { + bssid->Reserved[0] = 0; + ie_offset = _FIXED_IE_LENGTH_; + } + } + + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + + /* below is to copy the information element */ + bssid->IELength = len; + memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); + + /* get the signal strength */ + bssid->Rssi = precv_frame->attrib.phy_info.recvpower; /* in dBM.raw data */ + bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ + bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ + rtw_hal_get_def_var(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); + + /* checking SSID */ + p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset); + if (p == NULL) { + DBG_88E("marc: cannot find SSID for survey event\n"); + return _FAIL; + } + + if (*(p + 1)) { + if (len > NDIS_802_11_LENGTH_SSID) { + DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); + bssid->Ssid.SsidLength = *(p + 1); + } else { + bssid->Ssid.SsidLength = 0; + } + + memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); + + /* checking rate info... */ + i = 0; + p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + if (p != NULL) { + if (len > NDIS_802_11_LENGTH_RATES_EX) { + DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->SupportedRates, (p + 2), len); + i = len; + } + + p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); + if (p != NULL) { + if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { + DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); + return _FAIL; + } + memcpy(bssid->SupportedRates + i, (p + 2), len); + } + + /* todo: */ + bssid->NetworkTypeInUse = Ndis802_11OFDM24; + + if (bssid->IELength < 12) + return _FAIL; + + /* Checking for DSConfig */ + p = rtw_get_ie(bssid->IEs + ie_offset, _DSSET_IE_, &len, bssid->IELength - ie_offset); + + bssid->Configuration.DSConfig = 0; + bssid->Configuration.Length = 0; + + if (p) { + bssid->Configuration.DSConfig = *(p + 2); + } else {/* In 5G, some ap do not have DSSET IE */ + /* checking HT info for channel */ + p = rtw_get_ie(bssid->IEs + ie_offset, _HT_ADD_INFO_IE_, &len, bssid->IELength - ie_offset); + if (p) { + struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); + bssid->Configuration.DSConfig = HT_info->primary_channel; + } else { /* use current channel */ + bssid->Configuration.DSConfig = rtw_get_oper_ch(padapter); + } + } + + memcpy(&le32_tmp, rtw_get_beacon_interval_from_ie(bssid->IEs), 2); + bssid->Configuration.BeaconPeriod = le32_to_cpu(le32_tmp); + + val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); + + if (val16 & BIT(0)) { + bssid->InfrastructureMode = Ndis802_11Infrastructure; + memcpy(bssid->MacAddress, GetAddr2Ptr(pframe), ETH_ALEN); + } else { + bssid->InfrastructureMode = Ndis802_11IBSS; + memcpy(bssid->MacAddress, GetAddr3Ptr(pframe), ETH_ALEN); + } + + if (val16 & BIT(4)) + bssid->Privacy = 1; + else + bssid->Privacy = 0; + + bssid->Configuration.ATIMWindow = 0; + + /* 20/40 BSS Coexistence check */ + if ((pregistrypriv->wifi_spec == 1) && (!pmlmeinfo->bwmode_updated)) { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + p = rtw_get_ie(bssid->IEs + ie_offset, _HT_CAPABILITY_IE_, &len, bssid->IELength - ie_offset); + if (p && len > 0) { + struct HT_caps_element *pHT_caps; + pHT_caps = (struct HT_caps_element *)(p + 2); + + if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info)&BIT(14)) + pmlmepriv->num_FortyMHzIntolerant++; + } else { + pmlmepriv->num_sta_no_ht++; + } + } + + /* mark bss info receiving from nearby channel as SignalQuality 101 */ + if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter)) + bssid->PhyInfo.SignalQuality = 101; + return _SUCCESS; +} + +void start_create_ibss(struct adapter *padapter) +{ + unsigned short caps; + u8 val8; + u8 join_type; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); + + /* update wireless mode */ + update_wireless_mode(padapter); + + /* udpate capability */ + caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); + update_capinfo(padapter, caps); + if (caps&cap_IBSS) {/* adhoc master */ + val8 = 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* switch channel */ + /* SelectChannel(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + + beacon_timing_control(padapter); + + /* set msr to WIFI_FW_ADHOC_STATE */ + pmlmeinfo->state = WIFI_FW_ADHOC_STATE; + Set_MSR(padapter, (pmlmeinfo->state & 0x3)); + + /* issue beacon */ + if (send_beacon(padapter) == _FAIL) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n")); + + report_join_res(padapter, -1); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + } else { + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); + join_type = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + + report_join_res(padapter, 1); + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + rtw_indicate_connect(padapter); + } + } else { + DBG_88E("start_create_ibss, invalid cap:%x\n", caps); + return; + } + /* update bc/mc sta_info */ + update_bmc_sta(padapter); +} + +void start_clnt_join(struct adapter *padapter) +{ + unsigned short caps; + u8 val8; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + int beacon_timeout; + + pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; + pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); + + /* update wireless mode */ + update_wireless_mode(padapter); + + /* udpate capability */ + caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); + update_capinfo(padapter, caps); + if (caps&cap_ESS) { + Set_MSR(padapter, WIFI_FW_STATION_STATE); + + val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; + + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* switch channel */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + /* here wait for receiving the beacon to start auth */ + /* and enable a timer */ + beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval); + set_link_timer(pmlmeext, beacon_timeout); + _set_timer(&padapter->mlmepriv.assoc_timer, + (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout); + + pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; + } else if (caps&cap_IBSS) { /* adhoc client */ + Set_MSR(padapter, WIFI_FW_ADHOC_STATE); + + val8 = 0xcf; + rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); + + /* switch channel */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + beacon_timing_control(padapter); + + pmlmeinfo->state = WIFI_FW_ADHOC_STATE; + + report_join_res(padapter, 1); + } else { + return; + } +} + +void start_clnt_auth(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + _cancel_timer_ex(&pmlmeext->link_timer); + + pmlmeinfo->state &= (~WIFI_FW_AUTH_NULL); + pmlmeinfo->state |= WIFI_FW_AUTH_STATE; + + pmlmeinfo->auth_seq = 1; + pmlmeinfo->reauth_count = 0; + pmlmeinfo->reassoc_count = 0; + pmlmeinfo->link_count = 0; + pmlmeext->retry = 0; + + /* Because of AP's not receiving deauth before */ + /* AP may: 1)not response auth or 2)deauth us after link is complete */ + /* issue deauth before issuing auth to deal with the situation */ + /* Commented by Albert 2012/07/21 */ + /* For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */ + issue_deauth(padapter, (&(pmlmeinfo->network))->MacAddress, WLAN_REASON_DEAUTH_LEAVING); + + DBG_88E_LEVEL(_drv_info_, "start auth\n"); + issue_auth(padapter, NULL, 0); + + set_link_timer(pmlmeext, REAUTH_TO); +} + +void start_clnt_assoc(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + _cancel_timer_ex(&pmlmeext->link_timer); + + pmlmeinfo->state &= (~(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE)); + pmlmeinfo->state |= (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE); + + issue_assocreq(padapter); + + set_link_timer(pmlmeext, REASSOC_TO); +} + +unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* check A3 */ + if (!(!memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) + return _SUCCESS; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_del_sta_event(padapter, MacAddr, reason); + } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -2); + } + } + return _SUCCESS; +} + +static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid) +{ + struct registry_priv *pregistrypriv; + struct mlme_ext_priv *pmlmeext; + struct rt_channel_info *chplan_new; + u8 channel; + u8 i; + + pregistrypriv = &padapter->registrypriv; + pmlmeext = &padapter->mlmeextpriv; + + /* Adjust channel plan by AP Country IE */ + if (pregistrypriv->enable80211d && + (!pmlmeext->update_channel_plan_by_ap_done)) { + u8 *ie, *p; + u32 len; + struct rt_channel_plan chplan_ap; + struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM]; + u8 country[4]; + u8 fcn; /* first channel number */ + u8 noc; /* number of channel */ + u8 j, k; + + ie = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _COUNTRY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (!ie) + return; + if (len < 6) + return; + ie += 2; + p = ie; + ie += len; + + memset(country, 0, 4); + memcpy(country, p, 3); + p += 3; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("%s: 802.11d country =%s\n", __func__, country)); + + i = 0; + while ((ie - p) >= 3) { + fcn = *(p++); + noc = *(p++); + p++; + + for (j = 0; j < noc; j++) { + if (fcn <= 14) + channel = fcn + j; /* 2.4 GHz */ + else + channel = fcn + j*4; /* 5 GHz */ + + chplan_ap.Channel[i++] = channel; + } + } + chplan_ap.Len = i; + + memcpy(chplan_sta, pmlmeext->channel_set, sizeof(chplan_sta)); + + memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set)); + chplan_new = pmlmeext->channel_set; + + i = 0; + j = 0; + k = 0; + if (pregistrypriv->wireless_mode & WIRELESS_11G) { + do { + if ((i == MAX_CHANNEL_NUM) || + (chplan_sta[i].ChannelNum == 0) || + (chplan_sta[i].ChannelNum > 14)) + break; + + if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) + break; + + if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + i++; + j++; + k++; + } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = SCAN_PASSIVE; + i++; + k++; + } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; + k++; + } + } while (1); + + /* change AP not support channel to Passive scan */ + while ((i < MAX_CHANNEL_NUM) && + (chplan_sta[i].ChannelNum != 0) && + (chplan_sta[i].ChannelNum <= 14)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = SCAN_PASSIVE; + i++; + k++; + } + + /* add channel AP supported */ + while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { + chplan_new[k].ChannelNum = chplan_ap.Channel[j]; + chplan_new[k].ScanType = SCAN_ACTIVE; + j++; + k++; + } + } else { + /* keep original STA 2.4G channel plan */ + while ((i < MAX_CHANNEL_NUM) && + (chplan_sta[i].ChannelNum != 0) && + (chplan_sta[i].ChannelNum <= 14)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = chplan_sta[i].ScanType; + i++; + k++; + } + + /* skip AP 2.4G channel plan */ + while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) + j++; + } + + /* keep original STA 5G channel plan */ + while ((i < MAX_CHANNEL_NUM) && (chplan_sta[i].ChannelNum != 0)) { + chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; + chplan_new[k].ScanType = chplan_sta[i].ScanType; + i++; + k++; + } + + pmlmeext->update_channel_plan_by_ap_done = 1; + } + + /* If channel is used by AP, set channel scan type to active */ + channel = bssid->Configuration.DSConfig; + chplan_new = pmlmeext->channel_set; + i = 0; + while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { + if (chplan_new[i].ChannelNum == channel) { + if (chplan_new[i].ScanType == SCAN_PASSIVE) { + chplan_new[i].ScanType = SCAN_ACTIVE; + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, + ("%s: change channel %d scan type from passive to active\n", + __func__, channel)); + } + break; + } + i++; + } +} + +/**************************************************************************** + +Following are the functions to report events + +*****************************************************************************/ + +void report_survey_event(struct adapter *padapter, struct recv_frame *precv_frame) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct survey_event *psurvey_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext; + struct cmd_priv *pcmdpriv; + /* u8 *pframe = precv_frame->rx_data; */ + /* uint len = precv_frame->len; */ + + if (!padapter) + return; + + pmlmeext = &padapter->mlmeextpriv; + pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + INIT_LIST_HEAD(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct survey_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + + if (collect_bss_info(padapter, precv_frame, (struct wlan_bssid_ex *)&psurvey_evt->bss) == _FAIL) { + kfree(pcmd_obj); + kfree(pevtcmd); + return; + } + + process_80211d(padapter, &psurvey_evt->bss); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + pmlmeext->sitesurvey_res.bss_cnt++; + + return; +} + +void report_surveydone_event(struct adapter *padapter) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct surveydone_event *psurveydone_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + INIT_LIST_HEAD(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct surveydone_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; + + DBG_88E("survey done event(%x)\n", psurveydone_evt->bss_cnt); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +void report_join_res(struct adapter *padapter, int res) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct joinbss_event *pjoinbss_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + INIT_LIST_HEAD(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct joinbss_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + pjoinbss_evt->network.join_res = res; + pjoinbss_evt->network.aid = res; + + DBG_88E("report_join_res(%d)\n", res); + + rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct sta_info *psta; + int mac_id; + struct stadel_event *pdel_sta_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + INIT_LIST_HEAD(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct stadel_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); + memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); + + psta = rtw_get_stainfo(&padapter->stapriv, MacAddr); + if (psta) + mac_id = (int)psta->mac_id; + else + mac_id = (-1); + + pdel_sta_evt->mac_id = mac_id; + + DBG_88E("report_del_sta_event: delete STA, mac_id =%d\n", mac_id); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) +{ + struct cmd_obj *pcmd_obj; + u8 *pevtcmd; + u32 cmdsz; + struct stassoc_event *padd_sta_evt; + struct C2HEvent_Header *pc2h_evt_hdr; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + + pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd_obj == NULL) + return; + + cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); + pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + if (pevtcmd == NULL) { + kfree(pcmd_obj); + return; + } + + INIT_LIST_HEAD(&pcmd_obj->list); + + pcmd_obj->cmdcode = GEN_CMD_CODE(_Set_MLME_EVT); + pcmd_obj->cmdsz = cmdsz; + pcmd_obj->parmbuf = pevtcmd; + + pcmd_obj->rsp = NULL; + pcmd_obj->rspsz = 0; + + pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); + pc2h_evt_hdr->len = sizeof(struct stassoc_event); + pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA); + pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + + padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); + memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); + padd_sta_evt->cam_id = cam_idx; + + DBG_88E("report_add_sta_event: add STA\n"); + + rtw_enqueue_cmd(pcmdpriv, pcmd_obj); + + return; +} + +/**************************************************************************** + +Following are the event callback functions + +*****************************************************************************/ + +/* for sta/adhoc mode */ +void update_sta_info(struct adapter *padapter, struct sta_info *psta) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + /* ERP */ + VCS_update(padapter, psta); + + /* HT */ + if (pmlmepriv->htpriv.ht_option) { + psta->htpriv.ht_option = true; + + psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; + + if (support_short_GI(padapter, &(pmlmeinfo->HT_caps))) + psta->htpriv.sgi = true; + + psta->qos_option = true; + } else { + psta->htpriv.ht_option = false; + + psta->htpriv.ampdu_enable = false; + + psta->htpriv.sgi = false; + psta->qos_option = false; + } + psta->htpriv.bwmode = pmlmeext->cur_bwmode; + psta->htpriv.ch_offset = pmlmeext->cur_ch_offset; + + psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ + psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ + + /* QoS */ + if (pmlmepriv->qospriv.qos_option) + psta->qos_option = true; + + psta->state = _FW_LINKED; +} + +void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) +{ + struct sta_info *psta, *psta_bmc; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + u8 join_type; + u16 media_status; + + if (join_res < 0) { + join_type = 1; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + + /* restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + + goto exit_mlmeext_joinbss_event_callback; + } + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + /* for bc/mc */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (psta_bmc) { + pmlmeinfo->FW_sta_info[psta_bmc->mac_id].psta = psta_bmc; + update_bmc_sta_support_rate(padapter, psta_bmc->mac_id); + Update_RA_Entry(padapter, psta_bmc->mac_id); + } + } + + /* turn on dynamic functions */ + Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); + + /* update IOT-releated issue */ + update_IOT_info(padapter); + + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); + + /* BCN interval */ + rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); + + /* udpate capability */ + update_capinfo(padapter, pmlmeinfo->capability); + + /* WMM, Update EDCA param */ + WMMOnAssocRsp(padapter); + + /* HT */ + HTOnAssocRsp(padapter); + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); + if (psta) { /* only for infra. mode */ + pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; + + psta->wireless_mode = pmlmeext->cur_wireless_mode; + + /* set per sta rate after updating HT cap. */ + set_sta_rate(padapter, psta); + rtw_hal_set_hwreg(padapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&psta->mac_id); + media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE: 1 means connect */ + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); + } + + join_type = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + /* correcting TSF */ + correct_TSF(padapter, pmlmeext); + } + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_CONNECT, 0); + +exit_mlmeext_joinbss_event_callback: + + DBG_88E("=>%s\n", __func__); +} + +void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 join_type; + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {/* adhoc master or sta_count>1 */ + /* nothing to do */ + } else { /* adhoc client */ + /* correcting TSF */ + correct_TSF(padapter, pmlmeext); + + /* start beacon */ + if (send_beacon(padapter) == _FAIL) { + pmlmeinfo->FW_sta_info[psta->mac_id].status = 0; + pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE; + return; + } + pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; + } + + join_type = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + } + + pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; + + /* rate radaptive */ + Update_RA_Entry(padapter, psta->mac_id); + + /* update adhoc sta_info */ + update_sta_info(padapter, psta); +} + +void mlmeext_sta_del_event_callback(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + + /* restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + + /* switch to the 20M Hz mode after disconnect */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + /* SelectChannel(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset); */ + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + flush_all_cam_entry(padapter); + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + + /* set MSR to no link state -> infra. mode */ + Set_MSR(padapter, _HW_STATE_STATION_); + + _cancel_timer_ex(&pmlmeext->link_timer); + } +} + +/**************************************************************************** + +Following are the functions for the timer handlers + +*****************************************************************************/ +void _linked_rx_signal_strehgth_display(struct adapter *padapter); +void _linked_rx_signal_strehgth_display(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 mac_id; + int UndecoratedSmoothedPWDB; + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + mac_id = 0; + else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) + mac_id = 2; + + rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &mac_id); + + rtw_hal_get_def_var(padapter, HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, &UndecoratedSmoothedPWDB); + DBG_88E("UndecoratedSmoothedPWDB:%d\n", UndecoratedSmoothedPWDB); +} + +static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta) +{ + u8 ret = false; + + if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta)) && + sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta) && + sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta)) + ret = false; + else + ret = true; + + sta_update_last_rx_pkts(psta); + + return ret; +} + +void linked_status_chk(struct adapter *padapter) +{ + u32 i; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct sta_priv *pstapriv = &padapter->stapriv; + + if (padapter->bRxRSSIDisplay) + _linked_rx_signal_strehgth_display(padapter); + + rtw_hal_sreset_linked_status_check(padapter); + + if (is_client_associated_to_ap(padapter)) { + /* linked infrastructure client mode */ + + int tx_chk = _SUCCESS, rx_chk = _SUCCESS; + int rx_chk_limit; + + rx_chk_limit = 4; + psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); + if (psta != NULL) { + bool is_p2p_enable = false; + #ifdef CONFIG_88EU_P2P + is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); + #endif + + if (!chk_ap_is_alive(padapter, psta)) + rx_chk = _FAIL; + + if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts) + tx_chk = _FAIL; + + if (pmlmeext->active_keep_alive_check && (rx_chk == _FAIL || tx_chk == _FAIL)) { + u8 backup_oper_channel = 0; + + /* switch to correct channel of current network before issue keep-alive frames */ + if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { + backup_oper_channel = rtw_get_oper_ch(padapter); + SelectChannel(padapter, pmlmeext->cur_channel); + } + + if (rx_chk != _SUCCESS) + issue_probereq_ex(padapter, &pmlmeinfo->network.Ssid, psta->hwaddr, 3, 1); + + if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) { + tx_chk = issue_nulldata(padapter, psta->hwaddr, 0, 3, 1); + /* if tx acked and p2p disabled, set rx_chk _SUCCESS to reset retry count */ + if (tx_chk == _SUCCESS && !is_p2p_enable) + rx_chk = _SUCCESS; + } + + /* back to the original operation channel */ + if (backup_oper_channel > 0) + SelectChannel(padapter, backup_oper_channel); + } else { + if (rx_chk != _SUCCESS) { + if (pmlmeext->retry == 0) { + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + issue_probereq(padapter, &pmlmeinfo->network.Ssid, pmlmeinfo->network.MacAddress); + } + } + + if (tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) { + tx_chk = issue_nulldata(padapter, NULL, 0, 1, 0); + } + } + + if (rx_chk == _FAIL) { + pmlmeext->retry++; + if (pmlmeext->retry > rx_chk_limit) { + DBG_88E_LEVEL(_drv_always_, FUNC_ADPT_FMT" disconnect or roaming\n", + FUNC_ADPT_ARG(padapter)); + receive_disconnect(padapter, pmlmeinfo->network.MacAddress, + WLAN_REASON_EXPIRATION_CHK); + return; + } + } else { + pmlmeext->retry = 0; + } + + if (tx_chk == _FAIL) { + pmlmeinfo->link_count &= 0xf; + } else { + pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; + pmlmeinfo->link_count = 0; + } + } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.MacAddress)) != NULL) */ + } else if (is_client_associated_to_ibss(padapter)) { + /* linked IBSS mode */ + /* for each assoc list entry to check the rx pkt counter */ + for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { + if (pmlmeinfo->FW_sta_info[i].status == 1) { + psta = pmlmeinfo->FW_sta_info[i].psta; + + if (NULL == psta) + continue; + if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) { + if (pmlmeinfo->FW_sta_info[i].retry < 3) { + pmlmeinfo->FW_sta_info[i].retry++; + } else { + pmlmeinfo->FW_sta_info[i].retry = 0; + pmlmeinfo->FW_sta_info[i].status = 0; + report_del_sta_event(padapter, psta->hwaddr + , 65535/* indicate disconnect caused by no rx */ + ); + } + } else { + pmlmeinfo->FW_sta_info[i].retry = 0; + pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta); + } + } + } + } +} + +void survey_timer_hdl(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct sitesurvey_parm *psurveyPara; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif + + /* issue rtw_sitesurvey_cmd */ + if (pmlmeext->sitesurvey_res.state > SCAN_START) { + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) + pmlmeext->sitesurvey_res.channel_idx++; + + if (pmlmeext->scan_abort) { + #ifdef CONFIG_88EU_P2P + if (!rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE)) { + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_MAX); + pmlmeext->sitesurvey_res.channel_idx = 3; + DBG_88E("%s idx:%d, cnt:%u\n", __func__ + , pmlmeext->sitesurvey_res.channel_idx + , pwdinfo->find_phase_state_exchange_cnt + ); + } else + #endif + { + pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; + DBG_88E("%s idx:%d\n", __func__ + , pmlmeext->sitesurvey_res.channel_idx + ); + } + + pmlmeext->scan_abort = false;/* reset */ + } + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) + goto exit_survey_timer_hdl; + + psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + if (psurveyPara == NULL) { + kfree(ph2c); + goto exit_survey_timer_hdl; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); + rtw_enqueue_cmd(pcmdpriv, ph2c); + } + +exit_survey_timer_hdl: + return; +} + +void link_timer_hdl(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { + DBG_88E("link_timer_hdl:no beacon while connecting\n"); + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -3); + } else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) { + /* re-auth timer */ + if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) { + pmlmeinfo->state = 0; + report_join_res(padapter, -1); + return; + } + + DBG_88E("link_timer_hdl: auth timeout and try again\n"); + pmlmeinfo->auth_seq = 1; + issue_auth(padapter, NULL, 0); + set_link_timer(pmlmeext, REAUTH_TO); + } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) { + /* re-assoc timer */ + if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) { + pmlmeinfo->state = WIFI_FW_NULL_STATE; + report_join_res(padapter, -2); + return; + } + + DBG_88E("link_timer_hdl: assoc timeout and try again\n"); + issue_assocreq(padapter); + set_link_timer(pmlmeext, REASSOC_TO); + } + return; +} + +void addba_timer_hdl(struct sta_info *psta) +{ + struct ht_priv *phtpriv; + + if (!psta) + return; + + phtpriv = &psta->htpriv; + + if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { + if (phtpriv->candidate_tid_bitmap) + phtpriv->candidate_tid_bitmap = 0x0; + } +} + +u8 NULL_hdl(struct adapter *padapter, u8 *pbuf) +{ + return H2C_SUCCESS; +} + +u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) +{ + u8 type; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; + + if (psetop->mode == Ndis802_11APMode) { + pmlmeinfo->state = WIFI_FW_AP_STATE; + type = _HW_STATE_AP_; + } else if (psetop->mode == Ndis802_11Infrastructure) { + pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ + pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ + type = _HW_STATE_STATION_; + } else if (psetop->mode == Ndis802_11IBSS) { + type = _HW_STATE_ADHOC_; + } else { + type = _HW_STATE_NOLINK_; + } + + rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); + /* Set_NETYPE0_MSR(padapter, type); */ + + return H2C_SUCCESS; +} + +u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + /* u32 initialgain; */ + + if (pparm->network.InfrastructureMode == Ndis802_11APMode) { +#ifdef CONFIG_88EU_AP_MODE + + if (pmlmeinfo->state == WIFI_FW_AP_STATE) { + /* todo: */ + return H2C_SUCCESS; + } +#endif + } + + /* below is for ad-hoc master */ + if (pparm->network.InfrastructureMode == Ndis802_11IBSS) { + rtw_joinbss_reset(padapter); + + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeinfo->ERP_enable = 0; + pmlmeinfo->WMM_enable = 0; + pmlmeinfo->HT_enable = 0; + pmlmeinfo->HT_caps_enable = 0; + pmlmeinfo->HT_info_enable = 0; + pmlmeinfo->agg_enable_bitmap = 0; + pmlmeinfo->candidate_tid_bitmap = 0; + + /* disable dynamic functions, such as high power, DIG */ + Save_DM_Func_Flag(padapter); + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); + + /* config the initial gain under linking, need to write the BB registers */ + /* initialgain = 0x1E; */ + /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ + + /* cancel link timer */ + _cancel_timer_ex(&pmlmeext->link_timer); + + /* clear CAM */ + flush_all_cam_entry(padapter); + + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); + pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + + if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + return H2C_PARAMETERS_ERROR; + + memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); + + start_create_ibss(padapter); + } + + return H2C_SUCCESS; +} + +u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) +{ + u8 join_type; + struct ndis_802_11_var_ie *pIE; + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; + u32 i; + + /* check already connecting to AP or not */ + if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { + if (pmlmeinfo->state & WIFI_FW_STATION_STATE) + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 5, 100); + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + + /* clear CAM */ + flush_all_cam_entry(padapter); + + _cancel_timer_ex(&pmlmeext->link_timer); + + /* set MSR to nolink -> infra. mode */ + Set_MSR(padapter, _HW_STATE_STATION_); + + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + } + + rtw_antenna_select_cmd(padapter, pparm->network.PhyInfo.Optimum_antenna, false); + + rtw_joinbss_reset(padapter); + + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmlmeinfo->ERP_enable = 0; + pmlmeinfo->WMM_enable = 0; + pmlmeinfo->HT_enable = 0; + pmlmeinfo->HT_caps_enable = 0; + pmlmeinfo->HT_info_enable = 0; + pmlmeinfo->agg_enable_bitmap = 0; + pmlmeinfo->candidate_tid_bitmap = 0; + pmlmeinfo->bwmode_updated = false; + + memcpy(pnetwork, pbuf, FIELD_OFFSET(struct wlan_bssid_ex, IELength)); + pnetwork->IELength = ((struct wlan_bssid_ex *)pbuf)->IELength; + + if (pnetwork->IELength > MAX_IE_SZ)/* Check pbuf->IELength */ + return H2C_PARAMETERS_ERROR; + + memcpy(pnetwork->IEs, ((struct wlan_bssid_ex *)pbuf)->IEs, pnetwork->IELength); + + /* Check AP vendor to move rtw_joinbss_cmd() */ + + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_:/* Get WMM IE. */ + if (!memcmp(pIE->data, WMM_OUI, 4)) + pmlmeinfo->WMM_enable = 1; + break; + case _HT_CAPABILITY_IE_: /* Get HT Cap IE. */ + pmlmeinfo->HT_caps_enable = 1; + break; + case _HT_EXTRA_INFO_IE_: /* Get HT Info IE. */ + pmlmeinfo->HT_info_enable = 1; + + /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ + { + struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); + + if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { + /* switch to the 40M Hz mode according to the AP */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; + switch (pht_info->infos[0] & 0x3) { + case 1: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case 3: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + + DBG_88E("set ch/bw before connected\n"); + } + } + break; + default: + break; + } + + i += (pIE->Length + 2); + } + /* disable dynamic functions, such as high power, DIG */ + + /* config the initial gain under linking, need to write the BB registers */ + + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); + join_type = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); + + /* cancel link timer */ + _cancel_timer_ex(&pmlmeext->link_timer); + + start_clnt_join(padapter); + + return H2C_SUCCESS; +} + +u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct disconnect_parm *param = (struct disconnect_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + u8 val8; + + if (is_client_associated_to_ap(padapter)) + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); + + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); + rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); + + /* restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + /* Stop BCN */ + val8 = 0; + rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); + } + + /* set MSR to no link state -> infra. mode */ + Set_MSR(padapter, _HW_STATE_STATION_); + + pmlmeinfo->state = WIFI_FW_NULL_STATE; + + /* switch to the 20M Hz mode after disconnect */ + pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; + pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); + + flush_all_cam_entry(padapter); + + _cancel_timer_ex(&pmlmeext->link_timer); + + rtw_free_uc_swdec_pending_queue(padapter); + + return H2C_SUCCESS; +} + +static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_channel *out, + u32 out_num, struct rtw_ieee80211_channel *in, u32 in_num) +{ + int i, j; + int set_idx; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + /* clear out first */ + memset(out, 0, sizeof(struct rtw_ieee80211_channel)*out_num); + + /* acquire channels from in */ + j = 0; + for (i = 0; i < in_num; i++) { + set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value); + if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) && + set_idx >= 0) { + memcpy(&out[j], &in[i], sizeof(struct rtw_ieee80211_channel)); + + if (pmlmeext->channel_set[set_idx].ScanType == SCAN_PASSIVE) + out[j].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; + + j++; + } + if (j >= out_num) + break; + } + + /* if out is empty, use channel_set as default */ + if (j == 0) { + for (i = 0; i < pmlmeext->max_chan_nums; i++) { + out[i].hw_value = pmlmeext->channel_set[i].ChannelNum; + + if (pmlmeext->channel_set[i].ScanType == SCAN_PASSIVE) + out[i].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; + + j++; + } + } + + return j; +} + +u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; + u8 bdelayscan = false; + u8 val8; + u32 initialgain; + u32 i; + +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif + + if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { + /* for first time sitesurvey_cmd */ + rtw_hal_set_hwreg(padapter, HW_VAR_CHECK_TXBUF, NULL); + + pmlmeext->sitesurvey_res.state = SCAN_START; + pmlmeext->sitesurvey_res.bss_cnt = 0; + pmlmeext->sitesurvey_res.channel_idx = 0; + + for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { + if (pparm->ssid[i].SsidLength) { + memcpy(pmlmeext->sitesurvey_res.ssid[i].Ssid, pparm->ssid[i].Ssid, IW_ESSID_MAX_SIZE); + pmlmeext->sitesurvey_res.ssid[i].SsidLength = pparm->ssid[i].SsidLength; + } else { + pmlmeext->sitesurvey_res.ssid[i].SsidLength = 0; + } + } + + pmlmeext->sitesurvey_res.ch_num = rtw_scan_ch_decision(padapter + , pmlmeext->sitesurvey_res.ch, RTW_CHANNEL_SCAN_AMOUNT + , pparm->ch, pparm->ch_num + ); + + pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode; + + /* issue null data if associating to the AP */ + if (is_client_associated_to_ap(padapter)) { + pmlmeext->sitesurvey_res.state = SCAN_TXNULL; + + issue_nulldata(padapter, NULL, 1, 3, 500); + + bdelayscan = true; + } + if (bdelayscan) { + /* delay 50ms to protect nulldata(1). */ + set_survey_timer(pmlmeext, 50); + return H2C_SUCCESS; + } + } + + if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { + /* disable dynamic functions, such as high power, DIG */ + Save_DM_Func_Flag(padapter); + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); + + /* config the initial gain under scanning, need to write the BB registers */ +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + initialgain = 0x1E; + else + initialgain = 0x28; +#else /* CONFIG_88EU_P2P */ + initialgain = 0x1E; +#endif /* CONFIG_88EU_P2P */ + + rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); + + /* set MSR to no link state */ + Set_MSR(padapter, _HW_STATE_NOLINK_); + + val8 = 1; /* under site survey */ + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + + pmlmeext->sitesurvey_res.state = SCAN_PROCESS; + } + + site_survey(padapter); + + return H2C_SUCCESS; +} + +u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct setauth_parm *pparm = (struct setauth_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pparm->mode < 4) + pmlmeinfo->auth_algo = pparm->mode; + return H2C_SUCCESS; +} + +u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) +{ + unsigned short ctrl; + struct setkey_parm *pparm = (struct setkey_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + /* main tx key for wep. */ + if (pparm->set_tx) + pmlmeinfo->key_index = pparm->keyid; + + /* write cam */ + ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid; + + DBG_88E_LEVEL(_drv_info_, "set group key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) " + "keyid:%d\n", pparm->algorithm, pparm->keyid); + write_cam(padapter, pparm->keyid, ctrl, null_sta, pparm->key); + + return H2C_SUCCESS; +} + +u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) +{ + u16 ctrl = 0; + u8 cam_id;/* cam_entry */ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; + + /* cam_entry: */ + /* 0~3 for default key */ + + /* for concurrent mode (ap+sta): */ + /* default key is disable, using sw encrypt/decrypt */ + /* cam_entry = 4 for sta mode (macid = 0) */ + /* cam_entry(macid+3) = 5 ~ N for ap mode (aid = 1~N, macid = 2 ~N) */ + + /* for concurrent mode (sta+sta): */ + /* default key is disable, using sw encrypt/decrypt */ + /* cam_entry = 4 mapping to macid = 0 */ + /* cam_entry = 5 mapping to macid = 2 */ + + cam_id = 4; + + DBG_88E_LEVEL(_drv_info_, "set pairwise key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) camid:%d\n", + pparm->algorithm, cam_id); + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (pparm->algorithm == _NO_PRIVACY_) /* clear cam entry */ { + clear_cam_entry(padapter, pparm->id); + return H2C_SUCCESS_RSP; + } + + psta = rtw_get_stainfo(pstapriv, pparm->addr); + if (psta) { + ctrl = (BIT(15) | ((pparm->algorithm) << 2)); + + DBG_88E("r871x_set_stakey_hdl(): enc_algorithm=%d\n", pparm->algorithm); + + if ((psta->mac_id < 1) || (psta->mac_id > (NUM_STA-4))) { + DBG_88E("r871x_set_stakey_hdl():set_stakey failed, mac_id(aid)=%d\n", psta->mac_id); + return H2C_REJECTED; + } + + cam_id = (psta->mac_id + 3);/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ + + DBG_88E("Write CAM, mac_addr =%x:%x:%x:%x:%x:%x, cam_entry=%d\n", pparm->addr[0], + pparm->addr[1], pparm->addr[2], pparm->addr[3], pparm->addr[4], + pparm->addr[5], cam_id); + + write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); + + return H2C_SUCCESS_RSP; + } else { + DBG_88E("r871x_set_stakey_hdl(): sta has been free\n"); + return H2C_REJECTED; + } + } + + /* below for sta mode */ + + if (pparm->algorithm == _NO_PRIVACY_) { /* clear cam entry */ + clear_cam_entry(padapter, pparm->id); + return H2C_SUCCESS; + } + ctrl = BIT(15) | ((pparm->algorithm) << 2); + write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); + pmlmeinfo->enc_algo = pparm->algorithm; + return H2C_SUCCESS; +} + +u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); + + if (!psta) + return H2C_SUCCESS; + + if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || + ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); + _set_timer(&psta->addba_retry_timer, ADDBA_TO); + } else { + psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); + } + return H2C_SUCCESS; +} + +u8 set_tx_beacon_cmd(struct adapter *padapter) +{ + struct cmd_obj *ph2c; + struct Tx_Beacon_param *ptxBeacon_parm; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u8 res = _SUCCESS; + int len_diff = 0; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); + if (ptxBeacon_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + memcpy(&(ptxBeacon_parm->network), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + + len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, + ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, + pmlmeinfo->hidden_ssid_mode); + ptxBeacon_parm->network.IELength += len_diff; + + init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, GEN_CMD_CODE(_TX_Beacon)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + u8 evt_code; + u16 evt_sz; + uint *peventbuf; + void (*event_callback)(struct adapter *dev, u8 *pbuf); + struct evt_priv *pevt_priv = &(padapter->evtpriv); + + peventbuf = (uint *)pbuf; + evt_sz = (u16)(*peventbuf&0xffff); + evt_code = (u8)((*peventbuf>>16)&0xff); + + /* checking if event code is valid */ + if (evt_code >= MAX_C2HEVT) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) mismatch!\n", evt_code)); + goto _abort_event_; + } + + /* checking if event size match the event parm size */ + if ((wlanevents[evt_code].parmsize != 0) && + (wlanevents[evt_code].parmsize != evt_sz)) { + RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, + ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n", + evt_code, wlanevents[evt_code].parmsize, evt_sz)); + goto _abort_event_; + } + + ATOMIC_INC(&pevt_priv->event_seq); + + peventbuf += 2; + + if (peventbuf) { + event_callback = wlanevents[evt_code].event_callback; + event_callback(padapter, (u8 *)peventbuf); + + pevt_priv->evt_done_cnt++; + } + +_abort_event_: + return H2C_SUCCESS; +} + +u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + return H2C_SUCCESS; +} + +u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + if (send_beacon(padapter) == _FAIL) { + DBG_88E("issue_beacon, fail!\n"); + return H2C_PARAMETERS_ERROR; + } +#ifdef CONFIG_88EU_AP_MODE + else { /* tx bc/mc frames after update TIM */ + struct sta_info *psta_bmc; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + /* for BC/MC Frames */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (!psta_bmc) + return H2C_SUCCESS; + + if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { + rtw_msleep_os(10);/* 10ms, ATIM(HIQ) Windows */ + spin_lock_bh(&psta_bmc->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + xmitframe_plist = xmitframe_phead->next; + + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = xmitframe_plist->next; + + list_del_init(&pxmitframe->list); + + psta_bmc->sleepq_len--; + if (psta_bmc->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + pxmitframe->attrib.triggered = 1; + + pxmitframe->attrib.qsel = 0x11;/* HIQ */ + + spin_unlock_bh(&psta_bmc->sleep_q.lock); + if (rtw_hal_xmit(padapter, pxmitframe)) + rtw_os_xmit_complete(padapter, pxmitframe); + spin_lock_bh(&psta_bmc->sleep_q.lock); + } + spin_unlock_bh(&psta_bmc->sleep_q.lock); + } + } +#endif + return H2C_SUCCESS; +} + +u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) +{ + struct set_ch_parm *set_ch_parm; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + set_ch_parm = (struct set_ch_parm *)pbuf; + + DBG_88E(FUNC_NDEV_FMT" ch:%u, bw:%u, ch_offset:%u\n", + FUNC_NDEV_ARG(padapter->pnetdev), + set_ch_parm->ch, set_ch_parm->bw, set_ch_parm->ch_offset); + + pmlmeext->cur_channel = set_ch_parm->ch; + pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; + pmlmeext->cur_bwmode = set_ch_parm->bw; + + set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); + + return H2C_SUCCESS; +} + +u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + struct SetChannelPlan_param *setChannelPlan_param; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + if (!pbuf) + return H2C_PARAMETERS_ERROR; + + setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; + + pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); + init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); + + return H2C_SUCCESS; +} + +u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + if (!pbuf) + return H2C_PARAMETERS_ERROR; + return H2C_SUCCESS; +} + +u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + return H2C_REJECTED; +} + +/* TDLS_WRCR : write RCR DATA BIT */ +/* TDLS_SD_PTI : issue peer traffic indication */ +/* TDLS_CS_OFF : go back to the channel linked with AP, terminating channel switch procedure */ +/* TDLS_INIT_CH_SEN : init channel sensing, receive all data and mgnt frame */ +/* TDLS_DONE_CH_SEN: channel sensing and report candidate channel */ +/* TDLS_OFF_CH : first time set channel to off channel */ +/* TDLS_BASE_CH : go back tp the channel linked with AP when set base channel as target channel */ +/* TDLS_P_OFF_CH : periodically go to off channel */ +/* TDLS_P_BASE_CH : periodically go back to base channel */ +/* TDLS_RS_RCR : restore RCR */ +/* TDLS_CKALV_PH1 : check alive timer phase1 */ +/* TDLS_CKALV_PH2 : check alive timer phase2 */ +/* TDLS_FREE_STA : free tdls sta */ +u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf) +{ + return H2C_REJECTED; +} diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c new file mode 100644 index 000000000000..30bcac68f8e9 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -0,0 +1,1000 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + *published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MP_C_ + +#include + +#include "odm_precomp.h" +#include "rtl8188e_hal.h" + +u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz) +{ + u32 val = 0; + + switch (sz) { + case 1: + val = rtw_read8(padapter, addr); + break; + case 2: + val = rtw_read16(padapter, addr); + break; + case 4: + val = rtw_read32(padapter, addr); + break; + default: + val = 0xffffffff; + break; + } + + return val; +} + +void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz) +{ + switch (sz) { + case 1: + rtw_write8(padapter, addr, (u8)val); + break; + case 2: + rtw_write16(padapter, addr, (u16)val); + break; + case 4: + rtw_write32(padapter, addr, val); + break; + default: + break; + } +} + +u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask) +{ + return rtw_hal_read_bbreg(padapter, addr, bitmask); +} + +void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val) +{ + rtw_hal_write_bbreg(padapter, addr, bitmask, val); +} + +u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask) +{ + return rtw_hal_read_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bitmask); +} + +void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val) +{ + rtw_hal_write_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bitmask, val); +} + +u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr) +{ + return _read_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bRFRegOffsetMask); +} + +void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val) +{ + _write_rfreg(padapter, (enum rf_radio_path)rfpath, addr, bRFRegOffsetMask, val); +} + +static void _init_mp_priv_(struct mp_priv *pmp_priv) +{ + struct wlan_bssid_ex *pnetwork; + + memset(pmp_priv, 0, sizeof(struct mp_priv)); + + pmp_priv->mode = MP_OFF; + + pmp_priv->channel = 1; + pmp_priv->bandwidth = HT_CHANNEL_WIDTH_20; + pmp_priv->prime_channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + pmp_priv->rateidx = MPT_RATE_1M; + pmp_priv->txpoweridx = 0x2A; + + pmp_priv->antenna_tx = ANTENNA_A; + pmp_priv->antenna_rx = ANTENNA_AB; + + pmp_priv->check_mp_pkt = 0; + + pmp_priv->tx_pktcount = 0; + + pmp_priv->rx_pktcount = 0; + pmp_priv->rx_crcerrpktcount = 0; + + pmp_priv->network_macaddr[0] = 0x00; + pmp_priv->network_macaddr[1] = 0xE0; + pmp_priv->network_macaddr[2] = 0x4C; + pmp_priv->network_macaddr[3] = 0x87; + pmp_priv->network_macaddr[4] = 0x66; + pmp_priv->network_macaddr[5] = 0x55; + + pnetwork = &pmp_priv->mp_network.network; + memcpy(pnetwork->MacAddress, pmp_priv->network_macaddr, ETH_ALEN); + + pnetwork->Ssid.SsidLength = 8; + memcpy(pnetwork->Ssid.Ssid, "mp_871x", pnetwork->Ssid.SsidLength); +} + +static void mp_init_xmit_attrib(struct mp_tx *pmptx, struct adapter *padapter) +{ + struct pkt_attrib *pattrib; + struct tx_desc *desc; + + /* init xmitframe attribute */ + pattrib = &pmptx->attrib; + memset(pattrib, 0, sizeof(struct pkt_attrib)); + desc = &pmptx->desc; + memset(desc, 0, TXDESC_SIZE); + + pattrib->ether_type = 0x8712; + memset(pattrib->dst, 0xFF, ETH_ALEN); + pattrib->ack_policy = 0; + pattrib->hdrlen = WLAN_HDR_A3_LEN; + pattrib->subtype = WIFI_DATA; + pattrib->priority = 0; + pattrib->qsel = pattrib->priority; + pattrib->nr_frags = 1; + pattrib->encrypt = 0; + pattrib->bswenc = false; + pattrib->qos_en = false; +} + +s32 init_mp_priv(struct adapter *padapter) +{ + struct mp_priv *pmppriv = &padapter->mppriv; + + _init_mp_priv_(pmppriv); + pmppriv->papdater = padapter; + + pmppriv->tx.stop = 1; + mp_init_xmit_attrib(&pmppriv->tx, padapter); + + switch (padapter->registrypriv.rf_config) { + case RF_1T1R: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_A; + break; + case RF_1T2R: + default: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T2R: + case RF_2T2R_GREEN: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T4R: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_ABCD; + break; + } + + return _SUCCESS; +} + +void free_mp_priv(struct mp_priv *pmp_priv) +{ + kfree(pmp_priv->pallocated_mp_xmitframe_buf); + pmp_priv->pallocated_mp_xmitframe_buf = NULL; + pmp_priv->pmp_xmtframe_buf = NULL; +} + +#define PHY_IQCalibrate(a, b) PHY_IQCalibrate_8188E(a, b) +#define PHY_LCCalibrate(a) PHY_LCCalibrate_8188E(a) +#define PHY_SetRFPathSwitch(a, b) PHY_SetRFPathSwitch_8188E(a, b) + +s32 MPT_InitializeAdapter(struct adapter *pAdapter, u8 Channel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + s32 rtStatus = _SUCCESS; + struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; + struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv; + + /* HW Initialization for 8190 MPT. */ + /* SW Initialization for 8190 MP. */ + pMptCtx->bMptDrvUnload = false; + pMptCtx->bMassProdTest = false; + pMptCtx->bMptIndexEven = true; /* default gain index is -6.0db */ + pMptCtx->h2cReqNum = 0x0; + /* Init mpt event. */ + /* init for BT MP */ + + pMptCtx->bMptWorkItemInProgress = false; + pMptCtx->CurrMptAct = NULL; + /* */ + + /* Don't accept any packets */ + rtw_write32(pAdapter, REG_RCR, 0); + + PHY_IQCalibrate(pAdapter, false); + dm_CheckTXPowerTracking(&pHalData->odmpriv); /* trigger thermal meter */ + PHY_LCCalibrate(pAdapter); + + pMptCtx->backup0xc50 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_XAAGCCore1, bMaskByte0); + pMptCtx->backup0xc58 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_XBAGCCore1, bMaskByte0); + pMptCtx->backup0xc30 = (u8)PHY_QueryBBReg(pAdapter, rOFDM0_RxDetector1, bMaskByte0); + pMptCtx->backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + pMptCtx->backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + + /* set ant to wifi side in mp mode */ + rtw_write16(pAdapter, 0x870, 0x300); + rtw_write16(pAdapter, 0x860, 0x110); + + if (pAdapter->registrypriv.mp_mode == 1) + pmlmepriv->fw_state = WIFI_MP_STATE; + + return rtStatus; +} + +/*----------------------------------------------------------------------------- + * Function: MPT_DeInitAdapter() + * + * Overview: Extra DeInitialization for Mass Production Test. + * + * Input: struct adapter * pAdapter + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 05/08/2007 MHC Create Version 0. + * 05/18/2007 MHC Add normal driver MPHalt code. + * + *---------------------------------------------------------------------------*/ +void MPT_DeInitAdapter(struct adapter *pAdapter) +{ + struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; + + pMptCtx->bMptDrvUnload = true; +} + +static u8 mpt_ProStartTest(struct adapter *padapter) +{ + struct mpt_context *pMptCtx = &padapter->mppriv.MptCtx; + + pMptCtx->bMassProdTest = true; + pMptCtx->bStartContTx = false; + pMptCtx->bCckContTx = false; + pMptCtx->bOfdmContTx = false; + pMptCtx->bSingleCarrier = false; + pMptCtx->bCarrierSuppression = false; + pMptCtx->bSingleTone = false; + + return _SUCCESS; +} + +/* + * General use + */ +s32 SetPowerTracking(struct adapter *padapter, u8 enable) +{ + Hal_SetPowerTracking(padapter, enable); + return 0; +} + +void GetPowerTracking(struct adapter *padapter, u8 *enable) +{ + Hal_GetPowerTracking(padapter, enable); +} + +static void disable_dm(struct adapter *padapter) +{ + u8 v8; + + /* 3 1. disable firmware dynamic mechanism */ + /* disable Power Training, Rate Adaptive */ + v8 = rtw_read8(padapter, REG_BCN_CTRL); + v8 &= ~EN_BCN_FUNCTION; + rtw_write8(padapter, REG_BCN_CTRL, v8); + + /* 3 2. disable driver dynamic mechanism */ + /* disable Dynamic Initial Gain */ + /* disable High Power */ + /* disable Power Tracking */ + Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); + + /* enable APK, LCK and IQK but disable power tracking */ + Switch_DM_Func(padapter, DYNAMIC_RF_CALIBRATION, true); +} + +/* This function initializes the DUT to the MP test mode */ +s32 mp_start_test(struct adapter *padapter) +{ + struct wlan_bssid_ex bssid; + struct sta_info *psta; + u32 length; + u8 val8; + s32 res = _SUCCESS; + struct mp_priv *pmppriv = &padapter->mppriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + + padapter->registrypriv.mp_mode = 1; + pmppriv->bSetTxPower = 0; /* for manually set tx power */ + + /* 3 disable dynamic mechanism */ + disable_dm(padapter); + + /* 3 0. update mp_priv */ + + if (padapter->registrypriv.rf_config == RF_819X_MAX_TYPE) { + switch (GET_RF_TYPE(padapter)) { + case RF_1T1R: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_A; + break; + case RF_1T2R: + default: + pmppriv->antenna_tx = ANTENNA_A; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T2R: + case RF_2T2R_GREEN: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_AB; + break; + case RF_2T4R: + pmppriv->antenna_tx = ANTENNA_AB; + pmppriv->antenna_rx = ANTENNA_ABCD; + break; + } + } + + mpt_ProStartTest(padapter); + + /* 3 1. initialize a new struct wlan_bssid_ex */ +/* memset(&bssid, 0, sizeof(struct wlan_bssid_ex)); */ + memcpy(bssid.MacAddress, pmppriv->network_macaddr, ETH_ALEN); + bssid.Ssid.SsidLength = strlen("mp_pseudo_adhoc"); + memcpy(bssid.Ssid.Ssid, (u8 *)"mp_pseudo_adhoc", bssid.Ssid.SsidLength); + bssid.InfrastructureMode = Ndis802_11IBSS; + bssid.NetworkTypeInUse = Ndis802_11DS; + bssid.IELength = 0; + + length = get_wlan_bssid_ex_sz(&bssid); + if (length % 4) + bssid.Length = ((length >> 2) + 1) << 2; /* round up to multiple of 4 bytes. */ + else + bssid.Length = length; + + spin_lock_bh(&pmlmepriv->lock); + + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + goto end_of_mp_start_test; + + /* init mp_start_test status */ + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + rtw_disassoc_cmd(padapter, 500, true); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); + } + pmppriv->prev_fw_state = get_fwstate(pmlmepriv); + if (padapter->registrypriv.mp_mode == 1) + pmlmepriv->fw_state = WIFI_MP_STATE; + set_fwstate(pmlmepriv, _FW_UNDER_LINKING); + + /* 3 2. create a new psta for mp driver */ + /* clear psta in the cur_network, if any */ + psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); + if (psta) + rtw_free_stainfo(padapter, psta); + + psta = rtw_alloc_stainfo(&padapter->stapriv, bssid.MacAddress); + if (psta == NULL) { + RT_TRACE(_module_mp_, _drv_err_, ("mp_start_test: Can't alloc sta_info!\n")); + pmlmepriv->fw_state = pmppriv->prev_fw_state; + res = _FAIL; + goto end_of_mp_start_test; + } + + /* 3 3. join psudo AdHoc */ + tgt_network->join_res = 1; + tgt_network->aid = 1; + psta->aid = 1; + memcpy(&tgt_network->network, &bssid, length); + + rtw_indicate_connect(padapter); + _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); + +end_of_mp_start_test: + + spin_unlock_bh(&pmlmepriv->lock); + + if (res == _SUCCESS) { + /* set MSR to WIFI_FW_ADHOC_STATE */ + val8 = rtw_read8(padapter, MSR) & 0xFC; /* 0x0102 */ + val8 |= WIFI_FW_ADHOC_STATE; + rtw_write8(padapter, MSR, val8); /* Link in ad hoc network */ + } + return res; +} +/* */ +/* This function change the DUT from the MP test mode into normal mode */ +void mp_stop_test(struct adapter *padapter) +{ + struct mp_priv *pmppriv = &padapter->mppriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *tgt_network = &pmlmepriv->cur_network; + struct sta_info *psta; + + if (pmppriv->mode == MP_ON) { + pmppriv->bSetTxPower = 0; + spin_lock_bh(&pmlmepriv->lock); + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false) + goto end_of_mp_stop_test; + + /* 3 1. disconnect psudo AdHoc */ + rtw_indicate_disconnect(padapter); + + /* 3 2. clear psta used in mp test mode. */ + psta = rtw_get_stainfo(&padapter->stapriv, tgt_network->network.MacAddress); + if (psta) + rtw_free_stainfo(padapter, psta); + + /* 3 3. return to normal state (default:station mode) */ + pmlmepriv->fw_state = pmppriv->prev_fw_state; /* WIFI_STATION_STATE; */ + + /* flush the cur_network */ + memset(tgt_network, 0, sizeof(struct wlan_network)); + + _clr_fwstate_(pmlmepriv, WIFI_MP_STATE); + +end_of_mp_stop_test: + + spin_unlock_bh(&pmlmepriv->lock); + } +} + +/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ +/* + * SetChannel + * Description + * Use H2C command to change channel, + * not only modify rf register, but also other setting need to be done. + */ +void SetChannel(struct adapter *pAdapter) +{ + Hal_SetChannel(pAdapter); +} + +/* + * Notice + * Switch bandwitdth may change center frequency(channel) + */ +void SetBandwidth(struct adapter *pAdapter) +{ + Hal_SetBandwidth(pAdapter); +} + +void SetAntenna(struct adapter *pAdapter) +{ + Hal_SetAntenna(pAdapter); +} + +void SetAntennaPathPower(struct adapter *pAdapter) +{ + Hal_SetAntennaPathPower(pAdapter); +} + +void SetTxPower(struct adapter *pAdapter) +{ + Hal_SetTxPower(pAdapter); + } + +void SetDataRate(struct adapter *pAdapter) +{ + Hal_SetDataRate(pAdapter); +} + +void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter , bool bMain) +{ + PHY_SetRFPathSwitch(pAdapter, bMain); +} + +s32 SetThermalMeter(struct adapter *pAdapter, u8 target_ther) +{ + return Hal_SetThermalMeter(pAdapter, target_ther); +} + +void GetThermalMeter(struct adapter *pAdapter, u8 *value) +{ + Hal_GetThermalMeter(pAdapter, value); +} + +void SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetSingleCarrierTx(pAdapter, bStart); +} + +void SetSingleToneTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetSingleToneTx(pAdapter, bStart); +} + +void SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetCarrierSuppressionTx(pAdapter, bStart); +} + +void SetContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + PhySetTxPowerLevel(pAdapter); + Hal_SetContinuousTx(pAdapter, bStart); +} + +void PhySetTxPowerLevel(struct adapter *pAdapter) +{ + struct mp_priv *pmp_priv = &pAdapter->mppriv; + + if (pmp_priv->bSetTxPower == 0) /* for NO manually set power index */ + PHY_SetTxPowerLevel8188E(pAdapter, pmp_priv->channel); +} + +/* */ +static void dump_mpframe(struct adapter *padapter, struct xmit_frame *pmpframe) +{ + rtw_hal_mgnt_xmit(padapter, pmpframe); +} + +static struct xmit_frame *alloc_mp_xmitframe(struct xmit_priv *pxmitpriv) +{ + struct xmit_frame *pmpframe; + struct xmit_buf *pxmitbuf; + + pmpframe = rtw_alloc_xmitframe(pxmitpriv); + if (pmpframe == NULL) + return NULL; + + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (pxmitbuf == NULL) { + rtw_free_xmitframe(pxmitpriv, pmpframe); + return NULL; + } + + pmpframe->frame_tag = MP_FRAMETAG; + + pmpframe->pxmitbuf = pxmitbuf; + + pmpframe->buf_addr = pxmitbuf->pbuf; + + pxmitbuf->priv_data = pmpframe; + + return pmpframe; +} + +static int mp_xmit_packet_thread(void *context) +{ + struct xmit_frame *pxmitframe; + struct mp_tx *pmptx; + struct mp_priv *pmp_priv; + struct xmit_priv *pxmitpriv; + struct adapter *padapter; + + pmp_priv = (struct mp_priv *)context; + pmptx = &pmp_priv->tx; + padapter = pmp_priv->papdater; + pxmitpriv = &(padapter->xmitpriv); + + thread_enter("RTW_MP_THREAD"); + + /* DBG_88E("%s:pkTx Start\n", __func__); */ + while (1) { + pxmitframe = alloc_mp_xmitframe(pxmitpriv); + if (pxmitframe == NULL) { + if (pmptx->stop || + padapter->bSurpriseRemoved || + padapter->bDriverStopped) { + goto exit; + } else { + rtw_msleep_os(1); + continue; + } + } + + memcpy((u8 *)(pxmitframe->buf_addr+TXDESC_OFFSET), pmptx->buf, pmptx->write_size); + memcpy(&(pxmitframe->attrib), &(pmptx->attrib), sizeof(struct pkt_attrib)); + + dump_mpframe(padapter, pxmitframe); + + pmptx->sended++; + pmp_priv->tx_pktcount++; + + if (pmptx->stop || + padapter->bSurpriseRemoved || + padapter->bDriverStopped) + goto exit; + if ((pmptx->count != 0) && + (pmptx->count == pmptx->sended)) + goto exit; + + flush_signals_thread(); + } + +exit: + kfree(pmptx->pallocated_buf); + pmptx->pallocated_buf = NULL; + pmptx->stop = 1; + + thread_exit(); +} + +void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc) +{ + struct mp_priv *pmp_priv = &padapter->mppriv; + memcpy(ptxdesc, &(pmp_priv->tx.desc), TXDESC_SIZE); +} + +void SetPacketTx(struct adapter *padapter) +{ + u8 *ptr, *pkt_start, *pkt_end; + u32 pkt_size; + struct tx_desc *desc; + struct rtw_ieee80211_hdr *hdr; + u8 payload; + s32 bmcast; + struct pkt_attrib *pattrib; + struct mp_priv *pmp_priv; + + pmp_priv = &padapter->mppriv; + if (pmp_priv->tx.stop) + return; + pmp_priv->tx.sended = 0; + pmp_priv->tx.stop = 0; + pmp_priv->tx_pktcount = 0; + + /* 3 1. update_attrib() */ + pattrib = &pmp_priv->tx.attrib; + memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + bmcast = IS_MCAST(pattrib->ra); + if (bmcast) { + pattrib->mac_id = 1; + pattrib->psta = rtw_get_bcmc_stainfo(padapter); + } else { + pattrib->mac_id = 0; + pattrib->psta = rtw_get_stainfo(&padapter->stapriv, get_bssid(&padapter->mlmepriv)); + } + + pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->pktlen; + + /* 3 2. allocate xmit buffer */ + pkt_size = pattrib->last_txcmdsz; + + kfree(pmp_priv->tx.pallocated_buf); + pmp_priv->tx.write_size = pkt_size; + pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ; + pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size); + if (pmp_priv->tx.pallocated_buf == NULL) { + DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size); + return; + } + pmp_priv->tx.buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pmp_priv->tx.pallocated_buf), XMITBUF_ALIGN_SZ); + ptr = pmp_priv->tx.buf; + + desc = &(pmp_priv->tx.desc); + memset(desc, 0, TXDESC_SIZE); + pkt_start = ptr; + pkt_end = pkt_start + pkt_size; + + /* 3 3. init TX descriptor */ + /* offset 0 */ + desc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); + desc->txdw0 |= cpu_to_le32(pkt_size & 0x0000FFFF); /* packet size */ + desc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00FF0000); /* 32 bytes for TX Desc */ + if (bmcast) + desc->txdw0 |= cpu_to_le32(BMC); /* broadcast packet */ + + desc->txdw1 |= cpu_to_le32((0x01 << 26) & 0xff000000); + /* offset 4 */ + desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x3F); /* CAM_ID(MAC_ID) */ + desc->txdw1 |= cpu_to_le32((pattrib->qsel << QSEL_SHT) & 0x00001F00); /* Queue Select, TID */ + + desc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); /* Rate Adaptive ID */ + /* offset 8 */ + /* offset 12 */ + + desc->txdw3 |= cpu_to_le32((pattrib->seqnum<<16)&0x0fff0000); + + /* offset 16 */ + desc->txdw4 |= cpu_to_le32(HW_SSN); + desc->txdw4 |= cpu_to_le32(USERATE); + desc->txdw4 |= cpu_to_le32(DISDATAFB); + + if (pmp_priv->preamble) { + if (pmp_priv->rateidx <= MPT_RATE_54M) + desc->txdw4 |= cpu_to_le32(DATA_SHORT); /* CCK Short Preamble */ + } + if (pmp_priv->bandwidth == HT_CHANNEL_WIDTH_40) + desc->txdw4 |= cpu_to_le32(DATA_BW); + + /* offset 20 */ + desc->txdw5 |= cpu_to_le32(pmp_priv->rateidx & 0x0000001F); + + if (pmp_priv->preamble) { + if (pmp_priv->rateidx > MPT_RATE_54M) + desc->txdw5 |= cpu_to_le32(SGI); /* MCS Short Guard Interval */ + } + desc->txdw5 |= cpu_to_le32(RTY_LMT_EN); /* retry limit enable */ + desc->txdw5 |= cpu_to_le32(0x00180000); /* DATA/RTS Rate Fallback Limit */ + + /* 3 4. make wlan header, make_wlanhdr() */ + hdr = (struct rtw_ieee80211_hdr *)pkt_start; + SetFrameSubType(&hdr->frame_ctl, pattrib->subtype); + memcpy(hdr->addr1, pattrib->dst, ETH_ALEN); /* DA */ + memcpy(hdr->addr2, pattrib->src, ETH_ALEN); /* SA */ + memcpy(hdr->addr3, get_bssid(&padapter->mlmepriv), ETH_ALEN); /* RA, BSSID */ + + /* 3 5. make payload */ + ptr = pkt_start + pattrib->hdrlen; + + switch (pmp_priv->tx.payload) { + case 0: + payload = 0x00; + break; + case 1: + payload = 0x5a; + break; + case 2: + payload = 0xa5; + break; + case 3: + payload = 0xff; + break; + default: + payload = 0x00; + break; + } + + memset(ptr, payload, pkt_end - ptr); + + /* 3 6. start thread */ + pmp_priv->tx.PktTxThread = kthread_run(mp_xmit_packet_thread, pmp_priv, "RTW_MP_THREAD"); + if (IS_ERR(pmp_priv->tx.PktTxThread)) + DBG_88E("Create PktTx Thread Fail !!!!!\n"); +} + +void SetPacketRx(struct adapter *pAdapter, u8 bStartRx) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (bStartRx) { + /* Accept CRC error and destination address */ + pHalData->ReceiveConfig = AAP | APM | AM | AB | APP_ICV | + AMF | ADF | APP_FCS | HTC_LOC_CTRL | + APP_MIC | APP_PHYSTS; + + pHalData->ReceiveConfig |= (RCR_ACRC32 | RCR_AAP); + + rtw_write32(pAdapter, REG_RCR, pHalData->ReceiveConfig); + + /* Accept all data frames */ + rtw_write16(pAdapter, REG_RXFLTMAP2, 0xFFFF); + } else { + rtw_write32(pAdapter, REG_RCR, 0); + } +} + +void ResetPhyRxPktCount(struct adapter *pAdapter) +{ + u32 i, phyrx_set = 0; + + for (i = 0; i <= 0xF; i++) { + phyrx_set = 0; + phyrx_set |= _RXERR_RPT_SEL(i); /* select */ + phyrx_set |= RXERR_RPT_RST; /* set counter to zero */ + rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set); + } +} + +static u32 GetPhyRxPktCounts(struct adapter *pAdapter, u32 selbit) +{ + /* selection */ + u32 phyrx_set = 0, count = 0; + + phyrx_set = _RXERR_RPT_SEL(selbit & 0xF); + rtw_write32(pAdapter, REG_RXERR_RPT, phyrx_set); + + /* Read packet count */ + count = rtw_read32(pAdapter, REG_RXERR_RPT) & RXERR_COUNTER_MASK; + + return count; +} + +u32 GetPhyRxPktReceived(struct adapter *pAdapter) +{ + u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; + + OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_OK); + CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_OK); + HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_OK); + + return OFDM_cnt + CCK_cnt + HT_cnt; +} + +u32 GetPhyRxPktCRC32Error(struct adapter *pAdapter) +{ + u32 OFDM_cnt = 0, CCK_cnt = 0, HT_cnt = 0; + + OFDM_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_OFDM_MPDU_FAIL); + CCK_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_CCK_MPDU_FAIL); + HT_cnt = GetPhyRxPktCounts(pAdapter, RXERR_TYPE_HT_MPDU_FAIL); + + return OFDM_cnt + CCK_cnt + HT_cnt; +} + +/* reg 0x808[9:0]: FFT data x */ +/* reg 0x808[22]: 0 --> 1 to get 1 FFT data y */ +/* reg 0x8B4[15:0]: FFT data y report */ +static u32 rtw_GetPSDData(struct adapter *pAdapter, u32 point) +{ + int psd_val; + + psd_val = rtw_read32(pAdapter, 0x808); + psd_val &= 0xFFBFFC00; + psd_val |= point; + + rtw_write32(pAdapter, 0x808, psd_val); + rtw_mdelay_os(1); + psd_val |= 0x00400000; + + rtw_write32(pAdapter, 0x808, psd_val); + rtw_mdelay_os(1); + psd_val = rtw_read32(pAdapter, 0x8B4); + + psd_val &= 0x0000FFFF; + + return psd_val; +} + +/* + *pts start_point_min stop_point_max + * 128 64 64 + 128 = 192 + * 256 128 128 + 256 = 384 + * 512 256 256 + 512 = 768 + * 1024 512 512 + 1024 = 1536 + */ +u32 mp_query_psd(struct adapter *pAdapter, u8 *data) +{ + u32 i, psd_pts = 0, psd_start = 0, psd_stop = 0; + u32 psd_data = 0; + + if (!netif_running(pAdapter->pnetdev)) { + RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! interface not opened!\n")); + return 0; + } + + if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { + RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! not in MP mode!\n")); + return 0; + } + + if (strlen(data) == 0) { /* default value */ + psd_pts = 128; + psd_start = 64; + psd_stop = 128; + } else { + sscanf(data, "pts =%d, start =%d, stop =%d", &psd_pts, &psd_start, &psd_stop); + } + + memset(data, '\0', sizeof(*data)); + + i = psd_start; + while (i < psd_stop) { + if (i >= psd_pts) { + psd_data = rtw_GetPSDData(pAdapter, i-psd_pts); + } else { + psd_data = rtw_GetPSDData(pAdapter, i); + } + sprintf(data + strlen(data), "%x ", psd_data); + i++; + } + + rtw_msleep_os(100); + return strlen(data)+1; +} + +void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) +{ + int i, res; + struct adapter *padapter = pxmitpriv->adapter; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + + u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + if (padapter->registrypriv.mp_mode == 0) { + max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + num_xmit_extbuf = NR_XMIT_EXTBUFF; + } else { + max_xmit_extbuf_size = 6000; + num_xmit_extbuf = 8; + } + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + for (i = 0; i < num_xmit_extbuf; i++) { + rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); + + pxmitbuf++; + } + + if (pxmitpriv->pallocated_xmit_extbuf) + rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + + if (padapter->registrypriv.mp_mode == 0) { + max_xmit_extbuf_size = 6000; + num_xmit_extbuf = 8; + } else { + max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + num_xmit_extbuf = NR_XMIT_EXTBUFF; + } + + /* Init xmit extension buff */ + _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + + pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + + if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); + res = _FAIL; + goto exit; + } + + pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4); + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + + for (i = 0; i < num_xmit_extbuf; i++) { + INIT_LIST_HEAD(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->ext_tag = true; + + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); + if (res == _FAIL) { + res = _FAIL; + goto exit; + } + + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + pxmitbuf++; + } + + pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; + +exit: + ; +} + +void Hal_ProSetCrystalCap (struct adapter *pAdapter, u32 CrystalCapVal) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + CrystalCapVal = CrystalCapVal & 0x3F; + + // write 0x24[16:11] = 0x24[22:17] = CrystalCap + PHY_SetBBReg(pAdapter, REG_AFE_XTAL_CTRL, 0x7FF800, + (CrystalCapVal | (CrystalCapVal << 6))); +} diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c new file mode 100644 index 000000000000..87c3f29b16ef --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -0,0 +1,1352 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_MP_IOCTL_C_ + +#include +#include +#include + +/* include */ +#include + +/* rtl8188eu_oid_rtl_seg_81_85 section start **************** */ +int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->information_buf_len < sizeof(u8)) + return NDIS_STATUS_INVALID_LENGTH; + + if (poid_par_priv->type_of_oid == SET_OID) { + Adapter->registrypriv.wireless_mode = *(u8 *)poid_par_priv->information_buf; + } else if (poid_par_priv->type_of_oid == QUERY_OID) { + *(u8 *)poid_par_priv->information_buf = Adapter->registrypriv.wireless_mode; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + RT_TRACE(_module_mp_, _drv_info_, ("-query Wireless Mode=%d\n", Adapter->registrypriv.wireless_mode)); + } else { + status = NDIS_STATUS_NOT_ACCEPTED; + } + + return status; +} +/* rtl8188eu_oid_rtl_seg_81_87_80 section start **************** */ +int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct bb_reg_param *pbbreg; + u16 offset; + u32 value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_bb_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); + + offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */ + if (offset < BB_REG_BASE_ADDR) + offset |= BB_REG_BASE_ADDR; + + value = pbbreg->value; + + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n", + offset, value)); + + _irqlevel_changed_(&oldirql, LOWER); + write_bbreg(Adapter, offset, 0xFFFFFFFF, value); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct bb_reg_param *pbbreg; + u16 offset; + u32 value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_bb_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct bb_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct bb_reg_param *)(poid_par_priv->information_buf); + + offset = (u16)(pbbreg->offset) & 0xFFF; /* 0ffset :0x800~0xfff */ + if (offset < BB_REG_BASE_ADDR) + offset |= BB_REG_BASE_ADDR; + + _irqlevel_changed_(&oldirql, LOWER); + value = read_bbreg(Adapter, offset, 0xFFFFFFFF); + _irqlevel_changed_(&oldirql, RAISE); + + pbbreg->value = value; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_notice_, + ("-rtl8188eu_oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", + offset, value)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct rf_reg_param *pbbreg; + u8 path; + u8 offset; + u32 value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_rf_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); + + if (pbbreg->path >= RF_PATH_MAX) + return NDIS_STATUS_NOT_ACCEPTED; + if (pbbreg->offset > 0xFF) + return NDIS_STATUS_NOT_ACCEPTED; + if (pbbreg->value > 0xFFFFF) + return NDIS_STATUS_NOT_ACCEPTED; + + path = (u8)pbbreg->path; + offset = (u8)pbbreg->offset; + value = pbbreg->value; + + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", + path, offset, value)); + + _irqlevel_changed_(&oldirql, LOWER); + write_rfreg(Adapter, path, offset, value); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) +{ + struct rf_reg_param *pbbreg; + u8 path; + u8 offset; + u32 value; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + int status = NDIS_STATUS_SUCCESS; + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_rf_reg_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct rf_reg_param)) + return NDIS_STATUS_INVALID_LENGTH; + + pbbreg = (struct rf_reg_param *)(poid_par_priv->information_buf); + + if (pbbreg->path >= RF_PATH_MAX) + return NDIS_STATUS_NOT_ACCEPTED; + if (pbbreg->offset > 0xFF) + return NDIS_STATUS_NOT_ACCEPTED; + + path = (u8)pbbreg->path; + offset = (u8)pbbreg->offset; + + _irqlevel_changed_(&oldirql, LOWER); + value = read_rfreg(Adapter, path, offset); + _irqlevel_changed_(&oldirql, RAISE); + + pbbreg->value = value; + + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_notice_, + ("-rtl8188eu_oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", + path, offset, value)); + + return status; +} +/* rtl8188eu_oid_rtl_seg_81_87_00 section end**************** */ +/* */ + +/* rtl8188eu_oid_rtl_seg_81_80_00 section start **************** */ +/* */ +int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 ratevalue;/* 4 */ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, + ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */ + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue)); + if (ratevalue >= MPT_RATE_LAST) + return NDIS_STATUS_INVALID_DATA; + + Adapter->mppriv.rateidx = ratevalue; + + _irqlevel_changed_(&oldirql, LOWER); + SetDataRate(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 mode; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_start_test_hdl\n")); + + if (Adapter->registrypriv.mp_mode == 0) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + /* IQCalibrateBcut(Adapter); */ + + mode = *((u32 *)poid_par_priv->information_buf); + Adapter->mppriv.mode = mode;/* 1 for loopback */ + + if (mp_start_test(Adapter) == _FAIL) { + status = NDIS_STATUS_NOT_ACCEPTED; + goto exit; + } + +exit: + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+Set OID_RT_PRO_STOP_TEST\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + mp_stop_test(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n")); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 Channel; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n")); + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + if (poid_par_priv->type_of_oid == QUERY_OID) { + *((u32 *)poid_par_priv->information_buf) = Adapter->mppriv.channel; + return NDIS_STATUS_SUCCESS; + } + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + Channel = *((u32 *)poid_par_priv->information_buf); + RT_TRACE(_module_mp_, _drv_notice_, ("rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel)); + if (Channel > 14) + return NDIS_STATUS_NOT_ACCEPTED; + Adapter->mppriv.channel = Channel; + + _irqlevel_changed_(&oldirql, LOWER); + SetChannel(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) +{ + u16 bandwidth; + u16 channel_offset; + int status = NDIS_STATUS_SUCCESS; + struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_info_, + ("+rtl8188eu_oid_rt_set_bandwidth_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + bandwidth = *((u32 *)poid_par_priv->information_buf);/* 4 */ + channel_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + + if (bandwidth != HT_CHANNEL_WIDTH_40) + bandwidth = HT_CHANNEL_WIDTH_20; + padapter->mppriv.bandwidth = (u8)bandwidth; + padapter->mppriv.prime_channel_offset = (u8)channel_offset; + + _irqlevel_changed_(&oldirql, LOWER); + SetBandwidth(padapter); + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_notice_, + ("-rtl8188eu_oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", + bandwidth, channel_offset)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 antenna; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_antenna_bb_hdl\n")); + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + if (poid_par_priv->type_of_oid == SET_OID) { + antenna = *(u32 *)poid_par_priv->information_buf; + + Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); + Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n", + Adapter->mppriv.antenna_tx, Adapter->mppriv.antenna_rx)); + + _irqlevel_changed_(&oldirql, LOWER); + SetAntenna(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + } else { + antenna = (Adapter->mppriv.antenna_tx << 16)|Adapter->mppriv.antenna_rx; + *(u32 *)poid_par_priv->information_buf = antenna; + } + + return status; +} + +int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 tx_pwr_idx; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_set_tx_power_control_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + tx_pwr_idx = *((u32 *)poid_par_priv->information_buf); + if (tx_pwr_idx > MAX_TX_PWR_INDEX_N_MODE) + return NDIS_STATUS_NOT_ACCEPTED; + + Adapter->mppriv.txpoweridx = (u8)tx_pwr_idx; + + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n", + Adapter->mppriv.txpoweridx)); + + _irqlevel_changed_(&oldirql, LOWER); + SetTxPower(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} + +/* */ +/* rtl8188eu_oid_rtl_seg_81_80_20 section start **************** */ +/* */ +int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != QUERY_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + if (poid_par_priv->information_buf_len == sizeof(u32)) { + *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.tx_pktcount; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != QUERY_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl.\n")); + if (poid_par_priv->information_buf_len == sizeof(u32)) { + *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + RT_TRACE(_module_mp_, _drv_alert_, ("recv_ok:%d\n", Adapter->mppriv.rx_pktcount)); + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != QUERY_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl.\n")); + if (poid_par_priv->information_buf_len == sizeof(u32)) { + *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + RT_TRACE(_module_mp_, _drv_alert_, ("recv_err:%d\n", Adapter->mppriv.rx_crcerrpktcount)); + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + + return status; +} +/* */ + +int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl.\n")); + Adapter->mppriv.tx_pktcount = 0; + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + if (poid_par_priv->information_buf_len == sizeof(u32)) { + Adapter->mppriv.rx_pktcount = 0; + Adapter->mppriv.rx_crcerrpktcount = 0; + } else { + status = NDIS_STATUS_INVALID_LENGTH; + } + + return status; +} +/* */ +int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + _irqlevel_changed_(&oldirql, LOWER); + ResetPhyRxPktCount(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + *(u32 *)poid_par_priv->information_buf = GetPhyRxPktReceived(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len != sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + *(u32 *)poid_par_priv->information_buf = GetPhyRxPktCRC32Error(Adapter); + _irqlevel_changed_(&oldirql, RAISE); + + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_info_, + ("-rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", + *(u32 *)poid_par_priv->information_buf)); + + return status; +} +/* rtl8188eu_oid_rtl_seg_81_80_20 section end **************** */ +int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_continuous_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetContinuousTx(Adapter, (u8)bStartTest); + if (bStartTest) { + struct mp_priv *pmp_priv = &Adapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + DBG_88E("%s: pkt tx is running...\n", __func__); + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(Adapter); + } + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} + +int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetSingleCarrierTx(Adapter, (u8)bStartTest); + if (bStartTest) { + struct mp_priv *pmp_priv = &Adapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + DBG_88E("%s: pkt tx is running...\n", __func__); + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(Adapter); + } + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} + +int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetCarrierSuppressionTx(Adapter, (u8)bStartTest); + if (bStartTest) { + struct mp_priv *pmp_priv = &Adapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + DBG_88E("%s: pkt tx is running...\n", __func__); + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(Adapter); + } + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} + +int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv) +{ + u32 bStartTest; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + bStartTest = *((u32 *)poid_par_priv->information_buf); + + _irqlevel_changed_(&oldirql, LOWER); + SetSingleToneTx(Adapter, (u8)bStartTest); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} + +int rtl8188eu_oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv) +{ + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + int status = NDIS_STATUS_SUCCESS; + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + rtw_hal_set_hwreg(Adapter, HW_VAR_TRIGGER_GPIO_0, NULL); + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* rtl8188eu_oid_rtl_seg_81_80_00 section end **************** */ +/* */ +int rtl8188eu_oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) +{ + struct mp_rw_reg *RegRWStruct; + u32 offset, width; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_info_, + ("+rtl8188eu_oid_rt_pro_read_register_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; + offset = RegRWStruct->offset; + width = RegRWStruct->width; + + if (offset > 0xFFF) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + switch (width) { + case 1: + RegRWStruct->value = rtw_read8(Adapter, offset); + break; + case 2: + RegRWStruct->value = rtw_read16(Adapter, offset); + break; + default: + width = 4; + RegRWStruct->value = rtw_read32(Adapter, offset); + break; + } + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n", + offset, RegRWStruct->value)); + + _irqlevel_changed_(&oldirql, RAISE); + + *poid_par_priv->bytes_rw = width; + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) +{ + struct mp_rw_reg *RegRWStruct; + u32 offset, width, value; + int status = NDIS_STATUS_SUCCESS; + struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_info_, + ("+rtl8188eu_oid_rt_pro_write_register_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; + offset = RegRWStruct->offset; + width = RegRWStruct->width; + value = RegRWStruct->value; + + if (offset > 0xFFF) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + switch (RegRWStruct->width) { + case 1: + if (value > 0xFF) { + status = NDIS_STATUS_NOT_ACCEPTED; + break; + } + rtw_write8(padapter, offset, (u8)value); + break; + case 2: + if (value > 0xFFFF) { + status = NDIS_STATUS_NOT_ACCEPTED; + break; + } + rtw_write16(padapter, offset, (u16)value); + break; + case 4: + rtw_write32(padapter, offset, value); + break; + default: + status = NDIS_STATUS_NOT_ACCEPTED; + break; + } + + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_info_, + ("-rtl8188eu_oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", + offset, width, value)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +/* */ +int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +/* */ +int rtl8188eu_oid_rt_pro_write16_eeprom_hdl (struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv) +{ + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + int status = NDIS_STATUS_SUCCESS; + + RT_TRACE(_module_mp_, _drv_notice_, ("+OID_RT_PRO_SET_DATA_RATE_EX\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, LOWER); + + if (rtw_setdatarate_cmd(Adapter, poid_par_priv->information_buf) != _SUCCESS) + status = NDIS_STATUS_NOT_ACCEPTED; + + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + u8 thermal = 0; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_get_thermal_meter_hdl\n")); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + GetThermalMeter(Adapter, &thermal); + _irqlevel_changed_(&oldirql, RAISE); + + *(u32 *)poid_par_priv->information_buf = (u32)thermal; + *poid_par_priv->bytes_rw = sizeof(u32); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->information_buf_len < sizeof(u8)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + if (poid_par_priv->type_of_oid == SET_OID) { + u8 enable; + + enable = *(u8 *)poid_par_priv->information_buf; + RT_TRACE(_module_mp_, _drv_notice_, + ("+rtl8188eu_oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable)); + + SetPowerTracking(Adapter, enable); + } else { + GetPowerTracking(Adapter, (u8 *)poid_par_priv->information_buf); + } + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} +/* */ +int rtl8188eu_oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +/* rtl8188eu_oid_rtl_seg_87_12_00 section start **************** */ +int rtl8188eu_oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) +{ + return NDIS_STATUS_SUCCESS; +} +/* */ +int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) +{ + struct efuse_access_struct *pefuse; + u8 *data; + u16 addr = 0, cnts = 0, max_available_size = 0; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(struct efuse_access_struct)) + return NDIS_STATUS_INVALID_LENGTH; + + pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf; + addr = pefuse->start_addr; + cnts = pefuse->cnts; + data = pefuse->data; + + RT_TRACE(_module_mp_, _drv_notice_, + ("+rtl8188eu_oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n", + poid_par_priv->information_buf_len, addr, cnts)); + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + + if ((addr + cnts) > max_available_size) { + RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: parameter error!\n")); + return NDIS_STATUS_NOT_ACCEPTED; + } + + _irqlevel_changed_(&oldirql, LOWER); + if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) { + RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n")); + status = NDIS_STATUS_FAILURE; + } else { + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + } + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) +{ + struct efuse_access_struct *pefuse; + u8 *data; + u16 addr = 0, cnts = 0, max_available_size = 0; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + pefuse = (struct efuse_access_struct *)poid_par_priv->information_buf; + addr = pefuse->start_addr; + cnts = pefuse->cnts; + data = pefuse->data; + + RT_TRACE(_module_mp_, _drv_notice_, + ("+rtl8188eu_oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n", + poid_par_priv->information_buf_len, addr, cnts)); + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + + if ((addr + cnts) > max_available_size) { + RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_write_efuse_hdl: parameter error")); + return NDIS_STATUS_NOT_ACCEPTED; + } + + _irqlevel_changed_(&oldirql, LOWER); + if (rtw_efuse_access(Adapter, true, addr, cnts, data) == _FAIL) + status = NDIS_STATUS_FAILURE; + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) +{ + struct pgpkt *ppgpkt; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + *poid_par_priv->bytes_rw = 0; + + if (poid_par_priv->information_buf_len < sizeof(struct pgpkt *)) + return NDIS_STATUS_INVALID_LENGTH; + + ppgpkt = (struct pgpkt *)poid_par_priv->information_buf; + + _irqlevel_changed_(&oldirql, LOWER); + + if (poid_par_priv->type_of_oid == QUERY_OID) { + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\ + ppgpkt->offset)); + + Efuse_PowerSwitch(Adapter, false, true); + if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false) == true) + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + else + status = NDIS_STATUS_FAILURE; + Efuse_PowerSwitch(Adapter, false, false); + } else { + RT_TRACE(_module_mp_, _drv_notice_, + ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\ + ppgpkt->offset, ppgpkt->word_en)); + + Efuse_PowerSwitch(Adapter, true, true); + if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false) == true) + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + else + status = NDIS_STATUS_FAILURE; + Efuse_PowerSwitch(Adapter, true, false); + } + + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_info_, + ("-rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv) +{ + u16 size; + u8 ret; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + _irqlevel_changed_(&oldirql, LOWER); + ret = efuse_GetCurrentSize(Adapter, &size); + _irqlevel_changed_(&oldirql, RAISE); + if (ret == _SUCCESS) { + *(u32 *)poid_par_priv->information_buf = size; + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + } else { + status = NDIS_STATUS_FAILURE; + } + + return status; +} +/* */ +int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + + if (poid_par_priv->type_of_oid != QUERY_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u32)) + return NDIS_STATUS_INVALID_LENGTH; + + *(u32 *)poid_par_priv->information_buf = efuse_GetMaxSize(Adapter); + *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; + + RT_TRACE(_module_mp_, _drv_info_, + ("-rtl8188eu_oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", + *(int *)poid_par_priv->information_buf, status)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) +{ + int status; + + RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_efuse_hdl\n")); + + if (poid_par_priv->type_of_oid == QUERY_OID) + status = rtl8188eu_oid_rt_pro_read_efuse_hdl(poid_par_priv); + else + status = rtl8188eu_oid_rt_pro_write_efuse_hdl(poid_par_priv); + + RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); + + return status; +} +/* */ +int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) +{ + u8 *data; + int status = NDIS_STATUS_SUCCESS; + struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); + u16 maplen = 0; + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_efuse_map_hdl\n")); + + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&maplen, false); + + *poid_par_priv->bytes_rw = 0; + + if (poid_par_priv->information_buf_len < maplen) + return NDIS_STATUS_INVALID_LENGTH; + + data = (u8 *)poid_par_priv->information_buf; + + _irqlevel_changed_(&oldirql, LOWER); + + if (poid_par_priv->type_of_oid == QUERY_OID) { + RT_TRACE(_module_mp_, _drv_info_, + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ\n")); + + if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) { + *poid_par_priv->bytes_rw = maplen; + } else { + RT_TRACE(_module_mp_, _drv_err_, + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ fail\n")); + status = NDIS_STATUS_FAILURE; + } + } else { + /* SET_OID */ + RT_TRACE(_module_mp_, _drv_info_, + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE\n")); + + if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) { + *poid_par_priv->bytes_rw = maplen; + } else { + RT_TRACE(_module_mp_, _drv_err_, + ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE fail\n")); + status = NDIS_STATUS_FAILURE; + } + } + + _irqlevel_changed_(&oldirql, RAISE); + + RT_TRACE(_module_mp_, _drv_info_, + ("-rtl8188eu_oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); + + return status; +} + +int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + return status; +} + +int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) +{ + u8 rx_pkt_type; + int status = NDIS_STATUS_SUCCESS; + + RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_set_rx_packet_type_hdl\n")); + + if (poid_par_priv->type_of_oid != SET_OID) + return NDIS_STATUS_NOT_ACCEPTED; + + if (poid_par_priv->information_buf_len < sizeof(u8)) + return NDIS_STATUS_INVALID_LENGTH; + + rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */ + + RT_TRACE(_module_mp_, _drv_info_, ("rx_pkt_type: %x\n", rx_pkt_type)); + + return status; +} + +int rtl8188eu_oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} + +int rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) +{ + struct mp_xmit_parm *pparm; + struct adapter *padapter; + struct mp_priv *pmp_priv; + struct pkt_attrib *pattrib; + + RT_TRACE(_module_mp_, _drv_notice_, ("+%s\n", __func__)); + + pparm = (struct mp_xmit_parm *)poid_par_priv->information_buf; + padapter = (struct adapter *)poid_par_priv->adapter_context; + pmp_priv = &padapter->mppriv; + + if (poid_par_priv->type_of_oid == QUERY_OID) { + pparm->enable = !pmp_priv->tx.stop; + pparm->count = pmp_priv->tx.sended; + } else { + if (pparm->enable == 0) { + pmp_priv->tx.stop = 1; + } else if (pmp_priv->tx.stop == 1) { + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = pparm->count; + pmp_priv->tx.payload = pparm->payload_type; + pattrib = &pmp_priv->tx.attrib; + pattrib->pktlen = pparm->length; + memcpy(pattrib->dst, pparm->da, ETH_ALEN); + SetPacketTx(padapter); + } else { + return NDIS_STATUS_FAILURE; + } + } + + return NDIS_STATUS_SUCCESS; +} + +/* */ +int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) +{ + int status = NDIS_STATUS_SUCCESS; + + if (poid_par_priv->type_of_oid != SET_OID) { + status = NDIS_STATUS_NOT_ACCEPTED; + return status; + } + + RT_TRACE(_module_mp_, _drv_info_, + ("\n ===> Setrtl8188eu_oid_rt_set_power_down_hdl.\n")); + + _irqlevel_changed_(&oldirql, LOWER); + + /* CALL the power_down function */ + _irqlevel_changed_(&oldirql, RAISE); + + return status; +} +/* */ +int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv) +{ + return 0; +} diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c new file mode 100644 index 000000000000..2e21496fe71b --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -0,0 +1,2068 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_P2P_C_ + +#include +#include +#include + +#ifdef CONFIG_88EU_P2P + +static int rtw_p2p_is_channel_list_ok(u8 desired_ch, u8 *ch_list, u8 ch_cnt) +{ + int found = 0, i = 0; + + for (i = 0; i < ch_cnt; i++) { + if (ch_list[i] == desired_ch) { + found = 1; + break; + } + } + return found; +} + +static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + struct list_head *phead, *plist; + u32 len = 0; + u16 attr_len = 0; + u8 tmplen, *pdata_attr, *pstart, *pcur; + struct sta_info *psta = NULL; + struct adapter *padapter = pwdinfo->padapter; + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("%s\n", __func__); + + pdata_attr = rtw_zmalloc(MAX_P2P_IE_LEN); + + pstart = pdata_attr; + pcur = pdata_attr; + + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* look up sta asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + + plist = plist->next; + + if (psta->is_p2p_device) { + tmplen = 0; + + pcur++; + + /* P2P device address */ + memcpy(pcur, psta->dev_addr, ETH_ALEN); + pcur += ETH_ALEN; + + /* P2P interface address */ + memcpy(pcur, psta->hwaddr, ETH_ALEN); + pcur += ETH_ALEN; + + *pcur = psta->dev_cap; + pcur++; + + /* u16*)(pcur) = cpu_to_be16(psta->config_methods); */ + RTW_PUT_BE16(pcur, psta->config_methods); + pcur += 2; + + memcpy(pcur, psta->primary_dev_type, 8); + pcur += 8; + + *pcur = psta->num_of_secdev_type; + pcur++; + + memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8); + pcur += psta->num_of_secdev_type*8; + + if (psta->dev_name_len > 0) { + /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ + RTW_PUT_BE16(pcur, WPS_ATTR_DEVICE_NAME); + pcur += 2; + + /* u16*)(pcur) = cpu_to_be16(psta->dev_name_len); */ + RTW_PUT_BE16(pcur, psta->dev_name_len); + pcur += 2; + + memcpy(pcur, psta->dev_name, psta->dev_name_len); + pcur += psta->dev_name_len; + } + + tmplen = (u8)(pcur-pstart); + + *pstart = (tmplen-1); + + attr_len += tmplen; + + /* pstart += tmplen; */ + pstart = pcur; + } + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + + if (attr_len > 0) + len = rtw_set_p2p_attr_content(pbuf, P2P_ATTR_GROUP_INFO, attr_len, pdata_attr); + + kfree(pdata_attr); + return len; +} + +static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct adapter *padapter = pwdinfo->padapter; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_GO_DISC_REQUEST; + u8 dialogToken = 0; + + DBG_88E("[%s]\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* Build P2P action frame header */ + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* there is no IE in this P2P action frame */ + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct adapter *padapter = pwdinfo->padapter; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_DEVDISC_RESP; + u8 p2pie[8] = { 0x00 }; + u32 p2pielen = 0; + + DBG_88E("[%s]\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, pwdinfo->device_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->device_addr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* Build P2P public action frame header */ + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* Build P2P IE */ + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* P2P_ATTR_STATUS */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, u8 *frame_body, u16 config_method) +{ + struct adapter *padapter = pwdinfo->padapter; + unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; + u8 action = P2P_PUB_ACTION_ACTION; + u8 dialogToken = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_PROVISION_DISC_RESP; + u8 wpsie[100] = { 0x00 }; + u8 wpsielen = 0; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + wpsielen = 0; + /* WPS OUI */ + RTW_PUT_BE32(wpsie, WPSOUI); + wpsielen += 4; + + /* Config Method */ + /* Type: */ + RTW_PUT_BE16(wpsie + wpsielen, WPS_ATTR_CONF_METHOD); + wpsielen += 2; + + /* Length: */ + RTW_PUT_BE16(wpsie + wpsielen, 0x0002); + wpsielen += 2; + + /* Value: */ + RTW_PUT_BE16(wpsie + wpsielen, config_method); + wpsielen += 2; + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, wpsielen, (unsigned char *)wpsie, &pattrib->pktlen); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); + + return; +} + +static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) +{ + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + unsigned char *pframe; + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + struct adapter *padapter = pwdinfo->padapter; + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ + __be32 p2poui = cpu_to_be32(P2POUI); + u8 oui_subtype = P2P_PRESENCE_RESPONSE; + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u8 noa_attr_content[32] = { 0x00 }; + u32 p2pielen = 0; + + DBG_88E("[%s]\n", __func__); + + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + return; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(padapter, pattrib); + + memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); + + pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, da, ETH_ALEN); + memcpy(pwlanhdr->addr2, pwdinfo->interface_addr, ETH_ALEN); + memcpy(pwlanhdr->addr3, pwdinfo->interface_addr, ETH_ALEN); + + SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); + pmlmeext->mgnt_seq++; + SetFrameSubType(pframe, WIFI_ACTION); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* Build P2P action frame header */ + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + + /* Add P2P IE header */ + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Add Status attribute in P2P IE */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status); + + /* Add NoA attribute in P2P IE */ + noa_attr_content[0] = 0x1;/* index */ + noa_attr_content[1] = 0x0;/* CTWindow and OppPS Parameters */ + + /* todo: Notice of Absence Descriptor(s) */ + + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); + + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &(pattrib->pktlen)); + + pattrib->last_txcmdsz = pattrib->pktlen; + + dump_mgntframe(padapter, pmgntframe); +} + +u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u16 capability = 0; + u32 len = 0, p2pielen = 0; + __le16 le_tmp; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* According to the P2P Specification, the beacon frame should contain 3 P2P attributes */ + /* 1. P2P Capability */ + /* 2. P2P Device ID */ + /* 3. Notice of Absence (NOA) */ + + /* P2P Capability ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + /* Be able to participate in additional P2P Groups and */ + /* support the P2P Invitation Procedure */ + /* Group Capability Bitmap, 1 byte */ + capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY; + capability |= ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8); + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) + capability |= (P2P_GRPCAP_GROUP_FORMATION<<8); + + le_tmp = cpu_to_le16(capability); + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8 *)&le_tmp); + + /* P2P Device ID ATTR */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_DEVICE_ID, ETH_ALEN, pwdinfo->device_addr); + + /* Notice of Absence ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + return len; +} + +u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u32 len = 0, p2pielen = 0; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20100907 */ + /* According to the P2P Specification, the probe response frame should contain 5 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Extended Listen Timing */ + /* 3. Notice of Absence (NOA) (Only GO needs this) */ + /* 4. Device Info */ + /* 5. Group Info (Only GO need this) */ + + /* P2P Capability ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ + RTW_PUT_LE16(p2pie + p2pielen, 0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + p2pie[p2pielen] = (P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) + p2pie[p2pielen] |= P2P_GRPCAP_GROUP_FORMATION; + + p2pielen++; + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + } + + /* Extended Listen Timing ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_EX_LISTEN_TIMING; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0004); */ + RTW_PUT_LE16(p2pie + p2pielen, 0x0004); + p2pielen += 2; + + /* Value: */ + /* Availability Period */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ + RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); + p2pielen += 2; + + /* Availability Interval */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0xFFFF); */ + RTW_PUT_LE16(p2pie + p2pielen, 0xFFFF); + p2pielen += 2; + + /* Notice of Absence ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + + /* Device Info ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ + RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->supported_wps_cm); */ + RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->supported_wps_cm); + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ + RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ + RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + /* Group Info ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) + p2pielen += go_add_group_info_attr(pwdinfo, p2pie + p2pielen); + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + + return len; +} + +u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u32 len = 0, p2pielen = 0; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* Commented by Albert 20110301 */ + /* According to the P2P Specification, the provision discovery request frame should contain 3 P2P attributes */ + /* 1. P2P Capability */ + /* 2. Device Info */ + /* 3. Group ID (When joining an operating P2P Group) */ + + /* P2P Capability ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_CAPABILITY; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(0x0002); */ + RTW_PUT_LE16(p2pie + p2pielen, 0x0002); + p2pielen += 2; + + /* Value: */ + /* Device Capability Bitmap, 1 byte */ + p2pie[p2pielen++] = DMP_P2P_DEVCAP_SUPPORT; + + /* Group Capability Bitmap, 1 byte */ + if (pwdinfo->persistent_supported) + p2pie[p2pielen++] = P2P_GRPCAP_PERSISTENT_GROUP | DMP_P2P_GRPCAP_SUPPORT; + else + p2pie[p2pielen++] = DMP_P2P_GRPCAP_SUPPORT; + + /* Device Info ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_DEVICE_INFO; + + /* Length: */ + /* 21 -> P2P Device Address (6bytes) + Config Methods (2bytes) + Primary Device Type (8bytes) */ + /* + NumofSecondDevType (1byte) + WPS Device Name ID field (2bytes) + WPS Device Name Len field (2bytes) */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(21 + pwdinfo->device_name_len); */ + RTW_PUT_LE16(p2pie + p2pielen, 21 + pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + /* P2P Device Address */ + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); + p2pielen += ETH_ALEN; + + /* Config Method */ + /* This field should be big endian. Noted by P2P specification. */ + if (pwdinfo->ui_got_wps_info == P2P_GOT_WPSINFO_PBC) { + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_PBC); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_PBC); + } else { + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_CONFIG_METHOD_DISPLAY); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_CONFIG_METHOD_DISPLAY); + } + + p2pielen += 2; + + /* Primary Device Type */ + /* Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_CID_MULIT_MEDIA); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_CID_MULIT_MEDIA); + p2pielen += 2; + + /* OUI */ + /* u32*) (p2pie + p2pielen) = cpu_to_be32(WPSOUI); */ + RTW_PUT_BE32(p2pie + p2pielen, WPSOUI); + p2pielen += 4; + + /* Sub Category ID */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_PDT_SCID_MEDIA_SERVER); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_PDT_SCID_MEDIA_SERVER); + p2pielen += 2; + + /* Number of Secondary Device Types */ + p2pie[p2pielen++] = 0x00; /* No Secondary Device Type List */ + + /* Device Name */ + /* Type: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ + RTW_PUT_BE16(p2pie + p2pielen, WPS_ATTR_DEVICE_NAME); + p2pielen += 2; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_be16(pwdinfo->device_name_len); */ + RTW_PUT_BE16(p2pie + p2pielen, pwdinfo->device_name_len); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); + p2pielen += pwdinfo->device_name_len; + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + /* Added by Albert 2011/05/19 */ + /* In this case, the pdev_raddr is the device address of the group owner. */ + + /* P2P Group ID ATTR */ + /* Type: */ + p2pie[p2pielen++] = P2P_ATTR_GROUP_ID; + + /* Length: */ + /* u16*) (p2pie + p2pielen) = cpu_to_le16(ETH_ALEN + ussidlen); */ + RTW_PUT_LE16(p2pie + p2pielen, ETH_ALEN + ussidlen); + p2pielen += 2; + + /* Value: */ + memcpy(p2pie + p2pielen, pdev_raddr, ETH_ALEN); + p2pielen += ETH_ALEN; + + memcpy(p2pie + p2pielen, pssid, ussidlen); + p2pielen += ussidlen; + } + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + + return len; +} + +u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf, u8 status_code) +{ + u8 p2pie[MAX_P2P_IE_LEN] = { 0x00 }; + u32 len = 0, p2pielen = 0; + + /* P2P OUI */ + p2pielen = 0; + p2pie[p2pielen++] = 0x50; + p2pie[p2pielen++] = 0x6F; + p2pie[p2pielen++] = 0x9A; + p2pie[p2pielen++] = 0x09; /* WFA P2P v1.0 */ + + /* According to the P2P Specification, the Association response frame should contain 2 P2P attributes */ + /* 1. Status */ + /* 2. Extended Listen Timing (optional) */ + + /* Status ATTR */ + p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_STATUS, 1, &status_code); + + /* Extended Listen Timing ATTR */ + /* Type: */ + /* Length: */ + /* Value: */ + + pbuf = rtw_set_ie(pbuf, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &len); + + return len; +} + +u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) +{ + u32 len = 0; + + return len; +} + +u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *p; + u32 ret = false; + u8 *p2pie; + u32 p2pielen = 0; + int ssid_len = 0, rate_cnt = 0; + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SUPPORTEDRATES_IE_, (int *)&rate_cnt, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + if (rate_cnt <= 4) { + int i, g_rate = 0; + + for (i = 0; i < rate_cnt; i++) { + if (((*(p + 2 + i) & 0xff) != 0x02) && + ((*(p + 2 + i) & 0xff) != 0x04) && + ((*(p + 2 + i) & 0xff) != 0x0B) && + ((*(p + 2 + i) & 0xff) != 0x16)) + g_rate = 1; + } + + if (g_rate == 0) { + /* There is no OFDM rate included in SupportedRates IE of this probe request frame */ + /* The driver should response this probe request. */ + return ret; + } + } else { + /* rate_cnt > 4 means the SupportRates IE contains the OFDM rate because the count of CCK rates are 4. */ + /* We should proceed the following check for this probe request. */ + } + + /* Added comments by Albert 20100906 */ + /* There are several items we should check here. */ + /* 1. This probe request frame must contain the P2P IE. (Done) */ + /* 2. This probe request frame must contain the wildcard SSID. (Done) */ + /* 3. Wildcard BSSID. (Todo) */ + /* 4. Destination Address. (Done in mgt_dispatcher function) */ + /* 5. Requested Device Type in WSC IE. (Todo) */ + /* 6. Device ID attribute in P2P IE. (Todo) */ + + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ssid_len, + len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); + + ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_ , len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_ , NULL, &p2pielen); + if (p2pie) { + if ((p != NULL) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid , 7)) { + /* todo: */ + /* Check Requested Device Type attributes in WSC IE. */ + /* Check Device ID attribute in P2P IE */ + + ret = true; + } else if ((p != NULL) && (ssid_len == 0)) { + ret = true; + } + } else { + /* non -p2p device */ + } + } + + return ret; +} + +u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint len, struct sta_info *psta) +{ + u8 status_code = P2P_STATUS_SUCCESS; + u8 *pbuf, *pattr_content = NULL; + u32 attr_contentlen = 0; + u16 cap_attr = 0; + unsigned short frame_type, ie_offset = 0; + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u32 p2p_ielen = 0; + __be16 be_tmp; + __le16 le_tmp; + + if (!rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) + return P2P_STATUS_FAIL_REQUEST_UNABLE; + + frame_type = GetFrameSubType(pframe); + if (frame_type == WIFI_ASSOCREQ) + ie_offset = _ASOCREQ_IE_OFFSET_; + else /* WIFI_REASSOCREQ */ + ie_offset = _REASOCREQ_IE_OFFSET_; + + ies = pframe + WLAN_HDR_A3_LEN + ie_offset; + ies_len = len - WLAN_HDR_A3_LEN - ie_offset; + + p2p_ie = rtw_get_p2p_ie(ies , ies_len , NULL, &p2p_ielen); + + if (!p2p_ie) { + DBG_88E("[%s] P2P IE not Found!!\n", __func__); + status_code = P2P_STATUS_FAIL_INVALID_PARAM; + } else { + DBG_88E("[%s] P2P IE Found!!\n", __func__); + } + + while (p2p_ie) { + /* Check P2P Capability ATTR */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8 *)&le_tmp, (uint *)&attr_contentlen)) { + DBG_88E("[%s] Got P2P Capability Attr!!\n", __func__); + cap_attr = le16_to_cpu(le_tmp); + psta->dev_cap = cap_attr&0xff; + } + + /* Check Extended Listen Timing ATTR */ + + /* Check P2P Device Info ATTR */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) { + DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); + pattr_content = rtw_zmalloc(attr_contentlen); + pbuf = pattr_content; + if (pattr_content) { + u8 num_of_secdev_type; + u16 dev_name_len; + + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO , pattr_content, (uint *)&attr_contentlen); + + memcpy(psta->dev_addr, pattr_content, ETH_ALEN);/* P2P Device Address */ + + pattr_content += ETH_ALEN; + + memcpy(&be_tmp, pattr_content, 2);/* Config Methods */ + psta->config_methods = be16_to_cpu(be_tmp); + + pattr_content += 2; + + memcpy(psta->primary_dev_type, pattr_content, 8); + + pattr_content += 8; + + num_of_secdev_type = *pattr_content; + pattr_content += 1; + + if (num_of_secdev_type == 0) { + psta->num_of_secdev_type = 0; + } else { + u32 len; + + psta->num_of_secdev_type = num_of_secdev_type; + + len = (sizeof(psta->secdev_types_list) < (num_of_secdev_type*8)) ? + (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8); + + memcpy(psta->secdev_types_list, pattr_content, len); + + pattr_content += (num_of_secdev_type*8); + } + + psta->dev_name_len = 0; + if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(__be16 *)pattr_content)) { + dev_name_len = be16_to_cpu(*(__be16 *)(pattr_content+2)); + + psta->dev_name_len = (sizeof(psta->dev_name) < dev_name_len) ? sizeof(psta->dev_name) : dev_name_len; + + memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len); + } + kfree(pbuf); + } + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + + return status_code; +} + +u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *frame_body; + u8 status, dialogToken; + struct sta_info *psta = NULL; + struct adapter *padapter = pwdinfo->padapter; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *p2p_ie; + u32 p2p_ielen = 0; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[7]; + status = P2P_STATUS_FAIL_UNKNOWN_P2PGROUP; + + p2p_ie = rtw_get_p2p_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &p2p_ielen); + if (p2p_ie) { + u8 groupid[38] = { 0x00 }; + u8 dev_addr[ETH_ALEN] = { 0x00 }; + u32 attr_contentlen = 0; + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { + if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && + !memcmp(pwdinfo->p2p_group_ssid, groupid+ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_ID, dev_addr, &attr_contentlen)) { + struct list_head *phead, *plist; + + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* look up sta asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + + plist = plist->next; + + if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && + !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { + /* issue GO Discoverability Request */ + issue_group_disc_req(pwdinfo, psta->hwaddr); + status = P2P_STATUS_SUCCESS; + break; + } else { + status = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + } + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + } else { + status = P2P_STATUS_FAIL_INVALID_PARAM; + } + } else { + status = P2P_STATUS_FAIL_INVALID_PARAM; + } + } + } + + /* issue Device Discoverability Response */ + issue_p2p_devdisc_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken); + + return (status == P2P_STATUS_SUCCESS) ? true : false; +} + +u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + return true; +} + +u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *frame_body; + u8 *wpsie; + uint wps_ielen = 0, attr_contentlen = 0; + u16 uconfig_method = 0; + __be16 be_tmp; + + frame_body = (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + wpsie = rtw_get_wps_ie(frame_body + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen); + if (wpsie) { + if (rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_CONF_METHOD, (u8 *)&be_tmp, &attr_contentlen)) { + uconfig_method = be16_to_cpu(be_tmp); + switch (uconfig_method) { + case WPS_CM_DISPLYA: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); + break; + case WPS_CM_LABEL: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "lab", 3); + break; + case WPS_CM_PUSH_BUTTON: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); + break; + case WPS_CM_KEYPAD: + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); + break; + } + issue_p2p_provision_resp(pwdinfo, GetAddr2Ptr(pframe), frame_body, uconfig_method); + } + } + DBG_88E("[%s] config method = %s\n", __func__, pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); + return true; +} + +u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe) +{ + return true; +} + +static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_content, u8 ch_cnt, u8 *peer_ch_list) +{ + u8 i = 0, j = 0; + u8 temp = 0; + u8 ch_no = 0; + ch_content += 3; + ch_cnt -= 3; + + while (ch_cnt > 0) { + ch_content += 1; + ch_cnt -= 1; + temp = *ch_content; + for (i = 0 ; i < temp ; i++, j++) + peer_ch_list[j] = *(ch_content + 1 + i); + ch_content += (temp + 1); + ch_cnt -= (temp + 1); + ch_no += temp ; + } + + return ch_no; +} + +static u8 rtw_p2p_ch_inclusion(struct mlme_ext_priv *pmlmeext, u8 *peer_ch_list, u8 peer_ch_num, u8 *ch_list_inclusioned) +{ + int i = 0, j = 0, temp = 0; + u8 ch_no = 0; + + for (i = 0; i < peer_ch_num; i++) { + for (j = temp; j < pmlmeext->max_chan_nums; j++) { + if (*(peer_ch_list + i) == pmlmeext->channel_set[j].ChannelNum) { + ch_list_inclusioned[ch_no++] = *(peer_ch_list + i); + temp = j; + break; + } + } + } + + return ch_no; +} + +u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + struct adapter *padapter = pwdinfo->padapter; + u8 result = P2P_STATUS_SUCCESS; + u32 p2p_ielen = 0, wps_ielen = 0; + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u8 *wpsie; + u16 wps_devicepassword_id = 0x0000; + uint wps_devicepassword_id_len = 0; + __be16 be_tmp; + + wpsie = rtw_get_wps_ie(pframe + _PUBLIC_ACTION_IE_OFFSET_, len - _PUBLIC_ACTION_IE_OFFSET_, NULL, &wps_ielen); + if (wpsie) { + /* Commented by Kurt 20120113 */ + /* If some device wants to do p2p handshake without sending prov_disc_req */ + /* We have to get peer_req_cm from here. */ + if (!memcmp(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "000", 3)) { + rtw_get_wps_attr_content(wpsie, wps_ielen, WPS_ATTR_DEVICE_PWID, (u8 *)&be_tmp, &wps_devicepassword_id_len); + wps_devicepassword_id = be16_to_cpu(be_tmp); + + if (wps_devicepassword_id == WPS_DPID_USER_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "dis", 3); + else if (wps_devicepassword_id == WPS_DPID_REGISTRAR_SPEC) + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pad", 3); + else + memcpy(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, "pbc", 3); + } + } else { + DBG_88E("[%s] WPS IE not Found!!\n", __func__); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + return result; + } + + if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) { + result = P2P_STATUS_FAIL_INFO_UNAVAILABLE; + rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INFOR_NOREADY); + return result; + } + + ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; + ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + + if (!p2p_ie) { + DBG_88E("[%s] P2P IE not Found!!\n", __func__); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } + + while (p2p_ie) { + u8 attr_content = 0x00; + u32 attr_contentlen = 0; + u8 ch_content[50] = { 0x00 }; + uint ch_cnt = 0; + u8 peer_ch_list[50] = { 0x00 }; + u8 peer_ch_num = 0; + u8 ch_list_inclusioned[50] = { 0x00 }; + u8 ch_num_inclusioned = 0; + + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { + DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); + pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ + + if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) { + /* Try to match the tie breaker value */ + if (pwdinfo->intent == P2P_MAX_INTENT) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; + } else { + if (attr_content & 0x01) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + else + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } + } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Store the group id information. */ + memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + } + } + + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) { + if (attr_contentlen != ETH_ALEN) + memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); + } + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, ch_content, &ch_cnt)) { + peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, ch_content, ch_cnt, peer_ch_list); + ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); + + if (ch_num_inclusioned == 0) { + DBG_88E("[%s] No common channel in channel list!\n", __func__); + result = P2P_STATUS_FAIL_NO_COMMON_CH; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + break; + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, + ch_list_inclusioned, ch_num_inclusioned)) { + u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; + attr_contentlen = 0; + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) + peer_operating_ch = operatingch_info[4]; + + if (rtw_p2p_is_channel_list_ok(peer_operating_ch, + ch_list_inclusioned, ch_num_inclusioned)) { + /** + * Change our operating channel as peer's for compatibility. + */ + pwdinfo->operating_channel = peer_operating_ch; + DBG_88E("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); + } else { + /* Take first channel of ch_list_inclusioned as operating channel */ + pwdinfo->operating_channel = ch_list_inclusioned[0]; + DBG_88E("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); + } + } + } + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + return result; +} + +u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + struct adapter *padapter = pwdinfo->padapter; + u8 result = P2P_STATUS_SUCCESS; + u32 p2p_ielen, wps_ielen; + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + + ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; + ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; + + /* Be able to know which one is the P2P GO and which one is P2P client. */ + + if (rtw_get_wps_ie(ies, ies_len, NULL, &wps_ielen)) { + } else { + DBG_88E("[%s] WPS IE not Found!!\n", __func__); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + if (!p2p_ie) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + result = P2P_STATUS_FAIL_INCOMPATIBLE_PARAM; + } else { + u8 attr_content = 0x00; + u32 attr_contentlen = 0; + u8 operatingch_info[5] = { 0x00 }; + u8 groupid[38]; + u8 peer_ch_list[50] = { 0x00 }; + u8 peer_ch_num = 0; + u8 ch_list_inclusioned[50] = { 0x00 }; + u8 ch_num_inclusioned = 0; + + while (p2p_ie) { /* Found the P2P IE. */ + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); + if (attr_contentlen == 1) { + DBG_88E("[%s] Status = %d\n", __func__, attr_content); + if (attr_content == P2P_STATUS_SUCCESS) { + /* Do nothing. */ + } else { + if (P2P_STATUS_FAIL_INFO_UNAVAILABLE == attr_content) { + rtw_p2p_set_state(pwdinfo, P2P_STATE_RX_INFOR_NOREADY); + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + result = attr_content; + break; + } + } + + /* Try to get the peer's interface address */ + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_INTENTED_IF_ADDR, pwdinfo->p2p_peer_interface_addr, &attr_contentlen)) { + if (attr_contentlen != ETH_ALEN) + memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); + } + + /* Try to get the peer's intent and tie breaker value. */ + attr_content = 0x00; + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { + DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); + pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ + + if (pwdinfo->intent == (pwdinfo->peer_intent >> 1)) { + /* Try to match the tie breaker value */ + if (pwdinfo->intent == P2P_MAX_INTENT) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + result = P2P_STATUS_FAIL_BOTH_GOINTENT_15; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + if (attr_content & 0x01) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + else + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } + } else if (pwdinfo->intent > (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else { + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + /* Store the group id information. */ + memcpy(pwdinfo->groupid_info.go_device_addr, pwdinfo->device_addr, ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, pwdinfo->nego_ssid, pwdinfo->nego_ssidlen); + } + } + + /* Try to get the operation channel information */ + + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { + DBG_88E("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); + pwdinfo->peer_operating_ch = operatingch_info[4]; + } + + /* Try to get the channel list information */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CH_LIST, pwdinfo->channel_list_attr, &pwdinfo->channel_list_attr_len)) { + DBG_88E("[%s] channel list attribute found, len = %d\n", __func__, pwdinfo->channel_list_attr_len); + + peer_ch_num = rtw_p2p_get_peer_ch_list(pwdinfo, pwdinfo->channel_list_attr, pwdinfo->channel_list_attr_len, peer_ch_list); + ch_num_inclusioned = rtw_p2p_ch_inclusion(&padapter->mlmeextpriv, peer_ch_list, peer_ch_num, ch_list_inclusioned); + + if (ch_num_inclusioned == 0) { + DBG_88E("[%s] No common channel in channel list!\n", __func__); + result = P2P_STATUS_FAIL_NO_COMMON_CH; + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + break; + } + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + if (!rtw_p2p_is_channel_list_ok(pwdinfo->operating_channel, + ch_list_inclusioned, ch_num_inclusioned)) { + u8 operatingch_info[5] = { 0x00 }, peer_operating_ch = 0; + attr_contentlen = 0; + + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) + peer_operating_ch = operatingch_info[4]; + + if (rtw_p2p_is_channel_list_ok(peer_operating_ch, + ch_list_inclusioned, ch_num_inclusioned)) { + /** + * Change our operating channel as peer's for compatibility. + */ + pwdinfo->operating_channel = peer_operating_ch; + DBG_88E("[%s] Change op ch to %02x as peer's\n", __func__, pwdinfo->operating_channel); + } else { + /* Take first channel of ch_list_inclusioned as operating channel */ + pwdinfo->operating_channel = ch_list_inclusioned[0]; + DBG_88E("[%s] Change op ch to %02x\n", __func__, pwdinfo->operating_channel); + } + } + } + } else { + DBG_88E("[%s] channel list attribute not found!\n", __func__); + } + + /* Try to get the group id information if peer is GO */ + attr_contentlen = 0; + memset(groupid, 0x00, 38); + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { + memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + } + return result; +} + +u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u32 p2p_ielen = 0; + u8 result = P2P_STATUS_SUCCESS; + ies = pframe + _PUBLIC_ACTION_IE_OFFSET_; + ies_len = len - _PUBLIC_ACTION_IE_OFFSET_; + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + while (p2p_ie) { /* Found the P2P IE. */ + u8 attr_content = 0x00, operatingch_info[5] = { 0x00 }; + u8 groupid[38] = { 0x00 }; + u32 attr_contentlen = 0; + + pwdinfo->negotiation_dialog_token = 1; + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_STATUS, &attr_content, &attr_contentlen); + if (attr_contentlen == 1) { + DBG_88E("[%s] Status = %d\n", __func__, attr_content); + result = attr_content; + + if (attr_content == P2P_STATUS_SUCCESS) { + u8 bcancelled = 0; + + _cancel_timer(&pwdinfo->restore_p2p_state_timer, &bcancelled); + + /* Commented by Albert 20100911 */ + /* Todo: Need to handle the case which both Intents are the same. */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + if ((pwdinfo->intent) > (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } else if ((pwdinfo->intent) < (pwdinfo->peer_intent >> 1)) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + } else { + /* Have to compare the Tie Breaker */ + if (pwdinfo->peer_intent & 0x01) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + else + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + } + } else { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_FAIL); + break; + } + } + + /* Try to get the group id information */ + attr_contentlen = 0; + memset(groupid, 0x00, 38); + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { + DBG_88E("[%s] Ssid = %s, ssidlen = %zu\n", __func__, &groupid[ETH_ALEN], strlen(&groupid[ETH_ALEN])); + memcpy(pwdinfo->groupid_info.go_device_addr, &groupid[0], ETH_ALEN); + memcpy(pwdinfo->groupid_info.ssid, &groupid[6], attr_contentlen - ETH_ALEN); + } + + attr_contentlen = 0; + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_OPERATING_CH, operatingch_info, &attr_contentlen)) { + DBG_88E("[%s] Peer's operating channel = %d\n", __func__, operatingch_info[4]); + pwdinfo->peer_operating_ch = operatingch_info[4]; + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + return result; +} + +u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint len) +{ + u8 *frame_body; + u8 dialogToken = 0; + u8 status = P2P_STATUS_SUCCESS; + + frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); + + dialogToken = frame_body[6]; + + /* todo: check NoA attribute */ + + issue_p2p_presence_resp(pwdinfo, GetAddr2Ptr(pframe), status, dialogToken); + + return true; +} + +static void find_phase_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ndis_802_11_ssid ssid; + + memset((unsigned char *)&ssid, 0, sizeof(struct ndis_802_11_ssid)); + memcpy(ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); + ssid.SsidLength = P2P_WILDCARD_SSID_LEN; + + rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); + + spin_lock_bh(&pmlmepriv->lock); + spin_unlock_bh(&pmlmepriv->lock); + +} + +void p2p_concurrent_handler(struct adapter *padapter); + +static void restore_p2p_state_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING) || rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_FAIL)) + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, rtw_p2p_pre_state(pwdinfo)); + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE)) { + /* In the P2P client mode, the driver should not switch back to its listen channel */ + /* because this P2P client should stay at the operating channel of P2P GO. */ + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + } + +} + +static void pre_tx_invitereq_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 val8 = 1; + + set_channel_bwmode(padapter, pwdinfo->invitereq_info.peer_ch, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + issue_probereq_p2p(padapter, NULL); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + +} + +static void pre_tx_provdisc_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 val8 = 1; + + set_channel_bwmode(padapter, pwdinfo->tx_prov_disc_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + issue_probereq_p2p(padapter, NULL); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + +} + +static void pre_tx_negoreq_handler(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + u8 val8 = 1; + + set_channel_bwmode(padapter, pwdinfo->nego_req_info.peer_channel_num[0], HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); + issue_probereq_p2p(padapter, NULL); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + +} + +void p2p_protocol_wk_hdl(struct adapter *padapter, int intCmdType) +{ + + switch (intCmdType) { + case P2P_FIND_PHASE_WK: + find_phase_handler(padapter); + break; + case P2P_RESTORE_STATE_WK: + restore_p2p_state_handler(padapter); + break; + case P2P_PRE_TX_PROVDISC_PROCESS_WK: + pre_tx_provdisc_handler(padapter); + break; + case P2P_PRE_TX_INVITEREQ_PROCESS_WK: + pre_tx_invitereq_handler(padapter); + break; + case P2P_PRE_TX_NEGOREQ_PROCESS_WK: + pre_tx_negoreq_handler(padapter); + break; + } + +} + +void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) +{ + u8 *ies; + u32 ies_len; + u8 *p2p_ie; + u32 p2p_ielen = 0; + u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ + u32 attr_contentlen = 0; + + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 find_p2p = false, find_p2p_ps = false; + u8 noa_offset, noa_num, noa_index; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + if (IELength <= _BEACON_IE_OFFSET_) + return; + + ies = IEs + _BEACON_IE_OFFSET_; + ies_len = IELength - _BEACON_IE_OFFSET_; + + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); + + while (p2p_ie) { + find_p2p = true; + /* Get Notice of Absence IE. */ + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_NOA, noa_attr, &attr_contentlen)) { + find_p2p_ps = true; + noa_index = noa_attr[0]; + + if ((pwdinfo->p2p_ps_mode == P2P_PS_NONE) || + (noa_index != pwdinfo->noa_index)) { /* if index change, driver should reconfigure related setting. */ + pwdinfo->noa_index = noa_index; + pwdinfo->opp_ps = noa_attr[1] >> 7; + pwdinfo->ctwindow = noa_attr[1] & 0x7F; + + noa_offset = 2; + noa_num = 0; + /* NoA length should be n*(13) + 2 */ + if (attr_contentlen > 2) { + while (noa_offset < attr_contentlen) { + /* memcpy(&wifidirect_info->noa_count[noa_num], &noa_attr[noa_offset], 1); */ + pwdinfo->noa_count[noa_num] = noa_attr[noa_offset]; + noa_offset += 1; + + memcpy(&pwdinfo->noa_duration[noa_num], &noa_attr[noa_offset], 4); + noa_offset += 4; + + memcpy(&pwdinfo->noa_interval[noa_num], &noa_attr[noa_offset], 4); + noa_offset += 4; + + memcpy(&pwdinfo->noa_start_time[noa_num], &noa_attr[noa_offset], 4); + noa_offset += 4; + + noa_num++; + } + } + pwdinfo->noa_num = noa_num; + + if (pwdinfo->opp_ps == 1) { + pwdinfo->p2p_ps_mode = P2P_PS_CTWINDOW; + /* driver should wait LPS for entering CTWindow */ + if (padapter->pwrctrlpriv.bFwCurrentInPSMode) + p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1); + } else if (pwdinfo->noa_num > 0) { + pwdinfo->p2p_ps_mode = P2P_PS_NOA; + p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 1); + } else if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); + } + } + + break; /* find target, just break. */ + } + + /* Get the next P2P IE */ + p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + } + + if (find_p2p) { + if ((pwdinfo->p2p_ps_mode > P2P_PS_NONE) && !find_p2p_ps) + p2p_ps_wk_cmd(padapter, P2P_PS_DISABLE, 1); + } + +} + +void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + /* Pre action for p2p state */ + switch (p2p_ps_state) { + case P2P_PS_DISABLE: + pwdinfo->p2p_ps_state = p2p_ps_state; + + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + + pwdinfo->noa_index = 0; + pwdinfo->ctwindow = 0; + pwdinfo->opp_ps = 0; + pwdinfo->noa_num = 0; + pwdinfo->p2p_ps_mode = P2P_PS_NONE; + if (padapter->pwrctrlpriv.bFwCurrentInPSMode) { + if (pwrpriv->smart_ps == 0) { + pwrpriv->smart_ps = 2; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&(padapter->pwrctrlpriv.pwr_mode))); + } + } + break; + case P2P_PS_ENABLE: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + pwdinfo->p2p_ps_state = p2p_ps_state; + + if (pwdinfo->ctwindow > 0) { + if (pwrpriv->smart_ps != 0) { + pwrpriv->smart_ps = 0; + DBG_88E("%s(): Enter CTW, change SmartPS\n", __func__); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&(padapter->pwrctrlpriv.pwr_mode))); + } + } + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + } + break; + case P2P_PS_SCAN: + case P2P_PS_SCAN_DONE: + case P2P_PS_ALLSTASLEEP: + if (pwdinfo->p2p_ps_mode > P2P_PS_NONE) { + pwdinfo->p2p_ps_state = p2p_ps_state; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); + } + break; + default: + break; + } + +} + +u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) +{ + struct cmd_obj *ph2c; + struct drvextra_cmd_parm *pdrvextra_cmd_parm; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return res; + + if (enqueue) { + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + if (pdrvextra_cmd_parm == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + pdrvextra_cmd_parm->ec_id = P2P_PS_WK_CID; + pdrvextra_cmd_parm->type_size = p2p_ps_state; + pdrvextra_cmd_parm->pbuf = NULL; + + init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, GEN_CMD_CODE(_Set_Drv_Extra)); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + } else { + p2p_ps_wk_hdl(padapter, p2p_ps_state); + } + +exit: + + return res; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void reset_ch_sitesurvey_timer_process(struct timer_list *t) +#else +static void reset_ch_sitesurvey_timer_process (void *FunctionContext) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer); +#else + struct adapter *adapter = (struct adapter *)FunctionContext; +#endif + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + DBG_88E("[%s] In\n", __func__); + /* Reset the operation channel information */ + pwdinfo->rx_invitereq_info.operation_ch[0] = 0; + pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void reset_ch_sitesurvey_timer_process2 (struct timer_list *t) +#else +static void reset_ch_sitesurvey_timer_process2 (void *FunctionContext) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer); +#else + struct adapter *adapter = (struct adapter *)FunctionContext; +#endif + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + DBG_88E("[%s] In\n", __func__); + /* Reset the operation channel information */ + pwdinfo->p2p_info.operation_ch[0] = 0; + pwdinfo->p2p_info.scan_op_ch_only = 0; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void restore_p2p_state_timer_process(struct timer_list *t) +#else +static void restore_p2p_state_timer_process (void *FunctionContext) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = from_timer(adapter, t, wdinfo.restore_p2p_state_timer); +#else + struct adapter *adapter = (struct adapter *)FunctionContext; +#endif + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + p2p_protocol_wk_cmd(adapter, P2P_RESTORE_STATE_WK); +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void pre_tx_scan_timer_process(struct timer_list *t) +#else +static void pre_tx_scan_timer_process(void *FunctionContext) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = from_timer(adapter, t, wdinfo.pre_tx_scan_timer); +#else + struct adapter *adapter = (struct adapter *)FunctionContext; +#endif + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + spin_lock_bh(&pmlmepriv->lock); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) { + if (pwdinfo->tx_prov_disc_info.benable) { /* the provision discovery request frame is trigger to send or not */ + p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_PROVDISC_PROCESS_WK); + /* issue_probereq_p2p(adapter, NULL); */ + /* _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); */ + } + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_ING)) { + if (pwdinfo->nego_req_info.benable) + p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_NEGOREQ_PROCESS_WK); + } else if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_INVITE_REQ)) { + if (pwdinfo->invitereq_info.benable) + p2p_protocol_wk_cmd(adapter, P2P_PRE_TX_INVITEREQ_PROCESS_WK); + } else { + DBG_88E("[%s] p2p_state is %d, ignore!!\n", __func__, rtw_p2p_state(pwdinfo)); + } + + spin_unlock_bh(&pmlmepriv->lock); +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void find_phase_timer_process(struct timer_list *t) +#else +static void find_phase_timer_process(void *FunctionContext) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = from_timer(adapter, t, wdinfo.find_phase_timer); +#else + struct adapter *adapter = (struct adapter *)FunctionContext; +#endif + struct wifidirect_info *pwdinfo = &adapter->wdinfo; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; + + adapter->wdinfo.find_phase_state_exchange_cnt++; + + p2p_protocol_wk_cmd(adapter, P2P_FIND_PHASE_WK); +} + +void reset_global_wifidirect_info(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo; + + pwdinfo = &padapter->wdinfo; + pwdinfo->persistent_supported = 0; + pwdinfo->session_available = true; + pwdinfo->wfd_tdls_enable = 0; + pwdinfo->wfd_tdls_weaksec = 0; +} + +void rtw_init_wifidirect_timers(struct adapter *padapter) +{ + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + timer_setup(&pwdinfo->find_phase_timer, find_phase_timer_process, 0); + timer_setup(&pwdinfo->restore_p2p_state_timer, restore_p2p_state_timer_process, 0); + timer_setup(&pwdinfo->pre_tx_scan_timer, pre_tx_scan_timer_process, 0); + timer_setup(&pwdinfo->reset_ch_sitesurvey, reset_ch_sitesurvey_timer_process, 0); + timer_setup(&pwdinfo->reset_ch_sitesurvey2, reset_ch_sitesurvey_timer_process2, 0); +#else + _init_timer(&pwdinfo->find_phase_timer, padapter->pnetdev, find_phase_timer_process, padapter); + _init_timer(&pwdinfo->restore_p2p_state_timer, padapter->pnetdev, restore_p2p_state_timer_process, padapter); + _init_timer(&pwdinfo->pre_tx_scan_timer, padapter->pnetdev, pre_tx_scan_timer_process, padapter); + _init_timer(&pwdinfo->reset_ch_sitesurvey, padapter->pnetdev, reset_ch_sitesurvey_timer_process, padapter); + _init_timer(&pwdinfo->reset_ch_sitesurvey2, padapter->pnetdev, reset_ch_sitesurvey_timer_process2, padapter); +#endif +} + +void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, u8 *iface_addr) +{ +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + /*init device&interface address */ + if (dev_addr) + memcpy(pwdinfo->device_addr, dev_addr, ETH_ALEN); + if (iface_addr) + memcpy(pwdinfo->interface_addr, iface_addr, ETH_ALEN); +#endif +} + +void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) +{ + struct wifidirect_info *pwdinfo; + + pwdinfo = &padapter->wdinfo; + pwdinfo->padapter = padapter; + + /* 1, 6, 11 are the social channel defined in the WiFi Direct specification. */ + pwdinfo->social_chan[0] = 1; + pwdinfo->social_chan[1] = 6; + pwdinfo->social_chan[2] = 11; + pwdinfo->social_chan[3] = 0; /* channel 0 for scanning ending in site survey function. */ + + /* Use the channel 11 as the listen channel */ + pwdinfo->listen_channel = 11; + + if (role == P2P_ROLE_DEVICE) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DEVICE); + rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); + pwdinfo->intent = 1; + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_LISTEN); + } else if (role == P2P_ROLE_CLIENT) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + pwdinfo->intent = 1; + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + } else if (role == P2P_ROLE_GO) { + rtw_p2p_set_role(pwdinfo, P2P_ROLE_GO); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_OK); + pwdinfo->intent = 15; + rtw_p2p_set_pre_state(pwdinfo, P2P_STATE_GONEGO_OK); + } + +/* Use the OFDM rate in the P2P probe response frame. (6(B), 9(B), 12, 18, 24, 36, 48, 54) */ + pwdinfo->support_rate[0] = 0x8c; /* 6(B) */ + pwdinfo->support_rate[1] = 0x92; /* 9(B) */ + pwdinfo->support_rate[2] = 0x18; /* 12 */ + pwdinfo->support_rate[3] = 0x24; /* 18 */ + pwdinfo->support_rate[4] = 0x30; /* 24 */ + pwdinfo->support_rate[5] = 0x48; /* 36 */ + pwdinfo->support_rate[6] = 0x60; /* 48 */ + pwdinfo->support_rate[7] = 0x6c; /* 54 */ + + memcpy(pwdinfo->p2p_wildcard_ssid, "DIRECT-", 7); + + memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); + pwdinfo->device_name_len = 0; + + memset(&pwdinfo->invitereq_info, 0x00, sizeof(struct tx_invite_req_info)); + pwdinfo->invitereq_info.token = 3; /* Token used for P2P invitation request frame. */ + + memset(&pwdinfo->inviteresp_info, 0x00, sizeof(struct tx_invite_resp_info)); + pwdinfo->inviteresp_info.token = 0; + + pwdinfo->profileindex = 0; + memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); + + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); + + pwdinfo->listen_dwell = (u8) ((jiffies % 3) + 1); + + memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE; + + memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); + + pwdinfo->device_password_id_for_nego = WPS_DPID_PBC; + pwdinfo->negotiation_dialog_token = 1; + + memset(pwdinfo->nego_ssid, 0x00, WLAN_SSID_MAXLEN); + pwdinfo->nego_ssidlen = 0; + + pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; + pwdinfo->supported_wps_cm = WPS_CONFIG_METHOD_DISPLAY | WPS_CONFIG_METHOD_PBC | WPS_CONFIG_METHOD_KEYPAD; + pwdinfo->channel_list_attr_len = 0; + memset(pwdinfo->channel_list_attr, 0x00, 100); + + memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, 0x00, 4); + memset(pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req, '0', 3); + memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); + pwdinfo->wfd_tdls_enable = 0; + memset(pwdinfo->p2p_peer_interface_addr, 0x00, ETH_ALEN); + memset(pwdinfo->p2p_peer_device_addr, 0x00, ETH_ALEN); + + pwdinfo->rx_invitereq_info.operation_ch[0] = 0; + pwdinfo->rx_invitereq_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ + pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; + pwdinfo->p2p_info.operation_ch[0] = 0; + pwdinfo->p2p_info.operation_ch[1] = 0; /* Used to indicate the scan end in site survey function */ + pwdinfo->p2p_info.scan_op_ch_only = 0; +} + +int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) +{ + int ret = _SUCCESS; + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) { + /* leave IPS/Autosuspend */ + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = _FAIL; + goto exit; + } + + /* Added by Albert 2011/03/22 */ + /* In the P2P mode, the driver should not support the b mode. */ + /* So, the Tx packet shouldn't use the CCK rate */ + update_tx_basic_rate(padapter, WIRELESS_11AGN); + + /* Enable P2P function */ + init_wifidirect_info(padapter, role); + + rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, true); + } else if (role == P2P_ROLE_DISABLE) { + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = _FAIL; + goto exit; + } + + /* Disable P2P function */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + _cancel_timer_ex(&pwdinfo->find_phase_timer); + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); + _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +#else + reset_ch_sitesurvey_timer_process(padapter); + reset_ch_sitesurvey_timer_process2(padapter); +#endif + rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); + rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE); + memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info)); + } + + rtw_hal_set_odm_var(padapter, HAL_ODM_P2P_STATE, NULL, false); + + /* Restore to initial setting. */ + update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); + } + +exit: + return ret; +} + +#else +u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) +{ + return _FAIL; +} + +void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) +{ +} + +#endif /* CONFIG_88EU_P2P */ diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c new file mode 100644 index 000000000000..50e8b5e6aed8 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -0,0 +1,655 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_PWRCTRL_C_ + +#include +#include +#include +#include + +void ips_enter(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct xmit_priv *pxmit_priv = &padapter->xmitpriv; + + if (padapter->registrypriv.mp_mode == 1) + return; + + if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || + pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) { + DBG_88E_LEVEL(_drv_info_, "There are some pkts to transmit\n"); + DBG_88E_LEVEL(_drv_info_, "free_xmitbuf_cnt: %d, free_xmit_extbuf_cnt: %d\n", + pxmit_priv->free_xmitbuf_cnt, pxmit_priv->free_xmit_extbuf_cnt); + return; + } + + _enter_pwrlock(&pwrpriv->lock); + + pwrpriv->bips_processing = true; + + /* syn ips_mode with request */ + pwrpriv->ips_mode = pwrpriv->ips_mode_req; + + pwrpriv->ips_enter_cnts++; + DBG_88E("==>ips_enter cnts:%d\n", pwrpriv->ips_enter_cnts); + if (rf_off == pwrpriv->change_rfpwrstate) { + pwrpriv->bpower_saving = true; + DBG_88E_LEVEL(_drv_info_, "nolinked power save enter\n"); + + if (pwrpriv->ips_mode == IPS_LEVEL_2) + pwrpriv->bkeepfwalive = true; + + rtw_ips_pwr_down(padapter); + pwrpriv->rf_pwrstate = rf_off; + } + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); +} + +int ips_leave(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int result = _SUCCESS; + int keyid; + + _enter_pwrlock(&pwrpriv->lock); + + if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { + pwrpriv->bips_processing = true; + pwrpriv->change_rfpwrstate = rf_on; + pwrpriv->ips_leave_cnts++; + DBG_88E("==>ips_leave cnts:%d\n", pwrpriv->ips_leave_cnts); + + result = rtw_ips_pwr_up(padapter); + if (result == _SUCCESS) { + pwrpriv->rf_pwrstate = rf_on; + } + DBG_88E_LEVEL(_drv_info_, "nolinked power save leave\n"); + + if ((_WEP40_ == psecuritypriv->dot11PrivacyAlgrthm) || (_WEP104_ == psecuritypriv->dot11PrivacyAlgrthm)) { + DBG_88E("==>%s, channel(%d), processing(%x)\n", __func__, padapter->mlmeextpriv.cur_channel, pwrpriv->bips_processing); + set_channel_bwmode(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + for (keyid = 0; keyid < 4; keyid++) { + if (pmlmepriv->key_mask & BIT(keyid)) { + if (keyid == psecuritypriv->dot11PrivacyKeyIndex) + result = rtw_set_key(padapter, psecuritypriv, keyid, 1); + else + result = rtw_set_key(padapter, psecuritypriv, keyid, 0); + } + } + } + + DBG_88E("==> ips_leave.....LED(0x%08x)...\n", rtw_read32(padapter, 0x4c)); + pwrpriv->bips_processing = false; + + pwrpriv->bkeepfwalive = false; + pwrpriv->bpower_saving = false; + } + + _exit_pwrlock(&pwrpriv->lock); + + return result; +} + +static bool rtw_pwr_unassociated_idle(struct adapter *adapter) +{ + struct adapter *buddy = adapter->pbuddy_adapter; + struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(adapter->wdinfo); +#endif + + bool ret = false; + + if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) + goto exit; + + if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(pmlmepriv, WIFI_UNDER_WPS) || + check_fwstate(pmlmepriv, WIFI_AP_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) || +#if defined(CONFIG_88EU_P2P) + !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) +#else + 0) +#endif + goto exit; + + /* consider buddy, if exist */ + if (buddy) { + struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv); + #ifdef CONFIG_88EU_P2P + struct wifidirect_info *b_pwdinfo = &(buddy->wdinfo); + #endif + + if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || + check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || + check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) || +#if defined(CONFIG_88EU_P2P) + !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE)) +#else + 0) +#endif + goto exit; + } + ret = true; + +exit: + return ret; +} + +void rtw_ps_processor(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + enum rt_rf_power_state rfpwrstate; + + pwrpriv->ps_processing = true; + + if (pwrpriv->bips_processing) + goto exit; + + if (padapter->pwrctrlpriv.bHWPwrPindetect) { + rfpwrstate = RfOnOffDetect(padapter); + DBG_88E("@@@@- #2 %s==> rfstate:%s\n", __func__, (rfpwrstate == rf_on) ? "rf_on" : "rf_off"); + + if (rfpwrstate != pwrpriv->rf_pwrstate) { + if (rfpwrstate == rf_off) { + pwrpriv->change_rfpwrstate = rf_off; + pwrpriv->brfoffbyhw = true; + padapter->bCardDisableWOHSM = true; + rtw_hw_suspend(padapter); + } else { + pwrpriv->change_rfpwrstate = rf_on; + rtw_hw_resume(padapter); + } + DBG_88E("current rf_pwrstate(%s)\n", (pwrpriv->rf_pwrstate == rf_off) ? "rf_off" : "rf_on"); + } + pwrpriv->pwr_state_check_cnts++; + } + + if (pwrpriv->ips_mode_req == IPS_NONE) + goto exit; + + if (!rtw_pwr_unassociated_idle(padapter)) + goto exit; + + if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) { + DBG_88E("==>%s .fw_state(%x)\n", __func__, get_fwstate(pmlmepriv)); + pwrpriv->change_rfpwrstate = rf_off; + + ips_enter(padapter); + } +exit: + rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); + pwrpriv->ps_processing = false; + return; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +static void pwr_state_check_handler(struct timer_list *t) +#else +static void pwr_state_check_handler(void *FunctionContext) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *padapter = + from_timer(padapter, t, + pwrctrlpriv.pwr_state_check_timer); +#else + struct adapter *padapter = (struct adapter *)FunctionContext; +#endif + rtw_ps_cmd(padapter); +} + +/* + * + * Parameters + * padapter + * pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4 + * + */ +void rtw_set_rpwm(struct adapter *padapter, u8 pslv) +{ + u8 rpwm; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + + pslv = PS_STATE(pslv); + + if (pwrpriv->btcoex_rfon) { + if (pslv < PS_STATE_S4) + pslv = PS_STATE_S3; + } + + if ((pwrpriv->rpwm == pslv)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: Already set rpwm[0x%02X], new=0x%02X!\n", __func__, pwrpriv->rpwm, pslv)); + return; + } + + if ((padapter->bSurpriseRemoved) || + (!padapter->hw_init_completed)) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", + __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed)); + + pwrpriv->cpwm = PS_STATE_S4; + + return; + } + + if (padapter->bDriverStopped) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv)); + + if (pslv < PS_STATE_S2) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, + ("%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n", __func__, pslv)); + return; + } + } + + rpwm = pslv | pwrpriv->tog; + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("rtw_set_rpwm: rpwm=0x%02x cpwm=0x%02x\n", rpwm, pwrpriv->cpwm)); + + pwrpriv->rpwm = pslv; + + rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm)); + + pwrpriv->tog += 0x80; + pwrpriv->cpwm = pslv; + +} + +static u8 PS_RDY_CHECK(struct adapter *padapter) +{ + u32 curr_time, delta_time; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + curr_time = jiffies; + delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; + + if (delta_time < LPS_DELAY_TIME) + return false; + + if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) || + (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) || + (check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + return false; + if (pwrpriv->bInSuspend) + return false; + if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) { + DBG_88E("Group handshake still in progress !!!\n"); + return false; + } + return true; +} + +void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, + ("%s: PowerMode=%d Smart_PS=%d\n", + __func__, ps_mode, smart_ps)); + + if (ps_mode > PM_Card_Disable) { + RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, ("ps_mode:%d error\n", ps_mode)); + return; + } + + if (pwrpriv->pwr_mode == ps_mode) { + if (PS_MODE_ACTIVE == ps_mode) + return; + + if ((pwrpriv->smart_ps == smart_ps) && + (pwrpriv->bcn_ant_mode == bcn_ant_mode)) + return; + } + + /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ + if (ps_mode == PS_MODE_ACTIVE) { +#ifdef CONFIG_88EU_P2P + if (pwdinfo->opp_ps == 0) { + DBG_88E("rtw_set_ps_mode: Leave 802.11 power save\n"); + pwrpriv->pwr_mode = ps_mode; + rtw_set_rpwm(padapter, PS_STATE_S4); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + pwrpriv->bFwCurrentInPSMode = false; + } + } else { +#endif /* CONFIG_88EU_P2P */ + if (PS_RDY_CHECK(padapter)) { + DBG_88E("%s: Enter 802.11 power save\n", __func__); + pwrpriv->bFwCurrentInPSMode = true; + pwrpriv->pwr_mode = ps_mode; + pwrpriv->smart_ps = smart_ps; + pwrpriv->bcn_ant_mode = bcn_ant_mode; + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); + +#ifdef CONFIG_88EU_P2P + /* Set CTWindow after LPS */ + if (pwdinfo->opp_ps == 1) + p2p_ps_wk_cmd(padapter, P2P_PS_ENABLE, 0); +#endif /* CONFIG_88EU_P2P */ + + rtw_set_rpwm(padapter, PS_STATE_S2); + } + } + +} + +/* + * Return: + * 0: Leave OK + * -1: Timeout + * -2: Other error + */ +s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) +{ + u32 start_time; + u8 bAwake = false; + s32 err = 0; + + start_time = jiffies; + while (1) { + rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); + if (bAwake) + break; + + if (padapter->bSurpriseRemoved) { + err = -2; + DBG_88E("%s: device surprise removed!!\n", __func__); + break; + } + + if (rtw_get_passing_time_ms(start_time) > delay_ms) { + err = -1; + DBG_88E("%s: Wait for FW LPS leave more than %u ms!!!\n", __func__, delay_ms); + break; + } + rtw_usleep_os(100); + } + + return err; +} + +/* */ +/* Description: */ +/* Enter the leisure power save mode. */ +/* */ +void LPS_Enter(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + + if (PS_RDY_CHECK(padapter) == false) + return; + + if (pwrpriv->bLeisurePs) { + /* Idle for a while if we connect to AP a while ago. */ + if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */ + if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { + pwrpriv->bpower_saving = true; + DBG_88E("%s smart_ps:%d\n", __func__, pwrpriv->smart_ps); + /* For Tenda W311R IOT issue */ + rtw_set_ps_mode(padapter, pwrpriv->power_mgnt, + pwrpriv->smart_ps, 0x40); + } + } else { + pwrpriv->LpsIdleCount++; + } + } + +} + +#define LPS_LEAVE_TIMEOUT_MS 100 + +/* Description: */ +/* Leave the leisure power save mode. */ +void LPS_Leave(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + + if (pwrpriv->bLeisurePs) { + if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { + rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0x40); + + if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) + LPS_RF_ON_check(padapter, LPS_LEAVE_TIMEOUT_MS); + } + } + + pwrpriv->bpower_saving = false; + +} + +/* */ +/* Description: Leave all power save mode: LPS, FwLPS, IPS if needed. */ +/* Move code to function by tynli. 2010.03.26. */ +/* */ +void LeaveAllPowerSaveMode(struct adapter *Adapter) +{ + struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + u8 enqueue = 0; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ + p2p_ps_wk_cmd(Adapter, P2P_PS_DISABLE, enqueue); + + rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, enqueue); + } + +} + +void rtw_init_pwrctrl_priv(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + _init_pwrlock(&pwrctrlpriv->lock); + pwrctrlpriv->rf_pwrstate = rf_on; + pwrctrlpriv->ips_enter_cnts = 0; + pwrctrlpriv->ips_leave_cnts = 0; + pwrctrlpriv->bips_processing = false; + + pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode; + pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode; + + pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL; + pwrctrlpriv->pwr_state_check_cnts = 0; + pwrctrlpriv->bInternalAutoSuspend = false; + pwrctrlpriv->bInSuspend = false; + pwrctrlpriv->bkeepfwalive = false; + + pwrctrlpriv->LpsIdleCount = 0; + if (padapter->registrypriv.mp_mode == 1) + pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE ; + else + pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ + pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + + pwrctrlpriv->bFwCurrentInPSMode = false; + + pwrctrlpriv->rpwm = 0; + pwrctrlpriv->cpwm = PS_STATE_S4; + + pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE; + pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps; + pwrctrlpriv->bcn_ant_mode = 0; + + pwrctrlpriv->tog = 0x80; + + pwrctrlpriv->btcoex_rfon = false; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + timer_setup(&pwrctrlpriv->pwr_state_check_timer, pwr_state_check_handler, 0); +#else + _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter); +#endif +} + +void rtw_free_pwrctrl_priv(struct adapter *adapter) +{ + struct pwrctrl_priv *pwrctrlpriv = &adapter->pwrctrlpriv; + + _free_pwrlock(&pwrctrlpriv->lock); + +} + +u8 rtw_interface_ps_func(struct adapter *padapter, enum hal_intf_ps_func efunc_id, u8 *val) +{ + u8 bResult = true; + rtw_hal_intf_ps_func(padapter, efunc_id, val); + + return bResult; +} + +inline void rtw_set_ips_deny(struct adapter *padapter, u32 ms) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ms); +} + +/* +* rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend +* @adapter: pointer to struct adapter structure +* @ips_deffer_ms: the ms wiil prevent from falling into IPS after wakeup +* Return _SUCCESS or _FAIL +*/ + +int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *caller) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int ret = _SUCCESS; + u32 start = jiffies; + + if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms)) + pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms); + + if (pwrpriv->ps_processing) { + DBG_88E("%s wait ps_processing...\n", __func__); + while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000) + rtw_msleep_os(10); + if (pwrpriv->ps_processing) + DBG_88E("%s wait ps_processing timeout\n", __func__); + else + DBG_88E("%s wait ps_processing done\n", __func__); + } + + /* System suspend is not allowed to wakeup */ + if ((!pwrpriv->bInternalAutoSuspend) && pwrpriv->bInSuspend) { + while (pwrpriv->bInSuspend && + (rtw_get_passing_time_ms(start) <= 3000 || + (rtw_get_passing_time_ms(start) <= 500))) + rtw_msleep_os(10); + if (pwrpriv->bInSuspend) + DBG_88E("%s wait bInSuspend timeout\n", __func__); + else + DBG_88E("%s wait bInSuspend done\n", __func__); + } + + /* block??? */ + if ((pwrpriv->bInternalAutoSuspend) && (padapter->net_closed)) { + ret = _FAIL; + goto exit; + } + + /* I think this should be check in IPS, LPS, autosuspend functions... */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + ret = _SUCCESS; + goto exit; + } + if (rf_off == pwrpriv->rf_pwrstate) { + DBG_88E("%s call ips_leave....\n", __func__); + if (_FAIL == ips_leave(padapter)) { + DBG_88E("======> ips_leave fail.............\n"); + ret = _FAIL; + goto exit; + } + } + + /* TODO: the following checking need to be merged... */ + if (padapter->bDriverStopped || !padapter->bup || + !padapter->hw_init_completed) { + DBG_88E("%s: bDriverStopped=%d, bup=%d, hw_init_completed =%u\n" + , caller + , padapter->bDriverStopped + , padapter->bup + , padapter->hw_init_completed); + ret = false; + goto exit; + } + +exit: + if (pwrpriv->ips_deny_time < jiffies + rtw_ms_to_systime(ips_deffer_ms)) + pwrpriv->ips_deny_time = jiffies + rtw_ms_to_systime(ips_deffer_ms); + return ret; +} + +int rtw_pm_set_lps(struct adapter *padapter, u8 mode) +{ + int ret = 0; + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + if (mode < PS_MODE_NUM) { + if (pwrctrlpriv->power_mgnt != mode) { + if (PS_MODE_ACTIVE == mode) + LeaveAllPowerSaveMode(padapter); + else + pwrctrlpriv->LpsIdleCount = 2; + pwrctrlpriv->power_mgnt = mode; + pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; + } + } else { + ret = -EINVAL; + } + + return ret; +} + +int rtw_pm_set_ips(struct adapter *padapter, u8 mode) +{ + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) { + rtw_ips_mode_req(pwrctrlpriv, mode); + DBG_88E("%s %s\n", __func__, mode == IPS_NORMAL ? "IPS_NORMAL" : "IPS_LEVEL_2"); + return 0; + } else if (mode == IPS_NONE) { + rtw_ips_mode_req(pwrctrlpriv, mode); + DBG_88E("%s %s\n", __func__, "IPS_NONE"); + if ((padapter->bSurpriseRemoved == 0) && (_FAIL == rtw_pwr_wakeup(padapter))) + return -EFAULT; + } else { + return -EINVAL; + } + return 0; +} diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c new file mode 100644 index 000000000000..16a38a2fbe87 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -0,0 +1,2252 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_RECV_C_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; +static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; + +/* Bridge-Tunnel header (for EtherTypes ETH_P_AARP and ETH_P_IPX) */ +static u8 rtw_bridge_tunnel_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0xf8 +}; + +static u8 rtw_rfc1042_header[] = { + 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 +}; + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +void rtw_signal_stat_timer_hdl(struct timer_list *); +#else +void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); +#endif + +void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) +{ + + memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); + + spin_lock_init(&psta_recvpriv->lock); + + _rtw_init_queue(&psta_recvpriv->defrag_q); + +} + +int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) +{ + int i; + + struct recv_frame *precvframe; + + int res = _SUCCESS; + + spin_lock_init(&precvpriv->lock); + + _rtw_init_queue(&precvpriv->free_recv_queue); + _rtw_init_queue(&precvpriv->recv_pending_queue); + _rtw_init_queue(&precvpriv->uc_swdec_pending_queue); + + precvpriv->adapter = padapter; + + precvpriv->free_recvframe_cnt = NR_RECVFRAME; + + rtw_os_recv_resource_init(precvpriv, padapter); + + precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); + + if (precvpriv->pallocated_frame_buf == NULL) { + res = _FAIL; + goto exit; + } + + precvpriv->precv_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_frame_buf), RXFRAME_ALIGN_SZ); + + precvframe = (struct recv_frame *)precvpriv->precv_frame_buf; + + for (i = 0; i < NR_RECVFRAME; i++) { + INIT_LIST_HEAD(&(precvframe->list)); + + list_add_tail(&(precvframe->list), &(precvpriv->free_recv_queue.queue)); + + res = rtw_os_recv_resource_alloc(padapter, precvframe); + + precvframe->len = 0; + + precvframe->adapter = padapter; + precvframe++; + } + precvpriv->rx_pending_cnt = 1; + + sema_init(&precvpriv->allrxreturnevt, 0); + + res = rtw_hal_init_recv_priv(padapter); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, 0); +#else + _init_timer(&precvpriv->signal_stat_timer, padapter->pnetdev, RTW_TIMER_HDL_NAME(signal_stat), padapter); +#endif + precvpriv->signal_stat_sampling_interval = 1000; /* ms */ + + rtw_set_signal_stat_timer(precvpriv); +exit: + + return res; +} + +static void rtw_mfree_recv_priv_lock(struct recv_priv *precvpriv) +{ + _rtw_spinlock_free(&precvpriv->lock); + _rtw_spinlock_free(&precvpriv->free_recv_queue.lock); + _rtw_spinlock_free(&precvpriv->recv_pending_queue.lock); + + _rtw_spinlock_free(&precvpriv->free_recv_buf_queue.lock); +} + +void _rtw_free_recv_priv (struct recv_priv *precvpriv) +{ + struct adapter *padapter = precvpriv->adapter; + + rtw_free_uc_swdec_pending_queue(padapter); + + rtw_mfree_recv_priv_lock(precvpriv); + + rtw_os_recv_resource_free(precvpriv); + + if (precvpriv->pallocated_frame_buf) { + rtw_vmfree(precvpriv->pallocated_frame_buf, NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); + } + + rtw_hal_free_recv_priv(padapter); + +} + +struct recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +{ + struct recv_frame *hdr; + struct list_head *plist, *phead; + struct adapter *padapter; + struct recv_priv *precvpriv; + + if (list_empty(&pfree_recv_queue->queue)) { + hdr = NULL; + } else { + phead = get_list_head(pfree_recv_queue); + + plist = phead->next; + + hdr = container_of(plist, struct recv_frame, list); + + list_del_init(&hdr->list); + padapter = hdr->adapter; + if (padapter != NULL) { + precvpriv = &padapter->recvpriv; + if (pfree_recv_queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt--; + } + } + + return (struct recv_frame *)hdr; +} + +struct recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +{ + struct recv_frame *precvframe; + + spin_lock_bh(&pfree_recv_queue->lock); + + precvframe = _rtw_alloc_recvframe(pfree_recv_queue); + + spin_unlock_bh(&pfree_recv_queue->lock); + + return precvframe; +} + +void rtw_init_recvframe(struct recv_frame *precvframe, struct recv_priv *precvpriv) +{ + /* Perry: This can be removed */ + INIT_LIST_HEAD(&precvframe->list); + + precvframe->len = 0; +} + +int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue) +{ + struct adapter *padapter; + struct recv_priv *precvpriv; + + if (!precvframe) + return _FAIL; + padapter = precvframe->adapter; + precvpriv = &padapter->recvpriv; + if (precvframe->pkt) { + dev_kfree_skb_any(precvframe->pkt);/* free skb by driver */ + precvframe->pkt = NULL; + } + + spin_lock_bh(&pfree_recv_queue->lock); + + list_del_init(&(precvframe->list)); + + precvframe->len = 0; + + list_add_tail(&(precvframe->list), get_list_head(pfree_recv_queue)); + + if (padapter != NULL) { + if (pfree_recv_queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt++; + } + + spin_unlock_bh(&pfree_recv_queue->lock); + + return _SUCCESS; +} + +int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) +{ + struct adapter *padapter = precvframe->adapter; + struct recv_priv *precvpriv = &padapter->recvpriv; + + list_del_init(&(precvframe->list)); + list_add_tail(&(precvframe->list), get_list_head(queue)); + + if (padapter != NULL) { + if (queue == &precvpriv->free_recv_queue) + precvpriv->free_recvframe_cnt++; + } + + return _SUCCESS; +} + +int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) +{ + int ret; + + spin_lock_bh(&queue->lock); + ret = _rtw_enqueue_recvframe(precvframe, queue); + spin_unlock_bh(&queue->lock); + + return ret; +} + +/* +caller : defrag ; recvframe_chk_defrag in recv_thread (passive) +pframequeue: defrag_queue : will be accessed in recv_thread (passive) + +using spinlock to protect + +*/ + +void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) +{ + struct recv_frame *hdr; + struct list_head *plist, *phead; + + spin_lock(&pframequeue->lock); + + phead = get_list_head(pframequeue); + plist = phead->next; + + while (phead != plist) { + hdr = container_of(plist, struct recv_frame, list); + + plist = plist->next; + + rtw_free_recvframe((struct recv_frame *)hdr, pfree_recv_queue); + } + + spin_unlock(&pframequeue->lock); + +} + +u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) +{ + u32 cnt = 0; + struct recv_frame *pending_frame; + while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { + rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); + DBG_88E("%s: dequeue uc_swdec_pending_queue\n", __func__); + cnt++; + } + + return cnt; +} + +int rtw_enqueue_recvbuf_to_head(struct recv_buf *precvbuf, struct __queue *queue) +{ + spin_lock_bh(&queue->lock); + + list_del_init(&precvbuf->list); + list_add(&precvbuf->list, get_list_head(queue)); + + spin_unlock_bh(&queue->lock); + + return _SUCCESS; +} + +int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) +{ + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + + list_del_init(&precvbuf->list); + + list_add_tail(&precvbuf->list, get_list_head(queue)); + spin_unlock_irqrestore(&queue->lock, flags); + return _SUCCESS; +} + +struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) +{ + struct recv_buf *precvbuf; + struct list_head *plist, *phead; + unsigned long flags; + + spin_lock_irqsave(&queue->lock, flags); + + if (list_empty(&queue->queue)) { + precvbuf = NULL; + } else { + phead = get_list_head(queue); + + plist = phead->next; + + precvbuf = container_of(plist, struct recv_buf, list); + + list_del_init(&precvbuf->list); + } + + spin_unlock_irqrestore(&queue->lock, flags); + + return precvbuf; +} + +static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvframe) +{ + int i, res = _SUCCESS; + u32 datalen; + u8 miccode[8]; + u8 bmic_err = false, brpt_micerror = true; + u8 *pframe, *payload, *pframemic; + u8 *mickey; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &precvframe->attrib; + struct security_priv *psecuritypriv = &adapter->securitypriv; + + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); + + if (prxattrib->encrypt == _TKIP_) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt==_TKIP_\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); + + /* calculate mic code */ + if (stainfo != NULL) { + if (IS_MCAST(prxattrib->ra)) { + mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); + + if (!psecuritypriv) { + res = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); + DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); + goto exit; + } + } else { + mickey = &stainfo->dot11tkiprxmickey.skey[0]; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); + } + + datalen = precvframe->len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ + pframe = precvframe->rx_data; + payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len)); + rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], + (unsigned char)prxattrib->priority); /* care the length of the data */ + + pframemic = payload+datalen; + + bmic_err = false; + + for (i = 0; i < 8; i++) { + if (miccode[i] != *(pframemic+i)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("recvframe_chkmic:miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", + i, miccode[i], i, *(pframemic+i))); + bmic_err = true; + } + } + + if (bmic_err) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n *(pframemic-8)-*(pframemic-1)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + *(pframemic-8), *(pframemic-7), *(pframemic-6), + *(pframemic-5), *(pframemic-4), *(pframemic-3), + *(pframemic-2), *(pframemic-1))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("\n *(pframemic-16)-*(pframemic-9)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", + *(pframemic-16), *(pframemic-15), *(pframemic-14), + *(pframemic-13), *(pframemic-12), *(pframemic-11), + *(pframemic-10), *(pframemic-9))); + { + uint i; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len=%d)======\n", precvframe->len)); + for (i = 0; i < precvframe->len; i = i+8) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", + *(precvframe->rx_data+i), *(precvframe->rx_data+i+1), + *(precvframe->rx_data+i+2), *(precvframe->rx_data+i+3), + *(precvframe->rx_data+i+4), *(precvframe->rx_data+i+5), + *(precvframe->rx_data+i+6), *(precvframe->rx_data+i+7))); + } + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ====== demp packet end [len=%d]======\n", precvframe->len)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n hrdlen=%d,\n", prxattrib->hdrlen)); + } + + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("ra=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x psecuritypriv->binstallGrpkey=%d ", + prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], + prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5], psecuritypriv->binstallGrpkey)); + + /* double check key_index for some timing issue , */ + /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ + if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index)) + brpt_micerror = false; + + if ((prxattrib->bdecrypted) && (brpt_micerror)) { + rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted)); + DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted)); + DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); + } + res = _FAIL; + } else { + /* mic checked ok */ + if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST(prxattrib->ra))) { + psecuritypriv->bcheck_grpkey = true; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grpkey = true")); + } + } + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo==NULL!!!\n")); + } + + recvframe_pull_tail(precvframe, 8); + } + +exit: + + return res; +} + +/* decrypt and set the ivlen, icvlen of the recv_frame */ +static struct recv_frame *decryptor(struct adapter *padapter, struct recv_frame *precv_frame) +{ + struct rx_pkt_attrib *prxattrib = &precv_frame->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct recv_frame *return_packet = precv_frame; + u32 res = _SUCCESS; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted=%x prxattrib->encrypt=0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); + + if (prxattrib->encrypt > 0) { + u8 *iv = precv_frame->rx_data+prxattrib->hdrlen; + prxattrib->key_index = (((iv[3])>>6)&0x3); + + if (prxattrib->key_index > WEP_KEYS) { + DBG_88E("prxattrib->key_index(%d)>WEP_KEYS\n", prxattrib->key_index); + + switch (prxattrib->encrypt) { + case _WEP40_: + case _WEP104_: + prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex; + break; + case _TKIP_: + case _AES_: + default: + prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid; + break; + } + } + } + + if ((prxattrib->encrypt > 0) && ((prxattrib->bdecrypted == 0) || (psecuritypriv->sw_decrypt))) { + psecuritypriv->hw_decrypted = false; + + switch (prxattrib->encrypt) { + case _WEP40_: + case _WEP104_: + rtw_wep_decrypt(padapter, (u8 *)precv_frame); + break; + case _TKIP_: + res = rtw_tkip_decrypt(padapter, (u8 *)precv_frame); + break; + case _AES_: + res = rtw_aes_decrypt(padapter, (u8 *)precv_frame); + break; + default: + break; + } + } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && + (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_)) + psecuritypriv->hw_decrypted = true; + + if (res == _FAIL) { + rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue); + return_packet = NULL; + } else { + prxattrib->bdecrypted = true; + } + + return return_packet; +} + +/* set the security information in the recv_frame */ +static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *precv_frame) +{ + u8 *psta_addr, *ptr; + uint auth_alg; + struct recv_frame *pfhdr; + struct sta_info *psta; + struct sta_priv *pstapriv; + struct recv_frame *prtnframe; + u16 ether_type; + u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ + struct rx_pkt_attrib *pattrib; + __be16 be_tmp; + + pstapriv = &adapter->stapriv; + + auth_alg = adapter->securitypriv.dot11AuthAlgrthm; + + ptr = precv_frame->rx_data; + pfhdr = precv_frame; + pattrib = &pfhdr->attrib; + psta_addr = pattrib->ta; + + prtnframe = NULL; + + psta = rtw_get_stainfo(pstapriv, psta_addr); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm=%d\n", + adapter->securitypriv.dot11AuthAlgrthm)); + + if (auth_alg == 2) { + if ((psta != NULL) && (psta->ieee8021x_blocked)) { + /* blocked */ + /* only accept EAPOL frame */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==1\n")); + + prtnframe = precv_frame; + + /* get ether_type */ + ptr = ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; + memcpy(&be_tmp, ptr, 2); + ether_type = ntohs(be_tmp); + + if (ether_type == eapol_type) { + prtnframe = precv_frame; + } else { + /* free this frame */ + rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue); + prtnframe = NULL; + } + } else { + /* allowed */ + /* check decryption status, and decrypt the frame if needed */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==0\n")); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", precv_frame->attrib.privacy)); + + if (pattrib->bdecrypted == 0) + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted=%x\n", pattrib->bdecrypted)); + + prtnframe = precv_frame; + /* check is the EAPOL frame or not (Rekey) */ + if (ether_type == eapol_type) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type==0x888e\n")); + /* check Rekey */ + + prtnframe = precv_frame; + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type=0x%04x\n", ether_type)); + } + } + } else { + prtnframe = precv_frame; + } + + return prtnframe; +} + +static int recv_decache(struct recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache) +{ + int tid = precv_frame->attrib.priority; + + u16 seq_ctrl = ((precv_frame->attrib.seq_num&0xffff) << 4) | + (precv_frame->attrib.frag_num & 0xf); + + if (tid > 15) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, (tid>15)! seq_ctrl=0x%x, tid=0x%x\n", seq_ctrl, tid)); + + return _FAIL; + } + + if (1) {/* if (bretry) */ + if (seq_ctrl == prxcache->tid_rxseq[tid]) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, seq_ctrl=0x%x, tid=0x%x, tid_rxseq=0x%x\n", seq_ctrl, tid, prxcache->tid_rxseq[tid])); + + return _FAIL; + } + } + + prxcache->tid_rxseq[tid] = seq_ctrl; + + return _SUCCESS; +} + +void process_pwrbit_data(struct adapter *padapter, struct recv_frame *precv_frame); +void process_pwrbit_data(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + unsigned char pwrbit; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + + psta = rtw_get_stainfo(pstapriv, pattrib->src); + + pwrbit = GetPwrMgt(ptr); + + if (psta) { + if (pwrbit) { + if (!(psta->state & WIFI_SLEEP_STATE)) + stop_sta_xmit(padapter, psta); + } else { + if (psta->state & WIFI_SLEEP_STATE) + wakeup_sta_to_xmit(padapter, psta); + } + } + +#endif +} + +static void process_wmmps_data(struct adapter *padapter, struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *psta = NULL; + + psta = rtw_get_stainfo(pstapriv, pattrib->src); + + if (!psta) + return; + + if (!psta->qos_option) + return; + + if (!(psta->qos_info&0xf)) + return; + + if (psta->state&WIFI_SLEEP_STATE) { + u8 wmmps_ac = 0; + + switch (pattrib->priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(1); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(1); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(1); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(1); + break; + } + + if (wmmps_ac) { + if (psta->sleepq_ac_len > 0) { + /* process received triggered frame */ + xmit_delivery_enabled_frames(padapter, psta); + } else { + /* issue one qos null frame with More data bit = 0 and the EOSP bit set (= 1) */ + issue_qos_nulldata(padapter, psta->hwaddr, (u16)pattrib->priority, 0, 0); + } + } + } + +#endif +} + +static void count_rx_stats(struct adapter *padapter, struct recv_frame *prframe, struct sta_info *sta) +{ + int sz; + struct sta_info *psta = NULL; + struct stainfo_stats *pstats = NULL; + struct rx_pkt_attrib *pattrib = &prframe->attrib; + struct recv_priv *precvpriv = &padapter->recvpriv; + + sz = get_recvframe_len(prframe); + precvpriv->rx_bytes += sz; + + padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; + + if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) + padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; + + if (sta) + psta = sta; + else + psta = prframe->psta; + + if (psta) { + pstats = &psta->sta_stats; + + pstats->rx_data_pkts++; + pstats->rx_bytes += sz; + } +} + +int sta2sta_data_frame( + struct adapter *adapter, + struct recv_frame *precv_frame, + struct sta_info **psta +); + +int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, struct sta_info **psta) +{ + u8 *ptr = precv_frame->rx_data; + int ret = _SUCCESS; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *mybssid = get_bssid(pmlmepriv); + u8 *myhwaddr = myid(&adapter->eeprompriv); + u8 *sta_addr = NULL; + int bmcast = IS_MCAST(pattrib->dst); + + if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + /* filter packets that SA is myself or multicast or broadcast */ + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); + ret = _FAIL; + goto exit; + } + + if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + ret = _FAIL; + goto exit; + } + + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + sta_addr = pattrib->src; + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ + if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid!=TA under STATION_MODE; drop pkt\n")); + ret = _FAIL; + goto exit; + } + sta_addr = pattrib->bssid; + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + if (bmcast) { + /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ + if (!IS_MCAST(pattrib->bssid)) { + ret = _FAIL; + goto exit; + } + } else { /* not mc-frame */ + /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ + if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + sta_addr = pattrib->src; + } + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { + memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); + memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + + sta_addr = mybssid; + } else { + ret = _FAIL; + } + + if (bmcast) + *psta = rtw_get_bcmc_stainfo(adapter); + else + *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ + + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n")); + if (adapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + adapter->mppriv.rx_pktloss++; + } + ret = _FAIL; + goto exit; + } + +exit: + + return ret; +} + +static int ap2sta_data_frame ( + struct adapter *adapter, + struct recv_frame *precv_frame, + struct sta_info **psta) +{ + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + int ret = _SUCCESS; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *mybssid = get_bssid(pmlmepriv); + u8 *myhwaddr = myid(&adapter->eeprompriv); + int bmcast = IS_MCAST(pattrib->dst); + + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && + (check_fwstate(pmlmepriv, _FW_LINKED) == true || + check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + /* filter packets that SA is myself or multicast or broadcast */ + if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); + ret = _FAIL; + goto exit; + } + + /* da should be for me */ + if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + (" ap2sta_data_frame: compare DA fail; DA=%pM\n", (pattrib->dst))); + ret = _FAIL; + goto exit; + } + + /* check BSSID */ + if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || + (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + (" ap2sta_data_frame: compare BSSID fail ; BSSID=%pM\n", (pattrib->bssid))); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid=%pM\n", (mybssid))); + + if (!bmcast) { + DBG_88E("issue_deauth to the nonassociated ap=%pM for the reason(7)\n", (pattrib->bssid)); + issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + } + + ret = _FAIL; + goto exit; + } + + if (bmcast) + *psta = rtw_get_bcmc_stainfo(adapter); + else + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ + + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n")); + ret = _FAIL; + goto exit; + } + + /* if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { */ + /* */ + + if (GetFrameSubType(ptr) & BIT(6)) { + /* No data, will not indicate to upper layer, temporily count it here */ + count_rx_stats(adapter, precv_frame, *psta); + ret = RTW_RX_HANDLED; + goto exit; + } + } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && + (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); + memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + + /* */ + memcpy(pattrib->bssid, mybssid, ETH_ALEN); + + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under MP_MODE ; drop pkt\n")); + ret = _FAIL; + goto exit; + } + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* Special case */ + ret = RTW_RX_HANDLED; + goto exit; + } else { + if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { + *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ + if (*psta == NULL) { + DBG_88E("issue_deauth to the ap =%pM for the reason(7)\n", (pattrib->bssid)); + + issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + } + } + + ret = _FAIL; + } + +exit: + + return ret; +} + +static int sta2ap_data_frame(struct adapter *adapter, + struct recv_frame *precv_frame, + struct sta_info **psta) +{ + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + struct sta_priv *pstapriv = &adapter->stapriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + u8 *ptr = precv_frame->rx_data; + unsigned char *mybssid = get_bssid(pmlmepriv); + int ret = _SUCCESS; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ + if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { + ret = _FAIL; + goto exit; + } + + *psta = rtw_get_stainfo(pstapriv, pattrib->src); + if (*psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); + DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); + + issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + + ret = RTW_RX_HANDLED; + goto exit; + } + + process_pwrbit_data(adapter, precv_frame); + + if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { + process_wmmps_data(adapter, precv_frame); + } + + if (GetFrameSubType(ptr) & BIT(6)) { + /* No data, will not indicate to upper layer, temporily count it here */ + count_rx_stats(adapter, precv_frame, *psta); + ret = RTW_RX_HANDLED; + goto exit; + } + } else { + u8 *myhwaddr = myid(&adapter->eeprompriv); + if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { + ret = RTW_RX_HANDLED; + goto exit; + } + DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); + issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); + ret = RTW_RX_HANDLED; + goto exit; + } + +exit: + + return ret; +} + +static int validate_recv_ctrl_frame(struct adapter *padapter, + struct recv_frame *precv_frame) +{ +#ifdef CONFIG_88EU_AP_MODE + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 *pframe = precv_frame->rx_data; + /* uint len = precv_frame->len; */ + + if (GetFrameType(pframe) != WIFI_CTRL_TYPE) + return _FAIL; + + /* receive the frames that ra(a1) is my address */ + if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) + return _FAIL; + + /* only handle ps-poll */ + if (GetFrameSubType(pframe) == WIFI_PSPOLL) { + u16 aid; + u8 wmmps_ac = 0; + struct sta_info *psta = NULL; + + aid = GetAid(pframe); + psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); + + if ((psta == NULL) || (psta->aid != aid)) + return _FAIL; + + /* for rx pkt statistics */ + psta->sta_stats.rx_ctrl_pkts++; + + switch (pattrib->priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(0); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(0); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(0); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(0); + break; + } + + if (wmmps_ac) + return _FAIL; + + if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { + DBG_88E("%s alive check-rx ps-poll\n", __func__); + psta->expire_to = pstapriv->expire_to; + psta->state ^= WIFI_STA_ALIVE_CHK_STATE; + } + + if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + spin_lock_bh(&pxmitpriv->lock); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = xmitframe_phead->next; + + if (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = xmitframe_plist->next; + + list_del_init(&pxmitframe->list); + + psta->sleepq_len--; + + if (psta->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + pxmitframe->attrib.triggered = 1; + + rtw_hal_xmitframe_enqueue(padapter, pxmitframe); + + if (psta->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* upate BCN for TIM IE */ + /* update_BCNTIM(padapter); */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } else { + if (pstapriv->tim_bitmap&BIT(psta->aid)) { + if (psta->sleepq_len == 0) { + DBG_88E("no buffered packets to xmit\n"); + + /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */ + issue_nulldata(padapter, psta->hwaddr, 0, 0, 0); + } else { + DBG_88E("error!psta->sleepq_len=%d\n", psta->sleepq_len); + psta->sleepq_len = 0; + } + + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* upate BCN for TIM IE */ + /* update_BCNTIM(padapter); */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } + spin_unlock_bh(&pxmitpriv->lock); + } + } + +#endif + + return _FAIL; +} + +struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_frame *precv_frame); + +static int validate_recv_mgnt_frame(struct adapter *padapter, + struct recv_frame *precv_frame) +{ + struct sta_info *psta; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+validate_recv_mgnt_frame\n")); + + precv_frame = recvframe_chk_defrag(padapter, precv_frame); + if (precv_frame == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); + return _SUCCESS; + } + + /* for rx pkt statistics */ + psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->rx_data)); + if (psta) { + psta->sta_stats.rx_mgnt_pkts++; + if (GetFrameSubType(precv_frame->rx_data) == WIFI_BEACON) { + psta->sta_stats.rx_beacon_pkts++; + } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBEREQ) { + psta->sta_stats.rx_probereq_pkts++; + } else if (GetFrameSubType(precv_frame->rx_data) == WIFI_PROBERSP) { + if (!memcmp(padapter->eeprompriv.mac_addr, GetAddr1Ptr(precv_frame->rx_data), ETH_ALEN)) + psta->sta_stats.rx_probersp_pkts++; + else if (is_broadcast_mac_addr(GetAddr1Ptr(precv_frame->rx_data)) || + is_multicast_mac_addr(GetAddr1Ptr(precv_frame->rx_data))) + psta->sta_stats.rx_probersp_bm_pkts++; + else + psta->sta_stats.rx_probersp_uo_pkts++; + } + } + + mgt_dispatcher(padapter, precv_frame); + + return _SUCCESS; +} + +static int validate_recv_data_frame(struct adapter *adapter, + struct recv_frame *precv_frame) +{ + u8 bretry; + u8 *psa, *pda, *pbssid; + struct sta_info *psta = NULL; + u8 *ptr = precv_frame->rx_data; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + struct security_priv *psecuritypriv = &adapter->securitypriv; + int ret = _SUCCESS; + + bretry = GetRetry(ptr); + pda = get_da(ptr); + psa = get_sa(ptr); + pbssid = get_hdr_bssid(ptr); + + if (pbssid == NULL) { + ret = _FAIL; + goto exit; + } + + memcpy(pattrib->dst, pda, ETH_ALEN); + memcpy(pattrib->src, psa, ETH_ALEN); + + memcpy(pattrib->bssid, pbssid, ETH_ALEN); + + switch (pattrib->to_fr_ds) { + case 0: + memcpy(pattrib->ra, pda, ETH_ALEN); + memcpy(pattrib->ta, psa, ETH_ALEN); + ret = sta2sta_data_frame(adapter, precv_frame, &psta); + break; + case 1: + memcpy(pattrib->ra, pda, ETH_ALEN); + memcpy(pattrib->ta, pbssid, ETH_ALEN); + ret = ap2sta_data_frame(adapter, precv_frame, &psta); + break; + case 2: + memcpy(pattrib->ra, pbssid, ETH_ALEN); + memcpy(pattrib->ta, psa, ETH_ALEN); + ret = sta2ap_data_frame(adapter, precv_frame, &psta); + break; + case 3: + memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN); + memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN); + ret = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n")); + break; + default: + ret = _FAIL; + break; + } + + if (ret == _FAIL) { + goto exit; + } else if (ret == RTW_RX_HANDLED) { + goto exit; + } + + if (psta == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" after to_fr_ds_chk; psta==NULL\n")); + ret = _FAIL; + goto exit; + } + + /* psta->rssi = prxcmd->rssi; */ + /* psta->signal_quality = prxcmd->sq; */ + precv_frame->psta = psta; + + pattrib->amsdu = 0; + pattrib->ack_policy = 0; + /* parsing QC field */ + if (pattrib->qos == 1) { + pattrib->priority = GetPriority((ptr + 24)); + pattrib->ack_policy = GetAckpolicy((ptr + 24)); + pattrib->amsdu = GetAMsdu((ptr + 24)); + pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26; + + if (pattrib->priority != 0 && pattrib->priority != 3) + adapter->recvpriv.bIsAnyNonBEPkts = true; + } else { + pattrib->priority = 0; + pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 30 : 24; + } + + if (pattrib->order)/* HT-CTRL 11n */ + pattrib->hdrlen += 4; + + precv_frame->preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; + + /* decache, drop duplicate recv packets */ + if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decache : drop pkt\n")); + ret = _FAIL; + goto exit; + } + + if (pattrib->privacy) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("validate_recv_data_frame:pattrib->privacy=%x\n", pattrib->privacy)); + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x))=%d^^^^^^^^^^^^^^^6\n", pattrib->ra[0], IS_MCAST(pattrib->ra))); + + GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, IS_MCAST(pattrib->ra)); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt=%d\n", pattrib->encrypt)); + + SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); + } else { + pattrib->encrypt = 0; + pattrib->iv_len = 0; + pattrib->icv_len = 0; + } + +exit: + + return ret; +} + +static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv_frame) +{ + /* shall check frame subtype, to / from ds, da, bssid */ + + /* then call check if rx seq/frag. duplicated. */ + + u8 type; + u8 subtype; + int retval = _SUCCESS; + u8 bDumpRxPkt; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + u8 *ptr = precv_frame->rx_data; + u8 ver = (unsigned char) (*ptr)&0x3; + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + int ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, rtw_get_oper_ch(adapter)); + if (ch_set_idx >= 0) + pmlmeext->channel_set[ch_set_idx].rx_count++; + } + + /* add version chk */ + if (ver != 0) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! (ver!=0)\n")); + retval = _FAIL; + goto exit; + } + + type = GetFrameType(ptr); + subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */ + + pattrib->to_fr_ds = get_tofr_ds(ptr); + + pattrib->frag_num = GetFragNum(ptr); + pattrib->seq_num = GetSequence(ptr); + + pattrib->pw_save = GetPwrMgt(ptr); + pattrib->mfrag = GetMFrag(ptr); + pattrib->mdata = GetMData(ptr); + pattrib->privacy = GetPrivacy(ptr); + pattrib->order = GetOrder(ptr); + + /* Dump rx packets */ + rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); + if (bDumpRxPkt == 1) {/* dump all rx packets */ + int i; + DBG_88E("#############################\n"); + + for (i = 0; i < 64; i = i+8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), + *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_88E("#############################\n"); + } else if (bDumpRxPkt == 2) { + if (type == WIFI_MGT_TYPE) { + int i; + DBG_88E("#############################\n"); + + for (i = 0; i < 64; i = i+8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), + *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_88E("#############################\n"); + } + } else if (bDumpRxPkt == 3) { + if (type == WIFI_DATA_TYPE) { + int i; + DBG_88E("#############################\n"); + + for (i = 0; i < 64; i = i+8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), + *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + DBG_88E("#############################\n"); + } + } + switch (type) { + case WIFI_MGT_TYPE: /* mgnt */ + retval = validate_recv_mgnt_frame(adapter, precv_frame); + if (retval == _FAIL) + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_mgnt_frame fail\n")); + retval = _FAIL; /* only data frame return _SUCCESS */ + break; + case WIFI_CTRL_TYPE: /* ctrl */ + retval = validate_recv_ctrl_frame(adapter, precv_frame); + if (retval == _FAIL) + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_ctrl_frame fail\n")); + retval = _FAIL; /* only data frame return _SUCCESS */ + break; + case WIFI_DATA_TYPE: /* data */ + rtw_led_control(adapter, LED_CTL_RX); + pattrib->qos = (subtype & BIT(7)) ? 1 : 0; + retval = validate_recv_data_frame(adapter, precv_frame); + if (retval == _FAIL) { + struct recv_priv *precvpriv = &adapter->recvpriv; + precvpriv->rx_drop++; + } + break; + default: + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! type= 0x%x\n", type)); + retval = _FAIL; + break; + } + +exit: + + return retval; +} + +/* remove the wlanhdr and add the eth_hdr */ + +static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) +{ + int rmv_len; + u16 eth_type, len; + __be16 be_tmp; + u8 bsnaphdr; + u8 *psnap_type; + struct ieee80211_snap_hdr *psnap; + + int ret = _SUCCESS; + struct adapter *adapter = precvframe->adapter; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + + u8 *ptr = get_recvframe_data(precvframe); /* point to frame_ctrl field */ + struct rx_pkt_attrib *pattrib = &precvframe->attrib; + + if (pattrib->encrypt) + recvframe_pull_tail(precvframe, pattrib->icv_len); + + psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); + psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; + /* convert hdr + possible LLC headers into Ethernet header */ + if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && + memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) && + memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) || + !memcmp(psnap, rtw_bridge_tunnel_header, SNAP_SIZE)) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ + bsnaphdr = true; + } else { + /* Leave Ethernet header part of hdr and full payload */ + bsnaphdr = false; + } + + rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); + len = precvframe->len - rmv_len; + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len)); + + memcpy(&be_tmp, ptr+rmv_len, 2); + eth_type = ntohs(be_tmp); /* pattrib->ether_type */ + pattrib->eth_type = eth_type; + + if ((check_fwstate(pmlmepriv, WIFI_MP_STATE))) { + ptr += rmv_len; + *ptr = 0x87; + *(ptr+1) = 0x12; + + eth_type = 0x8712; + /* append rx status for mp test packets */ + ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr)+2)-24); + memcpy(ptr, get_rxmem(precvframe), 24); + ptr += 24; + } else { + ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0))); + } + + memcpy(ptr, pattrib->dst, ETH_ALEN); + memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN); + + if (!bsnaphdr) { + be_tmp = htons(len); + memcpy(ptr+12, &be_tmp, 2); + } + + return ret; +} + +/* perform defrag */ +static struct recv_frame *recvframe_defrag(struct adapter *adapter, struct __queue *defrag_q) +{ + struct list_head *plist, *phead; + u8 wlanhdr_offset; + u8 curfragnum; + struct recv_frame *pfhdr, *pnfhdr; + struct recv_frame *prframe, *pnextrframe; + struct __queue *pfree_recv_queue; + + curfragnum = 0; + pfree_recv_queue = &adapter->recvpriv.free_recv_queue; + + phead = get_list_head(defrag_q); + plist = phead->next; + pfhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)pfhdr; + list_del_init(&(prframe->list)); + + if (curfragnum != pfhdr->attrib.frag_num) { + /* the first fragment number must be 0 */ + /* free the whole queue */ + rtw_free_recvframe(prframe, pfree_recv_queue); + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); + + return NULL; + } + + curfragnum++; + + plist = get_list_head(defrag_q); + plist = phead->next; + pfhdr = container_of(plist, struct recv_frame, list); + prframe = (struct recv_frame *)pfhdr; + list_del_init(&(prframe->list)); + + plist = plist->next; + + while (phead != plist) { + pnfhdr = container_of(plist, struct recv_frame, list); + pnextrframe = (struct recv_frame *)pnfhdr; + + /* check the fragment sequence (2nd ~n fragment frame) */ + + if (curfragnum != pnfhdr->attrib.frag_num) { + /* the fragment number must be increasing (after decache) */ + /* release the defrag_q & prframe */ + rtw_free_recvframe(prframe, pfree_recv_queue); + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); + return NULL; + } + + curfragnum++; + + /* copy the 2nd~n fragment frame's payload to the first fragment */ + /* get the 2nd~last fragment frame's payload */ + + wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len; + + recvframe_pull(pnextrframe, wlanhdr_offset); + + /* append to first fragment frame's tail (if privacy frame, pull the ICV) */ + recvframe_pull_tail(prframe, pfhdr->attrib.icv_len); + + /* memcpy */ + memcpy(pfhdr->rx_tail, pnfhdr->rx_data, pnfhdr->len); + + recvframe_put(prframe, pnfhdr->len); + + pfhdr->attrib.icv_len = pnfhdr->attrib.icv_len; + plist = plist->next; + } + + /* free the defrag_q queue and return the prframe */ + rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n")); + + return prframe; +} + +/* check if need to defrag, if needed queue the frame to defrag_q */ +struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_frame *precv_frame) +{ + u8 ismfrag; + u8 fragnum; + u8 *psta_addr; + struct recv_frame *pfhdr; + struct sta_info *psta; + struct sta_priv *pstapriv; + struct list_head *phead; + struct recv_frame *prtnframe = NULL; + struct __queue *pfree_recv_queue, *pdefrag_q; + + pstapriv = &padapter->stapriv; + + pfhdr = precv_frame; + + pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + + /* need to define struct of wlan header frame ctrl */ + ismfrag = pfhdr->attrib.mfrag; + fragnum = pfhdr->attrib.frag_num; + + psta_addr = pfhdr->attrib.ta; + psta = rtw_get_stainfo(pstapriv, psta_addr); + if (psta == NULL) { + u8 type = GetFrameType(pfhdr->rx_data); + if (type != WIFI_DATA_TYPE) { + psta = rtw_get_bcmc_stainfo(padapter); + pdefrag_q = &psta->sta_recvpriv.defrag_q; + } else { + pdefrag_q = NULL; + } + } else { + pdefrag_q = &psta->sta_recvpriv.defrag_q; + } + + if ((ismfrag == 0) && (fragnum == 0)) + prtnframe = precv_frame;/* isn't a fragment frame */ + + if (ismfrag == 1) { + /* 0~(n-1) fragment frame */ + /* enqueue to defraf_g */ + if (pdefrag_q != NULL) { + if (fragnum == 0) { + /* the first fragment */ + if (!list_empty(&pdefrag_q->queue)) { + /* free current defrag_q */ + rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue); + } + } + + /* Then enqueue the 0~(n-1) fragment into the defrag_q */ + + phead = get_list_head(pdefrag_q); + list_add_tail(&pfhdr->list, phead); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + + prtnframe = NULL; + } else { + /* can't find this ta's defrag_queue, so free this recv_frame */ + if (precv_frame && pfree_recv_queue) + rtw_free_recvframe(precv_frame, pfree_recv_queue); + prtnframe = NULL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q==NULL: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + } + } + + if ((ismfrag == 0) && (fragnum != 0)) { + /* the last fragment frame */ + /* enqueue the last fragment */ + if (pdefrag_q != NULL) { + phead = get_list_head(pdefrag_q); + list_add_tail(&pfhdr->list, phead); + + /* call recvframe_defrag to defrag */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + precv_frame = recvframe_defrag(padapter, pdefrag_q); + prtnframe = precv_frame; + } else { + /* can't find this ta's defrag_queue, so free this recv_frame */ + if (precv_frame && pfree_recv_queue) + rtw_free_recvframe(precv_frame, pfree_recv_queue); + prtnframe = NULL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q==NULL: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); + } + } + + if ((prtnframe != NULL) && (prtnframe->attrib.privacy)) { + /* after defrag we must check tkip mic code */ + if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); + if (precv_frame && pfree_recv_queue) + rtw_free_recvframe(prtnframe, pfree_recv_queue); + prtnframe = NULL; + } + } + + return prtnframe; +} + +static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) +{ + int a_len, padding_len; + u16 eth_type, nSubframe_Length; + u8 nr_subframes, i; + unsigned char *pdata; + struct rx_pkt_attrib *pattrib; + unsigned char *data_ptr; + struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); + int ret = _SUCCESS; + nr_subframes = 0; + + pattrib = &prframe->attrib; + + recvframe_pull(prframe, prframe->attrib.hdrlen); + + if (prframe->attrib.iv_len > 0) + recvframe_pull(prframe, prframe->attrib.iv_len); + + a_len = prframe->len; + + pdata = prframe->rx_data; + + while (a_len > ETH_HLEN) { + /* Offset 12 denote 2 mac address */ + nSubframe_Length = RTW_GET_BE16(pdata + 12); + + if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { + DBG_88E("nRemain_Length is %d and nSubframe_Length is : %d\n", a_len, nSubframe_Length); + goto exit; + } + + /* move the data point to data content */ + pdata += ETH_HLEN; + a_len -= ETH_HLEN; + + /* Allocate new skb for releasing to upper layer */ + sub_skb = dev_alloc_skb(nSubframe_Length + 12); + if (sub_skb) { + skb_reserve(sub_skb, 12); + data_ptr = (u8 *)skb_put(sub_skb, nSubframe_Length); + memcpy(data_ptr, pdata, nSubframe_Length); + } else { + sub_skb = skb_clone(prframe->pkt, GFP_ATOMIC); + if (sub_skb) { + sub_skb->data = pdata; + sub_skb->len = nSubframe_Length; + skb_set_tail_pointer(sub_skb, nSubframe_Length); + } else { + DBG_88E("skb_clone() Fail!!! , nr_subframes=%d\n", nr_subframes); + break; + } + } + + subframes[nr_subframes++] = sub_skb; + + if (nr_subframes >= MAX_SUBFRAME_COUNT) { + DBG_88E("ParseSubframe(): Too many Subframes! Packets dropped!\n"); + break; + } + + pdata += nSubframe_Length; + a_len -= nSubframe_Length; + if (a_len != 0) { + padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4-1)); + if (padding_len == 4) { + padding_len = 0; + } + + if (a_len < padding_len) { + goto exit; + } + pdata += padding_len; + a_len -= padding_len; + } + } + + for (i = 0; i < nr_subframes; i++) { + sub_skb = subframes[i]; + /* convert hdr + possible LLC headers into Ethernet header */ + eth_type = RTW_GET_BE16(&sub_skb->data[6]); + if (sub_skb->len >= 8 && + ((!memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE) && + eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || + !memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))) { + /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ + skb_pull(sub_skb, SNAP_SIZE); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN); + } else { + __be16 len; + /* Leave Ethernet header part of hdr and full payload */ + len = htons(sub_skb->len); + memcpy(skb_push(sub_skb, 2), &len, 2); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); + memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN); + } + + /* Indicate the packets to upper layer */ + /* Insert NAT2.5 RX here! */ + sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); + sub_skb->dev = padapter->pnetdev; + + sub_skb->ip_summed = CHECKSUM_NONE; + + netif_rx(sub_skb); + } + +exit: + + prframe->len = 0; + rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ + + return ret; +} + +static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num) +{ + u8 wsize = preorder_ctrl->wsize_b; + u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) & 0xFFF;/* 4096; */ + + /* Rx Reorder initialize condition. */ + if (preorder_ctrl->indicate_seq == 0xFFFF) + preorder_ctrl->indicate_seq = seq_num; + + /* Drop out the packet which SeqNum is smaller than WinStart */ + if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) + return false; + + /* */ + /* Sliding window manipulation. Conditions includes: */ + /* 1. Incoming SeqNum is equal to WinStart =>Window shift 1 */ + /* 2. Incoming SeqNum is larger than the WinEnd => Window shift N */ + /* */ + if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) { + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; + } else if (SN_LESS(wend, seq_num)) { + if (seq_num >= (wsize - 1)) + preorder_ctrl->indicate_seq = seq_num + 1 - wsize; + else + preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1; + } + + return true; +} + +int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, struct recv_frame *prframe); +int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, struct recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib = &prframe->attrib; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + struct list_head *phead, *plist; + struct recv_frame *hdr; + struct rx_pkt_attrib *pnextattrib; + + phead = get_list_head(ppending_recvframe_queue); + plist = phead->next; + + while (phead != plist) { + hdr = container_of(plist, struct recv_frame, list); + pnextattrib = &hdr->attrib; + + if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) + plist = plist->next; + else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) + return false; + else + break; + } + + list_del_init(&(prframe->list)); + + list_add_tail(&(prframe->list), plist); + return true; +} + +static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) +{ + struct list_head *phead, *plist; + struct recv_frame *prframe; + struct rx_pkt_attrib *pattrib; + int bPktInBuf = false; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + phead = get_list_head(ppending_recvframe_queue); + plist = phead->next; + + /* Handling some condition for forced indicate case. */ + if (bforced) { + if (list_empty(phead)) + return true; + + prframe = container_of(plist, struct recv_frame, list); + pattrib = &prframe->attrib; + preorder_ctrl->indicate_seq = pattrib->seq_num; + } + + /* Prepare indication list and indication. */ + /* Check if there is any packet need indicate. */ + while (!list_empty(phead)) { + prframe = container_of(plist, struct recv_frame, list); + pattrib = &prframe->attrib; + + if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("recv_indicatepkts_in_order: indicate=%d seq=%d amsdu=%d\n", + preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); + plist = plist->next; + list_del_init(&(prframe->list)); + + if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; + + /* Set this as a lock to make sure that only one thread is indicating packet. */ + + /* indicate this recv_frame */ + if (!pattrib->amsdu) { + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) + rtw_recv_indicatepkt(padapter, prframe);/* indicate this recv_frame */ + } else if (pattrib->amsdu == 1) { + if (amsdu_to_msdu(padapter, prframe) != _SUCCESS) + rtw_free_recvframe(prframe, &precvpriv->free_recv_queue); + } else { + /* error condition; */ + } + + /* Update local variables. */ + bPktInBuf = false; + } else { + bPktInBuf = true; + break; + } + } + return bPktInBuf; +} + +static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame *prframe) +{ + int retval = _SUCCESS; + struct rx_pkt_attrib *pattrib = &prframe->attrib; + struct recv_reorder_ctrl *preorder_ctrl = prframe->preorder_ctrl; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + if (!pattrib->amsdu) { + /* s1. */ + wlanhdr_to_ethhdr(prframe); + + if (pattrib->qos != 1) { + if (!padapter->bDriverStopped && + !padapter->bSurpriseRemoved) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("@@@@ recv_indicatepkt_reorder -recv_func recv_indicatepkt\n")); + + rtw_recv_indicatepkt(padapter, prframe); + return _SUCCESS; + } + + return _FAIL; + } + + if (!preorder_ctrl->enable) { + /* indicate this recv_frame */ + preorder_ctrl->indicate_seq = pattrib->seq_num; + rtw_recv_indicatepkt(padapter, prframe); + + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096; + return _SUCCESS; + } + } else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */ + if (!preorder_ctrl->enable) { + preorder_ctrl->indicate_seq = pattrib->seq_num; + retval = amsdu_to_msdu(padapter, prframe); + + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096; + return retval; + } + } + + spin_lock_bh(&ppending_recvframe_queue->lock); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, + ("recv_indicatepkt_reorder: indicate=%d seq=%d\n", + preorder_ctrl->indicate_seq, pattrib->seq_num)); + + /* s2. check if winstart_b(indicate_seq) needs to been updated */ + if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) + goto _err_exit; + + /* s3. Insert all packet into Reorder Queue to maintain its ordering. */ + if (!enqueue_reorder_recvframe(preorder_ctrl, prframe)) + goto _err_exit; + + /* s4. */ + /* Indication process. */ + /* After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets */ + /* with the SeqNum smaller than latest WinStart and buffer other packets. */ + /* */ + /* For Rx Reorder condition: */ + /* 1. All packets with SeqNum smaller than WinStart => Indicate */ + /* 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. */ + /* */ + + /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */ + if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false)) { + _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); + spin_unlock_bh(&ppending_recvframe_queue->lock); + } else { + spin_unlock_bh(&ppending_recvframe_queue->lock); + _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + } + +_success_exit: + + return _SUCCESS; + +_err_exit: + + spin_unlock_bh(&ppending_recvframe_queue->lock); + + return _FAIL; +} + +void rtw_reordering_ctrl_timeout_handler(void *pcontext) +{ + struct recv_reorder_ctrl *preorder_ctrl = (struct recv_reorder_ctrl *)pcontext; + struct adapter *padapter = preorder_ctrl->padapter; + struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + if (padapter->bDriverStopped || padapter->bSurpriseRemoved) + return; + + spin_lock_bh(&ppending_recvframe_queue->lock); + + if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true) + _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); + + spin_unlock_bh(&ppending_recvframe_queue->lock); +} + +static int process_recv_indicatepkts(struct adapter *padapter, struct recv_frame *prframe) +{ + int retval = _SUCCESS; + /* struct recv_priv *precvpriv = &padapter->recvpriv; */ + /* struct rx_pkt_attrib *pattrib = &prframe->attrib; */ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (phtpriv->ht_option) { /* B/G/N Mode */ + /* prframe->preorder_ctrl = &precvpriv->recvreorder_ctrl[pattrib->priority]; */ + + if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { + /* including perform A-MPDU Rx Ordering Buffer Control */ + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) { + retval = _FAIL; + return retval; + } + } + } else { /* B/G mode */ + retval = wlanhdr_to_ethhdr (prframe); + if (retval != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n")); + return retval; + } + + if ((!padapter->bDriverStopped) && + (!padapter->bSurpriseRemoved)) { + /* indicate this recv_frame */ + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func recv_indicatepkt\n")); + rtw_recv_indicatepkt(padapter, prframe); + } else { + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func free_indicatepkt\n")); + + RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); + retval = _FAIL; + return retval; + } + } + + return retval; +} + +static int recv_func_prehandle(struct adapter *padapter, struct recv_frame *rframe) +{ + int ret = _SUCCESS; + struct rx_pkt_attrib *pattrib = &rframe->attrib; + struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (padapter->registrypriv.mp_mode == 1) { + if (pattrib->crc_err == 1) + padapter->mppriv.rx_crcerrpktcount++; + else + padapter->mppriv.rx_pktcount++; + + if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_alert_, ("MP - Not in loopback mode , drop pkt\n")); + ret = _FAIL; + rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ + goto exit; + } + } + + /* check the frame crtl field and decache */ + ret = validate_recv_frame(padapter, rframe); + if (ret != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n")); + rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ + goto exit; + } + +exit: + return ret; +} + +static int recv_func_posthandle(struct adapter *padapter, struct recv_frame *prframe) +{ + int ret = _SUCCESS; + struct recv_frame *orig_prframe = prframe; + struct recv_priv *precvpriv = &padapter->recvpriv; + struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + + /* DATA FRAME */ + rtw_led_control(padapter, LED_CTL_RX); + + prframe = decryptor(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decryptor: drop pkt\n")); + ret = _FAIL; + goto _recv_data_drop; + } + + prframe = recvframe_chk_defrag(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chk_defrag: drop pkt\n")); + goto _recv_data_drop; + } + + prframe = portctrl(padapter, prframe); + if (prframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n")); + ret = _FAIL; + goto _recv_data_drop; + } + + count_rx_stats(padapter, prframe, NULL); + + ret = process_recv_indicatepkts(padapter, prframe); + if (ret != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recv_func: process_recv_indicatepkts fail!\n")); + rtw_free_recvframe(orig_prframe, pfree_recv_queue);/* free this recv_frame */ + goto _recv_data_drop; + } + return ret; + +_recv_data_drop: + precvpriv->rx_drop++; + return ret; +} + +static int recv_func(struct adapter *padapter, struct recv_frame *rframe) +{ + int ret; + struct rx_pkt_attrib *prxattrib = &rframe->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *mlmepriv = &padapter->mlmepriv; + struct recv_priv *recvpriv = &padapter->recvpriv; + + /* check if need to handle uc_swdec_pending_queue*/ + if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && + psecuritypriv->busetkipkey) { + struct recv_frame *pending_frame; + int cnt = 0; + + pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue); + while (pending_frame) { + cnt++; + recv_func_posthandle(padapter, pending_frame); + } + } + + ret = recv_func_prehandle(padapter, rframe); + + if (ret == _SUCCESS) { + /* check if need to enqueue into uc_swdec_pending_queue*/ + if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && + !IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 && + (prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt) && + psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK && + !psecuritypriv->busetkipkey) { + rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue); + DBG_88E("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); + if (recvpriv->free_recvframe_cnt < NR_RECVFRAME/4) { + /* to prevent from recvframe starvation, + * get recvframe from uc_swdec_pending_queue to + * free_recvframe_cnt */ + rframe = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue); + if (rframe) + goto do_posthandle; + } + goto exit; + } +do_posthandle: + ret = recv_func_posthandle(padapter, rframe); + } + +exit: + return ret; +} + +s32 rtw_recv_entry(struct recv_frame *precvframe) +{ + struct adapter *padapter; + struct recv_priv *precvpriv; + s32 ret = _SUCCESS; + + padapter = precvframe->adapter; + + precvpriv = &padapter->recvpriv; + + ret = recv_func(padapter, precvframe); + if (ret == _FAIL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("rtw_recv_entry: recv_func return fail!!!\n")); + goto _recv_entry_drop; + } + + precvpriv->rx_pkts++; + + return ret; + +_recv_entry_drop: + + if (padapter->registrypriv.mp_mode == 1) + padapter->mppriv.rx_pktloss = precvpriv->rx_drop; + + return ret; +} + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +void rtw_signal_stat_timer_hdl(struct timer_list *t) +#else +void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) +#endif +{ +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = from_timer(adapter, t, recvpriv.signal_stat_timer); +#else + struct adapter *adapter = (struct adapter *)FunctionContext; +#endif + struct recv_priv *recvpriv = &adapter->recvpriv; + + u32 tmp_s, tmp_q; + u8 avg_signal_strength = 0; + u8 avg_signal_qual = 0; + u8 _alpha = 3; /* this value is based on converging_constant = 5000 and sampling_interval = 1000 */ + + if (adapter->recvpriv.is_signal_dbg) { + /* update the user specific value, signal_strength_dbg, to signal_strength, rssi */ + adapter->recvpriv.signal_strength = adapter->recvpriv.signal_strength_dbg; + adapter->recvpriv.rssi = (s8)translate_percentage_to_dbm((u8)adapter->recvpriv.signal_strength_dbg); + } else { + if (recvpriv->signal_strength_data.update_req == 0) {/* update_req is clear, means we got rx */ + avg_signal_strength = recvpriv->signal_strength_data.avg_val; + /* after avg_vals are accquired, we can re-stat the signal values */ + recvpriv->signal_strength_data.update_req = 1; + } + + if (recvpriv->signal_qual_data.update_req == 0) {/* update_req is clear, means we got rx */ + avg_signal_qual = recvpriv->signal_qual_data.avg_val; + /* after avg_vals are accquired, we can re-stat the signal values */ + recvpriv->signal_qual_data.update_req = 1; + } + + /* update value of signal_strength, rssi, signal_qual */ + if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == false) { + tmp_s = (avg_signal_strength+(_alpha-1)*recvpriv->signal_strength); + if (tmp_s % _alpha) + tmp_s = tmp_s/_alpha + 1; + else + tmp_s = tmp_s/_alpha; + if (tmp_s > 100) + tmp_s = 100; + + tmp_q = (avg_signal_qual+(_alpha-1)*recvpriv->signal_qual); + if (tmp_q % _alpha) + tmp_q = tmp_q/_alpha + 1; + else + tmp_q = tmp_q/_alpha; + if (tmp_q > 100) + tmp_q = 100; + + recvpriv->signal_strength = tmp_s; + recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s); + recvpriv->signal_qual = tmp_q; + } + } + rtw_set_signal_stat_timer(recvpriv); +} diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c new file mode 100644 index 000000000000..40c0f5aa0731 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_rf.c @@ -0,0 +1,88 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_RF_C_ + +#include +#include +#include +#include + +struct ch_freq { + u32 channel; + u32 frequency; +}; + +static struct ch_freq ch_freq_map[] = { + {1, 2412}, {2, 2417}, {3, 2422}, {4, 2427}, {5, 2432}, + {6, 2437}, {7, 2442}, {8, 2447}, {9, 2452}, {10, 2457}, + {11, 2462}, {12, 2467}, {13, 2472}, {14, 2484}, + /* UNII */ + {36, 5180}, {40, 5200}, {44, 5220}, {48, 5240}, {52, 5260}, + {56, 5280}, {60, 5300}, {64, 5320}, {149, 5745}, {153, 5765}, + {157, 5785}, {161, 5805}, {165, 5825}, {167, 5835}, {169, 5845}, + {171, 5855}, {173, 5865}, + /* HiperLAN2 */ + {100, 5500}, {104, 5520}, {108, 5540}, {112, 5560}, {116, 5580}, + {120, 5600}, {124, 5620}, {128, 5640}, {132, 5660}, {136, 5680}, + {140, 5700}, + /* Japan MMAC */ + {34, 5170}, {38, 5190}, {42, 5210}, {46, 5230}, + /* Japan */ + {184, 4920}, {188, 4940}, {192, 4960}, {196, 4980}, + {208, 5040},/* Japan, means J08 */ + {212, 5060},/* Japan, means J12 */ + {216, 5080},/* Japan, means J16 */ +}; + +static int ch_freq_map_num = (sizeof(ch_freq_map) / sizeof(struct ch_freq)); + +u32 rtw_ch2freq(u32 channel) +{ + u8 i; + u32 freq = 0; + + for (i = 0; i < ch_freq_map_num; i++) { + if (channel == ch_freq_map[i].channel) { + freq = ch_freq_map[i].frequency; + break; + } + } + if (i == ch_freq_map_num) + freq = 2412; + + return freq; +} + +u32 rtw_freq2ch(u32 freq) +{ + u8 i; + u32 ch = 0; + + for (i = 0; i < ch_freq_map_num; i++) { + if (freq == ch_freq_map[i].frequency) { + ch = ch_freq_map[i].channel; + break; + } + } + if (i == ch_freq_map_num) + ch = 1; + + return ch; +} diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c new file mode 100644 index 000000000000..1da908694e18 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -0,0 +1,1757 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_SECURITY_C_ + +#include +#include +#include +#include + +/* WEP related ===== */ + +#define CRC32_POLY 0x04c11db7 + +struct arc4context { + u32 x; + u32 y; + u8 state[256]; +}; + +static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) +{ + u32 t, u; + u32 keyindex; + u32 stateindex; + u8 *state; + u32 counter; + + state = parc4ctx->state; + parc4ctx->x = 0; + parc4ctx->y = 0; + for (counter = 0; counter < 256; counter++) + state[counter] = (u8)counter; + keyindex = 0; + stateindex = 0; + for (counter = 0; counter < 256; counter++) { + t = state[counter]; + stateindex = (stateindex + key[keyindex] + t) & 0xff; + u = state[stateindex]; + state[stateindex] = (u8)t; + state[counter] = (u8)u; + if (++keyindex >= key_len) + keyindex = 0; + } + +} + +static u32 arcfour_byte(struct arc4context *parc4ctx) +{ + u32 x; + u32 y; + u32 sx, sy; + u8 *state; + + state = parc4ctx->state; + x = (parc4ctx->x + 1) & 0xff; + sx = state[x]; + y = (sx + parc4ctx->y) & 0xff; + sy = state[y]; + parc4ctx->x = x; + parc4ctx->y = y; + state[y] = (u8)sx; + state[x] = (u8)sy; + + return state[(sx + sy) & 0xff]; +} + +static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) +{ + u32 i; + + for (i = 0; i < len; i++) + dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); + +} + +static int bcrc32initialized; +static u32 crc32_table[256]; + +static u8 crc32_reverseBit(u8 data) +{ + return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | + ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | + ((data>>5)&0x02) | ((data>>7)&0x01); +} + +static void crc32_init(void) +{ + if (bcrc32initialized == 1) { + return; + } else { + int i, j; + u32 c; + u8 *p = (u8 *)&c, *p1; + u8 k; + + c = 0x12340000; + + for (i = 0; i < 256; ++i) { + k = crc32_reverseBit((u8)i); + for (c = ((u32)k) << 24, j = 8; j > 0; --j) + c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); + p1 = (u8 *)&crc32_table[i]; + + p1[0] = crc32_reverseBit(p[3]); + p1[1] = crc32_reverseBit(p[2]); + p1[2] = crc32_reverseBit(p[1]); + p1[3] = crc32_reverseBit(p[0]); + } + bcrc32initialized = 1; + } +} + +static __le32 getcrc32(u8 *buf, int len) +{ + u8 *p; + u32 crc; + + if (bcrc32initialized == 0) + crc32_init(); + + crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ + + for (p = buf; len > 0; ++p, --len) + crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); + + return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ +} + +/* + Need to consider the fragment situation +*/ +void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + + unsigned char crc[4]; + struct arc4context mycontext; + + int curfragnum, length; + u32 keylength; + + u8 *pframe, *payload, *iv; /* wepkey */ + u8 wepkey[16]; + u8 hw_hdr_offset = 0; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return; + + hw_hdr_offset = TXDESC_SIZE + + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* start to encrypt each fragment */ + if ((pattrib->encrypt == _WEP40_) || (pattrib->encrypt == _WEP104_)) { + keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex]; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + iv = pframe+pattrib->hdrlen; + memcpy(&wepkey[0], iv, 3); + memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); + payload = pframe+pattrib->iv_len+pattrib->hdrlen; + + if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + *((__le32 *)crc) = getcrc32(payload, length); + + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + *((__le32 *)crc) = getcrc32(payload, length); + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + + pframe += pxmitpriv->frag_len; + pframe = (u8 *)RND4((size_t)(pframe)); + } + } + } + +} + +void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) +{ + /* exclude ICV */ + u8 crc[4]; + struct arc4context mycontext; + int length; + u32 keylength; + u8 *pframe, *payload, *iv, wepkey[16]; + u8 keyindex; + struct rx_pkt_attrib *prxattrib = &(((struct recv_frame *)precvframe)->attrib); + struct security_priv *psecuritypriv = &padapter->securitypriv; + + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; + + /* start to decrypt recvframe */ + if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { + iv = pframe+prxattrib->hdrlen; + keyindex = prxattrib->key_index; + keylength = psecuritypriv->dot11DefKeylen[keyindex]; + memcpy(&wepkey[0], iv, 3); + memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; + + payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + + /* decrypt payload include icv */ + arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_encrypt(&mycontext, payload, payload, length); + + /* calculate icv and compare the icv */ + *((__le32 *)crc) = getcrc32(payload, length - 4); + + if (crc[3] != payload[length-1] || + crc[2] != payload[length-2] || + crc[1] != payload[length-3] || + crc[0] != payload[length-4]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", + &crc, &payload[length-4])); + } + } + + return; +} + +/* 3 ===== TKIP related ===== */ + +static u32 secmicgetuint32(u8 *p) +/* Convert from Byte[] to Us3232 in a portable way */ +{ + s32 i; + u32 res = 0; + + for (i = 0; i < 4; i++) + res |= ((u32)(*p++)) << (8*i); + + return res; +} + +static void secmicputuint32(u8 *p, u32 val) +/* Convert from Us3232 to Byte[] in a portable way */ +{ + long i; + + for (i = 0; i < 4; i++) { + *p++ = (u8) (val & 0xff); + val >>= 8; + } + +} + +static void secmicclear(struct mic_data *pmicdata) +{ +/* Reset the state to the empty message. */ + + pmicdata->L = pmicdata->K0; + pmicdata->R = pmicdata->K1; + pmicdata->nBytesInM = 0; + pmicdata->M = 0; + +} + +void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) +{ + /* Set the key */ + + pmicdata->K0 = secmicgetuint32(key); + pmicdata->K1 = secmicgetuint32(key + 4); + /* and reset the message */ + secmicclear(pmicdata); + +} + +void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) +{ + + /* Append the byte to our word-sized buffer */ + pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); + pmicdata->nBytesInM++; + /* Process the word if it is full. */ + if (pmicdata->nBytesInM >= 4) { + pmicdata->L ^= pmicdata->M; + pmicdata->R ^= ROL32(pmicdata->L, 17); + pmicdata->L += pmicdata->R; + pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) | ((pmicdata->L & 0x00ff00ff) << 8); + pmicdata->L += pmicdata->R; + pmicdata->R ^= ROL32(pmicdata->L, 3); + pmicdata->L += pmicdata->R; + pmicdata->R ^= ROR32(pmicdata->L, 2); + pmicdata->L += pmicdata->R; + /* Clear the buffer */ + pmicdata->M = 0; + pmicdata->nBytesInM = 0; + } + +} + +void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes) +{ + + /* This is simple */ + while (nbytes > 0) { + rtw_secmicappendbyte(pmicdata, *src++); + nbytes--; + } + +} + +void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) +{ + + /* Append the minimum padding */ + rtw_secmicappendbyte(pmicdata, 0x5a); + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + rtw_secmicappendbyte(pmicdata, 0); + /* and then zeroes until the length is a multiple of 4 */ + while (pmicdata->nBytesInM != 0) + rtw_secmicappendbyte(pmicdata, 0); + /* The appendByte function has already computed the result. */ + secmicputuint32(dst, pmicdata->L); + secmicputuint32(dst+4, pmicdata->R); + /* Reset to the empty message. */ + secmicclear(pmicdata); + +} + +void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) +{ + struct mic_data micdata; + u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; + + rtw_secmicsetkey(&micdata, key); + priority[0] = pri; + + /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ + if (header[1]&1) { /* ToDS == 1 */ + rtw_secmicappend(&micdata, &header[16], 6); /* DA */ + if (header[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &header[24], 6); + else + rtw_secmicappend(&micdata, &header[10], 6); + } else { /* ToDS == 0 */ + rtw_secmicappend(&micdata, &header[4], 6); /* DA */ + if (header[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &header[16], 6); + else + rtw_secmicappend(&micdata, &header[10], 6); + } + rtw_secmicappend(&micdata, &priority[0], 4); + + rtw_secmicappend(&micdata, data, data_len); + + rtw_secgetmic(&micdata, mic_code); + +} + +/* macros for extraction/creation of unsigned char/unsigned short values */ +#define RotR1(v16) ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15)) +#define Lo8(v16) ((u8)((v16) & 0x00FF)) +#define Hi8(v16) ((u8)(((v16) >> 8) & 0x00FF)) +#define Lo16(v32) ((u16)((v32) & 0xFFFF)) +#define Hi16(v32) ((u16)(((v32) >> 16) & 0xFFFF)) +#define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8)) + +/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ +#define TK16(N) Mk16(tk[2*(N)+1], tk[2*(N)]) + +/* S-box lookup: 16 bits --> 16 bits */ +#define _S_(v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)]) + +/* fixed algorithm "parameters" */ +#define PHASE1_LOOP_CNT 8 /* this needs to be "big enough" */ +#define TA_SIZE 6 /* 48-bit transmitter address */ +#define TK_SIZE 16 /* 128-bit temporal key */ +#define P1K_SIZE 10 /* 80-bit Phase1 key */ +#define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ + +/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ +static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ +{ + 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, + 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, + 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, + 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, + 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, + 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, + 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, + 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, + 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, + 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, + 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, + 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, + 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, + 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, + 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, + 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, + 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, + 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, + 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, + 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, + 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, + 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, + 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, + 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, + 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, + 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, + 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, + 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, + 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, + 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, + 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, + 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, + }, + + { /* second half of table is unsigned char-reversed version of first! */ + 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, + 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, + 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, + 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, + 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, + 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, + 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, + 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, + 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, + 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, + 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, + 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, + 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, + 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, + 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, + 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, + 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, + 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, + 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, + 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, + 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, + 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, + 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, + 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, + 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, + 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, + 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, + 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, + 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, + 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, + 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, + 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, + } +}; + + /* +********************************************************************** +* Routine: Phase 1 -- generate P1K, given TA, TK, IV32 +* +* Inputs: +* tk[] = temporal key [128 bits] +* ta[] = transmitter's MAC address [ 48 bits] +* iv32 = upper 32 bits of IV [ 32 bits] +* Output: +* p1k[] = Phase 1 key [ 80 bits] +* +* Note: +* This function only needs to be called every 2**16 packets, +* although in theory it could be called every packet. +* +********************************************************************** +*/ +static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) +{ + int i; + + /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ + p1k[0] = Lo16(iv32); + p1k[1] = Hi16(iv32); + p1k[2] = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */ + p1k[3] = Mk16(ta[3], ta[2]); + p1k[4] = Mk16(ta[5], ta[4]); + + /* Now compute an unbalanced Feistel cipher with 80-bit block */ + /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ + for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ + p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); + p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); + p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); + p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); + p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); + p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ + } + +} + +/* +********************************************************************** +* Routine: Phase 2 -- generate RC4KEY, given TK, P1K, IV16 +* +* Inputs: +* tk[] = Temporal key [128 bits] +* p1k[] = Phase 1 output key [ 80 bits] +* iv16 = low 16 bits of IV counter [ 16 bits] +* Output: +* rc4key[] = the key used to encrypt the packet [128 bits] +* +* Note: +* The value {TA, IV32, IV16} for Phase1/Phase2 must be unique +* across all packets using the same key TK value. Then, for a +* given value of TK[], this TKIP48 construction guarantees that +* the final RC4KEY value is unique across all packets. +* +* Suggested implementation optimization: if PPK[] is "overlaid" +* appropriately on RC4KEY[], there is no need for the final +* for loop below that copies the PPK[] result into RC4KEY[]. +* +********************************************************************** +*/ +static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) +{ + int i; + u16 PPK[6]; /* temporary key for mixing */ + + /* Note: all adds in the PPK[] equations below are mod 2**16 */ + for (i = 0; i < 5; i++) + PPK[i] = p1k[i]; /* first, copy P1K to PPK */ + PPK[5] = p1k[4] + iv16; /* next, add in IV16 */ + + /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ + PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ + PPK[1] += _S_(PPK[0] ^ TK16(1)); + PPK[2] += _S_(PPK[1] ^ TK16(2)); + PPK[3] += _S_(PPK[2] ^ TK16(3)); + PPK[4] += _S_(PPK[3] ^ TK16(4)); + PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */ + + /* Final sweep: bijective, "linear". Rotates kill LSB correlations */ + PPK[0] += RotR1(PPK[5] ^ TK16(6)); + PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */ + PPK[2] += RotR1(PPK[1]); + PPK[3] += RotR1(PPK[2]); + PPK[4] += RotR1(PPK[3]); + PPK[5] += RotR1(PPK[4]); + /* Note: At this point, for a given key TK[0..15], the 96-bit output */ + /* value PPK[0..5] is guaranteed to be unique, as a function */ + /* of the 96-bit "input" value {TA, IV32, IV16}. That is, P1K */ + /* is now a keyed permutation of {TA, IV32, IV16}. */ + + /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */ + rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */ + rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ + rc4key[2] = Lo8(iv16); + rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); + + /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ + for (i = 0; i < 6; i++) { + rc4key[4+2*i] = Lo8(PPK[i]); + rc4key[5+2*i] = Hi8(PPK[i]); + } + +} + +/* The hlen isn't include the IV */ +u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + u16 pnl; + u32 pnh; + u8 rc4key[16]; + u8 ttkey[16]; + u8 crc[4]; + u8 hw_hdr_offset = 0; + struct arc4context mycontext; + int curfragnum, length; + + u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; + struct sta_info *stainfo; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u32 res = _SUCCESS; + + if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return _FAIL; + + hw_hdr_offset = TXDESC_SIZE + + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + /* 4 start to encrypt each fragment */ + if (pattrib->encrypt == _TKIP_) { + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); + + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(pattrib->ra)) + prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + iv = pframe+pattrib->hdrlen; + payload = pframe+pattrib->iv_len+pattrib->hdrlen; + + GET_TKIP_PN(iv, dot11txpn); + + pnl = (u16)(dot11txpn.val); + pnh = (u32)(dot11txpn.val>>16); + phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); + phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); + + if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + RT_TRACE(_module_rtl871x_security_c_, _drv_info_, + ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", + pattrib->iv_len, pattrib->icv_len)); + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + arcfour_encrypt(&mycontext, payload+length, crc, 4); + + pframe += pxmitpriv->frag_len; + pframe = (u8 *)RND4((size_t)(pframe)); + } + } + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } + + return res; +} + +/* The hlen isn't include the IV */ +u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) +{ /* exclude ICV */ + u16 pnl; + u32 pnh; + u8 rc4key[16]; + u8 ttkey[16]; + u8 crc[4]; + struct arc4context mycontext; + int length; + + u8 *pframe, *payload, *iv, *prwskey; + union pn48 dot11txpn; + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 res = _SUCCESS; + + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; + + /* 4 start to decrypt recvframe */ + if (prxattrib->encrypt == _TKIP_) { + stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); + if (stainfo != NULL) { + if (IS_MCAST(prxattrib->ra)) { + if (!psecuritypriv->binstallGrpkey) { + res = _FAIL; + DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); + goto exit; + } + prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo!= NULL!!!\n")); + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + } + + iv = pframe+prxattrib->hdrlen; + payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; + + GET_TKIP_PN(iv, dot11txpn); + + pnl = (u16)(dot11txpn.val); + pnh = (u32)(dot11txpn.val>>16); + + phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh); + phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl); + + /* 4 decrypt payload include icv */ + + arcfour_init(&mycontext, rc4key, 16); + arcfour_encrypt(&mycontext, payload, payload, length); + + *((__le32 *)crc) = getcrc32(payload, length-4); + + if (crc[3] != payload[length-1] || + crc[2] != payload[length-2] || + crc[1] != payload[length-3] || + crc[0] != payload[length-4]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", + &crc, &payload[length-4])); + res = _FAIL; + } + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } + +exit: + return res; +} + +/* 3 ===== AES related ===== */ + +#define MAX_MSG_SIZE 2048 +/*****************************/ +/******** SBOX Table *********/ +/*****************************/ + +static u8 sbox_table[256] = { + 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, + 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, + 0xca, 0x82, 0xc9, 0x7d, 0xfa, 0x59, 0x47, 0xf0, + 0xad, 0xd4, 0xa2, 0xaf, 0x9c, 0xa4, 0x72, 0xc0, + 0xb7, 0xfd, 0x93, 0x26, 0x36, 0x3f, 0xf7, 0xcc, + 0x34, 0xa5, 0xe5, 0xf1, 0x71, 0xd8, 0x31, 0x15, + 0x04, 0xc7, 0x23, 0xc3, 0x18, 0x96, 0x05, 0x9a, + 0x07, 0x12, 0x80, 0xe2, 0xeb, 0x27, 0xb2, 0x75, + 0x09, 0x83, 0x2c, 0x1a, 0x1b, 0x6e, 0x5a, 0xa0, + 0x52, 0x3b, 0xd6, 0xb3, 0x29, 0xe3, 0x2f, 0x84, + 0x53, 0xd1, 0x00, 0xed, 0x20, 0xfc, 0xb1, 0x5b, + 0x6a, 0xcb, 0xbe, 0x39, 0x4a, 0x4c, 0x58, 0xcf, + 0xd0, 0xef, 0xaa, 0xfb, 0x43, 0x4d, 0x33, 0x85, + 0x45, 0xf9, 0x02, 0x7f, 0x50, 0x3c, 0x9f, 0xa8, + 0x51, 0xa3, 0x40, 0x8f, 0x92, 0x9d, 0x38, 0xf5, + 0xbc, 0xb6, 0xda, 0x21, 0x10, 0xff, 0xf3, 0xd2, + 0xcd, 0x0c, 0x13, 0xec, 0x5f, 0x97, 0x44, 0x17, + 0xc4, 0xa7, 0x7e, 0x3d, 0x64, 0x5d, 0x19, 0x73, + 0x60, 0x81, 0x4f, 0xdc, 0x22, 0x2a, 0x90, 0x88, + 0x46, 0xee, 0xb8, 0x14, 0xde, 0x5e, 0x0b, 0xdb, + 0xe0, 0x32, 0x3a, 0x0a, 0x49, 0x06, 0x24, 0x5c, + 0xc2, 0xd3, 0xac, 0x62, 0x91, 0x95, 0xe4, 0x79, + 0xe7, 0xc8, 0x37, 0x6d, 0x8d, 0xd5, 0x4e, 0xa9, + 0x6c, 0x56, 0xf4, 0xea, 0x65, 0x7a, 0xae, 0x08, + 0xba, 0x78, 0x25, 0x2e, 0x1c, 0xa6, 0xb4, 0xc6, + 0xe8, 0xdd, 0x74, 0x1f, 0x4b, 0xbd, 0x8b, 0x8a, + 0x70, 0x3e, 0xb5, 0x66, 0x48, 0x03, 0xf6, 0x0e, + 0x61, 0x35, 0x57, 0xb9, 0x86, 0xc1, 0x1d, 0x9e, + 0xe1, 0xf8, 0x98, 0x11, 0x69, 0xd9, 0x8e, 0x94, + 0x9b, 0x1e, 0x87, 0xe9, 0xce, 0x55, 0x28, 0xdf, + 0x8c, 0xa1, 0x89, 0x0d, 0xbf, 0xe6, 0x42, 0x68, + 0x41, 0x99, 0x2d, 0x0f, 0xb0, 0x54, 0xbb, 0x16 +}; + +/*****************************/ +/**** Function Prototypes ****/ +/*****************************/ + +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out); +static void construct_mic_iv(u8 *mic_header1, int qc_exists, int a4_exists, u8 *mpdu, uint payload_length, u8 *pn_vector); +static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu); +static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists); +static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c); +static void xor_128(u8 *a, u8 *b, u8 *out); +static void xor_32(u8 *a, u8 *b, u8 *out); +static u8 sbox(u8 a); +static void next_key(u8 *key, int round); +static void byte_sub(u8 *in, u8 *out); +static void shift_row(u8 *in, u8 *out); +static void mix_column(u8 *in, u8 *out); +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext); + +/****************************************/ +/* aes128k128d() */ +/* Performs a 128 bit AES encrypt with */ +/* 128 bit data. */ +/****************************************/ +static void xor_128(u8 *a, u8 *b, u8 *out) +{ + int i; + + for (i = 0; i < 16; i++) + out[i] = a[i] ^ b[i]; + +} + +static void xor_32(u8 *a, u8 *b, u8 *out) +{ + int i; + + for (i = 0; i < 4; i++) + out[i] = a[i] ^ b[i]; + +} + +static u8 sbox(u8 a) +{ + return sbox_table[(int)a]; +} + +static void next_key(u8 *key, int round) +{ + u8 rcon; + u8 sbox_key[4]; + u8 rcon_table[12] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, + 0x1b, 0x36, 0x36, 0x36 + }; + + sbox_key[0] = sbox(key[13]); + sbox_key[1] = sbox(key[14]); + sbox_key[2] = sbox(key[15]); + sbox_key[3] = sbox(key[12]); + + rcon = rcon_table[round]; + + xor_32(&key[0], sbox_key, &key[0]); + key[0] = key[0] ^ rcon; + + xor_32(&key[4], &key[0], &key[4]); + xor_32(&key[8], &key[4], &key[8]); + xor_32(&key[12], &key[8], &key[12]); + +} + +static void byte_sub(u8 *in, u8 *out) +{ + int i; + + for (i = 0; i < 16; i++) + out[i] = sbox(in[i]); + +} + +static void shift_row(u8 *in, u8 *out) +{ + + out[0] = in[0]; + out[1] = in[5]; + out[2] = in[10]; + out[3] = in[15]; + out[4] = in[4]; + out[5] = in[9]; + out[6] = in[14]; + out[7] = in[3]; + out[8] = in[8]; + out[9] = in[13]; + out[10] = in[2]; + out[11] = in[7]; + out[12] = in[12]; + out[13] = in[1]; + out[14] = in[6]; + out[15] = in[11]; + +} + +static void mix_column(u8 *in, u8 *out) +{ + int i; + u8 add1b[4]; + u8 add1bf7[4]; + u8 rotl[4]; + u8 swap_halfs[4]; + u8 andf7[4]; + u8 rotr[4]; + u8 temp[4]; + u8 tempb[4]; + + for (i = 0 ; i < 4; i++) { + if ((in[i] & 0x80) == 0x80) + add1b[i] = 0x1b; + else + add1b[i] = 0x00; + } + + swap_halfs[0] = in[2]; /* Swap halves */ + swap_halfs[1] = in[3]; + swap_halfs[2] = in[0]; + swap_halfs[3] = in[1]; + + rotl[0] = in[3]; /* Rotate left 8 bits */ + rotl[1] = in[0]; + rotl[2] = in[1]; + rotl[3] = in[2]; + + andf7[0] = in[0] & 0x7f; + andf7[1] = in[1] & 0x7f; + andf7[2] = in[2] & 0x7f; + andf7[3] = in[3] & 0x7f; + + for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ + andf7[i] = andf7[i] << 1; + if ((andf7[i-1] & 0x80) == 0x80) + andf7[i] = (andf7[i] | 0x01); + } + andf7[0] = andf7[0] << 1; + andf7[0] = andf7[0] & 0xfe; + + xor_32(add1b, andf7, add1bf7); + + xor_32(in, add1bf7, rotr); + + temp[0] = rotr[0]; /* Rotate right 8 bits */ + rotr[0] = rotr[1]; + rotr[1] = rotr[2]; + rotr[2] = rotr[3]; + rotr[3] = temp[0]; + + xor_32(add1bf7, rotr, temp); + xor_32(swap_halfs, rotl, tempb); + xor_32(temp, tempb, out); + +} + +static void aes128k128d(u8 *key, u8 *data, u8 *ciphertext) +{ + int round; + int i; + u8 intermediatea[16]; + u8 intermediateb[16]; + u8 round_key[16]; + + for (i = 0; i < 16; i++) + round_key[i] = key[i]; + for (round = 0; round < 11; round++) { + if (round == 0) { + xor_128(round_key, data, ciphertext); + next_key(round_key, round); + } else if (round == 10) { + byte_sub(ciphertext, intermediatea); + shift_row(intermediatea, intermediateb); + xor_128(intermediateb, round_key, ciphertext); + } else { /* 1 - 9 */ + byte_sub(ciphertext, intermediatea); + shift_row(intermediatea, intermediateb); + mix_column(&intermediateb[0], &intermediatea[0]); + mix_column(&intermediateb[4], &intermediatea[4]); + mix_column(&intermediateb[8], &intermediatea[8]); + mix_column(&intermediateb[12], &intermediatea[12]); + xor_128(intermediatea, round_key, ciphertext); + next_key(round_key, round); + } + } + +} + +/************************************************/ +/* construct_mic_iv() */ +/* Builds the MIC IV from header fields and PN */ +/************************************************/ +static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, + uint payload_length, u8 *pn_vector) +{ + int i; + + mic_iv[0] = 0x59; + if (qc_exists && a4_exists) + mic_iv[1] = mpdu[30] & 0x0f; /* QoS_TC */ + if (qc_exists && !a4_exists) + mic_iv[1] = mpdu[24] & 0x0f; /* mute bits 7-4 */ + if (!qc_exists) + mic_iv[1] = 0x00; + for (i = 2; i < 8; i++) + mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ + for (i = 8; i < 14; i++) + mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ + mic_iv[14] = (unsigned char) (payload_length / 256); + mic_iv[15] = (unsigned char) (payload_length % 256); + +} + +/************************************************/ +/* construct_mic_header1() */ +/* Builds the first MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_mic_header1(u8 *mic_header1, int header_length, u8 *mpdu) +{ + + mic_header1[0] = (u8)((header_length - 2) / 256); + mic_header1[1] = (u8)((header_length - 2) % 256); + mic_header1[2] = mpdu[0] & 0xcf; /* Mute CF poll & CF ack bits */ + mic_header1[3] = mpdu[1] & 0xc7; /* Mute retry, more data and pwr mgt bits */ + mic_header1[4] = mpdu[4]; /* A1 */ + mic_header1[5] = mpdu[5]; + mic_header1[6] = mpdu[6]; + mic_header1[7] = mpdu[7]; + mic_header1[8] = mpdu[8]; + mic_header1[9] = mpdu[9]; + mic_header1[10] = mpdu[10]; /* A2 */ + mic_header1[11] = mpdu[11]; + mic_header1[12] = mpdu[12]; + mic_header1[13] = mpdu[13]; + mic_header1[14] = mpdu[14]; + mic_header1[15] = mpdu[15]; + +} + +/************************************************/ +/* construct_mic_header2() */ +/* Builds the last MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int qc_exists) +{ + int i; + + for (i = 0; i < 16; i++) + mic_header2[i] = 0x00; + + mic_header2[0] = mpdu[16]; /* A3 */ + mic_header2[1] = mpdu[17]; + mic_header2[2] = mpdu[18]; + mic_header2[3] = mpdu[19]; + mic_header2[4] = mpdu[20]; + mic_header2[5] = mpdu[21]; + + mic_header2[6] = 0x00; + mic_header2[7] = 0x00; /* mpdu[23]; */ + + if (!qc_exists && a4_exists) { + for (i = 0; i < 6; i++) + mic_header2[8+i] = mpdu[24+i]; /* A4 */ + } + + if (qc_exists && !a4_exists) { + mic_header2[8] = mpdu[24] & 0x0f; /* mute bits 15 - 4 */ + mic_header2[9] = mpdu[25] & 0x00; + } + + if (qc_exists && a4_exists) { + for (i = 0; i < 6; i++) + mic_header2[8+i] = mpdu[24+i]; /* A4 */ + + mic_header2[14] = mpdu[30] & 0x0f; + mic_header2[15] = mpdu[31] & 0x00; + } + +} + +/************************************************/ +/* construct_mic_header2() */ +/* Builds the last MIC header block from */ +/* header fields. */ +/************************************************/ +static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, u8 *mpdu, u8 *pn_vector, int c) +{ + int i; + + for (i = 0; i < 16; i++) + ctr_preload[i] = 0x00; + i = 0; + + ctr_preload[0] = 0x01; /* flag */ + if (qc_exists && a4_exists) + ctr_preload[1] = mpdu[30] & 0x0f; /* QoC_Control */ + if (qc_exists && !a4_exists) + ctr_preload[1] = mpdu[24] & 0x0f; + + for (i = 2; i < 8; i++) + ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ + for (i = 8; i < 14; i++) + ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ + ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ + ctr_preload[15] = (unsigned char) (c % 256); + +} + +/************************************/ +/* bitwise_xor() */ +/* A 128 bit, bitwise exclusive or */ +/************************************/ +static void bitwise_xor(u8 *ina, u8 *inb, u8 *out) +{ + int i; + + for (i = 0; i < 16; i++) + out[i] = ina[i] ^ inb[i]; + +} + +static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) +{ + uint qc_exists, a4_exists, i, j, payload_remainder, + num_blocks, payload_index; + + u8 pn_vector[6]; + u8 mic_iv[16]; + u8 mic_header1[16]; + u8 mic_header2[16]; + u8 ctr_preload[16]; + + /* Intermediate Buffers */ + u8 chain_buffer[16]; + u8 aes_out[16]; + u8 padded_buffer[16]; + u8 mic[8]; + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); + + frsubtype = frsubtype>>4; + + memset((void *)mic_iv, 0, 16); + memset((void *)mic_header1, 0, 16); + memset((void *)mic_header2, 0, 16); + memset((void *)ctr_preload, 0, 16); + memset((void *)chain_buffer, 0, 16); + memset((void *)aes_out, 0, 16); + memset((void *)padded_buffer, 0, 16); + + if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || (frtype == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || (frsubtype == 0x0a) || (frsubtype == 0x0b)) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + qc_exists = 1; + } else { + qc_exists = 0; + } + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + + construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); + + construct_mic_header1(mic_header1, hdrlen, pframe); + construct_mic_header2(mic_header2, pframe, a4_exists, qc_exists); + + payload_remainder = plen % 16; + num_blocks = plen / 16; + + /* Find start of payload */ + payload_index = (hdrlen + 8); + + /* Calculate MIC */ + aes128k128d(key, mic_iv, aes_out); + bitwise_xor(aes_out, mic_header1, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + bitwise_xor(aes_out, mic_header2, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + + for (i = 0; i < num_blocks; i++) { + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer);/* bitwise_xor(aes_out, &message[payload_index], chain_buffer); */ + + payload_index += 16; + aes128k128d(key, chain_buffer, aes_out); + } + + /* Add on the final payload block if it needs padding */ + if (payload_remainder > 0) { + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index++];/* padded_buffer[j] = message[payload_index++]; */ + bitwise_xor(aes_out, padded_buffer, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + } + + for (j = 0; j < 8; j++) + mic[j] = aes_out[j]; + + /* Insert MIC into payload */ + for (j = 0; j < 8; j++) + pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + + payload_index = hdrlen + 8; + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + for (j = 0; j < 16; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + pframe[payload_index++] = chain_buffer[j]; + } + /* Encrypt the MIC */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, 0); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < 8; j++) + padded_buffer[j] = pframe[j+hdrlen+8+plen]; + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < 8; j++) + pframe[payload_index++] = chain_buffer[j]; + + return _SUCCESS; +} + +u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) +{ /* exclude ICV */ + + /*static*/ +/* unsigned char message[MAX_MSG_SIZE]; */ + + /* Intermediate Buffers */ + int curfragnum, length; + u8 *pframe, *prwskey; /* *payload,*iv */ + u8 hw_hdr_offset = 0; + struct sta_info *stainfo; + struct pkt_attrib *pattrib = &((struct xmit_frame *)pxmitframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + +/* uint offset = 0; */ + u32 res = _SUCCESS; + + if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + return _FAIL; + + hw_hdr_offset = TXDESC_SIZE + + (((struct xmit_frame *)pxmitframe)->pkt_offset * PACKET_OFFSET_SZ); + + pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; + + /* 4 start to encrypt each fragment */ + if ((pattrib->encrypt == _AES_)) { + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); + + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(pattrib->ra)) + prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; + else + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); + } else{ + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + + aes_cipher(prwskey, pattrib->hdrlen, pframe, length); + pframe += pxmitpriv->frag_len; + pframe = (u8 *)RND4((size_t)(pframe)); + } + } + } else{ + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } + + return res; +} + +static int aes_decipher(u8 *key, uint hdrlen, + u8 *pframe, uint plen) +{ + static u8 message[MAX_MSG_SIZE]; + uint qc_exists, a4_exists, i, j, payload_remainder, + num_blocks, payload_index; + int res = _SUCCESS; + u8 pn_vector[6]; + u8 mic_iv[16]; + u8 mic_header1[16]; + u8 mic_header2[16]; + u8 ctr_preload[16]; + + /* Intermediate Buffers */ + u8 chain_buffer[16]; + u8 aes_out[16]; + u8 padded_buffer[16]; + u8 mic[8]; + +/* uint offset = 0; */ + uint frtype = GetFrameType(pframe); + uint frsubtype = GetFrameSubType(pframe); + + frsubtype = frsubtype>>4; + + memset((void *)mic_iv, 0, 16); + memset((void *)mic_header1, 0, 16); + memset((void *)mic_header2, 0, 16); + memset((void *)ctr_preload, 0, 16); + memset((void *)chain_buffer, 0, 16); + memset((void *)aes_out, 0, 16); + memset((void *)padded_buffer, 0, 16); + + /* start to decrypt the payload */ + + num_blocks = (plen-8) / 16; /* plen including llc, payload_length and mic) */ + + payload_remainder = (plen-8) % 16; + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + + if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) + a4_exists = 0; + else + a4_exists = 1; + + if ((frtype == WIFI_DATA_CFACK) || (frtype == WIFI_DATA_CFPOLL) || + (frtype == WIFI_DATA_CFACKPOLL)) { + qc_exists = 1; + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + } else if ((frsubtype == 0x08) || (frsubtype == 0x09) || + (frsubtype == 0x0a) || (frsubtype == 0x0b)) { + if (hdrlen != WLAN_HDR_A3_QOS_LEN) + hdrlen += 2; + qc_exists = 1; + } else { + qc_exists = 0; + } + + /* now, decrypt pframe with hdrlen offset and plen long */ + + payload_index = hdrlen + 8; /* 8 is for extiv */ + + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); + + for (j = 0; j < 16; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = pframe[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + pframe[payload_index++] = chain_buffer[j]; + } + + /* start to calculate the mic */ + if ((hdrlen+plen+8) <= MAX_MSG_SIZE) + memcpy(message, pframe, (hdrlen + plen+8)); /* 8 is for ext iv len */ + + pn_vector[0] = pframe[hdrlen]; + pn_vector[1] = pframe[hdrlen+1]; + pn_vector[2] = pframe[hdrlen+4]; + pn_vector[3] = pframe[hdrlen+5]; + pn_vector[4] = pframe[hdrlen+6]; + pn_vector[5] = pframe[hdrlen+7]; + construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen-8, pn_vector); + + construct_mic_header1(mic_header1, hdrlen, message); + construct_mic_header2(mic_header2, message, a4_exists, qc_exists); + + payload_remainder = (plen-8) % 16; + num_blocks = (plen-8) / 16; + + /* Find start of payload */ + payload_index = (hdrlen + 8); + + /* Calculate MIC */ + aes128k128d(key, mic_iv, aes_out); + bitwise_xor(aes_out, mic_header1, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + bitwise_xor(aes_out, mic_header2, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + + for (i = 0; i < num_blocks; i++) { + bitwise_xor(aes_out, &message[payload_index], chain_buffer); + + payload_index += 16; + aes128k128d(key, chain_buffer, aes_out); + } + + /* Add on the final payload block if it needs padding */ + if (payload_remainder > 0) { + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = message[payload_index++]; + bitwise_xor(aes_out, padded_buffer, chain_buffer); + aes128k128d(key, chain_buffer, aes_out); + } + + for (j = 0 ; j < 8; j++) + mic[j] = aes_out[j]; + + /* Insert MIC into payload */ + for (j = 0; j < 8; j++) + message[payload_index+j] = mic[j]; + + payload_index = hdrlen + 8; + for (i = 0; i < num_blocks; i++) { + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, i+1); + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, &message[payload_index], chain_buffer); + for (j = 0; j < 16; j++) + message[payload_index++] = chain_buffer[j]; + } + + if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ + /* encrypt it and copy the unpadded part back */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, num_blocks+1); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < payload_remainder; j++) + padded_buffer[j] = message[payload_index+j]; + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < payload_remainder; j++) + message[payload_index++] = chain_buffer[j]; + } + + /* Encrypt the MIC */ + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, 0); + + for (j = 0; j < 16; j++) + padded_buffer[j] = 0x00; + for (j = 0; j < 8; j++) + padded_buffer[j] = message[j+hdrlen+8+plen-8]; + + aes128k128d(key, ctr_preload, aes_out); + bitwise_xor(aes_out, padded_buffer, chain_buffer); + for (j = 0; j < 8; j++) + message[payload_index++] = chain_buffer[j]; + + /* compare the mic */ + for (i = 0; i < 8; i++) { + if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, + ("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", + i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i])); + DBG_88E("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", + i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); + res = _FAIL; + } + } + + return res; +} + +u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) +{ /* exclude ICV */ + /* Intermediate Buffers */ + int length; + u8 *pframe, *prwskey; /* *payload,*iv */ + struct sta_info *stainfo; + struct rx_pkt_attrib *prxattrib = &((struct recv_frame *)precvframe)->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 res = _SUCCESS; + + pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; + /* 4 start to encrypt each fragment */ + if ((prxattrib->encrypt == _AES_)) { + stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); + if (stainfo != NULL) { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); + + if (IS_MCAST(prxattrib->ra)) { + /* in concurrent we should use sw descrypt in group key, so we remove this message */ + if (!psecuritypriv->binstallGrpkey) { + res = _FAIL; + DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); + goto exit; + } + prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; + if (psecuritypriv->dot118021XGrpKeyid != prxattrib->key_index) { + DBG_88E("not match packet_index=%d, install_index=%d\n", + prxattrib->key_index, psecuritypriv->dot118021XGrpKeyid); + res = _FAIL; + goto exit; + } + } else { + prwskey = &stainfo->dot118021x_UncstKey.skey[0]; + } + length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; + res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); + } else { + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); + res = _FAIL; + } + } + +exit: + return res; +} + +/* AES tables*/ +const u32 Te0[256] = { + 0xc66363a5U, 0xf87c7c84U, 0xee777799U, 0xf67b7b8dU, + 0xfff2f20dU, 0xd66b6bbdU, 0xde6f6fb1U, 0x91c5c554U, + 0x60303050U, 0x02010103U, 0xce6767a9U, 0x562b2b7dU, + 0xe7fefe19U, 0xb5d7d762U, 0x4dababe6U, 0xec76769aU, + 0x8fcaca45U, 0x1f82829dU, 0x89c9c940U, 0xfa7d7d87U, + 0xeffafa15U, 0xb25959ebU, 0x8e4747c9U, 0xfbf0f00bU, + 0x41adadecU, 0xb3d4d467U, 0x5fa2a2fdU, 0x45afafeaU, + 0x239c9cbfU, 0x53a4a4f7U, 0xe4727296U, 0x9bc0c05bU, + 0x75b7b7c2U, 0xe1fdfd1cU, 0x3d9393aeU, 0x4c26266aU, + 0x6c36365aU, 0x7e3f3f41U, 0xf5f7f702U, 0x83cccc4fU, + 0x6834345cU, 0x51a5a5f4U, 0xd1e5e534U, 0xf9f1f108U, + 0xe2717193U, 0xabd8d873U, 0x62313153U, 0x2a15153fU, + 0x0804040cU, 0x95c7c752U, 0x46232365U, 0x9dc3c35eU, + 0x30181828U, 0x379696a1U, 0x0a05050fU, 0x2f9a9ab5U, + 0x0e070709U, 0x24121236U, 0x1b80809bU, 0xdfe2e23dU, + 0xcdebeb26U, 0x4e272769U, 0x7fb2b2cdU, 0xea75759fU, + 0x1209091bU, 0x1d83839eU, 0x582c2c74U, 0x341a1a2eU, + 0x361b1b2dU, 0xdc6e6eb2U, 0xb45a5aeeU, 0x5ba0a0fbU, + 0xa45252f6U, 0x763b3b4dU, 0xb7d6d661U, 0x7db3b3ceU, + 0x5229297bU, 0xdde3e33eU, 0x5e2f2f71U, 0x13848497U, + 0xa65353f5U, 0xb9d1d168U, 0x00000000U, 0xc1eded2cU, + 0x40202060U, 0xe3fcfc1fU, 0x79b1b1c8U, 0xb65b5bedU, + 0xd46a6abeU, 0x8dcbcb46U, 0x67bebed9U, 0x7239394bU, + 0x944a4adeU, 0x984c4cd4U, 0xb05858e8U, 0x85cfcf4aU, + 0xbbd0d06bU, 0xc5efef2aU, 0x4faaaae5U, 0xedfbfb16U, + 0x864343c5U, 0x9a4d4dd7U, 0x66333355U, 0x11858594U, + 0x8a4545cfU, 0xe9f9f910U, 0x04020206U, 0xfe7f7f81U, + 0xa05050f0U, 0x783c3c44U, 0x259f9fbaU, 0x4ba8a8e3U, + 0xa25151f3U, 0x5da3a3feU, 0x804040c0U, 0x058f8f8aU, + 0x3f9292adU, 0x219d9dbcU, 0x70383848U, 0xf1f5f504U, + 0x63bcbcdfU, 0x77b6b6c1U, 0xafdada75U, 0x42212163U, + 0x20101030U, 0xe5ffff1aU, 0xfdf3f30eU, 0xbfd2d26dU, + 0x81cdcd4cU, 0x180c0c14U, 0x26131335U, 0xc3ecec2fU, + 0xbe5f5fe1U, 0x359797a2U, 0x884444ccU, 0x2e171739U, + 0x93c4c457U, 0x55a7a7f2U, 0xfc7e7e82U, 0x7a3d3d47U, + 0xc86464acU, 0xba5d5de7U, 0x3219192bU, 0xe6737395U, + 0xc06060a0U, 0x19818198U, 0x9e4f4fd1U, 0xa3dcdc7fU, + 0x44222266U, 0x542a2a7eU, 0x3b9090abU, 0x0b888883U, + 0x8c4646caU, 0xc7eeee29U, 0x6bb8b8d3U, 0x2814143cU, + 0xa7dede79U, 0xbc5e5ee2U, 0x160b0b1dU, 0xaddbdb76U, + 0xdbe0e03bU, 0x64323256U, 0x743a3a4eU, 0x140a0a1eU, + 0x924949dbU, 0x0c06060aU, 0x4824246cU, 0xb85c5ce4U, + 0x9fc2c25dU, 0xbdd3d36eU, 0x43acacefU, 0xc46262a6U, + 0x399191a8U, 0x319595a4U, 0xd3e4e437U, 0xf279798bU, + 0xd5e7e732U, 0x8bc8c843U, 0x6e373759U, 0xda6d6db7U, + 0x018d8d8cU, 0xb1d5d564U, 0x9c4e4ed2U, 0x49a9a9e0U, + 0xd86c6cb4U, 0xac5656faU, 0xf3f4f407U, 0xcfeaea25U, + 0xca6565afU, 0xf47a7a8eU, 0x47aeaee9U, 0x10080818U, + 0x6fbabad5U, 0xf0787888U, 0x4a25256fU, 0x5c2e2e72U, + 0x381c1c24U, 0x57a6a6f1U, 0x73b4b4c7U, 0x97c6c651U, + 0xcbe8e823U, 0xa1dddd7cU, 0xe874749cU, 0x3e1f1f21U, + 0x964b4bddU, 0x61bdbddcU, 0x0d8b8b86U, 0x0f8a8a85U, + 0xe0707090U, 0x7c3e3e42U, 0x71b5b5c4U, 0xcc6666aaU, + 0x904848d8U, 0x06030305U, 0xf7f6f601U, 0x1c0e0e12U, + 0xc26161a3U, 0x6a35355fU, 0xae5757f9U, 0x69b9b9d0U, + 0x17868691U, 0x99c1c158U, 0x3a1d1d27U, 0x279e9eb9U, + 0xd9e1e138U, 0xebf8f813U, 0x2b9898b3U, 0x22111133U, + 0xd26969bbU, 0xa9d9d970U, 0x078e8e89U, 0x339494a7U, + 0x2d9b9bb6U, 0x3c1e1e22U, 0x15878792U, 0xc9e9e920U, + 0x87cece49U, 0xaa5555ffU, 0x50282878U, 0xa5dfdf7aU, + 0x038c8c8fU, 0x59a1a1f8U, 0x09898980U, 0x1a0d0d17U, + 0x65bfbfdaU, 0xd7e6e631U, 0x844242c6U, 0xd06868b8U, + 0x824141c3U, 0x299999b0U, 0x5a2d2d77U, 0x1e0f0f11U, + 0x7bb0b0cbU, 0xa85454fcU, 0x6dbbbbd6U, 0x2c16163aU, +}; + +const u32 Td0[256] = { + 0x51f4a750U, 0x7e416553U, 0x1a17a4c3U, 0x3a275e96U, + 0x3bab6bcbU, 0x1f9d45f1U, 0xacfa58abU, 0x4be30393U, + 0x2030fa55U, 0xad766df6U, 0x88cc7691U, 0xf5024c25U, + 0x4fe5d7fcU, 0xc52acbd7U, 0x26354480U, 0xb562a38fU, + 0xdeb15a49U, 0x25ba1b67U, 0x45ea0e98U, 0x5dfec0e1U, + 0xc32f7502U, 0x814cf012U, 0x8d4697a3U, 0x6bd3f9c6U, + 0x038f5fe7U, 0x15929c95U, 0xbf6d7aebU, 0x955259daU, + 0xd4be832dU, 0x587421d3U, 0x49e06929U, 0x8ec9c844U, + 0x75c2896aU, 0xf48e7978U, 0x99583e6bU, 0x27b971ddU, + 0xbee14fb6U, 0xf088ad17U, 0xc920ac66U, 0x7dce3ab4U, + 0x63df4a18U, 0xe51a3182U, 0x97513360U, 0x62537f45U, + 0xb16477e0U, 0xbb6bae84U, 0xfe81a01cU, 0xf9082b94U, + 0x70486858U, 0x8f45fd19U, 0x94de6c87U, 0x527bf8b7U, + 0xab73d323U, 0x724b02e2U, 0xe31f8f57U, 0x6655ab2aU, + 0xb2eb2807U, 0x2fb5c203U, 0x86c57b9aU, 0xd33708a5U, + 0x302887f2U, 0x23bfa5b2U, 0x02036abaU, 0xed16825cU, + 0x8acf1c2bU, 0xa779b492U, 0xf307f2f0U, 0x4e69e2a1U, + 0x65daf4cdU, 0x0605bed5U, 0xd134621fU, 0xc4a6fe8aU, + 0x342e539dU, 0xa2f355a0U, 0x058ae132U, 0xa4f6eb75U, + 0x0b83ec39U, 0x4060efaaU, 0x5e719f06U, 0xbd6e1051U, + 0x3e218af9U, 0x96dd063dU, 0xdd3e05aeU, 0x4de6bd46U, + 0x91548db5U, 0x71c45d05U, 0x0406d46fU, 0x605015ffU, + 0x1998fb24U, 0xd6bde997U, 0x894043ccU, 0x67d99e77U, + 0xb0e842bdU, 0x07898b88U, 0xe7195b38U, 0x79c8eedbU, + 0xa17c0a47U, 0x7c420fe9U, 0xf8841ec9U, 0x00000000U, + 0x09808683U, 0x322bed48U, 0x1e1170acU, 0x6c5a724eU, + 0xfd0efffbU, 0x0f853856U, 0x3daed51eU, 0x362d3927U, + 0x0a0fd964U, 0x685ca621U, 0x9b5b54d1U, 0x24362e3aU, + 0x0c0a67b1U, 0x9357e70fU, 0xb4ee96d2U, 0x1b9b919eU, + 0x80c0c54fU, 0x61dc20a2U, 0x5a774b69U, 0x1c121a16U, + 0xe293ba0aU, 0xc0a02ae5U, 0x3c22e043U, 0x121b171dU, + 0x0e090d0bU, 0xf28bc7adU, 0x2db6a8b9U, 0x141ea9c8U, + 0x57f11985U, 0xaf75074cU, 0xee99ddbbU, 0xa37f60fdU, + 0xf701269fU, 0x5c72f5bcU, 0x44663bc5U, 0x5bfb7e34U, + 0x8b432976U, 0xcb23c6dcU, 0xb6edfc68U, 0xb8e4f163U, + 0xd731dccaU, 0x42638510U, 0x13972240U, 0x84c61120U, + 0x854a247dU, 0xd2bb3df8U, 0xaef93211U, 0xc729a16dU, + 0x1d9e2f4bU, 0xdcb230f3U, 0x0d8652ecU, 0x77c1e3d0U, + 0x2bb3166cU, 0xa970b999U, 0x119448faU, 0x47e96422U, + 0xa8fc8cc4U, 0xa0f03f1aU, 0x567d2cd8U, 0x223390efU, + 0x87494ec7U, 0xd938d1c1U, 0x8ccaa2feU, 0x98d40b36U, + 0xa6f581cfU, 0xa57ade28U, 0xdab78e26U, 0x3fadbfa4U, + 0x2c3a9de4U, 0x5078920dU, 0x6a5fcc9bU, 0x547e4662U, + 0xf68d13c2U, 0x90d8b8e8U, 0x2e39f75eU, 0x82c3aff5U, + 0x9f5d80beU, 0x69d0937cU, 0x6fd52da9U, 0xcf2512b3U, + 0xc8ac993bU, 0x10187da7U, 0xe89c636eU, 0xdb3bbb7bU, + 0xcd267809U, 0x6e5918f4U, 0xec9ab701U, 0x834f9aa8U, + 0xe6956e65U, 0xaaffe67eU, 0x21bccf08U, 0xef15e8e6U, + 0xbae79bd9U, 0x4a6f36ceU, 0xea9f09d4U, 0x29b07cd6U, + 0x31a4b2afU, 0x2a3f2331U, 0xc6a59430U, 0x35a266c0U, + 0x744ebc37U, 0xfc82caa6U, 0xe090d0b0U, 0x33a7d815U, + 0xf104984aU, 0x41ecdaf7U, 0x7fcd500eU, 0x1791f62fU, + 0x764dd68dU, 0x43efb04dU, 0xccaa4d54U, 0xe49604dfU, + 0x9ed1b5e3U, 0x4c6a881bU, 0xc12c1fb8U, 0x4665517fU, + 0x9d5eea04U, 0x018c355dU, 0xfa877473U, 0xfb0b412eU, + 0xb3671d5aU, 0x92dbd252U, 0xe9105633U, 0x6dd64713U, + 0x9ad7618cU, 0x37a10c7aU, 0x59f8148eU, 0xeb133c89U, + 0xcea927eeU, 0xb761c935U, 0xe11ce5edU, 0x7a47b13cU, + 0x9cd2df59U, 0x55f2733fU, 0x1814ce79U, 0x73c737bfU, + 0x53f7cdeaU, 0x5ffdaa5bU, 0xdf3d6f14U, 0x7844db86U, + 0xcaaff381U, 0xb968c43eU, 0x3824342cU, 0xc2a3405fU, + 0x161dc372U, 0xbce2250cU, 0x283c498bU, 0xff0d9541U, + 0x39a80171U, 0x080cb3deU, 0xd8b4e49cU, 0x6456c190U, + 0x7bcb8461U, 0xd532b670U, 0x486c5c74U, 0xd0b85742U, +}; + +const u8 Td4s[256] = { + 0x52U, 0x09U, 0x6aU, 0xd5U, 0x30U, 0x36U, 0xa5U, 0x38U, + 0xbfU, 0x40U, 0xa3U, 0x9eU, 0x81U, 0xf3U, 0xd7U, 0xfbU, + 0x7cU, 0xe3U, 0x39U, 0x82U, 0x9bU, 0x2fU, 0xffU, 0x87U, + 0x34U, 0x8eU, 0x43U, 0x44U, 0xc4U, 0xdeU, 0xe9U, 0xcbU, + 0x54U, 0x7bU, 0x94U, 0x32U, 0xa6U, 0xc2U, 0x23U, 0x3dU, + 0xeeU, 0x4cU, 0x95U, 0x0bU, 0x42U, 0xfaU, 0xc3U, 0x4eU, + 0x08U, 0x2eU, 0xa1U, 0x66U, 0x28U, 0xd9U, 0x24U, 0xb2U, + 0x76U, 0x5bU, 0xa2U, 0x49U, 0x6dU, 0x8bU, 0xd1U, 0x25U, + 0x72U, 0xf8U, 0xf6U, 0x64U, 0x86U, 0x68U, 0x98U, 0x16U, + 0xd4U, 0xa4U, 0x5cU, 0xccU, 0x5dU, 0x65U, 0xb6U, 0x92U, + 0x6cU, 0x70U, 0x48U, 0x50U, 0xfdU, 0xedU, 0xb9U, 0xdaU, + 0x5eU, 0x15U, 0x46U, 0x57U, 0xa7U, 0x8dU, 0x9dU, 0x84U, + 0x90U, 0xd8U, 0xabU, 0x00U, 0x8cU, 0xbcU, 0xd3U, 0x0aU, + 0xf7U, 0xe4U, 0x58U, 0x05U, 0xb8U, 0xb3U, 0x45U, 0x06U, + 0xd0U, 0x2cU, 0x1eU, 0x8fU, 0xcaU, 0x3fU, 0x0fU, 0x02U, + 0xc1U, 0xafU, 0xbdU, 0x03U, 0x01U, 0x13U, 0x8aU, 0x6bU, + 0x3aU, 0x91U, 0x11U, 0x41U, 0x4fU, 0x67U, 0xdcU, 0xeaU, + 0x97U, 0xf2U, 0xcfU, 0xceU, 0xf0U, 0xb4U, 0xe6U, 0x73U, + 0x96U, 0xacU, 0x74U, 0x22U, 0xe7U, 0xadU, 0x35U, 0x85U, + 0xe2U, 0xf9U, 0x37U, 0xe8U, 0x1cU, 0x75U, 0xdfU, 0x6eU, + 0x47U, 0xf1U, 0x1aU, 0x71U, 0x1dU, 0x29U, 0xc5U, 0x89U, + 0x6fU, 0xb7U, 0x62U, 0x0eU, 0xaaU, 0x18U, 0xbeU, 0x1bU, + 0xfcU, 0x56U, 0x3eU, 0x4bU, 0xc6U, 0xd2U, 0x79U, 0x20U, + 0x9aU, 0xdbU, 0xc0U, 0xfeU, 0x78U, 0xcdU, 0x5aU, 0xf4U, + 0x1fU, 0xddU, 0xa8U, 0x33U, 0x88U, 0x07U, 0xc7U, 0x31U, + 0xb1U, 0x12U, 0x10U, 0x59U, 0x27U, 0x80U, 0xecU, 0x5fU, + 0x60U, 0x51U, 0x7fU, 0xa9U, 0x19U, 0xb5U, 0x4aU, 0x0dU, + 0x2dU, 0xe5U, 0x7aU, 0x9fU, 0x93U, 0xc9U, 0x9cU, 0xefU, + 0xa0U, 0xe0U, 0x3bU, 0x4dU, 0xaeU, 0x2aU, 0xf5U, 0xb0U, + 0xc8U, 0xebU, 0xbbU, 0x3cU, 0x83U, 0x53U, 0x99U, 0x61U, + 0x17U, 0x2bU, 0x04U, 0x7eU, 0xbaU, 0x77U, 0xd6U, 0x26U, + 0xe1U, 0x69U, 0x14U, 0x63U, 0x55U, 0x21U, 0x0cU, 0x7dU, +}; +const u8 rcons[] = { + 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1B, 0x36 + /* for 128-bit blocks, Rijndael never uses more than 10 rcon values */ +}; + +/** + * Expand the cipher key into the encryption key schedule. + * + * @return the number of rounds for the given cipher key size. + */ +#define ROUND(i, d, s) \ +do { \ + d##0 = TE0(s##0) ^ TE1(s##1) ^ TE2(s##2) ^ TE3(s##3) ^ rk[4 * i]; \ + d##1 = TE0(s##1) ^ TE1(s##2) ^ TE2(s##3) ^ TE3(s##0) ^ rk[4 * i + 1]; \ + d##2 = TE0(s##2) ^ TE1(s##3) ^ TE2(s##0) ^ TE3(s##1) ^ rk[4 * i + 2]; \ + d##3 = TE0(s##3) ^ TE1(s##0) ^ TE2(s##1) ^ TE3(s##2) ^ rk[4 * i + 3]; \ +} while (0); + +/** + * omac1_aes_128 - One-Key CBC MAC (OMAC1) hash with AES-128 (aka AES-CMAC) + * @key: 128-bit key for the hash operation + * @data: Data buffer for which a MAC is determined + * @data_len: Length of data buffer in bytes + * @mac: Buffer for MAC (128 bits, i.e., 16 bytes) + * Returns: 0 on success, -1 on failure + * + * This is a mode for using block cipher (AES in this case) for authentication. + * OMAC1 was standardized with the name CMAC by NIST in a Special Publication + * (SP) 800-38B. + */ +void rtw_use_tkipkey_handler(void *FunctionContext) +{ + struct adapter *padapter = (struct adapter *)FunctionContext; + + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler ^^^\n")); + + padapter->securitypriv.busetkipkey = true; + + RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler padapter->securitypriv.busetkipkey=%d^^^\n", padapter->securitypriv.busetkipkey)); + +} diff --git a/drivers/staging/r8188eu/core/rtw_sreset.c b/drivers/staging/r8188eu/core/rtw_sreset.c new file mode 100644 index 000000000000..298f75400c8f --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_sreset.c @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include + +void sreset_init_value(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + _rtw_mutex_init(&psrtpriv->silentreset_mutex); + psrtpriv->silent_reset_inprogress = false; + psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->last_tx_time = 0; + psrtpriv->last_tx_complete_time = 0; +} +void sreset_reset_value(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + psrtpriv->silent_reset_inprogress = false; + psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->last_tx_time = 0; + psrtpriv->last_tx_complete_time = 0; +} + +u8 sreset_get_wifi_status(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + u8 status = WIFI_STATUS_SUCCESS; + u32 val32 = 0; + + if (psrtpriv->silent_reset_inprogress) + return status; + val32 = rtw_read32(padapter, REG_TXDMA_STATUS); + if (val32 == 0xeaeaeaea) { + psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST; + } else if (val32 != 0) { + DBG_88E("txdmastatu(%x)\n", val32); + psrtpriv->Wifi_Error_Status = WIFI_MAC_TXDMA_ERROR; + } + + if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) { + DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->Wifi_Error_Status); + status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL|USB_WRITE_PORT_FAIL))); + } + DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status); + + /* status restore */ + psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + + return status; +} + +void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + pHalData->srestpriv.Wifi_Error_Status = status; +} diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c new file mode 100644 index 000000000000..30a1dd369112 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -0,0 +1,609 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_STA_MGT_C_ + +#include +#include +#include +#include +#include +#include + +static void _rtw_init_stainfo(struct sta_info *psta) +{ + + memset((u8 *)psta, 0, sizeof (struct sta_info)); + + spin_lock_init(&psta->lock); + INIT_LIST_HEAD(&psta->list); + INIT_LIST_HEAD(&psta->hash_list); + _rtw_init_queue(&psta->sleep_q); + psta->sleepq_len = 0; + + _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); + _rtw_init_sta_recv_priv(&psta->sta_recvpriv); + +#ifdef CONFIG_88EU_AP_MODE + + INIT_LIST_HEAD(&psta->asoc_list); + + INIT_LIST_HEAD(&psta->auth_list); + + psta->expire_to = 0; + + psta->flags = 0; + + psta->capability = 0; + + psta->bpairwise_key_installed = false; + +#ifdef CONFIG_88EU_AP_MODE + psta->nonerp_set = 0; + psta->no_short_slot_time_set = 0; + psta->no_short_preamble_set = 0; + psta->no_ht_gf_set = 0; + psta->no_ht_set = 0; + psta->ht_20mhz_set = 0; +#endif + + psta->under_exist_checking = 0; + + psta->keep_alive_trycnt = 0; + +#endif /* CONFIG_88EU_AP_MODE */ + +} + +u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) +{ + struct sta_info *psta; + s32 i; + + pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4); + + if (!pstapriv->pallocated_stainfo_buf) + return _FAIL; + + pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - + ((size_t)(pstapriv->pallocated_stainfo_buf) & 3); + + _rtw_init_queue(&pstapriv->free_sta_queue); + + spin_lock_init(&pstapriv->sta_hash_lock); + + pstapriv->asoc_sta_count = 0; + _rtw_init_queue(&pstapriv->sleep_q); + _rtw_init_queue(&pstapriv->wakeup_q); + + psta = (struct sta_info *)(pstapriv->pstainfo_buf); + + for (i = 0; i < NUM_STA; i++) { + _rtw_init_stainfo(psta); + + INIT_LIST_HEAD(&(pstapriv->sta_hash[i])); + + list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); + + psta++; + } + +#ifdef CONFIG_88EU_AP_MODE + + pstapriv->sta_dz_bitmap = 0; + pstapriv->tim_bitmap = 0; + + INIT_LIST_HEAD(&pstapriv->asoc_list); + INIT_LIST_HEAD(&pstapriv->auth_list); + spin_lock_init(&pstapriv->asoc_list_lock); + spin_lock_init(&pstapriv->auth_list_lock); + pstapriv->asoc_list_cnt = 0; + pstapriv->auth_list_cnt = 0; + + pstapriv->auth_to = 3; /* 3*2 = 6 sec */ + pstapriv->assoc_to = 3; + pstapriv->expire_to = 3; /* 3*2 = 6 sec */ + pstapriv->max_num_sta = NUM_STA; +#endif + + return _SUCCESS; +} + +inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta) +{ + int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info); + + if (!stainfo_offset_valid(offset)) + DBG_88E("%s invalid offset(%d), out of range!!!", __func__, offset); + + return offset; +} + +inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset) +{ + if (!stainfo_offset_valid(offset)) + DBG_88E("%s invalid offset(%d), out of range!!!", __func__, offset); + + return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); +} + +void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv); +void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv) +{ + + _rtw_spinlock_free(&psta_xmitpriv->lock); + + _rtw_spinlock_free(&(psta_xmitpriv->be_q.sta_pending.lock)); + _rtw_spinlock_free(&(psta_xmitpriv->bk_q.sta_pending.lock)); + _rtw_spinlock_free(&(psta_xmitpriv->vi_q.sta_pending.lock)); + _rtw_spinlock_free(&(psta_xmitpriv->vo_q.sta_pending.lock)); + +} + +static void _rtw_free_sta_recv_priv_lock(struct sta_recv_priv *psta_recvpriv) +{ + + _rtw_spinlock_free(&psta_recvpriv->lock); + + _rtw_spinlock_free(&(psta_recvpriv->defrag_q.lock)); + +} + +void rtw_mfree_stainfo(struct sta_info *psta); +void rtw_mfree_stainfo(struct sta_info *psta) +{ + + if (&psta->lock != NULL) + _rtw_spinlock_free(&psta->lock); + + _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); + _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); + +} + +/* this function is used to free the memory of lock || sema for all stainfos */ +void rtw_mfree_all_stainfo(struct sta_priv *pstapriv); +void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) +{ + struct list_head *plist, *phead; + struct sta_info *psta = NULL; + + spin_lock_bh(&pstapriv->sta_hash_lock); + + phead = get_list_head(&pstapriv->free_sta_queue); + plist = phead->next; + + while (phead != plist) { + psta = container_of(plist, struct sta_info , list); + plist = plist->next; + } + + spin_unlock_bh(&pstapriv->sta_hash_lock); +} + +static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) +{ +#ifdef CONFIG_88EU_AP_MODE + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; +#endif + + rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ + + _rtw_spinlock_free(&pstapriv->free_sta_queue.lock); + + _rtw_spinlock_free(&pstapriv->sta_hash_lock); + _rtw_spinlock_free(&pstapriv->wakeup_q.lock); + _rtw_spinlock_free(&pstapriv->sleep_q.lock); + +#ifdef CONFIG_88EU_AP_MODE + _rtw_spinlock_free(&pstapriv->asoc_list_lock); + _rtw_spinlock_free(&pstapriv->auth_list_lock); + _rtw_spinlock_free(&pacl_list->acl_node_q.lock); +#endif +} + +u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) +{ + struct list_head *phead, *plist; + struct sta_info *psta = NULL; + struct recv_reorder_ctrl *preorder_ctrl; + int index; + + if (pstapriv) { + /* delete all reordering_ctrl_timer */ + spin_lock_bh(&pstapriv->sta_hash_lock); + for (index = 0; index < NUM_STA; index++) { + phead = &(pstapriv->sta_hash[index]); + plist = phead->next; + + while (phead != plist) { + int i; + psta = container_of(plist, struct sta_info , hash_list); + plist = plist->next; + + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + } + } + } + spin_unlock_bh(&pstapriv->sta_hash_lock); + /*===============================*/ + + rtw_mfree_sta_priv_lock(pstapriv); + + if (pstapriv->pallocated_stainfo_buf) + rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); + } + + return _SUCCESS; +} + +struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) +{ + s32 index; + struct list_head *phash_list; + struct sta_info *psta; + struct __queue *pfree_sta_queue; + struct recv_reorder_ctrl *preorder_ctrl; + int i = 0; + u16 wRxSeqInitialValue = 0xffff; + + pfree_sta_queue = &pstapriv->free_sta_queue; + + spin_lock_bh(&pfree_sta_queue->lock); + + if (list_empty(&pfree_sta_queue->queue)) { + spin_unlock_bh(&pfree_sta_queue->lock); + psta = NULL; + } else { + psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list); + list_del_init(&(psta->list)); + spin_unlock_bh(&pfree_sta_queue->lock); + _rtw_init_stainfo(psta); + memcpy(psta->hwaddr, hwaddr, ETH_ALEN); + index = wifi_mac_hash(hwaddr); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("rtw_alloc_stainfo: index=%x", index)); + if (index >= NUM_STA) { + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => rtw_alloc_stainfo: index >= NUM_STA")); + psta = NULL; + goto exit; + } + phash_list = &(pstapriv->sta_hash[index]); + + spin_lock_bh(&pstapriv->sta_hash_lock); + + list_add_tail(&psta->hash_list, phash_list); + + pstapriv->asoc_sta_count++ ; + + spin_unlock_bh(&pstapriv->sta_hash_lock); + +/* Commented by Albert 2009/08/13 */ +/* For the SMC router, the sequence number of first packet of WPS handshake will be 0. */ +/* In this case, this packet will be dropped by recv_decache function if we use the 0x00 as the default value for tid_rxseq variable. */ +/* So, we initialize the tid_rxseq variable as the 0xffff. */ + + for (i = 0; i < 16; i++) + memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); + + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, + ("alloc number_%d stainfo with hwaddr = %pM\n", + pstapriv->asoc_sta_count , hwaddr)); + + init_addba_retry_timer(pstapriv->padapter, psta); + + /* for A-MPDU Rx reordering buffer control */ + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + + preorder_ctrl->padapter = pstapriv->padapter; + + preorder_ctrl->enable = false; + + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->wend_b = 0xffff; + preorder_ctrl->wsize_b = 64;/* 64; */ + + _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); + + rtw_init_recv_timer(preorder_ctrl); + } + + /* init for DM */ + psta->rssi_stat.UndecoratedSmoothedPWDB = (-1); + psta->rssi_stat.UndecoratedSmoothedCCK = (-1); + + /* init for the sequence number of received management frame */ + psta->RxMgmtFrameSeqNum = 0xffff; + } + +exit: + + return psta; +} + +/* using pstapriv->sta_hash_lock to protect */ +u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) +{ + int i; + struct __queue *pfree_sta_queue; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_xmit_priv *pstaxmitpriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (psta == NULL) + goto exit; + + pfree_sta_queue = &pstapriv->free_sta_queue; + + pstaxmitpriv = &psta->sta_xmitpriv; + + spin_lock_bh(&pxmitpriv->lock); + + rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q); + psta->sleepq_len = 0; + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); + + list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); + + list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); + + list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + + rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); + + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + + spin_unlock_bh(&pxmitpriv->lock); + + list_del_init(&psta->hash_list); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); + pstapriv->asoc_sta_count--; + + /* re-init sta_info; 20061114 */ + _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); + _rtw_init_sta_recv_priv(&psta->sta_recvpriv); + + _cancel_timer_ex(&psta->addba_retry_timer); + + /* for A-MPDU Rx reordering buffer control, cancel reordering_ctrl_timer */ + for (i = 0; i < 16 ; i++) { + struct list_head *phead, *plist; + struct recv_frame *prframe; + struct __queue *ppending_recvframe_queue; + struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; + + preorder_ctrl = &psta->recvreorder_ctrl[i]; + + _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); + + ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; + + spin_lock_bh(&ppending_recvframe_queue->lock); + + phead = get_list_head(ppending_recvframe_queue); + plist = phead->next; + + while (!list_empty(phead)) { + prframe = container_of(plist, struct recv_frame, list); + + plist = plist->next; + + list_del_init(&(prframe->list)); + + rtw_free_recvframe(prframe, pfree_recv_queue); + } + + spin_unlock_bh(&ppending_recvframe_queue->lock); + } + + if (!(psta->state & WIFI_AP_STATE)) + rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, false); + +#ifdef CONFIG_88EU_AP_MODE + + spin_lock_bh(&pstapriv->auth_list_lock); + if (!list_empty(&psta->auth_list)) { + list_del_init(&psta->auth_list); + pstapriv->auth_list_cnt--; + } + spin_unlock_bh(&pstapriv->auth_list_lock); + + psta->expire_to = 0; + + psta->sleepq_ac_len = 0; + psta->qos_info = 0; + + psta->max_sp_len = 0; + psta->uapsd_bk = 0; + psta->uapsd_be = 0; + psta->uapsd_vi = 0; + psta->uapsd_vo = 0; + psta->has_legacy_ac = 0; + + pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) { + pstapriv->sta_aid[psta->aid - 1] = NULL; + psta->aid = 0; + } + + psta->under_exist_checking = 0; + +#endif /* CONFIG_88EU_AP_MODE */ + + spin_lock_bh(&pfree_sta_queue->lock); + list_add_tail(&psta->list, get_list_head(pfree_sta_queue)); + spin_unlock_bh(&pfree_sta_queue->lock); + +exit: + + return _SUCCESS; +} + +/* free all stainfo which in sta_hash[all] */ +void rtw_free_all_stainfo(struct adapter *padapter) +{ + struct list_head *plist, *phead; + s32 index; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); + + if (pstapriv->asoc_sta_count == 1) + return; + + spin_lock_bh(&pstapriv->sta_hash_lock); + + for (index = 0; index < NUM_STA; index++) { + phead = &(pstapriv->sta_hash[index]); + plist = phead->next; + + while (phead != plist) { + psta = container_of(plist, struct sta_info , hash_list); + + plist = plist->next; + + if (pbcmc_stainfo != psta) + rtw_free_stainfo(padapter , psta); + } + } + spin_unlock_bh(&pstapriv->sta_hash_lock); +} + +/* any station allocated can be searched by hash list */ +struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) +{ + struct list_head *plist, *phead; + struct sta_info *psta = NULL; + u32 index; + u8 *addr; + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + if (hwaddr == NULL) + return NULL; + + if (IS_MCAST(hwaddr)) + addr = bc_addr; + else + addr = hwaddr; + + index = wifi_mac_hash(addr); + + spin_lock_bh(&pstapriv->sta_hash_lock); + + phead = &(pstapriv->sta_hash[index]); + plist = phead->next; + + while (phead != plist) { + psta = container_of(plist, struct sta_info, hash_list); + + if ((!memcmp(psta->hwaddr, addr, ETH_ALEN))) { + /* if found the matched address */ + break; + } + psta = NULL; + plist = plist->next; + } + + spin_unlock_bh(&pstapriv->sta_hash_lock); + + return psta; +} + +u32 rtw_init_bcmc_stainfo(struct adapter *padapter) +{ + struct sta_info *psta; + u32 res = _SUCCESS; + unsigned char bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + struct sta_priv *pstapriv = &padapter->stapriv; + + psta = rtw_alloc_stainfo(pstapriv, bcast_addr); + + if (psta == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); + goto exit; + } + + /* default broadcast & multicast use macid 1 */ + psta->mac_id = 1; + +exit: + + return res; +} + +struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) +{ + struct sta_info *psta; + struct sta_priv *pstapriv = &padapter->stapriv; + u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + psta = rtw_get_stainfo(pstapriv, bc_addr); + + return psta; +} + +u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) +{ + u8 res = true; +#ifdef CONFIG_88EU_AP_MODE + struct list_head *plist, *phead; + struct rtw_wlan_acl_node *paclnode; + u8 match = false; + struct sta_priv *pstapriv = &padapter->stapriv; + struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; + struct __queue *pacl_node_q = &pacl_list->acl_node_q; + + spin_lock_bh(&pacl_node_q->lock); + phead = get_list_head(pacl_node_q); + plist = phead->next; + while (phead != plist) { + paclnode = container_of(plist, struct rtw_wlan_acl_node, list); + plist = plist->next; + + if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { + if (paclnode->valid) { + match = true; + break; + } + } + } + spin_unlock_bh(&pacl_node_q->lock); + + if (pacl_list->mode == 1)/* accept unless in deny list */ + res = (match) ? false : true; + else if (pacl_list->mode == 2)/* deny unless in accept list */ + res = (match) ? true : false; + else + res = true; + +#endif + + return res; +} diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c new file mode 100644 index 000000000000..335d6a2c93ec --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -0,0 +1,1690 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_WLAN_UTIL_C_ + +#include +#include +#include + +static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; +static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; + +static unsigned char BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; +static unsigned char BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; + +static unsigned char CISCO_OUI[] = {0x00, 0x40, 0x96}; +static unsigned char MARVELL_OUI[] = {0x00, 0x50, 0x43}; +static unsigned char RALINK_OUI[] = {0x00, 0x0c, 0x43}; +static unsigned char REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; +static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; +static unsigned char EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; + +unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; + +#define R2T_PHY_DELAY (0) + +/* define WAIT_FOR_BCN_TO_M (3000) */ +#define WAIT_FOR_BCN_TO_MIN (6000) +#define WAIT_FOR_BCN_TO_MAX (20000) + +static u8 rtw_basic_rate_cck[4] = { + IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK +}; + +static u8 rtw_basic_rate_ofdm[3] = { + IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK +}; + +static u8 rtw_basic_rate_mix[7] = { + IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK +}; + +int cckrates_included(unsigned char *rate, int ratelen) +{ + int i; + + for (i = 0; i < ratelen; i++) { + if ((((rate[i]) & 0x7f) == 2) || (((rate[i]) & 0x7f) == 4) || + (((rate[i]) & 0x7f) == 11) || (((rate[i]) & 0x7f) == 22)) + return true; + } + return false; +} + +int cckratesonly_included(unsigned char *rate, int ratelen) +{ + int i; + + for (i = 0; i < ratelen; i++) { + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + return false; + } + + return true; +} + +unsigned char networktype_to_raid(unsigned char network_type) +{ + unsigned char raid; + + switch (network_type) { + case WIRELESS_11B: + raid = RATR_INX_WIRELESS_B; + break; + case WIRELESS_11A: + case WIRELESS_11G: + raid = RATR_INX_WIRELESS_G; + break; + case WIRELESS_11BG: + raid = RATR_INX_WIRELESS_GB; + break; + case WIRELESS_11_24N: + case WIRELESS_11_5N: + raid = RATR_INX_WIRELESS_N; + break; + case WIRELESS_11A_5N: + case WIRELESS_11G_24N: + raid = RATR_INX_WIRELESS_NG; + break; + case WIRELESS_11BG_24N: + raid = RATR_INX_WIRELESS_NGB; + break; + default: + raid = RATR_INX_WIRELESS_GB; + break; + } + return raid; +} + +u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen) +{ + u8 network_type = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeext->cur_channel > 14) { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_5N; + + network_type |= WIRELESS_11A; + } else { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_24N; + + if ((cckratesonly_included(rate, ratelen)) == true) + network_type |= WIRELESS_11B; + else if ((cckrates_included(rate, ratelen)) == true) + network_type |= WIRELESS_11BG; + else + network_type |= WIRELESS_11G; + } + return network_type; +} + +static unsigned char ratetbl_val_2wifirate(unsigned char rate) +{ + unsigned char val = 0; + + switch (rate & 0x7f) { + case 0: + val = IEEE80211_CCK_RATE_1MB; + break; + case 1: + val = IEEE80211_CCK_RATE_2MB; + break; + case 2: + val = IEEE80211_CCK_RATE_5MB; + break; + case 3: + val = IEEE80211_CCK_RATE_11MB; + break; + case 4: + val = IEEE80211_OFDM_RATE_6MB; + break; + case 5: + val = IEEE80211_OFDM_RATE_9MB; + break; + case 6: + val = IEEE80211_OFDM_RATE_12MB; + break; + case 7: + val = IEEE80211_OFDM_RATE_18MB; + break; + case 8: + val = IEEE80211_OFDM_RATE_24MB; + break; + case 9: + val = IEEE80211_OFDM_RATE_36MB; + break; + case 10: + val = IEEE80211_OFDM_RATE_48MB; + break; + case 11: + val = IEEE80211_OFDM_RATE_54MB; + break; + } + return val; +} + +static int is_basicrate(struct adapter *padapter, unsigned char rate) +{ + int i; + unsigned char val; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + for (i = 0; i < NumRates; i++) { + val = pmlmeext->basicrate[i]; + + if ((val != 0xff) && (val != 0xfe)) { + if (rate == ratetbl_val_2wifirate(val)) + return true; + } + } + return false; +} + +static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset) +{ + int i; + unsigned char rate; + unsigned int len = 0; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + for (i = 0; i < NumRates; i++) { + rate = pmlmeext->datarate[i]; + + switch (rate) { + case 0xff: + return len; + case 0xfe: + continue; + default: + rate = ratetbl_val_2wifirate(rate); + + if (is_basicrate(padapter, rate) == true) + rate |= IEEE80211_BASIC_RATE_MASK; + + rateset[len] = rate; + len++; + break; + } + } + return len; +} + +void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len) +{ + unsigned char supportedrates[NumRates]; + + memset(supportedrates, 0, NumRates); + *bssrate_len = ratetbl2rateset(padapter, supportedrates); + memcpy(pbssrate, supportedrates, *bssrate_len); +} + +void UpdateBrateTbl(struct adapter *Adapter, u8 *mbrate) +{ + u8 i; + u8 rate; + + /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + rate = mbrate[i] & 0x7f; + switch (rate) { + case IEEE80211_CCK_RATE_1MB: + case IEEE80211_CCK_RATE_2MB: + case IEEE80211_CCK_RATE_5MB: + case IEEE80211_CCK_RATE_11MB: + case IEEE80211_OFDM_RATE_6MB: + case IEEE80211_OFDM_RATE_12MB: + case IEEE80211_OFDM_RATE_24MB: + mbrate[i] |= IEEE80211_BASIC_RATE_MASK; + break; + } + } +} + +void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) +{ + u8 i; + u8 rate; + + for (i = 0; i < bssratelen; i++) { + rate = bssrateset[i] & 0x7f; + switch (rate) { + case IEEE80211_CCK_RATE_1MB: + case IEEE80211_CCK_RATE_2MB: + case IEEE80211_CCK_RATE_5MB: + case IEEE80211_CCK_RATE_11MB: + bssrateset[i] |= IEEE80211_BASIC_RATE_MASK; + break; + } + } +} + +void Save_DM_Func_Flag(struct adapter *padapter) +{ + u8 saveflag = true; + + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); +} + +void Restore_DM_Func_Flag(struct adapter *padapter) +{ + u8 saveflag = false; + + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); +} + +void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable) +{ + if (enable) + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); + else + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); +} + +static void Set_NETYPE0_MSR(struct adapter *padapter, u8 type) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); +} + +void Set_MSR(struct adapter *padapter, u8 type) +{ + Set_NETYPE0_MSR(padapter, type); +} + +inline u8 rtw_get_oper_ch(struct adapter *adapter) +{ + return adapter->mlmeextpriv.oper_channel; +} + +inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) +{ + adapter->mlmeextpriv.oper_channel = ch; +} + +inline u8 rtw_get_oper_bw(struct adapter *adapter) +{ + return adapter->mlmeextpriv.oper_bwmode; +} + +inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw) +{ + adapter->mlmeextpriv.oper_bwmode = bw; +} + +inline u8 rtw_get_oper_choffset(struct adapter *adapter) +{ + return adapter->mlmeextpriv.oper_ch_offset; +} + +inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset) +{ + adapter->mlmeextpriv.oper_ch_offset = offset; +} + +void SelectChannel(struct adapter *padapter, unsigned char channel) +{ + /* saved channel info */ + rtw_set_oper_ch(padapter, channel); + rtw_hal_set_chan(padapter, channel); +} + +void SetBWMode(struct adapter *padapter, unsigned short bwmode, + unsigned char channel_offset) +{ + /* saved bw info */ + rtw_set_oper_bw(padapter, bwmode); + rtw_set_oper_choffset(padapter, channel_offset); + + rtw_hal_set_bwmode(padapter, (enum ht_channel_width)bwmode, channel_offset); +} + +void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode) +{ + u8 center_ch; + + if (padapter->bNotifyChannelChange) + DBG_88E("[%s] ch = %d, offset = %d, bwmode = %d\n", __func__, channel, channel_offset, bwmode); + + if ((bwmode == HT_CHANNEL_WIDTH_20) || + (channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)) { + /* SelectChannel(padapter, channel); */ + center_ch = channel; + } else { + /* switch to the proper channel */ + if (channel_offset == HAL_PRIME_CHNL_OFFSET_LOWER) { + /* SelectChannel(padapter, channel + 2); */ + center_ch = channel + 2; + } else { + /* SelectChannel(padapter, channel - 2); */ + center_ch = channel - 2; + } + } + + /* set Channel */ + /* saved channel/bw info */ + rtw_set_oper_ch(padapter, channel); + rtw_set_oper_bw(padapter, bwmode); + rtw_set_oper_choffset(padapter, channel_offset); + + rtw_hal_set_chan(padapter, center_ch); /* set center channel */ + SetBWMode(padapter, bwmode, channel_offset); +} + +int get_bsstype(unsigned short capability) +{ + if (capability & BIT(0)) + return WIFI_FW_AP_STATE; + else if (capability & BIT(1)) + return WIFI_FW_ADHOC_STATE; + else + return 0; +} + +__inline u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork) +{ + return pnetwork->MacAddress; +} + +u16 get_beacon_interval(struct wlan_bssid_ex *bss) +{ + __le16 val; + memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->IEs), 2); + + return le16_to_cpu(val); +} + +int is_client_associated_to_ap(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + + if (!padapter) + return _FAIL; + + pmlmeext = &padapter->mlmeextpriv; + pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) + return true; + else + return _FAIL; +} + +int is_client_associated_to_ibss(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) + return true; + else + return _FAIL; +} + +int is_IBSS_empty(struct adapter *padapter) +{ + unsigned int i; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { + if (pmlmeinfo->FW_sta_info[i].status == 1) + return _FAIL; + } + return true; +} + +unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) +{ + if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN) + return WAIT_FOR_BCN_TO_MIN; + else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX) + return WAIT_FOR_BCN_TO_MAX; + else + return bcn_interval << 2; +} + +void CAM_empty_entry(struct adapter *Adapter, u8 ucIndex) +{ + rtw_hal_set_hwreg(Adapter, HW_VAR_CAM_EMPTY_ENTRY, (u8 *)(&ucIndex)); +} + +void invalidate_cam_all(struct adapter *padapter) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); +} + +void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) +{ + unsigned int i, val, addr; + int j; + u32 cam_val[2]; + + addr = entry << 3; + + for (j = 5; j >= 0; j--) { + switch (j) { + case 0: + val = (ctrl | (mac[0] << 16) | (mac[1] << 24)); + break; + case 1: + val = (mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24)); + break; + default: + i = (j - 2) << 2; + val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24)); + break; + } + + cam_val[0] = val; + cam_val[1] = addr + (unsigned int)j; + + rtw_hal_set_hwreg(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); + } +} + +void clear_cam_entry(struct adapter *padapter, u8 entry) +{ + unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + unsigned char null_key[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + + write_cam(padapter, entry, 0, null_sta, null_key); +} + +int allocate_fw_sta_entry(struct adapter *padapter) +{ + unsigned int mac_id; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { + if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { + pmlmeinfo->FW_sta_info[mac_id].status = 1; + pmlmeinfo->FW_sta_info[mac_id].retry = 0; + break; + } + } + + return mac_id; +} + +void flush_all_cam_entry(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); + + memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); +} + +int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + /* struct registry_priv *pregpriv = &padapter->registrypriv; */ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmepriv->qospriv.qos_option == 0) { + pmlmeinfo->WMM_enable = 0; + return _FAIL; + } + + pmlmeinfo->WMM_enable = 1; + memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element)); + return true; +} + +void WMMOnAssocRsp(struct adapter *padapter) +{ + u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; + u8 acm_mask; + u16 TXOP; + u32 acParm, i; + u32 edca[4], inx[4]; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregpriv = &padapter->registrypriv; + + if (pmlmeinfo->WMM_enable == 0) { + padapter->mlmepriv.acm_mask = 0; + return; + } + + acm_mask = 0; + + if (pmlmeext->cur_wireless_mode == WIRELESS_11B) + aSifsTime = 10; + else + aSifsTime = 16; + + for (i = 0; i < 4; i++) { + ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03; + ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01; + + /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */ + AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime; + + ECWMin = (pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f); + ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4; + TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit); + + acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); + + switch (ACI) { + case 0x0: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); + acm_mask |= (ACM ? BIT(1) : 0); + edca[XMIT_BE_QUEUE] = acParm; + break; + case 0x1: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); + edca[XMIT_BK_QUEUE] = acParm; + break; + case 0x2: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); + acm_mask |= (ACM ? BIT(2) : 0); + edca[XMIT_VI_QUEUE] = acParm; + break; + case 0x3: + rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); + acm_mask |= (ACM ? BIT(3) : 0); + edca[XMIT_VO_QUEUE] = acParm; + break; + } + + DBG_88E("WMM(%x): %x, %x\n", ACI, ACM, acParm); + } + + if (padapter->registrypriv.acm_method == 1) + rtw_hal_set_hwreg(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); + else + padapter->mlmepriv.acm_mask = acm_mask; + + inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; + + if (pregpriv->wifi_spec == 1) { + u32 j, tmp, change_inx = false; + + /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ + for (i = 0; i < 4; i++) { + for (j = i+1; j < 4; j++) { + /* compare CW and AIFS */ + if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { + change_inx = true; + } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { + /* compare TXOP */ + if ((edca[j] >> 16) > (edca[i] >> 16)) + change_inx = true; + } + + if (change_inx) { + tmp = edca[i]; + edca[i] = edca[j]; + edca[j] = tmp; + + tmp = inx[i]; + inx[i] = inx[j]; + inx[j] = tmp; + + change_inx = false; + } + } + } + } + + for (i = 0; i < 4; i++) { + pxmitpriv->wmm_para_seq[i] = inx[i]; + DBG_88E("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); + } + + return; +} + +static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + unsigned char new_bwmode; + unsigned char new_ch_offset; + struct HT_info_element *pHT_info; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (!pIE) + return; + + if (!phtpriv) + return; + + if (pIE->Length > sizeof(struct HT_info_element)) + return; + + pHT_info = (struct HT_info_element *)pIE->data; + + if ((pHT_info->infos[0] & BIT(2)) && pregistrypriv->cbw40_enable) { + new_bwmode = HT_CHANNEL_WIDTH_40; + + switch (pHT_info->infos[0] & 0x3) { + case 1: + new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; + break; + case 3: + new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; + break; + default: + new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + break; + } + } else { + new_bwmode = HT_CHANNEL_WIDTH_20; + new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + + if ((new_bwmode != pmlmeext->cur_bwmode) || + (new_ch_offset != pmlmeext->cur_ch_offset)) { + pmlmeinfo->bwmode_updated = true; + + pmlmeext->cur_bwmode = new_bwmode; + pmlmeext->cur_ch_offset = new_ch_offset; + + /* update HT info also */ + HT_info_handler(padapter, pIE); + } else { + pmlmeinfo->bwmode_updated = false; + } + + if (pmlmeinfo->bwmode_updated) { + struct sta_info *psta; + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct sta_priv *pstapriv = &padapter->stapriv; + + /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ + + /* update ap's stainfo */ + psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); + if (psta) { + struct ht_priv *phtpriv_sta = &psta->htpriv; + + if (phtpriv_sta->ht_option) { + /* bwmode */ + phtpriv_sta->bwmode = pmlmeext->cur_bwmode; + phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; + } else { + phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; + phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + } + } + } +} + +void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + unsigned int i; + u8 rf_type; + u8 max_AMPDU_len, min_MPDU_spacing; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (pIE == NULL) + return; + + if (!phtpriv->ht_option) + return; + + pmlmeinfo->HT_caps_enable = 1; + + for (i = 0; i < (pIE->Length); i++) { + if (i != 2) { + /* Got the endian issue here. */ + pmlmeinfo->HT_caps.u.HT_cap[i] &= (pIE->data[i]); + } else { + /* modify from fw by Thomas 2010/11/17 */ + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3) > (pIE->data[i] & 0x3)) + max_AMPDU_len = (pIE->data[i] & 0x3); + else + max_AMPDU_len = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x3); + + if ((pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) > (pIE->data[i] & 0x1c)) + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c); + else + min_MPDU_spacing = (pIE->data[i] & 0x1c); + + pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing; + } + } + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + /* update the MCS rates */ + for (i = 0; i < 16; i++) { + if ((rf_type == RF_1T1R) || (rf_type == RF_1T2R)) + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_1R[i]; + else + pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i]; + } + return; +} + +void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ht_priv *phtpriv = &pmlmepriv->htpriv; + + if (pIE == NULL) + return; + + if (!phtpriv->ht_option) + return; + + if (pIE->Length > sizeof(struct HT_info_element)) + return; + + pmlmeinfo->HT_info_enable = 1; + memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); + return; +} + +void HTOnAssocRsp(struct adapter *padapter) +{ + unsigned char max_AMPDU_len; + unsigned char min_MPDU_spacing; + /* struct registry_priv *pregpriv = &padapter->registrypriv; */ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + DBG_88E("%s\n", __func__); + + if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) { + pmlmeinfo->HT_enable = 1; + } else { + pmlmeinfo->HT_enable = 0; + return; + } + + /* handle A-MPDU parameter field */ + /* + AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k + AMPDU_para [4:2]:Min MPDU Start Spacing + */ + max_AMPDU_len = pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x03; + + min_MPDU_spacing = (pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para & 0x1c) >> 2; + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, (u8 *)(&min_MPDU_spacing)); + + rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, (u8 *)(&max_AMPDU_len)); +} + +void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pIE->Length > 1) + return; + + pmlmeinfo->ERP_enable = 1; + memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length); +} + +void VCS_update(struct adapter *padapter, struct sta_info *psta) +{ + struct registry_priv *pregpriv = &padapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ + case 0: /* off */ + psta->rtsen = 0; + psta->cts2self = 0; + break; + case 1: /* on */ + if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ + psta->rtsen = 1; + psta->cts2self = 0; + } else { + psta->rtsen = 0; + psta->cts2self = 1; + } + break; + case 2: /* auto */ + default: + if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) { + if (pregpriv->vcs_type == 1) { + psta->rtsen = 1; + psta->cts2self = 0; + } else { + psta->rtsen = 0; + psta->cts2self = 1; + } + } else { + psta->rtsen = 0; + psta->cts2self = 0; + } + break; + } +} + +int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) +{ + unsigned int len; + unsigned char *p; + unsigned short val16, subtype; + struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network); + /* u8 wpa_ie[255], rsn_ie[255]; */ + u16 wpa_len = 0, rsn_len = 0; + u8 encryp_protocol = 0; + struct wlan_bssid_ex *bssid; + int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; + unsigned char *pbuf; + u32 wpa_ielen = 0; + u8 *pbssid = GetAddr3Ptr(pframe); + u32 hidden_ssid = 0; + struct HT_info_element *pht_info = NULL; + struct ieee80211_ht_cap *pht_cap = NULL; + u32 bcn_channel; + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; + + if (is_client_associated_to_ap(Adapter) == false) + return true; + + len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); + + if (len > MAX_IE_SZ) { + DBG_88E("%s IE too long for survey event\n", __func__); + return _FAIL; + } + + if (memcmp(cur_network->network.MacAddress, pbssid, 6)) { + DBG_88E("Oops: rtw_check_network_encrypt linked but recv other bssid bcn\n%pM %pM\n", + (pbssid), (cur_network->network.MacAddress)); + return true; + } + + bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); + if (!bssid) + return _FAIL; + + subtype = GetFrameSubType(pframe) >> 4; + + if (subtype == WIFI_BEACON) + bssid->Reserved[0] = 1; + + bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; + + /* below is to copy the information element */ + bssid->IELength = len; + memcpy(bssid->IEs, (pframe + sizeof(struct rtw_ieee80211_hdr_3addr)), bssid->IELength); + + /* check bw and channel offset */ + /* parsing HT_CAP_IE */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_cap = (struct ieee80211_ht_cap *)(p + 2); + ht_cap_info = le16_to_cpu(pht_cap->cap_info); + } else { + ht_cap_info = 0; + } + /* parsing HT_INFO_IE */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p && len > 0) { + pht_info = (struct HT_info_element *)(p + 2); + ht_info_infos_0 = pht_info->infos[0]; + } else { + ht_info_infos_0 = 0; + } + if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || + ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { + DBG_88E("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, + ht_cap_info, ht_info_infos_0); + DBG_88E("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, + cur_network->BcnInfo.ht_cap_info, cur_network->BcnInfo.ht_info_infos_0); + DBG_88E("%s bw mode change, disconnect\n", __func__); + /* bcn_info_update */ + cur_network->BcnInfo.ht_cap_info = ht_cap_info; + cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; + /* to do : need to check that whether modify related register of BB or not */ + /* goto _mismatch; */ + } + + /* Checking for channel */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _DSSET_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p) { + bcn_channel = *(p + 2); + } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _HT_ADD_INFO_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (pht_info) { + bcn_channel = pht_info->primary_channel; + } else { /* we don't find channel IE, so don't check it */ + DBG_88E("Oops: %s we don't find channel IE, so don't check it\n", __func__); + bcn_channel = Adapter->mlmeextpriv.cur_channel; + } + } + if (bcn_channel != Adapter->mlmeextpriv.cur_channel) { + DBG_88E("%s beacon channel:%d cur channel:%d disconnect\n", __func__, + bcn_channel, Adapter->mlmeextpriv.cur_channel); + goto _mismatch; + } + + /* checking SSID */ + p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); + if (p == NULL) { + DBG_88E("%s marc: cannot find SSID for survey event\n", __func__); + hidden_ssid = true; + } else { + hidden_ssid = false; + } + + if ((NULL != p) && (false == hidden_ssid && (*(p + 1)))) { + memcpy(bssid->Ssid.Ssid, (p + 2), *(p + 1)); + bssid->Ssid.SsidLength = *(p + 1); + } else { + bssid->Ssid.SsidLength = 0; + bssid->Ssid.Ssid[0] = '\0'; + } + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " + "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid, + bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid, + cur_network->network.Ssid.SsidLength)); + + if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || + bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) { + if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */ + DBG_88E("%s(), SSID is not match return FAIL\n", __func__); + goto _mismatch; + } + } + + /* check encryption info */ + val16 = rtw_get_capability((struct wlan_bssid_ex *)bssid); + + if (val16 & BIT(4)) + bssid->Privacy = 1; + else + bssid->Privacy = 0; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n", + __func__, cur_network->network.Privacy, bssid->Privacy)); + if (cur_network->network.Privacy != bssid->Privacy) { + DBG_88E("%s(), privacy is not match return FAIL\n", __func__); + goto _mismatch; + } + + rtw_get_sec_ie(bssid->IEs, bssid->IELength, NULL, &rsn_len, NULL, &wpa_len); + + if (rsn_len > 0) { + encryp_protocol = ENCRYP_PROTOCOL_WPA2; + } else if (wpa_len > 0) { + encryp_protocol = ENCRYP_PROTOCOL_WPA; + } else { + if (bssid->Privacy) + encryp_protocol = ENCRYP_PROTOCOL_WEP; + } + + if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) { + DBG_88E("%s(): enctyp is not match , return FAIL\n", __func__); + goto _mismatch; + } + + if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { + pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + if (pbuf && (wpa_ielen > 0)) { + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, + pairwise_cipher, group_cipher, is_8021x)); + } + } else { + pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + + if (pbuf && (wpa_ielen > 0)) { + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, + ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", + __func__, pairwise_cipher, group_cipher, is_8021x)); + } + } + } + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, + ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher)); + if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { + DBG_88E("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__, + pairwise_cipher, cur_network->BcnInfo.pairwise_cipher, + group_cipher, cur_network->BcnInfo.group_cipher); + goto _mismatch; + } + + if (is_8021x != cur_network->BcnInfo.is_8021x) { + DBG_88E("%s authentication is not match , return FAIL\n", __func__); + goto _mismatch; + } + } + + kfree(bssid); + + return _SUCCESS; + +_mismatch: + kfree(bssid); + + return _FAIL; +} + +void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta) +{ + unsigned int i; + unsigned int len; + struct ndis_802_11_var_ie *pIE; + + len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN); + + for (i = 0; i < len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); + + switch (pIE->ElementID) { + case _HT_EXTRA_INFO_IE_: /* HT info */ + /* HT_info_handler(padapter, pIE); */ + bwmode_update_check(padapter, pIE); + break; + case _ERPINFO_IE_: + ERP_IE_handler(padapter, pIE); + VCS_update(padapter, psta); + break; + default: + break; + } + + i += (pIE->Length + 2); + } +} + +unsigned int is_ap_in_tkip(struct adapter *padapter) +{ + u32 i; + struct ndis_802_11_var_ie *pIE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) + return true; + break; + case _RSN_IE_2_: + if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) + return true; + default: + break; + } + + i += (pIE->Length + 2); + } + return false; + } else { + return false; + } +} + +unsigned int should_forbid_n_rate(struct adapter *padapter) +{ + u32 i; + struct ndis_802_11_var_ie *pIE; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_bssid_ex *cur_network = &pmlmepriv->cur_network.network; + + if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + for (i = sizeof(struct ndis_802_11_fixed_ie); i < cur_network->IELength;) { + pIE = (struct ndis_802_11_var_ie *)(cur_network->IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (!memcmp(pIE->data, RTW_WPA_OUI, 4) && + ((!memcmp((pIE->data + 12), WPA_CIPHER_SUITE_CCMP, 4)) || + (!memcmp((pIE->data + 16), WPA_CIPHER_SUITE_CCMP, 4)))) + return false; + break; + case _RSN_IE_2_: + if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || + (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) + return false; + default: + break; + } + + i += (pIE->Length + 2); + } + + return true; + } else { + return false; + } +} + +unsigned int is_ap_in_wep(struct adapter *padapter) +{ + u32 i; + struct ndis_802_11_var_ie *pIE; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { + for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { + pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.IEs + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if (!memcmp(pIE->data, RTW_WPA_OUI, 4)) + return false; + break; + case _RSN_IE_2_: + return false; + default: + break; + } + i += (pIE->Length + 2); + } + return true; + } else { + return false; + } +} + +int wifirate2_ratetbl_inx(unsigned char rate) +{ + int inx = 0; + rate = rate & 0x7f; + + switch (rate) { + case 54*2: + inx = 11; + break; + case 48*2: + inx = 10; + break; + case 36*2: + inx = 9; + break; + case 24*2: + inx = 8; + break; + case 18*2: + inx = 7; + break; + case 12*2: + inx = 6; + break; + case 9*2: + inx = 5; + break; + case 6*2: + inx = 4; + break; + case 11*2: + inx = 3; + break; + case 11: + inx = 2; + break; + case 2*2: + inx = 1; + break; + case 1*2: + inx = 0; + break; + } + return inx; +} + +unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz) +{ + unsigned int i, num_of_rate; + unsigned int mask = 0; + + num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz; + + for (i = 0; i < num_of_rate; i++) { + if ((*(ptn + i)) & 0x80) + mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i)); + } + return mask; +} + +unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz) +{ + unsigned int i, num_of_rate; + unsigned int mask = 0; + + num_of_rate = (ptn_sz > NumRates) ? NumRates : ptn_sz; + + for (i = 0; i < num_of_rate; i++) + mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i)); + return mask; +} + +unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps) +{ + unsigned int mask = 0; + + mask = ((pHT_caps->u.HT_cap_element.MCS_rate[0] << 12) | (pHT_caps->u.HT_cap_element.MCS_rate[1] << 20)); + + return mask; +} + +int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps) +{ + unsigned char bit_offset; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (!(pmlmeinfo->HT_enable)) + return _FAIL; + + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)) + return _FAIL; + + bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40) ? 6 : 5; + + if (__le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & (0x1 << bit_offset)) + return _SUCCESS; + else + return _FAIL; +} + +unsigned char get_highest_rate_idx(u32 mask) +{ + int i; + unsigned char rate_idx = 0; + + for (i = 27; i >= 0; i--) { + if (mask & BIT(i)) { + rate_idx = i; + break; + } + } + return rate_idx; +} + +void Update_RA_Entry(struct adapter *padapter, u32 mac_id) +{ + rtw_hal_update_ra_mask(padapter, mac_id, 0); +} + +static void enable_rate_adaptive(struct adapter *padapter, u32 mac_id) +{ + Update_RA_Entry(padapter, mac_id); +} + +void set_sta_rate(struct adapter *padapter, struct sta_info *psta) +{ + /* rate adaptive */ + enable_rate_adaptive(padapter, psta->mac_id); +} + +/* Update RRSR and Rate for USERATE */ +void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) +{ + unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + /* Added by Albert 2011/03/22 */ + /* In the P2P mode, the driver should not support the b mode. */ + /* So, the Tx packet shouldn't use the CCK rate */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) + return; +#endif /* CONFIG_88EU_P2P */ + memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); + + if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) + memcpy(supported_rates, rtw_basic_rate_cck, 4); + else if (wirelessmode & WIRELESS_11B) + memcpy(supported_rates, rtw_basic_rate_mix, 7); + else + memcpy(supported_rates, rtw_basic_rate_ofdm, 3); + + if (wirelessmode & WIRELESS_11B) + update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); + else + update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); + + rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, supported_rates); +} + +unsigned char check_assoc_AP(u8 *pframe, uint len) +{ + unsigned int i; + struct ndis_802_11_var_ie *pIE; + u8 epigram_vendor_flag; + u8 ralink_vendor_flag; + epigram_vendor_flag = 0; + ralink_vendor_flag = 0; + + for (i = sizeof(struct ndis_802_11_fixed_ie); i < len;) { + pIE = (struct ndis_802_11_var_ie *)(pframe + i); + + switch (pIE->ElementID) { + case _VENDOR_SPECIFIC_IE_: + if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || + (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { + DBG_88E("link to Artheros AP\n"); + return HT_IOT_PEER_ATHEROS; + } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI2, 3)) || + (!memcmp(pIE->data, BROADCOM_OUI2, 3))) { + DBG_88E("link to Broadcom AP\n"); + return HT_IOT_PEER_BROADCOM; + } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { + DBG_88E("link to Marvell AP\n"); + return HT_IOT_PEER_MARVELL; + } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { + if (!ralink_vendor_flag) { + ralink_vendor_flag = 1; + } else { + DBG_88E("link to Ralink AP\n"); + return HT_IOT_PEER_RALINK; + } + } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { + DBG_88E("link to Cisco AP\n"); + return HT_IOT_PEER_CISCO; + } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { + DBG_88E("link to Realtek 96B\n"); + return HT_IOT_PEER_REALTEK; + } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { + DBG_88E("link to Airgo Cap\n"); + return HT_IOT_PEER_AIRGO; + } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) { + epigram_vendor_flag = 1; + if (ralink_vendor_flag) { + DBG_88E("link to Tenda W311R AP\n"); + return HT_IOT_PEER_TENDA; + } else { + DBG_88E("Capture EPIGRAM_OUI\n"); + } + } else { + break; + } + + default: + break; + } + i += (pIE->Length + 2); + } + + if (ralink_vendor_flag && !epigram_vendor_flag) { + DBG_88E("link to Ralink AP\n"); + return HT_IOT_PEER_RALINK; + } else if (ralink_vendor_flag && epigram_vendor_flag) { + DBG_88E("link to Tenda W311R AP\n"); + return HT_IOT_PEER_TENDA; + } else { + DBG_88E("link to new AP\n"); + return HT_IOT_PEER_UNKNOWN; + } +} + +void update_IOT_info(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + switch (pmlmeinfo->assoc_AP_vendor) { + case HT_IOT_PEER_MARVELL: + pmlmeinfo->turboMode_cts2self = 1; + pmlmeinfo->turboMode_rtsen = 0; + break; + case HT_IOT_PEER_RALINK: + pmlmeinfo->turboMode_cts2self = 0; + pmlmeinfo->turboMode_rtsen = 1; + /* disable high power */ + Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); + break; + case HT_IOT_PEER_REALTEK: + /* rtw_write16(padapter, 0x4cc, 0xffff); */ + /* rtw_write16(padapter, 0x546, 0x01c0); */ + /* disable high power */ + Switch_DM_Func(padapter, (~DYNAMIC_BB_DYNAMIC_TXPWR), false); + break; + default: + pmlmeinfo->turboMode_cts2self = 0; + pmlmeinfo->turboMode_rtsen = 1; + break; + } +} + +void update_capinfo(struct adapter *Adapter, u16 updateCap) +{ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + bool ShortPreamble; + + /* Check preamble mode, 2005.01.06, by rcnjko. */ + /* Mark to update preamble value forever, 2008.03.18 by lanhsin */ + + if (updateCap & cShortPreamble) { /* Short Preamble */ + if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ + ShortPreamble = true; + pmlmeinfo->preamble_mode = PREAMBLE_SHORT; + rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + } + } else { /* Long Preamble */ + if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ + ShortPreamble = false; + pmlmeinfo->preamble_mode = PREAMBLE_LONG; + rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); + } + } + + if (updateCap & cIBSS) { + /* Filen: See 802.11-2007 p.91 */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } else { /* Filen: See 802.11-2007 p.90 */ + if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11_24N)) { + if (updateCap & cShortSlotTime) { /* Short Slot Time */ + if (pmlmeinfo->slotTime != SHORT_SLOT_TIME) + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + } else { /* Long Slot Time */ + if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME) + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } + } else if (pmlmeext->cur_wireless_mode & (WIRELESS_11A | WIRELESS_11_5N)) { + pmlmeinfo->slotTime = SHORT_SLOT_TIME; + } else { + /* B Mode */ + pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; + } + } + + rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); +} + +void update_wireless_mode(struct adapter *padapter) +{ + int ratelen, network_type = 0; + u32 SIFS_Timer; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + unsigned char *rate = cur_network->SupportedRates; + + ratelen = rtw_get_rateset_len(cur_network->SupportedRates); + + if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) + pmlmeinfo->HT_enable = 1; + + if (pmlmeext->cur_channel > 14) { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_5N; + + network_type |= WIRELESS_11A; + } else { + if (pmlmeinfo->HT_enable) + network_type = WIRELESS_11_24N; + + if ((cckratesonly_included(rate, ratelen)) == true) + network_type |= WIRELESS_11B; + else if ((cckrates_included(rate, ratelen)) == true) + network_type |= WIRELESS_11BG; + else + network_type |= WIRELESS_11G; + } + + pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; + + SIFS_Timer = 0x0a0a0808;/* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ + /* change this value if having IOT issues. */ + + padapter->HalFunc.SetHwRegHandler(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); + + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); + else + update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); +} + +void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) +{ + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { + /* Only B, B/G, and B/G/N AP could use CCK rate */ + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4); + } else { + memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 3); + } +} + +int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) +{ + unsigned int ie_len; + struct ndis_802_11_var_ie *pIE; + int supportRateNum = 0; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + if (pIE == NULL) + return _FAIL; + + memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); + supportRateNum = ie_len; + + pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _EXT_SUPPORTEDRATES_IE_, &ie_len, var_ie_len); + if (pIE) + memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); + + return _SUCCESS; +} + +void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) +{ + struct sta_info *psta; + u16 tid; + u16 param; + struct recv_reorder_ctrl *preorder_ctrl; + struct sta_priv *pstapriv = &padapter->stapriv; + struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + psta = rtw_get_stainfo(pstapriv, addr); + + if (psta) { + param = le16_to_cpu(preq->BA_para_set); + tid = (param>>2)&0x0f; + preorder_ctrl = &psta->recvreorder_ctrl[tid]; + preorder_ctrl->indicate_seq = 0xffff; + preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq) ? true : false; + } +} + +void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) +{ + u8 *pIE; + __le32 *pbuf; + + pIE = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); + pbuf = (__le32 *)pIE; + + pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1)); + + pmlmeext->TSFValue = pmlmeext->TSFValue << 32; + + pmlmeext->TSFValue |= le32_to_cpu(*pbuf); +} + +void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext) +{ + rtw_hal_set_hwreg(padapter, HW_VAR_CORRECT_TSF, NULL); +} + +void beacon_timing_control(struct adapter *padapter) +{ + rtw_hal_bcn_related_reg_setting(padapter); +} + +static struct adapter *pbuddy_padapter; + +int rtw_handle_dualmac(struct adapter *adapter, bool init) +{ + int status = _SUCCESS; + + if (init) { + if (pbuddy_padapter == NULL) { + pbuddy_padapter = adapter; + DBG_88E("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __func__); + } else { + adapter->pbuddy_adapter = pbuddy_padapter; + pbuddy_padapter->pbuddy_adapter = adapter; + /* clear global value */ + pbuddy_padapter = NULL; + DBG_88E("%s(): pbuddy_padapter exist, Exchange Information\n", __func__); + } + } else { + pbuddy_padapter = NULL; + } + return status; +} diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c new file mode 100644 index 000000000000..867cd3bbd135 --- /dev/null +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -0,0 +1,2370 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTW_XMIT_C_ + +#include +#include +#include +#include +#include +#include +#include + +static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; +static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; + +static void _init_txservq(struct tx_servq *ptxservq) +{ + + INIT_LIST_HEAD(&ptxservq->tx_pending); + _rtw_init_queue(&ptxservq->sta_pending); + ptxservq->qcnt = 0; + +} + +void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) +{ + + memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); + spin_lock_init(&psta_xmitpriv->lock); + _init_txservq(&psta_xmitpriv->be_q); + _init_txservq(&psta_xmitpriv->bk_q); + _init_txservq(&psta_xmitpriv->vi_q); + _init_txservq(&psta_xmitpriv->vo_q); + INIT_LIST_HEAD(&psta_xmitpriv->legacy_dz); + INIT_LIST_HEAD(&psta_xmitpriv->apsd); + +} + +s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) +{ + int i; + struct xmit_buf *pxmitbuf; + struct xmit_frame *pxframe; + int res = _SUCCESS; + u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + + spin_lock_init(&pxmitpriv->lock); + sema_init(&pxmitpriv->xmit_sema, 0); + sema_init(&pxmitpriv->terminate_xmitthread_sema, 0); + + /* + Please insert all the queue initializaiton using _rtw_init_queue below + */ + + pxmitpriv->adapter = padapter; + + _rtw_init_queue(&pxmitpriv->be_pending); + _rtw_init_queue(&pxmitpriv->bk_pending); + _rtw_init_queue(&pxmitpriv->vi_pending); + _rtw_init_queue(&pxmitpriv->vo_pending); + _rtw_init_queue(&pxmitpriv->bm_pending); + + _rtw_init_queue(&pxmitpriv->free_xmit_queue); + + /* + Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, + and initialize free_xmit_frame below. + Please also apply free_txobj to link_up all the xmit_frames... + */ + + pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + + if (pxmitpriv->pallocated_frame_buf == NULL) { + pxmitpriv->pxmit_frame_buf = NULL; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); + res = _FAIL; + goto exit; + } + pxmitpriv->pxmit_frame_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_frame_buf), 4); + /* pxmitpriv->pxmit_frame_buf = pxmitpriv->pallocated_frame_buf + 4 - */ + /* ((size_t) (pxmitpriv->pallocated_frame_buf) &3); */ + + pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; + + for (i = 0; i < NR_XMITFRAME; i++) { + INIT_LIST_HEAD(&(pxframe->list)); + + pxframe->padapter = padapter; + pxframe->frame_tag = NULL_FRAMETAG; + + pxframe->pkt = NULL; + + pxframe->buf_addr = NULL; + pxframe->pxmitbuf = NULL; + + list_add_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); + + pxframe++; + } + + pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME; + + pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; + + /* init xmit_buf */ + _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); + _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); + + pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + + if (pxmitpriv->pallocated_xmitbuf == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); + res = _FAIL; + goto exit; + } + + pxmitpriv->pxmitbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmitbuf), 4); + /* pxmitpriv->pxmitbuf = pxmitpriv->pallocated_xmitbuf + 4 - */ + /* ((size_t) (pxmitpriv->pallocated_xmitbuf) &3); */ + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + + for (i = 0; i < NR_XMITBUFF; i++) { + INIT_LIST_HEAD(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->ext_tag = false; + + /* Tx buf allocation may fail sometimes, so sleep and retry. */ + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + if (res == _FAIL) { + rtw_msleep_os(10); + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + if (res == _FAIL) { + goto exit; + } + } + + pxmitbuf->flags = XMIT_VO_QUEUE; + + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + pxmitbuf++; + } + + pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; + + /* Init xmit extension buff */ + _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); + + pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + + if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); + res = _FAIL; + goto exit; + } + + pxmitpriv->pxmit_extbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitpriv->pallocated_xmit_extbuf), 4); + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + + for (i = 0; i < num_xmit_extbuf; i++) { + INIT_LIST_HEAD(&pxmitbuf->list); + + pxmitbuf->priv_data = NULL; + pxmitbuf->padapter = padapter; + pxmitbuf->ext_tag = true; + + res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); + if (res == _FAIL) { + res = _FAIL; + goto exit; + } + + list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + pxmitbuf++; + } + + pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; + + rtw_alloc_hwxmits(padapter); + rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); + + for (i = 0; i < 4; i++) + pxmitpriv->wmm_para_seq[i] = i; + + pxmitpriv->txirp_cnt = 1; + + sema_init(&(pxmitpriv->tx_retevt), 0); + + /* per AC pending irp */ + pxmitpriv->beq_cnt = 0; + pxmitpriv->bkq_cnt = 0; + pxmitpriv->viq_cnt = 0; + pxmitpriv->voq_cnt = 0; + + pxmitpriv->ack_tx = false; + _rtw_mutex_init(&pxmitpriv->ack_tx_mutex); + rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0); + + rtw_hal_init_xmit_priv(padapter); + +exit: + + return res; +} + +static void rtw_mfree_xmit_priv_lock (struct xmit_priv *pxmitpriv) +{ + _rtw_spinlock_free(&pxmitpriv->lock); + + _rtw_spinlock_free(&pxmitpriv->be_pending.lock); + _rtw_spinlock_free(&pxmitpriv->bk_pending.lock); + _rtw_spinlock_free(&pxmitpriv->vi_pending.lock); + _rtw_spinlock_free(&pxmitpriv->vo_pending.lock); + _rtw_spinlock_free(&pxmitpriv->bm_pending.lock); + + _rtw_spinlock_free(&pxmitpriv->free_xmit_queue.lock); + _rtw_spinlock_free(&pxmitpriv->free_xmitbuf_queue.lock); + _rtw_spinlock_free(&pxmitpriv->pending_xmitbuf_queue.lock); +} + +void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) +{ + int i; + struct adapter *padapter = pxmitpriv->adapter; + struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; + u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; + u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + + rtw_hal_free_xmit_priv(padapter); + + rtw_mfree_xmit_priv_lock(pxmitpriv); + + if (pxmitpriv->pxmit_frame_buf == NULL) + return; + + for (i = 0; i < NR_XMITFRAME; i++) { + rtw_os_xmit_complete(padapter, pxmitframe); + + pxmitframe++; + } + + for (i = 0; i < NR_XMITBUFF; i++) { + rtw_os_xmit_resource_free(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); + pxmitbuf++; + } + + if (pxmitpriv->pallocated_frame_buf) + rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + + if (pxmitpriv->pallocated_xmitbuf) + rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + + /* free xmit extension buff */ + _rtw_spinlock_free(&pxmitpriv->free_xmit_extbuf_queue.lock); + + pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; + for (i = 0; i < num_xmit_extbuf; i++) { + rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); + pxmitbuf++; + } + + if (pxmitpriv->pallocated_xmit_extbuf) { + rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + } + + rtw_free_hwxmits(padapter); + + _rtw_mutex_free(&pxmitpriv->ack_tx_mutex); +} + +static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + u32 sz; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_info *psta = pattrib->psta; + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if (pattrib->nr_frags != 1) + sz = padapter->xmitpriv.frag_len; + else /* no frag */ + sz = pattrib->last_txcmdsz; + + /* (1) RTS_Threshold is compared to the MPDU, not MSDU. */ + /* (2) If there are more than one frag in this MSDU, only the first frag uses protection frame. */ + /* Other fragments are protected by previous fragment. */ + /* So we only need to check the length of first fragment. */ + if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { + if (sz > padapter->registrypriv.rts_thresh) { + pattrib->vcs_mode = RTS_CTS; + } else { + if (psta->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (psta->cts2self) + pattrib->vcs_mode = CTS_TO_SELF; + else + pattrib->vcs_mode = NONE_VCS; + } + } else { + while (true) { + /* IOT action */ + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && pattrib->ampdu_en && + (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { + pattrib->vcs_mode = CTS_TO_SELF; + break; + } + + /* check ERP protection */ + if (psta->rtsen || psta->cts2self) { + if (psta->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (psta->cts2self) + pattrib->vcs_mode = CTS_TO_SELF; + + break; + } + + /* check HT op mode */ + if (pattrib->ht_en) { + u8 htopmode = pmlmeinfo->HT_protection; + if ((pmlmeext->cur_bwmode && (htopmode == 2 || htopmode == 3)) || + (!pmlmeext->cur_bwmode && htopmode == 3)) { + pattrib->vcs_mode = RTS_CTS; + break; + } + } + + /* check rts */ + if (sz > padapter->registrypriv.rts_thresh) { + pattrib->vcs_mode = RTS_CTS; + break; + } + + /* to do list: check MIMO power save condition. */ + + /* check AMPDU aggregation for TXOP */ + if (pattrib->ampdu_en) { + pattrib->vcs_mode = RTS_CTS; + break; + } + + pattrib->vcs_mode = NONE_VCS; + break; + } + } +} + +static void update_attrib_phy_info(struct pkt_attrib *pattrib, struct sta_info *psta) +{ + /*if (psta->rtsen) + pattrib->vcs_mode = RTS_CTS; + else if (psta->cts2self) + pattrib->vcs_mode = CTS_TO_SELF; + else + pattrib->vcs_mode = NONE_VCS;*/ + + pattrib->mdata = 0; + pattrib->eosp = 0; + pattrib->triggered = 0; + + /* qos_en, ht_en, init rate, , bw, ch_offset, sgi */ + pattrib->qos_en = psta->qos_option; + + pattrib->raid = psta->raid; + pattrib->ht_en = psta->htpriv.ht_option; + pattrib->bwmode = psta->htpriv.bwmode; + pattrib->ch_offset = psta->htpriv.ch_offset; + pattrib->sgi = psta->htpriv.sgi; + pattrib->ampdu_en = false; + pattrib->retry_ctrl = false; +} + +u8 qos_acm(u8 acm_mask, u8 priority) +{ + u8 change_priority = priority; + + switch (priority) { + case 0: + case 3: + if (acm_mask & BIT(1)) + change_priority = 1; + break; + case 1: + case 2: + break; + case 4: + case 5: + if (acm_mask & BIT(2)) + change_priority = 0; + break; + case 6: + case 7: + if (acm_mask & BIT(3)) + change_priority = 5; + break; + default: + DBG_88E("qos_acm(): invalid pattrib->priority: %d!!!\n", priority); + break; + } + + return change_priority; +} + +static void set_qos(struct pkt_file *ppktfile, struct pkt_attrib *pattrib) +{ + struct ethhdr etherhdr; + struct iphdr ip_hdr; + s32 user_prio = 0; + + _rtw_open_pktfile(ppktfile->pkt, ppktfile); + _rtw_pktfile_read(ppktfile, (unsigned char *)ðerhdr, ETH_HLEN); + + /* get user_prio from IP hdr */ + if (pattrib->ether_type == 0x0800) { + _rtw_pktfile_read(ppktfile, (u8 *)&ip_hdr, sizeof(ip_hdr)); +/* user_prio = (ntohs(ip_hdr.tos) >> 5) & 0x3; */ + user_prio = ip_hdr.tos >> 5; + } else if (pattrib->ether_type == 0x888e) { + /* "When priority processing of data frames is supported, */ + /* a STA's SME should send EAPOL-Key frames at the highest priority." */ + user_prio = 7; + } + + pattrib->priority = user_prio; + pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN; + pattrib->subtype = WIFI_QOS_DATA_TYPE; +} + +static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib) +{ + struct pkt_file pktfile; + struct sta_info *psta = NULL; + struct ethhdr etherhdr; + + int bmcast; + struct sta_priv *pstapriv = &padapter->stapriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + int res = _SUCCESS; + + + + _rtw_open_pktfile(pkt, &pktfile); + _rtw_pktfile_read(&pktfile, (u8 *)ðerhdr, ETH_HLEN); + + pattrib->ether_type = ntohs(etherhdr.h_proto); + + memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); + memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); + + pattrib->pctrl = 0; + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { + memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pattrib->ta, pattrib->src, ETH_ALEN); + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); + memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); + } + + pattrib->pktlen = pktfile.pkt_len; + + if (ETH_P_IP == pattrib->ether_type) { + /* The following is for DHCP and ARP packet, we use cck1M to tx these packets and let LPS awake some time */ + /* to prevent DHCP protocol fail */ + u8 tmp[24]; + _rtw_pktfile_read(&pktfile, &tmp[0], 24); + pattrib->dhcp_pkt = 0; + if (pktfile.pkt_len > 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ + if (ETH_P_IP == pattrib->ether_type) {/* IP header */ + if (((tmp[21] == 68) && (tmp[23] == 67)) || + ((tmp[21] == 67) && (tmp[23] == 68))) { + /* 68 : UDP BOOTP client */ + /* 67 : UDP BOOTP server */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====================== update_attrib: get DHCP Packet\n")); + /* Use low rate to send DHCP packet. */ + pattrib->dhcp_pkt = 1; + } + } + } + } else if (0x888e == pattrib->ether_type) { + DBG_88E_LEVEL(_drv_info_, "send eapol packet\n"); + } + + if ((pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) + rtw_set_scan_deny(padapter, 3000); + + /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ + if ((pattrib->ether_type == 0x0806) || (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1); + + bmcast = IS_MCAST(pattrib->ra); + + /* get sta_info */ + if (bmcast) { + psta = rtw_get_bcmc_stainfo(padapter); + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->ra); + if (psta == NULL) { /* if we cannot get psta => drrp the pkt */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra: %pM\n", (pattrib->ra))); + res = _FAIL; + goto exit; + } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) { + res = _FAIL; + goto exit; + } + } + + if (psta) { + pattrib->mac_id = psta->mac_id; + /* DBG_88E("%s ==> mac_id(%d)\n", __func__, pattrib->mac_id); */ + pattrib->psta = psta; + } else { + /* if we cannot get psta => drop the pkt */ + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", (pattrib->ra))); + res = _FAIL; + goto exit; + } + + pattrib->ack_policy = 0; + /* get ether_hdr_len */ + pattrib->pkt_hdrlen = ETH_HLEN;/* pattrib->ether_type == 0x8100) ? (14 + 4): 14; vlan tag */ + + pattrib->hdrlen = WLAN_HDR_A3_LEN; + pattrib->subtype = WIFI_DATA_TYPE; + pattrib->priority = 0; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (psta->qos_option) + set_qos(&pktfile, pattrib); + } else { + if (pqospriv->qos_option) { + set_qos(&pktfile, pattrib); + + if (pmlmepriv->acm_mask != 0) + pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority); + } + } + + if (psta->ieee8021x_blocked) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\n psta->ieee8021x_blocked == true\n")); + + pattrib->encrypt = 0; + + if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n", pattrib->ether_type)); + res = _FAIL; + goto exit; + } + } else { + GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, bmcast); + + switch (psecuritypriv->dot11AuthAlgrthm) { + case dot11AuthAlgrthm_Open: + case dot11AuthAlgrthm_Shared: + case dot11AuthAlgrthm_Auto: + pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex; + break; + case dot11AuthAlgrthm_8021X: + if (bmcast) + pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid; + else + pattrib->key_idx = 0; + break; + default: + pattrib->key_idx = 0; + break; + } + } + + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + pattrib->iv_len = 4; + pattrib->icv_len = 4; + break; + case _TKIP_: + pattrib->iv_len = 8; + pattrib->icv_len = 4; + + if (padapter->securitypriv.busetkipkey == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("\npadapter->securitypriv.busetkipkey(%d) == _FAIL drop packet\n", + padapter->securitypriv.busetkipkey)); + res = _FAIL; + goto exit; + } + break; + case _AES_: + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("pattrib->encrypt=%d (_AES_)\n", pattrib->encrypt)); + pattrib->iv_len = 8; + pattrib->icv_len = 8; + break; + default: + pattrib->iv_len = 0; + pattrib->icv_len = 0; + break; + } + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + ("update_attrib: encrypt=%d securitypriv.sw_encrypt=%d\n", + pattrib->encrypt, padapter->securitypriv.sw_encrypt)); + + if (pattrib->encrypt && + (padapter->securitypriv.sw_encrypt || !psecuritypriv->hw_decrypted)) { + pattrib->bswenc = true; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("update_attrib: encrypt=%d securitypriv.hw_decrypted=%d bswenc = true\n", + pattrib->encrypt, padapter->securitypriv.sw_encrypt)); + } else { + pattrib->bswenc = false; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc = false\n")); + } + + rtw_set_tx_chksum_offload(pkt, pattrib); + + update_attrib_phy_info(pattrib, psta); + +exit: + + return res; +} + +static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + int curfragnum, length; + u8 *pframe, *payload, mic[8]; + struct mic_data micdata; + struct sta_info *stainfo; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; + u8 hw_hdr_offset = 0; + int bmcst = IS_MCAST(pattrib->ra); + + if (pattrib->psta) + stainfo = pattrib->psta; + else + stainfo = rtw_get_stainfo(&padapter->stapriv , &pattrib->ra[0]); + + hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);; + + if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ + /* encode mic code */ + if (stainfo != NULL) { + u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, + 0x0, 0x0}; + + pframe = pxmitframe->buf_addr + hw_hdr_offset; + + if (bmcst) { + if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) + return _FAIL; + /* start to calculate the mic code */ + rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); + } else { + if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) { + /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ + /* rtw_msleep_os(10); */ + return _FAIL; + } + /* start to calculate the mic code */ + rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]); + } + + if (pframe[1]&1) { /* ToDS == 1 */ + rtw_secmicappend(&micdata, &pframe[16], 6); /* DA */ + if (pframe[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &pframe[24], 6); + else + rtw_secmicappend(&micdata, &pframe[10], 6); + } else { /* ToDS == 0 */ + rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */ + if (pframe[1]&2) /* From Ds == 1 */ + rtw_secmicappend(&micdata, &pframe[16], 6); + else + rtw_secmicappend(&micdata, &pframe[10], 6); + } + + if (pattrib->qos_en) + priority[0] = (u8)pxmitframe->attrib.priority; + + rtw_secmicappend(&micdata, &priority[0], 4); + + payload = pframe; + + for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { + payload = (u8 *)RND4((size_t)(payload)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("=== curfragnum=%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n", + curfragnum, *payload, *(payload+1), + *(payload+2), *(payload+3), + *(payload+4), *(payload+5), + *(payload+6), *(payload+7))); + + payload = payload+pattrib->hdrlen+pattrib->iv_len; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("curfragnum=%d pattrib->hdrlen=%d pattrib->iv_len=%d", + curfragnum, pattrib->hdrlen, pattrib->iv_len)); + if ((curfragnum+1) == pattrib->nr_frags) { + length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + rtw_secmicappend(&micdata, payload, length); + payload = payload+length; + } else { + length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + rtw_secmicappend(&micdata, payload, length); + payload = payload+length+pattrib->icv_len; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum=%d length=%d pattrib->icv_len=%d", curfragnum, length, pattrib->icv_len)); + } + } + rtw_secgetmic(&micdata, &(mic[0])); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n", pattrib->last_txcmdsz)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]=0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x, mic[3]=0x%.2x\n\ + mic[4]= 0x%.2x , mic[5]= 0x%.2x , mic[6]= 0x%.2x , mic[7]= 0x%.2x !!!!\n", + mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7])); + /* add mic code and add the mic code length in last_txcmdsz */ + + memcpy(payload, &(mic[0]), 8); + pattrib->last_txcmdsz += 8; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ======== last pkt ========\n")); + payload = payload-pattrib->last_txcmdsz+8; + for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8) + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, + (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", + *(payload+curfragnum), *(payload+curfragnum+1), + *(payload+curfragnum+2), *(payload+curfragnum+3), + *(payload+curfragnum+4), *(payload+curfragnum+5), + *(payload+curfragnum+6), *(payload+curfragnum+7))); + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n")); + } + } + + return _SUCCESS; +} + +static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + struct pkt_attrib *pattrib = &pxmitframe->attrib; + + if (pattrib->bswenc) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + rtw_wep_encrypt(padapter, (u8 *)pxmitframe); + break; + case _TKIP_: + rtw_tkip_encrypt(padapter, (u8 *)pxmitframe); + break; + case _AES_: + rtw_aes_encrypt(padapter, (u8 *)pxmitframe); + break; + default: + break; + } + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); + } + + return _SUCCESS; +} + +s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) +{ + u16 *qc; + + struct rtw_ieee80211_hdr *pwlanhdr = (struct rtw_ieee80211_hdr *)hdr; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct qos_priv *pqospriv = &pmlmepriv->qospriv; + u8 qos_option = false; + + int res = _SUCCESS; + __le16 *fctrl = &pwlanhdr->frame_ctl; + + struct sta_info *psta; + + int bmcst = IS_MCAST(pattrib->ra); + + if (pattrib->psta) { + psta = pattrib->psta; + } else { + if (bmcst) { + psta = rtw_get_bcmc_stainfo(padapter); + } else { + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); + } + } + + memset(hdr, 0, WLANHDR_OFFSET); + + SetFrameSubType(fctrl, pattrib->subtype); + + if (pattrib->subtype & WIFI_DATA_TYPE) { + if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + /* to_ds = 1, fr_ds = 0; */ + /* Data transfer to AP */ + SetToDs(fctrl); + memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); + + if (pqospriv->qos_option) + qos_option = true; + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + /* to_ds = 0, fr_ds = 1; */ + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); + + if (psta->qos_option) + qos_option = true; + } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); + memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); + memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); + + if (psta->qos_option) + qos_option = true; + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv))); + res = _FAIL; + goto exit; + } + + if (pattrib->mdata) + SetMData(fctrl); + + if (pattrib->encrypt) + SetPrivacy(fctrl); + + if (qos_option) { + qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); + + if (pattrib->priority) + SetPriority(qc, pattrib->priority); + + SetEOSP(qc, pattrib->eosp); + + SetAckpolicy(qc, pattrib->ack_policy); + } + + /* TODO: fill HT Control Field */ + + /* Update Seq Num will be handled by f/w */ + if (psta) { + psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; + psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; + + pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; + + SetSeqNum(hdr, pattrib->seqnum); + + /* check if enable ampdu */ + if (pattrib->ht_en && psta->htpriv.ampdu_enable) { + if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) + pattrib->ampdu_en = true; + } + + /* re-check if enable ampdu by BA_starting_seqctrl */ + if (pattrib->ampdu_en) { + u16 tx_seq; + + tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; + + /* check BA_starting_seqctrl */ + if (SN_LESS(pattrib->seqnum, tx_seq)) { + pattrib->ampdu_en = false;/* AGG BK */ + } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; + + pattrib->ampdu_en = true;/* AGG EN */ + } else { + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; + pattrib->ampdu_en = true;/* AGG EN */ + } + } + } + } +exit: + + return res; +} + +s32 rtw_txframes_pending(struct adapter *padapter) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + return (!list_empty(&pxmitpriv->be_pending.queue) || + !list_empty(&pxmitpriv->bk_pending.queue) || + !list_empty(&pxmitpriv->vi_pending.queue) || + !list_empty(&pxmitpriv->vo_pending.queue)); +} + +s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib) +{ + struct sta_info *psta; + struct tx_servq *ptxservq; + int priority = pattrib->priority; + + psta = pattrib->psta; + + switch (priority) { + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + break; + } + + if (ptxservq) + return ptxservq->qcnt; + return 0; +} + +/* + * Calculate wlan 802.11 packet MAX size from pkt_attrib + * This function doesn't consider fragment case + */ +u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib) +{ + u32 len = 0; + + len = pattrib->hdrlen + pattrib->iv_len; /* WLAN Header and IV */ + len += SNAP_SIZE + sizeof(u16); /* LLC */ + len += pattrib->pktlen; + if (pattrib->encrypt == _TKIP_) + len += 8; /* MIC */ + len += ((pattrib->bswenc) ? pattrib->icv_len : 0); /* ICV */ + + return len; +} + +/* + +This sub-routine will perform all the following: + +1. remove 802.3 header. +2. create wlan_header, based on the info in pxmitframe +3. append sta's iv/ext-iv +4. append LLC +5. move frag chunk from pframe to pxmitframe->mem +6. apply sw-encrypt, if necessary. + +*/ +s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe) +{ + struct pkt_file pktfile; + s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; + size_t addr; + u8 *pframe, *mem_start; + u8 hw_hdr_offset; + struct sta_info *psta; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + u8 *pbuf_start; + s32 bmcst = IS_MCAST(pattrib->ra); + s32 res = _SUCCESS; + + if (!pkt) + return _FAIL; + + psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); + + if (psta == NULL) + return _FAIL; + + if (pxmitframe->buf_addr == NULL) { + DBG_88E("==> %s buf_addr == NULL\n", __func__); + return _FAIL; + } + + pbuf_start = pxmitframe->buf_addr; + + hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); + + mem_start = pbuf_start + hw_hdr_offset; + + if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n")); + DBG_88E("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n"); + res = _FAIL; + goto exit; + } + + _rtw_open_pktfile(pkt, &pktfile); + _rtw_pktfile_read(&pktfile, NULL, pattrib->pkt_hdrlen); + + frg_inx = 0; + frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ + + while (1) { + llc_sz = 0; + + mpdu_len = frg_len; + + pframe = mem_start; + + SetMFrag(mem_start); + + pframe += pattrib->hdrlen; + mpdu_len -= pattrib->hdrlen; + + /* adding icv, if necessary... */ + if (pattrib->iv_len) { + if (psta != NULL) { + switch (pattrib->encrypt) { + case _WEP40_: + case _WEP104_: + WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + break; + case _TKIP_: + if (bmcst) + TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + else + TKIP_IV(pattrib->iv, psta->dot11txpn, 0); + break; + case _AES_: + if (bmcst) + AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); + else + AES_IV(pattrib->iv, psta->dot11txpn, 0); + break; + } + } + + memcpy(pframe, pattrib->iv, pattrib->iv_len); + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, + ("rtw_xmitframe_coalesce: keyid=%d pattrib->iv[3]=%.2x pframe=%.2x %.2x %.2x %.2x\n", + padapter->securitypriv.dot11PrivacyKeyIndex, pattrib->iv[3], *pframe, *(pframe+1), *(pframe+2), *(pframe+3))); + + pframe += pattrib->iv_len; + + mpdu_len -= pattrib->iv_len; + } + + if (frg_inx == 0) { + llc_sz = rtw_put_snap(pframe, pattrib->ether_type); + pframe += llc_sz; + mpdu_len -= llc_sz; + } + + if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + mpdu_len -= pattrib->icv_len; + } + + if (bmcst) { + /* don't do fragment to broadcat/multicast packets */ + mem_sz = _rtw_pktfile_read(&pktfile, pframe, pattrib->pktlen); + } else { + mem_sz = _rtw_pktfile_read(&pktfile, pframe, mpdu_len); + } + + pframe += mem_sz; + + if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { + memcpy(pframe, pattrib->icv, pattrib->icv_len); + pframe += pattrib->icv_len; + } + + frg_inx++; + + if (bmcst || rtw_endofpktfile(&pktfile)) { + pattrib->nr_frags = frg_inx; + + pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz : 0) + + ((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz; + + ClearMFrag(mem_start); + + break; + } else { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); + } + + addr = (size_t)(pframe); + + mem_start = (unsigned char *)RND4(addr) + hw_hdr_offset; + memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); + } + + if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); + DBG_88E("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"); + res = _FAIL; + goto exit; + } + + xmitframe_swencrypt(padapter, pxmitframe); + + if (!bmcst) + update_attrib_vcs_info(padapter, pxmitframe); + else + pattrib->vcs_mode = NONE_VCS; + +exit: + + return res; +} + +/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header + * IEEE LLC/SNAP header contains 8 octets + * First 3 octets comprise the LLC portion + * SNAP portion, 5 octets, is divided into two fields: + * Organizationally Unique Identifier(OUI), 3 octets, + * type, defined by that organization, 2 octets. + */ +s32 rtw_put_snap(u8 *data, u16 h_proto) +{ + struct ieee80211_snap_hdr *snap; + u8 *oui; + + snap = (struct ieee80211_snap_hdr *)data; + snap->dsap = 0xaa; + snap->ssap = 0xaa; + snap->ctrl = 0x03; + + if (h_proto == 0x8137 || h_proto == 0x80f3) + oui = P802_1H_OUI; + else + oui = RFC1042_OUI; + + snap->oui[0] = oui[0]; + snap->oui[1] = oui[1]; + snap->oui[2] = oui[2]; + + *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); + + return SNAP_SIZE + sizeof(u16); +} + +void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) +{ + uint protection; + u8 *perp; + int erp_len; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + + switch (pxmitpriv->vcs_setting) { + case DISABLE_VCS: + pxmitpriv->vcs = NONE_VCS; + break; + case ENABLE_VCS: + break; + case AUTO_VCS: + default: + perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); + if (perp == NULL) { + pxmitpriv->vcs = NONE_VCS; + } else { + protection = (*(perp + 2)) & BIT(1); + if (protection) { + if (pregistrypriv->vcs_type == RTS_CTS) + pxmitpriv->vcs = RTS_CTS; + else + pxmitpriv->vcs = CTS_TO_SELF; + } else { + pxmitpriv->vcs = NONE_VCS; + } + } + break; + } + +} + +void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) +{ + struct sta_info *psta = NULL; + struct stainfo_stats *pstats = NULL; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + pxmitpriv->tx_bytes += sz; + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num; + + psta = pxmitframe->attrib.psta; + if (psta) { + pstats = &psta->sta_stats; + pstats->tx_pkts += pxmitframe->agg_num; + pstats->tx_bytes += sz; + } + } +} + +struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) +{ + struct xmit_buf *pxmitbuf = NULL; + struct list_head *plist, *phead; + struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; + unsigned long flags; + + spin_lock_irqsave(&pfree_queue->lock, flags); + + if (list_empty(&pfree_queue->queue)) { + pxmitbuf = NULL; + } else { + phead = get_list_head(pfree_queue); + + plist = phead->next; + + pxmitbuf = container_of(plist, struct xmit_buf, list); + + list_del_init(&(pxmitbuf->list)); + } + + if (pxmitbuf != NULL) { + pxmitpriv->free_xmit_extbuf_cnt--; + + pxmitbuf->priv_data = NULL; + /* pxmitbuf->ext_tag = true; */ + + if (pxmitbuf->sctx) { + DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); + } + } + + spin_unlock_irqrestore(&pfree_queue->lock, flags); + + return pxmitbuf; +} + +s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +{ + struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; + unsigned long flags; + + if (pxmitbuf == NULL) + return _FAIL; + + spin_lock_irqsave(&pfree_queue->lock, flags); + + list_del_init(&pxmitbuf->list); + + list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + pxmitpriv->free_xmit_extbuf_cnt++; + + spin_unlock_irqrestore(&pfree_queue->lock, flags); + + return _SUCCESS; +} + +struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) +{ + struct xmit_buf *pxmitbuf = NULL; + struct list_head *plist, *phead; + struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; + unsigned long flags; + + /* DBG_88E("+rtw_alloc_xmitbuf\n"); */ + + spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags); + + if (list_empty(&pfree_xmitbuf_queue->queue)) { + pxmitbuf = NULL; + } else { + phead = get_list_head(pfree_xmitbuf_queue); + + plist = phead->next; + + pxmitbuf = container_of(plist, struct xmit_buf, list); + + list_del_init(&(pxmitbuf->list)); + } + + if (pxmitbuf != NULL) { + pxmitpriv->free_xmitbuf_cnt--; + pxmitbuf->priv_data = NULL; + if (pxmitbuf->sctx) { + DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); + } + } + spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags); + + return pxmitbuf; +} + +s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +{ + struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; + unsigned long flags; + + if (pxmitbuf == NULL) + return _FAIL; + + if (pxmitbuf->sctx) { + DBG_88E("%s pxmitbuf->sctx is not NULL\n", __func__); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE); + } + + if (pxmitbuf->ext_tag) { + rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf); + } else { + spin_lock_irqsave(&pfree_xmitbuf_queue->lock, flags); + + list_del_init(&pxmitbuf->list); + + list_add_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); + + pxmitpriv->free_xmitbuf_cnt++; + spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags); + } + + return _SUCCESS; +} + +/* +Calling context: +1. OS_TXENTRY +2. RXENTRY (rx_thread or RX_ISR/RX_CallBack) + +If we turn on USE_RXTHREAD, then, no need for critical section. +Otherwise, we must use _enter/_exit critical to protect free_xmit_queue... + +Must be very very cautious... + +*/ + +struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pfree_xmit_queue) */ +{ + /* + Please remember to use all the osdep_service api, + and lock/unlock or _enter/_exit critical to protect + pfree_xmit_queue + */ + + struct xmit_frame *pxframe = NULL; + struct list_head *plist, *phead; + struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; + + spin_lock_bh(&pfree_xmit_queue->lock); + + if (list_empty(&pfree_xmit_queue->queue)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt)); + pxframe = NULL; + } else { + phead = get_list_head(pfree_xmit_queue); + + plist = phead->next; + + pxframe = container_of(plist, struct xmit_frame, list); + + list_del_init(&(pxframe->list)); + } + + if (pxframe != NULL) { /* default value setting */ + pxmitpriv->free_xmitframe_cnt--; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); + + pxframe->buf_addr = NULL; + pxframe->pxmitbuf = NULL; + + memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); + /* pxframe->attrib.psta = NULL; */ + + pxframe->frame_tag = DATA_FRAMETAG; + + pxframe->pkt = NULL; + pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */ + + pxframe->agg_num = 1; + pxframe->ack_report = 0; + } + + spin_unlock_bh(&pfree_xmit_queue->lock); + + return pxframe; +} + +s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe) +{ + struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; + struct adapter *padapter = pxmitpriv->adapter; + struct sk_buff *pndis_pkt = NULL; + + if (pxmitframe == NULL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); + goto exit; + } + + spin_lock_bh(&pfree_xmit_queue->lock); + + list_del_init(&pxmitframe->list); + + if (pxmitframe->pkt) { + pndis_pkt = pxmitframe->pkt; + pxmitframe->pkt = NULL; + } + + list_add_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); + + pxmitpriv->free_xmitframe_cnt++; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); + + spin_unlock_bh(&pfree_xmit_queue->lock); + + if (pndis_pkt) + rtw_os_pkt_complete(padapter, pndis_pkt); + +exit: + + return _SUCCESS; +} + +void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue) +{ + struct list_head *plist, *phead; + struct xmit_frame *pxmitframe; + + spin_lock_bh(&pframequeue->lock); + + phead = get_list_head(pframequeue); + plist = phead->next; + + while (phead != plist) { + pxmitframe = container_of(plist, struct xmit_frame, list); + + plist = plist->next; + + rtw_free_xmitframe(pxmitpriv, pxmitframe); + } + spin_unlock_bh(&pframequeue->lock); + +} + +s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, + ("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n")); +/* pxmitframe->pkt = NULL; */ + return _FAIL; + } + + return _SUCCESS; +} + +static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit, struct tx_servq *ptxservq, struct __queue *pframe_queue) +{ + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + + xmitframe_phead = get_list_head(pframe_queue); + xmitframe_plist = xmitframe_phead->next; + + if (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = xmitframe_plist->next; + + list_del_init(&pxmitframe->list); + + ptxservq->qcnt--; + } + return pxmitframe; +} + +struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry) +{ + struct list_head *sta_plist, *sta_phead; + struct hw_xmit *phwxmit; + struct tx_servq *ptxservq = NULL; + struct __queue *pframe_queue = NULL; + struct xmit_frame *pxmitframe = NULL; + struct adapter *padapter = pxmitpriv->adapter; + struct registry_priv *pregpriv = &padapter->registrypriv; + int i, inx[4]; + + inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; + + if (pregpriv->wifi_spec == 1) { + int j; + + for (j = 0; j < 4; j++) + inx[j] = pxmitpriv->wmm_para_seq[j]; + } + + spin_lock_bh(&pxmitpriv->lock); + + for (i = 0; i < entry; i++) { + phwxmit = phwxmit_i + inx[i]; + + sta_phead = get_list_head(phwxmit->sta_queue); + sta_plist = sta_phead->next; + + while (sta_phead != sta_plist) { + ptxservq = container_of(sta_plist, struct tx_servq, tx_pending); + + pframe_queue = &ptxservq->sta_pending; + + pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit, ptxservq, pframe_queue); + + if (pxmitframe) { + phwxmit->accnt--; + + /* Remove sta node when there are no pending packets. */ + if (list_empty(&pframe_queue->queue)) /* must be done after get_next and before break */ + list_del_init(&ptxservq->tx_pending); + goto exit; + } + + sta_plist = sta_plist->next; + } + } +exit: + spin_unlock_bh(&pxmitpriv->lock); + + return pxmitframe; +} + +struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info *psta, int up, u8 *ac) +{ + struct tx_servq *ptxservq; + + switch (up) { + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + *(ac) = 3; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + *(ac) = 1; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + *(ac) = 0; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + *(ac) = 2; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); + break; + } + + return ptxservq; +} + +/* + * Will enqueue pxmitframe to the proper queue, + * and indicate it to xx_pending list..... + */ +s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + u8 ac_index; + struct sta_info *psta; + struct tx_servq *ptxservq; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct sta_priv *pstapriv = &padapter->stapriv; + struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; + int res = _SUCCESS; + + if (pattrib->psta) { + psta = pattrib->psta; + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->ra); + } + + if (psta == NULL) { + res = _FAIL; + DBG_88E("rtw_xmit_classifier: psta == NULL\n"); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmit_classifier: psta == NULL\n")); + goto exit; + } + + ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); + + if (list_empty(&ptxservq->tx_pending)) + list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); + + list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); + ptxservq->qcnt++; + phwxmits[ac_index].accnt++; +exit: + + return res; +} + +void rtw_alloc_hwxmits(struct adapter *padapter) +{ + struct hw_xmit *hwxmits; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; + + pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); + + hwxmits = pxmitpriv->hwxmits; + + if (pxmitpriv->hwxmit_entry == 5) { + hwxmits[0] .sta_queue = &pxmitpriv->bm_pending; + hwxmits[1] .sta_queue = &pxmitpriv->vo_pending; + hwxmits[2] .sta_queue = &pxmitpriv->vi_pending; + hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; + hwxmits[4] .sta_queue = &pxmitpriv->be_pending; + } else if (pxmitpriv->hwxmit_entry == 4) { + hwxmits[0] .sta_queue = &pxmitpriv->vo_pending; + hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; + hwxmits[2] .sta_queue = &pxmitpriv->be_pending; + hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; + } else { + } +} + +void rtw_free_hwxmits(struct adapter *padapter) +{ + struct hw_xmit *hwxmits; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + hwxmits = pxmitpriv->hwxmits; + kfree(hwxmits); +} + +void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry) +{ + int i; + + for (i = 0; i < entry; i++, phwxmit++) + phwxmit->accnt = 0; + +} + +static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) +{ + struct sk_buff *skb = *pskb; + int res, is_vlan_tag = 0, i, do_nat25 = 1; + unsigned short vlan_hdr = 0; + void *br_port = NULL; + + rcu_read_lock(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); +#else + br_port = rcu_dereference(padapter->pnetdev->br_port); +#endif + rcu_read_unlock(); + spin_lock_bh(&padapter->br_ext_lock); + if (!(skb->data[0] & 1) && br_port && + memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && + *((__be16 *)(skb->data+MACADDRLEN*2)) != __constant_htons(ETH_P_8021Q) && + *((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP) && + !memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN) && padapter->scdb_entry) { + memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + padapter->scdb_entry->ageing_timer = jiffies; + spin_unlock_bh(&padapter->br_ext_lock); + } else { + if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_8021Q)) { + is_vlan_tag = 1; + vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2)); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2)); + skb_pull(skb, 4); + } + if (!memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && + (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP))) + memcpy(padapter->br_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); + + if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP)) { + if (memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN)) { + padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter, + skb->data+MACADDRLEN, skb->data+WLAN_ETHHDR_LEN+12); + if (padapter->scdb_entry) { + memcpy(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN); + memcpy(padapter->scdb_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); + padapter->scdb_entry->ageing_timer = jiffies; + do_nat25 = 0; + } + } else { + if (padapter->scdb_entry) { + padapter->scdb_entry->ageing_timer = jiffies; + do_nat25 = 0; + } else { + memset(padapter->scdb_mac, 0, MACADDRLEN); + memset(padapter->scdb_ip, 0, 4); + } + } + } + spin_unlock_bh(&padapter->br_ext_lock); + if (do_nat25) { + if (nat25_db_handle(padapter, skb, NAT25_CHECK) == 0) { + struct sk_buff *newskb; + + if (is_vlan_tag) { + skb_push(skb, 4); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); + *((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr; + } + + newskb = skb_copy(skb, GFP_ATOMIC); + if (newskb == NULL) { + DEBUG_ERR("TX DROP: skb_copy fail!\n"); + return -1; + } + dev_kfree_skb_any(skb); + + *pskb = skb = newskb; + if (is_vlan_tag) { + vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2)); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2)); + skb_pull(skb, 4); + } + } + + if (skb_is_nonlinear(skb)) + DEBUG_ERR("%s(): skb_is_nonlinear!!\n", __func__); + + res = skb_linearize(skb); + if (res < 0) { + DEBUG_ERR("TX DROP: skb_linearize fail!\n"); + return -1; + } + + res = nat25_db_handle(padapter, skb, NAT25_INSERT); + if (res < 0) { + if (res == -2) { + DEBUG_ERR("TX DROP: nat25_db_handle fail!\n"); + return -1; + } + return 0; + } + } + + memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + + dhcp_flag_bcast(padapter, skb); + + if (is_vlan_tag) { + skb_push(skb, 4); + for (i = 0; i < 6; i++) + *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); + *((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr; + } + } + + /* check if SA is equal to our MAC */ + if (memcmp(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { + DEBUG_ERR("TX DROP: untransformed frame SA:%02X%02X%02X%02X%02X%02X!\n", + skb->data[6], skb->data[7], skb->data[8], skb->data[9], skb->data[10], skb->data[11]); + return -1; + } + return 0; +} + +u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) +{ + u32 addr; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + + switch (pattrib->qsel) { + case 0: + case 3: + addr = BE_QUEUE_INX; + break; + case 1: + case 2: + addr = BK_QUEUE_INX; + break; + case 4: + case 5: + addr = VI_QUEUE_INX; + break; + case 6: + case 7: + addr = VO_QUEUE_INX; + break; + case 0x10: + addr = BCN_QUEUE_INX; + break; + case 0x11:/* BC/MC in PS (HIQ) */ + addr = HIGH_QUEUE_INX; + break; + case 0x12: + default: + addr = MGT_QUEUE_INX; + break; + } + + return addr; +} + +static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib) +{ + u8 qsel; + + qsel = pattrib->priority; + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority=%d , qsel = %d\n", pattrib->priority , qsel)); + + pattrib->qsel = qsel; +} + +/* + * The main transmit(tx) entry + * + * Return + * 1 enqueue + * 0 success, hardware will handle this xmit frame(packet) + * <0 fail + */ +s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_frame *pxmitframe = NULL; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + void *br_port = NULL; + s32 res; + + pxmitframe = rtw_alloc_xmitframe(pxmitpriv); + if (pxmitframe == NULL) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); + DBG_88E("DBG_TX_DROP_FRAME %s no more pxmitframe\n", __func__); + return -1; + } + + rcu_read_lock(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); +#else + br_port = rcu_dereference(padapter->pnetdev->br_port); +#endif + rcu_read_unlock(); + + if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { + res = rtw_br_client_tx(padapter, ppkt); + if (res == -1) { + rtw_free_xmitframe(pxmitpriv, pxmitframe); + return -1; + } + } + + res = update_attrib(padapter, *ppkt, &pxmitframe->attrib); + + if (res == _FAIL) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: update attrib fail\n")); + rtw_free_xmitframe(pxmitpriv, pxmitframe); + return -1; + } + pxmitframe->pkt = *ppkt; + + rtw_led_control(padapter, LED_CTL_TX); + + do_queue_select(padapter, &pxmitframe->attrib); + +#ifdef CONFIG_88EU_AP_MODE + spin_lock_bh(&pxmitpriv->lock); + if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) { + spin_unlock_bh(&pxmitpriv->lock); + return 1; + } + spin_unlock_bh(&pxmitpriv->lock); +#endif + + if (rtw_hal_xmit(padapter, pxmitframe) == false) + return 1; + + return 0; +} + +#if defined(CONFIG_88EU_AP_MODE) + +int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe) +{ + int ret = false; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + int bmcst = IS_MCAST(pattrib->ra); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) + return ret; + + if (pattrib->psta) + psta = pattrib->psta; + else + psta = rtw_get_stainfo(pstapriv, pattrib->ra); + + if (psta == NULL) + return ret; + + if (pattrib->triggered == 1) { + if (bmcst) + pattrib->qsel = 0x11;/* HIQ */ + return ret; + } + + if (bmcst) { + spin_lock_bh(&psta->sleep_q.lock); + + if (pstapriv->sta_dz_bitmap) {/* if any one sta is in ps mode */ + list_del_init(&pxmitframe->list); + + list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); + + psta->sleepq_len++; + + pstapriv->tim_bitmap |= BIT(0);/* */ + pstapriv->sta_dz_bitmap |= BIT(0); + + update_beacon(padapter, _TIM_IE_, NULL, false);/* tx bc/mc packets after upate bcn */ + + ret = true; + } + + spin_unlock_bh(&psta->sleep_q.lock); + + return ret; + } + + spin_lock_bh(&psta->sleep_q.lock); + + if (psta->state&WIFI_SLEEP_STATE) { + u8 wmmps_ac = 0; + + if (pstapriv->sta_dz_bitmap&BIT(psta->aid)) { + list_del_init(&pxmitframe->list); + + list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); + + psta->sleepq_len++; + + switch (pattrib->priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(0); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(0); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(0); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(0); + break; + } + + if (wmmps_ac) + psta->sleepq_ac_len++; + + if (((psta->has_legacy_ac) && (!wmmps_ac)) || + ((!psta->has_legacy_ac) && (wmmps_ac))) { + pstapriv->tim_bitmap |= BIT(psta->aid); + + if (psta->sleepq_len == 1) { + /* upate BCN for TIM IE */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } + ret = true; + } + } + + spin_unlock_bh(&psta->sleep_q.lock); + + return ret; +} + +static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue) +{ + struct list_head *plist, *phead; + u8 ac_index; + struct tx_servq *ptxservq; + struct pkt_attrib *pattrib; + struct xmit_frame *pxmitframe; + struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; + + phead = get_list_head(pframequeue); + plist = phead->next; + + while (phead != plist) { + pxmitframe = container_of(plist, struct xmit_frame, list); + + plist = plist->next; + + xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe); + + pattrib = &pxmitframe->attrib; + + ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); + + ptxservq->qcnt--; + phwxmits[ac_index].accnt--; + } +} + +void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) +{ + struct sta_info *psta_bmc; + struct sta_xmit_priv *pstaxmitpriv; + struct sta_priv *pstapriv = &padapter->stapriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + pstaxmitpriv = &psta->sta_xmitpriv; + + /* for BC/MC Frames */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + + spin_lock_bh(&pxmitpriv->lock); + + psta->state |= WIFI_SLEEP_STATE; + + pstapriv->sta_dz_bitmap |= BIT(psta->aid); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); + list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); + list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + + dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); + list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + + /* for BC/MC Frames */ + pstaxmitpriv = &psta_bmc->sta_xmitpriv; + dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); + list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + + spin_unlock_bh(&pxmitpriv->lock); +} + +void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) +{ + u8 update_mask = 0, wmmps_ac = 0; + struct sta_info *psta_bmc; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + spin_lock_bh(&psta->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = xmitframe_phead->next; + + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = xmitframe_plist->next; + + list_del_init(&pxmitframe->list); + + switch (pxmitframe->attrib.priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(1); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(1); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(1); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(1); + break; + } + + psta->sleepq_len--; + if (psta->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + if (wmmps_ac) { + psta->sleepq_ac_len--; + if (psta->sleepq_ac_len > 0) { + pxmitframe->attrib.mdata = 1; + pxmitframe->attrib.eosp = 0; + } else { + pxmitframe->attrib.mdata = 0; + pxmitframe->attrib.eosp = 1; + } + } + + pxmitframe->attrib.triggered = 1; + + spin_unlock_bh(&psta->sleep_q.lock); + if (rtw_hal_xmit(padapter, pxmitframe)) + rtw_os_xmit_complete(padapter, pxmitframe); + spin_lock_bh(&psta->sleep_q.lock); + } + + if (psta->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + update_mask = BIT(0); + + if (psta->state&WIFI_SLEEP_STATE) + psta->state ^= WIFI_SLEEP_STATE; + + if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { + psta->expire_to = pstapriv->expire_to; + psta->state ^= WIFI_STA_ALIVE_CHK_STATE; + } + + pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); + } + + spin_unlock_bh(&psta->sleep_q.lock); + + /* for BC/MC Frames */ + psta_bmc = rtw_get_bcmc_stainfo(padapter); + if (!psta_bmc) + return; + + if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0) { /* no any sta in ps mode */ + spin_lock_bh(&psta_bmc->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta_bmc->sleep_q); + xmitframe_plist = xmitframe_phead->next; + + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = xmitframe_plist->next; + + list_del_init(&pxmitframe->list); + + psta_bmc->sleepq_len--; + if (psta_bmc->sleepq_len > 0) + pxmitframe->attrib.mdata = 1; + else + pxmitframe->attrib.mdata = 0; + + pxmitframe->attrib.triggered = 1; + + spin_unlock_bh(&psta_bmc->sleep_q.lock); + if (rtw_hal_xmit(padapter, pxmitframe)) + rtw_os_xmit_complete(padapter, pxmitframe); + spin_lock_bh(&psta_bmc->sleep_q.lock); + } + + if (psta_bmc->sleepq_len == 0) { + pstapriv->tim_bitmap &= ~BIT(0); + pstapriv->sta_dz_bitmap &= ~BIT(0); + + update_mask |= BIT(1); + } + + spin_unlock_bh(&psta_bmc->sleep_q.lock); + } + + if (update_mask) + update_beacon(padapter, _TIM_IE_, NULL, false); +} + +void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) +{ + u8 wmmps_ac = 0; + struct list_head *xmitframe_plist, *xmitframe_phead; + struct xmit_frame *pxmitframe = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + + spin_lock_bh(&psta->sleep_q.lock); + + xmitframe_phead = get_list_head(&psta->sleep_q); + xmitframe_plist = xmitframe_phead->next; + + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + + xmitframe_plist = xmitframe_plist->next; + + switch (pxmitframe->attrib.priority) { + case 1: + case 2: + wmmps_ac = psta->uapsd_bk&BIT(1); + break; + case 4: + case 5: + wmmps_ac = psta->uapsd_vi&BIT(1); + break; + case 6: + case 7: + wmmps_ac = psta->uapsd_vo&BIT(1); + break; + case 0: + case 3: + default: + wmmps_ac = psta->uapsd_be&BIT(1); + break; + } + + if (!wmmps_ac) + continue; + + list_del_init(&pxmitframe->list); + + psta->sleepq_len--; + psta->sleepq_ac_len--; + + if (psta->sleepq_ac_len > 0) { + pxmitframe->attrib.mdata = 1; + pxmitframe->attrib.eosp = 0; + } else { + pxmitframe->attrib.mdata = 0; + pxmitframe->attrib.eosp = 1; + } + + pxmitframe->attrib.triggered = 1; + + if (rtw_hal_xmit(padapter, pxmitframe) == true) + rtw_os_xmit_complete(padapter, pxmitframe); + + if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { + pstapriv->tim_bitmap &= ~BIT(psta->aid); + + /* upate BCN for TIM IE */ + update_beacon(padapter, _TIM_IE_, NULL, false); + } + } + + spin_unlock_bh(&psta->sleep_q.lock); +} + +#endif + +void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms) +{ + sctx->timeout_ms = timeout_ms; + sctx->submit_time = jiffies; + init_completion(&sctx->done); + sctx->status = RTW_SCTX_SUBMITTED; +} + +int rtw_sctx_wait(struct submit_ctx *sctx) +{ + int ret = _FAIL; + unsigned long expire; + int status = 0; + + expire = sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT; + if (!wait_for_completion_timeout(&sctx->done, expire)) { + /* timeout, do something?? */ + status = RTW_SCTX_DONE_TIMEOUT; + DBG_88E("%s timeout\n", __func__); + } else { + status = sctx->status; + } + + if (status == RTW_SCTX_DONE_SUCCESS) + ret = _SUCCESS; + + return ret; +} + +static bool rtw_sctx_chk_waring_status(int status) +{ + switch (status) { + case RTW_SCTX_DONE_UNKNOWN: + case RTW_SCTX_DONE_BUF_ALLOC: + case RTW_SCTX_DONE_BUF_FREE: + + case RTW_SCTX_DONE_DRV_STOP: + case RTW_SCTX_DONE_DEV_REMOVE: + return true; + default: + return false; + } +} + +void rtw_sctx_done_err(struct submit_ctx **sctx, int status) +{ + if (*sctx) { + if (rtw_sctx_chk_waring_status(status)) + DBG_88E("%s status:%d\n", __func__, status); + (*sctx)->status = status; + complete(&((*sctx)->done)); + *sctx = NULL; + } +} + +void rtw_sctx_done(struct submit_ctx **sctx) +{ + rtw_sctx_done_err(sctx, RTW_SCTX_DONE_SUCCESS); +} + +int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms) +{ + struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; + + pack_tx_ops->submit_time = jiffies; + pack_tx_ops->timeout_ms = timeout_ms; + pack_tx_ops->status = RTW_SCTX_SUBMITTED; + + return rtw_sctx_wait(pack_tx_ops); +} + +void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status) +{ + struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; + + if (pxmitpriv->ack_tx) + rtw_sctx_done_err(&pack_tx_ops, status); + else + DBG_88E("%s ack_tx not set\n", __func__); +} -- cgit v1.2.3 From 8cd574e6af5463af7d693d111c61212e52c44810 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 28 Jul 2021 00:22:15 +0100 Subject: staging: r8188eu: introduce new hal dir for RTL8188eu driver This patchset is split in order to keep the file sizes down. This hal directory is part of the newer/better driver from GitHub modified by Larry Finger. Import this as the basis for all future work going forward. Suggested-by: Larry Finger Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210727232219.2948-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c | 86 + drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 760 +++++++ drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 720 ++++++ drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c | 230 ++ drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 268 +++ drivers/staging/r8188eu/hal/HalPhyRf.c | 49 + drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 1505 ++++++++++++ drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 132 ++ drivers/staging/r8188eu/hal/hal_com.c | 381 ++++ drivers/staging/r8188eu/hal/hal_intf.c | 468 ++++ drivers/staging/r8188eu/hal/odm.c | 2174 ++++++++++++++++++ drivers/staging/r8188eu/hal/odm_HWConfig.c | 601 +++++ drivers/staging/r8188eu/hal/odm_RTL8188E.c | 400 ++++ drivers/staging/r8188eu/hal/odm_RegConfig8188E.c | 130 ++ drivers/staging/r8188eu/hal/odm_debug.c | 32 + drivers/staging/r8188eu/hal/odm_interface.c | 205 ++ drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 762 +++++++ drivers/staging/r8188eu/hal/rtl8188e_dm.c | 267 +++ drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2390 ++++++++++++++++++++ drivers/staging/r8188eu/hal/rtl8188e_mp.c | 851 +++++++ drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 1135 ++++++++++ drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 569 +++++ drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 202 ++ drivers/staging/r8188eu/hal/rtl8188e_sreset.c | 80 + drivers/staging/r8188eu/hal/rtl8188e_xmit.c | 91 + drivers/staging/r8188eu/hal/rtl8188eu_led.c | 111 + drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 136 ++ drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 703 ++++++ drivers/staging/r8188eu/hal/usb_halinit.c | 2334 +++++++++++++++++++ drivers/staging/r8188eu/hal/usb_ops_linux.c | 717 ++++++ 30 files changed, 18489 insertions(+) create mode 100644 drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c create mode 100644 drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c create mode 100644 drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c create mode 100644 drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c create mode 100644 drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c create mode 100644 drivers/staging/r8188eu/hal/HalPhyRf.c create mode 100644 drivers/staging/r8188eu/hal/HalPhyRf_8188e.c create mode 100644 drivers/staging/r8188eu/hal/HalPwrSeqCmd.c create mode 100644 drivers/staging/r8188eu/hal/hal_com.c create mode 100644 drivers/staging/r8188eu/hal/hal_intf.c create mode 100644 drivers/staging/r8188eu/hal/odm.c create mode 100644 drivers/staging/r8188eu/hal/odm_HWConfig.c create mode 100644 drivers/staging/r8188eu/hal/odm_RTL8188E.c create mode 100644 drivers/staging/r8188eu/hal/odm_RegConfig8188E.c create mode 100644 drivers/staging/r8188eu/hal/odm_debug.c create mode 100644 drivers/staging/r8188eu/hal/odm_interface.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_cmd.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_dm.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_hal_init.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_mp.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_phycfg.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_rf6052.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_sreset.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188e_xmit.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188eu_led.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188eu_recv.c create mode 100644 drivers/staging/r8188eu/hal/rtl8188eu_xmit.c create mode 100644 drivers/staging/r8188eu/hal/usb_halinit.c create mode 100644 drivers/staging/r8188eu/hal/usb_ops_linux.c (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c b/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c new file mode 100644 index 000000000000..fc23bf159345 --- /dev/null +++ b/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c @@ -0,0 +1,86 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "Hal8188EPwrSeq.h" +#include + +/* + drivers should parse below arrays and do the corresponding actions +*/ +/* 3 Power on Array */ +struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END +}; + +/* 3Radio off Array */ +struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_END +}; + +/* 3Card Disable Array */ +struct wl_pwr_cfg rtl8188E_card_disable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_CARDDIS + RTL8188E_TRANS_END +}; + +/* 3 Card Enable Array */ +struct wl_pwr_cfg rtl8188E_card_enable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_CARDDIS_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END +}; + +/* 3Suspend Array */ +struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_SUS + RTL8188E_TRANS_END +}; + +/* 3 Resume Array */ +struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_SUS_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_ACT + RTL8188E_TRANS_END +}; + +/* 3HWPDN Array */ +struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + RTL8188E_TRANS_END_STEPS] = { + RTL8188E_TRANS_ACT_TO_CARDEMU + RTL8188E_TRANS_CARDEMU_TO_PDN + RTL8188E_TRANS_END +}; + +/* 3 Enter LPS */ +struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS] = { + /* FW behavior */ + RTL8188E_TRANS_ACT_TO_LPS + RTL8188E_TRANS_END +}; + +/* 3 Leave LPS */ +struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS] = { + /* FW behavior */ + RTL8188E_TRANS_LPS_TO_ACT + RTL8188E_TRANS_END +}; diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c new file mode 100644 index 000000000000..e9b12128b6b1 --- /dev/null +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -0,0 +1,760 @@ +/*++ +Copyright (c) Realtek Semiconductor Corp. All rights reserved. + +Module Name: + RateAdaptive.c + +Abstract: + Implement Rate Adaptive functions for common operations. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-08-12 Page Create. + +--*/ +#include "odm_precomp.h" + +/* Rate adaptive parameters */ + +static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = { + {5, 4, 3, 2, 0, 3}, /* 92 , idx = 0 */ + {6, 5, 4, 3, 0, 4}, /* 86 , idx = 1 */ + {6, 5, 4, 2, 0, 4}, /* 81 , idx = 2 */ + {8, 7, 6, 4, 0, 6}, /* 75 , idx = 3 */ + {10, 9, 8, 6, 0, 8}, /* 71 , idx = 4 */ + {10, 9, 8, 4, 0, 8}, /* 66 , idx = 5 */ + {10, 9, 8, 2, 0, 8}, /* 62 , idx = 6 */ + {10, 9, 8, 0, 0, 8}, /* 59 , idx = 7 */ + {18, 17, 16, 8, 0, 16}, /* 53 , idx = 8 */ + {26, 25, 24, 16, 0, 24}, /* 50 , idx = 9 */ + {34, 33, 32, 24, 0, 32}, /* 47 , idx = 0x0a */ + {34, 31, 28, 20, 0, 32}, /* 43 , idx = 0x0b */ + {34, 31, 27, 18, 0, 32}, /* 40 , idx = 0x0c */ + {34, 31, 26, 16, 0, 32}, /* 37 , idx = 0x0d */ + {34, 30, 22, 16, 0, 32}, /* 32 , idx = 0x0e */ + {34, 30, 24, 16, 0, 32}, /* 26 , idx = 0x0f */ + {49, 46, 40, 16, 0, 48}, /* 20 , idx = 0x10 */ + {49, 45, 32, 0, 0, 48}, /* 17 , idx = 0x11 */ + {49, 45, 22, 18, 0, 48}, /* 15 , idx = 0x12 */ + {49, 40, 24, 16, 0, 48}, /* 12 , idx = 0x13 */ + {49, 32, 18, 12, 0, 48}, /* 9 , idx = 0x14 */ + {49, 22, 18, 14, 0, 48}, /* 6 , idx = 0x15 */ + {49, 16, 16, 0, 0, 48} + }; /* 3, idx = 0x16 */ + +static u8 PT_PENALTY[RETRYSIZE+1] = {34, 31, 30, 24, 0, 32}; + +/* wilson modify */ +static u8 RETRY_PENALTY_IDX[2][RATESIZE] = { + {4, 4, 4, 5, 4, 4, 5, 7, 7, 7, 8, 0x0a, /* SS>TH */ + 4, 4, 4, 4, 6, 0x0a, 0x0b, 0x0d, + 5, 5, 7, 7, 8, 0x0b, 0x0d, 0x0f}, /* 0329 R01 */ + {0x0a, 0x0a, 0x0b, 0x0c, 0x0a, + 0x0a, 0x0b, 0x0c, 0x0d, 0x10, 0x13, 0x14, /* SSTH */ + 0x0f, 0x10, 0x10, 0x12, 0x12, 0x13, 0x14, 0x15, + 0x11, 0x11, 0x12, 0x13, 0x13, 0x13, 0x14, 0x15}; + +static u8 RSSI_THRESHOLD[RATESIZE] = { + 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0x24, 0x26, 0x2a, + 0x18, 0x1a, 0x1d, 0x1f, 0x21, 0x27, 0x29, 0x2a, + 0, 0, 0, 0x1f, 0x23, 0x28, 0x2a, 0x2c}; + +static u16 N_THRESHOLD_HIGH[RATESIZE] = { + 4, 4, 8, 16, + 24, 36, 48, 72, 96, 144, 192, 216, + 60, 80, 100, 160, 240, 400, 560, 640, + 300, 320, 480, 720, 1000, 1200, 1600, 2000}; +static u16 N_THRESHOLD_LOW[RATESIZE] = { + 2, 2, 4, 8, + 12, 18, 24, 36, 48, 72, 96, 108, + 30, 40, 50, 80, 120, 200, 280, 320, + 150, 160, 240, 360, 500, 600, 800, 1000}; + +static u8 DROPING_NECESSARY[RATESIZE] = { + 1, 1, 1, 1, + 1, 2, 3, 4, 5, 6, 7, 8, + 1, 2, 3, 4, 5, 6, 7, 8, + 5, 6, 7, 8, 9, 10, 11, 12}; + +static u8 PendingForRateUpFail[5] = {2, 10, 24, 40, 60}; +static u16 DynamicTxRPTTiming[6] = { + 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 , 0x927c}; /* 200ms-1200ms */ + +/* End Rate adaptive parameters */ + +static void odm_SetTxRPTTiming_8188E( + struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo, + u8 extend + ) +{ + u8 idx = 0; + + for (idx = 0; idx < 5; idx++) + if (DynamicTxRPTTiming[idx] == pRaInfo->RptTime) + break; + + if (extend == 0) { /* back to default timing */ + idx = 0; /* 200ms */ + } else if (extend == 1) {/* increase the timing */ + idx += 1; + if (idx > 5) + idx = 5; + } else if (extend == 2) {/* decrease the timing */ + if (idx != 0) + idx -= 1; + } + pRaInfo->RptTime = DynamicTxRPTTiming[idx]; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime)); +} + +static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) +{ + u8 RateID, LowestRate, HighestRate; + u8 i; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n")); + if (NULL == pRaInfo) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateDown_8188E(): pRaInfo is NULL\n")); + return -1; + } + RateID = pRaInfo->PreRate; + LowestRate = pRaInfo->LowestRate; + HighestRate = pRaInfo->HighestRate; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" RateID =%d LowestRate =%d HighestRate =%d RateSGI =%d\n", + RateID, LowestRate, HighestRate, pRaInfo->RateSGI)); + if (RateID > HighestRate) { + RateID = HighestRate; + } else if (pRaInfo->RateSGI) { + pRaInfo->RateSGI = 0; + } else if (RateID > LowestRate) { + if (RateID > 0) { + for (i = RateID-1; i > LowestRate; i--) { + if (pRaInfo->RAUseRate & BIT(i)) { + RateID = i; + goto RateDownFinish; + } + } + } + } else if (RateID <= LowestRate) { + RateID = LowestRate; + } +RateDownFinish: + if (pRaInfo->RAWaitingCounter == 1) { + pRaInfo->RAWaitingCounter += 1; + pRaInfo->RAPendingCounter += 1; + } else if (pRaInfo->RAWaitingCounter == 0) { + ; + } else { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } + + if (pRaInfo->RAPendingCounter >= 4) + pRaInfo->RAPendingCounter = 4; + + pRaInfo->DecisionRate = RateID; + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down, RPT Timing default\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDown_8188E()\n")); + return 0; +} + +static int odm_RateUp_8188E( + struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo + ) +{ + u8 RateID, HighestRate; + u8 i; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n")); + if (NULL == pRaInfo) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n")); + return -1; + } + RateID = pRaInfo->PreRate; + HighestRate = pRaInfo->HighestRate; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" RateID =%d HighestRate =%d\n", + RateID, HighestRate)); + if (pRaInfo->RAWaitingCounter == 1) { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } else if (pRaInfo->RAWaitingCounter > 1) { + pRaInfo->PreRssiStaRA = pRaInfo->RssiStaRA; + goto RateUpfinish; + } + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E():Decrease RPT Timing\n")); + + if (RateID < HighestRate) { + for (i = RateID+1; i <= HighestRate; i++) { + if (pRaInfo->RAUseRate & BIT(i)) { + RateID = i; + goto RateUpfinish; + } + } + } else if (RateID == HighestRate) { + if (pRaInfo->SGIEnable && (pRaInfo->RateSGI != 1)) + pRaInfo->RateSGI = 1; + else if ((pRaInfo->SGIEnable) != 1) + pRaInfo->RateSGI = 0; + } else { + RateID = HighestRate; + } +RateUpfinish: + if (pRaInfo->RAWaitingCounter == (4+PendingForRateUpFail[pRaInfo->RAPendingCounter])) + pRaInfo->RAWaitingCounter = 0; + else + pRaInfo->RAWaitingCounter++; + + pRaInfo->DecisionRate = RateID; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate up to RateID %d\n", RateID)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n")); + return 0; +} + +static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) +{ + u8 RateID; + + RateID = pRaInfo->DecisionRate; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; +} + +static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, + struct odm_ra_info *pRaInfo + ) +{ + u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0; + /* u32 pool_retry; */ + static u8 DynamicTxRPTTimingCounter; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n")); + + if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ + if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || + (pRaInfo->RssiStaRA > (pRaInfo->PreRssiStaRA + 3))) { + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + } + /* Start RA decision */ + if (pRaInfo->PreRate > pRaInfo->HighestRate) + RateID = pRaInfo->HighestRate; + else + RateID = pRaInfo->PreRate; + if (pRaInfo->RssiStaRA > RSSI_THRESHOLD[RateID]) + RtyPtID = 0; + else + RtyPtID = 1; + PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */ + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscDown init is %d\n", pRaInfo->NscDown)); + pRaInfo->NscDown += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID1][0]; + pRaInfo->NscDown += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID1][1]; + pRaInfo->NscDown += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID1][2]; + pRaInfo->NscDown += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID1][3]; + pRaInfo->NscDown += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID1][4]; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscDown is %d, total*penalty[5] is %d\n", + pRaInfo->NscDown, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))); + if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])) + pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]; + else + pRaInfo->NscDown = 0; + + /* rate up */ + PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID]; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" NscUp init is %d\n", pRaInfo->NscUp)); + pRaInfo->NscUp += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID2][0]; + pRaInfo->NscUp += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID2][1]; + pRaInfo->NscUp += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID2][2]; + pRaInfo->NscUp += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID2][3]; + pRaInfo->NscUp += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID2][4]; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("NscUp is %d, total*up[5] is %d\n", + pRaInfo->NscUp, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))); + if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5])) + pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]; + else + pRaInfo->NscUp = 0; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE|ODM_COMP_INIT, ODM_DBG_LOUD, + (" RssiStaRa = %d RtyPtID =%d PenaltyID1 = 0x%x PenaltyID2 = 0x%x RateID =%d NscDown =%d NscUp =%d SGI =%d\n", + pRaInfo->RssiStaRA, RtyPtID, PenaltyID1, PenaltyID2, RateID, pRaInfo->NscDown, pRaInfo->NscUp, pRaInfo->RateSGI)); + if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) || + (pRaInfo->DROP > DROPING_NECESSARY[RateID])) + odm_RateDown_8188E(dm_odm, pRaInfo); + else if (pRaInfo->NscUp > N_THRESHOLD_HIGH[RateID]) + odm_RateUp_8188E(dm_odm, pRaInfo); + + if (pRaInfo->DecisionRate > pRaInfo->HighestRate) + pRaInfo->DecisionRate = pRaInfo->HighestRate; + + if ((pRaInfo->DecisionRate) == (pRaInfo->PreRate)) + DynamicTxRPTTimingCounter += 1; + else + DynamicTxRPTTimingCounter = 0; + + if (DynamicTxRPTTimingCounter >= 4) { + odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 1); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, + ODM_DBG_LOUD, ("<===== Rate don't change 4 times, Extend RPT Timing\n")); + DynamicTxRPTTimingCounter = 0; + } + + pRaInfo->PreRate = pRaInfo->DecisionRate; /* YJ, add, 120120 */ + + odm_ResetRaCounter_8188E(pRaInfo); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDecision_8188E()\n")); +} + +static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) +{ /* Wilson 2011/10/26 */ + u32 MaskFromReg; + s8 i; + + switch (pRaInfo->RateID) { + case RATR_INX_WIRELESS_NGB: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff015; + break; + case RATR_INX_WIRELESS_NG: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff010; + break; + case RATR_INX_WIRELESS_NB: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff005; + break; + case RATR_INX_WIRELESS_N: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff000; + break; + case RATR_INX_WIRELESS_GB: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff5; + break; + case RATR_INX_WIRELESS_G: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff0; + break; + case RATR_INX_WIRELESS_B: + pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0000000d; + break; + case 12: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR0); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 13: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR1); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 14: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR2); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + case 15: + MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR3); + pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + break; + default: + pRaInfo->RAUseRate = (pRaInfo->RateMask); + break; + } + /* Highest rate */ + if (pRaInfo->RAUseRate) { + for (i = RATESIZE; i >= 0; i--) { + if ((pRaInfo->RAUseRate)&BIT(i)) { + pRaInfo->HighestRate = i; + break; + } + } + } else { + pRaInfo->HighestRate = 0; + } + /* Lowest rate */ + if (pRaInfo->RAUseRate) { + for (i = 0; i < RATESIZE; i++) { + if ((pRaInfo->RAUseRate) & BIT(i)) { + pRaInfo->LowestRate = i; + break; + } + } + } else { + pRaInfo->LowestRate = 0; + } + if (pRaInfo->HighestRate > 0x13) + pRaInfo->PTModeSS = 3; + else if (pRaInfo->HighestRate > 0x0b) + pRaInfo->PTModeSS = 2; + else if (pRaInfo->HighestRate > 0x03) + pRaInfo->PTModeSS = 1; + else + pRaInfo->PTModeSS = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_ARFBRefresh_8188E(): PTModeSS =%d\n", pRaInfo->PTModeSS)); + + if (pRaInfo->DecisionRate > pRaInfo->HighestRate) + pRaInfo->DecisionRate = pRaInfo->HighestRate; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_ARFBRefresh_8188E(): RateID =%d RateMask =%8.8x RAUseRate =%8.8x HighestRate =%d, DecisionRate =%d\n", + pRaInfo->RateID, pRaInfo->RateMask, pRaInfo->RAUseRate, pRaInfo->HighestRate, pRaInfo->DecisionRate)); + return 0; +} + +static void odm_PTTryState_8188E(struct odm_ra_info *pRaInfo) +{ + pRaInfo->PTTryState = 0; + switch (pRaInfo->PTModeSS) { + case 3: + if (pRaInfo->DecisionRate >= 0x19) + pRaInfo->PTTryState = 1; + break; + case 2: + if (pRaInfo->DecisionRate >= 0x11) + pRaInfo->PTTryState = 1; + break; + case 1: + if (pRaInfo->DecisionRate >= 0x0a) + pRaInfo->PTTryState = 1; + break; + case 0: + if (pRaInfo->DecisionRate >= 0x03) + pRaInfo->PTTryState = 1; + break; + default: + pRaInfo->PTTryState = 0; + break; + } + + if (pRaInfo->RssiStaRA < 48) { + pRaInfo->PTStage = 0; + } else if (pRaInfo->PTTryState == 1) { + if ((pRaInfo->PTStopCount >= 10) || + (pRaInfo->PTPreRssi > pRaInfo->RssiStaRA + 5) || + (pRaInfo->PTPreRssi < pRaInfo->RssiStaRA - 5) || + (pRaInfo->DecisionRate != pRaInfo->PTPreRate)) { + if (pRaInfo->PTStage == 0) + pRaInfo->PTStage = 1; + else if (pRaInfo->PTStage == 1) + pRaInfo->PTStage = 3; + else + pRaInfo->PTStage = 5; + + pRaInfo->PTPreRssi = pRaInfo->RssiStaRA; + pRaInfo->PTStopCount = 0; + } else { + pRaInfo->RAstage = 0; + pRaInfo->PTStopCount++; + } + } else { + pRaInfo->PTStage = 0; + pRaInfo->RAstage = 0; + } + pRaInfo->PTPreRate = pRaInfo->DecisionRate; +} + +static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) +{ + u8 j; + u8 temp_stage; + u32 numsc; + u32 num_total; + u8 stage_id; + + numsc = 0; + num_total = pRaInfo->TOTAL * PT_PENALTY[5]; + for (j = 0; j <= 4; j++) { + numsc += pRaInfo->RTY[j] * PT_PENALTY[j]; + if (numsc > num_total) + break; + } + + j = j >> 1; + temp_stage = (pRaInfo->PTStage + 1) >> 1; + if (temp_stage > j) + stage_id = temp_stage-j; + else + stage_id = 0; + + pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor>>1) + (pRaInfo->PTSmoothFactor>>2) + stage_id*16+2; + if (pRaInfo->PTSmoothFactor > 192) + pRaInfo->PTSmoothFactor = 192; + stage_id = pRaInfo->PTSmoothFactor >> 6; + temp_stage = stage_id*2; + if (temp_stage != 0) + temp_stage -= 1; + if (pRaInfo->DROP > 3) + temp_stage = 0; + pRaInfo->PTStage = temp_stage; +} + +static void +odm_RATxRPTTimerSetting( + struct odm_dm_struct *dm_odm, + u16 minRptTime +) +{ + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" =====>odm_RATxRPTTimerSetting()\n")); + + if (dm_odm->CurrminRptTime != minRptTime) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + (" CurrminRptTime = 0x%04x minRptTime = 0x%04x\n", dm_odm->CurrminRptTime, minRptTime)); + rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime); + dm_odm->CurrminRptTime = minRptTime; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" <===== odm_RATxRPTTimerSetting()\n")); +} + +void +ODM_RASupport_Init( + struct odm_dm_struct *dm_odm + ) +{ + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); + + /* 2012/02/14 MH Be noticed, the init must be after IC type is recognized!!!!! */ + if (dm_odm->SupportICType == ODM_RTL8188E) + dm_odm->RaSupport88E = true; +} + +int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) +{ + struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid]; + u8 WirelessMode = 0xFF; /* invalid value */ + u8 max_rate_idx = 0x13; /* MCS7 */ + if (dm_odm->pWirelessMode != NULL) + WirelessMode = *(dm_odm->pWirelessMode); + + if (WirelessMode != 0xFF) { + if (WirelessMode & ODM_WM_N24G) + max_rate_idx = 0x13; + else if (WirelessMode & ODM_WM_G) + max_rate_idx = 0x0b; + else if (WirelessMode & ODM_WM_B) + max_rate_idx = 0x03; + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("ODM_RAInfo_Init(): WirelessMode:0x%08x , max_raid_idx:0x%02x\n", + WirelessMode, max_rate_idx)); + + pRaInfo->DecisionRate = max_rate_idx; + pRaInfo->PreRate = max_rate_idx; + pRaInfo->HighestRate = max_rate_idx; + pRaInfo->LowestRate = 0; + pRaInfo->RateID = 0; + pRaInfo->RateMask = 0xffffffff; + pRaInfo->RssiStaRA = 0; + pRaInfo->PreRssiStaRA = 0; + pRaInfo->SGIEnable = 0; + pRaInfo->RAUseRate = 0xffffffff; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; + pRaInfo->RateSGI = 0; + pRaInfo->Active = 1; /* Active is not used at present. by page, 110819 */ + pRaInfo->RptTime = 0x927c; + pRaInfo->DROP = 0; + pRaInfo->RTY[0] = 0; + pRaInfo->RTY[1] = 0; + pRaInfo->RTY[2] = 0; + pRaInfo->RTY[3] = 0; + pRaInfo->RTY[4] = 0; + pRaInfo->TOTAL = 0; + pRaInfo->RAWaitingCounter = 0; + pRaInfo->RAPendingCounter = 0; + pRaInfo->PTActive = 1; /* Active when this STA is use */ + pRaInfo->PTTryState = 0; + pRaInfo->PTStage = 5; /* Need to fill into HW_PWR_STATUS */ + pRaInfo->PTSmoothFactor = 192; + pRaInfo->PTStopCount = 0; + pRaInfo->PTPreRate = 0; + pRaInfo->PTPreRssi = 0; + pRaInfo->PTModeSS = 0; + pRaInfo->RAstage = 0; + return 0; +} + +int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm) +{ + u8 macid = 0; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>\n")); + dm_odm->CurrminRptTime = 0; + + for (macid = 0; macid < ODM_ASSOCIATE_ENTRY_NUM; macid++) + ODM_RAInfo_Init(dm_odm, macid); + + return 0; +} + +u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 macid) +{ + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("macid =%d SGI =%d\n", macid, dm_odm->RAInfo[macid].RateSGI)); + return dm_odm->RAInfo[macid].RateSGI; +} + +u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid) +{ + u8 DecisionRate = 0; + + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return 0; + DecisionRate = (dm_odm->RAInfo[macid].DecisionRate); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate)); + return DecisionRate; +} + +u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 macid) +{ + u8 PTStage = 5; + + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return 0; + PTStage = (dm_odm->RAInfo[macid].PTStage); + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + ("macid =%d PTStage = 0x%x\n", macid, PTStage)); + return PTStage; +} + +void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 RateID, u32 RateMask, u8 SGIEnable) +{ + struct odm_ra_info *pRaInfo = NULL; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("macid =%d RateID = 0x%x RateMask = 0x%x SGIEnable =%d\n", + macid, RateID, RateMask, SGIEnable)); + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return; + + pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo->RateID = RateID; + pRaInfo->RateMask = RateMask; + pRaInfo->SGIEnable = SGIEnable; + odm_ARFBRefresh_8188E(dm_odm, pRaInfo); +} + +void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) +{ + struct odm_ra_info *pRaInfo = NULL; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, + (" macid =%d Rssi =%d\n", macid, Rssi)); + if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) + return; + + pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo->RssiStaRA = Rssi; +} + +void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime) +{ + ODM_Write2Byte(dm_odm, REG_TX_RPT_TIME, minRptTime); +} + +void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 TxRPT_Len, u32 macid_entry0, u32 macid_entry1) +{ + struct odm_ra_info *pRAInfo = NULL; + u8 MacId = 0; + u8 *pBuffer = NULL; + u32 valid = 0, ItemNum = 0; + u16 minRptTime = 0x927c; + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("=====>ODM_RA_TxRPT2Handle_8188E(): valid0 =%d valid1 =%d BufferLength =%d\n", + macid_entry0, macid_entry1, TxRPT_Len)); + + ItemNum = TxRPT_Len >> 3; + pBuffer = TxRPT_Buf; + + do { + if (MacId >= ASSOCIATE_ENTRY_NUM) + valid = 0; + else if (MacId >= 32) + valid = (1 << (MacId - 32)) & macid_entry1; + else + valid = (1 << MacId) & macid_entry0; + + pRAInfo = &(dm_odm->RAInfo[MacId]); + if (valid) { + pRAInfo->RTY[0] = (u16)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer); + pRAInfo->RTY[1] = (u16)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer); + pRAInfo->RTY[2] = (u16)GET_TX_REPORT_TYPE1_RERTY_2(pBuffer); + pRAInfo->RTY[3] = (u16)GET_TX_REPORT_TYPE1_RERTY_3(pBuffer); + pRAInfo->RTY[4] = (u16)GET_TX_REPORT_TYPE1_RERTY_4(pBuffer); + pRAInfo->DROP = (u16)GET_TX_REPORT_TYPE1_DROP_0(pBuffer); + pRAInfo->TOTAL = pRAInfo->RTY[0] + pRAInfo->RTY[1] + + pRAInfo->RTY[2] + pRAInfo->RTY[3] + + pRAInfo->RTY[4] + pRAInfo->DROP; + if (pRAInfo->TOTAL != 0) { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, + ("macid =%d Total =%d R0 =%d R1 =%d R2 =%d R3 =%d R4 =%d D0 =%d valid0 =%x valid1 =%x\n", + MacId, pRAInfo->TOTAL, + pRAInfo->RTY[0], pRAInfo->RTY[1], + pRAInfo->RTY[2], pRAInfo->RTY[3], + pRAInfo->RTY[4], pRAInfo->DROP, + macid_entry0 , macid_entry1)); + if (pRAInfo->PTActive) { + if (pRAInfo->RAstage < 5) + odm_RateDecision_8188E(dm_odm, pRAInfo); + else if (pRAInfo->RAstage == 5) /* Power training try state */ + odm_PTTryState_8188E(pRAInfo); + else /* RAstage == 6 */ + odm_PTDecision_8188E(pRAInfo); + + /* Stage_RA counter */ + if (pRAInfo->RAstage <= 5) + pRAInfo->RAstage++; + else + pRAInfo->RAstage = 0; + } else { + odm_RateDecision_8188E(dm_odm, pRAInfo); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("macid =%d R0 =%d R1 =%d R2 =%d R3 =%d R4 =%d drop =%d valid0 =%x RateID =%d SGI =%d\n", + MacId, + pRAInfo->RTY[0], + pRAInfo->RTY[1], + pRAInfo->RTY[2], + pRAInfo->RTY[3], + pRAInfo->RTY[4], + pRAInfo->DROP, + macid_entry0, + pRAInfo->DecisionRate, + pRAInfo->RateSGI)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, (" TOTAL = 0!!!!\n")); + } + } + + if (minRptTime > pRAInfo->RptTime) + minRptTime = pRAInfo->RptTime; + + pBuffer += TX_RPT2_ITEM_SIZE; + MacId++; + } while (MacId < ItemNum); + + odm_RATxRPTTimerSetting(dm_odm, minRptTime); + + ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n")); +} diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c new file mode 100644 index 000000000000..f06c14cd4e04 --- /dev/null +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -0,0 +1,720 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" + +#include + +#define read_next_pair(array, v1, v2, i) \ + do { \ + i += 2; \ + v1 = array[i]; \ + v2 = array[i+1]; \ + } while (0) + +static bool CheckCondition(const u32 condition, const u32 hex) +{ + u32 _board = (hex & 0x000000FF); + u32 _interface = (hex & 0x0000FF00) >> 8; + u32 _platform = (hex & 0x00FF0000) >> 16; + u32 cond = condition; + + if (condition == 0xCDCDCDCD) + return true; + + cond = condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + +/****************************************************************************** +* AGC_TAB_1T.TXT +******************************************************************************/ + +static u32 array_agc_tab_1t_8188e[] = { + 0xC78, 0xFB000001, + 0xC78, 0xFB010001, + 0xC78, 0xFB020001, + 0xC78, 0xFB030001, + 0xC78, 0xFB040001, + 0xC78, 0xFB050001, + 0xC78, 0xFA060001, + 0xC78, 0xF9070001, + 0xC78, 0xF8080001, + 0xC78, 0xF7090001, + 0xC78, 0xF60A0001, + 0xC78, 0xF50B0001, + 0xC78, 0xF40C0001, + 0xC78, 0xF30D0001, + 0xC78, 0xF20E0001, + 0xC78, 0xF10F0001, + 0xC78, 0xF0100001, + 0xC78, 0xEF110001, + 0xC78, 0xEE120001, + 0xC78, 0xED130001, + 0xC78, 0xEC140001, + 0xC78, 0xEB150001, + 0xC78, 0xEA160001, + 0xC78, 0xE9170001, + 0xC78, 0xE8180001, + 0xC78, 0xE7190001, + 0xC78, 0xE61A0001, + 0xC78, 0xE51B0001, + 0xC78, 0xE41C0001, + 0xC78, 0xE31D0001, + 0xC78, 0xE21E0001, + 0xC78, 0xE11F0001, + 0xC78, 0x8A200001, + 0xC78, 0x89210001, + 0xC78, 0x88220001, + 0xC78, 0x87230001, + 0xC78, 0x86240001, + 0xC78, 0x85250001, + 0xC78, 0x84260001, + 0xC78, 0x83270001, + 0xC78, 0x82280001, + 0xC78, 0x6B290001, + 0xC78, 0x6A2A0001, + 0xC78, 0x692B0001, + 0xC78, 0x682C0001, + 0xC78, 0x672D0001, + 0xC78, 0x662E0001, + 0xC78, 0x652F0001, + 0xC78, 0x64300001, + 0xC78, 0x63310001, + 0xC78, 0x62320001, + 0xC78, 0x61330001, + 0xC78, 0x46340001, + 0xC78, 0x45350001, + 0xC78, 0x44360001, + 0xC78, 0x43370001, + 0xC78, 0x42380001, + 0xC78, 0x41390001, + 0xC78, 0x403A0001, + 0xC78, 0x403B0001, + 0xC78, 0x403C0001, + 0xC78, 0x403D0001, + 0xC78, 0x403E0001, + 0xC78, 0x403F0001, + 0xC78, 0xFB400001, + 0xC78, 0xFB410001, + 0xC78, 0xFB420001, + 0xC78, 0xFB430001, + 0xC78, 0xFB440001, + 0xC78, 0xFB450001, + 0xC78, 0xFB460001, + 0xC78, 0xFB470001, + 0xC78, 0xFB480001, + 0xC78, 0xFA490001, + 0xC78, 0xF94A0001, + 0xC78, 0xF84B0001, + 0xC78, 0xF74C0001, + 0xC78, 0xF64D0001, + 0xC78, 0xF54E0001, + 0xC78, 0xF44F0001, + 0xC78, 0xF3500001, + 0xC78, 0xF2510001, + 0xC78, 0xF1520001, + 0xC78, 0xF0530001, + 0xC78, 0xEF540001, + 0xC78, 0xEE550001, + 0xC78, 0xED560001, + 0xC78, 0xEC570001, + 0xC78, 0xEB580001, + 0xC78, 0xEA590001, + 0xC78, 0xE95A0001, + 0xC78, 0xE85B0001, + 0xC78, 0xE75C0001, + 0xC78, 0xE65D0001, + 0xC78, 0xE55E0001, + 0xC78, 0xE45F0001, + 0xC78, 0xE3600001, + 0xC78, 0xE2610001, + 0xC78, 0xC3620001, + 0xC78, 0xC2630001, + 0xC78, 0xC1640001, + 0xC78, 0x8B650001, + 0xC78, 0x8A660001, + 0xC78, 0x89670001, + 0xC78, 0x88680001, + 0xC78, 0x87690001, + 0xC78, 0x866A0001, + 0xC78, 0x856B0001, + 0xC78, 0x846C0001, + 0xC78, 0x676D0001, + 0xC78, 0x666E0001, + 0xC78, 0x656F0001, + 0xC78, 0x64700001, + 0xC78, 0x63710001, + 0xC78, 0x62720001, + 0xC78, 0x61730001, + 0xC78, 0x60740001, + 0xC78, 0x46750001, + 0xC78, 0x45760001, + 0xC78, 0x44770001, + 0xC78, 0x43780001, + 0xC78, 0x42790001, + 0xC78, 0x417A0001, + 0xC78, 0x407B0001, + 0xC78, 0x407C0001, + 0xC78, 0x407D0001, + 0xC78, 0x407E0001, + 0xC78, 0x407F0001, +}; + +enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) +{ + u32 hex = 0; + u32 i = 0; + u8 platform = dm_odm->SupportPlatform; + u8 interfaceValue = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 arraylen = sizeof(array_agc_tab_1t_8188e)/sizeof(u32); + u32 *array = array_agc_tab_1t_8188e; + bool biol = false; + struct adapter *adapter = dm_odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + + hex += board; + hex += interfaceValue << 8; + hex += platform << 16; + hex += 0xFF000000; + biol = rtw_IOL_applied(adapter); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < arraylen; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } else { + odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2); + } + continue; + } else { + /* This line is the start line of branch. */ + if (!CheckCondition(array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } else { + odm_ConfigBB_AGC_8188E(dm_odm, v1, bMaskDWord, v2); + } + read_next_pair(array, v1, v2, i); + } + + while (v2 != 0xDEAD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + printk("~~~ %s IOL_exec_cmds Failed !!!\n", __func__); + rst = HAL_STATUS_FAILURE; + } + } + return rst; +} + +/****************************************************************************** +* PHY_REG_1T.TXT +******************************************************************************/ + +static u32 array_phy_reg_1t_8188e[] = { + 0x800, 0x80040000, + 0x804, 0x00000003, + 0x808, 0x0000FC00, + 0x80C, 0x0000000A, + 0x810, 0x10001331, + 0x814, 0x020C3D10, + 0x818, 0x02200385, + 0x81C, 0x00000000, + 0x820, 0x01000100, + 0x824, 0x00390204, + 0x828, 0x00000000, + 0x82C, 0x00000000, + 0x830, 0x00000000, + 0x834, 0x00000000, + 0x838, 0x00000000, + 0x83C, 0x00000000, + 0x840, 0x00010000, + 0x844, 0x00000000, + 0x848, 0x00000000, + 0x84C, 0x00000000, + 0x850, 0x00000000, + 0x854, 0x00000000, + 0x858, 0x569A11A9, + 0x85C, 0x01000014, + 0x860, 0x66F60110, + 0x864, 0x061F0649, + 0x868, 0x00000000, + 0x86C, 0x27272700, + 0x870, 0x07000760, + 0x874, 0x25004000, + 0x878, 0x00000808, + 0x87C, 0x00000000, + 0x880, 0xB0000C1C, + 0x884, 0x00000001, + 0x888, 0x00000000, + 0x88C, 0xCCC000C0, + 0x890, 0x00000800, + 0x894, 0xFFFFFFFE, + 0x898, 0x40302010, + 0x89C, 0x00706050, + 0x900, 0x00000000, + 0x904, 0x00000023, + 0x908, 0x00000000, + 0x90C, 0x81121111, + 0x910, 0x00000002, + 0x914, 0x00000201, + 0xA00, 0x00D047C8, + 0xA04, 0x80FF000C, + 0xA08, 0x8C838300, + 0xA0C, 0x2E7F120F, + 0xA10, 0x9500BB78, + 0xA14, 0x1114D028, + 0xA18, 0x00881117, + 0xA1C, 0x89140F00, + 0xA20, 0x1A1B0000, + 0xA24, 0x090E1317, + 0xA28, 0x00000204, + 0xA2C, 0x00D30000, + 0xA70, 0x101FBF00, + 0xA74, 0x00000007, + 0xA78, 0x00000900, + 0xA7C, 0x225B0606, + 0xA80, 0x218075B1, + 0xB2C, 0x80000000, + 0xC00, 0x48071D40, + 0xC04, 0x03A05611, + 0xC08, 0x000000E4, + 0xC0C, 0x6C6C6C6C, + 0xC10, 0x08800000, + 0xC14, 0x40000100, + 0xC18, 0x08800000, + 0xC1C, 0x40000100, + 0xC20, 0x00000000, + 0xC24, 0x00000000, + 0xC28, 0x00000000, + 0xC2C, 0x00000000, + 0xC30, 0x69E9AC47, + 0xC34, 0x469652AF, + 0xC38, 0x49795994, + 0xC3C, 0x0A97971C, + 0xC40, 0x1F7C403F, + 0xC44, 0x000100B7, + 0xC48, 0xEC020107, + 0xC4C, 0x007F037F, + 0xC50, 0x69553420, + 0xC54, 0x43BC0094, + 0xC58, 0x00013169, + 0xC5C, 0x00250492, + 0xC60, 0x00000000, + 0xC64, 0x7112848B, + 0xC68, 0x47C00BFF, + 0xC6C, 0x00000036, + 0xC70, 0x2C7F000D, + 0xC74, 0x020610DB, + 0xC78, 0x0000001F, + 0xC7C, 0x00B91612, + 0xC80, 0x390000E4, + 0xC84, 0x20F60000, + 0xC88, 0x40000100, + 0xC8C, 0x20200000, + 0xC90, 0x00091521, + 0xC94, 0x00000000, + 0xC98, 0x00121820, + 0xC9C, 0x00007F7F, + 0xCA0, 0x00000000, + 0xCA4, 0x000300A0, + 0xCA8, 0x00000000, + 0xCAC, 0x00000000, + 0xCB0, 0x00000000, + 0xCB4, 0x00000000, + 0xCB8, 0x00000000, + 0xCBC, 0x28000000, + 0xCC0, 0x00000000, + 0xCC4, 0x00000000, + 0xCC8, 0x00000000, + 0xCCC, 0x00000000, + 0xCD0, 0x00000000, + 0xCD4, 0x00000000, + 0xCD8, 0x64B22427, + 0xCDC, 0x00766932, + 0xCE0, 0x00222222, + 0xCE4, 0x00000000, + 0xCE8, 0x37644302, + 0xCEC, 0x2F97D40C, + 0xD00, 0x00000740, + 0xD04, 0x00020401, + 0xD08, 0x0000907F, + 0xD0C, 0x20010201, + 0xD10, 0xA0633333, + 0xD14, 0x3333BC43, + 0xD18, 0x7A8F5B6F, + 0xD2C, 0xCC979975, + 0xD30, 0x00000000, + 0xD34, 0x80608000, + 0xD38, 0x00000000, + 0xD3C, 0x00127353, + 0xD40, 0x00000000, + 0xD44, 0x00000000, + 0xD48, 0x00000000, + 0xD4C, 0x00000000, + 0xD50, 0x6437140A, + 0xD54, 0x00000000, + 0xD58, 0x00000282, + 0xD5C, 0x30032064, + 0xD60, 0x4653DE68, + 0xD64, 0x04518A3C, + 0xD68, 0x00002101, + 0xD6C, 0x2A201C16, + 0xD70, 0x1812362E, + 0xD74, 0x322C2220, + 0xD78, 0x000E3C24, + 0xE00, 0x2D2D2D2D, + 0xE04, 0x2D2D2D2D, + 0xE08, 0x0390272D, + 0xE10, 0x2D2D2D2D, + 0xE14, 0x2D2D2D2D, + 0xE18, 0x2D2D2D2D, + 0xE1C, 0x2D2D2D2D, + 0xE28, 0x00000000, + 0xE30, 0x1000DC1F, + 0xE34, 0x10008C1F, + 0xE38, 0x02140102, + 0xE3C, 0x681604C2, + 0xE40, 0x01007C00, + 0xE44, 0x01004800, + 0xE48, 0xFB000000, + 0xE4C, 0x000028D1, + 0xE50, 0x1000DC1F, + 0xE54, 0x10008C1F, + 0xE58, 0x02140102, + 0xE5C, 0x28160D05, + 0xE60, 0x00000008, + 0xE68, 0x001B25A4, + 0xE6C, 0x00C00014, + 0xE70, 0x00C00014, + 0xE74, 0x01000014, + 0xE78, 0x01000014, + 0xE7C, 0x01000014, + 0xE80, 0x01000014, + 0xE84, 0x00C00014, + 0xE88, 0x01000014, + 0xE8C, 0x00C00014, + 0xED0, 0x00C00014, + 0xED4, 0x00C00014, + 0xED8, 0x00C00014, + 0xEDC, 0x00000014, + 0xEE0, 0x00000014, + 0xEEC, 0x01C00014, + 0xF14, 0x00000003, + 0xF4C, 0x00000000, + 0xF00, 0x00000300, +}; + +enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) +{ + u32 hex = 0; + u32 i = 0; + u8 platform = dm_odm->SupportPlatform; + u8 interfaceValue = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 arraylen = sizeof(array_phy_reg_1t_8188e)/sizeof(u32); + u32 *array = array_phy_reg_1t_8188e; + bool biol = false; + struct adapter *adapter = dm_odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + hex += board; + hex += interfaceValue << 8; + hex += platform << 16; + hex += 0xFF000000; + biol = rtw_IOL_applied(adapter); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < arraylen; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + if (v1 == 0xfe) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + } else if (v1 == 0xfd) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + } else if (v1 == 0xfc) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + } else if (v1 == 0xfb) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + } else if (v1 == 0xfa) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + } else if (v1 == 0xf9) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + } else { + if (v1 == 0xa24) + dm_odm->RFCalibrateInfo.RegA24 = v2; + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } + } else { + odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2); + } + continue; + } else { /* This line is the start line of branch. */ + if (!CheckCondition(array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + read_next_pair(array, v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < arraylen - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + if (v1 == 0xfe) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + } else if (v1 == 0xfd) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + } else if (v1 == 0xfc) { + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + } else if (v1 == 0xfb) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + } else if (v1 == 0xfa) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + } else if (v1 == 0xf9) { + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + } else{ + if (v1 == 0xa24) + dm_odm->RFCalibrateInfo.RegA24 = v2; + + rtw_IOL_append_WD_cmd(pxmit_frame, (u16)v1, v2, bMaskDWord); + } + } else { + odm_ConfigBB_PHY_8188E(dm_odm, v1, bMaskDWord, v2); + } + read_next_pair(array, v1, v2, i); + } + + while (v2 != 0xDEAD && i < arraylen - 2) + read_next_pair(array, v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + rst = HAL_STATUS_FAILURE; + pr_info("~~~ IOL Config %s Failed !!!\n", __func__); + } + } + return rst; +} + +/****************************************************************************** +* PHY_REG_PG.TXT +******************************************************************************/ + +static u32 array_phy_reg_pg_8188e[] = { + 0xE00, 0xFFFFFFFF, 0x06070809, + 0xE04, 0xFFFFFFFF, 0x02020405, + 0xE08, 0x0000FF00, 0x00000006, + 0x86C, 0xFFFFFF00, 0x00020400, + 0xE10, 0xFFFFFFFF, 0x08090A0B, + 0xE14, 0xFFFFFFFF, 0x01030607, + 0xE18, 0xFFFFFFFF, 0x08090A0B, + 0xE1C, 0xFFFFFFFF, 0x01030607, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x02020202, + 0xE04, 0xFFFFFFFF, 0x00020202, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x04040404, + 0xE14, 0xFFFFFFFF, 0x00020404, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x02020202, + 0xE04, 0xFFFFFFFF, 0x00020202, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x04040404, + 0xE14, 0xFFFFFFFF, 0x00020404, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x02020202, + 0xE04, 0xFFFFFFFF, 0x00020202, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x04040404, + 0xE14, 0xFFFFFFFF, 0x00020404, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + 0xE00, 0xFFFFFFFF, 0x00000000, + 0xE04, 0xFFFFFFFF, 0x00000000, + 0xE08, 0x0000FF00, 0x00000000, + 0x86C, 0xFFFFFF00, 0x00000000, + 0xE10, 0xFFFFFFFF, 0x00000000, + 0xE14, 0xFFFFFFFF, 0x00000000, + 0xE18, 0xFFFFFFFF, 0x00000000, + 0xE1C, 0xFFFFFFFF, 0x00000000, + +}; + +void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm) +{ + u32 hex; + u32 i = 0; + u8 platform = dm_odm->SupportPlatform; + u8 interfaceValue = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 arraylen = sizeof(array_phy_reg_pg_8188e) / sizeof(u32); + u32 *array = array_phy_reg_pg_8188e; + + hex = board + (interfaceValue << 8); + hex += (platform << 16) + 0xFF000000; + + for (i = 0; i < arraylen; i += 3) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + u32 v3 = array[i+2]; + + /* this line is a line of pure_body */ + if (v1 < 0xCDCDCDCD) { + odm_ConfigBB_PHY_REG_PG_8188E(dm_odm, v1, v2, v3); + continue; + } else { /* this line is the start of branch */ + if (!CheckCondition(array[i], hex)) { + /* don't need the hw_body */ + i += 2; /* skip the pair of expression */ + v1 = array[i]; + v2 = array[i+1]; + v3 = array[i+2]; + while (v2 != 0xDEAD) { + i += 3; + v1 = array[i]; + v2 = array[i+1]; + v3 = array[i+1]; + } + } + } + } +} diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c new file mode 100644 index 000000000000..bac0238e314c --- /dev/null +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c @@ -0,0 +1,230 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" +#include + +static bool Checkcondition(const u32 condition, const u32 hex) +{ + u32 _board = (hex & 0x000000FF); + u32 _interface = (hex & 0x0000FF00) >> 8; + u32 _platform = (hex & 0x00FF0000) >> 16; + u32 cond = condition; + + if (condition == 0xCDCDCDCD) + return true; + + cond = condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + +/****************************************************************************** +* MAC_REG.TXT +******************************************************************************/ + +static u32 array_MAC_REG_8188E[] = { + 0x026, 0x00000041, + 0x027, 0x00000035, + 0x428, 0x0000000A, + 0x429, 0x00000010, + 0x430, 0x00000000, + 0x431, 0x00000001, + 0x432, 0x00000002, + 0x433, 0x00000004, + 0x434, 0x00000005, + 0x435, 0x00000006, + 0x436, 0x00000007, + 0x437, 0x00000008, + 0x438, 0x00000000, + 0x439, 0x00000000, + 0x43A, 0x00000001, + 0x43B, 0x00000002, + 0x43C, 0x00000004, + 0x43D, 0x00000005, + 0x43E, 0x00000006, + 0x43F, 0x00000007, + 0x440, 0x0000005D, + 0x441, 0x00000001, + 0x442, 0x00000000, + 0x444, 0x00000015, + 0x445, 0x000000F0, + 0x446, 0x0000000F, + 0x447, 0x00000000, + 0x458, 0x00000041, + 0x459, 0x000000A8, + 0x45A, 0x00000072, + 0x45B, 0x000000B9, + 0x460, 0x00000066, + 0x461, 0x00000066, + 0x480, 0x00000008, + 0x4C8, 0x000000FF, + 0x4C9, 0x00000008, + 0x4CC, 0x000000FF, + 0x4CD, 0x000000FF, + 0x4CE, 0x00000001, + 0x4D3, 0x00000001, + 0x500, 0x00000026, + 0x501, 0x000000A2, + 0x502, 0x0000002F, + 0x503, 0x00000000, + 0x504, 0x00000028, + 0x505, 0x000000A3, + 0x506, 0x0000005E, + 0x507, 0x00000000, + 0x508, 0x0000002B, + 0x509, 0x000000A4, + 0x50A, 0x0000005E, + 0x50B, 0x00000000, + 0x50C, 0x0000004F, + 0x50D, 0x000000A4, + 0x50E, 0x00000000, + 0x50F, 0x00000000, + 0x512, 0x0000001C, + 0x514, 0x0000000A, + 0x516, 0x0000000A, + 0x525, 0x0000004F, + 0x550, 0x00000010, + 0x551, 0x00000010, + 0x559, 0x00000002, + 0x55D, 0x000000FF, + 0x605, 0x00000030, + 0x608, 0x0000000E, + 0x609, 0x0000002A, + 0x620, 0x000000FF, + 0x621, 0x000000FF, + 0x622, 0x000000FF, + 0x623, 0x000000FF, + 0x624, 0x000000FF, + 0x625, 0x000000FF, + 0x626, 0x000000FF, + 0x627, 0x000000FF, + 0x652, 0x00000020, + 0x63C, 0x0000000A, + 0x63D, 0x0000000A, + 0x63E, 0x0000000E, + 0x63F, 0x0000000E, + 0x640, 0x00000040, + 0x66E, 0x00000005, + 0x700, 0x00000021, + 0x701, 0x00000043, + 0x702, 0x00000065, + 0x703, 0x00000087, + 0x708, 0x00000021, + 0x709, 0x00000043, + 0x70A, 0x00000065, + 0x70B, 0x00000087, +}; + +enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) +{ + #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i+1]; } while (0) + + u32 hex = 0; + u32 i; + u8 platform = dm_odm->SupportPlatform; + u8 interface_val = dm_odm->SupportInterface; + u8 board = dm_odm->BoardType; + u32 array_len = sizeof(array_MAC_REG_8188E)/sizeof(u32); + u32 *array = array_MAC_REG_8188E; + bool biol = false; + + struct adapter *adapt = dm_odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + hex += board; + hex += interface_val << 8; + hex += platform << 16; + hex += 0xFF000000; + + biol = rtw_IOL_applied(adapt); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < array_len; i += 2) { + u32 v1 = array[i]; + u32 v2 = array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF); + } else { + odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2); + } + continue; + } else { /* This line is the start line of branch. */ + if (!Checkcondition(array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < array_len - 2) { + READ_NEXT_PAIR(v1, v2, i); + } + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < array_len - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + rtw_IOL_append_WB_cmd(pxmit_frame, (u16)v1, (u8)v2, 0xFF); + } else { + odm_ConfigMAC_8188E(dm_odm, v1, (u8)v2); + } + + READ_NEXT_PAIR(v1, v2, i); + } + while (v2 != 0xDEAD && i < array_len - 2) + READ_NEXT_PAIR(v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(dm_odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + pr_info("~~~ MAC IOL_exec_cmds Failed !!!\n"); + rst = HAL_STATUS_FAILURE; + } + } + return rst; +} diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c new file mode 100644 index 000000000000..b5d5050c0a17 --- /dev/null +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -0,0 +1,268 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#include "odm_precomp.h" + +#include + +static bool CheckCondition(const u32 Condition, const u32 Hex) +{ + u32 _board = (Hex & 0x000000FF); + u32 _interface = (Hex & 0x0000FF00) >> 8; + u32 _platform = (Hex & 0x00FF0000) >> 16; + u32 cond = Condition; + + if (Condition == 0xCDCDCDCD) + return true; + + cond = Condition & 0x000000FF; + if ((_board == cond) && cond != 0x00) + return false; + + cond = Condition & 0x0000FF00; + cond = cond >> 8; + if ((_interface & cond) == 0 && cond != 0x07) + return false; + + cond = Condition & 0x00FF0000; + cond = cond >> 16; + if ((_platform & cond) == 0 && cond != 0x0F) + return false; + return true; +} + +/****************************************************************************** +* RadioA_1T.TXT +******************************************************************************/ + +static u32 Array_RadioA_1T_8188E[] = { + 0x000, 0x00030000, + 0x008, 0x00084000, + 0x018, 0x00000407, + 0x019, 0x00000012, + 0x01E, 0x00080009, + 0x01F, 0x00000880, + 0x02F, 0x0001A060, + 0x03F, 0x00000000, + 0x042, 0x000060C0, + 0x057, 0x000D0000, + 0x058, 0x000BE180, + 0x067, 0x00001552, + 0x083, 0x00000000, + 0x0B0, 0x000FF8FC, + 0x0B1, 0x00054400, + 0x0B2, 0x000CCC19, + 0x0B4, 0x00043003, + 0x0B6, 0x0004953E, + 0x0B7, 0x0001C718, + 0x0B8, 0x000060FF, + 0x0B9, 0x00080001, + 0x0BA, 0x00040000, + 0x0BB, 0x00000400, + 0x0BF, 0x000C0000, + 0x0C2, 0x00002400, + 0x0C3, 0x00000009, + 0x0C4, 0x00040C91, + 0x0C5, 0x00099999, + 0x0C6, 0x000000A3, + 0x0C7, 0x00088820, + 0x0C8, 0x00076C06, + 0x0C9, 0x00000000, + 0x0CA, 0x00080000, + 0x0DF, 0x00000180, + 0x0EF, 0x000001A0, + 0x051, 0x0006B27D, + 0xFF0F041F, 0xABCD, + 0x052, 0x0007E4DD, + 0xCDCDCDCD, 0xCDCD, + 0x052, 0x0007E49D, + 0xFF0F041F, 0xDEAD, + 0x053, 0x00000073, + 0x056, 0x00051FF3, + 0x035, 0x00000086, + 0x035, 0x00000186, + 0x035, 0x00000286, + 0x036, 0x00001C25, + 0x036, 0x00009C25, + 0x036, 0x00011C25, + 0x036, 0x00019C25, + 0x0B6, 0x00048538, + 0x018, 0x00000C07, + 0x05A, 0x0004BD00, + 0x019, 0x000739D0, + 0x034, 0x0000ADF3, + 0x034, 0x00009DF0, + 0x034, 0x00008DED, + 0x034, 0x00007DEA, + 0x034, 0x00006DE7, + 0x034, 0x000054EE, + 0x034, 0x000044EB, + 0x034, 0x000034E8, + 0x034, 0x0000246B, + 0x034, 0x00001468, + 0x034, 0x0000006D, + 0x000, 0x00030159, + 0x084, 0x00068200, + 0x086, 0x000000CE, + 0x087, 0x00048A00, + 0x08E, 0x00065540, + 0x08F, 0x00088000, + 0x0EF, 0x000020A0, + 0x03B, 0x000F02B0, + 0x03B, 0x000EF7B0, + 0x03B, 0x000D4FB0, + 0x03B, 0x000CF060, + 0x03B, 0x000B0090, + 0x03B, 0x000A0080, + 0x03B, 0x00090080, + 0x03B, 0x0008F780, + 0x03B, 0x000722B0, + 0x03B, 0x0006F7B0, + 0x03B, 0x00054FB0, + 0x03B, 0x0004F060, + 0x03B, 0x00030090, + 0x03B, 0x00020080, + 0x03B, 0x00010080, + 0x03B, 0x0000F780, + 0x0EF, 0x000000A0, + 0x000, 0x00010159, + 0x018, 0x0000F407, + 0xFFE, 0x00000000, + 0xFFE, 0x00000000, + 0x01F, 0x00080003, + 0xFFE, 0x00000000, + 0xFFE, 0x00000000, + 0x01E, 0x00000001, + 0x01F, 0x00080000, + 0x000, 0x00033E60, +}; + +enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) +{ + #define READ_NEXT_PAIR(v1, v2, i) do \ + { i += 2; v1 = Array[i]; \ + v2 = Array[i+1]; } while (0) + + u32 hex = 0; + u32 i = 0; + u8 platform = pDM_Odm->SupportPlatform; + u8 interfaceValue = pDM_Odm->SupportInterface; + u8 board = pDM_Odm->BoardType; + u32 ArrayLen = sizeof(Array_RadioA_1T_8188E)/sizeof(u32); + u32 *Array = Array_RadioA_1T_8188E; + bool biol = false; + struct adapter *Adapter = pDM_Odm->Adapter; + struct xmit_frame *pxmit_frame = NULL; + u8 bndy_cnt = 1; + enum HAL_STATUS rst = HAL_STATUS_SUCCESS; + + hex += board; + hex += interfaceValue << 8; + hex += platform << 16; + hex += 0xFF000000; + biol = rtw_IOL_applied(Adapter); + + if (biol) { + pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter); + if (pxmit_frame == NULL) { + pr_info("rtw_IOL_accquire_xmit_frame failed\n"); + return HAL_STATUS_FAILURE; + } + } + + for (i = 0; i < ArrayLen; i += 2) { + u32 v1 = Array[i]; + u32 v2 = Array[i+1]; + + /* This (offset, data) pair meets the condition. */ + if (v1 < 0xCDCDCDCD) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + + if (v1 == 0xffe) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + else if (v1 == 0xfd) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + else if (v1 == 0xfc) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + else if (v1 == 0xfb) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + else if (v1 == 0xfa) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + else if (v1 == 0xf9) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + else + rtw_IOL_append_WRF_cmd(pxmit_frame, RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask); + } else { + odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); + } + continue; + } else { /* This line is the start line of branch. */ + if (!CheckCondition(Array[i], hex)) { + /* Discard the following (offset, data) pairs. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < ArrayLen - 2) + READ_NEXT_PAIR(v1, v2, i); + i -= 2; /* prevent from for-loop += 2 */ + } else { /* Configure matched pairs and skip to end of if-else. */ + READ_NEXT_PAIR(v1, v2, i); + while (v2 != 0xDEAD && + v2 != 0xCDEF && + v2 != 0xCDCD && i < ArrayLen - 2) { + if (biol) { + if (rtw_IOL_cmd_boundary_handle(pxmit_frame)) + bndy_cnt++; + + if (v1 == 0xffe) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 50); + else if (v1 == 0xfd) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 5); + else if (v1 == 0xfc) + rtw_IOL_append_DELAY_MS_cmd(pxmit_frame, 1); + else if (v1 == 0xfb) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 50); + else if (v1 == 0xfa) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); + else if (v1 == 0xf9) + rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); + else + rtw_IOL_append_WRF_cmd(pxmit_frame, RF_PATH_A, (u16)v1, v2, bRFRegOffsetMask); + } else { + odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); + } + READ_NEXT_PAIR(v1, v2, i); + } + + while (v2 != 0xDEAD && i < ArrayLen - 2) + READ_NEXT_PAIR(v1, v2, i); + } + } + } + if (biol) { + if (!rtw_IOL_exec_cmds_sync(pDM_Odm->Adapter, pxmit_frame, 1000, bndy_cnt)) { + rst = HAL_STATUS_FAILURE; + pr_info("~~~ IOL Config %s Failed !!!\n", __func__); + } + } + return rst; +} diff --git a/drivers/staging/r8188eu/hal/HalPhyRf.c b/drivers/staging/r8188eu/hal/HalPhyRf.c new file mode 100644 index 000000000000..980f7da8ab3b --- /dev/null +++ b/drivers/staging/r8188eu/hal/HalPhyRf.c @@ -0,0 +1,49 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + #include "odm_precomp.h" + +/* 3============================================================ */ +/* 3 IQ Calibration */ +/* 3============================================================ */ + +void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm) +{ +} + +u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) +{ + u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, + 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, + 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, + 155, 157, 159, 161, 163, 165 + }; + u8 place = chnl; + + if (chnl > 14) { + for (place = 14; place < sizeof(channel_all); place++) { + if (channel_all[place] == chnl) + return place-13; + } + } + return 0; +} diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c new file mode 100644 index 000000000000..8a7947d8de7f --- /dev/null +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -0,0 +1,1505 @@ + +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" + +/*---------------------------Define Local Constant---------------------------*/ +/* 2010/04/25 MH Define the max tx power tracking tx agc power. */ +#define ODM_TXPWRTRACK_MAX_IDX_88E 6 + +/*---------------------------Define Local Constant---------------------------*/ + +/* 3============================================================ */ +/* 3 Tx Power Tracking */ +/* 3============================================================ */ +/*----------------------------------------------------------------------------- + * Function: ODM_TxPwrTrackAdjust88E() + * + * Overview: 88E we can not write 0xc80/c94/c4c/ 0xa2x. Instead of write TX agc. + * No matter OFDM & CCK use the same method. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 04/23/2012 MHC Create Version 0. + * 04/23/2012 MHC Adjust TX agc directly not throughput BB digital. + * + *---------------------------------------------------------------------------*/ +void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, 1 = CCK */ + u8 *pDirection, /* 1 = +(increase) 2 = -(decrease) */ + u32 *pOutWriteVal /* Tx tracking CCK/OFDM BB swing index adjust */ + ) +{ + u8 pwr_value = 0; + /* Tx power tracking BB swing table. */ + /* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ + if (Type == 0) { /* For OFDM afjust */ + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", + dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); + + if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) { + *pDirection = 1; + pwr_value = (dm_odm->BbSwingIdxOfdmBase - dm_odm->BbSwingIdxOfdm); + } else { + *pDirection = 2; + pwr_value = (dm_odm->BbSwingIdxOfdm - dm_odm->BbSwingIdxOfdmBase); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", + dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); + } else if (Type == 1) { /* For CCK adjust. */ + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, + ("dm_odm->BbSwingIdxCck = %d dm_odm->BbSwingIdxCckBase = %d\n", + dm_odm->BbSwingIdxCck, dm_odm->BbSwingIdxCckBase)); + + if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) { + *pDirection = 1; + pwr_value = (dm_odm->BbSwingIdxCckBase - dm_odm->BbSwingIdxCck); + } else { + *pDirection = 2; + pwr_value = (dm_odm->BbSwingIdxCck - dm_odm->BbSwingIdxCckBase); + } + } + + /* */ + /* 2012/04/25 MH According to Ed/Luke.Lees estimate for EVM the max tx power tracking */ + /* need to be less than 6 power index for 88E. */ + /* */ + if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *pDirection == 1) + pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E; + + *pOutWriteVal = pwr_value | (pwr_value<<8) | (pwr_value<<16) | (pwr_value<<24); +} /* ODM_TxPwrTrackAdjust88E */ + +/*----------------------------------------------------------------------------- + * Function: odm_TxPwrTrackSetPwr88E() + * + * Overview: 88E change all channel tx power accordign to flag. + * OFDM & CCK are all different. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 04/23/2012 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +static void odm_TxPwrTrackSetPwr88E(struct odm_dm_struct *dm_odm) +{ + if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { + ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("odm_TxPwrTrackSetPwr88E CH=%d\n", *(dm_odm->pChannel))); + PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *(dm_odm->pChannel)); + dm_odm->BbSwingFlagOfdm = false; + dm_odm->BbSwingFlagCck = false; + } +} /* odm_TxPwrTrackSetPwr88E */ + +/* 091212 chiyokolin */ +void +odm_TXPowerTrackingCallback_ThermalMeter_8188E( + struct adapter *Adapter + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 ThermalValue = 0, delta, delta_LCK, delta_IQK, offset; + u8 ThermalValue_AVG_count = 0; + u32 ThermalValue_AVG = 0; + s32 ele_A = 0, ele_D, TempCCk, X, value32; + s32 Y, ele_C = 0; + s8 OFDM_index[2], CCK_index = 0; + s8 OFDM_index_old[2] = {0, 0}, CCK_index_old = 0; + u32 i = 0, j = 0; + bool is2t = false; + + u8 OFDM_min_index = 6, rf; /* OFDM BB Swing should be less than +3.0dB, which is required by Arthur */ + u8 Indexforchannel = 0/*GetRightChnlPlaceforIQK(pHalData->CurrentChannel)*/; + s8 OFDM_index_mapping[2][index_mapping_NUM_88E] = { + {0, 0, 2, 3, 4, 4, /* 2.4G, decrease power */ + 5, 6, 7, 7, 8, 9, + 10, 10, 11}, /* For lower temperature, 20120220 updated on 20120220. */ + {0, 0, -1, -2, -3, -4, /* 2.4G, increase power */ + -4, -4, -4, -5, -7, -8, + -9, -9, -10}, + }; + u8 Thermal_mapping[2][index_mapping_NUM_88E] = { + {0, 2, 4, 6, 8, 10, /* 2.4G, decrease power */ + 12, 14, 16, 18, 20, 22, + 24, 26, 27}, + {0, 2, 4, 6, 8, 10, /* 2.4G,, increase power */ + 12, 14, 16, 18, 20, 22, + 25, 25, 25}, + }; + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + /* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */ + odm_TxPwrTrackSetPwr88E(dm_odm); + + dm_odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; /* cosa add for debug */ + dm_odm->RFCalibrateInfo.bTXPowerTrackingInit = true; + + /* RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */ + dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("===>dm_TXPowerTrackingCallback_ThermalMeter_8188E txpowercontrol %d\n", + dm_odm->RFCalibrateInfo.TxPowerTrackControl)); + + ThermalValue = (u8)ODM_GetRFReg(dm_odm, RF_PATH_A, RF_T_METER_88E, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", + ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, pHalData->EEPROMThermalMeter)); + + if (is2t) + rf = 2; + else + rf = 1; + + if (ThermalValue) { + /* Query OFDM path A default setting */ + ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord)&bMaskOFDM_D; + for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ + if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { + OFDM_index_old[0] = (u8)i; + dm_odm->BbSwingIdxOfdmBase = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial pathA ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", + rOFDM0_XATxIQImbalance, ele_D, OFDM_index_old[0])); + break; + } + } + + /* Query OFDM path B default setting */ + if (is2t) { + ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord)&bMaskOFDM_D; + for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ + if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { + OFDM_index_old[1] = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial pathB ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", + rOFDM0_XBTxIQImbalance, ele_D, OFDM_index_old[1])); + break; + } + } + } + + /* Query CCK default setting From 0xa24 */ + TempCCk = dm_odm->RFCalibrateInfo.RegA24; + + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (dm_odm->RFCalibrateInfo.bCCKinCH14) { + if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { + CCK_index_old = (u8)i; + dm_odm->BbSwingIdxCckBase = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch 14 %d\n", + rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); + break; + } + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("RegA24: 0x%X, CCKSwingTable_Ch1_Ch13[%d][2]: CCKSwingTable_Ch1_Ch13[i][2]: 0x%X\n", + TempCCk, i, CCKSwingTable_Ch1_Ch13[i][2])); + if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { + CCK_index_old = (u8)i; + dm_odm->BbSwingIdxCckBase = (u8)i; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch14 %d\n", + rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); + break; + } + } + } + + if (!dm_odm->RFCalibrateInfo.ThermalValue) { + dm_odm->RFCalibrateInfo.ThermalValue = pHalData->EEPROMThermalMeter; + dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; + dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; + + for (i = 0; i < rf; i++) + dm_odm->RFCalibrateInfo.OFDM_index[i] = OFDM_index_old[i]; + dm_odm->RFCalibrateInfo.CCK_index = CCK_index_old; + } + + if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("reload ofdm index for band switch\n")); + + /* calculate average thermal meter */ + dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue; + dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++; + if (dm_odm->RFCalibrateInfo.ThermalValue_AVG_index == AVG_THERMAL_NUM_88E) + dm_odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; + + for (i = 0; i < AVG_THERMAL_NUM_88E; i++) { + if (dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]) { + ThermalValue_AVG += dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]; + ThermalValue_AVG_count++; + } + } + + if (ThermalValue_AVG_count) { + ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("AVG Thermal Meter = 0x%x\n", ThermalValue)); + } + + if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { + delta = ThermalValue > pHalData->EEPROMThermalMeter ? + (ThermalValue - pHalData->EEPROMThermalMeter) : + (pHalData->EEPROMThermalMeter - ThermalValue); + dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false; + dm_odm->RFCalibrateInfo.bDoneTxpower = false; + } else if (dm_odm->RFCalibrateInfo.bDoneTxpower) { + delta = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue) ? + (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue) : + (dm_odm->RFCalibrateInfo.ThermalValue - ThermalValue); + } else { + delta = ThermalValue > pHalData->EEPROMThermalMeter ? + (ThermalValue - pHalData->EEPROMThermalMeter) : + (pHalData->EEPROMThermalMeter - ThermalValue); + } + delta_LCK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_LCK) ? + (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_LCK) : + (dm_odm->RFCalibrateInfo.ThermalValue_LCK - ThermalValue); + delta_IQK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ? + (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_IQK) : + (dm_odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x delta 0x%x delta_LCK 0x%x delta_IQK 0x%x\n", + ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, + pHalData->EEPROMThermalMeter, delta, delta_LCK, delta_IQK)); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("pre thermal meter LCK 0x%x pre thermal meter IQK 0x%x delta_LCK_bound 0x%x delta_IQK_bound 0x%x\n", + dm_odm->RFCalibrateInfo.ThermalValue_LCK, + dm_odm->RFCalibrateInfo.ThermalValue_IQK, + dm_odm->RFCalibrateInfo.Delta_LCK, + dm_odm->RFCalibrateInfo.Delta_IQK)); + + if ((delta_LCK >= 8)) { /* Delta temperature is equal to or larger than 20 centigrade. */ + dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; + PHY_LCCalibrate_8188E(Adapter); + } + + if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) { + delta = ThermalValue > pHalData->EEPROMThermalMeter ? + (ThermalValue - pHalData->EEPROMThermalMeter) : + (pHalData->EEPROMThermalMeter - ThermalValue); + /* calculate new OFDM / CCK offset */ + if (ThermalValue > pHalData->EEPROMThermalMeter) + j = 1; + else + j = 0; + for (offset = 0; offset < index_mapping_NUM_88E; offset++) { + if (delta < Thermal_mapping[j][offset]) { + if (offset != 0) + offset--; + break; + } + } + if (offset >= index_mapping_NUM_88E) + offset = index_mapping_NUM_88E-1; + for (i = 0; i < rf; i++) + OFDM_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + OFDM_index_mapping[j][offset]; + CCK_index = dm_odm->RFCalibrateInfo.CCK_index + OFDM_index_mapping[j][offset]; + + if (is2t) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", + dm_odm->RFCalibrateInfo.OFDM_index[0], + dm_odm->RFCalibrateInfo.OFDM_index[1], + dm_odm->RFCalibrateInfo.CCK_index)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("temp OFDM_A_index=0x%x, CCK_index=0x%x\n", + dm_odm->RFCalibrateInfo.OFDM_index[0], + dm_odm->RFCalibrateInfo.CCK_index)); + } + + for (i = 0; i < rf; i++) { + if (OFDM_index[i] > OFDM_TABLE_SIZE_92D-1) + OFDM_index[i] = OFDM_TABLE_SIZE_92D-1; + else if (OFDM_index[i] < OFDM_min_index) + OFDM_index[i] = OFDM_min_index; + } + + if (CCK_index > CCK_TABLE_SIZE-1) + CCK_index = CCK_TABLE_SIZE-1; + else if (CCK_index < 0) + CCK_index = 0; + + if (is2t) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("new OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", + OFDM_index[0], OFDM_index[1], CCK_index)); + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("new OFDM_A_index=0x%x, CCK_index=0x%x\n", + OFDM_index[0], CCK_index)); + } + + /* 2 temporarily remove bNOPG */ + /* Config by SwingTable */ + if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) { + dm_odm->RFCalibrateInfo.bDoneTxpower = true; + + /* Adujst OFDM Ant_A according to IQK result */ + ele_D = (OFDMSwingTable[(u8)OFDM_index[0]] & 0xFFC00000)>>22; + X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][0]; + Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][1]; + + /* Revse TX power table. */ + dm_odm->BbSwingIdxOfdm = (u8)OFDM_index[0]; + dm_odm->BbSwingIdxCck = (u8)CCK_index; + + if (dm_odm->BbSwingIdxOfdmCurrent != dm_odm->BbSwingIdxOfdm) { + dm_odm->BbSwingIdxOfdmCurrent = dm_odm->BbSwingIdxOfdm; + dm_odm->BbSwingFlagOfdm = true; + } + + if (dm_odm->BbSwingIdxCckCurrent != dm_odm->BbSwingIdxCck) { + dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck; + dm_odm->BbSwingFlagCck = true; + } + + if (X != 0) { + if ((X & 0x00000200) != 0) + X = X | 0xFFFFFC00; + ele_A = ((X * ele_D)>>8)&0x000003FF; + + /* new element C = element D x Y */ + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + ele_C = ((Y * ele_D)>>8)&0x000003FF; + + /* 2012/04/23 MH According to Luke's suggestion, we can not write BB digital */ + /* to increase TX power. Otherwise, EVM will be bad. */ + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("TxPwrTracking for path A: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xe94=0x%x 0xe9c=0x%x\n", + (u32)X, (u32)Y, (u32)ele_A, (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); + + if (is2t) { + ele_D = (OFDMSwingTable[(u8)OFDM_index[1]] & 0xFFC00000)>>22; + + /* new element A = element D x X */ + X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][4]; + Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][5]; + + if ((X != 0) && (*(dm_odm->pBandType) == ODM_BAND_2_4G)) { + if ((X & 0x00000200) != 0) /* consider minus */ + X = X | 0xFFFFFC00; + ele_A = ((X * ele_D)>>8)&0x000003FF; + + /* new element C = element D x Y */ + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + ele_C = ((Y * ele_D)>>8)&0x00003FF; + + /* wtite new elements A, C, D to regC88 and regC9C, element B is always 0 */ + value32 = (ele_D<<22) | ((ele_C&0x3F)<<16) | ele_A; + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); + + value32 = (ele_C&0x000003C0)>>6; + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, value32); + + value32 = ((X * ele_D)>>7)&0x01; + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, value32); + } else { + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)OFDM_index[1]]); + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, 0x00); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("TxPwrTracking path B: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xeb4=0x%x 0xebc=0x%x\n", + (u32)X, (u32)Y, (u32)ele_A, + (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = 0x%x RF 0x24 = 0x%x\n", + ODM_GetBBReg(dm_odm, 0xc80, bMaskDWord), ODM_GetBBReg(dm_odm, + 0xc94, bMaskDWord), ODM_GetRFReg(dm_odm, RF_PATH_A, 0x24, bRFRegOffsetMask))); + } + } + + if (delta_IQK >= 8) { /* Delta temperature is equal to or larger than 20 centigrade. */ + ODM_ResetIQKResult(dm_odm); + + dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; + PHY_IQCalibrate_8188E(Adapter, false); + } + /* update thermal meter value */ + if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) + dm_odm->RFCalibrateInfo.ThermalValue = ThermalValue; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("<===dm_TXPowerTrackingCallback_ThermalMeter_8188E\n")); + dm_odm->RFCalibrateInfo.TXPowercount = 0; +} + +/* 1 7. IQK */ +#define MAX_TOLERANCE 5 +#define IQK_DELAY_TIME 1 /* ms */ + +static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ +phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) +{ + u32 regeac, regE94, regE9C, regEA4; + u8 result = 0x00; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK!\n")); + + /* 1 Tx IQK */ + /* path-A IQK setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A IQK setting!\n")); + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); + ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x8214032a); + ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); + + /* LO calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); + + /* One shot, path A LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); + /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); + regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); + regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); + regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); + + if (!(regeac & BIT28) && + (((regE94 & 0x03FF0000)>>16) != 0x142) && + (((regE9C & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + return result; +} + +static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ +phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) +{ + u32 regeac, regE94, regE9C, regEA4, u4tmp; + u8 result = 0x00; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); + + /* 1 Get TXIMR setting */ + /* modify RXIQK mode table */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf117B); + + /* PA,PAD off */ + ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x980); + ODM_SetRFReg(dm_odm, RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); + + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + + /* IQK setting */ + ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); + ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); + + /* path-A IQK setting */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); + ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x82160c1f); + ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); + + /* LO calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); + + /* One shot, path A LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Delay %d ms for One shot, path A LOK & IQK.\n", + IQK_DELAY_TIME_88E)); + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xeac = 0x%x\n", regeac)); + regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xe94 = 0x%x\n", regE94)); + regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xe9c = 0x%x\n", regE9C)); + + if (!(regeac & BIT28) && + (((regE94 & 0x03FF0000)>>16) != 0x142) && + (((regE9C & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + else /* if Tx not OK, ignore Rx */ + return result; + + u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); + ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, u4tmp); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe40 = 0x%x u4tmp = 0x%x\n", ODM_GetBBReg(dm_odm, rTx_IQK, bMaskDWord), u4tmp)); + + /* 1 RX IQK */ + /* modify RXIQK mode table */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table 2!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7ffa); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + + /* IQK setting */ + ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x01004800); + + /* path-A IQK setting */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x38008c1c); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x18008c1c); + ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x82160c05); + ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f); + + /* LO calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); + + /* One shot, path A LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); + ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); + /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); + regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); + regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); + regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); + + /* reload RF 0xdf */ + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); + + if (!(regeac & BIT27) && /* if Tx is OK, check whether Rx is OK */ + (((regEA4 & 0x03FF0000)>>16) != 0x132) && + (((regeac & 0x03FF0000)>>16) != 0x36)) + result |= 0x02; + else + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK fail!!\n")); + + return result; +} + +static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ +phy_PathB_IQK_8188E(struct adapter *adapt) +{ + u32 regeac, regeb4, regebc, regec4, regecc; + u8 result = 0x00; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK!\n")); + + /* One shot, path B LOK & IQK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); + ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000002); + ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000000); + + /* delay x ms */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Delay %d ms for One shot, path B LOK & IQK.\n", + IQK_DELAY_TIME_88E)); + ODM_delay_ms(IQK_DELAY_TIME_88E); + + /* Check failed */ + regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xeac = 0x%x\n", regeac)); + regeb4 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xeb4 = 0x%x\n", regeb4)); + regebc = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xebc = 0x%x\n", regebc)); + regec4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xec4 = 0x%x\n", regec4)); + regecc = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("0xecc = 0x%x\n", regecc)); + + if (!(regeac & BIT31) && + (((regeb4 & 0x03FF0000)>>16) != 0x142) && + (((regebc & 0x03FF0000)>>16) != 0x42)) + result |= 0x01; + else + return result; + + if (!(regeac & BIT30) && + (((regec4 & 0x03FF0000)>>16) != 0x132) && + (((regecc & 0x03FF0000)>>16) != 0x36)) + result |= 0x02; + else + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK fail!!\n")); + return result; +} + +static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) +{ + u32 Oldval_0, X, TX0_A, reg; + s32 Y, TX0_C; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path A IQ Calibration %s !\n", + (iqkok) ? "Success" : "Failed")); + + if (final_candidate == 0xFF) { + return; + } else if (iqkok) { + Oldval_0 = (ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + X = result[final_candidate][0]; + if ((X & 0x00000200) != 0) + X = X | 0xFFFFFC00; + TX0_A = (X * Oldval_0) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x\n", + X, TX0_A, Oldval_0)); + ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1)); + + Y = result[final_candidate][1]; + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + + TX0_C = (Y * Oldval_0) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX = 0x%x\n", Y, TX0_C)); + ODM_SetBBReg(dm_odm, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6)); + ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F)); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1)); + + if (txonly) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("patha_fill_iqk only Tx OK\n")); + return; + } + + reg = result[final_candidate][2]; + ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0x3FF, reg); + + reg = result[final_candidate][3] & 0x3F; + ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0xFC00, reg); + + reg = (result[final_candidate][3] >> 6) & 0xF; + ODM_SetBBReg(dm_odm, rOFDM0_RxIQExtAnta, 0xF0000000, reg); + } +} + +static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u8 final_candidate, bool txonly) +{ + u32 Oldval_1, X, TX1_A, reg; + s32 Y, TX1_C; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("Path B IQ Calibration %s !\n", + (iqkok) ? "Success" : "Failed")); + + if (final_candidate == 0xFF) { + return; + } else if (iqkok) { + Oldval_1 = (ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord) >> 22) & 0x3FF; + + X = result[final_candidate][4]; + if ((X & 0x00000200) != 0) + X = X | 0xFFFFFC00; + TX1_A = (X * Oldval_1) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("X = 0x%x, TX1_A = 0x%x\n", X, TX1_A)); + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1)); + + Y = result[final_candidate][5]; + if ((Y & 0x00000200) != 0) + Y = Y | 0xFFFFFC00; + + TX1_C = (Y * Oldval_1) >> 8; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX1_C = 0x%x\n", Y, TX1_C)); + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6)); + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F)); + + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1>>7) & 0x1)); + + if (txonly) + return; + + reg = result[final_candidate][6]; + ODM_SetBBReg(dm_odm, rOFDM0_XBRxIQImbalance, 0x3FF, reg); + + reg = result[final_candidate][7] & 0x3F; + ODM_SetBBReg(dm_odm, rOFDM0_XBRxIQImbalance, 0xFC00, reg); + + reg = (result[final_candidate][7] >> 6) & 0xF; + ODM_SetBBReg(dm_odm, rOFDM0_AGCRSSITable, 0x0000F000, reg); + } +} + +/* */ +/* 2011/07/26 MH Add an API for testing IQK fail case. */ +/* */ +/* MP Already declare in odm.c */ +static bool ODM_CheckPowerStatus(struct adapter *Adapter) +{ + return true; +} + +void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegisterNum) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + if (!ODM_CheckPowerStatus(adapt)) + return; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA parameters.\n")); + for (i = 0; i < RegisterNum; i++) { + ADDABackup[i] = ODM_GetBBReg(dm_odm, ADDAReg[i], bMaskDWord); + } +} + +static void _PHY_SaveMACRegisters( + struct adapter *adapt, + u32 *MACReg, + u32 *MACBackup + ) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n")); + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + MACBackup[i] = ODM_Read1Byte(dm_odm, MACReg[i]); + } + MACBackup[i] = ODM_Read4Byte(dm_odm, MACReg[i]); +} + +static void reload_adda_reg(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup, u32 RegiesterNum) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n")); + for (i = 0; i < RegiesterNum; i++) + ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, ADDABackup[i]); +} + +static void +_PHY_ReloadMACRegisters( + struct adapter *adapt, + u32 *MACReg, + u32 *MACBackup + ) +{ + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload MAC parameters !\n")); + for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { + ODM_Write1Byte(dm_odm, MACReg[i], (u8)MACBackup[i]); + } + ODM_Write4Byte(dm_odm, MACReg[i], MACBackup[i]); +} + +void +_PHY_PathADDAOn( + struct adapter *adapt, + u32 *ADDAReg, + bool isPathAOn, + bool is2t + ) +{ + u32 pathOn; + u32 i; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); + + pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4; + if (!is2t) { + pathOn = 0x0bdb25a0; + ODM_SetBBReg(dm_odm, ADDAReg[0], bMaskDWord, 0x0b1b25a0); + } else { + ODM_SetBBReg(dm_odm, ADDAReg[0], bMaskDWord, pathOn); + } + + for (i = 1; i < IQK_ADDA_REG_NUM; i++) + ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, pathOn); +} + +void +_PHY_MACSettingCalibration( + struct adapter *adapt, + u32 *MACReg, + u32 *MACBackup + ) +{ + u32 i = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n")); + + ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); + + for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); + } + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); +} + +void +_PHY_PathAStandBy( + struct adapter *adapt + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A standby mode!\n")); + + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x0); + ODM_SetBBReg(dm_odm, 0x840, bMaskDWord, 0x00010000); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); +} + +static void _PHY_PIModeSwitch( + struct adapter *adapt, + bool PIMode + ) +{ + u32 mode; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("BB Switch to %s mode!\n", (PIMode ? "PI" : "SI"))); + + mode = PIMode ? 0x01000100 : 0x01000000; + ODM_SetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode); + ODM_SetBBReg(dm_odm, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode); +} + +static bool phy_SimularityCompare_8188E( + struct adapter *adapt, + s32 resulta[][8], + u8 c1, + u8 c2 + ) +{ + u32 i, j, diff, sim_bitmap, bound = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ + bool result = true; + bool is2t; + s32 tmp1 = 0, tmp2 = 0; + + if ((dm_odm->RFType == ODM_2T2R) || (dm_odm->RFType == ODM_2T3R) || (dm_odm->RFType == ODM_2T4R)) + is2t = true; + else + is2t = false; + + if (is2t) + bound = 8; + else + bound = 4; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("===> IQK:phy_SimularityCompare_8188E c1 %d c2 %d!!!\n", c1, c2)); + + sim_bitmap = 0; + + for (i = 0; i < bound; i++) { + if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { + if ((resulta[c1][i] & 0x00000200) != 0) + tmp1 = resulta[c1][i] | 0xFFFFFC00; + else + tmp1 = resulta[c1][i]; + + if ((resulta[c2][i] & 0x00000200) != 0) + tmp2 = resulta[c2][i] | 0xFFFFFC00; + else + tmp2 = resulta[c2][i]; + } else { + tmp1 = resulta[c1][i]; + tmp2 = resulta[c2][i]; + } + + diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); + + if (diff > MAX_TOLERANCE) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK:phy_SimularityCompare_8188E differnece overflow index %d compare1 0x%x compare2 0x%x!!!\n", + i, resulta[c1][i], resulta[c2][i])); + + if ((i == 2 || i == 6) && !sim_bitmap) { + if (resulta[c1][i] + resulta[c1][i+1] == 0) + final_candidate[(i/4)] = c2; + else if (resulta[c2][i] + resulta[c2][i+1] == 0) + final_candidate[(i/4)] = c1; + else + sim_bitmap = sim_bitmap | (1<odmpriv; + u32 i; + u8 PathAOK, PathBOK; + u32 ADDA_REG[IQK_ADDA_REG_NUM] = { + rFPGA0_XCD_SwitchControl, rBlue_Tooth, + rRx_Wait_CCA, rTx_CCK_RFON, + rTx_CCK_BBON, rTx_OFDM_RFON, + rTx_OFDM_BBON, rTx_To_Rx, + rTx_To_Tx, rRx_CCK, + rRx_OFDM, rRx_Wait_RIFS, + rRx_TO_Rx, rStandby, + rSleep, rPMPD_ANAEN }; + u32 IQK_MAC_REG[IQK_MAC_REG_NUM] = { + REG_TXPAUSE, REG_BCN_CTRL, + REG_BCN_CTRL_1, REG_GPIO_MUXCFG}; + + /* since 92C & 92D have the different define in IQK_BB_REG */ + u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { + rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, + rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, + rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, + rFPGA0_XB_RFInterfaceOE, rFPGA0_RFMOD + }; + + u32 retryCount = 9; + if (*(dm_odm->mp_mode) == 1) + retryCount = 9; + else + retryCount = 2; + /* Note: IQ calibration must be performed after loading */ + /* PHY_REG.txt , and radio_a, radio_b.txt */ + + if (t == 0) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); + + /* Save ADDA parameters, turn Path A ADDA on */ + _PHY_SaveADDARegisters(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); + _PHY_SaveMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); + _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); + + _PHY_PathADDAOn(adapt, ADDA_REG, true, is2t); + if (t == 0) + dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)ODM_GetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, BIT(8)); + + if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { + /* Switch BB to PI mode to do IQ Calibration. */ + _PHY_PIModeSwitch(adapt, true); + } + + /* BB setting */ + ODM_SetBBReg(dm_odm, rFPGA0_RFMOD, BIT24, 0x00); + ODM_SetBBReg(dm_odm, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); + ODM_SetBBReg(dm_odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); + ODM_SetBBReg(dm_odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); + + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); + + if (is2t) { + ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000); + ODM_SetBBReg(dm_odm, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00010000); + } + + /* MAC settings */ + _PHY_MACSettingCalibration(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); + + /* Page B init */ + /* AP or IQK */ + ODM_SetBBReg(dm_odm, rConfig_AntA, bMaskDWord, 0x0f600000); + + if (is2t) + ODM_SetBBReg(dm_odm, rConfig_AntB, bMaskDWord, 0x0f600000); + + /* IQ calibration setting */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK setting!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); + ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); + + for (i = 0; i < retryCount; i++) { + PathAOK = phy_PathA_IQK_8188E(adapt, is2t); + if (PathAOK == 0x01) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Tx IQK Success!!\n")); + result[t][0] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; + result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; + break; + } + } + + for (i = 0; i < retryCount; i++) { + PathAOK = phy_PathA_RxIQK(adapt, is2t); + if (PathAOK == 0x03) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Success!!\n")); + result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + break; + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Fail!!\n")); + } + } + + if (0x00 == PathAOK) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK failed!!\n")); + } + + if (is2t) { + _PHY_PathAStandBy(adapt); + + /* Turn Path B ADDA on */ + _PHY_PathADDAOn(adapt, ADDA_REG, false, is2t); + + for (i = 0; i < retryCount; i++) { + PathBOK = phy_PathB_IQK_8188E(adapt); + if (PathBOK == 0x03) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK Success!!\n")); + result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][6] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; + result[t][7] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; + break; + } else if (i == (retryCount - 1) && PathBOK == 0x01) { /* Tx IQK OK */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Only Tx IQK Success!!\n")); + result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; + } + } + + if (0x00 == PathBOK) { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK failed!!\n")); + } + } + + /* Back to BB mode, load original value */ + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Back to BB mode, load original value!\n")); + ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0); + + if (t != 0) { + if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { + /* Switch back BB to SI mode after finish IQ Calibration. */ + _PHY_PIModeSwitch(adapt, false); + } + + /* Reload ADDA power saving parameters */ + reload_adda_reg(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); + + /* Reload MAC parameters */ + _PHY_ReloadMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); + + reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); + + /* Restore RX initial gain */ + ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00032ed3); + if (is2t) + ODM_SetBBReg(dm_odm, rFPGA0_XB_LSSIParameter, bMaskDWord, 0x00032ed3); + + /* load 0xe30 IQC default value */ + ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); + ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_IQCalibrate_8188E() <==\n")); +} + +static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) +{ + u8 tmpreg; + u32 RF_Amode = 0, RF_Bmode = 0, LC_Cal; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + /* Check continuous TX and Packet TX */ + tmpreg = ODM_Read1Byte(dm_odm, 0xd03); + + if ((tmpreg&0x70) != 0) /* Deal with contisuous TX case */ + ODM_Write1Byte(dm_odm, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ + else /* Deal with Packet TX case */ + ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0xFF); /* block all queues */ + + if ((tmpreg&0x70) != 0) { + /* 1. Read original RF mode */ + /* Path-A */ + RF_Amode = PHY_QueryRFReg(adapt, RF_PATH_A, RF_AC, bMask12Bits); + + /* Path-B */ + if (is2t) + RF_Bmode = PHY_QueryRFReg(adapt, RF_PATH_B, RF_AC, bMask12Bits); + + /* 2. Set RF mode = standby mode */ + /* Path-A */ + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); + + /* Path-B */ + if (is2t) + ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); + } + + /* 3. Read RF reg18 */ + LC_Cal = PHY_QueryRFReg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits); + + /* 4. Set LC calibration begin bit15 */ + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); + + ODM_sleep_ms(100); + + /* Restore original situation */ + if ((tmpreg&0x70) != 0) { + /* Deal with continuous TX case */ + /* Path-A */ + ODM_Write1Byte(dm_odm, 0xd03, tmpreg); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); + + /* Path-B */ + if (is2t) + ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); + } else { + /* Deal with Packet TX case */ + ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0x00); + } +} + +void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + s32 result[4][8]; /* last is final result */ + u8 i, final_candidate, Indexforchannel; + bool pathaok, pathbok; + s32 RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC; + bool is12simular, is13simular, is23simular; + bool singletone = false, carrier_sup = false; + u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { + rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, + rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, + rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, + rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, + rOFDM0_RxIQExtAnta}; + bool is2t; + + is2t = (dm_odm->RFType == ODM_2T2R) ? true : false; + if (!ODM_CheckPowerStatus(adapt)) + return; + + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + + if (*(dm_odm->mp_mode) == 1) { + singletone = pMptCtx->bSingleTone; + carrier_sup = pMptCtx->bCarrierSuppression; + } + + /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ + if (singletone || carrier_sup) + return; + + if (recovery) { + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("PHY_IQCalibrate_8188E: Return due to recovery!\n")); + reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); + return; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Start!!!\n")); + + for (i = 0; i < 8; i++) { + result[0][i] = 0; + result[1][i] = 0; + result[2][i] = 0; + if ((i == 0) || (i == 2) || (i == 4) || (i == 6)) + result[3][i] = 0x100; + else + result[3][i] = 0; + } + final_candidate = 0xff; + pathaok = false; + pathbok = false; + is12simular = false; + is23simular = false; + is13simular = false; + + for (i = 0; i < 3; i++) { + phy_IQCalibrate_8188E(adapt, result, i, is2t); + + if (i == 1) { + is12simular = phy_SimularityCompare_8188E(adapt, result, 0, 1); + if (is12simular) { + final_candidate = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is12simular final_candidate is %x\n", final_candidate)); + break; + } + } + + if (i == 2) { + is13simular = phy_SimularityCompare_8188E(adapt, result, 0, 2); + if (is13simular) { + final_candidate = 0; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is13simular final_candidate is %x\n", final_candidate)); + + break; + } + is23simular = phy_SimularityCompare_8188E(adapt, result, 1, 2); + if (is23simular) { + final_candidate = 1; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is23simular final_candidate is %x\n", final_candidate)); + } else { + final_candidate = 3; + } + } + } + + for (i = 0; i < 4; i++) { + RegE94 = result[i][0]; + RegE9C = result[i][1]; + RegEA4 = result[i][2]; + RegEAC = result[i][3]; + RegEB4 = result[i][4]; + RegEBC = result[i][5]; + RegEC4 = result[i][6]; + RegECC = result[i][7]; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", + RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); + } + + if (final_candidate != 0xff) { + RegE94 = result[final_candidate][0]; + RegE9C = result[final_candidate][1]; + RegEA4 = result[final_candidate][2]; + RegEAC = result[final_candidate][3]; + RegEB4 = result[final_candidate][4]; + RegEBC = result[final_candidate][5]; + dm_odm->RFCalibrateInfo.RegE94 = RegE94; + dm_odm->RFCalibrateInfo.RegE9C = RegE9C; + dm_odm->RFCalibrateInfo.RegEB4 = RegEB4; + dm_odm->RFCalibrateInfo.RegEBC = RegEBC; + RegEC4 = result[final_candidate][6]; + RegECC = result[final_candidate][7]; + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: final_candidate is %x\n", final_candidate)); + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", + RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); + pathaok = true; + pathbok = true; + } else { + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: FAIL use default value\n")); + dm_odm->RFCalibrateInfo.RegE94 = 0x100; + dm_odm->RFCalibrateInfo.RegEB4 = 0x100; /* X default value */ + dm_odm->RFCalibrateInfo.RegE9C = 0x0; + dm_odm->RFCalibrateInfo.RegEBC = 0x0; /* Y default value */ + } + if (RegE94 != 0) + patha_fill_iqk(adapt, pathaok, result, final_candidate, (RegEA4 == 0)); + if (is2t) { + if (RegEB4 != 0) + pathb_fill_iqk(adapt, pathbok, result, final_candidate, (RegEC4 == 0)); + } + + Indexforchannel = ODM_GetRightChnlPlaceforIQK(pHalData->CurrentChannel); + +/* To Fix BSOD when final_candidate is 0xff */ +/* by sherry 20120321 */ + if (final_candidate < 4) { + for (i = 0; i < IQK_Matrix_REG_NUM; i++) + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][i] = result[final_candidate][i]; + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].bIQKDone = true; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("\nIQK OK Indexforchannel %d.\n", Indexforchannel)); + + _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK finished\n")); +} + +void PHY_LCCalibrate_8188E(struct adapter *adapt) +{ + bool singletone = false, carrier_sup = false; + u32 timeout = 2000, timecount = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + + if (*(dm_odm->mp_mode) == 1) { + singletone = pMptCtx->bSingleTone; + carrier_sup = pMptCtx->bCarrierSuppression; + } + if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) + return; + /* 20120213 Turn on when continuous Tx to pass lab testing. (required by Edlu) */ + if (singletone || carrier_sup) + return; + + while (*(dm_odm->pbScanInProcess) && timecount < timeout) { + ODM_delay_ms(50); + timecount += 50; + } + + dm_odm->RFCalibrateInfo.bLCKInProgress = true; + + if (dm_odm->RFType == ODM_2T2R) { + phy_LCCalibrate_8188E(adapt, true); + } else { + /* For 88C 1T1R */ + phy_LCCalibrate_8188E(adapt, false); + } + + dm_odm->RFCalibrateInfo.bLCKInProgress = false; + + ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, + ("LCK:Finish!!!interface %d\n", dm_odm->InterfaceIndex)); +} + +static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2t) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + if (!adapt->hw_init_completed) { + u8 u1btmp; + u1btmp = ODM_Read1Byte(dm_odm, REG_LEDCFG2) | BIT7; + ODM_Write1Byte(dm_odm, REG_LEDCFG2, u1btmp); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFParameter, BIT13, 0x01); + } + + if (is2t) { /* 92C */ + if (main) + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x1); /* 92C_Path_A */ + else + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x2); /* BT */ + } else { /* 88C */ + if (main) + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x2); /* Main */ + else + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x1); /* Aux */ + } +} + +void PHY_SetRFPathSwitch_8188E(struct adapter *adapt, bool main) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); + struct odm_dm_struct *dm_odm = &pHalData->odmpriv; + + if (dm_odm->RFType == ODM_2T2R) { + phy_setrfpathswitch_8188e(adapt, main, true); + } else { + /* For 88C 1T1R */ + phy_setrfpathswitch_8188e(adapt, main, false); + } +} diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c new file mode 100644 index 000000000000..5700dbce5b8c --- /dev/null +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -0,0 +1,132 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/*++ +Copyright (c) Realtek Semiconductor Corp. All rights reserved. + +Module Name: + HalPwrSeqCmd.c + +Abstract: + Implement HW Power sequence configuration CMD handling routine for Realtek devices. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-10-26 Lucas Modify to be compatible with SD4-CE driver. + 2011-07-07 Roger Create. + +--*/ + +#include + +/* Description: */ +/* This routine deals with the Power Configuration CMDs parsing + * for RTL8723/RTL8188E Series IC. + * Assumption: + * We should follow specific format which was released from HW SD. + */ +u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, + u8 ifacetype, struct wl_pwr_cfg pwrseqcmd[]) +{ + struct wl_pwr_cfg pwrcfgcmd = {0}; + u8 poll_bit = false; + u32 aryidx = 0; + u8 value = 0; + u32 offset = 0; + u32 poll_count = 0; /* polling autoload done. */ + u32 max_poll_count = 5000; + + do { + pwrcfgcmd = pwrseqcmd[aryidx]; + + RT_TRACE(_module_hal_init_c_ , _drv_info_, + ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", + GET_PWR_CFG_OFFSET(pwrcfgcmd), + GET_PWR_CFG_CUT_MASK(pwrcfgcmd), + GET_PWR_CFG_FAB_MASK(pwrcfgcmd), + GET_PWR_CFG_INTF_MASK(pwrcfgcmd), + GET_PWR_CFG_BASE(pwrcfgcmd), + GET_PWR_CFG_CMD(pwrcfgcmd), + GET_PWR_CFG_MASK(pwrcfgcmd), + GET_PWR_CFG_VALUE(pwrcfgcmd))); + + /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ + if ((GET_PWR_CFG_FAB_MASK(pwrcfgcmd) & fab_vers) && + (GET_PWR_CFG_CUT_MASK(pwrcfgcmd) & cut_vers) && + (GET_PWR_CFG_INTF_MASK(pwrcfgcmd) & ifacetype)) { + switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { + case PWR_CMD_READ: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); + break; + case PWR_CMD_WRITE: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); + offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); + + /* Read the value from system register */ + value = rtw_read8(padapter, offset); + + value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); + value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); + + /* Write the value back to system register */ + rtw_write8(padapter, offset, value); + break; + case PWR_CMD_POLLING: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); + + poll_bit = false; + offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); + do { + value = rtw_read8(padapter, offset); + + value &= GET_PWR_CFG_MASK(pwrcfgcmd); + if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) + poll_bit = true; + else + rtw_udelay_os(10); + + if (poll_count++ > max_poll_count) { + DBG_88E("Fail to polling Offset[%#x]\n", offset); + return false; + } + } while (!poll_bit); + break; + case PWR_CMD_DELAY: + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); + if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) + rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); + else + rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + break; + case PWR_CMD_END: + /* When this command is parsed, end the process */ + RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); + return true; + break; + default: + RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); + break; + } + } + + aryidx++;/* Add Array Index */ + } while (1); + return true; +} diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c new file mode 100644 index 000000000000..60ff30f1c3ac --- /dev/null +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -0,0 +1,381 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#include +#include + +#include +#include +#include + +#define _HAL_INIT_C_ + +void dump_chip_info(struct HAL_VERSION chip_vers) +{ + uint cnt = 0; + char buf[128]; + + if (IS_81XXC(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: %s_", + IS_92C_SERIAL(chip_vers) ? + "CHIP_8192C" : "CHIP_8188C"); + } else if (IS_92D(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8192D_"); + } else if (IS_8723_SERIES(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723A_"); + } else if (IS_8188E(chip_vers)) { + cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_"); + } + + cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ? + "Normal_Chip" : "Test_Chip"); + cnt += sprintf((buf+cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ? + "TSMC" : "UMC"); + if (IS_A_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "A_CUT_"); + else if (IS_B_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "B_CUT_"); + else if (IS_C_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "C_CUT_"); + else if (IS_D_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "D_CUT_"); + else if (IS_E_CUT(chip_vers)) + cnt += sprintf((buf+cnt), "E_CUT_"); + else + cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", + chip_vers.CUTVersion); + + if (IS_1T1R(chip_vers)) + cnt += sprintf((buf+cnt), "1T1R_"); + else if (IS_1T2R(chip_vers)) + cnt += sprintf((buf+cnt), "1T2R_"); + else if (IS_2T2R(chip_vers)) + cnt += sprintf((buf+cnt), "2T2R_"); + else + cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_", + chip_vers.RFType); + + cnt += sprintf((buf+cnt), "RomVer(%d)\n", chip_vers.ROMVer); + + pr_info("%s", buf); +} + +#define CHAN_PLAN_HW 0x80 + +u8 /* return the final channel plan decision */ +hal_com_get_channel_plan(struct adapter *padapter, u8 hw_channel_plan, + u8 sw_channel_plan, u8 def_channel_plan, + bool load_fail) +{ + u8 sw_cfg; + u8 chnlplan; + + sw_cfg = true; + if (!load_fail) { + if (!rtw_is_channel_plan_valid(sw_channel_plan)) + sw_cfg = false; + if (hw_channel_plan & CHAN_PLAN_HW) + sw_cfg = false; + } + + if (sw_cfg) + chnlplan = sw_channel_plan; + else + chnlplan = hw_channel_plan & (~CHAN_PLAN_HW); + + if (!rtw_is_channel_plan_valid(chnlplan)) + chnlplan = def_channel_plan; + + return chnlplan; +} + +u8 MRateToHwRate(u8 rate) +{ + u8 ret = DESC_RATE1M; + + switch (rate) { + /* CCK and OFDM non-HT rates */ + case IEEE80211_CCK_RATE_1MB: + ret = DESC_RATE1M; + break; + case IEEE80211_CCK_RATE_2MB: + ret = DESC_RATE2M; + break; + case IEEE80211_CCK_RATE_5MB: + ret = DESC_RATE5_5M; + break; + case IEEE80211_CCK_RATE_11MB: + ret = DESC_RATE11M; + break; + case IEEE80211_OFDM_RATE_6MB: + ret = DESC_RATE6M; + break; + case IEEE80211_OFDM_RATE_9MB: + ret = DESC_RATE9M; + break; + case IEEE80211_OFDM_RATE_12MB: + ret = DESC_RATE12M; + break; + case IEEE80211_OFDM_RATE_18MB: + ret = DESC_RATE18M; + break; + case IEEE80211_OFDM_RATE_24MB: + ret = DESC_RATE24M; + break; + case IEEE80211_OFDM_RATE_36MB: + ret = DESC_RATE36M; + break; + case IEEE80211_OFDM_RATE_48MB: + ret = DESC_RATE48M; + break; + case IEEE80211_OFDM_RATE_54MB: + ret = DESC_RATE54M; + break; + default: + break; + } + return ret; +} + +void HalSetBrateCfg(struct adapter *adapt, u8 *brates, u16 *rate_cfg) +{ + u8 i, is_brate, brate; + + for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { + is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK; + brate = brates[i] & 0x7f; + + if (is_brate) { + switch (brate) { + case IEEE80211_CCK_RATE_1MB: + *rate_cfg |= RATE_1M; + break; + case IEEE80211_CCK_RATE_2MB: + *rate_cfg |= RATE_2M; + break; + case IEEE80211_CCK_RATE_5MB: + *rate_cfg |= RATE_5_5M; + break; + case IEEE80211_CCK_RATE_11MB: + *rate_cfg |= RATE_11M; + break; + case IEEE80211_OFDM_RATE_6MB: + *rate_cfg |= RATE_6M; + break; + case IEEE80211_OFDM_RATE_9MB: + *rate_cfg |= RATE_9M; + break; + case IEEE80211_OFDM_RATE_12MB: + *rate_cfg |= RATE_12M; + break; + case IEEE80211_OFDM_RATE_18MB: + *rate_cfg |= RATE_18M; + break; + case IEEE80211_OFDM_RATE_24MB: + *rate_cfg |= RATE_24M; + break; + case IEEE80211_OFDM_RATE_36MB: + *rate_cfg |= RATE_36M; + break; + case IEEE80211_OFDM_RATE_48MB: + *rate_cfg |= RATE_48M; + break; + case IEEE80211_OFDM_RATE_54MB: + *rate_cfg |= RATE_54M; + break; + } + } + } +} + +static void one_out_pipe(struct adapter *adapter) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ +} + +static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + if (wifi_cfg) { /* WMM */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 0, 1, 0, 1, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + + } else {/* typical setting */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 1, 1, 0, 0, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + } +} + +static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) +{ + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); + + if (wifi_cfg) {/* for WMM */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 1, 2, 1, 0, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:N, 2:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + + } else {/* typical setting */ + /* BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA */ + /* 2, 2, 1, 0, 0, 0, 0, 0, 0}; */ + /* 0:H, 1:N, 2:L */ + + pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ + pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ + pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ + pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */ + + pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ + pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ + pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ + pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ + } +} + +bool Hal_MappingOutPipe(struct adapter *adapter, u8 numoutpipe) +{ + struct registry_priv *pregistrypriv = &adapter->registrypriv; + bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false; + bool result = true; + + switch (numoutpipe) { + case 2: + two_out_pipe(adapter, wifi_cfg); + break; + case 3: + three_out_pipe(adapter, wifi_cfg); + break; + case 1: + one_out_pipe(adapter); + break; + default: + result = false; + break; + } + return result; +} + +void hal_init_macaddr(struct adapter *adapter) +{ + rtw_hal_set_hwreg(adapter, HW_VAR_MAC_ADDR, + adapter->eeprompriv.mac_addr); +} + +/* +* C2H event format: +* Field TRIGGER CONTENT CMD_SEQ CMD_LEN CMD_ID +* BITS [127:120] [119:16] [15:8] [7:4] [3:0] +*/ + +void c2h_evt_clear(struct adapter *adapter) +{ + rtw_write8(adapter, REG_C2HEVT_CLEAR, C2H_EVT_HOST_CLOSE); +} + +s32 c2h_evt_read(struct adapter *adapter, u8 *buf) +{ + s32 ret = _FAIL; + struct c2h_evt_hdr *c2h_evt; + int i; + u8 trigger; + + if (buf == NULL) + goto exit; + + trigger = rtw_read8(adapter, REG_C2HEVT_CLEAR); + + if (trigger == C2H_EVT_HOST_CLOSE) + goto exit; /* Not ready */ + else if (trigger != C2H_EVT_FW_CLOSE) + goto clear_evt; /* Not a valid value */ + + c2h_evt = (struct c2h_evt_hdr *)buf; + + memset(c2h_evt, 0, 16); + + *buf = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL); + *(buf+1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); + + RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): ", + &c2h_evt , sizeof(c2h_evt)); + + /* Read the content */ + for (i = 0; i < c2h_evt->plen; i++) + c2h_evt->payload[i] = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + + sizeof(*c2h_evt) + i); + + RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, + "c2h_evt_read(): Command Content:\n", + c2h_evt->payload, c2h_evt->plen); + + ret = _SUCCESS; + +clear_evt: + /* + * Clear event to notify FW we have read the command. + * If this field isn't clear, the FW won't update the next + * command message. + */ + c2h_evt_clear(adapter); +exit: + return ret; +} diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c new file mode 100644 index 000000000000..ce37c7594f2d --- /dev/null +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -0,0 +1,468 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#define _HAL_INTF_C_ +#include +#include +#include +#include + +void rtw_hal_chip_configure(struct adapter *adapt) +{ + if (adapt->HalFunc.intf_chip_configure) + adapt->HalFunc.intf_chip_configure(adapt); +} + +void rtw_hal_read_chip_info(struct adapter *adapt) +{ + if (adapt->HalFunc.read_adapter_info) + adapt->HalFunc.read_adapter_info(adapt); +} + +void rtw_hal_read_chip_version(struct adapter *adapt) +{ + if (adapt->HalFunc.read_chip_version) + adapt->HalFunc.read_chip_version(adapt); +} + +void rtw_hal_def_value_init(struct adapter *adapt) +{ + if (adapt->HalFunc.init_default_value) + adapt->HalFunc.init_default_value(adapt); +} + +void rtw_hal_free_data(struct adapter *adapt) +{ + if (adapt->HalFunc.free_hal_data) + adapt->HalFunc.free_hal_data(adapt); +} + +void rtw_hal_dm_init(struct adapter *adapt) +{ + if (adapt->HalFunc.dm_init) + adapt->HalFunc.dm_init(adapt); +} + +void rtw_hal_dm_deinit(struct adapter *adapt) +{ + /* cancel dm timer */ + if (adapt->HalFunc.dm_deinit) + adapt->HalFunc.dm_deinit(adapt); +} + +void rtw_hal_sw_led_init(struct adapter *adapt) +{ + if (adapt->HalFunc.InitSwLeds) + adapt->HalFunc.InitSwLeds(adapt); +} + +void rtw_hal_sw_led_deinit(struct adapter *adapt) +{ + if (adapt->HalFunc.DeInitSwLeds) + adapt->HalFunc.DeInitSwLeds(adapt); +} + +u32 rtw_hal_power_on(struct adapter *adapt) +{ + if (adapt->HalFunc.hal_power_on) + return adapt->HalFunc.hal_power_on(adapt); + return _FAIL; +} + +uint rtw_hal_init(struct adapter *adapt) +{ + uint status = _SUCCESS; + + adapt->hw_init_completed = false; + + status = adapt->HalFunc.hal_init(adapt); + + if (status == _SUCCESS) { + adapt->hw_init_completed = true; + + if (adapt->registrypriv.notch_filter == 1) + rtw_hal_notch_filter(adapt, 1); + + rtw_hal_reset_security_engine(adapt); + } else { + adapt->hw_init_completed = false; + DBG_88E("rtw_hal_init: hal__init fail\n"); + } + + RT_TRACE(_module_hal_init_c_, _drv_err_, + ("-rtl871x_hal_init:status=0x%x\n", status)); + + return status; +} + +uint rtw_hal_deinit(struct adapter *adapt) +{ + uint status = _SUCCESS; + + status = adapt->HalFunc.hal_deinit(adapt); + + if (status == _SUCCESS) + adapt->hw_init_completed = false; + else + DBG_88E("\n rtw_hal_deinit: hal_init fail\n"); + + return status; +} + +void rtw_hal_set_hwreg(struct adapter *adapt, u8 variable, u8 *val) +{ + if (adapt->HalFunc.SetHwRegHandler) + adapt->HalFunc.SetHwRegHandler(adapt, variable, val); +} + +void rtw_hal_get_hwreg(struct adapter *adapt, u8 variable, u8 *val) +{ + if (adapt->HalFunc.GetHwRegHandler) + adapt->HalFunc.GetHwRegHandler(adapt, variable, val); +} + +u8 rtw_hal_set_def_var(struct adapter *adapt, enum hal_def_variable var, + void *val) +{ + if (adapt->HalFunc.SetHalDefVarHandler) + return adapt->HalFunc.SetHalDefVarHandler(adapt, var, val); + return _FAIL; +} + +u8 rtw_hal_get_def_var(struct adapter *adapt, + enum hal_def_variable var, void *val) +{ + if (adapt->HalFunc.GetHalDefVarHandler) + return adapt->HalFunc.GetHalDefVarHandler(adapt, var, val); + return _FAIL; +} + +void rtw_hal_set_odm_var(struct adapter *adapt, + enum hal_odm_variable var, void *val1, + bool set) +{ + if (adapt->HalFunc.SetHalODMVarHandler) + adapt->HalFunc.SetHalODMVarHandler(adapt, var, + val1, set); +} + +void rtw_hal_get_odm_var(struct adapter *adapt, + enum hal_odm_variable var, void *val1, + bool set) +{ + if (adapt->HalFunc.GetHalODMVarHandler) + adapt->HalFunc.GetHalODMVarHandler(adapt, var, + val1, set); +} + +void rtw_hal_enable_interrupt(struct adapter *adapt) +{ + if (adapt->HalFunc.enable_interrupt) + adapt->HalFunc.enable_interrupt(adapt); + else + DBG_88E("%s: HalFunc.enable_interrupt is NULL!\n", __func__); +} + +void rtw_hal_disable_interrupt(struct adapter *adapt) +{ + if (adapt->HalFunc.disable_interrupt) + adapt->HalFunc.disable_interrupt(adapt); + else + DBG_88E("%s: HalFunc.disable_interrupt is NULL!\n", __func__); +} + +u32 rtw_hal_inirp_init(struct adapter *adapt) +{ + u32 rst = _FAIL; + + if (adapt->HalFunc.inirp_init) + rst = adapt->HalFunc.inirp_init(adapt); + else + DBG_88E(" %s HalFunc.inirp_init is NULL!!!\n", __func__); + return rst; +} + +u32 rtw_hal_inirp_deinit(struct adapter *adapt) +{ + if (adapt->HalFunc.inirp_deinit) + return adapt->HalFunc.inirp_deinit(adapt); + + return _FAIL; +} + +u8 rtw_hal_intf_ps_func(struct adapter *adapt, + enum hal_intf_ps_func efunc_id, u8 *val) +{ + if (adapt->HalFunc.interface_ps_func) + return adapt->HalFunc.interface_ps_func(adapt, efunc_id, + val); + return _FAIL; +} + +s32 rtw_hal_xmitframe_enqueue(struct adapter *padapter, + struct xmit_frame *pxmitframe) +{ + if(padapter->HalFunc.hal_xmitframe_enqueue) + return padapter->HalFunc.hal_xmitframe_enqueue(padapter, pxmitframe); + return false; +} + +s32 rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + if (adapt->HalFunc.hal_xmit) + return adapt->HalFunc.hal_xmit(adapt, pxmitframe); + + return false; +} + +s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) +{ + s32 ret = _FAIL; + if (adapt->HalFunc.mgnt_xmit) + ret = adapt->HalFunc.mgnt_xmit(adapt, pmgntframe); + return ret; +} + +s32 rtw_hal_init_xmit_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.init_xmit_priv != NULL) + return adapt->HalFunc.init_xmit_priv(adapt); + return _FAIL; +} + +void rtw_hal_free_xmit_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.free_xmit_priv != NULL) + adapt->HalFunc.free_xmit_priv(adapt); +} + +s32 rtw_hal_init_recv_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.init_recv_priv) + return adapt->HalFunc.init_recv_priv(adapt); + + return _FAIL; +} + +void rtw_hal_free_recv_priv(struct adapter *adapt) +{ + if (adapt->HalFunc.free_recv_priv) + adapt->HalFunc.free_recv_priv(adapt); +} + +void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) +{ + struct mlme_priv *pmlmepriv = &(adapt->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { +#ifdef CONFIG_88EU_AP_MODE + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &adapt->stapriv; + if ((mac_id-1) > 0) + psta = pstapriv->sta_aid[(mac_id-1) - 1]; + if (psta) + add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/ +#endif + } else { + if (adapt->HalFunc.UpdateRAMaskHandler) + adapt->HalFunc.UpdateRAMaskHandler(adapt, mac_id, + rssi_level); + } +} + +void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, + u8 rssi_level) +{ + if (adapt->HalFunc.Add_RateATid) + adapt->HalFunc.Add_RateATid(adapt, bitmap, arg, + rssi_level); +} + +/* Start specifical interface thread */ +void rtw_hal_start_thread(struct adapter *adapt) +{ + if (adapt->HalFunc.run_thread) + adapt->HalFunc.run_thread(adapt); +} + +/* Start specifical interface thread */ +void rtw_hal_stop_thread(struct adapter *adapt) +{ + if (adapt->HalFunc.cancel_thread) + adapt->HalFunc.cancel_thread(adapt); +} + +u32 rtw_hal_read_bbreg(struct adapter *adapt, u32 regaddr, u32 bitmask) +{ + u32 data = 0; + + if (adapt->HalFunc.read_bbreg) + data = adapt->HalFunc.read_bbreg(adapt, regaddr, bitmask); + return data; +} + +void rtw_hal_write_bbreg(struct adapter *adapt, u32 regaddr, u32 bitmask, + u32 data) +{ + if (adapt->HalFunc.write_bbreg) + adapt->HalFunc.write_bbreg(adapt, regaddr, bitmask, data); +} + +u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, + u32 regaddr, u32 bitmask) +{ + u32 data = 0; + + if (adapt->HalFunc.read_rfreg) + data = adapt->HalFunc.read_rfreg(adapt, rfpath, regaddr, + bitmask); + return data; +} + +void rtw_hal_write_rfreg(struct adapter *adapt, enum rf_radio_path rfpath, + u32 regaddr, u32 bitmask, u32 data) +{ + if (adapt->HalFunc.write_rfreg) + adapt->HalFunc.write_rfreg(adapt, rfpath, regaddr, + bitmask, data); +} + +s32 rtw_hal_interrupt_handler(struct adapter *adapt) +{ + if (adapt->HalFunc.interrupt_handler) + return adapt->HalFunc.interrupt_handler(adapt); + return _FAIL; +} + +void rtw_hal_set_bwmode(struct adapter *adapt, + enum ht_channel_width bandwidth, u8 offset) +{ + if (adapt->HalFunc.set_bwmode_handler) + adapt->HalFunc.set_bwmode_handler(adapt, bandwidth, + offset); +} + +void rtw_hal_set_chan(struct adapter *adapt, u8 channel) +{ + if (adapt->HalFunc.set_channel_handler) + adapt->HalFunc.set_channel_handler(adapt, channel); +} + +void rtw_hal_dm_watchdog(struct adapter *adapt) +{ + if (adapt->HalFunc.hal_dm_watchdog) + adapt->HalFunc.hal_dm_watchdog(adapt); +} + +void rtw_hal_bcn_related_reg_setting(struct adapter *adapt) +{ + if (adapt->HalFunc.SetBeaconRelatedRegistersHandler) + adapt->HalFunc.SetBeaconRelatedRegistersHandler(adapt); +} + +u8 rtw_hal_antdiv_before_linked(struct adapter *adapt) +{ + if (adapt->HalFunc.AntDivBeforeLinkHandler) + return adapt->HalFunc.AntDivBeforeLinkHandler(adapt); + return false; +} + +void rtw_hal_antdiv_rssi_compared(struct adapter *adapt, + struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src) +{ + if (adapt->HalFunc.AntDivCompareHandler) + adapt->HalFunc.AntDivCompareHandler(adapt, dst, src); +} + +void rtw_hal_sreset_init(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_init_value) + adapt->HalFunc.sreset_init_value(adapt); +} + +void rtw_hal_sreset_reset(struct adapter *adapt) +{ + if (adapt->HalFunc.silentreset) + adapt->HalFunc.silentreset(adapt); +} + +void rtw_hal_sreset_reset_value(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_reset_value) + adapt->HalFunc.sreset_reset_value(adapt); +} + +void rtw_hal_sreset_xmit_status_check(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_xmit_status_check) + adapt->HalFunc.sreset_xmit_status_check(adapt); +} + +void rtw_hal_sreset_linked_status_check(struct adapter *adapt) +{ + if (adapt->HalFunc.sreset_linked_status_check) + adapt->HalFunc.sreset_linked_status_check(adapt); +} + +u8 rtw_hal_sreset_get_wifi_status(struct adapter *adapt) +{ + u8 status = 0; + + if (adapt->HalFunc.sreset_get_wifi_status) + status = adapt->HalFunc.sreset_get_wifi_status(adapt); + return status; +} + +int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, + u32 max_wating_ms, u32 bndy_cnt) +{ + if (adapter->HalFunc.IOL_exec_cmds_sync) + return adapter->HalFunc.IOL_exec_cmds_sync(adapter, xmit_frame, + max_wating_ms, + bndy_cnt); + return _FAIL; +} + +void rtw_hal_notch_filter(struct adapter *adapter, bool enable) +{ + if (adapter->HalFunc.hal_notch_filter) + adapter->HalFunc.hal_notch_filter(adapter, enable); +} + +void rtw_hal_reset_security_engine(struct adapter *adapter) +{ + if (adapter->HalFunc.hal_reset_security_engine) + adapter->HalFunc.hal_reset_security_engine(adapter); +} + +s32 rtw_hal_c2h_handler(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt) +{ + s32 ret = _FAIL; + + if (adapter->HalFunc.c2h_handler) + ret = adapter->HalFunc.c2h_handler(adapter, c2h_evt); + return ret; +} + +c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter) +{ + return adapter->HalFunc.c2h_id_filter_ccx; +} diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c new file mode 100644 index 000000000000..8b8754c42bc1 --- /dev/null +++ b/drivers/staging/r8188eu/hal/odm.c @@ -0,0 +1,2174 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* include files */ + +#include "odm_precomp.h" + +static const u16 dB_Invert_Table[8][12] = { + {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, + {4, 5, 6, 6, 7, 8, 9, 10, 11, 13, 14, 16}, + {18, 20, 22, 25, 28, 32, 35, 40, 45, 50, 56, 63}, + {71, 79, 89, 100, 112, 126, 141, 158, 178, 200, 224, 251}, + {282, 316, 355, 398, 447, 501, 562, 631, 708, 794, 891, 1000}, + {1122, 1259, 1413, 1585, 1778, 1995, 2239, 2512, 2818, 3162, 3548, 3981}, + {4467, 5012, 5623, 6310, 7079, 7943, 8913, 10000, 11220, 12589, 14125, 15849}, + {17783, 19953, 22387, 25119, 28184, 31623, 35481, 39811, 44668, 50119, 56234, 65535} +}; + +/* avoid to warn in FreeBSD ==> To DO modify */ +static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { + /* UL DL */ + {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 0:unknown AP */ + {0xa44f, 0x5ea44f, 0x5e431c}, /* 1:realtek AP */ + {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 2:unknown AP => realtek_92SE */ + {0x5ea32b, 0x5ea42b, 0x5e4322}, /* 3:broadcom AP */ + {0x5ea422, 0x00a44f, 0x00a44f}, /* 4:ralink AP */ + {0x5ea322, 0x00a630, 0x00a44f}, /* 5:atheros AP */ + {0x5e4322, 0x5e4322, 0x5e4322},/* 6:cisco AP */ + {0x5ea44f, 0x00a44f, 0x5ea42b}, /* 8:marvell AP */ + {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 10:unknown AP=> 92U AP */ + {0x5ea42b, 0xa630, 0x5e431c}, /* 11:airgocap AP */ +}; + +/* Global var */ +u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D] = { + 0x7f8001fe, /* 0, +6.0dB */ + 0x788001e2, /* 1, +5.5dB */ + 0x71c001c7, /* 2, +5.0dB */ + 0x6b8001ae, /* 3, +4.5dB */ + 0x65400195, /* 4, +4.0dB */ + 0x5fc0017f, /* 5, +3.5dB */ + 0x5a400169, /* 6, +3.0dB */ + 0x55400155, /* 7, +2.5dB */ + 0x50800142, /* 8, +2.0dB */ + 0x4c000130, /* 9, +1.5dB */ + 0x47c0011f, /* 10, +1.0dB */ + 0x43c0010f, /* 11, +0.5dB */ + 0x40000100, /* 12, +0dB */ + 0x3c8000f2, /* 13, -0.5dB */ + 0x390000e4, /* 14, -1.0dB */ + 0x35c000d7, /* 15, -1.5dB */ + 0x32c000cb, /* 16, -2.0dB */ + 0x300000c0, /* 17, -2.5dB */ + 0x2d4000b5, /* 18, -3.0dB */ + 0x2ac000ab, /* 19, -3.5dB */ + 0x288000a2, /* 20, -4.0dB */ + 0x26000098, /* 21, -4.5dB */ + 0x24000090, /* 22, -5.0dB */ + 0x22000088, /* 23, -5.5dB */ + 0x20000080, /* 24, -6.0dB */ + 0x1e400079, /* 25, -6.5dB */ + 0x1c800072, /* 26, -7.0dB */ + 0x1b00006c, /* 27. -7.5dB */ + 0x19800066, /* 28, -8.0dB */ + 0x18000060, /* 29, -8.5dB */ + 0x16c0005b, /* 30, -9.0dB */ + 0x15800056, /* 31, -9.5dB */ + 0x14400051, /* 32, -10.0dB */ + 0x1300004c, /* 33, -10.5dB */ + 0x12000048, /* 34, -11.0dB */ + 0x11000044, /* 35, -11.5dB */ + 0x10000040, /* 36, -12.0dB */ + 0x0f00003c,/* 37, -12.5dB */ + 0x0e400039,/* 38, -13.0dB */ + 0x0d800036,/* 39, -13.5dB */ + 0x0cc00033,/* 40, -14.0dB */ + 0x0c000030,/* 41, -14.5dB */ + 0x0b40002d,/* 42, -15.0dB */ +}; + +u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = { + {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */ + {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */ + {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */ + {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */ + {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */ + {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */ + {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */ + {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */ + {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */ + {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */ + {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */ + {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */ + {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB */ + {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */ + {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */ + {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */ + {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */ + {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */ + {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */ + {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */ + {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */ + {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */ + {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */ + {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */ + {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */ + {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */ + {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */ + {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */ + {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */ + {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */ + {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */ + {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */ + {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */ +}; + +u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = { + {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */ + {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */ + {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */ + {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */ + {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */ + {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */ + {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */ + {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */ + {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */ + {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */ + {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */ + {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */ + {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB */ + {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */ + {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */ + {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */ + {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */ + {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */ + {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */ + {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */ + {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */ + {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */ + {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */ + {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */ + {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */ + {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */ + {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */ + {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */ + {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */ + {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */ + {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */ + {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */ + {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ +}; + +#define RxDefaultAnt1 0x65a9 +#define RxDefaultAnt2 0x569a + +/* 3 Export Interface */ + +/* 2011/09/21 MH Add to describe different team necessary resource allocate?? */ +void ODM_DMInit(struct odm_dm_struct *pDM_Odm) +{ + /* 2012.05.03 Luke: For all IC series */ + odm_CommonInfoSelfInit(pDM_Odm); + odm_CmnInfoInit_Debug(pDM_Odm); + odm_DIGInit(pDM_Odm); + odm_RateAdaptiveMaskInit(pDM_Odm); + + if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { + ; + } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { + odm_PrimaryCCA_Init(pDM_Odm); /* Gary */ + odm_DynamicBBPowerSavingInit(pDM_Odm); + odm_DynamicTxPowerInit(pDM_Odm); + odm_TXPowerTrackingInit(pDM_Odm); + ODM_EdcaTurboInit(pDM_Odm); + ODM_RAInfo_Init_all(pDM_Odm); + if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) + odm_InitHybridAntDiv(pDM_Odm); + else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV) + odm_SwAntDivInit(pDM_Odm); + } +} + +/* 2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */ +/* You can not add any dummy function here, be care, you can only use DM structure */ +/* to perform any new ODM_DM. */ +void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) +{ + /* 2012.05.03 Luke: For all IC series */ + odm_GlobalAdapterCheck(); + odm_CmnInfoHook_Debug(pDM_Odm); + odm_CmnInfoUpdate_Debug(pDM_Odm); + odm_CommonInfoSelfUpdate(pDM_Odm); + odm_FalseAlarmCounterStatistics(pDM_Odm); + odm_RSSIMonitorCheck(pDM_Odm); + + /* For CE Platform(SPRD or Tablet) */ + /* 8723A or 8189ES platform */ + /* NeilChen--2012--08--24-- */ + /* Fix Leave LPS issue */ + if ((pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&/* in LPS mode */ + ((pDM_Odm->SupportICType & (ODM_RTL8723A)) || + (pDM_Odm->SupportICType & (ODM_RTL8188E) && + ((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))))) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n")); + odm_DIGbyRSSI_LPS(pDM_Odm); + } else { + odm_DIG(pDM_Odm); + } + odm_CCKPacketDetectionThresh(pDM_Odm); + + if (*(pDM_Odm->pbPowerSaving)) + return; + + odm_RefreshRateAdaptiveMask(pDM_Odm); + + odm_DynamicBBPowerSaving(pDM_Odm); + odm_DynamicPrimaryCCA(pDM_Odm); + if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || + (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) + odm_HwAntDiv(pDM_Odm); + else if (pDM_Odm->AntDivType == CGCS_RX_SW_ANTDIV) + odm_SwAntDivChkAntSwitch(pDM_Odm, SWAW_STEP_PEAK); + + if (pDM_Odm->SupportICType & ODM_IC_11AC_SERIES) { + ; + } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { + ODM_TXPowerTrackingCheck(pDM_Odm); + odm_EdcaTurboCheck(pDM_Odm); + odm_DynamicTxPower(pDM_Odm); + } + odm_dtc(pDM_Odm); +} + +/* Init /.. Fixed HW value. Only init time. */ +void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u32 Value) +{ + /* This section is used for init value */ + switch (CmnInfo) { + /* Fixed ODM value. */ + case ODM_CMNINFO_ABILITY: + pDM_Odm->SupportAbility = (u32)Value; + break; + case ODM_CMNINFO_PLATFORM: + pDM_Odm->SupportPlatform = (u8)Value; + break; + case ODM_CMNINFO_INTERFACE: + pDM_Odm->SupportInterface = (u8)Value; + break; + case ODM_CMNINFO_MP_TEST_CHIP: + pDM_Odm->bIsMPChip = (u8)Value; + break; + case ODM_CMNINFO_IC_TYPE: + pDM_Odm->SupportICType = Value; + break; + case ODM_CMNINFO_CUT_VER: + pDM_Odm->CutVersion = (u8)Value; + break; + case ODM_CMNINFO_FAB_VER: + pDM_Odm->FabVersion = (u8)Value; + break; + case ODM_CMNINFO_RF_TYPE: + pDM_Odm->RFType = (u8)Value; + break; + case ODM_CMNINFO_RF_ANTENNA_TYPE: + pDM_Odm->AntDivType = (u8)Value; + break; + case ODM_CMNINFO_BOARD_TYPE: + pDM_Odm->BoardType = (u8)Value; + break; + case ODM_CMNINFO_EXT_LNA: + pDM_Odm->ExtLNA = (u8)Value; + break; + case ODM_CMNINFO_EXT_PA: + pDM_Odm->ExtPA = (u8)Value; + break; + case ODM_CMNINFO_EXT_TRSW: + pDM_Odm->ExtTRSW = (u8)Value; + break; + case ODM_CMNINFO_PATCH_ID: + pDM_Odm->PatchID = (u8)Value; + break; + case ODM_CMNINFO_BINHCT_TEST: + pDM_Odm->bInHctTest = (bool)Value; + break; + case ODM_CMNINFO_BWIFI_TEST: + pDM_Odm->bWIFITest = (bool)Value; + break; + case ODM_CMNINFO_SMART_CONCURRENT: + pDM_Odm->bDualMacSmartConcurrent = (bool)Value; + break; + /* To remove the compiler warning, must add an empty default statement to handle the other values. */ + default: + /* do nothing */ + break; + } + + /* Tx power tracking BB swing table. */ + /* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ + pDM_Odm->BbSwingIdxOfdm = 12; /* Set defalut value as index 12. */ + pDM_Odm->BbSwingIdxOfdmCurrent = 12; + pDM_Odm->BbSwingFlagOfdm = false; +} + +void ODM_CmnInfoHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, void *pValue) +{ + /* */ + /* Hook call by reference pointer. */ + /* */ + switch (CmnInfo) { + /* Dynamic call by reference pointer. */ + case ODM_CMNINFO_MAC_PHY_MODE: + pDM_Odm->pMacPhyMode = (u8 *)pValue; + break; + case ODM_CMNINFO_TX_UNI: + pDM_Odm->pNumTxBytesUnicast = (u64 *)pValue; + break; + case ODM_CMNINFO_RX_UNI: + pDM_Odm->pNumRxBytesUnicast = (u64 *)pValue; + break; + case ODM_CMNINFO_WM_MODE: + pDM_Odm->pWirelessMode = (u8 *)pValue; + break; + case ODM_CMNINFO_BAND: + pDM_Odm->pBandType = (u8 *)pValue; + break; + case ODM_CMNINFO_SEC_CHNL_OFFSET: + pDM_Odm->pSecChOffset = (u8 *)pValue; + break; + case ODM_CMNINFO_SEC_MODE: + pDM_Odm->pSecurity = (u8 *)pValue; + break; + case ODM_CMNINFO_BW: + pDM_Odm->pBandWidth = (u8 *)pValue; + break; + case ODM_CMNINFO_CHNL: + pDM_Odm->pChannel = (u8 *)pValue; + break; + case ODM_CMNINFO_DMSP_GET_VALUE: + pDM_Odm->pbGetValueFromOtherMac = (bool *)pValue; + break; + case ODM_CMNINFO_BUDDY_ADAPTOR: + pDM_Odm->pBuddyAdapter = (struct adapter **)pValue; + break; + case ODM_CMNINFO_DMSP_IS_MASTER: + pDM_Odm->pbMasterOfDMSP = (bool *)pValue; + break; + case ODM_CMNINFO_SCAN: + pDM_Odm->pbScanInProcess = (bool *)pValue; + break; + case ODM_CMNINFO_POWER_SAVING: + pDM_Odm->pbPowerSaving = (bool *)pValue; + break; + case ODM_CMNINFO_ONE_PATH_CCA: + pDM_Odm->pOnePathCCA = (u8 *)pValue; + break; + case ODM_CMNINFO_DRV_STOP: + pDM_Odm->pbDriverStopped = (bool *)pValue; + break; + case ODM_CMNINFO_PNP_IN: + pDM_Odm->pbDriverIsGoingToPnpSetPowerSleep = (bool *)pValue; + break; + case ODM_CMNINFO_INIT_ON: + pDM_Odm->pinit_adpt_in_progress = (bool *)pValue; + break; + case ODM_CMNINFO_ANT_TEST: + pDM_Odm->pAntennaTest = (u8 *)pValue; + break; + case ODM_CMNINFO_NET_CLOSED: + pDM_Odm->pbNet_closed = (bool *)pValue; + break; + case ODM_CMNINFO_MP_MODE: + pDM_Odm->mp_mode = (u8 *)pValue; + break; + /* To remove the compiler warning, must add an empty default statement to handle the other values. */ + default: + /* do nothing */ + break; + } +} + +void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u16 Index, void *pValue) +{ + /* Hook call by reference pointer. */ + switch (CmnInfo) { + /* Dynamic call by reference pointer. */ + case ODM_CMNINFO_STA_STATUS: + pDM_Odm->pODM_StaInfo[Index] = (struct sta_info *)pValue; + break; + /* To remove the compiler warning, must add an empty default statement to handle the other values. */ + default: + /* do nothing */ + break; + } +} + +/* Update Band/CHannel/.. The values are dynamic but non-per-packet. */ +void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value) +{ + /* */ + /* This init variable may be changed in run time. */ + /* */ + switch (CmnInfo) { + case ODM_CMNINFO_ABILITY: + pDM_Odm->SupportAbility = (u32)Value; + break; + case ODM_CMNINFO_RF_TYPE: + pDM_Odm->RFType = (u8)Value; + break; + case ODM_CMNINFO_WIFI_DIRECT: + pDM_Odm->bWIFI_Direct = (bool)Value; + break; + case ODM_CMNINFO_WIFI_DISPLAY: + pDM_Odm->bWIFI_Display = (bool)Value; + break; + case ODM_CMNINFO_LINK: + pDM_Odm->bLinked = (bool)Value; + break; + case ODM_CMNINFO_RSSI_MIN: + pDM_Odm->RSSI_Min = (u8)Value; + break; + case ODM_CMNINFO_DBG_COMP: + pDM_Odm->DebugComponents = Value; + break; + case ODM_CMNINFO_DBG_LEVEL: + pDM_Odm->DebugLevel = (u32)Value; + break; + case ODM_CMNINFO_RA_THRESHOLD_HIGH: + pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value; + break; + case ODM_CMNINFO_RA_THRESHOLD_LOW: + pDM_Odm->RateAdaptive.LowRSSIThresh = (u8)Value; + break; + } +} + +void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT9); + pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); + if (pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D)) + pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV; + if (pDM_Odm->SupportICType & (ODM_RTL8723A)) + pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV; + + ODM_InitDebugSetting(pDM_Odm); +} + +void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm) +{ + u8 EntryCnt = 0; + u8 i; + struct sta_info *pEntry; + + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) { + if (*(pDM_Odm->pSecChOffset) == 1) + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) - 2; + else if (*(pDM_Odm->pSecChOffset) == 2) + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) + 2; + } else { + pDM_Odm->ControlChannel = *(pDM_Odm->pChannel); + } + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + pEntry = pDM_Odm->pODM_StaInfo[i]; + if (IS_STA_VALID(pEntry)) + EntryCnt++; + } + if (EntryCnt == 1) + pDM_Odm->bOneEntryOnly = true; + else + pDM_Odm->bOneEntryOnly = false; +} + +void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform=%d\n", pDM_Odm->SupportPlatform)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility=0x%x\n", pDM_Odm->SupportAbility)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface=%d\n", pDM_Odm->SupportInterface)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType=0x%x\n", pDM_Odm->SupportICType)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion=%d\n", pDM_Odm->CutVersion)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion=%d\n", pDM_Odm->FabVersion)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType=%d\n", pDM_Odm->RFType)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType=%d\n", pDM_Odm->BoardType)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA=%d\n", pDM_Odm->ExtLNA)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA=%d\n", pDM_Odm->ExtPA)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW=%d\n", pDM_Odm->ExtTRSW)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID=%d\n", pDM_Odm->PatchID)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest=%d\n", pDM_Odm->bInHctTest)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest=%d\n", pDM_Odm->bWIFITest)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent=%d\n", pDM_Odm->bDualMacSmartConcurrent)); +} + +void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoHook_Debug==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumTxBytesUnicast=%llu\n", *(pDM_Odm->pNumTxBytesUnicast))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumRxBytesUnicast=%llu\n", *(pDM_Odm->pNumRxBytesUnicast))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pWirelessMode=0x%x\n", *(pDM_Odm->pWirelessMode))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecChOffset=%d\n", *(pDM_Odm->pSecChOffset))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecurity=%d\n", *(pDM_Odm->pSecurity))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBandWidth=%d\n", *(pDM_Odm->pBandWidth))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pChannel=%d\n", *(pDM_Odm->pChannel))); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbScanInProcess=%d\n", *(pDM_Odm->pbScanInProcess))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbPowerSaving=%d\n", *(pDM_Odm->pbPowerSaving))); + + if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pOnePathCCA=%d\n", *(pDM_Odm->pOnePathCCA))); +} + +void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm) +{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoUpdate_Debug==>\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Direct=%d\n", pDM_Odm->bWIFI_Direct)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Display=%d\n", pDM_Odm->bWIFI_Display)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked=%d\n", pDM_Odm->bLinked)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min=%d\n", pDM_Odm->RSSI_Min)); +} + +static int getIGIForDiff(int value_IGI) +{ + #define ONERCCA_LOW_TH 0x30 + #define ONERCCA_LOW_DIFF 8 + + if (value_IGI < ONERCCA_LOW_TH) { + if ((ONERCCA_LOW_TH - value_IGI) < ONERCCA_LOW_DIFF) + return ONERCCA_LOW_TH; + else + return value_IGI + ONERCCA_LOW_DIFF; + } else { + return value_IGI; + } +} + +void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("ODM_REG(IGI_A,pDM_Odm)=0x%x, ODM_BIT(IGI,pDM_Odm)=0x%x\n", + ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm))); + + if (pDM_DigTable->CurIGValue != CurrentIGI) { + if (pDM_Odm->SupportPlatform & (ODM_CE|ODM_MP)) { + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + } else if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + switch (*(pDM_Odm->pOnePathCCA)) { + case ODM_CCA_2R: + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + break; + case ODM_CCA_1R_A: + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); + break; + case ODM_CCA_1R_B: + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); + if (pDM_Odm->SupportICType != ODM_RTL8188E) + ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + break; + } + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x).\n", CurrentIGI)); + /* pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue; */ + pDM_DigTable->CurIGValue = CurrentIGI; + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_Write_DIG():CurrentIGI=0x%x\n", CurrentIGI)); + +/* Add by Neil Chen to enable edcca to MP Platform */ +} + +/* Need LPS mode for CE platform --2012--08--24--- */ +/* 8723AS/8189ES */ +void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *pAdapter = pDM_Odm->Adapter; + struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; + + u8 RSSI_Lower = DM_DIG_MIN_NIC; /* 0x1E or 0x1C */ + u8 bFwCurrentInPSMode = false; + u8 CurrentIGI = pDM_Odm->RSSI_Min; + + if (!(pDM_Odm->SupportICType & (ODM_RTL8723A | ODM_RTL8188E))) + return; + + CurrentIGI = CurrentIGI + RSSI_OFFSET_DIG; + bFwCurrentInPSMode = pAdapter->pwrctrlpriv.bFwCurrentInPSMode; + + /* Using FW PS mode to make IGI */ + if (bFwCurrentInPSMode) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG is in LPS mode\n")); + /* Adjust by FA in LPS MODE */ + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) + CurrentIGI = CurrentIGI+2; + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) + CurrentIGI = CurrentIGI+1; + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS) + CurrentIGI = CurrentIGI-1; + } else { + CurrentIGI = RSSI_Lower; + } + + /* Lower bound checking */ + + /* RSSI Lower bound check */ + if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) + RSSI_Lower = (pDM_Odm->RSSI_Min-10); + else + RSSI_Lower = DM_DIG_MIN_NIC; + + /* Upper and Lower Bound checking */ + if (CurrentIGI > DM_DIG_MAX_NIC) + CurrentIGI = DM_DIG_MAX_NIC; + else if (CurrentIGI < RSSI_Lower) + CurrentIGI = RSSI_Lower; + + ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ +} + +void odm_DIGInit(struct odm_dm_struct *pDM_Odm) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + + pDM_DigTable->CurIGValue = (u8) ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)); + pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; + pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; + pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; + pDM_DigTable->FAHighThresh = DM_false_ALARM_THRESH_HIGH; + if (pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) { + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; + } else { + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; + } + pDM_DigTable->BackoffVal = DM_DIG_BACKOFF_DEFAULT; + pDM_DigTable->BackoffVal_range_max = DM_DIG_BACKOFF_MAX; + pDM_DigTable->BackoffVal_range_min = DM_DIG_BACKOFF_MIN; + pDM_DigTable->PreCCK_CCAThres = 0xFF; + pDM_DigTable->CurCCK_CCAThres = 0x83; + pDM_DigTable->ForbiddenIGI = DM_DIG_MIN_NIC; + pDM_DigTable->LargeFAHit = 0; + pDM_DigTable->Recover_cnt = 0; + pDM_DigTable->DIG_Dynamic_MIN_0 = DM_DIG_MIN_NIC; + pDM_DigTable->DIG_Dynamic_MIN_1 = DM_DIG_MIN_NIC; + pDM_DigTable->bMediaConnect_0 = false; + pDM_DigTable->bMediaConnect_1 = false; + + /* To Initialize pDM_Odm->bDMInitialGainEnable == false to avoid DIG error */ + pDM_Odm->bDMInitialGainEnable = true; +} + +void odm_DIG(struct odm_dm_struct *pDM_Odm) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; + u8 DIG_Dynamic_MIN; + u8 DIG_MaxOfMin; + bool FirstConnect, FirstDisConnect; + u8 dm_dig_max, dm_dig_min; + u8 CurrentIGI = pDM_DigTable->CurIGValue; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n")); + if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); + return; + } + + if (*(pDM_Odm->pbScanInProcess)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: In Scan Progress\n")); + return; + } + + /* add by Neil Chen to avoid PSD is processing */ + if (pDM_Odm->bDMInitialGainEnable == false) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing\n")); + return; + } + + if (pDM_Odm->SupportICType == ODM_RTL8192D) { + if (*(pDM_Odm->pMacPhyMode) == ODM_DMSP) { + if (*(pDM_Odm->pbMasterOfDMSP)) { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); + } else { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); + } + } else { + if (*(pDM_Odm->pBandType) == ODM_BAND_5G) { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); + } else { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); + } + } + } else { + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); + } + + /* 1 Boundary Decision */ + if ((pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8723A)) && + ((pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) || pDM_Odm->ExtLNA)) { + if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + dm_dig_max = DM_DIG_MAX_AP_HP; + dm_dig_min = DM_DIG_MIN_AP_HP; + } else { + dm_dig_max = DM_DIG_MAX_NIC_HP; + dm_dig_min = DM_DIG_MIN_NIC_HP; + } + DIG_MaxOfMin = DM_DIG_MAX_AP_HP; + } else { + if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + dm_dig_max = DM_DIG_MAX_AP; + dm_dig_min = DM_DIG_MIN_AP; + DIG_MaxOfMin = dm_dig_max; + } else { + dm_dig_max = DM_DIG_MAX_NIC; + dm_dig_min = DM_DIG_MIN_NIC; + DIG_MaxOfMin = DM_DIG_MAX_AP; + } + } + if (pDM_Odm->bLinked) { + /* 2 8723A Series, offset need to be 10 */ + if (pDM_Odm->SupportICType == (ODM_RTL8723A)) { + /* 2 Upper Bound */ + if ((pDM_Odm->RSSI_Min + 10) > DM_DIG_MAX_NIC) + pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; + else if ((pDM_Odm->RSSI_Min + 10) < DM_DIG_MIN_NIC) + pDM_DigTable->rx_gain_range_max = DM_DIG_MIN_NIC; + else + pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 10; + /* 2 If BT is Concurrent, need to set Lower Bound */ + DIG_Dynamic_MIN = DM_DIG_MIN_NIC; + } else { + /* 2 Modify DIG upper bound */ + if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max) + pDM_DigTable->rx_gain_range_max = dm_dig_max; + else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min) + pDM_DigTable->rx_gain_range_max = dm_dig_min; + else + pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20; + /* 2 Modify DIG lower bound */ + if (pDM_Odm->bOneEntryOnly) { + if (pDM_Odm->RSSI_Min < dm_dig_min) + DIG_Dynamic_MIN = dm_dig_min; + else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin) + DIG_Dynamic_MIN = DIG_MaxOfMin; + else + DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() : bOneEntryOnly=true, DIG_Dynamic_MIN=0x%x\n", + DIG_Dynamic_MIN)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG() : pDM_Odm->RSSI_Min=%d\n", + pDM_Odm->RSSI_Min)); + } else if ((pDM_Odm->SupportICType == ODM_RTL8188E) && + (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { + /* 1 Lower Bound for 88E AntDiv */ + if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) { + DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d\n", + pDM_DigTable->AntDiv_RSSI_max)); + } + } else { + DIG_Dynamic_MIN = dm_dig_min; + } + } + } else { + pDM_DigTable->rx_gain_range_max = dm_dig_max; + DIG_Dynamic_MIN = dm_dig_min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() : No Link\n")); + } + + /* 1 Modify DIG lower bound, deal with abnormally large false alarm */ + if (pFalseAlmCnt->Cnt_all > 10000) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("dm_DIG(): Abnornally false alarm case.\n")); + + if (pDM_DigTable->LargeFAHit != 3) + pDM_DigTable->LargeFAHit++; + if (pDM_DigTable->ForbiddenIGI < CurrentIGI) { + pDM_DigTable->ForbiddenIGI = CurrentIGI; + pDM_DigTable->LargeFAHit = 1; + } + + if (pDM_DigTable->LargeFAHit >= 3) { + if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) + pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; + else + pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); + pDM_DigTable->Recover_cnt = 3600; /* 3600=2hr */ + } + + } else { + /* Recovery mechanism for IGI lower bound */ + if (pDM_DigTable->Recover_cnt != 0) { + pDM_DigTable->Recover_cnt--; + } else { + if (pDM_DigTable->LargeFAHit < 3) { + if ((pDM_DigTable->ForbiddenIGI-1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ + pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ + pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n")); + } else { + pDM_DigTable->ForbiddenIGI--; + pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: Approach Lower Bound\n")); + } + } else { + pDM_DigTable->LargeFAHit = 0; + } + } + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG(): pDM_DigTable->LargeFAHit=%d\n", + pDM_DigTable->LargeFAHit)); + + /* 1 Adjust initial gain by false alarm */ + if (pDM_Odm->bLinked) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG AfterLink\n")); + if (FirstConnect) { + CurrentIGI = pDM_Odm->RSSI_Min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("DIG: First Connect\n")); + } else { + if (pDM_Odm->SupportICType == ODM_RTL8192D) { + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_92D) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_92D) + CurrentIGI = CurrentIGI + 1; /* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_92D) + CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ + } else { + if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2) + CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0) + CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ + } + } + } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG BeforeLink\n")); + if (FirstDisConnect) { + CurrentIGI = pDM_DigTable->rx_gain_range_min; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): First DisConnect\n")); + } else { + /* 2012.03.30 LukeLee: enable DIG before link but with very high thresholds */ + if (pFalseAlmCnt->Cnt_all > 10000) + CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ + else if (pFalseAlmCnt->Cnt_all > 8000) + CurrentIGI = CurrentIGI + 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ + else if (pFalseAlmCnt->Cnt_all < 500) + CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): England DIG\n")); + } + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG End Adjust IGI\n")); + /* 1 Check initial gain by upper/lower bound */ + if (CurrentIGI > pDM_DigTable->rx_gain_range_max) + CurrentIGI = pDM_DigTable->rx_gain_range_max; + if (CurrentIGI < pDM_DigTable->rx_gain_range_min) + CurrentIGI = pDM_DigTable->rx_gain_range_min; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, + ("odm_DIG(): rx_gain_range_max=0x%x, rx_gain_range_min=0x%x\n", + pDM_DigTable->rx_gain_range_max, pDM_DigTable->rx_gain_range_min)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): TotalFA=%d\n", pFalseAlmCnt->Cnt_all)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue=0x%x\n", CurrentIGI)); + + /* 2 High power RSSI threshold */ + + ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ + pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked; + pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN; +} + +/* 3============================================================ */ +/* 3 FASLE ALARM CHECK */ +/* 3============================================================ */ + +void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) +{ + u32 ret_value; + struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); + + if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) + return; + + if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { + /* hold ofdm counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ + + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); + FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16); + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); + FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); + + FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; + + if (pDM_Odm->SupportICType == ODM_RTL8188E) { + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_SC_CNT_11N, bMaskDWord); + FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff); + FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16); + } + + /* hold cck counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT12, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT14, 1); + + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); + FalseAlmCnt->Cnt_Cck_fail = ret_value; + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); + FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff)<<8; + + ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); + FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); + + FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + + FalseAlmCnt->Cnt_SB_Search_fail + + FalseAlmCnt->Cnt_Parity_Fail + + FalseAlmCnt->Cnt_Rate_Illegal + + FalseAlmCnt->Cnt_Crc8_fail + + FalseAlmCnt->Cnt_Mcs_fail + + FalseAlmCnt->Cnt_Cck_fail); + + FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; + + if (pDM_Odm->SupportICType >= ODM_RTL8723A) { + /* reset false alarm counter registers */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 0); + /* update ofdm counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 0); /* update page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 0); /* update page D counter */ + + /* reset CCK CCA counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 2); + /* reset CCK FA counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2); + } + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n")); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Fast_Fsync=%d, Cnt_SB_Search_fail=%d\n", + FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Parity_Fail=%d, Cnt_Rate_Illegal=%d\n", + FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, + ("Cnt_Crc8_fail=%d, Cnt_Mcs_fail=%d\n", + FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); + } else { /* FOR ODM_IC_11AC_SERIES */ + /* read OFDM FA counter */ + FalseAlmCnt->Cnt_Ofdm_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_11AC, bMaskLWord); + FalseAlmCnt->Cnt_Cck_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_11AC, bMaskLWord); + FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail; + + /* reset OFDM FA coutner */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 0); + /* reset CCK FA counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1); + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail=%d\n", FalseAlmCnt->Cnt_Cck_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail=%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm=%d\n", FalseAlmCnt->Cnt_all)); +} + +/* 3============================================================ */ +/* 3 CCK Packet Detect Threshold */ +/* 3============================================================ */ + +void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) +{ + u8 CurCCK_CCAThres; + struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); + + if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD|ODM_BB_FA_CNT))) + return; + if (pDM_Odm->ExtLNA) + return; + if (pDM_Odm->bLinked) { + if (pDM_Odm->RSSI_Min > 25) { + CurCCK_CCAThres = 0xcd; + } else if ((pDM_Odm->RSSI_Min <= 25) && (pDM_Odm->RSSI_Min > 10)) { + CurCCK_CCAThres = 0x83; + } else { + if (FalseAlmCnt->Cnt_Cck_fail > 1000) + CurCCK_CCAThres = 0x83; + else + CurCCK_CCAThres = 0x40; + } + } else { + if (FalseAlmCnt->Cnt_Cck_fail > 1000) + CurCCK_CCAThres = 0x83; + else + CurCCK_CCAThres = 0x40; + } + ODM_Write_CCK_CCA_Thres(pDM_Odm, CurCCK_CCAThres); +} + +void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) +{ + struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; + + if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ + ODM_Write1Byte(pDM_Odm, ODM_REG(CCK_CCA, pDM_Odm), CurCCK_CCAThres); + pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; + pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; +} + +/* 3============================================================ */ +/* 3 BB Power Save */ +/* 3============================================================ */ +void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm) +{ + struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; + + pDM_PSTable->PreCCAState = CCA_MAX; + pDM_PSTable->CurCCAState = CCA_MAX; + pDM_PSTable->PreRFState = RF_MAX; + pDM_PSTable->CurRFState = RF_MAX; + pDM_PSTable->Rssi_val_min = 0; + pDM_PSTable->initialize = 0; +} + +void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm) +{ + if ((pDM_Odm->SupportICType != ODM_RTL8192C) && (pDM_Odm->SupportICType != ODM_RTL8723A)) + return; + if (!(pDM_Odm->SupportAbility & ODM_BB_PWR_SAVE)) + return; + if (!(pDM_Odm->SupportPlatform & (ODM_MP|ODM_CE))) + return; + + /* 1 2.Power Saving for 92C */ + if ((pDM_Odm->SupportICType == ODM_RTL8192C) && (pDM_Odm->RFType == ODM_2T2R)) { + odm_1R_CCA(pDM_Odm); + } else { + /* 20100628 Joseph: Turn off BB power save for 88CE because it makesthroughput unstable. */ + /* 20100831 Joseph: Turn ON BB power save again after modifying AGC delay from 900ns ot 600ns. */ + /* 1 3.Power Saving for 88C */ + ODM_RF_Saving(pDM_Odm, false); + } +} + +void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) +{ + struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; + + if (pDM_Odm->RSSI_Min != 0xFF) { + if (pDM_PSTable->PreCCAState == CCA_2R) { + if (pDM_Odm->RSSI_Min >= 35) + pDM_PSTable->CurCCAState = CCA_1R; + else + pDM_PSTable->CurCCAState = CCA_2R; + } else { + if (pDM_Odm->RSSI_Min <= 30) + pDM_PSTable->CurCCAState = CCA_2R; + else + pDM_PSTable->CurCCAState = CCA_1R; + } + } else { + pDM_PSTable->CurCCAState = CCA_MAX; + } + + if (pDM_PSTable->PreCCAState != pDM_PSTable->CurCCAState) { + if (pDM_PSTable->CurCCAState == CCA_1R) { + if (pDM_Odm->RFType == ODM_2T2R) + ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x13); + else + ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x23); + } else { + ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x33); + } + pDM_PSTable->PreCCAState = pDM_PSTable->CurCCAState; + } +} + +void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) +{ + struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; + u8 Rssi_Up_bound = 30; + u8 Rssi_Low_bound = 25; + + if (pDM_Odm->PatchID == 40) { /* RT_CID_819x_FUNAI_TV */ + Rssi_Up_bound = 50; + Rssi_Low_bound = 45; + } + if (pDM_PSTable->initialize == 0) { + pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14; + pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT3)>>3; + pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24; + pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12; + pDM_PSTable->initialize = 1; + } + + if (!bForceInNormal) { + if (pDM_Odm->RSSI_Min != 0xFF) { + if (pDM_PSTable->PreRFState == RF_Normal) { + if (pDM_Odm->RSSI_Min >= Rssi_Up_bound) + pDM_PSTable->CurRFState = RF_Save; + else + pDM_PSTable->CurRFState = RF_Normal; + } else { + if (pDM_Odm->RSSI_Min <= Rssi_Low_bound) + pDM_PSTable->CurRFState = RF_Normal; + else + pDM_PSTable->CurRFState = RF_Save; + } + } else { + pDM_PSTable->CurRFState = RF_MAX; + } + } else { + pDM_PSTable->CurRFState = RF_Normal; + } + + if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { + if (pDM_PSTable->CurRFState == RF_Save) { + /* 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode. */ + /* Suggested by SD3 Yu-Nan. 2011.01.20. */ + if (pDM_Odm->SupportICType == ODM_RTL8723A) + ODM_SetBBReg(pDM_Odm, 0x874 , BIT5, 0x1); /* Reg874[5]=1b'1 */ + ODM_SetBBReg(pDM_Odm, 0x874 , 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ + ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); /* RegC70[3]=1'b0 */ + ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ + ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ + ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); /* Reg818[28]=1'b0 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); /* Reg818[28]=1'b1 */ + } else { + ODM_SetBBReg(pDM_Odm, 0x874 , 0x1CC000, pDM_PSTable->Reg874); + ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70); + ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); + ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); + ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); + + if (pDM_Odm->SupportICType == ODM_RTL8723A) + ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x0); /* Reg874[5]=1b'0 */ + } + pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; + } +} + +/* 3============================================================ */ +/* 3 RATR MASK */ +/* 3============================================================ */ +/* 3============================================================ */ +/* 3 Rate Adaptive */ +/* 3============================================================ */ + +void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm) +{ + struct odm_rate_adapt *pOdmRA = &pDM_Odm->RateAdaptive; + + pOdmRA->Type = DM_Type_ByDriver; + if (pOdmRA->Type == DM_Type_ByDriver) + pDM_Odm->bUseRAMask = true; + else + pDM_Odm->bUseRAMask = false; + + pOdmRA->RATRState = DM_RATR_STA_INIT; + pOdmRA->HighRSSIThresh = 50; + pOdmRA->LowRSSIThresh = 20; +} + +u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u8 rssi_level) +{ + struct sta_info *pEntry; + u32 rate_bitmap = 0x0fffffff; + u8 WirelessMode; + + pEntry = pDM_Odm->pODM_StaInfo[macid]; + if (!IS_STA_VALID(pEntry)) + return ra_mask; + + WirelessMode = pEntry->wireless_mode; + + switch (WirelessMode) { + case ODM_WM_B: + if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ + rate_bitmap = 0x0000000d; + else + rate_bitmap = 0x0000000f; + break; + case (ODM_WM_A|ODM_WM_G): + if (rssi_level == DM_RATR_STA_HIGH) + rate_bitmap = 0x00000f00; + else + rate_bitmap = 0x00000ff0; + break; + case (ODM_WM_B|ODM_WM_G): + if (rssi_level == DM_RATR_STA_HIGH) + rate_bitmap = 0x00000f00; + else if (rssi_level == DM_RATR_STA_MIDDLE) + rate_bitmap = 0x00000ff0; + else + rate_bitmap = 0x00000ff5; + break; + case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): + case (ODM_WM_A|ODM_WM_B|ODM_WM_G|ODM_WM_N24G): + if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) { + if (rssi_level == DM_RATR_STA_HIGH) { + rate_bitmap = 0x000f0000; + } else if (rssi_level == DM_RATR_STA_MIDDLE) { + rate_bitmap = 0x000ff000; + } else { + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + rate_bitmap = 0x000ff015; + else + rate_bitmap = 0x000ff005; + } + } else { + if (rssi_level == DM_RATR_STA_HIGH) { + rate_bitmap = 0x0f8f0000; + } else if (rssi_level == DM_RATR_STA_MIDDLE) { + rate_bitmap = 0x0f8ff000; + } else { + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + rate_bitmap = 0x0f8ff015; + else + rate_bitmap = 0x0f8ff005; + } + } + break; + default: + /* case WIRELESS_11_24N: */ + /* case WIRELESS_11_5N: */ + if (pDM_Odm->RFType == RF_1T2R) + rate_bitmap = 0x000fffff; + else + rate_bitmap = 0x0fffffff; + break; + } + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, + (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", + rssi_level, WirelessMode, rate_bitmap)); + + return rate_bitmap; +} + +/*----------------------------------------------------------------------------- + * Function: odm_RefreshRateAdaptiveMask() + * + * Overview: Update rate table mask according to rssi + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 05/27/2009 hpfan Create Version 0. + * + *---------------------------------------------------------------------------*/ +void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) + return; + /* */ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + /* */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + odm_RefreshRateAdaptiveMaskMP(pDM_Odm); + break; + case ODM_CE: + odm_RefreshRateAdaptiveMaskCE(pDM_Odm); + break; + case ODM_AP: + case ODM_ADSL: + odm_RefreshRateAdaptiveMaskAPADSL(pDM_Odm); + break; + } +} + +void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm) +{ +} + +void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) +{ + u8 i; + struct adapter *pAdapter = pDM_Odm->Adapter; + + if (pAdapter->bDriverStopped) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n")); + return; + } + + if (!pDM_Odm->bUseRAMask) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n")); + return; + } + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; + if (IS_STA_VALID(pstat)) { + if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false , &pstat->rssi_level)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, + ("RSSI:%d, RSSI_LEVEL:%d\n", + pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level)); + rtw_hal_update_ra_mask(pAdapter, i, pstat->rssi_level); + } + } + } +} + +void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm) +{ +} + +/* Return Value: bool */ +/* - true: RATRState is changed. */ +bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState) +{ + struct odm_rate_adapt *pRA = &pDM_Odm->RateAdaptive; + const u8 GoUpGap = 5; + u8 HighRSSIThreshForRA = pRA->HighRSSIThresh; + u8 LowRSSIThreshForRA = pRA->LowRSSIThresh; + u8 RATRState; + + /* Threshold Adjustment: */ + /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */ + /* Here GoUpGap is added to solve the boundary's level alternation issue. */ + switch (*pRATRState) { + case DM_RATR_STA_INIT: + case DM_RATR_STA_HIGH: + break; + case DM_RATR_STA_MIDDLE: + HighRSSIThreshForRA += GoUpGap; + break; + case DM_RATR_STA_LOW: + HighRSSIThreshForRA += GoUpGap; + LowRSSIThreshForRA += GoUpGap; + break; + default: + ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState)); + break; + } + + /* Decide RATRState by RSSI. */ + if (RSSI > HighRSSIThreshForRA) + RATRState = DM_RATR_STA_HIGH; + else if (RSSI > LowRSSIThreshForRA) + RATRState = DM_RATR_STA_MIDDLE; + else + RATRState = DM_RATR_STA_LOW; + + if (*pRATRState != RATRState || bForceUpdate) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState)); + *pRATRState = RATRState; + return true; + } + return false; +} + +/* 3============================================================ */ +/* 3 Dynamic Tx Power */ +/* 3============================================================ */ + +void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + pdmpriv->bDynamicTxPowerEnable = false; + pdmpriv->LastDTPLvl = TxHighPwrLevel_Normal; + pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; +} + +void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm) +{ + /* For AP/ADSL use struct rtl8192cd_priv * */ + /* For CE/NIC use struct adapter * */ + + if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR)) + return; + + /* 2012/01/12 MH According to Luke's suggestion, only high power will support the feature. */ + if (!pDM_Odm->ExtPA) + return; + + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + case ODM_CE: + odm_DynamicTxPowerNIC(pDM_Odm); + break; + case ODM_AP: + odm_DynamicTxPowerAP(pDM_Odm); + break; + case ODM_ADSL: + break; + } +} + +void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_DYNAMIC_TXPWR)) + return; + + if (pDM_Odm->SupportICType == ODM_RTL8188E) { + /* ??? */ + /* This part need to be redefined. */ + } +} + +void odm_DynamicTxPowerAP(struct odm_dm_struct *pDM_Odm) +{ +} + +/* 3============================================================ */ +/* 3 RSSI Monitor */ +/* 3============================================================ */ + +void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR)) + return; + + /* */ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + /* */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + odm_RSSIMonitorCheckMP(pDM_Odm); + break; + case ODM_CE: + odm_RSSIMonitorCheckCE(pDM_Odm); + break; + case ODM_AP: + odm_RSSIMonitorCheckAP(pDM_Odm); + break; + case ODM_ADSL: + /* odm_DIGAP(pDM_Odm); */ + break; + } + +} /* odm_RSSIMonitorCheck */ + +void odm_RSSIMonitorCheckMP(struct odm_dm_struct *pDM_Odm) +{ +} + +static void FindMinimumRSSI(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv; + + /* 1 1.Determine the minimum RSSI */ + if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) && + (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) + pdmpriv->MinUndecoratedPWDBForDM = 0; + if (check_fwstate(pmlmepriv, _FW_LINKED) == true) /* Default port */ + pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; + else /* associated entry pwdb */ + pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; +} + +void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + int i; + int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff; + u8 sta_cnt = 0; + u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ + struct sta_info *psta; + u8 bcast_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) + return; + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + psta = pDM_Odm->pODM_StaInfo[i]; + if (IS_STA_VALID(psta) && + (psta->state & WIFI_ASOC_STATE) && + memcmp(psta->hwaddr, bcast_addr, ETH_ALEN) && + memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { + if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) + tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; + + if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) + tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; + if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) + PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16)); + } + } + + for (i = 0; i < sta_cnt; i++) { + if (PWDB_rssi[i] != (0)) { + if (pHalData->fw_ractrl) { + /* Report every sta's RSSI to FW */ + } else { + ODM_RA_SetRSSI_8188E( + &(pHalData->odmpriv), (PWDB_rssi[i]&0xFF), (u8)((PWDB_rssi[i]>>16) & 0xFF)); + } + } + } + + if (tmpEntryMaxPWDB != 0) /* If associated entry is found */ + pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB; + else + pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0; + + if (tmpEntryMinPWDB != 0xff) /* If associated entry is found */ + pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB; + else + pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; + + FindMinimumRSSI(Adapter); + ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); +} + +void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm) +{ +} + +void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + ODM_InitializeTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, + (void *)odm_SwAntDivChkAntSwitchCallback, NULL, "SwAntennaSwitchTimer"); +#else + timer_setup(&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, odm_SwAntDivChkAntSwitchCallback, 0); +#endif +} + +void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm) +{ + ODM_CancelTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); +} + +void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm) +{ + ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer); + + ODM_ReleaseTimer(pDM_Odm, &pDM_Odm->FastAntTrainingTimer); +} + +/* 3============================================================ */ +/* 3 Tx Power Tracking */ +/* 3============================================================ */ + +void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm) +{ + odm_TXPowerTrackingThermalMeterInit(pDM_Odm); +} + +void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; + pDM_Odm->RFCalibrateInfo.TXPowercount = 0; + pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = false; + if (*(pDM_Odm->mp_mode) != 1) + pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; + MSG_88E("pDM_Odm TxPowerTrackControl = %d\n", pDM_Odm->RFCalibrateInfo.TxPowerTrackControl); + + pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; +} + +void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm) +{ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + odm_TXPowerTrackingCheckMP(pDM_Odm); + break; + case ODM_CE: + odm_TXPowerTrackingCheckCE(pDM_Odm); + break; + case ODM_AP: + odm_TXPowerTrackingCheckAP(pDM_Odm); + break; + case ODM_ADSL: + break; + } +} + +void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + + if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK)) + return; + + if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ + PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); + + pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; + return; + } else { + odm_TXPowerTrackingCallback_ThermalMeter_8188E(Adapter); + pDM_Odm->RFCalibrateInfo.TM_Trigger = 0; + } +} + +void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm) +{ +} + +void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm) +{ +} + +/* antenna mapping info */ +/* 1: right-side antenna */ +/* 2/0: left-side antenna */ +/* PDM_SWAT_Table->CCK_Ant1_Cnt /OFDM_Ant1_Cnt: for right-side antenna: Ant:1 RxDefaultAnt1 */ +/* PDM_SWAT_Table->CCK_Ant2_Cnt /OFDM_Ant2_Cnt: for left-side antenna: Ant:0 RxDefaultAnt2 */ +/* We select left antenna as default antenna in initial process, modify it as needed */ +/* */ + +/* 3============================================================ */ +/* 3 SW Antenna Diversity */ +/* 3============================================================ */ +void odm_SwAntDivInit(struct odm_dm_struct *pDM_Odm) +{ +} + +void ODM_SwAntDivChkPerPktRssi(struct odm_dm_struct *pDM_Odm, u8 StationID, struct odm_phy_status_info *pPhyInfo) +{ +} + +void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step) +{ +} + +void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm) +{ +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext) +#else +void odm_SwAntDivChkAntSwitchCallback(struct timer_list *t) +#endif +{ +} + +/* 3============================================================ */ +/* 3 SW Antenna Diversity */ +/* 3============================================================ */ + +void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Return: Not Support HW AntDiv\n")); + return; + } + + if (pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D)) + ; + else if (pDM_Odm->SupportICType == ODM_RTL8188E) + ODM_AntennaDiversityInit_88E(pDM_Odm); +} + +void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, u32 PWDBAll, bool isCCKrate) +{ + struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + + if (pDM_SWAT_Table->antsel == 1) { + if (isCCKrate) { + pDM_SWAT_Table->CCK_Ant1_Cnt[MacId]++; + } else { + pDM_SWAT_Table->OFDM_Ant1_Cnt[MacId]++; + pDM_SWAT_Table->RSSI_Ant1_Sum[MacId] += PWDBAll; + } + } else { + if (isCCKrate) { + pDM_SWAT_Table->CCK_Ant2_Cnt[MacId]++; + } else { + pDM_SWAT_Table->OFDM_Ant2_Cnt[MacId]++; + pDM_SWAT_Table->RSSI_Ant2_Sum[MacId] += PWDBAll; + } + } +} + +void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm) +{ + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Return: Not Support HW AntDiv\n")); + return; + } + + if (pDM_Odm->SupportICType == ODM_RTL8188E) + ODM_AntennaDiversity_88E(pDM_Odm); +} + +/* EDCA Turbo */ +void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; + pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; + Adapter->recvpriv.bIsAnyNonBEPkts = false; + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VO_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VI_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM))); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BK_PARAM))); +} /* ODM_InitEdcaTurbo */ + +void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) +{ + /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ + /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ + /* HW dynamic mechanism. */ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("odm_EdcaTurboCheck========================>\n")); + + if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO)) + return; + + switch (pDM_Odm->SupportPlatform) { + case ODM_MP: + break; + case ODM_CE: + odm_EdcaTurboCheckCE(pDM_Odm); + break; + case ODM_AP: + case ODM_ADSL: + break; + } + ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("<========================odm_EdcaTurboCheck\n")); +} /* odm_CheckEdcaTurbo */ + +void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + u32 trafficIndex; + u32 edca_param; + u64 cur_tx_bytes = 0; + u64 cur_rx_bytes = 0; + u8 bbtchange = false; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv); + struct recv_priv *precvpriv = &(Adapter->recvpriv); + struct registry_priv *pregpriv = &Adapter->registrypriv; + struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((pregpriv->wifi_spec == 1))/* (pmlmeinfo->HT_enable == 0)) */ + goto dm_CheckEdcaTurbo_EXIT; + + if (pmlmeinfo->assoc_AP_vendor >= HT_IOT_PEER_MAX) + goto dm_CheckEdcaTurbo_EXIT; + + /* Check if the status needs to be changed. */ + if ((bbtchange) || (!precvpriv->bIsAnyNonBEPkts)) { + cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes; + cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes; + + /* traffic, TX or RX */ + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) || + (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS)) { + if (cur_tx_bytes > (cur_rx_bytes << 2)) { + /* Uplink TP is present. */ + trafficIndex = UP_LINK; + } else { + /* Balance TP is present. */ + trafficIndex = DOWN_LINK; + } + } else { + if (cur_rx_bytes > (cur_tx_bytes << 2)) { + /* Downlink TP is present. */ + trafficIndex = DOWN_LINK; + } else { + /* Balance TP is present. */ + trafficIndex = UP_LINK; + } + } + + if ((pDM_Odm->DM_EDCA_Table.prv_traffic_idx != trafficIndex) || (!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)) { + if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_CISCO) && (pmlmeext->cur_wireless_mode & WIRELESS_11_24N)) + edca_param = EDCAParam[pmlmeinfo->assoc_AP_vendor][trafficIndex]; + else + edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex]; + + rtw_write32(Adapter, REG_EDCA_BE_PARAM, edca_param); + + pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex; + } + + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = true; + } else { + /* Turn Off EDCA turbo here. */ + /* Restore original EDCA according to the declaration of AP. */ + if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { + rtw_write32(Adapter, REG_EDCA_BE_PARAM, pHalData->AcParam_BE); + pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; + } + } + +dm_CheckEdcaTurbo_EXIT: + /* Set variables for next time. */ + precvpriv->bIsAnyNonBEPkts = false; + pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes; + precvpriv->last_rx_bytes = precvpriv->rx_bytes; +} + +/* need to ODM CE Platform */ +/* move to here for ANT detection mechanism using */ + +u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, u8 initial_gain_psd) +{ + u32 psd_report; + + /* Set DCO frequency index, offset=(40MHz/SamplePts)*point */ + ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point); + + /* Start PSD calculation, Reg808[22]=0->1 */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 1); + /* Need to wait for HW PSD report */ + ODM_StallExecution(30); + ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 0); + /* Read PSD report, Reg8B4[15:0] */ + psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF; + + psd_report = (u32) (ConvertTo_dB(psd_report))+(u32)(initial_gain_psd-0x1c); + + return psd_report; +} + +u32 ConvertTo_dB(u32 Value) +{ + u8 i; + u8 j; + u32 dB; + + Value = Value & 0xFFFF; + for (i = 0; i < 8; i++) { + if (Value <= dB_Invert_Table[i][11]) + break; + } + + if (i >= 8) + return 96; /* maximum 96 dB */ + + for (j = 0; j < 12; j++) { + if (Value <= dB_Invert_Table[i][j]) + break; + } + + dB = i*12 + j + 1; + + return dB; +} + +/* 2011/09/22 MH Add for 92D global spin lock utilization. */ +void odm_GlobalAdapterCheck(void) +{ +} /* odm_GlobalAdapterCheck */ + +/* Description: */ +/* Set Single/Dual Antenna default setting for products that do not do detection in advance. */ +/* Added by Joseph, 2012.03.22 */ +void ODM_SingleDualAntennaDefaultSetting(struct odm_dm_struct *pDM_Odm) +{ + struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + + pDM_SWAT_Table->ANTA_ON = true; + pDM_SWAT_Table->ANTB_ON = true; +} + +/* 2 8723A ANT DETECT */ + +static void odm_PHY_SaveAFERegisters(struct odm_dm_struct *pDM_Odm, u32 *AFEReg, u32 *AFEBackup, u32 RegisterNum) +{ + u32 i; + + /* RTPRINT(FINIT, INIT_IQK, ("Save ADDA parameters.\n")); */ + for (i = 0; i < RegisterNum; i++) + AFEBackup[i] = ODM_GetBBReg(pDM_Odm, AFEReg[i], bMaskDWord); +} + +static void odm_PHY_ReloadAFERegisters(struct odm_dm_struct *pDM_Odm, u32 *AFEReg, u32 *AFEBackup, u32 RegiesterNum) +{ + u32 i; + + for (i = 0; i < RegiesterNum; i++) + ODM_SetBBReg(pDM_Odm, AFEReg[i], bMaskDWord, AFEBackup[i]); +} + +/* 2 8723A ANT DETECT */ +/* Description: */ +/* Implement IQK single tone for RF DPK loopback and BB PSD scanning. */ +/* This function is cooperated with BB team Neil. */ +bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) +{ + struct sw_ant_switch *pDM_SWAT_Table = &pDM_Odm->DM_SWAT_Table; + u32 CurrentChannel, RfLoopReg; + u8 n; + u32 Reg88c, Regc08, Reg874, Regc50; + u8 initial_gain = 0x5a; + u32 PSD_report_tmp; + u32 AntA_report = 0x0, AntB_report = 0x0, AntO_report = 0x0; + bool bResult = true; + u32 AFE_Backup[16]; + u32 AFE_REG_8723A[16] = { + rRx_Wait_CCA, rTx_CCK_RFON, + rTx_CCK_BBON, rTx_OFDM_RFON, + rTx_OFDM_BBON, rTx_To_Rx, + rTx_To_Tx, rRx_CCK, + rRx_OFDM, rRx_Wait_RIFS, + rRx_TO_Rx, rStandby, + rSleep, rPMPD_ANAEN, + rFPGA0_XCD_SwitchControl, rBlue_Tooth}; + + if (!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8192C))) + return bResult; + + if (!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV)) + return bResult; + + if (pDM_Odm->SupportICType == ODM_RTL8192C) { + /* Which path in ADC/DAC is turnned on for PSD: both I/Q */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT10|BIT11, 0x3); + /* Ageraged number: 8 */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT12|BIT13, 0x1); + /* pts = 128; */ + ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0); + } + + /* 1 Backup Current RF/BB Settings */ + + CurrentChannel = ODM_GetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask); + RfLoopReg = ODM_GetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask); + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, ODM_DPDT, Antenna_A); /* change to Antenna A */ + /* Step 1: USE IQK to transmitter single tone */ + + ODM_StallExecution(10); + + /* Store A Path Register 88c, c08, 874, c50 */ + Reg88c = ODM_GetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord); + Regc08 = ODM_GetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord); + Reg874 = ODM_GetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord); + Regc50 = ODM_GetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord); + + /* Store AFE Registers */ + odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); + + /* Set PSD 128 pts */ + ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT14|BIT15, 0x0); /* 128 pts */ + + /* To SET CH1 to do */ + ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); /* Channel 1 */ + + /* AFE all on step */ + ODM_SetBBReg(pDM_Odm, rRx_Wait_CCA, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_CCK_RFON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_CCK_BBON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_OFDM_RFON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_OFDM_BBON, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_To_Rx, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rTx_To_Tx, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_CCK, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_OFDM, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_Wait_RIFS, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rRx_TO_Rx, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rStandby, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rSleep, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rPMPD_ANAEN, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_SwitchControl, bMaskDWord, 0x6FDB25A4); + ODM_SetBBReg(pDM_Odm, rBlue_Tooth, bMaskDWord, 0x6FDB25A4); + + /* 3 wire Disable */ + ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, 0xCCF000C0); + + /* BB IQK Setting */ + ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800E4); + ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22208000); + + /* IQK setting tone@ 4.34Mhz */ + ODM_SetBBReg(pDM_Odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008C1C); + ODM_SetBBReg(pDM_Odm, rTx_IQK, bMaskDWord, 0x01007c00); + + /* Page B init */ + ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x00080000); + ODM_SetBBReg(pDM_Odm, rConfig_AntA, bMaskDWord, 0x0f600000); + ODM_SetBBReg(pDM_Odm, rRx_IQK, bMaskDWord, 0x01004800); + ODM_SetBBReg(pDM_Odm, rRx_IQK_Tone_A, bMaskDWord, 0x10008c1f); + ODM_SetBBReg(pDM_Odm, rTx_IQK_PI_A, bMaskDWord, 0x82150008); + ODM_SetBBReg(pDM_Odm, rRx_IQK_PI_A, bMaskDWord, 0x28150008); + ODM_SetBBReg(pDM_Odm, rIQK_AGC_Rsp, bMaskDWord, 0x001028d0); + + /* RF loop Setting */ + ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x0, 0xFFFFF, 0x50008); + + /* IQK Single tone start */ + ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x80800000); + ODM_SetBBReg(pDM_Odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); + ODM_StallExecution(1000); + PSD_report_tmp = 0x0; + + for (n = 0; n < 2; n++) { + PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); + if (PSD_report_tmp > AntA_report) + AntA_report = PSD_report_tmp; + } + + PSD_report_tmp = 0x0; + + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); /* change to Antenna B */ + ODM_StallExecution(10); + + for (n = 0; n < 2; n++) { + PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); + if (PSD_report_tmp > AntB_report) + AntB_report = PSD_report_tmp; + } + + /* change to open case */ + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, 0); /* change to Ant A and B all open case */ + ODM_StallExecution(10); + + for (n = 0; n < 2; n++) { + PSD_report_tmp = GetPSDData(pDM_Odm, 14, initial_gain); + if (PSD_report_tmp > AntO_report) + AntO_report = PSD_report_tmp; + } + + /* Close IQK Single Tone function */ + ODM_SetBBReg(pDM_Odm, rFPGA0_IQK, bMaskDWord, 0x00000000); + PSD_report_tmp = 0x0; + + /* 1 Return to antanna A */ + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); + ODM_SetBBReg(pDM_Odm, rFPGA0_AnalogParameter4, bMaskDWord, Reg88c); + ODM_SetBBReg(pDM_Odm, rOFDM0_TRMuxPar, bMaskDWord, Regc08); + ODM_SetBBReg(pDM_Odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, Reg874); + ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, 0x7F, 0x40); + ODM_SetBBReg(pDM_Odm, rOFDM0_XAAGCCore1, bMaskDWord, Regc50); + ODM_SetRFReg(pDM_Odm, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, CurrentChannel); + ODM_SetRFReg(pDM_Odm, RF_PATH_A, 0x00, bRFRegOffsetMask, RfLoopReg); + + /* Reload AFE Registers */ + odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d\n", 2416, AntA_report)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d\n", 2416, AntB_report)); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d\n", 2416, AntO_report)); + + if (pDM_Odm->SupportICType == ODM_RTL8723A) { + /* 2 Test Ant B based on Ant A is ON */ + if (mode == ANTTESTB) { + if (AntA_report >= 100) { + if (AntB_report > (AntA_report+1)) { + pDM_SWAT_Table->ANTB_ON = false; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); + } else { + pDM_SWAT_Table->ANTB_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna is A and B\n")); + } + } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); + pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ + bResult = false; + } + } else if (mode == ANTTESTALL) { + /* 2 Test Ant A and B based on DPDT Open */ + if ((AntO_report >= 100)&(AntO_report < 118)) { + if (AntA_report > (AntO_report+1)) { + pDM_SWAT_Table->ANTA_ON = false; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is OFF")); + } else { + pDM_SWAT_Table->ANTA_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is ON")); + } + + if (AntB_report > (AntO_report+2)) { + pDM_SWAT_Table->ANTB_ON = false; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is OFF")); + } else { + pDM_SWAT_Table->ANTB_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is ON")); + } + } + } + } else if (pDM_Odm->SupportICType == ODM_RTL8192C) { + if (AntA_report >= 100) { + if (AntB_report > (AntA_report+2)) { + pDM_SWAT_Table->ANTA_ON = false; + pDM_SWAT_Table->ANTB_ON = true; + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna B\n")); + } else if (AntA_report > (AntB_report+2)) { + pDM_SWAT_Table->ANTA_ON = true; + pDM_SWAT_Table->ANTB_ON = false; + ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); + } else { + pDM_SWAT_Table->ANTA_ON = true; + pDM_SWAT_Table->ANTB_ON = true; + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("ODM_SingleDualAntennaDetection(): Dual Antenna\n")); + } + } else { + ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); + pDM_SWAT_Table->ANTA_ON = true; /* Set Antenna A on as default */ + pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ + bResult = false; + } + } + return bResult; +} + +/* Justin: According to the current RRSI to adjust Response Frame TX power, 2012/11/05 */ +void odm_dtc(struct odm_dm_struct *pDM_Odm) +{ +} diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c new file mode 100644 index 000000000000..523801cabb43 --- /dev/null +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -0,0 +1,601 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* include files */ + +#include "odm_precomp.h" + +#define READ_AND_CONFIG READ_AND_CONFIG_MP + +#define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig##txt##ic(dm_odm)) +#define READ_AND_CONFIG_TC(ic, txt) (ODM_ReadAndConfig_TC##txt##ic(dm_odm)) + +static u8 odm_QueryRxPwrPercentage(s8 AntPower) +{ + if ((AntPower <= -100) || (AntPower >= 20)) + return 0; + else if (AntPower >= 0) + return 100; + else + return 100+AntPower; +} + +/* 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer. */ +/* IF other SW team do not support the feature, remove this section.?? */ +static s32 odm_sig_patch_lenove(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + return 0; +} + +static s32 odm_sig_patch_netcore(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + return 0; +} + +static s32 odm_SignalScaleMapping_92CSeries(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + s32 RetSig = 0; + + if ((dm_odm->SupportInterface == ODM_ITRF_USB) || + (dm_odm->SupportInterface == ODM_ITRF_SDIO)) { + if (CurrSig >= 51 && CurrSig <= 100) + RetSig = 100; + else if (CurrSig >= 41 && CurrSig <= 50) + RetSig = 80 + ((CurrSig - 40)*2); + else if (CurrSig >= 31 && CurrSig <= 40) + RetSig = 66 + (CurrSig - 30); + else if (CurrSig >= 21 && CurrSig <= 30) + RetSig = 54 + (CurrSig - 20); + else if (CurrSig >= 10 && CurrSig <= 20) + RetSig = 42 + (((CurrSig - 10) * 2) / 3); + else if (CurrSig >= 5 && CurrSig <= 9) + RetSig = 22 + (((CurrSig - 5) * 3) / 2); + else if (CurrSig >= 1 && CurrSig <= 4) + RetSig = 6 + (((CurrSig - 1) * 3) / 2); + else + RetSig = CurrSig; + } + return RetSig; +} + +static s32 odm_SignalScaleMapping(struct odm_dm_struct *dm_odm, s32 CurrSig) +{ + if ((dm_odm->SupportPlatform == ODM_MP) && + (dm_odm->SupportInterface != ODM_ITRF_PCIE) && /* USB & SDIO */ + (dm_odm->PatchID == 10)) + return odm_sig_patch_netcore(dm_odm, CurrSig); + else if ((dm_odm->SupportPlatform == ODM_MP) && + (dm_odm->SupportInterface == ODM_ITRF_PCIE) && + (dm_odm->PatchID == 19)) + return odm_sig_patch_lenove(dm_odm, CurrSig); + else + return odm_SignalScaleMapping_92CSeries(dm_odm, CurrSig); +} + +/* pMgntInfo->CustomerID == RT_CID_819x_Lenovo */ +static u8 odm_SQ_process_patch_RT_CID_819x_Lenovo(struct odm_dm_struct *dm_odm, + u8 isCCKrate, u8 PWDB_ALL, u8 path, u8 RSSI) +{ + return 0; +} + +static u8 odm_EVMdbToPercentage(s8 Value) +{ + /* -33dB~0dB to 0%~99% */ + s8 ret_val; + + ret_val = Value; + + if (ret_val >= 0) + ret_val = 0; + if (ret_val <= -33) + ret_val = -33; + + ret_val = 0 - ret_val; + ret_val *= 3; + + if (ret_val == 99) + ret_val = 100; + return ret_val; +} + +static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, + struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt) +{ + struct sw_ant_switch *pDM_SWAT_Table = &dm_odm->DM_SWAT_Table; + u8 i, Max_spatial_stream; + s8 rx_pwr[4], rx_pwr_all = 0; + u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; + u8 RSSI, total_rssi = 0; + u8 isCCKrate = 0; + u8 rf_rx_num = 0; + u8 cck_highpwr = 0; + u8 LNA_idx, VGA_idx; + + struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus; + + isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + + pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = -1; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; + + if (isCCKrate) { + u8 report; + u8 cck_agc_rpt; + + dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; + /* (1)Hardware does not provide RSSI for CCK */ + /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + + cck_highpwr = dm_odm->bCckHighPower; + + cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ; + + /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ + /* The RSSI formula should be modified according to the gain table */ + /* In 88E, cck_highpwr is always set to 1 */ + if (dm_odm->SupportICType & (ODM_RTL8188E|ODM_RTL8812)) { + LNA_idx = ((cck_agc_rpt & 0xE0) >> 5); + VGA_idx = (cck_agc_rpt & 0x1F); + switch (LNA_idx) { + case 7: + if (VGA_idx <= 27) + rx_pwr_all = -100 + 2*(27-VGA_idx); /* VGA_idx = 27~2 */ + else + rx_pwr_all = -100; + break; + case 6: + rx_pwr_all = -48 + 2*(2-VGA_idx); /* VGA_idx = 2~0 */ + break; + case 5: + rx_pwr_all = -42 + 2*(7-VGA_idx); /* VGA_idx = 7~5 */ + break; + case 4: + rx_pwr_all = -36 + 2*(7-VGA_idx); /* VGA_idx = 7~4 */ + break; + case 3: + rx_pwr_all = -24 + 2*(7-VGA_idx); /* VGA_idx = 7~0 */ + break; + case 2: + if (cck_highpwr) + rx_pwr_all = -12 + 2*(5-VGA_idx); /* VGA_idx = 5~0 */ + else + rx_pwr_all = -6 + 2*(5-VGA_idx); + break; + case 1: + rx_pwr_all = 8-2*VGA_idx; + break; + case 0: + rx_pwr_all = 14-2*VGA_idx; + break; + default: + break; + } + rx_pwr_all += 6; + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + if (!cck_highpwr) { + if (PWDB_ALL >= 80) + PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80; + else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) + PWDB_ALL += 3; + if (PWDB_ALL > 100) + PWDB_ALL = 100; + } + } else { + if (!cck_highpwr) { + report = (cck_agc_rpt & 0xc0)>>6; + switch (report) { + /* 03312009 modified by cosa */ + /* Modify the RF RNA gain value to -40, -20, -2, 14 by Jenyu's suggestion */ + /* Note: different RF with the different RNA gain. */ + case 0x3: + rx_pwr_all = -46 - (cck_agc_rpt & 0x3e); + break; + case 0x2: + rx_pwr_all = -26 - (cck_agc_rpt & 0x3e); + break; + case 0x1: + rx_pwr_all = -12 - (cck_agc_rpt & 0x3e); + break; + case 0x0: + rx_pwr_all = 16 - (cck_agc_rpt & 0x3e); + break; + } + } else { + report = (cck_agc_rpt & 0x60)>>5; + switch (report) { + case 0x3: + rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f)<<1) ; + break; + case 0x2: + rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f)<<1); + break; + case 0x1: + rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f)<<1); + break; + case 0x0: + rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f)<<1); + break; + } + } + + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + + /* Modification for ext-LNA board */ + if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { + if ((cck_agc_rpt>>7) == 0) { + PWDB_ALL = (PWDB_ALL > 94) ? 100 : (PWDB_ALL+6); + } else { + if (PWDB_ALL > 38) + PWDB_ALL -= 16; + else + PWDB_ALL = (PWDB_ALL <= 16) ? (PWDB_ALL>>2) : (PWDB_ALL-12); + } + + /* CCK modification */ + if (PWDB_ALL > 25 && PWDB_ALL <= 60) + PWDB_ALL += 6; + } else {/* Modification for int-LNA board */ + if (PWDB_ALL > 99) + PWDB_ALL -= 8; + else if (PWDB_ALL > 50 && PWDB_ALL <= 68) + PWDB_ALL += 4; + } + } + + pPhyInfo->RxPWDBAll = PWDB_ALL; + pPhyInfo->BTRxRSSIPercentage = PWDB_ALL; + pPhyInfo->RecvSignalPower = rx_pwr_all; + /* (3) Get Signal Quality (EVM) */ + if (pPktinfo->bPacketMatchBSSID) { + u8 SQ, SQ_rpt; + + if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { + SQ = odm_SQ_process_patch_RT_CID_819x_Lenovo(dm_odm, isCCKrate, PWDB_ALL, 0, 0); + } else if (pPhyInfo->RxPWDBAll > 40 && !dm_odm->bInHctTest) { + SQ = 100; + } else { + SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all; + + if (SQ_rpt > 64) + SQ = 0; + else if (SQ_rpt < 20) + SQ = 100; + else + SQ = ((64-SQ_rpt) * 100) / 44; + } + pPhyInfo->SignalQuality = SQ; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = SQ; + pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; + } + } else { /* is OFDM rate */ + dm_odm->PhyDbgInfo.NumQryPhyStatusOFDM++; + + /* (1)Get RSSI for HT rate */ + + for (i = RF_PATH_A; i < RF_PATH_MAX; i++) { + /* 2008/01/30 MH we will judge RF RX path now. */ + if (dm_odm->RFPathRxEnable & BIT(i)) + rf_rx_num++; + + rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F)*2) - 110; + if (i == RF_PATH_A) + adapt->signal_strength = rx_pwr[i]; + + pPhyInfo->RxPwr[i] = rx_pwr[i]; + + /* Translate DBM to percentage. */ + RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]); + total_rssi += RSSI; + + /* Modification for ext-LNA board */ + if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { + if ((pPhyStaRpt->path_agc[i].trsw) == 1) + RSSI = (RSSI > 94) ? 100 : (RSSI + 6); + else + RSSI = (RSSI <= 16) ? (RSSI >> 3) : (RSSI - 16); + + if ((RSSI <= 34) && (RSSI >= 4)) + RSSI -= 4; + } + + pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; + + /* Get Rx snr value in DB */ + pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + + /* Record Signal Strength for next packet */ + if (pPktinfo->bPacketMatchBSSID) { + if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { + if (i == RF_PATH_A) + pPhyInfo->SignalQuality = odm_SQ_process_patch_RT_CID_819x_Lenovo(dm_odm, isCCKrate, PWDB_ALL, i, RSSI); + } + } + } + /* (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) */ + rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; + + PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + PWDB_ALL_BT = PWDB_ALL; + + pPhyInfo->RxPWDBAll = PWDB_ALL; + pPhyInfo->BTRxRSSIPercentage = PWDB_ALL_BT; + pPhyInfo->RxPower = rx_pwr_all; + pPhyInfo->RecvSignalPower = rx_pwr_all; + + if ((dm_odm->SupportPlatform == ODM_MP) && (dm_odm->PatchID == 19)) { + /* do nothing */ + } else { + /* (3)EVM of HT rate */ + if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15) + Max_spatial_stream = 2; /* both spatial stream make sense */ + else + Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ + + for (i = 0; i < Max_spatial_stream; i++) { + /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ + /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ + /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ + EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ + + if (pPktinfo->bPacketMatchBSSID) { + if (i == RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ + pPhyInfo->SignalQuality = (u8)(EVM & 0xff); + pPhyInfo->RxMIMOSignalQuality[i] = (u8)(EVM & 0xff); + } + } + } + } + /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ + /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ + if (isCCKrate) { + pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */ + } else { + if (rf_rx_num != 0) + pPhyInfo->SignalStrength = (u8)(odm_SignalScaleMapping(dm_odm, total_rssi /= rf_rx_num)); + } + + /* For 92C/92D HW (Hybrid) Antenna Diversity */ + pDM_SWAT_Table->antsel = pPhyStaRpt->ant_sel; + /* For 88E HW Antenna Diversity */ + dm_odm->DM_FatTable.antsel_rx_keep_0 = pPhyStaRpt->ant_sel; + dm_odm->DM_FatTable.antsel_rx_keep_1 = pPhyStaRpt->ant_sel_b; + dm_odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2; +} + +void odm_Init_RSSIForDM(struct odm_dm_struct *dm_odm) +{ +} + +static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + struct odm_per_pkt_info *pPktinfo) +{ + s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK; + s32 UndecoratedSmoothedOFDM, RSSI_Ave; + u8 isCCKrate = 0; + u8 RSSI_max, RSSI_min, i; + u32 OFDM_pkt = 0; + u32 Weighting = 0; + struct sta_info *pEntry; + + if (pPktinfo->StationID == 0xFF) + return; + pEntry = dm_odm->pODM_StaInfo[pPktinfo->StationID]; + if (!IS_STA_VALID(pEntry)) + return; + if ((!pPktinfo->bPacketMatchBSSID)) + return; + + isCCKrate = ((pPktinfo->Rate >= DESC92C_RATE1M) && (pPktinfo->Rate <= DESC92C_RATE11M)) ? true : false; + + /* Smart Antenna Debug Message------------------ */ + if (dm_odm->SupportICType == ODM_RTL8188E) { + u8 antsel_tr_mux; + struct fast_ant_train *pDM_FatTable = &dm_odm->DM_FatTable; + + if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) { + if (pDM_FatTable->FAT_State == FAT_TRAINING_STATE) { + if (pPktinfo->bPacketToSelf) { + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | + (pDM_FatTable->antsel_rx_keep_1<<1) | + pDM_FatTable->antsel_rx_keep_0; + pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll; + pDM_FatTable->antRSSIcnt[antsel_tr_mux]++; + } + } + } else if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) { + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | + (pDM_FatTable->antsel_rx_keep_1<<1) | pDM_FatTable->antsel_rx_keep_0; + ODM_AntselStatistics_88E(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll); + } + } + } + /* Smart Antenna Debug Message------------------ */ + + UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK; + UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM; + UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB; + + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { + if (!isCCKrate) { /* ofdm rate */ + if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_B] == 0) { + RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; + } else { + if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]) { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]; + } else { + RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]; + RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; + } + if ((RSSI_max - RSSI_min) < 3) + RSSI_Ave = RSSI_max; + else if ((RSSI_max - RSSI_min) < 6) + RSSI_Ave = RSSI_max - 1; + else if ((RSSI_max - RSSI_min) < 10) + RSSI_Ave = RSSI_max - 2; + else + RSSI_Ave = RSSI_max - 3; + } + + /* 1 Process OFDM RSSI */ + if (UndecoratedSmoothedOFDM <= 0) { /* initialize */ + UndecoratedSmoothedOFDM = pPhyInfo->RxPWDBAll; + } else { + if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) { + UndecoratedSmoothedOFDM = + (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + + (RSSI_Ave)) / (Rx_Smooth_Factor); + UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1; + } else { + UndecoratedSmoothedOFDM = + (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + + (RSSI_Ave)) / (Rx_Smooth_Factor); + } + } + + pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0; + + } else { + RSSI_Ave = pPhyInfo->RxPWDBAll; + + /* 1 Process CCK RSSI */ + if (UndecoratedSmoothedCCK <= 0) { /* initialize */ + UndecoratedSmoothedCCK = pPhyInfo->RxPWDBAll; + } else { + if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) { + UndecoratedSmoothedCCK = + ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor-1)) + + pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; + UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1; + } else { + UndecoratedSmoothedCCK = + ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor-1)) + + pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; + } + } + pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1; + } + /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ + if (pEntry->rssi_stat.ValidBit >= 64) + pEntry->rssi_stat.ValidBit = 64; + else + pEntry->rssi_stat.ValidBit++; + + for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) + OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT0; + + if (pEntry->rssi_stat.ValidBit == 64) { + Weighting = ((OFDM_pkt<<4) > 64) ? 64 : (OFDM_pkt<<4); + UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6; + } else { + if (pEntry->rssi_stat.ValidBit != 0) + UndecoratedSmoothedPWDB = (OFDM_pkt * UndecoratedSmoothedOFDM + + (pEntry->rssi_stat.ValidBit-OFDM_pkt) * + UndecoratedSmoothedCCK)/pEntry->rssi_stat.ValidBit; + else + UndecoratedSmoothedPWDB = 0; + } + pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK; + pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM; + pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB; + } +} + +/* Endianness before calling this API */ +static void ODM_PhyStatusQuery_92CSeries(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, + struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt) +{ + odm_RxPhyStatus92CSeries_Parsing(dm_odm, pPhyInfo, pPhyStatus, + pPktinfo, adapt); + if (dm_odm->RSSI_test) { + /* Select the packets to do RSSI checking for antenna switching. */ + if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) + ODM_SwAntDivChkPerPktRssi(dm_odm, pPktinfo->StationID, pPhyInfo); + } else { + odm_Process_RSSIForDM(dm_odm, pPhyInfo, pPktinfo); + } +} + +void ODM_PhyStatusQuery(struct odm_dm_struct *dm_odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt) +{ + ODM_PhyStatusQuery_92CSeries(dm_odm, pPhyInfo, pPhyStatus, pPktinfo, adapt); +} + +/* For future use. */ +void ODM_MacStatusQuery(struct odm_dm_struct *dm_odm, u8 *mac_stat, + u8 macid, bool pkt_match_bssid, + bool pkttoself, bool pkt_beacon) +{ + /* 2011/10/19 Driver team will handle in the future. */ +} + +enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *dm_odm, + enum rf_radio_path content, + enum rf_radio_path rfpath) +{ + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===>ODM_ConfigRFWithHeaderFile\n")); + if (dm_odm->SupportICType == ODM_RTL8188E) { + if (rfpath == RF_PATH_A) + READ_AND_CONFIG(8188E, _RadioA_1T_); + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_A:Rtl8188ERadioA_1TArray\n")); + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_B:Rtl8188ERadioB_1TArray\n")); + } + + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("ODM_ConfigRFWithHeaderFile: Radio No %x\n", rfpath)); + return HAL_STATUS_SUCCESS; +} + +enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *dm_odm, + enum odm_bb_config_type config_tp) +{ + if (dm_odm->SupportICType == ODM_RTL8188E) { + if (config_tp == CONFIG_BB_PHY_REG) { + READ_AND_CONFIG(8188E, _PHY_REG_1T_); + } else if (config_tp == CONFIG_BB_AGC_TAB) { + READ_AND_CONFIG(8188E, _AGC_TAB_1T_); + } else if (config_tp == CONFIG_BB_PHY_REG_PG) { + READ_AND_CONFIG(8188E, _PHY_REG_PG_); + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, + (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8188EPHY_REG_PGArray\n")); + } + } + return HAL_STATUS_SUCCESS; +} + +enum HAL_STATUS ODM_ConfigMACWithHeaderFile(struct odm_dm_struct *dm_odm) +{ + u8 result = HAL_STATUS_SUCCESS; + if (dm_odm->SupportICType == ODM_RTL8188E) + result = READ_AND_CONFIG(8188E, _MAC_REG_); + return result; +} diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c new file mode 100644 index 000000000000..858fc39de6aa --- /dev/null +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -0,0 +1,400 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" + +void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) +{ + struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; + + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + pDM_DigTable->rx_gain_range_min = (u8) pDM_DigTable->AntDiv_RSSI_max; + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("ODM_DIG_LowerBound_88E(): pDM_DigTable->AntDiv_RSSI_max=%d\n", pDM_DigTable->AntDiv_RSSI_max)); + } + /* If only one Entry connected */ +} + +static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) +{ + u32 value32; + + if (*(dm_odm->mp_mode) == 1) { + dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* 1:CG, 0:CS */ + return; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_RX_HWAntDivInit()\n")); + + /* MAC Setting */ + value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + /* Pin Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 1); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + /* OFDM Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); + /* CCK Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); + ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201); /* antenna mapping table */ +} + +static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) +{ + u32 value32; + + if (*(dm_odm->mp_mode) == 1) { + dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, 0); /* Default RX (0/1) */ + return; + } + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_TRX_HWAntDivInit()\n")); + + /* MAC Setting */ + value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + /* Pin Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + /* OFDM Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); + /* CCK Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + /* Tx Settings */ + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); + + /* antenna mapping table */ + if (!dm_odm->bIsMPChip) { /* testchip */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + } else { /* MPchip */ + ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, 0x0201); /* Reg914=3'b010, Reg915=3'b001 */ + } +} + +static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) +{ + u32 value32, i; + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + u32 AntCombination = 2; + + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_FastAntTrainingInit()\n")); + + if (*(dm_odm->mp_mode) == 1) { + ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("dm_odm->AntDivType: %d\n", dm_odm->AntDivType)); + return; + } + + for (i = 0; i < 6; i++) { + dm_fat_tbl->Bssid[i] = 0; + dm_fat_tbl->antSumRSSI[i] = 0; + dm_fat_tbl->antRSSIcnt[i] = 0; + dm_fat_tbl->antAveRSSI[i] = 0; + } + dm_fat_tbl->TrainIdx = 0; + dm_fat_tbl->FAT_State = FAT_NORMAL_STATE; + + /* MAC Setting */ + value32 = ODM_GetMACReg(dm_odm, 0x4c, bMaskDWord); + ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + value32 = ODM_GetMACReg(dm_odm, 0x7B4, bMaskDWord); + ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32|(BIT16|BIT17)); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ + + /* Match MAC ADDR */ + ODM_SetMACReg(dm_odm, 0x7b4, 0xFFFF, 0); + ODM_SetMACReg(dm_odm, 0x7b0, bMaskDWord, 0); + + ODM_SetBBReg(dm_odm, 0x870, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, 0x864, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, 0xb2c, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, 0xb2c, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + ODM_SetBBReg(dm_odm, 0xca4, bMaskDWord, 0x000000a0); + + /* antenna mapping table */ + if (AntCombination == 2) { + if (!dm_odm->bIsMPChip) { /* testchip */ + ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + } else { /* MPchip */ + ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 1); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 2); + } + } else if (AntCombination == 7) { + if (!dm_odm->bIsMPChip) { /* testchip */ + ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 0); /* Reg858[10:8]=3'b000 */ + ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 1); /* Reg858[13:11]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x878, BIT16, 0); + ODM_SetBBReg(dm_odm, 0x858, BIT15|BIT14, 2); /* Reg878[0],Reg858[14:15])=3'b010 */ + ODM_SetBBReg(dm_odm, 0x878, BIT19|BIT18|BIT17, 3);/* Reg878[3:1]=3b'011 */ + ODM_SetBBReg(dm_odm, 0x878, BIT22|BIT21|BIT20, 4);/* Reg878[6:4]=3b'100 */ + ODM_SetBBReg(dm_odm, 0x878, BIT25|BIT24|BIT23, 5);/* Reg878[9:7]=3b'101 */ + ODM_SetBBReg(dm_odm, 0x878, BIT28|BIT27|BIT26, 6);/* Reg878[12:10]=3b'110 */ + ODM_SetBBReg(dm_odm, 0x878, BIT31|BIT30|BIT29, 7);/* Reg878[15:13]=3b'111 */ + } else { /* MPchip */ + ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 0); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 1); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte2, 2); + ODM_SetBBReg(dm_odm, 0x914, bMaskByte3, 3); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte0, 4); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte1, 5); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte2, 6); + ODM_SetBBReg(dm_odm, 0x918, bMaskByte3, 7); + } + } + + /* Default Ant Setting when no fast training */ + ODM_SetBBReg(dm_odm, 0x80c, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ + ODM_SetBBReg(dm_odm, 0x864, BIT5|BIT4|BIT3, 0); /* Default RX */ + ODM_SetBBReg(dm_odm, 0x864, BIT8|BIT7|BIT6, 1); /* Optional RX */ + + /* Enter Traing state */ + ODM_SetBBReg(dm_odm, 0x864, BIT2|BIT1|BIT0, (AntCombination-1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ + ODM_SetBBReg(dm_odm, 0xc50, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ +} + +void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *dm_odm) +{ + if (dm_odm->SupportICType != ODM_RTL8188E) + return; + + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->AntDivType=%d\n", dm_odm->AntDivType)); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->bIsMPChip=%s\n", (dm_odm->bIsMPChip ? "true" : "false"))); + + if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) + odm_RX_HWAntDivInit(dm_odm); + else if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + odm_TRX_HWAntDivInit(dm_odm); + else if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) + odm_FastAntTrainingInit(dm_odm); +} + +void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + u32 DefaultAnt, OptionalAnt; + + if (dm_fat_tbl->RxIdleAnt != Ant) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Update Rx Idle Ant\n")); + if (Ant == MAIN_ANT) { + DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; + OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; + } else { + DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; + OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; + } + + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT14|BIT13|BIT12, DefaultAnt); /* Default TX */ + ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT6|BIT7, DefaultAnt); /* Resp Tx */ + } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ + } + } + dm_fat_tbl->RxIdleAnt = Ant; + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("RxIdleAnt=%s\n", (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); + if (Ant != MAIN_ANT) + pr_info("RxIdleAnt=AUX_ANT\n"); +} + +static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + u8 TargetAnt; + + if (Ant == MAIN_ANT) + TargetAnt = MAIN_ANT_CG_TRX; + else + TargetAnt = AUX_ANT_CG_TRX; + dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT0; + dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT1)>>1; + dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT2)>>2; + + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("Tx from TxInfo, TargetAnt=%s\n", + (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("antsel_tr_mux=3'b%d%d%d\n", + dm_fat_tbl->antsel_c[MacId], dm_fat_tbl->antsel_b[MacId], dm_fat_tbl->antsel_a[MacId])); +} + +void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + + if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)) { + SET_TX_DESC_ANTSEL_A_88E(pDesc, dm_fat_tbl->antsel_a[macId]); + SET_TX_DESC_ANTSEL_B_88E(pDesc, dm_fat_tbl->antsel_b[macId]); + SET_TX_DESC_ANTSEL_C_88E(pDesc, dm_fat_tbl->antsel_c[macId]); + } +} + +void ODM_AntselStatistics_88E(struct odm_dm_struct *dm_odm, u8 antsel_tr_mux, u32 MacId, u8 RxPWDBAll) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + if (antsel_tr_mux == MAIN_ANT_CG_TRX) { + dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->MainAnt_Cnt[MacId]++; + } else { + dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->AuxAnt_Cnt[MacId]++; + } + } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { + if (antsel_tr_mux == MAIN_ANT_CGCS_RX) { + dm_fat_tbl->MainAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->MainAnt_Cnt[MacId]++; + } else { + dm_fat_tbl->AuxAnt_Sum[MacId] += RxPWDBAll; + dm_fat_tbl->AuxAnt_Cnt[MacId]++; + } + } +} + +static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) +{ + u32 i, MinRSSI = 0xFF, AntDivMaxRSSI = 0, MaxRSSI = 0, LocalMinRSSI, LocalMaxRSSI; + u32 Main_RSSI, Aux_RSSI; + u8 RxIdleAnt = 0, TargetAnt = 7; + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; + struct sta_info *pEntry; + + for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { + pEntry = dm_odm->pODM_StaInfo[i]; + if (IS_STA_VALID(pEntry)) { + /* 2 Caculate RSSI per Antenna */ + Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; + Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; + TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("MacID=%d, MainAnt_Sum=%d, MainAnt_Cnt=%d\n", + i, dm_fat_tbl->MainAnt_Sum[i], + dm_fat_tbl->MainAnt_Cnt[i])); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("MacID=%d, AuxAnt_Sum=%d, AuxAnt_Cnt=%d\n", + i, dm_fat_tbl->AuxAnt_Sum[i], dm_fat_tbl->AuxAnt_Cnt[i])); + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, + ("MacID=%d, Main_RSSI= %d, Aux_RSSI= %d\n", + i, Main_RSSI, Aux_RSSI)); + /* 2 Select MaxRSSI for DIG */ + LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; + if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) + AntDivMaxRSSI = LocalMaxRSSI; + if (LocalMaxRSSI > MaxRSSI) + MaxRSSI = LocalMaxRSSI; + + /* 2 Select RX Idle Antenna */ + if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && (Main_RSSI == 0)) + Main_RSSI = Aux_RSSI; + else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && (Aux_RSSI == 0)) + Aux_RSSI = Main_RSSI; + + LocalMinRSSI = (Main_RSSI > Aux_RSSI) ? Aux_RSSI : Main_RSSI; + if (LocalMinRSSI < MinRSSI) { + MinRSSI = LocalMinRSSI; + RxIdleAnt = TargetAnt; + } + /* 2 Select TRX Antenna */ + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + odm_UpdateTxAnt_88E(dm_odm, TargetAnt, i); + } + dm_fat_tbl->MainAnt_Sum[i] = 0; + dm_fat_tbl->AuxAnt_Sum[i] = 0; + dm_fat_tbl->MainAnt_Cnt[i] = 0; + dm_fat_tbl->AuxAnt_Cnt[i] = 0; + } + + /* 2 Set RX Idle Antenna */ + ODM_UpdateRxIdleAnt_88E(dm_odm, RxIdleAnt); + + pDM_DigTable->AntDiv_RSSI_max = AntDivMaxRSSI; + pDM_DigTable->RSSI_max = MaxRSSI; +} + +void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) +{ + struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; + if ((dm_odm->SupportICType != ODM_RTL8188E) || (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV))) + return; + if (!dm_odm->bLinked) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_AntennaDiversity_88E(): No Link.\n")); + if (dm_fat_tbl->bBecomeLinked) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn off HW AntDiv\n")); + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 0); /* Enable CCK AntDiv */ + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; + } + return; + } else { + if (!dm_fat_tbl->bBecomeLinked) { + ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn on HW AntDiv\n")); + /* Because HW AntDiv is disabled before Link, we enable HW AntDiv after link */ + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 1); /* Enable CCK AntDiv */ + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ + dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; + } + } + if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) + odm_HWAntDiv(dm_odm); +} + +/* 3============================================================ */ +/* 3 Dynamic Primary CCA */ +/* 3============================================================ */ + +void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) +{ + struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); + + PrimaryCCA->DupRTS_flag = 0; + PrimaryCCA->intf_flag = 0; + PrimaryCCA->intf_type = 0; + PrimaryCCA->Monitor_flag = 0; + PrimaryCCA->PriCCA_flag = 0; +} + +bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) +{ + struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); + + return PrimaryCCA->DupRTS_flag; +} + +void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) +{ + return; +} diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c new file mode 100644 index 000000000000..0ff31370fb98 --- /dev/null +++ b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" + +void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Data, enum rf_radio_path RF_PATH, + u32 RegAddr) +{ + if (Addr == 0xffe) { + ODM_sleep_ms(50); + } else if (Addr == 0xfd) { + ODM_delay_ms(5); + } else if (Addr == 0xfc) { + ODM_delay_ms(1); + } else if (Addr == 0xfb) { + ODM_delay_us(50); + } else if (Addr == 0xfa) { + ODM_delay_us(5); + } else if (Addr == 0xf9) { + ODM_delay_us(1); + } else { + ODM_SetRFReg(pDM_Odm, RF_PATH, RegAddr, bRFRegOffsetMask, Data); + /* Add 1us delay between BB/RF register setting. */ + ODM_delay_us(1); + } +} + +void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) +{ + u32 content = 0x1000; /* RF_Content: radioa_txt */ + u32 maskforPhySet = (u32)(content&0xE000); + + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_A, Addr|maskforPhySet); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioA] %08X %08X\n", Addr, Data)); +} + +void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) +{ + u32 content = 0x1001; /* RF_Content: radiob_txt */ + u32 maskforPhySet = (u32)(content&0xE000); + + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_B, Addr|maskforPhySet); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioB] %08X %08X\n", Addr, Data)); +} + +void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) +{ + ODM_Write1Byte(pDM_Odm, Addr, Data); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", Addr, Data)); +} + +void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) +{ + ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); + /* Add 1us delay between BB/RF register setting. */ + ODM_delay_us(1); + + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, + ("===> ODM_ConfigBBWithHeaderFile: [AGC_TAB] %08X %08X\n", + Addr, Data)); +} + +void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data) +{ + if (Addr == 0xfe) { + ODM_sleep_ms(50); + } else if (Addr == 0xfd) { + ODM_delay_ms(5); + } else if (Addr == 0xfc) { + ODM_delay_ms(1); + } else if (Addr == 0xfb) { + ODM_delay_us(50); + } else if (Addr == 0xfa) { + ODM_delay_us(5); + } else if (Addr == 0xf9) { + ODM_delay_us(1); + } else{ + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, + ("===> @@@@@@@ ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", + Addr, Bitmask, Data)); + storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data); + } +} + +void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) +{ + if (Addr == 0xfe) { + ODM_sleep_ms(50); + } else if (Addr == 0xfd) { + ODM_delay_ms(5); + } else if (Addr == 0xfc) { + ODM_delay_ms(1); + } else if (Addr == 0xfb) { + ODM_delay_us(50); + } else if (Addr == 0xfa) { + ODM_delay_us(5); + } else if (Addr == 0xf9) { + ODM_delay_us(1); + } else { + if (Addr == 0xa24) + pDM_Odm->RFCalibrateInfo.RegA24 = Data; + ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); + + /* Add 1us delay between BB/RF register setting. */ + ODM_delay_us(1); + ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, + ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X\n", + Addr, Data)); + } +} diff --git a/drivers/staging/r8188eu/hal/odm_debug.c b/drivers/staging/r8188eu/hal/odm_debug.c new file mode 100644 index 000000000000..84caadd6c8e5 --- /dev/null +++ b/drivers/staging/r8188eu/hal/odm_debug.c @@ -0,0 +1,32 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* include files */ + +#include "odm_precomp.h" + +void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm) +{ + pDM_Odm->DebugLevel = ODM_DBG_TRACE; + + pDM_Odm->DebugComponents = 0; +} + +u32 GlobalDebugLevel; diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c new file mode 100644 index 000000000000..3be5a5f8d873 --- /dev/null +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -0,0 +1,205 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include "odm_precomp.h" +/* ODM IO Relative API. */ + +u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return rtw_read8(Adapter, RegAddr); +} + +u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return rtw_read16(Adapter, RegAddr); +} + +u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return rtw_read32(Adapter, RegAddr); +} + +void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + rtw_write8(Adapter, RegAddr, Data); +} + +void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + rtw_write16(Adapter, RegAddr, Data); +} + +void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + rtw_write32(Adapter, RegAddr, Data); +} + +void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + PHY_SetBBReg(Adapter, RegAddr, BitMask, Data); +} + +u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return PHY_QueryBBReg(Adapter, RegAddr, BitMask); +} + +void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + PHY_SetBBReg(Adapter, RegAddr, BitMask, Data); +} + +u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return PHY_QueryBBReg(Adapter, RegAddr, BitMask); +} + +void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask, Data); +} + +u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, u32 RegAddr, u32 BitMask) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + return PHY_QueryRFReg(Adapter, (enum rf_radio_path)eRFPath, RegAddr, BitMask); +} + +/* ODM Memory relative API. */ +void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) +{ + *pPtr = rtw_zvmalloc(length); +} + +/* length could be ignored, used to detect memory leakage. */ +void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length) +{ + rtw_vmfree(pPtr, length); +} + +s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) +{ + return !memcmp(pBuf1, pBuf2, length); +} + +/* ODM MISC relative API. */ +void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type) +{ +} + +void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm, enum RT_SPINLOCK_TYPE type) +{ +} + +/* Work item relative API. FOr MP driver only~! */ +void ODM_InitializeWorkItem(struct odm_dm_struct *pDM_Odm, void *pRtWorkItem, + RT_WORKITEM_CALL_BACK RtWorkItemCallback, + void *pContext, const char *szID) +{ +} + +void ODM_StartWorkItem(void *pRtWorkItem) +{ +} + +void ODM_StopWorkItem(void *pRtWorkItem) +{ +} + +void ODM_FreeWorkItem(void *pRtWorkItem) +{ +} + +void ODM_ScheduleWorkItem(void *pRtWorkItem) +{ +} + +void ODM_IsWorkItemScheduled(void *pRtWorkItem) +{ +} + +/* ODM Timer relative API. */ +void ODM_StallExecution(u32 usDelay) +{ + rtw_udelay_os(usDelay); +} + +void ODM_delay_ms(u32 ms) +{ + rtw_mdelay_os(ms); +} + +void ODM_delay_us(u32 us) +{ + rtw_udelay_os(us); +} + +void ODM_sleep_ms(u32 ms) +{ + rtw_msleep_os(ms); +} + +void ODM_sleep_us(u32 us) +{ + rtw_usleep_os(us); +} + +void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 msDelay) +{ + _set_timer(pTimer, msDelay); /* ms */ +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, + void *CallBackFunc, void *pContext, + const char *szID) +{ + struct adapter *Adapter = pDM_Odm->Adapter; + _init_timer(pTimer, Adapter->pnetdev, CallBackFunc, pDM_Odm); +} +#endif + +void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) +{ + _cancel_timer_ex(pTimer); +} + +void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) +{ +} + +/* ODM FW relative API. */ +u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, + u32 *pElementID, u32 *pCmdLen, + u8 **pCmbBuffer, u8 *CmdStartSeq) +{ + return true; +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c new file mode 100644 index 000000000000..d60db45a6f0b --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -0,0 +1,762 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_CMD_C_ + +#include +#include +#include +#include +#include +#include + +#include + +#define RTL88E_MAX_H2C_BOX_NUMS 4 +#define RTL88E_MAX_CMD_LEN 7 +#define RTL88E_MESSAGE_BOX_SIZE 4 +#define RTL88E_EX_MESSAGE_BOX_SIZE 4 + +static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num) +{ + u8 read_down = false; + int retry_cnts = 100; + + u8 valid; + + do { + valid = rtw_read8(adapt, REG_HMETFR) & BIT(msgbox_num); + if (0 == valid) + read_down = true; + } while ((!read_down) && (retry_cnts--)); + + return read_down; +} + +/***************************************** +* H2C Msg format : +* 0x1DF - 0x1D0 +*| 31 - 8 | 7-5 4 - 0 | +*| h2c_msg |Class_ID CMD_ID | +* +* Extend 0x1FF - 0x1F0 +*|31 - 0 | +*|ext_msg| +******************************************/ +static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) +{ + u8 bcmd_down = false; + s32 retry_cnts = 100; + u8 h2c_box_num; + u32 msgbox_addr; + u32 msgbox_ex_addr; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + u8 cmd_idx, ext_cmd_len; + u32 h2c_cmd = 0; + u32 h2c_cmd_ex = 0; + s32 ret = _FAIL; + + if (!adapt->bFWReady) { + DBG_88E("FillH2CCmd_88E(): return H2C cmd because fw is not ready\n"); + return ret; + } + + if (!pCmdBuffer) + goto exit; + if (CmdLen > RTL88E_MAX_CMD_LEN) + goto exit; + if (adapt->bSurpriseRemoved) + goto exit; + + /* pay attention to if race condition happened in H2C cmd setting. */ + do { + h2c_box_num = haldata->LastHMEBoxNum; + + if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) { + DBG_88E(" fw read cmd failed...\n"); + goto exit; + } + + *(u8 *)(&h2c_cmd) = ElementID; + + if (CmdLen <= 3) { + memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen); + } else { + memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, 3); + ext_cmd_len = CmdLen-3; + memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer+3, ext_cmd_len); + + /* Write Ext command */ + msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); + for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) { + rtw_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); + } + } + /* Write command */ + msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); + for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) { + rtw_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); + } + bcmd_down = true; + + haldata->LastHMEBoxNum = (h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS; + + } while ((!bcmd_down) && (retry_cnts--)); + + ret = _SUCCESS; + +exit: + + return ret; +} + +u8 rtl8188e_set_rssi_cmd(struct adapter *adapt, u8 *param) +{ + u8 res = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (haldata->fw_ractrl) { + ; + } else { + DBG_88E("==>%s fw dont support RA\n", __func__); + res = _FAIL; + } + + return res; +} + +u8 rtl8188e_set_raid_cmd(struct adapter *adapt, u32 mask) +{ + u8 buf[3]; + u8 res = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (haldata->fw_ractrl) { + __le32 lmask; + + memset(buf, 0, 3); + lmask = cpu_to_le32(mask); + memcpy(buf, &lmask, 3); + + FillH2CCmd_88E(adapt, H2C_DM_MACID_CFG, 3, buf); + } else { + DBG_88E("==>%s fw dont support RA\n", __func__); + res = _FAIL; + } + + return res; +} + +/* bitmap[0:27] = tx_rate_bitmap */ +/* bitmap[28:31]= Rate Adaptive id */ +/* arg[0:4] = macid */ +/* arg[5] = Short GI */ +void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_level) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(pAdapter); + + u8 macid, init_rate, raid, shortGIrate = false; + + macid = arg&0x1f; + + raid = (bitmap>>28) & 0x0f; + bitmap &= 0x0fffffff; + + if (rssi_level != DM_RATR_STA_INIT) + bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, macid, bitmap, rssi_level); + + bitmap |= ((raid<<28)&0xf0000000); + + init_rate = get_highest_rate_idx(bitmap&0x0fffffff)&0x3f; + + shortGIrate = (arg&BIT(5)) ? true : false; + + if (shortGIrate) + init_rate |= BIT(6); + + raid = (bitmap>>28) & 0x0f; + + bitmap &= 0x0fffffff; + + DBG_88E("%s=> mac_id:%d, raid:%d, ra_bitmap=0x%x, shortGIrate=0x%02x\n", + __func__, macid, raid, bitmap, shortGIrate); + + ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), macid, raid, bitmap, shortGIrate); +} + +void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) +{ + struct setpwrmode_parm H2CSetPwrMode; + struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv; + u8 RLBM = 0; /* 0:Min, 1:Max, 2:User define */ + + DBG_88E("%s: Mode=%d SmartPS=%d UAPSD=%d\n", __func__, + Mode, pwrpriv->smart_ps, adapt->registrypriv.uapsd_enable); + + switch (Mode) { + case PS_MODE_ACTIVE: + H2CSetPwrMode.Mode = 0; + break; + case PS_MODE_MIN: + H2CSetPwrMode.Mode = 1; + break; + case PS_MODE_MAX: + RLBM = 1; + H2CSetPwrMode.Mode = 1; + break; + case PS_MODE_DTIM: + RLBM = 2; + H2CSetPwrMode.Mode = 1; + break; + case PS_MODE_UAPSD_WMM: + H2CSetPwrMode.Mode = 2; + break; + default: + H2CSetPwrMode.Mode = 0; + break; + } + + H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f)); + + H2CSetPwrMode.AwakeInterval = 1; + + H2CSetPwrMode.bAllQueueUAPSD = adapt->registrypriv.uapsd_enable; + + if (Mode > 0) + H2CSetPwrMode.PwrState = 0x00;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ + else + H2CSetPwrMode.PwrState = 0x0C;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ + + FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); + +} + +void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) +{ + u8 opmode, macid; + u16 mst_rpt = le16_to_cpu(mstatus_rpt); + opmode = (u8) mst_rpt; + macid = (u8)(mst_rpt >> 8); + + DBG_88E("### %s: MStatus=%x MACID=%d\n", __func__, opmode, macid); + FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt); +} + +static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + u32 rate_len, pktlen; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + + memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); + + SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); + SetFrameSubType(pframe, WIFI_BEACON); + + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + + /* timestamp will be inserted by hardware */ + pframe += 8; + pktlen += 8; + + /* beacon interval: 2 bytes */ + memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pktlen += 2; + + /* capability info: 2 bytes */ + memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->IEs)), 2); + + pframe += 2; + pktlen += 2; + + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fixed_ie); + memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fixed_ie), pktlen); + + goto _ConstructBeacon; + } + + /* below for ad-hoc mode */ + + /* SSID */ + pframe = rtw_set_ie(pframe, _SSID_IE_, cur_network->Ssid.SsidLength, cur_network->Ssid.Ssid, &pktlen); + + /* supported rates... */ + rate_len = rtw_get_rateset_len(cur_network->SupportedRates); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); + + /* DS parameter set */ + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); + + if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + u32 ATIMWindow; + /* IBSS Parameter Set... */ + ATIMWindow = 0; + pframe = rtw_set_ie(pframe, _IBSS_PARA_IE_, 2, (unsigned char *)(&ATIMWindow), &pktlen); + } + + /* todo: ERP IE */ + + /* EXTERNDED SUPPORTED RATE */ + if (rate_len > 8) + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); + + /* todo:HT for adhoc */ + +_ConstructBeacon: + + if ((pktlen + TXDESC_SIZE) > 512) { + DBG_88E("beacon frame too large\n"); + return; + } + + *pLength = pktlen; +} + +static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + __le16 *fctrl; + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + /* Frame control. */ + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + SetPwrMgt(fctrl); + SetFrameSubType(pframe, WIFI_PSPOLL); + + /* AID. */ + SetDuration(pframe, (pmlmeinfo->aid | 0xc000)); + + /* BSSID. */ + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + + /* TA. */ + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + + *pLength = 16; +} + +static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe, + u32 *pLength, + u8 *StaAddr, + u8 bQoS, + u8 AC, + u8 bEosp, + u8 bForcePowerSave) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + u32 pktlen; + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + fctrl = &pwlanhdr->frame_ctl; + *(fctrl) = 0; + if (bForcePowerSave) + SetPwrMgt(fctrl); + + switch (cur_network->network.InfrastructureMode) { + case Ndis802_11Infrastructure: + SetToDs(fctrl); + memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); + break; + case Ndis802_11APMode: + SetFrDs(fctrl); + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&(adapt->eeprompriv)), ETH_ALEN); + break; + case Ndis802_11IBSS: + default: + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + break; + } + + SetSeqNum(pwlanhdr, 0); + + if (bQoS) { + struct rtw_ieee80211_hdr_3addr_qos *pwlanqoshdr; + + SetFrameSubType(pframe, WIFI_QOS_DATA_NULL); + + pwlanqoshdr = (struct rtw_ieee80211_hdr_3addr_qos *)pframe; + SetPriority(&pwlanqoshdr->qc, AC); + SetEOSP(&pwlanqoshdr->qc, bEosp); + + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr_qos); + } else { + SetFrameSubType(pframe, WIFI_DATA_NULL); + + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + } + + *pLength = pktlen; +} + +static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID) +{ + struct rtw_ieee80211_hdr *pwlanhdr; + __le16 *fctrl; + u8 *mac, *bssid; + u32 pktlen; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; + + mac = myid(&(adapt->eeprompriv)); + bssid = cur_network->MacAddress; + + fctrl = &(pwlanhdr->frame_ctl); + *(fctrl) = 0; + memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); + memcpy(pwlanhdr->addr2, mac, ETH_ALEN); + memcpy(pwlanhdr->addr3, bssid, ETH_ALEN); + + SetSeqNum(pwlanhdr, 0); + SetFrameSubType(fctrl, WIFI_PROBERSP); + + pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); + pframe += pktlen; + + if (cur_network->IELength > MAX_IE_SZ) + return; + + memcpy(pframe, cur_network->IEs, cur_network->IELength); + pframe += cur_network->IELength; + pktlen += cur_network->IELength; + + *pLength = pktlen; +} + +/* To check if reserved page content is destroyed by beacon because beacon is too large. */ +/* 2010.06.23. Added by tynli. */ +void CheckFwRsvdPageContent(struct adapter *Adapter) +{ +} + +/* */ +/* Description: Fill the reserved packets that FW will use to RSVD page. */ +/* Now we just send 4 types packet to rsvd page. */ +/* (1)Beacon, (2)Ps-poll, (3)Null data, (4)ProbeRsp. */ +/* Input: */ +/* bDLFinished - false: At the first time we will send all the packets as a large packet to Hw, */ +/* so we need to set the packet length to total length. */ +/* true: At the second time, we should send the first packet (default:beacon) */ +/* to Hw again and set the length in descriptor to the real beacon length. */ +/* 2009.10.15 by tynli. */ +static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) +{ + struct hal_data_8188e *haldata; + struct xmit_frame *pmgntframe; + struct pkt_attrib *pattrib; + struct xmit_priv *pxmitpriv; + struct mlme_ext_priv *pmlmeext; + struct mlme_ext_info *pmlmeinfo; + u32 BeaconLength = 0, ProbeRspLength = 0, PSPollLength; + u32 NullDataLength, QosNullLength; + u8 *ReservedPagePacket; + u8 PageNum, PageNeed, TxDescLen; + u16 BufIndex; + u32 TotalPacketLen; + struct rsvdpage_loc RsvdPageLoc; + + DBG_88E("%s\n", __func__); + ReservedPagePacket = (u8 *)rtw_zmalloc(1000); + if (ReservedPagePacket == NULL) { + DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__); + return; + } + + haldata = GET_HAL_DATA(adapt); + pxmitpriv = &adapt->xmitpriv; + pmlmeext = &adapt->mlmeextpriv; + pmlmeinfo = &pmlmeext->mlmext_info; + + TxDescLen = TXDESC_SIZE; + PageNum = 0; + + /* 3 (1) beacon * 2 pages */ + BufIndex = TXDESC_OFFSET; + ConstructBeacon(adapt, &ReservedPagePacket[BufIndex], &BeaconLength); + + /* When we count the first page size, we need to reserve description size for the RSVD */ + /* packet, it will be filled in front of the packet in TXPKTBUF. */ + PageNeed = (u8)PageNum_128(TxDescLen + BeaconLength); + /* To reserved 2 pages for beacon buffer. 2010.06.24. */ + if (PageNeed == 1) + PageNeed += 1; + PageNum += PageNeed; + haldata->FwRsvdPageStartOffset = PageNum; + + BufIndex += PageNeed*128; + + /* 3 (2) ps-poll *1 page */ + RsvdPageLoc.LocPsPoll = PageNum; + ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], PSPollLength, true, false); + + PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength); + PageNum += PageNeed; + + BufIndex += PageNeed*128; + + /* 3 (3) null data * 1 page */ + RsvdPageLoc.LocNullData = PageNum; + ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, get_my_bssid(&pmlmeinfo->network), false, 0, 0, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false); + + PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); + PageNum += PageNeed; + + BufIndex += PageNeed*128; + + /* 3 (4) probe response * 1page */ + RsvdPageLoc.LocProbeRsp = PageNum; + ConstructProbeRsp(adapt, &ReservedPagePacket[BufIndex], &ProbeRspLength, get_my_bssid(&pmlmeinfo->network), false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], ProbeRspLength, false, false); + + PageNeed = (u8)PageNum_128(TxDescLen + ProbeRspLength); + PageNum += PageNeed; + + BufIndex += PageNeed*128; + + /* 3 (5) Qos null data */ + RsvdPageLoc.LocQosNull = PageNum; + ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], + &QosNullLength, get_my_bssid(&pmlmeinfo->network), true, 0, 0, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], QosNullLength, false, false); + + PageNeed = (u8)PageNum_128(TxDescLen + QosNullLength); + PageNum += PageNeed; + + TotalPacketLen = BufIndex + QosNullLength; + pmgntframe = alloc_mgtxmitframe(pxmitpriv); + if (pmgntframe == NULL) + goto exit; + + /* update attribute */ + pattrib = &pmgntframe->attrib; + update_mgntframe_attrib(adapt, pattrib); + pattrib->qsel = 0x10; + pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET; + pattrib->pktlen = pattrib->last_txcmdsz; + memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen); + + rtw_hal_mgnt_xmit(adapt, pmgntframe); + + DBG_88E("%s: Set RSVD page location to Fw\n", __func__); + FillH2CCmd_88E(adapt, H2C_COM_RSVD_PAGE, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); + +exit: + kfree(ReservedPagePacket); +} + +void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + bool bSendBeacon = false; + bool bcn_valid = false; + u8 DLBcnCount = 0; + u32 poll = 0; + + DBG_88E("%s mstatus(%x)\n", __func__, mstatus); + + if (mstatus == 1) { + /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ + /* Suggested by filen. Added by tynli. */ + rtw_write16(adapt, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); + /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ + + /* Set REG_CR bit 8. DMA beacon by SW. */ + haldata->RegCR_1 |= BIT0; + rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + + /* Disable Hw protection for a time which revserd for Hw sending beacon. */ + /* Fix download reserved page packet fail that access collision with the protection time. */ + /* 2010.05.11. Added by tynli. */ + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(3))); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(4)); + + if (haldata->RegFwHwTxQCtrl&BIT6) { + DBG_88E("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n"); + bSendBeacon = true; + } + + /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT6))); + haldata->RegFwHwTxQCtrl &= (~BIT6); + + /* Clear beacon valid check bit. */ + rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); + DLBcnCount = 0; + poll = 0; + do { + /* download rsvd page. */ + SetFwRsvdPagePkt(adapt, false); + DLBcnCount++; + do { + rtw_yield_os(); + /* rtw_mdelay_os(10); */ + /* check rsvd page download OK. */ + rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); + poll++; + } while (!bcn_valid && (poll%10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); + } while (!bcn_valid && DLBcnCount <= 100 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); + + if (adapt->bSurpriseRemoved || adapt->bDriverStopped) + ; + else if (!bcn_valid) + DBG_88E("%s: 1 Download RSVD page failed! DLBcnCount:%u, poll:%u\n", __func__, DLBcnCount, poll); + else + DBG_88E("%s: 1 Download RSVD success! DLBcnCount:%u, poll:%u\n", __func__, DLBcnCount, poll); + /* */ + /* We just can send the reserved page twice during the time that Tx thread is stopped (e.g. pnpsetpower) */ + /* because we need to free the Tx BCN Desc which is used by the first reserved page packet. */ + /* At run time, we cannot get the Tx Desc until it is released in TxHandleInterrupt() so we will return */ + /* the beacon TCB in the following code. 2011.11.23. by tynli. */ + /* */ + + /* Enable Bcn */ + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(3)); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(4))); + + /* To make sure that if there exists an adapter which would like to send beacon. */ + /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */ + /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */ + /* the beacon cannot be sent by HW. */ + /* 2010.06.23. Added by tynli. */ + if (bSendBeacon) { + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT6)); + haldata->RegFwHwTxQCtrl |= BIT6; + } + + /* Update RSVD page location H2C to Fw. */ + if (bcn_valid) { + rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); + DBG_88E("Set RSVD page location to Fw.\n"); + } + + /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */ + /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ + haldata->RegCR_1 &= (~BIT0); + rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + } + +} + +void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state) +{ +#ifdef CONFIG_88EU_P2P + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct wifidirect_info *pwdinfo = &(adapt->wdinfo); + struct P2P_PS_Offload_t *p2p_ps_offload = &haldata->p2p_ps_offload; + u8 i; + + switch (p2p_ps_state) { + case P2P_PS_DISABLE: + DBG_88E("P2P_PS_DISABLE\n"); + memset(p2p_ps_offload, 0, 1); + break; + case P2P_PS_ENABLE: + DBG_88E("P2P_PS_ENABLE\n"); + /* update CTWindow value. */ + if (pwdinfo->ctwindow > 0) { + p2p_ps_offload->CTWindow_En = 1; + rtw_write8(adapt, REG_P2P_CTWIN, pwdinfo->ctwindow); + } + + /* hw only support 2 set of NoA */ + for (i = 0; i < pwdinfo->noa_num; i++) { + /* To control the register setting for which NOA */ + rtw_write8(adapt, REG_NOA_DESC_SEL, (i << 4)); + if (i == 0) + p2p_ps_offload->NoA0_En = 1; + else + p2p_ps_offload->NoA1_En = 1; + + /* config P2P NoA Descriptor Register */ + rtw_write32(adapt, REG_NOA_DESC_DURATION, pwdinfo->noa_duration[i]); + rtw_write32(adapt, REG_NOA_DESC_INTERVAL, pwdinfo->noa_interval[i]); + rtw_write32(adapt, REG_NOA_DESC_START, pwdinfo->noa_start_time[i]); + rtw_write8(adapt, REG_NOA_DESC_COUNT, pwdinfo->noa_count[i]); + } + + if ((pwdinfo->opp_ps == 1) || (pwdinfo->noa_num > 0)) { + /* rst p2p circuit */ + rtw_write8(adapt, REG_DUAL_TSF_RST, BIT(4)); + + p2p_ps_offload->Offload_En = 1; + + if (pwdinfo->role == P2P_ROLE_GO) { + p2p_ps_offload->role = 1; + p2p_ps_offload->AllStaSleep = 0; + } else { + p2p_ps_offload->role = 0; + } + + p2p_ps_offload->discovery = 0; + } + break; + case P2P_PS_SCAN: + DBG_88E("P2P_PS_SCAN\n"); + p2p_ps_offload->discovery = 1; + break; + case P2P_PS_SCAN_DONE: + DBG_88E("P2P_PS_SCAN_DONE\n"); + p2p_ps_offload->discovery = 0; + pwdinfo->p2p_ps_state = P2P_PS_ENABLE; + break; + default: + break; + } + + FillH2CCmd_88E(adapt, H2C_PS_P2P_OFFLOAD, 1, (u8 *)p2p_ps_offload); +#endif + +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c new file mode 100644 index 000000000000..2590277b95ba --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -0,0 +1,267 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* */ +/* Description: */ +/* */ +/* This file is for 92CE/92CU dynamic mechanism only */ +/* */ +/* */ +/* */ +#define _RTL8188E_DM_C_ + +#include +#include + +#include + +static void dm_CheckStatistics(struct adapter *Adapter) +{ +} + +/* Initialize GPIO setting registers */ +static void dm_InitGPIOSetting(struct adapter *Adapter) +{ + u8 tmp1byte; + + tmp1byte = rtw_read8(Adapter, REG_GPIO_MUXCFG); + tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT); + + rtw_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte); +} + +/* */ +/* functions */ +/* */ +static void Init_ODM_ComInfo_88E(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + u8 cut_ver, fab_ver; + + /* Init Value */ + memset(dm_odm, 0, sizeof(*dm_odm)); + + dm_odm->Adapter = Adapter; + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PLATFORM, ODM_CE); + + if (Adapter->interface_type == RTW_GSPI) + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, ODM_ITRF_SDIO); + else + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_INTERFACE, Adapter->interface_type);/* RTL871X_HCI_TYPE */ + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_IC_TYPE, ODM_RTL8188E); + + fab_ver = ODM_TSMC; + cut_ver = ODM_CUT_A; + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_FAB_VER, fab_ver); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_CUT_VER, cut_ver); + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(hal_data->VersionID)); + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_PATCH_ID, hal_data->CustomerID); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_BWIFI_TEST, Adapter->registrypriv.wifi_spec); + + if (hal_data->rf_type == RF_1T1R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_1T1R); + else if (hal_data->rf_type == RF_2T2R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_2T2R); + else if (hal_data->rf_type == RF_1T2R) + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_RF_TYPE, ODM_1T2R); + + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); + + pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); +} + +static void Update_ODM_ComInfo_88E(struct adapter *Adapter) +{ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + int i; + + pdmpriv->InitODMFlag = ODM_BB_DIG | + ODM_BB_RA_MASK | + ODM_BB_DYNAMIC_TXPWR | + ODM_BB_FA_CNT | + ODM_BB_RSSI_MONITOR | + ODM_BB_CCK_PD | + ODM_BB_PWR_SAVE | + ODM_MAC_EDCA_TURBO | + ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + if (hal_data->AntDivCfg) + pdmpriv->InitODMFlag |= ODM_BB_ANT_DIV; + + if (Adapter->registrypriv.mp_mode == 1) { + pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | + ODM_RF_TX_PWR_TRACK; + } + + ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); + + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_TX_UNI, &(Adapter->xmitpriv.tx_bytes)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_RX_UNI, &(Adapter->recvpriv.rx_bytes)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_WM_MODE, &(pmlmeext->cur_wireless_mode)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_CHNL_OFFSET, &(hal_data->nCur40MhzPrimeSC)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_MODE, &(Adapter->securitypriv.dot11PrivacyAlgrthm)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_BW, &(hal_data->CurrentChannelBW)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_CHNL, &(hal_data->CurrentChannel)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_NET_CLOSED, &(Adapter->net_closed)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_MP_MODE, &(Adapter->registrypriv.mp_mode)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SCAN, &(pmlmepriv->bScanInProcess)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_POWER_SAVING, &(pwrctrlpriv->bpower_saving)); + ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); + + for (i = 0; i < NUM_STA; i++) + ODM_CmnInfoPtrArrayHook(dm_odm, ODM_CMNINFO_STA_STATUS, i, NULL); +} + +void rtl8188e_InitHalDm(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + + dm_InitGPIOSetting(Adapter); + pdmpriv->DM_Type = DM_Type_ByDriver; + pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE; + Update_ODM_ComInfo_88E(Adapter); + ODM_DMInit(dm_odm); + Adapter->fix_rate = 0xFF; +} + +void rtl8188e_HalDmWatchDog(struct adapter *Adapter) +{ + bool fw_cur_in_ps = false; + bool fw_ps_awake = true; + u8 hw_init_completed = false; + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + + + hw_init_completed = Adapter->hw_init_completed; + + if (!hw_init_completed) + goto skip_dm; + + fw_cur_in_ps = Adapter->pwrctrlpriv.bFwCurrentInPSMode; + rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&fw_ps_awake)); + + /* Fw is under p2p powersaving mode, driver should stop dynamic mechanism. */ + /* modifed by thomas. 2011.06.11. */ + if (Adapter->wdinfo.p2p_ps_mode) + fw_ps_awake = false; + + if (hw_init_completed && ((!fw_cur_in_ps) && fw_ps_awake)) { + /* Calculate Tx/Rx statistics. */ + dm_CheckStatistics(Adapter); + + + } + + /* ODM */ + if (hw_init_completed) { + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + u8 bLinked = false; + + if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE))) { + if (Adapter->stapriv.asoc_sta_count > 2) + bLinked = true; + } else {/* Station mode */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) + bLinked = true; + } + + ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); + ODM_DMWatchdog(&hal_data->odmpriv); + } +skip_dm: + /* Check GPIO to determine current RF on/off and Pbc status. */ + /* Check Hardware Radio ON/OFF or not */ + return; +} + +void rtl8188e_init_dm_priv(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &hal_data->dmpriv; + struct odm_dm_struct *podmpriv = &hal_data->odmpriv; + + memset(pdmpriv, 0, sizeof(struct dm_priv)); + Init_ODM_ComInfo_88E(Adapter); + ODM_InitDebugSetting(podmpriv); +} + +void rtl8188e_deinit_dm_priv(struct adapter *Adapter) +{ +} + +/* Add new function to reset the state of antenna diversity before link. */ +/* Compare RSSI for deciding antenna */ +void AntDivCompare8188E(struct adapter *Adapter, struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + + if (0 != hal_data->AntDivCfg) { + /* select optimum_antenna for before linked =>For antenna diversity */ + if (dst->Rssi >= src->Rssi) {/* keep org parameter */ + src->Rssi = dst->Rssi; + src->PhyInfo.Optimum_antenna = dst->PhyInfo.Optimum_antenna; + } + } +} + +/* Add new function to reset the state of antenna diversity before link. */ +u8 AntDivBeforeLink8188E(struct adapter *Adapter) +{ + struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; + struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table; + struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + + /* Condition that does not need to use antenna diversity. */ + if (hal_data->AntDivCfg == 0) + return false; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) + return false; + + if (dm_swat_tbl->SWAS_NoLink_State == 0) { + /* switch channel */ + dm_swat_tbl->SWAS_NoLink_State = 1; + dm_swat_tbl->CurAntenna = (dm_swat_tbl->CurAntenna == Antenna_A) ? Antenna_B : Antenna_A; + + rtw_antenna_select_cmd(Adapter, dm_swat_tbl->CurAntenna, false); + return true; + } else { + dm_swat_tbl->SWAS_NoLink_State = 0; + return false; + } +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c new file mode 100644 index 000000000000..d9f115d187c9 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -0,0 +1,2390 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HAL_INIT_C_ + +#include +#include +#include + +#include + +#include + +#include + +static void iol_mode_enable(struct adapter *padapter, u8 enable) +{ + u8 reg_0xf0 = 0; + + if (enable) { + /* Enable initial offload */ + reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); + rtw_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); + + if (!padapter->bFWReady) { + DBG_88E("bFWReady == false call reset 8051...\n"); + _8051Reset88E(padapter); + } + + } else { + /* disable initial offload */ + reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); + rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN); + } +} + +static s32 iol_execute(struct adapter *padapter, u8 control) +{ + s32 status = _FAIL; + u8 reg_0x88 = 0; + u32 start = 0, passing_time = 0; + + control = control&0x0f; + reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); + rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); + + start = jiffies; + while ((reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0)) & control && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { + ; + } + + reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); + status = (reg_0x88 & control) ? _FAIL : _SUCCESS; + if (reg_0x88 & control<<4) + status = _FAIL; + return status; +} + +static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) +{ + s32 rst = _SUCCESS; + iol_mode_enable(padapter, 1); + rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + rst = iol_execute(padapter, CMD_INIT_LLT); + iol_mode_enable(padapter, 0); + return rst; +} + +static void +efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) +{ + u8 *efuseTbl = NULL; + u8 rtemp8; + u16 eFuse_Addr = 0; + u8 offset, wren; + u16 i, j; + u16 **eFuseWord = NULL; + u16 efuse_utilized = 0; + u8 u1temp = 0; + + efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + if (efuseTbl == NULL) { + DBG_88E("%s: alloc efuseTbl fail!\n", __func__); + goto exit; + } + + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + if (eFuseWord == NULL) { + DBG_88E("%s: alloc eFuseWord fail!\n", __func__); + goto exit; + } + + /* 0. Refresh efuse init map as all oxFF. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) + eFuseWord[i][j] = 0xFFFF; + + /* */ + /* 1. Read the first byte to check if efuse is empty!!! */ + /* */ + /* */ + rtemp8 = *(phymap+eFuse_Addr); + if (rtemp8 != 0xFF) { + efuse_utilized++; + eFuse_Addr++; + } else { + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, rtemp8); + goto exit; + } + + /* */ + /* 2. Read real efuse content. Filter PG header and every section data. */ + /* */ + while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + /* Check PG header for section num. */ + if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((rtemp8 & 0xE0) >> 5); + rtemp8 = *(phymap+eFuse_Addr); + if ((rtemp8 & 0x0F) == 0x0F) { + eFuse_Addr++; + rtemp8 = *(phymap+eFuse_Addr); + + if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) + eFuse_Addr++; + continue; + } else { + offset = ((rtemp8 & 0xF0) >> 1) | u1temp; + wren = (rtemp8 & 0x0F); + eFuse_Addr++; + } + } else { + offset = ((rtemp8 >> 4) & 0x0f); + wren = (rtemp8 & 0x0f); + } + + if (offset < EFUSE_MAX_SECTION_88E) { + /* Get word enable value from PG header */ + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + /* Check word enable condition in the section */ + if (!(wren & 0x01)) { + rtemp8 = *(phymap+eFuse_Addr); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] = (rtemp8 & 0xff); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + rtemp8 = *(phymap+eFuse_Addr); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00); + + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + } + wren >>= 1; + } + } + /* Read next PG header */ + rtemp8 = *(phymap+eFuse_Addr); + + if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + efuse_utilized++; + eFuse_Addr++; + } + } + + /* */ + /* 3. Collect 16 sections and 4 word unit into Efuse map. */ + /* */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + } + } + + /* */ + /* 4. Copy from Efuse map to output pointer memory!!! */ + /* */ + for (i = 0; i < _size_byte; i++) + pbuf[i] = efuseTbl[_offset+i]; + + /* */ + /* 5. Calculate Efuse utilization. */ + /* */ + +exit: + kfree(efuseTbl); + + if (eFuseWord) + rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); +} + +static void efuse_read_phymap_from_txpktbuf( + struct adapter *adapter, + int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */ + u8 *content, /* buffer to store efuse physical map */ + u16 *size /* for efuse content: the max byte to read. will update to byte read */ + ) +{ + u16 dbg_addr = 0; + u32 start = 0, passing_time = 0; + u8 reg_0x143 = 0; + __le32 lo32 = 0, hi32 = 0; + u16 len = 0, count = 0; + int i = 0; + u16 limit = *size; + + u8 *pos = content; + + if (bcnhead < 0) /* if not valid */ + bcnhead = rtw_read8(adapter, REG_TDECTRL+1); + + DBG_88E("%s bcnhead:%d\n", __func__, bcnhead); + + rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + + dbg_addr = bcnhead*128/8; /* 8-bytes addressing */ + + while (1) { + rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr+i); + + rtw_write8(adapter, REG_TXPKTBUF_DBG, 0); + start = jiffies; + while (!(reg_0x143 = rtw_read8(adapter, REG_TXPKTBUF_DBG)) && + (passing_time = rtw_get_passing_time_ms(start)) < 1000) { + DBG_88E("%s polling reg_0x143:0x%02x, reg_0x106:0x%02x\n", __func__, reg_0x143, rtw_read8(adapter, 0x106)); + rtw_usleep_os(100); + } + + /* data from EEPROM needs to be in LE */ + lo32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_L)); + hi32 = cpu_to_le32(rtw_read32(adapter, REG_PKTBUF_DBG_DATA_H)); + + if (i == 0) { + /* Although lenc is only used in a debug statement, + * do not remove it as the rtw_read16() call consumes + * 2 bytes from the EEPROM source. + */ + u16 lenc = rtw_read16(adapter, REG_PKTBUF_DBG_DATA_L); + + len = le32_to_cpu(lo32) & 0x0000ffff; + + limit = (len-2 < limit) ? len-2 : limit; + + DBG_88E("%s len:%u, lenc:%u\n", __func__, len, lenc); + + memcpy(pos, ((u8 *)&lo32)+2, (limit >= count+2) ? 2 : limit-count); + count += (limit >= count+2) ? 2 : limit-count; + pos = content+count; + } else { + memcpy(pos, ((u8 *)&lo32), (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; + } + + if (limit > count && len-2 > count) { + memcpy(pos, (u8 *)&hi32, (limit >= count+4) ? 4 : limit-count); + count += (limit >= count+4) ? 4 : limit-count; + pos = content+count; + } + + if (limit <= count || len-2 <= count) + break; + i++; + } + rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS); + DBG_88E("%s read count:%u\n", __func__, count); + *size = count; +} + +static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map) +{ + s32 status = _FAIL; + u8 physical_map[512]; + u16 size = 512; + + rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + memset(physical_map, 0xFF, 512); + rtw_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + status = iol_execute(padapter, CMD_READ_EFUSE_MAP); + if (status == _SUCCESS) + efuse_read_phymap_from_txpktbuf(padapter, txpktbuf_bndy, physical_map, &size); + efuse_phymap_to_logical(physical_map, offset, size_byte, logical_map); + return status; +} + +s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) +{ + s32 result = _SUCCESS; + + DBG_88E("==> %s\n", __func__); + if (rtw_IOL_applied(padapter)) { + iol_mode_enable(padapter, 1); + result = iol_execute(padapter, CMD_READ_EFUSE_MAP); + if (result == _SUCCESS) + result = iol_execute(padapter, CMD_EFUSE_PATCH); + + iol_mode_enable(padapter, 0); + } + return result; +} + +static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy) +{ + s32 rst = _SUCCESS; + + rtw_write8(padapter, REG_TDECTRL+1, iocfg_bndy); + rst = iol_execute(padapter, CMD_IOCONFIG); + return rst; +} + +static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_frame *xmit_frame, u32 max_wating_ms, u32 bndy_cnt) +{ + struct pkt_attrib *pattrib = &xmit_frame->attrib; + u8 i; + int ret = _FAIL; + + if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) + goto exit; + if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE+pattrib->last_txcmdsz)) { + if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) + goto exit; + } + + dump_mgntframe_and_wait(adapter, xmit_frame, max_wating_ms); + + iol_mode_enable(adapter, 1); + for (i = 0; i < bndy_cnt; i++) { + u8 page_no = 0; + page_no = i*2; + ret = iol_ioconfig(adapter, page_no); + if (ret != _SUCCESS) + break; + } + iol_mode_enable(adapter, 0); +exit: + /* restore BCN_HEAD */ + rtw_write8(adapter, REG_TDECTRL+1, 0); + return ret; +} + +void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) +{ + u32 fifo_data, reg_140; + u32 addr, rstatus, loop = 0; + u16 data_cnts = (data_len/8)+1; + u8 *pbuf = rtw_zvmalloc(data_len+10); + DBG_88E("###### %s ######\n", __func__); + + rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); + if (pbuf) { + for (addr = 0; addr < data_cnts; addr++) { + rtw_write32(Adapter, 0x140, addr); + rtw_usleep_os(2); + loop = 0; + do { + rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL)&BIT24); + if (rstatus) { + fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_L); + memcpy(pbuf+(addr*8), &fifo_data, 4); + + fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_H); + memcpy(pbuf+(addr*8+4), &fifo_data, 4); + } + rtw_usleep_os(2); + } while (!rstatus && (loop++ < 10)); + } + rtw_IOL_cmd_buf_dump(Adapter, data_len, pbuf); + rtw_vmfree(pbuf, data_len+10); + } + DBG_88E("###### %s ######\n", __func__); +} + +static void _FWDownloadEnable(struct adapter *padapter, bool enable) +{ + u8 tmp; + + if (enable) { + /* MCU firmware download enable. */ + tmp = rtw_read8(padapter, REG_MCUFWDL); + rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01); + + /* 8051 reset */ + tmp = rtw_read8(padapter, REG_MCUFWDL+2); + rtw_write8(padapter, REG_MCUFWDL+2, tmp&0xf7); + } else { + /* MCU firmware download disable. */ + tmp = rtw_read8(padapter, REG_MCUFWDL); + rtw_write8(padapter, REG_MCUFWDL, tmp&0xfe); + + /* Reserved for fw extension. */ + rtw_write8(padapter, REG_MCUFWDL+1, 0x00); + } +} + +#define MAX_REG_BOLCK_SIZE 196 + +static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) +{ + int ret = _SUCCESS; + u32 blockSize_p1 = 4; /* (Default) Phase #1 : PCI muse use 4-byte write to download FW */ + u32 blockSize_p2 = 8; /* Phase #2 : Use 8-byte, if Phase#1 use big size to write FW. */ + u32 blockSize_p3 = 1; /* Phase #3 : Use 1-byte, the remnant of FW image. */ + u32 blockCount_p1 = 0, blockCount_p2 = 0, blockCount_p3 = 0; + u32 remainSize_p1 = 0, remainSize_p2 = 0; + u8 *bufferPtr = (u8 *)buffer; + u32 i = 0, offset = 0; + + blockSize_p1 = MAX_REG_BOLCK_SIZE; + + /* 3 Phase #1 */ + blockCount_p1 = buffSize / blockSize_p1; + remainSize_p1 = buffSize % blockSize_p1; + + if (blockCount_p1) { + RT_TRACE(_module_hal_init_c_, _drv_notice_, + ("_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n", + buffSize, blockSize_p1, blockCount_p1, remainSize_p1)); + } + + for (i = 0; i < blockCount_p1; i++) { + ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + i * blockSize_p1), blockSize_p1, (bufferPtr + i * blockSize_p1)); + if (ret == _FAIL) + goto exit; + } + + /* 3 Phase #2 */ + if (remainSize_p1) { + offset = blockCount_p1 * blockSize_p1; + + blockCount_p2 = remainSize_p1/blockSize_p2; + remainSize_p2 = remainSize_p1%blockSize_p2; + + if (blockCount_p2) { + RT_TRACE(_module_hal_init_c_, _drv_notice_, + ("_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", + (buffSize-offset), blockSize_p2 , blockCount_p2, remainSize_p2)); + } + + for (i = 0; i < blockCount_p2; i++) { + ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + offset + i*blockSize_p2), blockSize_p2, (bufferPtr + offset + i*blockSize_p2)); + + if (ret == _FAIL) + goto exit; + } + } + + /* 3 Phase #3 */ + if (remainSize_p2) { + offset = (blockCount_p1 * blockSize_p1) + (blockCount_p2 * blockSize_p2); + + blockCount_p3 = remainSize_p2 / blockSize_p3; + + RT_TRACE(_module_hal_init_c_, _drv_notice_, + ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) blockCount_p3(%d)\n", + (buffSize-offset), blockSize_p3, blockCount_p3)); + + for (i = 0; i < blockCount_p3; i++) { + ret = rtw_write8(padapter, (FW_8188E_START_ADDRESS + offset + i), *(bufferPtr + offset + i)); + + if (ret == _FAIL) + goto exit; + } + } + +exit: + return ret; +} + +static int _PageWrite(struct adapter *padapter, u32 page, void *buffer, u32 size) +{ + u8 value8; + u8 u8Page = (u8)(page & 0x07); + + value8 = (rtw_read8(padapter, REG_MCUFWDL+2) & 0xF8) | u8Page; + rtw_write8(padapter, REG_MCUFWDL+2, value8); + + return _BlockWrite(padapter, buffer, size); +} + +static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) +{ + /* Since we need dynamic decide method of dwonload fw, so we call this function to get chip version. */ + /* We can remove _ReadChipVersion from ReadpadapterInfo8192C later. */ + int ret = _SUCCESS; + u32 pageNums, remainSize; + u32 page, offset; + u8 *bufferPtr = (u8 *)buffer; + + pageNums = size / MAX_PAGE_SIZE; + remainSize = size % MAX_PAGE_SIZE; + + for (page = 0; page < pageNums; page++) { + offset = page * MAX_PAGE_SIZE; + ret = _PageWrite(padapter, page, bufferPtr+offset, MAX_PAGE_SIZE); + + if (ret == _FAIL) + goto exit; + } + if (remainSize) { + offset = pageNums * MAX_PAGE_SIZE; + page = pageNums; + ret = _PageWrite(padapter, page, bufferPtr+offset, remainSize); + + if (ret == _FAIL) + goto exit; + } + RT_TRACE(_module_hal_init_c_, _drv_info_, ("_WriteFW Done- for Normal chip.\n")); +exit: + return ret; +} + +void _8051Reset88E(struct adapter *padapter) +{ + u8 u1bTmp; + + u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2)); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT2)); + DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n"); +} + +static s32 _FWFreeToGo(struct adapter *padapter) +{ + u32 counter = 0; + u32 value32; + + /* polling CheckSum report */ + do { + value32 = rtw_read32(padapter, REG_MCUFWDL); + if (value32 & FWDL_ChkSum_rpt) + break; + } while (counter++ < POLLING_READY_TIMEOUT_COUNT); + + if (counter >= POLLING_READY_TIMEOUT_COUNT) { + DBG_88E("%s: chksum report fail! REG_MCUFWDL:0x%08x\n", __func__, value32); + return _FAIL; + } + DBG_88E("%s: Checksum report OK! REG_MCUFWDL:0x%08x\n", __func__, value32); + + value32 = rtw_read32(padapter, REG_MCUFWDL); + value32 |= MCUFWDL_RDY; + value32 &= ~WINTINI_RDY; + rtw_write32(padapter, REG_MCUFWDL, value32); + + _8051Reset88E(padapter); + + /* polling for FW ready */ + counter = 0; + do { + value32 = rtw_read32(padapter, REG_MCUFWDL); + if (value32 & WINTINI_RDY) { + DBG_88E("%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n", __func__, value32); + return _SUCCESS; + } + rtw_udelay_os(5); + } while (counter++ < POLLING_READY_TIMEOUT_COUNT); + + DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32); + return _FAIL; +} + +#define IS_FW_81xxC(padapter) (((GET_HAL_DATA(padapter))->FirmwareSignature & 0xFFF0) == 0x88C0) + +static int load_firmware(struct rt_firmware *pFirmware, struct device *device) +{ + s32 rtStatus = _SUCCESS; + const struct firmware *fw; + const char *fw_name = "rtlwifi/rtl8188eufw.bin"; + int err = request_firmware(&fw, fw_name, device); + + if (err) { + pr_err("Request firmware failed with error 0x%x\n", err); + rtStatus = _FAIL; + goto Exit; + } + if (!fw) { + pr_err("Firmware %s not available\n", fw_name); + rtStatus = _FAIL; + goto Exit; + } + if (fw->size > FW_8188E_SIZE) { + rtStatus = _FAIL; + RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)); + goto Exit; + } + + pFirmware->szFwBuffer = kzalloc(FW_8188E_SIZE, GFP_KERNEL); + if (!pFirmware->szFwBuffer) { + pr_err("Failed to allocate pFirmware->szFwBuffer\n"); + rtStatus = _FAIL; + goto Exit; + } + memcpy(pFirmware->szFwBuffer, fw->data, fw->size); + pFirmware->ulFwLength = fw->size; + release_firmware(fw); + DBG_88E_LEVEL(_drv_info_, "+%s: !bUsedWoWLANFw, FmrmwareLen:%d+\n", __func__, pFirmware->ulFwLength); + +Exit: + return rtStatus; +} + +s32 rtl8188e_FirmwareDownload(struct adapter *padapter) +{ + s32 rtStatus = _SUCCESS; + u8 writeFW_retry = 0; + u32 fwdl_start_time; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); + struct device *device = dvobj_to_dev(dvobj); + struct rt_firmware_hdr *pFwHdr = NULL; + u8 *pFirmwareBuf; + u32 FirmwareLen; + static int log_version; + + RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__)); + if (!dvobj->firmware.szFwBuffer) + rtStatus = load_firmware(&dvobj->firmware, device); + if (rtStatus == _FAIL) { + dvobj->firmware.szFwBuffer = NULL; + goto Exit; + } + pFirmwareBuf = dvobj->firmware.szFwBuffer; + FirmwareLen = dvobj->firmware.ulFwLength; + + /* To Check Fw header. Added by tynli. 2009.12.04. */ + pFwHdr = (struct rt_firmware_hdr *)dvobj->firmware.szFwBuffer; + + pHalData->FirmwareVersion = le16_to_cpu(pFwHdr->Version); + pHalData->FirmwareSubVersion = pFwHdr->Subversion; + pHalData->FirmwareSignature = le16_to_cpu(pFwHdr->Signature); + + if (!log_version++) + pr_info("%sFirmware Version %d, SubVersion %d, Signature 0x%x\n", + DRIVER_PREFIX, pHalData->FirmwareVersion, + pHalData->FirmwareSubVersion, pHalData->FirmwareSignature); + + if (IS_FW_HEADER_EXIST(pFwHdr)) { + /* Shift 32 bytes for FW header */ + pFirmwareBuf = pFirmwareBuf + 32; + FirmwareLen = FirmwareLen - 32; + } + + /* Suggested by Filen. If 8051 is running in RAM code, driver should inform Fw to reset by itself, */ + /* or it will cause download Fw fail. 2010.02.01. by tynli. */ + if (rtw_read8(padapter, REG_MCUFWDL) & RAM_DL_SEL) { /* 8051 RAM code */ + rtw_write8(padapter, REG_MCUFWDL, 0x00); + _8051Reset88E(padapter); + } + + _FWDownloadEnable(padapter, true); + fwdl_start_time = jiffies; + while (1) { + /* reset the FWDL chksum */ + rtw_write8(padapter, REG_MCUFWDL, rtw_read8(padapter, REG_MCUFWDL) | FWDL_ChkSum_rpt); + + rtStatus = _WriteFW(padapter, pFirmwareBuf, FirmwareLen); + + if (rtStatus == _SUCCESS || + (rtw_get_passing_time_ms(fwdl_start_time) > 500 && writeFW_retry++ >= 3)) + break; + + DBG_88E("%s writeFW_retry:%u, time after fwdl_start_time:%ums\n", + __func__, writeFW_retry, rtw_get_passing_time_ms(fwdl_start_time) + ); + } + _FWDownloadEnable(padapter, false); + if (_SUCCESS != rtStatus) { + DBG_88E("DL Firmware failed!\n"); + goto Exit; + } + + rtStatus = _FWFreeToGo(padapter); + if (_SUCCESS != rtStatus) { + DBG_88E("DL Firmware failed!\n"); + goto Exit; + } + RT_TRACE(_module_hal_init_c_, _drv_info_, ("Firmware is ready to run!\n")); + +Exit: + return rtStatus; +} + +void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + /* Init Fw LPS related. */ + padapter->pwrctrlpriv.bFwCurrentInPSMode = false; + + /* Init H2C counter. by tynli. 2009.12.09. */ + pHalData->LastHMEBoxNum = 0; +} + +static void rtl8188e_free_hal_data(struct adapter *padapter) +{ + + kfree(padapter->HalData); + padapter->HalData = NULL; + +} + +/* */ +/* Efuse related code */ +/* */ +enum{ + VOLTAGE_V25 = 0x03, + LDOE25_SHIFT = 28 , + }; + +static bool +hal_EfusePgPacketWrite2ByteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest); +static bool +hal_EfusePgPacketWrite1ByteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest); +static bool +hal_EfusePgPacketWriteData( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest); + +static void +hal_EfusePowerSwitch_RTL8188E( + struct adapter *pAdapter, + u8 bWrite, + u8 PwrState) +{ + u8 tempval; + u16 tmpV16; + + if (PwrState) { + rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); + + /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), defualt valid */ + tmpV16 = rtw_read16(pAdapter, REG_SYS_ISO_CTRL); + if (!(tmpV16 & PWC_EV12V)) { + tmpV16 |= PWC_EV12V; + rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); + } + /* Reset: 0x0000h[28], default valid */ + tmpV16 = rtw_read16(pAdapter, REG_SYS_FUNC_EN); + if (!(tmpV16 & FEN_ELDR)) { + tmpV16 |= FEN_ELDR; + rtw_write16(pAdapter, REG_SYS_FUNC_EN, tmpV16); + } + + /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ + tmpV16 = rtw_read16(pAdapter, REG_SYS_CLKR); + if ((!(tmpV16 & LOADER_CLK_EN)) || (!(tmpV16 & ANA8M))) { + tmpV16 |= (LOADER_CLK_EN | ANA8M); + rtw_write16(pAdapter, REG_SYS_CLKR, tmpV16); + } + + if (bWrite) { + /* Enable LDO 2.5V before read/write action */ + tempval = rtw_read8(pAdapter, EFUSE_TEST+3); + tempval &= 0x0F; + tempval |= (VOLTAGE_V25 << 4); + rtw_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); + } + } else { + rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); + + if (bWrite) { + /* Disable LDO 2.5V after read/write action */ + tempval = rtw_read8(pAdapter, EFUSE_TEST+3); + rtw_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); + } + } +} + +static void +rtl8188e_EfusePowerSwitch( + struct adapter *pAdapter, + u8 bWrite, + u8 PwrState) +{ + hal_EfusePowerSwitch_RTL8188E(pAdapter, bWrite, PwrState); +} + +static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, + u16 _offset, + u16 _size_byte, + u8 *pbuf, + bool bPseudoTest + ) +{ + u8 *efuseTbl = NULL; + u8 rtemp8[1]; + u16 eFuse_Addr = 0; + u8 offset, wren; + u16 i, j; + u16 **eFuseWord = NULL; + u16 efuse_utilized = 0; + u8 u1temp = 0; + + /* */ + /* Do NOT excess total size of EFuse table. Added by Roger, 2008.11.10. */ + /* */ + if ((_offset + _size_byte) > EFUSE_MAP_LEN_88E) {/* total E-Fuse table is 512bytes */ + DBG_88E("Hal_EfuseReadEFuse88E(): Invalid offset(%#x) with read bytes(%#x)!!\n", _offset, _size_byte); + goto exit; + } + + efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + if (efuseTbl == NULL) { + DBG_88E("%s: alloc efuseTbl fail!\n", __func__); + goto exit; + } + + eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + if (eFuseWord == NULL) { + DBG_88E("%s: alloc eFuseWord fail!\n", __func__); + goto exit; + } + + /* 0. Refresh efuse init map as all oxFF. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) + eFuseWord[i][j] = 0xFFFF; + + /* */ + /* 1. Read the first byte to check if efuse is empty!!! */ + /* */ + /* */ + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + if (*rtemp8 != 0xFF) { + efuse_utilized++; + eFuse_Addr++; + } else { + DBG_88E("EFUSE is empty efuse_Addr-%d efuse_data =%x\n", eFuse_Addr, *rtemp8); + goto exit; + } + + /* */ + /* 2. Read real efuse content. Filter PG header and every section data. */ + /* */ + while ((*rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + /* Check PG header for section num. */ + if ((*rtemp8 & 0x1F) == 0x0F) { /* extended header */ + u1temp = ((*rtemp8 & 0xE0) >> 5); + + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + + if ((*rtemp8 & 0x0F) == 0x0F) { + eFuse_Addr++; + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + + if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) + eFuse_Addr++; + continue; + } else { + offset = ((*rtemp8 & 0xF0) >> 1) | u1temp; + wren = (*rtemp8 & 0x0F); + eFuse_Addr++; + } + } else { + offset = ((*rtemp8 >> 4) & 0x0f); + wren = (*rtemp8 & 0x0f); + } + + if (offset < EFUSE_MAX_SECTION_88E) { + /* Get word enable value from PG header */ + + for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { + /* Check word enable condition in the section */ + if (!(wren & 0x01)) { + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] = (*rtemp8 & 0xff); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + eFuse_Addr++; + efuse_utilized++; + eFuseWord[offset][i] |= (((u16)*rtemp8 << 8) & 0xff00); + if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) + break; + } + wren >>= 1; + } + } + + /* Read next PG header */ + ReadEFuseByte(Adapter, eFuse_Addr, rtemp8, bPseudoTest); + + if (*rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { + efuse_utilized++; + eFuse_Addr++; + } + } + + /* 3. Collect 16 sections and 4 word unit into Efuse map. */ + for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { + for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { + efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + } + } + + /* 4. Copy from Efuse map to output pointer memory!!! */ + for (i = 0; i < _size_byte; i++) + pbuf[i] = efuseTbl[_offset+i]; + + /* 5. Calculate Efuse utilization. */ + rtw_hal_set_hwreg(Adapter, HW_VAR_EFUSE_BYTES, (u8 *)&eFuse_Addr); + +exit: + kfree(efuseTbl); + + if (eFuseWord) + rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); +} + +static void ReadEFuseByIC(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) +{ + if (!bPseudoTest) { + int ret = _FAIL; + if (rtw_IOL_applied(Adapter)) { + rtw_hal_power_on(Adapter); + + iol_mode_enable(Adapter, 1); + ret = iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); + iol_mode_enable(Adapter, 0); + + if (_SUCCESS == ret) + goto exit; + } + } + Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); + +exit: + return; +} + +static void ReadEFuse_Pseudo(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) +{ + Hal_EfuseReadEFuse88E(Adapter, _offset, _size_byte, pbuf, bPseudoTest); +} + +static void rtl8188e_ReadEFuse(struct adapter *Adapter, u8 efuseType, + u16 _offset, u16 _size_byte, u8 *pbuf, + bool bPseudoTest) +{ + if (bPseudoTest) + ReadEFuse_Pseudo (Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); + else + ReadEFuseByIC(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); +} + +/* Do not support BT */ +static void Hal_EFUSEGetEfuseDefinition88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) +{ + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = (u8 *)pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = 0; + } + break; + } +} + +static void Hal_EFUSEGetEfuseDefinition_Pseudo88E(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut) +{ + switch (type) { + case TYPE_EFUSE_MAX_SECTION: + { + u8 *pMax_section; + pMax_section = (u8 *)pOut; + *pMax_section = EFUSE_MAX_SECTION_88E; + } + break; + case TYPE_EFUSE_REAL_CONTENT_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_EFUSE_CONTENT_LEN_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = EFUSE_REAL_CONTENT_LEN_88E; + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_BANK: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + case TYPE_EFUSE_MAP_LEN: + { + u16 *pu2Tmp; + pu2Tmp = (u16 *)pOut; + *pu2Tmp = (u16)EFUSE_MAP_LEN_88E; + } + break; + case TYPE_EFUSE_PROTECT_BYTES_BANK: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = (u8)(EFUSE_OOB_PROTECT_BYTES_88E); + } + break; + default: + { + u8 *pu1Tmp; + pu1Tmp = (u8 *)pOut; + *pu1Tmp = 0; + } + break; + } +} + +static void rtl8188e_EFUSE_GetEfuseDefinition(struct adapter *pAdapter, u8 efuseType, u8 type, void *pOut, bool bPseudoTest) +{ + if (bPseudoTest) + Hal_EFUSEGetEfuseDefinition_Pseudo88E(pAdapter, efuseType, type, pOut); + else + Hal_EFUSEGetEfuseDefinition88E(pAdapter, efuseType, type, pOut); +} + +static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) +{ + u16 tmpaddr = 0; + u16 start_addr = efuse_addr; + u8 badworden = 0x0F; + u8 tmpdata[8]; + + memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); + + if (!(word_en&BIT0)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[0], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[1], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1], bPseudoTest); + if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) + badworden &= (~BIT0); + } + if (!(word_en&BIT1)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr , &tmpdata[2], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); + if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) + badworden &= (~BIT1); + } + if (!(word_en&BIT2)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[4], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[5], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5], bPseudoTest); + if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) + badworden &= (~BIT2); + } + if (!(word_en&BIT3)) { + tmpaddr = start_addr; + efuse_OneByteWrite(pAdapter, start_addr++, data[6], bPseudoTest); + efuse_OneByteWrite(pAdapter, start_addr++, data[7], bPseudoTest); + + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7], bPseudoTest); + if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) + badworden &= (~BIT3); + } + return badworden; +} + +static u8 Hal_EfuseWordEnableDataWrite_Pseudo(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) +{ + u8 ret; + + ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); + return ret; +} + +static u8 rtl8188e_Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data, bool bPseudoTest) +{ + u8 ret = 0; + + if (bPseudoTest) + ret = Hal_EfuseWordEnableDataWrite_Pseudo (pAdapter, efuse_addr, word_en, data, bPseudoTest); + else + ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); + return ret; +} + +static u16 hal_EfuseGetCurrentSize_8188e(struct adapter *pAdapter, bool bPseudoTest) +{ + int bContinual = true; + u16 efuse_addr = 0; + u8 hoffset = 0, hworden = 0; + u8 efuse_data, word_cnts = 0; + + if (bPseudoTest) + efuse_addr = (u16)(fakeEfuseUsedBytes); + else + rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); + + while (bContinual && + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && + AVAILABLE_EFUSE_ADDR(efuse_addr)) { + if (efuse_data != 0xFF) { + if ((efuse_data&0x1F) == 0x0F) { /* extended header */ + hoffset = efuse_data; + efuse_addr++; + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); + if ((efuse_data & 0x0F) == 0x0F) { + efuse_addr++; + continue; + } else { + hoffset = ((hoffset & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } + } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + /* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + } else { + bContinual = false; + } + } + + if (bPseudoTest) + fakeEfuseUsedBytes = efuse_addr; + else + rtw_hal_set_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); + + return efuse_addr; +} + +static u16 Hal_EfuseGetCurrentSize_Pseudo(struct adapter *pAdapter, bool bPseudoTest) +{ + u16 ret = 0; + + ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); + return ret; +} + +static u16 rtl8188e_EfuseGetCurrentSize(struct adapter *pAdapter, u8 efuseType, bool bPseudoTest) +{ + u16 ret = 0; + + if (bPseudoTest) + ret = Hal_EfuseGetCurrentSize_Pseudo(pAdapter, bPseudoTest); + else + ret = hal_EfuseGetCurrentSize_8188e(pAdapter, bPseudoTest); + return ret; +} + +static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + u8 ReadState = PG_STATE_HEADER; + int bContinual = true; + int bDataEmpty = true; + u8 efuse_data, word_cnts = 0; + u16 efuse_addr = 0; + u8 hoffset = 0, hworden = 0; + u8 tmpidx = 0; + u8 tmpdata[8]; + u8 max_section = 0; + u8 tmp_header = 0; + + EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, (void *)&max_section, bPseudoTest); + + if (data == NULL) + return false; + if (offset > max_section) + return false; + + memset((void *)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + memset((void *)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + + /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ + /* Skip dummy parts to prevent unexpected data read from Efuse. */ + /* By pass right now. 2009.02.19. */ + while (bContinual && AVAILABLE_EFUSE_ADDR(efuse_addr)) { + /* Header Read ------------- */ + if (ReadState & PG_STATE_HEADER) { + if (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { + tmp_header = efuse_data; + efuse_addr++; + efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); + if (!ALL_WORDS_DISABLED(efuse_data)) { + hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + hworden = efuse_data & 0x0F; + } else { + DBG_88E("Error, All words disabled\n"); + efuse_addr++; + continue; + } + } else { + hoffset = (efuse_data>>4) & 0x0F; + hworden = efuse_data & 0x0F; + } + word_cnts = Efuse_CalculateWordCnts(hworden); + bDataEmpty = true; + + if (hoffset == offset) { + for (tmpidx = 0; tmpidx < word_cnts*2; tmpidx++) { + if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx, &efuse_data, bPseudoTest)) { + tmpdata[tmpidx] = efuse_data; + if (efuse_data != 0xff) + bDataEmpty = false; + } + } + if (bDataEmpty == false) { + ReadState = PG_STATE_DATA; + } else {/* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + } else {/* read next header */ + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + } else { + bContinual = false; + } + } else if (ReadState & PG_STATE_DATA) { + /* Data section Read ------------- */ + efuse_WordEnableDataRead(hworden, tmpdata, data); + efuse_addr = efuse_addr + (word_cnts*2)+1; + ReadState = PG_STATE_HEADER; + } + + } + + if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && + (data[4] == 0xff) && (data[5] == 0xff) && (data[6] == 0xff) && (data[7] == 0xff)) + return false; + else + return true; +} + +static int Hal_EfusePgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + int ret; + + ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); + return ret; +} + +static int Hal_EfusePgPacketRead_Pseudo(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + int ret; + + ret = hal_EfusePgPacketRead_8188e(pAdapter, offset, data, bPseudoTest); + return ret; +} + +static int rtl8188e_Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data, bool bPseudoTest) +{ + int ret; + + if (bPseudoTest) + ret = Hal_EfusePgPacketRead_Pseudo (pAdapter, offset, data, bPseudoTest); + else + ret = Hal_EfusePgPacketRead(pAdapter, offset, data, bPseudoTest); + return ret; +} + +static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, struct pgpkt *pFixPkt, u16 *pAddr, bool bPseudoTest) +{ + u8 originaldata[8], badworden = 0; + u16 efuse_addr = *pAddr; + u32 PgWriteSuccess = 0; + + memset((void *)originaldata, 0xff, 8); + + if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) { + /* check if data exist */ + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata, bPseudoTest); + + if (badworden != 0xf) { /* write fail */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata, bPseudoTest); + + if (!PgWriteSuccess) + return false; + else + efuse_addr = Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest); + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + } + } else { + efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + } + *pAddr = efuse_addr; + return true; +} + +static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u16 efuse_addr = *pAddr, efuse_max_available_len = 0; + u8 pg_header = 0, tmp_header = 0, pg_header_temp = 0; + u8 repeatcnt = 0; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); + + while (efuse_addr < efuse_max_available_len) { + pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + } + + /* to write ext_header */ + if (tmp_header == pg_header) { + efuse_addr++; + pg_header_temp = pg_header; + pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + } + + if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) { + return false; + } else { + efuse_addr++; + continue; + } + } else if (pg_header != tmp_header) { /* offset PG fail */ + struct pgpkt fixPkt; + fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); + fixPkt.word_en = tmp_header & 0x0F; + fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) + return false; + } else { + bRet = true; + break; + } + } else if ((tmp_header & 0x1F) == 0x0F) { /* wrong extended header */ + efuse_addr += 2; + continue; + } + } + + *pAddr = efuse_addr; + return bRet; +} + +static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u8 pg_header = 0, tmp_header = 0; + u16 efuse_addr = *pAddr; + u8 repeatcnt = 0; + + pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; + + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + + while (tmp_header == 0xFF) { + if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) + return false; + efuse_OneByteWrite(pAdapter, efuse_addr, pg_header, bPseudoTest); + efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header, bPseudoTest); + } + + if (pg_header == tmp_header) { + bRet = true; + } else { + struct pgpkt fixPkt; + fixPkt.offset = (tmp_header>>4) & 0x0F; + fixPkt.word_en = tmp_header & 0x0F; + fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); + if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) + return false; + } + + *pAddr = efuse_addr; + return bRet; +} + +static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + u16 efuse_addr = *pAddr; + u8 badworden = 0; + u32 PgWriteSuccess = 0; + + badworden = 0x0f; + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); + if (badworden == 0x0F) { + /* write ok */ + return true; + } else { + /* reorganize other pg packet */ + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); + if (!PgWriteSuccess) + return false; + else + return true; + } +} + +static bool +hal_EfusePgPacketWriteHeader( + struct adapter *pAdapter, + u8 efuseType, + u16 *pAddr, + struct pgpkt *pTargetPkt, + bool bPseudoTest) +{ + bool bRet = false; + + if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) + bRet = hal_EfusePgPacketWrite2ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); + else + bRet = hal_EfusePgPacketWrite1ByteHeader(pAdapter, efuseType, pAddr, pTargetPkt, bPseudoTest); + + return bRet; +} + +static bool wordEnMatched(struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, + u8 *pWden) +{ + u8 match_word_en = 0x0F; /* default all words are disabled */ + + /* check if the same words are enabled both target and current PG packet */ + if (((pTargetPkt->word_en & BIT0) == 0) && + ((pCurPkt->word_en & BIT0) == 0)) + match_word_en &= ~BIT0; /* enable word 0 */ + if (((pTargetPkt->word_en & BIT1) == 0) && + ((pCurPkt->word_en & BIT1) == 0)) + match_word_en &= ~BIT1; /* enable word 1 */ + if (((pTargetPkt->word_en & BIT2) == 0) && + ((pCurPkt->word_en & BIT2) == 0)) + match_word_en &= ~BIT2; /* enable word 2 */ + if (((pTargetPkt->word_en & BIT3) == 0) && + ((pCurPkt->word_en & BIT3) == 0)) + match_word_en &= ~BIT3; /* enable word 3 */ + + *pWden = match_word_en; + + if (match_word_en != 0xf) + return true; + else + return false; +} + +static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, u16 startAddr, bool bPseudoTest) +{ + bool bRet = false; + u8 i, efuse_data; + + for (i = 0; i < (word_cnts*2); i++) { + if (efuse_OneByteRead(pAdapter, (startAddr+i), &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) + bRet = true; + } + return bRet; +} + +static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u16 *pAddr, struct pgpkt *pTargetPkt, bool bPseudoTest) +{ + bool bRet = false; + u8 i, efuse_data = 0, cur_header = 0; + u8 matched_wden = 0, badworden = 0; + u16 startAddr = 0, efuse_max_available_len = 0, efuse_max = 0; + struct pgpkt curPkt; + + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_AVAILABLE_EFUSE_BYTES_BANK, (void *)&efuse_max_available_len, bPseudoTest); + EFUSE_GetEfuseDefinition(pAdapter, efuseType, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&efuse_max, bPseudoTest); + + if (efuseType == EFUSE_WIFI) { + if (bPseudoTest) { + startAddr = (u16)(fakeEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + } else { + rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); + startAddr %= EFUSE_REAL_CONTENT_LEN; + } + } else { + if (bPseudoTest) + startAddr = (u16)(fakeBTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + else + startAddr = (u16)(BTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + } + + while (1) { + if (startAddr >= efuse_max_available_len) { + bRet = false; + break; + } + + if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) { + if (EXT_HEADER(efuse_data)) { + cur_header = efuse_data; + startAddr++; + efuse_OneByteRead(pAdapter, startAddr, &efuse_data, bPseudoTest); + if (ALL_WORDS_DISABLED(efuse_data)) { + bRet = false; + break; + } else { + curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); + curPkt.word_en = efuse_data & 0x0F; + } + } else { + cur_header = efuse_data; + curPkt.offset = (cur_header>>4) & 0x0F; + curPkt.word_en = cur_header & 0x0F; + } + + curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); + /* if same header is found but no data followed */ + /* write some part of data followed by the header. */ + if ((curPkt.offset == pTargetPkt->offset) && + (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && + wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { + /* Here to write partial data */ + badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); + if (badworden != 0x0F) { + u32 PgWriteSuccess = 0; + /* if write fail on some words, write these bad words again */ + + PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data, bPseudoTest); + + if (!PgWriteSuccess) { + bRet = false; /* write fail, return */ + break; + } + } + /* partial write ok, update the target packet for later use */ + for (i = 0; i < 4; i++) { + if ((matched_wden & (0x1<word_en |= (0x1<word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); + } + /* read from next header */ + startAddr = startAddr + (curPkt.word_cnts*2) + 1; + } else { + /* not used header, 0xff */ + *pAddr = startAddr; + bRet = true; + break; + } + } + return bRet; +} + +static bool +hal_EfusePgCheckAvailableAddr( + struct adapter *pAdapter, + u8 efuseType, + bool bPseudoTest + ) +{ + u16 efuse_max_available_len = 0; + + /* Change to check TYPE_EFUSE_MAP_LEN , because 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&efuse_max_available_len, false); + + if (Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest) >= efuse_max_available_len) + return false; + return true; +} + +static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) +{ + memset((void *)pTargetPkt->data, 0xFF, sizeof(u8)*8); + pTargetPkt->offset = offset; + pTargetPkt->word_en = word_en; + efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); + pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); +} + +static bool hal_EfusePgPacketWrite_8188e(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData, bool bPseudoTest) +{ + struct pgpkt targetPkt; + u16 startAddr = 0; + u8 efuseType = EFUSE_WIFI; + + if (!hal_EfusePgCheckAvailableAddr(pAdapter, efuseType, bPseudoTest)) + return false; + + hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); + + if (!hal_EfusePartialWriteCheck(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) + return false; + + if (!hal_EfusePgPacketWriteHeader(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) + return false; + + if (!hal_EfusePgPacketWriteData(pAdapter, efuseType, &startAddr, &targetPkt, bPseudoTest)) + return false; + + return true; +} + +static int Hal_EfusePgPacketWrite_Pseudo(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) +{ + int ret; + + ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); + return ret; +} + +static int Hal_EfusePgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) +{ + int ret = 0; + ret = hal_EfusePgPacketWrite_8188e(pAdapter, offset, word_en, data, bPseudoTest); + + return ret; +} + +static int rtl8188e_Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *data, bool bPseudoTest) +{ + int ret; + + if (bPseudoTest) + ret = Hal_EfusePgPacketWrite_Pseudo (pAdapter, offset, word_en, data, bPseudoTest); + else + ret = Hal_EfusePgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest); + return ret; +} + +static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) +{ + u32 value32; + struct HAL_VERSION ChipVersion; + struct hal_data_8188e *pHalData; + + pHalData = GET_HAL_DATA(padapter); + + value32 = rtw_read32(padapter, REG_SYS_CFG); + ChipVersion.ICType = CHIP_8188E; + ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); + + ChipVersion.RFType = RF_TYPE_1T1R; + ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); + ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ + + /* For regulator mode. by tynli. 2011.01.14 */ + pHalData->RegulatorMode = ((value32 & TRP_BT_EN) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR); + + ChipVersion.ROMVer = 0; /* ROM code version. */ + pHalData->MultiFunc = RT_MULTI_FUNC_NONE; + + dump_chip_info(ChipVersion); + + pHalData->VersionID = ChipVersion; + + if (IS_1T2R(ChipVersion)) { + pHalData->rf_type = RF_1T2R; + pHalData->NumTotalRFPath = 2; + } else if (IS_2T2R(ChipVersion)) { + pHalData->rf_type = RF_2T2R; + pHalData->NumTotalRFPath = 2; + } else{ + pHalData->rf_type = RF_1T1R; + pHalData->NumTotalRFPath = 1; + } + + MSG_88E("RF_Type is %x!!\n", pHalData->rf_type); + + return ChipVersion; +} + +static void rtl8188e_read_chip_version(struct adapter *padapter) +{ + ReadChipVersion8188E(padapter); +} + +static void rtl8188e_GetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) +{ +} + +static void rtl8188e_SetHalODMVar(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct odm_dm_struct *podmpriv = &pHalData->odmpriv; + switch (eVariable) { + case HAL_ODM_STA_INFO: + { + struct sta_info *psta = (struct sta_info *)pValue1; + if (bSet) { + DBG_88E("### Set STA_(%d) info\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); + ODM_RAInfo_Init(podmpriv, psta->mac_id); + } else { + DBG_88E("### Clean STA_(%d) info\n", psta->mac_id); + ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL); + } + } + break; + case HAL_ODM_P2P_STATE: + ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DIRECT, bSet); + break; + case HAL_ODM_WIFI_DISPLAY_STATE: + ODM_CmnInfoUpdate(podmpriv, ODM_CMNINFO_WIFI_DISPLAY, bSet); + break; + default: + break; + } +} + +void rtl8188e_clone_haldata(struct adapter *dst_adapter, struct adapter *src_adapter) +{ + memcpy(dst_adapter->HalData, src_adapter->HalData, dst_adapter->hal_data_sz); +} + +void rtl8188e_start_thread(struct adapter *padapter) +{ +} + +void rtl8188e_stop_thread(struct adapter *padapter) +{ +} + +static void hal_notch_filter_8188e(struct adapter *adapter, bool enable) +{ + if (enable) { + DBG_88E("Enable notch filter\n"); + rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT1); + } else { + DBG_88E("Disable notch filter\n"); + rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1); + } +} +void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) +{ + pHalFunc->free_hal_data = &rtl8188e_free_hal_data; + + pHalFunc->dm_init = &rtl8188e_init_dm_priv; + pHalFunc->dm_deinit = &rtl8188e_deinit_dm_priv; + + pHalFunc->read_chip_version = &rtl8188e_read_chip_version; + + pHalFunc->set_bwmode_handler = &PHY_SetBWMode8188E; + pHalFunc->set_channel_handler = &PHY_SwChnl8188E; + + pHalFunc->hal_dm_watchdog = &rtl8188e_HalDmWatchDog; + + pHalFunc->Add_RateATid = &rtl8188e_Add_RateATid; + pHalFunc->run_thread = &rtl8188e_start_thread; + pHalFunc->cancel_thread = &rtl8188e_stop_thread; + + pHalFunc->AntDivBeforeLinkHandler = &AntDivBeforeLink8188E; + pHalFunc->AntDivCompareHandler = &AntDivCompare8188E; + pHalFunc->read_bbreg = &rtl8188e_PHY_QueryBBReg; + pHalFunc->write_bbreg = &rtl8188e_PHY_SetBBReg; + pHalFunc->read_rfreg = &rtl8188e_PHY_QueryRFReg; + pHalFunc->write_rfreg = &rtl8188e_PHY_SetRFReg; + + /* Efuse related function */ + pHalFunc->EfusePowerSwitch = &rtl8188e_EfusePowerSwitch; + pHalFunc->ReadEFuse = &rtl8188e_ReadEFuse; + pHalFunc->EFUSEGetEfuseDefinition = &rtl8188e_EFUSE_GetEfuseDefinition; + pHalFunc->EfuseGetCurrentSize = &rtl8188e_EfuseGetCurrentSize; + pHalFunc->Efuse_PgPacketRead = &rtl8188e_Efuse_PgPacketRead; + pHalFunc->Efuse_PgPacketWrite = &rtl8188e_Efuse_PgPacketWrite; + pHalFunc->Efuse_WordEnableDataWrite = &rtl8188e_Efuse_WordEnableDataWrite; + + pHalFunc->sreset_init_value = &sreset_init_value; + pHalFunc->sreset_reset_value = &sreset_reset_value; + pHalFunc->silentreset = &rtl8188e_silentreset_for_specific_platform; + pHalFunc->sreset_xmit_status_check = &rtl8188e_sreset_xmit_status_check; + pHalFunc->sreset_linked_status_check = &rtl8188e_sreset_linked_status_check; + pHalFunc->sreset_get_wifi_status = &sreset_get_wifi_status; + + pHalFunc->GetHalODMVarHandler = &rtl8188e_GetHalODMVar; + pHalFunc->SetHalODMVarHandler = &rtl8188e_SetHalODMVar; + + pHalFunc->IOL_exec_cmds_sync = &rtl8188e_IOL_exec_cmds_sync; + + pHalFunc->hal_notch_filter = &hal_notch_filter_8188e; +} + +u8 GetEEPROMSize8188E(struct adapter *padapter) +{ + u8 size = 0; + u32 cr; + + cr = rtw_read16(padapter, REG_9346CR); + /* 6: EEPROM used is 93C46, 4: boot from E-Fuse. */ + size = (cr & BOOT_FROM_EEPROM) ? 6 : 4; + + MSG_88E("EEPROM type is %s\n", size == 4 ? "E-FUSE" : "93C46"); + + return size; +} + +/* */ +/* */ +/* LLT R/W/Init function */ +/* */ +/* */ +static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) +{ + s32 status = _SUCCESS; + s32 count = 0; + u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); + u16 LLTReg = REG_LLT_INIT; + + rtw_write32(padapter, LLTReg, value); + + /* polling */ + do { + value = rtw_read32(padapter, LLTReg); + if (_LLT_NO_ACTIVE == _LLT_OP_VALUE(value)) + break; + + if (count > POLLING_LLT_THRESHOLD) { + RT_TRACE(_module_hal_init_c_, _drv_err_, ("Failed to polling write LLT done at address %d!\n", address)); + status = _FAIL; + break; + } + } while (count++); + + return status; +} + +s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) +{ + s32 status = _FAIL; + u32 i; + u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/* 176, 22k */ + + if (rtw_IOL_applied(padapter)) { + status = iol_InitLLTTable(padapter, txpktbuf_bndy); + } else { + for (i = 0; i < (txpktbuf_bndy - 1); i++) { + status = _LLTWrite(padapter, i, i + 1); + if (_SUCCESS != status) + return status; + } + + /* end of list */ + status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF); + if (_SUCCESS != status) + return status; + + /* Make the other pages as ring buffer */ + /* This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */ + /* Otherwise used as local loopback buffer. */ + for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) { + status = _LLTWrite(padapter, i, (i + 1)); + if (_SUCCESS != status) + return status; + } + + /* Let last entry point to the start entry of ring buffer */ + status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy); + if (_SUCCESS != status) { + return status; + } + } + + return status; +} + +void +Hal_InitPGData88E(struct adapter *padapter) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + + if (!pEEPROM->bautoload_fail_flag) { /* autoload OK. */ + if (!is_boot_from_eeprom(padapter)) { + /* Read EFUSE real map to shadow. */ + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); + } + } else {/* autoload fail */ + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); + /* update to default value 0xFF */ + if (!is_boot_from_eeprom(padapter)) + EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); + } +} + +void +Hal_EfuseParseIDCode88E( + struct adapter *padapter, + u8 *hwinfo + ) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + u16 EEPROMId; + + /* Check 0x8129 again for making sure autoload status!! */ + EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); + if (EEPROMId != RTL_EEPROM_ID) { + pr_err("EEPROM ID(%#x) is invalid!!\n", EEPROMId); + pEEPROM->bautoload_fail_flag = true; + } else { + pEEPROM->bautoload_fail_flag = false; + } + + pr_info("EEPROM ID = 0x%04x\n", EEPROMId); +} + +static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail) +{ + u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0; + + memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g)); + + if (AutoLoadFail) { + for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) { + /* 2.4G default value */ + for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { + pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + if (TxCount == 0) { + pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; + pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } + } + } + return; + } + + for (rfPath = 0; rfPath < RF_PATH_MAX; rfPath++) { + /* 2.4G default value */ + for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { + pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++]; + if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) + pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } + for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { + pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; + if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) + pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; + } + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + if (TxCount == 0) { + pwrInfo24G->BW40_Diff[rfPath][TxCount] = 0; + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; + } else { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; + } + pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0; + eeAddr++; + } else { + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; + } + eeAddr++; + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; + } + + if (PROMContent[eeAddr] == 0xFF) { + pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; + } else { + pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; + } + eeAddr++; + } + } + } +} + +static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) +{ + u8 bIn24G = true; + + if (chnl <= 14) { + bIn24G = true; + + if (chnl < 3) /* Channel 1-2 */ + *pGroup = 0; + else if (chnl < 6) /* Channel 3-5 */ + *pGroup = 1; + else if (chnl < 9) /* Channel 6-8 */ + *pGroup = 2; + else if (chnl < 12) /* Channel 9-11 */ + *pGroup = 3; + else if (chnl < 14) /* Channel 12-13 */ + *pGroup = 4; + else if (chnl == 14) /* Channel 14 */ + *pGroup = 5; + } else { + bIn24G = false; + + if (chnl <= 40) + *pGroup = 0; + else if (chnl <= 48) + *pGroup = 1; + else if (chnl <= 56) + *pGroup = 2; + else if (chnl <= 64) + *pGroup = 3; + else if (chnl <= 104) + *pGroup = 4; + else if (chnl <= 112) + *pGroup = 5; + else if (chnl <= 120) + *pGroup = 5; + else if (chnl <= 128) + *pGroup = 6; + else if (chnl <= 136) + *pGroup = 7; + else if (chnl <= 144) + *pGroup = 8; + else if (chnl <= 153) + *pGroup = 9; + else if (chnl <= 161) + *pGroup = 10; + else if (chnl <= 177) + *pGroup = 11; + } + return bIn24G; +} + +void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + if (AutoLoadFail) { + padapter->pwrctrlpriv.bHWPowerdown = false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = false; + } else { + /* hw power down mode selection , 0:rf-off / 1:power down */ + + if (padapter->registrypriv.hwpdn_mode == 2) + padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT4); + else + padapter->pwrctrlpriv.bHWPowerdown = padapter->registrypriv.hwpdn_mode; + + /* decide hw if support remote wakeup function */ + /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ + padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1) ? true : false; + + DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) , bSupportRemoteWakeup(%x)\n", __func__, + padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown , padapter->pwrctrlpriv.bSupportRemoteWakeup); + + DBG_88E("### PS params => power_mgnt(%x), usbss_enable(%x) ###\n", padapter->registrypriv.power_mgnt, padapter->registrypriv.usbss_enable); + } +} + +void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct txpowerinfo24g pwrInfo24G; + u8 rfPath, ch, group; + u8 bIn24G, TxCount; + + Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail); + + if (!AutoLoadFail) + pHalData->bTXPowerDataReadFromEEPORM = true; + + for (rfPath = 0; rfPath < pHalData->NumTotalRFPath; rfPath++) { + for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { + bIn24G = Hal_GetChnlGroup88E(ch, &group); + if (bIn24G) { + pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; + if (ch == 14) + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][4]; + else + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; + } + if (bIn24G) { + DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch); + DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_CCK_Base[rfPath][ch]); + DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_BW40_Base[rfPath][ch]); + } + } + for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { + pHalData->CCK_24G_Diff[rfPath][TxCount] = pwrInfo24G.CCK_Diff[rfPath][TxCount]; + pHalData->OFDM_24G_Diff[rfPath][TxCount] = pwrInfo24G.OFDM_Diff[rfPath][TxCount]; + pHalData->BW20_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW20_Diff[rfPath][TxCount]; + pHalData->BW40_24G_Diff[rfPath][TxCount] = pwrInfo24G.BW40_Diff[rfPath][TxCount]; + DBG_88E("======= TxCount %d =======\n", TxCount); + DBG_88E("CCK_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->CCK_24G_Diff[rfPath][TxCount]); + DBG_88E("OFDM_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->OFDM_24G_Diff[rfPath][TxCount]); + DBG_88E("BW20_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW20_24G_Diff[rfPath][TxCount]); + DBG_88E("BW40_24G_Diff[%d][%d] = %d\n", rfPath, TxCount, pHalData->BW40_24G_Diff[rfPath][TxCount]); + } + } + + /* 2010/10/19 MH Add Regulator recognize for CU. */ + if (!AutoLoadFail) { + pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x7); /* bit0~2 */ + if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) + pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */ + } else { + pHalData->EEPROMRegulatory = 0; + } + DBG_88E("EEPROMRegulatory = 0x%x\n", pHalData->EEPROMRegulatory); +} + +void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (!AutoLoadFail) { + pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E]; + if (pHalData->CrystalCap == 0xFF) + pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; + } else { + pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; + } + DBG_88E("CrystalCap: 0x%2x\n", pHalData->CrystalCap); +} + +void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (!AutoLoadFail) + pHalData->BoardType = ((hwinfo[EEPROM_RF_BOARD_OPTION_88E]&0xE0)>>5); + else + pHalData->BoardType = 0; + DBG_88E("Board Type: 0x%2x\n", pHalData->BoardType); +} + +void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + if (!AutoLoadFail) { + pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_88E]; + if (pHalData->EEPROMVersion == 0xFF) + pHalData->EEPROMVersion = EEPROM_Default_Version; + } else { + pHalData->EEPROMVersion = 1; + } + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, + ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n", + pHalData->EEPROMVersion)); +} + +void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + padapter->mlmepriv.ChannelPlan = + hal_com_get_channel_plan(padapter, + hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF, + padapter->registrypriv.channel_plan, + RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail); + + DBG_88E("mlmepriv.ChannelPlan = 0x%02x\n", padapter->mlmepriv.ChannelPlan); +} + +void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + if (!AutoLoadFail) { + pHalData->EEPROMCustomerID = hwinfo[EEPROM_CUSTOMERID_88E]; + } else { + pHalData->EEPROMCustomerID = 0; + pHalData->EEPROMSubCustomerID = 0; + } + DBG_88E("EEPROM Customer ID: 0x%2x\n", pHalData->EEPROMCustomerID); +} + +void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct registry_priv *registry_par = &pAdapter->registrypriv; + + if (!AutoLoadFail) { + /* Antenna Diversity setting. */ + if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ + pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x18)>>3; + if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) + pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3;; + } else { + pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ + } + + if (registry_par->antdiv_type == 0) { + /* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */ + pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E]; + if (pHalData->TRxAntDivType == 0xFF) + pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /* For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ + } else { + pHalData->TRxAntDivType = registry_par->antdiv_type; + } + + if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV) + pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */ + } else { + pHalData->AntDivCfg = 0; + pHalData->TRxAntDivType = pHalData->TRxAntDivType; /* The value in the driver setting of device manager. */ + } + DBG_88E("EEPROM : AntDivCfg = %x, TRxAntDivType = %x\n", pHalData->AntDivCfg, pHalData->TRxAntDivType); +} + +void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + /* ThermalMeter from EEPROM */ + if (!AutoloadFail) + pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E]; + else + pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; + + if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) { + pHalData->bAPKThermalMeterIgnore = true; + pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; + } + DBG_88E("ThermalMeter = 0x%x\n", pHalData->EEPROMThermalMeter); +} + +void Hal_InitChannelPlan(struct adapter *padapter) +{ +} + +bool HalDetectPwrDownMode88E(struct adapter *Adapter) +{ + u8 tmpvalue = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; + + EFUSE_ShadowRead(Adapter, 1, EEPROM_RF_FEATURE_OPTION_88E, (u32 *)&tmpvalue); + + /* 2010/08/25 MH INF priority > PDN Efuse value. */ + if (tmpvalue & BIT(4) && pwrctrlpriv->reg_pdnmode) + pHalData->pwrdown = true; + else + pHalData->pwrdown = false; + + DBG_88E("HalDetectPwrDownMode(): PDN =%d\n", pHalData->pwrdown); + + return pHalData->pwrdown; +} /* HalDetectPwrDownMode */ + +/* This function is used only for 92C to set REG_BCN_CTRL(0x550) register. */ +/* We just reserve the value of the register in variable pHalData->RegBcnCtrlVal and then operate */ +/* the value of the register via atomic operation. */ +/* This prevents from race condition when setting this register. */ +/* The value of pHalData->RegBcnCtrlVal is initialized in HwConfigureRTL8192CE() function. */ + +void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits) +{ + struct hal_data_8188e *pHalData; + + pHalData = GET_HAL_DATA(padapter); + + pHalData->RegBcnCtrlVal |= SetBits; + pHalData->RegBcnCtrlVal &= ~ClearBits; + + rtw_write8(padapter, REG_BCN_CTRL, (u8)pHalData->RegBcnCtrlVal); +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c new file mode 100644 index 000000000000..66388902ab94 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -0,0 +1,851 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_MP_C_ + +#include +#include +#include +#include + +s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + + if (!netif_running(padapter->pnetdev)) { + RT_TRACE(_module_mp_, _drv_warning_, + ("SetPowerTracking! Fail: interface not opened!\n")); + return _FAIL; + } + + if (!check_fwstate(&padapter->mlmepriv, WIFI_MP_STATE)) { + RT_TRACE(_module_mp_, _drv_warning_, + ("SetPowerTracking! Fail: not in MP mode!\n")); + return _FAIL; + } + + if (enable) + pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; + else + pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = false; + + return _SUCCESS; +} + +void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + + *enable = pDM_Odm->RFCalibrateInfo.TxPowerTrackControl; +} + +/*----------------------------------------------------------------------------- + * Function: mpt_SwitchRfSetting + * + * Overview: Change RF Setting when we siwthc channel/rate/BW for MP. + * + * Input: struct adapter * pAdapter + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 01/08/2009 MHC Suggestion from SD3 Willis for 92S series. + * 01/09/2009 MHC Add CCK modification for 40MHZ. Suggestion from SD3. + * + *---------------------------------------------------------------------------*/ +void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter) +{ + struct mp_priv *pmp = &pAdapter->mppriv; + + /* <20120525, Kordan> Dynamic mechanism for APK, asked by Dennis. */ + pmp->MptCtx.backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + pmp->MptCtx.backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0); + PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD); + PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD); + + return; +} +/*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/ + +/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ +void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14) +{ + u32 TempVal = 0, TempVal2 = 0, TempVal3 = 0; + u32 CurrCCKSwingVal = 0, CCKSwingIndex = 12; + u8 i; + + /* get current cck swing value and check 0xa22 & 0xa23 later to match the table. */ + CurrCCKSwingVal = read_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord); + + if (!bInCH14) { + /* Readback the current bb cck swing value and compare with the table to */ + /* get the current swing index */ + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch1_Ch13[i][0]) && + (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch1_Ch13[i][1])) { + CCKSwingIndex = i; + break; + } + } + + /* Write 0xa22 0xa23 */ + TempVal = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][0] + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][1]<<8); + + /* Write 0xa24 ~ 0xa27 */ + TempVal2 = 0; + TempVal2 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][2] + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][3]<<8) + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][4]<<16)+ + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][5]<<24); + + /* Write 0xa28 0xa29 */ + TempVal3 = 0; + TempVal3 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][6] + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][7]<<8); + } else { + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch14[i][0]) && + (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch14[i][1])) { + CCKSwingIndex = i; + break; + } + } + + /* Write 0xa22 0xa23 */ + TempVal = CCKSwingTable_Ch14[CCKSwingIndex][0] + + (CCKSwingTable_Ch14[CCKSwingIndex][1]<<8); + + /* Write 0xa24 ~ 0xa27 */ + TempVal2 = 0; + TempVal2 = CCKSwingTable_Ch14[CCKSwingIndex][2] + + (CCKSwingTable_Ch14[CCKSwingIndex][3]<<8) + + (CCKSwingTable_Ch14[CCKSwingIndex][4]<<16)+ + (CCKSwingTable_Ch14[CCKSwingIndex][5]<<24); + + /* Write 0xa28 0xa29 */ + TempVal3 = 0; + TempVal3 = CCKSwingTable_Ch14[CCKSwingIndex][6] + + (CCKSwingTable_Ch14[CCKSwingIndex][7]<<8); + } + + write_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord, TempVal); + write_bbreg(Adapter, rCCK0_TxFilter2, bMaskDWord, TempVal2); + write_bbreg(Adapter, rCCK0_DebugPort, bMaskLWord, TempVal3); +} + +void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + s32 TempCCk; + u8 CCK_index, CCK_index_old = 0; + u8 Action = 0; /* 0: no action, 1: even->odd, 2:odd->even */ + s32 i = 0; + + if (!IS_92C_SERIAL(pHalData->VersionID)) + return; + if (beven && !pMptCtx->bMptIndexEven) { + /* odd->even */ + Action = 2; + pMptCtx->bMptIndexEven = true; + } else if (!beven && pMptCtx->bMptIndexEven) { + /* even->odd */ + Action = 1; + pMptCtx->bMptIndexEven = false; + } + + if (Action != 0) { + /* Query CCK default setting From 0xa24 */ + TempCCk = read_bbreg(pAdapter, rCCK0_TxFilter2, bMaskDWord) & bMaskCCK; + for (i = 0; i < CCK_TABLE_SIZE; i++) { + if (pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + if (!memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4)) { + CCK_index_old = (u8)i; + break; + } + } else { + if (!memcmp((void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4)) { + CCK_index_old = (u8)i; + break; + } + } + } + + if (Action == 1) + CCK_index = CCK_index_old - 1; + else + CCK_index = CCK_index_old + 1; + + /* Adjust CCK according to gain index */ + if (!pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch1_Ch13[CCK_index][0]); + rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch1_Ch13[CCK_index][1]); + rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch1_Ch13[CCK_index][2]); + rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch1_Ch13[CCK_index][3]); + rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch1_Ch13[CCK_index][4]); + rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch1_Ch13[CCK_index][5]); + rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch1_Ch13[CCK_index][6]); + rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch1_Ch13[CCK_index][7]); + } else { + rtw_write8(pAdapter, 0xa22, CCKSwingTable_Ch14[CCK_index][0]); + rtw_write8(pAdapter, 0xa23, CCKSwingTable_Ch14[CCK_index][1]); + rtw_write8(pAdapter, 0xa24, CCKSwingTable_Ch14[CCK_index][2]); + rtw_write8(pAdapter, 0xa25, CCKSwingTable_Ch14[CCK_index][3]); + rtw_write8(pAdapter, 0xa26, CCKSwingTable_Ch14[CCK_index][4]); + rtw_write8(pAdapter, 0xa27, CCKSwingTable_Ch14[CCK_index][5]); + rtw_write8(pAdapter, 0xa28, CCKSwingTable_Ch14[CCK_index][6]); + rtw_write8(pAdapter, 0xa29, CCKSwingTable_Ch14[CCK_index][7]); + } + } +} +/*---------------------------hal\rtl8192c\MPT_HelperFunc.c---------------------------*/ + +/* + * SetChannel + * Description + * Use H2C command to change channel, + * not only modify rf register, but also other setting need to be done. + */ +void Hal_SetChannel(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + struct mp_priv *pmp = &pAdapter->mppriv; + struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + u8 eRFPath; + u8 channel = pmp->channel; + + /* set RF channel register */ + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) + _write_rfreg(pAdapter, eRFPath, ODM_CHANNEL, 0x3FF, channel); + Hal_mpt_SwitchRfSetting(pAdapter); + + SelectChannel(pAdapter, channel); + + if (pHalData->CurrentChannel == 14 && !pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + pDM_Odm->RFCalibrateInfo.bCCKinCH14 = true; + Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14); + } else if (pHalData->CurrentChannel != 14 && pDM_Odm->RFCalibrateInfo.bCCKinCH14) { + pDM_Odm->RFCalibrateInfo.bCCKinCH14 = false; + Hal_MPT_CCKTxPowerAdjust(pAdapter, pDM_Odm->RFCalibrateInfo.bCCKinCH14); + } +} + +/* + * Notice + * Switch bandwitdth may change center frequency(channel) + */ +void Hal_SetBandwidth(struct adapter *pAdapter) +{ + struct mp_priv *pmp = &pAdapter->mppriv; + + SetBWMode(pAdapter, pmp->bandwidth, pmp->prime_channel_offset); + Hal_mpt_SwitchRfSetting(pAdapter); +} + +void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 *TxPower) +{ + u32 tmpval = 0; + + /* rf-A cck tx power */ + write_bbreg(pAdapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, TxPower[RF_PATH_A]); + tmpval = (TxPower[RF_PATH_A]<<16) | (TxPower[RF_PATH_A]<<8) | TxPower[RF_PATH_A]; + write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); + + /* rf-B cck tx power */ + write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, TxPower[RF_PATH_B]); + tmpval = (TxPower[RF_PATH_B]<<16) | (TxPower[RF_PATH_B]<<8) | TxPower[RF_PATH_B]; + write_bbreg(pAdapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); + + RT_TRACE(_module_mp_, _drv_notice_, + ("-SetCCKTxPower: A[0x%02x] B[0x%02x]\n", + TxPower[RF_PATH_A], TxPower[RF_PATH_B])); +} + +void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 *TxPower) +{ + u32 TxAGC = 0; + u8 tmpval = 0; + + /* HT Tx-rf(A) */ + tmpval = TxPower[RF_PATH_A]; + TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; + + write_bbreg(pAdapter, rTxAGC_A_Rate18_06, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Rate54_24, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs03_Mcs00, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs07_Mcs04, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs11_Mcs08, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_A_Mcs15_Mcs12, bMaskDWord, TxAGC); + + /* HT Tx-rf(B) */ + tmpval = TxPower[RF_PATH_B]; + TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; + + write_bbreg(pAdapter, rTxAGC_B_Rate18_06, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Rate54_24, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs03_Mcs00, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs07_Mcs04, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs11_Mcs08, bMaskDWord, TxAGC); + write_bbreg(pAdapter, rTxAGC_B_Mcs15_Mcs12, bMaskDWord, TxAGC); +} + +void Hal_SetAntennaPathPower(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + u8 TxPowerLevel[RF_PATH_MAX]; + u8 rfPath; + + TxPowerLevel[RF_PATH_A] = pAdapter->mppriv.txpoweridx; + TxPowerLevel[RF_PATH_B] = pAdapter->mppriv.txpoweridx_b; + + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + default: + rfPath = RF_PATH_A; + break; + case ANTENNA_B: + rfPath = RF_PATH_B; + break; + case ANTENNA_C: + rfPath = RF_PATH_C; + break; + } + + switch (pHalData->rf_chip) { + case RF_8225: + case RF_8256: + case RF_6052: + Hal_SetCCKTxPower(pAdapter, TxPowerLevel); + if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ + Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); + Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); + break; + default: + break; + } +} + +void Hal_SetTxPower(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + u8 TxPower = pAdapter->mppriv.txpoweridx; + u8 TxPowerLevel[RF_PATH_MAX]; + u8 rf, rfPath; + + for (rf = 0; rf < RF_PATH_MAX; rf++) + TxPowerLevel[rf] = TxPower; + + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + default: + rfPath = RF_PATH_A; + break; + case ANTENNA_B: + rfPath = RF_PATH_B; + break; + case ANTENNA_C: + rfPath = RF_PATH_C; + break; + } + + switch (pHalData->rf_chip) { + /* 2008/09/12 MH Test only !! We enable the TX power tracking for MP!!!!! */ + /* We should call normal driver API later!! */ + case RF_8225: + case RF_8256: + case RF_6052: + Hal_SetCCKTxPower(pAdapter, TxPowerLevel); + if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ + Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); + Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); + break; + default: + break; + } +} + +void Hal_SetDataRate(struct adapter *pAdapter) +{ + Hal_mpt_SwitchRfSetting(pAdapter); +} + +void Hal_SetAntenna(struct adapter *pAdapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + struct ant_sel_ofdm *p_ofdm_tx; /* OFDM Tx register */ + struct ant_sel_cck *p_cck_txrx; + u8 r_rx_antenna_ofdm = 0, r_ant_select_cck_val = 0; + u8 chgTx = 0, chgRx = 0; + u32 r_ant_select_ofdm_val = 0, r_ofdm_tx_en_val = 0; + + p_ofdm_tx = (struct ant_sel_ofdm *)&r_ant_select_ofdm_val; + p_cck_txrx = (struct ant_sel_cck *)&r_ant_select_cck_val; + + p_ofdm_tx->r_ant_ht1 = 0x1; + p_ofdm_tx->r_ant_ht2 = 0x2; /* Second TX RF path is A */ + p_ofdm_tx->r_ant_non_ht = 0x3; /* 0x1+0x2=0x3 */ + + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + p_ofdm_tx->r_tx_antenna = 0x1; + r_ofdm_tx_en_val = 0x1; + p_ofdm_tx->r_ant_l = 0x1; + p_ofdm_tx->r_ant_ht_s1 = 0x1; + p_ofdm_tx->r_ant_non_ht_s1 = 0x1; + p_cck_txrx->r_ccktx_enable = 0x8; + chgTx = 1; + + /* From SD3 Willis suggestion !!! Set RF A=TX and B as standby */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 1); + r_ofdm_tx_en_val = 0x3; + + /* Power save */ + + /* We need to close RFB by SW control */ + if (pHalData->rf_type == RF_2T2R) { + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 0); + } + break; + case ANTENNA_B: + p_ofdm_tx->r_tx_antenna = 0x2; + r_ofdm_tx_en_val = 0x2; + p_ofdm_tx->r_ant_l = 0x2; + p_ofdm_tx->r_ant_ht_s1 = 0x2; + p_ofdm_tx->r_ant_non_ht_s1 = 0x2; + p_cck_txrx->r_ccktx_enable = 0x4; + chgTx = 1; + /* From SD3 Willis suggestion !!! Set RF A as standby */ + PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2); + + /* Power save */ + /* cosa r_ant_select_ofdm_val = 0x22222222; */ + + /* 2008/10/31 MH From SD3 Willi's suggestion. We must read RF 1T table. */ + /* 2009/01/08 MH From Sd3 Willis. We need to close RFA by SW control */ + if (pHalData->rf_type == RF_2T2R || pHalData->rf_type == RF_1T2R) { + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); + } + break; + case ANTENNA_AB: /* For 8192S */ + p_ofdm_tx->r_tx_antenna = 0x3; + r_ofdm_tx_en_val = 0x3; + p_ofdm_tx->r_ant_l = 0x3; + p_ofdm_tx->r_ant_ht_s1 = 0x3; + p_ofdm_tx->r_ant_non_ht_s1 = 0x3; + p_cck_txrx->r_ccktx_enable = 0xC; + chgTx = 1; + + /* From SD3 Willis suggestion !!! Set RF B as standby */ + PHY_SetBBReg(pAdapter, rFPGA0_XA_HSSIParameter2, 0xe, 2); + PHY_SetBBReg(pAdapter, rFPGA0_XB_HSSIParameter2, 0xe, 2); + + /* Disable Power save */ + /* cosa r_ant_select_ofdm_val = 0x3321333; */ + /* 2009/01/08 MH From Sd3 Willis. We need to enable RFA/B by SW control */ + if (pHalData->rf_type == RF_2T2R) { + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); + } + break; + default: + break; + } + + /* r_rx_antenna_ofdm, bit0=A, bit1=B, bit2=C, bit3=D */ + /* r_cckrx_enable : CCK default, 0=A, 1=B, 2=C, 3=D */ + /* r_cckrx_enable_2 : CCK option, 0=A, 1=B, 2=C, 3=D */ + switch (pAdapter->mppriv.antenna_rx) { + case ANTENNA_A: + r_rx_antenna_ofdm = 0x1; /* A */ + p_cck_txrx->r_cckrx_enable = 0x0; /* default: A */ + p_cck_txrx->r_cckrx_enable_2 = 0x0; /* option: A */ + chgRx = 1; + break; + case ANTENNA_B: + r_rx_antenna_ofdm = 0x2; /* B */ + p_cck_txrx->r_cckrx_enable = 0x1; /* default: B */ + p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option: B */ + chgRx = 1; + break; + case ANTENNA_AB: + r_rx_antenna_ofdm = 0x3; /* AB */ + p_cck_txrx->r_cckrx_enable = 0x0; /* default:A */ + p_cck_txrx->r_cckrx_enable_2 = 0x1; /* option:B */ + chgRx = 1; + break; + default: + break; + } + + if (chgTx && chgRx) { + switch (pHalData->rf_chip) { + case RF_8225: + case RF_8256: + case RF_6052: + /* r_ant_sel_cck_val = r_ant_select_cck_val; */ + PHY_SetBBReg(pAdapter, rFPGA1_TxInfo, 0x7fffffff, r_ant_select_ofdm_val); /* OFDM Tx */ + PHY_SetBBReg(pAdapter, rFPGA0_TxInfo, 0x0000000f, r_ofdm_tx_en_val); /* OFDM Tx */ + PHY_SetBBReg(pAdapter, rOFDM0_TRxPathEnable, 0x0000000f, r_rx_antenna_ofdm); /* OFDM Rx */ + PHY_SetBBReg(pAdapter, rOFDM1_TRxPathEnable, 0x0000000f, r_rx_antenna_ofdm); /* OFDM Rx */ + PHY_SetBBReg(pAdapter, rCCK0_AFESetting, bMaskByte3, r_ant_select_cck_val); /* CCK TxRx */ + + break; + default: + break; + } + } + + RT_TRACE(_module_mp_, _drv_notice_, ("-SwitchAntenna: finished\n")); +} + +s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + + if (!netif_running(pAdapter->pnetdev)) { + RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter! Fail: interface not opened!\n")); + return _FAIL; + } + + if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { + RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter: Fail! not in MP mode!\n")); + return _FAIL; + } + + target_ther &= 0xff; + if (target_ther < 0x07) + target_ther = 0x07; + else if (target_ther > 0x1d) + target_ther = 0x1d; + + pHalData->EEPROMThermalMeter = target_ther; + + return _SUCCESS; +} + +void Hal_TriggerRFThermalMeter(struct adapter *pAdapter) +{ + _write_rfreg(pAdapter, RF_PATH_A , RF_T_METER_88E , BIT17 | BIT16 , 0x03); +} + +u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter) +{ + u32 ThermalValue = 0; + + ThermalValue = _read_rfreg(pAdapter, RF_PATH_A, RF_T_METER_88E, 0xfc00); + return (u8)ThermalValue; +} + +void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value) +{ + Hal_TriggerRFThermalMeter(pAdapter); + rtw_msleep_os(1000); + *value = Hal_ReadRFThermalMeter(pAdapter); +} + +void Hal_SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) +{ + pAdapter->mppriv.MptCtx.bSingleCarrier = bStart; + if (bStart) { + /* Start Single Carrier. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test start\n")); + /* 1. if OFDM block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ + + /* 2. set CCK test mode off, set to CCK normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable); + /* 3. turn on scramble setting */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); + /* 4. Turn On Single Carrier Tx and turn off the other test modes. */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bEnable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + } else { + /* Stop Single Carrier. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test stop\n")); + + /* Turn off all test modes. */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + rtw_msleep_os(10); + + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } +} + +void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); + bool is92C = IS_92C_SERIAL(pHalData->VersionID); + + u8 rfPath; + u32 reg58 = 0x0; + switch (pAdapter->mppriv.antenna_tx) { + case ANTENNA_A: + default: + rfPath = RF_PATH_A; + break; + case ANTENNA_B: + rfPath = RF_PATH_B; + break; + case ANTENNA_C: + rfPath = RF_PATH_C; + break; + } + + pAdapter->mppriv.MptCtx.bSingleTone = bStart; + if (bStart) { + /* Start Single Tone. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test start\n")); + /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ + if (IS_HARDWARE_TYPE_8188E(pAdapter)) { + reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); + reg58 &= 0xFFFFFFF0; + reg58 += 2; + PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58); + } + PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x0); + PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x0); + + if (is92C) { + _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x01); + rtw_usleep_os(100); + if (rfPath == RF_PATH_A) + write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x10000); /* PAD all on. */ + else if (rfPath == RF_PATH_B) + write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x10000); /* PAD all on. */ + write_rfreg(pAdapter, rfPath, 0x00, 0x2001f); /* PAD all on. */ + rtw_usleep_os(100); + } else { + write_rfreg(pAdapter, rfPath, 0x21, 0xd4000); + rtw_usleep_os(100); + write_rfreg(pAdapter, rfPath, 0x00, 0x2001f); /* PAD all on. */ + rtw_usleep_os(100); + } + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + + } else { + /* Stop Single Tone. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test stop\n")); + + /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ + /* <20120326, Kordan> Only in single tone mode. (asked by Edlu) */ + if (IS_HARDWARE_TYPE_8188E(pAdapter)) { + reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); + reg58 &= 0xFFFFFFF0; + PHY_SetRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask, reg58); + } + write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x1); + write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x1); + if (is92C) { + _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x00); + rtw_usleep_os(100); + write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x32d75); /* PAD all on. */ + write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x32d75); /* PAD all on. */ + rtw_usleep_os(100); + } else { + write_rfreg(pAdapter, rfPath, 0x21, 0x54000); + rtw_usleep_os(100); + write_rfreg(pAdapter, rfPath, 0x00, 0x30000); /* PAD all on. */ + rtw_usleep_os(100); + } + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } +} + +void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) +{ + pAdapter->mppriv.MptCtx.bCarrierSuppression = bStart; + if (bStart) { + /* Start Carrier Suppression. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test start\n")); + if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { + /* 1. if CCK block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ + + /* Turn Off All Test Mode */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); /* transmit mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x0); /* turn off scramble setting */ + + /* Set CCK Tx Test Rate */ + write_bbreg(pAdapter, rCCK0_System, bCCKTxRate, 0x0); /* Set FTxRate to 1Mbps */ + } + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + } else { + /* Stop Carrier Suppression. */ + RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test stop\n")); + if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x1); /* turn on scramble setting */ + + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + } + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } +} + +void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + u32 cckrate; + + if (bStart) { + RT_TRACE(_module_mp_, _drv_alert_, + ("SetCCKContinuousTx: test start\n")); + + /* 1. if CCK block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ + + /* Turn Off All Test Mode */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + /* Set CCK Tx Test Rate */ + cckrate = pAdapter->mppriv.rateidx; + write_bbreg(pAdapter, rCCK0_System, bCCKTxRate, cckrate); + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x2); /* transmit mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + } else { + RT_TRACE(_module_mp_, _drv_info_, + ("SetCCKContinuousTx: test stop\n")); + + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ + + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } + + pAdapter->mppriv.MptCtx.bCckContTx = bStart; + pAdapter->mppriv.MptCtx.bOfdmContTx = false; +} /* mpt_StartCckContTx */ + +void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + if (bStart) { + RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test start\n")); + /* 1. if OFDM block on? */ + if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) + write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ + + /* 2. set CCK test mode off, set to CCK normal mode */ + write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, bDisable); + + /* 3. turn on scramble setting */ + write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); + /* 4. Turn On Continue Tx and turn off the other test modes. */ + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bEnable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + + /* for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); + + } else { + RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test stop\n")); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); + write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); + /* Delay 10 ms */ + rtw_msleep_os(10); + /* BB Reset */ + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); + write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); + + /* Stop for dynamic set Power index. */ + write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000100); + write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000100); + } + + pAdapter->mppriv.MptCtx.bCckContTx = false; + pAdapter->mppriv.MptCtx.bOfdmContTx = bStart; +} /* mpt_StartOfdmContTx */ + +void Hal_SetContinuousTx(struct adapter *pAdapter, u8 bStart) +{ + RT_TRACE(_module_mp_, _drv_info_, + ("SetContinuousTx: rate:%d\n", pAdapter->mppriv.rateidx)); + + pAdapter->mppriv.MptCtx.bStartContTx = bStart; + if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) + Hal_SetCCKContinuousTx(pAdapter, bStart); + else if ((pAdapter->mppriv.rateidx >= MPT_RATE_6M) && + (pAdapter->mppriv.rateidx <= MPT_RATE_MCS15)) + Hal_SetOFDMContinuousTx(pAdapter, bStart); +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c new file mode 100644 index 000000000000..36ad9dbbd8b0 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -0,0 +1,1135 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_PHYCFG_C_ + +#include +#include +#include +#include + +/*---------------------------Define Local Constant---------------------------*/ +/* Channel switch:The size of command tables for switch channel*/ +#define MAX_PRECMD_CNT 16 +#define MAX_RFDEPENDCMD_CNT 16 +#define MAX_POSTCMD_CNT 16 + +#define MAX_DOZE_WAITING_TIMES_9x 64 + +/*---------------------------Define Local Constant---------------------------*/ + +/*------------------------Define global variable-----------------------------*/ + +/*------------------------Define local variable------------------------------*/ + +/*--------------------Define export function prototype-----------------------*/ +/* Please refer to header file */ +/*--------------------Define export function prototype-----------------------*/ + +/*----------------------------Function Body----------------------------------*/ +/* */ +/* 1. BB register R/W API */ +/* */ + +/** +* Function: phy_CalculateBitShift +* +* OverView: Get shifted position of the BitMask +* +* Input: +* u32 BitMask, +* +* Output: none +* Return: u32 Return the shift bit bit position of the mask +*/ +static u32 phy_CalculateBitShift(u32 BitMask) +{ + u32 i; + + for (i = 0; i <= 31; i++) { + if (((BitMask>>i) & 0x1) == 1) + break; + } + return i; +} + +/** +* Function: PHY_QueryBBReg +* +* OverView: Read "sepcific bits" from BB register +* +* Input: +* struct adapter *Adapter, +* u32 RegAddr, The target address to be readback +* u32 BitMask The target bit position in the target address +* to be readback +* Output: None +* Return: u32 Data The readback register value +* Note: This function is equal to "GetRegSetting" in PHY programming guide +*/ +u32 +rtl8188e_PHY_QueryBBReg( + struct adapter *Adapter, + u32 RegAddr, + u32 BitMask + ) +{ + u32 ReturnValue = 0, OriginalValue, BitShift; + + OriginalValue = rtw_read32(Adapter, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + ReturnValue = (OriginalValue & BitMask) >> BitShift; + return ReturnValue; +} + +/** +* Function: PHY_SetBBReg +* +* OverView: Write "Specific bits" to BB register (page 8~) +* +* Input: +* struct adapter *Adapter, +* u32 RegAddr, The target address to be modified +* u32 BitMask The target bit position in the target address +* to be modified +* u32 Data The new register value in the target bit position +* of the target address +* +* Output: None +* Return: None +* Note: This function is equal to "PutRegSetting" in PHY programming guide +*/ + +void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) +{ + u32 OriginalValue, BitShift; + + if (BitMask != bMaskDWord) { /* if not "double word" write */ + OriginalValue = rtw_read32(Adapter, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); + } + + rtw_write32(Adapter, RegAddr, Data); +} + +/* */ +/* 2. RF register R/W API */ +/* */ +/** +* Function: phy_RFSerialRead +* +* OverView: Read regster from RF chips +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 Offset, The target address to be read +* +* Output: None +* Return: u32 reback value +* Note: Threre are three types of serial operations: +* 1. Software serial write +* 2. Hardware LSSI-Low Speed Serial Interface +* 3. Hardware HSSI-High speed +* serial write. Driver need to implement (1) and (2). +* This function is equal to the combination of RF_ReadReg() and RFLSSIRead() +*/ +static u32 +phy_RFSerialRead( + struct adapter *Adapter, + enum rf_radio_path eRFPath, + u32 Offset + ) +{ + u32 retValue = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; + u32 NewOffset; + u32 tmplong, tmplong2; + u8 RfPiEnable = 0; + /* */ + /* Make sure RF register offset is correct */ + /* */ + Offset &= 0xff; + + /* */ + /* Switch page for 8256 RF IC */ + /* */ + NewOffset = Offset; + + /* For 92S LSSI Read RFLSSIRead */ + /* For RF A/B write 0x824/82c(does not work in the future) */ + /* We must use 0x824 for RF A and B to execute read trigger */ + tmplong = PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord); + if (eRFPath == RF_PATH_A) + tmplong2 = tmplong; + else + tmplong2 = PHY_QueryBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord); + + tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ + + PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong&(~bLSSIReadEdge)); + rtw_udelay_os(10);/* PlatformStallExecution(10); */ + + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2); + rtw_udelay_os(100);/* PlatformStallExecution(100); */ + + rtw_udelay_os(10);/* PlatformStallExecution(10); */ + + if (eRFPath == RF_PATH_A) + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT8); + else if (eRFPath == RF_PATH_B) + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter1, BIT8); + + if (RfPiEnable) { /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ + retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBackPi, bLSSIReadBackData); + } else { /* Read from BBreg8a0, 12 bits for 8190, 20 bits for T65 RF */ + retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBack, bLSSIReadBackData); + } + return retValue; +} + +/** +* Function: phy_RFSerialWrite +* +* OverView: Write data to RF register (page 8~) +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 Offset, The target address to be read +* u32 Data The new register Data in the target bit position +* of the target to be read +* +* Output: None +* Return: None +* Note: Threre are three types of serial operations: +* 1. Software serial write +* 2. Hardware LSSI-Low Speed Serial Interface +* 3. Hardware HSSI-High speed +* serial write. Driver need to implement (1) and (2). +* This function is equal to the combination of RF_ReadReg() and RFLSSIRead() + * + * Note: For RF8256 only + * The total count of RTL8256(Zebra4) register is around 36 bit it only employs + * 4-bit RF address. RTL8256 uses "register mode control bit" (Reg00[12], Reg00[10]) + * to access register address bigger than 0xf. See "Appendix-4 in PHY Configuration + * programming guide" for more details. + * Thus, we define a sub-finction for RTL8526 register address conversion + * =========================================================== + * Register Mode RegCTL[1] RegCTL[0] Note + * (Reg00[12]) (Reg00[10]) + * =========================================================== + * Reg_Mode0 0 x Reg 0 ~15(0x0 ~ 0xf) + * ------------------------------------------------------------------ + * Reg_Mode1 1 0 Reg 16 ~30(0x1 ~ 0xf) + * ------------------------------------------------------------------ + * Reg_Mode2 1 1 Reg 31 ~ 45(0x1 ~ 0xf) + * ------------------------------------------------------------------ + * + * 2008/09/02 MH Add 92S RF definition + * + * + * +*/ +static void +phy_RFSerialWrite( + struct adapter *Adapter, + enum rf_radio_path eRFPath, + u32 Offset, + u32 Data + ) +{ + u32 DataAndAddr = 0; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct bb_reg_def *pPhyReg = &pHalData->PHYRegDef[eRFPath]; + u32 NewOffset; + + /* 2009/06/17 MH We can not execute IO for power save or other accident mode. */ + + Offset &= 0xff; + + /* */ + /* Switch page for 8256 RF IC */ + /* */ + NewOffset = Offset; + + /* */ + /* Put write addr in [5:0] and write data in [31:16] */ + /* */ + DataAndAddr = ((NewOffset<<20) | (Data&0x000fffff)) & 0x0fffffff; /* T65 RF */ + + /* */ + /* Write Operation */ + /* */ + PHY_SetBBReg(Adapter, pPhyReg->rf3wireOffset, bMaskDWord, DataAndAddr); +} + +/** +* Function: PHY_QueryRFReg +* +* OverView: Query "Specific bits" to RF register (page 8~) +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 RegAddr, The target address to be read +* u32 BitMask The target bit position in the target address +* to be read +* +* Output: None +* Return: u32 Readback value +* Note: This function is equal to "GetRFRegSetting" in PHY programming guide +*/ +u32 rtl8188e_PHY_QueryRFReg(struct adapter *Adapter, enum rf_radio_path eRFPath, + u32 RegAddr, u32 BitMask) +{ + u32 Original_Value, Readback_Value, BitShift; + + Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr); + + BitShift = phy_CalculateBitShift(BitMask); + Readback_Value = (Original_Value & BitMask) >> BitShift; + return Readback_Value; +} + +/** +* Function: PHY_SetRFReg +* +* OverView: Write "Specific bits" to RF register (page 8~) +* +* Input: +* struct adapter *Adapter, +* enum rf_radio_path eRFPath, Radio path of A/B/C/D +* u32 RegAddr, The target address to be modified +* u32 BitMask The target bit position in the target address +* to be modified +* u32 Data The new register Data in the target bit position +* of the target address +* +* Output: None +* Return: None +* Note: This function is equal to "PutRFRegSetting" in PHY programming guide +*/ +void +rtl8188e_PHY_SetRFReg( + struct adapter *Adapter, + enum rf_radio_path eRFPath, + u32 RegAddr, + u32 BitMask, + u32 Data + ) +{ + u32 Original_Value, BitShift; + + /* RF data is 12 bits only */ + if (BitMask != bRFRegOffsetMask) { + Original_Value = phy_RFSerialRead(Adapter, eRFPath, RegAddr); + BitShift = phy_CalculateBitShift(BitMask); + Data = ((Original_Value & (~BitMask)) | (Data << BitShift)); + } + + phy_RFSerialWrite(Adapter, eRFPath, RegAddr, Data); +} + +/* */ +/* 3. Initial MAC/BB/RF config by reading MAC/BB/RF txt. */ +/* */ + +/*----------------------------------------------------------------------------- + * Function: PHY_MACConfig8192C + * + * Overview: Condig MAC by header file or parameter file. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 08/12/2008 MHC Create Version 0. + * + *---------------------------------------------------------------------------*/ +s32 PHY_MACConfig8188E(struct adapter *Adapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + int rtStatus = _SUCCESS; + + /* */ + /* Config MAC */ + /* */ + if (HAL_STATUS_FAILURE == ODM_ConfigMACWithHeaderFile(&pHalData->odmpriv)) + rtStatus = _FAIL; + + /* 2010.07.13 AMPDU aggregation number B */ + rtw_write16(Adapter, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); + + return rtStatus; +} + +/** +* Function: phy_InitBBRFRegisterDefinition +* +* OverView: Initialize Register definition offset for Radio Path A/B/C/D +* +* Input: +* struct adapter *Adapter, +* +* Output: None +* Return: None +* Note: The initialization value is constant and it should never be changes +*/ +static void +phy_InitBBRFRegisterDefinition( + struct adapter *Adapter +) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + /* RF Interface Sowrtware Control */ + pHalData->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 LSBs if read 32-bit from 0x870 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) */ + pHalData->PHYRegDef[RF_PATH_C].rfintfs = rFPGA0_XCD_RFInterfaceSW;/* 16 LSBs if read 32-bit from 0x874 */ + pHalData->PHYRegDef[RF_PATH_D].rfintfs = rFPGA0_XCD_RFInterfaceSW;/* 16 MSBs if read 32-bit from 0x874 (16-bit for 0x876) */ + + /* RF Interface Readback Value */ + pHalData->PHYRegDef[RF_PATH_A].rfintfi = rFPGA0_XAB_RFInterfaceRB; /* 16 LSBs if read 32-bit from 0x8E0 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfi = rFPGA0_XAB_RFInterfaceRB;/* 16 MSBs if read 32-bit from 0x8E0 (16-bit for 0x8E2) */ + pHalData->PHYRegDef[RF_PATH_C].rfintfi = rFPGA0_XCD_RFInterfaceRB;/* 16 LSBs if read 32-bit from 0x8E4 */ + pHalData->PHYRegDef[RF_PATH_D].rfintfi = rFPGA0_XCD_RFInterfaceRB;/* 16 MSBs if read 32-bit from 0x8E4 (16-bit for 0x8E6) */ + + /* RF Interface Output (and Enable) */ + pHalData->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x860 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x864 */ + + /* RF Interface (Output and) Enable */ + pHalData->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */ + pHalData->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) */ + + /* Addr of LSSI. Wirte RF register by driver */ + pHalData->PHYRegDef[RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; /* LSSI Parameter */ + pHalData->PHYRegDef[RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; + + /* RF parameter */ + pHalData->PHYRegDef[RF_PATH_A].rfLSSI_Select = rFPGA0_XAB_RFParameter; /* BB Band Select */ + pHalData->PHYRegDef[RF_PATH_B].rfLSSI_Select = rFPGA0_XAB_RFParameter; + pHalData->PHYRegDef[RF_PATH_C].rfLSSI_Select = rFPGA0_XCD_RFParameter; + pHalData->PHYRegDef[RF_PATH_D].rfLSSI_Select = rFPGA0_XCD_RFParameter; + + /* Tx AGC Gain Stage (same for all path. Should we remove this?) */ + pHalData->PHYRegDef[RF_PATH_A].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + pHalData->PHYRegDef[RF_PATH_B].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + pHalData->PHYRegDef[RF_PATH_C].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + pHalData->PHYRegDef[RF_PATH_D].rfTxGainStage = rFPGA0_TxGainStage; /* Tx gain stage */ + + /* Tranceiver A~D HSSI Parameter-1 */ + pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; /* wire control parameter1 */ + pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; /* wire control parameter1 */ + + /* Tranceiver A~D HSSI Parameter-2 */ + pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; /* wire control parameter2 */ + pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; /* wire control parameter2 */ + + /* RF switch Control */ + pHalData->PHYRegDef[RF_PATH_A].rfSwitchControl = rFPGA0_XAB_SwitchControl; /* TR/Ant switch control */ + pHalData->PHYRegDef[RF_PATH_B].rfSwitchControl = rFPGA0_XAB_SwitchControl; + pHalData->PHYRegDef[RF_PATH_C].rfSwitchControl = rFPGA0_XCD_SwitchControl; + pHalData->PHYRegDef[RF_PATH_D].rfSwitchControl = rFPGA0_XCD_SwitchControl; + + /* AGC control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfAGCControl1 = rOFDM0_XAAGCCore1; + pHalData->PHYRegDef[RF_PATH_B].rfAGCControl1 = rOFDM0_XBAGCCore1; + pHalData->PHYRegDef[RF_PATH_C].rfAGCControl1 = rOFDM0_XCAGCCore1; + pHalData->PHYRegDef[RF_PATH_D].rfAGCControl1 = rOFDM0_XDAGCCore1; + + /* AGC control 2 */ + pHalData->PHYRegDef[RF_PATH_A].rfAGCControl2 = rOFDM0_XAAGCCore2; + pHalData->PHYRegDef[RF_PATH_B].rfAGCControl2 = rOFDM0_XBAGCCore2; + pHalData->PHYRegDef[RF_PATH_C].rfAGCControl2 = rOFDM0_XCAGCCore2; + pHalData->PHYRegDef[RF_PATH_D].rfAGCControl2 = rOFDM0_XDAGCCore2; + + /* RX AFE control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfRxIQImbalance = rOFDM0_XARxIQImbalance; + pHalData->PHYRegDef[RF_PATH_B].rfRxIQImbalance = rOFDM0_XBRxIQImbalance; + pHalData->PHYRegDef[RF_PATH_C].rfRxIQImbalance = rOFDM0_XCRxIQImbalance; + pHalData->PHYRegDef[RF_PATH_D].rfRxIQImbalance = rOFDM0_XDRxIQImbalance; + + /* RX AFE control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfRxAFE = rOFDM0_XARxAFE; + pHalData->PHYRegDef[RF_PATH_B].rfRxAFE = rOFDM0_XBRxAFE; + pHalData->PHYRegDef[RF_PATH_C].rfRxAFE = rOFDM0_XCRxAFE; + pHalData->PHYRegDef[RF_PATH_D].rfRxAFE = rOFDM0_XDRxAFE; + + /* Tx AFE control 1 */ + pHalData->PHYRegDef[RF_PATH_A].rfTxIQImbalance = rOFDM0_XATxIQImbalance; + pHalData->PHYRegDef[RF_PATH_B].rfTxIQImbalance = rOFDM0_XBTxIQImbalance; + pHalData->PHYRegDef[RF_PATH_C].rfTxIQImbalance = rOFDM0_XCTxIQImbalance; + pHalData->PHYRegDef[RF_PATH_D].rfTxIQImbalance = rOFDM0_XDTxIQImbalance; + + /* Tx AFE control 2 */ + pHalData->PHYRegDef[RF_PATH_A].rfTxAFE = rOFDM0_XATxAFE; + pHalData->PHYRegDef[RF_PATH_B].rfTxAFE = rOFDM0_XBTxAFE; + pHalData->PHYRegDef[RF_PATH_C].rfTxAFE = rOFDM0_XCTxAFE; + pHalData->PHYRegDef[RF_PATH_D].rfTxAFE = rOFDM0_XDTxAFE; + + /* Tranceiver LSSI Readback SI mode */ + pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_C].rfLSSIReadBack = rFPGA0_XC_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_D].rfLSSIReadBack = rFPGA0_XD_LSSIReadBack; + + /* Tranceiver LSSI Readback PI mode */ + pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; + pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; +} + +void storePwrIndexDiffRateOffset(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u32 Data) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + if (RegAddr == rTxAGC_A_Rate18_06) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][0] = Data; + if (RegAddr == rTxAGC_A_Rate54_24) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][1] = Data; + if (RegAddr == rTxAGC_A_CCK1_Mcs32) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][6] = Data; + if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0xffffff00) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][7] = Data; + if (RegAddr == rTxAGC_A_Mcs03_Mcs00) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][2] = Data; + if (RegAddr == rTxAGC_A_Mcs07_Mcs04) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][3] = Data; + if (RegAddr == rTxAGC_A_Mcs11_Mcs08) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][4] = Data; + if (RegAddr == rTxAGC_A_Mcs15_Mcs12) { + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][5] = Data; + if (pHalData->rf_type == RF_1T1R) + pHalData->pwrGroupCnt++; + } + if (RegAddr == rTxAGC_B_Rate18_06) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][8] = Data; + if (RegAddr == rTxAGC_B_Rate54_24) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][9] = Data; + if (RegAddr == rTxAGC_B_CCK1_55_Mcs32) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][14] = Data; + if (RegAddr == rTxAGC_B_CCK11_A_CCK2_11 && BitMask == 0x000000ff) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][15] = Data; + if (RegAddr == rTxAGC_B_Mcs03_Mcs00) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][10] = Data; + if (RegAddr == rTxAGC_B_Mcs07_Mcs04) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][11] = Data; + if (RegAddr == rTxAGC_B_Mcs11_Mcs08) + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][12] = Data; + if (RegAddr == rTxAGC_B_Mcs15_Mcs12) { + pHalData->MCSTxPowerLevelOriginalOffset[pHalData->pwrGroupCnt][13] = Data; + if (pHalData->rf_type != RF_1T1R) + pHalData->pwrGroupCnt++; + } +} + +static int phy_BB8188E_Config_ParaFile(struct adapter *Adapter) +{ + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(Adapter); + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + int rtStatus = _SUCCESS; + + /* */ + /* 1. Read PHY_REG.TXT BB INIT!! */ + /* We will separate as 88C / 92C according to chip version */ + /* */ + if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG)) + rtStatus = _FAIL; + if (rtStatus != _SUCCESS) + goto phy_BB8190_Config_ParaFile_Fail; + + /* 2. If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ + if (!pEEPROM->bautoload_fail_flag) { + pHalData->pwrGroupCnt = 0; + + if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_PHY_REG_PG)) + rtStatus = _FAIL; + } + + if (rtStatus != _SUCCESS) + goto phy_BB8190_Config_ParaFile_Fail; + + /* 3. BB AGC table Initialization */ + if (HAL_STATUS_FAILURE == ODM_ConfigBBWithHeaderFile(&pHalData->odmpriv, CONFIG_BB_AGC_TAB)) + rtStatus = _FAIL; + + if (rtStatus != _SUCCESS) + goto phy_BB8190_Config_ParaFile_Fail; + +phy_BB8190_Config_ParaFile_Fail: + + return rtStatus; +} + +int +PHY_BBConfig8188E( + struct adapter *Adapter + ) +{ + int rtStatus = _SUCCESS; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 RegVal; + u8 CrystalCap; + + phy_InitBBRFRegisterDefinition(Adapter); + + /* Enable BB and RF */ + RegVal = rtw_read16(Adapter, REG_SYS_FUNC_EN); + rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal|BIT13|BIT0|BIT1)); + + /* 20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */ + + rtw_write8(Adapter, REG_RF_CTRL, RF_EN|RF_RSTB|RF_SDMRSTB); + + rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); + + /* Config BB and AGC */ + rtStatus = phy_BB8188E_Config_ParaFile(Adapter); + + /* write 0x24[16:11] = 0x24[22:17] = CrystalCap */ + CrystalCap = pHalData->CrystalCap & 0x3F; + PHY_SetBBReg(Adapter, REG_AFE_XTAL_CTRL, 0x7ff800, (CrystalCap | (CrystalCap << 6))); + + return rtStatus; +} + +int PHY_RFConfig8188E(struct adapter *Adapter) +{ + int rtStatus = _SUCCESS; + + /* RF config */ + rtStatus = PHY_RF6052_Config8188E(Adapter); + return rtStatus; +} + +/*----------------------------------------------------------------------------- + * Function: PHY_ConfigRFWithParaFile() + * + * Overview: This function read RF parameters from general file format, and do RF 3-wire + * + * Input: struct adapter *Adapter + * ps8 pFileName + * enum rf_radio_path eRFPath + * + * Output: NONE + * + * Return: RT_STATUS_SUCCESS: configuration file exist + * + * Note: Delay may be required for RF configuration + *---------------------------------------------------------------------------*/ +int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *Adapter, u8 *pFileName, enum rf_radio_path eRFPath) +{ + return _SUCCESS; +} + +void +rtl8192c_PHY_GetHWRegOriginalValue( + struct adapter *Adapter + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + /* read rx initial gain */ + pHalData->DefaultInitialGain[0] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XAAGCCore1, bMaskByte0); + pHalData->DefaultInitialGain[1] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XBAGCCore1, bMaskByte0); + pHalData->DefaultInitialGain[2] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XCAGCCore1, bMaskByte0); + pHalData->DefaultInitialGain[3] = (u8)PHY_QueryBBReg(Adapter, rOFDM0_XDAGCCore1, bMaskByte0); + + /* read framesync */ + pHalData->framesync = (u8)PHY_QueryBBReg(Adapter, rOFDM0_RxDetector3, bMaskByte0); + pHalData->framesyncC34 = PHY_QueryBBReg(Adapter, rOFDM0_RxDetector2, bMaskDWord); +} + +/* */ +/* Description: */ +/* Map dBm into Tx power index according to */ +/* current HW model, for example, RF and PA, and */ +/* current wireless mode. */ +/* By Bruce, 2008-01-29. */ +/* */ +static u8 phy_DbmToTxPwrIdx(struct adapter *Adapter, enum wireless_mode WirelessMode, int PowerInDbm) +{ + u8 TxPwrIdx = 0; + int Offset = 0; + + /* */ + /* Tested by MP, we found that CCK Index 0 equals to 8dbm, OFDM legacy equals to */ + /* 3dbm, and OFDM HT equals to 0dbm respectively. */ + /* Note: */ + /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ + /* By Bruce, 2008-01-29. */ + /* */ + switch (WirelessMode) { + case WIRELESS_MODE_B: + Offset = -7; + break; + + case WIRELESS_MODE_G: + case WIRELESS_MODE_N_24G: + default: + Offset = -8; + break; + } + + if ((PowerInDbm - Offset) > 0) + TxPwrIdx = (u8)((PowerInDbm - Offset) * 2); + else + TxPwrIdx = 0; + + /* Tx Power Index is too large. */ + if (TxPwrIdx > MAX_TXPWR_IDX_NMODE_92S) + TxPwrIdx = MAX_TXPWR_IDX_NMODE_92S; + + return TxPwrIdx; +} + +/* */ +/* Description: */ +/* Map Tx power index into dBm according to */ +/* current HW model, for example, RF and PA, and */ +/* current wireless mode. */ +/* By Bruce, 2008-01-29. */ +/* */ +static int phy_TxPwrIdxToDbm(struct adapter *Adapter, enum wireless_mode WirelessMode, u8 TxPwrIdx) +{ + int Offset = 0; + int PwrOutDbm = 0; + + /* */ + /* Tested by MP, we found that CCK Index 0 equals to -7dbm, OFDM legacy equals to -8dbm. */ + /* Note: */ + /* The mapping may be different by different NICs. Do not use this formula for what needs accurate result. */ + /* By Bruce, 2008-01-29. */ + /* */ + switch (WirelessMode) { + case WIRELESS_MODE_B: + Offset = -7; + break; + case WIRELESS_MODE_G: + case WIRELESS_MODE_N_24G: + default: + Offset = -8; + break; + } + + PwrOutDbm = TxPwrIdx / 2 + Offset; /* Discard the decimal part. */ + + return PwrOutDbm; +} + +/*----------------------------------------------------------------------------- + * Function: GetTxPowerLevel8190() + * + * Overview: This function is export to "common" moudule + * + * Input: struct adapter *Adapter + * psByte Power Level + * + * Output: NONE + * + * Return: NONE + * + *---------------------------------------------------------------------------*/ +void PHY_GetTxPowerLevel8188E(struct adapter *Adapter, u32 *powerlevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 TxPwrLevel = 0; + int TxPwrDbm; + + /* */ + /* Because the Tx power indexes are different, we report the maximum of them to */ + /* meet the CCX TPC request. By Bruce, 2008-01-31. */ + /* */ + + /* CCK */ + TxPwrLevel = pHalData->CurrentCckTxPwrIdx; + TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_B, TxPwrLevel); + + /* Legacy OFDM */ + TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx + pHalData->LegacyHTTxPowerDiff; + + /* Compare with Legacy OFDM Tx power. */ + if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel) > TxPwrDbm) + TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_G, TxPwrLevel); + + /* HT OFDM */ + TxPwrLevel = pHalData->CurrentOfdm24GTxPwrIdx; + + /* Compare with HT OFDM Tx power. */ + if (phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel) > TxPwrDbm) + TxPwrDbm = phy_TxPwrIdxToDbm(Adapter, WIRELESS_MODE_N_24G, TxPwrLevel); + + *powerlevel = TxPwrDbm; +} + +static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, + u8 *ofdmPowerLevel, u8 *BW20PowerLevel, + u8 *BW40PowerLevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 index = (channel - 1); + u8 TxCount = 0, path_nums; + + if ((RF_1T2R == pHalData->rf_type) || (RF_1T1R == pHalData->rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (TxCount = 0; TxCount < path_nums; TxCount++) { + if (TxCount == RF_PATH_A) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->OFDM_24G_Diff[TxCount][RF_PATH_A]; + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]; + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_B) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_C) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } else if (TxCount == RF_PATH_D) { + /* 1. CCK */ + cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; + /* 2. OFDM */ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[RF_PATH_C][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + + /* 1. BW20 */ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + pHalData->BW20_24G_Diff[RF_PATH_C][index]+ + pHalData->BW20_24G_Diff[TxCount][index]; + + /* 2. BW40 */ + BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; + } + } +} + +static void phy_PowerIndexCheck88E(struct adapter *Adapter, u8 channel, u8 *cckPowerLevel, + u8 *ofdmPowerLevel, u8 *BW20PowerLevel, u8 *BW40PowerLevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + pHalData->CurrentCckTxPwrIdx = cckPowerLevel[0]; + pHalData->CurrentOfdm24GTxPwrIdx = ofdmPowerLevel[0]; + pHalData->CurrentBW2024GTxPwrIdx = BW20PowerLevel[0]; + pHalData->CurrentBW4024GTxPwrIdx = BW40PowerLevel[0]; +} + +/*----------------------------------------------------------------------------- + * Function: SetTxPowerLevel8190() + * + * Overview: This function is export to "HalCommon" moudule + * We must consider RF path later!!!!!!! + * + * Input: struct adapter *Adapter + * u8 channel + * + * Output: NONE + * + * Return: NONE + * 2008/11/04 MHC We remove EEPROM_93C56. + * We need to move CCX relative code to independet file. + * 2009/01/21 MHC Support new EEPROM format from SD3 requirement. + * + *---------------------------------------------------------------------------*/ +void +PHY_SetTxPowerLevel8188E( + struct adapter *Adapter, + u8 channel + ) +{ + u8 cckPowerLevel[MAX_TX_COUNT] = {0}; + u8 ofdmPowerLevel[MAX_TX_COUNT] = {0};/* [0]:RF-A, [1]:RF-B */ + u8 BW20PowerLevel[MAX_TX_COUNT] = {0}; + u8 BW40PowerLevel[MAX_TX_COUNT] = {0}; + + getTxPowerIndex88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]); + + phy_PowerIndexCheck88E(Adapter, channel, &cckPowerLevel[0], &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0]); + + rtl8188e_PHY_RF6052SetCckTxPower(Adapter, &cckPowerLevel[0]); + rtl8188e_PHY_RF6052SetOFDMTxPower(Adapter, &ofdmPowerLevel[0], &BW20PowerLevel[0], &BW40PowerLevel[0], channel); +} + +/* */ +/* Description: */ +/* Update transmit power level of all channel supported. */ +/* */ +/* TODO: */ +/* A mode. */ +/* By Bruce, 2008-02-04. */ +/* */ +bool +PHY_UpdateTxPowerDbm8188E( + struct adapter *Adapter, + int powerInDbm + ) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 idx; + u8 rf_path; + + /* TODO: A mode Tx power. */ + u8 CckTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_B, powerInDbm); + u8 OfdmTxPwrIdx = phy_DbmToTxPwrIdx(Adapter, WIRELESS_MODE_N_24G, powerInDbm); + + if (OfdmTxPwrIdx - pHalData->LegacyHTTxPowerDiff > 0) + OfdmTxPwrIdx -= pHalData->LegacyHTTxPowerDiff; + else + OfdmTxPwrIdx = 0; + + for (idx = 0; idx < 14; idx++) { + for (rf_path = 0; rf_path < 2; rf_path++) { + pHalData->TxPwrLevelCck[rf_path][idx] = CckTxPwrIdx; + pHalData->TxPwrLevelHT40_1S[rf_path][idx] = + pHalData->TxPwrLevelHT40_2S[rf_path][idx] = OfdmTxPwrIdx; + } + } + return true; +} + +void +PHY_ScanOperationBackup8188E( + struct adapter *Adapter, + u8 Operation + ) +{ +} + +/*----------------------------------------------------------------------------- + * Function: PHY_SetBWModeCallback8192C() + * + * Overview: Timer callback function for SetSetBWMode + * + * Input: PRT_TIMER pTimer + * + * Output: NONE + * + * Return: NONE + * + * Note: (1) We do not take j mode into consideration now + * (2) Will two workitem of "switch channel" and "switch channel bandwidth" run + * concurrently? + *---------------------------------------------------------------------------*/ +static void +_PHY_SetBWMode92C( + struct adapter *Adapter +) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 regBwOpMode; + u8 regRRSR_RSC; + + if (pHalData->rf_chip == RF_PSEUDO_11N) + return; + + /* There is no 40MHz mode in RF_8225. */ + if (pHalData->rf_chip == RF_8225) + return; + + if (Adapter->bDriverStopped) + return; + + /* 3 */ + /* 3<1>Set MAC register */ + /* 3 */ + + regBwOpMode = rtw_read8(Adapter, REG_BWOPMODE); + regRRSR_RSC = rtw_read8(Adapter, REG_RRSR+2); + + switch (pHalData->CurrentChannelBW) { + case HT_CHANNEL_WIDTH_20: + regBwOpMode |= BW_OPMODE_20MHZ; + /* 2007/02/07 Mark by Emily because we have not verify whether this register works */ + rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); + break; + case HT_CHANNEL_WIDTH_40: + regBwOpMode &= ~BW_OPMODE_20MHZ; + /* 2007/02/07 Mark by Emily because we have not verify whether this register works */ + rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); + regRRSR_RSC = (regRRSR_RSC&0x90) | (pHalData->nCur40MhzPrimeSC<<5); + rtw_write8(Adapter, REG_RRSR+2, regRRSR_RSC); + break; + default: + break; + } + + /* 3 */ + /* 3 <2>Set PHY related register */ + /* 3 */ + switch (pHalData->CurrentChannelBW) { + /* 20 MHz channel*/ + case HT_CHANNEL_WIDTH_20: + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x0); + PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x0); + break; + /* 40 MHz channel*/ + case HT_CHANNEL_WIDTH_40: + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); + PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); + /* Set Control channel to upper or lower. These settings are required only for 40MHz */ + PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); + PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); + PHY_SetBBReg(Adapter, 0x818, (BIT26 | BIT27), + (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); + break; + default: + break; + } + /* Skip over setting of J-mode in BB register here. Default value is "None J mode". Emily 20070315 */ + + /* 3<3>Set RF related register */ + switch (pHalData->rf_chip) { + case RF_8225: + break; + case RF_8256: + /* Please implement this function in Hal8190PciPhy8256.c */ + break; + case RF_8258: + /* Please implement this function in Hal8190PciPhy8258.c */ + break; + case RF_PSEUDO_11N: + break; + case RF_6052: + rtl8188e_PHY_RF6052SetBandwidth(Adapter, pHalData->CurrentChannelBW); + break; + default: + break; + } +} + + /*----------------------------------------------------------------------------- + * Function: SetBWMode8190Pci() + * + * Overview: This function is export to "HalCommon" moudule + * + * Input: struct adapter *Adapter + * enum ht_channel_width Bandwidth 20M or 40M + * + * Output: NONE + * + * Return: NONE + * + * Note: We do not take j mode into consideration now + *---------------------------------------------------------------------------*/ +void PHY_SetBWMode8188E(struct adapter *Adapter, enum ht_channel_width Bandwidth, /* 20M or 40M */ + unsigned char Offset) /* Upper, Lower, or Don't care */ +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + enum ht_channel_width tmpBW = pHalData->CurrentChannelBW; + + pHalData->CurrentChannelBW = Bandwidth; + + pHalData->nCur40MhzPrimeSC = Offset; + + if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) + _PHY_SetBWMode92C(Adapter); + else + pHalData->CurrentChannelBW = tmpBW; +} + +static void _PHY_SwChnl8192C(struct adapter *Adapter, u8 channel) +{ + u8 eRFPath; + u32 param1, param2; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + if (Adapter->bNotifyChannelChange) + DBG_88E("[%s] ch = %d\n", __func__, channel); + + /* s1. pre common command - CmdID_SetTxPowerLevel */ + PHY_SetTxPowerLevel8188E(Adapter, channel); + + /* s2. RF dependent command - CmdID_RF_WriteReg, param1=RF_CHNLBW, param2=channel */ + param1 = RF_CHNLBW; + param2 = channel; + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { + pHalData->RfRegChnlVal[eRFPath] = ((pHalData->RfRegChnlVal[eRFPath] & 0xfffffc00) | param2); + PHY_SetRFReg(Adapter, (enum rf_radio_path)eRFPath, param1, bRFRegOffsetMask, pHalData->RfRegChnlVal[eRFPath]); + } +} + +void PHY_SwChnl8188E(struct adapter *Adapter, u8 channel) +{ + /* Call after initialization */ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u8 tmpchannel = pHalData->CurrentChannel; + bool bResult = true; + + if (pHalData->rf_chip == RF_PSEUDO_11N) + return; /* return immediately if it is peudo-phy */ + + if (channel == 0) + channel = 1; + + pHalData->CurrentChannel = channel; + + if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) { + _PHY_SwChnl8192C(Adapter, channel); + + if (bResult) + ; + else + pHalData->CurrentChannel = tmpchannel; + + } else { + pHalData->CurrentChannel = tmpchannel; + } +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c new file mode 100644 index 000000000000..0ed6ff67ad57 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -0,0 +1,569 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/****************************************************************************** + * + * + * Module: rtl8192c_rf6052.c ( Source C File) + * + * Note: Provide RF 6052 series relative API. + * + * Function: + * + * Export: + * + * Abbrev: + * + * History: + * Data Who Remark + * + * 09/25/2008 MHC Create initial version. + * 11/05/2008 MHC Add API for tw power setting. + * + * +******************************************************************************/ + +#define _RTL8188E_RF6052_C_ + +#include +#include + +#include + +/*---------------------------Define Local Constant---------------------------*/ +/* Define local structure for debug!!!!! */ +struct rf_shadow { + /* Shadow register value */ + u32 Value; + /* Compare or not flag */ + u8 Compare; + /* Record If it had ever modified unpredicted */ + u8 ErrorOrNot; + /* Recorver Flag */ + u8 Recorver; + /* */ + u8 Driver_Write; +}; + +/*---------------------------Define Local Constant---------------------------*/ + +/*------------------------Define global variable-----------------------------*/ + +/*------------------------Define local variable------------------------------*/ + +/*----------------------------------------------------------------------------- + * Function: RF_ChangeTxPath + * + * Overview: For RL6052, we must change some RF settign for 1T or 2T. + * + * Input: u16 DataRate 0x80-8f, 0x90-9f + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 09/25/2008 MHC Create Version 0. + * Firmwaer support the utility later. + * + *---------------------------------------------------------------------------*/ +void rtl8188e_RF_ChangeTxPath(struct adapter *Adapter, u16 DataRate) +{ +/* We do not support gain table change inACUT now !!!! Delete later !!! */ +} /* RF_ChangeTxPath */ + +/*----------------------------------------------------------------------------- + * Function: PHY_RF6052SetBandwidth() + * + * Overview: This function is called by SetBWModeCallback8190Pci() only + * + * Input: struct adapter *Adapter + * WIRELESS_BANDWIDTH_E Bandwidth 20M or 40M + * + * Output: NONE + * + * Return: NONE + * + * Note: For RF type 0222D + *---------------------------------------------------------------------------*/ +void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter, + enum ht_channel_width Bandwidth) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + + switch (Bandwidth) { + case HT_CHANNEL_WIDTH_20: + pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT(10) | BIT(11)); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + break; + case HT_CHANNEL_WIDTH_40: + pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT(10)); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + break; + default: + break; + } +} + +/*----------------------------------------------------------------------------- + * Function: PHY_RF6052SetCckTxPower + * + * Overview: + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/05/2008 MHC Simulate 8192series.. + * + *---------------------------------------------------------------------------*/ + +void +rtl8188e_PHY_RF6052SetCckTxPower( + struct adapter *Adapter, + u8 *pPowerlevel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + u32 TxAGC[2] = {0, 0}, tmpval = 0, pwrtrac_value; + bool TurboScanOff = false; + u8 idx1, idx2; + u8 *ptr; + u8 direction; + /* FOR CE ,must disable turbo scan */ + TurboScanOff = true; + + if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { + TxAGC[RF_PATH_A] = 0x3f3f3f3f; + TxAGC[RF_PATH_B] = 0x3f3f3f3f; + + TurboScanOff = true;/* disable turbo scan */ + + if (TurboScanOff) { + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + TxAGC[idx1] = + pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | + (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + /* 2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */ + if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA) + TxAGC[idx1] = 0x20; + } + } + } else { + /* Driver dynamic Tx power shall not affect Tx power. + * It shall be determined by power training mechanism. +i * Currently, we cannot fully disable driver dynamic + * tx power mechanism because it is referenced by BT + * coexist mechanism. + * In the future, two mechanism shall be separated from + * each other and maintained independently. */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { + TxAGC[RF_PATH_A] = 0x10101010; + TxAGC[RF_PATH_B] = 0x10101010; + } else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) { + TxAGC[RF_PATH_A] = 0x00000000; + TxAGC[RF_PATH_B] = 0x00000000; + } else { + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + TxAGC[idx1] = + pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | + (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + } + if (pHalData->EEPROMRegulatory == 0) { + tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) + + (pHalData->MCSTxPowerLevelOriginalOffset[0][7]<<8); + TxAGC[RF_PATH_A] += tmpval; + + tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) + + (pHalData->MCSTxPowerLevelOriginalOffset[0][15]<<24); + TxAGC[RF_PATH_B] += tmpval; + } + } + } + for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { + ptr = (u8 *)(&(TxAGC[idx1])); + for (idx2 = 0; idx2 < 4; idx2++) { + if (*ptr > RF6052_MAX_TX_PWR) + *ptr = RF6052_MAX_TX_PWR; + ptr++; + } + } + ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 1, &direction, &pwrtrac_value); + + if (direction == 1) { + /* Increase TX power */ + TxAGC[0] += pwrtrac_value; + TxAGC[1] += pwrtrac_value; + } else if (direction == 2) { + /* Decrease TX power */ + TxAGC[0] -= pwrtrac_value; + TxAGC[1] -= pwrtrac_value; + } + + /* rf-A cck tx power */ + tmpval = TxAGC[RF_PATH_A]&0xff; + PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); + tmpval = TxAGC[RF_PATH_A]>>8; + PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); + + /* rf-B cck tx power */ + tmpval = TxAGC[RF_PATH_B]>>24; + PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); + tmpval = TxAGC[RF_PATH_B]&0x00ffffff; + PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); +} /* PHY_RF6052SetCckTxPower */ + +/* */ +/* powerbase0 for OFDM rates */ +/* powerbase1 for HT MCS rates */ +/* */ +static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM, + u8 *pPowerLevelBW20, u8 *pPowerLevelBW40, u8 Channel, u32 *OfdmBase, u32 *MCSBase) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 powerBase0, powerBase1; + u8 i, powerlevel[2]; + + for (i = 0; i < 2; i++) { + powerBase0 = pPowerLevelOFDM[i]; + + powerBase0 = (powerBase0<<24) | (powerBase0<<16) | (powerBase0<<8) | powerBase0; + *(OfdmBase+i) = powerBase0; + } + for (i = 0; i < pHalData->NumTotalRFPath; i++) { + /* Check HT20 to HT40 diff */ + if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + powerlevel[i] = pPowerLevelBW20[i]; + else + powerlevel[i] = pPowerLevelBW40[i]; + powerBase1 = powerlevel[i]; + powerBase1 = (powerBase1<<24) | (powerBase1<<16) | (powerBase1<<8) | powerBase1; + *(MCSBase+i) = powerBase1; + } +} +static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, + u8 index, u32 *powerBase0, u32 *powerBase1, + u32 *pOutWriteVal) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &pHalData->dmpriv; + u8 i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit; + s8 pwr_diff = 0; + u32 writeVal, customer_limit, rf; + u8 Regulatory = pHalData->EEPROMRegulatory; + + /* Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */ + + for (rf = 0; rf < 2; rf++) { + switch (Regulatory) { + case 0: /* Realtek better performance */ + /* increase power diff defined by Realtek for large power */ + chnlGroup = 0; + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + case 1: /* Realtek regulatory */ + /* increase power diff defined by Realtek for regulatory */ + if (pHalData->pwrGroupCnt == 1) + chnlGroup = 0; + if (pHalData->pwrGroupCnt >= pHalData->PGMaxGroup) { + if (Channel < 3) /* Channel 1-2 */ + chnlGroup = 0; + else if (Channel < 6) /* Channel 3-5 */ + chnlGroup = 1; + else if (Channel < 9) /* Channel 6-8 */ + chnlGroup = 2; + else if (Channel < 12) /* Channel 9-11 */ + chnlGroup = 3; + else if (Channel < 14) /* Channel 12-13 */ + chnlGroup = 4; + else if (Channel == 14) /* Channel 14 */ + chnlGroup = 5; + } + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + case 2: /* Better regulatory */ + /* don't increase any power diff */ + writeVal = ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + case 3: /* Customer defined power diff. */ + /* increase power diff defined by customer. */ + chnlGroup = 0; + + if (index < 2) + pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel-1]; + else if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) + pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel-1]; + + if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40) + customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel-1]; + else + customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel-1]; + + if (pwr_diff >= customer_pwr_limit) + pwr_diff = 0; + else + pwr_diff = customer_pwr_limit - pwr_diff; + + for (i = 0; i < 4; i++) { + pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)]&(0x7f<<(i*8)))>>(i*8)); + + if (pwr_diff_limit[i] > pwr_diff) + pwr_diff_limit[i] = pwr_diff; + } + customer_limit = (pwr_diff_limit[3]<<24) | (pwr_diff_limit[2]<<16) | + (pwr_diff_limit[1]<<8) | (pwr_diff_limit[0]); + writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + default: + chnlGroup = 0; + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); + break; + } +/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ +/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ +/* In the future, two mechanism shall be separated from each other and maintained independently. Thanks for Lanhsin's reminder. */ + /* 92d do not need this */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) + writeVal = 0x14141414; + else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) + writeVal = 0x00000000; + + /* 20100628 Joseph: High power mode for BT-Coexist mechanism. */ + /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */ + if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1) + writeVal = writeVal - 0x06060606; + else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2) + writeVal = writeVal; + *(pOutWriteVal+rf) = writeVal; + } +} +static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u16 regoffset_a[6] = { + rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24, + rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04, + rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12}; + u16 regoffset_b[6] = { + rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24, + rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04, + rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12}; + u8 i, rf, pwr_val[4]; + u32 writeVal; + u16 regoffset; + + for (rf = 0; rf < 2; rf++) { + writeVal = pValue[rf]; + for (i = 0; i < 4; i++) { + pwr_val[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8)); + if (pwr_val[i] > RF6052_MAX_TX_PWR) + pwr_val[i] = RF6052_MAX_TX_PWR; + } + writeVal = (pwr_val[3]<<24) | (pwr_val[2]<<16) | (pwr_val[1]<<8) | pwr_val[0]; + + if (rf == 0) + regoffset = regoffset_a[index]; + else + regoffset = regoffset_b[index]; + + PHY_SetBBReg(Adapter, regoffset, bMaskDWord, writeVal); + + /* 201005115 Joseph: Set Tx Power diff for Tx power training mechanism. */ + if (((pHalData->rf_type == RF_2T2R) && + (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs15_Mcs12)) || + ((pHalData->rf_type != RF_2T2R) && + (regoffset == rTxAGC_A_Mcs07_Mcs04 || regoffset == rTxAGC_B_Mcs07_Mcs04))) { + writeVal = pwr_val[3]; + if (regoffset == rTxAGC_A_Mcs15_Mcs12 || regoffset == rTxAGC_A_Mcs07_Mcs04) + regoffset = 0xc90; + if (regoffset == rTxAGC_B_Mcs15_Mcs12 || regoffset == rTxAGC_B_Mcs07_Mcs04) + regoffset = 0xc98; + for (i = 0; i < 3; i++) { + if (i != 2) + writeVal = (writeVal > 8) ? (writeVal-8) : 0; + else + writeVal = (writeVal > 6) ? (writeVal-6) : 0; + rtw_write8(Adapter, (u32)(regoffset+i), (u8)writeVal); + } + } + } +} + +/*----------------------------------------------------------------------------- + * Function: PHY_RF6052SetOFDMTxPower + * + * Overview: For legacy and HY OFDM, we must read EEPROM TX power index for + * different channel and read original value in TX power register area from + * 0xe00. We increase offset and original value to be correct tx pwr. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 11/05/2008 MHC Simulate 8192 series method. + * 01/06/2009 MHC 1. Prevent Path B tx power overflow or underflow dure to + * A/B pwr difference or legacy/HT pwr diff. + * 2. We concern with path B legacy/HT OFDM difference. + * 01/22/2009 MHC Support new EPRO format from SD3. + * + *---------------------------------------------------------------------------*/ + +void +rtl8188e_PHY_RF6052SetOFDMTxPower( + struct adapter *Adapter, + u8 *pPowerLevelOFDM, + u8 *pPowerLevelBW20, + u8 *pPowerLevelBW40, + u8 Channel) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 writeVal[2], powerBase0[2], powerBase1[2], pwrtrac_value; + u8 direction; + u8 index = 0; + + getpowerbase88e(Adapter, pPowerLevelOFDM, pPowerLevelBW20, pPowerLevelBW40, Channel, &powerBase0[0], &powerBase1[0]); + + /* 2012/04/23 MH According to power tracking value, we need to revise OFDM tx power. */ + /* This is ued to fix unstable power tracking mode. */ + ODM_TxPwrTrackAdjust88E(&pHalData->odmpriv, 0, &direction, &pwrtrac_value); + + for (index = 0; index < 6; index++) { + get_rx_power_val_by_reg(Adapter, Channel, index, + &powerBase0[0], &powerBase1[0], + &writeVal[0]); + + if (direction == 1) { + writeVal[0] += pwrtrac_value; + writeVal[1] += pwrtrac_value; + } else if (direction == 2) { + writeVal[0] -= pwrtrac_value; + writeVal[1] -= pwrtrac_value; + } + writeOFDMPowerReg88E(Adapter, index, &writeVal[0]); + } +} + +static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) +{ + struct bb_reg_def *pPhyReg; + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + u32 u4RegValue = 0; + u8 eRFPath; + int rtStatus = _SUCCESS; + + /* 3----------------------------------------------------------------- */ + /* 3 <2> Initialize RF */ + /* 3----------------------------------------------------------------- */ + for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) { + pPhyReg = &pHalData->PHYRegDef[eRFPath]; + + /*----Store original RFENV control type----*/ + switch (eRFPath) { + case RF_PATH_A: + case RF_PATH_C: + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); + break; + case RF_PATH_B: + case RF_PATH_D: + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); + break; + } + /*----Set RF_ENV enable----*/ + PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + /*----Set RF_ENV output high----*/ + PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + /* Set bit number of Address and Data for RF register */ + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ + rtw_udelay_os(1);/* PlatformStallExecution(1); */ + + /*----Initialize RF fom connfiguration file----*/ + switch (eRFPath) { + case RF_PATH_A: + if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum rf_radio_path)eRFPath, (enum rf_radio_path)eRFPath)) + rtStatus = _FAIL; + break; + case RF_PATH_B: + if (HAL_STATUS_FAILURE == ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, (enum rf_radio_path)eRFPath, (enum rf_radio_path)eRFPath)) + rtStatus = _FAIL; + break; + case RF_PATH_C: + break; + case RF_PATH_D: + break; + } + /*----Restore RFENV control type----*/; + switch (eRFPath) { + case RF_PATH_A: + case RF_PATH_C: + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); + break; + case RF_PATH_B: + case RF_PATH_D: + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + break; + } + if (rtStatus != _SUCCESS) + goto phy_RF6052_Config_ParaFile_Fail; + } + return rtStatus; + +phy_RF6052_Config_ParaFile_Fail: + return rtStatus; +} + +int PHY_RF6052_Config8188E(struct adapter *Adapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); + int rtStatus = _SUCCESS; + + /* */ + /* Initialize general global value */ + /* */ + /* TODO: Extend RF_PATH_C and RF_PATH_D in the future */ + if (pHalData->rf_type == RF_1T1R) + pHalData->NumTotalRFPath = 1; + else + pHalData->NumTotalRFPath = 2; + + /* */ + /* Config BB and RF */ + /* */ + rtStatus = phy_RF6052_Config_ParaFile(Adapter); + return rtStatus; +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c new file mode 100644 index 000000000000..a07ad95ad84b --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -0,0 +1,202 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_REDESC_C_ + +#include +#include +#include + +static void process_rssi(struct adapter *padapter, struct recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib = &prframe->attrib; + struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; + + if (signal_stat->update_req) { + signal_stat->total_num = 0; + signal_stat->total_val = 0; + signal_stat->update_req = 0; + } + + signal_stat->total_num++; + signal_stat->total_val += pattrib->phy_info.SignalStrength; + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; +} /* Process_UI_RSSI_8192C */ + +static void process_link_qual(struct adapter *padapter, struct recv_frame *prframe) +{ + struct rx_pkt_attrib *pattrib; + struct signal_stat *signal_stat; + + if (prframe == NULL || padapter == NULL) + return; + + pattrib = &prframe->attrib; + signal_stat = &padapter->recvpriv.signal_qual_data; + + if (signal_stat->update_req) { + signal_stat->total_num = 0; + signal_stat->total_val = 0; + signal_stat->update_req = 0; + } + + signal_stat->total_num++; + signal_stat->total_val += pattrib->phy_info.SignalQuality; + signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; +} + +void rtl8188e_process_phy_info(struct adapter *padapter, void *prframe) +{ + struct recv_frame *precvframe = (struct recv_frame *)prframe; + + /* Check RSSI */ + process_rssi(padapter, precvframe); + /* Check EVM */ + process_link_qual(padapter, precvframe); +} + +void update_recvframe_attrib_88e(struct recv_frame *precvframe, struct recv_stat *prxstat) +{ + struct rx_pkt_attrib *pattrib; + struct recv_stat report; + + report.rxdw0 = prxstat->rxdw0; + report.rxdw1 = prxstat->rxdw1; + report.rxdw2 = prxstat->rxdw2; + report.rxdw3 = prxstat->rxdw3; + report.rxdw4 = prxstat->rxdw4; + report.rxdw5 = prxstat->rxdw5; + + pattrib = &precvframe->attrib; + memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); + + pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);;/* u8)prxreport->crc32; */ + + /* update rx report to recv_frame attribute */ + pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */ + + if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ + pattrib->drvinfo_sz = (u8)((le32_to_cpu(report.rxdw0) >> 16) & 0xf) * 8;/* u8)(prxreport->drvinfosize << 3); */ + + pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);/* u8)prxreport->physt; */ + + pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;/* u8)(prxreport->swdec ? 0 : 1); */ + pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);/* u8)prxreport->security; */ + + pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);/* u8)prxreport->qos; */ + pattrib->priority = (u8)((le32_to_cpu(report.rxdw1) >> 8) & 0xf);/* u8)prxreport->tid; */ + + pattrib->amsdu = (u8)((le32_to_cpu(report.rxdw1) >> 13) & 0x1);/* u8)prxreport->amsdu; */ + + pattrib->seq_num = (u16)(le32_to_cpu(report.rxdw2) & 0x00000fff);/* u16)prxreport->seq; */ + pattrib->frag_num = (u8)((le32_to_cpu(report.rxdw2) >> 12) & 0xf);/* u8)prxreport->frag; */ + pattrib->mfrag = (u8)((le32_to_cpu(report.rxdw1) >> 27) & 0x1);/* u8)prxreport->mf; */ + pattrib->mdata = (u8)((le32_to_cpu(report.rxdw1) >> 26) & 0x1);/* u8)prxreport->md; */ + + pattrib->mcs_rate = (u8)(le32_to_cpu(report.rxdw3) & 0x3f);/* u8)prxreport->rxmcs; */ + pattrib->rxht = (u8)((le32_to_cpu(report.rxdw3) >> 6) & 0x1);/* u8)prxreport->rxht; */ + + pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);/* u8)prxreport->icverr; */ + pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3); + } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */ + pattrib->pkt_len = TX_RPT1_PKT_LEN; + pattrib->drvinfo_sz = 0; + } else if (pattrib->pkt_rpt_type == TX_REPORT2) { /* TX RPT */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */ + pattrib->drvinfo_sz = 0; + + /* */ + /* Get TX report MAC ID valid. */ + /* */ + pattrib->MacIDValidEntry[0] = le32_to_cpu(report.rxdw4); + pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5); + + } else if (pattrib->pkt_rpt_type == HIS_REPORT) { /* USB HISR RPT */ + pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ + } +} + +/* + * Notice: + * Before calling this function, + * precvframe->rx_data should be ready! + */ +void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat *pphy_status) +{ + struct adapter *padapter = precvframe->adapter; + struct rx_pkt_attrib *pattrib = &precvframe->attrib; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); + u8 *wlanhdr; + struct odm_per_pkt_info pkt_info; + u8 *sa = NULL; + struct sta_priv *pstapriv; + struct sta_info *psta; + + pkt_info.bPacketMatchBSSID = false; + pkt_info.bPacketToSelf = false; + pkt_info.bPacketBeacon = false; + + wlanhdr = get_recvframe_data(precvframe); + + pkt_info.bPacketMatchBSSID = ((!IsFrameTypeCtrl(wlanhdr)) && + !pattrib->icv_err && !pattrib->crc_err && + !memcmp(get_hdr_bssid(wlanhdr), + get_bssid(&padapter->mlmepriv), ETH_ALEN)); + + pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && + (!memcmp(get_da(wlanhdr), + myid(&padapter->eeprompriv), ETH_ALEN)); + + pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && + (GetFrameSubType(wlanhdr) == WIFI_BEACON); + + if (pkt_info.bPacketBeacon) { + if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) + sa = padapter->mlmepriv.cur_network.network.MacAddress; + /* to do Ad-hoc */ + } else { + sa = get_sa(wlanhdr); + } + + pstapriv = &padapter->stapriv; + pkt_info.StationID = 0xFF; + psta = rtw_get_stainfo(pstapriv, sa); + if (psta) + pkt_info.StationID = psta->mac_id; + pkt_info.Rate = pattrib->mcs_rate; + + ODM_PhyStatusQuery(&pHalData->odmpriv, pPHYInfo, (u8 *)pphy_status, &(pkt_info), padapter); + + precvframe->psta = NULL; + if (pkt_info.bPacketMatchBSSID && + (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { + if (psta) { + precvframe->psta = psta; + rtl8188e_process_phy_info(padapter, precvframe); + } + } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (psta) + precvframe->psta = psta; + } + rtl8188e_process_phy_info(padapter, precvframe); + } +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_sreset.c b/drivers/staging/r8188eu/hal/rtl8188e_sreset.c new file mode 100644 index 000000000000..047b53482e67 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_sreset.c @@ -0,0 +1,80 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_SRESET_C_ + +#include +#include + +void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter) +{ +} + +void rtl8188e_sreset_xmit_status_check(struct adapter *padapter) +{ + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + struct sreset_priv *psrtpriv = &pHalData->srestpriv; + + unsigned long current_time; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + unsigned int diff_time; + u32 txdma_status; + + txdma_status = rtw_read32(padapter, REG_TXDMA_STATUS); + if (txdma_status != 0x00) { + DBG_88E("%s REG_TXDMA_STATUS:0x%08x\n", __func__, txdma_status); + rtw_write32(padapter, REG_TXDMA_STATUS, txdma_status); + rtl8188e_silentreset_for_specific_platform(padapter); + } + /* total xmit irp = 4 */ + current_time = jiffies; + if (0 == pxmitpriv->free_xmitbuf_cnt) { + diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_time); + + if (diff_time > 2000) { + if (psrtpriv->last_tx_complete_time == 0) { + psrtpriv->last_tx_complete_time = current_time; + } else { + diff_time = jiffies_to_msecs(current_time - psrtpriv->last_tx_complete_time); + if (diff_time > 4000) { + DBG_88E("%s tx hang\n", __func__); + rtl8188e_silentreset_for_specific_platform(padapter); + } + } + } + } +} + +void rtl8188e_sreset_linked_status_check(struct adapter *padapter) +{ + u32 rx_dma_status = 0; + u8 fw_status = 0; + rx_dma_status = rtw_read32(padapter, REG_RXDMA_STATUS); + if (rx_dma_status != 0x00) { + DBG_88E("%s REG_RXDMA_STATUS:0x%08x\n", __func__, rx_dma_status); + rtw_write32(padapter, REG_RXDMA_STATUS, rx_dma_status); + } + fw_status = rtw_read8(padapter, REG_FMETHR); + if (fw_status != 0x00) { + if (fw_status == 1) + DBG_88E("%s REG_FW_STATUS (0x%02x), Read_Efuse_Fail !!\n", __func__, fw_status); + else if (fw_status == 2) + DBG_88E("%s REG_FW_STATUS (0x%02x), Condition_No_Match !!\n", __func__, fw_status); + } +} diff --git a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c new file mode 100644 index 000000000000..7ecbcf731ea9 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c @@ -0,0 +1,91 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_XMIT_C_ + +#include +#include +#include + +void dump_txrpt_ccx_88e(void *buf) +{ + struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + + DBG_88E("%s:\n" + "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n" + "mac_id:%u, pkt_ok:%u, bmc:%u\n" + "retry_cnt:%u, lifetime_over:%u, retry_over:%u\n" + "ccx_qtime:%u\n" + "final_data_rate:0x%02x\n" + "qsel:%u, sw:0x%03x\n", + __func__, txrpt_ccx->tag1, txrpt_ccx->pkt_num, + txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt, + txrpt_ccx->int_tri, txrpt_ccx->int_ccx, + txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc, + txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over, + txrpt_ccx->retry_over, txrpt_ccx_qtime_88e(txrpt_ccx), + txrpt_ccx->final_data_rate, txrpt_ccx->qsel, + txrpt_ccx_sw_88e(txrpt_ccx) + ); +} + +void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) +{ + struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; + + if (txrpt_ccx->int_ccx) { + if (txrpt_ccx->pkt_ok) + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_SUCCESS); + else + rtw_ack_tx_done(&adapter->xmitpriv, + RTW_SCTX_DONE_CCX_PKT_FAIL); + } +} + +void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, + struct tx_desc *ptxdesc) +{ + u8 dmp_txpkt; + bool dump_txdesc = false; + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(dmp_txpkt)); + + if (dmp_txpkt == 1) {/* dump txdesc for data frame */ + DBG_88E("dump tx_desc for data frame\n"); + if ((frame_tag & 0x0f) == DATA_FRAMETAG) + dump_txdesc = true; + } else if (dmp_txpkt == 2) {/* dump txdesc for mgnt frame */ + DBG_88E("dump tx_desc for mgnt frame\n"); + if ((frame_tag & 0x0f) == MGNT_FRAMETAG) + dump_txdesc = true; + } + + if (dump_txdesc) { + DBG_88E("=====================================\n"); + DBG_88E("txdw0(0x%08x)\n", ptxdesc->txdw0); + DBG_88E("txdw1(0x%08x)\n", ptxdesc->txdw1); + DBG_88E("txdw2(0x%08x)\n", ptxdesc->txdw2); + DBG_88E("txdw3(0x%08x)\n", ptxdesc->txdw3); + DBG_88E("txdw4(0x%08x)\n", ptxdesc->txdw4); + DBG_88E("txdw5(0x%08x)\n", ptxdesc->txdw5); + DBG_88E("txdw6(0x%08x)\n", ptxdesc->txdw6); + DBG_88E("txdw7(0x%08x)\n", ptxdesc->txdw7); + DBG_88E("=====================================\n"); + } +} diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_led.c b/drivers/staging/r8188eu/hal/rtl8188eu_led.c new file mode 100644 index 000000000000..08dfd94163e6 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188eu_led.c @@ -0,0 +1,111 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include +#include +#include +#include + +/* LED object. */ + +/* LED_819xUsb routines. */ +/* Description: */ +/* Turn on LED according to LedPin specified. */ +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) +{ + u8 LedCfg; + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + return; + LedCfg = rtw_read8(padapter, REG_LEDCFG2); + switch (pLed->LedPin) { + case LED_PIN_LED0: + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ + break; + case LED_PIN_LED1: + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ + break; + default: + break; + } + pLed->bLedOn = true; +} + +/* Description: */ +/* Turn off LED according to LedPin specified. */ +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) +{ + u8 LedCfg; + struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped) + goto exit; + + LedCfg = rtw_read8(padapter, REG_LEDCFG2);/* 0x4E */ + + switch (pLed->LedPin) { + case LED_PIN_LED0: + if (pHalData->bLedOpenDrain) { + /* Open-drain arrangement for controlling the LED) */ + LedCfg &= 0x90; /* Set to software control. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); + LedCfg &= 0xFE; + rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); + } else { + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); + } + break; + case LED_PIN_LED1: + LedCfg &= 0x0f; /* Set to software control. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + break; + default: + break; + } +exit: + pLed->bLedOn = false; +} + +/* Interface to manipulate LED objects. */ +/* Default LED behavior. */ + +/* Description: */ +/* Initialize all LED_871x objects. */ +void rtl8188eu_InitSwLeds(struct adapter *padapter) +{ + struct led_priv *pledpriv = &(padapter->ledpriv); + + pledpriv->LedControlHandler = LedControl8188eu; + + InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); + + InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1); +} + +/* Description: */ +/* DeInitialize all LED_819xUsb objects. */ +void rtl8188eu_DeInitSwLeds(struct adapter *padapter) +{ + struct led_priv *ledpriv = &(padapter->ledpriv); + + DeInitLed871x(&(ledpriv->SwLed0)); + DeInitLed871x(&(ledpriv->SwLed1)); +} diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c new file mode 100644 index 000000000000..ab0853ceeb61 --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -0,0 +1,136 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188EU_RECV_C_ +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) +{ + precvbuf->transfer_len = 0; + + precvbuf->len = 0; + + precvbuf->ref_cnt = 0; + + if (precvbuf->pbuf) { + precvbuf->pdata = precvbuf->pbuf; + precvbuf->phead = precvbuf->pbuf; + precvbuf->ptail = precvbuf->pbuf; + precvbuf->pend = precvbuf->pdata + MAX_RECVBUF_SZ; + } +} + +int rtl8188eu_init_recv_priv(struct adapter *padapter) +{ + struct recv_priv *precvpriv = &padapter->recvpriv; + int i, res = _SUCCESS; + struct recv_buf *precvbuf; + + tasklet_init(&precvpriv->recv_tasklet, + (void(*)(unsigned long))rtl8188eu_recv_tasklet, + (unsigned long)padapter); + + /* init recv_buf */ + _rtw_init_queue(&precvpriv->free_recv_buf_queue); + + precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); + if (precvpriv->pallocated_recv_buf == NULL) { + res = _FAIL; + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); + goto exit; + } + memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF * sizeof(struct recv_buf) + 4); + + precvpriv->precv_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(precvpriv->pallocated_recv_buf), 4); + + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + + for (i = 0; i < NR_RECVBUFF; i++) { + INIT_LIST_HEAD(&precvbuf->list); + spin_lock_init(&precvbuf->recvbuf_lock); + precvbuf->alloc_sz = MAX_RECVBUF_SZ; + res = rtw_os_recvbuf_resource_alloc(padapter, precvbuf); + if (res == _FAIL) + break; + precvbuf->ref_cnt = 0; + precvbuf->adapter = padapter; + precvbuf++; + } + precvpriv->free_recv_buf_queue_cnt = NR_RECVBUFF; + skb_queue_head_init(&precvpriv->rx_skb_queue); + { + int i; + size_t tmpaddr = 0; + size_t alignment = 0; + struct sk_buff *pskb = NULL; + + skb_queue_head_init(&precvpriv->free_recv_skb_queue); + + for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { + pskb = __netdev_alloc_skb(padapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ, GFP_KERNEL); + if (pskb) { + pskb->dev = padapter->pnetdev; + tmpaddr = (size_t)pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); + + skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + } + pskb = NULL; + } + } +exit: + return res; +} + +void rtl8188eu_free_recv_priv(struct adapter *padapter) +{ + int i; + struct recv_buf *precvbuf; + struct recv_priv *precvpriv = &padapter->recvpriv; + + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + + for (i = 0; i < NR_RECVBUFF; i++) { + rtw_os_recvbuf_resource_free(padapter, precvbuf); + precvbuf++; + } + + kfree(precvpriv->pallocated_recv_buf); + + if (skb_queue_len(&precvpriv->rx_skb_queue)) + DBG_88E(KERN_WARNING "rx_skb_queue not empty\n"); + skb_queue_purge(&precvpriv->rx_skb_queue); + + if (skb_queue_len(&precvpriv->free_recv_skb_queue)) + DBG_88E(KERN_WARNING "free_recv_skb_queue not empty, %d\n", skb_queue_len(&precvpriv->free_recv_skb_queue)); + + skb_queue_purge(&precvpriv->free_recv_skb_queue); +} diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c new file mode 100644 index 000000000000..7f5d677b1d6f --- /dev/null +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -0,0 +1,703 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RTL8188E_XMIT_C_ +#include +#include +#include +#include +#include +#include + +s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) +{ + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + + tasklet_init(&pxmitpriv->xmit_tasklet, + (void(*)(unsigned long))rtl8188eu_xmit_tasklet, + (unsigned long)adapt); + return _SUCCESS; +} + +void rtl8188eu_free_xmit_priv(struct adapter *adapt) +{ +} + +static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) +{ + u8 set_tx_desc_offset; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + set_tx_desc_offset = (((sz + TXDESC_SIZE) % haldata->UsbBulkOutSize) == 0) ? 1 : 0; + + return set_tx_desc_offset; +} + +static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) +{ + u16 *usptr = (u16 *)ptxdesc; + u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ + u32 index; + u16 checksum = 0; + + /* Clear first */ + ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); + + for (index = 0; index < count; index++) + checksum = checksum ^ le16_to_cpu(*(__le16 *)(usptr + index)); + ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff & checksum); +} + +/* Description: In normal chip, we should send some packet to Hw which will be used by Fw */ +/* in FW LPS mode. The function is to fill the Tx descriptor of this packets, then */ +/* Fw can tell Hw to send these packet derectly. */ +void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8 ispspoll, u8 is_btqosnull) +{ + struct tx_desc *ptxdesc; + + /* Clear all status */ + ptxdesc = (struct tx_desc *)desc; + memset(desc, 0, TXDESC_SIZE); + + /* offset 0 */ + ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ + + ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(BufferLen&0x0000ffff); /* Buffer size + command header */ + + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32(NAVUSEHDR); + } else { + ptxdesc->txdw4 |= cpu_to_le32(BIT(7)); /* Hw set sequence number */ + ptxdesc->txdw3 |= cpu_to_le32((8 << 28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */ + } + + if (is_btqosnull) + ptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /* BT NULL */ + + /* offset 16 */ + ptxdesc->txdw4 |= cpu_to_le32(BIT(8));/* driver uses rate */ + + /* USB interface drop packet if the checksum of descriptor isn't correct. */ + /* Using this checksum can let hardware recovery from packet bulk out error (e.g. Cancel URC, Bulk out error.). */ + rtl8188eu_cal_txdesc_chksum(ptxdesc); +} + +static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxdesc) +{ + if ((pattrib->encrypt > 0) && !pattrib->bswenc) { + switch (pattrib->encrypt) { + /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */ + case _WEP40_: + case _WEP104_: + ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _TKIP_: + case _TKIP_WTMIC_: + ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _AES_: + ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); + break; + case _NO_PRIVACY_: + default: + break; + } + } +} + +static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) +{ + switch (pattrib->vcs_mode) { + case RTS_CTS: + *pdw |= cpu_to_le32(RTS_EN); + break; + case CTS_TO_SELF: + *pdw |= cpu_to_le32(CTS_2_SELF); + break; + case NONE_VCS: + default: + break; + } + if (pattrib->vcs_mode) { + *pdw |= cpu_to_le32(HW_RTS_EN); + /* Set RTS BW */ + if (pattrib->ht_en) { + *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; + + if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + *pdw |= cpu_to_le32((0x01 << 28) & 0x30000000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + *pdw |= cpu_to_le32((0x02 << 28) & 0x30000000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + *pdw |= 0; + else + *pdw |= cpu_to_le32((0x03 << 28) & 0x30000000); + } + } +} + +static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) +{ + if (pattrib->ht_en) { + *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; + + if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) + *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f0000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) + *pdw |= cpu_to_le32((0x02 << DATA_SC_SHT) & 0x003f0000); + else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) + *pdw |= 0; + else + *pdw |= cpu_to_le32((0x03 << DATA_SC_SHT) & 0x003f0000); + } +} + +static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagg_pkt) +{ + int pull = 0; + uint qsel; + u8 data_rate, pwr_status, offset; + struct adapter *adapt = pxmitframe->padapter; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct tx_desc *ptxdesc = (struct tx_desc *)pmem; + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + int bmcst = IS_MCAST(pattrib->ra); + + if (adapt->registrypriv.mp_mode == 0) { + if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { + ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ); + pull = 1; + } + } + + memset(ptxdesc, 0, sizeof(struct tx_desc)); + + /* 4 offset 0 */ + ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); + ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff);/* update TXPKTSIZE */ + + offset = TXDESC_SIZE + OFFSET_SZ; + + ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */ + + if (bmcst) + ptxdesc->txdw0 |= cpu_to_le32(BMC); + + if (adapt->registrypriv.mp_mode == 0) { + if (!bagg_pkt) { + if ((pull) && (pxmitframe->pkt_offset > 0)) + pxmitframe->pkt_offset = pxmitframe->pkt_offset - 1; + } + } + + /* pkt_offset, unit:8 bytes padding */ + if (pxmitframe->pkt_offset > 0) + ptxdesc->txdw1 |= cpu_to_le32((pxmitframe->pkt_offset << 26) & 0x7c000000); + + /* driver uses rate */ + ptxdesc->txdw4 |= cpu_to_le32(USERATE);/* rate control always by driver */ + + if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) { + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3F); + + qsel = (uint)(pattrib->qsel & 0x0000001f); + ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); + + ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); + + fill_txdesc_sectype(pattrib, ptxdesc); + + if (pattrib->ampdu_en) { + ptxdesc->txdw2 |= cpu_to_le32(AGG_EN);/* AGG EN */ + ptxdesc->txdw6 = cpu_to_le32(0x6666f800); + } else { + ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ + } + + /* offset 8 */ + + /* offset 12 */ + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000); + + /* offset 16 , offset 20 */ + if (pattrib->qos_en) + ptxdesc->txdw4 |= cpu_to_le32(QOS);/* QoS */ + + /* offset 20 */ + if (pxmitframe->agg_num > 1) + ptxdesc->txdw5 |= cpu_to_le32((pxmitframe->agg_num << USB_TXAGG_NUM_SHT) & 0xFF000000); + + if ((pattrib->ether_type != 0x888e) && + (pattrib->ether_type != 0x0806) && + (pattrib->ether_type != 0x88b4) && + (pattrib->dhcp_pkt != 1)) { + /* Non EAP & ARP & DHCP type data packet */ + + fill_txdesc_vcs(pattrib, &ptxdesc->txdw4); + fill_txdesc_phy(pattrib, &ptxdesc->txdw4); + + ptxdesc->txdw4 |= cpu_to_le32(0x00000008);/* RTS Rate=24M */ + ptxdesc->txdw5 |= cpu_to_le32(0x0001ff00);/* DATA/RTS Rate FB LMT */ + + if (pattrib->ht_en) { + if (ODM_RA_GetShortGI_8188E(&haldata->odmpriv, pattrib->mac_id)) + ptxdesc->txdw5 |= cpu_to_le32(SGI);/* SGI */ + } + data_rate = ODM_RA_GetDecisionRate_8188E(&haldata->odmpriv, pattrib->mac_id); + ptxdesc->txdw5 |= cpu_to_le32(data_rate & 0x3F); + pwr_status = ODM_RA_GetHwPwrStatus_8188E(&haldata->odmpriv, pattrib->mac_id); + ptxdesc->txdw4 |= cpu_to_le32((pwr_status & 0x7) << PWR_STATUS_SHT); + } else { + /* EAP data packet and ARP packet and DHCP. */ + /* Use the 1M data rate to send the EAP/ARP packet. */ + /* This will maybe make the handshake smooth. */ + ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ + if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT) + ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ + ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); + } + } else if ((pxmitframe->frame_tag&0x0f) == MGNT_FRAMETAG) { + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3f); + + qsel = (uint)(pattrib->qsel&0x0000001f); + ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); + + ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000f0000); + + /* offset 8 */ + /* CCX-TXRPT ack for xmit mgmt frames. */ + if (pxmitframe->ack_report) + ptxdesc->txdw2 |= cpu_to_le32(BIT(19)); + + /* offset 12 */ + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<txdw5 |= cpu_to_le32(RTY_LMT_EN);/* retry limit enable */ + if (pattrib->retry_ctrl) + ptxdesc->txdw5 |= cpu_to_le32(0x00180000);/* retry limit = 6 */ + else + ptxdesc->txdw5 |= cpu_to_le32(0x00300000);/* retry limit = 12 */ + + ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); + } else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { + DBG_88E("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); + } else if (((pxmitframe->frame_tag&0x0f) == MP_FRAMETAG) && + (adapt->registrypriv.mp_mode == 1)) { + fill_txdesc_for_mp(adapt, ptxdesc); + } else { + DBG_88E("pxmitframe->frame_tag = %d\n", pxmitframe->frame_tag); + + /* offset 4 */ + ptxdesc->txdw1 |= cpu_to_le32((4) & 0x3f);/* CAM_ID(MAC_ID) */ + + ptxdesc->txdw1 |= cpu_to_le32((6 << RATE_ID_SHT) & 0x000f0000);/* raid */ + + /* offset 8 */ + + /* offset 12 */ + ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); + } + + /* 2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */ + /* (1) The sequence number of each non-Qos frame / broadcast / multicast / */ + /* mgnt frame should be controlled by Hw because Fw will also send null data */ + /* which we cannot control when Fw LPS enable. */ + /* --> default enable non-Qos data sequense number. 2010.06.23. by tynli. */ + /* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */ + /* (3) Use HW Qos SEQ to control the seq num of Ext port non-Qos packets. */ + /* 2010.06.23. Added by tynli. */ + if (!pattrib->qos_en) { + ptxdesc->txdw3 |= cpu_to_le32(EN_HWSEQ); /* Hw set sequence number */ + ptxdesc->txdw4 |= cpu_to_le32(HW_SSN); /* Hw set sequence number */ + } + + ODM_SetTxAntByTxInfo_88E(&haldata->odmpriv, pmem, pattrib->mac_id); + + rtl8188eu_cal_txdesc_chksum(ptxdesc); + _dbg_dump_tx_info(adapt, pxmitframe->frame_tag, ptxdesc); + return pull; +} + +/* for non-agg data frame or management frame */ +static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + s32 ret = _SUCCESS; + s32 inner_ret = _SUCCESS; + int t, sz, w_sz, pull = 0; + u8 *mem_addr; + u32 ff_hwaddr; + struct xmit_buf *pxmitbuf = pxmitframe->pxmitbuf; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct security_priv *psecuritypriv = &adapt->securitypriv; + if ((pxmitframe->frame_tag == DATA_FRAMETAG) && + (pxmitframe->attrib.ether_type != 0x0806) && + (pxmitframe->attrib.ether_type != 0x888e) && + (pxmitframe->attrib.ether_type != 0x88b4) && + (pxmitframe->attrib.dhcp_pkt != 1)) + rtw_issue_addbareq_cmd(adapt, pxmitframe); + mem_addr = pxmitframe->buf_addr; + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_dump_xframe()\n")); + + for (t = 0; t < pattrib->nr_frags; t++) { + if (inner_ret != _SUCCESS && ret == _SUCCESS) + ret = _FAIL; + + if (t != (pattrib->nr_frags - 1)) { + RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("pattrib->nr_frags=%d\n", pattrib->nr_frags)); + + sz = pxmitpriv->frag_len; + sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 : pattrib->icv_len); + } else { + /* no frag */ + sz = pattrib->last_txcmdsz; + } + + pull = update_txdesc(pxmitframe, mem_addr, sz, false); + + if (pull) { + mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */ + pxmitframe->buf_addr = mem_addr; + w_sz = sz + TXDESC_SIZE; + } else { + w_sz = sz + TXDESC_SIZE + PACKET_OFFSET_SZ; + } + ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe); + + inner_ret = rtw_write_port(adapt, ff_hwaddr, w_sz, (unsigned char *)pxmitbuf); + + rtw_count_tx_stats(adapt, pxmitframe, sz); + + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_write_port, w_sz=%d\n", w_sz)); + + mem_addr += w_sz; + + mem_addr = (u8 *)RND4(((size_t)(mem_addr))); + } + + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + if (ret != _SUCCESS) + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_UNKNOWN); + + return ret; +} + +static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) +{ + struct pkt_attrib *pattrib = &pxmitframe->attrib; + + u32 len = 0; + + /* no consider fragement */ + len = pattrib->hdrlen + pattrib->iv_len + + SNAP_SIZE + sizeof(u16) + + pattrib->pktlen + + ((pattrib->bswenc) ? pattrib->icv_len : 0); + + if (pattrib->encrypt == _TKIP_) + len += 8; + + return len; +} + +s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct xmit_frame *pxmitframe = NULL; + struct xmit_frame *pfirstframe = NULL; + + /* aggregate variable */ + struct hw_xmit *phwxmit; + struct sta_info *psta = NULL; + struct tx_servq *ptxservq = NULL; + struct list_head *xmitframe_plist = NULL, *xmitframe_phead = NULL; + + u32 pbuf; /* next pkt address */ + u32 pbuf_tail; /* last pkt tail */ + u32 len; /* packet length, except TXDESC_SIZE and PKT_OFFSET */ + + u32 bulksize = haldata->UsbBulkOutSize; + u8 desc_cnt; + u32 bulkptr; + + /* dump frame variable */ + u32 ff_hwaddr; + + RT_TRACE(_module_rtl8192c_xmit_c_, _drv_info_, ("+xmitframe_complete\n")); + + /* check xmitbuffer is ok */ + if (pxmitbuf == NULL) { + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (pxmitbuf == NULL) + return false; + } + + /* 3 1. pick up first frame */ + do { + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); + if (pxmitframe == NULL) { + /* no more xmit frame, release xmit buffer */ + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + return false; + } + + pxmitframe->pxmitbuf = pxmitbuf; + pxmitframe->buf_addr = pxmitbuf->pbuf; + pxmitbuf->priv_data = pxmitframe; + + pxmitframe->agg_num = 1; /* alloc xmitframe should assign to 1. */ + pxmitframe->pkt_offset = 1; /* first frame of aggregation, reserve offset */ + + rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + + /* always return ndis_packet after rtw_xmitframe_coalesce */ + rtw_os_xmit_complete(adapt, pxmitframe); + + break; + } while (1); + + /* 3 2. aggregate same priority and same DA(AP or STA) frames */ + pfirstframe = pxmitframe; + len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset*PACKET_OFFSET_SZ); + pbuf_tail = len; + pbuf = _RND8(pbuf_tail); + + /* check pkt amount in one bulk */ + desc_cnt = 0; + bulkptr = bulksize; + if (pbuf < bulkptr) { + desc_cnt++; + } else { + desc_cnt = 0; + bulkptr = ((pbuf / bulksize) + 1) * bulksize; /* round to next bulksize */ + } + + /* dequeue same priority packet from station tx queue */ + psta = pfirstframe->attrib.psta; + switch (pfirstframe->attrib.priority) { + case 1: + case 2: + ptxservq = &(psta->sta_xmitpriv.bk_q); + phwxmit = pxmitpriv->hwxmits + 3; + break; + case 4: + case 5: + ptxservq = &(psta->sta_xmitpriv.vi_q); + phwxmit = pxmitpriv->hwxmits + 1; + break; + case 6: + case 7: + ptxservq = &(psta->sta_xmitpriv.vo_q); + phwxmit = pxmitpriv->hwxmits; + break; + case 0: + case 3: + default: + ptxservq = &(psta->sta_xmitpriv.be_q); + phwxmit = pxmitpriv->hwxmits + 2; + break; + } + spin_lock_bh(&pxmitpriv->lock); + + xmitframe_phead = get_list_head(&ptxservq->sta_pending); + xmitframe_plist = xmitframe_phead->next; + + while (xmitframe_phead != xmitframe_plist) { + pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); + xmitframe_plist = xmitframe_plist->next; + + pxmitframe->agg_num = 0; /* not first frame of aggregation */ + pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ + + len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset*PACKET_OFFSET_SZ); + + if (_RND8(pbuf + len) > MAX_XMITBUF_SZ) { + pxmitframe->agg_num = 1; + pxmitframe->pkt_offset = 1; + break; + } + list_del_init(&pxmitframe->list); + ptxservq->qcnt--; + phwxmit->accnt--; + + pxmitframe->buf_addr = pxmitbuf->pbuf + pbuf; + + rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + /* always return ndis_packet after rtw_xmitframe_coalesce */ + rtw_os_xmit_complete(adapt, pxmitframe); + + /* (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */ + update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz, true); + + /* don't need xmitframe any more */ + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + /* handle pointer and stop condition */ + pbuf_tail = pbuf + len; + pbuf = _RND8(pbuf_tail); + + pfirstframe->agg_num++; + if (MAX_TX_AGG_PACKET_NUMBER == pfirstframe->agg_num) + break; + + if (pbuf < bulkptr) { + desc_cnt++; + if (desc_cnt == haldata->UsbTxAggDescNum) + break; + } else { + desc_cnt = 0; + bulkptr = ((pbuf / bulksize) + 1) * bulksize; + } + } /* end while (aggregate same priority and same DA(AP or STA) frames) */ + + if (list_empty(&ptxservq->sta_pending.queue)) + list_del_init(&ptxservq->tx_pending); + + spin_unlock_bh(&pxmitpriv->lock); + if ((pfirstframe->attrib.ether_type != 0x0806) && + (pfirstframe->attrib.ether_type != 0x888e) && + (pfirstframe->attrib.ether_type != 0x88b4) && + (pfirstframe->attrib.dhcp_pkt != 1)) + rtw_issue_addbareq_cmd(adapt, pfirstframe); + /* 3 3. update first frame txdesc */ + if ((pbuf_tail % bulksize) == 0) { + /* remove pkt_offset */ + pbuf_tail -= PACKET_OFFSET_SZ; + pfirstframe->buf_addr += PACKET_OFFSET_SZ; + pfirstframe->pkt_offset--; + } + + update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz, true); + + /* 3 4. write xmit buffer to USB FIFO */ + ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe); + rtw_write_port(adapt, ff_hwaddr, pbuf_tail, (u8 *)pxmitbuf); + + /* 3 5. update statisitc */ + pbuf_tail -= (pfirstframe->agg_num * TXDESC_SIZE); + pbuf_tail -= (pfirstframe->pkt_offset * PACKET_OFFSET_SZ); + + rtw_count_tx_stats(adapt, pfirstframe, pbuf_tail); + + rtw_free_xmitframe(pxmitpriv, pfirstframe); + + return true; +} + +static s32 xmitframe_direct(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + s32 res = _SUCCESS; + + res = rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); + if (res == _SUCCESS) + rtw_dump_xframe(adapt, pxmitframe); + else + DBG_88E("==> %s xmitframe_coalsece failed\n", __func__); + return res; +} + +/* + * Return + * true dump packet directly + * false enqueue packet + */ +static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + s32 res; + struct xmit_buf *pxmitbuf = NULL; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + struct pkt_attrib *pattrib = &pxmitframe->attrib; + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; + + spin_lock_bh(&pxmitpriv->lock); + + if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) + goto enqueue; + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) + goto enqueue; + + pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); + if (pxmitbuf == NULL) + goto enqueue; + + spin_unlock_bh(&pxmitpriv->lock); + + pxmitframe->pxmitbuf = pxmitbuf; + pxmitframe->buf_addr = pxmitbuf->pbuf; + pxmitbuf->priv_data = pxmitframe; + + if (xmitframe_direct(adapt, pxmitframe) != _SUCCESS) { + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + rtw_free_xmitframe(pxmitpriv, pxmitframe); + } + + return true; + +enqueue: + res = rtw_xmitframe_enqueue(adapt, pxmitframe); + spin_unlock_bh(&pxmitpriv->lock); + + if (res != _SUCCESS) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("pre_xmitframe: enqueue xmitframe fail\n")); + rtw_free_xmitframe(pxmitpriv, pxmitframe); + + /* Trick, make the statistics correct */ + pxmitpriv->tx_pkts--; + pxmitpriv->tx_drop++; + return true; + } + + return false; +} + +s32 rtl8188eu_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) +{ + return rtw_dump_xframe(adapt, pmgntframe); +} + +/* + * Return + * true dump packet directly ok + * false temporary can't transmit packets to hardware + */ +s32 rtl8188eu_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) +{ + return pre_xmitframe(adapt, pxmitframe); +} diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c new file mode 100644 index 000000000000..144cc5f6787d --- /dev/null +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -0,0 +1,2334 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HCI_HAL_INIT_C_ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#define HAL_MAC_ENABLE 1 +#define HAL_BB_ENABLE 1 +#define HAL_RF_ENABLE 1 + +static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + switch (NumOutPipe) { + case 3: + haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ; + haldata->OutEpNumber = 3; + break; + case 2: + haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; + haldata->OutEpNumber = 2; + break; + case 1: + haldata->OutEpQueueSel = TX_SELE_HQ; + haldata->OutEpNumber = 1; + break; + default: + break; + } + DBG_88E("%s OutEpQueueSel(0x%02x), OutEpNumber(%d)\n", __func__, haldata->OutEpQueueSel, haldata->OutEpNumber); +} + +static bool HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumInPipe, u8 NumOutPipe) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + bool result = false; + + _ConfigNormalChipOutEP_8188E(adapt, NumOutPipe); + + /* Normal chip with one IN and one OUT doesn't have interrupt IN EP. */ + if (1 == haldata->OutEpNumber) { + if (1 != NumInPipe) + return result; + } + + /* All config other than above support one Bulk IN and one Interrupt IN. */ + + result = Hal_MappingOutPipe(adapt, NumOutPipe); + + return result; +} + +static void rtl8188eu_interface_configure(struct adapter *adapt) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt); + + if (pdvobjpriv->ishighspeed) + haldata->UsbBulkOutSize = USB_HIGH_SPEED_BULK_SIZE;/* 512 bytes */ + else + haldata->UsbBulkOutSize = USB_FULL_SPEED_BULK_SIZE;/* 64 bytes */ + + haldata->interfaceIndex = pdvobjpriv->InterfaceNumber; + + haldata->UsbTxAggMode = 1; + haldata->UsbTxAggDescNum = 0x6; /* only 4 bits */ + + haldata->UsbRxAggMode = USB_RX_AGG_DMA;/* USB_RX_AGG_DMA; */ + haldata->UsbRxAggBlockCount = 8; /* unit : 512b */ + haldata->UsbRxAggBlockTimeout = 0x6; + haldata->UsbRxAggPageCount = 48; /* uint :128 b 0x0A; 10 = MAX_RX_DMA_BUFFER_SIZE/2/haldata->UsbBulkOutSize */ + haldata->UsbRxAggPageTimeout = 0x4; /* 6, absolute time = 34ms/(2^6) */ + + HalUsbSetQueuePipeMapping8188EUsb(adapt, + pdvobjpriv->RtNumInPipes, pdvobjpriv->RtNumOutPipes); +} + +static u32 rtl8188eu_InitPowerOn(struct adapter *adapt) +{ + u16 value16; + /* HW Power on sequence */ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + if (haldata->bMacPwrCtrlOn) + return _SUCCESS; + + if (!HalPwrSeqCmdParsing(adapt, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_PWR_ON_FLOW)) { + DBG_88E(KERN_ERR "%s: run power on flow fail\n", __func__); + return _FAIL; + } + + /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ + /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ + rtw_write16(adapt, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ + + /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ + value16 = rtw_read16(adapt, REG_CR); + value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN + | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); + /* for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ + + rtw_write16(adapt, REG_CR, value16); + haldata->bMacPwrCtrlOn = true; + + return _SUCCESS; +} + +/* Shall USB interface init this? */ +static void _InitInterrupt(struct adapter *Adapter) +{ + u32 imr, imr_ex; + u8 usb_opt; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + /* HISR write one to clear */ + rtw_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF); + /* HIMR - */ + imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E; + rtw_write32(Adapter, REG_HIMR_88E, imr); + haldata->IntrMask[0] = imr; + + imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E; + rtw_write32(Adapter, REG_HIMRE_88E, imr_ex); + haldata->IntrMask[1] = imr_ex; + + /* REG_USB_SPECIAL_OPTION - BIT(4) */ + /* 0; Use interrupt endpoint to upload interrupt pkt */ + /* 1; Use bulk endpoint to upload interrupt pkt, */ + usb_opt = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); + + if (!adapter_to_dvobj(Adapter)->ishighspeed) + usb_opt = usb_opt & (~INT_BULK_SEL); + else + usb_opt = usb_opt | (INT_BULK_SEL); + + rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt); +} + +static void _InitQueueReservedPage(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u32 numHQ = 0; + u32 numLQ = 0; + u32 numNQ = 0; + u32 numPubQ; + u32 value32; + u8 value8; + bool bWiFiConfig = pregistrypriv->wifi_spec; + + if (bWiFiConfig) { + if (haldata->OutEpQueueSel & TX_SELE_HQ) + numHQ = 0x29; + + if (haldata->OutEpQueueSel & TX_SELE_LQ) + numLQ = 0x1C; + + /* NOTE: This step shall be proceed before writting REG_RQPN. */ + if (haldata->OutEpQueueSel & TX_SELE_NQ) + numNQ = 0x1C; + value8 = (u8)_NPQ(numNQ); + rtw_write8(Adapter, REG_RQPN_NPQ, value8); + + numPubQ = 0xA8 - numHQ - numLQ - numNQ; + + /* TX DMA */ + value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; + rtw_write32(Adapter, REG_RQPN, value32); + } else { + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0d); + rtw_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ + } +} + +static void _InitTxBufferBoundary(struct adapter *Adapter, u8 txpktbuf_bndy) +{ + rtw_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); + rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); + rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); + rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); + rtw_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); +} + +static void _InitPageBoundary(struct adapter *Adapter) +{ + /* RX Page Boundary */ + /* */ + u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E-1; + + rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); +} + +static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, + u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, + u16 hiQ) +{ + u16 value16 = (rtw_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); + + value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | + _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | + _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ); + + rtw_write16(Adapter, REG_TRXDMA_CTRL, value16); +} + +static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + u16 value = 0; + switch (haldata->OutEpQueueSel) { + case TX_SELE_HQ: + value = QUEUE_HIGH; + break; + case TX_SELE_LQ: + value = QUEUE_LOW; + break; + case TX_SELE_NQ: + value = QUEUE_NORMAL; + break; + default: + break; + } + _InitNormalChipRegPriority(Adapter, value, value, value, value, + value, value); +} + +static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + u16 valueHi = 0; + u16 valueLow = 0; + + switch (haldata->OutEpQueueSel) { + case (TX_SELE_HQ | TX_SELE_LQ): + valueHi = QUEUE_HIGH; + valueLow = QUEUE_LOW; + break; + case (TX_SELE_NQ | TX_SELE_LQ): + valueHi = QUEUE_NORMAL; + valueLow = QUEUE_LOW; + break; + case (TX_SELE_HQ | TX_SELE_NQ): + valueHi = QUEUE_HIGH; + valueLow = QUEUE_NORMAL; + break; + default: + break; + } + + if (!pregistrypriv->wifi_spec) { + beQ = valueLow; + bkQ = valueLow; + viQ = valueHi; + voQ = valueHi; + mgtQ = valueHi; + hiQ = valueHi; + } else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */ + beQ = valueLow; + bkQ = valueHi; + viQ = valueHi; + voQ = valueLow; + mgtQ = valueHi; + hiQ = valueHi; + } + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); +} + +static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter) +{ + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; + + if (!pregistrypriv->wifi_spec) {/* typical setting */ + beQ = QUEUE_LOW; + bkQ = QUEUE_LOW; + viQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; + mgtQ = QUEUE_HIGH; + hiQ = QUEUE_HIGH; + } else {/* for WMM */ + beQ = QUEUE_LOW; + bkQ = QUEUE_NORMAL; + viQ = QUEUE_NORMAL; + voQ = QUEUE_HIGH; + mgtQ = QUEUE_HIGH; + hiQ = QUEUE_HIGH; + } + _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); +} + +static void _InitQueuePriority(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + switch (haldata->OutEpNumber) { + case 1: + _InitNormalChipOneOutEpPriority(Adapter); + break; + case 2: + _InitNormalChipTwoOutEpPriority(Adapter); + break; + case 3: + _InitNormalChipThreeOutEpPriority(Adapter); + break; + default: + break; + } +} + +static void _InitNetworkType(struct adapter *Adapter) +{ + u32 value32; + + value32 = rtw_read32(Adapter, REG_CR); + /* TODO: use the other function to set network type */ + value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP); + + rtw_write32(Adapter, REG_CR, value32); +} + +static void _InitTransferPageSize(struct adapter *Adapter) +{ + /* Tx page size is always 128. */ + + u8 value8; + value8 = _PSRX(PBP_128) | _PSTX(PBP_128); + rtw_write8(Adapter, REG_PBP, value8); +} + +static void _InitDriverInfoSize(struct adapter *Adapter, u8 drvInfoSize) +{ + rtw_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); +} + +static void _InitWMACSetting(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + haldata->ReceiveConfig = RCR_AAP | RCR_APM | RCR_AM | RCR_AB | + RCR_CBSSID_DATA | RCR_CBSSID_BCN | + RCR_APP_ICV | RCR_AMF | RCR_HTC_LOC_CTRL | + RCR_APP_MIC | RCR_APP_PHYSTS; + + /* some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */ + rtw_write32(Adapter, REG_RCR, haldata->ReceiveConfig); + + /* Accept all multicast address */ + rtw_write32(Adapter, REG_MAR, 0xFFFFFFFF); + rtw_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); +} + +static void _InitAdaptiveCtrl(struct adapter *Adapter) +{ + u16 value16; + u32 value32; + + /* Response Rate Set */ + value32 = rtw_read32(Adapter, REG_RRSR); + value32 &= ~RATE_BITMAP_ALL; + value32 |= RATE_RRSR_CCK_ONLY_1M; + rtw_write32(Adapter, REG_RRSR, value32); + + /* CF-END Threshold */ + + /* SIFS (used in NAV) */ + value16 = _SPEC_SIFS_CCK(0x10) | _SPEC_SIFS_OFDM(0x10); + rtw_write16(Adapter, REG_SPEC_SIFS, value16); + + /* Retry Limit */ + value16 = _LRL(0x30) | _SRL(0x30); + rtw_write16(Adapter, REG_RL, value16); +} + +static void _InitEDCA(struct adapter *Adapter) +{ + /* Set Spec SIFS (used in NAV) */ + rtw_write16(Adapter, REG_SPEC_SIFS, 0x100a); + rtw_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); + + /* Set SIFS for CCK */ + rtw_write16(Adapter, REG_SIFS_CTX, 0x100a); + + /* Set SIFS for OFDM */ + rtw_write16(Adapter, REG_SIFS_TRX, 0x100a); + + /* TXOP */ + rtw_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); + rtw_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); + rtw_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); + rtw_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); +} + +static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) +{ +} + +static void _InitHWLed(struct adapter *Adapter) +{ + struct led_priv *pledpriv = &(Adapter->ledpriv); + + if (pledpriv->LedStrategy != HW_LED) + return; + +/* HW led control */ +/* to do .... */ +/* must consider cases of antenna diversity/ commbo card/solo card/mini card */ +} + +static void _InitRDGSetting(struct adapter *Adapter) +{ + rtw_write8(Adapter, REG_RD_CTRL, 0xFF); + rtw_write16(Adapter, REG_RD_NAV_NXT, 0x200); + rtw_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); +} + +static void _InitRxSetting(struct adapter *Adapter) +{ + rtw_write32(Adapter, REG_MACID, 0x87654321); + rtw_write32(Adapter, 0x0700, 0x87654321); +} + +static void _InitRetryFunction(struct adapter *Adapter) +{ + u8 value8; + + value8 = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL); + value8 |= EN_AMPDU_RTY_NEW; + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); + + /* Set ACK timeout */ + rtw_write8(Adapter, REG_ACKTO, 0x40); +} + +/*----------------------------------------------------------------------------- + * Function: usb_AggSettingTxUpdate() + * + * Overview: Separate TX/RX parameters update independent for TP detection and + * dynamic TX/RX aggreagtion parameters update. + * + * Input: struct adapter * + * + * Output/Return: NONE + * + * Revised History: + * When Who Remark + * 12/10/2010 MHC Separate to smaller function. + * + *---------------------------------------------------------------------------*/ +static void usb_AggSettingTxUpdate(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u32 value32; + + if (Adapter->registrypriv.wifi_spec) + haldata->UsbTxAggMode = false; + + if (haldata->UsbTxAggMode) { + value32 = rtw_read32(Adapter, REG_TDECTRL); + value32 = value32 & ~(BLK_DESC_NUM_MASK << BLK_DESC_NUM_SHIFT); + value32 |= ((haldata->UsbTxAggDescNum & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT); + + rtw_write32(Adapter, REG_TDECTRL, value32); + } +} /* usb_AggSettingTxUpdate */ + +/*----------------------------------------------------------------------------- + * Function: usb_AggSettingRxUpdate() + * + * Overview: Separate TX/RX parameters update independent for TP detection and + * dynamic TX/RX aggreagtion parameters update. + * + * Input: struct adapter * + * + * Output/Return: NONE + * + * Revised History: + * When Who Remark + * 12/10/2010 MHC Separate to smaller function. + * + *---------------------------------------------------------------------------*/ +static void +usb_AggSettingRxUpdate( + struct adapter *Adapter + ) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 valueDMA; + u8 valueUSB; + + valueDMA = rtw_read8(Adapter, REG_TRXDMA_CTRL); + valueUSB = rtw_read8(Adapter, REG_USB_SPECIAL_OPTION); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + valueDMA |= RXDMA_AGG_EN; + valueUSB &= ~USB_AGG_EN; + break; + case USB_RX_AGG_USB: + valueDMA &= ~RXDMA_AGG_EN; + valueUSB |= USB_AGG_EN; + break; + case USB_RX_AGG_MIX: + valueDMA |= RXDMA_AGG_EN; + valueUSB |= USB_AGG_EN; + break; + case USB_RX_AGG_DISABLE: + default: + valueDMA &= ~RXDMA_AGG_EN; + valueUSB &= ~USB_AGG_EN; + break; + } + + rtw_write8(Adapter, REG_TRXDMA_CTRL, valueDMA); + rtw_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, haldata->UsbRxAggPageTimeout); + break; + case USB_RX_AGG_USB: + rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + break; + case USB_RX_AGG_MIX: + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ + rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); + rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); + break; + case USB_RX_AGG_DISABLE: + default: + /* TODO: */ + break; + } + + switch (PBP_128) { + case PBP_128: + haldata->HwRxPageSize = 128; + break; + case PBP_64: + haldata->HwRxPageSize = 64; + break; + case PBP_256: + haldata->HwRxPageSize = 256; + break; + case PBP_512: + haldata->HwRxPageSize = 512; + break; + case PBP_1024: + haldata->HwRxPageSize = 1024; + break; + default: + break; + } +} /* usb_AggSettingRxUpdate */ + +static void InitUsbAggregationSetting(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + /* Tx aggregation setting */ + usb_AggSettingTxUpdate(Adapter); + + /* Rx aggregation setting */ + usb_AggSettingRxUpdate(Adapter); + + /* 201/12/10 MH Add for USB agg mode dynamic switch. */ + haldata->UsbRxHighSpeedMode = false; +} + +static void _InitOperationMode(struct adapter *Adapter) +{ +} + +static void _InitBeaconParameters(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + rtw_write16(Adapter, REG_BCN_CTRL, 0x1010); + + /* TODO: Remove these magic number */ + rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/* ms */ + rtw_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/* 5ms */ + rtw_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* 2ms */ + + /* Suggested by designer timchen. Change beacon AIFS to the largest number */ + /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ + rtw_write16(Adapter, REG_BCNTCFG, 0x660F); + + haldata->RegBcnCtrlVal = rtw_read8(Adapter, REG_BCN_CTRL); + haldata->RegTxPause = rtw_read8(Adapter, REG_TXPAUSE); + haldata->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); + haldata->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT+2); + haldata->RegCR_1 = rtw_read8(Adapter, REG_CR+1); +} + +static void _BeaconFunctionEnable(struct adapter *Adapter, + bool Enable, bool Linked) +{ + rtw_write8(Adapter, REG_BCN_CTRL, (BIT4 | BIT3 | BIT1)); + + rtw_write8(Adapter, REG_RD_CTRL+1, 0x6F); +} + +/* Set CCK and OFDM Block "ON" */ +static void _BBTurnOnBlock(struct adapter *Adapter) +{ + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1); + PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bOFDMEn, 0x1); +} + +enum { + Antenna_Lfet = 1, + Antenna_Right = 2, +}; + +static void _InitAntenna_Selection(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + if (haldata->AntDivCfg == 0) + return; + DBG_88E("==> %s ....\n", __func__); + + rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT23); + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT13, 0x01); + + if (PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) + haldata->CurAntenna = Antenna_A; + else + haldata->CurAntenna = Antenna_B; + DBG_88E("%s,Cur_ant:(%x)%s\n", __func__, haldata->CurAntenna, (haldata->CurAntenna == Antenna_A) ? "Antenna_A" : "Antenna_B"); +} + +/*----------------------------------------------------------------------------- + * Function: HwSuspendModeEnable92Cu() + * + * Overview: HW suspend mode switch. + * + * Input: NONE + * + * Output: NONE + * + * Return: NONE + * + * Revised History: + * When Who Remark + * 08/23/2010 MHC HW suspend mode switch test.. + *---------------------------------------------------------------------------*/ +enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) +{ + u8 val8; + enum rt_rf_power_state rfpowerstate = rf_off; + + if (adapt->pwrctrlpriv.bHWPowerdown) { + val8 = rtw_read8(adapt, REG_HSISR); + DBG_88E("pwrdown, 0x5c(BIT7)=%02x\n", val8); + rfpowerstate = (val8 & BIT7) ? rf_off : rf_on; + } else { /* rf on/off */ + rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT3)); + val8 = rtw_read8(adapt, REG_GPIO_IO_SEL); + DBG_88E("GPIO_IN=%02x\n", val8); + rfpowerstate = (val8 & BIT3) ? rf_on : rf_off; + } + return rfpowerstate; +} /* HalDetectPwrDownMode */ + +static u32 rtl8188eu_hal_init(struct adapter *Adapter) +{ + u8 value8 = 0; + u16 value16; + u8 txpktbuf_bndy; + u32 status = _SUCCESS; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; + struct registry_priv *pregistrypriv = &Adapter->registrypriv; + u32 init_start_time = jiffies; + + #define HAL_INIT_PROFILE_TAG(stage) do {} while (0) + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BEGIN); + + if (Adapter->pwrctrlpriv.bkeepfwalive) { + _ps_open_RF(Adapter); + + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + PHY_IQCalibrate_8188E(Adapter, true); + } else { + PHY_IQCalibrate_8188E(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + } + + ODM_TXPowerTrackingCheck(&haldata->odmpriv); + PHY_LCCalibrate_8188E(Adapter); + + goto exit; + } + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PW_ON); + status = rtl8188eu_InitPowerOn(Adapter); + if (status == _FAIL) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init power on!\n")); + goto exit; + } + + /* Save target channel */ + haldata->CurrentChannel = 6;/* default set to 6 */ + + if (pwrctrlpriv->reg_rfoff) { + pwrctrlpriv->rf_pwrstate = rf_off; + } + + /* 2010/08/09 MH We need to check if we need to turnon or off RF after detecting */ + /* HW GPIO pin. Before PHY_RFConfig8192C. */ + /* 2010/08/26 MH If Efuse does not support sective suspend then disable the function. */ + + if (!pregistrypriv->wifi_spec) { + txpktbuf_bndy = TX_PAGE_BOUNDARY_88E; + } else { + /* for WMM */ + txpktbuf_bndy = WMM_NORMAL_TX_PAGE_BOUNDARY_88E; + } + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC01); + _InitQueueReservedPage(Adapter); + _InitQueuePriority(Adapter); + _InitPageBoundary(Adapter); + _InitTransferPageSize(Adapter); + + _InitTxBufferBoundary(Adapter, 0); + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_DOWNLOAD_FW); + if (Adapter->registrypriv.mp_mode == 1) { + _InitRxSetting(Adapter); + Adapter->bFWReady = false; + haldata->fw_ractrl = false; + } else { + status = rtl8188e_FirmwareDownload(Adapter); + + if (status != _SUCCESS) { + DBG_88E("%s: Download Firmware failed!!\n", __func__); + Adapter->bFWReady = false; + haldata->fw_ractrl = false; + return status; + } else { + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializeadapt8192CSdio(): Download Firmware Success!!\n")); + Adapter->bFWReady = true; + haldata->fw_ractrl = false; + } + } + rtl8188e_InitializeFirmwareVars(Adapter); + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MAC); +#if (HAL_MAC_ENABLE == 1) + status = PHY_MACConfig8188E(Adapter); + if (status == _FAIL) { + DBG_88E(" ### Failed to init MAC ......\n "); + goto exit; + } +#endif + + /* */ + /* d. Initialize BB related configurations. */ + /* */ + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_BB); +#if (HAL_BB_ENABLE == 1) + status = PHY_BBConfig8188E(Adapter); + if (status == _FAIL) { + DBG_88E(" ### Failed to init BB ......\n "); + goto exit; + } +#endif + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_RF); +#if (HAL_RF_ENABLE == 1) + status = PHY_RFConfig8188E(Adapter); + if (status == _FAIL) { + DBG_88E(" ### Failed to init RF ......\n "); + goto exit; + } +#endif + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_EFUSE_PATCH); + status = rtl8188e_iol_efuse_patch(Adapter); + if (status == _FAIL) { + DBG_88E("%s rtl8188e_iol_efuse_patch failed\n", __func__); + goto exit; + } + + _InitTxBufferBoundary(Adapter, txpktbuf_bndy); + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_LLTT); + status = InitLLTTable(Adapter, txpktbuf_bndy); + if (status == _FAIL) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init LLT table\n")); + goto exit; + } + + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC02); + /* Get Rx PHY status in order to report RSSI and others. */ + _InitDriverInfoSize(Adapter, DRVINFO_SZ); + + _InitInterrupt(Adapter); + hal_init_macaddr(Adapter);/* set mac_address */ + _InitNetworkType(Adapter);/* set msr */ + _InitWMACSetting(Adapter); + _InitAdaptiveCtrl(Adapter); + _InitEDCA(Adapter); + _InitRetryFunction(Adapter); + InitUsbAggregationSetting(Adapter); + _InitOperationMode(Adapter);/* todo */ + _InitBeaconParameters(Adapter); + _InitBeaconMaxError(Adapter, true); + + /* */ + /* Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */ + /* Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */ + /* */ + /* Enable MACTXEN/MACRXEN block */ + value16 = rtw_read16(Adapter, REG_CR); + value16 |= (MACTXEN | MACRXEN); + rtw_write8(Adapter, REG_CR, value16); + + if (haldata->bRDGEnable) + _InitRDGSetting(Adapter); + + /* Enable TX Report */ + /* Enable Tx Report Timer */ + value8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); + rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT1|BIT0)); + /* Set MAX RPT MACID */ + rtw_write8(Adapter, REG_TX_RPT_CTRL+1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ + /* Tx RPT Timer. Unit: 32us */ + rtw_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0); + + rtw_write8(Adapter, REG_EARLY_MODE_CONTROL, 0); + + rtw_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ + rtw_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ + + _InitHWLed(Adapter); + + /* Keep RfRegChnlVal for later use. */ + haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); + haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); + _BBTurnOnBlock(Adapter); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); + invalidate_cam_all(Adapter); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); + /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ + PHY_SetTxPowerLevel8188E(Adapter, haldata->CurrentChannel); + +/* Move by Neo for USB SS to below setp */ +/* _RfPowerSave(Adapter); */ + + _InitAntenna_Selection(Adapter); + + /* */ + /* Disable BAR, suggested by Scott */ + /* 2010.04.09 add by hpfan */ + /* */ + rtw_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); + + /* HW SEQ CTRL */ + /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */ + rtw_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); + + if (pregistrypriv->wifi_spec) + rtw_write16(Adapter, REG_FAST_EDCA_CTRL, 0); + + /* Nav limit , suggest by scott */ + rtw_write8(Adapter, 0x652, 0x0); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); + rtl8188e_InitHalDm(Adapter); + + if (Adapter->registrypriv.mp_mode == 1) { + Adapter->mppriv.channel = haldata->CurrentChannel; + MPT_InitializeAdapter(Adapter, Adapter->mppriv.channel); + } else { + /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ + /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ + /* call initstruct adapter. May cause some problem?? */ + /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ + /* in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */ + /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ + /* Added by tynli. 2010.03.30. */ + pwrctrlpriv->rf_pwrstate = rf_on; + + /* enable Tx report. */ + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); + + /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ + rtw_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ + + /* tynli_test_tx_report. */ + rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); + + /* enable tx DMA to drop the redundate data of packet */ + rtw_write16(Adapter, REG_TXDMA_OFFSET_CHK, (rtw_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); + /* 2010/08/26 MH Merge from 8192CE. */ + if (pwrctrlpriv->rf_pwrstate == rf_on) { + if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { + PHY_IQCalibrate_8188E(Adapter, true); + } else { + PHY_IQCalibrate_8188E(Adapter, false); + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; + } + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); + + ODM_TXPowerTrackingCheck(&haldata->odmpriv); + +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); + PHY_LCCalibrate_8188E(Adapter); + } + } + +/* HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PABIAS); */ +/* _InitPABias(Adapter); */ + rtw_write8(Adapter, REG_USB_HRPWM, 0); + + /* ack for xmit mgmt frames. */ + rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + +exit: +HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); + + DBG_88E("%s in %dms\n", __func__, rtw_get_passing_time_ms(init_start_time)); + + return status; +} + +void _ps_open_RF(struct adapter *adapt) +{ + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ + /* phy_SsPwrSwitch92CU(adapt, rf_on, 1); */ +} + +static void _ps_close_RF(struct adapter *adapt) +{ + /* here call with bRegSSPwrLvl 1, bRegSSPwrLvl 2 needs to be verified */ + /* phy_SsPwrSwitch92CU(adapt, rf_off, 1); */ +} + +static void CardDisableRTL8188EU(struct adapter *Adapter) +{ + u8 val8; + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("CardDisableRTL8188EU\n")); + + /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ + val8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); + rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT1)); + + /* stop rx */ + rtw_write8(Adapter, REG_CR, 0x0); + + /* Run LPS WL RFOFF flow */ + HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_LPS_ENTER_FLOW); + + /* 2. 0x1F[7:0] = 0 turn off RF */ + + val8 = rtw_read8(Adapter, REG_MCUFWDL); + if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */ + /* Reset MCU 0x2[10]=0. */ + val8 = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); + val8 &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ + rtw_write8(Adapter, REG_SYS_FUNC_EN+1, val8); + } + + /* reset MCU ready status */ + rtw_write8(Adapter, REG_MCUFWDL, 0); + + /* YJ,add,111212 */ + /* Disable 32k */ + val8 = rtw_read8(Adapter, REG_32K_CTRL); + rtw_write8(Adapter, REG_32K_CTRL, val8&(~BIT0)); + + /* Card disable power action flow */ + HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_DISABLE_FLOW); + + /* Reset MCU IO Wrapper */ + val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); + rtw_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT3))); + val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); + rtw_write8(Adapter, REG_RSV_CTRL+1, val8|BIT3); + + /* YJ,test add, 111207. For Power Consumption. */ + val8 = rtw_read8(Adapter, GPIO_IN); + rtw_write8(Adapter, GPIO_OUT, val8); + rtw_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */ + + val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL); + rtw_write8(Adapter, REG_GPIO_IO_SEL, (val8<<4)); + val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL+1); + rtw_write8(Adapter, REG_GPIO_IO_SEL+1, val8|0x0F);/* Reg0x43 */ + rtw_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ + haldata->bMacPwrCtrlOn = false; + Adapter->bFWReady = false; +} +static void rtl8192cu_hw_power_down(struct adapter *adapt) +{ + /* 2010/-8/09 MH For power down module, we need to enable register block contrl reg at 0x1c. */ + /* Then enable power down control bit of register 0x04 BIT4 and BIT15 as 1. */ + + /* Enable register area 0x0-0xc. */ + rtw_write8(adapt, REG_RSV_CTRL, 0x0); + rtw_write16(adapt, REG_APS_FSMCO, 0x8812); +} + +static u32 rtl8188eu_hal_deinit(struct adapter *Adapter) +{ + + DBG_88E("==> %s\n", __func__); + + rtw_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E); + rtw_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E); + + DBG_88E("bkeepfwalive(%x)\n", Adapter->pwrctrlpriv.bkeepfwalive); + if (Adapter->pwrctrlpriv.bkeepfwalive) { + _ps_close_RF(Adapter); + if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) + rtl8192cu_hw_power_down(Adapter); + } else { + if (Adapter->hw_init_completed) { + CardDisableRTL8188EU(Adapter); + + if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) + rtl8192cu_hw_power_down(Adapter); + } + } + return _SUCCESS; + } + +static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) +{ + u8 i; + struct recv_buf *precvbuf; + uint status; + struct intf_hdl *pintfhdl = &Adapter->iopriv.intf; + struct recv_priv *precvpriv = &(Adapter->recvpriv); + u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); + + _read_port = pintfhdl->io_ops._read_port; + + status = _SUCCESS; + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, + ("===> usb_inirp_init\n")); + + precvpriv->ff_hwaddr = RECV_BULK_IN_ADDR; + + /* issue Rx irp to receive data */ + precvbuf = (struct recv_buf *)precvpriv->precv_buf; + for (i = 0; i < NR_RECVBUFF; i++) { + if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { + RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); + status = _FAIL; + goto exit; + } + + precvbuf++; + precvpriv->free_recv_buf_queue_cnt--; + } + +exit: + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); + + return status; +} + +static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) +{ + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); + + rtw_read_port_cancel(Adapter); + + RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); + + return _SUCCESS; +} + +/* */ +/* */ +/* EEPROM/EFUSE Content Parsing */ +/* */ +/* */ +static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) +{ + struct led_priv *pledpriv = &(Adapter->ledpriv); + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + pledpriv->bRegUseLed = true; + pledpriv->LedStrategy = SW_LED_MODE1; + haldata->bLedOpenDrain = true;/* Support Open-drain arrangement for controlling the LED. */ +} + +static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (!AutoLoadFail) { + /* VID, PID */ + haldata->EEPROMVID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_VID_88EU]); + haldata->EEPROMPID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_PID_88EU]); + + /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ + haldata->EEPROMCustomerID = *(u8 *)&hwinfo[EEPROM_CUSTOMERID_88E]; + haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; + } else { + haldata->EEPROMVID = EEPROM_Default_VID; + haldata->EEPROMPID = EEPROM_Default_PID; + + /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ + haldata->EEPROMCustomerID = EEPROM_Default_CustomerID; + haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; + } + + DBG_88E("VID = 0x%04X, PID = 0x%04X\n", haldata->EEPROMVID, haldata->EEPROMPID); + DBG_88E("Customer ID: 0x%02X, SubCustomer ID: 0x%02X\n", haldata->EEPROMCustomerID, haldata->EEPROMSubCustomerID); +} + +static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) +{ + u16 i; + u8 sMacAddr[6] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); + + if (AutoLoadFail) { + for (i = 0; i < 6; i++) + eeprom->mac_addr[i] = sMacAddr[i]; + } else { + /* Read Permanent MAC address */ + memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); + } + RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, + ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", + eeprom->mac_addr[0], eeprom->mac_addr[1], + eeprom->mac_addr[2], eeprom->mac_addr[3], + eeprom->mac_addr[4], eeprom->mac_addr[5])); +} + +static void Hal_CustomizeByCustomerID_8188EU(struct adapter *adapt) +{ +} + +static void +readAdapterInfo_8188EU( + struct adapter *adapt + ) +{ + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); + + /* parse the eeprom/efuse content */ + Hal_EfuseParseIDCode88E(adapt, eeprom->efuse_eeprom_data); + Hal_EfuseParsePIDVID_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseMACAddr_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + + Hal_ReadPowerSavingMode88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadTxPowerInfo88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseEEPROMVer88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + rtl8188e_EfuseParseChnlPlan(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseXtal_8188E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseCustomerID88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadAntennaDiversity88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_EfuseParseBoardType88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); + + /* */ + /* The following part initialize some vars by PG info. */ + /* */ + Hal_InitChannelPlan(adapt); + Hal_CustomizeByCustomerID_8188EU(adapt); + + _ReadLEDSetting(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); +} + +static void _ReadPROMContent( + struct adapter *Adapter + ) +{ + struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); + u8 eeValue; + + /* check system boot selection */ + eeValue = rtw_read8(Adapter, REG_9346CR); + eeprom->EepromOrEfuse = (eeValue & BOOT_FROM_EEPROM) ? true : false; + eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; + + DBG_88E("Boot from %s, Autoload %s !\n", (eeprom->EepromOrEfuse ? "EEPROM" : "EFUSE"), + (eeprom->bautoload_fail_flag ? "Fail" : "OK")); + + Hal_InitPGData88E(Adapter); + readAdapterInfo_8188EU(Adapter); +} + +static void _ReadRFType(struct adapter *Adapter) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + + haldata->rf_chip = RF_6052; +} + +static int _ReadAdapterInfo8188EU(struct adapter *Adapter) +{ + u32 start = jiffies; + + MSG_88E("====> %s\n", __func__); + + _ReadRFType(Adapter);/* rf_chip -> _InitRFType() */ + _ReadPROMContent(Adapter); + + MSG_88E("<==== %s in %d ms\n", __func__, rtw_get_passing_time_ms(start)); + + return _SUCCESS; +} + +static void ReadAdapterInfo8188EU(struct adapter *Adapter) +{ + /* Read EEPROM size before call any EEPROM function */ + Adapter->EepromAddressSize = GetEEPROMSize8188E(Adapter); + + _ReadAdapterInfo8188EU(Adapter); +} + +#define GPIO_DEBUG_PORT_NUM 0 +static void rtl8192cu_trigger_gpio_0(struct adapter *adapt) +{ +} + +static void ResumeTxBeacon(struct adapter *adapt) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ + /* which should be read from register to a global variable. */ + + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT6); + haldata->RegFwHwTxQCtrl |= BIT6; + rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); + haldata->RegReg542 |= BIT0; + rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); +} + +static void StopTxBeacon(struct adapter *adapt) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ + /* which should be read from register to a global variable. */ + + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT6)); + haldata->RegFwHwTxQCtrl &= (~BIT6); + rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); + haldata->RegReg542 &= ~(BIT0); + rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); + + /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ +} + +static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) +{ + u8 val8; + u8 mode = *((u8 *)val); + + /* disable Port0 TSF update */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + + /* set net_type */ + val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 |= mode; + rtw_write8(Adapter, MSR, val8); + + DBG_88E("%s()-%d mode = %d\n", __func__, __LINE__, mode); + + if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { + StopTxBeacon(Adapter); + + rtw_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ + } else if ((mode == _HW_STATE_ADHOC_)) { + ResumeTxBeacon(Adapter); + rtw_write8(Adapter, REG_BCN_CTRL, 0x1a); + } else if (mode == _HW_STATE_AP_) { + ResumeTxBeacon(Adapter); + + rtw_write8(Adapter, REG_BCN_CTRL, 0x12); + + /* Set RCR */ + rtw_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ + /* enable to rx data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + /* enable to rx ps-poll */ + rtw_write16(Adapter, REG_RXFLTMAP1, 0x0400); + + /* Beacon Control related register for first time */ + rtw_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ + + rtw_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ + rtw_write16(Adapter, REG_BCNTCFG, 0x00); + rtw_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); + rtw_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ + + /* reset TSF */ + rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); + + /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ + rtw_write8(Adapter, REG_MBID_NUM, rtw_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); + + /* enable BCN0 Function for if1 */ + /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ + rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION | BIT(1))); + + /* dis BCN1 ATIM WND if if2 is station */ + rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); + } +} + +static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val) +{ + u8 idx = 0; + u32 reg_macid; + + reg_macid = REG_MACID; + + for (idx = 0; idx < 6; idx++) + rtw_write8(Adapter, (reg_macid+idx), val[idx]); +} + +static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) +{ + u8 idx = 0; + u32 reg_bssid; + + reg_bssid = REG_BSSID; + + for (idx = 0; idx < 6; idx++) + rtw_write8(Adapter, (reg_bssid+idx), val[idx]); +} + +static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) +{ + u32 bcn_ctrl_reg; + + bcn_ctrl_reg = REG_BCN_CTRL; + + if (*((u8 *)val)) + rtw_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); + else + rtw_write8(Adapter, bcn_ctrl_reg, rtw_read8(Adapter, bcn_ctrl_reg)&(~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); +} + +static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct dm_priv *pdmpriv = &haldata->dmpriv; + struct odm_dm_struct *podmpriv = &haldata->odmpriv; + + switch (variable) { + case HW_VAR_MEDIA_STATUS: + { + u8 val8; + + val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 |= *((u8 *)val); + rtw_write8(Adapter, MSR, val8); + } + break; + case HW_VAR_MEDIA_STATUS1: + { + u8 val8; + + val8 = rtw_read8(Adapter, MSR) & 0x03; + val8 |= *((u8 *)val) << 2; + rtw_write8(Adapter, MSR, val8); + } + break; + case HW_VAR_SET_OPMODE: + hw_var_set_opmode(Adapter, variable, val); + break; + case HW_VAR_MAC_ADDR: + hw_var_set_macaddr(Adapter, variable, val); + break; + case HW_VAR_BSSID: + hw_var_set_bssid(Adapter, variable, val); + break; + case HW_VAR_BASIC_RATE: + { + u16 BrateCfg = 0; + u8 RateIndex = 0; + + /* 2007.01.16, by Emily */ + /* Select RRSR (in Legacy-OFDM and CCK) */ + /* For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, 2M, and 1M from the Basic rate. */ + /* We do not use other rates. */ + HalSetBrateCfg(Adapter, val, &BrateCfg); + DBG_88E("HW_VAR_BASIC_RATE: BrateCfg(%#x)\n", BrateCfg); + + /* 2011.03.30 add by Luke Lee */ + /* CCK 2M ACK should be disabled for some BCM and Atheros AP IOT */ + /* because CCK 2M has poor TXEVM */ + /* CCK 5.5M & 11M ACK should be enabled for better performance */ + + BrateCfg = (BrateCfg | 0xd) & 0x15d; + haldata->BasicRateSet = BrateCfg; + + BrateCfg |= 0x01; /* default enable 1M ACK rate */ + /* Set RRSR rate table. */ + rtw_write8(Adapter, REG_RRSR, BrateCfg & 0xff); + rtw_write8(Adapter, REG_RRSR+1, (BrateCfg >> 8) & 0xff); + rtw_write8(Adapter, REG_RRSR+2, rtw_read8(Adapter, REG_RRSR+2)&0xf0); + + /* Set RTS initial rate */ + while (BrateCfg > 0x1) { + BrateCfg = (BrateCfg >> 1); + RateIndex++; + } + /* Ziv - Check */ + rtw_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); + } + break; + case HW_VAR_TXPAUSE: + rtw_write8(Adapter, REG_TXPAUSE, *((u8 *)val)); + break; + case HW_VAR_BCN_FUNC: + hw_var_set_bcn_func(Adapter, variable, val); + break; + case HW_VAR_CORRECT_TSF: + { + u64 tsf; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */ + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + StopTxBeacon(Adapter); + + /* disable related TSF function */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); + + rtw_write32(Adapter, REG_TSFTR, tsf); + rtw_write32(Adapter, REG_TSFTR+4, tsf>>32); + + /* enable related TSF function */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(3)); + + if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + ResumeTxBeacon(Adapter); + } + break; + case HW_VAR_CHECK_BSSID: + if (*((u8 *)val)) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + } else { + u32 val32; + + val32 = rtw_read32(Adapter, REG_RCR); + + val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); + + rtw_write32(Adapter, REG_RCR, val32); + } + break; + case HW_VAR_MLME_DISCONNECT: + /* Set RCR to not to receive data frame when NO LINK state */ + /* reject all data frames */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + + /* reset TSF */ + rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); + + /* disable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + break; + case HW_VAR_MLME_SITESURVEY: + if (*((u8 *)val)) { /* under sitesurvey */ + /* config RCR to receive different BSSID & not to receive data frame */ + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_BCN); + rtw_write32(Adapter, REG_RCR, v); + /* reject all data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + + /* disable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + } else { /* sitesurvey done */ + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + if ((is_client_associated_to_ap(Adapter)) || + ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) { + /* enable to rx data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + } else if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + } + if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + } else { + if (Adapter->in_cta_test) { + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(Adapter, REG_RCR, v); + } else { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + } + } + } + break; + case HW_VAR_MLME_JOIN: + { + u8 RetryLimit = 0x30; + u8 type = *((u8 *)val); + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + + if (type == 0) { /* prepare to join */ + /* enable to rx data frame.Accept all data frame */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); + + if (Adapter->in_cta_test) { + u32 v = rtw_read32(Adapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(Adapter, REG_RCR, v); + } else { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + } + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + RetryLimit = (haldata->CustomerID == RT_CID_CCX) ? 7 : 48; + else /* Ad-hoc Mode */ + RetryLimit = 0x7; + } else if (type == 1) { + /* joinbss_event call back when join res < 0 */ + rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); + } else if (type == 2) { + /* sta add event call back */ + /* enable update TSF */ + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) + RetryLimit = 0x7; + } + rtw_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); + } + break; + case HW_VAR_BEACON_INTERVAL: + rtw_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); + break; + case HW_VAR_SLOT_TIME: + { + u8 u1bAIFS, aSifsTime; + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + rtw_write8(Adapter, REG_SLOT, val[0]); + + if (pmlmeinfo->WMM_enable == 0) { + if (pmlmeext->cur_wireless_mode == WIRELESS_11B) + aSifsTime = 10; + else + aSifsTime = 16; + + u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); + + /* Temporary removed, 2008.06.20. */ + rtw_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); + rtw_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); + } + } + break; + case HW_VAR_RESP_SIFS: + /* RESP_SIFS for CCK */ + rtw_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ + rtw_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ + /* RESP_SIFS for OFDM */ + rtw_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ + rtw_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ + break; + case HW_VAR_ACK_PREAMBLE: + { + u8 regTmp; + u8 bShortPreamble = *((bool *)val); + /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ + regTmp = (haldata->nCur40MhzPrimeSC)<<5; + if (bShortPreamble) + regTmp |= 0x80; + + rtw_write8(Adapter, REG_RRSR+2, regTmp); + } + break; + case HW_VAR_SEC_CFG: + rtw_write8(Adapter, REG_SECCFG, *((u8 *)val)); + break; + case HW_VAR_DM_FLAG: + podmpriv->SupportAbility = *((u8 *)val); + break; + case HW_VAR_DM_FUNC_OP: + if (val[0]) + podmpriv->BK_SupportAbility = podmpriv->SupportAbility; + else + podmpriv->SupportAbility = podmpriv->BK_SupportAbility; + break; + case HW_VAR_DM_FUNC_SET: + if (*((u32 *)val) == DYNAMIC_ALL_FUNC_ENABLE) { + pdmpriv->DMFlag = pdmpriv->InitDMFlag; + podmpriv->SupportAbility = pdmpriv->InitODMFlag; + } else { + podmpriv->SupportAbility |= *((u32 *)val); + } + break; + case HW_VAR_DM_FUNC_CLR: + podmpriv->SupportAbility &= *((u32 *)val); + break; + case HW_VAR_CAM_EMPTY_ENTRY: + { + u8 ucIndex = *((u8 *)val); + u8 i; + u32 ulCommand = 0; + u32 ulContent = 0; + u32 ulEncAlgo = CAM_AES; + + for (i = 0; i < CAM_CONTENT_COUNT; i++) { + /* filled id in CAM config 2 byte */ + if (i == 0) + ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo)<<2); + else + ulContent = 0; + /* polling bit, and No Write enable, and address */ + ulCommand = CAM_CONTENT_COUNT*ucIndex+i; + ulCommand = ulCommand | CAM_POLLINIG|CAM_WRITE; + /* write content 0 is equall to mark invalid */ + rtw_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ + rtw_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ + } + } + break; + case HW_VAR_CAM_INVALID_ALL: + rtw_write32(Adapter, RWCAM, BIT(31)|BIT(30)); + break; + case HW_VAR_CAM_WRITE: + { + u32 cmd; + u32 *cam_val = (u32 *)val; + rtw_write32(Adapter, WCAMI, cam_val[0]); + + cmd = CAM_POLLINIG | CAM_WRITE | cam_val[1]; + rtw_write32(Adapter, RWCAM, cmd); + } + break; + case HW_VAR_AC_PARAM_VO: + rtw_write32(Adapter, REG_EDCA_VO_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_VI: + rtw_write32(Adapter, REG_EDCA_VI_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_BE: + haldata->AcParam_BE = ((u32 *)(val))[0]; + rtw_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_AC_PARAM_BK: + rtw_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); + break; + case HW_VAR_ACM_CTRL: + { + u8 acm_ctrl = *((u8 *)val); + u8 AcmCtrl = rtw_read8(Adapter, REG_ACMHWCTRL); + + if (acm_ctrl > 1) + AcmCtrl = AcmCtrl | 0x1; + + if (acm_ctrl & BIT(3)) + AcmCtrl |= AcmHw_VoqEn; + else + AcmCtrl &= (~AcmHw_VoqEn); + + if (acm_ctrl & BIT(2)) + AcmCtrl |= AcmHw_ViqEn; + else + AcmCtrl &= (~AcmHw_ViqEn); + + if (acm_ctrl & BIT(1)) + AcmCtrl |= AcmHw_BeqEn; + else + AcmCtrl &= (~AcmHw_BeqEn); + + DBG_88E("[HW_VAR_ACM_CTRL] Write 0x%X\n", AcmCtrl); + rtw_write8(Adapter, REG_ACMHWCTRL, AcmCtrl); + } + break; + case HW_VAR_AMPDU_MIN_SPACE: + { + u8 MinSpacingToSet; + u8 SecMinSpace; + + MinSpacingToSet = *((u8 *)val); + if (MinSpacingToSet <= 7) { + switch (Adapter->securitypriv.dot11PrivacyAlgrthm) { + case _NO_PRIVACY_: + case _AES_: + SecMinSpace = 0; + break; + case _WEP40_: + case _WEP104_: + case _TKIP_: + case _TKIP_WTMIC_: + SecMinSpace = 6; + break; + default: + SecMinSpace = 7; + break; + } + if (MinSpacingToSet < SecMinSpace) + MinSpacingToSet = SecMinSpace; + rtw_write8(Adapter, REG_AMPDU_MIN_SPACE, (rtw_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); + } + } + break; + case HW_VAR_AMPDU_FACTOR: + { + u8 RegToSet_Normal[4] = {0x41, 0xa8, 0x72, 0xb9}; + u8 FactorToSet; + u8 *pRegToSet; + u8 index = 0; + + pRegToSet = RegToSet_Normal; /* 0xb972a841; */ + FactorToSet = *((u8 *)val); + if (FactorToSet <= 3) { + FactorToSet = (1<<(FactorToSet + 2)); + if (FactorToSet > 0xf) + FactorToSet = 0xf; + + for (index = 0; index < 4; index++) { + if ((pRegToSet[index] & 0xf0) > (FactorToSet<<4)) + pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet<<4); + + if ((pRegToSet[index] & 0x0f) > FactorToSet) + pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); + + rtw_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); + } + } + } + break; + case HW_VAR_RXDMA_AGG_PG_TH: + { + u8 threshold = *((u8 *)val); + if (threshold == 0) + threshold = haldata->UsbRxAggPageCount; + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); + } + break; + case HW_VAR_SET_RPWM: + break; + case HW_VAR_H2C_FW_PWRMODE: + { + u8 psmode = (*(u8 *)val); + + /* Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */ + /* saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */ + if ((psmode != PS_MODE_ACTIVE) && (!IS_92C_SERIAL(haldata->VersionID))) + ODM_RF_Saving(podmpriv, true); + rtl8188e_set_FwPwrMode_cmd(Adapter, psmode); + } + break; + case HW_VAR_H2C_FW_JOINBSSRPT: + { + u8 mstatus = (*(u8 *)val); + rtl8188e_set_FwJoinBssReport_cmd(Adapter, mstatus); + } + break; +#ifdef CONFIG_88EU_P2P + case HW_VAR_H2C_FW_P2P_PS_OFFLOAD: + { + u8 p2p_ps_state = (*(u8 *)val); + rtl8188e_set_p2p_ps_offload_cmd(Adapter, p2p_ps_state); + } + break; +#endif + case HW_VAR_INITIAL_GAIN: + { + struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; + u32 rx_gain = ((u32 *)(val))[0]; + + if (rx_gain == 0xff) {/* restore rx gain */ + ODM_Write_DIG(podmpriv, pDigTable->BackupIGValue); + } else { + pDigTable->BackupIGValue = pDigTable->CurIGValue; + ODM_Write_DIG(podmpriv, rx_gain); + } + } + break; + case HW_VAR_TRIGGER_GPIO_0: + rtl8192cu_trigger_gpio_0(Adapter); + break; + case HW_VAR_RPT_TIMER_SETTING: + { + u16 min_rpt_time = (*(u16 *)val); + ODM_RA_Set_TxRPT_Time(podmpriv, min_rpt_time); + } + break; + case HW_VAR_ANTENNA_DIVERSITY_SELECT: + { + u8 Optimum_antenna = (*(u8 *)val); + u8 Ant; + /* switch antenna to Optimum_antenna */ + if (haldata->CurAntenna != Optimum_antenna) { + Ant = (Optimum_antenna == 2) ? MAIN_ANT : AUX_ANT; + ODM_UpdateRxIdleAnt_88E(&haldata->odmpriv, Ant); + + haldata->CurAntenna = Optimum_antenna; + } + } + break; + case HW_VAR_EFUSE_BYTES: /* To set EFUE total used bytes, added by Roger, 2008.12.22. */ + haldata->EfuseUsedBytes = *((u16 *)val); + break; + case HW_VAR_FIFO_CLEARN_UP: + { + struct pwrctrl_priv *pwrpriv = &Adapter->pwrctrlpriv; + u8 trycnt = 100; + + /* pause tx */ + rtw_write8(Adapter, REG_TXPAUSE, 0xff); + + /* keep sn */ + Adapter->xmitpriv.nqos_ssn = rtw_read16(Adapter, REG_NQOS_SEQ); + + if (!pwrpriv->bkeepfwalive) { + /* RX DMA stop */ + rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + do { + if (!(rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) + break; + } while (trycnt--); + if (trycnt == 0) + DBG_88E("Stop RX DMA failed......\n"); + + /* RQPN Load 0 */ + rtw_write16(Adapter, REG_RQPN_NPQ, 0x0); + rtw_write32(Adapter, REG_RQPN, 0x80000000); + rtw_mdelay_os(10); + } + } + break; + case HW_VAR_CHECK_TXBUF: + break; + case HW_VAR_APFM_ON_MAC: + haldata->bMacPwrCtrlOn = *val; + DBG_88E("%s: bMacPwrCtrlOn=%d\n", __func__, haldata->bMacPwrCtrlOn); + break; + case HW_VAR_TX_RPT_MAX_MACID: + { + u8 maxMacid = *val; + DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n", maxMacid, maxMacid+1); + rtw_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); + } + break; + case HW_VAR_H2C_MEDIA_STATUS_RPT: + rtl8188e_set_FwMediaStatus_cmd(Adapter , (*(__le16 *)val)); + break; + case HW_VAR_BCN_VALID: + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ + rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT0); + break; + default: + break; + } + +} + +static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + struct odm_dm_struct *podmpriv = &haldata->odmpriv; + + switch (variable) { + case HW_VAR_BASIC_RATE: + *((u16 *)(val)) = haldata->BasicRateSet; + __attribute__((__fallthrough__)); + case HW_VAR_TXPAUSE: + val[0] = rtw_read8(Adapter, REG_TXPAUSE); + break; + case HW_VAR_BCN_VALID: + /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ + val[0] = (BIT0 & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; + break; + case HW_VAR_DM_FLAG: + val[0] = podmpriv->SupportAbility; + break; + case HW_VAR_RF_TYPE: + val[0] = haldata->rf_type; + break; + case HW_VAR_FWLPS_RF_ON: + { + /* When we halt NIC, we should check if FW LPS is leave. */ + if (Adapter->pwrctrlpriv.rf_pwrstate == rf_off) { + /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ + /* because Fw is unload. */ + val[0] = true; + } else { + u32 valRCR; + valRCR = rtw_read32(Adapter, REG_RCR); + valRCR &= 0x00070000; + if (valRCR) + val[0] = false; + else + val[0] = true; + } + } + break; + case HW_VAR_CURRENT_ANTENNA: + val[0] = haldata->CurAntenna; + break; + case HW_VAR_EFUSE_BYTES: /* To get EFUE total used bytes, added by Roger, 2008.12.22. */ + *((u16 *)(val)) = haldata->EfuseUsedBytes; + break; + case HW_VAR_APFM_ON_MAC: + *val = haldata->bMacPwrCtrlOn; + break; + case HW_VAR_CHK_HI_QUEUE_EMPTY: + *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00) == 0) ? true : false; + break; + default: + break; + } + +} + +/* */ +/* Description: */ +/* Query setting of specified variable. */ +/* */ +static u8 +GetHalDefVar8188EUsb( + struct adapter *Adapter, + enum hal_def_variable eVariable, + void *pValue + ) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 bResult = _SUCCESS; + + switch (eVariable) { + case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: + { + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; + struct sta_priv *pstapriv = &Adapter->stapriv; + struct sta_info *psta; + psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); + if (psta) + *((int *)pValue) = psta->rssi_stat.UndecoratedSmoothedPWDB; + } + break; + case HAL_DEF_IS_SUPPORT_ANT_DIV: + *((u8 *)pValue) = (haldata->AntDivCfg == 0) ? false : true; + break; + case HAL_DEF_CURRENT_ANTENNA: + *((u8 *)pValue) = haldata->CurAntenna; + break; + case HAL_DEF_DRVINFO_SZ: + *((u32 *)pValue) = DRVINFO_SZ; + break; + case HAL_DEF_MAX_RECVBUF_SZ: + *((u32 *)pValue) = MAX_RECVBUF_SZ; + break; + case HAL_DEF_RX_PACKET_OFFSET: + *((u32 *)pValue) = RXDESC_SIZE + DRVINFO_SZ; + break; + case HAL_DEF_DBG_DM_FUNC: + *((u32 *)pValue) = haldata->odmpriv.SupportAbility; + break; + case HAL_DEF_RA_DECISION_RATE: + { + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetDecisionRate_8188E(&(haldata->odmpriv), MacID); + } + break; + case HAL_DEF_RA_SGI: + { + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetShortGI_8188E(&(haldata->odmpriv), MacID); + } + break; + case HAL_DEF_PT_PWR_STATUS: + { + u8 MacID = *((u8 *)pValue); + *((u8 *)pValue) = ODM_RA_GetHwPwrStatus_8188E(&(haldata->odmpriv), MacID); + } + break; + case HW_VAR_MAX_RX_AMPDU_FACTOR: + *((u32 *)pValue) = MAX_AMPDU_FACTOR_64K; + break; + case HW_DEF_RA_INFO_DUMP: + { + u8 entry_id = *((u8 *)pValue); + if (check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) { + DBG_88E("============ RA status check ===================\n"); + DBG_88E("Mac_id:%d , RateID = %d, RAUseRate = 0x%08x, RateSGI = %d, DecisionRate = 0x%02x ,PTStage = %d\n", + entry_id, + haldata->odmpriv.RAInfo[entry_id].RateID, + haldata->odmpriv.RAInfo[entry_id].RAUseRate, + haldata->odmpriv.RAInfo[entry_id].RateSGI, + haldata->odmpriv.RAInfo[entry_id].DecisionRate, + haldata->odmpriv.RAInfo[entry_id].PTStage); + } + } + break; + case HW_DEF_ODM_DBG_FLAG: + { + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + pr_info("dm_ocm->DebugComponents = 0x%llx\n", dm_ocm->DebugComponents); + } + break; + case HAL_DEF_DBG_DUMP_RXPKT: + *((u8 *)pValue) = haldata->bDumpRxPkt; + break; + case HAL_DEF_DBG_DUMP_TXPKT: + *((u8 *)pValue) = haldata->bDumpTxPkt; + break; + default: + bResult = _FAIL; + break; + } + + return bResult; +} + +/* */ +/* Description: */ +/* Change default setting of specified variable. */ +/* */ +static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eVariable, void *pValue) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); + u8 bResult = _SUCCESS; + + switch (eVariable) { + case HAL_DEF_DBG_DM_FUNC: + { + u8 dm_func = *((u8 *)pValue); + struct odm_dm_struct *podmpriv = &haldata->odmpriv; + + if (dm_func == 0) { /* disable all dynamic func */ + podmpriv->SupportAbility = DYNAMIC_FUNC_DISABLE; + DBG_88E("==> Disable all dynamic function...\n"); + } else if (dm_func == 1) {/* disable DIG */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_DIG); + DBG_88E("==> Disable DIG...\n"); + } else if (dm_func == 2) {/* disable High power */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_DYNAMIC_TXPWR); + } else if (dm_func == 3) {/* disable tx power tracking */ + podmpriv->SupportAbility &= (~DYNAMIC_RF_CALIBRATION); + DBG_88E("==> Disable tx power tracking...\n"); + } else if (dm_func == 5) {/* disable antenna diversity */ + podmpriv->SupportAbility &= (~DYNAMIC_BB_ANT_DIV); + } else if (dm_func == 6) {/* turn on all dynamic func */ + if (!(podmpriv->SupportAbility & DYNAMIC_BB_DIG)) { + struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; + pDigTable->CurIGValue = rtw_read8(Adapter, 0xc50); + } + podmpriv->SupportAbility = DYNAMIC_ALL_FUNC_ENABLE; + DBG_88E("==> Turn on all dynamic function...\n"); + } + } + break; + case HAL_DEF_DBG_DUMP_RXPKT: + haldata->bDumpRxPkt = *((u8 *)pValue); + break; + case HAL_DEF_DBG_DUMP_TXPKT: + haldata->bDumpTxPkt = *((u8 *)pValue); + break; + case HW_DEF_FA_CNT_DUMP: + { + u8 bRSSIDump = *((u8 *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + if (bRSSIDump) + dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; + else + dm_ocm->DebugComponents = 0; + } + break; + case HW_DEF_ODM_DBG_FLAG: + { + u64 DebugComponents = *((u64 *)pValue); + struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); + dm_ocm->DebugComponents = DebugComponents; + } + break; + default: + bResult = _FAIL; + break; + } + + return bResult; +} + +static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level) +{ + u8 init_rate = 0; + u8 networkType, raid; + u32 mask, rate_bitmap; + u8 shortGIrate = false; + int supportRateNum = 0; + struct sta_info *psta; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + + if (mac_id >= NUM_STA) /* CAM_SIZE */ + return; + psta = pmlmeinfo->FW_sta_info[mac_id].psta; + if (psta == NULL) + return; + switch (mac_id) { + case 0:/* for infra mode */ + supportRateNum = rtw_get_rateset_len(cur_network->SupportedRates); + networkType = judge_network_type(adapt, cur_network->SupportedRates, supportRateNum) & 0xf; + raid = networktype_to_raid(networkType); + mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); + mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&(pmlmeinfo->HT_caps)) : 0; + if (support_short_GI(adapt, &(pmlmeinfo->HT_caps))) + shortGIrate = true; + break; + case 1:/* for broadcast/multicast */ + supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + if (pmlmeext->cur_wireless_mode & WIRELESS_11B) + networkType = WIRELESS_11B; + else + networkType = WIRELESS_11G; + raid = networktype_to_raid(networkType); + mask = update_basic_rate(cur_network->SupportedRates, supportRateNum); + break; + default: /* for each sta in IBSS */ + supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); + networkType = judge_network_type(adapt, pmlmeinfo->FW_sta_info[mac_id].SupportedRates, supportRateNum) & 0xf; + raid = networktype_to_raid(networkType); + mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); + + /* todo: support HT in IBSS */ + break; + } + + rate_bitmap = 0x0fffffff; + rate_bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, mac_id, mask, rssi_level); + DBG_88E("%s => mac_id:%d, networkType:0x%02x, mask:0x%08x\n\t ==> rssi_level:%d, rate_bitmap:0x%08x\n", + __func__, mac_id, networkType, mask, rssi_level, rate_bitmap); + + mask &= rate_bitmap; + + init_rate = get_highest_rate_idx(mask)&0x3f; + + if (haldata->fw_ractrl) { + u8 arg; + + arg = mac_id & 0x1f;/* MACID */ + arg |= BIT(7); + if (shortGIrate) + arg |= BIT(5); + mask |= ((raid << 28) & 0xf0000000); + DBG_88E("update raid entry, mask=0x%x, arg=0x%x\n", mask, arg); + psta->ra_mask = mask; + mask |= ((raid << 28) & 0xf0000000); + + /* to do ,for 8188E-SMIC */ + rtl8188e_set_raid_cmd(adapt, mask); + } else { + ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), + mac_id, + raid, + mask, + shortGIrate + ); + } + /* set ra_id */ + psta->raid = raid; + psta->init_rate = init_rate; +} + +static void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) +{ + u32 value32; + struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + u32 bcn_ctrl_reg = REG_BCN_CTRL; + /* reset TSF, enable update TSF, correcting TSF On Beacon */ + + /* BCN interval */ + rtw_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); + rtw_write8(adapt, REG_ATIMWND, 0x02);/* 2ms */ + + _InitBeaconParameters(adapt); + + rtw_write8(adapt, REG_SLOT, 0x09); + + value32 = rtw_read32(adapt, REG_TCR); + value32 &= ~TSFRST; + rtw_write32(adapt, REG_TCR, value32); + + value32 |= TSFRST; + rtw_write32(adapt, REG_TCR, value32); + + /* NOTE: Fix test chip's bug (about contention windows's randomness) */ + rtw_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); + rtw_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); + + _BeaconFunctionEnable(adapt, true, true); + + ResumeTxBeacon(adapt); + + rtw_write8(adapt, bcn_ctrl_reg, rtw_read8(adapt, bcn_ctrl_reg)|BIT(1)); +} + +static void rtl8188eu_init_default_value(struct adapter *adapt) +{ + struct hal_data_8188e *haldata; + struct pwrctrl_priv *pwrctrlpriv; + u8 i; + + haldata = GET_HAL_DATA(adapt); + pwrctrlpriv = &adapt->pwrctrlpriv; + + /* init default value */ + haldata->fw_ractrl = false; + if (!pwrctrlpriv->bkeepfwalive) + haldata->LastHMEBoxNum = 0; + + /* init dm default value */ + haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = false; + haldata->odmpriv.RFCalibrateInfo.TM_Trigger = 0;/* for IQK */ + haldata->pwrGroupCnt = 0; + haldata->PGMaxGroup = 13; + haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP_index = 0; + for (i = 0; i < HP_THERMAL_NUM; i++) + haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; +} + +static u8 rtl8188eu_ps_func(struct adapter *Adapter, enum hal_intf_ps_func efunc_id, u8 *val) +{ + u8 bResult = true; + return bResult; +} + +void rtl8188eu_set_hal_ops(struct adapter *adapt) +{ + struct hal_ops *halfunc = &adapt->HalFunc; + + adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); + if (adapt->HalData == NULL) + DBG_88E("cant not alloc memory for HAL DATA\n"); + adapt->hal_data_sz = sizeof(struct hal_data_8188e); + + halfunc->hal_power_on = rtl8188eu_InitPowerOn; + halfunc->hal_init = &rtl8188eu_hal_init; + halfunc->hal_deinit = &rtl8188eu_hal_deinit; + + halfunc->inirp_init = &rtl8188eu_inirp_init; + halfunc->inirp_deinit = &rtl8188eu_inirp_deinit; + + halfunc->init_xmit_priv = &rtl8188eu_init_xmit_priv; + halfunc->free_xmit_priv = &rtl8188eu_free_xmit_priv; + + halfunc->init_recv_priv = &rtl8188eu_init_recv_priv; + halfunc->free_recv_priv = &rtl8188eu_free_recv_priv; + halfunc->InitSwLeds = &rtl8188eu_InitSwLeds; + halfunc->DeInitSwLeds = &rtl8188eu_DeInitSwLeds; + + halfunc->init_default_value = &rtl8188eu_init_default_value; + halfunc->intf_chip_configure = &rtl8188eu_interface_configure; + halfunc->read_adapter_info = &ReadAdapterInfo8188EU; + + halfunc->SetHwRegHandler = &SetHwReg8188EU; + halfunc->GetHwRegHandler = &GetHwReg8188EU; + halfunc->GetHalDefVarHandler = &GetHalDefVar8188EUsb; + halfunc->SetHalDefVarHandler = &SetHalDefVar8188EUsb; + + halfunc->UpdateRAMaskHandler = &UpdateHalRAMask8188EUsb; + halfunc->SetBeaconRelatedRegistersHandler = &SetBeaconRelatedRegisters8188EUsb; + + halfunc->hal_xmit = &rtl8188eu_hal_xmit; + halfunc->mgnt_xmit = &rtl8188eu_mgnt_xmit; + + halfunc->interface_ps_func = &rtl8188eu_ps_func; + + rtl8188e_set_hal_ops(halfunc); + +} diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c new file mode 100644 index 000000000000..d31f0be4c8a6 --- /dev/null +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -0,0 +1,717 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HCI_OPS_OS_C_ + +#include +#include +#include +#include +#include +#include + +static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +{ + struct adapter *adapt = pintfhdl->padapter; + struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); + struct usb_device *udev = dvobjpriv->pusbdev; + unsigned int pipe; + int status = 0; + u8 reqtype; + u8 *pIo_buf; + int vendorreq_times = 0; + + if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + status = -EPERM; + goto exit; + } + + if (len > MAX_VENDOR_REQ_CMD_SIZE) { + DBG_88E("[%s] Buffer len error ,vendor request failed\n", __func__); + status = -EINVAL; + goto exit; + } + + _enter_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); + + /* Acquire IO memory for vendorreq */ + pIo_buf = dvobjpriv->usb_vendor_req_buf; + + if (pIo_buf == NULL) { + DBG_88E("[%s] pIo_buf == NULL\n", __func__); + status = -ENOMEM; + goto release_mutex; + } + + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + memset(pIo_buf, 0, len); + + if (requesttype == 0x01) { + pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ + reqtype = REALTEK_USB_VENQT_READ; + } else { + pipe = usb_sndctrlpipe(udev, 0);/* write_out */ + reqtype = REALTEK_USB_VENQT_WRITE; + memcpy(pIo_buf, pdata, len); + } + + status = rtw_usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + + if (status == len) { /* Success this control transfer. */ + rtw_reset_continual_urb_error(dvobjpriv); + if (requesttype == 0x01) + memcpy(pdata, pIo_buf, len); + } else { /* error cases */ + DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n", + value, (requesttype == 0x01) ? "read" : "write", + len, status, *(u32 *)pdata, vendorreq_times); + + if (status < 0) { + if (status == (-ESHUTDOWN) || status == -ENODEV) { + adapt->bSurpriseRemoved = true; + } else { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; + } + } else { /* status != len && status >= 0 */ + if (status > 0) { + if (requesttype == 0x01) { + /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ + memcpy(pdata, pIo_buf, len); + } + } + } + + if (rtw_inc_and_chk_continual_urb_error(dvobjpriv)) { + adapt->bSurpriseRemoved = true; + break; + } + + } + + /* firmware download is checksumed, don't retry */ + if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) + break; + } +release_mutex: + _exit_critical_mutex(&dvobjpriv->usb_vendor_req_mutex, NULL); +exit: + return status; +} + +static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 data = 0; + + + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 1; + + usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + + + return data; + +} + +static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + wvalue = (u16)(addr&0x0000ffff); + len = 2; + usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + return (u16)(le32_to_cpu(data)&0xffff); +} + +static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + + request = 0x05; + requesttype = 0x01;/* read_in */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 4; + + usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + return le32_to_cpu(data); +} + +static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 data; + int ret; + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + wvalue = (u16)(addr&0x0000ffff); + len = 1; + data = val; + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + return ret; +} + +static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + int ret; + + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 2; + + data = cpu_to_le32(val & 0x0000ffff); + + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + + + return ret; +} + +static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + __le32 data; + int ret; + + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = 4; + data = cpu_to_le32(val); + + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + + + + return ret; +} + +static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) +{ + u8 request; + u8 requesttype; + u16 wvalue; + u16 index; + u16 len; + u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; + int ret; + + + + request = 0x05; + requesttype = 0x00;/* write_out */ + index = 0;/* n/a */ + + wvalue = (u16)(addr&0x0000ffff); + len = length; + memcpy(buf, pdata, len); + + ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); + + + + return ret; +} + +static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) +{ + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + + if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) { + DBG_88E("%s Invalid interrupt content length (%d)!\n", __func__, pkt_len); + return; + } + + /* HISR */ + memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); + memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); + + /* C2H Event */ + if (pbuf[0] != 0) + memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); +} + +static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) +{ + u8 *pbuf; + u8 shift_sz = 0; + u16 pkt_cnt; + u32 pkt_offset, skb_len, alloc_sz; + s32 transfer_len; + struct recv_stat *prxstat; + struct phy_stat *pphy_status = NULL; + struct sk_buff *pkt_copy = NULL; + struct recv_frame *precvframe = NULL; + struct rx_pkt_attrib *pattrib = NULL; + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + struct recv_priv *precvpriv = &adapt->recvpriv; + struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; + + transfer_len = (s32)pskb->len; + pbuf = pskb->data; + + prxstat = (struct recv_stat *)pbuf; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; + + do { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, + ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", + prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); + + prxstat = (struct recv_stat *)pbuf; + + precvframe = rtw_alloc_recvframe(pfree_recv_queue); + if (precvframe == NULL) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); + DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); + goto _exit_recvbuf2recvframe; + } + + INIT_LIST_HEAD(&precvframe->list); + precvframe->precvbuf = NULL; /* can't access the precvbuf for new arch. */ + precvframe->len = 0; + + update_recvframe_attrib_88e(precvframe, prxstat); + + pattrib = &precvframe->attrib; + + if ((pattrib->crc_err) || (pattrib->icv_err)) { + DBG_88E("%s: RX Warning! crc_err=%d icv_err=%d, skip!\n", __func__, pattrib->crc_err, pattrib->icv_err); + + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + + if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) + pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET); + + pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; + + if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); + DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + + /* Modified by Albert 20101213 */ + /* For 8 bytes IP header alignment. */ + if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ + shift_sz = 6; + else + shift_sz = 0; + + skb_len = pattrib->pkt_len; + + /* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */ + /* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */ + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + if (skb_len <= 1650) + alloc_sz = 1664; + else + alloc_sz = skb_len + 14; + } else { + alloc_sz = skb_len; + /* 6 is for IP header 8 bytes alignment in QoS packet case. */ + /* 8 is for skb->data 4 bytes alignment. */ + alloc_sz += 14; + } + + pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); + if (pkt_copy) { + pkt_copy->dev = adapt->pnetdev; + precvframe->pkt = pkt_copy; + precvframe->rx_head = pkt_copy->data; + precvframe->rx_end = pkt_copy->data + alloc_sz; + skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ + skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ + memcpy(pkt_copy->data, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); + precvframe->rx_tail = pkt_copy->data; + precvframe->rx_data = pkt_copy->data; + } else { + if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { + DBG_88E("recvbuf2recvframe: alloc_skb fail , drop frag frame\n"); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + precvframe->pkt = skb_clone(pskb, GFP_ATOMIC); + if (precvframe->pkt) { + precvframe->rx_tail = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE; + precvframe->rx_head = precvframe->rx_tail; + precvframe->rx_data = precvframe->rx_tail; + precvframe->rx_end = pbuf + pattrib->drvinfo_sz + RXDESC_SIZE + alloc_sz; + } else { + DBG_88E("recvbuf2recvframe: skb_clone fail\n"); + rtw_free_recvframe(precvframe, pfree_recv_queue); + goto _exit_recvbuf2recvframe; + } + } + + recvframe_put(precvframe, skb_len); + + switch (haldata->UsbRxAggMode) { + case USB_RX_AGG_DMA: + case USB_RX_AGG_MIX: + pkt_offset = (u16)_RND128(pkt_offset); + break; + case USB_RX_AGG_USB: + pkt_offset = (u16)_RND4(pkt_offset); + break; + case USB_RX_AGG_DISABLE: + default: + break; + } + if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ + if (pattrib->physt) + update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status); + if (rtw_recv_entry(precvframe) != _SUCCESS) { + RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, + ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); + } + } else { + /* enqueue recvframe to txrtp queue */ + if (pattrib->pkt_rpt_type == TX_REPORT1) { + /* CCX-TXRPT ack for xmit mgmt frames. */ + handle_txrpt_ccx_88e(adapt, precvframe->rx_data); + } else if (pattrib->pkt_rpt_type == TX_REPORT2) { + ODM_RA_TxRPT2Handle_8188E( + &haldata->odmpriv, + precvframe->rx_data, + pattrib->pkt_len, + pattrib->MacIDValidEntry[0], + pattrib->MacIDValidEntry[1] + ); + } else if (pattrib->pkt_rpt_type == HIS_REPORT) { + interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->rx_data); + } + rtw_free_recvframe(precvframe, pfree_recv_queue); + } + pkt_cnt--; + transfer_len -= pkt_offset; + pbuf += pkt_offset; + precvframe = NULL; + pkt_copy = NULL; + + if (transfer_len > 0 && pkt_cnt == 0) + pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; + + } while ((transfer_len > 0) && (pkt_cnt > 0)); + +_exit_recvbuf2recvframe: + + return _SUCCESS; +} + +void rtl8188eu_recv_tasklet(void *priv) +{ + struct sk_buff *pskb; + struct adapter *adapt = (struct adapter *)priv; + struct recv_priv *precvpriv = &adapt->recvpriv; + + while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { + if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) { + DBG_88E("recv_tasklet => bDriverStopped or bSurpriseRemoved\n"); + dev_kfree_skb_any(pskb); + break; + } + recvbuf2recvframe(adapt, pskb); + skb_reset_tail_pointer(pskb); + pskb->len = 0; + skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); + } +} + +static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) +{ + struct recv_buf *precvbuf = (struct recv_buf *)purb->context; + struct adapter *adapt = (struct adapter *)precvbuf->adapter; + struct recv_priv *precvpriv = &adapt->recvpriv; + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); + + precvpriv->rx_pending_cnt--; + + if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", + adapt->bDriverStopped, adapt->bSurpriseRemoved)); + + precvbuf->reuse = true; + DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", + __func__, adapt->bDriverStopped, + adapt->bSurpriseRemoved, adapt->bReadPortCancel); + return; + } + + if (purb->status == 0) { /* SUCCESS */ + if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); + precvbuf->reuse = true; + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); + } else { + rtw_reset_continual_urb_error(adapter_to_dvobj(adapt)); + + precvbuf->transfer_len = purb->actual_length; + skb_put(precvbuf->pskb, purb->actual_length); + skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); + + if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1) + tasklet_schedule(&precvpriv->recv_tasklet); + + precvbuf->pskb = NULL; + precvbuf->reuse = false; + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + } + } else { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); + + DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); + skb_put(precvbuf->pskb, purb->actual_length); + precvbuf->pskb = NULL; + + if (rtw_inc_and_chk_continual_urb_error(adapter_to_dvobj(adapt))) + adapt->bSurpriseRemoved = true; + + switch (purb->status) { + case -EINVAL: + case -EPIPE: + case -ENODEV: + case -ESHUTDOWN: + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bSurpriseRemoved=true\n")); + __attribute__((__fallthrough__)); + case -ENOENT: + adapt->bDriverStopped = true; + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); + break; + case -EPROTO: + case -EOVERFLOW: + { + struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); + haldata->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; + } + precvbuf->reuse = true; + rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); + break; + case -EINPROGRESS: + DBG_88E("ERROR: URB IS IN PROGRESS!/n"); + break; + default: + break; + } + } +} + +static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +{ + struct urb *purb = NULL; + struct recv_buf *precvbuf = (struct recv_buf *)rmem; + struct adapter *adapter = pintfhdl->padapter; + struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); + struct recv_priv *precvpriv = &adapter->recvpriv; + struct usb_device *pusbd = pdvobj->pusbdev; + int err; + unsigned int pipe; + size_t tmpaddr = 0; + size_t alignment = 0; + u32 ret = _SUCCESS; + + if (adapter->bDriverStopped || adapter->bSurpriseRemoved || + adapter->pwrctrlpriv.pnp_bstop_trx) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + return _FAIL; + } + + if (!precvbuf) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_read_port:precvbuf==NULL\n")); + return _FAIL; + } + + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); + if (NULL != precvbuf->pskb) + precvbuf->reuse = true; + } + + rtl8188eu_init_recvbuf(adapter, precvbuf); + + /* re-assign for linux based on skb */ + if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); + if (precvbuf->pskb == NULL) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); + DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); + return _FAIL; + } + + tmpaddr = (size_t)precvbuf->pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); + + precvbuf->phead = precvbuf->pskb->head; + precvbuf->pdata = precvbuf->pskb->data; + precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); + precvbuf->pend = skb_end_pointer(precvbuf->pskb); + precvbuf->pbuf = precvbuf->pskb->data; + } else { /* reuse skb */ + precvbuf->phead = precvbuf->pskb->head; + precvbuf->pdata = precvbuf->pskb->data; + precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); + precvbuf->pend = skb_end_pointer(precvbuf->pskb); + precvbuf->pbuf = precvbuf->pskb->data; + + precvbuf->reuse = false; + } + + precvpriv->rx_pending_cnt++; + + purb = precvbuf->purb; + + /* translate DMA FIFO addr to pipehandle */ + pipe = ffaddr2pipehdl(pdvobj, addr); + + usb_fill_bulk_urb(purb, pusbd, pipe, + precvbuf->pbuf, + MAX_RECVBUF_SZ, + usb_read_port_complete, + precvbuf);/* context is precvbuf */ + + err = usb_submit_urb(purb, GFP_ATOMIC); + if ((err) && (err != (-EPERM))) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", + err, purb->status)); + DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", + err, purb->status); + ret = _FAIL; + } + + return ret; +} + +void rtl8188eu_xmit_tasklet(void *priv) +{ + int ret = false; + struct adapter *adapt = (struct adapter *)priv; + struct xmit_priv *pxmitpriv = &adapt->xmitpriv; + + if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) + return; + + while (1) { + if ((adapt->bDriverStopped) || + (adapt->bSurpriseRemoved) || + (adapt->bWritePortCancel)) { + DBG_88E("xmit_tasklet => bDriverStopped or bSurpriseRemoved or bWritePortCancel\n"); + break; + } + + ret = rtl8188eu_xmitframe_complete(adapt, pxmitpriv, NULL); + + if (!ret) + break; + } +} + +void rtl8188eu_set_intf_ops(struct _io_ops *pops) +{ + + memset((u8 *)pops, 0, sizeof(struct _io_ops)); + pops->_read8 = &usb_read8; + pops->_read16 = &usb_read16; + pops->_read32 = &usb_read32; + pops->_read_mem = &usb_read_mem; + pops->_read_port = &usb_read_port; + pops->_write8 = &usb_write8; + pops->_write16 = &usb_write16; + pops->_write32 = &usb_write32; + pops->_writeN = &usb_writeN; + pops->_write_mem = &usb_write_mem; + pops->_write_port = &usb_write_port; + pops->_read_port_cancel = &usb_read_port_cancel; + pops->_write_port_cancel = &usb_write_port_cancel; + +} + +void rtl8188eu_set_hw_type(struct adapter *adapt) +{ + adapt->chip_type = RTL8188E; + adapt->HardwareType = HARDWARE_TYPE_RTL8188EU; + DBG_88E("CHIP TYPE: RTL8188E\n"); +} -- cgit v1.2.3 From 2b42bd58b32155a1be4dd78991845dec05aaef9e Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 28 Jul 2021 00:22:16 +0100 Subject: staging: r8188eu: introduce new os_dep dir for RTL8188eu driver This patchset is split in order to keep the file sizes down. This os_dep directory is part of the newer/better driver from GitHub modified by Larry Finger. Import this as the basis for all future work going forward. Suggested-by: Larry Finger Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210727232219.2948-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 8178 ++++++++++++++++++++++++ drivers/staging/r8188eu/os_dep/mlme_linux.c | 302 + drivers/staging/r8188eu/os_dep/os_intfs.c | 1283 ++++ drivers/staging/r8188eu/os_dep/osdep_service.c | 535 ++ drivers/staging/r8188eu/os_dep/recv_linux.c | 270 + drivers/staging/r8188eu/os_dep/rtw_android.c | 303 + drivers/staging/r8188eu/os_dep/usb_intf.c | 863 +++ drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 283 + drivers/staging/r8188eu/os_dep/xmit_linux.c | 282 + 9 files changed, 12299 insertions(+) create mode 100644 drivers/staging/r8188eu/os_dep/ioctl_linux.c create mode 100644 drivers/staging/r8188eu/os_dep/mlme_linux.c create mode 100644 drivers/staging/r8188eu/os_dep/os_intfs.c create mode 100644 drivers/staging/r8188eu/os_dep/osdep_service.c create mode 100644 drivers/staging/r8188eu/os_dep/recv_linux.c create mode 100644 drivers/staging/r8188eu/os_dep/rtw_android.c create mode 100644 drivers/staging/r8188eu/os_dep/usb_intf.c create mode 100644 drivers/staging/r8188eu/os_dep/usb_ops_linux.c create mode 100644 drivers/staging/r8188eu/os_dep/xmit_linux.c (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c new file mode 100644 index 000000000000..faced0d0af1d --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -0,0 +1,8178 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _IOCTL_LINUX_C_ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) + +#define SCAN_ITEM_SIZE 768 +#define MAX_CUSTOM_LEN 64 +#define RATE_COUNT 4 + +/* combo scan */ +#define WEXT_CSCAN_AMOUNT 9 +#define WEXT_CSCAN_BUF_LEN 360 +#define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00" +#define WEXT_CSCAN_HEADER_SIZE 12 +#define WEXT_CSCAN_SSID_SECTION 'S' +#define WEXT_CSCAN_CHANNEL_SECTION 'C' +#define WEXT_CSCAN_NPROBE_SECTION 'N' +#define WEXT_CSCAN_ACTV_DWELL_SECTION 'A' +#define WEXT_CSCAN_PASV_DWELL_SECTION 'P' +#define WEXT_CSCAN_HOME_DWELL_SECTION 'H' +#define WEXT_CSCAN_TYPE_SECTION 'T' + +static struct mp_ioctl_handler mp_ioctl_hdl[] = { +/*0*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_start_test_hdl, OID_RT_PRO_START_TEST) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_stop_test_hdl, OID_RT_PRO_STOP_TEST) + + GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_read_register_hdl, OID_RT_PRO_READ_REGISTER) + GEN_HANDLER(sizeof(struct rwreg_param), rtl8188eu_oid_rt_pro_write_register_hdl, OID_RT_PRO_WRITE_REGISTER) + GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_read_bb_reg_hdl, OID_RT_PRO_READ_BB_REG) +/*5*/ GEN_HANDLER(sizeof(struct bb_reg_param), rtl8188eu_oid_rt_pro_write_bb_reg_hdl, OID_RT_PRO_WRITE_BB_REG) + GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_read_rf_reg_hdl, OID_RT_PRO_RF_READ_REGISTRY) + GEN_HANDLER(sizeof(struct rf_reg_param), rtl8188eu_oid_rt_pro_write_rf_reg_hdl, OID_RT_PRO_RF_WRITE_REGISTRY) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl, OID_RT_PRO_SET_CHANNEL_DIRECT_CALL) + GEN_HANDLER(sizeof(struct txpower_param), rtl8188eu_oid_rt_pro_set_tx_power_control_hdl, OID_RT_PRO_SET_TX_POWER_CONTROL) +/*10*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_data_rate_hdl, OID_RT_PRO_SET_DATA_RATE) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_bandwidth_hdl, OID_RT_SET_BANDWIDTH) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_antenna_bb_hdl, OID_RT_PRO_SET_ANTENNA_BB) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_continuous_tx_hdl, OID_RT_PRO_SET_CONTINUOUS_TX) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl, OID_RT_PRO_SET_SINGLE_CARRIER_TX) +/*15*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl, OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl, OID_RT_PRO_SET_SINGLE_TONE_TX) + + EXT_MP_IOCTL_HANDLER(0, xmit_packet, 0) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_set_rx_packet_type_hdl, OID_RT_SET_RX_PACKET_TYPE) + GEN_HANDLER(0, rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl, OID_RT_RESET_PHY_RX_PACKET_COUNT) +/*20*/ GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl, OID_RT_GET_PHY_RX_PACKET_RECEIVED) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl, OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR) + + GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) + GEN_HANDLER(sizeof(struct eeprom_rw_param), NULL, 0) + GEN_HANDLER(sizeof(struct efuse_access_struct), rtl8188eu_oid_rt_pro_efuse_hdl, OID_RT_PRO_EFUSE) +/*25*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_efuse_map_hdl, OID_RT_PRO_EFUSE_MAP) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_max_size_hdl, OID_RT_GET_EFUSE_MAX_SIZE) + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_efuse_current_size_hdl, OID_RT_GET_EFUSE_CURRENT_SIZE) + + GEN_HANDLER(sizeof(u32), rtl8188eu_oid_rt_get_thermal_meter_hdl, OID_RT_PRO_GET_THERMAL_METER) + GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_pro_set_power_tracking_hdl, OID_RT_PRO_SET_POWER_TRACKING) +/*30*/ GEN_HANDLER(sizeof(u8), rtl8188eu_oid_rt_set_power_down_hdl, OID_RT_SET_POWER_DOWN) +/*31*/ GEN_HANDLER(0, rtl8188eu_oid_rt_pro_trigger_gpio_hdl, 0) +}; + +static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, + 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, + 48000000, 54000000}; + +static const char * const iw_operation_mode[] = { + "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", + "Secondary", "Monitor" +}; + +static int hex2num_i(char c) +{ + if (c >= '0' && c <= '9') + return c - '0'; + if (c >= 'a' && c <= 'f') + return c - 'a' + 10; + if (c >= 'A' && c <= 'F') + return c - 'A' + 10; + return -1; +} + +/** + * hwaddr_aton - Convert ASCII string to MAC address + * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") + * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) + * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) + */ +static int hwaddr_aton_i(const char *txt, u8 *addr) +{ + int i; + + for (i = 0; i < 6; i++) { + int a, b; + + a = hex2num_i(*txt++); + if (a < 0) + return -1; + b = hex2num_i(*txt++); + if (b < 0) + return -1; + *addr++ = (a << 4) | b; + if (i < 5 && *txt++ != ':') + return -1; + } + + return 0; +} + +void indicate_wx_scan_complete_event(struct adapter *padapter) +{ + union iwreq_data wrqu; + + memset(&wrqu, 0, sizeof(union iwreq_data)); + wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL); +} + +void rtw_indicate_wx_assoc_event(struct adapter *padapter) +{ + union iwreq_data wrqu; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + memset(&wrqu, 0, sizeof(union iwreq_data)); + + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN); + + DBG_88E_LEVEL(_drv_always_, "assoc success\n"); + wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); +} + +void rtw_indicate_wx_disassoc_event(struct adapter *padapter) +{ + union iwreq_data wrqu; + + memset(&wrqu, 0, sizeof(union iwreq_data)); + + wrqu.ap_addr.sa_family = ARPHRD_ETHER; + memset(wrqu.ap_addr.sa_data, 0, ETH_ALEN); + + DBG_88E_LEVEL(_drv_always_, "indicate disassoc\n"); + wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); +} + +static char *translate_scan(struct adapter *padapter, + struct iw_request_info *info, + struct wlan_network *pnetwork, + char *start, char *stop) +{ + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct iw_event iwe; + u16 cap; + __le16 le_tmp; + u32 ht_ielen = 0; + char *custom; + char *p; + u16 max_rate = 0, rate, ht_cap = false; + u32 i = 0; + u8 bw_40MHz = 0, short_GI = 0; + u16 mcs_rate = 0; + u8 ss, sq; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + u32 blnGotP2PIE = false; + + /* User is doing the P2P device discovery */ + /* The prefix of SSID should be "DIRECT-" and the IE should contains the P2P IE. */ + /* If not, the driver should ignore this AP and go to the next AP. */ + + /* Verifying the SSID */ + if (!memcmp(pnetwork->network.Ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN)) { + u32 p2pielen = 0; + + if (pnetwork->network.Reserved[0] == 2) {/* Probe Request */ + /* Verifying the P2P IE */ + if (rtw_get_p2p_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &p2pielen)) + blnGotP2PIE = true; + } else {/* Beacon or Probe Respones */ + /* Verifying the P2P IE */ + if (rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen)) + blnGotP2PIE = true; + } + } + + if (!blnGotP2PIE) + return start; + } +#endif /* CONFIG_88EU_P2P */ + + /* AP MAC address */ + iwe.cmd = SIOCGIWAP; + iwe.u.ap_addr.sa_family = ARPHRD_ETHER; + + memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN); + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); + + /* Add the ESSID */ + iwe.cmd = SIOCGIWESSID; + iwe.u.data.flags = 1; + iwe.u.data.length = min_t(u16, pnetwork->network.Ssid.SsidLength, 32); + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); + + /* parsing HT_CAP_IE */ + p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); + + if (p && ht_ielen > 0) { + struct ieee80211_ht_cap *pht_capie; + + ht_cap = true; + pht_capie = (struct ieee80211_ht_cap *)(p+2); + memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); + bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & + IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; + short_GI = (le16_to_cpu(pht_capie->cap_info) & + (IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; + } + + /* Add the protocol name */ + iwe.cmd = SIOCGIWNAME; + if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates))) { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); + } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); + } else { + if (pnetwork->network.Configuration.DSConfig > 14) { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); + } else { + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); + } + } + + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); + + /* Add mode */ + iwe.cmd = SIOCGIWMODE; + memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.IEs), 2); + + cap = le16_to_cpu(le_tmp); + + if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_BSS)) { + if (cap & WLAN_CAPABILITY_BSS) + iwe.u.mode = IW_MODE_MASTER; + else + iwe.u.mode = IW_MODE_ADHOC; + + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); + } + + if (pnetwork->network.Configuration.DSConfig < 1) + pnetwork->network.Configuration.DSConfig = 1; + + /* Add frequency/channel */ + iwe.cmd = SIOCGIWFREQ; + iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000; + iwe.u.freq.e = 1; + iwe.u.freq.i = pnetwork->network.Configuration.DSConfig; + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); + + /* Add encryption capability */ + iwe.cmd = SIOCGIWENCODE; + if (cap & WLAN_CAPABILITY_PRIVACY) + iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; + else + iwe.u.data.flags = IW_ENCODE_DISABLED; + iwe.u.data.length = 0; + start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); + + /*Add basic and extended rates */ + max_rate = 0; + custom = kzalloc(MAX_CUSTOM_LEN, GFP_ATOMIC); + if (!custom) + return start; + p = custom; + p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); + while (pnetwork->network.SupportedRates[i] != 0) { + rate = pnetwork->network.SupportedRates[i]&0x7F; + if (rate > max_rate) + max_rate = rate; + p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), + "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); + i++; + } + + if (ht_cap) { + if (mcs_rate&0x8000)/* MCS15 */ + max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); + else if (mcs_rate&0x0080)/* MCS7 */ + ; + else/* default MCS7 */ + max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); + + max_rate = max_rate*2;/* Mbps/2; */ + } + + iwe.cmd = SIOCGIWRATE; + iwe.u.bitrate.fixed = 0; + iwe.u.bitrate.disabled = 0; + iwe.u.bitrate.value = max_rate * 500000; + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); + + /* parsing WPA/WPA2 IE */ + { + u8 *buf; + u8 *wpa_ie, *rsn_ie; + u16 wpa_len = 0, rsn_len = 0; + u8 *p; + + buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC); + if (!buf) + goto exit; + wpa_ie = kzalloc(255, GFP_ATOMIC); + if (!wpa_ie) { + kfree(buf); + goto exit; + } + rsn_ie = kzalloc(255, GFP_ATOMIC); + if (!rsn_ie) { + kfree(buf); + kfree(wpa_ie); + goto exit; + } + rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); + + if (wpa_len > 0) { + p = buf; + memset(buf, 0, MAX_WPA_IE_LEN); + p += sprintf(p, "wpa_ie ="); + for (i = 0; i < wpa_len; i++) + p += sprintf(p, "%02x", wpa_ie[i]); + + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + iwe.u.data.length = strlen(buf); + start = iwe_stream_add_point(info, start, stop, &iwe, buf); + + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = wpa_len; + start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); + } + if (rsn_len > 0) { + p = buf; + memset(buf, 0, MAX_WPA_IE_LEN); + p += sprintf(p, "rsn_ie ="); + for (i = 0; i < rsn_len; i++) + p += sprintf(p, "%02x", rsn_ie[i]); + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVCUSTOM; + iwe.u.data.length = strlen(buf); + start = iwe_stream_add_point(info, start, stop, &iwe, buf); + + memset(&iwe, 0, sizeof(iwe)); + iwe.cmd = IWEVGENIE; + iwe.u.data.length = rsn_len; + start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); + } + kfree(buf); + kfree(wpa_ie); + kfree(rsn_ie); + } + + {/* parsing WPS IE */ + uint cnt = 0, total_ielen; + u8 *wpsie_ptr = NULL; + uint wps_ielen = 0; + + u8 *ie_ptr = pnetwork->network.IEs + _FIXED_IE_LENGTH_; + total_ielen = pnetwork->network.IELength - _FIXED_IE_LENGTH_; + + while (cnt < total_ielen) { + if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) { + wpsie_ptr = &ie_ptr[cnt]; + iwe.cmd = IWEVGENIE; + iwe.u.data.length = (u16)wps_ielen; + start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); + } + cnt += ie_ptr[cnt+1]+2; /* goto next */ + } + } + + /* Add quality statistics */ + iwe.cmd = IWEVQUAL; + iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; + + if (check_fwstate(pmlmepriv, _FW_LINKED) == true && + is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { + ss = padapter->recvpriv.signal_strength; + sq = padapter->recvpriv.signal_qual; + } else { + ss = pnetwork->network.PhyInfo.SignalStrength; + sq = pnetwork->network.PhyInfo.SignalQuality; + } + + iwe.u.qual.level = (u8)ss; + iwe.u.qual.qual = (u8)sq; /* signal quality */ + iwe.u.qual.noise = 0; /* noise level */ + start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); +exit: + kfree(custom); + return start; +} + +static int wpa_set_auth_algs(struct net_device *dev, u32 value) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + int ret = 0; + + if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY and AUTH_ALG_OPEN_SYSTEM [value:0x%x]\n", value); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; + } else if (value & AUTH_ALG_SHARED_KEY) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_SHARED_KEY [value:0x%x]\n", value); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; + } else if (value & AUTH_ALG_OPEN_SYSTEM) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_OPEN_SYSTEM\n"); + if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) { + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; + } + } else if (value & AUTH_ALG_LEAP) { + DBG_88E("wpa_set_auth_algs, AUTH_ALG_LEAP\n"); + } else { + DBG_88E("wpa_set_auth_algs, error!\n"); + ret = -EINVAL; + } + return ret; +} + +static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) +{ + int ret = 0; + u32 wep_key_idx, wep_key_len, wep_total_len; + struct ndis_802_11_wep *pwep = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_88EU_P2P */ + + param->u.crypt.err = 0; + param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; + + if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { + ret = -EINVAL; + goto exit; + } + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) { + ret = -EINVAL; + goto exit; + } + } else { + ret = -EINVAL; + goto exit; + } + + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n")); + DBG_88E("wpa_set_encryption, crypt.alg = WEP\n"); + + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + + wep_key_idx = param->u.crypt.idx; + wep_key_len = param->u.crypt.key_len; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(1)wep_key_idx =%d\n", wep_key_idx)); + DBG_88E("(1)wep_key_idx =%d\n", wep_key_idx); + + if (wep_key_idx > WEP_KEYS) + return -EINVAL; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx)); + + if (wep_key_len > 0) { + wep_key_len = wep_key_len <= 5 ? 5 : 13; + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + if (pwep == NULL) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); + goto exit; + } + memset(pwep, 0, wep_total_len); + pwep->KeyLength = wep_key_len; + pwep->Length = wep_total_len; + if (wep_key_len == 13) { + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + } + } else { + ret = -EINVAL; + goto exit; + } + pwep->KeyIndex = wep_key_idx; + pwep->KeyIndex |= 0x80000000; + memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); + if (param->u.crypt.set_tx) { + DBG_88E("wep, set_tx = 1\n"); + if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) + ret = -EOPNOTSUPP; + } else { + DBG_88E("wep, set_tx = 0\n"); + if (wep_key_idx >= WEP_KEYS) { + ret = -EOPNOTSUPP; + goto exit; + } + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); + } + goto exit; + } + + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802_1x */ + struct sta_info *psta, *pbcmc_sta; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE)) { /* sta mode */ + psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); + if (psta == NULL) { + ; + } else { + if (strcmp(param->u.crypt.alg, "none") != 0) + psta->ieee8021x_blocked = false; + + if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || + (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) + psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + + if (param->u.crypt.set_tx == 1) { /* pairwise key */ + memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */ + memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); + memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); + padapter->securitypriv.busetkipkey = false; + } + + DBG_88E(" ~~~~set sta key:unicastkey\n"); + + rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); + } else { /* group key */ + memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + padapter->securitypriv.binstallGrpkey = true; + DBG_88E(" ~~~~set sta key:groupkey\n"); + + padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; + + rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) + rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_DONE); +#endif /* CONFIG_88EU_P2P */ + } + } + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta == NULL) { + ; + } else { + /* Jeff: don't disable ieee8021x_blocked while clearing key */ + if (strcmp(param->u.crypt.alg, "none") != 0) + pbcmc_sta->ieee8021x_blocked = false; + + if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || + (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) + pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; + } + } + } + +exit: + + kfree(pwep); + + return ret; +} + +static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen) +{ + u8 *buf = NULL; + int group_cipher = 0, pairwise_cipher = 0; + int ret = 0; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_88EU_P2P */ + + if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) { + _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); + if (pie == NULL) + return ret; + else + return -EINVAL; + } + + if (ielen) { + buf = rtw_zmalloc(ielen); + if (buf == NULL) { + ret = -ENOMEM; + goto exit; + } + + memcpy(buf, pie, ielen); + + /* dump */ + { + int i; + DBG_88E("\n wpa_ie(length:%d):\n", ielen); + for (i = 0; i < ielen; i += 8) + DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); + } + + if (ielen < RSN_HEADER_LEN) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen)); + ret = -1; + goto exit; + } + + if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; + memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); + } + + if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; + memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); + } + + switch (group_cipher) { + case WPA_CIPHER_NONE: + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot118021XGrpPrivacy = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + } + + switch (pairwise_cipher) { + case WPA_CIPHER_NONE: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + break; + case WPA_CIPHER_WEP40: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + case WPA_CIPHER_TKIP: + padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + } + + _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); + {/* set wps_ie */ + u16 cnt = 0; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + while (cnt < ielen) { + eid = buf[cnt]; + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { + DBG_88E("SET WPS_IE\n"); + + padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2) : (MAX_WPA_IE_LEN<<2); + + memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); + + set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); +#ifdef CONFIG_88EU_P2P + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK)) + rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING); +#endif /* CONFIG_88EU_P2P */ + cnt += buf[cnt+1]+2; + break; + } else { + cnt += buf[cnt+1]+2; /* goto next */ + } + } + } + } + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->securitypriv.ndisencryptstatus =%d padapter->securitypriv.ndisauthtype =%d\n", + pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype)); +exit: + kfree(buf); + return ret; +} + +typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; + +static int rtw_wx_get_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u32 ht_ielen = 0; + char *p; + u8 ht_cap = false; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + NDIS_802_11_RATES_EX *prates = NULL; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); + + + + if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + /* parsing HT_CAP_IE */ + p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + if (p && ht_ielen > 0) + ht_cap = true; + + prates = &pcur_bss->SupportedRates; + + if (rtw_is_cckratesonly_included((u8 *)prates) == true) { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); + } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); + } else { + if (pcur_bss->Configuration.DSConfig > 14) { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); + } else { + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); + } + } + } else { + snprintf(wrqu->name, IFNAMSIZ, "unassociated"); + } + + + + return 0; +} + +static int rtw_wx_set_freq(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n")); + + + + return 0; +} + +static int rtw_wx_get_freq(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ + wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; + wrqu->freq.e = 1; + wrqu->freq.i = pcur_bss->Configuration.DSConfig; + } else { + wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; + wrqu->freq.e = 1; + wrqu->freq.i = padapter->mlmeextpriv.cur_channel; + } + + return 0; +} + +static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + enum ndis_802_11_network_infra networkType; + int ret = 0; + + + + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -EPERM; + goto exit; + } + + if (!padapter->hw_init_completed) { + ret = -EPERM; + goto exit; + } + + switch (wrqu->mode) { + case IW_MODE_AUTO: + networkType = Ndis802_11AutoUnknown; + DBG_88E("set_mode = IW_MODE_AUTO\n"); + break; + case IW_MODE_ADHOC: + networkType = Ndis802_11IBSS; + DBG_88E("set_mode = IW_MODE_ADHOC\n"); + break; + case IW_MODE_MASTER: + networkType = Ndis802_11APMode; + DBG_88E("set_mode = IW_MODE_MASTER\n"); + break; + case IW_MODE_INFRA: + networkType = Ndis802_11Infrastructure; + DBG_88E("set_mode = IW_MODE_INFRA\n"); + break; + default: + ret = -EINVAL; + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported\n", iw_operation_mode[wrqu->mode])); + goto exit; + } + if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { + ret = -EPERM; + goto exit; + } + rtw_setopmode_cmd(padapter, networkType); +exit: + + return ret; +} + +static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); + + + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) + wrqu->mode = IW_MODE_INFRA; + else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + wrqu->mode = IW_MODE_ADHOC; + else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) + wrqu->mode = IW_MODE_MASTER; + else + wrqu->mode = IW_MODE_AUTO; + + + + return 0; +} + +static int rtw_wx_set_pmkid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 j, blInserted = false; + int ret = false; + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct iw_pmksa *pPMK = (struct iw_pmksa *)extra; + u8 strZeroMacAddress[ETH_ALEN] = {0x00}; + u8 strIssueBssid[ETH_ALEN] = {0x00}; + + memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); + if (pPMK->cmd == IW_PMKSA_ADD) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_ADD!\n"); + if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN)) + return ret; + else + ret = true; + blInserted = false; + + /* overwrite PMKID */ + for (j = 0; j < NUM_PMKID_CACHE; j++) { + if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => rewrite with new PMKID. */ + DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); + memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); + psecuritypriv->PMKIDList[j].bUsed = true; + psecuritypriv->PMKIDIndex = j+1; + blInserted = true; + break; + } + } + + if (!blInserted) { + /* Find a new entry */ + DBG_88E("[rtw_wx_set_pmkid] Use the new entry index = %d for this PMKID.\n", + psecuritypriv->PMKIDIndex); + + memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); + memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); + + psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true; + psecuritypriv->PMKIDIndex++; + if (psecuritypriv->PMKIDIndex == 16) + psecuritypriv->PMKIDIndex = 0; + } + } else if (pPMK->cmd == IW_PMKSA_REMOVE) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_REMOVE!\n"); + ret = true; + for (j = 0; j < NUM_PMKID_CACHE; j++) { + if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { + /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ + memset(psecuritypriv->PMKIDList[j].Bssid, 0x00, ETH_ALEN); + psecuritypriv->PMKIDList[j].bUsed = false; + break; + } + } + } else if (pPMK->cmd == IW_PMKSA_FLUSH) { + DBG_88E("[rtw_wx_set_pmkid] IW_PMKSA_FLUSH!\n"); + memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + psecuritypriv->PMKIDIndex = 0; + ret = true; + } + return ret; +} + +static int rtw_wx_get_sens(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + wrqu->sens.value = 0; + wrqu->sens.fixed = 0; /* no auto select */ + wrqu->sens.disabled = 1; + return 0; +} + +static int rtw_wx_get_range(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct iw_range *range = (struct iw_range *)extra; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + + u16 val; + int i; + + + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); + + wrqu->data.length = sizeof(*range); + memset(range, 0, sizeof(*range)); + + /* Let's try to keep this struct in the same order as in + * linux/include/wireless.h + */ + + /* TODO: See what values we can set, and remove the ones we can't + * set, or fill them with some default data. + */ + + /* ~5 Mb/s real (802.11b) */ + range->throughput = 5 * 1000 * 1000; + + /* signal level threshold range */ + + /* percent values between 0 and 100. */ + range->max_qual.qual = 100; + range->max_qual.level = 100; + range->max_qual.noise = 100; + range->max_qual.updated = 7; /* Updated all three */ + + range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ + /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ + range->avg_qual.level = 178; /* -78 dBm */ + range->avg_qual.noise = 0; + range->avg_qual.updated = 7; /* Updated all three */ + + range->num_bitrates = RATE_COUNT; + + for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) + range->bitrate[i] = rtw_rates[i]; + + range->min_frag = MIN_FRAG_THRESHOLD; + range->max_frag = MAX_FRAG_THRESHOLD; + + range->pm_capa = 0; + + range->we_version_compiled = WIRELESS_EXT; + range->we_version_source = 16; + + for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { + /* Include only legal frequencies for some countries */ + if (pmlmeext->channel_set[i].ChannelNum != 0) { + range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; + range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; + range->freq[val].e = 1; + val++; + } + + if (val == IW_MAX_FREQUENCIES) + break; + } + + range->num_channels = val; + range->num_frequency = val; + +/* The following code will proivde the security capability to network manager. */ +/* If the driver doesn't provide this capability to network manager, */ +/* the WPA/WPA2 routers can't be chosen in the network manager. */ + +/* +#define IW_SCAN_CAPA_NONE 0x00 +#define IW_SCAN_CAPA_ESSID 0x01 +#define IW_SCAN_CAPA_BSSID 0x02 +#define IW_SCAN_CAPA_CHANNEL 0x04 +#define IW_SCAN_CAPA_MODE 0x08 +#define IW_SCAN_CAPA_RATE 0x10 +#define IW_SCAN_CAPA_TYPE 0x20 +#define IW_SCAN_CAPA_TIME 0x40 +*/ + + range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | + IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; + + range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | + IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | + IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; + + + return 0; +} + +/* set bssid flow */ +/* s1. rtw_set_802_11_infrastructure_mode() */ +/* s2. rtw_set_802_11_authentication_mode() */ +/* s3. set_802_11_encryption_mode() */ +/* s4. rtw_set_802_11_bssid() */ +static int rtw_wx_set_wap(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra) +{ + uint ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct sockaddr *temp = (struct sockaddr *)awrq; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct list_head *phead; + u8 *dst_bssid, *src_bssid; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + enum ndis_802_11_auth_mode authmode; + + + + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -1; + goto exit; + } + + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (temp->sa_family != ARPHRD_ETHER) { + ret = -EINVAL; + goto exit; + } + + authmode = padapter->securitypriv.ndisauthtype; + spin_lock_bh(&queue->lock); + phead = get_list_head(queue); + pmlmepriv->pscanned = phead->next; + + while (phead != pmlmepriv->pscanned) { + + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); + + pmlmepriv->pscanned = pmlmepriv->pscanned->next; + + dst_bssid = pnetwork->network.MacAddress; + + src_bssid = temp->sa_data; + + if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { + ret = -1; + spin_unlock_bh(&queue->lock); + goto exit; + } + + break; + } + } + spin_unlock_bh(&queue->lock); + + rtw_set_802_11_authentication_mode(padapter, authmode); + /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ + if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) { + ret = -1; + goto exit; + } + +exit: + + + + return ret; +} + +static int rtw_wx_get_wap(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + + wrqu->ap_addr.sa_family = ARPHRD_ETHER; + + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); + + + + if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || + ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || + ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) + memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); + else + memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); + + + + return 0; +} + +static int rtw_wx_set_mlme(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u16 reason; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_mlme *mlme = (struct iw_mlme *)extra; + + if (mlme == NULL) + return -1; + + DBG_88E("%s\n", __func__); + + reason = mlme->reason_code; + + DBG_88E("%s, cmd =%d, reason =%d\n", __func__, mlme->cmd, reason); + + switch (mlme->cmd) { + case IW_MLME_DEAUTH: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + case IW_MLME_DISASSOC: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + default: + return -EOPNOTSUPP; + } + return ret; +} + +static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + u8 _status = false; + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); +#endif /* CONFIG_88EU_P2P */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); + + if (padapter->registrypriv.mp_mode == 1) { + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { + ret = -1; + goto exit; + } + } + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -1; + goto exit; + } + + if (padapter->bDriverStopped) { + DBG_88E("bDriverStopped =%d\n", padapter->bDriverStopped); + ret = -1; + goto exit; + } + + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (!padapter->hw_init_completed) { + ret = -1; + goto exit; + } + + /* When Busy Traffic, driver do not site survey. So driver return success. */ + /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ + /* modify by thomas 2011-02-22. */ + if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { + indicate_wx_scan_complete_event(padapter); + goto exit; + } + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + indicate_wx_scan_complete_event(padapter); + goto exit; + } + +/* For the DMP WiFi Display project, the driver won't to scan because */ +/* the pmlmepriv->scan_interval is always equal to 3. */ +/* So, the wpa_supplicant won't find out the WPS SoftAP. */ + +#ifdef CONFIG_88EU_P2P + if (pwdinfo->p2p_state != P2P_STATE_NONE) { + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_FIND_PHASE_SEARCH); + rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_FULL); + rtw_free_network_queue(padapter, true); + } +#endif /* CONFIG_88EU_P2P */ + + memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); + + if (wrqu->data.length == sizeof(struct iw_scan_req)) { + struct iw_scan_req *req = (struct iw_scan_req *)extra; + + if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { + int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); + + memcpy(ssid[0].Ssid, req->essid, len); + ssid[0].SsidLength = len; + + DBG_88E("IW_SCAN_THIS_ESSID, ssid =%s, len =%d\n", req->essid, req->essid_len); + + spin_lock_bh(&pmlmepriv->lock); + + _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); + + spin_unlock_bh(&pmlmepriv->lock); + } else if (req->scan_type == IW_SCAN_TYPE_PASSIVE) { + DBG_88E("rtw_wx_set_scan, req->scan_type == IW_SCAN_TYPE_PASSIVE\n"); + } + } else { + if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { + int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; + char *pos = extra+WEXT_CSCAN_HEADER_SIZE; + char section; + char sec_len; + int ssid_index = 0; + + while (len >= 1) { + section = *(pos++); + len -= 1; + + switch (section) { + case WEXT_CSCAN_SSID_SECTION: + if (len < 1) { + len = 0; + break; + } + sec_len = *(pos++); len -= 1; + if (sec_len > 0 && sec_len <= len) { + ssid[ssid_index].SsidLength = sec_len; + memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + ssid_index++; + } + pos += sec_len; + len -= sec_len; + break; + case WEXT_CSCAN_TYPE_SECTION: + case WEXT_CSCAN_CHANNEL_SECTION: + pos += 1; + len -= 1; + break; + case WEXT_CSCAN_PASV_DWELL_SECTION: + case WEXT_CSCAN_HOME_DWELL_SECTION: + case WEXT_CSCAN_ACTV_DWELL_SECTION: + pos += 2; + len -= 2; + break; + default: + len = 0; /* stop parsing */ + } + } + + /* it has still some scan parameter to parse, we only do this now... */ + _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); + } else { + _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); + } + } + + if (!_status) + ret = -1; + +exit: + + return ret; +} + +static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + struct list_head *plist, *phead; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + char *ev = extra; + char *stop = ev + wrqu->data.length; + u32 ret = 0; + u32 cnt = 0; + u32 wait_for_surveydone; + int wait_status; +#ifdef CONFIG_88EU_P2P + struct wifidirect_info *pwdinfo = &padapter->wdinfo; +#endif /* CONFIG_88EU_P2P */ + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); + + + + if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { + ret = -EINVAL; + goto exit; + } + +#ifdef CONFIG_88EU_P2P + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + /* P2P is enabled */ + wait_for_surveydone = 200; + } else { + /* P2P is disabled */ + wait_for_surveydone = 100; + } +#else + { + wait_for_surveydone = 100; + } +#endif /* CONFIG_88EU_P2P */ + + wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; + + while (check_fwstate(pmlmepriv, wait_status)) { + rtw_msleep_os(30); + cnt++; + if (cnt > wait_for_surveydone) + break; + } + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + if ((stop - ev) < SCAN_ITEM_SIZE) { + ret = -E2BIG; + break; + } + + pnetwork = container_of(plist, struct wlan_network, list); + + /* report network only if the current channel set contains the channel to which this network belongs */ + if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) + ev = translate_scan(padapter, a, pnetwork, ev, stop); + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + wrqu->data.length = ev-extra; + wrqu->data.flags = 0; + +exit: + + return ret; +} + +/* set ssid flow */ +/* s1. rtw_set_802_11_infrastructure_mode() */ +/* s2. set_802_11_authenticaion_mode() */ +/* s3. set_802_11_encryption_mode() */ +/* s4. rtw_set_802_11_ssid() */ +static int rtw_wx_set_essid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; + struct list_head *phead; + struct wlan_network *pnetwork = NULL; + enum ndis_802_11_auth_mode authmode; + struct ndis_802_11_ssid ndis_ssid; + u8 *dst_ssid, *src_ssid; + + uint ret = 0, len; + + + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); + if (_FAIL == rtw_pwr_wakeup(padapter)) { + ret = -1; + goto exit; + } + + if (!padapter->bup) { + ret = -1; + goto exit; + } + + if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { + ret = -E2BIG; + goto exit; + } + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + ret = -1; + goto exit; + } + + authmode = padapter->securitypriv.ndisauthtype; + DBG_88E("=>%s\n", __func__); + if (wrqu->essid.flags && wrqu->essid.length) { + len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; + + if (wrqu->essid.length != 33) + DBG_88E("ssid =%s, len =%d\n", extra, wrqu->essid.length); + + memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); + ndis_ssid.SsidLength = len; + memcpy(ndis_ssid.Ssid, extra, len); + src_ssid = ndis_ssid.Ssid; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); + spin_lock_bh(&queue->lock); + phead = get_list_head(queue); + pmlmepriv->pscanned = phead->next; + + while (phead != pmlmepriv->pscanned) { + pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); + + pmlmepriv->pscanned = pmlmepriv->pscanned->next; + + dst_ssid = pnetwork->network.Ssid.Ssid; + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_wx_set_essid: dst_ssid =%s\n", + pnetwork->network.Ssid.Ssid)); + + if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && + (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_wx_set_essid: find match, set infra mode\n")); + + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) + continue; + } + + if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { + ret = -1; + spin_unlock_bh(&queue->lock); + goto exit; + } + + break; + } + } + spin_unlock_bh(&queue->lock); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("set ssid: set_802_11_auth. mode =%d\n", authmode)); + rtw_set_802_11_authentication_mode(padapter, authmode); + if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { + ret = -1; + goto exit; + } + } + +exit: + + DBG_88E("<=%s, ret %d\n", __func__, ret); + + + + return ret; +} + +static int rtw_wx_get_essid(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + u32 len, ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); + + + + if ((check_fwstate(pmlmepriv, _FW_LINKED)) || + (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { + len = pcur_bss->Ssid.SsidLength; + memcpy(extra, pcur_bss->Ssid.Ssid, len); + } else { + len = 0; + *extra = 0; + } + wrqu->essid.length = len; + wrqu->essid.flags = 1; + +exit: + return ret; +} + +static int rtw_wx_set_rate(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra) +{ + int i, ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 datarates[NumRates]; + u32 target_rate = wrqu->bitrate.value; + u32 fixed = wrqu->bitrate.fixed; + u32 ratevalue = 0; + u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); + + if (target_rate == -1) { + ratevalue = 11; + goto set_rate; + } + target_rate = target_rate/100000; + + switch (target_rate) { + case 10: + ratevalue = 0; + break; + case 20: + ratevalue = 1; + break; + case 55: + ratevalue = 2; + break; + case 60: + ratevalue = 3; + break; + case 90: + ratevalue = 4; + break; + case 110: + ratevalue = 5; + break; + case 120: + ratevalue = 6; + break; + case 180: + ratevalue = 7; + break; + case 240: + ratevalue = 8; + break; + case 360: + ratevalue = 9; + break; + case 480: + ratevalue = 10; + break; + case 540: + ratevalue = 11; + break; + default: + ratevalue = 11; + break; + } + +set_rate: + + for (i = 0; i < NumRates; i++) { + if (ratevalue == mpdatarate[i]) { + datarates[i] = mpdatarate[i]; + if (fixed == 0) + break; + } else { + datarates[i] = 0xff; + } + + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i])); + } + + if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("rtw_wx_set_rate Fail!!!\n")); + ret = -1; + } + + return ret; +} + +static int rtw_wx_get_rate(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + u16 max_rate = 0; + + max_rate = rtw_get_cur_max_rate((struct adapter *)rtw_netdev_priv(dev)); + + if (max_rate == 0) + return -EPERM; + + wrqu->bitrate.fixed = 0; /* no auto select */ + wrqu->bitrate.value = max_rate * 100000; + + return 0; +} + +static int rtw_wx_set_rts(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + + + if (wrqu->rts.disabled) { + padapter->registrypriv.rts_thresh = 2347; + } else { + if (wrqu->rts.value < 0 || + wrqu->rts.value > 2347) + return -EINVAL; + + padapter->registrypriv.rts_thresh = wrqu->rts.value; + } + + DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); + + + + return 0; +} + +static int rtw_wx_get_rts(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + + + DBG_88E("%s, rts_thresh =%d\n", __func__, padapter->registrypriv.rts_thresh); + + wrqu->rts.value = padapter->registrypriv.rts_thresh; + wrqu->rts.fixed = 0; /* no auto select */ + /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ + + + + return 0; +} + +static int rtw_wx_set_frag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + + + if (wrqu->frag.disabled) { + padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; + } else { + if (wrqu->frag.value < MIN_FRAG_THRESHOLD || + wrqu->frag.value > MAX_FRAG_THRESHOLD) + return -EINVAL; + + padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; + } + + DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); + + + + return 0; +} + +static int rtw_wx_get_frag(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + + + DBG_88E("%s, frag_len =%d\n", __func__, padapter->xmitpriv.frag_len); + + wrqu->frag.value = padapter->xmitpriv.frag_len; + wrqu->frag.fixed = 0; /* no auto select */ + + + + return 0; +} + +static int rtw_wx_get_retry(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + wrqu->retry.value = 7; + wrqu->retry.fixed = 0; /* no auto select */ + wrqu->retry.disabled = 1; + + return 0; +} + +static int rtw_wx_set_enc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *keybuf) +{ + u32 key, ret = 0; + u32 keyindex_provided; + struct ndis_802_11_wep wep; + enum ndis_802_11_auth_mode authmode; + + struct iw_point *erq = &(wrqu->encoding); + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + DBG_88E("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); + + memset(&wep, 0, sizeof(struct ndis_802_11_wep)); + + key = erq->flags & IW_ENCODE_INDEX; + + + + if (erq->flags & IW_ENCODE_DISABLED) { + DBG_88E("EncryptionDisabled\n"); + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + authmode = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisauthtype = authmode; + + goto exit; + } + + if (key) { + if (key > WEP_KEYS) + return -EINVAL; + key--; + keyindex_provided = 1; + } else { + keyindex_provided = 0; + key = padapter->securitypriv.dot11PrivacyKeyIndex; + DBG_88E("rtw_wx_set_enc, key =%d\n", key); + } + + /* set authentication mode */ + if (erq->flags & IW_ENCODE_OPEN) { + DBG_88E("rtw_wx_set_enc():IW_ENCODE_OPEN\n"); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + authmode = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisauthtype = authmode; + } else if (erq->flags & IW_ENCODE_RESTRICTED) { + DBG_88E("rtw_wx_set_enc():IW_ENCODE_RESTRICTED\n"); + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; + authmode = Ndis802_11AuthModeShared; + padapter->securitypriv.ndisauthtype = authmode; + } else { + DBG_88E("rtw_wx_set_enc():erq->flags = 0x%x\n", erq->flags); + + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + authmode = Ndis802_11AuthModeOpen; + padapter->securitypriv.ndisauthtype = authmode; + } + + wep.KeyIndex = key; + if (erq->length > 0) { + wep.KeyLength = erq->length <= 5 ? 5 : 13; + + wep.Length = wep.KeyLength + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + } else { + wep.KeyLength = 0; + + if (keyindex_provided == 1) { + /* set key_id only, no given KeyMaterial(erq->length == 0). */ + padapter->securitypriv.dot11PrivacyKeyIndex = key; + + DBG_88E("(keyindex_provided == 1), keyid =%d, key_len =%d\n", key, padapter->securitypriv.dot11DefKeylen[key]); + + switch (padapter->securitypriv.dot11DefKeylen[key]) { + case 5: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; + break; + case 13: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + break; + default: + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + break; + } + + goto exit; + } + } + + wep.KeyIndex |= 0x80000000; + + memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); + + if (rtw_set_802_11_add_wep(padapter, &wep) == false) { + if (rf_on == pwrpriv->rf_pwrstate) + ret = -EOPNOTSUPP; + goto exit; + } + +exit: + + + + return ret; +} + +static int rtw_wx_get_enc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *keybuf) +{ + uint key, ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *erq = &(wrqu->encoding); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + + + if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { + if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + return 0; + } + } + + key = erq->flags & IW_ENCODE_INDEX; + + if (key) { + if (key > WEP_KEYS) + return -EINVAL; + key--; + } else { + key = padapter->securitypriv.dot11PrivacyKeyIndex; + } + + erq->flags = key + 1; + + switch (padapter->securitypriv.ndisencryptstatus) { + case Ndis802_11EncryptionNotSupported: + case Ndis802_11EncryptionDisabled: + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + break; + case Ndis802_11Encryption1Enabled: + erq->length = padapter->securitypriv.dot11DefKeylen[key]; + if (erq->length) { + memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); + + erq->flags |= IW_ENCODE_ENABLED; + + if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) + erq->flags |= IW_ENCODE_OPEN; + else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) + erq->flags |= IW_ENCODE_RESTRICTED; + } else { + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + } + break; + case Ndis802_11Encryption2Enabled: + case Ndis802_11Encryption3Enabled: + erq->length = 16; + erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY); + break; + default: + erq->length = 0; + erq->flags |= IW_ENCODE_DISABLED; + break; + } + + + return ret; +} + +static int rtw_wx_get_power(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + wrqu->power.value = 0; + wrqu->power.fixed = 0; /* no auto select */ + wrqu->power.disabled = 1; + + return 0; +} + +static int rtw_wx_set_gen_ie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + ret = rtw_set_wpa_ie(padapter, extra, wrqu->data.length); + return ret; +} + +static int rtw_wx_set_auth(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_param *param = (struct iw_param *)&(wrqu->param); + int ret = 0; + + switch (param->flags & IW_AUTH_INDEX) { + case IW_AUTH_WPA_VERSION: + break; + case IW_AUTH_CIPHER_PAIRWISE: + + break; + case IW_AUTH_CIPHER_GROUP: + + break; + case IW_AUTH_KEY_MGMT: + /* + * ??? does not use these parameters + */ + break; + case IW_AUTH_TKIP_COUNTERMEASURES: + if (param->value) { + /* wpa_supplicant is enabling the tkip countermeasure. */ + padapter->securitypriv.btkip_countermeasure = true; + } else { + /* wpa_supplicant is disabling the tkip countermeasure. */ + padapter->securitypriv.btkip_countermeasure = false; + } + break; + case IW_AUTH_DROP_UNENCRYPTED: + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ + + if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) + break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */ + /* then it needn't reset it; */ + + if (param->value) { + padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; + padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; + padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + } + + break; + case IW_AUTH_80211_AUTH_ALG: + /* + * It's the starting point of a link layer connection using wpa_supplicant + */ + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + LeaveAllPowerSaveMode(padapter); + rtw_disassoc_cmd(padapter, 500, false); + DBG_88E("%s...call rtw_indicate_disconnect\n ", __func__); + rtw_indicate_disconnect(padapter); + rtw_free_assoc_resources(padapter, 1); + } + ret = wpa_set_auth_algs(dev, (u32)param->value); + break; + case IW_AUTH_WPA_ENABLED: + break; + case IW_AUTH_RX_UNENCRYPTED_EAPOL: + break; + case IW_AUTH_PRIVACY_INVOKED: + break; + default: + return -EOPNOTSUPP; + } + + return ret; +} + +static int rtw_wx_set_enc_ext(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + char *alg_name; + u32 param_len; + struct ieee_param *param = NULL; + struct iw_point *pencoding = &wrqu->encoding; + struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; + int ret = 0; + + param_len = sizeof(struct ieee_param) + pext->key_len; + param = (struct ieee_param *)rtw_malloc(param_len); + if (param == NULL) + return -1; + + memset(param, 0, param_len); + + param->cmd = IEEE_CMD_SET_ENCRYPTION; + memset(param->sta_addr, 0xff, ETH_ALEN); + + switch (pext->alg) { + case IW_ENCODE_ALG_NONE: + /* todo: remove key */ + /* remove = 1; */ + alg_name = "none"; + break; + case IW_ENCODE_ALG_WEP: + alg_name = "WEP"; + break; + case IW_ENCODE_ALG_TKIP: + alg_name = "TKIP"; + break; + case IW_ENCODE_ALG_CCMP: + alg_name = "CCMP"; + break; + default: + return -1; + } + + strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); + + if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) + param->u.crypt.set_tx = 1; + + /* cliW: WEP does not have group key + * just not checking GROUP key setting + */ + if ((pext->alg != IW_ENCODE_ALG_WEP) && + (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) + param->u.crypt.set_tx = 0; + + param->u.crypt.idx = (pencoding->flags&0x00FF) - 1; + + if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) + memcpy(param->u.crypt.seq, pext->rx_seq, 8); + + if (pext->key_len) { + param->u.crypt.key_len = pext->key_len; + memcpy(param->u.crypt.key, pext + 1, pext->key_len); + } + + ret = wpa_set_encryption(dev, param, param_len); + + kfree(param); + return ret; +} + +static int rtw_wx_get_nick(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + if (extra) { + wrqu->data.length = 14; + wrqu->data.flags = 1; + memcpy(extra, "", 14); + } + + /* dump debug info here */ + return 0; +} + +static int rtw_wx_read32(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter; + struct iw_point *p; + u16 len; + u32 addr; + u32 data32; + u32 bytes; + u8 *ptmp; + + padapter = (struct adapter *)rtw_netdev_priv(dev); + p = &wrqu->data; + len = p->length; + ptmp = (u8 *)rtw_malloc(len); + if (NULL == ptmp) + return -ENOMEM; + + if (copy_from_user(ptmp, p->pointer, len)) { + kfree(ptmp); + return -EFAULT; + } + + bytes = 0; + addr = 0; + sscanf(ptmp, "%d,%x", &bytes, &addr); + + switch (bytes) { + case 1: + data32 = rtw_read8(padapter, addr); + sprintf(extra, "0x%02X", data32); + break; + case 2: + data32 = rtw_read16(padapter, addr); + sprintf(extra, "0x%04X", data32); + break; + case 4: + data32 = rtw_read32(padapter, addr); + sprintf(extra, "0x%08X", data32); + break; + default: + DBG_88E(KERN_INFO "%s: usage> read [bytes],[address(hex)]\n", __func__); + return -EINVAL; + } + DBG_88E(KERN_INFO "%s: addr = 0x%08X data =%s\n", __func__, addr, extra); + + kfree(ptmp); + return 0; +} + +static int rtw_wx_write32(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + u32 addr; + u32 data32; + u32 bytes; + + bytes = 0; + addr = 0; + data32 = 0; + sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); + + switch (bytes) { + case 1: + rtw_write8(padapter, addr, (u8)data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%02X\n", __func__, addr, (u8)data32); + break; + case 2: + rtw_write16(padapter, addr, (u16)data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%04X\n", __func__, addr, (u16)data32); + break; + case 4: + rtw_write32(padapter, addr, data32); + DBG_88E(KERN_INFO "%s: addr = 0x%08X data = 0x%08X\n", __func__, addr, data32); + break; + default: + DBG_88E(KERN_INFO "%s: usage> write [bytes],[address(hex)],[data(hex)]\n", __func__); + return -EINVAL; + } + + return 0; +} + +static int rtw_wx_read_rf(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u32 path, addr, data32; + + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); + data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); + /* + * IMPORTANT!! + * Only when wireless private ioctl is at odd order, + * "extra" would be copied to user space. + */ + sprintf(extra, "0x%05x", data32); + + return 0; +} + +static int rtw_wx_write_rf(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u32 path, addr, data32; + + path = *(u32 *)extra; + addr = *((u32 *)extra + 1); + data32 = *((u32 *)extra + 2); + rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); + + return 0; +} + +static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + return -1; +} + +static int dummy(struct net_device *dev, struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + return -1; +} + +static int rtw_wx_set_channel_plan(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 channel_plan_req = (u8) (*((int *)wrqu)); + + if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) + DBG_88E("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan); + else + return -EPERM; + + return 0; +} + +static int rtw_wx_set_mtk_wps_probe_ie(struct net_device *dev, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b) +{ + return 0; +} + +static int rtw_wx_get_sensitivity(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *buf) +{ + return 0; +} + +static int rtw_wx_set_mtk_wps_ie(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +/* + * For all data larger than 16 octets, we need to use a + * pointer to memory allocated in user space. + */ +static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +static void rtw_dbg_mode_hdl(struct adapter *padapter, u32 id, u8 *pdata, u32 len) +{ + struct mp_rw_reg *RegRWStruct; + struct rf_reg_param *prfreg; + u8 path; + u8 offset; + u32 value; + + DBG_88E("%s\n", __func__); + + switch (id) { + case GEN_MP_IOCTL_SUBCODE(MP_START): + DBG_88E("871x_driver is only for normal mode, can't enter mp mode\n"); + break; + case GEN_MP_IOCTL_SUBCODE(READ_REG): + RegRWStruct = (struct mp_rw_reg *)pdata; + switch (RegRWStruct->width) { + case 1: + RegRWStruct->value = rtw_read8(padapter, RegRWStruct->offset); + break; + case 2: + RegRWStruct->value = rtw_read16(padapter, RegRWStruct->offset); + break; + case 4: + RegRWStruct->value = rtw_read32(padapter, RegRWStruct->offset); + break; + default: + break; + } + + break; + case GEN_MP_IOCTL_SUBCODE(WRITE_REG): + RegRWStruct = (struct mp_rw_reg *)pdata; + switch (RegRWStruct->width) { + case 1: + rtw_write8(padapter, RegRWStruct->offset, (u8)RegRWStruct->value); + break; + case 2: + rtw_write16(padapter, RegRWStruct->offset, (u16)RegRWStruct->value); + break; + case 4: + rtw_write32(padapter, RegRWStruct->offset, (u32)RegRWStruct->value); + break; + default: + break; + } + + break; + case GEN_MP_IOCTL_SUBCODE(READ_RF_REG): + + prfreg = (struct rf_reg_param *)pdata; + + path = (u8)prfreg->path; + offset = (u8)prfreg->offset; + + value = rtw_hal_read_rfreg(padapter, path, offset, 0xffffffff); + + prfreg->value = value; + + break; + case GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG): + + prfreg = (struct rf_reg_param *)pdata; + + path = (u8)prfreg->path; + offset = (u8)prfreg->offset; + value = prfreg->value; + + rtw_hal_write_rfreg(padapter, path, offset, 0xffffffff, value); + + break; + case GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO): + DBG_88E("==> trigger gpio 0\n"); + rtw_hal_set_hwreg(padapter, HW_VAR_TRIGGER_GPIO_0, NULL); + break; + case GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS): + *pdata = rtw_hal_sreset_get_wifi_status(padapter); + break; + default: + break; + } +} + +static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u32 BytesRead, BytesWritten, BytesNeeded; + struct oid_par_priv oid_par; + struct mp_ioctl_handler *phandler; + struct mp_ioctl_param *poidparam; + uint status = 0; + u16 len; + u8 *pparmbuf = NULL, bset; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *p = &wrqu->data; + + if ((!p->length) || (!p->pointer)) { + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; + } + pparmbuf = NULL; + bset = (u8)(p->flags & 0xFFFF); + len = p->length; + pparmbuf = (u8 *)rtw_malloc(len); + if (pparmbuf == NULL) { + ret = -ENOMEM; + goto _rtw_mp_ioctl_hdl_exit; + } + + if (copy_from_user(pparmbuf, p->pointer, len)) { + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + + poidparam = (struct mp_ioctl_param *)pparmbuf; + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("rtw_mp_ioctl_hdl: subcode [%d], len[%d], buffer_len[%d]\r\n", + poidparam->subcode, poidparam->len, len)); + + if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("no matching drvext subcodes\r\n")); + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; + } + + if (padapter->registrypriv.mp_mode == 1) { + phandler = mp_ioctl_hdl + poidparam->subcode; + + if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) { + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, + ("no matching drvext param size %d vs %d\r\n", + poidparam->len, phandler->paramsize)); + ret = -EINVAL; + goto _rtw_mp_ioctl_hdl_exit; + } + + if (phandler->handler) { + oid_par.adapter_context = padapter; + oid_par.oid = phandler->oid; + oid_par.information_buf = poidparam->data; + oid_par.information_buf_len = poidparam->len; + oid_par.dbg = 0; + + BytesWritten = 0; + BytesNeeded = 0; + + if (bset) { + oid_par.bytes_rw = &BytesRead; + oid_par.bytes_needed = &BytesNeeded; + oid_par.type_of_oid = SET_OID; + } else { + oid_par.bytes_rw = &BytesWritten; + oid_par.bytes_needed = &BytesNeeded; + oid_par.type_of_oid = QUERY_OID; + } + + status = phandler->handler(&oid_par); + } else { + DBG_88E("rtw_mp_ioctl_hdl(): err!, subcode =%d, oid =%d, handler =%p\n", + poidparam->subcode, phandler->oid, phandler->handler); + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + } else { + rtw_dbg_mode_hdl(padapter, poidparam->subcode, poidparam->data, poidparam->len); + } + + if (bset == 0x00) {/* query info */ + if (copy_to_user(p->pointer, pparmbuf, len)) + ret = -EFAULT; + } + + if (status) { + ret = -EFAULT; + goto _rtw_mp_ioctl_hdl_exit; + } + +_rtw_mp_ioctl_hdl_exit: + + kfree(pparmbuf); + return ret; +} + +static int rtw_get_ap_info(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u32 cnt = 0, wpa_ielen; + struct list_head *plist, *phead; + unsigned char *pbuf; + u8 bssid[ETH_ALEN]; + char data[32]; + struct wlan_network *pnetwork = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct iw_point *pdata = &wrqu->data; + + DBG_88E("+rtw_get_aplist_info\n"); + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + + while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { + rtw_msleep_os(30); + cnt++; + if (cnt > 100) + break; + } + pdata->flags = 0; + if (pdata->length >= 32) { + if (copy_from_user(data, pdata->pointer, 32)) { + ret = -EINVAL; + goto exit; + } + } else { + ret = -EINVAL; + goto exit; + } + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + + if (hwaddr_aton_i(data, bssid)) { + DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + return -EINVAL; + } + + if (!memcmp(bssid, pnetwork->network.MacAddress, ETH_ALEN)) { + /* BSSID match, then check if supporting wpa/wpa2 */ + DBG_88E("BSSID:%pM\n", (bssid)); + + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + if (pbuf && (wpa_ielen > 0)) { + pdata->flags = 1; + break; + } + + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + if (pbuf && (wpa_ielen > 0)) { + pdata->flags = 2; + break; + } + } + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (pdata->length >= 34) { + if (copy_to_user(pdata->pointer+32, (u8 *)&pdata->flags, 1)) { + ret = -EINVAL; + goto exit; + } + } + +exit: + + return ret; +} + +static int rtw_set_pid(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + int *pdata = (int *)wrqu; + int selector; + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + + selector = *pdata; + if (selector < 3 && selector >= 0) { + padapter->pid[selector] = *(pdata+1); + ui_pid[selector] = *(pdata+1); + DBG_88E("%s set pid[%d] =%d\n", __func__, selector, padapter->pid[selector]); + } else { + DBG_88E("%s selector %d error\n", __func__, selector); + } +exit: + return ret; +} + +static int rtw_wps_start(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *pdata = &wrqu->data; + u32 u32wps_start = 0; + + ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); + if (ret) { + ret = -EINVAL; + goto exit; + } + + if ((padapter->bDriverStopped) || (pdata == NULL)) { + ret = -EINVAL; + goto exit; + } + + if (u32wps_start == 0) + u32wps_start = *extra; + + DBG_88E("[%s] wps_start = %d\n", __func__, u32wps_start); + + if (u32wps_start == 1) /* WPS Start */ + rtw_led_control(padapter, LED_CTL_START_WPS); + else if (u32wps_start == 2) /* WPS Stop because of wps success */ + rtw_led_control(padapter, LED_CTL_STOP_WPS); + else if (u32wps_start == 3) /* WPS Stop because of wps fail */ + rtw_led_control(padapter, LED_CTL_STOP_WPS_FAIL); + +exit: + return ret; +} + +#ifdef CONFIG_88EU_P2P +static int rtw_wext_p2p_enable(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + enum P2P_ROLE init_role = P2P_ROLE_DISABLE; + + if (*extra == '0') + init_role = P2P_ROLE_DISABLE; + else if (*extra == '1') + init_role = P2P_ROLE_DEVICE; + else if (*extra == '2') + init_role = P2P_ROLE_CLIENT; + else if (*extra == '3') + init_role = P2P_ROLE_GO; + + if (_FAIL == rtw_p2p_enable(padapter, init_role)) { + ret = -EFAULT; + goto exit; + } + + /* set channel/bandwidth */ + if (init_role != P2P_ROLE_DISABLE) { + u8 channel, ch_offset; + u16 bwmode; + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_LISTEN)) { + /* Stay at the listen state and wait for discovery. */ + channel = pwdinfo->listen_channel; + pwdinfo->operating_channel = pwdinfo->listen_channel; + ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; + bwmode = HT_CHANNEL_WIDTH_20; + } else { + pwdinfo->operating_channel = pmlmeext->cur_channel; + + channel = pwdinfo->operating_channel; + ch_offset = pmlmeext->cur_ch_offset; + bwmode = pmlmeext->cur_bwmode; + } + + set_channel_bwmode(padapter, channel, ch_offset, bwmode); + } + +exit: + return ret; +} + +static int rtw_p2p_set_go_nego_ssid(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] ssid = %s, len = %zu\n", __func__, extra, strlen(extra)); + memcpy(pwdinfo->nego_ssid, extra, strlen(extra)); + pwdinfo->nego_ssidlen = strlen(extra); + + return ret; +} + +static int rtw_p2p_set_intent(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 intent = pwdinfo->intent; + + switch (wrqu->data.length) { + case 1: + intent = extra[0] - '0'; + break; + case 2: + intent = str_2char2num(extra[0], extra[1]); + break; + } + if (intent <= 15) + pwdinfo->intent = intent; + else + ret = -1; + DBG_88E("[%s] intent = %d\n", __func__, intent); + return ret; +} + +static int rtw_p2p_set_listen_ch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */ + + switch (wrqu->data.length) { + case 1: + listen_ch = extra[0] - '0'; + break; + case 2: + listen_ch = str_2char2num(extra[0], extra[1]); + break; + } + + if ((listen_ch == 1) || (listen_ch == 6) || (listen_ch == 11)) { + pwdinfo->listen_channel = listen_ch; + set_channel_bwmode(padapter, pwdinfo->listen_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + } else { + ret = -1; + } + + DBG_88E("[%s] listen_ch = %d\n", __func__, pwdinfo->listen_channel); + + return ret; +} + +static int rtw_p2p_set_op_ch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ +/* Commented by Albert 20110524 */ +/* This function is used to set the operating channel if the driver will become the group owner */ + + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */ + + switch (wrqu->data.length) { + case 1: + op_ch = extra[0] - '0'; + break; + case 2: + op_ch = str_2char2num(extra[0], extra[1]); + break; + } + + if (op_ch > 0) + pwdinfo->operating_channel = op_ch; + else + ret = -1; + + DBG_88E("[%s] op_ch = %d\n", __func__, pwdinfo->operating_channel); + + return ret; +} + +static int rtw_p2p_profilefound(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + /* Comment by Albert 2010/10/13 */ + /* Input data format: */ + /* Ex: 0 */ + /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ + /* 0 => Reflush the profile record list. */ + /* 1 => Add the profile list */ + /* XX:XX:XX:XX:XX:XX => peer's MAC Address (ex: 00:E0:4C:00:00:01) */ + /* YY => SSID Length */ + /* SSID => SSID for persistence group */ + + DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length - 1); + + /* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */ + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + if (extra[0] == '0') { + /* Remove all the profile information of wifidirect_info structure. */ + memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); + pwdinfo->profileindex = 0; + } else { + if (pwdinfo->profileindex >= P2P_MAX_PERSISTENT_GROUP_NUM) { + ret = -1; + } else { + int jj, kk; + + /* Add this profile information into pwdinfo->profileinfo */ + /* Ex: 1XX:XX:XX:XX:XX:XXYYSSID */ + for (jj = 0, kk = 1; jj < ETH_ALEN; jj++, kk += 3) + pwdinfo->profileinfo[pwdinfo->profileindex].peermac[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen = (extra[18] - '0') * 10 + (extra[19] - '0'); + memcpy(pwdinfo->profileinfo[pwdinfo->profileindex].ssid, &extra[20], pwdinfo->profileinfo[pwdinfo->profileindex].ssidlen); + pwdinfo->profileindex++; + } + } + } + + return ret; +} + +static int rtw_p2p_setDN(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length - 1); + memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); + memcpy(pwdinfo->device_name, extra, wrqu->data.length - 1); + pwdinfo->device_name_len = wrqu->data.length - 1; + + return ret; +} + +static int rtw_p2p_get_status(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + if (padapter->bShowGetP2PState) + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], + pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); + + /* Commented by Albert 2010/10/12 */ + /* Because of the output size limitation, I had removed the "Role" information. */ + /* About the "Role" information, we will use the new private IOCTL to get the "Role" information. */ + sprintf(extra, "\n\nStatus =%.2d\n", rtw_p2p_state(pwdinfo)); + wrqu->data.length = strlen(extra); + + return ret; +} + +/* Commented by Albert 20110520 */ +/* This function will return the config method description */ +/* This config method description will show us which config method the remote P2P device is intended to use */ +/* by sending the provisioning discovery request frame. */ + +static int rtw_p2p_get_req_cm(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + sprintf(extra, "\n\nCM =%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_role(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], + pwdinfo->p2p_peer_interface_addr[3], pwdinfo->p2p_peer_interface_addr[4], pwdinfo->p2p_peer_interface_addr[5]); + + sprintf(extra, "\n\nRole =%.2d\n", rtw_p2p_role(pwdinfo)); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_peer_ifaddr(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, + rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_interface_addr); + sprintf(extra, "\nMAC %pM", + pwdinfo->p2p_peer_interface_addr); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_peer_devaddr(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, + rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->rx_prov_disc_info.peerDevAddr); + sprintf(extra, "\n%pM", + pwdinfo->rx_prov_disc_info.peerDevAddr); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", + __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), + pwdinfo->p2p_peer_device_addr); + sprintf(extra, "\nMAC %pM", + pwdinfo->p2p_peer_device_addr); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_groupid(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + sprintf(extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s", + pwdinfo->groupid_info.go_device_addr[0], pwdinfo->groupid_info.go_device_addr[1], + pwdinfo->groupid_info.go_device_addr[2], pwdinfo->groupid_info.go_device_addr[3], + pwdinfo->groupid_info.go_device_addr[4], pwdinfo->groupid_info.go_device_addr[5], + pwdinfo->groupid_info.ssid); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_op_ch(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) + +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] Op_ch = %02x\n", __func__, pwdinfo->operating_channel); + + sprintf(extra, "\n\nOp_ch =%.2d\n", pwdinfo->operating_channel); + wrqu->data.length = strlen(extra); + return ret; +} + +static int rtw_p2p_get_wps_configmethod(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u16 attr_content = 0; + uint attr_contentlen = 0; + /* 6 is the string "wpsCM =", 17 is the MAC addr, we have to clear it at wrqu->data.pointer */ + u8 attr_content_str[6 + 17] = {0x00}; + + /* Commented by Albert 20110727 */ + /* The input data is the MAC address which the application wants to know its WPS config method. */ + /* After knowing its WPS config method, the application can decide the config method for provisioning discovery. */ + /* Format: iwpriv wlanx p2p_get_wpsCM 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 6, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + u8 *wpsie; + uint wpsie_len = 0; + __be16 be_tmp; + + /* The mac address is matched. */ + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *) &be_tmp, &attr_contentlen); + if (attr_contentlen) { + attr_content = be16_to_cpu(be_tmp); + sprintf(attr_content_str, "\n\nM =%.4d", attr_content); + blnMatch = 1; + } + } + break; + } + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (!blnMatch) + sprintf(attr_content_str, "\n\nM = 0000"); + + if (copy_to_user(wrqu->data.pointer, attr_content_str, 6 + 17)) + return -EFAULT; + return ret; +} + +static int rtw_p2p_get_go_device_address(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + u8 attr_content[100] = {0x00}; + + u8 go_devadd_str[100 + 10] = {0x00}; + /* +10 is for the str "go_devadd =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Albert 20121209 */ + /* The input data is the GO's interface address which the application wants to know its device address. */ + /* Format: iwpriv wlanx p2p_get2 go_devadd = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 10, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ + + memset(attr_content, 0x00, 100); + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + blnMatch = 1; + break; + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + blnMatch = 1; + break; + } + + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + } + } + } + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (!blnMatch) + sprintf(go_devadd_str, "\n\ndev_add = NULL"); + else + sprintf(go_devadd_str, "\ndev_add =%.2X:%.2X:%.2X:%.2X:%.2X:%.2X", + attr_content[0], attr_content[1], attr_content[2], attr_content[3], attr_content[4], attr_content[5]); + + if (copy_to_user(wrqu->data.pointer, go_devadd_str, 10 + 17)) + return -EFAULT; + return ret; +} + +static int rtw_p2p_get_device_type(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 dev_type[8] = {0x00}; + uint dev_type_len = 0; + u8 dev_type_str[17 + 9] = {0x00}; /* +9 is for the str "dev_type =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Albert 20121209 */ + /* The input data is the MAC address which the application wants to know its device type. */ + /* Such user interface could know the device type. */ + /* Format: iwpriv wlanx p2p_get2 dev_type = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 9, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + u8 *wpsie; + uint wpsie_len = 0; + + /* The mac address is matched. */ + + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], + pnetwork->network.IELength - 12, + NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_PRIMARY_DEV_TYPE, dev_type, &dev_type_len); + if (dev_type_len) { + u16 type = 0; + __be16 be_tmp; + + memcpy(&be_tmp, dev_type, 2); + type = be16_to_cpu(be_tmp); + sprintf(dev_type_str, "\n\nN =%.2d", type); + blnMatch = 1; + } + } + break; + } + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (!blnMatch) + sprintf(dev_type_str, "\n\nN = 00"); + + if (copy_to_user(wrqu->data.pointer, dev_type_str, 9 + 17)) { + return -EFAULT; + } + + return ret; +} + +static int rtw_p2p_get_device_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00}; + uint dev_len = 0; + u8 dev_name_str[WPS_MAX_DEVICE_NAME_LEN + 5] = {0x00}; /* +5 is for the str "devN =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Albert 20121225 */ + /* The input data is the MAC address which the application wants to know its device name. */ + /* Such user interface could show peer device's device name instead of ssid. */ + /* Format: iwpriv wlanx p2p_get2 devN = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 5, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + u8 *wpsie; + uint wpsie_len = 0; + + /* The mac address is matched. */ + wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); + if (wpsie) { + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_DEVICE_NAME, dev_name, &dev_len); + if (dev_len) { + sprintf(dev_name_str, "\n\nN =%s", dev_name); + blnMatch = 1; + } + } + break; + } + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (!blnMatch) + sprintf(dev_name_str, "\n\nN = 0000"); + + if (copy_to_user(wrqu->data.pointer, dev_name_str, 5 + ((dev_len > 17) ? dev_len : 17))) + return -EFAULT; + return ret; +} + +static int rtw_p2p_get_invitation_procedure(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + u8 peerMACStr[17] = {0x00}; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + u8 blnMatch = 0; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + u8 attr_content[2] = {0x00}; + + u8 inv_proc_str[17 + 8] = {0x00}; + /* +8 is for the str "InvProc =", we have to clear it at wrqu->data.pointer */ + + /* Commented by Ouden 20121226 */ + /* The application wants to know P2P initiation procedure is supported or not. */ + /* Format: iwpriv wlanx p2p_get2 InvProc = 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, (char *)extra); + if (copy_from_user(peerMACStr, wrqu->data.pointer + 8, 17)) + return -EFAULT; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(peerMACStr[kk], peerMACStr[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + /* Commented by Albert 20121226 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_CAPABILITY, attr_content, &attr_contentlen)) { + /* Handle the P2P capability attribute */ + blnMatch = 1; + break; + } + + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + } + } + } + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (!blnMatch) { + sprintf(inv_proc_str, "\nIP =-1"); + } else { + if (attr_content[0] & 0x20) + sprintf(inv_proc_str, "\nIP = 1"); + else + sprintf(inv_proc_str, "\nIP = 0"); + } + if (copy_to_user(wrqu->data.pointer, inv_proc_str, 8 + 17)) + return -EFAULT; + return ret; +} + +static int rtw_p2p_connect(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + + /* Commented by Albert 20110304 */ + /* The input data contains two informations. */ + /* 1. First information is the MAC address which wants to formate with */ + /* 2. Second information is the WPS PINCode or "pbc" string for push button method */ + /* Format: 00:E0:4C:00:00:05 */ + /* Format: 00:E0:4C:00:00:05 */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (pwdinfo->p2p_state == P2P_STATE_NONE) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } + + if (pwdinfo->ui_got_wps_info == P2P_NO_WPSINFO) + return -1; + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + if (!memcmp(pnetwork->network.MacAddress, peerMAC, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (uintPeerChannel) { + memset(&pwdinfo->nego_req_info, 0x00, sizeof(struct tx_nego_req_info)); + memset(&pwdinfo->groupid_info, 0x00, sizeof(struct group_id_info)); + + pwdinfo->nego_req_info.peer_channel_num[0] = uintPeerChannel; + memcpy(pwdinfo->nego_req_info.peerDevAddr, pnetwork->network.MacAddress, ETH_ALEN); + pwdinfo->nego_req_info.benable = true; + + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + if (rtw_p2p_state(pwdinfo) != P2P_STATE_GONEGO_OK) { + /* Restore to the listen state if the current p2p state is not nego OK */ + rtw_p2p_set_state(pwdinfo, P2P_STATE_LISTEN); + } + + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); + + DBG_88E("[%s] Start PreTx Procedure!\n", __func__); + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_GO_NEGO_TIMEOUT); + } else { + DBG_88E("[%s] Not Found in Scanning Queue~\n", __func__); + ret = -1; + } + return ret; +} + +static int rtw_p2p_invite_req(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + int jj, kk; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + u8 attr_content[50] = {0x00}; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + struct tx_invite_req_info *pinvite_req_info = &pwdinfo->invitereq_info; + + /* The input data contains two informations. */ + /* 1. First information is the P2P device address which you want to send to. */ + /* 2. Second information is the group id which combines with GO's mac address, space and GO's ssid. */ + /* Command line sample: iwpriv wlan0 p2p_set invite ="00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy" */ + /* Format: 00:11:22:33:44:55 00:E0:4C:00:00:05 DIRECT-xy */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (wrqu->data.length <= 37) { + DBG_88E("[%s] Wrong format!\n", __func__); + return ret; + } + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } else { + /* Reset the content of struct tx_invite_req_info */ + pinvite_req_info->benable = false; + memset(pinvite_req_info->go_bssid, 0x00, ETH_ALEN); + memset(pinvite_req_info->go_ssid, 0x00, WLAN_SSID_MAXLEN); + pinvite_req_info->ssidlen = 0x00; + pinvite_req_info->operating_ch = pwdinfo->operating_channel; + memset(pinvite_req_info->peer_macaddr, 0x00, ETH_ALEN); + pinvite_req_info->token = 3; + } + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + pinvite_req_info->peer_macaddr[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + pnetwork = container_of(plist, struct wlan_network, list); + + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ + + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + if (!memcmp(attr_content, pinvite_req_info->peer_macaddr, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } + } + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (uintPeerChannel) { + /* Store the GO's bssid */ + for (jj = 0, kk = 18; jj < ETH_ALEN; jj++, kk += 3) + pinvite_req_info->go_bssid[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + /* Store the GO's ssid */ + pinvite_req_info->ssidlen = wrqu->data.length - 36; + memcpy(pinvite_req_info->go_ssid, &extra[36], (u32) pinvite_req_info->ssidlen); + pinvite_req_info->benable = true; + pinvite_req_info->peer_ch = uintPeerChannel; + + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_INVITE_REQ); + + set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_INVITE_TIMEOUT); + } else { + DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); + } + return ret; +} + +static int rtw_p2p_set_persistent(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + /* The input data is 0 or 1 */ + /* 0: disable persistent group functionality */ + /* 1: enable persistent group founctionality */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } else { + if (extra[0] == '0') /* Disable the persistent group function. */ + pwdinfo->persistent_supported = false; + else if (extra[0] == '1') /* Enable the persistent group function. */ + pwdinfo->persistent_supported = true; + else + pwdinfo->persistent_supported = false; + } + pr_info("[%s] persistent_supported = %d\n", __func__, pwdinfo->persistent_supported); + return ret; +} + +static int rtw_p2p_prov_disc(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + u8 peerMAC[ETH_ALEN] = {0x00}; + int jj, kk; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct list_head *plist, *phead; + struct __queue *queue = &(pmlmepriv->scanned_queue); + struct wlan_network *pnetwork = NULL; + uint uintPeerChannel = 0; + u8 attr_content[100] = {0x00}; + u8 *p2pie; + uint p2pielen = 0, attr_contentlen = 0; + + /* The input data contains two informations. */ + /* 1. First information is the MAC address which wants to issue the provisioning discovery request frame. */ + /* 2. Second information is the WPS configuration method which wants to discovery */ + /* Format: 00:E0:4C:00:00:05_display */ + /* Format: 00:E0:4C:00:00:05_keypad */ + /* Format: 00:E0:4C:00:00:05_pbc */ + /* Format: 00:E0:4C:00:00:05_label */ + + DBG_88E("[%s] data = %s\n", __func__, extra); + + if (pwdinfo->p2p_state == P2P_STATE_NONE) { + DBG_88E("[%s] WiFi Direct is disable!\n", __func__); + return ret; + } else { + /* Reset the content of struct tx_provdisc_req_info excluded the wps_config_method_request. */ + memset(pwdinfo->tx_prov_disc_info.peerDevAddr, 0x00, ETH_ALEN); + memset(pwdinfo->tx_prov_disc_info.peerIFAddr, 0x00, ETH_ALEN); + memset(&pwdinfo->tx_prov_disc_info.ssid, 0x00, sizeof(struct ndis_802_11_ssid)); + pwdinfo->tx_prov_disc_info.peer_channel_num[0] = 0; + pwdinfo->tx_prov_disc_info.peer_channel_num[1] = 0; + pwdinfo->tx_prov_disc_info.benable = false; + } + + for (jj = 0, kk = 0; jj < ETH_ALEN; jj++, kk += 3) + peerMAC[jj] = key_2char2num(extra[kk], extra[kk + 1]); + + if (!memcmp(&extra[18], "display", 7)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_DISPLYA; + } else if (!memcmp(&extra[18], "keypad", 7)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_KEYPAD; + } else if (!memcmp(&extra[18], "pbc", 3)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_PUSH_BUTTON; + } else if (!memcmp(&extra[18], "label", 5)) { + pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_LABEL; + } else { + DBG_88E("[%s] Unknown WPS config methodn", __func__); + return ret; + } + + spin_lock_bh(&pmlmepriv->scanned_queue.lock); + + phead = get_list_head(queue); + plist = phead->next; + + while (phead != plist) { + if (uintPeerChannel != 0) + break; + + pnetwork = container_of(plist, struct wlan_network, list); + + /* Commented by Albert 2011/05/18 */ + /* Match the device address located in the P2P IE */ + /* This is for the case that the P2P device address is not the same as the P2P interface address. */ + + p2pie = rtw_get_p2p_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &p2pielen); + if (p2pie) { + while (p2pie) { + /* The P2P Device ID attribute is included in the Beacon frame. */ + /* The P2P Device Info attribute is included in the probe response frame. */ + + if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_ID, attr_content, &attr_contentlen)) { + /* Handle the P2P Device ID attribute of Beacon first */ + if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } else if (rtw_get_p2p_attr_content(p2pie, p2pielen, P2P_ATTR_DEVICE_INFO, attr_content, &attr_contentlen)) { + /* Handle the P2P Device Info attribute of probe response */ + if (!memcmp(attr_content, peerMAC, ETH_ALEN)) { + uintPeerChannel = pnetwork->network.Configuration.DSConfig; + break; + } + } + + /* Get the next P2P IE */ + p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + } + } + + plist = plist->next; + } + + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); + + if (uintPeerChannel) { + DBG_88E("[%s] peer channel: %d!\n", __func__, uintPeerChannel); + memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN); + memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN); + pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16) uintPeerChannel; + pwdinfo->tx_prov_disc_info.benable = true; + rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); + rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ); + + if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_CLIENT)) { + memcpy(&pwdinfo->tx_prov_disc_info.ssid, &pnetwork->network.Ssid, sizeof(struct ndis_802_11_ssid)); + } else if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { + memcpy(pwdinfo->tx_prov_disc_info.ssid.Ssid, pwdinfo->p2p_wildcard_ssid, P2P_WILDCARD_SSID_LEN); + pwdinfo->tx_prov_disc_info.ssid.SsidLength = P2P_WILDCARD_SSID_LEN; + } + + set_channel_bwmode(padapter, uintPeerChannel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); + + _set_timer(&pwdinfo->pre_tx_scan_timer, P2P_TX_PRESCAN_TIMEOUT); + + _set_timer(&pwdinfo->restore_p2p_state_timer, P2P_PROVISION_TIMEOUT); + } else { + DBG_88E("[%s] NOT Found in the Scanning Queue!\n", __func__); + } + return ret; +} + +/* This function is used to inform the driver the user had specified the pin code value or pbc */ +/* to application. */ + +static int rtw_p2p_got_wpsinfo(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + + DBG_88E("[%s] data = %s\n", __func__, extra); + /* Added by Albert 20110328 */ + /* if the input data is P2P_NO_WPSINFO -> reset the wpsinfo */ + /* if the input data is P2P_GOT_WPSINFO_PEER_DISPLAY_PIN -> the utility just input the PIN code got from the peer P2P device. */ + /* if the input data is P2P_GOT_WPSINFO_SELF_DISPLAY_PIN -> the utility just got the PIN code from itself. */ + /* if the input data is P2P_GOT_WPSINFO_PBC -> the utility just determine to use the PBC */ + + if (*extra == '0') + pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; + else if (*extra == '1') + pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PEER_DISPLAY_PIN; + else if (*extra == '2') + pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_SELF_DISPLAY_PIN; + else if (*extra == '3') + pwdinfo->ui_got_wps_info = P2P_GOT_WPSINFO_PBC; + else + pwdinfo->ui_got_wps_info = P2P_NO_WPSINFO; + return ret; +} + +#endif /* CONFIG_88EU_P2P */ + +static int rtw_p2p_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + +#ifdef CONFIG_88EU_P2P + DBG_88E("[%s] extra = %s\n", __func__, extra); + if (!memcmp(extra, "enable =", 7)) { + rtw_wext_p2p_enable(dev, info, wrqu, &extra[7]); + } else if (!memcmp(extra, "setDN =", 6)) { + wrqu->data.length -= 6; + rtw_p2p_setDN(dev, info, wrqu, &extra[6]); + } else if (!memcmp(extra, "profilefound =", 13)) { + wrqu->data.length -= 13; + rtw_p2p_profilefound(dev, info, wrqu, &extra[13]); + } else if (!memcmp(extra, "prov_disc =", 10)) { + wrqu->data.length -= 10; + rtw_p2p_prov_disc(dev, info, wrqu, &extra[10]); + } else if (!memcmp(extra, "nego =", 5)) { + wrqu->data.length -= 5; + rtw_p2p_connect(dev, info, wrqu, &extra[5]); + } else if (!memcmp(extra, "intent =", 7)) { + /* Commented by Albert 2011/03/23 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease 7 + 1 */ + wrqu->data.length -= 8; + rtw_p2p_set_intent(dev, info, wrqu, &extra[7]); + } else if (!memcmp(extra, "ssid =", 5)) { + wrqu->data.length -= 5; + rtw_p2p_set_go_nego_ssid(dev, info, wrqu, &extra[5]); + } else if (!memcmp(extra, "got_wpsinfo =", 12)) { + wrqu->data.length -= 12; + rtw_p2p_got_wpsinfo(dev, info, wrqu, &extra[12]); + } else if (!memcmp(extra, "listen_ch =", 10)) { + /* Commented by Albert 2011/05/24 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease (10 + 1) */ + wrqu->data.length -= 11; + rtw_p2p_set_listen_ch(dev, info, wrqu, &extra[10]); + } else if (!memcmp(extra, "op_ch =", 6)) { + /* Commented by Albert 2011/05/24 */ + /* The wrqu->data.length will include the null character */ + /* So, we will decrease (6 + 1) */ + wrqu->data.length -= 7; + rtw_p2p_set_op_ch(dev, info, wrqu, &extra[6]); + } else if (!memcmp(extra, "invite =", 7)) { + wrqu->data.length -= 8; + rtw_p2p_invite_req(dev, info, wrqu, &extra[7]); + } else if (!memcmp(extra, "persistent =", 11)) { + wrqu->data.length -= 11; + rtw_p2p_set_persistent(dev, info, wrqu, &extra[11]); + } +#endif /* CONFIG_88EU_P2P */ + + return ret; +} + +static int rtw_p2p_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + +#ifdef CONFIG_88EU_P2P + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + if (padapter->bShowGetP2PState) + DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); + if (!memcmp(wrqu->data.pointer, "status", 6)) { + rtw_p2p_get_status(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "role", 4)) { + rtw_p2p_get_role(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "peer_ifa", 8)) { + rtw_p2p_get_peer_ifaddr(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "req_cm", 6)) { + rtw_p2p_get_req_cm(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "peer_deva", 9)) { + /* Get the P2P device address when receiving the provision discovery request frame. */ + rtw_p2p_get_peer_devaddr(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "group_id", 8)) { + rtw_p2p_get_groupid(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "peer_deva_inv", 9)) { + /* Get the P2P device address when receiving the P2P Invitation request frame. */ + rtw_p2p_get_peer_devaddr_by_invitation(dev, info, wrqu, extra); + } else if (!memcmp(wrqu->data.pointer, "op_ch", 5)) { + rtw_p2p_get_op_ch(dev, info, wrqu, extra); + } +#endif /* CONFIG_88EU_P2P */ + return ret; +} + +static int rtw_p2p_get2(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + +#ifdef CONFIG_88EU_P2P + DBG_88E("[%s] extra = %s\n", __func__, (char *)wrqu->data.pointer); + if (!memcmp(extra, "wpsCM =", 6)) { + wrqu->data.length -= 6; + rtw_p2p_get_wps_configmethod(dev, info, wrqu, &extra[6]); + } else if (!memcmp(extra, "devN =", 5)) { + wrqu->data.length -= 5; + rtw_p2p_get_device_name(dev, info, wrqu, &extra[5]); + } else if (!memcmp(extra, "dev_type =", 9)) { + wrqu->data.length -= 9; + rtw_p2p_get_device_type(dev, info, wrqu, &extra[9]); + } else if (!memcmp(extra, "go_devadd =", 10)) { + wrqu->data.length -= 10; + rtw_p2p_get_go_device_address(dev, info, wrqu, &extra[10]); + } else if (!memcmp(extra, "InvProc =", 8)) { + wrqu->data.length -= 8; + rtw_p2p_get_invitation_procedure(dev, info, wrqu, &extra[8]); + } + +#endif /* CONFIG_88EU_P2P */ + + return ret; +} + +static int rtw_cta_test_start(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + DBG_88E("%s %s\n", __func__, extra); + if (!strcmp(extra, "1")) + padapter->in_cta_test = 1; + else + padapter->in_cta_test = 0; + + if (padapter->in_cta_test) { + u32 v = rtw_read32(padapter, REG_RCR); + v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ + rtw_write32(padapter, REG_RCR, v); + DBG_88E("enable RCR_ADF\n"); + } else { + u32 v = rtw_read32(padapter, REG_RCR); + v |= RCR_CBSSID_DATA | RCR_CBSSID_BCN;/* RCR_ADF */ + rtw_write32(padapter, REG_RCR, v); + DBG_88E("disable RCR_ADF\n"); + } + return ret; +} + +static int rtw_rereg_nd_name(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv; + char new_ifname[IFNAMSIZ]; + + if (rereg_priv->old_ifname[0] == 0) { + char *reg_ifname; + reg_ifname = padapter->registrypriv.if2name; + + strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); + rereg_priv->old_ifname[IFNAMSIZ-1] = 0; + } + + if (wrqu->data.length > IFNAMSIZ) + return -EFAULT; + + if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) + return -EFAULT; + + if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) + return ret; + + DBG_88E("%s new_ifname:%s\n", __func__, new_ifname); + ret = rtw_change_ifname(padapter, new_ifname); + if (0 != ret) + goto exit; + + if (!memcmp(rereg_priv->old_ifname, "disable%d", 9)) { + padapter->ledpriv.bRegUseLed = rereg_priv->old_bRegUseLed; + rtw_hal_sw_led_init(padapter); + rtw_ips_mode_req(&padapter->pwrctrlpriv, rereg_priv->old_ips_mode); + } + + strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); + rereg_priv->old_ifname[IFNAMSIZ-1] = 0; + + if (!memcmp(new_ifname, "disable%d", 9)) { + DBG_88E("%s disable\n", __func__); + /* free network queue for Android's timming issue */ + rtw_free_network_queue(padapter, true); + + /* close led */ + rtw_led_control(padapter, LED_CTL_POWER_OFF); + rereg_priv->old_bRegUseLed = padapter->ledpriv.bRegUseLed; + padapter->ledpriv.bRegUseLed = false; + rtw_hal_sw_led_deinit(padapter); + + /* the interface is being "disabled", we can do deeper IPS */ + rereg_priv->old_ips_mode = rtw_get_ips_mode_req(&padapter->pwrctrlpriv); + rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); + } +exit: + return ret; +} + +static void mac_reg_dump(struct adapter *padapter) +{ + int i, j = 1; + pr_info("\n ======= MAC REG =======\n"); + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); + } + for (i = 0x400; i < 0x800; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); + } +} + +static void bb_reg_dump(struct adapter *padapter) +{ + int i, j = 1; + pr_info("\n ======= BB REG =======\n"); + for (i = 0x800; i < 0x1000; i += 4) { + if (j%4 == 1) + pr_info("0x%02x", i); + + pr_info(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + pr_info("\n"); + } +} + +static void rf_reg_dump(struct adapter *padapter) +{ + int i, j = 1, path; + u32 value; + u8 rf_type, path_nums = 0; + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + pr_info("\n ======= RF REG =======\n"); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (path = 0; path < path_nums; path++) { + pr_info("\nRF_Path(%x)\n", path); + for (i = 0; i < 0x100; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + pr_info("0x%02x ", i); + pr_info(" 0x%08x ", value); + if ((j++)%4 == 0) + pr_info("\n"); + } + } +} + +static int rtw_dbg_port(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + u8 major_cmd, minor_cmd; + u16 arg; + s32 extra_arg; + u32 *pdata, val32; + struct sta_info *psta; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct sta_priv *pstapriv = &padapter->stapriv; + + pdata = (u32 *)&wrqu->data; + + val32 = *pdata; + arg = (u16)(val32 & 0x0000ffff); + major_cmd = (u8)(val32 >> 24); + minor_cmd = (u8)((val32 >> 16) & 0x00ff); + + extra_arg = *(pdata+1); + + switch (major_cmd) { + case 0x70:/* read_reg */ + switch (minor_cmd) { + case 1: + DBG_88E("rtw_read8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); + break; + case 2: + DBG_88E("rtw_read16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); + break; + case 4: + DBG_88E("rtw_read32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); + break; + } + break; + case 0x71:/* write_reg */ + switch (minor_cmd) { + case 1: + rtw_write8(padapter, arg, extra_arg); + DBG_88E("rtw_write8(0x%x) = 0x%02x\n", arg, rtw_read8(padapter, arg)); + break; + case 2: + rtw_write16(padapter, arg, extra_arg); + DBG_88E("rtw_write16(0x%x) = 0x%04x\n", arg, rtw_read16(padapter, arg)); + break; + case 4: + rtw_write32(padapter, arg, extra_arg); + DBG_88E("rtw_write32(0x%x) = 0x%08x\n", arg, rtw_read32(padapter, arg)); + break; + } + break; + case 0x72:/* read_bb */ + DBG_88E("read_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + break; + case 0x73:/* write_bb */ + rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); + DBG_88E("write_bbreg(0x%x) = 0x%x\n", arg, rtw_hal_read_bbreg(padapter, arg, 0xffffffff)); + break; + case 0x74:/* read_rf */ + DBG_88E("read RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); + break; + case 0x75:/* write_rf */ + rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); + DBG_88E("write RF_reg path(0x%02x), offset(0x%x), value(0x%08x)\n", minor_cmd, arg, rtw_hal_read_rfreg(padapter, minor_cmd, arg, 0xffffffff)); + break; + + case 0x76: + switch (minor_cmd) { + case 0x00: /* normal mode, */ + padapter->recvpriv.is_signal_dbg = 0; + break; + case 0x01: /* dbg mode */ + padapter->recvpriv.is_signal_dbg = 1; + extra_arg = extra_arg > 100 ? 100 : extra_arg; + extra_arg = extra_arg < 0 ? 0 : extra_arg; + padapter->recvpriv.signal_strength_dbg = extra_arg; + break; + } + break; + case 0x78: /* IOL test */ + switch (minor_cmd) { + case 0x04: /* LLT table initialization test */ + { + u8 page_boundary = 0xf9; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + rtw_IOL_append_LLT_cmd(xmit_frame, page_boundary); + + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 500, 0)) + ret = -EPERM; + } + break; + case 0x05: /* blink LED test */ + { + u16 reg = 0x4c; + u32 blink_num = 50; + u32 blink_delay_ms = 200; + int i; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < blink_num; i++) { + rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x00, 0xff); + rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); + rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff); + rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); + } + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200, 0)) + ret = -EPERM; + } + break; + + case 0x06: /* continuous write byte test */ + { + u16 reg = arg; + u16 start_value = 0; + u32 write_num = extra_arg; + int i; + u8 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value, 0xFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read8(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); + } + break; + + case 0x07: /* continuous write word test */ + { + u16 reg = arg; + u16 start_value = 200; + u32 write_num = extra_arg; + + int i; + u16 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value, 0xFFFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read16(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); + } + break; + case 0x08: /* continuous write dword test */ + { + u16 reg = arg; + u32 start_value = 0x110000c7; + u32 write_num = extra_arg; + + int i; + u32 final; + struct xmit_frame *xmit_frame; + + xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); + if (xmit_frame == NULL) { + ret = -ENOMEM; + break; + } + + for (i = 0; i < write_num; i++) + rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value, 0xFFFFFFFF); + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) + ret = -EPERM; + + final = rtw_read32(padapter, reg); + if (start_value+write_num-1 == final) + DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", + reg, write_num, start_value, final); + else + DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Fail, start:%u, final:%u\n", + reg, write_num, start_value, final); + } + break; + } + break; + case 0x79: + { + /* + * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15 + * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15 + */ + u8 value = extra_arg & 0x0f; + u8 sign = minor_cmd; + u16 write_value = 0; + + DBG_88E("%s set RESP_TXAGC to %s %u\n", __func__, sign ? "minus" : "plus", value); + + if (sign) + value = value | 0x10; + + write_value = value | (value << 5); + rtw_write16(padapter, 0x6d9, write_value); + } + break; + case 0x7a: + receive_disconnect(padapter, pmlmeinfo->network.MacAddress + , WLAN_REASON_EXPIRATION_CHK); + break; + case 0x7F: + switch (minor_cmd) { + case 0x0: + DBG_88E("fwstate = 0x%x\n", get_fwstate(pmlmepriv)); + break; + case 0x01: + DBG_88E("auth_alg = 0x%x, enc_alg = 0x%x, auth_type = 0x%x, enc_type = 0x%x\n", + psecuritypriv->dot11AuthAlgrthm, psecuritypriv->dot11PrivacyAlgrthm, + psecuritypriv->ndisauthtype, psecuritypriv->ndisencryptstatus); + break; + case 0x02: + DBG_88E("pmlmeinfo->state = 0x%x\n", pmlmeinfo->state); + break; + case 0x03: + DBG_88E("qos_option =%d\n", pmlmepriv->qospriv.qos_option); + DBG_88E("ht_option =%d\n", pmlmepriv->htpriv.ht_option); + break; + case 0x04: + DBG_88E("cur_ch =%d\n", pmlmeext->cur_channel); + DBG_88E("cur_bw =%d\n", pmlmeext->cur_bwmode); + DBG_88E("cur_ch_off =%d\n", pmlmeext->cur_ch_offset); + break; + case 0x05: + psta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); + if (psta) { + int i; + struct recv_reorder_ctrl *preorder_ctrl; + + DBG_88E("SSID =%s\n", cur_network->network.Ssid.Ssid); + DBG_88E("sta's macaddr: %pM\n", psta->hwaddr); + DBG_88E("cur_channel =%d, cur_bwmode =%d, cur_ch_offset =%d\n", pmlmeext->cur_channel, pmlmeext->cur_bwmode, pmlmeext->cur_ch_offset); + DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); + DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + for (i = 0; i < 16; i++) { + preorder_ctrl = &psta->recvreorder_ctrl[i]; + if (preorder_ctrl->enable) + DBG_88E("tid =%d, indicate_seq =%d\n", i, preorder_ctrl->indicate_seq); + } + } else { + DBG_88E("can't get sta's macaddr, cur_network's macaddr:%pM\n", (cur_network->network.MacAddress)); + } + break; + case 0x06: + { + u32 ODMFlag; + rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); + DBG_88E("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg); + ODMFlag = (u32)(0x0f&arg); + DBG_88E("(A)DMFlag = 0x%x\n", ODMFlag); + rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); + } + break; + case 0x07: + DBG_88E("bSurpriseRemoved =%d, bDriverStopped =%d\n", + padapter->bSurpriseRemoved, padapter->bDriverStopped); + break; + case 0x08: + { + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct recv_priv *precvpriv = &padapter->recvpriv; + + DBG_88E("free_xmitbuf_cnt =%d, free_xmitframe_cnt =%d, free_xmit_extbuf_cnt =%d\n", + pxmitpriv->free_xmitbuf_cnt, pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmit_extbuf_cnt); + DBG_88E("rx_urb_pending_cn =%d\n", precvpriv->rx_pending_cnt); + } + break; + case 0x09: + { + int i, j; + struct list_head *plist, *phead; + struct recv_reorder_ctrl *preorder_ctrl; + +#ifdef CONFIG_88EU_AP_MODE + DBG_88E("sta_dz_bitmap = 0x%x, tim_bitmap = 0x%x\n", pstapriv->sta_dz_bitmap, pstapriv->tim_bitmap); +#endif + spin_lock_bh(&pstapriv->sta_hash_lock); + + for (i = 0; i < NUM_STA; i++) { + phead = &(pstapriv->sta_hash[i]); + plist = phead->next; + + while (phead != plist) { + psta = container_of(plist, struct sta_info, hash_list); + + plist = plist->next; + + if (extra_arg == psta->aid) { + DBG_88E("sta's macaddr:%pM\n", (psta->hwaddr)); + DBG_88E("rtsen =%d, cts2slef =%d\n", psta->rtsen, psta->cts2self); + DBG_88E("state = 0x%x, aid =%d, macid =%d, raid =%d\n", psta->state, psta->aid, psta->mac_id, psta->raid); + DBG_88E("qos_en =%d, ht_en =%d, init_rate =%d\n", psta->qos_option, psta->htpriv.ht_option, psta->init_rate); + DBG_88E("bwmode =%d, ch_offset =%d, sgi =%d\n", psta->htpriv.bwmode, psta->htpriv.ch_offset, psta->htpriv.sgi); + DBG_88E("ampdu_enable = %d\n", psta->htpriv.ampdu_enable); + DBG_88E("agg_enable_bitmap =%x, candidate_tid_bitmap =%x\n", psta->htpriv.agg_enable_bitmap, psta->htpriv.candidate_tid_bitmap); + +#ifdef CONFIG_88EU_AP_MODE + DBG_88E("capability = 0x%x\n", psta->capability); + DBG_88E("flags = 0x%x\n", psta->flags); + DBG_88E("wpa_psk = 0x%x\n", psta->wpa_psk); + DBG_88E("wpa2_group_cipher = 0x%x\n", psta->wpa2_group_cipher); + DBG_88E("wpa2_pairwise_cipher = 0x%x\n", psta->wpa2_pairwise_cipher); + DBG_88E("qos_info = 0x%x\n", psta->qos_info); +#endif + DBG_88E("dot118021XPrivacy = 0x%x\n", psta->dot118021XPrivacy); + + for (j = 0; j < 16; j++) { + preorder_ctrl = &psta->recvreorder_ctrl[j]; + if (preorder_ctrl->enable) + DBG_88E("tid =%d, indicate_seq =%d\n", j, preorder_ctrl->indicate_seq); + } + } + } + } + spin_unlock_bh(&pstapriv->sta_hash_lock); + } + break; + case 0x0c:/* dump rx/tx packet */ + if (arg == 0) { + DBG_88E("dump rx packet (%d)\n", extra_arg); + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); + } else if (arg == 1) { + DBG_88E("dump tx packet (%d)\n", extra_arg); + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); + } + break; + case 0x0f: + if (extra_arg == 0) { + DBG_88E("###### silent reset test.......#####\n"); + rtw_hal_sreset_reset(padapter); + } + break; + case 0x15: + { + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + DBG_88E("==>silent resete cnts:%d\n", pwrpriv->ips_enter_cnts); + } + break; + case 0x10:/* driver version display */ + DBG_88E("rtw driver version =%s\n", DRIVERVERSION); + break; + case 0x11: + DBG_88E("turn %s Rx RSSI display function\n", (extra_arg == 1) ? "on" : "off"); + padapter->bRxRSSIDisplay = extra_arg; + rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &extra_arg); + break; + case 0x12: /* set rx_stbc */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + /* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, 0x3: enable both 2.4g and 5g */ + /* default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ + if (pregpriv && + (extra_arg == 0 || + extra_arg == 1 || + extra_arg == 2 || + extra_arg == 3)) { + pregpriv->rx_stbc = extra_arg; + DBG_88E("set rx_stbc =%d\n", pregpriv->rx_stbc); + } else { + DBG_88E("get rx_stbc =%d\n", pregpriv->rx_stbc); + } + } + break; + case 0x13: /* set ampdu_enable */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ + if (pregpriv && extra_arg >= 0 && extra_arg < 3) { + pregpriv->ampdu_enable = extra_arg; + DBG_88E("set ampdu_enable =%d\n", pregpriv->ampdu_enable); + } else { + DBG_88E("get ampdu_enable =%d\n", pregpriv->ampdu_enable); + } + } + break; + case 0x14: /* get wifi_spec */ + { + struct registry_priv *pregpriv = &padapter->registrypriv; + DBG_88E("get wifi_spec =%d\n", pregpriv->wifi_spec); + } + break; + case 0x16: + if (arg == 0xff) { + pr_info("ODM_COMP_DIG\t\tBIT0\n"); + pr_info("ODM_COMP_RA_MASK\t\tBIT1\n"); + pr_info("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); + pr_info("ODM_COMP_FA_CNT\t\tBIT3\n"); + pr_info("ODM_COMP_RSSI_MONITOR\tBIT4\n"); + pr_info("ODM_COMP_CCK_PD\t\tBIT5\n"); + pr_info("ODM_COMP_ANT_DIV\t\tBIT6\n"); + pr_info("ODM_COMP_PWR_SAVE\t\tBIT7\n"); + pr_info("ODM_COMP_PWR_TRAIN\tBIT8\n"); + pr_info("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); + pr_info("ODM_COMP_PATH_DIV\t\tBIT10\n"); + pr_info("ODM_COMP_PSD \tBIT11\n"); + pr_info("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); + pr_info("ODM_COMP_RXHP\t\tBIT13\n"); + pr_info("ODM_COMP_EDCA_TURBO\tBIT16\n"); + pr_info("ODM_COMP_EARLY_MODE\tBIT17\n"); + pr_info("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); + pr_info("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); + pr_info("ODM_COMP_CALIBRATION\tBIT26\n"); + rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); + } else { + rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); + } + break; + case 0x23: + DBG_88E("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1) ? "on" : "off"); + padapter->bNotifyChannelChange = extra_arg; + break; + case 0x24: +#ifdef CONFIG_88EU_P2P + DBG_88E("turn %s the bShowGetP2PState Variable\n", (extra_arg == 1) ? "on" : "off"); + padapter->bShowGetP2PState = extra_arg; +#endif /* CONFIG_88EU_P2P */ + break; + case 0xaa: + if (extra_arg > 0x13) + extra_arg = 0xFF; + DBG_88E("chang data rate to :0x%02x\n", extra_arg); + padapter->fix_rate = extra_arg; + break; + case 0xdd:/* registers dump, 0 for mac reg, 1 for bb reg, 2 for rf reg */ + if (extra_arg == 0) + mac_reg_dump(padapter); + else if (extra_arg == 1) + bb_reg_dump(padapter); + else if (extra_arg == 2) + rf_reg_dump(padapter); + break; + case 0xee:/* turn on/off dynamic funcs */ + { + u32 odm_flag; + + if (0xf == extra_arg) { + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); + DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); + DBG_88E("extra_arg = 0 - disable all dynamic func\n"); + DBG_88E("extra_arg = 1 - disable DIG- BIT(0)\n"); + DBG_88E("extra_arg = 2 - disable High power - BIT(1)\n"); + DBG_88E("extra_arg = 3 - disable tx power tracking - BIT(2)\n"); + DBG_88E("extra_arg = 4 - disable BT coexistence - BIT(3)\n"); + DBG_88E("extra_arg = 5 - disable antenna diversity - BIT(4)\n"); + DBG_88E("extra_arg = 6 - enable all dynamic func\n"); + } else { + /* extra_arg = 0 - disable all dynamic func + extra_arg = 1 - disable DIG + extra_arg = 2 - disable tx power tracking + extra_arg = 3 - turn on all dynamic func + */ + rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); + rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); + DBG_88E(" === DMFlag(0x%08x) ===\n", odm_flag); + } + } + break; + + case 0xfd: + rtw_write8(padapter, 0xc50, arg); + DBG_88E("wr(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); + rtw_write8(padapter, 0xc58, arg); + DBG_88E("wr(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); + break; + case 0xfe: + DBG_88E("rd(0xc50) = 0x%x\n", rtw_read8(padapter, 0xc50)); + DBG_88E("rd(0xc58) = 0x%x\n", rtw_read8(padapter, 0xc58)); + break; + case 0xff: + DBG_88E("dbg(0x210) = 0x%x\n", rtw_read32(padapter, 0x210)); + DBG_88E("dbg(0x608) = 0x%x\n", rtw_read32(padapter, 0x608)); + DBG_88E("dbg(0x280) = 0x%x\n", rtw_read32(padapter, 0x280)); + DBG_88E("dbg(0x284) = 0x%x\n", rtw_read32(padapter, 0x284)); + DBG_88E("dbg(0x288) = 0x%x\n", rtw_read32(padapter, 0x288)); + + DBG_88E("dbg(0x664) = 0x%x\n", rtw_read32(padapter, 0x664)); + + DBG_88E("\n"); + + DBG_88E("dbg(0x430) = 0x%x\n", rtw_read32(padapter, 0x430)); + DBG_88E("dbg(0x438) = 0x%x\n", rtw_read32(padapter, 0x438)); + + DBG_88E("dbg(0x440) = 0x%x\n", rtw_read32(padapter, 0x440)); + + DBG_88E("dbg(0x458) = 0x%x\n", rtw_read32(padapter, 0x458)); + + DBG_88E("dbg(0x484) = 0x%x\n", rtw_read32(padapter, 0x484)); + DBG_88E("dbg(0x488) = 0x%x\n", rtw_read32(padapter, 0x488)); + + DBG_88E("dbg(0x444) = 0x%x\n", rtw_read32(padapter, 0x444)); + DBG_88E("dbg(0x448) = 0x%x\n", rtw_read32(padapter, 0x448)); + DBG_88E("dbg(0x44c) = 0x%x\n", rtw_read32(padapter, 0x44c)); + DBG_88E("dbg(0x450) = 0x%x\n", rtw_read32(padapter, 0x450)); + break; + } + break; + default: + DBG_88E("error dbg cmd!\n"); + break; + } + return ret; +} + +static int wpa_set_param(struct net_device *dev, u8 name, u32 value) +{ + uint ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + switch (name) { + case IEEE_PARAM_WPA_ENABLED: + padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ + switch ((value)&0xff) { + case 1: /* WPA */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; + break; + case 2: /* WPA2 */ + padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */ + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + } + RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, + ("wpa_set_param:padapter->securitypriv.ndisauthtype =%d\n", padapter->securitypriv.ndisauthtype)); + break; + case IEEE_PARAM_TKIP_COUNTERMEASURES: + break; + case IEEE_PARAM_DROP_UNENCRYPTED: { + /* HACK: + * + * wpa_supplicant calls set_wpa_enabled when the driver + * is loaded and unloaded, regardless of if WPA is being + * used. No other calls are made which can be used to + * determine if encryption will be used or not prior to + * association being expected. If encryption is not being + * used, drop_unencrypted is set to false, else true -- we + * can use this to determine if the CAP_PRIVACY_ON bit should + * be set. + */ + + break; + } + case IEEE_PARAM_PRIVACY_INVOKED: + break; + + case IEEE_PARAM_AUTH_ALGS: + ret = wpa_set_auth_algs(dev, value); + break; + case IEEE_PARAM_IEEE_802_1X: + break; + case IEEE_PARAM_WPAX_SELECT: + break; + default: + ret = -EOPNOTSUPP; + break; + } + return ret; +} + +static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + switch (command) { + case IEEE_MLME_STA_DEAUTH: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + case IEEE_MLME_STA_DISASSOC: + if (!rtw_set_802_11_disassociate(padapter)) + ret = -1; + break; + default: + ret = -EOPNOTSUPP; + break; + } + + return ret; +} + +static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) +{ + struct ieee_param *param; + uint ret = 0; + + if (p->length < sizeof(struct ieee_param) || !p->pointer) { + ret = -EINVAL; + goto out; + } + + param = (struct ieee_param *)rtw_malloc(p->length); + if (param == NULL) { + ret = -ENOMEM; + goto out; + } + + if (copy_from_user(param, p->pointer, p->length)) { + kfree(param); + ret = -EFAULT; + goto out; + } + + switch (param->cmd) { + case IEEE_CMD_SET_WPA_PARAM: + ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value); + break; + + case IEEE_CMD_SET_WPA_IE: + ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), + (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); + break; + + case IEEE_CMD_SET_ENCRYPTION: + ret = wpa_set_encryption(dev, param, p->length); + break; + + case IEEE_CMD_MLME: + ret = wpa_mlme(dev, param->u.mlme.command, param->u.mlme.reason_code); + break; + + default: + DBG_88E("Unknown WPA supplicant request: %d\n", param->cmd); + ret = -EOPNOTSUPP; + break; + } + + if (ret == 0 && copy_to_user(p->pointer, param, p->length)) + ret = -EFAULT; + + kfree(param); + +out: + + return ret; +} + +#ifdef CONFIG_88EU_AP_MODE +static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) +{ + struct cmd_obj *ph2c; + struct set_stakey_parm *psetstakey_para; + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; + u8 res = _SUCCESS; + + ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (ph2c == NULL) { + res = _FAIL; + goto exit; + } + + psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + if (psetstakey_para == NULL) { + kfree(ph2c); + res = _FAIL; + goto exit; + } + + init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); + + psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; + + memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); + + memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); + + res = rtw_enqueue_cmd(pcmdpriv, ph2c); + +exit: + + return res; +} + +static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) +{ + u8 keylen; + struct cmd_obj *pcmd; + struct setkey_parm *psetkeyparm; + struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + int res = _SUCCESS; + + DBG_88E("%s\n", __func__); + + pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + if (pcmd == NULL) { + res = _FAIL; + goto exit; + } + psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + if (psetkeyparm == NULL) { + kfree(pcmd); + res = _FAIL; + goto exit; + } + + memset(psetkeyparm, 0, sizeof(struct setkey_parm)); + + psetkeyparm->keyid = (u8)keyid; + + psetkeyparm->algorithm = alg; + + psetkeyparm->set_tx = 1; + + switch (alg) { + case _WEP40_: + keylen = 5; + break; + case _WEP104_: + keylen = 13; + break; + case _TKIP_: + case _TKIP_WTMIC_: + case _AES_: + default: + keylen = 16; + } + + memcpy(&(psetkeyparm->key[0]), key, keylen); + + pcmd->cmdcode = _SetKey_CMD_; + pcmd->parmbuf = (u8 *)psetkeyparm; + pcmd->cmdsz = (sizeof(struct setkey_parm)); + pcmd->rsp = NULL; + pcmd->rspsz = 0; + + INIT_LIST_HEAD(&pcmd->list); + + res = rtw_enqueue_cmd(pcmdpriv, pcmd); + +exit: + + return res; +} + +static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid) +{ + u8 alg; + + switch (keylen) { + case 5: + alg = _WEP40_; + break; + case 13: + alg = _WEP104_; + break; + default: + alg = _NO_PRIVACY_; + } + + return set_group_key(padapter, key, alg, keyid); +} + +static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) +{ + int ret = 0; + u32 wep_key_idx, wep_key_len, wep_total_len; + struct ndis_802_11_wep *pwep = NULL; + struct sta_info *psta = NULL, *pbcmc_sta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("%s\n", __func__); + param->u.crypt.err = 0; + param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; + if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) { + ret = -EINVAL; + goto exit; + } + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { + if (param->u.crypt.idx >= WEP_KEYS) { + ret = -EINVAL; + goto exit; + } + } else { + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (!psta) { + DBG_88E("rtw_set_encryption(), sta has already been removed or never been added\n"); + goto exit; + } + } + + if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) { + /* todo:clear default encryption keys */ + + DBG_88E("clear default encryption keys, keyid =%d\n", param->u.crypt.idx); + goto exit; + } + if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) { + DBG_88E("r871x_set_encryption, crypt.alg = WEP\n"); + wep_key_idx = param->u.crypt.idx; + wep_key_len = param->u.crypt.key_len; + DBG_88E("r871x_set_encryption, wep_key_idx=%d, len=%d\n", wep_key_idx, wep_key_len); + if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) { + ret = -EINVAL; + goto exit; + } + + if (wep_key_len > 0) { + wep_key_len = wep_key_len <= 5 ? 5 : 13; + wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); + pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + if (pwep == NULL) { + DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); + goto exit; + } + + memset(pwep, 0, wep_total_len); + + pwep->KeyLength = wep_key_len; + pwep->Length = wep_total_len; + } + + pwep->KeyIndex = wep_key_idx; + + memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); + + if (param->u.crypt.set_tx) { + DBG_88E("wep, set_tx = 1\n"); + + psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; + psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + + if (pwep->KeyLength == 13) { + psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + } + + psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; + + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + + set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); + } else { + DBG_88E("wep, set_tx = 0\n"); + + /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ + /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ + + memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + + psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; + + set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); + } + + goto exit; + } + + if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ + if (param->u.crypt.set_tx == 1) { + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + DBG_88E("%s, set group_key, WEP\n", __func__); + + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + if (param->u.crypt.key_len == 13) + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + DBG_88E("%s, set group_key, TKIP\n", __func__); + psecuritypriv->dot118021XGrpPrivacy = _TKIP_; + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + /* set mic key */ + memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + + psecuritypriv->busetkipkey = true; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + DBG_88E("%s, set group_key, CCMP\n", __func__); + psecuritypriv->dot118021XGrpPrivacy = _AES_; + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + } else { + DBG_88E("%s, set group_key, none\n", __func__); + psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + } + psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; + psecuritypriv->binstallGrpkey = true; + psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ + set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta) { + pbcmc_sta->ieee8021x_blocked = false; + pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ + } + } + goto exit; + } + + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */ + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + if (param->u.crypt.set_tx == 1) { + memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + DBG_88E("%s, set pairwise key, WEP\n", __func__); + + psta->dot118021XPrivacy = _WEP40_; + if (param->u.crypt.key_len == 13) + psta->dot118021XPrivacy = _WEP104_; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + DBG_88E("%s, set pairwise key, TKIP\n", __func__); + + psta->dot118021XPrivacy = _TKIP_; + + /* set mic key */ + memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); + memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); + + psecuritypriv->busetkipkey = true; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + DBG_88E("%s, set pairwise key, CCMP\n", __func__); + + psta->dot118021XPrivacy = _AES_; + } else { + DBG_88E("%s, set pairwise key, none\n", __func__); + + psta->dot118021XPrivacy = _NO_PRIVACY_; + } + + set_pairwise_key(padapter, psta); + + psta->ieee8021x_blocked = false; + } else { /* group key??? */ + if (strcmp(param->u.crypt.alg, "WEP") == 0) { + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + psecuritypriv->dot118021XGrpPrivacy = _WEP40_; + if (param->u.crypt.key_len == 13) + psecuritypriv->dot118021XGrpPrivacy = _WEP104_; + } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { + psecuritypriv->dot118021XGrpPrivacy = _TKIP_; + + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + + /* set mic key */ + memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); + memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + + psecuritypriv->busetkipkey = true; + } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { + psecuritypriv->dot118021XGrpPrivacy = _AES_; + + memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, + param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); + } else { + psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + } + + psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; + + psecuritypriv->binstallGrpkey = true; + + psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ + + set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); + + pbcmc_sta = rtw_get_bcmc_stainfo(padapter); + if (pbcmc_sta) { + pbcmc_sta->ieee8021x_blocked = false; + pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ + } + } + } + } + +exit: + + kfree(pwep); + + return ret; +} + +static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + unsigned char *pbuf = param->u.bcn_ie.buf; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); + + if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) + pstapriv->max_num_sta = NUM_STA; + + if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */ + ret = 0; + else + ret = -EINVAL; + + return ret; +} + +static int rtw_hostapd_sta_flush(struct net_device *dev) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + DBG_88E("%s\n", __func__); + + flush_all_cam_entry(padapter); /* clear CAM */ + + ret = rtw_sta_flush(padapter); + + return ret; +} + +static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); + + if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) { + int flags = param->u.add_sta.flags; + + psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */ + + memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); + + /* check wmm cap. */ + if (WLAN_STA_WME&flags) + psta->qos_option = 1; + else + psta->qos_option = 0; + + if (pmlmepriv->qospriv.qos_option == 0) + psta->qos_option = 0; + + /* chec 802.11n ht cap. */ + if (WLAN_STA_HT&flags) { + psta->htpriv.ht_option = true; + psta->qos_option = 1; + memcpy((void *)&psta->htpriv.ht_cap, (void *)¶m->u.add_sta.ht_cap, sizeof(struct ieee80211_ht_cap)); + } else { + psta->htpriv.ht_option = false; + } + + if (pmlmepriv->htpriv.ht_option == false) + psta->htpriv.ht_option = false; + + update_sta_info_apmode(padapter, psta); + } else { + ret = -ENOMEM; + } + + return ret; +} + +static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + int updated = 0; + + DBG_88E("rtw_del_sta =%pM\n", (param->sta_addr)); + + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) { + spin_lock_bh(&pstapriv->asoc_list_lock); + if (!list_empty(&psta->asoc_list)) { + list_del_init(&psta->asoc_list); + pstapriv->asoc_list_cnt--; + updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); + } + spin_unlock_bh(&pstapriv->asoc_list_lock); + associated_clients_update(padapter, updated); + psta = NULL; + } else { + DBG_88E("rtw_del_sta(), sta has already been removed or never been added\n"); + } + + return ret; +} + +static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; + struct sta_data *psta_data = (struct sta_data *)param_ex->data; + + DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr)); + + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + return -EINVAL; + + if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && + param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && + param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); + if (psta) { + psta_data->aid = (u16)psta->aid; + psta_data->capability = psta->capability; + psta_data->flags = psta->flags; + +/* + nonerp_set : BIT(0) + no_short_slot_time_set : BIT(1) + no_short_preamble_set : BIT(2) + no_ht_gf_set : BIT(3) + no_ht_set : BIT(4) + ht_20mhz_set : BIT(5) +*/ + + psta_data->sta_set = ((psta->nonerp_set) | + (psta->no_short_slot_time_set << 1) | + (psta->no_short_preamble_set << 2) | + (psta->no_ht_gf_set << 3) | + (psta->no_ht_set << 4) | + (psta->ht_20mhz_set << 5)); + psta_data->tx_supp_rates_len = psta->bssratelen; + memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); + memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct ieee80211_ht_cap)); + psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; + psta_data->rx_bytes = psta->sta_stats.rx_bytes; + psta_data->rx_drops = psta->sta_stats.rx_drops; + psta_data->tx_pkts = psta->sta_stats.tx_pkts; + psta_data->tx_bytes = psta->sta_stats.tx_bytes; + psta_data->tx_drops = psta->sta_stats.tx_drops; + } else { + ret = -1; + } + + return ret; +} + +static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) +{ + int ret = 0; + struct sta_info *psta = NULL; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct sta_priv *pstapriv = &padapter->stapriv; + + DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); + + if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + + psta = rtw_get_stainfo(pstapriv, param->sta_addr); + if (psta) { + if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) { + int wpa_ie_len; + int copy_len; + + wpa_ie_len = psta->wpa_ie[1]; + copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)) : (wpa_ie_len+2); + param->u.wpa_ie.len = copy_len; + memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); + } else { + DBG_88E("sta's wpa_ie is NONE\n"); + } + } else { + ret = -1; + } + + return ret; +} + +static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + int ie_len; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + ie_len = len-12-2;/* 12 = param header, 2:no packed */ + + if (pmlmepriv->wps_beacon_ie) { + kfree(pmlmepriv->wps_beacon_ie); + pmlmepriv->wps_beacon_ie = NULL; + } + + if (ie_len > 0) { + pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); + pmlmepriv->wps_beacon_ie_len = ie_len; + if (pmlmepriv->wps_beacon_ie == NULL) { + DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + return -EINVAL; + } + + memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); + + update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); + + pmlmeext->bstart_bss = true; + } + + return ret; +} + +static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int ie_len; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + ie_len = len-12-2;/* 12 = param header, 2:no packed */ + + if (pmlmepriv->wps_probe_resp_ie) { + kfree(pmlmepriv->wps_probe_resp_ie); + pmlmepriv->wps_probe_resp_ie = NULL; + } + + if (ie_len > 0) { + pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); + pmlmepriv->wps_probe_resp_ie_len = ie_len; + if (pmlmepriv->wps_probe_resp_ie == NULL) { + DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + return -EINVAL; + } + memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); + } + + return ret; +} + +static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + int ie_len; + + DBG_88E("%s, len =%d\n", __func__, len); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + ie_len = len-12-2;/* 12 = param header, 2:no packed */ + + if (pmlmepriv->wps_assoc_resp_ie) { + kfree(pmlmepriv->wps_assoc_resp_ie); + pmlmepriv->wps_assoc_resp_ie = NULL; + } + + if (ie_len > 0) { + pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); + pmlmepriv->wps_assoc_resp_ie_len = ie_len; + if (pmlmepriv->wps_assoc_resp_ie == NULL) { + DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + return -EINVAL; + } + + memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); + } + + return ret; +} + +static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + + u8 value; + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + if (param->u.wpa_param.name != 0) /* dummy test... */ + DBG_88E("%s name(%u) != 0\n", __func__, param->u.wpa_param.name); + value = param->u.wpa_param.value; + + /* use the same definition of hostapd's ignore_broadcast_ssid */ + if (value != 1 && value != 2) + value = 0; + DBG_88E("%s value(%u)\n", __func__, value); + pmlmeinfo->hidden_ssid_mode = value; + return ret; +} + +static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + ret = rtw_acl_remove_sta(padapter, param->sta_addr); + return ret; +} + +static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && + param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && + param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) + return -EINVAL; + ret = rtw_acl_add_sta(padapter, param->sta_addr); + return ret; +} + +static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) +{ + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) + return -EINVAL; + + rtw_set_macaddr_acl(padapter, param->u.mlme.command); + + return ret; +} + +static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) +{ + struct ieee_param *param; + int ret = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + /* + * this function is expect to call in master mode, which allows no power saving + * so, we just check hw_init_completed + */ + + if (!padapter->hw_init_completed) { + ret = -EPERM; + goto out; + } + + if (!p->pointer || p->length > (sizeof(struct ieee_param) + 100)) { + ret = -EINVAL; + goto out; + } + + param = (struct ieee_param *)rtw_malloc(p->length); + if (param == NULL) { + ret = -ENOMEM; + goto out; + } + + if (copy_from_user(param, p->pointer, p->length)) { + kfree(param); + ret = -EFAULT; + goto out; + } + + switch (param->cmd) { + case RTL871X_HOSTAPD_FLUSH: + ret = rtw_hostapd_sta_flush(dev); + break; + case RTL871X_HOSTAPD_ADD_STA: + ret = rtw_add_sta(dev, param); + break; + case RTL871X_HOSTAPD_REMOVE_STA: + ret = rtw_del_sta(dev, param); + break; + case RTL871X_HOSTAPD_SET_BEACON: + ret = rtw_set_beacon(dev, param, p->length); + break; + case RTL871X_SET_ENCRYPTION: + ret = rtw_set_encryption(dev, param, p->length); + break; + case RTL871X_HOSTAPD_GET_WPAIE_STA: + ret = rtw_get_sta_wpaie(dev, param); + break; + case RTL871X_HOSTAPD_SET_WPS_BEACON: + ret = rtw_set_wps_beacon(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: + ret = rtw_set_wps_probe_resp(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: + ret = rtw_set_wps_assoc_resp(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_HIDDEN_SSID: + ret = rtw_set_hidden_ssid(dev, param, p->length); + break; + case RTL871X_HOSTAPD_GET_INFO_STA: + ret = rtw_ioctl_get_sta_data(dev, param, p->length); + break; + case RTL871X_HOSTAPD_SET_MACADDR_ACL: + ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); + break; + case RTL871X_HOSTAPD_ACL_ADD_STA: + ret = rtw_ioctl_acl_add_sta(dev, param, p->length); + break; + case RTL871X_HOSTAPD_ACL_REMOVE_STA: + ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); + break; + default: + pr_info("Unknown hostapd request: %d\n", param->cmd); + ret = -EOPNOTSUPP; + break; + } + + if (ret == 0 && copy_to_user(p->pointer, param, p->length)) + ret = -EFAULT; + kfree(param); +out: + return ret; +} +#endif + +#include +static int rtw_wx_set_priv(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra) +{ + int ret = 0; + int len = 0; + char *ext; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *dwrq = (struct iw_point *)awrq; + + if (dwrq->length == 0) + return -EFAULT; + + len = dwrq->length; + ext = rtw_vmalloc(len); + if (!ext) + return -ENOMEM; + + if (copy_from_user(ext, dwrq->pointer, len)) { + rtw_vmfree(ext, len); + return -EFAULT; + } + + /* added for wps2.0 @20110524 */ + if (dwrq->flags == 0x8766 && len > 8) { + u32 cp_sz; + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + u8 *probereq_wpsie = ext; + int probereq_wpsie_len = len; + u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; + + if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && + (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { + cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; + + pmlmepriv->wps_probe_req_ie_len = 0; + kfree(pmlmepriv->wps_probe_req_ie); + pmlmepriv->wps_probe_req_ie = NULL; + + pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); + if (pmlmepriv->wps_probe_req_ie == NULL) { + pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); + ret = -EINVAL; + goto FREE_EXT; + } + memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); + pmlmepriv->wps_probe_req_ie_len = cp_sz; + } + goto FREE_EXT; + } + + if (len >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { + ret = rtw_wx_set_scan(dev, info, awrq, ext); + goto FREE_EXT; + } + +FREE_EXT: + + rtw_vmfree(ext, len); + + return ret; +} + +static int rtw_pm_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + int ret = 0; + unsigned mode = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + + DBG_88E("[%s] extra = %s\n", __func__, extra); + + if (!memcmp(extra, "lps =", 4)) { + sscanf(extra+4, "%u", &mode); + ret = rtw_pm_set_lps(padapter, mode); + } else if (!memcmp(extra, "ips =", 4)) { + sscanf(extra+4, "%u", &mode); + ret = rtw_pm_set_ips(padapter, mode); + } else { + ret = -EINVAL; + } + + return ret; +} + +static int rtw_mp_efuse_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + struct efuse_hal *pEfuseHal; + struct iw_point *wrqu; + + u8 *PROMContent = pEEPROM->efuse_eeprom_data; + u8 ips_mode = 0, lps_mode = 0; + struct pwrctrl_priv *pwrctrlpriv; + u8 *data = NULL; + u8 *rawdata = NULL; + char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; + u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; + u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; + int err; + u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ + + wrqu = (struct iw_point *)wdata; + pwrctrlpriv = &padapter->pwrctrlpriv; + pEfuseHal = &haldata->EfuseHal; + + err = 0; + data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); + if (data == NULL) { + err = -ENOMEM; + goto exit; + } + rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); + if (rawdata == NULL) { + err = -ENOMEM; + goto exit; + } + + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { + err = -EFAULT; + goto exit; + } + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); + + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); + + pch = extra; + DBG_88E("%s: in =%s\n", __func__, extra); + + i = 0; + /* mac 16 "00e04c871200" rmap, 00, 2 */ + while ((token = strsep(&pch, ",")) != NULL) { + if (i > 2) + break; + tmp[i] = token; + i++; + } + padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ + + if (strcmp(tmp[0], "status") == 0) { + sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); + + goto exit; + } else if (strcmp(tmp[0], "filemap") == 0) { + mapLen = EFUSE_MAP_SIZE; + + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra + strlen(extra), "0x%02x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else if (strcmp(tmp[0], "realmap") == 0) { + mapLen = EFUSE_MAP_SIZE; + if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { + DBG_88E("%s: read realmap Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra + strlen(extra), "0x%02x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else if (strcmp(tmp[0], "rmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + DBG_88E("%s: rmap Fail!! Parameters error!\n", __func__); + err = -EINVAL; + goto exit; + } + + /* rmap addr cnts */ + addr = simple_strtoul(tmp[1], &ptmp, 16); + DBG_88E("%s: addr =%x\n", __func__, addr); + + cnts = simple_strtoul(tmp[2], &ptmp, 10); + if (cnts == 0) { + DBG_88E("%s: rmap Fail!! cnts error!\n", __func__); + err = -EINVAL; + goto exit; + } + DBG_88E("%s: cnts =%d\n", __func__, cnts); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EINVAL; + goto exit; + } + + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) + sprintf(extra + strlen(extra), "0x%02X ", data[i]); + } else if (strcmp(tmp[0], "realraw") == 0) { + addr = 0; + mapLen = EFUSE_MAX_SIZE; + if (rtw_efuse_access(padapter, false, addr, mapLen, rawdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_access Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 0; i < mapLen; i++) { + sprintf(extra + strlen(extra), "%02X", rawdata[i]); + + if ((i & 0xF) == 0xF) + sprintf(extra + strlen(extra), "\n"); + else if ((i & 0x7) == 0x7) + sprintf(extra + strlen(extra), "\t"); + else + sprintf(extra + strlen(extra), " "); + } + } else if (strcmp(tmp[0], "mac") == 0) { + cnts = 6; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_read error!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) { + sprintf(extra + strlen(extra), "%02X", data[i]); + if (i != (cnts-1)) + sprintf(extra + strlen(extra), ":"); + } + } else if (strcmp(tmp[0], "vidpid") == 0) { + cnts = 4; + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%02x)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + if (rtw_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_efuse_access error!!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) { + sprintf(extra + strlen(extra), "0x%02X", data[i]); + if (i != (cnts-1)) + sprintf(extra + strlen(extra), ","); + } + } else if (strcmp(tmp[0], "ableraw") == 0) { + efuse_GetCurrentSize(padapter, &raw_cursize); + raw_maxsize = efuse_GetMaxSize(padapter); + sprintf(extra, "[available raw size] = %d bytes", raw_maxsize-raw_cursize); + } else if (strcmp(tmp[0], "btfmap") == 0) { + mapLen = EFUSE_BT_MAX_MAP_LEN; + if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 0; i < 512; i += 16) { + /* set 512 because the iwpriv's extra size have limit 0x7FF */ + sprintf(extra + strlen(extra), "0x%03x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else if (strcmp(tmp[0], "btbmap") == 0) { + mapLen = EFUSE_BT_MAX_MAP_LEN; + if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_read Fail!!\n", __func__); + err = -EFAULT; + goto exit; + } + + sprintf(extra, "\n"); + for (i = 512; i < 1024; i += 16) { + sprintf(extra + strlen(extra), "0x%03x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else if (strcmp(tmp[0], "btrmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + /* rmap addr cnts */ + addr = simple_strtoul(tmp[1], &ptmp, 16); + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + + cnts = simple_strtoul(tmp[2], &ptmp, 10); + if (cnts == 0) { + DBG_88E("%s: btrmap Fail!! cnts error!\n", __func__); + err = -EINVAL; + goto exit; + } + DBG_88E("%s: cnts =%d\n", __func__, cnts); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr + cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_BT_efuse_map_read(padapter, addr, cnts, data) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_read error!!\n", __func__); + err = -EFAULT; + goto exit; + } + + *extra = 0; + for (i = 0; i < cnts; i++) + sprintf(extra + strlen(extra), " 0x%02X ", data[i]); + } else if (strcmp(tmp[0], "btffake") == 0) { + sprintf(extra, "\n"); + for (i = 0; i < 512; i += 16) { + sprintf(extra + strlen(extra), "0x%03x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else if (strcmp(tmp[0], "btbfake") == 0) { + sprintf(extra, "\n"); + for (i = 512; i < 1024; i += 16) { + sprintf(extra + strlen(extra), "0x%03x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else if (strcmp(tmp[0], "wlrfkmap") == 0) { + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra + strlen(extra), "0x%02x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), " %02X", pEfuseHal->fakeEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "\n"); + } + } else { + sprintf(extra, "Command not found!"); + } + +exit: + kfree(data); + kfree(rawdata); + if (!err) + wrqu->length = strlen(extra); + + rtw_pm_set_ips(padapter, ips_mode); + rtw_pm_set_lps(padapter, lps_mode); + padapter->registrypriv.fw_iol = org_fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ + return err; +} + +static int rtw_mp_efuse_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct adapter *padapter; + struct pwrctrl_priv *pwrctrlpriv; + struct hal_data_8188e *haldata; + struct efuse_hal *pEfuseHal; + + u8 ips_mode = 0, lps_mode = 0; + u32 i, jj, kk; + u8 *setdata = NULL; + u8 *ShadowMapBT = NULL; + u8 *ShadowMapWiFi = NULL; + u8 *setrawdata = NULL; + char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; + u16 addr = 0, cnts = 0, max_available_size = 0; + int err; + + padapter = rtw_netdev_priv(dev); + pwrctrlpriv = &padapter->pwrctrlpriv; + haldata = GET_HAL_DATA(padapter); + pEfuseHal = &haldata->EfuseHal; + err = 0; + setdata = _rtw_zmalloc(1024); + if (setdata == NULL) { + err = -ENOMEM; + goto exit; + } + ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); + if (ShadowMapBT == NULL) { + err = -ENOMEM; + goto exit; + } + ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); + if (ShadowMapWiFi == NULL) { + err = -ENOMEM; + goto exit; + } + setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); + if (setrawdata == NULL) { + err = -ENOMEM; + goto exit; + } + + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); + + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); + + pch = extra; + DBG_88E("%s: in =%s\n", __func__, extra); + + i = 0; + while ((token = strsep(&pch, ",")) != NULL) { + if (i > 2) + break; + tmp[i] = token; + i++; + } + + /* tmp[0],[1],[2] */ + /* wmap, addr, 00e04c871200 */ + if (strcmp(tmp[0], "wmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: map data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "wraw") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: raw data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setrawdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + + if (rtw_efuse_access(padapter, true, addr, cnts, setrawdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_access error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "mac") == 0) { + if (tmp[1] == NULL) { + err = -EINVAL; + goto exit; + } + + /* mac, 00e04c871200 */ + addr = EEPROM_MAC_ADDR_88EU; + cnts = strlen(tmp[1]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + if (cnts > 6) { + DBG_88E("%s: error data for mac addr =\"%s\"\n", __func__, tmp[1]); + err = -EFAULT; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: MAC address =%s\n", __func__, tmp[1]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); + /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "vidpid") == 0) { + if (tmp[1] == NULL) { + err = -EINVAL; + goto exit; + } + + /* pidvid, da0b7881 */ + addr = EEPROM_VID_88EE; + cnts = strlen(tmp[1]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: VID/PID =%s\n", __func__, tmp[1]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "btwmap") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: BT data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if ((addr+cnts) > max_available_size) { + DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); + err = -EFAULT; + goto exit; + } + + if (rtw_BT_efuse_map_write(padapter, addr, cnts, setdata) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_write error!!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "btwfake") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + } else if (strcmp(tmp[0], "btdumpfake") == 0) { + if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) { + DBG_88E("%s: BT read all map success\n", __func__); + } else { + DBG_88E("%s: BT read all map Fail!\n", __func__); + err = -EFAULT; + } + } else if (strcmp(tmp[0], "wldumpfake") == 0) { + if (rtw_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _SUCCESS) { + DBG_88E("%s: BT read all map success\n", __func__); + } else { + DBG_88E("%s: BT read all map Fail\n", __func__); + err = -EFAULT; + } + } else if (strcmp(tmp[0], "btfk2map") == 0) { + memcpy(pEfuseHal->BTEfuseModifiedMap, pEfuseHal->fakeBTEfuseModifiedMap, EFUSE_BT_MAX_MAP_LEN); + + EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (max_available_size < 1) { + err = -EFAULT; + goto exit; + } + + if (rtw_BT_efuse_map_write(padapter, 0x00, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _FAIL) { + DBG_88E("%s: rtw_BT_efuse_map_write error!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "wlfk2map") == 0) { + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (max_available_size < 1) { + err = -EFAULT; + goto exit; + } + + if (rtw_efuse_map_write(padapter, 0x00, EFUSE_MAX_MAP_LEN, pEfuseHal->fakeEfuseModifiedMap) == _FAIL) { + DBG_88E("%s: rtw_efuse_map_write error!\n", __func__); + err = -EFAULT; + goto exit; + } + } else if (strcmp(tmp[0], "wlwfake") == 0) { + if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + err = -EINVAL; + goto exit; + } + + addr = simple_strtoul(tmp[1], &ptmp, 16); + addr &= 0xFFF; + + cnts = strlen(tmp[2]); + if (cnts%2) { + err = -EINVAL; + goto exit; + } + cnts /= 2; + if (cnts == 0) { + err = -EINVAL; + goto exit; + } + + DBG_88E("%s: addr = 0x%X\n", __func__, addr); + DBG_88E("%s: cnts =%d\n", __func__, cnts); + DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]); + + for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) + pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + } + +exit: + kfree(setdata); + kfree(ShadowMapBT); + kfree(ShadowMapWiFi); + kfree(setrawdata); + + rtw_pm_set_ips(padapter, ips_mode); + rtw_pm_set_lps(padapter, lps_mode); + + return err; +} + +/* + * Input Format: %s,%d,%d + * %s is width, could be + * "b" for 1 byte + * "w" for WORD (2 bytes) + * "dw" for DWORD (4 bytes) + * 1st %d is address(offset) + * 2st %d is data to write + */ +static int rtw_mp_write_reg(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + char *pch, *pnext, *ptmp; + char *width_str; + char width; + u32 addr, data; + int ret; + struct adapter *padapter = rtw_netdev_priv(dev); + + pch = extra; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) + return -EINVAL; + *pnext = 0; + width_str = pch; + + pch = pnext + 1; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) + return -EINVAL; + *pnext = 0; + addr = simple_strtoul(pch, &ptmp, 16); + if (addr > 0x3FFF) + return -EINVAL; + + pch = pnext + 1; + if ((pch - extra) >= wrqu->length) + return -EINVAL; + data = simple_strtoul(pch, &ptmp, 16); + + ret = 0; + width = width_str[0]; + switch (width) { + case 'b': + /* 1 byte */ + if (data > 0xFF) { + ret = -EINVAL; + break; + } + rtw_write8(padapter, addr, data); + break; + case 'w': + /* 2 bytes */ + if (data > 0xFFFF) { + ret = -EINVAL; + break; + } + rtw_write16(padapter, addr, data); + break; + case 'd': + /* 4 bytes */ + rtw_write32(padapter, addr, data); + break; + default: + ret = -EINVAL; + break; + } + + return ret; +} + +/* + * Input Format: %s,%d + * %s is width, could be + * "b" for 1 byte + * "w" for WORD (2 bytes) + * "dw" for DWORD (4 bytes) + * %d is address(offset) + * + * Return: + * %d for data readed + */ +static int rtw_mp_read_reg(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + char *pch, *pnext, *ptmp; + char *width_str; + char width; + char data[20], tmp[20]; + u32 addr; + u32 ret, i = 0, j = 0, strtout = 0; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + memset(data, 0, 20); + memset(tmp, 0, 20); + memset(extra, 0, wrqu->length); + + pch = input; + pnext = strpbrk(pch, ",.-"); + if (pnext == NULL) { + kfree(input); + return -EINVAL; + } + *pnext = 0; + width_str = pch; + + pch = pnext + 1; + if ((pch - input) >= wrqu->length) { + kfree(input); + return -EINVAL; + } + kfree(input); + addr = simple_strtoul(pch, &ptmp, 16); + if (addr > 0x3FFF) + return -EINVAL; + + ret = 0; + width = width_str[0]; + switch (width) { + case 'b': + /* 1 byte */ + sprintf(extra, "%d\n", rtw_read8(padapter, addr)); + wrqu->length = strlen(extra); + break; + case 'w': + /* 2 bytes */ + sprintf(data, "%04x\n", rtw_read16(padapter, addr)); + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + if (data[i] != '\0') + tmp[j] = data[i]; + j++; + } + pch = tmp; + DBG_88E("pch =%s", pch); + + while (*pch != '\0') { + pnext = strpbrk(pch, " "); + if (!pnext) + break; + + pnext++; + if (*pnext != '\0') { + strtout = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtout); + } else { + break; + } + pch = pnext; + } + wrqu->length = 6; + break; + case 'd': + /* 4 bytes */ + sprintf(data, "%08x", rtw_read32(padapter, addr)); + /* add read data format blank */ + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + if (data[i] != '\0') + tmp[j] = data[i]; + + j++; + } + pch = tmp; + DBG_88E("pch =%s", pch); + + while (*pch != '\0') { + pnext = strpbrk(pch, " "); + if (!pnext) + break; + pnext++; + if (*pnext != '\0') { + strtout = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtout); + } else { + break; + } + pch = pnext; + } + wrqu->length = strlen(extra); + break; + default: + wrqu->length = 0; + ret = -EINVAL; + break; + } + + return ret; +} + +/* + * Input Format: %d,%x,%x + * %d is RF path, should be smaller than RF_PATH_MAX + * 1st %x is address(offset) + * 2st %x is data to write + */ + static int rtw_mp_write_rf(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 path, addr, data; + int ret; + struct adapter *padapter = rtw_netdev_priv(dev); + + ret = sscanf(extra, "%d,%x,%x", &path, &addr, &data); + if (ret < 3) + return -EINVAL; + + if (path >= RF_PATH_MAX) + return -EINVAL; + if (addr > 0xFF) + return -EINVAL; + if (data > 0xFFFFF) + return -EINVAL; + + memset(extra, 0, wrqu->length); + + write_rfreg(padapter, path, addr, data); + + sprintf(extra, "write_rf completed\n"); + wrqu->length = strlen(extra); + + return 0; +} + +/* + * Input Format: %d,%x + * %d is RF path, should be smaller than RF_PATH_MAX + * %x is address(offset) + * + * Return: + * %d for data readed + */ +static int rtw_mp_read_rf(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + char *input = kmalloc(wrqu->length, GFP_KERNEL); + char *pch, *pnext, *ptmp; + char data[20], tmp[20]; + u32 path, addr; + u32 ret, i = 0, j = 0, strtou = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + ret = sscanf(input, "%d,%x", &path, &addr); + kfree(input); + if (ret < 2) + return -EINVAL; + + if (path >= RF_PATH_MAX) + return -EINVAL; + if (addr > 0xFF) + return -EINVAL; + + memset(extra, 0, wrqu->length); + + sprintf(data, "%08x", read_rfreg(padapter, path, addr)); + /* add read data format blank */ + for (i = 0; i <= strlen(data); i++) { + if (i%2 == 0) { + tmp[j] = ' '; + j++; + } + tmp[j] = data[i]; + j++; + } + pch = tmp; + DBG_88E("pch =%s", pch); + + while (*pch != '\0') { + pnext = strpbrk(pch, " "); + pnext++; + if (*pnext != '\0') { + strtou = simple_strtoul(pnext, &ptmp, 16); + sprintf(extra, "%s %d", extra, strtou); + } else { + break; + } + pch = pnext; + } + wrqu->length = strlen(extra); + return 0; +} + +static int rtw_mp_start(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter->registrypriv.mp_mode == 0) { + padapter->registrypriv.mp_mode = 1; + + rtw_pm_set_ips(padapter, IPS_NONE); + LeaveAllPowerSaveMode(padapter); + + MPT_InitializeAdapter(padapter, 1); + } + if (padapter->registrypriv.mp_mode == 0) + return -EPERM; + if (padapter->mppriv.mode == MP_OFF) { + if (mp_start_test(padapter) == _FAIL) + return -EPERM; + padapter->mppriv.mode = MP_ON; + } + return 0; +} + +static int rtw_mp_stop(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter->registrypriv.mp_mode == 1) { + MPT_DeInitAdapter(padapter); + padapter->registrypriv.mp_mode = 0; + } + + if (padapter->mppriv.mode != MP_OFF) { + mp_stop_test(padapter); + padapter->mppriv.mode = MP_OFF; + } + + return 0; +} + +extern int wifirate2_ratetbl_inx(unsigned char rate); + +static int rtw_mp_rate(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 rate = MPT_RATE_1M; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + rate = rtw_atoi(input); + sprintf(extra, "Set data rate to %d", rate); + kfree(input); + if (rate <= 0x7f) + rate = wifirate2_ratetbl_inx((u8)rate); + else + rate = (rate-0x80+MPT_RATE_MCS0); + + if (rate >= MPT_RATE_LAST) + return -EINVAL; + + padapter->mppriv.rateidx = rate; + Hal_SetDataRate(padapter); + + wrqu->length = strlen(extra) + 1; + return 0; +} + +static int rtw_mp_channel(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + u32 channel = 1; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + channel = rtw_atoi(input); + sprintf(extra, "Change channel %d to channel %d", padapter->mppriv.channel, channel); + + padapter->mppriv.channel = channel; + Hal_SetChannel(padapter); + + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_bandwidth(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 bandwidth = 0, sg = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + sscanf(extra, "40M =%d, shortGI =%d", &bandwidth, &sg); + + if (bandwidth != HT_CHANNEL_WIDTH_40) + bandwidth = HT_CHANNEL_WIDTH_20; + + padapter->mppriv.bandwidth = (u8)bandwidth; + padapter->mppriv.preamble = sg; + + SetBandwidth(padapter); + + return 0; +} + +static int rtw_mp_txpower(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 idx_a = 0, idx_b = 0; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + sscanf(input, "patha =%d, pathb =%d", &idx_a, &idx_b); + + sprintf(extra, "Set power level path_A:%d path_B:%d", idx_a, idx_b); + padapter->mppriv.txpoweridx = (u8)idx_a; + padapter->mppriv.txpoweridx_b = (u8)idx_b; + padapter->mppriv.bSetTxPower = 1; + Hal_SetAntennaPathPower(padapter); + + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_ant_tx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 i; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + u16 antenna = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + + sprintf(extra, "switch Tx antenna to %s", input); + + for (i = 0; i < strlen(input); i++) { + switch (input[i]) { + case 'a': + antenna |= ANTENNA_A; + break; + case 'b': + antenna |= ANTENNA_B; + break; + } + } + padapter->mppriv.antenna_tx = antenna; + + Hal_SetAntenna(padapter); + + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_ant_rx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 i; + u16 antenna = 0; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + memset(extra, 0, wrqu->length); + + sprintf(extra, "switch Rx antenna to %s", input); + + for (i = 0; i < strlen(input); i++) { + switch (input[i]) { + case 'a': + antenna |= ANTENNA_A; + break; + case 'b': + antenna |= ANTENNA_B; + break; + } + } + + padapter->mppriv.antenna_rx = antenna; + Hal_SetAntenna(padapter); + wrqu->length = strlen(extra); + kfree(input); + return 0; +} + +static int rtw_mp_ctx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 pkTx = 1, countPkTx = 1, cotuTx = 1, CarrSprTx = 1, scTx = 1, sgleTx = 1, stop = 1; + u32 bStartTest = 1; + u32 count = 0; + struct mp_priv *pmp_priv; + struct pkt_attrib *pattrib; + + struct adapter *padapter = rtw_netdev_priv(dev); + + pmp_priv = &padapter->mppriv; + + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) + return -EFAULT; + + DBG_88E("%s: in =%s\n", __func__, extra); + + countPkTx = strncmp(extra, "count =", 5); /* strncmp true is 0 */ + cotuTx = strncmp(extra, "background", 20); + CarrSprTx = strncmp(extra, "background, cs", 20); + scTx = strncmp(extra, "background, sc", 20); + sgleTx = strncmp(extra, "background, stone", 20); + pkTx = strncmp(extra, "background, pkt", 20); + stop = strncmp(extra, "stop", 4); + sscanf(extra, "count =%d, pkt", &count); + + memset(extra, '\0', sizeof(*extra)); + + if (stop == 0) { + bStartTest = 0; /* To set Stop */ + pmp_priv->tx.stop = 1; + sprintf(extra, "Stop continuous Tx"); + } else { + bStartTest = 1; + if (pmp_priv->mode != MP_ON) { + if (pmp_priv->tx.stop != 1) { + DBG_88E("%s: MP_MODE != ON %d\n", __func__, pmp_priv->mode); + return -EFAULT; + } + } + } + + if (pkTx == 0 || countPkTx == 0) + pmp_priv->mode = MP_PACKET_TX; + if (sgleTx == 0) + pmp_priv->mode = MP_SINGLE_TONE_TX; + if (cotuTx == 0) + pmp_priv->mode = MP_CONTINUOUS_TX; + if (CarrSprTx == 0) + pmp_priv->mode = MP_CARRIER_SUPPRISSION_TX; + if (scTx == 0) + pmp_priv->mode = MP_SINGLE_CARRIER_TX; + + switch (pmp_priv->mode) { + case MP_PACKET_TX: + if (bStartTest == 0) { + pmp_priv->tx.stop = 1; + pmp_priv->mode = MP_ON; + sprintf(extra, "Stop continuous Tx"); + } else if (pmp_priv->tx.stop == 1) { + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500 count =%u,\n", count); + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = count; + pmp_priv->tx.payload = 2; + pattrib = &pmp_priv->tx.attrib; + pattrib->pktlen = 1500; + memset(pattrib->dst, 0xFF, ETH_ALEN); + SetPacketTx(padapter); + } else { + return -EFAULT; + } + wrqu->length = strlen(extra); + return 0; + case MP_SINGLE_TONE_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetSingleToneTx(padapter, (u8)bStartTest); + break; + case MP_CONTINUOUS_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetContinuousTx(padapter, (u8)bStartTest); + break; + case MP_CARRIER_SUPPRISSION_TX: + if (bStartTest != 0) { + if (pmp_priv->rateidx <= MPT_RATE_11M) { + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetCarrierSuppressionTx(padapter, (u8)bStartTest); + } else { + sprintf(extra, "Specify carrier suppression but not CCK rate"); + } + } + break; + case MP_SINGLE_CARRIER_TX: + if (bStartTest != 0) + sprintf(extra, "Start continuous DA = ffffffffffff len = 1500\n infinite = yes."); + Hal_SetSingleCarrierTx(padapter, (u8)bStartTest); + break; + default: + sprintf(extra, "Error! Continuous-Tx is not on-going."); + return -EFAULT; + } + + if (bStartTest == 1 && pmp_priv->mode != MP_ON) { + struct mp_priv *pmp_priv = &padapter->mppriv; + if (pmp_priv->tx.stop == 0) { + pmp_priv->tx.stop = 1; + rtw_msleep_os(5); + } + pmp_priv->tx.stop = 0; + pmp_priv->tx.count = 1; + SetPacketTx(padapter); + } else { + pmp_priv->mode = MP_ON; + } + + wrqu->length = strlen(extra); + return 0; +} + +static int rtw_mp_arx(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 bStartRx = 0, bStopRx = 0, bQueryPhy; + u32 cckok = 0, cckcrc = 0, ofdmok = 0, ofdmcrc = 0, htok = 0, htcrc = 0, OFDM_FA = 0, CCK_FA = 0; + char *input = kmalloc(wrqu->length, GFP_KERNEL); + struct adapter *padapter = rtw_netdev_priv(dev); + + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + DBG_88E("%s: %s\n", __func__, input); + + bStartRx = (strncmp(input, "start", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ + bStopRx = (strncmp(input, "stop", 5) == 0) ? 1 : 0; /* strncmp true is 0 */ + bQueryPhy = (strncmp(input, "phy", 3) == 0) ? 1 : 0; /* strncmp true is 0 */ + + if (bStartRx) { + sprintf(extra, "start"); + SetPacketRx(padapter, bStartRx); + } else if (bStopRx) { + SetPacketRx(padapter, 0); + sprintf(extra, "Received packet OK:%d CRC error:%d", padapter->mppriv.rx_pktcount, padapter->mppriv.rx_crcerrpktcount); + } else if (bQueryPhy) { + /* + OFDM FA + RegCF0[15:0] + RegCF2[31:16] + RegDA0[31:16] + RegDA4[15:0] + RegDA4[31:16] + RegDA8[15:0] + CCK FA + (RegA5B<<8) | RegA5C + */ + cckok = read_bbreg(padapter, 0xf88, 0xffffffff); + cckcrc = read_bbreg(padapter, 0xf84, 0xffffffff); + ofdmok = read_bbreg(padapter, 0xf94, 0x0000FFFF); + ofdmcrc = read_bbreg(padapter, 0xf94, 0xFFFF0000); + htok = read_bbreg(padapter, 0xf90, 0x0000FFFF); + htcrc = read_bbreg(padapter, 0xf90, 0xFFFF0000); + + OFDM_FA = read_bbreg(padapter, 0xcf0, 0x0000FFFF); + OFDM_FA = read_bbreg(padapter, 0xcf2, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda0, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda4, 0x0000FFFF); + OFDM_FA = read_bbreg(padapter, 0xda4, 0xFFFF0000); + OFDM_FA = read_bbreg(padapter, 0xda8, 0x0000FFFF); + CCK_FA = (rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); + + sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok+ofdmok+htok, cckcrc+ofdmcrc+htcrc, OFDM_FA+CCK_FA); + } + wrqu->length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_trx_query(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 txok, txfail, rxok, rxfail; + struct adapter *padapter = rtw_netdev_priv(dev); + + txok = padapter->mppriv.tx.sended; + txfail = 0; + rxok = padapter->mppriv.rx_pktcount; + rxfail = padapter->mppriv.rx_crcerrpktcount; + + memset(extra, '\0', 128); + + sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail, rxok, rxfail); + + wrqu->length = strlen(extra)+1; + + return 0; +} + +static int rtw_mp_pwrtrk(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 enable; + u32 thermal; + s32 ret; + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + memset(extra, 0, wrqu->length); + + enable = 1; + if (wrqu->length > 1) {/* not empty string */ + if (strncmp(input, "stop", 4) == 0) { + enable = 0; + sprintf(extra, "mp tx power tracking stop"); + } else if (sscanf(input, "ther =%d", &thermal)) { + ret = Hal_SetThermalMeter(padapter, (u8)thermal); + if (ret == _FAIL) + return -EPERM; + sprintf(extra, "mp tx power tracking start, target value =%d ok ", thermal); + } else { + kfree(input); + return -EINVAL; + } + } + + kfree(input); + ret = Hal_SetPowerTracking(padapter, enable); + if (ret == _FAIL) + return -EPERM; + + wrqu->length = strlen(extra); + return 0; +} + +static int rtw_mp_psd(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->length, GFP_KERNEL); + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + + strcpy(extra, input); + + wrqu->length = mp_query_psd(padapter, extra); + kfree(input); + return 0; +} + +static int rtw_mp_thermal(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u8 val; + u16 bwrite = 1; + u16 addr = EEPROM_THERMAL_METER_88E; + + u16 cnt = 1; + u16 max_available_size = 0; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) + return -EFAULT; + + bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ + + Hal_GetThermalMeter(padapter, &val); + + if (bwrite == 0) { + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (2 > max_available_size) { + DBG_88E("no available efuse!\n"); + return -EFAULT; + } + if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { + DBG_88E("rtw_efuse_map_write error\n"); + return -EFAULT; + } else { + sprintf(extra, " efuse write ok :%d", val); + } + } else { + sprintf(extra, "%d", val); + } + wrqu->length = strlen(extra); + + return 0; +} + +static int rtw_mp_reset_stats(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + struct mp_priv *pmp_priv; + struct adapter *padapter = rtw_netdev_priv(dev); + + pmp_priv = &padapter->mppriv; + + pmp_priv->tx.sended = 0; + pmp_priv->tx_pktcount = 0; + pmp_priv->rx_pktcount = 0; + pmp_priv->rx_crcerrpktcount = 0; + + /* reset phy counter */ + write_bbreg(padapter, 0xf14, BIT16, 0x1); + rtw_msleep_os(10); + write_bbreg(padapter, 0xf14, BIT16, 0x0); + + return 0; +} + +static int rtw_mp_dump(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + u32 value; + u8 rf_type, path_nums = 0; + u32 i, j = 1, path; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (strncmp(extra, "all", 4) == 0) { + DBG_88E("\n ======= MAC REG =======\n"); + for (i = 0x0; i < 0x300; i += 4) { + if (j%4 == 1) + DBG_88E("0x%02x", i); + DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + DBG_88E("\n"); + } + for (i = 0x400; i < 0x1000; i += 4) { + if (j%4 == 1) + DBG_88E("0x%02x", i); + DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); + if ((j++)%4 == 0) + DBG_88E("\n"); + } + + j = 1; + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + + DBG_88E("\n ======= RF REG =======\n"); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) + path_nums = 1; + else + path_nums = 2; + + for (path = 0; path < path_nums; path++) { + for (i = 0; i < 0x34; i++) { + value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); + if (j%4 == 1) + DBG_88E("0x%02x ", i); + DBG_88E(" 0x%08x ", value); + if ((j++)%4 == 0) + DBG_88E("\n"); + } + } + } + return 0; +} + +static int rtw_mp_phypara(struct net_device *dev, + struct iw_request_info *info, + struct iw_point *wrqu, char *extra) +{ + char *input = kmalloc(wrqu->length, GFP_KERNEL); + u32 valxcap; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->pointer, wrqu->length)) { + kfree(input); + return -EFAULT; + } + + DBG_88E("%s:iwpriv in =%s\n", __func__, input); + + sscanf(input, "xcap =%d", &valxcap); + + kfree(input); + return 0; +} + +static int rtw_mp_SetRFPath(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->data.length, GFP_KERNEL); + u8 bMain = 1, bTurnoff = 1; + + if (!input) + return -ENOMEM; + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) + return -EFAULT; + DBG_88E("%s:iwpriv in =%s\n", __func__, input); + + bMain = strncmp(input, "1", 2); /* strncmp true is 0 */ + bTurnoff = strncmp(input, "0", 3); /* strncmp true is 0 */ + + if (bMain == 0) { + MP_PHY_SetRFPathSwitch(padapter, true); + DBG_88E("%s:PHY_SetRFPathSwitch = true\n", __func__); + } else if (bTurnoff == 0) { + MP_PHY_SetRFPathSwitch(padapter, false); + DBG_88E("%s:PHY_SetRFPathSwitch = false\n", __func__); + } + kfree(input); + return 0; +} + +static int rtw_mp_QueryDrv(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + char *input = kmalloc(wrqu->data.length, GFP_KERNEL); + u8 qAutoLoad = 1; + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + + if (!input) + return -ENOMEM; + + if (copy_from_user(input, wrqu->data.pointer, wrqu->data.length)) + return -EFAULT; + DBG_88E("%s:iwpriv in =%s\n", __func__, input); + + qAutoLoad = strncmp(input, "autoload", 8); /* strncmp true is 0 */ + + if (qAutoLoad == 0) { + DBG_88E("%s:qAutoLoad\n", __func__); + + if (pEEPROM->bautoload_fail_flag) + sprintf(extra, "fail"); + else + sprintf(extra, "ok"); + } + wrqu->data.length = strlen(extra) + 1; + kfree(input); + return 0; +} + +static int rtw_mp_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct iw_point *wrqu = (struct iw_point *)wdata; + u32 subcmd = wrqu->flags; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter == NULL) + return -ENETDOWN; + + if (extra == NULL) { + wrqu->length = 0; + return -EIO; + } + + switch (subcmd) { + case MP_START: + DBG_88E("set case mp_start\n"); + rtw_mp_start(dev, info, wrqu, extra); + break; + case MP_STOP: + DBG_88E("set case mp_stop\n"); + rtw_mp_stop(dev, info, wrqu, extra); + break; + case MP_BANDWIDTH: + DBG_88E("set case mp_bandwidth\n"); + rtw_mp_bandwidth(dev, info, wrqu, extra); + break; + case MP_RESET_STATS: + DBG_88E("set case MP_RESET_STATS\n"); + rtw_mp_reset_stats(dev, info, wrqu, extra); + break; + case MP_SetRFPathSwh: + DBG_88E("set MP_SetRFPathSwitch\n"); + rtw_mp_SetRFPath(dev, info, wdata, extra); + break; + case CTA_TEST: + DBG_88E("set CTA_TEST\n"); + rtw_cta_test_start(dev, info, wdata, extra); + break; + } + + return 0; +} + +static int rtw_mp_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) +{ + struct iw_point *wrqu = (struct iw_point *)wdata; + u32 subcmd = wrqu->flags; + struct adapter *padapter = rtw_netdev_priv(dev); + + if (padapter == NULL) + return -ENETDOWN; + if (extra == NULL) { + wrqu->length = 0; + return -EIO; + } + + switch (subcmd) { + case WRITE_REG: + rtw_mp_write_reg(dev, info, wrqu, extra); + break; + case WRITE_RF: + rtw_mp_write_rf(dev, info, wrqu, extra); + break; + case MP_PHYPARA: + DBG_88E("mp_get MP_PHYPARA\n"); + rtw_mp_phypara(dev, info, wrqu, extra); + break; + case MP_CHANNEL: + DBG_88E("set case mp_channel\n"); + rtw_mp_channel(dev, info, wrqu, extra); + break; + case READ_REG: + DBG_88E("mp_get READ_REG\n"); + rtw_mp_read_reg(dev, info, wrqu, extra); + break; + case READ_RF: + DBG_88E("mp_get READ_RF\n"); + rtw_mp_read_rf(dev, info, wrqu, extra); + break; + case MP_RATE: + DBG_88E("set case mp_rate\n"); + rtw_mp_rate(dev, info, wrqu, extra); + break; + case MP_TXPOWER: + DBG_88E("set case MP_TXPOWER\n"); + rtw_mp_txpower(dev, info, wrqu, extra); + break; + case MP_ANT_TX: + DBG_88E("set case MP_ANT_TX\n"); + rtw_mp_ant_tx(dev, info, wrqu, extra); + break; + case MP_ANT_RX: + DBG_88E("set case MP_ANT_RX\n"); + rtw_mp_ant_rx(dev, info, wrqu, extra); + break; + case MP_QUERY: + rtw_mp_trx_query(dev, info, wrqu, extra); + break; + case MP_CTX: + DBG_88E("set case MP_CTX\n"); + rtw_mp_ctx(dev, info, wrqu, extra); + break; + case MP_ARX: + DBG_88E("set case MP_ARX\n"); + rtw_mp_arx(dev, info, wrqu, extra); + break; + case EFUSE_GET: + DBG_88E("efuse get EFUSE_GET\n"); + rtw_mp_efuse_get(dev, info, wdata, extra); + break; + case MP_DUMP: + DBG_88E("set case MP_DUMP\n"); + rtw_mp_dump(dev, info, wrqu, extra); + break; + case MP_PSD: + DBG_88E("set case MP_PSD\n"); + rtw_mp_psd(dev, info, wrqu, extra); + break; + case MP_THER: + DBG_88E("set case MP_THER\n"); + rtw_mp_thermal(dev, info, wrqu, extra); + break; + case MP_QueryDrvStats: + DBG_88E("mp_get MP_QueryDrvStats\n"); + rtw_mp_QueryDrv (dev, info, wdata, extra); + break; + case MP_PWRTRK: + DBG_88E("set case MP_PWRTRK\n"); + rtw_mp_pwrtrk(dev, info, wrqu, extra); + break; + case EFUSE_SET: + DBG_88E("set case efuse set\n"); + rtw_mp_efuse_set(dev, info, wdata, extra); + break; + } + + rtw_msleep_os(10); /* delay 5ms for sending pkt before exit adb shell operation */ + return 0; +} + +static int rtw_tdls(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +static int rtw_tdls_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + return 0; +} + +static int rtw_test( + struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) +{ + u32 len; + u8 *pbuf, *pch; + char *ptmp; + u8 *delim = ","; + + DBG_88E("+%s\n", __func__); + len = wrqu->data.length; + + pbuf = (u8 *)rtw_zmalloc(len); + if (pbuf == NULL) { + DBG_88E("%s: no memory!\n", __func__); + return -ENOMEM; + } + + if (copy_from_user(pbuf, wrqu->data.pointer, len)) { + kfree(pbuf); + DBG_88E("%s: copy from user fail!\n", __func__); + return -EFAULT; + } + DBG_88E("%s: string =\"%s\"\n", __func__, pbuf); + + ptmp = (char *)pbuf; + pch = strsep(&ptmp, delim); + if ((pch == NULL) || (strlen(pch) == 0)) { + kfree(pbuf); + DBG_88E("%s: parameter error(level 1)!\n", __func__); + return -EFAULT; + } + kfree(pbuf); + return 0; +} + +static iw_handler rtw_handlers[] = { + NULL, /* SIOCSIWCOMMIT */ + rtw_wx_get_name, /* SIOCGIWNAME */ + dummy, /* SIOCSIWNWID */ + dummy, /* SIOCGIWNWID */ + rtw_wx_set_freq, /* SIOCSIWFREQ */ + rtw_wx_get_freq, /* SIOCGIWFREQ */ + rtw_wx_set_mode, /* SIOCSIWMODE */ + rtw_wx_get_mode, /* SIOCGIWMODE */ + dummy, /* SIOCSIWSENS */ + rtw_wx_get_sens, /* SIOCGIWSENS */ + NULL, /* SIOCSIWRANGE */ + rtw_wx_get_range, /* SIOCGIWRANGE */ + rtw_wx_set_priv, /* SIOCSIWPRIV */ + NULL, /* SIOCGIWPRIV */ + NULL, /* SIOCSIWSTATS */ + NULL, /* SIOCGIWSTATS */ + dummy, /* SIOCSIWSPY */ + dummy, /* SIOCGIWSPY */ + NULL, /* SIOCGIWTHRSPY */ + NULL, /* SIOCWIWTHRSPY */ + rtw_wx_set_wap, /* SIOCSIWAP */ + rtw_wx_get_wap, /* SIOCGIWAP */ + rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */ + dummy, /* SIOCGIWAPLIST -- depricated */ + rtw_wx_set_scan, /* SIOCSIWSCAN */ + rtw_wx_get_scan, /* SIOCGIWSCAN */ + rtw_wx_set_essid, /* SIOCSIWESSID */ + rtw_wx_get_essid, /* SIOCGIWESSID */ + dummy, /* SIOCSIWNICKN */ + rtw_wx_get_nick, /* SIOCGIWNICKN */ + NULL, /* -- hole -- */ + NULL, /* -- hole -- */ + rtw_wx_set_rate, /* SIOCSIWRATE */ + rtw_wx_get_rate, /* SIOCGIWRATE */ + rtw_wx_set_rts, /* SIOCSIWRTS */ + rtw_wx_get_rts, /* SIOCGIWRTS */ + rtw_wx_set_frag, /* SIOCSIWFRAG */ + rtw_wx_get_frag, /* SIOCGIWFRAG */ + dummy, /* SIOCSIWTXPOW */ + dummy, /* SIOCGIWTXPOW */ + dummy, /* SIOCSIWRETRY */ + rtw_wx_get_retry, /* SIOCGIWRETRY */ + rtw_wx_set_enc, /* SIOCSIWENCODE */ + rtw_wx_get_enc, /* SIOCGIWENCODE */ + dummy, /* SIOCSIWPOWER */ + rtw_wx_get_power, /* SIOCGIWPOWER */ + NULL, /*---hole---*/ + NULL, /*---hole---*/ + rtw_wx_set_gen_ie, /* SIOCSIWGENIE */ + NULL, /* SIOCGWGENIE */ + rtw_wx_set_auth, /* SIOCSIWAUTH */ + NULL, /* SIOCGIWAUTH */ + rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ + NULL, /* SIOCGIWENCODEEXT */ + rtw_wx_set_pmkid, /* SIOCSIWPMKSA */ + NULL, /*---hole---*/ +}; + +static const struct iw_priv_args rtw_private_args[] = { + { + SIOCIWFIRSTPRIV + 0x0, + IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write" + }, + { + SIOCIWFIRSTPRIV + 0x1, + IW_PRIV_TYPE_CHAR | 0x7FF, + IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read" + }, + { + SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext" + }, + { + SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl" + }, + { + SIOCIWFIRSTPRIV + 0x4, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo" + }, + { + SIOCIWFIRSTPRIV + 0x5, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid" + }, + { + SIOCIWFIRSTPRIV + 0x6, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start" + }, + { + SIOCIWFIRSTPRIV + 0x7, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "get_sensitivity" + }, + { + SIOCIWFIRSTPRIV + 0x8, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_prob_req_ie" + }, + { + SIOCIWFIRSTPRIV + 0x9, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_assoc_req_ie" + }, + + { + SIOCIWFIRSTPRIV + 0xA, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan" + }, + + { + SIOCIWFIRSTPRIV + 0xB, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg" + }, + { + SIOCIWFIRSTPRIV + 0xC, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw" + }, + { + SIOCIWFIRSTPRIV + 0xD, + IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr" + }, + { + SIOCIWFIRSTPRIV + 0x10, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, 0, "p2p_set" + }, + { + SIOCIWFIRSTPRIV + 0x11, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "p2p_get" + }, + { + SIOCIWFIRSTPRIV + 0x12, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IFNAMSIZ, "p2p_get2" + }, + {SIOCIWFIRSTPRIV + 0x13, IW_PRIV_TYPE_CHAR | 128, 0, "NULL"}, + { + SIOCIWFIRSTPRIV + 0x14, + IW_PRIV_TYPE_CHAR | 64, 0, "tdls" + }, + { + SIOCIWFIRSTPRIV + 0x15, + IW_PRIV_TYPE_CHAR | P2P_PRIVATE_IOCTL_SET_LEN, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | P2P_PRIVATE_IOCTL_SET_LEN, "tdls_get" + }, + { + SIOCIWFIRSTPRIV + 0x16, + IW_PRIV_TYPE_CHAR | 64, 0, "pm_set" + }, + + {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"}, + + {SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"}, + {SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, + {SIOCIWFIRSTPRIV + 0x1D, IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" + }, + + {SIOCIWFIRSTPRIV + 0x0E, IW_PRIV_TYPE_CHAR | 1024, 0, ""}, /* set */ + {SIOCIWFIRSTPRIV + 0x0F, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, ""},/* get */ +/* --- sub-ioctls definitions --- */ + + {MP_START, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_start"}, /* set */ + {MP_PHYPARA, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_phypara"},/* get */ + {MP_STOP, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_stop"}, /* set */ + {MP_CHANNEL, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_channel"},/* get */ + {MP_BANDWIDTH, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_bandwidth"}, /* set */ + {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"},/* get */ + {MP_RESET_STATS, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_reset_stats"}, + {MP_QUERY, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_query"}, /* get */ + {READ_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_reg"}, + {MP_RATE, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_rate"}, + {READ_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "read_rf"}, + {MP_PSD, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_psd"}, + {MP_DUMP, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_dump"}, + {MP_TXPOWER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_txpower"}, + {MP_ANT_TX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_tx"}, + {MP_ANT_RX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ant_rx"}, + {WRITE_REG, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_reg"}, + {WRITE_RF, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "write_rf"}, + {MP_CTX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ctx"}, + {MP_ARX, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_arx"}, + {MP_THER, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_ther"}, + {EFUSE_SET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_set"}, + {EFUSE_GET, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, + {MP_PWRTRK, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_pwrtrk"}, + {MP_QueryDrvStats, IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "mp_drvquery"}, + {MP_IOCTL, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_ioctl"}, /* mp_ioctl */ + {MP_SetRFPathSwh, IW_PRIV_TYPE_CHAR | 1024, 0, "mp_setrfpath"}, + {CTA_TEST, IW_PRIV_TYPE_CHAR | 1024, 0, "cta_test"}, +}; + +static iw_handler rtw_private_handler[] = { +rtw_wx_write32, /* 0x00 */ +rtw_wx_read32, /* 0x01 */ +rtw_drvext_hdl, /* 0x02 */ +rtw_mp_ioctl_hdl, /* 0x03 */ + +/* for MM DTV platform */ + rtw_get_ap_info, /* 0x04 */ + + rtw_set_pid, /* 0x05 */ + rtw_wps_start, /* 0x06 */ + + rtw_wx_get_sensitivity, /* 0x07 */ + rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */ + rtw_wx_set_mtk_wps_ie, /* 0x09 */ + +/* Set Channel depend on the country code */ + rtw_wx_set_channel_plan, /* 0x0A */ + + rtw_dbg_port, /* 0x0B */ + rtw_wx_write_rf, /* 0x0C */ + rtw_wx_read_rf, /* 0x0D */ + + rtw_mp_set, /* 0x0E */ + rtw_mp_get, /* 0x0F */ + rtw_p2p_set, /* 0x10 */ + rtw_p2p_get, /* 0x11 */ + rtw_p2p_get2, /* 0x12 */ + + NULL, /* 0x13 */ + rtw_tdls, /* 0x14 */ + rtw_tdls_get, /* 0x15 */ + + rtw_pm_set, /* 0x16 */ + rtw_wx_priv_null, /* 0x17 */ + rtw_rereg_nd_name, /* 0x18 */ + rtw_wx_priv_null, /* 0x19 */ + + rtw_mp_efuse_set, /* 0x1A */ + rtw_mp_efuse_get, /* 0x1B */ + NULL, /* 0x1C is reserved for hostapd */ + rtw_test, /* 0x1D */ +}; + +static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_statistics *piwstats = &padapter->iwstats; + int tmp_noise = 0; + int tmp; + + if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { + piwstats->qual.qual = 0; + piwstats->qual.level = 0; + piwstats->qual.noise = 0; + } else { + tmp_noise = padapter->recvpriv.noise; + + piwstats->qual.level = padapter->signal_strength; + tmp = 219 + 3 * padapter->signal_strength; + tmp = min(100, tmp); + tmp = max(0, tmp); + piwstats->qual.qual = tmp; + piwstats->qual.noise = tmp_noise; + } + piwstats->qual.updated = IW_QUAL_ALL_UPDATED | IW_QUAL_DBM; + return &padapter->iwstats; +} + +struct iw_handler_def rtw_handlers_def = { + .standard = rtw_handlers, + .num_standard = sizeof(rtw_handlers) / sizeof(iw_handler), + .private = rtw_private_handler, + .private_args = (struct iw_priv_args *)rtw_private_args, + .num_private = sizeof(rtw_private_handler) / sizeof(iw_handler), + .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), + .get_wireless_stats = rtw_get_wireless_stats, +}; + +/* copy from net/wireless/wext.c start */ +/* ---------------------------------------------------------------- */ +/* + * Calculate size of private arguments + */ +static const char iw_priv_type_size[] = { + 0, /* IW_PRIV_TYPE_NONE */ + 1, /* IW_PRIV_TYPE_BYTE */ + 1, /* IW_PRIV_TYPE_CHAR */ + 0, /* Not defined */ + sizeof(__u32), /* IW_PRIV_TYPE_INT */ + sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ + sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ + 0, /* Not defined */ +}; + +static int get_priv_size(__u16 args) +{ + int num = args & IW_PRIV_SIZE_MASK; + int type = (args & IW_PRIV_TYPE_MASK) >> 12; + + return num * iw_priv_type_size[type]; +} +/* copy from net/wireless/wext.c end */ + +static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) +{ + int err = 0; + u8 *input = NULL; + u32 input_len = 0; + const char delim[] = " "; + u8 *output = NULL; + u32 output_len = 0; + u32 count = 0; + u8 *buffer = NULL; + u32 buffer_len = 0; + char *ptr = NULL; + u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ + u32 cmdlen; + s32 len; + u8 *extra = NULL; + u32 extra_size = 0; + + s32 k; + const iw_handler *priv; /* Private ioctl */ + const struct iw_priv_args *priv_args; /* Private ioctl description */ + u32 num_priv_args; /* Number of descriptions */ + iw_handler handler; + int temp; + int subcmd = 0; /* sub-ioctl index */ + int offset = 0; /* Space for sub-ioctl index */ + + union iwreq_data wdata; + + memcpy(&wdata, wrq_data, sizeof(wdata)); + + input_len = wdata.data.length; + if (input_len == 0) + return -EFAULT; + input = rtw_zmalloc(input_len); + if (NULL == input) + return -ENOMEM; + if (copy_from_user(input, wdata.data.pointer, input_len)) { + err = -EFAULT; + goto exit; + } + ptr = input; + len = input_len; + + sscanf(ptr, "%16s", cmdname); + cmdlen = strlen(cmdname); + DBG_88E("%s: cmd =%s\n", __func__, cmdname); + + /* skip command string */ + if (cmdlen > 0) + cmdlen += 1; /* skip one space */ + ptr += cmdlen; + len -= cmdlen; + DBG_88E("%s: parameters =%s\n", __func__, ptr); + + priv = rtw_private_handler; + priv_args = rtw_private_args; + num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); + + if (num_priv_args == 0) { + err = -EOPNOTSUPP; + goto exit; + } + + /* Search the correct ioctl */ + k = -1; + while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname)); + + /* If not found... */ + if (k == num_priv_args) { + err = -EOPNOTSUPP; + goto exit; + } + + /* Watch out for sub-ioctls ! */ + if (priv_args[k].cmd < SIOCDEVPRIVATE) { + int j = -1; + + /* Find the matching *real* ioctl */ + while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') || + (priv_args[j].set_args != priv_args[k].set_args) || + (priv_args[j].get_args != priv_args[k].get_args))); + + /* If not found... */ + if (j == num_priv_args) { + err = -EINVAL; + goto exit; + } + + /* Save sub-ioctl number */ + subcmd = priv_args[k].cmd; + /* Reserve one int (simplify alignment issues) */ + offset = sizeof(__u32); + /* Use real ioctl definition from now on */ + k = j; + } + + buffer = rtw_zmalloc(4096); + if (NULL == buffer) { + err = -ENOMEM; + goto exit; + } + + /* If we have to set some data */ + if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && + (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { + u8 *str; + + switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { + case IW_PRIV_TYPE_BYTE: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) + break; + sscanf(str, "%i", &temp); + buffer[count++] = (u8)temp; + } while (1); + buffer_len = count; + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + break; + case IW_PRIV_TYPE_INT: + /* Fetch args */ + count = 0; + do { + str = strsep(&ptr, delim); + if (NULL == str) + break; + sscanf(str, "%i", &temp); + ((s32 *)buffer)[count++] = (s32)temp; + } while (1); + buffer_len = count * sizeof(s32); + /* Number of args to fetch */ + wdata.data.length = count; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + break; + case IW_PRIV_TYPE_CHAR: + if (len > 0) { + /* Size of the string to fetch */ + wdata.data.length = len; + if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) + wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; + + /* Fetch string */ + memcpy(buffer, ptr, wdata.data.length); + } else { + wdata.data.length = 1; + buffer[0] = '\0'; + } + buffer_len = wdata.data.length; + break; + default: + DBG_88E("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; + } + + if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && + (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { + DBG_88E("%s: The command %s needs exactly %d argument(s)...\n", + __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); + err = -EINVAL; + goto exit; + } + } else { + /* if args to set */ + wdata.data.length = 0L; + } + + /* Those two tests are important. They define how the driver + * will have to handle the data */ + if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && + ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { + /* First case : all SET args fit within wrq */ + if (offset) + wdata.mode = subcmd; + memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); + } else { + if ((priv_args[k].set_args == 0) && + (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { + /* Second case : no SET args, GET args fit within wrq */ + if (offset) + wdata.mode = subcmd; + } else { + /* Third case : args won't fit in wrq, or variable number of args */ + if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { + err = -EFAULT; + goto exit; + } + wdata.data.flags = subcmd; + } + } + + kfree(input); + input = NULL; + + extra_size = 0; + if (IW_IS_SET(priv_args[k].cmd)) { + /* Size of set arguments */ + extra_size = get_priv_size(priv_args[k].set_args); + + /* Does it fits in iwr ? */ + if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && + ((extra_size + offset) <= IFNAMSIZ)) + extra_size = 0; + } else { + /* Size of get arguments */ + extra_size = get_priv_size(priv_args[k].get_args); + + /* Does it fits in iwr ? */ + if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (extra_size <= IFNAMSIZ)) + extra_size = 0; + } + + if (extra_size == 0) { + extra = (u8 *)&wdata; + kfree(buffer); + buffer = NULL; + } else { + extra = buffer; + } + + handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; + err = handler(dev, NULL, &wdata, extra); + + /* If we have to get some data */ + if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && + (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { + int j; + int n = 0; /* number of args */ + u8 str[20] = {0}; + + /* Check where is the returned data */ + if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && + (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) + n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; + else + n = wdata.data.length; + + output = rtw_zmalloc(4096); + if (NULL == output) { + err = -ENOMEM; + goto exit; + } + switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { + case IW_PRIV_TYPE_BYTE: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", extra[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; + } + memcpy(output+output_len, str, len); + } + break; + case IW_PRIV_TYPE_INT: + /* Display args */ + for (j = 0; j < n; j++) { + sprintf(str, "%d ", ((__s32 *)extra)[j]); + len = strlen(str); + output_len = strlen(output); + if ((output_len + len + 1) > 4096) { + err = -E2BIG; + goto exit; + } + memcpy(output+output_len, str, len); + } + break; + case IW_PRIV_TYPE_CHAR: + /* Display args */ + memcpy(output, extra, n); + break; + default: + DBG_88E("%s: Not yet implemented...\n", __func__); + err = -1; + goto exit; + } + + output_len = strlen(output) + 1; + wrq_data->data.length = output_len; + if (copy_to_user(wrq_data->data.pointer, output, output_len)) { + err = -EFAULT; + goto exit; + } + } else { + /* if args to set */ + wrq_data->data.length = 0; + } + +exit: + kfree(input); + kfree(buffer); + kfree(output); + return err; +} + +#include +int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) +{ + struct iwreq *wrq = (struct iwreq *)rq; + int ret = 0; + + switch (cmd) { + case RTL_IOCTL_WPA_SUPPLICANT: + ret = wpa_supplicant_ioctl(dev, &wrq->u.data); + break; +#ifdef CONFIG_88EU_AP_MODE + case RTL_IOCTL_HOSTAPD: + ret = rtw_hostapd_ioctl(dev, &wrq->u.data); + break; +#endif /* CONFIG_88EU_AP_MODE */ + case SIOCDEVPRIVATE: + ret = rtw_ioctl_wext_private(dev, &wrq->u); + break; + case (SIOCDEVPRIVATE+1): + ret = rtw_android_priv_cmd(dev, rq, cmd); + break; + default: + ret = -EOPNOTSUPP; + break; + } + return ret; +} diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c new file mode 100644 index 000000000000..97c2b62f8fd4 --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -0,0 +1,302 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#define _MLME_OSDEP_C_ + +#include +#include +#include + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +void rtw_join_timeout_handler (void *FunctionContext) +#else +void rtw_join_timeout_handler (struct timer_list *t) +#endif +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = (struct adapter *)FunctionContext; +#else + struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer); +#endif + + _rtw_join_timeout_handler(adapter); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +void _rtw_scan_timeout_handler (void *FunctionContext) +#else +void _rtw_scan_timeout_handler (struct timer_list *t) +#endif +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = (struct adapter *)FunctionContext; +#else + struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer); +#endif + + rtw_scan_timeout_handler(adapter); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +static void _dynamic_check_timer_handlder(void *FunctionContext) +#else +static void _dynamic_check_timer_handlder(struct timer_list *t) +#endif +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + struct adapter *adapter = (struct adapter *)FunctionContext; +#else + struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer); +#endif + + if (adapter->registrypriv.mp_mode == 1) + return; + rtw_dynamic_check_timer_handlder(adapter); + _set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000); +} + +void rtw_init_mlme_timer(struct adapter *padapter) +{ + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, rtw_join_timeout_handler, padapter); + _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, _rtw_scan_timeout_handler, padapter); + _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter); +#else + timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0); + timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0); + timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0); +#endif +} + +void rtw_os_indicate_connect(struct adapter *adapter) +{ + + rtw_indicate_wx_assoc_event(adapter); + netif_carrier_on(adapter->pnetdev); + if (adapter->pid[2] != 0) + rtw_signal_process(adapter->pid[2], SIGALRM); + +} + +void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) +{ + indicate_wx_scan_complete_event(padapter); +} + +static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE]; + +void rtw_reset_securitypriv(struct adapter *adapter) +{ + u8 backup_index = 0; + u8 backup_counter = 0x00; + u32 backup_time = 0; + + if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + /* 802.1x */ + /* We have to backup the PMK information for WiFi PMK Caching test item. */ + /* Backup the btkip_countermeasure information. */ + /* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */ + memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + backup_index = adapter->securitypriv.PMKIDIndex; + backup_counter = adapter->securitypriv.btkip_countermeasure; + backup_time = adapter->securitypriv.btkip_countermeasure_time; + memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv)); + + /* Restore the PMK information to securitypriv structure for the following connection. */ + memcpy(&adapter->securitypriv.PMKIDList[0], + &backup_pmkid[0], + sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); + adapter->securitypriv.PMKIDIndex = backup_index; + adapter->securitypriv.btkip_countermeasure = backup_counter; + adapter->securitypriv.btkip_countermeasure_time = backup_time; + adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; + adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; + } else { + /* reset values in securitypriv */ + struct security_priv *psec_priv = &adapter->securitypriv; + + psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psec_priv->dot11PrivacyKeyIndex = 0; + psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psec_priv->dot118021XGrpKeyid = 1; + psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; + psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; + } +} + +void rtw_os_indicate_disconnect(struct adapter *adapter) +{ + + netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */ + rtw_indicate_wx_disassoc_event(adapter); + rtw_reset_securitypriv(adapter); + +} + +void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) +{ + uint len; + u8 *buff, *p, i; + union iwreq_data wrqu; + + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("+rtw_report_sec_ie, authmode=%d\n", authmode)); + buff = NULL; + if (authmode == _WPA_IE_ID_) { + RT_TRACE(_module_mlme_osdep_c_, _drv_info_, + ("rtw_report_sec_ie, authmode=%d\n", authmode)); + buff = rtw_malloc(IW_CUSTOM_MAX); + if (!buff) + return; + memset(buff, 0, IW_CUSTOM_MAX); + p = buff; + p += sprintf(p, "ASSOCINFO(ReqIEs ="); + len = sec_ie[1]+2; + len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; + for (i = 0; i < len; i++) + p += sprintf(p, "%02x", sec_ie[i]); + p += sprintf(p, ")"); + memset(&wrqu, 0, sizeof(wrqu)); + wrqu.data.length = p-buff; + wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? + wrqu.data.length : IW_CUSTOM_MAX; + wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); + kfree(buff); + } +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +static void _survey_timer_hdl(void *FunctionContext) +#else +static void _survey_timer_hdl(struct timer_list *t) +#endif +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + struct adapter *padapter = (struct adapter *)FunctionContext; +#else + struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer); +#endif + + survey_timer_hdl(padapter); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +static void _link_timer_hdl(void *FunctionContext) +#else +static void _link_timer_hdl(struct timer_list *t) +#endif +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + struct adapter *padapter = (struct adapter *)FunctionContext; +#else + struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer); +#endif + link_timer_hdl(padapter); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +static void _addba_timer_hdl(void *FunctionContext) +#else +static void _addba_timer_hdl(struct timer_list *t) +#endif +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + struct sta_info *psta = (struct sta_info *)FunctionContext; +#else + struct sta_info *psta = from_timer(psta, t, addba_retry_timer); +#endif + addba_timer_hdl(psta); +} + +void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) +{ +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + _init_timer(&psta->addba_retry_timer, padapter->pnetdev, _addba_timer_hdl, psta); +#else + timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0); +#endif +} + +void init_mlme_ext_timer(struct adapter *padapter) +{ + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, _survey_timer_hdl, padapter); + _init_timer(&pmlmeext->link_timer, padapter->pnetdev, _link_timer_hdl, padapter); +#else + timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0); + timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0); +#endif +} + +#ifdef CONFIG_88EU_AP_MODE + +void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta) +{ + union iwreq_data wrqu; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (psta == NULL) + return; + + if (psta->aid > NUM_STA) + return; + + if (pstapriv->sta_aid[psta->aid - 1] != psta) + return; + + wrqu.addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); + + DBG_88E("+rtw_indicate_sta_assoc_event\n"); + + wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL); +} + +void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta) +{ + union iwreq_data wrqu; + struct sta_priv *pstapriv = &padapter->stapriv; + + if (psta == NULL) + return; + + if (psta->aid > NUM_STA) + return; + + if (pstapriv->sta_aid[psta->aid - 1] != psta) + return; + + wrqu.addr.sa_family = ARPHRD_ETHER; + + memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); + + DBG_88E("+rtw_indicate_sta_disassoc_event\n"); + + wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL); +} + +#endif diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c new file mode 100644 index 000000000000..8c8ef9063b0c --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -0,0 +1,1283 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _OS_INTFS_C_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); +MODULE_AUTHOR("Realtek Semiconductor Corp."); +MODULE_VERSION(DRIVERVERSION); + +#define CONFIG_BR_EXT_BRNAME "br0" +#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ + +/* module param defaults */ +static int rtw_chip_version = 0x00; +static int rtw_rfintfs = HWPI; +static int rtw_lbkmode;/* RTL8712_AIR_TRX; */ +static int rtw_network_mode = Ndis802_11IBSS;/* Ndis802_11Infrastructure; infra, ad-hoc, auto */ +static int rtw_channel = 1;/* ad-hoc support requirement */ +static int rtw_wireless_mode = WIRELESS_11BG_24N; +static int rtw_vrtl_carrier_sense = AUTO_VCS; +static int rtw_vcs_type = RTS_CTS;/* */ +static int rtw_rts_thresh = 2347;/* */ +static int rtw_frag_thresh = 2346;/* */ +static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */ +static int rtw_scan_mode = 1;/* active, passive */ +static int rtw_adhoc_tx_pwr = 1; +static int rtw_soft_ap; +static int rtw_power_mgnt = 1; +static int rtw_ips_mode = IPS_NORMAL; + +static int rtw_smart_ps = 2; + +module_param(rtw_ips_mode, int, 0644); +MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode"); + +static int rtw_debug = 1; +static int rtw_radio_enable = 1; +static int rtw_long_retry_lmt = 7; +static int rtw_short_retry_lmt = 7; +static int rtw_busy_thresh = 40; +static int rtw_ack_policy = NORMAL_ACK; + +static int rtw_mp_mode; + +static int rtw_software_encrypt; +static int rtw_software_decrypt; + +static int rtw_acm_method;/* 0:By SW 1:By HW. */ + +static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ +static int rtw_uapsd_enable; +static int rtw_uapsd_max_sp = NO_LIMIT; +static int rtw_uapsd_acbk_en; +static int rtw_uapsd_acbe_en; +static int rtw_uapsd_acvi_en; +static int rtw_uapsd_acvo_en; + +static int rtw_led_enable = 1; + +int rtw_ht_enable = 1; +int rtw_cbw40_enable = 3; /* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ +int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ +static int rtw_rx_stbc = 1;/* 0: disable, bit(0):enable 2.4g, bit(1):enable 5g, default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ */ +static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ + +static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */ + +static int rtw_rf_config = RF_819X_MAX_TYPE; /* auto */ +static int rtw_low_power; +static int rtw_wifi_spec; +static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; +static int rtw_AcceptAddbaReq = true;/* 0:Reject AP's Add BA req, 1:Accept AP's Add BA req. */ + +static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */ +static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ + +static int rtw_enusbss;/* 0:disable, 1:enable */ + +static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */ + +static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */ + +static int rtw_hw_wps_pbc = 1; + +int rtw_mc2u_disable; + +static int rtw_80211d; + +static char *ifname = "wlan%d"; +module_param(ifname, charp, 0644); +MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); + +static char *if2name = "wlan%d"; +module_param(if2name, charp, 0644); +MODULE_PARM_DESC(if2name, "The default name to allocate for second interface"); + +char *rtw_initmac; /* temp mac address if users want to use instead of the mac address in Efuse */ + +module_param(rtw_initmac, charp, 0644); +module_param(rtw_channel_plan, int, 0644); +module_param(rtw_chip_version, int, 0644); +module_param(rtw_rfintfs, int, 0644); +module_param(rtw_lbkmode, int, 0644); +module_param(rtw_network_mode, int, 0644); +module_param(rtw_channel, int, 0644); +module_param(rtw_mp_mode, int, 0644); +module_param(rtw_wmm_enable, int, 0644); +module_param(rtw_vrtl_carrier_sense, int, 0644); +module_param(rtw_vcs_type, int, 0644); +module_param(rtw_busy_thresh, int, 0644); +module_param(rtw_led_enable, int, 0644); +module_param(rtw_ht_enable, int, 0644); +module_param(rtw_cbw40_enable, int, 0644); +module_param(rtw_ampdu_enable, int, 0644); +module_param(rtw_rx_stbc, int, 0644); +module_param(rtw_ampdu_amsdu, int, 0644); +module_param(rtw_lowrate_two_xmit, int, 0644); +module_param(rtw_rf_config, int, 0644); +module_param(rtw_power_mgnt, int, 0644); +module_param(rtw_smart_ps, int, 0644); +module_param(rtw_low_power, int, 0644); +module_param(rtw_wifi_spec, int, 0644); +module_param(rtw_antdiv_cfg, int, 0644); +module_param(rtw_antdiv_type, int, 0644); +module_param(rtw_enusbss, int, 0644); +module_param(rtw_hwpdn_mode, int, 0644); +module_param(rtw_hwpwrp_detect, int, 0644); +module_param(rtw_hw_wps_pbc, int, 0644); + +static uint rtw_max_roaming_times = 2; +module_param(rtw_max_roaming_times, uint, 0644); +MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try"); + +static int rtw_fw_iol = 1;/* 0:Disable, 1:enable, 2:by usb speed */ +module_param(rtw_fw_iol, int, 0644); +MODULE_PARM_DESC(rtw_fw_iol, "FW IOL"); + +module_param(rtw_mc2u_disable, int, 0644); + +module_param(rtw_80211d, int, 0644); +MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism"); + +static uint rtw_notch_filter = RTW_NOTCH_FILTER; +module_param(rtw_notch_filter, uint, 0644); +MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P"); +module_param_named(debug, rtw_debug, int, 0444); +MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); + +/* dummy routines */ +void rtw_proc_remove_one(struct net_device *dev) +{ +} + +void rtw_proc_init_one(struct net_device *dev) +{ +} + +#if 0 /* TODO: Convert these to /sys */ +void rtw_proc_init_one(struct net_device *dev) +{ + struct proc_dir_entry *dir_dev = NULL; + struct proc_dir_entry *entry = NULL; + struct adapter *padapter = rtw_netdev_priv(dev); + u8 rf_type; + + if (rtw_proc == NULL) { + memcpy(rtw_proc_name, DRV_NAME, sizeof(DRV_NAME)); + + rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, init_net.proc_net); + if (rtw_proc == NULL) { + DBG_88E(KERN_ERR "Unable to create rtw_proc directory\n"); + return; + } + + entry = create_proc_read_entry("ver_info", S_IFREG | S_IRUGO, rtw_proc, proc_get_drv_version, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + } + + if (padapter->dir_dev == NULL) { + padapter->dir_dev = create_proc_entry(dev->name, + S_IFDIR | S_IRUGO | S_IXUGO, + rtw_proc); + dir_dev = padapter->dir_dev; + if (dir_dev == NULL) { + if (rtw_proc_cnt == 0) { + if (rtw_proc) { + remove_proc_entry(rtw_proc_name, init_net.proc_net); + rtw_proc = NULL; + } + } + + pr_info("Unable to create dir_dev directory\n"); + return; + } + } else { + return; + } + + rtw_proc_cnt++; + + entry = create_proc_read_entry("write_reg", S_IFREG | S_IRUGO, + dir_dev, proc_get_write_reg, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_write_reg; + + entry = create_proc_read_entry("read_reg", S_IFREG | S_IRUGO, + dir_dev, proc_get_read_reg, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_read_reg; + + entry = create_proc_read_entry("fwstate", S_IFREG | S_IRUGO, + dir_dev, proc_get_fwstate, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("sec_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_sec_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mlmext_state", S_IFREG | S_IRUGO, + dir_dev, proc_get_mlmext_state, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("qos_option", S_IFREG | S_IRUGO, + dir_dev, proc_get_qos_option, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("ht_option", S_IFREG | S_IRUGO, + dir_dev, proc_get_ht_option, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("ap_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_ap_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("adapter_state", S_IFREG | S_IRUGO, + dir_dev, proc_getstruct adapter_state, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("trx_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_trx_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mac_reg_dump1", S_IFREG | S_IRUGO, + dir_dev, proc_get_mac_reg_dump1, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mac_reg_dump2", S_IFREG | S_IRUGO, + dir_dev, proc_get_mac_reg_dump2, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("mac_reg_dump3", S_IFREG | S_IRUGO, + dir_dev, proc_get_mac_reg_dump3, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("bb_reg_dump1", S_IFREG | S_IRUGO, + dir_dev, proc_get_bb_reg_dump1, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("bb_reg_dump2", S_IFREG | S_IRUGO, + dir_dev, proc_get_bb_reg_dump2, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("bb_reg_dump3", S_IFREG | S_IRUGO, + dir_dev, proc_get_bb_reg_dump3, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_reg_dump1", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump1, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_reg_dump2", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump2, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) { + entry = create_proc_read_entry("rf_reg_dump3", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump3, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rf_reg_dump4", S_IFREG | S_IRUGO, + dir_dev, proc_get_rf_reg_dump4, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + } + +#ifdef CONFIG_88EU_AP_MODE + + entry = create_proc_read_entry("all_sta_info", S_IFREG | S_IRUGO, + dir_dev, proc_get_all_sta_info, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } +#endif + + entry = create_proc_read_entry("best_channel", S_IFREG | S_IRUGO, + dir_dev, proc_get_best_channel, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + + entry = create_proc_read_entry("rx_signal", S_IFREG | S_IRUGO, + dir_dev, proc_get_rx_signal, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_rx_signal; + entry = create_proc_read_entry("ht_enable", S_IFREG | S_IRUGO, + dir_dev, proc_get_ht_enable, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_ht_enable; + + entry = create_proc_read_entry("cbw40_enable", S_IFREG | S_IRUGO, + dir_dev, proc_get_cbw40_enable, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_cbw40_enable; + + entry = create_proc_read_entry("ampdu_enable", S_IFREG | S_IRUGO, + dir_dev, proc_get_ampdu_enable, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_ampdu_enable; + + entry = create_proc_read_entry("rx_stbc", S_IFREG | S_IRUGO, + dir_dev, proc_get_rx_stbc, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_rx_stbc; + + entry = create_proc_read_entry("path_rssi", S_IFREG | S_IRUGO, + dir_dev, proc_get_two_path_rssi, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry = create_proc_read_entry("rssi_disp", S_IFREG | S_IRUGO, + dir_dev, proc_get_rssi_disp, dev); + if (!entry) { + pr_info("Unable to create_proc_read_entry!\n"); + return; + } + entry->write_proc = proc_set_rssi_disp; +} + +void rtw_proc_remove_one(struct net_device *dev) +{ + struct proc_dir_entry *dir_dev = NULL; + struct adapter *padapter = rtw_netdev_priv(dev); + u8 rf_type; + + dir_dev = padapter->dir_dev; + padapter->dir_dev = NULL; + + if (dir_dev) { + remove_proc_entry("write_reg", dir_dev); + remove_proc_entry("read_reg", dir_dev); + remove_proc_entry("fwstate", dir_dev); + remove_proc_entry("sec_info", dir_dev); + remove_proc_entry("mlmext_state", dir_dev); + remove_proc_entry("qos_option", dir_dev); + remove_proc_entry("ht_option", dir_dev); + remove_proc_entry("rf_info", dir_dev); + remove_proc_entry("ap_info", dir_dev); + remove_proc_entry("adapter_state", dir_dev); + remove_proc_entry("trx_info", dir_dev); + remove_proc_entry("mac_reg_dump1", dir_dev); + remove_proc_entry("mac_reg_dump2", dir_dev); + remove_proc_entry("mac_reg_dump3", dir_dev); + remove_proc_entry("bb_reg_dump1", dir_dev); + remove_proc_entry("bb_reg_dump2", dir_dev); + remove_proc_entry("bb_reg_dump3", dir_dev); + remove_proc_entry("rf_reg_dump1", dir_dev); + remove_proc_entry("rf_reg_dump2", dir_dev); + rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) { + remove_proc_entry("rf_reg_dump3", dir_dev); + remove_proc_entry("rf_reg_dump4", dir_dev); + } +#ifdef CONFIG_88EU_AP_MODE + remove_proc_entry("all_sta_info", dir_dev); +#endif + + remove_proc_entry("best_channel", dir_dev); + remove_proc_entry("rx_signal", dir_dev); + remove_proc_entry("cbw40_enable", dir_dev); + remove_proc_entry("ht_enable", dir_dev); + remove_proc_entry("ampdu_enable", dir_dev); + remove_proc_entry("rx_stbc", dir_dev); + remove_proc_entry("path_rssi", dir_dev); + remove_proc_entry("rssi_disp", dir_dev); + remove_proc_entry(dev->name, rtw_proc); + dir_dev = NULL; + } else { + return; + } + rtw_proc_cnt--; + + if (rtw_proc_cnt == 0) { + if (rtw_proc) { + remove_proc_entry("ver_info", rtw_proc); + + remove_proc_entry(rtw_proc_name, init_net.proc_net); + rtw_proc = NULL; + } + } +} +#endif + +static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) +{ + uint status = _SUCCESS; + struct registry_priv *registry_par = &padapter->registrypriv; + + GlobalDebugLevel = rtw_debug; + registry_par->chip_version = (u8)rtw_chip_version; + registry_par->rfintfs = (u8)rtw_rfintfs; + registry_par->lbkmode = (u8)rtw_lbkmode; + registry_par->network_mode = (u8)rtw_network_mode; + + memcpy(registry_par->ssid.Ssid, "ANY", 3); + registry_par->ssid.SsidLength = 3; + + registry_par->channel = (u8)rtw_channel; + registry_par->wireless_mode = (u8)rtw_wireless_mode; + registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; + registry_par->vcs_type = (u8)rtw_vcs_type; + registry_par->rts_thresh = (u16)rtw_rts_thresh; + registry_par->frag_thresh = (u16)rtw_frag_thresh; + registry_par->preamble = (u8)rtw_preamble; + registry_par->scan_mode = (u8)rtw_scan_mode; + registry_par->adhoc_tx_pwr = (u8)rtw_adhoc_tx_pwr; + registry_par->soft_ap = (u8)rtw_soft_ap; + registry_par->smart_ps = (u8)rtw_smart_ps; + registry_par->power_mgnt = (u8)rtw_power_mgnt; + registry_par->ips_mode = (u8)rtw_ips_mode; + registry_par->radio_enable = (u8)rtw_radio_enable; + registry_par->long_retry_lmt = (u8)rtw_long_retry_lmt; + registry_par->short_retry_lmt = (u8)rtw_short_retry_lmt; + registry_par->busy_thresh = (u16)rtw_busy_thresh; + registry_par->ack_policy = (u8)rtw_ack_policy; + registry_par->mp_mode = (u8)rtw_mp_mode; + registry_par->software_encrypt = (u8)rtw_software_encrypt; + registry_par->software_decrypt = (u8)rtw_software_decrypt; + registry_par->acm_method = (u8)rtw_acm_method; + + /* UAPSD */ + registry_par->wmm_enable = (u8)rtw_wmm_enable; + registry_par->uapsd_enable = (u8)rtw_uapsd_enable; + registry_par->uapsd_max_sp = (u8)rtw_uapsd_max_sp; + registry_par->uapsd_acbk_en = (u8)rtw_uapsd_acbk_en; + registry_par->uapsd_acbe_en = (u8)rtw_uapsd_acbe_en; + registry_par->uapsd_acvi_en = (u8)rtw_uapsd_acvi_en; + registry_par->uapsd_acvo_en = (u8)rtw_uapsd_acvo_en; + + registry_par->led_enable = (u8)rtw_led_enable; + + registry_par->ht_enable = (u8)rtw_ht_enable; + registry_par->cbw40_enable = (u8)rtw_cbw40_enable; + registry_par->ampdu_enable = (u8)rtw_ampdu_enable; + registry_par->rx_stbc = (u8)rtw_rx_stbc; + registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu; + registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit; + registry_par->rf_config = (u8)rtw_rf_config; + registry_par->low_power = (u8)rtw_low_power; + registry_par->wifi_spec = (u8)rtw_wifi_spec; + registry_par->channel_plan = (u8)rtw_channel_plan; + registry_par->bAcceptAddbaReq = (u8)rtw_AcceptAddbaReq; + registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg; + registry_par->antdiv_type = (u8)rtw_antdiv_type; + registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode;/* 0:disable, 1:enable, 2:by EFUSE config */ + registry_par->hwpwrp_detect = (u8)rtw_hwpwrp_detect;/* 0:disable, 1:enable */ + registry_par->hw_wps_pbc = (u8)rtw_hw_wps_pbc; + + registry_par->max_roaming_times = (u8)rtw_max_roaming_times; + + registry_par->fw_iol = rtw_fw_iol; + + registry_par->enable80211d = (u8)rtw_80211d; + snprintf(registry_par->ifname, 16, "%s", ifname); + snprintf(registry_par->if2name, 16, "%s", if2name); + registry_par->notch_filter = (u8)rtw_notch_filter; + + return status; +} + +static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct sockaddr *addr = p; + + if (!padapter->bup) + memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN); + + return 0; +} + +static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct recv_priv *precvpriv = &(padapter->recvpriv); + + padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */ + padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */ + padapter->stats.tx_dropped = pxmitpriv->tx_drop; + padapter->stats.rx_dropped = precvpriv->rx_drop; + padapter->stats.tx_bytes = pxmitpriv->tx_bytes; + padapter->stats.rx_bytes = precvpriv->rx_bytes; + return &padapter->stats; +} + +/* + * AC to queue mapping + * + * AC_VO -> queue 0 + * AC_VI -> queue 1 + * AC_BE -> queue 2 + * AC_BK -> queue 3 + */ +static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; + +/* Given a data frame determine the 802.1p/1d tag to use. */ +static unsigned int rtw_classify8021d(struct sk_buff *skb) +{ + unsigned int dscp; + + /* skb->priority values from 256->263 are magic values to + * directly indicate a specific 802.1d priority. This is used + * to allow 802.1d priority to be passed directly in from VLAN + * tags, etc. + */ + if (skb->priority >= 256 && skb->priority <= 263) + return skb->priority - 256; + + switch (skb->protocol) { + case htons(ETH_P_IP): + dscp = ip_hdr(skb)->tos & 0xfc; + break; + default: + return 0; + } + + return dscp >> 5; +} + +static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)) + ,struct net_device *sb_dev +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) + ,struct net_device *sb_dev + ,select_queue_fallback_t fallback +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) + ,void *unused + ,select_queue_fallback_t fallback +#elif (LINUX_VERSION_CODE == KERNEL_VERSION(3, 13, 0)) + , void *accel +#endif +) +{ + struct adapter *padapter = rtw_netdev_priv(dev); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + skb->priority = rtw_classify8021d(skb); + + if (pmlmepriv->acm_mask != 0) + skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority); + + return rtw_1d_to_queue[skb->priority]; +} + +u16 rtw_recv_select_queue(struct sk_buff *skb) +{ + struct iphdr *piphdr; + unsigned int dscp; + __be16 eth_type; + u32 priority; + u8 *pdata = skb->data; + + memcpy(ð_type, pdata+(ETH_ALEN<<1), 2); + + switch (eth_type) { + case htons(ETH_P_IP): + piphdr = (struct iphdr *)(pdata+ETH_HLEN); + dscp = piphdr->tos & 0xfc; + priority = dscp >> 5; + break; + default: + priority = 0; + } + + return rtw_1d_to_queue[priority]; +} + +static const struct net_device_ops rtw_netdev_ops = { + .ndo_open = netdev_open, + .ndo_stop = netdev_close, + .ndo_start_xmit = rtw_xmit_entry, + .ndo_select_queue = rtw_select_queue, + .ndo_set_mac_address = rtw_net_set_mac_address, + .ndo_get_stats = rtw_net_get_stats, + .ndo_do_ioctl = rtw_ioctl, +}; + +int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) +{ + if (dev_alloc_name(pnetdev, ifname) < 0) + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("dev_alloc_name, fail!\n")); + + netif_carrier_off(pnetdev); + return 0; +} + +#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,39) +static const struct device_type wlan_type = { + .name = "wlan", +}; +#else +static struct device_type wlan_type = { + .name = "wlan", +}; +#endif + +struct net_device *rtw_init_netdev(struct adapter *old_padapter) +{ + struct adapter *padapter; + struct net_device *pnetdev; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); + + if (old_padapter != NULL) + pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); + else + pnetdev = rtw_alloc_etherdev(sizeof(struct adapter)); + + if (!pnetdev) + return NULL; + + pnetdev->dev.type = &wlan_type; + padapter = rtw_netdev_priv(pnetdev); + padapter->pnetdev = pnetdev; + DBG_88E("register rtw_netdev_ops to netdev_ops\n"); + pnetdev->netdev_ops = &rtw_netdev_ops; + pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ + pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; + + /* step 2. */ + loadparam(padapter, pnetdev); + + return pnetdev; +} + +u32 rtw_start_drv_threads(struct adapter *padapter) +{ + u32 _status = _SUCCESS; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n")); + + padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); + if (IS_ERR(padapter->cmdThread)) + _status = _FAIL; + else + _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); /* wait for cmd_thread to run */ + + rtw_hal_start_thread(padapter); + return _status; +} + +void rtw_stop_drv_threads(struct adapter *padapter) +{ + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n")); + + /* Below is to termindate rtw_cmd_thread & event_thread... */ + up(&padapter->cmdpriv.cmd_queue_sema); + if (padapter->cmdThread) + _rtw_down_sema(&padapter->cmdpriv.terminate_cmdthread_sema); + + rtw_hal_stop_thread(padapter); +} + +static u8 rtw_init_default_value(struct adapter *padapter) +{ + u8 ret = _SUCCESS; + struct registry_priv *pregistrypriv = &padapter->registrypriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + + /* xmit_priv */ + pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; + pxmitpriv->vcs = pregistrypriv->vcs_type; + pxmitpriv->vcs_type = pregistrypriv->vcs_type; + pxmitpriv->frag_len = pregistrypriv->frag_thresh; + + /* mlme_priv */ + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + pmlmepriv->scan_mode = SCAN_ACTIVE; + + /* ht_priv */ + pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */ + + /* security_priv */ + psecuritypriv->binstallGrpkey = _FAIL; + psecuritypriv->sw_encrypt = pregistrypriv->software_encrypt; + psecuritypriv->sw_decrypt = pregistrypriv->software_decrypt; + psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ + psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; + psecuritypriv->dot11PrivacyKeyIndex = 0; + psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; + psecuritypriv->dot118021XGrpKeyid = 1; + psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen; + psecuritypriv->ndisencryptstatus = Ndis802_11WEPDisabled; + + /* registry_priv */ + rtw_init_registrypriv_dev_network(padapter); + rtw_update_registrypriv_dev_network(padapter); + + /* hal_priv */ + rtw_hal_def_value_init(padapter); + + /* misc. */ + padapter->bReadPortCancel = false; + padapter->bWritePortCancel = false; + padapter->bRxRSSIDisplay = 0; + padapter->bNotifyChannelChange = 0; +#ifdef CONFIG_88EU_P2P + padapter->bShowGetP2PState = 1; +#endif + return ret; +} + +u8 rtw_reset_drv_sw(struct adapter *padapter) +{ + u8 ret8 = _SUCCESS; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + /* hal_priv */ + rtw_hal_def_value_init(padapter); + padapter->bReadPortCancel = false; + padapter->bWritePortCancel = false; + padapter->bRxRSSIDisplay = 0; + pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ + + padapter->xmitpriv.tx_pkts = 0; + padapter->recvpriv.rx_pkts = 0; + + pmlmepriv->LinkDetectInfo.bBusyTraffic = false; + + _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); + + rtw_hal_sreset_reset_value(padapter); + pwrctrlpriv->pwr_state_check_cnts = 0; + + /* mlmeextpriv */ + padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE; + + rtw_set_signal_stat_timer(&padapter->recvpriv); + + return ret8; +} + +u8 rtw_init_drv_sw(struct adapter *padapter) +{ + u8 ret8 = _SUCCESS; + unsigned long flags; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); + + if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n")); + ret8 = _FAIL; + goto exit; + } + + padapter->cmdpriv.padapter = padapter; + + if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n")); + ret8 = _FAIL; + goto exit; + } + + if (rtw_init_mlme_priv(padapter) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_priv\n")); + ret8 = _FAIL; + goto exit; + } + +#ifdef CONFIG_88EU_P2P + rtw_init_wifidirect_timers(padapter); + init_wifidirect_info(padapter, P2P_ROLE_DISABLE); + reset_global_wifidirect_info(padapter); +#endif /* CONFIG_88EU_P2P */ + + if (init_mlme_ext_priv(padapter) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_ext_priv\n")); + ret8 = _FAIL; + goto exit; + } + + if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) { + DBG_88E("Can't _rtw_init_xmit_priv\n"); + ret8 = _FAIL; + goto exit; + } + + if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) { + DBG_88E("Can't _rtw_init_recv_priv\n"); + ret8 = _FAIL; + goto exit; + } + + if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) { + DBG_88E("Can't _rtw_init_sta_priv\n"); + ret8 = _FAIL; + goto exit; + } + + padapter->stapriv.padapter = padapter; + + rtw_init_bcmc_stainfo(padapter); + + rtw_init_pwrctrl_priv(padapter); + + if (init_mp_priv(padapter) == _FAIL) + DBG_88E("%s: initialize MP private data Fail!\n", __func__); + + ret8 = rtw_init_default_value(padapter); + + rtw_hal_dm_init(padapter); + rtw_hal_sw_led_init(padapter); + + rtw_hal_sreset_init(padapter); + + spin_lock_init(&padapter->br_ext_lock); + +exit: + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n")); + + + + return ret8; +} + +void rtw_cancel_all_timer(struct adapter *padapter) +{ + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer\n")); + + _cancel_timer_ex(&padapter->mlmepriv.assoc_timer); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel association timer complete!\n")); + + _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel scan_to_timer!\n")); + + _cancel_timer_ex(&padapter->mlmepriv.dynamic_chk_timer); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel dynamic_chk_timer!\n")); + + /* cancel sw led timer */ + rtw_hal_sw_led_deinit(padapter); + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel DeInitSwLeds!\n")); + + _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer); + + _cancel_timer_ex(&padapter->recvpriv.signal_stat_timer); + /* cancel dm timer */ + rtw_hal_dm_deinit(padapter); +} + +u8 rtw_free_drv_sw(struct adapter *padapter) +{ + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw")); + + /* we can call rtw_p2p_enable here, but: */ + /* 1. rtw_p2p_enable may have IO operation */ + /* 2. rtw_p2p_enable is bundled with wext interface */ + #ifdef CONFIG_88EU_P2P + { + struct wifidirect_info *pwdinfo = &padapter->wdinfo; + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + _cancel_timer_ex(&pwdinfo->find_phase_timer); + _cancel_timer_ex(&pwdinfo->restore_p2p_state_timer); + _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); + rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); + } + } + #endif + + _rtw_spinlock_free(&padapter->br_ext_lock); + + free_mlme_ext_priv(&padapter->mlmeextpriv); + + rtw_free_cmd_priv(&padapter->cmdpriv); + + rtw_free_evt_priv(&padapter->evtpriv); + + rtw_free_mlme_priv(&padapter->mlmepriv); + _rtw_free_xmit_priv(&padapter->xmitpriv); + + _rtw_free_sta_priv(&padapter->stapriv); /* will free bcmc_stainfo here */ + + _rtw_free_recv_priv(&padapter->recvpriv); + + rtw_free_pwrctrl_priv(padapter); + + rtw_hal_free_data(padapter); + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw\n")); + + /* free the old_pnetdev */ + if (padapter->rereg_nd_name_priv.old_pnetdev) { + free_netdev(padapter->rereg_nd_name_priv.old_pnetdev); + padapter->rereg_nd_name_priv.old_pnetdev = NULL; + } + + /* clear pbuddystruct adapter to avoid access wrong pointer. */ + if (padapter->pbuddy_adapter != NULL) + padapter->pbuddy_adapter->pbuddy_adapter = NULL; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n")); + + return _SUCCESS; +} + +void netdev_br_init(struct net_device *netdev) +{ + struct adapter *adapter = (struct adapter *)rtw_netdev_priv(netdev); + + rcu_read_lock(); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + if (rcu_dereference(adapter->pnetdev->rx_handler_data)) { +#else + if (rcu_dereference(adapter->pnetdev->br_port)) { +#endif + struct net_device *br_netdev; + struct net *devnet = NULL; + + devnet = dev_net(netdev); + br_netdev = dev_get_by_name(devnet, CONFIG_BR_EXT_BRNAME); + if (br_netdev) { + memcpy(adapter->br_mac, br_netdev->dev_addr, ETH_ALEN); + dev_put(br_netdev); + } else { + pr_info("%s()-%d: dev_get_by_name(%s) failed!", + __func__, __LINE__, CONFIG_BR_EXT_BRNAME); + } + } + adapter->ethBrExtInfo.addPPPoETag = 1; + + rcu_read_unlock(); +} + +int _netdev_open(struct net_device *pnetdev) +{ + uint status; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - dev_open\n")); + DBG_88E("+88eu_drv - drv_open, bup =%d\n", padapter->bup); + + if (pwrctrlpriv->ps_flag) { + padapter->net_closed = false; + goto netdev_open_normal_process; + } + + if (!padapter->bup) { + padapter->bDriverStopped = false; + padapter->bSurpriseRemoved = false; + padapter->bCardDisableWOHSM = false; + + status = rtw_hal_init(padapter); + if (status == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("rtl88eu_hal_init(): Can't init h/w!\n")); + goto netdev_open_error; + } + + pr_info("MAC Address = %pM\n", pnetdev->dev_addr); + + status = rtw_start_drv_threads(padapter); + if (status == _FAIL) { + pr_info("Initialize driver software resource Failed!\n"); + goto netdev_open_error; + } + + if (init_hw_mlme_ext(padapter) == _FAIL) { + pr_info("can't init mlme_ext_priv\n"); + goto netdev_open_error; + } + if (padapter->intf_start) + padapter->intf_start(padapter); + rtw_proc_init_one(pnetdev); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + padapter->bup = true; + } + padapter->net_closed = false; + + _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 2000); + + padapter->pwrctrlpriv.bips_processing = false; + rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); + + if (!rtw_netif_queue_stopped(pnetdev)) + rtw_netif_start_queue(pnetdev); + else + rtw_netif_wake_queue(pnetdev); + + netdev_br_init(pnetdev); + +netdev_open_normal_process: + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - dev_open\n")); + DBG_88E("-88eu_drv - drv_open, bup =%d\n", padapter->bup); + return 0; + +netdev_open_error: + padapter->bup = false; + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-88eu_drv - dev_open, fail!\n")); + DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup); + return -1; +} + +int netdev_open(struct net_device *pnetdev) +{ + int ret; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + + _enter_critical_mutex(padapter->hw_init_mutex, NULL); + ret = _netdev_open(pnetdev); + _exit_critical_mutex(padapter->hw_init_mutex, NULL); + return ret; +} + +static int ips_netdrv_open(struct adapter *padapter) +{ + int status = _SUCCESS; + padapter->net_closed = false; + DBG_88E("===> %s.........\n", __func__); + + padapter->bDriverStopped = false; + padapter->bSurpriseRemoved = false; + padapter->bCardDisableWOHSM = false; + + status = rtw_hal_init(padapter); + if (status == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n")); + goto netdev_open_error; + } + + if (padapter->intf_start) + padapter->intf_start(padapter); + + rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); + _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000); + + return _SUCCESS; + +netdev_open_error: + DBG_88E("-ips_netdrv_open - drv_open failure, bup =%d\n", padapter->bup); + + return _FAIL; +} + +int rtw_ips_pwr_up(struct adapter *padapter) +{ + int result; + u32 start_time = jiffies; + DBG_88E("===> rtw_ips_pwr_up..............\n"); + rtw_reset_drv_sw(padapter); + + result = ips_netdrv_open(padapter); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + DBG_88E("<=== rtw_ips_pwr_up.............. in %dms\n", rtw_get_passing_time_ms(start_time)); + return result; +} + +void rtw_ips_pwr_down(struct adapter *padapter) +{ + u32 start_time = jiffies; + DBG_88E("===> rtw_ips_pwr_down...................\n"); + + padapter->bCardDisableWOHSM = true; + padapter->net_closed = true; + + rtw_led_control(padapter, LED_CTL_POWER_OFF); + + rtw_ips_dev_unload(padapter); + padapter->bCardDisableWOHSM = false; + DBG_88E("<=== rtw_ips_pwr_down..................... in %dms\n", rtw_get_passing_time_ms(start_time)); +} + +void rtw_ips_dev_unload(struct adapter *padapter) +{ + DBG_88E("====> %s...\n", __func__); + + rtw_hal_set_hwreg(padapter, HW_VAR_FIFO_CLEARN_UP, NULL); + + if (padapter->intf_stop) + padapter->intf_stop(padapter); + + /* s5. */ + if (!padapter->bSurpriseRemoved) + rtw_hal_deinit(padapter); +} + +int pm_netdev_open(struct net_device *pnetdev, u8 bnormal) +{ + int status; + + if (bnormal) + status = netdev_open(pnetdev); + else + status = (_SUCCESS == ips_netdrv_open((struct adapter *)rtw_netdev_priv(pnetdev))) ? (0) : (-1); + return status; +} + +int netdev_close(struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n")); + + if (padapter->pwrctrlpriv.bInternalAutoSuspend) { + if (padapter->pwrctrlpriv.rf_pwrstate == rf_off) + padapter->pwrctrlpriv.ps_flag = true; + } + padapter->net_closed = true; + + if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) { + DBG_88E("(2)88eu_drv - drv_close, bup =%d, hw_init_completed =%d\n", + padapter->bup, padapter->hw_init_completed); + + /* s1. */ + if (pnetdev) { + if (!rtw_netif_queue_stopped(pnetdev)) + rtw_netif_stop_queue(pnetdev); + } + + /* s2. */ + LeaveAllPowerSaveMode(padapter); + rtw_disassoc_cmd(padapter, 500, false); + /* s2-2. indicate disconnect to os */ + rtw_indicate_disconnect(padapter); + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + /* s2-4. */ + rtw_free_network_queue(padapter, true); + /* Close LED */ + rtw_led_control(padapter, LED_CTL_POWER_OFF); + } + + nat25_db_cleanup(padapter); + +#ifdef CONFIG_88EU_P2P + rtw_p2p_enable(padapter, P2P_ROLE_DISABLE); +#endif /* CONFIG_88EU_P2P */ + + kfree(dvobj->firmware.szFwBuffer); + dvobj->firmware.szFwBuffer = NULL; + + RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n")); + DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup); + return 0; +} diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c new file mode 100644 index 000000000000..541af56515ac --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -0,0 +1,535 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#define _OSDEP_SERVICE_C_ + +#include +#include +#include +#include +#include + +/* +* Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE +* @return: one of RTW_STATUS_CODE +*/ +inline int RTW_STATUS_CODE(int error_code) +{ + if (error_code >= 0) + return _SUCCESS; + return _FAIL; +} + +u32 rtw_atoi(u8 *s) +{ + int num = 0, flag = 0; + int i; + for (i = 0; i <= strlen(s); i++) { + if (s[i] >= '0' && s[i] <= '9') + num = num * 10 + s[i] - '0'; + else if (s[0] == '-' && i == 0) + flag = 1; + else + break; + } + if (flag == 1) + num = num * -1; + return num; +} + +inline u8 *_rtw_vmalloc(u32 sz) +{ + u8 *pbuf; + pbuf = vmalloc(sz); + return pbuf; +} + +inline u8 *_rtw_zvmalloc(u32 sz) +{ + u8 *pbuf; + pbuf = _rtw_vmalloc(sz); + if (pbuf != NULL) + memset(pbuf, 0, sz); + return pbuf; +} + +inline void _rtw_vmfree(u8 *pbuf, u32 sz) +{ + vfree(pbuf); +} + +u8 *_rtw_malloc(u32 sz) +{ + u8 *pbuf = NULL; + + pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); + return pbuf; +} + +u8 *_rtw_zmalloc(u32 sz) +{ + u8 *pbuf = _rtw_malloc(sz); + + if (pbuf != NULL) + memset(pbuf, 0, sz); + return pbuf; +} + +void *rtw_malloc2d(int h, int w, int size) +{ + int j; + + void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size); + if (a == NULL) { + pr_info("%s: alloc memory fail!\n", __func__); + return NULL; + } + + for (j = 0; j < h; j++) + a[j] = ((char *)(a+h)) + j*w*size; + + return a; +} + +void rtw_mfree2d(void *pbuf, int h, int w, int size) +{ + kfree(pbuf); +} + +/* +For the following list_xxx operations, +caller must guarantee the atomic context. +Otherwise, there will be racing condition. +*/ +/* +Caller must check if the list is empty before calling rtw_list_delete +*/ + +u32 _rtw_down_sema(struct semaphore *sema) +{ + if (down_interruptible(sema)) + return _FAIL; + else + return _SUCCESS; +} + +void _rtw_mutex_init(struct mutex *pmutex) +{ + mutex_init(pmutex); +} + +void _rtw_mutex_free(struct mutex *pmutex) +{ + mutex_destroy(pmutex); +} + +void _rtw_spinlock_free(spinlock_t *plock) +{ +} + +void _rtw_init_queue(struct __queue *pqueue) +{ + INIT_LIST_HEAD(&(pqueue->queue)); + spin_lock_init(&(pqueue->lock)); +} + +inline u32 rtw_systime_to_ms(u32 systime) +{ + return systime * 1000 / HZ; +} + +inline u32 rtw_ms_to_systime(u32 ms) +{ + return ms * HZ / 1000; +} + +/* the input parameter start use the same unit as jiffies */ +inline s32 rtw_get_passing_time_ms(u32 start) +{ + return rtw_systime_to_ms(jiffies-start); +} + +inline s32 rtw_get_time_interval_ms(u32 start, u32 end) +{ + return rtw_systime_to_ms(end-start); +} + +void rtw_sleep_schedulable(int ms) +{ + u32 delta; + + delta = (ms * HZ)/1000;/* ms) */ + if (delta == 0) + delta = 1;/* 1 ms */ + set_current_state(TASK_INTERRUPTIBLE); + if (schedule_timeout(delta) != 0) + return; +} + +void rtw_msleep_os(int ms) +{ + msleep((unsigned int)ms); +} + +void rtw_usleep_os(int us) +{ + if (1 < (us/1000)) + msleep(1); + else + msleep((us/1000) + 1); +} + +void rtw_mdelay_os(int ms) +{ + mdelay((unsigned long)ms); +} + +void rtw_udelay_os(int us) +{ + udelay((unsigned long)us); +} + +void rtw_yield_os(void) +{ + yield(); +} + +#define RTW_SUSPEND_LOCK_NAME "rtw_wifi" + +inline void rtw_suspend_lock_init(void) +{ +} + +inline void rtw_suspend_lock_uninit(void) +{ +} + +inline void rtw_lock_suspend(void) +{ +} + +inline void rtw_unlock_suspend(void) +{ +} + +inline void ATOMIC_SET(ATOMIC_T *v, int i) +{ + atomic_set(v, i); +} + +inline int ATOMIC_READ(ATOMIC_T *v) +{ + return atomic_read(v); +} + +inline void ATOMIC_ADD(ATOMIC_T *v, int i) +{ + atomic_add(i, v); +} + +inline void ATOMIC_SUB(ATOMIC_T *v, int i) +{ + atomic_sub(i, v); +} + +inline void ATOMIC_INC(ATOMIC_T *v) +{ + atomic_inc(v); +} + +inline void ATOMIC_DEC(ATOMIC_T *v) +{ + atomic_dec(v); +} + +inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i) +{ + return atomic_add_return(i, v); +} + +inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i) +{ + return atomic_sub_return(i, v); +} + +inline int ATOMIC_INC_RETURN(ATOMIC_T *v) +{ + return atomic_inc_return(v); +} + +inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) +{ + return atomic_dec_return(v); +} + +static const struct device_type wlan_type = { + .name = "wlan", +}; + +struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, + void *old_priv) +{ + struct net_device *pnetdev; + struct rtw_netdev_priv_indicator *pnpi; + + pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); + if (!pnetdev) + goto RETURN; + + pnetdev->dev.type = &wlan_type; + pnpi = netdev_priv(pnetdev); + pnpi->priv = old_priv; + pnpi->sizeof_priv = sizeof_priv; + +RETURN: + return pnetdev; +} + +struct net_device *rtw_alloc_etherdev(int sizeof_priv) +{ + struct net_device *pnetdev; + struct rtw_netdev_priv_indicator *pnpi; + + pnetdev = alloc_etherdev_mq(sizeof(struct rtw_netdev_priv_indicator), 4); + if (!pnetdev) + goto RETURN; + + pnpi = netdev_priv(pnetdev); + + pnpi->priv = rtw_zvmalloc(sizeof_priv); + if (!pnpi->priv) { + free_netdev(pnetdev); + pnetdev = NULL; + goto RETURN; + } + + pnpi->sizeof_priv = sizeof_priv; +RETURN: + return pnetdev; +} + +void rtw_free_netdev(struct net_device *netdev) +{ + struct rtw_netdev_priv_indicator *pnpi; + + if (!netdev) + goto RETURN; + + pnpi = netdev_priv(netdev); + + if (!pnpi->priv) + goto RETURN; + + rtw_vmfree(pnpi->priv, pnpi->sizeof_priv); + free_netdev(netdev); + +RETURN: + return; +} + +int rtw_change_ifname(struct adapter *padapter, const char *ifname) +{ + struct net_device *pnetdev; + struct net_device *cur_pnetdev; + struct rereg_nd_name_data *rereg_priv; + int ret; + + if (!padapter) + goto error; + + cur_pnetdev = padapter->pnetdev; + rereg_priv = &padapter->rereg_nd_name_priv; + + /* free the old_pnetdev */ + if (rereg_priv->old_pnetdev) { + free_netdev(rereg_priv->old_pnetdev); + rereg_priv->old_pnetdev = NULL; + } + + if (!rtnl_is_locked()) + unregister_netdev(cur_pnetdev); + else + unregister_netdevice(cur_pnetdev); + + rtw_proc_remove_one(cur_pnetdev); + + rereg_priv->old_pnetdev = cur_pnetdev; + + pnetdev = rtw_init_netdev(padapter); + if (!pnetdev) { + ret = -1; + goto error; + } + + SET_NETDEV_DEV(pnetdev, dvobj_to_dev(adapter_to_dvobj(padapter))); + + rtw_init_netdev_name(pnetdev, ifname); + + memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); + + if (!rtnl_is_locked()) + ret = register_netdev(pnetdev); + else + ret = register_netdevice(pnetdev); + if (ret != 0) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("register_netdev() failed\n")); + goto error; + } + rtw_proc_init_one(pnetdev); + return 0; +error: + return -1; +} + +u64 rtw_modular64(u64 x, u64 y) +{ + return do_div(x, y); +} + +u64 rtw_division64(u64 x, u64 y) +{ + do_div(x, y); + return x; +} + +void rtw_buf_free(u8 **buf, u32 *buf_len) +{ + *buf_len = 0; + kfree(*buf); + *buf = NULL; +} + +void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) +{ + u32 ori_len = 0, dup_len = 0; + u8 *ori = NULL; + u8 *dup = NULL; + + if (!buf || !buf_len) + return; + + if (!src || !src_len) + goto keep_ori; + + /* duplicate src */ + dup = rtw_malloc(src_len); + if (dup) { + dup_len = src_len; + memcpy(dup, src, dup_len); + } + +keep_ori: + ori = *buf; + ori_len = *buf_len; + + /* replace buf with dup */ + *buf_len = 0; + *buf = dup; + *buf_len = dup_len; + + /* free ori */ + kfree(ori); +} + +/** + * rtw_cbuf_full - test if cbuf is full + * @cbuf: pointer of struct rtw_cbuf + * + * Returns: true if cbuf is full + */ +inline bool rtw_cbuf_full(struct rtw_cbuf *cbuf) +{ + return (cbuf->write == cbuf->read-1) ? true : false; +} + +/** + * rtw_cbuf_empty - test if cbuf is empty + * @cbuf: pointer of struct rtw_cbuf + * + * Returns: true if cbuf is empty + */ +inline bool rtw_cbuf_empty(struct rtw_cbuf *cbuf) +{ + return (cbuf->write == cbuf->read) ? true : false; +} + +/** + * rtw_cbuf_push - push a pointer into cbuf + * @cbuf: pointer of struct rtw_cbuf + * @buf: pointer to push in + * + * Lock free operation, be careful of the use scheme + * Returns: true push success + */ +bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf) +{ + if (rtw_cbuf_full(cbuf)) + return _FAIL; + + if (0) + DBG_88E("%s on %u\n", __func__, cbuf->write); + cbuf->bufs[cbuf->write] = buf; + cbuf->write = (cbuf->write+1)%cbuf->size; + + return _SUCCESS; +} + +/** + * rtw_cbuf_pop - pop a pointer from cbuf + * @cbuf: pointer of struct rtw_cbuf + * + * Lock free operation, be careful of the use scheme + * Returns: pointer popped out + */ +void *rtw_cbuf_pop(struct rtw_cbuf *cbuf) +{ + void *buf; + if (rtw_cbuf_empty(cbuf)) + return NULL; + + if (0) + DBG_88E("%s on %u\n", __func__, cbuf->read); + buf = cbuf->bufs[cbuf->read]; + cbuf->read = (cbuf->read+1)%cbuf->size; + + return buf; +} + +/** + * rtw_cbuf_alloc - allocate a rtw_cbuf with given size and do initialization + * @size: size of pointer + * + * Returns: pointer of srtuct rtw_cbuf, NULL for allocation failure + */ +struct rtw_cbuf *rtw_cbuf_alloc(u32 size) +{ + struct rtw_cbuf *cbuf; + + cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + + sizeof(void *)*size); + + if (cbuf) { + cbuf->write = 0; + cbuf->read = 0; + cbuf->size = size; + } + return cbuf; +} diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c new file mode 100644 index 000000000000..44c5fcbafa6a --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -0,0 +1,270 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _RECV_OSDEP_C_ + +#include +#include + +#include +#include + +#include +#include +#include + +/* init os related resource in struct recv_priv */ +int rtw_os_recv_resource_init(struct recv_priv *precvpriv, + struct adapter *padapter) +{ + return _SUCCESS; +} + +/* alloc os related resource in struct recv_frame */ +int rtw_os_recv_resource_alloc(struct adapter *padapter, + struct recv_frame *precvframe) +{ + precvframe->pkt_newalloc = NULL; + precvframe->pkt = NULL; + return _SUCCESS; +} + +/* free os related resource in struct recv_frame */ +void rtw_os_recv_resource_free(struct recv_priv *precvpriv) +{ +} + +/* alloc os related resource in struct recv_buf */ +int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, + struct recv_buf *precvbuf) +{ + int res = _SUCCESS; + + precvbuf->irp_pending = false; + precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); + if (precvbuf->purb == NULL) + res = _FAIL; + precvbuf->pskb = NULL; + precvbuf->reuse = false; + precvbuf->pallocated_buf = NULL; + precvbuf->pbuf = NULL; + precvbuf->pdata = NULL; + precvbuf->phead = NULL; + precvbuf->ptail = NULL; + precvbuf->pend = NULL; + precvbuf->transfer_len = 0; + precvbuf->len = 0; + return res; +} + +/* free os related resource in struct recv_buf */ +int rtw_os_recvbuf_resource_free(struct adapter *padapter, + struct recv_buf *precvbuf) +{ + usb_free_urb(precvbuf->purb); + return _SUCCESS; +} + +void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) +{ + union iwreq_data wrqu; + struct iw_michaelmicfailure ev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; + u32 cur_time = 0; + + if (psecuritypriv->last_mic_err_time == 0) { + psecuritypriv->last_mic_err_time = jiffies; + } else { + cur_time = jiffies; + + if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) { + psecuritypriv->btkip_countermeasure = true; + psecuritypriv->last_mic_err_time = 0; + psecuritypriv->btkip_countermeasure_time = cur_time; + } else { + psecuritypriv->last_mic_err_time = jiffies; + } + } + + memset(&ev, 0x00, sizeof(ev)); + if (bgroup) + ev.flags |= IW_MICFAILURE_GROUP; + else + ev.flags |= IW_MICFAILURE_PAIRWISE; + + ev.src_addr.sa_family = ARPHRD_ETHER; + memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN); + memset(&wrqu, 0x00, sizeof(wrqu)); + wrqu.data.length = sizeof(ev); + wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, + &wrqu, (char *)&ev); +} + +void rtw_hostapd_mlme_rx(struct adapter *padapter, + struct recv_frame *precv_frame) +{ +} + +int rtw_recv_indicatepkt(struct adapter *padapter, + struct recv_frame *precv_frame) +{ + struct recv_priv *precvpriv; + struct __queue *pfree_recv_queue; + struct sk_buff *skb; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + precvpriv = &(padapter->recvpriv); + pfree_recv_queue = &(precvpriv->free_recv_queue); + + skb = precv_frame->pkt; + if (skb == NULL) { + RT_TRACE(_module_recv_osdep_c_, _drv_err_, + ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); + goto _recv_indicatepkt_drop; + } + + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("rtw_recv_indicatepkt():skb != NULL !!!\n")); + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("rtw_recv_indicatepkt():precv_frame->rx_head =%p precv_frame->hdr.rx_data =%p\n", + precv_frame->rx_head, precv_frame->rx_data)); + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("precv_frame->hdr.rx_tail =%p precv_frame->rx_end =%p precv_frame->hdr.len =%d\n", + precv_frame->rx_tail, precv_frame->rx_end, + precv_frame->len)); + + skb->data = precv_frame->rx_data; + + skb_set_tail_pointer(skb, precv_frame->len); + + skb->len = precv_frame->len; + + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", + skb->head, skb->data, skb_tail_pointer(skb), + skb_end_pointer(skb), skb->len)); + + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { + struct sk_buff *pskb2 = NULL; + struct sta_info *psta = NULL; + struct sta_priv *pstapriv = &padapter->stapriv; + struct rx_pkt_attrib *pattrib = &precv_frame->attrib; + int bmcast = IS_MCAST(pattrib->dst); + + if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), + ETH_ALEN)) { + if (bmcast) { + psta = rtw_get_bcmc_stainfo(padapter); + pskb2 = skb_clone(skb, GFP_ATOMIC); + } else { + psta = rtw_get_stainfo(pstapriv, pattrib->dst); + } + + if (psta) { + struct net_device *pnetdev; + + pnetdev = (struct net_device *)padapter->pnetdev; + skb->dev = pnetdev; + skb_set_queue_mapping(skb, rtw_recv_select_queue(skb)); + + rtw_xmit_entry(skb, pnetdev); + + if (bmcast) + skb = pskb2; + else + goto _recv_indicatepkt_end; + } + } + } + + rcu_read_lock(); +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) + rcu_dereference(padapter->pnetdev->rx_handler_data); +#else + rcu_dereference(padapter->pnetdev->br_port); +#endif + rcu_read_unlock(); + + skb->ip_summed = CHECKSUM_NONE; + skb->dev = padapter->pnetdev; + skb->protocol = eth_type_trans(skb, padapter->pnetdev); + + netif_rx(skb); + +_recv_indicatepkt_end: + + /* pointers to NULL before rtw_free_recvframe() */ + precv_frame->pkt = NULL; + + rtw_free_recvframe(precv_frame, pfree_recv_queue); + + RT_TRACE(_module_recv_osdep_c_, _drv_info_, + ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); + + return _SUCCESS; + +_recv_indicatepkt_drop: + + /* enqueue back to free_recv_queue */ + rtw_free_recvframe(precv_frame, pfree_recv_queue); + + return _FAIL; +} + +void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf) +{ + struct recv_priv *precvpriv = &padapter->recvpriv; + + precvbuf->ref_cnt--; + /* free skb in recv_buf */ + dev_kfree_skb_any(precvbuf->pskb); + precvbuf->pskb = NULL; + precvbuf->reuse = false; + if (!precvbuf->irp_pending) + rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, + (unsigned char *)precvbuf); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +static void _rtw_reordering_ctrl_timeout_handler(void *func_context) +#else +static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t) +#endif +{ + struct recv_reorder_ctrl *preorder_ctrl; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + preorder_ctrl = (struct recv_reorder_ctrl *)func_context; +#else + preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer); +#endif + rtw_reordering_ctrl_timeout_handler(preorder_ctrl); +} + +void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) +{ + struct adapter *padapter = preorder_ctrl->padapter; + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) + _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl); +#else + timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0); +#endif +} diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c new file mode 100644 index 000000000000..a20d900d85ca --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -0,0 +1,303 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#include +#include +#include + +#include +#include +#include +#include +#include + +static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { + "START", + "STOP", + "SCAN-ACTIVE", + "SCAN-PASSIVE", + "RSSI", + "LINKSPEED", + "RXFILTER-START", + "RXFILTER-STOP", + "RXFILTER-ADD", + "RXFILTER-REMOVE", + "BTCOEXSCAN-START", + "BTCOEXSCAN-STOP", + "BTCOEXMODE", + "SETSUSPENDOPT", + "P2P_DEV_ADDR", + "SETFWPATH", + "SETBAND", + "GETBAND", + "COUNTRY", + "P2P_SET_NOA", + "P2P_GET_NOA", + "P2P_SET_PS", + "SET_AP_WPS_P2P_IE", + "MACADDR", + "BLOCK", + "WFD-ENABLE", + "WFD-DISABLE", + "WFD-SET-TCPPORT", + "WFD-SET-MAXTPUT", + "WFD-SET-DEVTYPE", +}; + +struct android_wifi_priv_cmd { + const char __user *buf; + int used_len; + int total_len; +}; + +/** + * Local (static) functions and variables + */ + +/* Initialize g_wifi_on to 1 so dhd_bus_start will be called for the first + * time (only) in dhd_open, subsequential wifi on will be handled by + * wl_android_wifi_on + */ +static int g_wifi_on = true; + +int rtw_android_cmdstr_to_num(char *cmdstr) +{ + int cmd_num; + for(cmd_num=0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) + if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], + strlen(android_wifi_cmd_str[cmd_num]))) +#else + if(0 == strnicmp(cmdstr, android_wifi_cmd_str[cmd_num], + strlen(android_wifi_cmd_str[cmd_num]))) +#endif + break; + return cmd_num; +} + +static int rtw_android_get_rssi(struct net_device *net, char *command, + int total_len) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); + struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct wlan_network *pcur_network = &pmlmepriv->cur_network; + int bytes_written = 0; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + bytes_written += snprintf(&command[bytes_written], total_len, + "%s rssi %d", + pcur_network->network.Ssid.Ssid, + padapter->recvpriv.rssi); + } + return bytes_written; +} + +static int rtw_android_get_link_speed(struct net_device *net, char *command, + int total_len) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); + int bytes_written; + u16 link_speed; + + link_speed = rtw_get_cur_max_rate(padapter) / 10; + bytes_written = snprintf(command, total_len, "LinkSpeed %d", + link_speed); + return bytes_written; +} + +static int rtw_android_get_macaddr(struct net_device *net, char *command, + int total_len) +{ + int bytes_written; + + bytes_written = snprintf(command, total_len, "Macaddr = %pM", + net->dev_addr); + return bytes_written; +} + +static int android_set_cntry(struct net_device *net, char *command, + int total_len) +{ + struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net); + char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1; + int ret; + + ret = rtw_set_country(adapter, country_code); + return (ret == _SUCCESS) ? 0 : -1; +} + +static int android_get_p2p_addr(struct net_device *net, char *command, + int total_len) +{ + /* We use the same address as our HW MAC address */ + memcpy(command, net->dev_addr, ETH_ALEN); + return ETH_ALEN; +} + +static int rtw_android_set_block(struct net_device *net, char *command, + int total_len) +{ + return 0; +} + +int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) +{ + int ret = 0; + char *command = NULL; + int cmd_num; + int bytes_written = 0; + struct android_wifi_priv_cmd priv_cmd; + + rtw_lock_suspend(); + if (!ifr->ifr_data) { + ret = -EINVAL; + goto exit; + } + if (copy_from_user(&priv_cmd, ifr->ifr_data, + sizeof(struct android_wifi_priv_cmd))) { + ret = -EFAULT; + goto exit; + } + command = kmalloc(priv_cmd.total_len, GFP_KERNEL); + if (!command) { + DBG_88E("%s: failed to allocate memory\n", __func__); + ret = -ENOMEM; + goto exit; + } +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) + if (!access_ok(priv_cmd.buf, priv_cmd.total_len)) { +#else + if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) { +#endif + DBG_88E("%s: failed to access memory\n", __func__); + ret = -EFAULT; + goto exit; + } + if (copy_from_user(command, (char __user *)priv_cmd.buf, + priv_cmd.total_len)) { + ret = -EFAULT; + goto exit; + } + DBG_88E("%s: Android private cmd \"%s\" on %s\n", + __func__, command, ifr->ifr_name); + cmd_num = rtw_android_cmdstr_to_num(command); + switch (cmd_num) { + case ANDROID_WIFI_CMD_START: + goto response; + case ANDROID_WIFI_CMD_SETFWPATH: + goto response; + } + if (!g_wifi_on) { + DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n", + __func__, command, ifr->ifr_name); + ret = 0; + goto exit; + } + switch (cmd_num) { + case ANDROID_WIFI_CMD_STOP: + break; + case ANDROID_WIFI_CMD_SCAN_ACTIVE: + break; + case ANDROID_WIFI_CMD_SCAN_PASSIVE: + break; + case ANDROID_WIFI_CMD_RSSI: + bytes_written = rtw_android_get_rssi(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_LINKSPEED: + bytes_written = rtw_android_get_link_speed(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_MACADDR: + bytes_written = rtw_android_get_macaddr(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_BLOCK: + bytes_written = rtw_android_set_block(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_RXFILTER_START: + break; + case ANDROID_WIFI_CMD_RXFILTER_STOP: + break; + case ANDROID_WIFI_CMD_RXFILTER_ADD: + break; + case ANDROID_WIFI_CMD_RXFILTER_REMOVE: + break; + case ANDROID_WIFI_CMD_BTCOEXSCAN_START: + /* TBD: BTCOEXSCAN-START */ + break; + case ANDROID_WIFI_CMD_BTCOEXSCAN_STOP: + /* TBD: BTCOEXSCAN-STOP */ + break; + case ANDROID_WIFI_CMD_BTCOEXMODE: + break; + case ANDROID_WIFI_CMD_SETSUSPENDOPT: + break; + case ANDROID_WIFI_CMD_SETBAND: + break; + case ANDROID_WIFI_CMD_GETBAND: + break; + case ANDROID_WIFI_CMD_COUNTRY: + bytes_written = android_set_cntry(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_P2P_DEV_ADDR: + bytes_written = android_get_p2p_addr(net, command, + priv_cmd.total_len); + break; + case ANDROID_WIFI_CMD_P2P_SET_NOA: + break; + case ANDROID_WIFI_CMD_P2P_GET_NOA: + break; + case ANDROID_WIFI_CMD_P2P_SET_PS: + break; + default: + DBG_88E("Unknown PRIVATE command %s - ignored\n", command); + snprintf(command, 3, "OK"); + bytes_written = strlen("OK"); + } + +response: + if (bytes_written >= 0) { + if ((bytes_written == 0) && (priv_cmd.total_len > 0)) + command[0] = '\0'; + if (bytes_written >= priv_cmd.total_len) { + DBG_88E("%s: bytes_written = %d\n", __func__, + bytes_written); + bytes_written = priv_cmd.total_len; + } else { + bytes_written++; + } + priv_cmd.used_len = bytes_written; + if (copy_to_user((char __user *)priv_cmd.buf, command, + bytes_written)) { + DBG_88E("%s: failed to copy data to user buffer\n", + __func__); + ret = -EFAULT; + } + } else { + ret = bytes_written; + } +exit: + rtw_unlock_suspend(); + kfree(command); + return ret; +} diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c new file mode 100644 index 000000000000..fd16afa1de33 --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -0,0 +1,863 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _HCI_INTF_C_ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +int ui_pid[3] = {0, 0, 0}; + +static int rtw_suspend(struct usb_interface *intf, pm_message_t message); +static int rtw_resume(struct usb_interface *intf); + +static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid); +static void rtw_dev_remove(struct usb_interface *pusb_intf); + +#define USB_VENDER_ID_REALTEK 0x0bda + +/* DID_USB_v916_20130116 */ +static struct usb_device_id rtw_usb_id_tbl[] = { + /*=== Realtek demoboard ===*/ + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179)}, /* 8188EUS */ + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */ + {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xf179)}, /* 8188FU */ + /*=== Customer ID ===*/ + /****** 8188EUS ********/ + {USB_DEVICE(0x07B8, 0x8179)}, /* Abocom - Abocom */ + {USB_DEVICE(0x0DF6, 0x0076)}, /* Sitecom N150 v2 */ + {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ + {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ + {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ + {USB_DEVICE(0x2001, 0x331B)}, /* D-Link DWA-121 rev B1 */ + {USB_DEVICE(0x056E, 0x4008)}, /* Elecom WDC-150SU2M */ + {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ + {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */ + {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */ + {USB_DEVICE(0x0B05, 0x18F0)}, /* ASUS USB-N10 Nano B1 */ + {USB_DEVICE(0x7392, 0xb811)}, /* Edimax EW-7811Un V2 */ + {} /* Terminating entry */ +}; + +MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl); + +static struct specific_device_id specific_device_id_tbl[] = { + {} /* empty table for now */ +}; + +struct rtw_usb_drv { + struct usb_driver usbdrv; + int drv_registered; + struct mutex hw_init_mutex; +}; + +static struct rtw_usb_drv rtl8188e_usb_drv = { + .usbdrv.name = (char *)"r8188eu", + .usbdrv.probe = rtw_drv_init, + .usbdrv.disconnect = rtw_dev_remove, + .usbdrv.id_table = rtw_usb_id_tbl, + .usbdrv.suspend = rtw_suspend, + .usbdrv.resume = rtw_resume, + .usbdrv.reset_resume = rtw_resume, +}; + +static struct rtw_usb_drv *usb_drv = &rtl8188e_usb_drv; + +static inline int RT_usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN; +} + +static inline int RT_usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT; +} + +static inline int RT_usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_INT; +} + +static inline int RT_usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) +{ + return (epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == USB_ENDPOINT_XFER_BULK; +} + +static inline int RT_usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) +{ + return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_in(epd); +} + +static inline int RT_usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) +{ + return RT_usb_endpoint_xfer_bulk(epd) && RT_usb_endpoint_dir_out(epd); +} + +static inline int usb_endpoint_is_int(const struct usb_endpoint_descriptor *epd) +{ + return RT_usb_endpoint_xfer_int(epd) && RT_usb_endpoint_dir_in(epd); +} + +static inline int RT_usb_endpoint_num(const struct usb_endpoint_descriptor *epd) +{ + return epd->bEndpointAddress & USB_ENDPOINT_NUMBER_MASK; +} + +static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) +{ + u8 rst = _SUCCESS; + + _rtw_mutex_init(&dvobj->usb_vendor_req_mutex); + + dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); + if (dvobj->usb_alloc_vendor_req_buf == NULL) { + DBG_88E("alloc usb_vendor_req_buf failed... /n"); + rst = _FAIL; + goto exit; + } + dvobj->usb_vendor_req_buf = (u8 *)N_BYTE_ALIGMENT((size_t)(dvobj->usb_alloc_vendor_req_buf), ALIGNMENT_UNIT); +exit: + return rst; +} + +static u8 rtw_deinit_intf_priv(struct dvobj_priv *dvobj) +{ + u8 rst = _SUCCESS; + + kfree(dvobj->usb_alloc_vendor_req_buf); + _rtw_mutex_free(&dvobj->usb_vendor_req_mutex); + return rst; +} + +static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) +{ + int i; + int status = _FAIL; + struct dvobj_priv *pdvobjpriv; + struct usb_host_config *phost_conf; + struct usb_config_descriptor *pconf_desc; + struct usb_host_interface *phost_iface; + struct usb_interface_descriptor *piface_desc; + struct usb_endpoint_descriptor *pendp_desc; + struct usb_device *pusbd; + + pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); + if (pdvobjpriv == NULL) + goto exit; + + pdvobjpriv->pusbintf = usb_intf; + pusbd = interface_to_usbdev(usb_intf); + pdvobjpriv->pusbdev = pusbd; + usb_set_intfdata(usb_intf, pdvobjpriv); + + pdvobjpriv->RtNumInPipes = 0; + pdvobjpriv->RtNumOutPipes = 0; + + phost_conf = pusbd->actconfig; + pconf_desc = &phost_conf->desc; + + phost_iface = &usb_intf->altsetting[0]; + piface_desc = &phost_iface->desc; + + pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces; + pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber; + pdvobjpriv->nr_endpoint = piface_desc->bNumEndpoints; + + for (i = 0; i < pdvobjpriv->nr_endpoint; i++) { + int ep_num; + pendp_desc = &phost_iface->endpoint[i].desc; + + ep_num = usb_endpoint_num(pendp_desc); + + if (usb_endpoint_is_bulk_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_int_in(pendp_desc)) { + pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; + pdvobjpriv->RtNumInPipes++; + } else if (usb_endpoint_is_bulk_out(pendp_desc)) { + pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = + ep_num; + pdvobjpriv->RtNumOutPipes++; + } + pdvobjpriv->ep_num[i] = ep_num; + } + + if (pusbd->speed == USB_SPEED_HIGH) { + pdvobjpriv->ishighspeed = true; + DBG_88E("USB_SPEED_HIGH\n"); + } else { + pdvobjpriv->ishighspeed = false; + DBG_88E("NON USB_SPEED_HIGH\n"); + } + + if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) { + RT_TRACE(_module_os_intfs_c_, _drv_err_, + ("\n Can't INIT rtw_init_intf_priv\n")); + goto free_dvobj; + } + + /* 3 misc */ + sema_init(&(pdvobjpriv->usb_suspend_sema), 0); + rtw_reset_continual_urb_error(pdvobjpriv); + + usb_get_dev(pusbd); + + status = _SUCCESS; + +free_dvobj: + if (status != _SUCCESS && pdvobjpriv) { + usb_set_intfdata(usb_intf, NULL); + kfree(pdvobjpriv); + pdvobjpriv = NULL; + } +exit: + return pdvobjpriv; +} + +static void usb_dvobj_deinit(struct usb_interface *usb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf); + + usb_set_intfdata(usb_intf, NULL); + if (dvobj) { + /* Modify condition for 92DU DMDP 2010.11.18, by Thomas */ + if ((dvobj->NumInterfaces != 2 && + dvobj->NumInterfaces != 3) || + (dvobj->InterfaceNumber == 1)) { + if (interface_to_usbdev(usb_intf)->state != + USB_STATE_NOTATTACHED) { + /* If we didn't unplug usb dongle and + * remove/insert module, driver fails + * on sitesurvey for the first time when + * device is up . Reset usb port for sitesurvey + * fail issue. */ + DBG_88E("usb attached..., try to reset usb device\n"); + usb_reset_device(interface_to_usbdev(usb_intf)); + } + } + rtw_deinit_intf_priv(dvobj); + kfree(dvobj); + } + + usb_put_dev(interface_to_usbdev(usb_intf)); + +} + +static void chip_by_usb_id(struct adapter *padapter, + const struct usb_device_id *pdid) +{ + padapter->chip_type = NULL_CHIP_TYPE; + hal_set_hw_type(padapter); +} + +static void usb_intf_start(struct adapter *padapter) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); + + rtw_hal_inirp_init(padapter); + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_start\n")); +} + +static void usb_intf_stop(struct adapter *padapter) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n")); + + /* disabel_hw_interrupt */ + if (!padapter->bSurpriseRemoved) { + /* device still exists, so driver can do i/o operation */ + /* TODO: */ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("SurpriseRemoved == false\n")); + } + + /* cancel in irp */ + rtw_hal_inirp_deinit(padapter); + + /* cancel out irp */ + rtw_write_port_cancel(padapter); + + /* todo:cancel other irps */ + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n")); +} + +static void rtw_dev_unload(struct adapter *padapter) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n")); + + if (padapter->bup) { + DBG_88E("===> rtw_dev_unload\n"); + padapter->bDriverStopped = true; + if (padapter->xmitpriv.ack_tx) + rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP); + /* s3. */ + if (padapter->intf_stop) + padapter->intf_stop(padapter); + /* s4. */ + if (!padapter->pwrctrlpriv.bInternalAutoSuspend) + rtw_stop_drv_threads(padapter); + + /* s5. */ + if (!padapter->bSurpriseRemoved) { + rtw_hal_deinit(padapter); + padapter->bSurpriseRemoved = true; + } + + padapter->bup = false; + } else { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("r871x_dev_unload():padapter->bup == false\n")); + } + + DBG_88E("<=== rtw_dev_unload\n"); + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n")); +} + +static void process_spec_devid(const struct usb_device_id *pdid) +{ + u16 vid, pid; + u32 flags; + int i; + int num = sizeof(specific_device_id_tbl) / + sizeof(struct specific_device_id); + + for (i = 0; i < num; i++) { + vid = specific_device_id_tbl[i].idVendor; + pid = specific_device_id_tbl[i].idProduct; + flags = specific_device_id_tbl[i].flags; + + if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && + (flags&SPEC_DEV_ID_DISABLE_HT)) { + rtw_ht_enable = 0; + rtw_cbw40_enable = 0; + rtw_ampdu_enable = 0; + } + } +} + +int rtw_hw_suspend(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct net_device *pnetdev = padapter->pnetdev; + + + if ((!padapter->bup) || (padapter->bDriverStopped) || + (padapter->bSurpriseRemoved)) { + DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", + padapter->bup, padapter->bDriverStopped, + padapter->bSurpriseRemoved); + goto error_exit; + } + + if (padapter) { /* system suspend */ + LeaveAllPowerSaveMode(padapter); + + DBG_88E("==> rtw_hw_suspend\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + } + + /* s2. */ + rtw_disassoc_cmd(padapter, 500, false); + + /* s2-2. indicate disconnect to os */ + { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); + + rtw_led_control(padapter, LED_CTL_NO_LINK); + + rtw_os_indicate_disconnect(padapter); + + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); + } + } + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + + /* s2-4. */ + rtw_free_network_queue(padapter, true); + rtw_ips_dev_unload(padapter); + pwrpriv->rf_pwrstate = rf_off; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); + } else { + goto error_exit; + } + return 0; + +error_exit: + DBG_88E("%s, failed\n", __func__); + return -1; +} + +int rtw_hw_resume(struct adapter *padapter) +{ + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct net_device *pnetdev = padapter->pnetdev; + + + if (padapter) { /* system resume */ + DBG_88E("==> rtw_hw_resume\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + rtw_reset_drv_sw(padapter); + + if (pm_netdev_open(pnetdev, false) != 0) { + _exit_pwrlock(&pwrpriv->lock); + goto error_exit; + } + + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); + + if (!netif_queue_stopped(pnetdev)) + netif_start_queue(pnetdev); + else + netif_wake_queue(pnetdev); + + pwrpriv->bkeepfwalive = false; + pwrpriv->brfoffbyhw = false; + + pwrpriv->rf_pwrstate = rf_on; + pwrpriv->bips_processing = false; + + _exit_pwrlock(&pwrpriv->lock); + } else { + goto error_exit; + } + + + return 0; +error_exit: + DBG_88E("%s, Open net dev failed\n", __func__); + return -1; +} + +static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + struct net_device *pnetdev = padapter->pnetdev; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + + int ret = 0; + u32 start_time = jiffies; + + + DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); + + if ((!padapter->bup) || (padapter->bDriverStopped) || + (padapter->bSurpriseRemoved)) { + DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", + padapter->bup, padapter->bDriverStopped, + padapter->bSurpriseRemoved); + goto exit; + } + + pwrpriv->bInSuspend = true; + rtw_cancel_all_timer(padapter); + LeaveAllPowerSaveMode(padapter); + + _enter_pwrlock(&pwrpriv->lock); + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + } + + /* s2. */ + rtw_disassoc_cmd(padapter, 0, false); + + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && + check_fwstate(pmlmepriv, _FW_LINKED)) { + DBG_88E("%s:%d %s(%pM), length:%d assoc_ssid.length:%d\n", + __func__, __LINE__, + pmlmepriv->cur_network.network.Ssid.Ssid, + pmlmepriv->cur_network.network.MacAddress, + pmlmepriv->cur_network.network.Ssid.SsidLength, + pmlmepriv->assoc_ssid.SsidLength); + + pmlmepriv->to_roaming = 1; + } + /* s2-2. indicate disconnect to os */ + rtw_indicate_disconnect(padapter); + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); + /* s2-4. */ + rtw_free_network_queue(padapter, true); + + rtw_dev_unload(padapter); + _exit_pwrlock(&pwrpriv->lock); + + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) + rtw_indicate_scan_done(padapter, 1); + + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) + rtw_indicate_disconnect(padapter); + +exit: + DBG_88E("<=== %s return %d.............. in %dms\n", __func__ + , ret, rtw_get_passing_time_ms(start_time)); + + return ret; +} + +static int rtw_resume(struct usb_interface *pusb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + int ret = 0; + + if (pwrpriv->bInternalAutoSuspend) + ret = rtw_resume_process(padapter); + else + ret = rtw_resume_process(padapter); + return ret; +} + +int rtw_resume_process(struct adapter *padapter) +{ + struct net_device *pnetdev; + struct pwrctrl_priv *pwrpriv = NULL; + int ret = -1; + u32 start_time = jiffies; + + DBG_88E("==> %s (%s:%d)\n", __func__, current->comm, current->pid); + + if (padapter) { + pnetdev = padapter->pnetdev; + pwrpriv = &padapter->pwrctrlpriv; + } else { + goto exit; + } + + _enter_pwrlock(&pwrpriv->lock); + rtw_reset_drv_sw(padapter); + if (pwrpriv) + pwrpriv->bkeepfwalive = false; + + DBG_88E("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); + if (pm_netdev_open(pnetdev, true) != 0) + goto exit; + + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); + + _exit_pwrlock(&pwrpriv->lock); + + if (padapter->pid[1] != 0) { + DBG_88E("pid[1]:%d\n", padapter->pid[1]); + rtw_signal_process(padapter->pid[1], SIGUSR2); + } + + rtw_roaming(padapter, NULL); + + ret = 0; +exit: + if (pwrpriv) + pwrpriv->bInSuspend = false; + DBG_88E("<=== %s return %d.............. in %dms\n", __func__, + ret, rtw_get_passing_time_ms(start_time)); + + + return ret; +} + +/* + * drv_init() - a device potentially for us + * + * notes: drv_init() is called when the bus driver has located + * a card for us to support. + * We accept the new device by returning 0. + */ + +static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, + struct usb_interface *pusb_intf, const struct usb_device_id *pdid) +{ + struct adapter *padapter = NULL; + struct net_device *pnetdev = NULL; + int status = _FAIL; + + padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter)); + if (padapter == NULL) + goto exit; + padapter->dvobj = dvobj; + dvobj->if1 = padapter; + + padapter->bDriverStopped = true; + + padapter->hw_init_mutex = &usb_drv->hw_init_mutex; + + /* step 1-1., decide the chip_type via vid/pid */ + padapter->interface_type = RTW_USB; + chip_by_usb_id(padapter, pdid); + + if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) + goto free_adapter; + + pnetdev = rtw_init_netdev(padapter); + if (pnetdev == NULL) + goto handle_dualmac; + SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); + padapter = rtw_netdev_priv(pnetdev); + + /* step 2. hook HalFunc, allocate HalData */ + hal_set_hal_ops(padapter); + + padapter->intf_start = &usb_intf_start; + padapter->intf_stop = &usb_intf_stop; + + /* step init_io_priv */ + rtw_init_io_priv(padapter, usb_set_intf_ops); + + /* step read_chip_version */ + rtw_hal_read_chip_version(padapter); + + /* step usb endpoint mapping */ + rtw_hal_chip_configure(padapter); + + /* step read efuse/eeprom data and get mac_addr */ + rtw_hal_read_chip_info(padapter); + + /* step 5. */ + if (rtw_init_drv_sw(padapter) == _FAIL) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("Initialize driver software resource Failed!\n")); + goto free_hal_data; + } + +#ifdef CONFIG_PM + if (padapter->pwrctrlpriv.bSupportRemoteWakeup) { + dvobj->pusbdev->do_remote_wakeup = 1; + pusb_intf->needs_remote_wakeup = 1; + device_init_wakeup(&pusb_intf->dev, 1); + DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n"); + DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n", + device_may_wakeup(&pusb_intf->dev)); + } +#endif + + /* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto + * suspend influence */ + if (usb_autopm_get_interface(pusb_intf) < 0) + DBG_88E("can't get autopm:\n"); + + /* alloc dev name after read efuse. */ + rtw_init_netdev_name(pnetdev, padapter->registrypriv.ifname); + rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); +#ifdef CONFIG_88EU_P2P + rtw_init_wifidirect_addrs(padapter, padapter->eeprompriv.mac_addr, + padapter->eeprompriv.mac_addr); +#endif + memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); + DBG_88E("MAC Address from pnetdev->dev_addr = %pM\n", + pnetdev->dev_addr); + + /* step 6. Tell the network stack we exist */ + if (register_netdev(pnetdev) != 0) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n")); + goto free_hal_data; + } + + DBG_88E("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n" + , padapter->bDriverStopped + , padapter->bSurpriseRemoved + , padapter->bup + , padapter->hw_init_completed + ); + + status = _SUCCESS; + +free_hal_data: + if (status != _SUCCESS) + kfree(padapter->HalData); +handle_dualmac: + if (status != _SUCCESS) + rtw_handle_dualmac(padapter, 0); +free_adapter: + if (status != _SUCCESS) { + if (pnetdev) + rtw_free_netdev(pnetdev); + else if (padapter) + rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + padapter = NULL; + } +exit: + return padapter; +} + +static void rtw_usb_if1_deinit(struct adapter *if1) +{ + struct net_device *pnetdev = if1->pnetdev; + struct mlme_priv *pmlmepriv = &if1->mlmepriv; + + if (check_fwstate(pmlmepriv, _FW_LINKED)) + rtw_disassoc_cmd(if1, 0, false); + +#ifdef CONFIG_88EU_AP_MODE + free_mlme_ap_info(if1); +#endif + + if (if1->DriverState != DRIVER_DISAPPEAR) { + if (pnetdev) { + /* will call netdev_close() */ + unregister_netdev(pnetdev); + rtw_proc_remove_one(pnetdev); + } + } + rtw_cancel_all_timer(if1); + + rtw_dev_unload(if1); + DBG_88E("+r871xu_dev_remove, hw_init_completed=%d\n", + if1->hw_init_completed); + rtw_handle_dualmac(if1, 0); + rtw_free_drv_sw(if1); + if (pnetdev) + rtw_free_netdev(pnetdev); +} + +static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) +{ + struct adapter *if1 = NULL; + int status; + struct dvobj_priv *dvobj; + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); + + /* step 0. */ + process_spec_devid(pdid); + + /* Initialize dvobj_priv */ + dvobj = usb_dvobj_init(pusb_intf); + if (dvobj == NULL) { + RT_TRACE(_module_hci_intfs_c_, _drv_err_, + ("initialize device object priv Failed!\n")); + goto exit; + } + + if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid); + if (if1 == NULL) { + DBG_88E("rtw_init_primarystruct adapter Failed!\n"); + goto free_dvobj; + } + + if (ui_pid[1] != 0) { + DBG_88E("ui_pid[1]:%d\n", ui_pid[1]); + rtw_signal_process(ui_pid[1], SIGUSR2); + } + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n")); + + status = _SUCCESS; + + if (status != _SUCCESS && if1) + rtw_usb_if1_deinit(if1); +free_dvobj: + if (status != _SUCCESS) + usb_dvobj_deinit(pusb_intf); +exit: + return status == _SUCCESS ? 0 : -ENODEV; +} + +/* + * dev_remove() - our device is being removed +*/ +/* rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove() => how to recognize both */ +static void rtw_dev_remove(struct usb_interface *pusb_intf) +{ + struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); + struct adapter *padapter = dvobj->if1; + + DBG_88E("+rtw_dev_remove\n"); + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n")); + + if (usb_drv->drv_registered) + padapter->bSurpriseRemoved = true; + + rtw_pm_set_ips(padapter, IPS_NONE); + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); + + LeaveAllPowerSaveMode(padapter); + + rtw_usb_if1_deinit(padapter); + + usb_dvobj_deinit(pusb_intf); + + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); + DBG_88E("-r871xu_dev_remove, done\n"); + + return; +} + +static int __init rtw_drv_entry(void) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n")); + + DBG_88E(DRV_NAME " driver version=%s\n", DRIVERVERSION); + + rtw_suspend_lock_init(); + + _rtw_mutex_init(&usb_drv->hw_init_mutex); + + usb_drv->drv_registered = true; + return usb_register(&usb_drv->usbdrv); +} + +static void __exit rtw_drv_halt(void) +{ + RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n")); + DBG_88E("+rtw_drv_halt\n"); + + rtw_suspend_lock_uninit(); + + usb_drv->drv_registered = false; + usb_deregister(&usb_drv->usbdrv); + + _rtw_mutex_free(&usb_drv->hw_init_mutex); + DBG_88E("-rtw_drv_halt\n"); +} + +module_init(rtw_drv_entry); +module_exit(rtw_drv_halt); diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c new file mode 100644 index 000000000000..9cce79d412b9 --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -0,0 +1,283 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + ******************************************************************************/ +#define _USB_OPS_LINUX_C_ + +#include +#include +#include + +unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) +{ + unsigned int pipe = 0, ep_num = 0; + struct usb_device *pusbd = pdvobj->pusbdev; + + if (addr == RECV_BULK_IN_ADDR) { + pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); + } else if (addr == RECV_INT_IN_ADDR) { + pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]); + } else if (addr < HW_QUEUE_ENTRY) { + ep_num = pdvobj->Queue2Pipe[addr]; + pipe = usb_sndbulkpipe(pusbd, ep_num); + } + + return pipe; +} + +struct zero_bulkout_context { + void *pbuf; + void *purb; + void *pirp; + void *padapter; +}; + +void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) +{ +} + +void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +{ +} + +void usb_read_port_cancel(struct intf_hdl *pintfhdl) +{ + int i; + struct recv_buf *precvbuf; + struct adapter *padapter = pintfhdl->padapter; + precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf; + + DBG_88E("%s\n", __func__); + + padapter->bReadPortCancel = true; + + for (i = 0; i < NR_RECVBUFF; i++) { + precvbuf->reuse = true; + if (precvbuf->purb) + usb_kill_urb(precvbuf->purb); + precvbuf++; + } +} + +static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) +{ + struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; + struct adapter *padapter = pxmitbuf->padapter; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct hal_data_8188e *haldata; + + switch (pxmitbuf->flags) { + case VO_QUEUE_INX: + pxmitpriv->voq_cnt--; + break; + case VI_QUEUE_INX: + pxmitpriv->viq_cnt--; + break; + case BE_QUEUE_INX: + pxmitpriv->beq_cnt--; + break; + case BK_QUEUE_INX: + pxmitpriv->bkq_cnt--; + break; + case HIGH_QUEUE_INX: +#ifdef CONFIG_88EU_AP_MODE + rtw_chk_hi_queue_cmd(padapter); +#endif + break; + default: + break; + } + + if (padapter->bSurpriseRemoved || padapter->bDriverStopped || + padapter->bWritePortCancel) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", + padapter->bDriverStopped, padapter->bSurpriseRemoved)); + DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n", + __func__, padapter->bDriverStopped, + padapter->bSurpriseRemoved, padapter->bReadPortCancel, + pxmitbuf->ext_tag); + + goto check_completion; + } + + if (purb->status) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete : purb->status(%d) != 0\n", purb->status)); + DBG_88E("###=> urb_write_port_complete status(%d)\n", purb->status); + if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { + sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); + } else if (purb->status == -EINPROGRESS) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: EINPROGESS\n")); + goto check_completion; + } else if (purb->status == -ENOENT) { + DBG_88E("%s: -ENOENT\n", __func__); + goto check_completion; + } else if (purb->status == -ECONNRESET) { + DBG_88E("%s: -ECONNRESET\n", __func__); + goto check_completion; + } else if (purb->status == -ESHUTDOWN) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: ESHUTDOWN\n")); + padapter->bDriverStopped = true; + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bDriverStopped = true\n")); + goto check_completion; + } else { + padapter->bSurpriseRemoved = true; + DBG_88E("bSurpriseRemoved = true\n"); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bSurpriseRemoved = true\n")); + + goto check_completion; + } + } + + haldata = GET_HAL_DATA(padapter); + haldata->srestpriv.last_tx_complete_time = jiffies; + +check_completion: + rtw_sctx_done_err(&pxmitbuf->sctx, + purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : + RTW_SCTX_DONE_SUCCESS); + + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); + +} + +u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) +{ + unsigned long irqL; + unsigned int pipe; + int status; + u32 ret = _FAIL; + struct urb *purb = NULL; + struct adapter *padapter = (struct adapter *)pintfhdl->padapter; + struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem; + struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; + struct usb_device *pusbd = pdvobj->pusbdev; + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); + + if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || + (padapter->pwrctrlpriv.pnp_bstop_trx)) { + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, + ("usb_write_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); + goto exit; + } + + spin_lock_irqsave(&pxmitpriv->lock, irqL); + + switch (addr) { + case VO_QUEUE_INX: + pxmitpriv->voq_cnt++; + pxmitbuf->flags = VO_QUEUE_INX; + break; + case VI_QUEUE_INX: + pxmitpriv->viq_cnt++; + pxmitbuf->flags = VI_QUEUE_INX; + break; + case BE_QUEUE_INX: + pxmitpriv->beq_cnt++; + pxmitbuf->flags = BE_QUEUE_INX; + break; + case BK_QUEUE_INX: + pxmitpriv->bkq_cnt++; + pxmitbuf->flags = BK_QUEUE_INX; + break; + case HIGH_QUEUE_INX: + pxmitbuf->flags = HIGH_QUEUE_INX; + break; + default: + pxmitbuf->flags = MGT_QUEUE_INX; + break; + } + + spin_unlock_irqrestore(&pxmitpriv->lock, irqL); + + purb = pxmitbuf->pxmit_urb[0]; + + /* translate DMA FIFO addr to pipehandle */ + pipe = ffaddr2pipehdl(pdvobj, addr); + + usb_fill_bulk_urb(purb, pusbd, pipe, + pxmitframe->buf_addr, /* pxmitbuf->pbuf */ + cnt, + usb_write_port_complete, + pxmitbuf);/* context is pxmitbuf */ + + status = usb_submit_urb(purb, GFP_ATOMIC); + if (!status) { + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + + haldata->srestpriv.last_tx_time = jiffies; + } else { + rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); + DBG_88E("usb_write_port, status =%d\n", status); + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port(): usb_submit_urb, status =%x\n", status)); + + switch (status) { + case -ENODEV: + padapter->bDriverStopped = true; + break; + default: + break; + } + goto exit; + } + + ret = _SUCCESS; + +/* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */ + + RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port\n")); + +exit: + if (ret != _SUCCESS) + rtw_free_xmitbuf(pxmitpriv, pxmitbuf); + + return ret; +} + +void usb_write_port_cancel(struct intf_hdl *pintfhdl) +{ + int i, j; + struct adapter *padapter = pintfhdl->padapter; + struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf; + + DBG_88E("%s\n", __func__); + + padapter->bWritePortCancel = true; + + for (i = 0; i < NR_XMITBUFF; i++) { + for (j = 0; j < 8; j++) { + if (pxmitbuf->pxmit_urb[j]) + usb_kill_urb(pxmitbuf->pxmit_urb[j]); + } + pxmitbuf++; + } + + pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf; + for (i = 0; i < NR_XMIT_EXTBUFF; i++) { + for (j = 0; j < 8; j++) { + if (pxmitbuf->pxmit_urb[j]) + usb_kill_urb(pxmitbuf->pxmit_urb[j]); + } + pxmitbuf++; + } +} diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c new file mode 100644 index 000000000000..c6c5b2aabefb --- /dev/null +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -0,0 +1,282 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#define _XMIT_OSDEP_C_ + +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +uint rtw_remainder_len(struct pkt_file *pfile) +{ + return pfile->buf_len - ((size_t)(pfile->cur_addr) - + (size_t)(pfile->buf_start)); +} + +void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) +{ + + if (!pktptr) { + pr_err("8188eu: pktptr is NULL\n"); + return; + } + if (!pfile) { + pr_err("8188eu: pfile is NULL\n"); + return; + } + pfile->pkt = pktptr; + pfile->cur_addr = pktptr->data; + pfile->buf_start = pktptr->data; + pfile->pkt_len = pktptr->len; + pfile->buf_len = pktptr->len; + + pfile->cur_buffer = pfile->buf_start; + +} + +uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) +{ + uint len = 0; + + len = rtw_remainder_len(pfile); + len = (rlen > len) ? len : rlen; + + if (rmem) + skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, len); + + pfile->cur_addr += len; + pfile->pkt_len -= len; + + return len; +} + +int rtw_endofpktfile(struct pkt_file *pfile) +{ + + if (pfile->pkt_len == 0) { + + return true; + } + + return false; +} + +void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib) +{ +} + +int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz) +{ + int i; + + pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); + if (pxmitbuf->pallocated_buf == NULL) + return _FAIL; + + pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); + pxmitbuf->dma_transfer_addr = 0; + + for (i = 0; i < 8; i++) { + pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); + if (pxmitbuf->pxmit_urb[i] == NULL) { + DBG_88E("pxmitbuf->pxmit_urb[i]==NULL"); + return _FAIL; + } + } + return _SUCCESS; +} + +void rtw_os_xmit_resource_free(struct adapter *padapter, + struct xmit_buf *pxmitbuf, u32 free_sz) +{ + int i; + + for (i = 0; i < 8; i++) + usb_free_urb(pxmitbuf->pxmit_urb[i]); + + kfree(pxmitbuf->pallocated_buf); +} + +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5) + +void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) +{ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) + u16 queue; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + + queue = skb_get_queue_mapping(pkt); + if (padapter->registrypriv.wifi_spec) { + if (__netif_subqueue_stopped(padapter->pnetdev, queue) && + (pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD)) + netif_wake_subqueue(padapter->pnetdev, queue); + } else { + if (__netif_subqueue_stopped(padapter->pnetdev, queue)) + netif_wake_subqueue(padapter->pnetdev, queue); + } +#else + if (netif_queue_stopped(padapter->pnetdev)) + netif_wake_queue(padapter->pnetdev); +#endif + + dev_kfree_skb_any(pkt); +} + +void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe) +{ + if (pxframe->pkt) + rtw_os_pkt_complete(padapter, pxframe->pkt); + pxframe->pkt = NULL; +} + +void rtw_os_xmit_schedule(struct adapter *padapter) +{ + struct xmit_priv *pxmitpriv; + + if (!padapter) + return; + + pxmitpriv = &padapter->xmitpriv; + + spin_lock_bh(&pxmitpriv->lock); + + if (rtw_txframes_pending(padapter)) + tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); + + spin_unlock_bh(&pxmitpriv->lock); +} + +static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt) +{ + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + u16 queue; + + queue = skb_get_queue_mapping(pkt); + if (padapter->registrypriv.wifi_spec) { + /* No free space for Tx, tx_worker is too slow */ + if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) + netif_stop_subqueue(padapter->pnetdev, queue); + } else { + if (pxmitpriv->free_xmitframe_cnt <= 4) { + if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue))) + netif_stop_subqueue(padapter->pnetdev, queue); + } + } +} + +static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) +{ + struct sta_priv *pstapriv = &padapter->stapriv; + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct list_head *phead, *plist; + struct sk_buff *newskb; + struct sta_info *psta = NULL; + s32 res; + + spin_lock_bh(&pstapriv->asoc_list_lock); + phead = &pstapriv->asoc_list; + plist = phead->next; + + /* free sta asoc_queue */ + while (phead != plist) { + psta = container_of(plist, struct sta_info, asoc_list); + + plist = plist->next; + + /* avoid come from STA1 and send back STA1 */ + if (!memcmp(psta->hwaddr, &skb->data[6], 6)) + continue; + + newskb = skb_copy(skb, GFP_ATOMIC); + + if (newskb) { + memcpy(newskb->data, psta->hwaddr, 6); + res = rtw_xmit(padapter, &newskb); + if (res < 0) { + DBG_88E("%s()-%d: rtw_xmit() return error!\n", __func__, __LINE__); + pxmitpriv->tx_drop++; + dev_kfree_skb_any(newskb); + } else { + pxmitpriv->tx_pkts++; + } + } else { + DBG_88E("%s-%d: skb_copy() failed!\n", __func__, __LINE__); + pxmitpriv->tx_drop++; + + spin_unlock_bh(&pstapriv->asoc_list_lock); + return false; /* Caller shall tx this multicast frame via normal way. */ + } + } + + spin_unlock_bh(&pstapriv->asoc_list_lock); + dev_kfree_skb_any(skb); + return true; +} + +int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) +{ + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + s32 res = 0; + + RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); + + if (rtw_if_up(padapter) == false) { + RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit_entry: rtw_if_up fail\n")); + goto drop_packet; + } + + rtw_check_xmit_resource(padapter, pkt); + + if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) && + (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) && + (padapter->registrypriv.wifi_spec == 0)) { + if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) { + res = rtw_mlcst2unicst(padapter, pkt); + if (res) + goto exit; + } + } + + res = rtw_xmit(padapter, &pkt); + if (res < 0) + goto drop_packet; + + pxmitpriv->tx_pkts++; + RT_TRACE(_module_xmit_osdep_c_, _drv_info_, ("rtw_xmit_entry: tx_pkts=%d\n", (u32)pxmitpriv->tx_pkts)); + goto exit; + +drop_packet: + pxmitpriv->tx_drop++; + dev_kfree_skb_any(pkt); + RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop=%d\n", (u32)pxmitpriv->tx_drop)); + +exit: + + return 0; +} -- cgit v1.2.3 From 7884fc0a1473c2721f496f1d1ddc9d2c91aefa53 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 28 Jul 2021 00:22:17 +0100 Subject: staging: r8188eu: introduce new include dir for RTL8188eu driver This patchset is split in order to keep the file sizes down. This include directory is part of the newer/better driver from GitHub modified by Larry Finger. Import this as the basis for all future work going forward. Suggested-by: Larry Finger Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210727232219.2948-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/Hal8188EPhyCfg.h | 269 ++++ drivers/staging/r8188eu/include/Hal8188EPhyReg.h | 1088 +++++++++++++++ drivers/staging/r8188eu/include/Hal8188EPwrSeq.h | 173 +++ .../staging/r8188eu/include/Hal8188ERateAdaptive.h | 75 + drivers/staging/r8188eu/include/Hal8188EReg.h | 44 + drivers/staging/r8188eu/include/HalHWImg8188E_BB.h | 44 + drivers/staging/r8188eu/include/HalHWImg8188E_FW.h | 33 + .../staging/r8188eu/include/HalHWImg8188E_MAC.h | 30 + drivers/staging/r8188eu/include/HalHWImg8188E_RF.h | 30 + drivers/staging/r8188eu/include/HalPhyRf.h | 30 + drivers/staging/r8188eu/include/HalPhyRf_8188e.h | 58 + drivers/staging/r8188eu/include/HalPwrSeqCmd.h | 126 ++ drivers/staging/r8188eu/include/HalVerDef.h | 166 +++ drivers/staging/r8188eu/include/autoconf.h | 43 + drivers/staging/r8188eu/include/basic_types.h | 184 +++ drivers/staging/r8188eu/include/cmd_osdep.h | 32 + drivers/staging/r8188eu/include/drv_types.h | 346 +++++ drivers/staging/r8188eu/include/drv_types_linux.h | 23 + drivers/staging/r8188eu/include/ethernet.h | 41 + drivers/staging/r8188eu/include/h2clbk.h | 32 + drivers/staging/r8188eu/include/hal_com.h | 172 +++ drivers/staging/r8188eu/include/hal_intf.h | 430 ++++++ drivers/staging/r8188eu/include/ieee80211.h | 1261 +++++++++++++++++ drivers/staging/r8188eu/include/ieee80211_ext.h | 287 ++++ drivers/staging/r8188eu/include/if_ether.h | 111 ++ drivers/staging/r8188eu/include/ioctl_cfg80211.h | 107 ++ drivers/staging/r8188eu/include/ip.h | 125 ++ drivers/staging/r8188eu/include/mlme_osdep.h | 35 + drivers/staging/r8188eu/include/mp_custom_oid.h | 349 +++++ drivers/staging/r8188eu/include/nic_spec.h | 41 + drivers/staging/r8188eu/include/odm.h | 1182 ++++++++++++++++ drivers/staging/r8188eu/include/odm_HWConfig.h | 133 ++ drivers/staging/r8188eu/include/odm_RTL8188E.h | 56 + .../staging/r8188eu/include/odm_RegConfig8188E.h | 43 + .../staging/r8188eu/include/odm_RegDefine11AC.h | 46 + drivers/staging/r8188eu/include/odm_RegDefine11N.h | 160 +++ drivers/staging/r8188eu/include/odm_debug.h | 143 ++ drivers/staging/r8188eu/include/odm_interface.h | 164 +++ drivers/staging/r8188eu/include/odm_precomp.h | 103 ++ drivers/staging/r8188eu/include/odm_reg.h | 116 ++ drivers/staging/r8188eu/include/odm_types.h | 61 + drivers/staging/r8188eu/include/osdep_intf.h | 83 ++ drivers/staging/r8188eu/include/osdep_service.h | 489 +++++++ drivers/staging/r8188eu/include/recv_osdep.h | 54 + drivers/staging/r8188eu/include/rtl8188e_cmd.h | 122 ++ drivers/staging/r8188eu/include/rtl8188e_dm.h | 62 + drivers/staging/r8188eu/include/rtl8188e_hal.h | 471 +++++++ drivers/staging/r8188eu/include/rtl8188e_led.h | 34 + drivers/staging/r8188eu/include/rtl8188e_recv.h | 69 + drivers/staging/r8188eu/include/rtl8188e_rf.h | 35 + drivers/staging/r8188eu/include/rtl8188e_spec.h | 1438 ++++++++++++++++++++ drivers/staging/r8188eu/include/rtl8188e_sreset.h | 31 + drivers/staging/r8188eu/include/rtl8188e_xmit.h | 177 +++ drivers/staging/r8188eu/include/rtw_android.h | 64 + drivers/staging/r8188eu/include/rtw_ap.h | 67 + drivers/staging/r8188eu/include/rtw_br_ext.h | 66 + drivers/staging/r8188eu/include/rtw_cmd.h | 991 ++++++++++++++ drivers/staging/r8188eu/include/rtw_debug.h | 274 ++++ drivers/staging/r8188eu/include/rtw_eeprom.h | 130 ++ drivers/staging/r8188eu/include/rtw_efuse.h | 150 ++ drivers/staging/r8188eu/include/rtw_event.h | 113 ++ drivers/staging/r8188eu/include/rtw_ht.h | 44 + drivers/staging/r8188eu/include/rtw_io.h | 387 ++++++ drivers/staging/r8188eu/include/rtw_ioctl.h | 120 ++ drivers/staging/r8188eu/include/rtw_ioctl_rtl.h | 79 ++ drivers/staging/r8188eu/include/rtw_ioctl_set.h | 49 + drivers/staging/r8188eu/include/rtw_iol.h | 84 ++ drivers/staging/r8188eu/include/rtw_led.h | 201 +++ drivers/staging/r8188eu/include/rtw_mlme.h | 649 +++++++++ drivers/staging/r8188eu/include/rtw_mlme_ext.h | 874 ++++++++++++ drivers/staging/r8188eu/include/rtw_mp.h | 492 +++++++ drivers/staging/r8188eu/include/rtw_mp_ioctl.h | 339 +++++ .../staging/r8188eu/include/rtw_mp_phy_regdef.h | 1079 +++++++++++++++ drivers/staging/r8188eu/include/rtw_p2p.h | 135 ++ drivers/staging/r8188eu/include/rtw_pwrctrl.h | 282 ++++ drivers/staging/r8188eu/include/rtw_qos.h | 30 + drivers/staging/r8188eu/include/rtw_recv.h | 473 +++++++ drivers/staging/r8188eu/include/rtw_rf.h | 145 ++ drivers/staging/r8188eu/include/rtw_security.h | 382 ++++++ drivers/staging/r8188eu/include/rtw_sreset.h | 50 + drivers/staging/r8188eu/include/rtw_version.h | 1 + drivers/staging/r8188eu/include/rtw_xmit.h | 383 ++++++ drivers/staging/r8188eu/include/sta_info.h | 384 ++++++ drivers/staging/r8188eu/include/usb_hal.h | 26 + drivers/staging/r8188eu/include/usb_ops.h | 115 ++ drivers/staging/r8188eu/include/usb_ops_linux.h | 55 + drivers/staging/r8188eu/include/usb_osintf.h | 45 + drivers/staging/r8188eu/include/usb_vendor_req.h | 51 + drivers/staging/r8188eu/include/wifi.h | 1105 +++++++++++++++ drivers/staging/r8188eu/include/wlan_bssdef.h | 343 +++++ drivers/staging/r8188eu/include/xmit_osdep.h | 67 + 91 files changed, 21381 insertions(+) create mode 100644 drivers/staging/r8188eu/include/Hal8188EPhyCfg.h create mode 100644 drivers/staging/r8188eu/include/Hal8188EPhyReg.h create mode 100644 drivers/staging/r8188eu/include/Hal8188EPwrSeq.h create mode 100644 drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h create mode 100644 drivers/staging/r8188eu/include/Hal8188EReg.h create mode 100644 drivers/staging/r8188eu/include/HalHWImg8188E_BB.h create mode 100644 drivers/staging/r8188eu/include/HalHWImg8188E_FW.h create mode 100644 drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h create mode 100644 drivers/staging/r8188eu/include/HalHWImg8188E_RF.h create mode 100644 drivers/staging/r8188eu/include/HalPhyRf.h create mode 100644 drivers/staging/r8188eu/include/HalPhyRf_8188e.h create mode 100644 drivers/staging/r8188eu/include/HalPwrSeqCmd.h create mode 100644 drivers/staging/r8188eu/include/HalVerDef.h create mode 100644 drivers/staging/r8188eu/include/autoconf.h create mode 100644 drivers/staging/r8188eu/include/basic_types.h create mode 100644 drivers/staging/r8188eu/include/cmd_osdep.h create mode 100644 drivers/staging/r8188eu/include/drv_types.h create mode 100644 drivers/staging/r8188eu/include/drv_types_linux.h create mode 100644 drivers/staging/r8188eu/include/ethernet.h create mode 100644 drivers/staging/r8188eu/include/h2clbk.h create mode 100644 drivers/staging/r8188eu/include/hal_com.h create mode 100644 drivers/staging/r8188eu/include/hal_intf.h create mode 100644 drivers/staging/r8188eu/include/ieee80211.h create mode 100644 drivers/staging/r8188eu/include/ieee80211_ext.h create mode 100644 drivers/staging/r8188eu/include/if_ether.h create mode 100644 drivers/staging/r8188eu/include/ioctl_cfg80211.h create mode 100644 drivers/staging/r8188eu/include/ip.h create mode 100644 drivers/staging/r8188eu/include/mlme_osdep.h create mode 100644 drivers/staging/r8188eu/include/mp_custom_oid.h create mode 100644 drivers/staging/r8188eu/include/nic_spec.h create mode 100644 drivers/staging/r8188eu/include/odm.h create mode 100644 drivers/staging/r8188eu/include/odm_HWConfig.h create mode 100644 drivers/staging/r8188eu/include/odm_RTL8188E.h create mode 100644 drivers/staging/r8188eu/include/odm_RegConfig8188E.h create mode 100644 drivers/staging/r8188eu/include/odm_RegDefine11AC.h create mode 100644 drivers/staging/r8188eu/include/odm_RegDefine11N.h create mode 100644 drivers/staging/r8188eu/include/odm_debug.h create mode 100644 drivers/staging/r8188eu/include/odm_interface.h create mode 100644 drivers/staging/r8188eu/include/odm_precomp.h create mode 100644 drivers/staging/r8188eu/include/odm_reg.h create mode 100644 drivers/staging/r8188eu/include/odm_types.h create mode 100644 drivers/staging/r8188eu/include/osdep_intf.h create mode 100644 drivers/staging/r8188eu/include/osdep_service.h create mode 100644 drivers/staging/r8188eu/include/recv_osdep.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_cmd.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_dm.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_hal.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_led.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_recv.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_rf.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_spec.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_sreset.h create mode 100644 drivers/staging/r8188eu/include/rtl8188e_xmit.h create mode 100644 drivers/staging/r8188eu/include/rtw_android.h create mode 100644 drivers/staging/r8188eu/include/rtw_ap.h create mode 100644 drivers/staging/r8188eu/include/rtw_br_ext.h create mode 100644 drivers/staging/r8188eu/include/rtw_cmd.h create mode 100644 drivers/staging/r8188eu/include/rtw_debug.h create mode 100644 drivers/staging/r8188eu/include/rtw_eeprom.h create mode 100644 drivers/staging/r8188eu/include/rtw_efuse.h create mode 100644 drivers/staging/r8188eu/include/rtw_event.h create mode 100644 drivers/staging/r8188eu/include/rtw_ht.h create mode 100644 drivers/staging/r8188eu/include/rtw_io.h create mode 100644 drivers/staging/r8188eu/include/rtw_ioctl.h create mode 100644 drivers/staging/r8188eu/include/rtw_ioctl_rtl.h create mode 100644 drivers/staging/r8188eu/include/rtw_ioctl_set.h create mode 100644 drivers/staging/r8188eu/include/rtw_iol.h create mode 100644 drivers/staging/r8188eu/include/rtw_led.h create mode 100644 drivers/staging/r8188eu/include/rtw_mlme.h create mode 100644 drivers/staging/r8188eu/include/rtw_mlme_ext.h create mode 100644 drivers/staging/r8188eu/include/rtw_mp.h create mode 100644 drivers/staging/r8188eu/include/rtw_mp_ioctl.h create mode 100644 drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h create mode 100644 drivers/staging/r8188eu/include/rtw_p2p.h create mode 100644 drivers/staging/r8188eu/include/rtw_pwrctrl.h create mode 100644 drivers/staging/r8188eu/include/rtw_qos.h create mode 100644 drivers/staging/r8188eu/include/rtw_recv.h create mode 100644 drivers/staging/r8188eu/include/rtw_rf.h create mode 100644 drivers/staging/r8188eu/include/rtw_security.h create mode 100644 drivers/staging/r8188eu/include/rtw_sreset.h create mode 100644 drivers/staging/r8188eu/include/rtw_version.h create mode 100644 drivers/staging/r8188eu/include/rtw_xmit.h create mode 100644 drivers/staging/r8188eu/include/sta_info.h create mode 100644 drivers/staging/r8188eu/include/usb_hal.h create mode 100644 drivers/staging/r8188eu/include/usb_ops.h create mode 100644 drivers/staging/r8188eu/include/usb_ops_linux.h create mode 100644 drivers/staging/r8188eu/include/usb_osintf.h create mode 100644 drivers/staging/r8188eu/include/usb_vendor_req.h create mode 100644 drivers/staging/r8188eu/include/wifi.h create mode 100644 drivers/staging/r8188eu/include/wlan_bssdef.h create mode 100644 drivers/staging/r8188eu/include/xmit_osdep.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h new file mode 100644 index 000000000000..6fb059576a67 --- /dev/null +++ b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h @@ -0,0 +1,269 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __INC_HAL8188EPHYCFG_H__ +#define __INC_HAL8188EPHYCFG_H__ + +/*--------------------------Define Parameters-------------------------------*/ +#define LOOP_LIMIT 5 +#define MAX_STALL_TIME 50 /* us */ +#define AntennaDiversityValue 0x80 +#define MAX_TXPWR_IDX_NMODE_92S 63 +#define Reset_Cnt_Limit 3 + +#define IQK_MAC_REG_NUM 4 +#define IQK_ADDA_REG_NUM 16 +#define IQK_BB_REG_NUM 9 +#define HP_THERMAL_NUM 8 + +#define MAX_AGGR_NUM 0x07 + +/*--------------------------Define Parameters-------------------------------*/ + +/*------------------------------Define structure----------------------------*/ +enum sw_chnl_cmd_id { + CmdID_End, + CmdID_SetTxPowerLevel, + CmdID_BBRegWrite10, + CmdID_WritePortUlong, + CmdID_WritePortUshort, + CmdID_WritePortUchar, + CmdID_RF_WriteReg, +}; + +/* 1. Switch channel related */ +struct sw_chnl_cmd { + enum sw_chnl_cmd_id CmdID; + u32 Para1; + u32 Para2; + u32 msDelay; +}; + +enum hw90_block { + HW90_BLOCK_MAC = 0, + HW90_BLOCK_PHY0 = 1, + HW90_BLOCK_PHY1 = 2, + HW90_BLOCK_RF = 3, + HW90_BLOCK_MAXIMUM = 4, /* Never use this */ +}; + +enum rf_radio_path { + RF_PATH_A = 0, /* Radio Path A */ + RF_PATH_B = 1, /* Radio Path B */ + RF_PATH_C = 2, /* Radio Path C */ + RF_PATH_D = 3, /* Radio Path D */ +}; + +#define MAX_PG_GROUP 13 + +#define RF_PATH_MAX 3 +#define MAX_TX_COUNT 4 /* path numbers */ + +#define CHANNEL_MAX_NUMBER 14 /* 14 is the max chnl number */ +#define MAX_CHNL_GROUP_24G 6 /* ch1~2, ch3~5, ch6~8, + *ch9~11, ch12~13, CH 14 + * total three groups */ +#define CHANNEL_GROUP_MAX_88E 6 + +enum wireless_mode { + WIRELESS_MODE_UNKNOWN = 0x00, + WIRELESS_MODE_A = BIT2, + WIRELESS_MODE_B = BIT0, + WIRELESS_MODE_G = BIT1, + WIRELESS_MODE_AUTO = BIT5, + WIRELESS_MODE_N_24G = BIT3, + WIRELESS_MODE_N_5G = BIT4, + WIRELESS_MODE_AC = BIT6 +}; + +enum phy_rate_tx_offset_area { + RA_OFFSET_LEGACY_OFDM1, + RA_OFFSET_LEGACY_OFDM2, + RA_OFFSET_HT_OFDM1, + RA_OFFSET_HT_OFDM2, + RA_OFFSET_HT_OFDM3, + RA_OFFSET_HT_OFDM4, + RA_OFFSET_HT_CCK, +}; + +/* BB/RF related */ +enum RF_TYPE_8190P { + RF_TYPE_MIN, /* 0 */ + RF_8225 = 1, /* 1 11b/g RF for verification only */ + RF_8256 = 2, /* 2 11b/g/n */ + RF_8258 = 3, /* 3 11a/b/g/n RF */ + RF_6052 = 4, /* 4 11b/g/n RF */ + /* TODO: We should remove this psudo PHY RF after we get new RF. */ + RF_PSEUDO_11N = 5, /* 5, It is a temporality RF. */ +}; + +struct bb_reg_def { + u32 rfintfs; /* set software control: */ + /* 0x870~0x877[8 bytes] */ + u32 rfintfi; /* readback data: */ + /* 0x8e0~0x8e7[8 bytes] */ + u32 rfintfo; /* output data: */ + /* 0x860~0x86f [16 bytes] */ + u32 rfintfe; /* output enable: */ + /* 0x860~0x86f [16 bytes] */ + u32 rf3wireOffset; /* LSSI data: */ + /* 0x840~0x84f [16 bytes] */ + u32 rfLSSI_Select; /* BB Band Select: */ + /* 0x878~0x87f [8 bytes] */ + u32 rfTxGainStage; /* Tx gain stage: */ + /* 0x80c~0x80f [4 bytes] */ + u32 rfHSSIPara1; /* wire parameter control1 : */ + /* 0x820~0x823,0x828~0x82b, + * 0x830~0x833, 0x838~0x83b [16 bytes] */ + u32 rfHSSIPara2; /* wire parameter control2 : */ + /* 0x824~0x827,0x82c~0x82f, 0x834~0x837, + * 0x83c~0x83f [16 bytes] */ + u32 rfSwitchControl; /* Tx Rx antenna control : */ + /* 0x858~0x85f [16 bytes] */ + u32 rfAGCControl1; /* AGC parameter control1 : */ + /* 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, + * 0xc68~0xc6b [16 bytes] */ + u32 rfAGCControl2; /* AGC parameter control2 : */ + /* 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, + * 0xc6c~0xc6f [16 bytes] */ + u32 rfRxIQImbalance; /* OFDM Rx IQ imbalance matrix : */ + /* 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, + * 0xc2c~0xc2f [16 bytes] */ + u32 rfRxAFE; /* Rx IQ DC ofset and Rx digital filter, + * Rx DC notch filter : */ + /* 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, + * 0xc28~0xc2b [16 bytes] */ + u32 rfTxIQImbalance; /* OFDM Tx IQ imbalance matrix */ + /* 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, + * 0xc98~0xc9b [16 bytes] */ + u32 rfTxAFE; /* Tx IQ DC Offset and Tx DFIR type */ + /* 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, + * 0xc9c~0xc9f [16 bytes] */ + u32 rfLSSIReadBack; /* LSSI RF readback data SI mode */ + /* 0x8a0~0x8af [16 bytes] */ + u32 rfLSSIReadBackPi; /* LSSI RF readback data PI mode 0x8b8-8bc for + * Path A and B */ +}; + +struct ant_sel_ofdm { + u32 r_tx_antenna:4; + u32 r_ant_l:4; + u32 r_ant_non_ht:4; + u32 r_ant_ht1:4; + u32 r_ant_ht2:4; + u32 r_ant_ht_s1:4; + u32 r_ant_non_ht_s1:4; + u32 OFDM_TXSC:2; + u32 reserved:2; +}; + +struct ant_sel_cck { + u8 r_cckrx_enable_2:2; + u8 r_cckrx_enable:2; + u8 r_ccktx_enable:4; +}; + +/*------------------------------Define structure----------------------------*/ + +/*------------------------Export global variable----------------------------*/ +/*------------------------Export global variable----------------------------*/ + +/*------------------------Export Marco Definition---------------------------*/ +/*------------------------Export Marco Definition---------------------------*/ + +/*--------------------------Exported Function prototype---------------------*/ +/* */ +/* BB and RF register read/write */ +/* */ +u32 rtl8188e_PHY_QueryBBReg(struct adapter *adapter, u32 regaddr, u32 mask); +void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, + u32 mask, u32 data); +u32 rtl8188e_PHY_QueryRFReg(struct adapter *adapter, enum rf_radio_path rfpath, + u32 regaddr, u32 mask); +void rtl8188e_PHY_SetRFReg(struct adapter *adapter, enum rf_radio_path rfpath, + u32 regaddr, u32 mask, u32 data); + +/* Initialization related function */ +/* MAC/BB/RF HAL config */ +int PHY_MACConfig8188E(struct adapter *adapter); +int PHY_BBConfig8188E(struct adapter *adapter); +int PHY_RFConfig8188E(struct adapter *adapter); + +/* RF config */ +int rtl8188e_PHY_ConfigRFWithParaFile(struct adapter *adapter, u8 *filename, + enum rf_radio_path rfpath); +int rtl8188e_PHY_ConfigRFWithHeaderFile(struct adapter *adapter, + enum rf_radio_path rfpath); + +/* Read initi reg value for tx power setting. */ +void rtl8192c_PHY_GetHWRegOriginalValue(struct adapter *adapter); + +/* BB TX Power R/W */ +void PHY_GetTxPowerLevel8188E(struct adapter *adapter, u32 *powerlevel); +void PHY_SetTxPowerLevel8188E(struct adapter *adapter, u8 channel); +bool PHY_UpdateTxPowerDbm8188E(struct adapter *adapter, int power); + +void PHY_ScanOperationBackup8188E(struct adapter *Adapter, u8 Operation); + +/* Switch bandwidth for 8192S */ +void PHY_SetBWMode8188E(struct adapter *adapter, + enum ht_channel_width chnlwidth, unsigned char offset); + +/* channel switch related funciton */ +void PHY_SwChnl8188E(struct adapter *adapter, u8 channel); +/* Call after initialization */ +void ChkFwCmdIoDone(struct adapter *adapter); + +/* BB/MAC/RF other monitor API */ +void PHY_SetRFPathSwitch_8188E(struct adapter *adapter, bool main); + +void PHY_SwitchEphyParameter(struct adapter *adapter); + +void PHY_EnableHostClkReq(struct adapter *adapter); + +bool SetAntennaConfig92C(struct adapter *adapter, u8 defaultant); + +void storePwrIndexDiffRateOffset(struct adapter *adapter, u32 regaddr, + u32 mask, u32 data); +/*--------------------------Exported Function prototype---------------------*/ + +#define PHY_QueryBBReg(adapt, regaddr, mask) \ + rtl8188e_PHY_QueryBBReg((adapt), (regaddr), (mask)) +#define PHY_SetBBReg(adapt, regaddr, bitmask, data) \ + rtl8188e_PHY_SetBBReg((adapt), (regaddr), (bitmask), (data)) +#define PHY_QueryRFReg(adapt, rfpath, regaddr, bitmask) \ + rtl8188e_PHY_QueryRFReg((adapt), (rfpath), (regaddr), (bitmask)) +#define PHY_SetRFReg(adapt, rfpath, regaddr, bitmask, data) \ + rtl8188e_PHY_SetRFReg((adapt), (rfpath), (regaddr), (bitmask), (data)) + +#define PHY_SetMacReg PHY_SetBBReg + +#define SIC_HW_SUPPORT 0 + +#define SIC_MAX_POLL_CNT 5 + +#define SIC_CMD_READY 0 +#define SIC_CMD_WRITE 1 +#define SIC_CMD_READ 2 + +#define SIC_CMD_REG 0x1EB /* 1byte */ +#define SIC_ADDR_REG 0x1E8 /* 1b9~1ba, 2 bytes */ +#define SIC_DATA_REG 0x1EC /* 1bc~1bf */ + +#endif /* __INC_HAL8192CPHYCFG_H */ diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyReg.h b/drivers/staging/r8188eu/include/Hal8188EPhyReg.h new file mode 100644 index 000000000000..c324970171cd --- /dev/null +++ b/drivers/staging/r8188eu/include/Hal8188EPhyReg.h @@ -0,0 +1,1088 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __INC_HAL8188EPHYREG_H__ +#define __INC_HAL8188EPHYREG_H__ +/*--------------------------Define Parameters-------------------------------*/ +/* */ +/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ +/* 3. RF register 0x00-2E */ +/* 4. Bit Mask for BB/RF register */ +/* 5. Other definition for BB/RF R/W */ +/* */ + +/* */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 1. Page1(0x100) */ +/* */ +#define rPMAC_Reset 0x100 +#define rPMAC_TxStart 0x104 +#define rPMAC_TxLegacySIG 0x108 +#define rPMAC_TxHTSIG1 0x10c +#define rPMAC_TxHTSIG2 0x110 +#define rPMAC_PHYDebug 0x114 +#define rPMAC_TxPacketNum 0x118 +#define rPMAC_TxIdle 0x11c +#define rPMAC_TxMACHeader0 0x120 +#define rPMAC_TxMACHeader1 0x124 +#define rPMAC_TxMACHeader2 0x128 +#define rPMAC_TxMACHeader3 0x12c +#define rPMAC_TxMACHeader4 0x130 +#define rPMAC_TxMACHeader5 0x134 +#define rPMAC_TxDataType 0x138 +#define rPMAC_TxRandomSeed 0x13c +#define rPMAC_CCKPLCPPreamble 0x140 +#define rPMAC_CCKPLCPHeader 0x144 +#define rPMAC_CCKCRC16 0x148 +#define rPMAC_OFDMRxCRC32OK 0x170 +#define rPMAC_OFDMRxCRC32Er 0x174 +#define rPMAC_OFDMRxParityEr 0x178 +#define rPMAC_OFDMRxCRC8Er 0x17c +#define rPMAC_CCKCRxRC16Er 0x180 +#define rPMAC_CCKCRxRC32Er 0x184 +#define rPMAC_CCKCRxRC32OK 0x188 +#define rPMAC_TxStatus 0x18c + +/* 2. Page2(0x200) */ +/* The following two definition are only used for USB interface. */ +#define RF_BB_CMD_ADDR 0x02c0 /* RF/BB r/w cmd address. */ +#define RF_BB_CMD_DATA 0x02c4 /* RF/BB r/w cmd data. */ + +/* 3. Page8(0x800) */ +#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC RF BW Setting */ + +#define rFPGA0_TxInfo 0x804 /* Status report?? */ +#define rFPGA0_PSDFunction 0x808 + +#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */ + +#define rFPGA0_RFTiming1 0x810 /* Useless now */ +#define rFPGA0_RFTiming2 0x814 + +#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */ +#define rFPGA0_XA_HSSIParameter2 0x824 +#define rFPGA0_XB_HSSIParameter1 0x828 +#define rFPGA0_XB_HSSIParameter2 0x82c + +#define rFPGA0_XA_LSSIParameter 0x840 +#define rFPGA0_XB_LSSIParameter 0x844 + +#define rFPGA0_RFWakeUpParameter 0x850 /* Useless now */ +#define rFPGA0_RFSleepUpParameter 0x854 + +#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */ +#define rFPGA0_XCD_SwitchControl 0x85c + +#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ +#define rFPGA0_XB_RFInterfaceOE 0x864 + +#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Iface Software Control */ +#define rFPGA0_XCD_RFInterfaceSW 0x874 + +#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */ +#define rFPGA0_XCD_RFParameter 0x87c + +/* Crystal cap setting RF-R/W protection for parameter4?? */ +#define rFPGA0_AnalogParameter1 0x880 +#define rFPGA0_AnalogParameter2 0x884 +#define rFPGA0_AnalogParameter3 0x888 +/* enable ad/da clock1 for dual-phy */ +#define rFPGA0_AdDaClockEn 0x888 +#define rFPGA0_AnalogParameter4 0x88c + +#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */ +#define rFPGA0_XB_LSSIReadBack 0x8a4 +#define rFPGA0_XC_LSSIReadBack 0x8a8 +#define rFPGA0_XD_LSSIReadBack 0x8ac + +#define rFPGA0_PSDReport 0x8b4 /* Useless now */ +/* Transceiver A HSPI Readback */ +#define TransceiverA_HSPI_Readback 0x8b8 +/* Transceiver B HSPI Readback */ +#define TransceiverB_HSPI_Readback 0x8bc +/* Useless now RF Interface Readback Value */ +#define rFPGA0_XAB_RFInterfaceRB 0x8e0 +#define rFPGA0_XCD_RFInterfaceRB 0x8e4 /* Useless now */ + +/* 4. Page9(0x900) */ +/* RF mode & OFDM TxSC RF BW Setting?? */ +#define rFPGA1_RFMOD 0x900 + +#define rFPGA1_TxBlock 0x904 /* Useless now */ +#define rFPGA1_DebugSelect 0x908 /* Useless now */ +#define rFPGA1_TxInfo 0x90c /* Useless now Status report */ + +/* 5. PageA(0xA00) */ +/* Set Control channel to upper or lower - required only for 40MHz */ +#define rCCK0_System 0xa00 + +/* Disable init gain now Select RX path by RSSI */ +#define rCCK0_AFESetting 0xa04 +/* Disable init gain now Init gain */ +#define rCCK0_CCA 0xa08 + +/* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold, + * RX LNA Threshold useless now. Not the same as 90 series */ +#define rCCK0_RxAGC1 0xa0c +#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ + +#define rCCK0_RxHP 0xa14 + +/* Timing recovery & Channel estimation threshold */ +#define rCCK0_DSPParameter1 0xa18 +#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ + +#define rCCK0_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ +#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d useless now */ +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 /* 0xa57 */ +#define rCCK0_FACounterLower 0xa5c /* 0xa5b */ +#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */ + +/* */ +/* PageB(0xB00) */ +/* */ +#define rPdp_AntA 0xb00 +#define rPdp_AntA_4 0xb04 +#define rConfig_Pmpd_AntA 0xb28 +#define rConfig_AntA 0xb68 +#define rConfig_AntB 0xb6c +#define rPdp_AntB 0xb70 +#define rPdp_AntB_4 0xb74 +#define rConfig_Pmpd_AntB 0xb98 +#define rAPK 0xbd8 + +/* */ +/* 6. PageC(0xC00) */ +/* */ +#define rOFDM0_LSTF 0xc00 + +#define rOFDM0_TRxPathEnable 0xc04 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c + +/* RxIQ DC offset, Rx digital filter, DC notch filter */ +#define rOFDM0_XARxAFE 0xc10 +#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */ +#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxIQImbalance 0xc1c +#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxIQImbalance 0xc24 +#define rOFDM0_XDRxAFE 0xc28 +#define rOFDM0_XDRxIQImbalance 0xc2c + +#define rOFDM0_RxDetector1 0xc30 /*PD,BW & SBD DM tune init gain*/ +#define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync. */ +#define rOFDM0_RxDetector3 0xc38 /* Frame Sync. */ +#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync & Short-GI */ + +#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ +#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ +#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */ +#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ + +#define rOFDM0_XAAGCCore1 0xc50 /* DIG */ +#define rOFDM0_XAAGCCore2 0xc54 +#define rOFDM0_XBAGCCore1 0xc58 +#define rOFDM0_XBAGCCore2 0xc5c +#define rOFDM0_XCAGCCore1 0xc60 +#define rOFDM0_XCAGCCore2 0xc64 +#define rOFDM0_XDAGCCore1 0xc68 +#define rOFDM0_XDAGCCore2 0xc6c + +#define rOFDM0_AGCParameter1 0xc70 +#define rOFDM0_AGCParameter2 0xc74 +#define rOFDM0_AGCRSSITable 0xc78 +#define rOFDM0_HTSTFAGC 0xc7c + +#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */ +#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XBTxIQImbalance 0xc88 +#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XCTxIQImbalance 0xc90 +#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XDTxIQImbalance 0xc98 +#define rOFDM0_XDTxAFE 0xc9c + +#define rOFDM0_RxIQExtAnta 0xca0 +#define rOFDM0_TxCoeff1 0xca4 +#define rOFDM0_TxCoeff2 0xca8 +#define rOFDM0_TxCoeff3 0xcac +#define rOFDM0_TxCoeff4 0xcb0 +#define rOFDM0_TxCoeff5 0xcb4 +#define rOFDM0_TxCoeff6 0xcb8 +#define rOFDM0_RxHPParameter 0xce0 +#define rOFDM0_TxPseudoNoiseWgt 0xce4 +#define rOFDM0_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 + +/* */ +/* 7. PageD(0xD00) */ +/* */ +#define rOFDM1_LSTF 0xd00 +#define rOFDM1_TRxPathEnable 0xd04 + +#define rOFDM1_CFO 0xd08 /* No setting now */ +#define rOFDM1_CSI1 0xd10 +#define rOFDM1_SBD 0xd14 +#define rOFDM1_CSI2 0xd18 +#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_TRxMesaure1 0xd34 +#define rOFDM1_IntfDet 0xd3c +#define rOFDM1_PseudoNoiseStateAB 0xd50 +#define rOFDM1_PseudoNoiseStateCD 0xd54 +#define rOFDM1_RxPseudoNoiseWgt 0xd58 + +#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */ +#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ +#define rOFDM_PHYCounter3 0xda8 /* MCS not support */ + +#define rOFDM_ShortCFOAB 0xdac /* No setting now */ +#define rOFDM_ShortCFOCD 0xdb0 +#define rOFDM_LongCFOAB 0xdb4 +#define rOFDM_LongCFOCD 0xdb8 +#define rOFDM_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 0xdc0 +#define rOFDM_PWMeasure1 0xdc4 +#define rOFDM_PWMeasure2 0xdc8 +#define rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc + +/* */ +/* 8. PageE(0xE00) */ +/* */ +#define rTxAGC_A_Rate18_06 0xe00 +#define rTxAGC_A_Rate54_24 0xe04 +#define rTxAGC_A_CCK1_Mcs32 0xe08 +#define rTxAGC_A_Mcs03_Mcs00 0xe10 +#define rTxAGC_A_Mcs07_Mcs04 0xe14 +#define rTxAGC_A_Mcs11_Mcs08 0xe18 +#define rTxAGC_A_Mcs15_Mcs12 0xe1c + +#define rTxAGC_B_Rate18_06 0x830 +#define rTxAGC_B_Rate54_24 0x834 +#define rTxAGC_B_CCK1_55_Mcs32 0x838 +#define rTxAGC_B_Mcs03_Mcs00 0x83c +#define rTxAGC_B_Mcs07_Mcs04 0x848 +#define rTxAGC_B_Mcs11_Mcs08 0x84c +#define rTxAGC_B_Mcs15_Mcs12 0x868 +#define rTxAGC_B_CCK11_A_CCK2_11 0x86c + +#define rFPGA0_IQK 0xe28 +#define rTx_IQK_Tone_A 0xe30 +#define rRx_IQK_Tone_A 0xe34 +#define rTx_IQK_PI_A 0xe38 +#define rRx_IQK_PI_A 0xe3c + +#define rTx_IQK 0xe40 +#define rRx_IQK 0xe44 +#define rIQK_AGC_Pts 0xe48 +#define rIQK_AGC_Rsp 0xe4c +#define rTx_IQK_Tone_B 0xe50 +#define rRx_IQK_Tone_B 0xe54 +#define rTx_IQK_PI_B 0xe58 +#define rRx_IQK_PI_B 0xe5c +#define rIQK_AGC_Cont 0xe60 + +#define rBlue_Tooth 0xe6c +#define rRx_Wait_CCA 0xe70 +#define rTx_CCK_RFON 0xe74 +#define rTx_CCK_BBON 0xe78 +#define rTx_OFDM_RFON 0xe7c +#define rTx_OFDM_BBON 0xe80 +#define rTx_To_Rx 0xe84 +#define rTx_To_Tx 0xe88 +#define rRx_CCK 0xe8c + +#define rTx_Power_Before_IQK_A 0xe94 +#define rTx_Power_After_IQK_A 0xe9c + +#define rRx_Power_Before_IQK_A 0xea0 +#define rRx_Power_Before_IQK_A_2 0xea4 +#define rRx_Power_After_IQK_A 0xea8 +#define rRx_Power_After_IQK_A_2 0xeac + +#define rTx_Power_Before_IQK_B 0xeb4 +#define rTx_Power_After_IQK_B 0xebc + +#define rRx_Power_Before_IQK_B 0xec0 +#define rRx_Power_Before_IQK_B_2 0xec4 +#define rRx_Power_After_IQK_B 0xec8 +#define rRx_Power_After_IQK_B_2 0xecc + +#define rRx_OFDM 0xed0 +#define rRx_Wait_RIFS 0xed4 +#define rRx_TO_Rx 0xed8 +#define rStandby 0xedc +#define rSleep 0xee0 +#define rPMPD_ANAEN 0xeec + +/* */ +/* 7. RF Register 0x00-0x2E (RF 8256) */ +/* RF-0222D 0x00-3F */ +/* */ +/* Zebra1 */ +#define rZebra1_HSSIEnable 0x0 /* Useless now */ +#define rZebra1_TRxEnable1 0x1 +#define rZebra1_TRxEnable2 0x2 +#define rZebra1_AGC 0x4 +#define rZebra1_ChargePump 0x5 +#define rZebra1_Channel 0x7 /* RF channel switch */ + +/* endif */ +#define rZebra1_TxGain 0x8 /* Useless now */ +#define rZebra1_TxLPF 0x9 +#define rZebra1_RxLPF 0xb +#define rZebra1_RxHPFCorner 0xc + +/* Zebra4 */ +#define rGlobalCtrl 0 /* Useless now */ +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 + +/* RTL8258 */ +#define rRTL8258_TxLPF 0x11 /* Useless now */ +#define rRTL8258_RxLPF 0x13 +#define rRTL8258_RSSILPF 0xa + +/* */ +/* RL6052 Register definition */ +/* */ +#define RF_AC 0x00 /* */ + +#define RF_IQADJ_G1 0x01 /* */ +#define RF_IQADJ_G2 0x02 /* */ + +#define RF_POW_TRSW 0x05 /* */ + +#define RF_GAIN_RX 0x06 /* */ +#define RF_GAIN_TX 0x07 /* */ + +#define RF_TXM_IDAC 0x08 /* */ +#define RF_IPA_G 0x09 /* */ +#define RF_TXBIAS_G 0x0A +#define RF_TXPA_AG 0x0B +#define RF_IPA_A 0x0C /* */ +#define RF_TXBIAS_A 0x0D +#define RF_BS_PA_APSET_G9_G11 0x0E +#define RF_BS_IQGEN 0x0F /* */ + +#define RF_MODE1 0x10 /* */ +#define RF_MODE2 0x11 /* */ + +#define RF_RX_AGC_HP 0x12 /* */ +#define RF_TX_AGC 0x13 /* */ +#define RF_BIAS 0x14 /* */ +#define RF_IPA 0x15 /* */ +#define RF_TXBIAS 0x16 +#define RF_POW_ABILITY 0x17 /* */ +#define RF_CHNLBW 0x18 /* RF channel and BW switch */ +#define RF_TOP 0x19 /* */ + +#define RF_RX_G1 0x1A /* */ +#define RF_RX_G2 0x1B /* */ + +#define RF_RX_BB2 0x1C /* */ +#define RF_RX_BB1 0x1D /* */ + +#define RF_RCK1 0x1E /* */ +#define RF_RCK2 0x1F /* */ + +#define RF_TX_G1 0x20 /* */ +#define RF_TX_G2 0x21 /* */ +#define RF_TX_G3 0x22 /* */ + +#define RF_TX_BB1 0x23 /* */ + +#define RF_T_METER_92D 0x42 /* */ +#define RF_T_METER_88E 0x42 /* */ +#define RF_T_METER 0x24 /* */ + +#define RF_SYN_G1 0x25 /* RF TX Power control */ +#define RF_SYN_G2 0x26 /* RF TX Power control */ +#define RF_SYN_G3 0x27 /* RF TX Power control */ +#define RF_SYN_G4 0x28 /* RF TX Power control */ +#define RF_SYN_G5 0x29 /* RF TX Power control */ +#define RF_SYN_G6 0x2A /* RF TX Power control */ +#define RF_SYN_G7 0x2B /* RF TX Power control */ +#define RF_SYN_G8 0x2C /* RF TX Power control */ + +#define RF_RCK_OS 0x30 /* RF TX PA control */ +#define RF_TXPA_G1 0x31 /* RF TX PA control */ +#define RF_TXPA_G2 0x32 /* RF TX PA control */ +#define RF_TXPA_G3 0x33 /* RF TX PA control */ +#define RF_TX_BIAS_A 0x35 +#define RF_TX_BIAS_D 0x36 +#define RF_LOBF_9 0x38 +#define RF_RXRF_A3 0x3C /* */ +#define RF_TRSW 0x3F + +#define RF_TXRF_A2 0x41 +#define RF_TXPA_G4 0x46 +#define RF_TXPA_A4 0x4B +#define RF_0x52 0x52 +#define RF_WE_LUT 0xEF + +/* */ +/* Bit Mask */ +/* */ +/* 1. Page1(0x100) */ +#define bBBResetB 0x100 /* Useless now? */ +#define bGlobalResetB 0x200 +#define bOFDMTxStart 0x4 +#define bCCKTxStart 0x8 +#define bCRC32Debug 0x100 +#define bPMACLoopback 0x10 +#define bTxLSIG 0xffffff +#define bOFDMTxRate 0xf +#define bOFDMTxReserved 0x10 +#define bOFDMTxLength 0x1ffe0 +#define bOFDMTxParity 0x20000 +#define bTxHTSIG1 0xffffff +#define bTxHTMCSRate 0x7f +#define bTxHTBW 0x80 +#define bTxHTLength 0xffff00 +#define bTxHTSIG2 0xffffff +#define bTxHTSmoothing 0x1 +#define bTxHTSounding 0x2 +#define bTxHTReserved 0x4 +#define bTxHTAggreation 0x8 +#define bTxHTSTBC 0x30 +#define bTxHTAdvanceCoding 0x40 +#define bTxHTShortGI 0x80 +#define bTxHTNumberHT_LTF 0x300 +#define bTxHTCRC8 0x3fc00 +#define bCounterReset 0x10000 +#define bNumOfOFDMTx 0xffff +#define bNumOfCCKTx 0xffff0000 +#define bTxIdleInterval 0xffff +#define bOFDMService 0xffff0000 +#define bTxMACHeader 0xffffffff +#define bTxDataInit 0xff +#define bTxHTMode 0x100 +#define bTxDataType 0x30000 +#define bTxRandomSeed 0xffffffff +#define bCCKTxPreamble 0x1 +#define bCCKTxSFD 0xffff0000 +#define bCCKTxSIG 0xff +#define bCCKTxService 0xff00 +#define bCCKLengthExt 0x8000 +#define bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 + +#define IS_BB_REG_OFFSET_92S(_Offset) \ + ((_Offset >= 0x800) && (_Offset <= 0xfff)) + +/* 2. Page8(0x800) */ +#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */ +#define bJapanMode 0x2 +#define bCCKTxSC 0x30 +#define bCCKEn 0x1000000 +#define bOFDMEn 0x2000000 + +#define bOFDMRxADCPhase 0x10000 /* Useless now */ +#define bOFDMTxDACPhase 0x40000 +#define bXATxAGC 0x3f + +#define bAntennaSelect 0x0300 + +#define bXBTxAGC 0xf00 /* Reg 80c rFPGA0_TxGainStage */ +#define bXCTxAGC 0xf000 +#define bXDTxAGC 0xf0000 + +#define bPAStart 0xf0000000 /* Useless now */ +#define bTRStart 0x00f00000 +#define bRFStart 0x0000f000 +#define bBBStart 0x000000f0 +#define bBBCCKStart 0x0000000f +#define bPAEnd 0xf /* Reg0x814 */ +#define bTREnd 0x0f000000 +#define bRFEnd 0x000f0000 +#define bCCAMask 0x000000f0 /* T2R */ +#define bR2RCCAMask 0x00000f00 +#define bHSSI_R2TDelay 0xf8000000 +#define bHSSI_T2RDelay 0xf80000 +#define bContTxHSSI 0x400 /* change gain at continue Tx */ +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 + +/* Reg 0x820~84f rFPGA0_XA_HSSIParameter1 */ +#define b3WireDataLength 0x800 +#define b3WireAddressLength 0x400 + +#define b3WireRFPowerDown 0x1 /* Useless now */ +#define b5GPAPEPolarity 0x40000000 +#define b2GPAPEPolarity 0x80000000 +#define bRFSW_TxDefaultAnt 0x3 +#define bRFSW_TxOptionAnt 0x30 +#define bRFSW_RxDefaultAnt 0x300 +#define bRFSW_RxOptionAnt 0x3000 +#define bRFSI_3WireData 0x1 +#define bRFSI_3WireClock 0x2 +#define bRFSI_3WireLoad 0x4 +#define bRFSI_3WireRW 0x8 +#define bRFSI_3Wire 0xf + +#define bRFSI_RFENV 0x10 /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */ + +#define bRFSI_TRSW 0x20 /* Useless now */ +#define bRFSI_TRSWB 0x40 +#define bRFSI_ANTSW 0x100 +#define bRFSI_ANTSWB 0x200 +#define bRFSI_PAPE 0x400 +#define bRFSI_PAPE5G 0x800 +#define bBandSelect 0x1 +#define bHTSIG2_GI 0x80 +#define bHTSIG2_Smoothing 0x01 +#define bHTSIG2_Sounding 0x02 +#define bHTSIG2_Aggreaton 0x08 +#define bHTSIG2_STBC 0x30 +#define bHTSIG2_AdvCoding 0x40 +#define bHTSIG2_NumOfHTLTF 0x300 +#define bHTSIG2_CRC8 0x3fc +#define bHTSIG1_MCS 0x7f +#define bHTSIG1_BandWidth 0x80 +#define bHTSIG1_HTLength 0xffff +#define bLSIG_Rate 0xf +#define bLSIG_Reserved 0x10 +#define bLSIG_Length 0x1fffe +#define bLSIG_Parity 0x20 +#define bCCKRxPhase 0x4 + +#define bLSSIReadAddress 0x7f800000 /* T65 RF */ + +#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ + +#define bLSSIReadBackData 0xfffff /* T65 RF */ + +#define bLSSIReadOKFlag 0x1000 /* Useless now */ +#define bCCKSampleRate 0x8 /* 0: 44MHz, 1:88MHz */ +#define bRegulator0Standby 0x1 +#define bRegulatorPLLStandby 0x2 +#define bRegulator1Standby 0x4 +#define bPLLPowerUp 0x8 +#define bDPLLPowerUp 0x10 +#define bDA10PowerUp 0x20 +#define bAD7PowerUp 0x200 +#define bDA6PowerUp 0x2000 +#define bXtalPowerUp 0x4000 +#define b40MDClkPowerUP 0x8000 +#define bDA6DebugMode 0x20000 +#define bDA6Swing 0x380000 + +/* Reg 0x880 rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */ +#define bADClkPhase 0x4000000 + +#define b80MClkDelay 0x18000000 /* Useless */ +#define bAFEWatchDogEnable 0x20000000 + +/* Reg 0x884 rFPGA0_AnalogParameter2 Crystal cap */ +#define bXtalCap01 0xc0000000 +#define bXtalCap23 0x3 +#define bXtalCap92x 0x0f000000 +#define bXtalCap 0x0f000000 + +#define bIntDifClkEnable 0x400 /* Useless */ +#define bExtSigClkEnable 0x800 +#define bBandgapMbiasPowerUp 0x10000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 +#define bCCKRxAGCFormat 0x200 +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff + +/* 3. Page9(0x900) */ +#define bOFDMTxSC 0x30000000 /* Useless */ +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff /* reset debug page and HWord, LWord */ +#define bDebugItem 0xff /* reset debug page and LWord */ +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 + +/* 4. PageA(0xA00) */ +#define bCCKBBMode 0x3 /* Useless */ +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 + +#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0_System 20/40 */ + +#define bCCKScramble 0x8 /* Useless */ +#define bCCKAntDiversity 0x8000 +#define bCCKCarrierRecovery 0x4000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 +#define bCCKTxDACPhase 0x4 +#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ +#define bCCKr_cp_mode0 0x0100 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 /* CCK Rx Iinital gain polarity */ +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ +#define bCCKFixedRxAGC 0x8000 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 +#define bCCKRxAGCReportType 0x0300 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCSatLevel 0x1f000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 +#define bCCKRxRxReport_SQLoss 0x20000000 +#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Lockedbit 0x08000000 +#define bCCKRxReport_RateError 0x04000000 +#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxFACounterLower 0xff +#define bCCKRxFACounterUpper 0xff000000 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 +#define bCCKRxFalseAlarmEnable 0x8000 +#define bCCKFACounterFreeze 0x4000 +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 + +/* 5. PageC(0xC00) */ +#define bNumOfSTF 0x3 /* Useless */ +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 0x1f000000 +#define bPD_TH 0xf +#define bPD_TH_Opt2 0xc000 +#define bPWED_TH 0x700 +#define bIfMF_Win_L 0x800 +#define bPD_Option 0x1000 +#define bMF_Win_L 0xe000 +#define bBW_Search_L 0x30000 +#define bwin_enh_L 0xc0000 +#define bBW_TH 0x700000 +#define bED_TH2 0x3800000 +#define bBW_option 0x4000000 +#define bRatio_TH 0x18000000 +#define bWindow_L 0xe0000000 +#define bSBD_Option 0x1 +#define bFrame_TH 0x1c +#define bFS_Option 0x60 +#define bDC_Slope_check 0x80 +#define bFGuard_Counter_DC_L 0xe00 +#define bFrame_Weight_Short 0x7000 +#define bSub_Tune 0xe00000 +#define bFrame_DC_Length 0xe000000 +#define bSBD_start_offset 0x30000000 +#define bFrame_TH_2 0x7 +#define bFrame_GI2_TH 0x38 +#define bGI2_Sync_en 0x40 +#define bSarch_Short_Early 0x300 +#define bSarch_Short_Late 0xc00 +#define bSarch_GI2_Late 0x70000 +#define bCFOAntSum 0x1 +#define bCFOAcc 0x2 +#define bCFOStartOffset 0xc +#define bCFOLookBack 0x70 +#define bCFOSumWeight 0x80 +#define bDAGCEnable 0x10000 +#define bTXIQImb_A 0x3ff +#define bTXIQImb_B 0xfc00 +#define bTXIQImb_C 0x3f0000 +#define bTXIQImb_D 0xffc00000 +#define bTxIDCOffset 0xff +#define bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 +#define bLambda_ED 0x300 +#define bRxInitialGain 0x7f +#define bRxAntDivEn 0x80 +#define bRxAGCAddressForLNA 0x7f00 +#define bRxHighPowerFlow 0x8000 +#define bRxAGCFreezeThres 0xc0000 +#define bRxFreezeStep_AGC1 0x300000 +#define bRxFreezeStep_AGC2 0xc00000 +#define bRxFreezeStep_AGC3 0x3000000 +#define bRxFreezeStep_AGC0 0xc000000 +#define bRxRssi_Cmp_En 0x10000000 +#define bRxQuickAGCEn 0x20000000 +#define bRxAGCFreezeThresMode 0x40000000 +#define bRxOverFlowCheckType 0x80000000 +#define bRxAGCShift 0x7f +#define bTRSW_Tri_Only 0x80 +#define bPowerThres 0x300 +#define bRxAGCEn 0x1 +#define bRxAGCTogetherEn 0x2 +#define bRxAGCMin 0x4 +#define bRxHP_Ini 0x7 +#define bRxHP_TRLNA 0x70 +#define bRxHP_RSSI 0x700 +#define bRxHP_BBP1 0x7000 +#define bRxHP_BBP2 0x70000 +#define bRxHP_BBP3 0x700000 +#define bRSSI_H 0x7f0000 /* threshold for high power */ +#define bRSSI_Gen 0x7f000000 /* threshold for ant diversity */ +#define bRxSettle_TRSW 0x7 +#define bRxSettle_LNA 0x38 +#define bRxSettle_RSSI 0x1c0 +#define bRxSettle_BBP 0xe00 +#define bRxSettle_RxHP 0x7000 +#define bRxSettle_AntSW_RSSI 0x38000 +#define bRxSettle_AntSW 0xc0000 +#define bRxProcessTime_DAGC 0x300000 +#define bRxSettle_HSSI 0x400000 +#define bRxProcessTime_BBPPW 0x800000 +#define bRxAntennaPowerShift 0x3000000 +#define bRSSITableSelect 0xc000000 +#define bRxHP_Final 0x7000000 +#define bRxHTSettle_BBP 0x7 +#define bRxHTSettle_HSSI 0x8 +#define bRxHTSettle_RxHP 0x70 +#define bRxHTSettle_BBPPW 0x80 +#define bRxHTSettle_Idle 0x300 +#define bRxHTSettle_Reserved 0x1c00 +#define bRxHTRxHPEn 0x8000 +#define bRxHTAGCFreezeThres 0x30000 +#define bRxHTAGCTogetherEn 0x40000 +#define bRxHTAGCMin 0x80000 +#define bRxHTAGCEn 0x100000 +#define bRxHTDAGCEn 0x200000 +#define bRxHTRxHP_BBP 0x1c00000 +#define bRxHTRxHP_Final 0xe0000000 +#define bRxPWRatioTH 0x3 +#define bRxPWRatioEn 0x4 +#define bRxMFHold 0x3800 +#define bRxPD_Delay_TH1 0x38 +#define bRxPD_Delay_TH2 0x1c0 +#define bRxPD_DC_COUNT_MAX 0x600 +#define bRxPD_Delay_TH 0x8000 +#define bRxProcess_Delay 0xf0000 +#define bRxSearchrange_GI2_Early 0x700000 +#define bRxFrame_Guard_Counter_L 0x3800000 +#define bRxSGI_Guard_L 0xc000000 +#define bRxSGI_Search_L 0x30000000 +#define bRxSGI_TH 0xc0000000 +#define bDFSCnt0 0xff +#define bDFSCnt1 0xff00 +#define bDFSFlag 0xf0000 +#define bMFWeightSum 0x300000 +#define bMinIdxTH 0x7f000000 +#define bDAFormat 0x40000 +#define bTxChEmuEnable 0x01000000 +#define bTRSWIsolation_A 0x7f +#define bTRSWIsolation_B 0x7f00 +#define bTRSWIsolation_C 0x7f0000 +#define bTRSWIsolation_D 0x7f000000 +#define bExtLNAGain 0x7c00 + +/* 6. PageE(0xE00) */ +#define bSTBCEn 0x4 /* Useless */ +#define bAntennaMapping 0x10 +#define bNss 0x20 +#define bCFOAntSumD 0x200 +#define bPHYCounterReset 0x8000000 +#define bCFOReportGet 0x4000000 +#define bOFDMContinueTx 0x10000000 +#define bOFDMSingleCarrier 0x20000000 +#define bOFDMSingleTone 0x40000000 +#define bHTDetect 0x100 +#define bCFOEn 0x10000 +#define bCFOValue 0xfff00000 +#define bSigTone_Re 0x3f +#define bSigTone_Im 0x7f00 +#define bCounter_CCA 0xffff +#define bCounter_ParityFail 0xffff0000 +#define bCounter_RateIllegal 0xffff +#define bCounter_CRC8Fail 0xffff0000 +#define bCounter_MCSNoSupport 0xffff +#define bCounter_FastSync 0xffff +#define bShortCFO 0xfff +#define bShortCFOTLength 12 /* total */ +#define bShortCFOFLength 11 /* fraction */ +#define bLongCFO 0x7ff +#define bLongCFOTLength 11 +#define bLongCFOFLength 11 +#define bTailCFO 0x1fff +#define bTailCFOTLength 13 +#define bTailCFOFLength 12 +#define bmax_en_pwdB 0xffff +#define bCC_power_dB 0xffff0000 +#define bnoise_pwdB 0xffff +#define bPowerMeasTLength 10 +#define bPowerMeasFLength 3 +#define bRx_HT_BW 0x1 +#define bRxSC 0x6 +#define bRx_HT 0x8 +#define bNB_intf_det_on 0x1 +#define bIntf_win_len_cfg 0x30 +#define bNB_Intf_TH_cfg 0x1c0 +#define bRFGain 0x3f +#define bTableSel 0x40 +#define bTRSW 0x80 +#define bRxSNR_A 0xff +#define bRxSNR_B 0xff00 +#define bRxSNR_C 0xff0000 +#define bRxSNR_D 0xff000000 +#define bSNREVMTLength 8 +#define bSNREVMFLength 1 +#define bCSI1st 0xff +#define bCSI2nd 0xff00 +#define bRxEVM1st 0xff0000 +#define bRxEVM2nd 0xff000000 +#define bSIGEVM 0xff +#define bPWDB 0xff00 +#define bSGIEN 0x10000 + +#define bSFactorQAM1 0xf /* Useless */ +#define bSFactorQAM2 0xf0 +#define bSFactorQAM3 0xf00 +#define bSFactorQAM4 0xf000 +#define bSFactorQAM5 0xf0000 +#define bSFactorQAM6 0xf0000 +#define bSFactorQAM7 0xf00000 +#define bSFactorQAM8 0xf000000 +#define bSFactorQAM9 0xf0000000 +#define bCSIScheme 0x100000 + +#define bNoiseLvlTopSet 0x3 /* Useless */ +#define bChSmooth 0x4 +#define bChSmoothCfg1 0x38 +#define bChSmoothCfg2 0x1c0 +#define bChSmoothCfg3 0xe00 +#define bChSmoothCfg4 0x7000 +#define bMRCMode 0x800000 +#define bTHEVMCfg 0x7000000 + +#define bLoopFitType 0x1 /* Useless */ +#define bUpdCFO 0x40 +#define bUpdCFOOffData 0x80 +#define bAdvUpdCFO 0x100 +#define bAdvTimeCtrl 0x800 +#define bUpdClko 0x1000 +#define bFC 0x6000 +#define bTrackingMode 0x8000 +#define bPhCmpEnable 0x10000 +#define bUpdClkoLTF 0x20000 +#define bComChCFO 0x40000 +#define bCSIEstiMode 0x80000 +#define bAdvUpdEqz 0x100000 +#define bUChCfg 0x7000000 +#define bUpdEqz 0x8000000 + +/* Rx Pseduo noise */ +#define bRxPesudoNoiseOn 0x20000000 /* Useless */ +#define bRxPesudoNoise_A 0xff +#define bRxPesudoNoise_B 0xff00 +#define bRxPesudoNoise_C 0xff0000 +#define bRxPesudoNoise_D 0xff000000 +#define bPesudoNoiseState_A 0xffff +#define bPesudoNoiseState_B 0xffff0000 +#define bPesudoNoiseState_C 0xffff +#define bPesudoNoiseState_D 0xffff0000 + +/* 7. RF Register */ +/* Zebra1 */ +#define bZebra1_HSSIEnable 0x8 /* Useless */ +#define bZebra1_TRxControl 0xc00 +#define bZebra1_TRxGainSetting 0x07f +#define bZebra1_RxCorner 0xc00 +#define bZebra1_TxChargePump 0x38 +#define bZebra1_RxChargePump 0x7 +#define bZebra1_ChannelNum 0xf80 +#define bZebra1_TxLPFBW 0x400 +#define bZebra1_RxLPFBW 0x600 + +/* Zebra4 */ +#define bRTL8256RegModeCtrl1 0x100 /* Useless */ +#define bRTL8256RegModeCtrl0 0x40 +#define bRTL8256_TxLPFBW 0x18 +#define bRTL8256_RxLPFBW 0x600 + +/* RTL8258 */ +#define bRTL8258_TxLPFBW 0xc /* Useless */ +#define bRTL8258_RxLPFBW 0xc00 +#define bRTL8258_RSSILPFBW 0xc0 + +/* */ +/* Other Definition */ +/* */ + +/* byte endable for sb_write */ +#define bByte0 0x1 /* Useless */ +#define bByte1 0x2 +#define bByte2 0x4 +#define bByte3 0x8 +#define bWord0 0x3 +#define bWord1 0xc +#define bDWord 0xf + +/* for PutRegsetting & GetRegSetting BitMask */ +#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */ +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff +#define bMask12Bits 0xfff +#define bMaskH4Bits 0xf0000000 +#define bMaskOFDM_D 0xffc00000 +#define bMaskCCK 0x3f3f3f3f + +/* for PutRFRegsetting & GetRFRegSetting BitMask */ +#define bRFRegOffsetMask 0xfffff + +#define bEnable 0x1 /* Useless */ +#define bDisable 0x0 + +#define LeftAntenna 0x0 /* Useless */ +#define RightAntenna 0x1 + +#define tCheckTxStatus 500 /* 500ms Useless */ +#define tUpdateRxCounter 100 /* 100ms */ + +#define rateCCK 0 /* Useless */ +#define rateOFDM 1 +#define rateHT 2 + +/* define Register-End */ +#define bPMAC_End 0x1ff /* Useless */ +#define bFPGAPHY0_End 0x8ff +#define bFPGAPHY1_End 0x9ff +#define bCCKPHY0_End 0xaff +#define bOFDMPHY0_End 0xcff +#define bOFDMPHY1_End 0xdff + +#define bPMACControl 0x0 /* Useless */ +#define bWMACControl 0x1 +#define bWNICControl 0x2 + +#define PathA 0x0 /* Useless */ +#define PathB 0x1 +#define PathC 0x2 +#define PathD 0x3 + +/*--------------------------Define Parameters-------------------------------*/ + +#endif diff --git a/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h b/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h new file mode 100644 index 000000000000..df151b76f302 --- /dev/null +++ b/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h @@ -0,0 +1,173 @@ + +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HAL8188EPWRSEQ_H__ +#define __HAL8188EPWRSEQ_H__ + +#include "HalPwrSeqCmd.h" + +/* + Check document WM-20110607-Paul-RTL8188E_Power_Architecture-R02.vsd + There are 6 HW Power States: + 0: POFF--Power Off + 1: PDN--Power Down + 2: CARDEMU--Card Emulation + 3: ACT--Active Mode + 4: LPS--Low Power State + 5: SUS--Suspend + + The transision from different states are defined below + TRANS_CARDEMU_TO_ACT + TRANS_ACT_TO_CARDEMU + TRANS_CARDEMU_TO_SUS + TRANS_SUS_TO_CARDEMU + TRANS_CARDEMU_TO_PDN + TRANS_ACT_TO_LPS + TRANS_LPS_TO_ACT + + TRANS_END + + PWR SEQ Version: rtl8188E_PwrSeq_V09.h +*/ +#define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10 +#define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS 10 +#define RTL8188E_TRANS_SUS_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS 10 +#define RTL8188E_TRANS_PDN_TO_CARDEMU_STEPS 10 +#define RTL8188E_TRANS_ACT_TO_LPS_STEPS 15 +#define RTL8188E_TRANS_LPS_TO_ACT_STEPS 15 +#define RTL8188E_TRANS_END_STEPS 1 + +#define RTL8188E_TRANS_CARDEMU_TO_ACT \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, BIT1},/* wait till 0x04[17] = 1 power ready*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0|BIT1, 0}, /* 0x02[1:0] = 0 reset BB*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0}, /* 0x04[15] = 0 disable HWPDN (control by DRV)*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4|BIT3, 0}, /*0x04[12:11] = 2b'00 disable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0}, /*0x04[8] = 1 polling until return 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT0, 0}, /*wait till 0x04[8] = 0*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*LDO normal mode*/ \ + {0x0074, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*SDIO Driving*/ \ + +#define RTL8188E_TRANS_ACT_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0},/*0x1F[7:0] = 0 turn off RF*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*LDO Sleep mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*0x04[9] = 1 turn off MAC by HW state machine*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, 0}, /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ + +#define RTL8188E_TRANS_CARDEMU_TO_SUS \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3|BIT4}, /*0x04[12:11] = 2b'11enable WL suspend for PCIe*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, BIT7}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + +#define RTL8188E_TRANS_SUS_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + +#define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + +#define RTL8188E_TRANS_CARDDIS_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + +#define RTL8188E_TRANS_CARDEMU_TO_PDN \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/* 0x04[16] = 0*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7},/* 0x04[15] = 1*/ + +#define RTL8188E_TRANS_PDN_TO_CARDEMU \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0},/* 0x04[15] = 0*/ + +/* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ +#define RTL8188E_TRANS_ACT_TO_LPS \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/ \ + {0x05F8, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/*CCK and OFDM are disabled,and clock are gated*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US},/*Delay 1us*/ \ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x3F},/*Reset MAC TRX*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, 0},/*check if removed later*/ \ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, BIT5},/*Respond TxOK to scheduler*/ \ + +#define RTL8188E_TRANS_LPS_TO_ACT \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ + {0x0080, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, 0xFF, 0x84}, /*SDIO RPWM*/\ + {0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*USB RPWM*/\ + {0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*PCIe RPWM*/\ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, /*Delay*/\ + {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*. 0x08[4] = 0 switch TSF to 40M*/\ + {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT7, 0}, /*Polling 0x109[7]=0 TSF in 40M*/\ + {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT6|BIT7, 0}, /*. 0x29[7:6] = 2b'00 enable BB clock*/\ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*. 0x101[1] = 1*/\ + {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF}, /*. 0x100[7:0] = 0xFF enable WMAC TRX*/\ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ + {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ + +#define RTL8188E_TRANS_END \ + /* format */ \ + /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ + {0xFFFF, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK,0, PWR_CMD_END, 0, 0}, /* */ + +extern struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_radio_off_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_card_disable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_card_enable_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_suspend_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_resume_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_SUS_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_hwpdn_flow[RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS+RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS+RTL8188E_TRANS_END_STEPS]; +extern struct wl_pwr_cfg rtl8188E_leave_lps_flow[RTL8188E_TRANS_LPS_TO_ACT_STEPS+RTL8188E_TRANS_END_STEPS]; + +#endif /* __HAL8188EPWRSEQ_H__ */ diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h new file mode 100644 index 000000000000..21996a1173ef --- /dev/null +++ b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h @@ -0,0 +1,75 @@ +#ifndef __INC_RA_H +#define __INC_RA_H +/*++ +Copyright (c) Realtek Semiconductor Corp. All rights reserved. + +Module Name: + RateAdaptive.h + +Abstract: + Prototype of RA and related data structure. + +Major Change History: + When Who What + ---------- --------------- ------------------------------- + 2011-08-12 Page Create. +--*/ + +/* Rate adaptive define */ +#define PERENTRY 23 +#define RETRYSIZE 5 +#define RATESIZE 28 +#define TX_RPT2_ITEM_SIZE 8 + +/* */ +/* TX report 2 format in Rx desc */ +/* */ +#define GET_TX_RPT2_DESC_PKT_LEN_88E(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc, 0, 9) +#define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc+16, 0, 32) +#define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__pRxStatusDesc) \ + LE_BITS_TO_4BYTE(__pRxStatusDesc+20, 0, 32) + +#define GET_TX_REPORT_TYPE1_RERTY_0(__pAddr) \ + LE_BITS_TO_4BYTE(__pAddr, 0, 16) +#define GET_TX_REPORT_TYPE1_RERTY_1(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+2, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_2(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+3, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_3(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_4(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4+1, 0, 8) +#define GET_TX_REPORT_TYPE1_DROP_0(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4+2, 0, 8) +#define GET_TX_REPORT_TYPE1_DROP_1(__pAddr) \ + LE_BITS_TO_1BYTE(__pAddr+4+3, 0, 8) + +/* End rate adaptive define */ + +void ODM_RASupport_Init(struct odm_dm_struct *dm_odm); + +int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm); + +int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 MacID); + +u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 MacID); + +u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 MacID); + +u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 MacID); +void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 MacID, + u8 RateID, u32 RateMask, + u8 SGIEnable); + +void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, + u8 rssi); + +void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, + u8 *txrpt_buf, u16 txrpt_len, + u32 validentry0, u32 validentry1); + +void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime); + +#endif diff --git a/drivers/staging/r8188eu/include/Hal8188EReg.h b/drivers/staging/r8188eu/include/Hal8188EReg.h new file mode 100644 index 000000000000..06818ac6c330 --- /dev/null +++ b/drivers/staging/r8188eu/include/Hal8188EReg.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* */ +/* File Name: Hal8188EReg.h */ +/* */ +/* Description: */ +/* */ +/* This file is for RTL8188E register definition. */ +/* */ +/* */ +/* */ +#ifndef __HAL_8188E_REG_H__ +#define __HAL_8188E_REG_H__ + +/* */ +/* Register Definition */ +/* */ +#define TRX_ANTDIV_PATH 0x860 +#define RX_ANTDIV_PATH 0xb2c +#define ODM_R_A_AGC_CORE1_8188E 0xc50 + +/* */ +/* Bitmap Definition */ +/* */ +#define BIT_FA_RESET_8188E BIT0 + +#endif diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h new file mode 100644 index 000000000000..e57452104bfb --- /dev/null +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h @@ -0,0 +1,44 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_BB_8188E_HW_IMG_H +#define __INC_BB_8188E_HW_IMG_H + +/* static bool CheckCondition(const u32 Condition, const u32 Hex); */ + +/****************************************************************************** +* AGC_TAB_1T.TXT +******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *odm); + +/****************************************************************************** +* PHY_REG_1T.TXT +******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *odm); + +/****************************************************************************** +* PHY_REG_PG.TXT +******************************************************************************/ + +void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm); + +#endif diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h b/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h new file mode 100644 index 000000000000..ce81fea401a1 --- /dev/null +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h @@ -0,0 +1,33 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_FW_8188E_HW_IMG_H +#define __INC_FW_8188E_HW_IMG_H + +/****************************************************************************** +* FW_AP.TXT +******************************************************************************/ +/****************************************************************************** +* FW_WoWLAN.TXT +******************************************************************************/ +#define ArrayLength_8188E_FW_WoWLAN 15764 +extern const u8 Array_8188E_FW_WoWLAN[ArrayLength_8188E_FW_WoWLAN]; + +#endif diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h new file mode 100644 index 000000000000..acf78b94fddb --- /dev/null +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_MAC_8188E_HW_IMG_H +#define __INC_MAC_8188E_HW_IMG_H + +/****************************************************************************** +* MAC_REG.TXT +******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *pDM_Odm); + +#endif /* end of HWIMG_SUPPORT */ diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h new file mode 100644 index 000000000000..8ecb40d26c70 --- /dev/null +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h @@ -0,0 +1,30 @@ +/****************************************************************************** +* +* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify it +* under the terms of version 2 of the GNU General Public License as +* published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, but WITHOUT +* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for +* more details. +* +* You should have received a copy of the GNU General Public License along with +* this program; if not, write to the Free Software Foundation, Inc., +* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA +* +* +******************************************************************************/ + +#ifndef __INC_RF_8188E_HW_IMG_H +#define __INC_RF_8188E_HW_IMG_H + +/****************************************************************************** + * RadioA_1T.TXT + ******************************************************************************/ + +enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *odm); + +#endif /* end of HWIMG_SUPPORT */ diff --git a/drivers/staging/r8188eu/include/HalPhyRf.h b/drivers/staging/r8188eu/include/HalPhyRf.h new file mode 100644 index 000000000000..1ec497100da1 --- /dev/null +++ b/drivers/staging/r8188eu/include/HalPhyRf.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + + #ifndef __HAL_PHY_RF_H__ + #define __HAL_PHY_RF_H__ + +#define ODM_TARGET_CHNL_NUM_2G_5G 59 + +void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); + +u8 ODM_GetRightChnlPlaceforIQK(u8 chnl); + +#endif /* #ifndef __HAL_PHY_RF_H__ */ diff --git a/drivers/staging/r8188eu/include/HalPhyRf_8188e.h b/drivers/staging/r8188eu/include/HalPhyRf_8188e.h new file mode 100644 index 000000000000..807c301a86e4 --- /dev/null +++ b/drivers/staging/r8188eu/include/HalPhyRf_8188e.h @@ -0,0 +1,58 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HAL_PHY_RF_8188E_H__ +#define __HAL_PHY_RF_8188E_H__ + +/*--------------------------Define Parameters-------------------------------*/ +#define IQK_DELAY_TIME_88E 10 /* ms */ +#define index_mapping_NUM_88E 15 +#define AVG_THERMAL_NUM_88E 4 + +void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *pDM_Odm, + u8 Type, /* 0 = OFDM, 1 = CCK */ + u8 *pDirection,/* 1 = +(incr) 2 = -(decr) */ + u32 *pOutWriteVal); /* Tx tracking CCK/OFDM BB + * swing index adjust */ + +void odm_TXPowerTrackingCallback_ThermalMeter_8188E(struct adapter *Adapter); + +/* 1 7. IQK */ + +void PHY_IQCalibrate_8188E(struct adapter *Adapter, bool ReCovery); + +/* LC calibrate */ +void PHY_LCCalibrate_8188E(struct adapter *pAdapter); + +/* AP calibrate */ +void PHY_DigitalPredistortion_8188E(struct adapter *pAdapter); + +void _PHY_SaveADDARegisters(struct adapter *pAdapter, u32 *ADDAReg, + u32 *ADDABackup, u32 RegisterNum); + +void _PHY_PathADDAOn(struct adapter *pAdapter, u32 *ADDAReg, + bool isPathAOn, bool is2T); + +void _PHY_MACSettingCalibration(struct adapter *pAdapter, u32 *MACReg, + u32 *MACBackup); + +void _PHY_PathAStandBy(struct adapter *pAdapter); + +#endif /* #ifndef __HAL_PHY_RF_8188E_H__ */ diff --git a/drivers/staging/r8188eu/include/HalPwrSeqCmd.h b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h new file mode 100644 index 000000000000..c591e9d1c23b --- /dev/null +++ b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h @@ -0,0 +1,126 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HALPWRSEQCMD_H__ +#define __HALPWRSEQCMD_H__ + +#include + +/*---------------------------------------------*/ +/* 3 The value of cmd: 4 bits */ +/*---------------------------------------------*/ +#define PWR_CMD_READ 0x00 + /* offset: the read register offset */ + /* msk: the mask of the read value */ + /* value: N/A, left by 0 */ + /* note: dirver shall implement this function by read & msk */ + +#define PWR_CMD_WRITE 0x01 + /* offset: the read register offset */ + /* msk: the mask of the write bits */ + /* value: write value */ + /* note: driver shall implement this cmd by read & msk after write */ + +#define PWR_CMD_POLLING 0x02 + /* offset: the read register offset */ + /* msk: the mask of the polled value */ + /* value: the value to be polled, masked by the msd field. */ + /* note: driver shall implement this cmd by */ + /* do{ */ + /* if ( (Read(offset) & msk) == (value & msk) ) */ + /* break; */ + /* } while (not timeout); */ + +#define PWR_CMD_DELAY 0x03 + /* offset: the value to delay */ + /* msk: N/A */ + /* value: the unit of delay, 0: us, 1: ms */ + +#define PWR_CMD_END 0x04 + /* offset: N/A */ + /* msk: N/A */ + /* value: N/A */ + +/*---------------------------------------------*/ +/* 3 The value of base: 4 bits */ +/*---------------------------------------------*/ + /* define the base address of each block */ +#define PWR_BASEADDR_MAC 0x00 +#define PWR_BASEADDR_USB 0x01 +#define PWR_BASEADDR_PCIE 0x02 +#define PWR_BASEADDR_SDIO 0x03 + +/*---------------------------------------------*/ +/* 3 The value of interface_msk: 4 bits */ +/*---------------------------------------------*/ +#define PWR_INTF_SDIO_MSK BIT(0) +#define PWR_INTF_USB_MSK BIT(1) +#define PWR_INTF_PCI_MSK BIT(2) +#define PWR_INTF_ALL_MSK (BIT(0)|BIT(1)|BIT(2)|BIT(3)) + +/*---------------------------------------------*/ +/* 3 The value of fab_msk: 4 bits */ +/*---------------------------------------------*/ +#define PWR_FAB_TSMC_MSK BIT(0) +#define PWR_FAB_UMC_MSK BIT(1) +#define PWR_FAB_ALL_MSK (BIT(0)|BIT(1)|BIT(2)|BIT(3)) + +/*---------------------------------------------*/ +/* 3 The value of cut_msk: 8 bits */ +/*---------------------------------------------*/ +#define PWR_CUT_TESTCHIP_MSK BIT(0) +#define PWR_CUT_A_MSK BIT(1) +#define PWR_CUT_B_MSK BIT(2) +#define PWR_CUT_C_MSK BIT(3) +#define PWR_CUT_D_MSK BIT(4) +#define PWR_CUT_E_MSK BIT(5) +#define PWR_CUT_F_MSK BIT(6) +#define PWR_CUT_G_MSK BIT(7) +#define PWR_CUT_ALL_MSK 0xFF + +enum pwrseq_cmd_delat_unit { + PWRSEQ_DELAY_US, + PWRSEQ_DELAY_MS, +}; + +struct wl_pwr_cfg { + u16 offset; + u8 cut_msk; + u8 fab_msk:4; + u8 interface_msk:4; + u8 base:4; + u8 cmd:4; + u8 msk; + u8 value; +}; + +#define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset +#define GET_PWR_CFG_CUT_MASK(__PWR_CMD) __PWR_CMD.cut_msk +#define GET_PWR_CFG_FAB_MASK(__PWR_CMD) __PWR_CMD.fab_msk +#define GET_PWR_CFG_INTF_MASK(__PWR_CMD) __PWR_CMD.interface_msk +#define GET_PWR_CFG_BASE(__PWR_CMD) __PWR_CMD.base +#define GET_PWR_CFG_CMD(__PWR_CMD) __PWR_CMD.cmd +#define GET_PWR_CFG_MASK(__PWR_CMD) __PWR_CMD.msk +#define GET_PWR_CFG_VALUE(__PWR_CMD) __PWR_CMD.value + +/* Prototype of protected function. */ +u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 CutVersion, u8 FabVersion, + u8 InterfaceType, struct wl_pwr_cfg PwrCfgCmd[]); + +#endif diff --git a/drivers/staging/r8188eu/include/HalVerDef.h b/drivers/staging/r8188eu/include/HalVerDef.h new file mode 100644 index 000000000000..2a7dc28b8de7 --- /dev/null +++ b/drivers/staging/r8188eu/include/HalVerDef.h @@ -0,0 +1,166 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HAL_VERSION_DEF_H__ +#define __HAL_VERSION_DEF_H__ + +enum HAL_IC_TYPE { + CHIP_8192S = 0, + CHIP_8188C = 1, + CHIP_8192C = 2, + CHIP_8192D = 3, + CHIP_8723A = 4, + CHIP_8188E = 5, + CHIP_8881A = 6, + CHIP_8812A = 7, + CHIP_8821A = 8, + CHIP_8723B = 9, + CHIP_8192E = 10, +}; + +enum HAL_CHIP_TYPE { + TEST_CHIP = 0, + NORMAL_CHIP = 1, + FPGA = 2, +}; + +enum HAL_CUT_VERSION { + A_CUT_VERSION = 0, + B_CUT_VERSION = 1, + C_CUT_VERSION = 2, + D_CUT_VERSION = 3, + E_CUT_VERSION = 4, + F_CUT_VERSION = 5, + G_CUT_VERSION = 6, +}; + +enum HAL_VENDOR { + CHIP_VENDOR_TSMC = 0, + CHIP_VENDOR_UMC = 1, +}; + +enum HAL_RF_TYPE { + RF_TYPE_1T1R = 0, + RF_TYPE_1T2R = 1, + RF_TYPE_2T2R = 2, + RF_TYPE_2T3R = 3, + RF_TYPE_2T4R = 4, + RF_TYPE_3T3R = 5, + RF_TYPE_3T4R = 6, + RF_TYPE_4T4R = 7, +}; + +struct HAL_VERSION { + enum HAL_IC_TYPE ICType; + enum HAL_CHIP_TYPE ChipType; + enum HAL_CUT_VERSION CUTVersion; + enum HAL_VENDOR VendorType; + enum HAL_RF_TYPE RFType; + u8 ROMVer; +}; + +/* Get element */ +#define GET_CVID_IC_TYPE(version) (((version).ICType)) +#define GET_CVID_CHIP_TYPE(version) (((version).ChipType)) +#define GET_CVID_RF_TYPE(version) (((version).RFType)) +#define GET_CVID_MANUFACTUER(version) (((version).VendorType)) +#define GET_CVID_CUT_VERSION(version) (((version).CUTVersion)) +#define GET_CVID_ROM_VERSION(version) (((version).ROMVer) & ROM_VERSION_MASK) + +/* Common Macro. -- */ +/* HAL_VERSION VersionID */ + +/* HAL_IC_TYPE_E */ +#define IS_81XXC(version) \ + (((GET_CVID_IC_TYPE(version) == CHIP_8192C) || \ + (GET_CVID_IC_TYPE(version) == CHIP_8188C)) ? true : false) +#define IS_8723_SERIES(version) \ + ((GET_CVID_IC_TYPE(version) == CHIP_8723A) ? true : false) +#define IS_92D(version) \ + ((GET_CVID_IC_TYPE(version) == CHIP_8192D) ? true : false) +#define IS_8188E(version) \ + ((GET_CVID_IC_TYPE(version) == CHIP_8188E) ? true : false) + +/* HAL_CHIP_TYPE_E */ +#define IS_TEST_CHIP(version) \ + ((GET_CVID_CHIP_TYPE(version) == TEST_CHIP) ? true : false) +#define IS_NORMAL_CHIP(version) \ + ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false) + +/* HAL_CUT_VERSION_E */ +#define IS_A_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == A_CUT_VERSION) ? true : false) +#define IS_B_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == B_CUT_VERSION) ? true : false) +#define IS_C_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == C_CUT_VERSION) ? true : false) +#define IS_D_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == D_CUT_VERSION) ? true : false) +#define IS_E_CUT(version) \ + ((GET_CVID_CUT_VERSION(version) == E_CUT_VERSION) ? true : false) + +/* HAL_VENDOR_E */ +#define IS_CHIP_VENDOR_TSMC(version) \ + ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_TSMC) ? true : false) +#define IS_CHIP_VENDOR_UMC(version) \ + ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false) + +/* HAL_RF_TYPE_E */ +#define IS_1T1R(version) \ + ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T1R) ? true : false) +#define IS_1T2R(version) \ + ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R) ? true : false) +#define IS_2T2R(version) \ + ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R) ? true : false) + +/* Chip version Macro. -- */ +#define IS_81XXC_TEST_CHIP(version) \ + ((IS_81XXC(version) && (!IS_NORMAL_CHIP(version))) ? true : false) + +#define IS_92C_SERIAL(version) \ + ((IS_81XXC(version) && IS_2T2R(version)) ? true : false) +#define IS_81xxC_VENDOR_UMC_A_CUT(version) \ + (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \ + (IS_A_CUT(version) ? true : false) : false) : false) +#define IS_81xxC_VENDOR_UMC_B_CUT(version) \ + (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \ + (IS_B_CUT(version) ? true : false) : false) : false) +#define IS_81xxC_VENDOR_UMC_C_CUT(version) \ + (IS_81XXC(version) ? (IS_CHIP_VENDOR_UMC(version) ? \ + (IS_C_CUT(version) ? true : false) : false) : false) + +#define IS_NORMAL_CHIP92D(version) \ + ((IS_92D(version)) ? \ + ((GET_CVID_CHIP_TYPE(version) == NORMAL_CHIP) ? true : false) : false) + +#define IS_92D_SINGLEPHY(version) \ + ((IS_92D(version)) ? (IS_2T2R(version) ? true : false) : false) +#define IS_92D_C_CUT(version) \ + ((IS_92D(version)) ? (IS_C_CUT(version) ? true : false) : false) +#define IS_92D_D_CUT(version) \ + ((IS_92D(version)) ? (IS_D_CUT(version) ? true : false) : false) +#define IS_92D_E_CUT(version) \ + ((IS_92D(version)) ? (IS_E_CUT(version) ? true : false) : false) + +#define IS_8723A_A_CUT(version) \ + ((IS_8723_SERIES(version)) ? (IS_A_CUT(version) ? true : false) : false) +#define IS_8723A_B_CUT(version) \ + ((IS_8723_SERIES(version)) ? (IS_B_CUT(version) ? true : false) : false) + +#endif diff --git a/drivers/staging/r8188eu/include/autoconf.h b/drivers/staging/r8188eu/include/autoconf.h new file mode 100644 index 000000000000..cfa790794fd3 --- /dev/null +++ b/drivers/staging/r8188eu/include/autoconf.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +/* temporarily flag ******* */ +/* + * Public General Config + */ +#define RTL871X_MODULE_NAME "88EU" +#define DRV_NAME "rtl8188eu" + +/* + * Internal General Config + */ + +#define CONFIG_AP_MODE + +#define CONFIG_P2P + +#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ + +#define CONFIG_BR_EXT_BRNAME "br0" + +/* + * Debug Related Config + */ +#define DBG 1 diff --git a/drivers/staging/r8188eu/include/basic_types.h b/drivers/staging/r8188eu/include/basic_types.h new file mode 100644 index 000000000000..8a7ca992674a --- /dev/null +++ b/drivers/staging/r8188eu/include/basic_types.h @@ -0,0 +1,184 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __BASIC_TYPES_H__ +#define __BASIC_TYPES_H__ + +#define SUCCESS 0 +#define FAIL (-1) + +#include +#define NDIS_OID uint + +typedef void (*proc_t)(void *); + +#define FIELD_OFFSET(s, field) ((ssize_t)&((s *)(0))->field) + +#define MEM_ALIGNMENT_OFFSET (sizeof(size_t)) +#define MEM_ALIGNMENT_PADDING (sizeof(size_t) - 1) + +/* port from fw */ +/* TODO: Macros Below are Sync from SD7-Driver. It is necessary + * to check correctness */ + +/* + * Call endian free function when + * 1. Read/write packet content. + * 2. Before write integer to IO. + * 3. After read integer from IO. +*/ + +/* Convert little data endian to host ordering */ +#define EF1BYTE(_val) \ + ((u8)(_val)) +#define EF2BYTE(_val) \ + (le16_to_cpu(_val)) +#define EF4BYTE(_val) \ + (le32_to_cpu(_val)) + +/* Read data from memory */ +#define READEF1BYTE(_ptr) \ + EF1BYTE(*((u8 *)(_ptr))) +/* Read le16 data from memory and convert to host ordering */ +#define READEF2BYTE(_ptr) \ + EF2BYTE(*(_ptr)) +#define READEF4BYTE(_ptr) \ + EF4BYTE(*(_ptr)) + +/* Write data to memory */ +#define WRITEEF1BYTE(_ptr, _val) \ + do { \ + (*((u8 *)(_ptr))) = EF1BYTE(_val) \ + } while (0) +/* Write le data to memory in host ordering */ +#define WRITEEF2BYTE(_ptr, _val) \ + do { \ + (*((u16 *)(_ptr))) = EF2BYTE(_val) \ + } while (0) + +#define WRITEEF4BYTE(_ptr, _val) \ + do { \ + (*((u32 *)(_ptr))) = EF2BYTE(_val) \ + } while (0) + +/* Create a bit mask + * Examples: + * BIT_LEN_MASK_32(0) => 0x00000000 + * BIT_LEN_MASK_32(1) => 0x00000001 + * BIT_LEN_MASK_32(2) => 0x00000003 + * BIT_LEN_MASK_32(32) => 0xFFFFFFFF + */ +#define BIT_LEN_MASK_32(__bitlen) \ + (0xFFFFFFFF >> (32 - (__bitlen))) +#define BIT_LEN_MASK_16(__bitlen) \ + (0xFFFF >> (16 - (__bitlen))) +#define BIT_LEN_MASK_8(__bitlen) \ + (0xFF >> (8 - (__bitlen))) + +/* Create an offset bit mask + * Examples: + * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003 + * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000 + */ +#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_32(__bitlen) << (__bitoffset)) +#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_16(__bitlen) << (__bitoffset)) +#define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \ + (BIT_LEN_MASK_8(__bitlen) << (__bitoffset)) + +/*Description: + * Return 4-byte value in host byte ordering from + * 4-byte pointer in little-endian system. + */ +#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \ + (EF4BYTE(*((__le32 *)(__pstart)))) +#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \ + (EF2BYTE(*((__le16 *)(__pstart)))) +#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \ + (EF1BYTE(*((u8 *)(__pstart)))) + +/*Description: +Translate subfield (continuous bits in little-endian) of 4-byte +value to host byte ordering.*/ +#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_32(__bitlen) \ + ) +#define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_16(__bitlen) \ + ) +#define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \ + BIT_LEN_MASK_8(__bitlen) \ + ) + +/* Description: + * Mask subfield (continuous bits in little-endian) of 4-byte value + * and return the result in 4-byte value in host byte ordering. + */ +#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \ + ) +#define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \ + ) +#define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ + ( \ + LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \ + (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ + ) + +/* Description: + * Set subfield of little-endian 4-byte value to specified value. + */ +#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u32 *)(__pstart)) = \ + ( \ + LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \ + ) + +#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u16 *)(__pstart)) = \ + ( \ + LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \ + ); + +#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ + *((u8 *)(__pstart)) = EF1BYTE \ + ( \ + LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ + ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ + ) + +/* Get the N-bytes aligment offset from the current length */ +#define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \ + (__value) : (((__value + __aligment - 1) / __aligment) * __aligment)) + +#endif /* __BASIC_TYPES_H__ */ diff --git a/drivers/staging/r8188eu/include/cmd_osdep.h b/drivers/staging/r8188eu/include/cmd_osdep.h new file mode 100644 index 000000000000..5a8465e147b3 --- /dev/null +++ b/drivers/staging/r8188eu/include/cmd_osdep.h @@ -0,0 +1,32 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __CMD_OSDEP_H_ +#define __CMD_OSDEP_H_ + +#include +#include + +extern int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); +extern int _rtw_init_evt_priv(struct evt_priv *pevtpriv); +extern void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); +extern int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj); +extern struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue); + +#endif diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h new file mode 100644 index 000000000000..9aa72a91d467 --- /dev/null +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -0,0 +1,346 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/*----------------------------------------------------------------------------- + + For type defines and data structure defines + +------------------------------------------------------------------------------*/ + +#ifndef __DRV_TYPES_H__ +#define __DRV_TYPES_H__ + +#define DRV_NAME "r8188eu" +#define CONFIG_88EU_AP_MODE 1 +#define CONFIG_88EU_P2P 1 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum _NIC_VERSION { + RTL8711_NIC, + RTL8712_NIC, + RTL8713_NIC, + RTL8716_NIC +}; + +#define SPEC_DEV_ID_NONE BIT(0) +#define SPEC_DEV_ID_DISABLE_HT BIT(1) +#define SPEC_DEV_ID_ENABLE_PS BIT(2) +#define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3) +#define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4) +#define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5) + +struct specific_device_id { + u32 flags; + u16 idVendor; + u16 idProduct; +}; + +struct registry_priv { + u8 chip_version; + u8 rfintfs; + u8 lbkmode; + u8 hci; + struct ndis_802_11_ssid ssid; + u8 network_mode; /* infra, ad-hoc, auto */ + u8 channel;/* ad-hoc support requirement */ + u8 wireless_mode;/* A, B, G, auto */ + u8 scan_mode;/* active, passive */ + u8 radio_enable; + u8 preamble;/* long, short, auto */ + u8 vrtl_carrier_sense;/* Enable, Disable, Auto */ + u8 vcs_type;/* RTS/CTS, CTS-to-self */ + u16 rts_thresh; + u16 frag_thresh; + u8 adhoc_tx_pwr; + u8 soft_ap; + u8 power_mgnt; + u8 ips_mode; + u8 smart_ps; + u8 long_retry_lmt; + u8 short_retry_lmt; + u16 busy_thresh; + u8 ack_policy; + u8 mp_mode; + u8 software_encrypt; + u8 software_decrypt; + u8 acm_method; + /* UAPSD */ + u8 wmm_enable; + u8 uapsd_enable; + u8 uapsd_max_sp; + u8 uapsd_acbk_en; + u8 uapsd_acbe_en; + u8 uapsd_acvi_en; + u8 uapsd_acvo_en; + + u8 led_enable; + + struct wlan_bssid_ex dev_network; + + u8 ht_enable; + u8 cbw40_enable; + u8 ampdu_enable;/* for tx */ + u8 rx_stbc; + u8 ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */ + u8 lowrate_two_xmit; + + u8 rf_config; + u8 low_power; + + u8 wifi_spec;/* !turbo_mode */ + + u8 channel_plan; + bool bAcceptAddbaReq; + + u8 antdiv_cfg; + u8 antdiv_type; + + u8 usbss_enable;/* 0:disable,1:enable */ + u8 hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */ + u8 hwpwrp_detect;/* 0:disable,1:enable */ + + u8 hw_wps_pbc;/* 0:disable,1:enable */ + + u8 max_roaming_times; /* the max number driver will try */ + + u8 fw_iol; /* enable iol without other concern */ + + u8 enable80211d; + + u8 ifname[16]; + u8 if2name[16]; + + u8 notch_filter; +}; + +/* For registry parameters */ +#define RGTRY_OFT(field) ((u32)FIELD_OFFSET(struct registry_priv, field)) +#define RGTRY_SZ(field) sizeof(((struct registry_priv *)0)->field) +#define BSSID_OFT(field) ((u32)FIELD_OFFSET(struct wlan_bssid_ex, field)) +#define BSSID_SZ(field) sizeof(((struct wlan_bssid_ex *)0)->field) + +#define MAX_CONTINUAL_URB_ERR 4 + +struct rt_firmware { + u8 *szFwBuffer; + u32 ulFwLength; +}; + +struct dvobj_priv { + struct adapter *if1; + struct adapter *if2; + + /* For 92D, DMDP have 2 interface. */ + u8 InterfaceNumber; + u8 NumInterfaces; + + /* In /Out Pipe information */ + int RtInPipe[2]; + int RtOutPipe[3]; + u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */ + + u8 irq_alloc; + + struct rt_firmware firmware; + +/*-------- below is for USB INTERFACE --------*/ + + u8 nr_endpoint; + u8 ishighspeed; + u8 RtNumInPipes; + u8 RtNumOutPipes; + int ep_num[5]; /* endpoint number */ + int RegUsbSS; + struct semaphore usb_suspend_sema; + struct mutex usb_vendor_req_mutex; + + u8 *usb_alloc_vendor_req_buf; + u8 *usb_vendor_req_buf; + + struct usb_interface *pusbintf; + struct usb_device *pusbdev; + + ATOMIC_T continual_urb_error; + u8 signal_strength; +}; + +static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) +{ + /* todo: get interface type from dvobj and the return + * the dev accordingly */ + return &dvobj->pusbintf->dev; +}; + +enum _IFACE_TYPE { + IFACE_PORT0, /* mapping to port0 for C/D series chips */ + IFACE_PORT1, /* mapping to port1 for C/D series chip */ + MAX_IFACE_PORT, +}; + +enum _ADAPTER_TYPE { + PRIMARY_ADAPTER, + SECONDARY_ADAPTER, + MAX_ADAPTER, +}; + +enum driver_state { + DRIVER_NORMAL = 0, + DRIVER_DISAPPEAR = 1, + DRIVER_REPLACE_DONGLE = 2, +}; + +struct adapter { + int DriverState;/* for disable driver using module, use dongle toi + * replace module. */ + int pid[3];/* process id from UI, 0:wps, 1:hostapd, 2:dhcpcd */ + int bDongle;/* build-in module or external dongle */ + u16 chip_type; + u16 HardwareType; + u16 interface_type;/* USB,SDIO,SPI,PCI */ + + struct dvobj_priv *dvobj; + struct mlme_priv mlmepriv; + struct mlme_ext_priv mlmeextpriv; + struct cmd_priv cmdpriv; + struct evt_priv evtpriv; + struct io_priv iopriv; + struct xmit_priv xmitpriv; + struct recv_priv recvpriv; + struct sta_priv stapriv; + struct security_priv securitypriv; + struct registry_priv registrypriv; + struct pwrctrl_priv pwrctrlpriv; + struct eeprom_priv eeprompriv; + struct led_priv ledpriv; + struct mp_priv mppriv; + +#ifdef CONFIG_88EU_AP_MODE + struct hostapd_priv *phostapdpriv; +#endif + + struct wifidirect_info wdinfo; + + void *HalData; + u32 hal_data_sz; + struct hal_ops HalFunc; + + s32 bDriverStopped; + s32 bSurpriseRemoved; + s32 bCardDisableWOHSM; + + u32 IsrContent; + u32 ImrContent; + + u8 EepromAddressSize; + u8 hw_init_completed; + u8 bDriverIsGoingToUnload; + u8 init_adpt_in_progress; + u8 bHaltInProgress; + s8 signal_strength; + + void *cmdThread; + void *evtThread; + void *xmitThread; + void *recvThread; + void (*intf_start)(struct adapter *adapter); + void (*intf_stop)(struct adapter *adapter); + struct net_device *pnetdev; + + /* used by rtw_rereg_nd_name related function */ + struct rereg_nd_name_data { + struct net_device *old_pnetdev; + char old_ifname[IFNAMSIZ]; + u8 old_ips_mode; + u8 old_bRegUseLed; + } rereg_nd_name_priv; + + int bup; + struct net_device_stats stats; + struct iw_statistics iwstats; + struct proc_dir_entry *dir_dev;/* for proc directory */ + + int net_closed; + u8 bFWReady; + u8 bBTFWReady; + u8 bReadPortCancel; + u8 bWritePortCancel; + u8 bRxRSSIDisplay; + /* The driver will show up the desired channel number + * when this flag is 1. */ + u8 bNotifyChannelChange; +#ifdef CONFIG_88EU_P2P + /* The driver will show the current P2P status when the + * upper application reads it. */ + u8 bShowGetP2PState; +#endif + struct adapter *pbuddy_adapter; + + struct mutex *hw_init_mutex; + + spinlock_t br_ext_lock; + struct nat25_network_db_entry *nethash[NAT25_HASH_SIZE]; + int pppoe_connection_in_progress; + unsigned char pppoe_addr[MACADDRLEN]; + unsigned char scdb_mac[MACADDRLEN]; + unsigned char scdb_ip[4]; + struct nat25_network_db_entry *scdb_entry; + unsigned char br_mac[MACADDRLEN]; + unsigned char br_ip[4]; + struct br_ext_info ethBrExtInfo; + + u8 fix_rate; + + unsigned char in_cta_test; +}; + +#define adapter_to_dvobj(adapter) (adapter->dvobj) + +int rtw_handle_dualmac(struct adapter *adapter, bool init); + +static inline u8 *myid(struct eeprom_priv *peepriv) +{ + return peepriv->mac_addr; +} + +#endif /* __DRV_TYPES_H__ */ diff --git a/drivers/staging/r8188eu/include/drv_types_linux.h b/drivers/staging/r8188eu/include/drv_types_linux.h new file mode 100644 index 000000000000..f5db1dd14317 --- /dev/null +++ b/drivers/staging/r8188eu/include/drv_types_linux.h @@ -0,0 +1,23 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __DRV_TYPES_LINUX_H__ +#define __DRV_TYPES_LINUX_H__ + +#endif diff --git a/drivers/staging/r8188eu/include/ethernet.h b/drivers/staging/r8188eu/include/ethernet.h new file mode 100644 index 000000000000..5b17dcf143a4 --- /dev/null +++ b/drivers/staging/r8188eu/include/ethernet.h @@ -0,0 +1,41 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/*! \file */ +#ifndef __INC_ETHERNET_H +#define __INC_ETHERNET_H + +#define ETHERNET_ADDRESS_LENGTH 6 /* Ethernet Address Length */ +#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ +#define LLC_HEADER_SIZE 6 /* LLC Header Length */ +#define TYPE_LENGTH_FIELD_SIZE 2 /* Type/Length Size */ +#define MINIMUM_ETHERNET_PACKET_SIZE 60 /* Min Ethernet Packet Size */ +#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /* Max Ethernet Packet Size */ + +/* Is Multicast Address? */ +#define RT_ETH_IS_MULTICAST(_addr) ((((u8 *)(_addr))[0]&0x01) != 0) +#define RT_ETH_IS_BROADCAST(_addr) ( \ + ((u8 *)(_addr))[0] == 0xff && \ + ((u8 *)(_addr))[1] == 0xff && \ + ((u8 *)(_addr))[2] == 0xff && \ + ((u8 *)(_addr))[3] == 0xff && \ + ((u8 *)(_addr))[4] == 0xff && \ + ((u8 *)(_addr))[5] == 0xff) /* Is Broadcast Address? */ + +#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/r8188eu/include/h2clbk.h b/drivers/staging/r8188eu/include/h2clbk.h new file mode 100644 index 000000000000..72b67827bc6e --- /dev/null +++ b/drivers/staging/r8188eu/include/h2clbk.h @@ -0,0 +1,32 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#define _H2CLBK_H_ + +#include +#include + +void _lbk_cmd(struct adapter *adapter); + +void _lbk_rsp(struct adapter *adapter); + +void _lbk_evt(IN struct adapter *adapter); + +void h2c_event_callback(unsigned char *dev, unsigned char *pbuf); diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h new file mode 100644 index 000000000000..652f645d54ff --- /dev/null +++ b/drivers/staging/r8188eu/include/hal_com.h @@ -0,0 +1,172 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HAL_COMMON_H__ +#define __HAL_COMMON_H__ + +/* */ +/* Rate Definition */ +/* */ +/* CCK */ +#define RATR_1M 0x00000001 +#define RATR_2M 0x00000002 +#define RATR_55M 0x00000004 +#define RATR_11M 0x00000008 +/* OFDM */ +#define RATR_6M 0x00000010 +#define RATR_9M 0x00000020 +#define RATR_12M 0x00000040 +#define RATR_18M 0x00000080 +#define RATR_24M 0x00000100 +#define RATR_36M 0x00000200 +#define RATR_48M 0x00000400 +#define RATR_54M 0x00000800 +/* MCS 1 Spatial Stream */ +#define RATR_MCS0 0x00001000 +#define RATR_MCS1 0x00002000 +#define RATR_MCS2 0x00004000 +#define RATR_MCS3 0x00008000 +#define RATR_MCS4 0x00010000 +#define RATR_MCS5 0x00020000 +#define RATR_MCS6 0x00040000 +#define RATR_MCS7 0x00080000 +/* MCS 2 Spatial Stream */ +#define RATR_MCS8 0x00100000 +#define RATR_MCS9 0x00200000 +#define RATR_MCS10 0x00400000 +#define RATR_MCS11 0x00800000 +#define RATR_MCS12 0x01000000 +#define RATR_MCS13 0x02000000 +#define RATR_MCS14 0x04000000 +#define RATR_MCS15 0x08000000 + +/* CCK */ +#define RATE_1M BIT(0) +#define RATE_2M BIT(1) +#define RATE_5_5M BIT(2) +#define RATE_11M BIT(3) +/* OFDM */ +#define RATE_6M BIT(4) +#define RATE_9M BIT(5) +#define RATE_12M BIT(6) +#define RATE_18M BIT(7) +#define RATE_24M BIT(8) +#define RATE_36M BIT(9) +#define RATE_48M BIT(10) +#define RATE_54M BIT(11) +/* MCS 1 Spatial Stream */ +#define RATE_MCS0 BIT(12) +#define RATE_MCS1 BIT(13) +#define RATE_MCS2 BIT(14) +#define RATE_MCS3 BIT(15) +#define RATE_MCS4 BIT(16) +#define RATE_MCS5 BIT(17) +#define RATE_MCS6 BIT(18) +#define RATE_MCS7 BIT(19) +/* MCS 2 Spatial Stream */ +#define RATE_MCS8 BIT(20) +#define RATE_MCS9 BIT(21) +#define RATE_MCS10 BIT(22) +#define RATE_MCS11 BIT(23) +#define RATE_MCS12 BIT(24) +#define RATE_MCS13 BIT(25) +#define RATE_MCS14 BIT(26) +#define RATE_MCS15 BIT(27) + +/* ALL CCK Rate */ +#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) +#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ + RATR_24M | RATR_36M | RATR_48M | RATR_54M) +#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ + RATR_MCS3 | RATR_MCS4 | RATR_MCS5|RATR_MCS6 | \ + RATR_MCS7) +#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ + RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ + RATR_MCS14 | RATR_MCS15) + +/*------------------------------ Tx Desc definition Macro --------------------*/ +/* pragma mark -- Tx Desc related definition. -- */ +/* Rate */ +/* CCK Rates, TxHT = 0 */ +#define DESC_RATE1M 0x00 +#define DESC_RATE2M 0x01 +#define DESC_RATE5_5M 0x02 +#define DESC_RATE11M 0x03 + +/* OFDM Rates, TxHT = 0 */ +#define DESC_RATE6M 0x04 +#define DESC_RATE9M 0x05 +#define DESC_RATE12M 0x06 +#define DESC_RATE18M 0x07 +#define DESC_RATE24M 0x08 +#define DESC_RATE36M 0x09 +#define DESC_RATE48M 0x0a +#define DESC_RATE54M 0x0b + +/* MCS Rates, TxHT = 1 */ +#define DESC_RATEMCS0 0x0c +#define DESC_RATEMCS1 0x0d +#define DESC_RATEMCS2 0x0e +#define DESC_RATEMCS3 0x0f +#define DESC_RATEMCS4 0x10 +#define DESC_RATEMCS5 0x11 +#define DESC_RATEMCS6 0x12 +#define DESC_RATEMCS7 0x13 +#define DESC_RATEMCS8 0x14 +#define DESC_RATEMCS9 0x15 +#define DESC_RATEMCS10 0x16 +#define DESC_RATEMCS11 0x17 +#define DESC_RATEMCS12 0x18 +#define DESC_RATEMCS13 0x19 +#define DESC_RATEMCS14 0x1a +#define DESC_RATEMCS15 0x1b +#define DESC_RATEMCS15_SG 0x1c +#define DESC_RATEMCS32 0x20 + +/* 1 Byte long (in unit of TU) */ +#define REG_P2P_CTWIN 0x0572 +#define REG_NOA_DESC_SEL 0x05CF +#define REG_NOA_DESC_DURATION 0x05E0 +#define REG_NOA_DESC_INTERVAL 0x05E4 +#define REG_NOA_DESC_START 0x05E8 +#define REG_NOA_DESC_COUNT 0x05EC + +#include "HalVerDef.h" +void dump_chip_info(struct HAL_VERSION ChipVersion); + +/* return the final channel plan decision */ +u8 hal_com_get_channel_plan(struct adapter *padapter, + u8 hw_channel_plan, + u8 sw_channel_plan, + u8 def_channel_plan, + bool AutoLoadFail +); + +u8 MRateToHwRate(u8 rate); + +void HalSetBrateCfg(struct adapter *Adapter, u8 *mBratesOS, u16 *pBrateCfg); + +bool Hal_MappingOutPipe(struct adapter *pAdapter, u8 NumOutPipe); + +void hal_init_macaddr(struct adapter *adapter); + +void c2h_evt_clear(struct adapter *adapter); +s32 c2h_evt_read(struct adapter *adapter, u8 *buf); + +#endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h new file mode 100644 index 000000000000..49539b862863 --- /dev/null +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -0,0 +1,430 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __HAL_INTF_H__ +#define __HAL_INTF_H__ + +#include +#include +#include + +enum RTL871X_HCI_TYPE { + RTW_PCIE = BIT0, + RTW_USB = BIT1, + RTW_SDIO = BIT2, + RTW_GSPI = BIT3, +}; + +enum _CHIP_TYPE { + NULL_CHIP_TYPE, + RTL8712_8188S_8191S_8192S, + RTL8188C_8192C, + RTL8192D, + RTL8723A, + RTL8188E, + MAX_CHIP_TYPE +}; + +enum hw_variables { + HW_VAR_MEDIA_STATUS, + HW_VAR_MEDIA_STATUS1, + HW_VAR_SET_OPMODE, + HW_VAR_MAC_ADDR, + HW_VAR_BSSID, + HW_VAR_INIT_RTS_RATE, + HW_VAR_BASIC_RATE, + HW_VAR_TXPAUSE, + HW_VAR_BCN_FUNC, + HW_VAR_CORRECT_TSF, + HW_VAR_CHECK_BSSID, + HW_VAR_MLME_DISCONNECT, + HW_VAR_MLME_SITESURVEY, + HW_VAR_MLME_JOIN, + HW_VAR_BEACON_INTERVAL, + HW_VAR_SLOT_TIME, + HW_VAR_RESP_SIFS, + HW_VAR_ACK_PREAMBLE, + HW_VAR_SEC_CFG, + HW_VAR_BCN_VALID, + HW_VAR_RF_TYPE, + HW_VAR_DM_FLAG, + HW_VAR_DM_FUNC_OP, + HW_VAR_DM_FUNC_SET, + HW_VAR_DM_FUNC_CLR, + HW_VAR_CAM_EMPTY_ENTRY, + HW_VAR_CAM_INVALID_ALL, + HW_VAR_CAM_WRITE, + HW_VAR_CAM_READ, + HW_VAR_AC_PARAM_VO, + HW_VAR_AC_PARAM_VI, + HW_VAR_AC_PARAM_BE, + HW_VAR_AC_PARAM_BK, + HW_VAR_ACM_CTRL, + HW_VAR_AMPDU_MIN_SPACE, + HW_VAR_AMPDU_FACTOR, + HW_VAR_RXDMA_AGG_PG_TH, + HW_VAR_SET_RPWM, + HW_VAR_H2C_FW_PWRMODE, + HW_VAR_H2C_FW_JOINBSSRPT, + HW_VAR_FWLPS_RF_ON, + HW_VAR_H2C_FW_P2P_PS_OFFLOAD, + HW_VAR_TDLS_WRCR, + HW_VAR_TDLS_INIT_CH_SEN, + HW_VAR_TDLS_RS_RCR, + HW_VAR_TDLS_DONE_CH_SEN, + HW_VAR_INITIAL_GAIN, + HW_VAR_TRIGGER_GPIO_0, + HW_VAR_BT_SET_COEXIST, + HW_VAR_BT_ISSUE_DELBA, + HW_VAR_CURRENT_ANTENNA, + HW_VAR_ANTENNA_DIVERSITY_LINK, + HW_VAR_ANTENNA_DIVERSITY_SELECT, + HW_VAR_SWITCH_EPHY_WoWLAN, + HW_VAR_EFUSE_USAGE, + HW_VAR_EFUSE_BYTES, + HW_VAR_EFUSE_BT_USAGE, + HW_VAR_EFUSE_BT_BYTES, + HW_VAR_FIFO_CLEARN_UP, + HW_VAR_CHECK_TXBUF, + HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, + * power control for MAC only */ + /* The valid upper nav range for the HW updating, if the true value is + * larger than the upper range, the HW won't update it. */ + /* Unit in microsecond. 0 means disable this function. */ + HW_VAR_NAV_UPPER, + HW_VAR_RPT_TIMER_SETTING, + HW_VAR_TX_RPT_MAX_MACID, + HW_VAR_H2C_MEDIA_STATUS_RPT, + HW_VAR_CHK_HI_QUEUE_EMPTY, +}; + +enum hal_def_variable { + HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, + HAL_DEF_IS_SUPPORT_ANT_DIV, + HAL_DEF_CURRENT_ANTENNA, + HAL_DEF_DRVINFO_SZ, + HAL_DEF_MAX_RECVBUF_SZ, + HAL_DEF_RX_PACKET_OFFSET, + HAL_DEF_DBG_DUMP_RXPKT,/* for dbg */ + HAL_DEF_DBG_DM_FUNC,/* for dbg */ + HAL_DEF_RA_DECISION_RATE, + HAL_DEF_RA_SGI, + HAL_DEF_PT_PWR_STATUS, + HW_VAR_MAX_RX_AMPDU_FACTOR, + HW_DEF_RA_INFO_DUMP, + HAL_DEF_DBG_DUMP_TXPKT, + HW_DEF_FA_CNT_DUMP, + HW_DEF_ODM_DBG_FLAG, +}; + +enum hal_odm_variable { + HAL_ODM_STA_INFO, + HAL_ODM_P2P_STATE, + HAL_ODM_WIFI_DISPLAY_STATE, +}; + +enum hal_intf_ps_func { + HAL_USB_SELECT_SUSPEND, + HAL_MAX_ID, +}; + +typedef s32 (*c2h_id_filter)(u8 id); + +struct hal_ops { + u32 (*hal_power_on)(struct adapter *padapter); + u32 (*hal_init)(struct adapter *padapter); + u32 (*hal_deinit)(struct adapter *padapter); + + void (*free_hal_data)(struct adapter *padapter); + + u32 (*inirp_init)(struct adapter *padapter); + u32 (*inirp_deinit)(struct adapter *padapter); + + s32 (*init_xmit_priv)(struct adapter *padapter); + void (*free_xmit_priv)(struct adapter *padapter); + + s32 (*init_recv_priv)(struct adapter *padapter); + void (*free_recv_priv)(struct adapter *padapter); + + void (*InitSwLeds)(struct adapter *padapter); + void (*DeInitSwLeds)(struct adapter *padapter); + + void (*dm_init)(struct adapter *padapter); + void (*dm_deinit)(struct adapter *padapter); + void (*read_chip_version)(struct adapter *padapter); + + void (*init_default_value)(struct adapter *padapter); + + void (*intf_chip_configure)(struct adapter *padapter); + + void (*read_adapter_info)(struct adapter *padapter); + + void (*enable_interrupt)(struct adapter *padapter); + void (*disable_interrupt)(struct adapter *padapter); + s32 (*interrupt_handler)(struct adapter *padapter); + + void (*set_bwmode_handler)(struct adapter *padapter, + enum ht_channel_width Bandwidth, + u8 Offset); + void (*set_channel_handler)(struct adapter *padapter, u8 channel); + + void (*hal_dm_watchdog)(struct adapter *padapter); + + void (*SetHwRegHandler)(struct adapter *padapter, u8 variable, + u8 *val); + void (*GetHwRegHandler)(struct adapter *padapter, u8 variable, + u8 *val); + + u8 (*GetHalDefVarHandler)(struct adapter *padapter, + enum hal_def_variable eVariable, + void *pValue); + u8 (*SetHalDefVarHandler)(struct adapter *padapter, + enum hal_def_variable eVariable, + void *pValue); + + void (*GetHalODMVarHandler)(struct adapter *padapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); + void (*SetHalODMVarHandler)(struct adapter *padapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); + + void (*UpdateRAMaskHandler)(struct adapter *padapter, + u32 mac_id, u8 rssi_level); + void (*SetBeaconRelatedRegistersHandler)(struct adapter *padapter); + + void (*Add_RateATid)(struct adapter *adapter, u32 bitmap, u8 arg, + u8 rssi_level); + void (*run_thread)(struct adapter *adapter); + void (*cancel_thread)(struct adapter *adapter); + + u8 (*AntDivBeforeLinkHandler)(struct adapter *adapter); + void (*AntDivCompareHandler)(struct adapter *adapter, + struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src); + u8 (*interface_ps_func)(struct adapter *padapter, + enum hal_intf_ps_func efunc_id, u8 *val); + + s32 (*hal_xmit)(struct adapter *padapter, + struct xmit_frame *pxmitframe); + s32 (*mgnt_xmit)(struct adapter *padapter, + struct xmit_frame *pmgntframe); + s32 (*hal_xmitframe_enqueue)(struct adapter *padapter, + struct xmit_frame *pxmitframe); + + u32 (*read_bbreg)(struct adapter *padapter, u32 RegAddr, + u32 BitMask); + void (*write_bbreg)(struct adapter *padapter, u32 RegAddr, + u32 BitMask, u32 Data); + u32 (*read_rfreg)(struct adapter *padapter, + enum rf_radio_path eRFPath, u32 RegAddr, + u32 BitMask); + void (*write_rfreg)(struct adapter *padapter, + enum rf_radio_path eRFPath, u32 RegAddr, + u32 BitMask, u32 Data); + + void (*EfusePowerSwitch)(struct adapter *padapter, u8 bWrite, + u8 PwrState); + void (*ReadEFuse)(struct adapter *padapter, u8 efuseType, u16 _offset, + u16 _size_byte, u8 *pbuf, bool bPseudoTest); + void (*EFUSEGetEfuseDefinition)(struct adapter *padapter, u8 efuseType, + u8 type, void *pOut, bool bPseudoTest); + u16 (*EfuseGetCurrentSize)(struct adapter *padapter, u8 efuseType, + bool bPseudoTest); + int (*Efuse_PgPacketRead)(struct adapter *adapter, u8 offset, + u8 *data, bool bPseudoTest); + int (*Efuse_PgPacketWrite)(struct adapter *padapter, u8 offset, + u8 word_en, u8 *data, bool bPseudoTest); + u8 (*Efuse_WordEnableDataWrite)(struct adapter *padapter, + u16 efuse_addr, u8 word_en, + u8 *data, bool bPseudoTest); + bool (*Efuse_PgPacketWrite_BT)(struct adapter *padapter, u8 offset, + u8 word_en, u8 *data, bool test); + + void (*sreset_init_value)(struct adapter *padapter); + void (*sreset_reset_value)(struct adapter *padapter); + void (*silentreset)(struct adapter *padapter); + void (*sreset_xmit_status_check)(struct adapter *padapter); + void (*sreset_linked_status_check) (struct adapter *padapter); + u8 (*sreset_get_wifi_status)(struct adapter *padapter); + + int (*IOL_exec_cmds_sync)(struct adapter *padapter, + struct xmit_frame *frame, u32 max_wait, + u32 bndy_cnt); + + void (*hal_notch_filter)(struct adapter *adapter, bool enable); + void (*hal_reset_security_engine)(struct adapter *adapter); + s32 (*c2h_handler)(struct adapter *padapter, + struct c2h_evt_hdr *c2h_evt); + c2h_id_filter c2h_id_filter_ccx; +}; + +enum rt_eeprom_type { + EEPROM_93C46, + EEPROM_93C56, + EEPROM_BOOT_EFUSE, +}; + +#define RF_CHANGE_BY_INIT 0 +#define RF_CHANGE_BY_IPS BIT28 +#define RF_CHANGE_BY_PS BIT29 +#define RF_CHANGE_BY_HW BIT30 +#define RF_CHANGE_BY_SW BIT31 + +enum hardware_type { + HARDWARE_TYPE_RTL8180, + HARDWARE_TYPE_RTL8185, + HARDWARE_TYPE_RTL8187, + HARDWARE_TYPE_RTL8188, + HARDWARE_TYPE_RTL8190P, + HARDWARE_TYPE_RTL8192E, + HARDWARE_TYPE_RTL819xU, + HARDWARE_TYPE_RTL8192SE, + HARDWARE_TYPE_RTL8192SU, + HARDWARE_TYPE_RTL8192CE, + HARDWARE_TYPE_RTL8192CU, + HARDWARE_TYPE_RTL8192DE, + HARDWARE_TYPE_RTL8192DU, + HARDWARE_TYPE_RTL8723AE, + HARDWARE_TYPE_RTL8723AU, + HARDWARE_TYPE_RTL8723AS, + HARDWARE_TYPE_RTL8188EE, + HARDWARE_TYPE_RTL8188EU, + HARDWARE_TYPE_RTL8188ES, + HARDWARE_TYPE_MAX, +}; + +/* RTL8188E Series */ +#define IS_HARDWARE_TYPE_8188EE(_Adapter) \ +(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EE) +#define IS_HARDWARE_TYPE_8188EU(_Adapter) \ +(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188EU) +#define IS_HARDWARE_TYPE_8188ES(_Adapter) \ +(((struct adapter *)_Adapter)->HardwareType == HARDWARE_TYPE_RTL8188ES) +#define IS_HARDWARE_TYPE_8188E(_Adapter) \ +(IS_HARDWARE_TYPE_8188EE(_Adapter) || IS_HARDWARE_TYPE_8188EU(_Adapter) || \ + IS_HARDWARE_TYPE_8188ES(_Adapter)) + +#define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) + +#define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) + +void rtw_hal_def_value_init(struct adapter *padapter); + +void rtw_hal_free_data(struct adapter *padapter); + +void rtw_hal_dm_init(struct adapter *padapter); +void rtw_hal_dm_deinit(struct adapter *padapter); +void rtw_hal_sw_led_init(struct adapter *padapter); +void rtw_hal_sw_led_deinit(struct adapter *padapter); + +u32 rtw_hal_power_on(struct adapter *padapter); +uint rtw_hal_init(struct adapter *padapter); +uint rtw_hal_deinit(struct adapter *padapter); +void rtw_hal_stop(struct adapter *padapter); +void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val); +void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val); + +void rtw_hal_chip_configure(struct adapter *padapter); +void rtw_hal_read_chip_info(struct adapter *padapter); +void rtw_hal_read_chip_version(struct adapter *padapter); + +u8 rtw_hal_set_def_var(struct adapter *padapter, + enum hal_def_variable eVariable, void *pValue); +u8 rtw_hal_get_def_var(struct adapter *padapter, + enum hal_def_variable eVariable, void *pValue); + +void rtw_hal_set_odm_var(struct adapter *padapter, + enum hal_odm_variable eVariable, void *pValue1, + bool bSet); +void rtw_hal_get_odm_var(struct adapter *padapter, + enum hal_odm_variable eVariable, + void *pValue1, bool bSet); + +void rtw_hal_enable_interrupt(struct adapter *padapter); +void rtw_hal_disable_interrupt(struct adapter *padapter); + +u32 rtw_hal_inirp_init(struct adapter *padapter); +u32 rtw_hal_inirp_deinit(struct adapter *padapter); + +u8 rtw_hal_intf_ps_func(struct adapter *padapter, + enum hal_intf_ps_func efunc_id, u8 *val); +s32 rtw_hal_xmitframe_enqueue(struct adapter *padapter, + struct xmit_frame *pxmitframe); + +s32 rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); +s32 rtw_hal_mgnt_xmit(struct adapter *padapter, + struct xmit_frame *pmgntframe); + +s32 rtw_hal_init_xmit_priv(struct adapter *padapter); +void rtw_hal_free_xmit_priv(struct adapter *padapter); + +s32 rtw_hal_init_recv_priv(struct adapter *padapter); +void rtw_hal_free_recv_priv(struct adapter *padapter); + +void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level); +void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, u8 level); +void rtw_hal_clone_data(struct adapter *dst_adapt, + struct adapter *src_adapt); +void rtw_hal_start_thread(struct adapter *padapter); +void rtw_hal_stop_thread(struct adapter *padapter); + +void rtw_hal_bcn_related_reg_setting(struct adapter *padapter); + +u32 rtw_hal_read_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask); +void rtw_hal_write_bbreg(struct adapter *padapter, u32 RegAddr, u32 BitMask, + u32 Data); +u32 rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath, + u32 RegAddr, u32 BitMask); +void rtw_hal_write_rfreg(struct adapter *padapter, + enum rf_radio_path eRFPath, u32 RegAddr, + u32 BitMask, u32 Data); + +s32 rtw_hal_interrupt_handler(struct adapter *padapter); + +void rtw_hal_set_bwmode(struct adapter *padapter, + enum ht_channel_width Bandwidth, u8 Offset); +void rtw_hal_set_chan(struct adapter *padapter, u8 channel); +void rtw_hal_dm_watchdog(struct adapter *padapter); + +u8 rtw_hal_antdiv_before_linked(struct adapter *padapter); +void rtw_hal_antdiv_rssi_compared(struct adapter *padapter, + struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src); + +void rtw_hal_sreset_init(struct adapter *padapter); +void rtw_hal_sreset_reset(struct adapter *padapter); +void rtw_hal_sreset_reset_value(struct adapter *padapter); +void rtw_hal_sreset_xmit_status_check(struct adapter *padapter); +void rtw_hal_sreset_linked_status_check(struct adapter *padapter); +u8 rtw_hal_sreset_get_wifi_status(struct adapter *padapter); + +int rtw_hal_iol_cmd(struct adapter *adapter, struct xmit_frame *xmit_frame, + u32 max_wating_ms, u32 bndy_cnt); + +void rtw_hal_notch_filter(struct adapter *adapter, bool enable); +void rtw_hal_reset_security_engine(struct adapter *adapter); + +s32 rtw_hal_c2h_handler(struct adapter *adapter, + struct c2h_evt_hdr *c2h_evt); +c2h_id_filter rtw_hal_c2h_id_filter_ccx(struct adapter *adapter); +void indicate_wx_scan_complete_event(struct adapter *padapter); +u8 rtw_do_join(struct adapter *padapter); + +#endif /* __HAL_INTF_H__ */ diff --git a/drivers/staging/r8188eu/include/ieee80211.h b/drivers/staging/r8188eu/include/ieee80211.h new file mode 100644 index 000000000000..0e6beaebeb0f --- /dev/null +++ b/drivers/staging/r8188eu/include/ieee80211.h @@ -0,0 +1,1261 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __IEEE80211_H +#define __IEEE80211_H + +#include +#include +#include "wifi.h" +#include + +#define MGMT_QUEUE_NUM 5 + +#define ETH_ALEN 6 +#define ETH_TYPE_LEN 2 +#define PAYLOAD_TYPE_LEN 1 + +#ifdef CONFIG_88EU_AP_MODE + +#define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28) + +/* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */ +enum { + RTL871X_HOSTAPD_FLUSH = 1, + RTL871X_HOSTAPD_ADD_STA = 2, + RTL871X_HOSTAPD_REMOVE_STA = 3, + RTL871X_HOSTAPD_GET_INFO_STA = 4, + /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */ + RTL871X_HOSTAPD_GET_WPAIE_STA = 5, + RTL871X_SET_ENCRYPTION = 6, + RTL871X_GET_ENCRYPTION = 7, + RTL871X_HOSTAPD_SET_FLAGS_STA = 8, + RTL871X_HOSTAPD_GET_RID = 9, + RTL871X_HOSTAPD_SET_RID = 10, + RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11, + RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12, + RTL871X_HOSTAPD_MLME = 13, + RTL871X_HOSTAPD_SCAN_REQ = 14, + RTL871X_HOSTAPD_STA_CLEAR_STATS = 15, + RTL871X_HOSTAPD_SET_BEACON = 16, + RTL871X_HOSTAPD_SET_WPS_BEACON = 17, + RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18, + RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19, + RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20, + RTL871X_HOSTAPD_SET_MACADDR_ACL = 21, + RTL871X_HOSTAPD_ACL_ADD_STA = 22, + RTL871X_HOSTAPD_ACL_REMOVE_STA = 23, +}; + +/* STA flags */ +#define WLAN_STA_AUTH BIT(0) +#define WLAN_STA_ASSOC BIT(1) +#define WLAN_STA_PS BIT(2) +#define WLAN_STA_TIM BIT(3) +#define WLAN_STA_PERM BIT(4) +#define WLAN_STA_AUTHORIZED BIT(5) +#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */ +#define WLAN_STA_SHORT_PREAMBLE BIT(7) +#define WLAN_STA_PREAUTH BIT(8) +#define WLAN_STA_WME BIT(9) +#define WLAN_STA_MFP BIT(10) +#define WLAN_STA_HT BIT(11) +#define WLAN_STA_WPS BIT(12) +#define WLAN_STA_MAYBE_WPS BIT(13) +#define WLAN_STA_NONERP BIT(31) + +#endif + +#define IEEE_CMD_SET_WPA_PARAM 1 +#define IEEE_CMD_SET_WPA_IE 2 +#define IEEE_CMD_SET_ENCRYPTION 3 +#define IEEE_CMD_MLME 4 + +#define IEEE_PARAM_WPA_ENABLED 1 +#define IEEE_PARAM_TKIP_COUNTERMEASURES 2 +#define IEEE_PARAM_DROP_UNENCRYPTED 3 +#define IEEE_PARAM_PRIVACY_INVOKED 4 +#define IEEE_PARAM_AUTH_ALGS 5 +#define IEEE_PARAM_IEEE_802_1X 6 +#define IEEE_PARAM_WPAX_SELECT 7 + +#define AUTH_ALG_OPEN_SYSTEM 0x1 +#define AUTH_ALG_SHARED_KEY 0x2 +#define AUTH_ALG_LEAP 0x00000004 + +#define IEEE_MLME_STA_DEAUTH 1 +#define IEEE_MLME_STA_DISASSOC 2 + +#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 +#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 +#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 +#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 +#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 +#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 + +#define IEEE_CRYPT_ALG_NAME_LEN 16 + +#define WPA_CIPHER_NONE BIT(0) +#define WPA_CIPHER_WEP40 BIT(1) +#define WPA_CIPHER_WEP104 BIT(2) +#define WPA_CIPHER_TKIP BIT(3) +#define WPA_CIPHER_CCMP BIT(4) + + +#define WPA_SELECTOR_LEN 4 +extern u8 RTW_WPA_OUI_TYPE[]; +extern u16 RTW_WPA_VERSION; +extern u8 WPA_AUTH_KEY_MGMT_NONE[]; +extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[]; +extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; +extern u8 WPA_CIPHER_SUITE_NONE[]; +extern u8 WPA_CIPHER_SUITE_WEP40[]; +extern u8 WPA_CIPHER_SUITE_TKIP[]; +extern u8 WPA_CIPHER_SUITE_WRAP[]; +extern u8 WPA_CIPHER_SUITE_CCMP[]; +extern u8 WPA_CIPHER_SUITE_WEP104[]; + +#define RSN_HEADER_LEN 4 +#define RSN_SELECTOR_LEN 4 + +extern u16 RSN_VERSION_BSD; +extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[]; +extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; +extern u8 RSN_CIPHER_SUITE_NONE[]; +extern u8 RSN_CIPHER_SUITE_WEP40[]; +extern u8 RSN_CIPHER_SUITE_TKIP[]; +extern u8 RSN_CIPHER_SUITE_WRAP[]; +extern u8 RSN_CIPHER_SUITE_CCMP[]; +extern u8 RSN_CIPHER_SUITE_WEP104[]; + +enum ratr_table_mode { + RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */ + RATR_INX_WIRELESS_NG = 1, /* GN or N */ + RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */ + RATR_INX_WIRELESS_N = 3, + RATR_INX_WIRELESS_GB = 4, + RATR_INX_WIRELESS_G = 5, + RATR_INX_WIRELESS_B = 6, + RATR_INX_WIRELESS_MC = 7, + RATR_INX_WIRELESS_AC_N = 8, +}; + +enum NETWORK_TYPE { + WIRELESS_INVALID = 0, + /* Sub-Element */ + WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */ + WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/ + WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */ + WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */ + WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */ + WIRELESS_AC = BIT(6), + + /* Combination */ + /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ + WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), + /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ + WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N), + /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ + WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N), + /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ + WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), + /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ + WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | + WIRELESS_11_5N), + WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | + WIRELESS_11_24N | WIRELESS_11_5N), +}; + +#define SUPPORTED_24G_NETTYPE_MSK \ + (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) +#define SUPPORTED_5G_NETTYPE_MSK \ + (WIRELESS_11A | WIRELESS_11_5N) + +#define IsSupported24G(NetType) \ + ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) +#define IsSupported5G(NetType) \ + ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false) + +#define IsEnableHWCCK(NetType) \ + IsSupported24G(NetType) +#define IsEnableHWOFDM(NetType) \ + ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | \ + SUPPORTED_5G_NETTYPE_MSK) ? true : false) + +#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) +#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) +#define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType) + +#define IsSupportedTxCCK(NetType) \ + ((NetType) & (WIRELESS_11B) ? true : false) +#define IsSupportedTxOFDM(NetType) \ + ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false) +#define IsSupportedTxMCS(NetType) \ + ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false) + +struct ieee_param { + u32 cmd; + u8 sta_addr[ETH_ALEN]; + union { + struct { + u8 name; + u32 value; + } wpa_param; + struct { + u32 len; + u8 reserved[32]; + u8 data[0]; + } wpa_ie; + struct { + int command; + int reason_code; + } mlme; + struct { + u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; + u8 set_tx; + u32 err; + u8 idx; + u8 seq[8]; /* sequence counter (set: RX, get: TX) */ + u16 key_len; + u8 key[0]; + } crypt; +#ifdef CONFIG_88EU_AP_MODE + struct { + u16 aid; + u16 capability; + int flags; + u8 tx_supp_rates[16]; + struct ieee80211_ht_cap ht_cap; + } add_sta; + struct { + u8 reserved[2];/* for set max_num_sta */ + u8 buf[0]; + } bcn_ie; +#endif + + } u; +}; + +#ifdef CONFIG_88EU_AP_MODE +struct ieee_param_ex { + u32 cmd; + u8 sta_addr[ETH_ALEN]; + u8 data[0]; +}; + +struct sta_data { + u16 aid; + u16 capability; + int flags; + u32 sta_set; + u8 tx_supp_rates[16]; + u32 tx_supp_rates_len; + struct ieee80211_ht_cap ht_cap; + u64 rx_pkts; + u64 rx_bytes; + u64 rx_drops; + u64 tx_pkts; + u64 tx_bytes; + u64 tx_drops; +}; +#endif + +#define IEEE80211_DATA_LEN 2304 +/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section + 6.2.1.1.2. + + The figure in section 7.1.2 suggests a body size of up to 2312 + bytes is allowed, which is a bit confusing, I suspect this + represents the 2304 bytes of real data, plus a possible 8 bytes of + WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) */ + +#define IEEE80211_HLEN 30 +#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) + +/* this is stolen from ipw2200 driver */ +#define IEEE_IBSS_MAC_HASH_SIZE 31 + +struct ieee_ibss_seq { + u8 mac[ETH_ALEN]; + u16 seq_num; + u16 frag_num; + unsigned long packet_time; + struct list_head list; +}; + +struct rtw_ieee80211_hdr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; + u8 addr4[ETH_ALEN]; +} __packed; + +struct rtw_ieee80211_hdr_3addr { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; +} __packed; + +struct rtw_ieee80211_hdr_qos { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; + u8 addr4[ETH_ALEN]; + u16 qc; +} __packed; + +struct rtw_ieee80211_hdr_3addr_qos { + __le16 frame_ctl; + __le16 duration_id; + u8 addr1[ETH_ALEN]; + u8 addr2[ETH_ALEN]; + u8 addr3[ETH_ALEN]; + u16 seq_ctl; + u16 qc; +} __packed; + +struct eapol { + u8 snap[6]; + u16 ethertype; + u8 version; + u8 type; + u16 length; +} __packed; + +enum eap_type { + EAP_PACKET = 0, + EAPOL_START, + EAPOL_LOGOFF, + EAPOL_KEY, + EAPOL_ENCAP_ASF_ALERT +}; + +#define IEEE80211_3ADDR_LEN 24 +#define IEEE80211_4ADDR_LEN 30 +#define IEEE80211_FCS_LEN 4 + +#define MIN_FRAG_THRESHOLD 256U +#define MAX_FRAG_THRESHOLD 2346U + +/* Frame control field constants */ +#define RTW_IEEE80211_FCTL_VERS 0x0003 +#define RTW_IEEE80211_FCTL_FTYPE 0x000c +#define RTW_IEEE80211_FCTL_STYPE 0x00f0 +#define RTW_IEEE80211_FCTL_TODS 0x0100 +#define RTW_IEEE80211_FCTL_FROMDS 0x0200 +#define RTW_IEEE80211_FCTL_MOREFRAGS 0x0400 +#define RTW_IEEE80211_FCTL_RETRY 0x0800 +#define RTW_IEEE80211_FCTL_PM 0x1000 +#define RTW_IEEE80211_FCTL_MOREDATA 0x2000 +#define RTW_IEEE80211_FCTL_PROTECTED 0x4000 +#define RTW_IEEE80211_FCTL_ORDER 0x8000 +#define RTW_IEEE80211_FCTL_CTL_EXT 0x0f00 + +#define RTW_IEEE80211_FTYPE_MGMT 0x0000 +#define RTW_IEEE80211_FTYPE_CTL 0x0004 +#define RTW_IEEE80211_FTYPE_DATA 0x0008 +#define RTW_IEEE80211_FTYPE_EXT 0x000c + +/* management */ +#define RTW_IEEE80211_STYPE_ASSOC_REQ 0x0000 +#define RTW_IEEE80211_STYPE_ASSOC_RESP 0x0010 +#define RTW_IEEE80211_STYPE_REASSOC_REQ 0x0020 +#define RTW_IEEE80211_STYPE_REASSOC_RESP 0x0030 +#define RTW_IEEE80211_STYPE_PROBE_REQ 0x0040 +#define RTW_IEEE80211_STYPE_PROBE_RESP 0x0050 +#define RTW_IEEE80211_STYPE_BEACON 0x0080 +#define RTW_IEEE80211_STYPE_ATIM 0x0090 +#define RTW_IEEE80211_STYPE_DISASSOC 0x00A0 +#define RTW_IEEE80211_STYPE_AUTH 0x00B0 +#define RTW_IEEE80211_STYPE_DEAUTH 0x00C0 +#define RTW_IEEE80211_STYPE_ACTION 0x00D0 + +/* control */ +#define RTW_IEEE80211_STYPE_CTL_EXT 0x0060 +#define RTW_IEEE80211_STYPE_BACK_REQ 0x0080 +#define RTW_IEEE80211_STYPE_BACK 0x0090 +#define RTW_IEEE80211_STYPE_PSPOLL 0x00A0 +#define RTW_IEEE80211_STYPE_RTS 0x00B0 +#define RTW_IEEE80211_STYPE_CTS 0x00C0 +#define RTW_IEEE80211_STYPE_ACK 0x00D0 +#define RTW_IEEE80211_STYPE_CFEND 0x00E0 +#define RTW_IEEE80211_STYPE_CFENDACK 0x00F0 + +/* data */ +#define RTW_IEEE80211_STYPE_DATA 0x0000 +#define RTW_IEEE80211_STYPE_DATA_CFACK 0x0010 +#define RTW_IEEE80211_STYPE_DATA_CFPOLL 0x0020 +#define RTW_IEEE80211_STYPE_DATA_CFACKPOLL 0x0030 +#define RTW_IEEE80211_STYPE_NULLFUNC 0x0040 +#define RTW_IEEE80211_STYPE_CFACK 0x0050 +#define RTW_IEEE80211_STYPE_CFPOLL 0x0060 +#define RTW_IEEE80211_STYPE_CFACKPOLL 0x0070 +#define RTW_IEEE80211_STYPE_QOS_DATA 0x0080 +#define RTW_IEEE80211_STYPE_QOS_DATA_CFACK 0x0090 +#define RTW_IEEE80211_STYPE_QOS_DATA_CFPOLL 0x00A0 +#define RTW_IEEE80211_STYPE_QOS_DATA_CFACKPOLL 0x00B0 +#define RTW_IEEE80211_STYPE_QOS_NULLFUNC 0x00C0 +#define RTW_IEEE80211_STYPE_QOS_CFACK 0x00D0 +#define RTW_IEEE80211_STYPE_QOS_CFPOLL 0x00E0 +#define RTW_IEEE80211_STYPE_QOS_CFACKPOLL 0x00F0 + +/* sequence control field */ +#define RTW_IEEE80211_SCTL_FRAG 0x000F +#define RTW_IEEE80211_SCTL_SEQ 0xFFF0 + +#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) +#define RTW_ERP_INFO_USE_PROTECTION BIT(1) +#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) + +/* QoS, QOS */ +#define NORMAL_ACK 0 +#define NO_ACK 1 +#define NON_EXPLICIT_ACK 2 +#define BLOCK_ACK 3 + +#ifndef ETH_P_PAE +#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ +#endif /* ETH_P_PAE */ + +#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ + +#define ETH_P_ECONET 0x0018 + +#ifndef ETH_P_80211_RAW +#define ETH_P_80211_RAW (ETH_P_ECONET + 1) +#endif + +/* IEEE 802.11 defines */ + +#define P80211_OUI_LEN 3 + +struct ieee80211_snap_hdr { + u8 dsap; /* always 0xAA */ + u8 ssap; /* always 0xAA */ + u8 ctrl; /* always 0x03 */ + u8 oui[P80211_OUI_LEN]; /* organizational universal id */ +} __packed; + +#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) + +#define WLAN_FC_GET_TYPE(fc) ((fc) & RTW_IEEE80211_FCTL_FTYPE) +#define WLAN_FC_GET_STYPE(fc) ((fc) & RTW_IEEE80211_FCTL_STYPE) + +#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) + +#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) +#define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) + +/* Authentication algorithms */ +#define WLAN_AUTH_OPEN 0 +#define WLAN_AUTH_SHARED_KEY 1 + +#define WLAN_AUTH_CHALLENGE_LEN 128 + +#define WLAN_CAPABILITY_BSS (1<<0) +#define WLAN_CAPABILITY_IBSS (1<<1) +#define WLAN_CAPABILITY_CF_POLLABLE (1<<2) +#define WLAN_CAPABILITY_CF_POLL_REQUEST (1<<3) +#define WLAN_CAPABILITY_PRIVACY (1<<4) +#define WLAN_CAPABILITY_SHORT_PREAMBLE (1<<5) +#define WLAN_CAPABILITY_PBCC (1<<6) +#define WLAN_CAPABILITY_CHANNEL_AGILITY (1<<7) +#define WLAN_CAPABILITY_SHORT_SLOT (1<<10) + +/* Status codes */ +#define WLAN_STATUS_SUCCESS 0 +#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 +#define WLAN_STATUS_CAPS_UNSUPPORTED 10 +#define WLAN_STATUS_REASSOC_NO_ASSOC 11 +#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 +#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 +#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 +#define WLAN_STATUS_CHALLENGE_FAIL 15 +#define WLAN_STATUS_AUTH_TIMEOUT 16 +#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 +#define WLAN_STATUS_ASSOC_DENIED_RATES 18 +/* 802.11b */ +#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 +#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 +#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 + +/* Reason codes */ +#define WLAN_REASON_UNSPECIFIED 1 +#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 +#define WLAN_REASON_DEAUTH_LEAVING 3 +#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 +#define WLAN_REASON_DISASSOC_AP_BUSY 5 +#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 +#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 +#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 +#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 +#define WLAN_REASON_JOIN_WRONG_CHANNEL 65534 +#define WLAN_REASON_EXPIRATION_CHK 65535 + +/* Information Element IDs */ +#define WLAN_EID_SSID 0 +#define WLAN_EID_SUPP_RATES 1 +#define WLAN_EID_FH_PARAMS 2 +#define WLAN_EID_DS_PARAMS 3 +#define WLAN_EID_CF_PARAMS 4 +#define WLAN_EID_TIM 5 +#define WLAN_EID_IBSS_PARAMS 6 +#define WLAN_EID_CHALLENGE 16 +/* EIDs defined by IEEE 802.11h - START */ +#define WLAN_EID_PWR_CONSTRAINT 32 +#define WLAN_EID_PWR_CAPABILITY 33 +#define WLAN_EID_TPC_REQUEST 34 +#define WLAN_EID_TPC_REPORT 35 +#define WLAN_EID_SUPPORTED_CHANNELS 36 +#define WLAN_EID_CHANNEL_SWITCH 37 +#define WLAN_EID_MEASURE_REQUEST 38 +#define WLAN_EID_MEASURE_REPORT 39 +#define WLAN_EID_QUITE 40 +#define WLAN_EID_IBSS_DFS 41 +/* EIDs defined by IEEE 802.11h - END */ +#define WLAN_EID_ERP_INFO 42 +#define WLAN_EID_HT_CAP 45 +#define WLAN_EID_RSN 48 +#define WLAN_EID_EXT_SUPP_RATES 50 +#define WLAN_EID_MOBILITY_DOMAIN 54 +#define WLAN_EID_FAST_BSS_TRANSITION 55 +#define WLAN_EID_TIMEOUT_INTERVAL 56 +#define WLAN_EID_RIC_DATA 57 +#define WLAN_EID_HT_OPERATION 61 +#define WLAN_EID_SECONDARY_CHANNEL_OFFSET 62 +#define WLAN_EID_20_40_BSS_COEXISTENCE 72 +#define WLAN_EID_20_40_BSS_INTOLERANT 73 +#define WLAN_EID_OVERLAPPING_BSS_SCAN_PARAMS 74 +#define WLAN_EID_MMIE 76 +#define WLAN_EID_VENDOR_SPECIFIC 221 +#define WLAN_EID_GENERIC (WLAN_EID_VENDOR_SPECIFIC) + +#define IEEE80211_MGMT_HDR_LEN 24 +#define IEEE80211_DATA_HDR3_LEN 24 +#define IEEE80211_DATA_HDR4_LEN 30 + +#define IEEE80211_STATMASK_SIGNAL (1<<0) +#define IEEE80211_STATMASK_RSSI (1<<1) +#define IEEE80211_STATMASK_NOISE (1<<2) +#define IEEE80211_STATMASK_RATE (1<<3) +#define IEEE80211_STATMASK_WEMASK 0x7 + +#define IEEE80211_CCK_MODULATION (1<<0) +#define IEEE80211_OFDM_MODULATION (1<<1) + +#define IEEE80211_24GHZ_BAND (1<<0) +#define IEEE80211_52GHZ_BAND (1<<1) + +#define IEEE80211_CCK_RATE_LEN 4 +#define IEEE80211_NUM_OFDM_RATESLEN 8 + +#define IEEE80211_CCK_RATE_1MB 0x02 +#define IEEE80211_CCK_RATE_2MB 0x04 +#define IEEE80211_CCK_RATE_5MB 0x0B +#define IEEE80211_CCK_RATE_11MB 0x16 +#define IEEE80211_OFDM_RATE_LEN 8 +#define IEEE80211_OFDM_RATE_6MB 0x0C +#define IEEE80211_OFDM_RATE_9MB 0x12 +#define IEEE80211_OFDM_RATE_12MB 0x18 +#define IEEE80211_OFDM_RATE_18MB 0x24 +#define IEEE80211_OFDM_RATE_24MB 0x30 +#define IEEE80211_OFDM_RATE_36MB 0x48 +#define IEEE80211_OFDM_RATE_48MB 0x60 +#define IEEE80211_OFDM_RATE_54MB 0x6C +#define IEEE80211_BASIC_RATE_MASK 0x80 + +#define IEEE80211_CCK_RATE_1MB_MASK (1<<0) +#define IEEE80211_CCK_RATE_2MB_MASK (1<<1) +#define IEEE80211_CCK_RATE_5MB_MASK (1<<2) +#define IEEE80211_CCK_RATE_11MB_MASK (1<<3) +#define IEEE80211_OFDM_RATE_6MB_MASK (1<<4) +#define IEEE80211_OFDM_RATE_9MB_MASK (1<<5) +#define IEEE80211_OFDM_RATE_12MB_MASK (1<<6) +#define IEEE80211_OFDM_RATE_18MB_MASK (1<<7) +#define IEEE80211_OFDM_RATE_24MB_MASK (1<<8) +#define IEEE80211_OFDM_RATE_36MB_MASK (1<<9) +#define IEEE80211_OFDM_RATE_48MB_MASK (1<<10) +#define IEEE80211_OFDM_RATE_54MB_MASK (1<<11) + +#define IEEE80211_CCK_RATES_MASK 0x0000000F +#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ + IEEE80211_CCK_RATE_2MB_MASK) +#define IEEE80211_CCK_DEFAULT_RATES_MASK \ + (IEEE80211_CCK_BASIC_RATES_MASK | \ + IEEE80211_CCK_RATE_5MB_MASK | \ + IEEE80211_CCK_RATE_11MB_MASK) + +#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 +#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ + IEEE80211_OFDM_RATE_12MB_MASK | \ + IEEE80211_OFDM_RATE_24MB_MASK) +#define IEEE80211_OFDM_DEFAULT_RATES_MASK \ + (IEEE80211_OFDM_BASIC_RATES_MASK | \ + IEEE80211_OFDM_RATE_9MB_MASK | \ + IEEE80211_OFDM_RATE_18MB_MASK | \ + IEEE80211_OFDM_RATE_36MB_MASK | \ + IEEE80211_OFDM_RATE_48MB_MASK | \ + IEEE80211_OFDM_RATE_54MB_MASK) +#define IEEE80211_DEFAULT_RATES_MASK \ + (IEEE80211_OFDM_DEFAULT_RATES_MASK | \ + IEEE80211_CCK_DEFAULT_RATES_MASK) + +#define IEEE80211_NUM_OFDM_RATES 8 +#define IEEE80211_NUM_CCK_RATES 4 +#define IEEE80211_OFDM_SHIFT_MASK_A 4 + +/* NOTE: This data is for statistical purposes; not all hardware provides this + * information for frames received. Not setting these will not cause + * any adverse affects. */ +struct ieee80211_rx_stats { + /* u32 mac_time[2]; */ + s8 rssi; + u8 signal; + u8 noise; + u8 received_channel; + u16 rate; /* in 100 kbps */ + /* u8 control; */ + u8 mask; + u8 freq; + u16 len; +}; + +/* IEEE 802.11 requires that STA supports concurrent reception of at least + * three fragmented frames. This define can be increased to support more + * concurrent frames, but it should be noted that each entry can consume about + * 2 kB of RAM and increasing cache size will slow down frame reassembly. */ +#define IEEE80211_FRAG_CACHE_LEN 4 + +struct ieee80211_frag_entry { + u32 first_frag_time; + uint seq; + uint last_frag; + uint qos; /* jackson */ + uint tid; /* jackson */ + struct sk_buff *skb; + u8 src_addr[ETH_ALEN]; + u8 dst_addr[ETH_ALEN]; +}; + +struct ieee80211_stats { + uint tx_unicast_frames; + uint tx_multicast_frames; + uint tx_fragments; + uint tx_unicast_octets; + uint tx_multicast_octets; + uint tx_deferred_transmissions; + uint tx_single_retry_frames; + uint tx_multiple_retry_frames; + uint tx_retry_limit_exceeded; + uint tx_discards; + uint rx_unicast_frames; + uint rx_multicast_frames; + uint rx_fragments; + uint rx_unicast_octets; + uint rx_multicast_octets; + uint rx_fcs_errors; + uint rx_discards_no_buffer; + uint tx_discards_wrong_sa; + uint rx_discards_undecryptable; + uint rx_message_in_msg_fragments; + uint rx_message_in_bad_msg_fragments; +}; + +struct ieee80211_softmac_stats { + uint rx_ass_ok; + uint rx_ass_err; + uint rx_probe_rq; + uint tx_probe_rs; + uint tx_beacons; + uint rx_auth_rq; + uint rx_auth_rs_ok; + uint rx_auth_rs_err; + uint tx_auth_rq; + uint no_auth_rs; + uint no_ass_rs; + uint tx_ass_rq; + uint rx_ass_rq; + uint tx_probe_rq; + uint reassoc; + uint swtxstop; + uint swtxawake; +}; + +#define SEC_KEY_1 (1<<0) +#define SEC_KEY_2 (1<<1) +#define SEC_KEY_3 (1<<2) +#define SEC_KEY_4 (1<<3) +#define SEC_ACTIVE_KEY (1<<4) +#define SEC_AUTH_MODE (1<<5) +#define SEC_UNICAST_GROUP (1<<6) +#define SEC_LEVEL (1<<7) +#define SEC_ENABLED (1<<8) + +#define SEC_LEVEL_0 0 /* None */ +#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ +#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ +#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ +#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ + +#define WEP_KEYS 4 +#define WEP_KEY_LEN 13 + +struct ieee80211_security { + u16 active_key:2, + enabled:1, + auth_mode:2, + auth_algo:4, + unicast_uses_group:1; + u8 key_sizes[WEP_KEYS]; + u8 keys[WEP_KEYS][WEP_KEY_LEN]; + u8 level; + u16 flags; +} __packed; + +/* + + 802.11 data frame from AP + + ,-------------------------------------------------------------------. +Bytes | 2 | 2 | 6 | 6 | 6 | 2 | 0..2312 | 4 | + |------|------|---------|---------|---------|------|---------|------| +Desc. | ctrl | dura | DA/RA | TA | SA | Sequ | frame | fcs | + | | tion | (BSSID) | | | ence | data | | + `-------------------------------------------------------------------' + +Total: 28-2340 bytes + +*/ + +struct ieee80211_header_data { + u16 frame_ctl; + u16 duration_id; + u8 addr1[6]; + u8 addr2[6]; + u8 addr3[6]; + u16 seq_ctrl; +}; + +#define BEACON_PROBE_SSID_ID_POSITION 12 + +/* Management Frame Information Element Types */ +#define MFIE_TYPE_SSID 0 +#define MFIE_TYPE_RATES 1 +#define MFIE_TYPE_FH_SET 2 +#define MFIE_TYPE_DS_SET 3 +#define MFIE_TYPE_CF_SET 4 +#define MFIE_TYPE_TIM 5 +#define MFIE_TYPE_IBSS_SET 6 +#define MFIE_TYPE_CHALLENGE 16 +#define MFIE_TYPE_ERP 42 +#define MFIE_TYPE_RSN 48 +#define MFIE_TYPE_RATES_EX 50 +#define MFIE_TYPE_GENERIC 221 + +struct ieee80211_info_element_hdr { + u8 id; + u8 len; +} __packed; + +struct ieee80211_info_element { + u8 id; + u8 len; + u8 data[0]; +} __packed; + +/* + * These are the data types that can make up management packets + * + u16 auth_algorithm; + u16 auth_sequence; + u16 beacon_interval; + u16 capability; + u8 current_ap[ETH_ALEN]; + u16 listen_interval; + struct { + u16 association_id:14, reserved:2; + } __packed; + u32 time_stamp[2]; + u16 reason; + u16 status; +*/ + +#define IEEE80211_DEFAULT_TX_ESSID "Penguin" +#define IEEE80211_DEFAULT_BASIC_RATE 10 + +struct ieee80211_authentication { + struct ieee80211_header_data header; + u16 algorithm; + u16 transaction; + u16 status; + /* struct ieee80211_info_element_hdr info_element; */ +} __packed; + +struct ieee80211_probe_response { + struct ieee80211_header_data header; + u32 time_stamp[2]; + u16 beacon_interval; + u16 capability; + struct ieee80211_info_element info_element; +} __packed; + +struct ieee80211_probe_request { + struct ieee80211_header_data header; +} __packed; + +struct ieee80211_assoc_request_frame { + struct rtw_ieee80211_hdr_3addr header; + u16 capability; + u16 listen_interval; + struct ieee80211_info_element_hdr info_element; +} __packed; + +struct ieee80211_assoc_response_frame { + struct rtw_ieee80211_hdr_3addr header; + u16 capability; + u16 status; + u16 aid; +} __packed; + +struct ieee80211_txb { + u8 nr_frags; + u8 encrypted; + u16 reserved; + u16 frag_size; + u16 payload_size; + struct sk_buff *fragments[0]; +}; + +/* SWEEP TABLE ENTRIES NUMBER*/ +#define MAX_SWEEP_TAB_ENTRIES 42 +#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 +/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs + * only use 8, and then use extended rates for the remaining supported + * rates. Other APs, however, stick all of their supported rates on the + * main rates information element... */ +#define MAX_RATES_LENGTH ((u8)12) +#define MAX_RATES_EX_LENGTH ((u8)16) +#define MAX_NETWORK_COUNT 128 +#define MAX_CHANNEL_NUMBER 161 +#define IEEE80211_SOFTMAC_SCAN_TIME 400 +/* HZ / 2) */ +#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) + +#define CRC_LENGTH 4U + +#define MAX_WPA_IE_LEN (256) +#define MAX_WPS_IE_LEN (512) +#define MAX_P2P_IE_LEN (256) +#define MAX_WFD_IE_LEN (128) + +#define NETWORK_EMPTY_ESSID (1<<0) +#define NETWORK_HAS_OFDM (1<<1) +#define NETWORK_HAS_CCK (1<<2) + +#define IEEE80211_DTIM_MBCAST 4 +#define IEEE80211_DTIM_UCAST 2 +#define IEEE80211_DTIM_VALID 1 +#define IEEE80211_DTIM_INVALID 0 + +#define IEEE80211_PS_DISABLED 0 +#define IEEE80211_PS_UNICAST IEEE80211_DTIM_UCAST +#define IEEE80211_PS_MBCAST IEEE80211_DTIM_MBCAST +#define IW_ESSID_MAX_SIZE 32 +/* +join_res: +-1: authentication fail +-2: association fail +> 0: TID +*/ + +enum ieee80211_state { + /* the card is not linked at all */ + IEEE80211_NOLINK = 0, + + /* IEEE80211_ASSOCIATING* are for BSS client mode + * the driver shall not perform RX filtering unless + * the state is LINKED. + * The driver shall just check for the state LINKED and + * defaults to NOLINK for ALL the other states (including + * LINKED_SCANNING) + */ + + /* the association procedure will start (wq scheduling)*/ + IEEE80211_ASSOCIATING, + IEEE80211_ASSOCIATING_RETRY, + + /* the association procedure is sending AUTH request*/ + IEEE80211_ASSOCIATING_AUTHENTICATING, + + /* the association procedure has successfully authentcated + * and is sending association request + */ + IEEE80211_ASSOCIATING_AUTHENTICATED, + + /* the link is ok. the card associated to a BSS or linked + * to a ibss cell or acting as an AP and creating the bss + */ + IEEE80211_LINKED, + + /* same as LINKED, but the driver shall apply RX filter + * rules as we are in NO_LINK mode. As the card is still + * logically linked, but it is doing a syncro site survey + * then it will be back to LINKED state. + */ + IEEE80211_LINKED_SCANNING, + +}; + +#define DEFAULT_MAX_SCAN_AGE (15 * HZ) +#define DEFAULT_FTS 2346 + +static inline int is_multicast_mac_addr(const u8 *addr) +{ + return ((addr[0] != 0xff) && (0x01 & addr[0])); +} + +static inline int is_broadcast_mac_addr(const u8 *addr) +{ + return (addr[0] == 0xff) && (addr[1] == 0xff) && (addr[2] == 0xff) && + (addr[3] == 0xff) && (addr[4] == 0xff) && (addr[5] == 0xff); +} + +#define CFG_IEEE80211_RESERVE_FCS (1<<0) +#define CFG_IEEE80211_COMPUTE_FCS (1<<1) + +struct tx_pending { + int frag; + struct ieee80211_txb *txb; +}; + +#define MAXTID 16 + +#define IEEE_A (1<<0) +#define IEEE_B (1<<1) +#define IEEE_G (1<<2) +#define IEEE_MODE_MASK (IEEE_A|IEEE_B|IEEE_G) + +/* Baron move to ieee80211.c */ +int ieee80211_is_empty_essid(const char *essid, int essid_len); +int ieee80211_get_hdrlen(u16 fc); + +/* Action category code */ +enum rtw_ieee80211_category { + RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, + RTW_WLAN_CATEGORY_QOS = 1, + RTW_WLAN_CATEGORY_DLS = 2, + RTW_WLAN_CATEGORY_BACK = 3, + RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ + RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5, + RTW_WLAN_CATEGORY_FT = 6, + RTW_WLAN_CATEGORY_HT = 7, + RTW_WLAN_CATEGORY_SA_QUERY = 8, + RTW_WLAN_CATEGORY_TDLS = 12, + RTW_WLAN_CATEGORY_WMM = 17, + RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ +}; + +/* SPECTRUM_MGMT action code */ +enum rtw_ieee80211_spectrum_mgmt_actioncode { + RTW_WLAN_ACTION_SPCT_MSR_REQ = 0, + RTW_WLAN_ACTION_SPCT_MSR_RPRT = 1, + RTW_WLAN_ACTION_SPCT_TPC_REQ = 2, + RTW_WLAN_ACTION_SPCT_TPC_RPRT = 3, + RTW_WLAN_ACTION_SPCT_CHL_SWITCH = 4, + RTW_WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, +}; + +enum _PUBLIC_ACTION { + ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ + ACT_PUBLIC_DSE_ENABLE = 1, + ACT_PUBLIC_DSE_DEENABLE = 2, + ACT_PUBLIC_DSE_REG_LOCATION = 3, + ACT_PUBLIC_EXT_CHL_SWITCH = 4, + ACT_PUBLIC_DSE_MSR_REQ = 5, + ACT_PUBLIC_DSE_MSR_RPRT = 6, + ACT_PUBLIC_MP = 7, /* Measurement Pilot */ + ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, + ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ + ACT_PUBLIC_GAS_INITIAL_REQ = 10, + ACT_PUBLIC_GAS_INITIAL_RSP = 11, + ACT_PUBLIC_GAS_COMEBACK_REQ = 12, + ACT_PUBLIC_GAS_COMEBACK_RSP = 13, + ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, + ACT_PUBLIC_LOCATION_TRACK = 15, + ACT_PUBLIC_MAX +}; + +/* BACK action code */ +enum rtw_ieee80211_back_actioncode { + RTW_WLAN_ACTION_ADDBA_REQ = 0, + RTW_WLAN_ACTION_ADDBA_RESP = 1, + RTW_WLAN_ACTION_DELBA = 2, +}; + +/* HT features action code */ +enum rtw_ieee80211_ht_actioncode { + RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0, + RTW_WLAN_ACTION_SM_PS = 1, + RTW_WLAN_ACTION_PSPM = 2, + RTW_WLAN_ACTION_PCO_PHASE = 3, + RTW_WLAN_ACTION_MIMO_CSI_MX = 4, + RTW_WLAN_ACTION_MIMO_NONCP_BF = 5, + RTW_WLAN_ACTION_MIMP_CP_BF = 6, + RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7, + RTW_WLAN_ACTION_HI_INFO_EXCHG = 8, +}; + +/* BACK (block-ack) parties */ +enum rtw_ieee80211_back_parties { + RTW_WLAN_BACK_RECIPIENT = 0, + RTW_WLAN_BACK_INITIATOR = 1, + RTW_WLAN_BACK_TIMER = 2, +}; + +#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) + * 00:50:F2 */ +#define WME_OUI_TYPE 2 +#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 +#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 +#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 +#define WME_VERSION 1 + +#define WME_ACTION_CODE_SETUP_REQUEST 0 +#define WME_ACTION_CODE_SETUP_RESPONSE 1 +#define WME_ACTION_CODE_TEARDOWN 2 + +#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 +#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 +#define WME_SETUP_RESPONSE_STATUS_REFUSED 3 + +#define WME_TSPEC_DIRECTION_UPLINK 0 +#define WME_TSPEC_DIRECTION_DOWNLINK 1 +#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 + +#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ + +#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ + +/** + * enum rtw_ieee80211_channel_flags - channel flags + * + * Channel flags set by the regulatory control code. + * + * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. + * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted + * on this channel. + * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. + * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. + * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel + * is not permitted. + * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel + * is not permitted. + */ +enum rtw_ieee80211_channel_flags { + RTW_IEEE80211_CHAN_DISABLED = 1<<0, + RTW_IEEE80211_CHAN_PASSIVE_SCAN = 1<<1, + RTW_IEEE80211_CHAN_NO_IBSS = 1<<2, + RTW_IEEE80211_CHAN_RADAR = 1<<3, + RTW_IEEE80211_CHAN_NO_HT40PLUS = 1<<4, + RTW_IEEE80211_CHAN_NO_HT40MINUS = 1<<5, +}; + +#define RTW_IEEE80211_CHAN_NO_HT40 \ + (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS) + +/* Represent channel details, subset of ieee80211_channel */ +struct rtw_ieee80211_channel { + u16 hw_value; + u32 flags; +}; + +#define CHAN_FMT \ + "hw_value:%u, " \ + "flags:0x%08x" \ + +#define CHAN_ARG(channel) \ + (channel)->hw_value \ + , (channel)->flags \ + +/* Parsed Information Elements */ +struct rtw_ieee802_11_elems { + u8 *ssid; + u8 ssid_len; + u8 *supp_rates; + u8 supp_rates_len; + u8 *fh_params; + u8 fh_params_len; + u8 *ds_params; + u8 ds_params_len; + u8 *cf_params; + u8 cf_params_len; + u8 *tim; + u8 tim_len; + u8 *ibss_params; + u8 ibss_params_len; + u8 *challenge; + u8 challenge_len; + u8 *erp_info; + u8 erp_info_len; + u8 *ext_supp_rates; + u8 ext_supp_rates_len; + u8 *wpa_ie; + u8 wpa_ie_len; + u8 *rsn_ie; + u8 rsn_ie_len; + u8 *wme; + u8 wme_len; + u8 *wme_tspec; + u8 wme_tspec_len; + u8 *wps_ie; + u8 wps_ie_len; + u8 *power_cap; + u8 power_cap_len; + u8 *supp_channels; + u8 supp_channels_len; + u8 *mdie; + u8 mdie_len; + u8 *ftie; + u8 ftie_len; + u8 *timeout_int; + u8 timeout_int_len; + u8 *ht_capabilities; + u8 ht_capabilities_len; + u8 *ht_operation; + u8 ht_operation_len; + u8 *vendor_ht_cap; + u8 vendor_ht_cap_len; +}; + +enum parse_res { + ParseOK = 0, + ParseUnknown = 1, + ParseFailed = -1 +}; + +enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, + struct rtw_ieee802_11_elems *elems, + int show_errors); + +u8 *rtw_set_fixed_ie(unsigned char *pbuf, unsigned int len, + unsigned char *source, unsigned int *frlen); +u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen); + +enum secondary_ch_offset { + SCN = 0, /* no secondary channel */ + SCA = 1, /* secondary channel above */ + SCB = 3, /* secondary channel below */ +}; +u8 secondary_ch_offset_to_hal_ch_offset(u8 ch_offset); +u8 hal_ch_offset_to_secondary_ch_offset(u8 ch_offset); +u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, + u8 new_ch, u8 ch_switch_cnt); +u8 *rtw_set_ie_secondary_ch_offset(u8 *buf, u32 *buf_len, + u8 secondary_ch_offset); +u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, + u8 flags, u16 reason, u16 precedence); + +u8 *rtw_get_ie(u8 *pbuf, int index, int *len, int limit); +u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, + u8 oui_len, u8 *ie, uint *ielen); +int rtw_ies_remove_ie(u8 *ies, uint *ies_len, uint offset, + u8 eid, u8 *oui, u8 oui_len); + +void rtw_set_supported_rate(u8 *SupportedRates, uint mode); + +unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit); +unsigned char *rtw_get_wpa2_ie(unsigned char *pie, int *rsn_ie_len, int limit); +int rtw_get_wpa_cipher_suite(u8 *s); +int rtw_get_wpa2_cipher_suite(u8 *s); +int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); +int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, + int *pairwise_cipher, int *is_8021x); +int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, + int *pairwise_cipher, int *is_8021x); + +int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, + u8 *wpa_ie, u16 *wpa_len); + +u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); +u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); +u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, + u8 *buf_attr, u32 *len_attr); +u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, + u8 *buf_content, uint *len_content); + +/** + * for_each_ie - iterate over continuous IEs + * @ie: + * @buf: + * @buf_len: + */ +#define for_each_ie(ie, buf, buf_len) \ + for (ie = (void *)buf; (((u8 *)ie) - ((u8 *)buf) + 1) < buf_len; \ + ie = (void *)(((u8 *)ie) + *(((u8 *)ie)+1) + 2)) + +void dump_ies(u8 *buf, u32 buf_len); +void dump_wps_ie(u8 *ie, u32 ie_len); + +#ifdef CONFIG_88EU_P2P +void dump_p2p_ie(u8 *ie, u32 ie_len); +u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen); +u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, + u8 *buf_attr, u32 *len_attr); +u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, + u8 *buf_content, uint *len_content); +u32 rtw_set_p2p_attr_content(u8 *pbuf, u8 attr_id, u16 attr_len, + u8 *pdata_attr); +void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, + u8 attr_id); +#endif + +uint rtw_get_rateset_len(u8 *rateset); + +struct registry_priv; +int rtw_generate_ie(struct registry_priv *pregistrypriv); + +int rtw_get_bit_value_from_ieee_value(u8 val); + +uint rtw_is_cckrates_included(u8 *rate); + +uint rtw_is_cckratesonly_included(u8 *rate); + +int rtw_check_network_type(unsigned char *rate, int ratelen, int channel); + +void rtw_get_bcn_info(struct wlan_network *pnetwork); + +void rtw_macaddr_cfg(u8 *mac_addr); + +u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, + unsigned char *MCS_rate); + +int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, + u8 *action); +const char *action_public_str(u8 action); + +#endif /* IEEE80211_H */ diff --git a/drivers/staging/r8188eu/include/ieee80211_ext.h b/drivers/staging/r8188eu/include/ieee80211_ext.h new file mode 100644 index 000000000000..fa9e52572fe9 --- /dev/null +++ b/drivers/staging/r8188eu/include/ieee80211_ext.h @@ -0,0 +1,287 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __IEEE80211_EXT_H +#define __IEEE80211_EXT_H + +#include +#include + +#define WMM_OUI_TYPE 2 +#define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0 +#define WMM_OUI_SUBTYPE_PARAMETER_ELEMENT 1 +#define WMM_OUI_SUBTYPE_TSPEC_ELEMENT 2 +#define WMM_VERSION 1 + +#define WPA_PROTO_WPA BIT(0) +#define WPA_PROTO_RSN BIT(1) + +#define WPA_KEY_MGMT_IEEE8021X BIT(0) +#define WPA_KEY_MGMT_PSK BIT(1) +#define WPA_KEY_MGMT_NONE BIT(2) +#define WPA_KEY_MGMT_IEEE8021X_NO_WPA BIT(3) +#define WPA_KEY_MGMT_WPA_NONE BIT(4) + +#define WPA_CAPABILITY_PREAUTH BIT(0) +#define WPA_CAPABILITY_MGMT_FRAME_PROTECTION BIT(6) +#define WPA_CAPABILITY_PEERKEY_ENABLED BIT(9) + +#define PMKID_LEN 16 + +struct wpa_ie_hdr { + u8 elem_id; + u8 len; + u8 oui[4]; /* 24-bit OUI followed by 8-bit OUI type */ + u8 version[2]; /* little endian */ +} __packed; + +struct rsn_ie_hdr { + u8 elem_id; /* WLAN_EID_RSN */ + u8 len; + u8 version[2]; /* little endian */ +} __packed; + +struct wme_ac_parameter { +#if defined(__LITTLE_ENDIAN) + /* byte 1 */ + u8 aifsn:4, + acm:1, + aci:2, + reserved:1; + + /* byte 2 */ + u8 eCWmin:4, + eCWmax:4; +#elif defined(__BIG_ENDIAN) + /* byte 1 */ + u8 reserved:1, + aci:2, + acm:1, + aifsn:4; + + /* byte 2 */ + u8 eCWmax:4, + eCWmin:4; +#else +#error "Please fix " +#endif + + /* bytes 3 & 4 */ + u16 txopLimit; +} __packed; + +struct wme_parameter_element { + /* required fields for WME version 1 */ + u8 oui[3]; + u8 oui_type; + u8 oui_subtype; + u8 version; + u8 acInfo; + u8 reserved; + struct wme_ac_parameter ac[4]; + +} __packed; + +#define WPA_PUT_LE16(a, val) \ + do { \ + (a)[1] = ((u16) (val)) >> 8; \ + (a)[0] = ((u16) (val)) & 0xff; \ + } while (0) + +#define WPA_PUT_BE32(a, val) \ + do { \ + (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[3] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define WPA_PUT_LE32(a, val) \ + do { \ + (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[0] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RSN_SELECTOR_PUT(a, val) WPA_PUT_BE32((u8 *)(a), (val)) + +/* Action category code */ +enum ieee80211_category { + WLAN_CATEGORY_SPECTRUM_MGMT = 0, + WLAN_CATEGORY_QOS = 1, + WLAN_CATEGORY_DLS = 2, + WLAN_CATEGORY_BACK = 3, + WLAN_CATEGORY_HT = 7, + WLAN_CATEGORY_WMM = 17, +}; + +/* SPECTRUM_MGMT action code */ +enum ieee80211_spectrum_mgmt_actioncode { + WLAN_ACTION_SPCT_MSR_REQ = 0, + WLAN_ACTION_SPCT_MSR_RPRT = 1, + WLAN_ACTION_SPCT_TPC_REQ = 2, + WLAN_ACTION_SPCT_TPC_RPRT = 3, + WLAN_ACTION_SPCT_CHL_SWITCH = 4, + WLAN_ACTION_SPCT_EXT_CHL_SWITCH = 5, +}; + +/* BACK action code */ +enum ieee80211_back_actioncode { + WLAN_ACTION_ADDBA_REQ = 0, + WLAN_ACTION_ADDBA_RESP = 1, + WLAN_ACTION_DELBA = 2, +}; + +/* HT features action code */ +enum ieee80211_ht_actioncode { + WLAN_ACTION_NOTIFY_CH_WIDTH = 0, + WLAN_ACTION_SM_PS = 1, + WLAN_ACTION_PSPM = 2, + WLAN_ACTION_PCO_PHASE = 3, + WLAN_ACTION_MIMO_CSI_MX = 4, + WLAN_ACTION_MIMO_NONCP_BF = 5, + WLAN_ACTION_MIMP_CP_BF = 6, + WLAN_ACTION_ASEL_INDICATES_FB = 7, + WLAN_ACTION_HI_INFO_EXCHG = 8, +}; + +/* BACK (block-ack) parties */ +enum ieee80211_back_parties { + WLAN_BACK_RECIPIENT = 0, + WLAN_BACK_INITIATOR = 1, + WLAN_BACK_TIMER = 2, +}; + +struct ieee80211_mgmt { + u16 frame_control; + u16 duration; + u8 da[6]; + u8 sa[6]; + u8 bssid[6]; + u16 seq_ctrl; + union { + struct { + u16 auth_alg; + u16 auth_transaction; + u16 status_code; + /* possibly followed by Challenge text */ + u8 variable[0]; + } __packed auth; + struct { + u16 reason_code; + } __packed deauth; + struct { + u16 capab_info; + u16 listen_interval; + /* followed by SSID and Supported rates */ + u8 variable[0]; + } __packed assoc_req; + struct { + u16 capab_info; + u16 status_code; + u16 aid; + /* followed by Supported rates */ + u8 variable[0]; + } __packed assoc_resp, reassoc_resp; + struct { + u16 capab_info; + u16 listen_interval; + u8 current_ap[6]; + /* followed by SSID and Supported rates */ + u8 variable[0]; + } __packed reassoc_req; + struct { + u16 reason_code; + } __packed disassoc; + struct { + __le64 timestamp; + u16 beacon_int; + u16 capab_info; + /* followed by some of SSID, Supported rates, + * FH Params, DS Params, CF Params, IBSS Params, TIM */ + u8 variable[0]; + } __packed beacon; + struct { + /* only variable items: SSID, Supported rates */ + u8 variable[0]; + } __packed probe_req; + struct { + __le64 timestamp; + u16 beacon_int; + u16 capab_info; + /* followed by some of SSID, Supported rates, + * FH Params, DS Params, CF Params, IBSS Params */ + u8 variable[0]; + } __packed probe_resp; + struct { + u8 category; + union { + struct { + u8 action_code; + u8 dialog_token; + u8 status_code; + u8 variable[0]; + } __packed wme_action; + struct { + u8 action_code; + u8 dialog_token; + u16 capab; + u16 timeout; + u16 start_seq_num; + } __packed addba_req; + struct { + u8 action_code; + u8 dialog_token; + u16 status; + u16 capab; + u16 timeout; + } __packed addba_resp; + struct { + u8 action_code; + u16 params; + u16 reason_code; + } __packed delba; + structi { + u8 action_code; + /* capab_info for open and confirm, + * reason for close + */ + u16 aux; + /* Followed in plink_confirm by status + * code, AID and supported rates, + * and directly by supported rates in + * plink_open and plink_close + */ + u8 variable[0]; + } __packed plink_action; + struct{ + u8 action_code; + u8 variable[0]; + } __packed mesh_action; + } __packed u; + } __packed action; + } __packed u; +} __packed; + +/* mgmt header + 1 byte category code */ +#define IEEE80211_MIN_ACTION_SIZE \ + FIELD_OFFSET(struct ieee80211_mgmt, u.action.u) + +#endif diff --git a/drivers/staging/r8188eu/include/if_ether.h b/drivers/staging/r8188eu/include/if_ether.h new file mode 100644 index 000000000000..db157712a203 --- /dev/null +++ b/drivers/staging/r8188eu/include/if_ether.h @@ -0,0 +1,111 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef _LINUX_IF_ETHER_H +#define _LINUX_IF_ETHER_H + +/* + * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble + * and FCS/CRC (frame check sequence). + */ + +#define ETH_ALEN 6 /* Octets in one ethernet addr */ +#define ETH_HLEN 14 /* Total octets in header. */ +#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ +#define ETH_DATA_LEN 1500 /* Max. octets in payload */ +#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ + +/* + * These are the defined Ethernet Protocol ID's. + */ + +#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ +#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ +#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ +#define ETH_P_IP 0x0800 /* Internet Protocol packet */ +#define ETH_P_X25 0x0805 /* CCITT X.25 */ +#define ETH_P_ARP 0x0806 /* Address Resolution packet */ +#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet */ +#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ +#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP */ +#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ +#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ +#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ +#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ +#define ETH_P_LAT 0x6004 /* DEC LAT */ +#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ +#define ETH_P_CUST 0x6006 /* DEC Customer use */ +#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ +#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ +#define ETH_P_ATALK 0x809B /* Appletalk DDP */ +#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ +#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ +#define ETH_P_IPX 0x8137 /* IPX over DIX */ +#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ +#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ +#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ +#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ +#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport + * over Ethernet + */ + +/* + * Non DIX types. Won't clash for 1500 types. + */ + +#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ +#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ +#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ +#define ETH_P_802_2 0x0004 /* 802.2 frames */ +#define ETH_P_SNAP 0x0005 /* Internal only */ +#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ +#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ +#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ +#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ +#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ +#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ +#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ +#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ +#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ +#define ETH_P_ECONET 0x0018 /* Acorn Econet */ + +/* + * This is an Ethernet frame header. + */ + +struct ethhdr { + unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ + unsigned char h_source[ETH_ALEN]; /* source ether addr */ + unsigned short h_proto; /* packet type ID field */ +}; + +struct _vlan { + unsigned short h_vlan_TCI; /* Encap prio and VLAN ID */ + unsigned short h_vlan_encapsulated_proto; +}; + +#define get_vlan_id(pvlan) \ + ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff) +#define get_vlan_priority(pvlan) \ + ((ntohs((unsigned short)pvlan->h_vlan_TCI))>>13) +#define get_vlan_encap_proto(pvlan) \ + (ntohs((unsigned short)pvlan->h_vlan_encapsulated_proto)) + +#endif /* _LINUX_IF_ETHER_H */ diff --git a/drivers/staging/r8188eu/include/ioctl_cfg80211.h b/drivers/staging/r8188eu/include/ioctl_cfg80211.h new file mode 100644 index 000000000000..037e9a5e5af9 --- /dev/null +++ b/drivers/staging/r8188eu/include/ioctl_cfg80211.h @@ -0,0 +1,107 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __IOCTL_CFG80211_H__ +#define __IOCTL_CFG80211_H__ + +struct rtw_wdev_invit_info { + u8 token; + u8 flags; + u8 status; + u8 req_op_ch; + u8 rsp_op_ch; +}; + +#define rtw_wdev_invit_info_init(invit_info) \ + do { \ + (invit_info)->token = 0; \ + (invit_info)->flags = 0x00; \ + (invit_info)->status = 0xff; \ + (invit_info)->req_op_ch = 0; \ + (invit_info)->rsp_op_ch = 0; \ + } while (0) + +struct rtw_wdev_priv { + struct wireless_dev *rtw_wdev; + + struct adapter *padapter; + + struct cfg80211_scan_request *scan_request; + spinlock_t scan_req_lock; + + struct net_device *pmon_ndev;/* for monitor interface */ + char ifname_mon[IFNAMSIZ + 1]; /* name of monitor interface */ + + u8 p2p_enabled; + + u8 provdisc_req_issued; + + struct rtw_wdev_invit_info invit_info; + + u8 bandroid_scan; + bool block; + bool power_mgmt; +}; + +#define wdev_to_priv(w) ((struct rtw_wdev_priv *)(wdev_priv(w))) + +#define wiphy_to_wdev(x) \ +((struct wireless_dev *)(((struct rtw_wdev_priv *)wiphy_priv(x))->rtw_wdev)) + +int rtw_wdev_alloc(struct adapter *padapter, struct device *dev); +void rtw_wdev_free(struct wireless_dev *wdev); +void rtw_wdev_unregister(struct wireless_dev *wdev); + +void rtw_cfg80211_init_wiphy(struct adapter *padapter); + +void rtw_cfg80211_surveydone_event_callback(struct adapter *padapter); + +void rtw_cfg80211_indicate_connect(struct adapter *padapter); +void rtw_cfg80211_indicate_disconnect(struct adapter *padapter); +void rtw_cfg80211_indicate_scan_done(struct rtw_wdev_priv *pwdev_priv, + bool aborted); + +#ifdef CONFIG_88EU_AP_MODE +void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, + u8 *pmgmt_frame, uint frame_len); +void rtw_cfg80211_indicate_sta_disassoc(struct adapter *padapter, + unsigned char *da, + unsigned short reason); +#endif /* CONFIG_88EU_AP_MODE */ + +void rtw_cfg80211_issue_p2p_provision_request(struct adapter *padapter, + const u8 *buf, size_t len); +void rtw_cfg80211_rx_p2p_action_public(struct adapter *padapter, + u8 *pmgmt_frame, uint frame_len); +void rtw_cfg80211_rx_action_p2p(struct adapter *padapter, u8 *pmgmt_frame, + uint frame_len); +void rtw_cfg80211_rx_action(struct adapter *adapter, u8 *frame, + uint frame_len, const char *msg); + +int rtw_cfg80211_set_mgnt_wpsp2pie(struct net_device *net, + char *buf, int len, int type); + +bool rtw_cfg80211_pwr_mgmt(struct adapter *adapter); + +#define rtw_cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) \ + cfg80211_rx_mgmt(dev, freq, sig_dbm, buf, len, gfp) +#define rtw_cfg80211_send_rx_assoc(dev, bss, buf, len) \ + cfg80211_send_rx_assoc(dev, bss, buf, len) + +#endif /* __IOCTL_CFG80211_H__ */ diff --git a/drivers/staging/r8188eu/include/ip.h b/drivers/staging/r8188eu/include/ip.h new file mode 100644 index 000000000000..0107ac15c6ed --- /dev/null +++ b/drivers/staging/r8188eu/include/ip.h @@ -0,0 +1,125 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _LINUX_IP_H +#define _LINUX_IP_H + +/* SOL_IP socket options */ + +#define IPTOS_TOS_MASK 0x1E +#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) +#define IPTOS_LOWDELAY 0x10 +#define IPTOS_THROUGHPUT 0x08 +#define IPTOS_RELIABILITY 0x04 +#define IPTOS_MINCOST 0x02 + +#define IPTOS_PREC_MASK 0xE0 +#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) +#define IPTOS_PREC_NETCONTROL 0xe0 +#define IPTOS_PREC_INTERNETCONTROL 0xc0 +#define IPTOS_PREC_CRITIC_ECP 0xa0 +#define IPTOS_PREC_FLASHOVERRIDE 0x80 +#define IPTOS_PREC_FLASH 0x60 +#define IPTOS_PREC_IMMEDIATE 0x40 +#define IPTOS_PREC_PRIORITY 0x20 +#define IPTOS_PREC_ROUTINE 0x00 + +/* IP options */ +#define IPOPT_COPY 0x80 +#define IPOPT_CLASS_MASK 0x60 +#define IPOPT_NUMBER_MASK 0x1f + +#define IPOPT_COPIED(o) ((o)&IPOPT_COPY) +#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) +#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) + +#define IPOPT_CONTROL 0x00 +#define IPOPT_RESERVED1 0x20 +#define IPOPT_MEASUREMENT 0x40 +#define IPOPT_RESERVED2 0x60 + +#define IPOPT_END (0 | IPOPT_CONTROL) +#define IPOPT_NOOP (1 | IPOPT_CONTROL) +#define IPOPT_SEC (2 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_LSRR (3 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT) +#define IPOPT_RR (7 | IPOPT_CONTROL) +#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY) +#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY) + +#define IPVERSION 4 +#define MAXTTL 255 +#define IPDEFTTL 64 +#define IPOPT_OPTVAL 0 +#define IPOPT_OLEN 1 +#define IPOPT_OFFSET 2 +#define IPOPT_MINOFF 4 +#define MAX_IPOPTLEN 40 +#define IPOPT_NOP IPOPT_NOOP +#define IPOPT_EOL IPOPT_END +#define IPOPT_TS IPOPT_TIMESTAMP + +#define IPOPT_TS_TSONLY 0 /* timestamps only */ +#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ +#define IPOPT_TS_PRESPEC 3 /* specified modules only */ + +struct ip_options { + __u32 faddr; /* Saved first hop address */ + unsigned char optlen; + unsigned char srr; + unsigned char rr; + unsigned char ts; + unsigned char is_setbyuser:1, /* Set by setsockopt? */ + is_data:1, /* Options in __data, rather than skb*/ + is_strictroute:1,/* Strict source route */ + srr_is_hit:1, /* Packet destn addr was ours */ + is_changed:1, /* IP checksum more not valid */ + rr_needaddr:1, /* Need to record addr of out dev*/ + ts_needtime:1, /* Need to record timestamp */ + ts_needaddr:1; /* Need to record addr of out dev */ + unsigned char router_alert; + unsigned char __pad1; + unsigned char __pad2; + unsigned char __data[0]; +}; + +#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) + +struct iphdr { +#if defined(__LITTLE_ENDIAN_BITFIELD) + __u8 ihl:4, + version:4; +#elif defined(__BIG_ENDIAN_BITFIELD) + __u8 version:4, + ihl:4; +#endif + __u8 tos; + __u16 tot_len; + __u16 id; + __u16 frag_off; + __u8 ttl; + __u8 protocol; + __u16 check; + __u32 saddr; + __u32 daddr; + /*The options start here. */ +}; + +#endif /* _LINUX_IP_H */ diff --git a/drivers/staging/r8188eu/include/mlme_osdep.h b/drivers/staging/r8188eu/include/mlme_osdep.h new file mode 100644 index 000000000000..ae1722c67032 --- /dev/null +++ b/drivers/staging/r8188eu/include/mlme_osdep.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __MLME_OSDEP_H_ +#define __MLME_OSDEP_H_ + +#include +#include + +void rtw_init_mlme_timer(struct adapter *padapter); +void rtw_os_indicate_disconnect(struct adapter *adapter); +void rtw_os_indicate_connect(struct adapter *adapter); +void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted); +void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie); + +void rtw_reset_securitypriv(struct adapter *adapter); +void indicate_wx_scan_complete_event(struct adapter *padapter); + +#endif /* _MLME_OSDEP_H_ */ diff --git a/drivers/staging/r8188eu/include/mp_custom_oid.h b/drivers/staging/r8188eu/include/mp_custom_oid.h new file mode 100644 index 000000000000..be4f11864f63 --- /dev/null +++ b/drivers/staging/r8188eu/include/mp_custom_oid.h @@ -0,0 +1,349 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __CUSTOM_OID_H +#define __CUSTOM_OID_H + +/* by Owen */ +/* 0xFF818000 - 0xFF81802F RTL8180 Mass Production Kit */ +/* 0xFF818500 - 0xFF81850F RTL8185 Setup Utility */ +/* 0xFF818580 - 0xFF81858F RTL8185 Phy Status Utility */ + +/* */ + +/* by Owen for Production Kit */ +/* For Production Kit with Agilent Equipments */ +/* in order to make our custom oids hopefully somewhat unique */ +/* we will use 0xFF (indicating implementation specific OID) */ +/* 81(first byte of non zero Realtek unique identifier) */ +/* 80 (second byte of non zero Realtek unique identifier) */ +/* XX (the custom OID number - providing 255 possible custom oids) */ + +#define OID_RT_PRO_RESET_DUT 0xFF818000 +#define OID_RT_PRO_SET_DATA_RATE 0xFF818001 +#define OID_RT_PRO_START_TEST 0xFF818002 +#define OID_RT_PRO_STOP_TEST 0xFF818003 +#define OID_RT_PRO_SET_PREAMBLE 0xFF818004 +#define OID_RT_PRO_SET_SCRAMBLER 0xFF818005 +#define OID_RT_PRO_SET_FILTER_BB 0xFF818006 +#define OID_RT_PRO_SET_MANUAL_DIVERSITY_BB 0xFF818007 +#define OID_RT_PRO_SET_CHANNEL_DIRECT_CALL 0xFF818008 +#define OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL 0xFF818009 +#define OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL 0xFF81800A + +#define OID_RT_PRO_SET_TX_ANTENNA_BB 0xFF81800D +#define OID_RT_PRO_SET_ANTENNA_BB 0xFF81800E +#define OID_RT_PRO_SET_CR_SCRAMBLER 0xFF81800F +#define OID_RT_PRO_SET_CR_NEW_FILTER 0xFF818010 +#define OID_RT_PRO_SET_TX_POWER_CONTROL 0xFF818011 +#define OID_RT_PRO_SET_CR_TX_CONFIG 0xFF818012 +#define OID_RT_PRO_GET_TX_POWER_CONTROL 0xFF818013 +#define OID_RT_PRO_GET_CR_SIGNAL_QUALITY 0xFF818014 +#define OID_RT_PRO_SET_CR_SETPOINT 0xFF818015 +#define OID_RT_PRO_SET_INTEGRATOR 0xFF818016 +#define OID_RT_PRO_SET_SIGNAL_QUALITY 0xFF818017 +#define OID_RT_PRO_GET_INTEGRATOR 0xFF818018 +#define OID_RT_PRO_GET_SIGNAL_QUALITY 0xFF818019 +#define OID_RT_PRO_QUERY_EEPROM_TYPE 0xFF81801A +#define OID_RT_PRO_WRITE_MAC_ADDRESS 0xFF81801B +#define OID_RT_PRO_READ_MAC_ADDRESS 0xFF81801C +#define OID_RT_PRO_WRITE_CIS_DATA 0xFF81801D +#define OID_RT_PRO_READ_CIS_DATA 0xFF81801E +#define OID_RT_PRO_WRITE_POWER_CONTROL 0xFF81801F +#define OID_RT_PRO_READ_POWER_CONTROL 0xFF818020 +#define OID_RT_PRO_WRITE_EEPROM 0xFF818021 +#define OID_RT_PRO_READ_EEPROM 0xFF818022 +#define OID_RT_PRO_RESET_TX_PACKET_SENT 0xFF818023 +#define OID_RT_PRO_QUERY_TX_PACKET_SENT 0xFF818024 +#define OID_RT_PRO_RESET_RX_PACKET_RECEIVED 0xFF818025 +#define OID_RT_PRO_QUERY_RX_PACKET_RECEIVED 0xFF818026 +#define OID_RT_PRO_QUERY_RX_PACKET_CRC32_ERROR 0xFF818027 +#define OID_RT_PRO_QUERY_CURRENT_ADDRESS 0xFF818028 +#define OID_RT_PRO_QUERY_PERMANENT_ADDRESS 0xFF818029 +#define OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS 0xFF81802A +#define OID_RT_PRO_RECEIVE_PACKET 0xFF81802C +/* added by Owen on 04/08/03 for Cameo's request */ +#define OID_RT_PRO_WRITE_EEPROM_BYTE 0xFF81802D +#define OID_RT_PRO_READ_EEPROM_BYTE 0xFF81802E +#define OID_RT_PRO_SET_MODULATION 0xFF81802F +/* */ + +/* Sean */ +#define OID_RT_DRIVER_OPTION 0xFF818080 +#define OID_RT_RF_OFF 0xFF818081 +#define OID_RT_AUTH_STATUS 0xFF818082 + +/* */ +#define OID_RT_PRO_SET_CONTINUOUS_TX 0xFF81800B +#define OID_RT_PRO_SET_SINGLE_CARRIER_TX 0xFF81800C +#define OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX 0xFF81802B +#define OID_RT_PRO_SET_SINGLE_TONE_TX 0xFF818043 +/* */ + +/* by Owen for RTL8185 Phy Status Report Utility */ +#define OID_RT_UTILITY_false_ALARM_COUNTERS 0xFF818580 +#define OID_RT_UTILITY_SELECT_DEBUG_MODE 0xFF818581 +#define OID_RT_UTILITY_SELECT_SUBCARRIER_NUMBER 0xFF818582 +#define OID_RT_UTILITY_GET_RSSI_STATUS 0xFF818583 +#define OID_RT_UTILITY_GET_FRAME_DETECTION_STATUS 0xFF818584 +#define OID_RT_UTILITY_GET_AGC_AND_FREQUENCY_OFFSET_ESTIMATION_STATUS \ + 0xFF818585 +#define OID_RT_UTILITY_GET_CHANNEL_ESTIMATION_STATUS 0xFF818586 +/* */ + +/* by Owen on 03/09/19-03/09/22 for RTL8185 */ +#define OID_RT_WIRELESS_MODE 0xFF818500 +#define OID_RT_SUPPORTED_RATES 0xFF818501 +#define OID_RT_DESIRED_RATES 0xFF818502 +#define OID_RT_WIRELESS_MODE_STARTING_ADHOC 0xFF818503 +/* */ + +#define OID_RT_GET_CONNECT_STATE 0xFF030001 +#define OID_RT_RESCAN 0xFF030002 +#define OID_RT_SET_KEY_LENGTH 0xFF030003 +#define OID_RT_SET_DEFAULT_KEY_ID 0xFF030004 + +#define OID_RT_SET_CHANNEL 0xFF010182 +#define OID_RT_SET_SNIFFER_MODE 0xFF010183 +#define OID_RT_GET_SIGNAL_QUALITY 0xFF010184 +#define OID_RT_GET_SMALL_PACKET_CRC 0xFF010185 +#define OID_RT_GET_MIDDLE_PACKET_CRC 0xFF010186 +#define OID_RT_GET_LARGE_PACKET_CRC 0xFF010187 +#define OID_RT_GET_TX_RETRY 0xFF010188 +#define OID_RT_GET_RX_RETRY 0xFF010189 +#define OID_RT_PRO_SET_FW_DIG_STATE 0xFF01018A/* S */ +#define OID_RT_PRO_SET_FW_RA_STATE 0xFF01018B/* S */ + +#define OID_RT_GET_RX_TOTAL_PACKET 0xFF010190 +#define OID_RT_GET_TX_BEACON_OK 0xFF010191 +#define OID_RT_GET_TX_BEACON_ERR 0xFF010192 +#define OID_RT_GET_RX_ICV_ERR 0xFF010193 +#define OID_RT_SET_ENCRYPTION_ALGORITHM 0xFF010194 +#define OID_RT_SET_NO_AUTO_RESCAN 0xFF010195 +#define OID_RT_GET_PREAMBLE_MODE 0xFF010196 +#define OID_RT_GET_DRIVER_UP_DELTA_TIME 0xFF010197 +#define OID_RT_GET_AP_IP 0xFF010198 +#define OID_RT_GET_CHANNELPLAN 0xFF010199 +#define OID_RT_SET_PREAMBLE_MODE 0xFF01019A +#define OID_RT_SET_BCN_INTVL 0xFF01019B +#define OID_RT_GET_RF_VENDER 0xFF01019C +#define OID_RT_DEDICATE_PROBE 0xFF01019D +#define OID_RT_PRO_RX_FILTER_PATTERN 0xFF01019E + +#define OID_RT_GET_DCST_CURRENT_THRESHOLD 0xFF01019F + +#define OID_RT_GET_CCA_ERR 0xFF0101A0 +#define OID_RT_GET_CCA_UPGRADE_THRESHOLD 0xFF0101A1 +#define OID_RT_GET_CCA_FALLBACK_THRESHOLD 0xFF0101A2 + +#define OID_RT_GET_CCA_UPGRADE_EVALUATE_TIMES 0xFF0101A3 +#define OID_RT_GET_CCA_FALLBACK_EVALUATE_TIMES 0xFF0101A4 + +/* by Owen on 03/31/03 for Cameo's request */ +#define OID_RT_SET_RATE_ADAPTIVE 0xFF0101A5 +/* */ +#define OID_RT_GET_DCST_EVALUATE_PERIOD 0xFF0101A5 +#define OID_RT_GET_DCST_TIME_UNIT_INDEX 0xFF0101A6 +#define OID_RT_GET_TOTAL_TX_BYTES 0xFF0101A7 +#define OID_RT_GET_TOTAL_RX_BYTES 0xFF0101A8 +#define OID_RT_CURRENT_TX_POWER_LEVEL 0xFF0101A9 +#define OID_RT_GET_ENC_KEY_MISMATCH_COUNT 0xFF0101AA +#define OID_RT_GET_ENC_KEY_MATCH_COUNT 0xFF0101AB +#define OID_RT_GET_CHANNEL 0xFF0101AC + +#define OID_RT_SET_CHANNELPLAN 0xFF0101AD +#define OID_RT_GET_HARDWARE_RADIO_OFF 0xFF0101AE +#define OID_RT_CHANNELPLAN_BY_COUNTRY 0xFF0101AF +#define OID_RT_SCAN_AVAILABLE_BSSID 0xFF0101B0 +#define OID_RT_GET_HARDWARE_VERSION 0xFF0101B1 +#define OID_RT_GET_IS_ROAMING 0xFF0101B2 +#define OID_RT_GET_IS_PRIVACY 0xFF0101B3 +#define OID_RT_GET_KEY_MISMATCH 0xFF0101B4 +#define OID_RT_SET_RSSI_ROAM_TRAFFIC_TH 0xFF0101B5 +#define OID_RT_SET_RSSI_ROAM_SIGNAL_TH 0xFF0101B6 +#define OID_RT_RESET_LOG 0xFF0101B7 +#define OID_RT_GET_LOG 0xFF0101B8 +#define OID_RT_SET_INDICATE_HIDDEN_AP 0xFF0101B9 +#define OID_RT_GET_HEADER_FAIL 0xFF0101BA +#define OID_RT_SUPPORTED_WIRELESS_MODE 0xFF0101BB +#define OID_RT_GET_CHANNEL_LIST 0xFF0101BC +#define OID_RT_GET_SCAN_IN_PROGRESS 0xFF0101BD +#define OID_RT_GET_TX_INFO 0xFF0101BE +#define OID_RT_RF_READ_WRITE_OFFSET 0xFF0101BF +#define OID_RT_RF_READ_WRITE 0xFF0101C0 + +/* For Netgear request. 2005.01.13, by rcnjko. */ +#define OID_RT_FORCED_DATA_RATE 0xFF0101C1 +#define OID_RT_WIRELESS_MODE_FOR_SCAN_LIST 0xFF0101C2 +/* For Netgear request. 2005.02.17, by rcnjko. */ +#define OID_RT_GET_BSS_WIRELESS_MODE 0xFF0101C3 +/* For AZ project. 2005.06.27, by rcnjko. */ +#define OID_RT_SCAN_WITH_MAGIC_PACKET 0xFF0101C4 + +/* Vincent 8185MP */ +#define OID_RT_PRO_RX_FILTER 0xFF0111C0 + +#define OID_CE_USB_WRITE_REGISTRY 0xFF0111C1 +#define OID_CE_USB_READ_REGISTRY 0xFF0111C2 + +#define OID_RT_PRO_SET_INITIAL_GA 0xFF0111C3 +#define OID_RT_PRO_SET_BB_RF_STANDBY_MODE 0xFF0111C4 +#define OID_RT_PRO_SET_BB_RF_SHUTDOWN_MODE 0xFF0111C5 +#define OID_RT_PRO_SET_TX_CHARGE_PUMP 0xFF0111C6 +#define OID_RT_PRO_SET_RX_CHARGE_PUMP 0xFF0111C7 +#define OID_RT_PRO_RF_WRITE_REGISTRY 0xFF0111C8 +#define OID_RT_PRO_RF_READ_REGISTRY 0xFF0111C9 +#define OID_RT_PRO_QUERY_RF_TYPE 0xFF0111CA + +/* AP OID */ +#define OID_RT_AP_GET_ASSOCIATED_STATION_LIST 0xFF010300 +#define OID_RT_AP_GET_CURRENT_TIME_STAMP 0xFF010301 +#define OID_RT_AP_SWITCH_INTO_AP_MODE 0xFF010302 +#define OID_RT_AP_SET_DTIM_PERIOD 0xFF010303 +/* Determine if driver supports AP mode. */ +#define OID_RT_AP_SUPPORTED 0xFF010304 +/* Set WPA-PSK passphrase into authenticator. */ +#define OID_RT_AP_SET_PASSPHRASE 0xFF010305 + +/* 8187MP. 2004.09.06, by rcnjko. */ +#define OID_RT_PRO8187_WI_POLL 0xFF818780 +#define OID_RT_PRO_WRITE_BB_REG 0xFF818781 +#define OID_RT_PRO_READ_BB_REG 0xFF818782 +#define OID_RT_PRO_WRITE_RF_REG 0xFF818783 +#define OID_RT_PRO_READ_RF_REG 0xFF818784 + +/* Meeting House. added by Annie, 2005-07-20. */ +#define OID_RT_MH_VENDER_ID 0xFFEDC100 + +/* 8711 MP OID added 20051230. */ +#define OID_RT_PRO8711_JOIN_BSS 0xFF871100/* S */ + +#define OID_RT_PRO_READ_REGISTER 0xFF871101 /* Q */ +#define OID_RT_PRO_WRITE_REGISTER 0xFF871102 /* S */ + +#define OID_RT_PRO_BURST_READ_REGISTER 0xFF871103 /* Q */ +#define OID_RT_PRO_BURST_WRITE_REGISTER 0xFF871104 /* S */ + +#define OID_RT_PRO_WRITE_TXCMD 0xFF871105 /* S */ + +#define OID_RT_PRO_READ16_EEPROM 0xFF871106 /* Q */ +#define OID_RT_PRO_WRITE16_EEPROM 0xFF871107 /* S */ + +#define OID_RT_PRO_H2C_SET_COMMAND 0xFF871108 /* S */ +#define OID_RT_PRO_H2C_QUERY_RESULT 0xFF871109 /* Q */ + +#define OID_RT_PRO8711_WI_POLL 0xFF87110A /* Q */ +#define OID_RT_PRO8711_PKT_LOSS 0xFF87110B /* Q */ +#define OID_RT_RD_ATTRIB_MEM 0xFF87110C/* Q */ +#define OID_RT_WR_ATTRIB_MEM 0xFF87110D/* S */ + +/* Method 2 for H2C/C2H */ +#define OID_RT_PRO_H2C_CMD_MODE 0xFF871110 /* S */ +#define OID_RT_PRO_H2C_CMD_RSP_MODE 0xFF871111 /* Q */ +#define OID_RT_PRO_H2C_CMD_EVENT_MODE 0xFF871112 /* S */ +#define OID_RT_PRO_WAIT_C2H_EVENT 0xFF871113 /* Q */ +#define OID_RT_PRO_RW_ACCESS_PROTOCOL_TEST 0xFF871114/* Q */ + +#define OID_RT_PRO_SCSI_ACCESS_TEST 0xFF871115 /* Q, S */ + +#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_OUT 0xFF871116 /* S */ +#define OID_RT_PRO_SCSI_TCPIPOFFLOAD_IN 0xFF871117 /* Q,S */ +#define OID_RT_RRO_RX_PKT_VIA_IOCTRL 0xFF871118 /* Q */ +#define OID_RT_RRO_RX_PKTARRAY_VIA_IOCTRL 0xFF871119 /* Q */ + +#define OID_RT_RPO_SET_PWRMGT_TEST 0xFF87111A /* S */ +#define OID_RT_PRO_QRY_PWRMGT_TEST 0XFF87111B /* Q */ +#define OID_RT_RPO_ASYNC_RWIO_TEST 0xFF87111C /* S */ +#define OID_RT_RPO_ASYNC_RWIO_POLL 0xFF87111D /* Q */ +#define OID_RT_PRO_SET_RF_INTFS 0xFF87111E /* S */ +#define OID_RT_POLL_RX_STATUS 0xFF87111F /* Q */ + +#define OID_RT_PRO_CFG_DEBUG_MESSAGE 0xFF871120 /* Q,S */ +#define OID_RT_PRO_SET_DATA_RATE_EX 0xFF871121/* S */ +#define OID_RT_PRO_SET_BASIC_RATE 0xFF871122/* S */ +#define OID_RT_PRO_READ_TSSI 0xFF871123/* S */ +#define OID_RT_PRO_SET_POWER_TRACKING 0xFF871124/* S */ + +#define OID_RT_PRO_QRY_PWRSTATE 0xFF871150 /* Q */ +#define OID_RT_PRO_SET_PWRSTATE 0xFF871151 /* S */ + +/* Method 2 , using workitem */ +#define OID_RT_SET_READ_REG 0xFF871181 /* S */ +#define OID_RT_SET_WRITE_REG 0xFF871182 /* S */ +#define OID_RT_SET_BURST_READ_REG 0xFF871183 /* S */ +#define OID_RT_SET_BURST_WRITE_REG 0xFF871184 /* S */ +#define OID_RT_SET_WRITE_TXCMD 0xFF871185 /* S */ +#define OID_RT_SET_READ16_EEPROM 0xFF871186 /* S */ +#define OID_RT_SET_WRITE16_EEPROM 0xFF871187 /* S */ +#define OID_RT_QRY_POLL_WKITEM 0xFF871188 /* Q */ + +/* For SDIO INTERFACE only */ +#define OID_RT_PRO_SYNCPAGERW_SRAM 0xFF8711A0 /* Q, S */ +#define OID_RT_PRO_871X_DRV_EXT 0xFF8711A1 + +/* For USB INTERFACE only */ +#define OID_RT_PRO_USB_VENDOR_REQ 0xFF8711B0 /* Q, S */ +#define OID_RT_PRO_SCSI_AUTO_TEST 0xFF8711B1 /* S */ +#define OID_RT_PRO_USB_MAC_AC_FIFO_WRITE 0xFF8711B2 /* S */ +#define OID_RT_PRO_USB_MAC_RX_FIFO_READ 0xFF8711B3 /* Q */ +#define OID_RT_PRO_USB_MAC_RX_FIFO_POLLING 0xFF8711B4 /* Q */ + +#define OID_RT_PRO_H2C_SET_RATE_TABLE 0xFF8711FB /* S */ +#define OID_RT_PRO_H2C_GET_RATE_TABLE 0xFF8711FC /* S */ +#define OID_RT_PRO_H2C_C2H_LBK_TEST 0xFF8711FE + +#define OID_RT_PRO_ENCRYPTION_CTRL 0xFF871200 /* Q, S */ +#define OID_RT_PRO_ADD_STA_INFO 0xFF871201 /* S */ +#define OID_RT_PRO_DELE_STA_INFO 0xFF871202 /* S */ +#define OID_RT_PRO_QUERY_DR_VARIABLE 0xFF871203 /* Q */ + +#define OID_RT_PRO_RX_PACKET_TYPE 0xFF871204 /* Q, S */ + +#define OID_RT_PRO_READ_EFUSE 0xFF871205 /* Q */ +#define OID_RT_PRO_WRITE_EFUSE 0xFF871206 /* S */ +#define OID_RT_PRO_RW_EFUSE_PGPKT 0xFF871207 /* Q, S */ +#define OID_RT_GET_EFUSE_CURRENT_SIZE 0xFF871208 /* Q */ + +#define OID_RT_SET_BANDWIDTH 0xFF871209 /* S */ +#define OID_RT_SET_CRYSTAL_CAP 0xFF87120A /* S */ + +#define OID_RT_SET_RX_PACKET_TYPE 0xFF87120B /* S */ + +#define OID_RT_GET_EFUSE_MAX_SIZE 0xFF87120C /* Q */ + +#define OID_RT_PRO_SET_TX_AGC_OFFSET 0xFF87120D /* S */ + +#define OID_RT_PRO_SET_PKT_TEST_MODE 0xFF87120E /* S */ + +#define OID_RT_PRO_FOR_EVM_TEST_SETTING 0xFF87120F /* S */ + +#define OID_RT_PRO_GET_THERMAL_METER 0xFF871210 /* Q */ + +#define OID_RT_RESET_PHY_RX_PACKET_COUNT 0xFF871211 /* S */ +#define OID_RT_GET_PHY_RX_PACKET_RECEIVED 0xFF871212 /* Q */ +#define OID_RT_GET_PHY_RX_PACKET_CRC32_ERROR 0xFF871213 /* Q */ + +#define OID_RT_SET_POWER_DOWN 0xFF871214 /* S */ + +#define OID_RT_GET_POWER_MODE 0xFF871215 /* Q */ + +#define OID_RT_PRO_EFUSE 0xFF871216 /* Q, S */ +#define OID_RT_PRO_EFUSE_MAP 0xFF871217 /* Q, S */ + +#endif /* ifndef __CUSTOM_OID_H */ diff --git a/drivers/staging/r8188eu/include/nic_spec.h b/drivers/staging/r8188eu/include/nic_spec.h new file mode 100644 index 000000000000..cee6f06a4570 --- /dev/null +++ b/drivers/staging/r8188eu/include/nic_spec.h @@ -0,0 +1,41 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __NIC_SPEC_H__ +#define __NIC_SPEC_H__ + +#define RTL8711_MCTRL_ (0x20000) +#define RTL8711_UART_ (0x30000) +#define RTL8711_TIMER_ (0x40000) +#define RTL8711_FINT_ (0x50000) +#define RTL8711_HINT_ (0x50000) +#define RTL8711_GPIO_ (0x60000) +#define RTL8711_WLANCTRL_ (0x200000) +#define RTL8711_WLANFF_ (0xe00000) +#define RTL8711_HCICTRL_ (0x600000) +#define RTL8711_SYSCFG_ (0x620000) +#define RTL8711_SYSCTRL_ (0x620000) +#define RTL8711_MCCTRL_ (0x020000) + +#include + +#include + +#endif /* __RTL8711_SPEC_H__ */ diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h new file mode 100644 index 000000000000..b282b750de7c --- /dev/null +++ b/drivers/staging/r8188eu/include/odm.h @@ -0,0 +1,1182 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HALDMOUTSRC_H__ +#define __HALDMOUTSRC_H__ + +/* Definition */ +/* Define all team support ability. */ + +/* Define for all teams. Please Define the constant in your precomp header. */ + +/* define DM_ODM_SUPPORT_AP 0 */ +/* define DM_ODM_SUPPORT_ADSL 0 */ +/* define DM_ODM_SUPPORT_CE 0 */ +/* define DM_ODM_SUPPORT_MP 1 */ + +/* Define ODM SW team support flag. */ + +/* Antenna Switch Relative Definition. */ + +/* Add new function SwAntDivCheck8192C(). */ +/* This is the main function of Antenna diversity function before link. */ +/* Mainly, it just retains last scan result and scan again. */ +/* After that, it compares the scan result to see which one gets better + * RSSI. It selects antenna with better receiving power and returns better + * scan result. */ + +#define TP_MODE 0 +#define RSSI_MODE 1 +#define TRAFFIC_LOW 0 +#define TRAFFIC_HIGH 1 + +/* 3 Tx Power Tracking */ +/* 3============================================================ */ +#define DPK_DELTA_MAPPING_NUM 13 +#define index_mapping_HP_NUM 15 + +/* */ +/* 3 PSD Handler */ +/* 3============================================================ */ + +#define AFH_PSD 1 /* 0:normal PSD scan, 1: only do 20 pts PSD */ +#define MODE_40M 0 /* 0:20M, 1:40M */ +#define PSD_TH2 3 +#define PSD_CHM 20 /* Minimum channel number for BT AFH */ +#define SIR_STEP_SIZE 3 +#define Smooth_Size_1 5 +#define Smooth_TH_1 3 +#define Smooth_Size_2 10 +#define Smooth_TH_2 4 +#define Smooth_Size_3 20 +#define Smooth_TH_3 4 +#define Smooth_Step_Size 5 +#define Adaptive_SIR 1 +#define PSD_RESCAN 4 +#define PSD_SCAN_INTERVAL 700 /* ms */ + +/* 8723A High Power IGI Setting */ +#define DM_DIG_HIGH_PWR_IGI_LOWER_BOUND 0x22 +#define DM_DIG_Gmode_HIGH_PWR_IGI_LOWER_BOUND 0x28 +#define DM_DIG_HIGH_PWR_THRESHOLD 0x3a + +/* LPS define */ +#define DM_DIG_FA_TH0_LPS 4 /* 4 in lps */ +#define DM_DIG_FA_TH1_LPS 15 /* 15 lps */ +#define DM_DIG_FA_TH2_LPS 30 /* 30 lps */ +#define RSSI_OFFSET_DIG 0x05; + +/* ANT Test */ +#define ANTTESTALL 0x00 /* Ant A or B will be Testing */ +#define ANTTESTA 0x01 /* Ant A will be Testing */ +#define ANTTESTB 0x02 /* Ant B will be testing */ + +/* structure and define */ + +/* Add for AP/ADSLpseudo DM structuer requirement. */ +/* We need to remove to other position??? */ +struct rtl8192cd_priv { + u8 temp; +}; + +struct rtw_dig { + u8 Dig_Enable_Flag; + u8 Dig_Ext_Port_Stage; + + int RssiLowThresh; + int RssiHighThresh; + + u32 FALowThresh; + u32 FAHighThresh; + + u8 CurSTAConnectState; + u8 PreSTAConnectState; + u8 CurMultiSTAConnectState; + + u8 PreIGValue; + u8 CurIGValue; + u8 BackupIGValue; + + s8 BackoffVal; + s8 BackoffVal_range_max; + s8 BackoffVal_range_min; + u8 rx_gain_range_max; + u8 rx_gain_range_min; + u8 Rssi_val_min; + + u8 PreCCK_CCAThres; + u8 CurCCK_CCAThres; + u8 PreCCKPDState; + u8 CurCCKPDState; + + u8 LargeFAHit; + u8 ForbiddenIGI; + u32 Recover_cnt; + + u8 DIG_Dynamic_MIN_0; + u8 DIG_Dynamic_MIN_1; + bool bMediaConnect_0; + bool bMediaConnect_1; + + u32 AntDiv_RSSI_max; + u32 RSSI_max; +}; + +struct rtl_ps { + u8 PreCCAState; + u8 CurCCAState; + + u8 PreRFState; + u8 CurRFState; + + int Rssi_val_min; + + u8 initialize; + u32 Reg874,RegC70,Reg85C,RegA74; + +}; + +struct false_alarm_stats { + u32 Cnt_Parity_Fail; + u32 Cnt_Rate_Illegal; + u32 Cnt_Crc8_fail; + u32 Cnt_Mcs_fail; + u32 Cnt_Ofdm_fail; + u32 Cnt_Cck_fail; + u32 Cnt_all; + u32 Cnt_Fast_Fsync; + u32 Cnt_SB_Search_fail; + u32 Cnt_OFDM_CCA; + u32 Cnt_CCK_CCA; + u32 Cnt_CCA_all; + u32 Cnt_BW_USC; /* Gary */ + u32 Cnt_BW_LSC; /* Gary */ +}; + +struct dyn_primary_cca { + u8 PriCCA_flag; + u8 intf_flag; + u8 intf_type; + u8 DupRTS_flag; + u8 Monitor_flag; +}; + +struct rx_hpc { + u8 RXHP_flag; + u8 PSD_func_trigger; + u8 PSD_bitmap_RXHP[80]; + u8 Pre_IGI; + u8 Cur_IGI; + u8 Pre_pw_th; + u8 Cur_pw_th; + bool First_time_enter; + bool RXHP_enable; + u8 TP_Mode; + struct timer_list PSDTimer; +}; + +#define ASSOCIATE_ENTRY_NUM 32 /* Max size of AsocEntry[]. */ +#define ODM_ASSOCIATE_ENTRY_NUM ASSOCIATE_ENTRY_NUM + +/* This indicates two different steps. */ +/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to + * the signal on the air. */ +/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in + * SWAW_STEP_PEAK with original RSSI to determine if it is necessary to + * switch antenna. */ + +#define SWAW_STEP_PEAK 0 +#define SWAW_STEP_DETERMINE 1 + +#define TP_MODE 0 +#define RSSI_MODE 1 +#define TRAFFIC_LOW 0 +#define TRAFFIC_HIGH 1 + +struct sw_ant_switch { + u8 try_flag; + s32 PreRSSI; + u8 CurAntenna; + u8 PreAntenna; + u8 RSSI_Trying; + u8 TestMode; + u8 bTriggerAntennaSwitch; + u8 SelectAntennaMap; + u8 RSSI_target; + + /* Before link Antenna Switch check */ + u8 SWAS_NoLink_State; + u32 SWAS_NoLink_BK_Reg860; + bool ANTA_ON; /* To indicate Ant A is or not */ + bool ANTB_ON; /* To indicate Ant B is on or not */ + + s32 RSSI_sum_A; + s32 RSSI_sum_B; + s32 RSSI_cnt_A; + s32 RSSI_cnt_B; + u64 lastTxOkCnt; + u64 lastRxOkCnt; + u64 TXByteCnt_A; + u64 TXByteCnt_B; + u64 RXByteCnt_A; + u64 RXByteCnt_B; + u8 TrafficLoad; + struct timer_list SwAntennaSwitchTimer; + /* Hybrid Antenna Diversity */ + u32 CCK_Ant1_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 CCK_Ant2_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 OFDM_Ant1_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 OFDM_Ant2_Cnt[ASSOCIATE_ENTRY_NUM]; + u32 RSSI_Ant1_Sum[ASSOCIATE_ENTRY_NUM]; + u32 RSSI_Ant2_Sum[ASSOCIATE_ENTRY_NUM]; + u8 TxAnt[ASSOCIATE_ENTRY_NUM]; + u8 TargetSTA; + u8 antsel; + u8 RxIdleAnt; +}; + +struct edca_turbo { + bool bCurrentTurboEDCA; + bool bIsCurRDLState; + u32 prv_traffic_idx; /* edca turbo */ +}; + +struct odm_rate_adapt { + u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */ + u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */ + u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */ + u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */ + u32 LastRATR; /* RATR Register Content */ +}; + +#define IQK_MAC_REG_NUM 4 +#define IQK_ADDA_REG_NUM 16 +#define IQK_BB_REG_NUM_MAX 10 +#define IQK_BB_REG_NUM 9 +#define HP_THERMAL_NUM 8 + +#define AVG_THERMAL_NUM 8 +#define IQK_Matrix_REG_NUM 8 +#define IQK_Matrix_Settings_NUM 1+24+21 + +#define DM_Type_ByFWi 0 +#define DM_Type_ByDriver 1 + +/* Declare for common info */ + +struct odm_phy_status_info { + u8 RxPWDBAll; + u8 SignalQuality; /* in 0-100 index. */ + u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */ + u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */ + s8 RxPower; /* in dBm Translate from PWdB */ + s8 RecvSignalPower;/* Real power in dBm for this packet, no + * beautification and aggregation. Keep this raw + * info to be used for the other procedures. */ + u8 BTRxRSSIPercentage; + u8 SignalStrength; /* in 0-100 index. */ + u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ + u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */ +}; + +struct odm_phy_dbg_info { + /* ODM Write,debug info */ + s8 RxSNRdB[MAX_PATH_NUM_92CS]; + u64 NumQryPhyStatus; + u64 NumQryPhyStatusCCK; + u64 NumQryPhyStatusOFDM; + /* Others */ + s32 RxEVM[MAX_PATH_NUM_92CS]; +}; + +struct odm_per_pkt_info { + s8 Rate; + u8 StationID; + bool bPacketMatchBSSID; + bool bPacketToSelf; + bool bPacketBeacon; +}; + +struct odm_mac_status_info { + u8 test; +}; + +enum odm_ability { + /* BB Team */ + ODM_DIG = 0x00000001, + ODM_HIGH_POWER = 0x00000002, + ODM_CCK_CCA_TH = 0x00000004, + ODM_FA_STATISTICS = 0x00000008, + ODM_RAMASK = 0x00000010, + ODM_RSSI_MONITOR = 0x00000020, + ODM_SW_ANTDIV = 0x00000040, + ODM_HW_ANTDIV = 0x00000080, + ODM_BB_PWRSV = 0x00000100, + ODM_2TPATHDIV = 0x00000200, + ODM_1TPATHDIV = 0x00000400, + ODM_PSD2AFH = 0x00000800 +}; + +/* 2011/20/20 MH For MP driver RT_WLAN_STA = struct sta_info */ +/* Please declare below ODM relative info in your STA info structure. */ + +struct odm_sta_info { + /* Driver Write */ + bool bUsed; /* record the sta status link or not? */ + u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ + + /* ODM Write */ + /* 1 PHY_STATUS_INFO */ + u8 RSSI_Path[4]; /* */ + u8 RSSI_Ave; + u8 RXEVM[4]; + u8 RXSNR[4]; +}; + +/* 2011/10/20 MH Define Common info enum for all team. */ + +enum odm_common_info_def { + /* Fixed value: */ + + /* HOOK BEFORE REG INIT----------- */ + ODM_CMNINFO_PLATFORM = 0, + ODM_CMNINFO_ABILITY, /* ODM_ABILITY_E */ + ODM_CMNINFO_INTERFACE, /* ODM_INTERFACE_E */ + ODM_CMNINFO_MP_TEST_CHIP, + ODM_CMNINFO_IC_TYPE, /* ODM_IC_TYPE_E */ + ODM_CMNINFO_CUT_VER, /* ODM_CUT_VERSION_E */ + ODM_CMNINFO_FAB_VER, /* ODM_FAB_E */ + ODM_CMNINFO_RF_TYPE, /* RF_PATH_E or ODM_RF_TYPE_E? */ + ODM_CMNINFO_BOARD_TYPE, /* ODM_BOARD_TYPE_E */ + ODM_CMNINFO_EXT_LNA, /* true */ + ODM_CMNINFO_EXT_PA, + ODM_CMNINFO_EXT_TRSW, + ODM_CMNINFO_PATCH_ID, /* CUSTOMER ID */ + ODM_CMNINFO_BINHCT_TEST, + ODM_CMNINFO_BWIFI_TEST, + ODM_CMNINFO_SMART_CONCURRENT, + /* HOOK BEFORE REG INIT----------- */ + + /* Dynamic value: */ +/* POINTER REFERENCE----------- */ + ODM_CMNINFO_MAC_PHY_MODE, /* ODM_MAC_PHY_MODE_E */ + ODM_CMNINFO_TX_UNI, + ODM_CMNINFO_RX_UNI, + ODM_CMNINFO_WM_MODE, /* ODM_WIRELESS_MODE_E */ + ODM_CMNINFO_BAND, /* ODM_BAND_TYPE_E */ + ODM_CMNINFO_SEC_CHNL_OFFSET, /* ODM_SEC_CHNL_OFFSET_E */ + ODM_CMNINFO_SEC_MODE, /* ODM_SECURITY_E */ + ODM_CMNINFO_BW, /* ODM_BW_E */ + ODM_CMNINFO_CHNL, + + ODM_CMNINFO_DMSP_GET_VALUE, + ODM_CMNINFO_BUDDY_ADAPTOR, + ODM_CMNINFO_DMSP_IS_MASTER, + ODM_CMNINFO_SCAN, + ODM_CMNINFO_POWER_SAVING, + ODM_CMNINFO_ONE_PATH_CCA, /* ODM_CCA_PATH_E */ + ODM_CMNINFO_DRV_STOP, + ODM_CMNINFO_PNP_IN, + ODM_CMNINFO_INIT_ON, + ODM_CMNINFO_ANT_TEST, + ODM_CMNINFO_NET_CLOSED, + ODM_CMNINFO_MP_MODE, +/* POINTER REFERENCE----------- */ + +/* CALL BY VALUE------------- */ + ODM_CMNINFO_WIFI_DIRECT, + ODM_CMNINFO_WIFI_DISPLAY, + ODM_CMNINFO_LINK, + ODM_CMNINFO_RSSI_MIN, + ODM_CMNINFO_DBG_COMP, /* u64 */ + ODM_CMNINFO_DBG_LEVEL, /* u32 */ + ODM_CMNINFO_RA_THRESHOLD_HIGH, /* u8 */ + ODM_CMNINFO_RA_THRESHOLD_LOW, /* u8 */ + ODM_CMNINFO_RF_ANTENNA_TYPE, /* u8 */ + ODM_CMNINFO_BT_DISABLED, + ODM_CMNINFO_BT_OPERATION, + ODM_CMNINFO_BT_DIG, + ODM_CMNINFO_BT_BUSY, /* Check Bt is using or not */ + ODM_CMNINFO_BT_DISABLE_EDCA, +/* CALL BY VALUE-------------*/ + + /* Dynamic ptr array hook itms. */ + ODM_CMNINFO_STA_STATUS, + ODM_CMNINFO_PHY_STATUS, + ODM_CMNINFO_MAC_STATUS, + ODM_CMNINFO_MAX, +}; + +/* 2011/10/20 MH Define ODM support ability. ODM_CMNINFO_ABILITY */ + +enum odm_ability_def { + /* BB ODM section BIT 0-15 */ + ODM_BB_DIG = BIT0, + ODM_BB_RA_MASK = BIT1, + ODM_BB_DYNAMIC_TXPWR = BIT2, + ODM_BB_FA_CNT = BIT3, + ODM_BB_RSSI_MONITOR = BIT4, + ODM_BB_CCK_PD = BIT5, + ODM_BB_ANT_DIV = BIT6, + ODM_BB_PWR_SAVE = BIT7, + ODM_BB_PWR_TRA = BIT8, + ODM_BB_RATE_ADAPTIVE = BIT9, + ODM_BB_PATH_DIV = BIT10, + ODM_BB_PSD = BIT11, + ODM_BB_RXHP = BIT12, + + /* MAC DM section BIT 16-23 */ + ODM_MAC_EDCA_TURBO = BIT16, + ODM_MAC_EARLY_MODE = BIT17, + + /* RF ODM section BIT 24-31 */ + ODM_RF_TX_PWR_TRACK = BIT24, + ODM_RF_RX_GAIN_TRACK = BIT25, + ODM_RF_CALIBRATION = BIT26, +}; + +/* ODM_CMNINFO_INTERFACE */ +enum odm_interface_def { + ODM_ITRF_PCIE = 0x1, + ODM_ITRF_USB = 0x2, + ODM_ITRF_SDIO = 0x4, + ODM_ITRF_ALL = 0x7, +}; + +/* ODM_CMNINFO_IC_TYPE */ +enum odm_ic_type { + ODM_RTL8192S = BIT0, + ODM_RTL8192C = BIT1, + ODM_RTL8192D = BIT2, + ODM_RTL8723A = BIT3, + ODM_RTL8188E = BIT4, + ODM_RTL8812 = BIT5, + ODM_RTL8821 = BIT6, +}; + +#define ODM_IC_11N_SERIES \ + (ODM_RTL8192S | ODM_RTL8192C | ODM_RTL8192D | \ + ODM_RTL8723A | ODM_RTL8188E) +#define ODM_IC_11AC_SERIES (ODM_RTL8812) + +/* ODM_CMNINFO_CUT_VER */ +enum odm_cut_version { + ODM_CUT_A = 1, + ODM_CUT_B = 2, + ODM_CUT_C = 3, + ODM_CUT_D = 4, + ODM_CUT_E = 5, + ODM_CUT_F = 6, + ODM_CUT_TEST = 7, +}; + +/* ODM_CMNINFO_FAB_VER */ +enum odm_fab_Version { + ODM_TSMC = 0, + ODM_UMC = 1, +}; + +/* ODM_CMNINFO_RF_TYPE */ +/* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ +enum odm_rf_path { + ODM_RF_TX_A = BIT0, + ODM_RF_TX_B = BIT1, + ODM_RF_TX_C = BIT2, + ODM_RF_TX_D = BIT3, + ODM_RF_RX_A = BIT4, + ODM_RF_RX_B = BIT5, + ODM_RF_RX_C = BIT6, + ODM_RF_RX_D = BIT7, +}; + +enum odm_rf_type { + ODM_1T1R = 0, + ODM_1T2R = 1, + ODM_2T2R = 2, + ODM_2T3R = 3, + ODM_2T4R = 4, + ODM_3T3R = 5, + ODM_3T4R = 6, + ODM_4T4R = 7, +}; + +/* ODM Dynamic common info value definition */ + +enum odm_mac_phy_mode { + ODM_SMSP = 0, + ODM_DMSP = 1, + ODM_DMDP = 2, +}; + +enum odm_bt_coexist { + ODM_BT_BUSY = 1, + ODM_BT_ON = 2, + ODM_BT_OFF = 3, + ODM_BT_NONE = 4, +}; + +/* ODM_CMNINFO_OP_MODE */ +enum odm_operation_mode { + ODM_NO_LINK = BIT0, + ODM_LINK = BIT1, + ODM_SCAN = BIT2, + ODM_POWERSAVE = BIT3, + ODM_AP_MODE = BIT4, + ODM_CLIENT_MODE = BIT5, + ODM_AD_HOC = BIT6, + ODM_WIFI_DIRECT = BIT7, + ODM_WIFI_DISPLAY = BIT8, +}; + +/* ODM_CMNINFO_WM_MODE */ +enum odm_wireless_mode { + ODM_WM_UNKNOW = 0x0, + ODM_WM_B = BIT0, + ODM_WM_G = BIT1, + ODM_WM_A = BIT2, + ODM_WM_N24G = BIT3, + ODM_WM_N5G = BIT4, + ODM_WM_AUTO = BIT5, + ODM_WM_AC = BIT6, +}; + +/* ODM_CMNINFO_BAND */ +enum odm_band_type { + ODM_BAND_2_4G = BIT0, + ODM_BAND_5G = BIT1, +}; + +/* ODM_CMNINFO_SEC_CHNL_OFFSET */ +enum odm_sec_chnl_offset { + ODM_DONT_CARE = 0, + ODM_BELOW = 1, + ODM_ABOVE = 2 +}; + +/* ODM_CMNINFO_SEC_MODE */ +enum odm_security { + ODM_SEC_OPEN = 0, + ODM_SEC_WEP40 = 1, + ODM_SEC_TKIP = 2, + ODM_SEC_RESERVE = 3, + ODM_SEC_AESCCMP = 4, + ODM_SEC_WEP104 = 5, + ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ + ODM_SEC_SMS4 = 7, +}; + +/* ODM_CMNINFO_BW */ +enum odm_bw { + ODM_BW20M = 0, + ODM_BW40M = 1, + ODM_BW80M = 2, + ODM_BW160M = 3, + ODM_BW10M = 4, +}; + +/* ODM_CMNINFO_BOARD_TYPE */ +enum odm_board_type { + ODM_BOARD_NORMAL = 0, + ODM_BOARD_HIGHPWR = 1, + ODM_BOARD_MINICARD = 2, + ODM_BOARD_SLIM = 3, + ODM_BOARD_COMBO = 4, +}; + +/* ODM_CMNINFO_ONE_PATH_CCA */ +enum odm_cca_path { + ODM_CCA_2R = 0, + ODM_CCA_1R_A = 1, + ODM_CCA_1R_B = 2, +}; + +struct odm_ra_info { + u8 RateID; + u32 RateMask; + u32 RAUseRate; + u8 RateSGI; + u8 RssiStaRA; + u8 PreRssiStaRA; + u8 SGIEnable; + u8 DecisionRate; + u8 PreRate; + u8 HighestRate; + u8 LowestRate; + u32 NscUp; + u32 NscDown; + u16 RTY[5]; + u32 TOTAL; + u16 DROP; + u8 Active; + u16 RptTime; + u8 RAWaitingCounter; + u8 RAPendingCounter; + u8 PTActive; /* on or off */ + u8 PTTryState; /* 0 trying state, 1 for decision state */ + u8 PTStage; /* 0~6 */ + u8 PTStopCount; /* Stop PT counter */ + u8 PTPreRate; /* if rate change do PT */ + u8 PTPreRssi; /* if RSSI change 5% do PT */ + u8 PTModeSS; /* decide whitch rate should do PT */ + u8 RAstage; /* StageRA, decide how many times RA will be done + * between PT */ + u8 PTSmoothFactor; +}; + +struct ijk_matrix_regs_set { + bool bIQKDone; + s32 Value[1][IQK_Matrix_REG_NUM]; +}; + +struct odm_rf_cal { + /* for tx power tracking */ + u32 RegA24; /* for TempCCK */ + s32 RegE94; + s32 RegE9C; + s32 RegEB4; + s32 RegEBC; + + u8 TXPowercount; + bool bTXPowerTrackingInit; + bool bTXPowerTracking; + u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking + * as default */ + u8 TM_Trigger; + u8 InternalPA5G[2]; /* pathA / pathB */ + + u8 ThermalMeter[2]; /* ThermalMeter, index 0 for RFIC0, + * and 1 for RFIC1 */ + u8 ThermalValue; + u8 ThermalValue_LCK; + u8 ThermalValue_IQK; + u8 ThermalValue_DPK; + u8 ThermalValue_AVG[AVG_THERMAL_NUM]; + u8 ThermalValue_AVG_index; + u8 ThermalValue_RxGain; + u8 ThermalValue_Crystal; + u8 ThermalValue_DPKstore; + u8 ThermalValue_DPKtrack; + bool TxPowerTrackingInProgress; + bool bDPKenable; + + bool bReloadtxpowerindex; + u8 bRfPiEnable; + u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */ + + u8 bCCKinCH14; + u8 CCK_index; + u8 OFDM_index[2]; + bool bDoneTxpower; + + u8 ThermalValue_HP[HP_THERMAL_NUM]; + u8 ThermalValue_HP_index; + struct ijk_matrix_regs_set IQKMatrixRegSetting[IQK_Matrix_Settings_NUM]; + + u8 Delta_IQK; + u8 Delta_LCK; + + /* for IQK */ + u32 RegC04; + u32 Reg874; + u32 RegC08; + u32 RegB68; + u32 RegB6C; + u32 Reg870; + u32 Reg860; + u32 Reg864; + + bool bIQKInitialized; + bool bLCKInProgress; + bool bAntennaDetected; + u32 ADDA_backup[IQK_ADDA_REG_NUM]; + u32 IQK_MAC_backup[IQK_MAC_REG_NUM]; + u32 IQK_BB_backup_recover[9]; + u32 IQK_BB_backup[IQK_BB_REG_NUM]; + + /* for APK */ + u32 APKoutput[2][2]; /* path A/B; output1_1a/output1_2a */ + u8 bAPKdone; + u8 bAPKThermalMeterIgnore; + u8 bDPdone; + u8 bDPPathAOK; + u8 bDPPathBOK; +}; + +/* ODM Dynamic common info value definition */ + +struct fast_ant_train { + u8 Bssid[6]; + u8 antsel_rx_keep_0; + u8 antsel_rx_keep_1; + u8 antsel_rx_keep_2; + u32 antSumRSSI[7]; + u32 antRSSIcnt[7]; + u32 antAveRSSI[7]; + u8 FAT_State; + u32 TrainIdx; + u8 antsel_a[ODM_ASSOCIATE_ENTRY_NUM]; + u8 antsel_b[ODM_ASSOCIATE_ENTRY_NUM]; + u8 antsel_c[ODM_ASSOCIATE_ENTRY_NUM]; + u32 MainAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM]; + u32 AuxAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM]; + u32 MainAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; + u32 AuxAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; + u8 RxIdleAnt; + bool bBecomeLinked; +}; + +enum fat_state { + FAT_NORMAL_STATE = 0, + FAT_TRAINING_STATE = 1, +}; + +enum ant_div_type { + NO_ANTDIV = 0xFF, + CG_TRX_HW_ANTDIV = 0x01, + CGCS_RX_HW_ANTDIV = 0x02, + FIXED_HW_ANTDIV = 0x03, + CG_TRX_SMART_ANTDIV = 0x04, + CGCS_RX_SW_ANTDIV = 0x05, +}; + +/* Copy from SD4 defined structure. We use to support PHY DM integration. */ +struct odm_dm_struct { + /* Add for different team use temporarily */ + struct adapter *Adapter; /* For CE/NIC team */ + struct rtl8192cd_priv *priv; /* For AP/ADSL team */ + /* WHen you use above pointers, they must be initialized. */ + bool odm_ready; + + struct rtl8192cd_priv *fake_priv; + u64 DebugComponents; + u32 DebugLevel; + +/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ + bool bCckHighPower; + u8 RFPathRxEnable; /* ODM_CMNINFO_RFPATH_ENABLE */ + u8 ControlChannel; +/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ + +/* 1 COMMON INFORMATION */ + /* Init Value */ +/* HOOK BEFORE REG INIT----------- */ + /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ + u8 SupportPlatform; + /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/ �K�K = 1/2/3/�K */ + u32 SupportAbility; + /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */ + u8 SupportInterface; + /* ODM composite or independent. Bit oriented/ 92C+92D+ .... or any + * other type = 1/2/3/... */ + u32 SupportICType; + /* Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */ + u8 CutVersion; + /* Fab Version TSMC/UMC = 0/1 */ + u8 FabVersion; + /* RF Type 4T4R/3T3R/2T2R/1T2R/1T1R/... */ + u8 RFType; + /* Board Type Normal/HighPower/MiniCard/SLIM/Combo/. = 0/1/2/3/4/. */ + u8 BoardType; + /* with external LNA NO/Yes = 0/1 */ + u8 ExtLNA; + /* with external PA NO/Yes = 0/1 */ + u8 ExtPA; + /* with external TRSW NO/Yes = 0/1 */ + u8 ExtTRSW; + u8 PatchID; /* Customer ID */ + bool bInHctTest; + bool bWIFITest; + + bool bDualMacSmartConcurrent; + u32 BK_SupportAbility; + u8 AntDivType; +/* HOOK BEFORE REG INIT----------- */ + + /* Dynamic Value */ +/* POINTER REFERENCE----------- */ + + u8 u8_temp; + bool bool_temp; + struct adapter *adapter_temp; + + /* MAC PHY Mode SMSP/DMSP/DMDP = 0/1/2 */ + u8 *pMacPhyMode; + /* TX Unicast byte count */ + u64 *pNumTxBytesUnicast; + /* RX Unicast byte count */ + u64 *pNumRxBytesUnicast; + /* Wireless mode B/G/A/N = BIT0/BIT1/BIT2/BIT3 */ + u8 *pWirelessMode; /* ODM_WIRELESS_MODE_E */ + /* Frequence band 2.4G/5G = 0/1 */ + u8 *pBandType; + /* Secondary channel offset don't_care/below/above = 0/1/2 */ + u8 *pSecChOffset; + /* Security mode Open/WEP/AES/TKIP = 0/1/2/3 */ + u8 *pSecurity; + /* BW info 20M/40M/80M = 0/1/2 */ + u8 *pBandWidth; + /* Central channel location Ch1/Ch2/.... */ + u8 *pChannel; /* central channel number */ + /* Common info for 92D DMSP */ + + bool *pbGetValueFromOtherMac; + struct adapter **pBuddyAdapter; + bool *pbMasterOfDMSP; /* MAC0: master, MAC1: slave */ + /* Common info for Status */ + bool *pbScanInProcess; + bool *pbPowerSaving; + /* CCA Path 2-path/path-A/path-B = 0/1/2; using ODM_CCA_PATH_E. */ + u8 *pOnePathCCA; + /* pMgntInfo->AntennaTest */ + u8 *pAntennaTest; + bool *pbNet_closed; +/* POINTER REFERENCE----------- */ + /* */ +/* CALL BY VALUE------------- */ + bool bWIFI_Direct; + bool bWIFI_Display; + bool bLinked; + u8 RSSI_Min; + u8 InterfaceIndex; /* Add for 92D dual MAC: 0--Mac0 1--Mac1 */ + bool bIsMPChip; + bool bOneEntryOnly; + /* Common info for BTDM */ + bool bBtDisabled; /* BT is disabled */ + bool bBtHsOperation; /* BT HS mode is under progress */ + u8 btHsDigVal; /* use BT rssi to decide the DIG value */ + bool bBtDisableEdcaTurbo;/* Under some condition, don't enable the + * EDCA Turbo */ + bool bBtBusy; /* BT is busy. */ +/* CALL BY VALUE------------- */ + + /* 2 Define STA info. */ + /* _ODM_STA_INFO */ + /* For MP, we need to reduce one array pointer for default port.?? */ + struct sta_info *pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM]; + + u16 CurrminRptTime; + struct odm_ra_info RAInfo[ODM_ASSOCIATE_ENTRY_NUM]; /* Use MacID as + * array index. STA MacID=0, + * VWiFi Client MacID={1, ODM_ASSOCIATE_ENTRY_NUM-1} */ + /* */ + /* 2012/02/14 MH Add to share 88E ra with other SW team. */ + /* We need to colelct all support abilit to a proper area. */ + /* */ + bool RaSupport88E; + + /* Define ........... */ + + /* Latest packet phy info (ODM write) */ + struct odm_phy_dbg_info PhyDbgInfo; + + /* Latest packet phy info (ODM write) */ + struct odm_mac_status_info *pMacInfo; + + /* Different Team independt structure?? */ + + /* ODM Structure */ + struct fast_ant_train DM_FatTable; + struct rtw_dig DM_DigTable; + struct rtl_ps DM_PSTable; + struct dyn_primary_cca DM_PriCCA; + struct rx_hpc DM_RXHP_Table; + struct false_alarm_stats FalseAlmCnt; + struct false_alarm_stats FlaseAlmCntBuddyAdapter; + struct sw_ant_switch DM_SWAT_Table; + bool RSSI_test; + + struct edca_turbo DM_EDCA_Table; + u32 WMMEDCA_BE; + /* Copy from SD4 structure */ + /* */ + /* ================================================== */ + /* */ + + bool *pbDriverStopped; + bool *pbDriverIsGoingToPnpSetPowerSleep; + bool *pinit_adpt_in_progress; + + /* PSD */ + bool bUserAssignLevel; + struct timer_list PSDTimer; + u8 RSSI_BT; /* come from BT */ + bool bPSDinProcess; + bool bDMInitialGainEnable; + + /* for rate adaptive, in fact, 88c/92c fw will handle this */ + u8 bUseRAMask; + + struct odm_rate_adapt RateAdaptive; + + struct odm_rf_cal RFCalibrateInfo; + + /* TX power tracking */ + u8 BbSwingIdxOfdm; + u8 BbSwingIdxOfdmCurrent; + u8 BbSwingIdxOfdmBase; + bool BbSwingFlagOfdm; + u8 BbSwingIdxCck; + u8 BbSwingIdxCckCurrent; + u8 BbSwingIdxCckBase; + bool BbSwingFlagCck; + u8 *mp_mode; + /* ODM system resource. */ + + /* ODM relative time. */ + struct timer_list PathDivSwitchTimer; + /* 2011.09.27 add for Path Diversity */ + struct timer_list CCKPathDiversityTimer; + struct timer_list FastAntTrainingTimer; +}; /* DM_Dynamic_Mechanism_Structure */ + +enum ODM_RF_CONTENT { + odm_radioa_txt = 0x1000, + odm_radiob_txt = 0x1001, + odm_radioc_txt = 0x1002, + odm_radiod_txt = 0x1003 +}; + +enum odm_bb_config_type { + CONFIG_BB_PHY_REG, + CONFIG_BB_AGC_TAB, + CONFIG_BB_AGC_TAB_2G, + CONFIG_BB_AGC_TAB_5G, + CONFIG_BB_PHY_REG_PG, +}; + +/* Status code */ +enum rt_status { + RT_STATUS_SUCCESS, + RT_STATUS_FAILURE, + RT_STATUS_PENDING, + RT_STATUS_RESOURCE, + RT_STATUS_INVALID_CONTEXT, + RT_STATUS_INVALID_PARAMETER, + RT_STATUS_NOT_SUPPORT, + RT_STATUS_OS_API_FAILED, +}; + +/* 3=========================================================== */ +/* 3 DIG */ +/* 3=========================================================== */ + +enum dm_dig_op { + RT_TYPE_THRESH_HIGH = 0, + RT_TYPE_THRESH_LOW = 1, + RT_TYPE_BACKOFF = 2, + RT_TYPE_RX_GAIN_MIN = 3, + RT_TYPE_RX_GAIN_MAX = 4, + RT_TYPE_ENABLE = 5, + RT_TYPE_DISABLE = 6, + DIG_OP_TYPE_MAX +}; + +#define DM_DIG_THRESH_HIGH 40 +#define DM_DIG_THRESH_LOW 35 + +#define DM_SCAN_RSSI_TH 0x14 /* scan return issue for LC */ + +#define DM_false_ALARM_THRESH_LOW 400 +#define DM_false_ALARM_THRESH_HIGH 1000 + +#define DM_DIG_MAX_NIC 0x4e +#define DM_DIG_MIN_NIC 0x1e /* 0x22/0x1c */ + +#define DM_DIG_MAX_AP 0x32 +#define DM_DIG_MIN_AP 0x20 + +#define DM_DIG_MAX_NIC_HP 0x46 +#define DM_DIG_MIN_NIC_HP 0x2e + +#define DM_DIG_MAX_AP_HP 0x42 +#define DM_DIG_MIN_AP_HP 0x30 + +/* vivi 92c&92d has different definition, 20110504 */ +/* this is for 92c */ +#define DM_DIG_FA_TH0 0x200/* 0x20 */ +#define DM_DIG_FA_TH1 0x300/* 0x100 */ +#define DM_DIG_FA_TH2 0x400/* 0x200 */ +/* this is for 92d */ +#define DM_DIG_FA_TH0_92D 0x100 +#define DM_DIG_FA_TH1_92D 0x400 +#define DM_DIG_FA_TH2_92D 0x600 + +#define DM_DIG_BACKOFF_MAX 12 +#define DM_DIG_BACKOFF_MIN -4 +#define DM_DIG_BACKOFF_DEFAULT 10 + +/* 3=========================================================== */ +/* 3 AGC RX High Power Mode */ +/* 3=========================================================== */ +#define LNA_Low_Gain_1 0x64 +#define LNA_Low_Gain_2 0x5A +#define LNA_Low_Gain_3 0x58 + +#define FA_RXHP_TH1 5000 +#define FA_RXHP_TH2 1500 +#define FA_RXHP_TH3 800 +#define FA_RXHP_TH4 600 +#define FA_RXHP_TH5 500 + +/* 3=========================================================== */ +/* 3 EDCA */ +/* 3=========================================================== */ + +/* 3=========================================================== */ +/* 3 Dynamic Tx Power */ +/* 3=========================================================== */ +/* Dynamic Tx Power Control Threshold */ +#define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 +#define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 +#define TX_POWER_NEAR_FIELD_THRESH_AP 0x3F + +#define TxHighPwrLevel_Normal 0 +#define TxHighPwrLevel_Level1 1 +#define TxHighPwrLevel_Level2 2 +#define TxHighPwrLevel_BT1 3 +#define TxHighPwrLevel_BT2 4 +#define TxHighPwrLevel_15 5 +#define TxHighPwrLevel_35 6 +#define TxHighPwrLevel_50 7 +#define TxHighPwrLevel_70 8 +#define TxHighPwrLevel_100 9 + +/* 3=========================================================== */ +/* 3 Rate Adaptive */ +/* 3=========================================================== */ +#define DM_RATR_STA_INIT 0 +#define DM_RATR_STA_HIGH 1 +#define DM_RATR_STA_MIDDLE 2 +#define DM_RATR_STA_LOW 3 + +/* 3=========================================================== */ +/* 3 BB Power Save */ +/* 3=========================================================== */ + +enum dm_1r_cca { + CCA_1R = 0, + CCA_2R = 1, + CCA_MAX = 2, +}; + +enum dm_rf { + RF_Save = 0, + RF_Normal = 1, + RF_MAX = 2, +}; + +/* 3=========================================================== */ +/* 3 Antenna Diversity */ +/* 3=========================================================== */ +enum dm_swas { + Antenna_A = 1, + Antenna_B = 2, + Antenna_MAX = 3, +}; + +/* Maximal number of antenna detection mechanism needs to perform. */ +#define MAX_ANTENNA_DETECTION_CNT 10 + +/* Extern Global Variables. */ +#define OFDM_TABLE_SIZE_92C 37 +#define OFDM_TABLE_SIZE_92D 43 +#define CCK_TABLE_SIZE 33 + +extern u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D]; +extern u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8]; +extern u8 CCKSwingTable_Ch14 [CCK_TABLE_SIZE][8]; + +/* check Sta pointer valid or not */ +#define IS_STA_VALID(pSta) (pSta) +/* 20100514 Joseph: Add definition for antenna switching test after link. */ +/* This indicates two different the steps. */ +/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to the + * signal on the air. */ +/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in + * SWAW_STEP_PEAK */ +/* with original RSSI to determine if it is necessary to switch antenna. */ +#define SWAW_STEP_PEAK 0 +#define SWAW_STEP_DETERMINE 1 + +void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI); +void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres); + +void ODM_SetAntenna(struct odm_dm_struct *pDM_Odm, u8 Antenna); + +#define dm_RF_Saving ODM_RF_Saving +void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal); + +#define SwAntDivRestAfterLink ODM_SwAntDivRestAfterLink +void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm); + +#define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck +void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm); + +bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, + bool bForceUpdate, u8 *pRATRState); + +#define dm_SWAW_RSSI_Check ODM_SwAntDivChkPerPktRssi +void ODM_SwAntDivChkPerPktRssi(struct odm_dm_struct *pDM_Odm, u8 StationID, + struct odm_phy_status_info *pPhyInfo); + +u32 ConvertTo_dB(u32 Value); + +u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, + u8 initial_gain_psd); + +void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm); + +u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, + u32 ra_mask, u8 rssi_level); + +void ODM_DMInit(struct odm_dm_struct *pDM_Odm); + +void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm); + +void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, + enum odm_common_info_def CmnInfo, u32 Value); + +void ODM_CmnInfoHook(struct odm_dm_struct *pDM_Odm, + enum odm_common_info_def CmnInfo, void *pValue); + +void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, + enum odm_common_info_def CmnInfo, + u16 Index, void *pValue); + +void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value); + +void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm); + +void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm); + +void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm); + +void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); + +void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, + u32 PWDBAll, bool isCCKrate); + +void ODM_SingleDualAntennaDefaultSetting(struct odm_dm_struct *pDM_Odm); + +bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode); + +void odm_dtc(struct odm_dm_struct *pDM_Odm); + +#endif diff --git a/drivers/staging/r8188eu/include/odm_HWConfig.h b/drivers/staging/r8188eu/include/odm_HWConfig.h new file mode 100644 index 000000000000..80f549f196e2 --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_HWConfig.h @@ -0,0 +1,133 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __HALHWOUTSRC_H__ +#define __HALHWOUTSRC_H__ + +/* Definition */ +/* CCK Rates, TxHT = 0 */ +#define DESC92C_RATE1M 0x00 +#define DESC92C_RATE2M 0x01 +#define DESC92C_RATE5_5M 0x02 +#define DESC92C_RATE11M 0x03 + +/* OFDM Rates, TxHT = 0 */ +#define DESC92C_RATE6M 0x04 +#define DESC92C_RATE9M 0x05 +#define DESC92C_RATE12M 0x06 +#define DESC92C_RATE18M 0x07 +#define DESC92C_RATE24M 0x08 +#define DESC92C_RATE36M 0x09 +#define DESC92C_RATE48M 0x0a +#define DESC92C_RATE54M 0x0b + +/* MCS Rates, TxHT = 1 */ +#define DESC92C_RATEMCS0 0x0c +#define DESC92C_RATEMCS1 0x0d +#define DESC92C_RATEMCS2 0x0e +#define DESC92C_RATEMCS3 0x0f +#define DESC92C_RATEMCS4 0x10 +#define DESC92C_RATEMCS5 0x11 +#define DESC92C_RATEMCS6 0x12 +#define DESC92C_RATEMCS7 0x13 +#define DESC92C_RATEMCS8 0x14 +#define DESC92C_RATEMCS9 0x15 +#define DESC92C_RATEMCS10 0x16 +#define DESC92C_RATEMCS11 0x17 +#define DESC92C_RATEMCS12 0x18 +#define DESC92C_RATEMCS13 0x19 +#define DESC92C_RATEMCS14 0x1a +#define DESC92C_RATEMCS15 0x1b +#define DESC92C_RATEMCS15_SG 0x1c +#define DESC92C_RATEMCS32 0x20 + +/* structure and define */ + +struct phy_rx_agc_info { + #ifdef __LITTLE_ENDIAN + u8 gain:7, trsw:1; + #else + u8 trsw:1, gain:7; + #endif +}; + +struct phy_status_rpt { + struct phy_rx_agc_info path_agc[3]; + u8 ch_corr[2]; + u8 cck_sig_qual_ofdm_pwdb_all; + u8 cck_agc_rpt_ofdm_cfosho_a; + u8 cck_rpt_b_ofdm_cfosho_b; + u8 rsvd_1;/* ch_corr_msb; */ + u8 noise_power_db_msb; + u8 path_cfotail[2]; + u8 pcts_mask[2]; + s8 stream_rxevm[2]; + u8 path_rxsnr[3]; + u8 noise_power_db_lsb; + u8 rsvd_2[3]; + u8 stream_csi[2]; + u8 stream_target_csi[2]; + s8 sig_evm; + u8 rsvd_3; + +#ifdef __LITTLE_ENDIAN + u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ + u8 sgi_en:1; + u8 rxsc:2; + u8 idle_long:1; + u8 r_ant_train_en:1; + u8 ant_sel_b:1; + u8 ant_sel:1; +#else /* _BIG_ENDIAN_ */ + u8 ant_sel:1; + u8 ant_sel_b:1; + u8 r_ant_train_en:1; + u8 idle_long:1; + u8 rxsc:2; + u8 sgi_en:1; + u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ +#endif +}; + +void odm_Init_RSSIForDM(struct odm_dm_struct *pDM_Odm); + +void ODM_PhyStatusQuery(struct odm_dm_struct *pDM_Odm, + struct odm_phy_status_info *pPhyInfo, + u8 *pPhyStatus, + struct odm_per_pkt_info *pPktinfo, + struct adapter *adapt); + +void ODM_MacStatusQuery(struct odm_dm_struct *pDM_Odm, + u8 *pMacStatus, + u8 MacID, + bool bPacketMatchBSSID, + bool bPacketToSelf, + bool bPacketBeacon); + +enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *pDM_Odm, + enum rf_radio_path Content, + enum rf_radio_path eRFPath); + +enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *pDM_Odm, + enum odm_bb_config_type ConfigType); + +enum HAL_STATUS ODM_ConfigMACWithHeaderFile(struct odm_dm_struct *pDM_Odm); + +#endif diff --git a/drivers/staging/r8188eu/include/odm_RTL8188E.h b/drivers/staging/r8188eu/include/odm_RTL8188E.h new file mode 100644 index 000000000000..f96ad5af4bd5 --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_RTL8188E.h @@ -0,0 +1,56 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __ODM_RTL8188E_H__ +#define __ODM_RTL8188E_H__ + +#define MAIN_ANT 0 +#define AUX_ANT 1 +#define MAIN_ANT_CG_TRX 1 +#define AUX_ANT_CG_TRX 0 +#define MAIN_ANT_CGCS_RX 0 +#define AUX_ANT_CGCS_RX 1 + +void ODM_DIG_LowerBound_88E(struct odm_dm_struct *pDM_Odm); + +void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *pDM_Odm); + +void ODM_AntennaDiversity_88E(struct odm_dm_struct *pDM_Odm); + +void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *pDM_Odm, u8 *pDesc, + u8 macId); + +void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *pDM_Odm, u8 Ant); + +void ODM_AntselStatistics_88E(struct odm_dm_struct *pDM_Odm, u8 antsel_tr_mux, + u32 MacId, u8 RxPWDBAll); + +void odm_FastAntTraining(struct odm_dm_struct *pDM_Odm); + +void odm_FastAntTrainingCallback(struct odm_dm_struct *pDM_Odm); + +void odm_FastAntTrainingWorkItemCallback(struct odm_dm_struct *pDM_Odm); + +void odm_PrimaryCCA_Init(struct odm_dm_struct *pDM_Odm); + +bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); + +void odm_DynamicPrimaryCCA(struct odm_dm_struct *pDM_Odm); + +#endif diff --git a/drivers/staging/r8188eu/include/odm_RegConfig8188E.h b/drivers/staging/r8188eu/include/odm_RegConfig8188E.h new file mode 100644 index 000000000000..f2bf7a0d9867 --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_RegConfig8188E.h @@ -0,0 +1,43 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __INC_ODM_REGCONFIG_H_8188E +#define __INC_ODM_REGCONFIG_H_8188E + +void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data, + enum rf_radio_path RF_PATH, u32 RegAddr); + +void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, + u32 Addr, u32 Data); + +void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, + u32 Addr, u32 Data); + +void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data); + +void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data); + +void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data); + +void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, + u32 Bitmask, u32 Data); + +#endif diff --git a/drivers/staging/r8188eu/include/odm_RegDefine11AC.h b/drivers/staging/r8188eu/include/odm_RegDefine11AC.h new file mode 100644 index 000000000000..01425f36634c --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_RegDefine11AC.h @@ -0,0 +1,46 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_REGDEFINE11AC_H__ +#define __ODM_REGDEFINE11AC_H__ + +/* 2 RF REG LIST */ + +/* 2 BB REG LIST */ +/* PAGE 8 */ +/* PAGE 9 */ +#define ODM_REG_OFDM_FA_RST_11AC 0x9A4 +/* PAGE A */ +#define ODM_REG_CCK_CCA_11AC 0xA0A +#define ODM_REG_CCK_FA_RST_11AC 0xA2C +#define ODM_REG_CCK_FA_11AC 0xA5C +/* PAGE C */ +#define ODM_REG_IGI_A_11AC 0xC50 +/* PAGE E */ +#define ODM_REG_IGI_B_11AC 0xE50 +/* PAGE F */ +#define ODM_REG_OFDM_FA_11AC 0xF48 + +/* 2 MAC REG LIST */ + +/* DIG Related */ +#define ODM_BIT_IGI_11AC 0xFFFFFFFF + +#endif diff --git a/drivers/staging/r8188eu/include/odm_RegDefine11N.h b/drivers/staging/r8188eu/include/odm_RegDefine11N.h new file mode 100644 index 000000000000..2b888dee3dd5 --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_RegDefine11N.h @@ -0,0 +1,160 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_REGDEFINE11N_H__ +#define __ODM_REGDEFINE11N_H__ + +/* 2 RF REG LIST */ +#define ODM_REG_RF_MODE_11N 0x00 +#define ODM_REG_RF_0B_11N 0x0B +#define ODM_REG_CHNBW_11N 0x18 +#define ODM_REG_T_METER_11N 0x24 +#define ODM_REG_RF_25_11N 0x25 +#define ODM_REG_RF_26_11N 0x26 +#define ODM_REG_RF_27_11N 0x27 +#define ODM_REG_RF_2B_11N 0x2B +#define ODM_REG_RF_2C_11N 0x2C +#define ODM_REG_RXRF_A3_11N 0x3C +#define ODM_REG_T_METER_92D_11N 0x42 +#define ODM_REG_T_METER_88E_11N 0x42 + +/* 2 BB REG LIST */ +/* PAGE 8 */ +#define ODM_REG_BB_CTRL_11N 0x800 +#define ODM_REG_RF_PIN_11N 0x804 +#define ODM_REG_PSD_CTRL_11N 0x808 +#define ODM_REG_TX_ANT_CTRL_11N 0x80C +#define ODM_REG_BB_PWR_SAV5_11N 0x818 +#define ODM_REG_CCK_RPT_FORMAT_11N 0x824 +#define ODM_REG_RX_DEFUALT_A_11N 0x858 +#define ODM_REG_RX_DEFUALT_B_11N 0x85A +#define ODM_REG_BB_PWR_SAV3_11N 0x85C +#define ODM_REG_ANTSEL_CTRL_11N 0x860 +#define ODM_REG_RX_ANT_CTRL_11N 0x864 +#define ODM_REG_PIN_CTRL_11N 0x870 +#define ODM_REG_BB_PWR_SAV1_11N 0x874 +#define ODM_REG_ANTSEL_PATH_11N 0x878 +#define ODM_REG_BB_3WIRE_11N 0x88C +#define ODM_REG_SC_CNT_11N 0x8C4 +#define ODM_REG_PSD_DATA_11N 0x8B4 +/* PAGE 9 */ +#define ODM_REG_ANT_MAPPING1_11N 0x914 +#define ODM_REG_ANT_MAPPING2_11N 0x918 +/* PAGE A */ +#define ODM_REG_CCK_ANTDIV_PARA1_11N 0xA00 +#define ODM_REG_CCK_CCA_11N 0xA0A +#define ODM_REG_CCK_ANTDIV_PARA2_11N 0xA0C +#define ODM_REG_CCK_ANTDIV_PARA3_11N 0xA10 +#define ODM_REG_CCK_ANTDIV_PARA4_11N 0xA14 +#define ODM_REG_CCK_FILTER_PARA1_11N 0xA22 +#define ODM_REG_CCK_FILTER_PARA2_11N 0xA23 +#define ODM_REG_CCK_FILTER_PARA3_11N 0xA24 +#define ODM_REG_CCK_FILTER_PARA4_11N 0xA25 +#define ODM_REG_CCK_FILTER_PARA5_11N 0xA26 +#define ODM_REG_CCK_FILTER_PARA6_11N 0xA27 +#define ODM_REG_CCK_FILTER_PARA7_11N 0xA28 +#define ODM_REG_CCK_FILTER_PARA8_11N 0xA29 +#define ODM_REG_CCK_FA_RST_11N 0xA2C +#define ODM_REG_CCK_FA_MSB_11N 0xA58 +#define ODM_REG_CCK_FA_LSB_11N 0xA5C +#define ODM_REG_CCK_CCA_CNT_11N 0xA60 +#define ODM_REG_BB_PWR_SAV4_11N 0xA74 +/* PAGE B */ +#define ODM_REG_LNA_SWITCH_11N 0xB2C +#define ODM_REG_PATH_SWITCH_11N 0xB30 +#define ODM_REG_RSSI_CTRL_11N 0xB38 +#define ODM_REG_CONFIG_ANTA_11N 0xB68 +#define ODM_REG_RSSI_BT_11N 0xB9C +/* PAGE C */ +#define ODM_REG_OFDM_FA_HOLDC_11N 0xC00 +#define ODM_REG_RX_PATH_11N 0xC04 +#define ODM_REG_TRMUX_11N 0xC08 +#define ODM_REG_OFDM_FA_RSTC_11N 0xC0C +#define ODM_REG_RXIQI_MATRIX_11N 0xC14 +#define ODM_REG_TXIQK_MATRIX_LSB1_11N 0xC4C +#define ODM_REG_IGI_A_11N 0xC50 +#define ODM_REG_ANTDIV_PARA2_11N 0xC54 +#define ODM_REG_IGI_B_11N 0xC58 +#define ODM_REG_ANTDIV_PARA3_11N 0xC5C +#define ODM_REG_BB_PWR_SAV2_11N 0xC70 +#define ODM_REG_RX_OFF_11N 0xC7C +#define ODM_REG_TXIQK_MATRIXA_11N 0xC80 +#define ODM_REG_TXIQK_MATRIXB_11N 0xC88 +#define ODM_REG_TXIQK_MATRIXA_LSB2_11N 0xC94 +#define ODM_REG_TXIQK_MATRIXB_LSB2_11N 0xC9C +#define ODM_REG_RXIQK_MATRIX_LSB_11N 0xCA0 +#define ODM_REG_ANTDIV_PARA1_11N 0xCA4 +#define ODM_REG_OFDM_FA_TYPE1_11N 0xCF0 +/* PAGE D */ +#define ODM_REG_OFDM_FA_RSTD_11N 0xD00 +#define ODM_REG_OFDM_FA_TYPE2_11N 0xDA0 +#define ODM_REG_OFDM_FA_TYPE3_11N 0xDA4 +#define ODM_REG_OFDM_FA_TYPE4_11N 0xDA8 +/* PAGE E */ +#define ODM_REG_TXAGC_A_6_18_11N 0xE00 +#define ODM_REG_TXAGC_A_24_54_11N 0xE04 +#define ODM_REG_TXAGC_A_1_MCS32_11N 0xE08 +#define ODM_REG_TXAGC_A_MCS0_3_11N 0xE10 +#define ODM_REG_TXAGC_A_MCS4_7_11N 0xE14 +#define ODM_REG_TXAGC_A_MCS8_11_11N 0xE18 +#define ODM_REG_TXAGC_A_MCS12_15_11N 0xE1C +#define ODM_REG_FPGA0_IQK_11N 0xE28 +#define ODM_REG_TXIQK_TONE_A_11N 0xE30 +#define ODM_REG_RXIQK_TONE_A_11N 0xE34 +#define ODM_REG_TXIQK_PI_A_11N 0xE38 +#define ODM_REG_RXIQK_PI_A_11N 0xE3C +#define ODM_REG_TXIQK_11N 0xE40 +#define ODM_REG_RXIQK_11N 0xE44 +#define ODM_REG_IQK_AGC_PTS_11N 0xE48 +#define ODM_REG_IQK_AGC_RSP_11N 0xE4C +#define ODM_REG_BLUETOOTH_11N 0xE6C +#define ODM_REG_RX_WAIT_CCA_11N 0xE70 +#define ODM_REG_TX_CCK_RFON_11N 0xE74 +#define ODM_REG_TX_CCK_BBON_11N 0xE78 +#define ODM_REG_OFDM_RFON_11N 0xE7C +#define ODM_REG_OFDM_BBON_11N 0xE80 +#define ODM_REG_TX2RX_11N 0xE84 +#define ODM_REG_TX2TX_11N 0xE88 +#define ODM_REG_RX_CCK_11N 0xE8C +#define ODM_REG_RX_OFDM_11N 0xED0 +#define ODM_REG_RX_WAIT_RIFS_11N 0xED4 +#define ODM_REG_RX2RX_11N 0xED8 +#define ODM_REG_STANDBY_11N 0xEDC +#define ODM_REG_SLEEP_11N 0xEE0 +#define ODM_REG_PMPD_ANAEN_11N 0xEEC + +/* 2 MAC REG LIST */ +#define ODM_REG_BB_RST_11N 0x02 +#define ODM_REG_ANTSEL_PIN_11N 0x4C +#define ODM_REG_EARLY_MODE_11N 0x4D0 +#define ODM_REG_RSSI_MONITOR_11N 0x4FE +#define ODM_REG_EDCA_VO_11N 0x500 +#define ODM_REG_EDCA_VI_11N 0x504 +#define ODM_REG_EDCA_BE_11N 0x508 +#define ODM_REG_EDCA_BK_11N 0x50C +#define ODM_REG_TXPAUSE_11N 0x522 +#define ODM_REG_RESP_TX_11N 0x6D8 +#define ODM_REG_ANT_TRAIN_PARA1_11N 0x7b0 +#define ODM_REG_ANT_TRAIN_PARA2_11N 0x7b4 + +/* DIG Related */ +#define ODM_BIT_IGI_11N 0x0000007F + +#endif diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h new file mode 100644 index 000000000000..5e58b603d6ac --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -0,0 +1,143 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_DBG_H__ +#define __ODM_DBG_H__ + +/* */ +/* Define the debug levels */ +/* */ +/* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */ +/* They can help SW engineer to develop or trace states changed */ +/* and also help HW enginner to trace every operation to and from HW, */ +/* e.g IO, Tx, Rx. */ +/* */ +/* 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */ +/* which help us to debug SW or HW. */ + +/* Never used in a call to ODM_RT_TRACE()! */ +#define ODM_DBG_OFF 1 + +/* Fatal bug. */ +/* For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */ +/* resource allocation failed, unexpected HW behavior, HW BUG and so on. */ +#define ODM_DBG_SERIOUS 2 + +/* Abnormal, rare, or unexpeted cases. */ +/* For example, IRP/Packet/OID canceled, device suprisely unremoved and so on. */ +#define ODM_DBG_WARNING 3 + +/* Normal case with useful information about current SW or HW state. */ +/* For example, Tx/Rx descriptor to fill, Tx/Rx descr. completed status, */ +/* SW protocol state change, dynamic mechanism state change and so on. */ +/* */ +#define ODM_DBG_LOUD 4 + +/* Normal case with detail execution flow or information. */ +#define ODM_DBG_TRACE 5 + +/* Define the tracing components */ +/* BB Functions */ +#define ODM_COMP_DIG BIT0 +#define ODM_COMP_RA_MASK BIT1 +#define ODM_COMP_DYNAMIC_TXPWR BIT2 +#define ODM_COMP_FA_CNT BIT3 +#define ODM_COMP_RSSI_MONITOR BIT4 +#define ODM_COMP_CCK_PD BIT5 +#define ODM_COMP_ANT_DIV BIT6 +#define ODM_COMP_PWR_SAVE BIT7 +#define ODM_COMP_PWR_TRA BIT8 +#define ODM_COMP_RATE_ADAPTIVE BIT9 +#define ODM_COMP_PATH_DIV BIT10 +#define ODM_COMP_PSD BIT11 +#define ODM_COMP_DYNAMIC_PRICCA BIT12 +#define ODM_COMP_RXHP BIT13 +/* MAC Functions */ +#define ODM_COMP_EDCA_TURBO BIT16 +#define ODM_COMP_EARLY_MODE BIT17 +/* RF Functions */ +#define ODM_COMP_TX_PWR_TRACK BIT24 +#define ODM_COMP_RX_GAIN_TRACK BIT25 +#define ODM_COMP_CALIBRATION BIT26 +/* Common Functions */ +#define ODM_COMP_COMMON BIT30 +#define ODM_COMP_INIT BIT31 + +/*------------------------Export Marco Definition---------------------------*/ +#define DbgPrint pr_info +#define RT_PRINTK(fmt, args...) \ + DbgPrint( "%s(): " fmt, __func__, ## args); + +#ifndef ASSERT + #define ASSERT(expr) +#endif + +#define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ + if (((comp) & pDM_Odm->DebugComponents) && \ + (level <= pDM_Odm->DebugLevel)) { \ + if (pDM_Odm->SupportICType == ODM_RTL8192C) \ + DbgPrint("[ODM-92C] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8192D) \ + DbgPrint("[ODM-92D] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8723A) \ + DbgPrint("[ODM-8723A] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8188E) \ + DbgPrint("[ODM-8188E] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8812) \ + DbgPrint("[ODM-8812] "); \ + else if (pDM_Odm->SupportICType == ODM_RTL8821) \ + DbgPrint("[ODM-8821] "); \ + RT_PRINTK fmt; \ + } + +#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ + if (((comp) & pDM_Odm->DebugComponents) && \ + (level <= pDM_Odm->DebugLevel)) { \ + RT_PRINTK fmt; \ + } + +#define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ + if (!(expr)) { \ + DbgPrint( "Assertion failed! %s at ......\n", #expr); \ + DbgPrint( " ......%s,%s,line=%d\n", __FILE__, \ + __func__, __LINE__); \ + RT_PRINTK fmt; \ + ASSERT(false); \ + } +#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } +#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } +#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } + +#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ + if (((comp) & pDM_Odm->DebugComponents) && \ + (level <= pDM_Odm->DebugLevel)) { \ + int __i; \ + u8 *__ptr = (u8 *)ptr; \ + DbgPrint("[ODM] "); \ + DbgPrint(title_str); \ + DbgPrint(" "); \ + for (__i = 0; __i < 6; __i++) \ + DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-");\ + DbgPrint("\n"); \ + } + +void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); + +#endif /* __ODM_DBG_H__ */ diff --git a/drivers/staging/r8188eu/include/odm_interface.h b/drivers/staging/r8188eu/include/odm_interface.h new file mode 100644 index 000000000000..0abfa6febb7e --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_interface.h @@ -0,0 +1,164 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_INTERFACE_H__ +#define __ODM_INTERFACE_H__ + +/* */ +/* =========== Constant/Structure/Enum/... Define */ +/* */ + +/* */ +/* =========== Macro Define */ +/* */ + +#define _reg_all(_name) ODM_##_name +#define _reg_ic(_name, _ic) ODM_##_name##_ic +#define _bit_all(_name) BIT_##_name +#define _bit_ic(_name, _ic) BIT_##_name##_ic + +/* _cat: implemented by Token-Pasting Operator. */ + +/*=================================== + +#define ODM_REG_DIG_11N 0xC50 +#define ODM_REG_DIG_11AC 0xDDD + +ODM_REG(DIG,_pDM_Odm) +=====================================*/ + +#define _reg_11N(_name) ODM_REG_##_name##_11N +#define _reg_11AC(_name) ODM_REG_##_name##_11AC +#define _bit_11N(_name) ODM_BIT_##_name##_11N +#define _bit_11AC(_name) ODM_BIT_##_name##_11AC + +#define _cat(_name, _ic_type, _func) \ + ( \ + ((_ic_type) & ODM_IC_11N_SERIES) ? _func##_11N(_name) : \ + _func##_11AC(_name) \ + ) + +/* _name: name of register or bit. */ +/* Example: "ODM_REG(R_A_AGC_CORE1, pDM_Odm)" */ +/* gets "ODM_R_A_AGC_CORE1" or "ODM_R_A_AGC_CORE1_8192C", + * depends on SupportICType. */ +#define ODM_REG(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _reg) +#define ODM_BIT(_name, _pDM_Odm) _cat(_name, _pDM_Odm->SupportICType, _bit) + +enum odm_h2c_cmd { + ODM_H2C_RSSI_REPORT = 0, + ODM_H2C_PSD_RESULT= 1, + ODM_H2C_PathDiv = 2, + ODM_MAX_H2CCMD +}; + +/* 2012/02/17 MH For non-MP compile pass only. Linux does not support workitem. */ +/* Suggest HW team to use thread instead of workitem. Windows also support the feature. */ +typedef void (*RT_WORKITEM_CALL_BACK)(void *pContext); + +/* =========== Extern Variable ??? It should be forbidden. */ + +/* =========== EXtern Function Prototype */ + +u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); + +u16 ODM_Read2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); + +u32 ODM_Read4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr); + +void ODM_Write1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u8 Data); + +void ODM_Write2Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u16 Data); + +void ODM_Write4Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 Data); + +void ODM_SetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, + u32 BitMask, u32 Data); + +u32 ODM_GetMACReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask); + +void ODM_SetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, + u32 BitMask, u32 Data); + +u32 ODM_GetBBReg(struct odm_dm_struct *pDM_Odm, u32 RegAddr, u32 BitMask); + +void ODM_SetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, + u32 RegAddr, u32 BitMask, u32 Data); + +u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, + u32 RegAddr, u32 BitMask); + +/* Memory Relative Function. */ +void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length); +void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length); + +s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, + u32 length); + +/* ODM MISC-spin lock relative API. */ +void ODM_AcquireSpinLock(struct odm_dm_struct *pDM_Odm, + enum RT_SPINLOCK_TYPE type); + +void ODM_ReleaseSpinLock(struct odm_dm_struct *pDM_Odm, + enum RT_SPINLOCK_TYPE type); + +/* ODM MISC-workitem relative API. */ +void ODM_InitializeWorkItem(struct odm_dm_struct *pDM_Odm, void *pRtWorkItem, + RT_WORKITEM_CALL_BACK RtWorkItemCallback, + void *pContext, const char *szID); + +void ODM_StartWorkItem(void *pRtWorkItem); + +void ODM_StopWorkItem(void *pRtWorkItem); + +void ODM_FreeWorkItem(void *pRtWorkItem); + +void ODM_ScheduleWorkItem(void *pRtWorkItem); + +void ODM_IsWorkItemScheduled(void *pRtWorkItem); + +/* ODM Timer relative API. */ +void ODM_StallExecution(u32 usDelay); + +void ODM_delay_ms(u32 ms); + +void ODM_delay_us(u32 us); + +void ODM_sleep_ms(u32 ms); + +void ODM_sleep_us(u32 us); + +void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, + u32 msDelay); + +void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, + struct timer_list *pTimer, void *CallBackFunc, + void *pContext, const char *szID); + +void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); + +void ODM_ReleaseTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer); + +/* ODM FW relative API. */ +u32 ODM_FillH2CCmd(u8 *pH2CBuffer, u32 H2CBufferLen, u32 CmdNum, + u32 *pElementID, u32 *pCmdLen, u8 **pCmbBuffer, + u8 *CmdStartSeq); + +#endif /* __ODM_INTERFACE_H__ */ diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h new file mode 100644 index 000000000000..b2fbb5d5ea77 --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -0,0 +1,103 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __ODM_PRECOMP_H__ +#define __ODM_PRECOMP_H__ + +#include "odm_types.h" + +#define TEST_FALG___ 1 + +/* 2 Config Flags and Structs - defined by each ODM Type */ + +#include +#include +#include + +/* 2 OutSrc Header Files */ + +#include "odm.h" +#include "odm_HWConfig.h" +#include "odm_debug.h" +#include "odm_RegDefine11AC.h" +#include "odm_RegDefine11N.h" + +#include "HalPhyRf.h" +#include "HalPhyRf_8188e.h"/* for IQK,LCK,Power-tracking */ +#include "Hal8188ERateAdaptive.h"/* for RA,Power training */ +#include "rtl8188e_hal.h" + +#include "odm_interface.h" +#include "odm_reg.h" + +#include "HalHWImg8188E_MAC.h" +#include "HalHWImg8188E_RF.h" +#include "HalHWImg8188E_BB.h" +#include "Hal8188EReg.h" + +#include "odm_RegConfig8188E.h" +#include "odm_RTL8188E.h" + +void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm); +void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm); +void odm_DIGInit(struct odm_dm_struct *pDM_Odm); +void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm); +void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm); +void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivInit_NIC(struct odm_dm_struct *pDM_Odm); +void odm_GlobalAdapterCheck(void); +void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm); +void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm); +void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm); +void odm_DIG(struct odm_dm_struct *pDM_Odm); +void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm); +void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step); +void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPower(struct odm_dm_struct *pDM_Odm); +void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm); +void odm_SwAntDivInit(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm); +void odm_1R_CCA(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm); +void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm); +void odm_DynamicTxPowerAP(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheckMP(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm); +void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm); +void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm); +void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); +#else +void odm_SwAntDivChkAntSwitchCallback(struct timer_list *t); +#endif +void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm); +void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm); + +#endif /* __ODM_PRECOMP_H__ */ diff --git a/drivers/staging/r8188eu/include/odm_reg.h b/drivers/staging/r8188eu/include/odm_reg.h new file mode 100644 index 000000000000..4221855e333c --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_reg.h @@ -0,0 +1,116 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/* */ +/* File Name: odm_reg.h */ +/* */ +/* Description: */ +/* */ +/* This file is for general register definition. */ +/* */ +/* */ +/* */ +#ifndef __HAL_ODM_REG_H__ +#define __HAL_ODM_REG_H__ + +/* */ +/* Register Definition */ +/* */ + +/* MAC REG */ +#define ODM_BB_RESET 0x002 +#define ODM_DUMMY 0x4fe +#define ODM_EDCA_VO_PARAM 0x500 +#define ODM_EDCA_VI_PARAM 0x504 +#define ODM_EDCA_BE_PARAM 0x508 +#define ODM_EDCA_BK_PARAM 0x50C +#define ODM_TXPAUSE 0x522 + +/* BB REG */ +#define ODM_FPGA_PHY0_PAGE8 0x800 +#define ODM_PSD_SETTING 0x808 +#define ODM_AFE_SETTING 0x818 +#define ODM_TXAGC_B_6_18 0x830 +#define ODM_TXAGC_B_24_54 0x834 +#define ODM_TXAGC_B_MCS32_5 0x838 +#define ODM_TXAGC_B_MCS0_MCS3 0x83c +#define ODM_TXAGC_B_MCS4_MCS7 0x848 +#define ODM_TXAGC_B_MCS8_MCS11 0x84c +#define ODM_ANALOG_REGISTER 0x85c +#define ODM_RF_INTERFACE_OUTPUT 0x860 +#define ODM_TXAGC_B_MCS12_MCS15 0x868 +#define ODM_TXAGC_B_11_A_2_11 0x86c +#define ODM_AD_DA_LSB_MASK 0x874 +#define ODM_ENABLE_3_WIRE 0x88c +#define ODM_PSD_REPORT 0x8b4 +#define ODM_R_ANT_SELECT 0x90c +#define ODM_CCK_ANT_SELECT 0xa07 +#define ODM_CCK_PD_THRESH 0xa0a +#define ODM_CCK_RF_REG1 0xa11 +#define ODM_CCK_MATCH_FILTER 0xa20 +#define ODM_CCK_RAKE_MAC 0xa2e +#define ODM_CCK_CNT_RESET 0xa2d +#define ODM_CCK_TX_DIVERSITY 0xa2f +#define ODM_CCK_FA_CNT_MSB 0xa5b +#define ODM_CCK_FA_CNT_LSB 0xa5c +#define ODM_CCK_NEW_FUNCTION 0xa75 +#define ODM_OFDM_PHY0_PAGE_C 0xc00 +#define ODM_OFDM_RX_ANT 0xc04 +#define ODM_R_A_RXIQI 0xc14 +#define ODM_R_A_AGC_CORE1 0xc50 +#define ODM_R_A_AGC_CORE2 0xc54 +#define ODM_R_B_AGC_CORE1 0xc58 +#define ODM_R_AGC_PAR 0xc70 +#define ODM_R_HTSTF_AGC_PAR 0xc7c +#define ODM_TX_PWR_TRAINING_A 0xc90 +#define ODM_TX_PWR_TRAINING_B 0xc98 +#define ODM_OFDM_FA_CNT1 0xcf0 +#define ODM_OFDM_PHY0_PAGE_D 0xd00 +#define ODM_OFDM_FA_CNT2 0xda0 +#define ODM_OFDM_FA_CNT3 0xda4 +#define ODM_OFDM_FA_CNT4 0xda8 +#define ODM_TXAGC_A_6_18 0xe00 +#define ODM_TXAGC_A_24_54 0xe04 +#define ODM_TXAGC_A_1_MCS32 0xe08 +#define ODM_TXAGC_A_MCS0_MCS3 0xe10 +#define ODM_TXAGC_A_MCS4_MCS7 0xe14 +#define ODM_TXAGC_A_MCS8_MCS11 0xe18 +#define ODM_TXAGC_A_MCS12_MCS15 0xe1c + +/* RF REG */ +#define ODM_GAIN_SETTING 0x00 +#define ODM_CHANNEL 0x18 + +/* Ant Detect Reg */ +#define ODM_DPDT 0x300 + +/* PSD Init */ +#define ODM_PSDREG 0x808 + +/* 92D Path Div */ +#define PATHDIV_REG 0xB30 +#define PATHDIV_TRI 0xBA0 + +/* */ +/* Bitmap Definition */ +/* */ + +#define BIT_FA_RESET BIT0 + +#endif diff --git a/drivers/staging/r8188eu/include/odm_types.h b/drivers/staging/r8188eu/include/odm_types.h new file mode 100644 index 000000000000..f62d8b486a28 --- /dev/null +++ b/drivers/staging/r8188eu/include/odm_types.h @@ -0,0 +1,61 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __ODM_TYPES_H__ +#define __ODM_TYPES_H__ + +/* */ +/* Define Different SW team support */ +/* */ +#define ODM_AP 0x01 /* BIT0 */ +#define ODM_ADSL 0x02 /* BIT1 */ +#define ODM_CE 0x04 /* BIT2 */ +#define ODM_MP 0x08 /* BIT3 */ + +#define RT_PCI_INTERFACE 1 +#define RT_USB_INTERFACE 2 +#define RT_SDIO_INTERFACE 3 + +enum HAL_STATUS { + HAL_STATUS_SUCCESS, + HAL_STATUS_FAILURE, +}; + +enum RT_SPINLOCK_TYPE { + RT_TEMP = 1, +}; + +#include + +#define DEV_BUS_TYPE RT_USB_INTERFACE + +#define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ + SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) +#define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ + SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 25, 1, __Value) +#define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ + SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) + +/* define useless flag to avoid compile warning */ +#define USE_WORKITEM 0 +#define FOR_BRAZIL_PRETEST 0 +#define BT_30_SUPPORT 0 +#define FPGA_TWO_MAC_VERIFICATION 0 + +#endif /* __ODM_TYPES_H__ */ diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h new file mode 100644 index 000000000000..c4599c583b59 --- /dev/null +++ b/drivers/staging/r8188eu/include/osdep_intf.h @@ -0,0 +1,83 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __OSDEP_INTF_H_ +#define __OSDEP_INTF_H_ + +#include +#include + +struct intf_priv { + u8 *intf_dev; + u32 max_iosz; /* USB2.0: 128, USB1.1: 64, SDIO:64 */ + u32 max_xmitsz; /* USB2.0: unlimited, SDIO:512 */ + u32 max_recvsz; /* USB2.0: unlimited, SDIO:512 */ + + u8 *io_rwmem; + u8 *allocated_io_rwmem; + u32 io_wsz; /* unit: 4bytes */ + u32 io_rsz;/* unit: 4bytes */ + u8 intf_status; + + void (*_bus_io)(u8 *priv); + +/* +Under Sync. IRP (SDIO/USB) +A protection mechanism is necessary for the io_rwmem(read/write protocol) + +Under Async. IRP (SDIO/USB) +The protection mechanism is through the pending queue. +*/ + struct mutex ioctl_mutex; + /* when in USB, IO is through interrupt in/out endpoints */ + struct usb_device *udev; + struct urb *piorw_urb; + u8 io_irp_cnt; + u8 bio_irp_pending; + struct semaphore io_retevt; + struct timer_list io_timer; + u8 bio_irp_timeout; + u8 bio_timer_cancel; +}; + +u8 rtw_init_drv_sw(struct adapter *padapter); +u8 rtw_free_drv_sw(struct adapter *padapter); +u8 rtw_reset_drv_sw(struct adapter *padapter); + +u32 rtw_start_drv_threads(struct adapter *padapter); +void rtw_stop_drv_threads (struct adapter *padapter); +void rtw_cancel_all_timer(struct adapter *padapter); + +int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); + +int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname); +struct net_device *rtw_init_netdev(struct adapter *padapter); +u16 rtw_recv_select_queue(struct sk_buff *skb); +void rtw_proc_init_one(struct net_device *dev); +void rtw_proc_remove_one(struct net_device *dev); + +void rtw_ips_dev_unload(struct adapter *padapter); + +int rtw_ips_pwr_up(struct adapter *padapter); +void rtw_ips_pwr_down(struct adapter *padapter); +int rtw_hw_suspend(struct adapter *padapter); +int rtw_hw_resume(struct adapter *padapter); + +#endif /* _OSDEP_INTF_H_ */ diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h new file mode 100644 index 000000000000..ce76a2c99bbd --- /dev/null +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -0,0 +1,489 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __OSDEP_SERVICE_H_ +#define __OSDEP_SERVICE_H_ + +#include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) +#include +#endif +#include + +#define _FAIL 0 +#define _SUCCESS 1 +#define RTW_RX_HANDLED 2 + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /* Necessary because we use the proc fs */ +#include /* for struct tasklet_struct */ +#include +#include + +#include +#include + +struct __queue { + struct list_head queue; + spinlock_t lock; +}; + +#define thread_exit() complete_and_exit(NULL, 0) + +static inline struct list_head *get_list_head(struct __queue *queue) +{ + return (&(queue->queue)); +} + +static inline int _enter_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) +{ + int ret; + + ret = mutex_lock_interruptible(pmutex); + return ret; +} + +static inline void _exit_critical_mutex(struct mutex *pmutex, unsigned long *pirqL) +{ + mutex_unlock(pmutex); +} + +static inline void rtw_list_delete(struct list_head *plist) +{ + list_del_init(plist); +} + +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +static inline void _init_timer(struct timer_list *ptimer,struct net_device *nic_hdl,void *pfunc,void* cntx) +{ + ptimer->function = pfunc; + ptimer->data = (unsigned long)cntx; + init_timer(ptimer); +} +#endif + +static inline void _set_timer(struct timer_list *ptimer,u32 delay_time) +{ + mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); +} + +static inline void _cancel_timer(struct timer_list *ptimer,u8 *bcancelled) +{ + del_timer_sync(ptimer); + *bcancelled= true;/* true ==1; false==0 */ +} + +#define RTW_TIMER_HDL_ARGS void *FunctionContext +#define RTW_TIMER_HDL_NAME(name) rtw_##name##_timer_hdl +#define RTW_DECLARE_TIMER_HDL(name) void RTW_TIMER_HDL_NAME(name)(RTW_TIMER_HDL_ARGS) + +static inline void _init_workitem(struct work_struct *pwork, void *pfunc, void * cntx) +{ + INIT_WORK(pwork, pfunc); +} + +static inline void _set_workitem(struct work_struct *pwork) +{ + schedule_work(pwork); +} + +static inline void _cancel_workitem_sync(struct work_struct *pwork) +{ + cancel_work_sync(pwork); +} +/* */ +/* Global Mutex: can only be used at PASSIVE level. */ +/* */ + +#define ACQUIRE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + while (atomic_inc_return((atomic_t *)&(_MutexCounter)) != 1)\ + { \ + atomic_dec((atomic_t *)&(_MutexCounter)); \ + msleep(10); \ + } \ +} + +#define RELEASE_GLOBAL_MUTEX(_MutexCounter) \ +{ \ + atomic_dec((atomic_t *)&(_MutexCounter)); \ +} + +static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) +{ + return netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) && + netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) && + netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) && + netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); +} + +static inline void rtw_netif_wake_queue(struct net_device *pnetdev) +{ + netif_tx_wake_all_queues(pnetdev); +} + +static inline void rtw_netif_start_queue(struct net_device *pnetdev) +{ + netif_tx_start_all_queues(pnetdev); +} + +static inline void rtw_netif_stop_queue(struct net_device *pnetdev) +{ + netif_tx_stop_all_queues(pnetdev); +} + +#ifndef BIT + #define BIT(x) ( 1 << (x)) +#endif + +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 +#define BIT32 0x0100000000 +#define BIT33 0x0200000000 +#define BIT34 0x0400000000 +#define BIT35 0x0800000000 +#define BIT36 0x1000000000 + +extern int RTW_STATUS_CODE(int error_code); + +/* flags used for rtw_update_mem_stat() */ +enum { + MEM_STAT_VIR_ALLOC_SUCCESS, + MEM_STAT_VIR_ALLOC_FAIL, + MEM_STAT_VIR_FREE, + MEM_STAT_PHY_ALLOC_SUCCESS, + MEM_STAT_PHY_ALLOC_FAIL, + MEM_STAT_PHY_FREE, + MEM_STAT_TX, /* used to distinguish TX/RX, asigned from caller */ + MEM_STAT_TX_ALLOC_SUCCESS, + MEM_STAT_TX_ALLOC_FAIL, + MEM_STAT_TX_FREE, + MEM_STAT_RX, /* used to distinguish TX/RX, asigned from caller */ + MEM_STAT_RX_ALLOC_SUCCESS, + MEM_STAT_RX_ALLOC_FAIL, + MEM_STAT_RX_FREE +}; + +extern unsigned char MCS_rate_2R[16]; +extern unsigned char MCS_rate_1R[16]; +extern unsigned char RTW_WPA_OUI[]; +extern unsigned char WPA_TKIP_CIPHER[4]; +extern unsigned char RSN_TKIP_CIPHER[4]; + +#define rtw_update_mem_stat(flag, sz) do {} while (0) +u8 *_rtw_vmalloc(u32 sz); +u8 *_rtw_zvmalloc(u32 sz); +void _rtw_vmfree(u8 *pbuf, u32 sz); +u8 *_rtw_zmalloc(u32 sz); +u8 *_rtw_malloc(u32 sz); +void _rtw_mfree(u8 *pbuf, u32 sz); +#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) +#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) +#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) +#define rtw_malloc(sz) _rtw_malloc((sz)) +#define rtw_zmalloc(sz) _rtw_zmalloc((sz)) +#define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) + +void *rtw_malloc2d(int h, int w, int size); +void rtw_mfree2d(void *pbuf, int h, int w, int size); + +u32 _rtw_down_sema(struct semaphore *sema); +void _rtw_mutex_init(struct mutex *pmutex); +void _rtw_mutex_free(struct mutex *pmutex); +void _rtw_spinlock_free(spinlock_t *plock); + +void _rtw_init_queue(struct __queue *pqueue); + +u32 rtw_systime_to_ms(u32 systime); +u32 rtw_ms_to_systime(u32 ms); +s32 rtw_get_passing_time_ms(u32 start); +s32 rtw_get_time_interval_ms(u32 start, u32 end); + +void rtw_sleep_schedulable(int ms); + +void rtw_msleep_os(int ms); +void rtw_usleep_os(int us); + +u32 rtw_atoi(u8 *s); + +void rtw_mdelay_os(int ms); +void rtw_udelay_os(int us); + +void rtw_yield_os(void); + +static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) +{ + return del_timer_sync(ptimer); +} + +static __inline void thread_enter(char *name) +{ +#ifdef daemonize + daemonize("%s", name); +#endif + allow_signal(SIGTERM); +} + +static inline void flush_signals_thread(void) +{ + if (signal_pending (current)) + flush_signals(current); +} + +static inline int res_to_status(int res) +{ + return res; +} + +#define _RND(sz, r) ((((sz)+((r)-1))/(r))*(r)) +#define RND4(x) (((x >> 2) + (((x & 3) == 0) ? 0: 1)) << 2) + +static inline u32 _RND4(u32 sz) +{ + u32 val; + + val = ((sz >> 2) + ((sz & 3) ? 1: 0)) << 2; + return val; +} + +static inline u32 _RND8(u32 sz) +{ + u32 val; + + val = ((sz >> 3) + ((sz & 7) ? 1: 0)) << 3; + return val; +} + +static inline u32 _RND128(u32 sz) +{ + u32 val; + + val = ((sz >> 7) + ((sz & 127) ? 1: 0)) << 7; + return val; +} + +static inline u32 _RND256(u32 sz) +{ + u32 val; + + val = ((sz >> 8) + ((sz & 255) ? 1: 0)) << 8; + return val; +} + +static inline u32 _RND512(u32 sz) +{ + u32 val; + + val = ((sz >> 9) + ((sz & 511) ? 1: 0)) << 9; + return val; +} + +static inline u32 bitshift(u32 bitmask) +{ + u32 i; + + for (i = 0; i <= 31; i++) + if (((bitmask>>i) & 0x1) == 1) break; + return i; +} + +/* limitation of path length */ +#define PATH_LENGTH_MAX PATH_MAX + +void rtw_suspend_lock_init(void); +void rtw_suspend_lock_uninit(void); +void rtw_lock_suspend(void); +void rtw_unlock_suspend(void); + +/* Atomic integer operations */ +#define ATOMIC_T atomic_t + +void ATOMIC_SET(ATOMIC_T *v, int i); +int ATOMIC_READ(ATOMIC_T *v); +void ATOMIC_ADD(ATOMIC_T *v, int i); +void ATOMIC_SUB(ATOMIC_T *v, int i); +void ATOMIC_INC(ATOMIC_T *v); +void ATOMIC_DEC(ATOMIC_T *v); +int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i); +int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); +int ATOMIC_INC_RETURN(ATOMIC_T *v); +int ATOMIC_DEC_RETURN(ATOMIC_T *v); + +struct rtw_netdev_priv_indicator { + void *priv; + u32 sizeof_priv; +}; +struct net_device *rtw_alloc_etherdev_with_old_priv(int sizeof_priv, + void *old_priv); +struct net_device *rtw_alloc_etherdev(int sizeof_priv); + +#define rtw_netdev_priv(netdev) \ + (((struct rtw_netdev_priv_indicator *)netdev_priv(netdev))->priv) +void rtw_free_netdev(struct net_device *netdev); + +#define NDEV_FMT "%s" +#define NDEV_ARG(ndev) ndev->name +#define ADPT_FMT "%s" +#define ADPT_ARG(adapter) adapter->pnetdev->name +#define FUNC_NDEV_FMT "%s(%s)" +#define FUNC_NDEV_ARG(ndev) __func__, ndev->name +#define FUNC_ADPT_FMT "%s(%s)" +#define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name + +#define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) + +u64 rtw_modular64(u64 x, u64 y); +u64 rtw_division64(u64 x, u64 y); + +/* Macros for handling unaligned memory accesses */ + +#define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1])) +#define RTW_PUT_BE16(a, val) \ + do { \ + (a)[0] = ((u16) (val)) >> 8; \ + (a)[1] = ((u16) (val)) & 0xff; \ + } while (0) + +#define RTW_PUT_LE16(a, val) \ + do { \ + (a)[1] = ((u16) (val)) >> 8; \ + (a)[0] = ((u16) (val)) & 0xff; \ + } while (0) + +#define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ + ((u32) (a)[2])) +#define RTW_PUT_BE24(a, val) \ + do { \ + (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[2] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ + (((u32) (a)[2]) << 8) | ((u32) (a)[3])) +#define RTW_PUT_BE32(a, val) \ + do { \ + (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[3] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \ + (((u32) (a)[1]) << 8) | ((u32) (a)[0])) +#define RTW_PUT_LE32(a, val) \ + do { \ + (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ + (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ + (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ + (a)[0] = (u8) (((u32) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \ + (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \ + (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \ + (((u64) (a)[6]) << 8) | ((u64) (a)[7])) +#define RTW_PUT_BE64(a, val) \ + do { \ + (a)[0] = (u8) (((u64) (val)) >> 56); \ + (a)[1] = (u8) (((u64) (val)) >> 48); \ + (a)[2] = (u8) (((u64) (val)) >> 40); \ + (a)[3] = (u8) (((u64) (val)) >> 32); \ + (a)[4] = (u8) (((u64) (val)) >> 24); \ + (a)[5] = (u8) (((u64) (val)) >> 16); \ + (a)[6] = (u8) (((u64) (val)) >> 8); \ + (a)[7] = (u8) (((u64) (val)) & 0xff); \ + } while (0) + +#define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \ + (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \ + (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ + (((u64) (a)[1]) << 8) | ((u64) (a)[0])) + +void rtw_buf_free(u8 **buf, u32 *buf_len); +void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); + +struct rtw_cbuf { + u32 write; + u32 read; + u32 size; + void *bufs[0]; +}; + +bool rtw_cbuf_full(struct rtw_cbuf *cbuf); +bool rtw_cbuf_empty(struct rtw_cbuf *cbuf); +bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf); +void *rtw_cbuf_pop(struct rtw_cbuf *cbuf); +struct rtw_cbuf *rtw_cbuf_alloc(u32 size); +int wifirate2_ratetbl_inx(unsigned char rate); + +#endif diff --git a/drivers/staging/r8188eu/include/recv_osdep.h b/drivers/staging/r8188eu/include/recv_osdep.h new file mode 100644 index 000000000000..b6ddf0ba2dde --- /dev/null +++ b/drivers/staging/r8188eu/include/recv_osdep.h @@ -0,0 +1,54 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RECV_OSDEP_H_ +#define __RECV_OSDEP_H_ + +#include +#include + +int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); +void _rtw_free_recv_priv(struct recv_priv *precvpriv); + +s32 rtw_recv_entry(struct recv_frame *precv_frame); +int rtw_recv_indicatepkt(struct adapter *adapter, struct recv_frame *recv_frame); +void rtw_recv_returnpacket(struct net_device *cnxt, struct sk_buff *retpkt); + +void rtw_hostapd_mlme_rx(struct adapter *padapter, struct recv_frame *recv_fr); +void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); + +int rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); +void rtw_free_recv_priv(struct recv_priv *precvpriv); + +int rtw_os_recv_resource_init(struct recv_priv *recvpr, struct adapter *adapt); +int rtw_os_recv_resource_alloc(struct adapter *adapt, struct recv_frame *recvfr); +void rtw_os_recv_resource_free(struct recv_priv *precvpriv); + +int rtw_os_recvbuf_resource_alloc(struct adapter *adapt, struct recv_buf *buf); +int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); + +void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf); + +void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); +int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb); +int _netdev_open(struct net_device *pnetdev); +int netdev_open(struct net_device *pnetdev); +int netdev_close(struct net_device *pnetdev); + +#endif /* */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_cmd.h b/drivers/staging/r8188eu/include/rtl8188e_cmd.h new file mode 100644 index 000000000000..b32bc28503d0 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_cmd.h @@ -0,0 +1,122 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_CMD_H__ +#define __RTL8188E_CMD_H__ + +enum RTL8188E_H2C_CMD_ID { + /* Class Common */ + H2C_COM_RSVD_PAGE = 0x00, + H2C_COM_MEDIA_STATUS_RPT = 0x01, + H2C_COM_SCAN = 0x02, + H2C_COM_KEEP_ALIVE = 0x03, + H2C_COM_DISCNT_DECISION = 0x04, + H2C_COM_INIT_OFFLOAD = 0x06, + H2C_COM_REMOTE_WAKE_CTL = 0x07, + H2C_COM_AP_OFFLOAD = 0x08, + H2C_COM_BCN_RSVD_PAGE = 0x09, + H2C_COM_PROB_RSP_RSVD_PAGE = 0x0A, + + /* Class PS */ + H2C_PS_PWR_MODE = 0x20, + H2C_PS_TUNE_PARA = 0x21, + H2C_PS_TUNE_PARA_2 = 0x22, + H2C_PS_LPS_PARA = 0x23, + H2C_PS_P2P_OFFLOAD = 0x24, + + /* Class DM */ + H2C_DM_MACID_CFG = 0x40, + H2C_DM_TXBF = 0x41, + + /* Class BT */ + H2C_BT_COEX_MASK = 0x60, + H2C_BT_COEX_GPIO_MODE = 0x61, + H2C_BT_DAC_SWING_VAL = 0x62, + H2C_BT_PSD_RST = 0x63, + + /* Class */ + H2C_RESET_TSF = 0xc0, +}; + +struct cmd_msg_parm { + u8 eid; /* element id */ + u8 sz; /* sz */ + u8 buf[6]; +}; + +enum { + PWRS +}; + +struct setpwrmode_parm { + u8 Mode;/* 0:Active,1:LPS,2:WMMPS */ + u8 SmartPS_RLBM;/* LPS= 0:PS_Poll,1:PS_Poll,2:NullData,WMM= 0:PS_Poll,1:NullData */ + u8 AwakeInterval; /* unit: beacon interval */ + u8 bAllQueueUAPSD; + u8 PwrState;/* AllON(0x0c),RFON(0x04),RFOFF(0x00) */ +}; + +struct H2C_SS_RFOFF_PARAM { + u8 ROFOn; /* 1: on, 0:off */ + u16 gpio_period; /* unit: 1024 us */ +} __packed; + +struct joinbssrpt_parm { + u8 OpMode; /* RT_MEDIA_STATUS */ +}; + +struct rsvdpage_loc { + u8 LocProbeRsp; + u8 LocPsPoll; + u8 LocNullData; + u8 LocQosNull; + u8 LocBTQosNull; +}; + +struct P2P_PS_Offload_t { + u8 Offload_En:1; + u8 role:1; /* 1: Owner, 0: Client */ + u8 CTWindow_En:1; + u8 NoA0_En:1; + u8 NoA1_En:1; + u8 AllStaSleep:1; /* Only valid in Owner */ + u8 discovery:1; + u8 rsvd:1; +}; + +struct P2P_PS_CTWPeriod_t { + u8 CTWPeriod; /* TU */ +}; + +/* host message to firmware cmd */ +void rtl8188e_set_FwPwrMode_cmd(struct adapter *padapter, u8 Mode); +void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *padapter, u8 mstatus); +u8 rtl8188e_set_rssi_cmd(struct adapter *padapter, u8 *param); +u8 rtl8188e_set_raid_cmd(struct adapter *padapter, u32 mask); +void rtl8188e_Add_RateATid(struct adapter *padapter, u32 bitmap, u8 arg, + u8 rssi_level); + +#ifdef CONFIG_88EU_P2P +void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state); +#endif /* CONFIG_88EU_P2P */ + +void CheckFwRsvdPageContent(struct adapter *adapt); +void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt); + +#endif/* __RTL8188E_CMD_H__ */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_dm.h b/drivers/staging/r8188eu/include/rtl8188e_dm.h new file mode 100644 index 000000000000..97a3175250ef --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_dm.h @@ -0,0 +1,62 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_DM_H__ +#define __RTL8188E_DM_H__ +enum{ + UP_LINK, + DOWN_LINK, +}; +/* duplicate code,will move to ODM ######### */ +#define IQK_MAC_REG_NUM 4 +#define IQK_ADDA_REG_NUM 16 +#define IQK_BB_REG_NUM 9 +#define HP_THERMAL_NUM 8 +/* duplicate code,will move to ODM ######### */ +struct dm_priv { + u8 DM_Type; + u8 DMFlag; + u8 InitDMFlag; + u32 InitODMFlag; + + /* Upper and Lower Signal threshold for Rate Adaptive*/ + int UndecoratedSmoothedPWDB; + int UndecoratedSmoothedCCK; + int EntryMinUndecoratedSmoothedPWDB; + int EntryMaxUndecoratedSmoothedPWDB; + int MinUndecoratedPWDBForDM; + int LastMinUndecoratedPWDBForDM; + + /* for High Power */ + u8 bDynamicTxPowerEnable; + u8 LastDTPLvl; + u8 DynamicTxHighPowerLvl;/* Tx Power Control for Near/Far Range */ + u8 PowerIndex_backup[6]; +}; + +void rtl8188e_init_dm_priv(struct adapter *adapt); +void rtl8188e_deinit_dm_priv(struct adapter *adapt); +void rtl8188e_InitHalDm(struct adapter *adapt); +void rtl8188e_HalDmWatchDog(struct adapter *adapt); + +void AntDivCompare8188E(struct adapter *adapt, struct wlan_bssid_ex *dst, + struct wlan_bssid_ex *src); +u8 AntDivBeforeLink8188E(struct adapter *adapt); + +#endif diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h new file mode 100644 index 000000000000..09368a5cd6e8 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h @@ -0,0 +1,471 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_HAL_H__ +#define __RTL8188E_HAL_H__ + +/* include HAL Related header after HAL Related compiling flags */ +#include "rtl8188e_spec.h" +#include "Hal8188EPhyReg.h" +#include "Hal8188EPhyCfg.h" +#include "rtl8188e_rf.h" +#include "rtl8188e_dm.h" +#include "rtl8188e_recv.h" +#include "rtl8188e_xmit.h" +#include "rtl8188e_cmd.h" +#include "Hal8188EPwrSeq.h" +#include "rtl8188e_sreset.h" +#include "rtw_efuse.h" + +#include "odm_precomp.h" + +/* Fw Array */ +#define Rtl8188E_FwImageArray Rtl8188EFwImgArray +#define Rtl8188E_FWImgArrayLength Rtl8188EFWImgArrayLength + +#define RTL8188E_FW_UMC_IMG "rtl8188E\\rtl8188efw.bin" +#define RTL8188E_PHY_REG "rtl8188E\\PHY_REG_1T.txt" +#define RTL8188E_PHY_RADIO_A "rtl8188E\\radio_a_1T.txt" +#define RTL8188E_PHY_RADIO_B "rtl8188E\\radio_b_1T.txt" +#define RTL8188E_AGC_TAB "rtl8188E\\AGC_TAB_1T.txt" +#define RTL8188E_PHY_MACREG "rtl8188E\\MAC_REG.txt" +#define RTL8188E_PHY_REG_PG "rtl8188E\\PHY_REG_PG.txt" +#define RTL8188E_PHY_REG_MP "rtl8188E\\PHY_REG_MP.txt" + +/* RTL8188E Power Configuration CMDs for USB/SDIO interfaces */ +#define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow +#define Rtl8188E_NIC_RF_OFF_FLOW rtl8188E_radio_off_flow +#define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow +#define Rtl8188E_NIC_ENABLE_FLOW rtl8188E_card_enable_flow +#define Rtl8188E_NIC_SUSPEND_FLOW rtl8188E_suspend_flow +#define Rtl8188E_NIC_RESUME_FLOW rtl8188E_resume_flow +#define Rtl8188E_NIC_PDN_FLOW rtl8188E_hwpdn_flow +#define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow +#define Rtl8188E_NIC_LPS_LEAVE_FLOW rtl8188E_leave_lps_flow + +#define DRVINFO_SZ 4 /* unit is 8bytes */ +#define PageNum_128(_Len) (u32)(((_Len)>>7) + ((_Len) & 0x7F ? 1 : 0)) + +/* download firmware related data structure */ +#define FW_8188E_SIZE 0x4000 /* 16384,16k */ +#define FW_8188E_START_ADDRESS 0x1000 +#define FW_8188E_END_ADDRESS 0x1FFF /* 0x5FFF */ + +#define MAX_PAGE_SIZE 4096 /* @ page : 4k bytes */ + +#define IS_FW_HEADER_EXIST(_pFwHdr) \ + ((le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x92C0 || \ + (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88C0 || \ + (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x2300 || \ + (le16_to_cpu(_pFwHdr->Signature)&0xFFF0) == 0x88E0) + +/* This structure must be careful with byte-ordering */ + +struct rt_firmware_hdr { + /* 8-byte alinment required */ + /* LONG WORD 0 ---- */ + __le16 Signature; /* 92C0: test chip; 92C, + * 88C0: test chip; 88C1: MP A-cut; + * 92C1: MP A-cut */ + u8 Category; /* AP/NIC and USB/PCI */ + u8 Function; /* Reserved for different FW function + * indcation, for further use when + * driver needs to download different + * FW for different conditions */ + __le16 Version; /* FW Version */ + u8 Subversion; /* FW Subversion, default 0x00 */ + u16 Rsvd1; + + /* LONG WORD 1 ---- */ + u8 Month; /* Release time Month field */ + u8 Date; /* Release time Date field */ + u8 Hour; /* Release time Hour field */ + u8 Minute; /* Release time Minute field */ + __le16 RamCodeSize; /* The size of RAM code */ + u8 Foundry; + u8 Rsvd2; + + /* LONG WORD 2 ---- */ + __le32 SvnIdx; /* The SVN entry index */ + u32 Rsvd3; + + /* LONG WORD 3 ---- */ + u32 Rsvd4; + u32 Rsvd5; +}; + +#define DRIVER_EARLY_INT_TIME 0x05 +#define BCN_DMA_ATIME_INT_TIME 0x02 + +enum usb_rx_agg_mode { + USB_RX_AGG_DISABLE, + USB_RX_AGG_DMA, + USB_RX_AGG_USB, + USB_RX_AGG_MIX +}; + +#define MAX_RX_DMA_BUFFER_SIZE_88E \ + 0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8), + * WOLPattern(16*24)) */ + +#define MAX_TX_REPORT_BUFFER_SIZE 0x0400 /* 1k */ + +/* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */ +#define MAX_TX_QUEUE 9 + +#define TX_SELE_HQ BIT(0) /* High Queue */ +#define TX_SELE_LQ BIT(1) /* Low Queue */ +#define TX_SELE_NQ BIT(2) /* Normal Queue */ + +/* Note: We will divide number of page equally for each queue other + * than public queue! */ +/* 22k = 22528 bytes = 176 pages (@page = 128 bytes) */ +/* must reserved about 7 pages for LPS => 176-7 = 169 (0xA9) */ +/* 2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS + * null-data */ + +#define TX_TOTAL_PAGE_NUMBER_88E 0xA9/* 169 (21632=> 21k) */ + +#define TX_PAGE_BOUNDARY_88E (TX_TOTAL_PAGE_NUMBER_88E + 1) + +/* Note: For Normal Chip Setting ,modify later */ +#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER \ + TX_TOTAL_PAGE_NUMBER_88E /* 0xA9 , 0xb0=>176=>22k */ +#define WMM_NORMAL_TX_PAGE_BOUNDARY_88E \ + (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */ + +/* Chip specific */ +#define CHIP_BONDING_IDENTIFIER(_value) (((_value)>>22)&0x3) +#define CHIP_BONDING_92C_1T2R 0x1 +#define CHIP_BONDING_88C_USB_MCARD 0x2 +#define CHIP_BONDING_88C_USB_HP 0x1 +#include "HalVerDef.h" +#include "hal_com.h" + +/* Channel Plan */ +enum ChannelPlan { + CHPL_FCC = 0, + CHPL_IC = 1, + CHPL_ETSI = 2, + CHPL_SPA = 3, + CHPL_FRANCE = 4, + CHPL_MKK = 5, + CHPL_MKK1 = 6, + CHPL_ISRAEL = 7, + CHPL_TELEC = 8, + CHPL_GLOBAL = 9, + CHPL_WORLD = 10, +}; + +struct txpowerinfo24g { + u8 IndexCCK_Base[RF_PATH_MAX][MAX_CHNL_GROUP_24G]; + u8 IndexBW40_Base[RF_PATH_MAX][MAX_CHNL_GROUP_24G]; + /* If only one tx, only BW20 and OFDM are used. */ + s8 CCK_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + s8 OFDM_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + s8 BW20_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + s8 BW40_Diff[RF_PATH_MAX][MAX_TX_COUNT]; +}; + +#define EFUSE_REAL_CONTENT_LEN 512 +#define EFUSE_MAX_SECTION 16 +#define EFUSE_IC_ID_OFFSET 506 /* For some inferior IC purpose*/ +#define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN) +/* To prevent out of boundary programming case, */ +/* leave 1byte and program full section */ +/* 9bytes + 1byt + 5bytes and pre 1byte. */ +/* For worst case: */ +/* | 1byte|----8bytes----|1byte|--5bytes--| */ +/* | | Reserved(14bytes) | */ + +/* PG data exclude header, dummy 6 bytes frome CP test and reserved 1byte. */ +#define EFUSE_OOB_PROTECT_BYTES 15 + +#define HWSET_MAX_SIZE_88E 512 + +#define EFUSE_REAL_CONTENT_LEN_88E 256 +#define EFUSE_MAP_LEN_88E 512 +#define EFUSE_MAP_LEN EFUSE_MAP_LEN_88E +#define EFUSE_MAX_SECTION_88E 64 +#define EFUSE_MAX_WORD_UNIT_88E 4 +#define EFUSE_IC_ID_OFFSET_88E 506 +#define AVAILABLE_EFUSE_ADDR_88E(addr) \ + (addr < EFUSE_REAL_CONTENT_LEN_88E) +/* To prevent out of boundary programming case, leave 1byte and program + * full section */ +/* 9bytes + 1byt + 5bytes and pre 1byte. */ +/* For worst case: */ +/* | 2byte|----8bytes----|1byte|--7bytes--| 92D */ +/* PG data exclude header, dummy 7 bytes frome CP test and reserved 1byte. */ +#define EFUSE_OOB_PROTECT_BYTES_88E 18 +#define EFUSE_PROTECT_BYTES_BANK_88E 16 + +/* EFUSE for BT definition */ +#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */ +#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */ +#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */ + +#define EFUSE_PROTECT_BYTES_BANK 16 + +/* For RTL8723 WiFi/BT/GPS multi-function configuration. */ +enum rt_multi_func { + RT_MULTI_FUNC_NONE = 0x00, + RT_MULTI_FUNC_WIFI = 0x01, + RT_MULTI_FUNC_BT = 0x02, + RT_MULTI_FUNC_GPS = 0x04, +}; + +/* For RTL8723 regulator mode. */ +enum rt_regulator_mode { + RT_SWITCHING_REGULATOR = 0, + RT_LDO_REGULATOR = 1, +}; + +struct hal_data_8188e { + struct HAL_VERSION VersionID; + enum rt_multi_func MultiFunc; /* For multi-function consideration. */ + enum rt_regulator_mode RegulatorMode; /* switching regulator or LDO */ + u16 CustomerID; + + u16 FirmwareVersion; + u16 FirmwareVersionRev; + u16 FirmwareSubVersion; + u16 FirmwareSignature; + u8 PGMaxGroup; + /* current WIFI_PHY values */ + u32 ReceiveConfig; + enum wireless_mode CurrentWirelessMode; + enum ht_channel_width CurrentChannelBW; + u8 CurrentChannel; + u8 nCur40MhzPrimeSC;/* Control channel sub-carrier */ + + u16 BasicRateSet; + + /* rf_ctrl */ + u8 rf_chip; + u8 rf_type; + u8 NumTotalRFPath; + + u8 BoardType; + + /* EEPROM setting. */ + u16 EEPROMVID; + u16 EEPROMPID; + u16 EEPROMSVID; + u16 EEPROMSDID; + u8 EEPROMCustomerID; + u8 EEPROMSubCustomerID; + u8 EEPROMVersion; + u8 EEPROMRegulatory; + + u8 bTXPowerDataReadFromEEPORM; + u8 EEPROMThermalMeter; + u8 bAPKThermalMeterIgnore; + + bool EepromOrEfuse; + /* 92C:256bytes, 88E:512bytes, we use union set (512bytes) */ + u8 EfuseMap[2][HWSET_MAX_SIZE_512]; + u8 EfuseUsedPercentage; + struct efuse_hal EfuseHal; + + u8 Index24G_CCK_Base[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + u8 Index24G_BW40_Base[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* If only one tx, only BW20 and OFDM are used. */ + s8 CCK_24G_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + s8 OFDM_24G_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + s8 BW20_24G_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + s8 BW40_24G_Diff[RF_PATH_MAX][MAX_TX_COUNT]; + + u8 TxPwrLevelCck[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For HT 40MHZ pwr */ + u8 TxPwrLevelHT40_1S[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For HT 40MHZ pwr */ + u8 TxPwrLevelHT40_2S[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* HT 20<->40 Pwr diff */ + u8 TxPwrHt20Diff[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For HT<->legacy pwr diff */ + u8 TxPwrLegacyHtDiff[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + /* For power group */ + u8 PwrGroupHT20[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + u8 PwrGroupHT40[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; + + u8 LegacyHTTxPowerDiff;/* Legacy to HT rate power diff */ + /* The current Tx Power Level */ + u8 CurrentCckTxPwrIdx; + u8 CurrentOfdm24GTxPwrIdx; + u8 CurrentBW2024GTxPwrIdx; + u8 CurrentBW4024GTxPwrIdx; + + /* Read/write are allow for following hardware information variables */ + u8 framesync; + u32 framesyncC34; + u8 framesyncMonitor; + u8 DefaultInitialGain[4]; + u8 pwrGroupCnt; + u32 MCSTxPowerLevelOriginalOffset[MAX_PG_GROUP][16]; + u32 CCKTxPowerLevelOriginalOffset; + + u8 CrystalCap; + u32 AntennaTxPath; /* Antenna path Tx */ + u32 AntennaRxPath; /* Antenna path Rx */ + u8 BluetoothCoexist; + u8 ExternalPA; + + u8 bLedOpenDrain; /* Open-drain support for controlling the LED.*/ + + u8 b1x1RecvCombine; /* for 1T1R receive combining */ + + u32 AcParam_BE; /* Original parameter for BE, use for EDCA turbo. */ + + struct bb_reg_def PHYRegDef[4]; /* Radio A/B/C/D */ + + u32 RfRegChnlVal[2]; + + /* RDG enable */ + bool bRDGEnable; + + /* for host message to fw */ + u8 LastHMEBoxNum; + + u8 fw_ractrl; + u8 RegTxPause; + /* Beacon function related global variable. */ + u32 RegBcnCtrlVal; + u8 RegFwHwTxQCtrl; + u8 RegReg542; + u8 RegCR_1; + + struct dm_priv dmpriv; + struct odm_dm_struct odmpriv; + struct sreset_priv srestpriv; + + u8 CurAntenna; + u8 AntDivCfg; + u8 TRxAntDivType; + + u8 bDumpRxPkt;/* for debug */ + u8 bDumpTxPkt;/* for debug */ + u8 FwRsvdPageStartOffset; /* Reserve page start offset except + * beacon in TxQ. */ + + /* 2010/08/09 MH Add CU power down mode. */ + bool pwrdown; + + /* Add for dual MAC 0--Mac0 1--Mac1 */ + u32 interfaceIndex; + + u8 OutEpQueueSel; + u8 OutEpNumber; + + /* Add for USB aggreation mode dynamic shceme. */ + bool UsbRxHighSpeedMode; + + /* 2010/11/22 MH Add for slim combo debug mode selective. */ + /* This is used for fix the drawback of CU TSMC-A/UMC-A cut. + * HW auto suspend ability. Close BT clock. */ + bool SlimComboDbg; + + u16 EfuseUsedBytes; + +#ifdef CONFIG_88EU_P2P + struct P2P_PS_Offload_t p2p_ps_offload; +#endif + + /* Auto FSM to Turn On, include clock, isolation, power control + * for MAC only */ + u8 bMacPwrCtrlOn; + + u32 UsbBulkOutSize; + + /* Interrupt relatd register information. */ + u32 IntArray[3];/* HISR0,HISR1,HSISR */ + u32 IntrMask[3]; + u8 C2hArray[16]; + u8 UsbTxAggMode; + u8 UsbTxAggDescNum; + u16 HwRxPageSize; /* Hardware setting */ + u32 MaxUsbRxAggBlock; + + enum usb_rx_agg_mode UsbRxAggMode; + u8 UsbRxAggBlockCount; /* USB Block count. Block size is + * 512-byte in high speed and 64-byte + * in full speed */ + u8 UsbRxAggBlockTimeout; + u8 UsbRxAggPageCount; /* 8192C DMA page count */ + u8 UsbRxAggPageTimeout; +}; + +#define GET_HAL_DATA(__pAdapter) \ + ((struct hal_data_8188e *)((__pAdapter)->HalData)) +#define GET_RF_TYPE(priv) (GET_HAL_DATA(priv)->rf_type) + +#define INCLUDE_MULTI_FUNC_BT(_Adapter) \ + (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_BT) +#define INCLUDE_MULTI_FUNC_GPS(_Adapter) \ + (GET_HAL_DATA(_Adapter)->MultiFunc & RT_MULTI_FUNC_GPS) + +/* rtl8188e_hal_init.c */ +s32 rtl8188e_FirmwareDownload(struct adapter *padapter); +void _8051Reset88E(struct adapter *padapter); +void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); + +s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy); + +/* EFuse */ +u8 GetEEPROMSize8188E(struct adapter *padapter); +void Hal_InitPGData88E(struct adapter *padapter); +void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo); +void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); + +void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); +void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter,u8 *PROMContent, + bool AutoLoadFail); +void Hal_ReadThermalMeter_88E(struct adapter * dapter, u8 *PROMContent, + bool AutoloadFail); +void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, + bool AutoLoadFail); +void Hal_ReadPowerSavingMode88E(struct adapter *pAdapter, u8 *hwinfo, + bool AutoLoadFail); + +bool HalDetectPwrDownMode88E(struct adapter *Adapter); + +void Hal_InitChannelPlan(struct adapter *padapter); +void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc); + +/* register */ +void SetBcnCtrlReg(struct adapter *padapter, u8 SetBits, u8 ClearBits); + +void rtl8188e_clone_haldata(struct adapter *dst, struct adapter *src); +void rtl8188e_start_thread(struct adapter *padapter); +void rtl8188e_stop_thread(struct adapter *padapter); + +void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int len); +s32 rtl8188e_iol_efuse_patch(struct adapter *padapter); +void rtw_cancel_all_timer(struct adapter *padapter); +void _ps_open_RF(struct adapter *adapt); + +#endif /* __RTL8188E_HAL_H__ */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_led.h b/drivers/staging/r8188eu/include/rtl8188e_led.h new file mode 100644 index 000000000000..9cb03d6565d3 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_led.h @@ -0,0 +1,34 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_LED_H__ +#define __RTL8188E_LED_H__ + +#include +#include + +/* */ +/* Interface to manipulate LED objects. */ +/* */ +void rtl8188eu_InitSwLeds(struct adapter *padapter); +void rtl8188eu_DeInitSwLeds(struct adapter *padapter); +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); + +#endif diff --git a/drivers/staging/r8188eu/include/rtl8188e_recv.h b/drivers/staging/r8188eu/include/rtl8188e_recv.h new file mode 100644 index 000000000000..e2ef281c2c44 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_recv.h @@ -0,0 +1,69 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_RECV_H__ +#define __RTL8188E_RECV_H__ + +#define TX_RPT1_PKT_LEN 8 + +#define RECV_BLK_SZ 512 +#define RECV_BLK_CNT 16 +#define RECV_BLK_TH RECV_BLK_CNT +#define RECV_BULK_IN_ADDR 0x80 +#define RECV_INT_IN_ADDR 0x81 + +#define NR_PREALLOC_RECV_SKB (8) + +#define NR_RECVBUFF (4) + +#define MAX_RECVBUF_SZ (15360) /* 15k < 16k */ + +struct phy_stat { + unsigned int phydw0; + unsigned int phydw1; + unsigned int phydw2; + unsigned int phydw3; + unsigned int phydw4; + unsigned int phydw5; + unsigned int phydw6; + unsigned int phydw7; +}; + +/* Rx smooth factor */ +#define Rx_Smooth_Factor (20) + +enum rx_packet_type { + NORMAL_RX,/* Normal rx packet */ + TX_REPORT1,/* CCX */ + TX_REPORT2,/* TX RPT */ + HIS_REPORT,/* USB HISR RPT */ +}; + +#define INTERRUPT_MSG_FORMAT_LEN 60 +void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *buf); +s32 rtl8188eu_init_recv_priv(struct adapter *padapter); +void rtl8188eu_free_recv_priv(struct adapter * padapter); +void rtl8188eu_recv_hdl(struct adapter * padapter, struct recv_buf *precvbuf); +void rtl8188eu_recv_tasklet(void *priv); +void rtl8188e_query_rx_phy_status(struct recv_frame *fr, struct phy_stat *phy); +void rtl8188e_process_phy_info(struct adapter * padapter, void *prframe); +void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); +void update_recvframe_attrib_88e(struct recv_frame *fra, struct recv_stat *stat); + +#endif diff --git a/drivers/staging/r8188eu/include/rtl8188e_rf.h b/drivers/staging/r8188eu/include/rtl8188e_rf.h new file mode 100644 index 000000000000..0ebdc369b542 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_rf.h @@ -0,0 +1,35 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_RF_H__ +#define __RTL8188E_RF_H__ + +#define RF6052_MAX_TX_PWR 0x3F +#define RF6052_MAX_REG 0x3F +#define RF6052_MAX_PATH 2 + +int PHY_RF6052_Config8188E(struct adapter *Adapter); +void rtl8188e_RF_ChangeTxPath(struct adapter *Adapter, u16 DataRate); +void rtl8188e_PHY_RF6052SetBandwidth(struct adapter *Adapter, + enum ht_channel_width Bandwidth); +void rtl8188e_PHY_RF6052SetCckTxPower(struct adapter *Adapter, u8 *level); +void rtl8188e_PHY_RF6052SetOFDMTxPower(struct adapter *Adapter, u8 *ofdm, + u8 *pwrbw20, u8 *pwrbw40, u8 channel); + +#endif/* __RTL8188E_RF_H__ */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h new file mode 100644 index 000000000000..3956f770a951 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h @@ -0,0 +1,1438 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + *******************************************************************************/ +#ifndef __RTL8188E_SPEC_H__ +#define __RTL8188E_SPEC_H__ + +#ifndef BIT +#define BIT(x) (1 << (x)) +#endif + +#define BIT0 0x00000001 +#define BIT1 0x00000002 +#define BIT2 0x00000004 +#define BIT3 0x00000008 +#define BIT4 0x00000010 +#define BIT5 0x00000020 +#define BIT6 0x00000040 +#define BIT7 0x00000080 +#define BIT8 0x00000100 +#define BIT9 0x00000200 +#define BIT10 0x00000400 +#define BIT11 0x00000800 +#define BIT12 0x00001000 +#define BIT13 0x00002000 +#define BIT14 0x00004000 +#define BIT15 0x00008000 +#define BIT16 0x00010000 +#define BIT17 0x00020000 +#define BIT18 0x00040000 +#define BIT19 0x00080000 +#define BIT20 0x00100000 +#define BIT21 0x00200000 +#define BIT22 0x00400000 +#define BIT23 0x00800000 +#define BIT24 0x01000000 +#define BIT25 0x02000000 +#define BIT26 0x04000000 +#define BIT27 0x08000000 +#define BIT28 0x10000000 +#define BIT29 0x20000000 +#define BIT30 0x40000000 +#define BIT31 0x80000000 + +/* 8192C Regsiter offset definition */ + +#define HAL_PS_TIMER_INT_DELAY 50 /* 50 microseconds */ +#define HAL_92C_NAV_UPPER_UNIT 128 /* micro-second */ + +#define MAC_ADDR_LEN 6 +/* 8188E PKT_BUFF_ACCESS_CTRL value */ +#define TXPKT_BUF_SELECT 0x69 +#define RXPKT_BUF_SELECT 0xA5 +#define DISABLE_TRXPKT_BUF_ACCESS 0x0 + +/* 0x0000h ~ 0x00FFh System Configuration */ +#define REG_SYS_ISO_CTRL 0x0000 +#define REG_SYS_FUNC_EN 0x0002 +#define REG_APS_FSMCO 0x0004 +#define REG_SYS_CLKR 0x0008 +#define REG_9346CR 0x000A +#define REG_EE_VPD 0x000C +#define REG_AFE_MISC 0x0010 +#define REG_SPS0_CTRL 0x0011 +#define REG_SPS_OCP_CFG 0x0018 +#define REG_RSV_CTRL 0x001C +#define REG_RF_CTRL 0x001F +#define REG_LDOA15_CTRL 0x0020 +#define REG_LDOV12D_CTRL 0x0021 +#define REG_LDOHCI12_CTRL 0x0022 +#define REG_LPLDO_CTRL 0x0023 +#define REG_AFE_XTAL_CTRL 0x0024 +#define REG_AFE_PLL_CTRL 0x0028 +#define REG_APE_PLL_CTRL_EXT 0x002c +#define REG_EFUSE_CTRL 0x0030 +#define REG_EFUSE_TEST 0x0034 +#define REG_GPIO_MUXCFG 0x0040 +#define REG_GPIO_IO_SEL 0x0042 +#define REG_MAC_PINMUX_CFG 0x0043 +#define REG_GPIO_PIN_CTRL 0x0044 +#define REG_GPIO_INTM 0x0048 +#define REG_LEDCFG0 0x004C +#define REG_LEDCFG1 0x004D +#define REG_LEDCFG2 0x004E +#define REG_LEDCFG3 0x004F +#define REG_FSIMR 0x0050 +#define REG_FSISR 0x0054 +#define REG_HSIMR 0x0058 +#define REG_HSISR 0x005c +#define REG_GPIO_PIN_CTRL_2 0x0060 /* RTL8723 WIFI/BT/GPS + * Multi-Function GPIO Pin Control. */ +#define REG_GPIO_IO_SEL_2 0x0062 /* RTL8723 WIFI/BT/GPS + * Multi-Function GPIO Select. */ +#define REG_BB_PAD_CTRL 0x0064 +#define REG_MULTI_FUNC_CTRL 0x0068 /* RTL8723 WIFI/BT/GPS + * Multi-Function control source. */ +#define REG_GPIO_OUTPUT 0x006c +#define REG_AFE_XTAL_CTRL_EXT 0x0078 /* RTL8188E */ +#define REG_XCK_OUT_CTRL 0x007c /* RTL8188E */ +#define REG_MCUFWDL 0x0080 +#define REG_WOL_EVENT 0x0081 /* RTL8188E */ +#define REG_MCUTSTCFG 0x0084 +#define REG_HMEBOX_E0 0x0088 +#define REG_HMEBOX_E1 0x008A +#define REG_HMEBOX_E2 0x008C +#define REG_HMEBOX_E3 0x008E +#define REG_HMEBOX_EXT_0 0x01F0 +#define REG_HMEBOX_EXT_1 0x01F4 +#define REG_HMEBOX_EXT_2 0x01F8 +#define REG_HMEBOX_EXT_3 0x01FC +#define REG_HIMR_88E 0x00B0 +#define REG_HISR_88E 0x00B4 +#define REG_HIMRE_88E 0x00B8 +#define REG_HISRE_88E 0x00BC +#define REG_EFUSE_ACCESS 0x00CF /* Efuse access protection + * for RTL8723 */ +#define REG_BIST_SCAN 0x00D0 +#define REG_BIST_RPT 0x00D4 +#define REG_BIST_ROM_RPT 0x00D8 +#define REG_USB_SIE_INTF 0x00E0 +#define REG_PCIE_MIO_INTF 0x00E4 +#define REG_PCIE_MIO_INTD 0x00E8 +#define REG_HPON_FSM 0x00EC +#define REG_SYS_CFG 0x00F0 +#define REG_GPIO_OUTSTS 0x00F4 /* For RTL8723 only. */ +#define REG_TYPE_ID 0x00FC + +#define REG_MAC_PHY_CTRL_NORMAL 0x00f8 + +/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ +#define REG_CR 0x0100 +#define REG_PBP 0x0104 +#define REG_PKT_BUFF_ACCESS_CTRL 0x0106 +#define REG_TRXDMA_CTRL 0x010C +#define REG_TRXFF_BNDY 0x0114 +#define REG_TRXFF_STATUS 0x0118 +#define REG_RXFF_PTR 0x011C +/* define REG_HIMR 0x0120 */ +/* define REG_HISR 0x0124 */ +#define REG_HIMRE 0x0128 +#define REG_HISRE 0x012C +#define REG_CPWM 0x012F +#define REG_FWIMR 0x0130 +#define REG_FTIMR 0x0138 +#define REG_FWISR 0x0134 +#define REG_PKTBUF_DBG_CTRL 0x0140 +#define REG_PKTBUF_DBG_ADDR (REG_PKTBUF_DBG_CTRL) +#define REG_RXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL+2) +#define REG_TXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL+3) +#define REG_RXPKTBUF_CTRL (REG_PKTBUF_DBG_CTRL+2) +#define REG_PKTBUF_DBG_DATA_L 0x0144 +#define REG_PKTBUF_DBG_DATA_H 0x0148 + +#define REG_TC0_CTRL 0x0150 +#define REG_TC1_CTRL 0x0154 +#define REG_TC2_CTRL 0x0158 +#define REG_TC3_CTRL 0x015C +#define REG_TC4_CTRL 0x0160 +#define REG_TCUNIT_BASE 0x0164 +#define REG_MBIST_START 0x0174 +#define REG_MBIST_DONE 0x0178 +#define REG_MBIST_FAIL 0x017C +#define REG_32K_CTRL 0x0194 /* RTL8188E */ +#define REG_C2HEVT_MSG_NORMAL 0x01A0 +#define REG_C2HEVT_CLEAR 0x01AF +#define REG_MCUTST_1 0x01c0 +#define REG_FMETHR 0x01C8 +#define REG_HMETFR 0x01CC +#define REG_HMEBOX_0 0x01D0 +#define REG_HMEBOX_1 0x01D4 +#define REG_HMEBOX_2 0x01D8 +#define REG_HMEBOX_3 0x01DC + +#define REG_LLT_INIT 0x01E0 + +/* 0x0200h ~ 0x027Fh TXDMA Configuration */ +#define REG_RQPN 0x0200 +#define REG_FIFOPAGE 0x0204 +#define REG_TDECTRL 0x0208 +#define REG_TXDMA_OFFSET_CHK 0x020C +#define REG_TXDMA_STATUS 0x0210 +#define REG_RQPN_NPQ 0x0214 + +/* 0x0280h ~ 0x02FFh RXDMA Configuration */ +#define REG_RXDMA_AGG_PG_TH 0x0280 +#define REG_RXPKT_NUM 0x0284 +#define REG_RXDMA_STATUS 0x0288 + +/* 0x0300h ~ 0x03FFh PCIe */ +#define REG_PCIE_CTRL_REG 0x0300 +#define REG_INT_MIG 0x0304 /* Interrupt Migration */ +#define REG_BCNQ_DESA 0x0308 /* TX Beacon Descr Address */ +#define REG_HQ_DESA 0x0310 /* TX High Queue Descr Addr */ +#define REG_MGQ_DESA 0x0318 /* TX Manage Queue Descr Addr*/ +#define REG_VOQ_DESA 0x0320 /* TX VO Queue Descr Addr */ +#define REG_VIQ_DESA 0x0328 /* TX VI Queue Descr Addr */ +#define REG_BEQ_DESA 0x0330 /* TX BE Queue Descr Addr */ +#define REG_BKQ_DESA 0x0338 /* TX BK Queue Descr Addr */ +#define REG_RX_DESA 0x0340 /* RX Queue Descr Addr */ +#define REG_MDIO 0x0354 /* MDIO for Access PCIE PHY */ +#define REG_DBG_SEL 0x0360 /* Debug Selection Register */ +#define REG_PCIE_HRPWM 0x0361 /* PCIe RPWM */ +#define REG_PCIE_HCPWM 0x0363 /* PCIe CPWM */ +#define REG_WATCH_DOG 0x0368 + +/* RTL8723 series ------------------------------ */ +#define REG_PCIE_HISR 0x03A0 + +/* spec version 11 */ +/* 0x0400h ~ 0x047Fh Protocol Configuration */ +#define REG_VOQ_INFORMATION 0x0400 +#define REG_VIQ_INFORMATION 0x0404 +#define REG_BEQ_INFORMATION 0x0408 +#define REG_BKQ_INFORMATION 0x040C +#define REG_MGQ_INFORMATION 0x0410 +#define REG_HGQ_INFORMATION 0x0414 +#define REG_BCNQ_INFORMATION 0x0418 +#define REG_TXPKT_EMPTY 0x041A + +#define REG_CPU_MGQ_INFORMATION 0x041C +#define REG_FWHW_TXQ_CTRL 0x0420 +#define REG_HWSEQ_CTRL 0x0423 +#define REG_TXPKTBUF_BCNQ_BDNY 0x0424 +#define REG_TXPKTBUF_MGQ_BDNY 0x0425 +#define REG_LIFETIME_EN 0x0426 +#define REG_MULTI_BCNQ_OFFSET 0x0427 +#define REG_SPEC_SIFS 0x0428 +#define REG_RL 0x042A +#define REG_DARFRC 0x0430 +#define REG_RARFRC 0x0438 +#define REG_RRSR 0x0440 +#define REG_ARFR0 0x0444 +#define REG_ARFR1 0x0448 +#define REG_ARFR2 0x044C +#define REG_ARFR3 0x0450 +#define REG_AGGLEN_LMT 0x0458 +#define REG_AMPDU_MIN_SPACE 0x045C +#define REG_TXPKTBUF_WMAC_LBK_BF_HD 0x045D +#define REG_FAST_EDCA_CTRL 0x0460 +#define REG_RD_RESP_PKT_TH 0x0463 +#define REG_INIRTS_RATE_SEL 0x0480 +/* define REG_INIDATA_RATE_SEL 0x0484 */ +#define REG_POWER_STATUS 0x04A4 +#define REG_POWER_STAGE1 0x04B4 +#define REG_POWER_STAGE2 0x04B8 +#define REG_PKT_VO_VI_LIFE_TIME 0x04C0 +#define REG_PKT_BE_BK_LIFE_TIME 0x04C2 +#define REG_STBC_SETTING 0x04C4 +#define REG_PROT_MODE_CTRL 0x04C8 +#define REG_MAX_AGGR_NUM 0x04CA +#define REG_RTS_MAX_AGGR_NUM 0x04CB +#define REG_BAR_MODE_CTRL 0x04CC +#define REG_RA_TRY_RATE_AGG_LMT 0x04CF +#define REG_EARLY_MODE_CONTROL 0x4D0 +#define REG_NQOS_SEQ 0x04DC +#define REG_QOS_SEQ 0x04DE +#define REG_NEED_CPU_HANDLE 0x04E0 +#define REG_PKT_LOSE_RPT 0x04E1 +#define REG_PTCL_ERR_STATUS 0x04E2 +#define REG_TX_RPT_CTRL 0x04EC +#define REG_TX_RPT_TIME 0x04F0 /* 2 byte */ +#define REG_DUMMY 0x04FC + +/* 0x0500h ~ 0x05FFh EDCA Configuration */ +#define REG_EDCA_VO_PARAM 0x0500 +#define REG_EDCA_VI_PARAM 0x0504 +#define REG_EDCA_BE_PARAM 0x0508 +#define REG_EDCA_BK_PARAM 0x050C +#define REG_BCNTCFG 0x0510 +#define REG_PIFS 0x0512 +#define REG_RDG_PIFS 0x0513 +#define REG_SIFS_CTX 0x0514 +#define REG_SIFS_TRX 0x0516 +#define REG_TSFTR_SYN_OFFSET 0x0518 +#define REG_AGGR_BREAK_TIME 0x051A +#define REG_SLOT 0x051B +#define REG_TX_PTCL_CTRL 0x0520 +#define REG_TXPAUSE 0x0522 +#define REG_DIS_TXREQ_CLR 0x0523 +#define REG_RD_CTRL 0x0524 +/* Format for offset 540h-542h: */ +/* [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting + * beacon content before TBTT. */ +/* [7:4]: Reserved. */ +/* [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding + * to send the beacon packet. */ +/* [23:20]: Reserved */ +/* Description: */ +/* | */ +/* |<--Setup--|--Hold------------>| */ +/* --------------|---------------------- */ +/* | */ +/* TBTT */ +/* Note: We cannot update beacon content to HW or send any AC packets during + * the time between Setup and Hold. */ +#define REG_TBTT_PROHIBIT 0x0540 +#define REG_RD_NAV_NXT 0x0544 +#define REG_NAV_PROT_LEN 0x0546 +#define REG_BCN_CTRL 0x0550 +#define REG_BCN_CTRL_1 0x0551 +#define REG_MBID_NUM 0x0552 +#define REG_DUAL_TSF_RST 0x0553 +#define REG_BCN_INTERVAL 0x0554 +#define REG_DRVERLYINT 0x0558 +#define REG_BCNDMATIM 0x0559 +#define REG_ATIMWND 0x055A +#define REG_BCN_MAX_ERR 0x055D +#define REG_RXTSF_OFFSET_CCK 0x055E +#define REG_RXTSF_OFFSET_OFDM 0x055F +#define REG_TSFTR 0x0560 +#define REG_TSFTR1 0x0568 +#define REG_ATIMWND_1 0x0570 +#define REG_PSTIMER 0x0580 +#define REG_TIMER0 0x0584 +#define REG_TIMER1 0x0588 +#define REG_ACMHWCTRL 0x05C0 + +/* define REG_FW_TSF_SYNC_CNT 0x04A0 */ +#define REG_FW_RESET_TSF_CNT_1 0x05FC +#define REG_FW_RESET_TSF_CNT_0 0x05FD +#define REG_FW_BCN_DIS_CNT 0x05FE + +/* 0x0600h ~ 0x07FFh WMAC Configuration */ +#define REG_APSD_CTRL 0x0600 +#define REG_BWOPMODE 0x0603 +#define REG_TCR 0x0604 +#define REG_RCR 0x0608 +#define REG_RX_PKT_LIMIT 0x060C +#define REG_RX_DLK_TIME 0x060D +#define REG_RX_DRVINFO_SZ 0x060F + +#define REG_MACID 0x0610 +#define REG_BSSID 0x0618 +#define REG_MAR 0x0620 +#define REG_MBIDCAMCFG 0x0628 + +#define REG_USTIME_EDCA 0x0638 +#define REG_MAC_SPEC_SIFS 0x063A + +/* 20100719 Joseph: Hardware register definition change. (HW datasheet v54) */ +/* [15:8]SIFS_R2T_OFDM, [7:0]SIFS_R2T_CCK */ +#define REG_R2T_SIFS 0x063C +/* [15:8]SIFS_T2T_OFDM, [7:0]SIFS_T2T_CCK */ +#define REG_T2T_SIFS 0x063E +#define REG_ACKTO 0x0640 +#define REG_CTS2TO 0x0641 +#define REG_EIFS 0x0642 + +/* RXERR_RPT */ +#define RXERR_TYPE_OFDM_PPDU 0 +#define RXERR_TYPE_OFDM_false_ALARM 1 +#define RXERR_TYPE_OFDM_MPDU_OK 2 +#define RXERR_TYPE_OFDM_MPDU_FAIL 3 +#define RXERR_TYPE_CCK_PPDU 4 +#define RXERR_TYPE_CCK_false_ALARM 5 +#define RXERR_TYPE_CCK_MPDU_OK 6 +#define RXERR_TYPE_CCK_MPDU_FAIL 7 +#define RXERR_TYPE_HT_PPDU 8 +#define RXERR_TYPE_HT_false_ALARM 9 +#define RXERR_TYPE_HT_MPDU_TOTAL 10 +#define RXERR_TYPE_HT_MPDU_OK 11 +#define RXERR_TYPE_HT_MPDU_FAIL 12 +#define RXERR_TYPE_RX_FULL_DROP 15 + +#define RXERR_COUNTER_MASK 0xFFFFF +#define RXERR_RPT_RST BIT(27) +#define _RXERR_RPT_SEL(type) ((type) << 28) + +/* Note: */ +/* The NAV upper value is very important to WiFi 11n 5.2.3 NAV test. + * The default value is always too small, but the WiFi TestPlan test + * by 25,000 microseconds of NAV through sending CTS in the air. + * We must update this value greater than 25,000 microseconds to pass + * the item. The offset of NAV_UPPER in 8192C Spec is incorrect, and + * the offset should be 0x0652. */ +#define REG_NAV_UPPER 0x0652 /* unit of 128 */ + +/* WMA, BA, CCX */ +/* define REG_NAV_CTRL 0x0650 */ +#define REG_BACAMCMD 0x0654 +#define REG_BACAMCONTENT 0x0658 +#define REG_LBDLY 0x0660 +#define REG_FWDLY 0x0661 +#define REG_RXERR_RPT 0x0664 +#define REG_WMAC_TRXPTCL_CTL 0x0668 + +/* Security */ +#define REG_CAMCMD 0x0670 +#define REG_CAMWRITE 0x0674 +#define REG_CAMREAD 0x0678 +#define REG_CAMDBG 0x067C +#define REG_SECCFG 0x0680 + +/* Power */ +#define REG_WOW_CTRL 0x0690 +#define REG_PS_RX_INFO 0x0692 +#define REG_UAPSD_TID 0x0693 +#define REG_WKFMCAM_CMD 0x0698 +#define REG_WKFMCAM_NUM_88E 0x698 +#define REG_RXFLTMAP0 0x06A0 +#define REG_RXFLTMAP1 0x06A2 +#define REG_RXFLTMAP2 0x06A4 +#define REG_BCN_PSR_RPT 0x06A8 +#define REG_BT_COEX_TABLE 0x06C0 + +/* Hardware Port 2 */ +#define REG_MACID1 0x0700 +#define REG_BSSID1 0x0708 + +/* 0xFE00h ~ 0xFE55h USB Configuration */ +#define REG_USB_INFO 0xFE17 +#define REG_USB_SPECIAL_OPTION 0xFE55 +#define REG_USB_DMA_AGG_TO 0xFE5B +#define REG_USB_AGG_TO 0xFE5C +#define REG_USB_AGG_TH 0xFE5D + +/* For normal chip */ +#define REG_NORMAL_SIE_VID 0xFE60 /* 0xFE60~0xFE61 */ +#define REG_NORMAL_SIE_PID 0xFE62 /* 0xFE62~0xFE63 */ +#define REG_NORMAL_SIE_OPTIONAL 0xFE64 +#define REG_NORMAL_SIE_EP 0xFE65 /* 0xFE65~0xFE67 */ +#define REG_NORMAL_SIE_PHY 0xFE68 /* 0xFE68~0xFE6B */ +#define REG_NORMAL_SIE_OPTIONAL2 0xFE6C +#define REG_NORMAL_SIE_GPS_EP 0xFE6D /* 0xFE6D, for RTL8723 only. */ +#define REG_NORMAL_SIE_MAC_ADDR 0xFE70 /* 0xFE70~0xFE75 */ +#define REG_NORMAL_SIE_STRING 0xFE80 /* 0xFE80~0xFEDF */ + +/* TODO: use these definition when using REG_xxx naming rule. */ +/* NOTE: DO NOT Remove these definition. Use later. */ + +#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ +#define EFUSE_TEST REG_EFUSE_TEST /* E-Fuse Test. */ +#define MSR (REG_CR + 2) /* Media Status reg */ +#define ISR REG_HISR_88E +/* Timing Sync Function Timer Register. */ +#define TSFR REG_TSFTR + +#define PBP REG_PBP + +/* Redifine MACID register, to compatible prior ICs. */ +/* MAC ID Register, Offset 0x0050-0x0053 */ +#define IDR0 REG_MACID +/* MAC ID Register, Offset 0x0054-0x0055 */ +#define IDR4 (REG_MACID + 4) + +/* 9. Security Control Registers (Offset: ) */ +/* IN 8190 Data Sheet is called CAMcmd */ +#define RWCAM REG_CAMCMD +/* Software write CAM input content */ +#define WCAMI REG_CAMWRITE +/* Software read/write CAM config */ +#define RCAMO REG_CAMREAD +#define CAMDBG REG_CAMDBG +/* Security Configuration Register */ +#define SECR REG_SECCFG + +/* Unused register */ +#define UnusedRegister 0x1BF +#define DCAM UnusedRegister +#define PSR UnusedRegister +#define BBAddr UnusedRegister +#define PhyDataR UnusedRegister + +/* Min Spacing related settings. */ +#define MAX_MSS_DENSITY_2T 0x13 +#define MAX_MSS_DENSITY_1T 0x0A + +/* EEPROM enable when set 1 */ +#define CmdEEPROM_En BIT5 +/* System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346 */ +#define CmdEERPOMSEL BIT4 +#define Cmd9346CR_9356SEL BIT4 + +/* 8192C GPIO MUX Configuration Register (offset 0x40, 4 byte) */ +#define GPIOSEL_GPIO 0 +#define GPIOSEL_ENBT BIT5 + +/* 8192C GPIO PIN Control Register (offset 0x44, 4 byte) */ +/* GPIO pins input value */ +#define GPIO_IN REG_GPIO_PIN_CTRL +/* GPIO pins output value */ +#define GPIO_OUT (REG_GPIO_PIN_CTRL+1) +/* GPIO pins output enable when a bit is set to "1"; otherwise, + * input is configured. */ +#define GPIO_IO_SEL (REG_GPIO_PIN_CTRL+2) +#define GPIO_MOD (REG_GPIO_PIN_CTRL+3) + +/* 8723/8188E Host System Interrupt Mask Register (offset 0x58, 32 byte) */ +#define HSIMR_GPIO12_0_INT_EN BIT0 +#define HSIMR_SPS_OCP_INT_EN BIT5 +#define HSIMR_RON_INT_EN BIT6 +#define HSIMR_PDN_INT_EN BIT7 +#define HSIMR_GPIO9_INT_EN BIT25 + +/* 8723/8188E Host System Interrupt Status Register (offset 0x5C, 32 byte) */ +#define HSISR_GPIO12_0_INT BIT0 +#define HSISR_SPS_OCP_INT BIT5 +#define HSISR_RON_INT_EN BIT6 +#define HSISR_PDNINT BIT7 +#define HSISR_GPIO9_INT BIT25 + +/* 8192C (MSR) Media Status Register (Offset 0x4C, 8 bits) */ +/* +Network Type +00: No link +01: Link in ad hoc network +10: Link in infrastructure network +11: AP mode +Default: 00b. +*/ +#define MSR_NOLINK 0x00 +#define MSR_ADHOC 0x01 +#define MSR_INFRA 0x02 +#define MSR_AP 0x03 + +/* 88EU (MSR) Media Status Register (Offset 0x4C, 8 bits) */ +#define USB_INTR_CONTENT_C2H_OFFSET 0 +#define USB_INTR_CONTENT_CPWM1_OFFSET 16 +#define USB_INTR_CONTENT_CPWM2_OFFSET 20 +#define USB_INTR_CONTENT_HISR_OFFSET 48 +#define USB_INTR_CONTENT_HISRE_OFFSET 52 + +/* 88E Driver Initialization Offload REG_FDHM0(Offset 0x88, 8 bits) */ +/* IOL config for REG_FDHM0(Reg0x88) */ +#define CMD_INIT_LLT BIT0 +#define CMD_READ_EFUSE_MAP BIT1 +#define CMD_EFUSE_PATCH BIT2 +#define CMD_IOCONFIG BIT3 +#define CMD_INIT_LLT_ERR BIT4 +#define CMD_READ_EFUSE_MAP_ERR BIT5 +#define CMD_EFUSE_PATCH_ERR BIT6 +#define CMD_IOCONFIG_ERR BIT7 + +/* 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF) */ +/* 8192C Response Rate Set Register (offset 0x181, 24bits) */ +#define RRSR_1M BIT0 +#define RRSR_2M BIT1 +#define RRSR_5_5M BIT2 +#define RRSR_11M BIT3 +#define RRSR_6M BIT4 +#define RRSR_9M BIT5 +#define RRSR_12M BIT6 +#define RRSR_18M BIT7 +#define RRSR_24M BIT8 +#define RRSR_36M BIT9 +#define RRSR_48M BIT10 +#define RRSR_54M BIT11 +#define RRSR_MCS0 BIT12 +#define RRSR_MCS1 BIT13 +#define RRSR_MCS2 BIT14 +#define RRSR_MCS3 BIT15 +#define RRSR_MCS4 BIT16 +#define RRSR_MCS5 BIT17 +#define RRSR_MCS6 BIT18 +#define RRSR_MCS7 BIT19 + +/* 8192C Response Rate Set Register (offset 0x1BF, 8bits) */ +/* WOL bit information */ +#define HAL92C_WOL_PTK_UPDATE_EVENT BIT0 +#define HAL92C_WOL_GTK_UPDATE_EVENT BIT1 + +/* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ +#define BW_OPMODE_20MHZ BIT2 +#define BW_OPMODE_5G BIT1 + +/* 8192C CAM Config Setting (offset 0x250, 1 byte) */ +#define CAM_VALID BIT15 +#define CAM_NOTVALID 0x0000 +#define CAM_USEDK BIT5 + +#define CAM_CONTENT_COUNT 8 + +#define CAM_NONE 0x0 +#define CAM_WEP40 0x01 +#define CAM_TKIP 0x02 +#define CAM_AES 0x04 +#define CAM_WEP104 0x05 +#define CAM_SMS4 0x6 + +#define TOTAL_CAM_ENTRY 32 +#define HALF_CAM_ENTRY 16 + +#define CAM_CONFIG_USEDK true +#define CAM_CONFIG_NO_USEDK false + +#define CAM_WRITE BIT16 +#define CAM_READ 0x00000000 +#define CAM_POLLINIG BIT31 + +#define SCR_UseDK 0x01 +#define SCR_TxSecEnable 0x02 +#define SCR_RxSecEnable 0x04 + +/* 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF) */ +#define WOW_PMEN BIT0 /* Power management Enable. */ +#define WOW_WOMEN BIT1 /* WoW function on or off. */ +#define WOW_MAGIC BIT2 /* Magic packet */ +#define WOW_UWF BIT3 /* Unicast Wakeup frame. */ + +/* 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F) */ +/* 8188 IMR/ISR bits */ +#define IMR_DISABLED_88E 0x0 +/* IMR DW0(0x0060-0063) Bit 0-31 */ +#define IMR_TXCCK_88E BIT30 /* TXRPT interrupt when CCX bit of the packet is set */ +#define IMR_PSTIMEOUT_88E BIT29 /* Power Save Time Out Interrupt */ +#define IMR_GTINT4_88E BIT28 /* When GTIMER4 expires, this bit is set to 1 */ +#define IMR_GTINT3_88E BIT27 /* When GTIMER3 expires, this bit is set to 1 */ +#define IMR_TBDER_88E BIT26 /* Transmit Beacon0 Error */ +#define IMR_TBDOK_88E BIT25 /* Transmit Beacon0 OK */ +#define IMR_TSF_BIT32_TOGGLE_88E BIT24 /* TSF Timer BIT32 toggle indication interrupt */ +#define IMR_BCNDMAINT0_88E BIT20 /* Beacon DMA Interrupt 0 */ +#define IMR_BCNDERR0_88E BIT16 /* Beacon Queue DMA Error 0 */ +#define IMR_HSISR_IND_ON_INT_88E BIT15 /* HSISR Indicator (HSIMR & HSISR is true, this bit is set to 1) */ +#define IMR_BCNDMAINT_E_88E BIT14 /* Beacon DMA Interrupt Extension for Win7 */ +#define IMR_ATIMEND_88E BIT12 /* CTWidnow End or ATIM Window End */ +#define IMR_HISR1_IND_INT_88E BIT11 /* HISR1 Indicator (HISR1 & HIMR1 is true, this bit is set to 1) */ +#define IMR_C2HCMD_88E BIT10 /* CPU to Host Command INT Status, Write 1 clear */ +#define IMR_CPWM2_88E BIT9 /* CPU power Mode exchange INT Status, Write 1 clear */ +#define IMR_CPWM_88E BIT8 /* CPU power Mode exchange INT Status, Write 1 clear */ +#define IMR_HIGHDOK_88E BIT7 /* High Queue DMA OK */ +#define IMR_MGNTDOK_88E BIT6 /* Management Queue DMA OK */ +#define IMR_BKDOK_88E BIT5 /* AC_BK DMA OK */ +#define IMR_BEDOK_88E BIT4 /* AC_BE DMA OK */ +#define IMR_VIDOK_88E BIT3 /* AC_VI DMA OK */ +#define IMR_VODOK_88E BIT2 /* AC_VO DMA OK */ +#define IMR_RDU_88E BIT1 /* Rx Descriptor Unavailable */ +#define IMR_ROK_88E BIT0 /* Receive DMA OK */ + +/* IMR DW1(0x00B4-00B7) Bit 0-31 */ +#define IMR_BCNDMAINT7_88E BIT27 /* Beacon DMA Interrupt 7 */ +#define IMR_BCNDMAINT6_88E BIT26 /* Beacon DMA Interrupt 6 */ +#define IMR_BCNDMAINT5_88E BIT25 /* Beacon DMA Interrupt 5 */ +#define IMR_BCNDMAINT4_88E BIT24 /* Beacon DMA Interrupt 4 */ +#define IMR_BCNDMAINT3_88E BIT23 /* Beacon DMA Interrupt 3 */ +#define IMR_BCNDMAINT2_88E BIT22 /* Beacon DMA Interrupt 2 */ +#define IMR_BCNDMAINT1_88E BIT21 /* Beacon DMA Interrupt 1 */ +#define IMR_BCNDERR7_88E BIT20 /* Beacon DMA Error Int 7 */ +#define IMR_BCNDERR6_88E BIT19 /* Beacon DMA Error Int 6 */ +#define IMR_BCNDERR5_88E BIT18 /* Beacon DMA Error Int 5 */ +#define IMR_BCNDERR4_88E BIT17 /* Beacon DMA Error Int 4 */ +#define IMR_BCNDERR3_88E BIT16 /* Beacon DMA Error Int 3 */ +#define IMR_BCNDERR2_88E BIT15 /* Beacon DMA Error Int 2 */ +#define IMR_BCNDERR1_88E BIT14 /* Beacon DMA Error Int 1 */ +#define IMR_ATIMEND_E_88E BIT13 /* ATIM Window End Ext for Win7 */ +#define IMR_TXERR_88E BIT11 /* Tx Err Flag Int Status, write 1 clear. */ +#define IMR_RXERR_88E BIT10 /* Rx Err Flag INT Status, Write 1 clear */ +#define IMR_TXFOVW_88E BIT9 /* Transmit FIFO Overflow */ +#define IMR_RXFOVW_88E BIT8 /* Receive FIFO Overflow */ + +#define HAL_NIC_UNPLUG_ISR 0xFFFFFFFF /* The value when the NIC is unplugged for PCI. */ + +/* 8192C EFUSE */ +#define HWSET_MAX_SIZE 256 +#define HWSET_MAX_SIZE_88E 512 + +/*=================================================================== +===================================================================== +Here the register defines are for 92C. When the define is as same with 92C, +we will use the 92C's define for the consistency +So the following defines for 92C is not entire!!!!!! +===================================================================== +=====================================================================*/ +/* +Based on Datasheet V33---090401 +Register Summary +Current IOREG MAP +0x0000h ~ 0x00FFh System Configuration (256 Bytes) +0x0100h ~ 0x01FFh MACTOP General Configuration (256 Bytes) +0x0200h ~ 0x027Fh TXDMA Configuration (128 Bytes) +0x0280h ~ 0x02FFh RXDMA Configuration (128 Bytes) +0x0300h ~ 0x03FFh PCIE EMAC Reserved Region (256 Bytes) +0x0400h ~ 0x04FFh Protocol Configuration (256 Bytes) +0x0500h ~ 0x05FFh EDCA Configuration (256 Bytes) +0x0600h ~ 0x07FFh WMAC Configuration (512 Bytes) +0x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes) +*/ +/* 8192C (TXPAUSE) transmission pause (Offset 0x522, 8 bits) */ +/* Note: */ +/* The bits of stopping AC(VO/VI/BE/BK) queue in datasheet + * RTL8192S/RTL8192C are wrong, */ +/* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, + * and BK - Bit3. */ +/* 8723 and 88E may be not correct either in the earlier version. */ +#define StopBecon BIT6 +#define StopHigh BIT5 +#define StopMgt BIT4 +#define StopBK BIT3 +#define StopBE BIT2 +#define StopVI BIT1 +#define StopVO BIT0 + +/* 8192C (RCR) Receive Configuration Register(Offset 0x608, 32 bits) */ +#define RCR_APPFCS BIT31 /* WMAC append FCS after payload */ +#define RCR_APP_MIC BIT30 +#define RCR_APP_PHYSTS BIT28 +#define RCR_APP_ICV BIT29 +#define RCR_APP_PHYST_RXFF BIT28 +#define RCR_APP_BA_SSN BIT27 /* Accept BA SSN */ +#define RCR_ENMBID BIT24 /* Enable Multiple BssId. */ +#define RCR_LSIGEN BIT23 +#define RCR_MFBEN BIT22 +#define RCR_HTC_LOC_CTRL BIT14 /* MFC<--HTC=1 MFC-->HTC=0 */ +#define RCR_AMF BIT13 /* Accept management type frame */ +#define RCR_ACF BIT12 /* Accept control type frame */ +#define RCR_ADF BIT11 /* Accept data type frame */ +#define RCR_AICV BIT9 /* Accept ICV error packet */ +#define RCR_ACRC32 BIT8 /* Accept CRC32 error packet */ +#define RCR_CBSSID_BCN BIT7 /* Accept BSSID match packet + * (Rx beacon, probe rsp) */ +#define RCR_CBSSID_DATA BIT6 /* Accept BSSID match (Data)*/ +#define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match */ +#define RCR_APWRMGT BIT5 /* Accept power management pkt*/ +#define RCR_ADD3 BIT4 /* Accept address 3 match pkt */ +#define RCR_AB BIT3 /* Accept broadcast packet */ +#define RCR_AM BIT2 /* Accept multicast packet */ +#define RCR_APM BIT1 /* Accept physical match pkt */ +#define RCR_AAP BIT0 /* Accept all unicast packet */ +#define RCR_MXDMA_OFFSET 8 +#define RCR_FIFO_OFFSET 13 + +/* 0xFE00h ~ 0xFE55h USB Configuration */ +#define REG_USB_INFO 0xFE17 +#define REG_USB_SPECIAL_OPTION 0xFE55 +#define REG_USB_DMA_AGG_TO 0xFE5B +#define REG_USB_AGG_TO 0xFE5C +#define REG_USB_AGG_TH 0xFE5D + +#define REG_USB_HRPWM 0xFE58 +#define REG_USB_HCPWM 0xFE57 +/* 8192C Regsiter Bit and Content definition */ +/* 0x0000h ~ 0x00FFh System Configuration */ + +/* 2 SYS_ISO_CTRL */ +#define ISO_MD2PP BIT(0) +#define ISO_UA2USB BIT(1) +#define ISO_UD2CORE BIT(2) +#define ISO_PA2PCIE BIT(3) +#define ISO_PD2CORE BIT(4) +#define ISO_IP2MAC BIT(5) +#define ISO_DIOP BIT(6) +#define ISO_DIOE BIT(7) +#define ISO_EB2CORE BIT(8) +#define ISO_DIOR BIT(9) +#define PWC_EV12V BIT(15) + +/* 2 SYS_FUNC_EN */ +#define FEN_BBRSTB BIT(0) +#define FEN_BB_GLB_RSTn BIT(1) +#define FEN_USBA BIT(2) +#define FEN_UPLL BIT(3) +#define FEN_USBD BIT(4) +#define FEN_DIO_PCIE BIT(5) +#define FEN_PCIEA BIT(6) +#define FEN_PPLL BIT(7) +#define FEN_PCIED BIT(8) +#define FEN_DIOE BIT(9) +#define FEN_CPUEN BIT(10) +#define FEN_DCORE BIT(11) +#define FEN_ELDR BIT(12) +#define FEN_DIO_RF BIT(13) +#define FEN_HWPDN BIT(14) +#define FEN_MREGEN BIT(15) + +/* 2 APS_FSMCO */ +#define PFM_LDALL BIT(0) +#define PFM_ALDN BIT(1) +#define PFM_LDKP BIT(2) +#define PFM_WOWL BIT(3) +#define EnPDN BIT(4) +#define PDN_PL BIT(5) +#define APFM_ONMAC BIT(8) +#define APFM_OFF BIT(9) +#define APFM_RSM BIT(10) +#define AFSM_HSUS BIT(11) +#define AFSM_PCIE BIT(12) +#define APDM_MAC BIT(13) +#define APDM_HOST BIT(14) +#define APDM_HPDN BIT(15) +#define RDY_MACON BIT(16) +#define SUS_HOST BIT(17) +#define ROP_ALD BIT(20) +#define ROP_PWR BIT(21) +#define ROP_SPS BIT(22) +#define SOP_MRST BIT(25) +#define SOP_FUSE BIT(26) +#define SOP_ABG BIT(27) +#define SOP_AMB BIT(28) +#define SOP_RCK BIT(29) +#define SOP_A8M BIT(30) +#define XOP_BTCK BIT(31) + +/* 2 SYS_CLKR */ +#define ANAD16V_EN BIT(0) +#define ANA8M BIT(1) +#define MACSLP BIT(4) +#define LOADER_CLK_EN BIT(5) + +/* 2 9346CR */ + +#define BOOT_FROM_EEPROM BIT(4) +#define EEPROM_EN BIT(5) + +/* 2 SPS0_CTRL */ + +/* 2 SPS_OCP_CFG */ + +/* 2 RF_CTRL */ +#define RF_EN BIT(0) +#define RF_RSTB BIT(1) +#define RF_SDMRSTB BIT(2) + +/* 2 LDOV12D_CTRL */ +#define LDV12_EN BIT(0) +#define LDV12_SDBY BIT(1) +#define LPLDO_HSM BIT(2) +#define LPLDO_LSM_DIS BIT(3) +#define _LDV12_VADJ(x) (((x) & 0xF) << 4) + +/* 2EFUSE_CTRL */ +#define ALD_EN BIT(18) +#define EF_PD BIT(19) +#define EF_FLAG BIT(31) + +/* 2 EFUSE_TEST (For RTL8723 partially) */ +#define EF_TRPT BIT(7) +/* 00: Wifi Efuse, 01: BT Efuse0, 10: BT Efuse1, 11: BT Efuse2 */ +#define EF_CELL_SEL (BIT(8)|BIT(9)) +#define LDOE25_EN BIT(31) +#define EFUSE_SEL(x) (((x) & 0x3) << 8) +#define EFUSE_SEL_MASK 0x300 +#define EFUSE_WIFI_SEL_0 0x0 +#define EFUSE_BT_SEL_0 0x1 +#define EFUSE_BT_SEL_1 0x2 +#define EFUSE_BT_SEL_2 0x3 + +#define EFUSE_ACCESS_ON 0x69 /* For RTL8723 only. */ +#define EFUSE_ACCESS_OFF 0x00 /* For RTL8723 only. */ + +/* 2 8051FWDL */ +/* 2 MCUFWDL */ +#define MCUFWDL_EN BIT(0) +#define MCUFWDL_RDY BIT(1) +#define FWDL_ChkSum_rpt BIT(2) +#define MACINI_RDY BIT(3) +#define BBINI_RDY BIT(4) +#define RFINI_RDY BIT(5) +#define WINTINI_RDY BIT(6) +#define RAM_DL_SEL BIT(7) /* 1:RAM, 0:ROM */ +#define ROM_DLEN BIT(19) +#define CPRST BIT(23) + +/* 2 REG_SYS_CFG */ +#define XCLK_VLD BIT(0) +#define ACLK_VLD BIT(1) +#define UCLK_VLD BIT(2) +#define PCLK_VLD BIT(3) +#define PCIRSTB BIT(4) +#define V15_VLD BIT(5) +#define SW_OFFLOAD_EN BIT(7) +#define SIC_IDLE BIT(8) +#define BD_MAC2 BIT(9) +#define BD_MAC1 BIT(10) +#define IC_MACPHY_MODE BIT(11) +#define CHIP_VER (BIT(12)|BIT(13)|BIT(14)|BIT(15)) +#define BT_FUNC BIT(16) +#define VENDOR_ID BIT(19) +#define PAD_HWPD_IDN BIT(22) +#define TRP_VAUX_EN BIT(23) /* RTL ID */ +#define TRP_BT_EN BIT(24) +#define BD_PKG_SEL BIT(25) +#define BD_HCI_SEL BIT(26) +#define TYPE_ID BIT(27) + +#define CHIP_VER_RTL_MASK 0xF000 /* Bit 12 ~ 15 */ +#define CHIP_VER_RTL_SHIFT 12 + +/* 2REG_GPIO_OUTSTS (For RTL8723 only) */ +#define EFS_HCI_SEL (BIT(0)|BIT(1)) +#define PAD_HCI_SEL (BIT(2)|BIT(3)) +#define HCI_SEL (BIT(4)|BIT(5)) +#define PKG_SEL_HCI BIT(6) +#define FEN_GPS BIT(7) +#define FEN_BT BIT(8) +#define FEN_WL BIT(9) +#define FEN_PCI BIT(10) +#define FEN_USB BIT(11) +#define BTRF_HWPDN_N BIT(12) +#define WLRF_HWPDN_N BIT(13) +#define PDN_BT_N BIT(14) +#define PDN_GPS_N BIT(15) +#define BT_CTL_HWPDN BIT(16) +#define GPS_CTL_HWPDN BIT(17) +#define PPHY_SUSB BIT(20) +#define UPHY_SUSB BIT(21) +#define PCI_SUSEN BIT(22) +#define USB_SUSEN BIT(23) +#define RF_RL_ID (BIT(31)|BIT(30)|BIT(29)|BIT(28)) + +/* 2SYS_CFG */ +#define RTL_ID BIT(23) /* TestChip ID, 1:Test(RLE); 0:MP(RL) */ + +/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ + +/* 2 Function Enable Registers */ +/* 2 CR */ + +#define HCI_TXDMA_EN BIT(0) +#define HCI_RXDMA_EN BIT(1) +#define TXDMA_EN BIT(2) +#define RXDMA_EN BIT(3) +#define PROTOCOL_EN BIT(4) +#define SCHEDULE_EN BIT(5) +#define MACTXEN BIT(6) +#define MACRXEN BIT(7) +#define ENSWBCN BIT(8) +#define ENSEC BIT(9) +#define CALTMR_EN BIT(10) /* 32k CAL TMR enable */ + +/* Network type */ +#define _NETTYPE(x) (((x) & 0x3) << 16) +#define MASK_NETTYPE 0x30000 +#define NT_NO_LINK 0x0 +#define NT_LINK_AD_HOC 0x1 +#define NT_LINK_AP 0x2 +#define NT_AS_AP 0x3 + +/* 2 PBP - Page Size Register */ +#define GET_RX_PAGE_SIZE(value) ((value) & 0xF) +#define GET_TX_PAGE_SIZE(value) (((value) & 0xF0) >> 4) +#define _PSRX_MASK 0xF +#define _PSTX_MASK 0xF0 +#define _PSRX(x) (x) +#define _PSTX(x) ((x) << 4) + +#define PBP_64 0x0 +#define PBP_128 0x1 +#define PBP_256 0x2 +#define PBP_512 0x3 +#define PBP_1024 0x4 + +/* 2 TX/RXDMA */ +#define RXDMA_ARBBW_EN BIT(0) +#define RXSHFT_EN BIT(1) +#define RXDMA_AGG_EN BIT(2) +#define QS_VO_QUEUE BIT(8) +#define QS_VI_QUEUE BIT(9) +#define QS_BE_QUEUE BIT(10) +#define QS_BK_QUEUE BIT(11) +#define QS_MANAGER_QUEUE BIT(12) +#define QS_HIGH_QUEUE BIT(13) + +#define HQSEL_VOQ BIT(0) +#define HQSEL_VIQ BIT(1) +#define HQSEL_BEQ BIT(2) +#define HQSEL_BKQ BIT(3) +#define HQSEL_MGTQ BIT(4) +#define HQSEL_HIQ BIT(5) + +/* For normal driver, 0x10C */ +#define _TXDMA_HIQ_MAP(x) (((x)&0x3) << 14) +#define _TXDMA_MGQ_MAP(x) (((x)&0x3) << 12) +#define _TXDMA_BKQ_MAP(x) (((x)&0x3) << 10) +#define _TXDMA_BEQ_MAP(x) (((x)&0x3) << 8 ) +#define _TXDMA_VIQ_MAP(x) (((x)&0x3) << 6 ) +#define _TXDMA_VOQ_MAP(x) (((x)&0x3) << 4 ) + +#define QUEUE_LOW 1 +#define QUEUE_NORMAL 2 +#define QUEUE_HIGH 3 + +/* 2 TRXFF_BNDY */ + +/* 2 LLT_INIT */ +#define _LLT_NO_ACTIVE 0x0 +#define _LLT_WRITE_ACCESS 0x1 +#define _LLT_READ_ACCESS 0x2 + +#define _LLT_INIT_DATA(x) ((x) & 0xFF) +#define _LLT_INIT_ADDR(x) (((x) & 0xFF) << 8) +#define _LLT_OP(x) (((x) & 0x3) << 30) +#define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) + +/* 0x0200h ~ 0x027Fh TXDMA Configuration */ +/* 2RQPN */ +#define _HPQ(x) ((x) & 0xFF) +#define _LPQ(x) (((x) & 0xFF) << 8) +#define _PUBQ(x) (((x) & 0xFF) << 16) +/* NOTE: in RQPN_NPQ register */ +#define _NPQ(x) ((x) & 0xFF) + +#define HPQ_PUBLIC_DIS BIT(24) +#define LPQ_PUBLIC_DIS BIT(25) +#define LD_RQPN BIT(31) + +/* 2TDECTRL */ +#define BCN_VALID BIT(16) +#define BCN_HEAD(x) (((x) & 0xFF) << 8) +#define BCN_HEAD_MASK 0xFF00 + +/* 2 TDECTL */ +#define BLK_DESC_NUM_SHIFT 4 +#define BLK_DESC_NUM_MASK 0xF + +/* 2 TXDMA_OFFSET_CHK */ +#define DROP_DATA_EN BIT(9) + +/* 0x0280h ~ 0x028Bh RX DMA Configuration */ + +/* REG_RXDMA_CONTROL, 0x0286h */ + +/* 2 REG_RXPKT_NUM, 0x0284 */ +#define RXPKT_RELEASE_POLL BIT(16) +#define RXDMA_IDLE BIT(17) +#define RW_RELEASE_EN BIT(18) + +/* 0x0400h ~ 0x047Fh Protocol Configuration */ +/* 2 FWHW_TXQ_CTRL */ +#define EN_AMPDU_RTY_NEW BIT(7) + +/* 2 SPEC SIFS */ +#define _SPEC_SIFS_CCK(x) ((x) & 0xFF) +#define _SPEC_SIFS_OFDM(x) (((x) & 0xFF) << 8) + +/* 2 RL */ +#define RETRY_LIMIT_SHORT_SHIFT 8 +#define RETRY_LIMIT_LONG_SHIFT 0 + +/* 0x0500h ~ 0x05FFh EDCA Configuration */ + +/* 2 EDCA setting */ +#define AC_PARAM_TXOP_LIMIT_OFFSET 16 +#define AC_PARAM_ECW_MAX_OFFSET 12 +#define AC_PARAM_ECW_MIN_OFFSET 8 +#define AC_PARAM_AIFS_OFFSET 0 + +#define _LRL(x) ((x) & 0x3F) +#define _SRL(x) (((x) & 0x3F) << 8) + +/* 2 BCN_CTRL */ +#define EN_MBSSID BIT(1) +#define EN_TXBCN_RPT BIT(2) +#define EN_BCN_FUNCTION BIT(3) +#define DIS_TSF_UPDATE BIT(3) + +/* The same function but different bit field. */ +#define DIS_TSF_UDT0_NORMAL_CHIP BIT(4) +#define DIS_TSF_UDT0_TEST_CHIP BIT(5) +#define STOP_BCNQ BIT(6) + +/* 2 ACMHWCTRL */ +#define AcmHw_HwEn BIT(0) +#define AcmHw_BeqEn BIT(1) +#define AcmHw_ViqEn BIT(2) +#define AcmHw_VoqEn BIT(3) +#define AcmHw_BeqStatus BIT(4) +#define AcmHw_ViqStatus BIT(5) +#define AcmHw_VoqStatus BIT(6) + +/* 0x0600h ~ 0x07FFh WMAC Configuration */ +/* 2APSD_CTRL */ +#define APSDOFF BIT(6) +#define APSDOFF_STATUS BIT(7) + +#define RATE_BITMAP_ALL 0xFFFFF + +/* Only use CCK 1M rate for ACK */ +#define RATE_RRSR_CCK_ONLY_1M 0xFFFF1 + +/* 2 TCR */ +#define TSFRST BIT(0) +#define DIS_GCLK BIT(1) +#define PAD_SEL BIT(2) +#define PWR_ST BIT(6) +#define PWRBIT_OW_EN BIT(7) +#define ACRC BIT(8) +#define CFENDFORM BIT(9) +#define ICV BIT(10) + +/* 2 RCR */ +#define AAP BIT(0) +#define APM BIT(1) +#define AM BIT(2) +#define AB BIT(3) +#define ADD3 BIT(4) +#define APWRMGT BIT(5) +#define CBSSID BIT(6) +#define CBSSID_DATA BIT(6) +#define CBSSID_BCN BIT(7) +#define ACRC32 BIT(8) +#define AICV BIT(9) +#define ADF BIT(11) +#define ACF BIT(12) +#define AMF BIT(13) +#define HTC_LOC_CTRL BIT(14) +#define UC_DATA_EN BIT(16) +#define BM_DATA_EN BIT(17) +#define MFBEN BIT(22) +#define LSIGEN BIT(23) +#define EnMBID BIT(24) +#define APP_BASSN BIT(27) +#define APP_PHYSTS BIT(28) +#define APP_ICV BIT(29) +#define APP_MIC BIT(30) +#define APP_FCS BIT(31) + +/* 2 SECCFG */ +#define SCR_TxUseDK BIT(0) /* Force Tx Use Default Key */ +#define SCR_RxUseDK BIT(1) /* Force Rx Use Default Key */ +#define SCR_TxEncEnable BIT(2) /* Enable Tx Encryption */ +#define SCR_RxDecEnable BIT(3) /* Enable Rx Decryption */ +#define SCR_SKByA2 BIT(4) /* Search kEY BY A2 */ +#define SCR_NoSKMC BIT(5) /* No Key Search Multicast */ +#define SCR_TXBCUSEDK BIT(6) /* Force Tx Bcast pkt Use Default Key */ +#define SCR_RXBCUSEDK BIT(7) /* Force Rx Bcast pkt Use Default Key */ + +/* RTL8188E SDIO Configuration */ + +/* I/O bus domain address mapping */ +#define SDIO_LOCAL_BASE 0x10250000 +#define WLAN_IOREG_BASE 0x10260000 +#define FIRMWARE_FIFO_BASE 0x10270000 +#define TX_HIQ_BASE 0x10310000 +#define TX_MIQ_BASE 0x10320000 +#define TX_LOQ_BASE 0x10330000 +#define RX_RX0FF_BASE 0x10340000 + +/* SDIO host local register space mapping. */ +#define SDIO_LOCAL_MSK 0x0FFF +#define WLAN_IOREG_MSK 0x7FFF +#define WLAN_FIFO_MSK 0x1FFF /* Aggregation Length[12:0] */ +#define WLAN_RX0FF_MSK 0x0003 + +/* Without ref to the SDIO Device ID */ +#define SDIO_WITHOUT_REF_DEVICE_ID 0 +#define SDIO_LOCAL_DEVICE_ID 0 /* 0b[16], 000b[15:13] */ +#define WLAN_TX_HIQ_DEVICE_ID 4 /* 0b[16], 100b[15:13] */ +#define WLAN_TX_MIQ_DEVICE_ID 5 /* 0b[16], 101b[15:13] */ +#define WLAN_TX_LOQ_DEVICE_ID 6 /* 0b[16], 110b[15:13] */ +#define WLAN_RX0FF_DEVICE_ID 7 /* 0b[16], 111b[15:13] */ +#define WLAN_IOREG_DEVICE_ID 8 /* 1b[16] */ + +/* SDIO Tx Free Page Index */ +#define HI_QUEUE_IDX 0 +#define MID_QUEUE_IDX 1 +#define LOW_QUEUE_IDX 2 +#define PUBLIC_QUEUE_IDX 3 + +#define SDIO_MAX_TX_QUEUE 3 /* HIQ, MIQ and LOQ */ +#define SDIO_MAX_RX_QUEUE 1 + +/* SDIO Tx Control */ +#define SDIO_REG_TX_CTRL 0x0000 +/* SDIO Host Interrupt Mask */ +#define SDIO_REG_HIMR 0x0014 +/* SDIO Host Interrupt Service Routine */ +#define SDIO_REG_HISR 0x0018 +/* HCI Current Power Mode */ +#define SDIO_REG_HCPWM 0x0019 +/* RXDMA Request Length */ +#define SDIO_REG_RX0_REQ_LEN 0x001C +/* Free Tx Buffer Page */ +#define SDIO_REG_FREE_TXPG 0x0020 +/* HCI Current Power Mode 1 */ +#define SDIO_REG_HCPWM1 0x0024 +/* HCI Current Power Mode 2 */ +#define SDIO_REG_HCPWM2 0x0026 +/* HTSF Informaion */ +#define SDIO_REG_HTSFR_INFO 0x0030 +/* HCI Request Power Mode 1 */ +#define SDIO_REG_HRPWM1 0x0080 +/* HCI Request Power Mode 2 */ +#define SDIO_REG_HRPWM2 0x0082 +/* HCI Power Save Clock */ +#define SDIO_REG_HPS_CLKR 0x0084 +/* SDIO HCI Suspend Control */ +#define SDIO_REG_HSUS_CTRL 0x0086 +/* SDIO Host Extension Interrupt Mask Always */ +#define SDIO_REG_HIMR_ON 0x0090 +/* SDIO Host Extension Interrupt Status Always */ +#define SDIO_REG_HISR_ON 0x0091 + +#define SDIO_HIMR_DISABLED 0 + +/* RTL8188E SDIO Host Interrupt Mask Register */ +#define SDIO_HIMR_RX_REQUEST_MSK BIT0 +#define SDIO_HIMR_AVAL_MSK BIT1 +#define SDIO_HIMR_TXERR_MSK BIT2 +#define SDIO_HIMR_RXERR_MSK BIT3 +#define SDIO_HIMR_TXFOVW_MSK BIT4 +#define SDIO_HIMR_RXFOVW_MSK BIT5 +#define SDIO_HIMR_TXBCNOK_MSK BIT6 +#define SDIO_HIMR_TXBCNERR_MSK BIT7 +#define SDIO_HIMR_BCNERLY_INT_MSK BIT16 +#define SDIO_HIMR_C2HCMD_MSK BIT17 +#define SDIO_HIMR_CPWM1_MSK BIT18 +#define SDIO_HIMR_CPWM2_MSK BIT19 +#define SDIO_HIMR_HSISR_IND_MSK BIT20 +#define SDIO_HIMR_GTINT3_IND_MSK BIT21 +#define SDIO_HIMR_GTINT4_IND_MSK BIT22 +#define SDIO_HIMR_PSTIMEOUT_MSK BIT23 +#define SDIO_HIMR_OCPINT_MSK BIT24 +#define SDIO_HIMR_ATIMEND_MSK BIT25 +#define SDIO_HIMR_ATIMEND_E_MSK BIT26 +#define SDIO_HIMR_CTWEND_MSK BIT27 + +/* RTL8188E SDIO Specific */ +#define SDIO_HIMR_MCU_ERR_MSK BIT28 +#define SDIO_HIMR_TSF_BIT32_TOGGLE_MSK BIT29 + +/* SDIO Host Interrupt Service Routine */ +#define SDIO_HISR_RX_REQUEST BIT0 +#define SDIO_HISR_AVAL BIT1 +#define SDIO_HISR_TXERR BIT2 +#define SDIO_HISR_RXERR BIT3 +#define SDIO_HISR_TXFOVW BIT4 +#define SDIO_HISR_RXFOVW BIT5 +#define SDIO_HISR_TXBCNOK BIT6 +#define SDIO_HISR_TXBCNERR BIT7 +#define SDIO_HISR_BCNERLY_INT BIT16 +#define SDIO_HISR_C2HCMD BIT17 +#define SDIO_HISR_CPWM1 BIT18 +#define SDIO_HISR_CPWM2 BIT19 +#define SDIO_HISR_HSISR_IND BIT20 +#define SDIO_HISR_GTINT3_IND BIT21 +#define SDIO_HISR_GTINT4_IND BIT22 +#define SDIO_HISR_PSTIME BIT23 +#define SDIO_HISR_OCPINT BIT24 +#define SDIO_HISR_ATIMEND BIT25 +#define SDIO_HISR_ATIMEND_E BIT26 +#define SDIO_HISR_CTWEND BIT27 + +/* RTL8188E SDIO Specific */ +#define SDIO_HISR_MCU_ERR BIT28 +#define SDIO_HISR_TSF_BIT32_TOGGLE BIT29 + +#define MASK_SDIO_HISR_CLEAR \ + (SDIO_HISR_TXERR | SDIO_HISR_RXERR | SDIO_HISR_TXFOVW |\ + SDIO_HISR_RXFOVW | SDIO_HISR_TXBCNOK | SDIO_HISR_TXBCNERR |\ + SDIO_HISR_C2HCMD | SDIO_HISR_CPWM1 | SDIO_HISR_CPWM2 |\ + SDIO_HISR_HSISR_IND | SDIO_HISR_GTINT3_IND | SDIO_HISR_GTINT4_IND |\ + SDIO_HISR_PSTIMEOUT | SDIO_HISR_OCPINT) + +/* SDIO HCI Suspend Control Register */ +#define HCI_RESUME_PWR_RDY BIT1 +#define HCI_SUS_CTRL BIT0 + +/* SDIO Tx FIFO related */ +/* The number of Tx FIFO free page */ +#define SDIO_TX_FREE_PG_QUEUE 4 +#define SDIO_TX_FIFO_PAGE_SZ 128 + +/* 0xFE00h ~ 0xFE55h USB Configuration */ + +/* 2 USB Information (0xFE17) */ +#define USB_IS_HIGH_SPEED 0 +#define USB_IS_FULL_SPEED 1 +#define USB_SPEED_MASK BIT(5) + +#define USB_NORMAL_SIE_EP_MASK 0xF +#define USB_NORMAL_SIE_EP_SHIFT 4 + +/* 2 Special Option */ +#define USB_AGG_EN BIT(3) + +/* 0; Use interrupt endpoint to upload interrupt pkt */ +/* 1; Use bulk endpoint to upload interrupt pkt, */ +#define INT_BULK_SEL BIT(4) + +/* 2REG_C2HEVT_CLEAR */ +/* Set by driver and notify FW that the driver has read + * the C2H command message */ +#define C2H_EVT_HOST_CLOSE 0x00 +/* Set by FW indicating that FW had set the C2H command + * message and it's not yet read by driver. */ +#define C2H_EVT_FW_CLOSE 0xFF + +/* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ +/* Enable GPIO[9] as WiFi HW PDn source */ +#define WL_HWPDN_EN BIT0 +/* WiFi HW PDn polarity control */ +#define WL_HWPDN_SL BIT1 +/* WiFi function enable */ +#define WL_FUNC_EN BIT2 +/* Enable GPIO[9] as WiFi RF HW PDn source */ +#define WL_HWROF_EN BIT3 +/* Enable GPIO[11] as BT HW PDn source */ +#define BT_HWPDN_EN BIT16 +/* BT HW PDn polarity control */ +#define BT_HWPDN_SL BIT17 +/* BT function enable */ +#define BT_FUNC_EN BIT18 +/* Enable GPIO[11] as BT/GPS RF HW PDn source */ +#define BT_HWROF_EN BIT19 +/* Enable GPIO[10] as GPS HW PDn source */ +#define GPS_HWPDN_EN BIT20 +/* GPS HW PDn polarity control */ +#define GPS_HWPDN_SL BIT21 +/* GPS function enable */ +#define GPS_FUNC_EN BIT22 + +/* 3 REG_LIFECTRL_CTRL */ +#define HAL92C_EN_PKT_LIFE_TIME_BK BIT3 +#define HAL92C_EN_PKT_LIFE_TIME_BE BIT2 +#define HAL92C_EN_PKT_LIFE_TIME_VI BIT1 +#define HAL92C_EN_PKT_LIFE_TIME_VO BIT0 + +#define HAL92C_MSDU_LIFE_TIME_UNIT 128 /* in us */ + +/* General definitions */ +#define LAST_ENTRY_OF_TX_PKT_BUFFER 176 /* 22k 22528 bytes */ + +#define POLLING_LLT_THRESHOLD 20 +#define POLLING_READY_TIMEOUT_COUNT 1000 +/* GPIO BIT */ +#define HAL_8192C_HW_GPIO_WPS_BIT BIT2 + +/* 8192C EEPROM/EFUSE share register definition. */ + +/* EEPROM/Efuse PG Offset for 88EE/88EU/88ES */ +#define EEPROM_TX_PWR_INX_88E 0x10 + +#define EEPROM_ChannelPlan_88E 0xB8 +#define EEPROM_XTAL_88E 0xB9 +#define EEPROM_THERMAL_METER_88E 0xBA +#define EEPROM_IQK_LCK_88E 0xBB + +#define EEPROM_RF_BOARD_OPTION_88E 0xC1 +#define EEPROM_RF_FEATURE_OPTION_88E 0xC2 +#define EEPROM_RF_BT_SETTING_88E 0xC3 +#define EEPROM_VERSION_88E 0xC4 +#define EEPROM_CUSTOMERID_88E 0xC5 +#define EEPROM_RF_ANTENNA_OPT_88E 0xC9 + +/* RTL88EE */ +#define EEPROM_MAC_ADDR_88EE 0xD0 +#define EEPROM_VID_88EE 0xD6 +#define EEPROM_DID_88EE 0xD8 +#define EEPROM_SVID_88EE 0xDA +#define EEPROM_SMID_88EE 0xDC + +/* RTL88EU */ +#define EEPROM_MAC_ADDR_88EU 0xD7 +#define EEPROM_VID_88EU 0xD0 +#define EEPROM_PID_88EU 0xD2 +#define EEPROM_USB_OPTIONAL_FUNCTION0 0xD4 + +/* RTL88ES */ +#define EEPROM_MAC_ADDR_88ES 0x11A + +/* EEPROM/Efuse Value Type */ +#define EETYPE_TX_PWR 0x0 + +/* Default Value for EEPROM or EFUSE!!! */ +#define EEPROM_Default_TSSI 0x0 +#define EEPROM_Default_TxPowerDiff 0x0 +#define EEPROM_Default_CrystalCap 0x5 +/* Default: 2X2, RTL8192CE(QFPN68) */ +#define EEPROM_Default_BoardType 0x02 +#define EEPROM_Default_TxPower 0x1010 +#define EEPROM_Default_HT2T_TxPwr 0x10 + +#define EEPROM_Default_LegacyHTTxPowerDiff 0x3 +#define EEPROM_Default_ThermalMeter 0x12 + +#define EEPROM_Default_AntTxPowerDiff 0x0 +#define EEPROM_Default_TxPwDiff_CrystalCap 0x5 +#define EEPROM_Default_TxPowerLevel 0x2A + +#define EEPROM_Default_HT40_2SDiff 0x0 +/* HT20<->40 default Tx Power Index Difference */ +#define EEPROM_Default_HT20_Diff 2 +#define EEPROM_Default_LegacyHTTxPowerDiff 0x3 +#define EEPROM_Default_HT40_PwrMaxOffset 0 +#define EEPROM_Default_HT20_PwrMaxOffset 0 + +#define EEPROM_Default_CrystalCap_88E 0x20 +#define EEPROM_Default_ThermalMeter_88E 0x18 + +/* New EFUSE deafult value */ +#define EEPROM_DEFAULT_24G_INDEX 0x2D +#define EEPROM_DEFAULT_24G_HT20_DIFF 0X02 +#define EEPROM_DEFAULT_24G_OFDM_DIFF 0X04 + +#define EEPROM_DEFAULT_5G_INDEX 0X2A +#define EEPROM_DEFAULT_5G_HT20_DIFF 0X00 +#define EEPROM_DEFAULT_5G_OFDM_DIFF 0X04 + +#define EEPROM_DEFAULT_DIFF 0XFE +#define EEPROM_DEFAULT_CHANNEL_PLAN 0x7F +#define EEPROM_DEFAULT_BOARD_OPTION 0x00 +#define EEPROM_DEFAULT_FEATURE_OPTION 0x00 +#define EEPROM_DEFAULT_BT_OPTION 0x10 + +/* For debug */ +#define EEPROM_Default_PID 0x1234 +#define EEPROM_Default_VID 0x5678 +#define EEPROM_Default_CustomerID 0xAB +#define EEPROM_Default_CustomerID_8188E 0x00 +#define EEPROM_Default_SubCustomerID 0xCD +#define EEPROM_Default_Version 0 + +#define EEPROM_CHANNEL_PLAN_FCC 0x0 +#define EEPROM_CHANNEL_PLAN_IC 0x1 +#define EEPROM_CHANNEL_PLAN_ETSI 0x2 +#define EEPROM_CHANNEL_PLAN_SPA 0x3 +#define EEPROM_CHANNEL_PLAN_FRANCE 0x4 +#define EEPROM_CHANNEL_PLAN_MKK 0x5 +#define EEPROM_CHANNEL_PLAN_MKK1 0x6 +#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7 +#define EEPROM_CHANNEL_PLAN_TELEC 0x8 +#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMA 0x9 +#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA +#define EEPROM_CHANNEL_PLAN_NCC 0xB +#define EEPROM_USB_OPTIONAL1 0xE +#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80 + +#define EEPROM_CID_DEFAULT 0x0 +#define EEPROM_CID_TOSHIBA 0x4 +#define EEPROM_CID_CCX 0x10 /* CCX test. */ +#define EEPROM_CID_QMI 0x0D +#define EEPROM_CID_WHQL 0xFE +#define RTL_EEPROM_ID 0x8129 + +#endif /* __RTL8188E_SPEC_H__ */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_sreset.h b/drivers/staging/r8188eu/include/rtl8188e_sreset.h new file mode 100644 index 000000000000..a29e69519794 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_sreset.h @@ -0,0 +1,31 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTL8188E_SRESET_H_ +#define _RTL8188E_SRESET_H_ + +#include +#include +#include + +void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter); +void rtl8188e_sreset_xmit_status_check(struct adapter *padapter); +void rtl8188e_sreset_linked_status_check(struct adapter *padapter); + +#endif diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h new file mode 100644 index 000000000000..5e586058826d --- /dev/null +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -0,0 +1,177 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTL8188E_XMIT_H__ +#define __RTL8188E_XMIT_H__ + +#define MAX_TX_AGG_PACKET_NUMBER 0xFF +/* */ +/* Queue Select Value in TxDesc */ +/* */ +#define QSLT_BK 0x2/* 0x01 */ +#define QSLT_BE 0x0 +#define QSLT_VI 0x5/* 0x4 */ +#define QSLT_VO 0x7/* 0x6 */ +#define QSLT_BEACON 0x10 +#define QSLT_HIGH 0x11 +#define QSLT_MGNT 0x12 +#define QSLT_CMD 0x13 + +/* For 88e early mode */ +#define SET_EARLYMODE_PKTNUM(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 0, 3, __Value) +#define SET_EARLYMODE_LEN0(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 4, 12, __Value) +#define SET_EARLYMODE_LEN1(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 16, 12, __Value) +#define SET_EARLYMODE_LEN2_1(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr, 28, 4, __Value) +#define SET_EARLYMODE_LEN2_2(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr+4, 0, 8, __Value) +#define SET_EARLYMODE_LEN3(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr+4, 8, 12, __Value) +#define SET_EARLYMODE_LEN4(__pAddr, __Value) \ + SET_BITS_TO_LE_4BYTE(__pAddr+4, 20, 12, __Value) + +/* */ +/* defined for TX DESC Operation */ +/* */ + +#define MAX_TID (15) + +/* OFFSET 0 */ +#define OFFSET_SZ 0 +#define OFFSET_SHT 16 +#define BMC BIT(24) +#define LSG BIT(26) +#define FSG BIT(27) +#define OWN BIT(31) + +/* OFFSET 4 */ +#define PKT_OFFSET_SZ 0 +#define QSEL_SHT 8 +#define RATE_ID_SHT 16 +#define NAVUSEHDR BIT(20) +#define SEC_TYPE_SHT 22 +#define PKT_OFFSET_SHT 26 + +/* OFFSET 8 */ +#define AGG_EN BIT(12) +#define AGG_BK BIT(16) +#define AMPDU_DENSITY_SHT 20 +#define ANTSEL_A BIT(24) +#define ANTSEL_B BIT(25) +#define TX_ANT_CCK_SHT 26 +#define TX_ANTL_SHT 28 +#define TX_ANT_HT_SHT 30 + +/* OFFSET 12 */ +#define SEQ_SHT 16 +#define EN_HWSEQ BIT(31) + +/* OFFSET 16 */ +#define QOS BIT(6) +#define HW_SSN BIT(7) +#define USERATE BIT(8) +#define DISDATAFB BIT(10) +#define CTS_2_SELF BIT(11) +#define RTS_EN BIT(12) +#define HW_RTS_EN BIT(13) +#define DATA_SHORT BIT(24) +#define PWR_STATUS_SHT 15 +#define DATA_SC_SHT 20 +#define DATA_BW BIT(25) + +/* OFFSET 20 */ +#define RTY_LMT_EN BIT(17) + +enum TXDESC_SC { + SC_DONT_CARE = 0x00, + SC_UPPER = 0x01, + SC_LOWER = 0x02, + SC_DUPLICATE = 0x03 +}; +/* OFFSET 20 */ +#define SGI BIT(6) +#define USB_TXAGG_NUM_SHT 24 + +#define txdesc_set_ccx_sw_88e(txdesc, value) \ + do { \ + ((struct txdesc_88e *)(txdesc))->sw1 = (((value)>>8) & 0x0f); \ + ((struct txdesc_88e *)(txdesc))->sw0 = ((value) & 0xff); \ + } while (0) + +struct txrpt_ccx_88e { + /* offset 0 */ + u8 tag1:1; + u8 pkt_num:3; + u8 txdma_underflow:1; + u8 int_bt:1; + u8 int_tri:1; + u8 int_ccx:1; + + /* offset 1 */ + u8 mac_id:6; + u8 pkt_ok:1; + u8 bmc:1; + + /* offset 2 */ + u8 retry_cnt:6; + u8 lifetime_over:1; + u8 retry_over:1; + + /* offset 3 */ + u8 ccx_qtime0; + u8 ccx_qtime1; + + /* offset 5 */ + u8 final_data_rate; + + /* offset 6 */ + u8 sw1:4; + u8 qsel:4; + + /* offset 7 */ + u8 sw0; +}; + +#define txrpt_ccx_sw_88e(txrpt_ccx) ((txrpt_ccx)->sw0 + ((txrpt_ccx)->sw1<<8)) +#define txrpt_ccx_qtime_88e(txrpt_ccx) \ + ((txrpt_ccx)->ccx_qtime0+((txrpt_ccx)->ccx_qtime1<<8)) + +void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, + u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); +s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); +void rtl8188eu_free_xmit_priv(struct adapter *padapter); +s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame); +s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame); +s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); +#define hal_xmit_handler rtl8188eu_xmit_buf_handler +void rtl8188eu_xmit_tasklet(void *priv); +s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, + struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf); + +void dump_txrpt_ccx_88e(void *buf); +void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); + +void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, + struct tx_desc *ptxdesc); + +#endif /* __RTL8188E_XMIT_H__ */ diff --git a/drivers/staging/r8188eu/include/rtw_android.h b/drivers/staging/r8188eu/include/rtw_android.h new file mode 100644 index 000000000000..e85bf1ff01f8 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_android.h @@ -0,0 +1,64 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef __RTW_ANDROID_H__ +#define __RTW_ANDROID_H__ + +#include +#include + +enum ANDROID_WIFI_CMD { + ANDROID_WIFI_CMD_START, + ANDROID_WIFI_CMD_STOP, + ANDROID_WIFI_CMD_SCAN_ACTIVE, + ANDROID_WIFI_CMD_SCAN_PASSIVE, + ANDROID_WIFI_CMD_RSSI, + ANDROID_WIFI_CMD_LINKSPEED, + ANDROID_WIFI_CMD_RXFILTER_START, + ANDROID_WIFI_CMD_RXFILTER_STOP, + ANDROID_WIFI_CMD_RXFILTER_ADD, + ANDROID_WIFI_CMD_RXFILTER_REMOVE, + ANDROID_WIFI_CMD_BTCOEXSCAN_START, + ANDROID_WIFI_CMD_BTCOEXSCAN_STOP, + ANDROID_WIFI_CMD_BTCOEXMODE, + ANDROID_WIFI_CMD_SETSUSPENDOPT, + ANDROID_WIFI_CMD_P2P_DEV_ADDR, + ANDROID_WIFI_CMD_SETFWPATH, + ANDROID_WIFI_CMD_SETBAND, + ANDROID_WIFI_CMD_GETBAND, + ANDROID_WIFI_CMD_COUNTRY, + ANDROID_WIFI_CMD_P2P_SET_NOA, + ANDROID_WIFI_CMD_P2P_GET_NOA, + ANDROID_WIFI_CMD_P2P_SET_PS, + ANDROID_WIFI_CMD_SET_AP_WPS_P2P_IE, + ANDROID_WIFI_CMD_MACADDR, + ANDROID_WIFI_CMD_BLOCK, + ANDROID_WIFI_CMD_WFD_ENABLE, + ANDROID_WIFI_CMD_WFD_DISABLE, + ANDROID_WIFI_CMD_WFD_SET_TCPPORT, + ANDROID_WIFI_CMD_WFD_SET_MAX_TPUT, + ANDROID_WIFI_CMD_WFD_SET_DEVTYPE, + ANDROID_WIFI_CMD_MAX +}; + +int rtw_android_cmdstr_to_num(char *cmdstr); +int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd); + +#endif /* __RTW_ANDROID_H__ */ diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h new file mode 100644 index 000000000000..bf3c9fb60153 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_ap.h @@ -0,0 +1,67 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_AP_H_ +#define __RTW_AP_H_ + +#include +#include + +#ifdef CONFIG_88EU_AP_MODE + +/* external function */ +void rtw_indicate_sta_assoc_event(struct adapter *padapter, + struct sta_info *psta); +void rtw_indicate_sta_disassoc_event(struct adapter *padapter, + struct sta_info *psta); +void init_mlme_ap_info(struct adapter *padapter); +void free_mlme_ap_info(struct adapter *padapter); +void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, + u8 index, u8 *data, u8 len); +void rtw_remove_bcn_ie(struct adapter *padapter, + struct wlan_bssid_ex *pnetwork, u8 index); +void update_beacon(struct adapter *padapter, u8 ie_id, + u8 *oui, u8 tx); +void add_RATid(struct adapter *padapter, struct sta_info *psta, + u8 rssi_level); +void expire_timeout_chk(struct adapter *padapter); +void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta); +int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len); +void rtw_ap_restore_network(struct adapter *padapter); +void rtw_set_macaddr_acl(struct adapter *padapter, int mode); +int rtw_acl_add_sta(struct adapter *padapter, u8 *addr); +int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr); + +#ifdef CONFIG_88EU_AP_MODE +void associated_clients_update(struct adapter *padapter, u8 updated); +void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta); +u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta); +void sta_info_update(struct adapter *padapter, struct sta_info *psta); +void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta); +u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, + bool active, u16 reason); +int rtw_sta_flush(struct adapter *padapter); +int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset); +void start_ap_mode(struct adapter *padapter); +void stop_ap_mode(struct adapter *padapter); +#endif +#endif /* end of CONFIG_88EU_AP_MODE */ +void update_bmc_sta(struct adapter *padapter); + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_br_ext.h b/drivers/staging/r8188eu/include/rtw_br_ext.h new file mode 100644 index 000000000000..f21e7a4515d0 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_br_ext.h @@ -0,0 +1,66 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_BR_EXT_H_ +#define _RTW_BR_EXT_H_ + +#define MACADDRLEN 6 +#define _DEBUG_ERR DBG_88E +#define _DEBUG_INFO DBG_88E +#define DEBUG_WARN DBG_88E +#define DEBUG_INFO DBG_88E +#define DEBUG_ERR DBG_88E +#define GET_MY_HWADDR(padapter) ((padapter)->eeprompriv.mac_addr) + +#define NAT25_HASH_BITS 4 +#define NAT25_HASH_SIZE (1 << NAT25_HASH_BITS) +#define NAT25_AGEING_TIME 300 + +#define MAX_NETWORK_ADDR_LEN 17 + +struct nat25_network_db_entry { + struct nat25_network_db_entry *next_hash; + struct nat25_network_db_entry **pprev_hash; + atomic_t use_count; + unsigned char macAddr[6]; + unsigned long ageing_timer; + unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; +}; + +enum NAT25_METHOD { + NAT25_MIN, + NAT25_CHECK, + NAT25_INSERT, + NAT25_LOOKUP, + NAT25_PARSE, + NAT25_MAX +}; + +struct br_ext_info { + unsigned int nat25_disable; + unsigned int macclone_enable; + unsigned int dhcp_bcst_disable; + int addPPPoETag; /* 1: Add PPPoE relay-SID, 0: disable */ + unsigned char nat25_dmzMac[MACADDRLEN]; + unsigned int nat25sc_disable; +}; + +void nat25_db_cleanup(struct adapter *priv); + +#endif /* _RTW_BR_EXT_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h new file mode 100644 index 000000000000..357e732ac046 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -0,0 +1,991 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_CMD_H_ +#define __RTW_CMD_H_ + +#include +#include +#include + +#define C2H_MEM_SZ (16*1024) + +#include +#include /* */ + +#define FREE_CMDOBJ_SZ 128 + +#define MAX_CMDSZ 1024 +#define MAX_RSPSZ 512 +#define MAX_EVTSZ 1024 + +#define CMDBUFF_ALIGN_SZ 512 + +struct cmd_obj { + struct adapter *padapter; + u16 cmdcode; + u8 res; + u8 *parmbuf; + u32 cmdsz; + u8 *rsp; + u32 rspsz; + struct list_head list; +}; + +struct cmd_priv { + struct semaphore cmd_queue_sema; + struct semaphore terminate_cmdthread_sema; + struct __queue cmd_queue; + u8 cmd_seq; + u8 *cmd_buf; /* shall be non-paged, and 4 bytes aligned */ + u8 *cmd_allocated_buf; + u8 *rsp_buf; /* shall be non-paged, and 4 bytes aligned */ + u8 *rsp_allocated_buf; + u32 cmd_issued_cnt; + u32 cmd_done_cnt; + u32 rsp_cnt; + u8 cmdthd_running; + struct adapter *padapter; +}; + +struct evt_priv { + struct work_struct c2h_wk; + bool c2h_wk_alive; + struct rtw_cbuf *c2h_queue; + #define C2H_QUEUE_MAX_LEN 10 + ATOMIC_T event_seq; + u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ + u8 *evt_allocated_buf; + u32 evt_done_cnt; +}; + +#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \ +do {\ + INIT_LIST_HEAD(&pcmd->list);\ + pcmd->cmdcode = code;\ + pcmd->parmbuf = (u8 *)(pparm);\ + pcmd->cmdsz = sizeof(*pparm);\ + pcmd->rsp = NULL;\ + pcmd->rspsz = 0;\ +} while (0) + +struct c2h_evt_hdr { + u8 id:4; + u8 plen:4; + u8 seq; + u8 payload[0]; +}; + +#define c2h_evt_exist(c2h_evt) ((c2h_evt)->id || (c2h_evt)->plen) + +u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); +struct cmd_obj *rtw_dequeue_cmd(struct cmd_priv *pcmdpriv); +void rtw_free_cmd_obj(struct cmd_obj *pcmd); + +int rtw_cmd_thread(void *context); + +u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); +void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); + +u32 rtw_init_evt_priv(struct evt_priv *pevtpriv); +void rtw_free_evt_priv(struct evt_priv *pevtpriv); +void rtw_cmd_clr_isr(struct cmd_priv *pcmdpriv); +void rtw_evt_notify_isr(struct evt_priv *pevtpriv); +#ifdef CONFIG_88EU_P2P +u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType); +#endif /* CONFIG_88EU_P2P */ + +enum rtw_drvextra_cmd_id { + NONE_WK_CID, + DYNAMIC_CHK_WK_CID, + DM_CTRL_WK_CID, + PBC_POLLING_WK_CID, + POWER_SAVING_CTRL_WK_CID,/* IPS,AUTOSuspend */ + LPS_CTRL_WK_CID, + ANT_SELECT_WK_CID, + P2P_PS_WK_CID, + P2P_PROTO_WK_CID, + CHECK_HIQ_WK_CID,/* for softap mode, check hi queue if empty */ + INTEl_WIDI_WK_CID, + C2H_WK_CID, + RTP_TIMER_CFG_WK_CID, + MAX_WK_CID +}; + +enum LPS_CTRL_TYPE { + LPS_CTRL_SCAN = 0, + LPS_CTRL_JOINBSS = 1, + LPS_CTRL_CONNECT = 2, + LPS_CTRL_DISCONNECT = 3, + LPS_CTRL_SPECIAL_PACKET = 4, + LPS_CTRL_LEAVE = 5, +}; + +enum RFINTFS { + SWSI, + HWSI, + HWPI, +}; + +/* +Caller Mode: Infra, Ad-HoC(C) + +Notes: To enter USB suspend mode + +Command Mode + +*/ +struct usb_suspend_parm { + u32 action;/* 1: sleep, 0:resume */ +}; + +/* +Caller Mode: Infra, Ad-HoC + +Notes: To join a known BSS. + +Command-Event Mode + +*/ + +/* +Caller Mode: Infra, Ad-Hoc + +Notes: To join the specified bss + +Command Event Mode + +*/ +struct joinbss_parm { + struct wlan_bssid_ex network; +}; + +/* +Caller Mode: Infra, Ad-HoC(C) + +Notes: To disconnect the current associated BSS + +Command Mode + +*/ +struct disconnect_parm { + u32 deauth_timeout_ms; +}; + +/* +Caller Mode: AP, Ad-HoC(M) + +Notes: To create a BSS + +Command Mode +*/ +struct createbss_parm { + struct wlan_bssid_ex network; +}; + +struct setopmode_parm { + u8 mode; + u8 rsvd[3]; +}; + +/* +Caller Mode: AP, Ad-HoC, Infra + +Notes: To ask RTL8711 performing site-survey + +Command-Event Mode + +*/ + +#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */ +#define RTW_CHANNEL_SCAN_AMOUNT (14+37) +struct sitesurvey_parm { + int scan_mode; /* active: 1, passive: 0 */ + u8 ssid_num; + u8 ch_num; + struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; + struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; +}; + +/* +Caller Mode: Any + +Notes: To set the auth type of RTL8711. open/shared/802.1x + +Command Mode + +*/ +struct setauth_parm { + u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */ + u8 _1x; /* 0: PSK, 1: TLS */ + u8 rsvd[2]; +}; + +/* +Caller Mode: Infra + +a. algorithm: wep40, wep104, tkip & aes +b. keytype: grp key/unicast key +c. key contents + +when shared key ==> keyid is the camid +when 802.1x ==> keyid [0:1] ==> grp key +when 802.1x ==> keyid > 2 ==> unicast key + +*/ +struct setkey_parm { + u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */ + u8 keyid; + u8 grpkey; /* 1: this is the grpkey for 802.1x. + * 0: this is the unicast key for 802.1x */ + u8 set_tx; /* 1: main tx key for wep. 0: other key. */ + u8 key[16]; /* this could be 40 or 104 */ +}; + +/* +When in AP or Ad-Hoc mode, this is used to +allocate an sw/hw entry for a newly associated sta. + +Command + +when shared key ==> algorithm/keyid + +*/ +struct set_stakey_parm { + u8 addr[ETH_ALEN]; + u8 algorithm; + u8 id;/* currently for erasing cam entry if + * algorithm == _NO_PRIVACY_ */ + u8 key[16]; +}; + +struct set_stakey_rsp { + u8 addr[ETH_ALEN]; + u8 keyid; + u8 rsvd; +}; + +/* +Caller Ad-Hoc/AP + +Command -Rsp(AID == CAMID) mode + +This is to force fw to add an sta_data entry per driver's request. + +FW will write an cam entry associated with it. + +*/ +struct set_assocsta_parm { + u8 addr[ETH_ALEN]; +}; + +struct set_assocsta_rsp { + u8 cam_id; + u8 rsvd[3]; +}; + +/* + Caller Ad-Hoc/AP + + Command mode + + This is to force fw to del an sta_data entry per driver's request + + FW will invalidate the cam entry associated with it. + +*/ +struct del_assocsta_parm { + u8 addr[ETH_ALEN]; +}; + +/* +Caller Mode: AP/Ad-HoC(M) + +Notes: To notify fw that given staid has changed its power state + +Command Mode + +*/ +struct setstapwrstate_parm { + u8 staid; + u8 status; + u8 hwaddr[6]; +}; + +/* +Caller Mode: Any + +Notes: To setup the basic rate of RTL8711 + +Command Mode + +*/ +struct setbasicrate_parm { + u8 basicrates[NumRates]; +}; + +/* +Caller Mode: Any + +Notes: To read the current basic rate + +Command-Rsp Mode + +*/ +struct getbasicrate_parm { + u32 rsvd; +}; + +struct getbasicrate_rsp { + u8 basicrates[NumRates]; +}; + +/* +Caller Mode: Any + +Notes: To setup the data rate of RTL8711 + +Command Mode + +*/ +struct setdatarate_parm { + u8 mac_id; + u8 datarates[NumRates]; +}; + +/* +Caller Mode: Any + +Notes: To read the current data rate + +Command-Rsp Mode + +*/ +struct getdatarate_parm { + u32 rsvd; + +}; +struct getdatarate_rsp { + u8 datarates[NumRates]; +}; + +/* +Caller Mode: Any +AP: AP can use the info for the contents of beacon frame +Infra: STA can use the info when sitesurveying +Ad-HoC(M): Like AP +Ad-HoC(C): Like STA + +Notes: To set the phy capability of the NIC + +Command Mode + +*/ + +struct setphyinfo_parm { + struct regulatory_class class_sets[NUM_REGULATORYS]; + u8 status; +}; + +struct getphyinfo_parm { + u32 rsvd; +}; + +struct getphyinfo_rsp { + struct regulatory_class class_sets[NUM_REGULATORYS]; + u8 status; +}; + +/* +Caller Mode: Any + +Notes: To set the channel/modem/band +This command will be used when channel/modem/band is changed. + +Command Mode + +*/ +struct setphy_parm { + u8 rfchannel; + u8 modem; +}; + +/* +Caller Mode: Any + +Notes: To get the current setting of channel/modem/band + +Command-Rsp Mode + +*/ +struct getphy_parm { + u32 rsvd; + +}; +struct getphy_rsp { + u8 rfchannel; + u8 modem; +}; + +struct readBB_parm { + u8 offset; +}; +struct readBB_rsp { + u8 value; +}; + +struct readTSSI_parm { + u8 offset; +}; +struct readTSSI_rsp { + u8 value; +}; + +struct writeBB_parm { + u8 offset; + u8 value; +}; + +struct readRF_parm { + u8 offset; +}; +struct readRF_rsp { + u32 value; +}; + +struct writeRF_parm { + u32 offset; + u32 value; +}; + +struct getrfintfs_parm { + u8 rfintfs; +}; + +struct Tx_Beacon_param +{ + struct wlan_bssid_ex network; +}; + +/* + Notes: This command is used for H2C/C2H loopback testing + + mac[0] == 0 + ==> CMD mode, return H2C_SUCCESS. + The following condition must be ture under CMD mode + mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0; + s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7; + s2 == (b1 << 8 | b0); + + mac[0] == 1 + ==> CMD_RSP mode, return H2C_SUCCESS_RSP + + The rsp layout shall be: + rsp: parm: + mac[0] = mac[5]; + mac[1] = mac[4]; + mac[2] = mac[3]; + mac[3] = mac[2]; + mac[4] = mac[1]; + mac[5] = mac[0]; + s0 = s1; + s1 = swap16(s0); + w0 = swap32(w1); + b0 = b1 + s2 = s0 + s1 + b1 = b0 + w1 = w0 + + mac[0] == 2 + ==> CMD_EVENT mode, return H2C_SUCCESS + The event layout shall be: + event: parm: + mac[0] = mac[5]; + mac[1] = mac[4]; + mac[2] = event's seq no, starting from 1 to parm's marc[3] + mac[3] = mac[2]; + mac[4] = mac[1]; + mac[5] = mac[0]; + s0 = swap16(s0) - event.mac[2]; + s1 = s1 + event.mac[2]; + w0 = swap32(w0); + b0 = b1 + s2 = s0 + event.mac[2] + b1 = b0 + w1 = swap32(w1) - event.mac[2]; + + parm->mac[3] is the total event counts that host requested. + event will be the same with the cmd's param. +*/ + +/* CMD param Format for driver extra cmd handler */ +struct drvextra_cmd_parm { + int ec_id; /* extra cmd id */ + int type_size; /* Can use this field as the type id or command size */ + unsigned char *pbuf; +}; + +/*------------------- Below are used for RF/BB tunning ---------------------*/ + +struct setantenna_parm { + u8 tx_antset; + u8 rx_antset; + u8 tx_antenna; + u8 rx_antenna; +}; + +struct enrateadaptive_parm { + u32 en; +}; + +struct settxagctbl_parm { + u32 txagc[MAX_RATES_LENGTH]; +}; + +struct gettxagctbl_parm { + u32 rsvd; +}; +struct gettxagctbl_rsp { + u32 txagc[MAX_RATES_LENGTH]; +}; + +struct setagcctrl_parm { + u32 agcctrl; /* 0: pure hw, 1: fw */ +}; + +struct setssup_parm { + u32 ss_ForceUp[MAX_RATES_LENGTH]; +}; + +struct getssup_parm { + u32 rsvd; +}; + +struct getssup_rsp { + u8 ss_ForceUp[MAX_RATES_LENGTH]; +}; + +struct setssdlevel_parm { + u8 ss_DLevel[MAX_RATES_LENGTH]; +}; + +struct getssdlevel_parm { + u32 rsvd; +}; + +struct getssdlevel_rsp { + u8 ss_DLevel[MAX_RATES_LENGTH]; +}; + +struct setssulevel_parm { + u8 ss_ULevel[MAX_RATES_LENGTH]; +}; + +struct getssulevel_parm { + u32 rsvd; +}; + +struct getssulevel_rsp { + u8 ss_ULevel[MAX_RATES_LENGTH]; +}; + +struct setcountjudge_parm { + u8 count_judge[MAX_RATES_LENGTH]; +}; + +struct getcountjudge_parm { + u32 rsvd; +}; + +struct getcountjudge_rsp { + u8 count_judge[MAX_RATES_LENGTH]; +}; + +struct setratable_parm { + u8 ss_ForceUp[NumRates]; + u8 ss_ULevel[NumRates]; + u8 ss_DLevel[NumRates]; + u8 count_judge[NumRates]; +}; + +struct getratable_parm { + uint rsvd; +}; + +struct getratable_rsp { + u8 ss_ForceUp[NumRates]; + u8 ss_ULevel[NumRates]; + u8 ss_DLevel[NumRates]; + u8 count_judge[NumRates]; +}; + +/* to get TX,RX retry count */ + +struct gettxretrycnt_parm { + unsigned int rsvd; +}; + +struct gettxretrycnt_rsp { + unsigned long tx_retrycnt; +}; + +struct getrxretrycnt_parm { + unsigned int rsvd; +}; + +struct getrxretrycnt_rsp { + unsigned long rx_retrycnt; +}; + +/* to get BCNOK,BCNERR count */ +struct getbcnokcnt_parm { + unsigned int rsvd; +}; + +struct getbcnokcnt_rsp { + unsigned long bcnokcnt; +}; + +struct getbcnerrcnt_parm { + unsigned int rsvd; +}; + +struct getbcnerrcnt_rsp { + unsigned long bcnerrcnt; +}; + +/* to get current TX power level */ +struct getcurtxpwrlevel_parm { + unsigned int rsvd; +}; +struct getcurtxpwrlevel_rspi { + unsigned short tx_power; +}; + +struct setprobereqextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct setassocreqextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct setproberspextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct setassocrspextraie_parm { + unsigned char e_id; + unsigned char ie_len; + unsigned char ie[0]; +}; + +struct addBaReq_parm { + unsigned int tid; + u8 addr[ETH_ALEN]; +}; + +/*H2C Handler index: 46 */ +struct set_ch_parm { + u8 ch; + u8 bw; + u8 ch_offset; +}; + +/*H2C Handler index: 59 */ +struct SetChannelPlan_param +{ + u8 channel_plan; +}; + +/*H2C Handler index: 60 */ +struct LedBlink_param +{ + struct LED_871x *pLed; +}; + +/*H2C Handler index: 61 */ +struct SetChannelSwitch_param +{ + u8 new_ch_no; +}; + +/*H2C Handler index: 62 */ +struct TDLSoption_param +{ + u8 addr[ETH_ALEN]; + u8 option; +}; + +#define GEN_CMD_CODE(cmd) cmd ## _CMD_ + +/* + +Result: +0x00: success +0x01: success, and check Response. +0x02: cmd ignored due to duplicated sequcne number +0x03: cmd dropped due to invalid cmd code +0x04: reserved. + +*/ + +#define H2C_RSP_OFFSET 512 + +#define H2C_SUCCESS 0x00 +#define H2C_SUCCESS_RSP 0x01 +#define H2C_DUPLICATED 0x02 +#define H2C_DROPPED 0x03 +#define H2C_PARAMETERS_ERROR 0x04 +#define H2C_REJECTED 0x05 +#define H2C_CMD_OVERFLOW 0x06 +#define H2C_RESERVED 0x07 + +u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr); +u8 rtw_setstandby_cmd(struct adapter *padapter, uint action); +u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, + int ssid_num, struct rtw_ieee80211_channel *ch, + int ch_num); +u8 rtw_createbss_cmd(struct adapter *padapter); +u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, + unsigned int sz); +u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch); +u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key); +u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue); +u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network* pnetwork); +u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue); +u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype); +u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset); +u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset); +u8 rtw_setbbreg_cmd(struct adapter * padapter, u8 offset, u8 val); +u8 rtw_setrfreg_cmd(struct adapter * padapter, u8 offset, u32 val); +u8 rtw_getbbreg_cmd(struct adapter * padapter, u8 offset, u8 * pval); +u8 rtw_getrfreg_cmd(struct adapter * padapter, u8 offset, u8 * pval); +u8 rtw_setrfintfs_cmd(struct adapter *padapter, u8 mode); +u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_table); +u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval); + +u8 rtw_gettssi_cmd(struct adapter *padapter, u8 offset,u8 *pval); +u8 rtw_setfwdig_cmd(struct adapter*padapter, u8 type); +u8 rtw_setfwra_cmd(struct adapter*padapter, u8 type); + +u8 rtw_addbareq_cmd(struct adapter*padapter, u8 tid, u8 *addr); + +u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter); + +u8 rtw_lps_ctrl_wk_cmd(struct adapter*padapter, u8 lps_ctrl_type, u8 enqueue); +u8 rtw_rpt_timer_cfg_cmd(struct adapter*padapter, u16 minRptTime); + + u8 rtw_antenna_select_cmd(struct adapter*padapter, u8 antenna,u8 enqueue); +u8 rtw_ps_cmd(struct adapter*padapter); + +#ifdef CONFIG_88EU_AP_MODE +u8 rtw_chk_hi_queue_cmd(struct adapter*padapter); +#endif + +u8 rtw_set_ch_cmd(struct adapter*padapter, u8 ch, u8 bw, u8 ch_offset, u8 enqueue); +u8 rtw_set_chplan_cmd(struct adapter*padapter, u8 chplan, u8 enqueue); +u8 rtw_led_blink_cmd(struct adapter*padapter, struct LED_871x * pLed); +u8 rtw_set_csa_cmd(struct adapter*padapter, u8 new_ch_no); +u8 rtw_tdls_cmd(struct adapter *padapter, u8 *addr, u8 option); + +u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt); + +u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf); + +void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); +void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); +void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); +void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd); +void rtw_getbbrfreg_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); +void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); + +void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); +void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm); +void rtw_getrttbl_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); + +struct _cmd_callback { + u32 cmd_code; + void (*callback)(struct adapter *padapter, struct cmd_obj *cmd); +}; + +enum rtw_h2c_cmd { + GEN_CMD_CODE(_Read_MACREG), /*0*/ + GEN_CMD_CODE(_Write_MACREG), + GEN_CMD_CODE(_Read_BBREG), + GEN_CMD_CODE(_Write_BBREG), + GEN_CMD_CODE(_Read_RFREG), + GEN_CMD_CODE(_Write_RFREG), /*5*/ + GEN_CMD_CODE(_Read_EEPROM), + GEN_CMD_CODE(_Write_EEPROM), + GEN_CMD_CODE(_Read_EFUSE), + GEN_CMD_CODE(_Write_EFUSE), + + GEN_CMD_CODE(_Read_CAM), /*10*/ + GEN_CMD_CODE(_Write_CAM), + GEN_CMD_CODE(_setBCNITV), + GEN_CMD_CODE(_setMBIDCFG), + GEN_CMD_CODE(_JoinBss), /*14*/ + GEN_CMD_CODE(_DisConnect), /*15*/ + GEN_CMD_CODE(_CreateBss), + GEN_CMD_CODE(_SetOpMode), + GEN_CMD_CODE(_SiteSurvey), /*18*/ + GEN_CMD_CODE(_SetAuth), + + GEN_CMD_CODE(_SetKey), /*20*/ + GEN_CMD_CODE(_SetStaKey), + GEN_CMD_CODE(_SetAssocSta), + GEN_CMD_CODE(_DelAssocSta), + GEN_CMD_CODE(_SetStaPwrState), + GEN_CMD_CODE(_SetBasicRate), /*25*/ + GEN_CMD_CODE(_GetBasicRate), + GEN_CMD_CODE(_SetDataRate), + GEN_CMD_CODE(_GetDataRate), + GEN_CMD_CODE(_SetPhyInfo), + + GEN_CMD_CODE(_GetPhyInfo), /*30*/ + GEN_CMD_CODE(_SetPhy), + GEN_CMD_CODE(_GetPhy), + GEN_CMD_CODE(_readRssi), + GEN_CMD_CODE(_readGain), + GEN_CMD_CODE(_SetAtim), /*35*/ + GEN_CMD_CODE(_SetPwrMode), + GEN_CMD_CODE(_JoinbssRpt), + GEN_CMD_CODE(_SetRaTable), + GEN_CMD_CODE(_GetRaTable), + + GEN_CMD_CODE(_GetCCXReport), /*40*/ + GEN_CMD_CODE(_GetDTMReport), + GEN_CMD_CODE(_GetTXRateStatistics), + GEN_CMD_CODE(_SetUsbSuspend), + GEN_CMD_CODE(_SetH2cLbk), + GEN_CMD_CODE(_AddBAReq), /*45*/ + GEN_CMD_CODE(_SetChannel), /*46*/ + GEN_CMD_CODE(_SetTxPower), + GEN_CMD_CODE(_SwitchAntenna), + GEN_CMD_CODE(_SetCrystalCap), + GEN_CMD_CODE(_SetSingleCarrierTx), /*50*/ + + GEN_CMD_CODE(_SetSingleToneTx),/*51*/ + GEN_CMD_CODE(_SetCarrierSuppressionTx), + GEN_CMD_CODE(_SetContinuousTx), + GEN_CMD_CODE(_SwitchBandwidth), /*54*/ + GEN_CMD_CODE(_TX_Beacon), /*55*/ + + GEN_CMD_CODE(_Set_MLME_EVT), /*56*/ + GEN_CMD_CODE(_Set_Drv_Extra), /*57*/ + GEN_CMD_CODE(_Set_H2C_MSG), /*58*/ + + GEN_CMD_CODE(_SetChannelPlan), /*59*/ + GEN_CMD_CODE(_LedBlink), /*60*/ + + GEN_CMD_CODE(_SetChannelSwitch), /*61*/ + GEN_CMD_CODE(_TDLS), /*62*/ + + MAX_H2CCMD +}; + +#define _GetBBReg_CMD_ _Read_BBREG_CMD_ +#define _SetBBReg_CMD_ _Write_BBREG_CMD_ +#define _GetRFReg_CMD_ _Read_RFREG_CMD_ +#define _SetRFReg_CMD_ _Write_RFREG_CMD_ + +#ifdef _RTW_CMD_C_ +static struct _cmd_callback rtw_cmd_callback[] = +{ + {GEN_CMD_CODE(_Read_MACREG), NULL}, /*0*/ + {GEN_CMD_CODE(_Write_MACREG), NULL}, + {GEN_CMD_CODE(_Read_BBREG), &rtw_getbbrfreg_cmdrsp_callback}, + {GEN_CMD_CODE(_Write_BBREG), NULL}, + {GEN_CMD_CODE(_Read_RFREG), &rtw_getbbrfreg_cmdrsp_callback}, + {GEN_CMD_CODE(_Write_RFREG), NULL}, /*5*/ + {GEN_CMD_CODE(_Read_EEPROM), NULL}, + {GEN_CMD_CODE(_Write_EEPROM), NULL}, + {GEN_CMD_CODE(_Read_EFUSE), NULL}, + {GEN_CMD_CODE(_Write_EFUSE), NULL}, + + {GEN_CMD_CODE(_Read_CAM), NULL}, /*10*/ + {GEN_CMD_CODE(_Write_CAM), NULL}, + {GEN_CMD_CODE(_setBCNITV), NULL}, + {GEN_CMD_CODE(_setMBIDCFG), NULL}, + {GEN_CMD_CODE(_JoinBss), &rtw_joinbss_cmd_callback}, /*14*/ + {GEN_CMD_CODE(_DisConnect), &rtw_disassoc_cmd_callback}, /*15*/ + {GEN_CMD_CODE(_CreateBss), &rtw_createbss_cmd_callback}, + {GEN_CMD_CODE(_SetOpMode), NULL}, + {GEN_CMD_CODE(_SiteSurvey), &rtw_survey_cmd_callback}, /*18*/ + {GEN_CMD_CODE(_SetAuth), NULL}, + + {GEN_CMD_CODE(_SetKey), NULL}, /*20*/ + {GEN_CMD_CODE(_SetStaKey), &rtw_setstaKey_cmdrsp_callback}, + {GEN_CMD_CODE(_SetAssocSta), &rtw_setassocsta_cmdrsp_callback}, + {GEN_CMD_CODE(_DelAssocSta), NULL}, + {GEN_CMD_CODE(_SetStaPwrState), NULL}, + {GEN_CMD_CODE(_SetBasicRate), NULL}, /*25*/ + {GEN_CMD_CODE(_GetBasicRate), NULL}, + {GEN_CMD_CODE(_SetDataRate), NULL}, + {GEN_CMD_CODE(_GetDataRate), NULL}, + {GEN_CMD_CODE(_SetPhyInfo), NULL}, + + {GEN_CMD_CODE(_GetPhyInfo), NULL}, /*30*/ + {GEN_CMD_CODE(_SetPhy), NULL}, + {GEN_CMD_CODE(_GetPhy), NULL}, + {GEN_CMD_CODE(_readRssi), NULL}, + {GEN_CMD_CODE(_readGain), NULL}, + {GEN_CMD_CODE(_SetAtim), NULL}, /*35*/ + {GEN_CMD_CODE(_SetPwrMode), NULL}, + {GEN_CMD_CODE(_JoinbssRpt), NULL}, + {GEN_CMD_CODE(_SetRaTable), NULL}, + {GEN_CMD_CODE(_GetRaTable), NULL}, + + {GEN_CMD_CODE(_GetCCXReport), NULL}, /*40*/ + {GEN_CMD_CODE(_GetDTMReport), NULL}, + {GEN_CMD_CODE(_GetTXRateStatistics), NULL}, + {GEN_CMD_CODE(_SetUsbSuspend), NULL}, + {GEN_CMD_CODE(_SetH2cLbk), NULL}, + {GEN_CMD_CODE(_AddBAReq), NULL}, /*45*/ + {GEN_CMD_CODE(_SetChannel), NULL}, /*46*/ + {GEN_CMD_CODE(_SetTxPower), NULL}, + {GEN_CMD_CODE(_SwitchAntenna), NULL}, + {GEN_CMD_CODE(_SetCrystalCap), NULL}, + {GEN_CMD_CODE(_SetSingleCarrierTx), NULL}, /*50*/ + + {GEN_CMD_CODE(_SetSingleToneTx), NULL}, /*51*/ + {GEN_CMD_CODE(_SetCarrierSuppressionTx), NULL}, + {GEN_CMD_CODE(_SetContinuousTx), NULL}, + {GEN_CMD_CODE(_SwitchBandwidth), NULL}, /*54*/ + {GEN_CMD_CODE(_TX_Beacon), NULL},/*55*/ + + {GEN_CMD_CODE(_Set_MLME_EVT), NULL},/*56*/ + {GEN_CMD_CODE(_Set_Drv_Extra), NULL},/*57*/ + {GEN_CMD_CODE(_Set_H2C_MSG), NULL},/*58*/ + {GEN_CMD_CODE(_SetChannelPlan), NULL},/*59*/ + {GEN_CMD_CODE(_LedBlink), NULL},/*60*/ + + {GEN_CMD_CODE(_SetChannelSwitch), NULL},/*61*/ + {GEN_CMD_CODE(_TDLS), NULL},/*62*/ +}; +#endif + +#endif /* _CMD_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_debug.h b/drivers/staging/r8188eu/include/rtw_debug.h new file mode 100644 index 000000000000..d94639a8dc63 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_debug.h @@ -0,0 +1,274 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_DEBUG_H__ +#define __RTW_DEBUG_H__ + +#include +#include + +#define _drv_always_ 1 +#define _drv_emerg_ 2 +#define _drv_alert_ 3 +#define _drv_crit_ 4 +#define _drv_err_ 5 +#define _drv_warning_ 6 +#define _drv_notice_ 7 +#define _drv_info_ 8 +#define _drv_debug_ 9 + +#define _module_rtl871x_xmit_c_ BIT(0) +#define _module_xmit_osdep_c_ BIT(1) +#define _module_rtl871x_recv_c_ BIT(2) +#define _module_recv_osdep_c_ BIT(3) +#define _module_rtl871x_mlme_c_ BIT(4) +#define _module_mlme_osdep_c_ BIT(5) +#define _module_rtl871x_sta_mgt_c_ BIT(6) +#define _module_rtl871x_cmd_c_ BIT(7) +#define _module_cmd_osdep_c_ BIT(8) +#define _module_rtl871x_io_c_ BIT(9) +#define _module_io_osdep_c_ BIT(10) +#define _module_os_intfs_c_ BIT(11) +#define _module_rtl871x_security_c_ BIT(12) +#define _module_rtl871x_eeprom_c_ BIT(13) +#define _module_hal_init_c_ BIT(14) +#define _module_hci_hal_init_c_ BIT(15) +#define _module_rtl871x_ioctl_c_ BIT(16) +#define _module_rtl871x_ioctl_set_c_ BIT(17) +#define _module_rtl871x_ioctl_query_c_ BIT(18) +#define _module_rtl871x_pwrctrl_c_ BIT(19) +#define _module_hci_intfs_c_ BIT(20) +#define _module_hci_ops_c_ BIT(21) +#define _module_osdep_service_c_ BIT(22) +#define _module_mp_ BIT(23) +#define _module_hci_ops_os_c_ BIT(24) +#define _module_rtl871x_ioctl_os_c BIT(25) +#define _module_rtl8712_cmd_c_ BIT(26) +#define _module_rtl8192c_xmit_c_ BIT(27) +#define _module_hal_xmit_c_ BIT(28) +#define _module_efuse_ BIT(29) +#define _module_rtl8712_recv_c_ BIT(30) +#define _module_rtl8712_led_c_ BIT(31) + +#define DRIVER_PREFIX "R8188EU: " + +extern u32 GlobalDebugLevel; + +#define DBG_88E_LEVEL(_level, fmt, arg...) \ + do { \ + if (_level <= GlobalDebugLevel) \ + pr_info(DRIVER_PREFIX"INFO " fmt, ##arg); \ + } while (0) + +#define DBG_88E(...) \ + do { \ + if (_drv_err_ <= GlobalDebugLevel) \ + pr_info(DRIVER_PREFIX __VA_ARGS__); \ + } while (0) + +#define MSG_88E(...) \ + do { \ + if (_drv_err_ <= GlobalDebugLevel) \ + pr_info(DRIVER_PREFIX __VA_ARGS__); \ + } while (0) + +#define RT_TRACE(_comp, _level, fmt) \ + do { \ + if (_level <= GlobalDebugLevel) { \ + pr_info("%s [0x%08x,%d]", DRIVER_PREFIX, \ + (unsigned int)_comp, _level); \ + pr_info fmt; \ + } \ + } while (0) + +#define RT_PRINT_DATA(_comp, _level, _titlestring, _hexdata, _hexdatalen)\ + do { \ + if (_level <= GlobalDebugLevel) { \ + int __i; \ + u8 *ptr = (u8 *)_hexdata; \ + pr_info("%s", DRIVER_PREFIX); \ + pr_info(_titlestring); \ + for (__i = 0; __i < (int)_hexdatalen; __i++ ) { \ + pr_info("%02X%s", ptr[__i], \ + (((__i + 1) % 4) == 0) ? \ + " " : " "); \ + if (((__i + 1) % 16) == 0) \ + printk("\n"); \ + } \ + printk("\n"); \ + } \ + } while (0) + +int proc_get_drv_version(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_write_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_write_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data); +int proc_get_read_reg(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_read_reg(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_fwstate(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_sec_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_mlmext_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_qos_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_ht_option(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_rf_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); +int proc_get_ap_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_adapter_state(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_trx_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_mac_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_mac_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_mac_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_bb_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_bb_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_bb_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump1(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump2(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump3(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rf_reg_dump4(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +#ifdef CONFIG_88EU_AP_MODE + +int proc_get_all_sta_info(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +#endif + +int proc_get_best_channel(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rx_signal(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_rx_signal(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_ht_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_ht_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_cbw40_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_cbw40_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_ampdu_enable(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_ampdu_enable(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_rx_stbc(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_rx_stbc(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +int proc_get_two_path_rssi(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_get_rssi_disp(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_rssi_disp(struct file *file, const char __user *buffer, + unsigned long count, void *data); + +#ifdef CONFIG_BT_COEXIST +int proc_get_btcoex_dbg(char *page, char **start, + off_t offset, int count, + int *eof, void *data); + +int proc_set_btcoex_dbg(struct file *file, const char *buffer, + signed long count, void *data); + +#endif /* CONFIG_BT_COEXIST */ + +#endif /* __RTW_DEBUG_H__ */ diff --git a/drivers/staging/r8188eu/include/rtw_eeprom.h b/drivers/staging/r8188eu/include/rtw_eeprom.h new file mode 100644 index 000000000000..0b27eb7325c5 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_eeprom.h @@ -0,0 +1,130 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_EEPROM_H__ +#define __RTW_EEPROM_H__ + +#include +#include + +#define RTL8712_EEPROM_ID 0x8712 + +#define HWSET_MAX_SIZE_512 512 +#define EEPROM_MAX_SIZE HWSET_MAX_SIZE_512 + +#define CLOCK_RATE 50 /* 100us */ + +/* EEPROM opcodes */ +#define EEPROM_READ_OPCODE 06 +#define EEPROM_WRITE_OPCODE 05 +#define EEPROM_ERASE_OPCODE 07 +#define EEPROM_EWEN_OPCODE 19 /* Erase/write enable */ +#define EEPROM_EWDS_OPCODE 16 /* Erase/write disable */ + +/* Country codes */ +#define USA 0x555320 +#define EUROPE 0x1 /* temp, should be provided later */ +#define JAPAN 0x2 /* temp, should be provided later */ + +#define EEPROM_CID_DEFAULT 0x0 +#define EEPROM_CID_ALPHA 0x1 +#define EEPROM_CID_Senao 0x3 +#define EEPROM_CID_NetCore 0x5 +#define EEPROM_CID_CAMEO 0X8 +#define EEPROM_CID_SITECOM 0x9 +#define EEPROM_CID_COREGA 0xB +#define EEPROM_CID_EDIMAX_BELK 0xC +#define EEPROM_CID_SERCOMM_BELK 0xE +#define EEPROM_CID_CAMEO1 0xF +#define EEPROM_CID_WNC_COREGA 0x12 +#define EEPROM_CID_CLEVO 0x13 +#define EEPROM_CID_WHQL 0xFE + +/* Customer ID, note that: */ +/* This variable is initiailzed through EEPROM or registry, */ +/* however, its definition may be different with that in EEPROM for */ +/* EEPROM size consideration. So, we have to perform proper translation + * between them. */ +/* Besides, CustomerID of registry has precedence of that of EEPROM. */ +/* defined below. 060703, by rcnjko. */ +enum RT_CUSTOMER_ID { + RT_CID_DEFAULT = 0, + RT_CID_8187_ALPHA0 = 1, + RT_CID_8187_SERCOMM_PS = 2, + RT_CID_8187_HW_LED = 3, + RT_CID_8187_NETGEAR = 4, + RT_CID_WHQL = 5, + RT_CID_819x_CAMEO = 6, + RT_CID_819x_RUNTOP = 7, + RT_CID_819x_Senao = 8, + RT_CID_TOSHIBA = 9, /* Merge by Jacken, 2008/01/31. */ + RT_CID_819x_Netcore = 10, + RT_CID_Nettronix = 11, + RT_CID_DLINK = 12, + RT_CID_PRONET = 13, + RT_CID_COREGA = 14, + RT_CID_CHINA_MOBILE = 15, + RT_CID_819x_ALPHA = 16, + RT_CID_819x_Sitecom = 17, + RT_CID_CCX = 18, /* It's set under CCX logo test and isn't demanded + * for CCX functions, but for test behavior like retry + * limit and tx report. By Bruce, 2009-02-17. */ + RT_CID_819x_Lenovo = 19, + RT_CID_819x_QMI = 20, + RT_CID_819x_Edimax_Belkin = 21, + RT_CID_819x_Sercomm_Belkin = 22, + RT_CID_819x_CAMEO1 = 23, + RT_CID_819x_MSI = 24, + RT_CID_819x_Acer = 25, + RT_CID_819x_AzWave_ASUS = 26, + RT_CID_819x_AzWave = 27, /* For AzWave in PCIe,i + * The ID is AzWave use and not only Asus */ + RT_CID_819x_HP = 28, + RT_CID_819x_WNC_COREGA = 29, + RT_CID_819x_Arcadyan_Belkin = 30, + RT_CID_819x_SAMSUNG = 31, + RT_CID_819x_CLEVO = 32, + RT_CID_819x_DELL = 33, + RT_CID_819x_PRONETS = 34, + RT_CID_819x_Edimax_ASUS = 35, + RT_CID_819x_CAMEO_NETGEAR = 36, + RT_CID_PLANEX = 37, + RT_CID_CC_C = 38, + RT_CID_819x_Xavi = 39, + RT_CID_819x_FUNAI_TV = 40, + RT_CID_819x_ALPHA_WD=41, +}; + +struct eeprom_priv { + u8 bautoload_fail_flag; + u8 bloadfile_fail_flag; + u8 bloadmac_fail_flag; + u8 mac_addr[6]; /* PermanentAddress */ + u16 channel_plan; + u8 EepromOrEfuse; + u8 efuse_eeprom_data[HWSET_MAX_SIZE_512] __aligned(4); +}; + +void eeprom_write16(struct adapter *padapter, u16 reg, u16 data); +u16 eeprom_read16(struct adapter *padapter, u16 reg); +void read_eeprom_content(struct adapter *padapter); +void eeprom_read_sz(struct adapter *adapt, u16 reg, u8 *data, u32 sz); +void read_eeprom_content_by_attrib(struct adapter *padapter); + +#endif /* __RTL871X_EEPROM_H__ */ diff --git a/drivers/staging/r8188eu/include/rtw_efuse.h b/drivers/staging/r8188eu/include/rtw_efuse.h new file mode 100644 index 000000000000..cee6b5e8b070 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_efuse.h @@ -0,0 +1,150 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_EFUSE_H__ +#define __RTW_EFUSE_H__ + +#include + +#define EFUSE_ERROE_HANDLE 1 + +#define PG_STATE_HEADER 0x01 +#define PG_STATE_WORD_0 0x02 +#define PG_STATE_WORD_1 0x04 +#define PG_STATE_WORD_2 0x08 +#define PG_STATE_WORD_3 0x10 +#define PG_STATE_DATA 0x20 + +#define PG_SWBYTE_H 0x01 +#define PG_SWBYTE_L 0x02 + +#define PGPKT_DATA_SIZE 8 + +#define EFUSE_WIFI 0 +#define EFUSE_BT 1 + +enum _EFUSE_DEF_TYPE { + TYPE_EFUSE_MAX_SECTION = 0, + TYPE_EFUSE_REAL_CONTENT_LEN = 1, + TYPE_AVAILABLE_EFUSE_BYTES_BANK = 2, + TYPE_AVAILABLE_EFUSE_BYTES_TOTAL = 3, + TYPE_EFUSE_MAP_LEN = 4, + TYPE_EFUSE_PROTECT_BYTES_BANK = 5, + TYPE_EFUSE_CONTENT_LEN_BANK = 6, +}; + +/* E-Fuse */ +#define EFUSE_MAP_SIZE 512 +#define EFUSE_MAX_SIZE 256 +/* end of E-Fuse */ + +#define EFUSE_MAX_MAP_LEN 512 +#define EFUSE_MAX_HW_SIZE 512 +#define EFUSE_MAX_SECTION_BASE 16 + +#define EXT_HEADER(header) ((header & 0x1F) == 0x0F) +#define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F) +#define GET_HDR_OFFSET_2_0(header) ((header & 0xE0) >> 5) + +#define EFUSE_REPEAT_THRESHOLD_ 3 + +/* The following is for BT Efuse definition */ +#define EFUSE_BT_MAX_MAP_LEN 1024 +#define EFUSE_MAX_BANK 4 +#define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK-1) +/*--------------------------Define Parameters-------------------------------*/ +#define EFUSE_MAX_WORD_UNIT 4 + +/*------------------------------Define structure----------------------------*/ +struct pgpkt { + u8 offset; + u8 word_en; + u8 data[8]; + u8 word_cnts; +}; + +/*------------------------------Define structure----------------------------*/ +struct efuse_hal { + u8 fakeEfuseBank; + u32 fakeEfuseUsedBytes; + u8 fakeEfuseContent[EFUSE_MAX_HW_SIZE]; + u8 fakeEfuseInitMap[EFUSE_MAX_MAP_LEN]; + u8 fakeEfuseModifiedMap[EFUSE_MAX_MAP_LEN]; + + u16 BTEfuseUsedBytes; + u8 BTEfuseUsedPercentage; + u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; + u8 BTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]; + u8 BTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; + + u16 fakeBTEfuseUsedBytes; + u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; + u8 fakeBTEfuseInitMap[EFUSE_BT_MAX_MAP_LEN]; + u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN]; +}; + +/*------------------------Export global variable----------------------------*/ +extern u8 fakeEfuseBank; +extern u32 fakeEfuseUsedBytes; +extern u8 fakeEfuseContent[]; +extern u8 fakeEfuseInitMap[]; +extern u8 fakeEfuseModifiedMap[]; + +extern u32 BTEfuseUsedBytes; +extern u8 BTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +extern u8 BTEfuseInitMap[]; +extern u8 BTEfuseModifiedMap[]; + +extern u32 fakeBTEfuseUsedBytes; +extern u8 fakeBTEfuseContent[EFUSE_MAX_BT_BANK][EFUSE_MAX_HW_SIZE]; +extern u8 fakeBTEfuseInitMap[]; +extern u8 fakeBTEfuseModifiedMap[]; +/*------------------------Export global variable----------------------------*/ + +u8 efuse_GetCurrentSize(struct adapter *adapter, u16 *size); +u16 efuse_GetMaxSize(struct adapter *adapter); +u8 rtw_efuse_access(struct adapter *adapter, u8 read, u16 start_addr, + u16 cnts, u8 *data); +u8 rtw_efuse_map_read(struct adapter *adapter, u16 addr, u16 cnts, u8 *data); +u8 rtw_efuse_map_write(struct adapter *adapter, u16 addr, u16 cnts, u8 *data); +u8 rtw_BT_efuse_map_read(struct adapter *adapter, u16 addr, + u16 cnts, u8 *data); +u8 rtw_BT_efuse_map_write(struct adapter *adapter, u16 addr, + u16 cnts, u8 *data); +u16 Efuse_GetCurrentSize(struct adapter *adapter, u8 efusetype, bool test); +u8 Efuse_CalculateWordCnts(u8 word_en); +void ReadEFuseByte(struct adapter *adapter, u16 _offset, u8 *pbuf, bool test); +void EFUSE_GetEfuseDefinition(struct adapter *adapt, u8 type, u8 type1, + void *out, bool bPseudoTest); +u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data, bool test); +u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data, bool test); + +void Efuse_PowerSwitch(struct adapter *adapt,u8 bWrite,u8 PwrState); +int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data, bool test); +int Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data, + bool test); +void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); +u8 Efuse_WordEnableDataWrite(struct adapter *adapter, u16 efuse_addr, + u8 word_en, u8 *data, bool test); + +u8 EFUSE_Read1Byte(struct adapter *adapter, u16 address); +void EFUSE_ShadowMapUpdate(struct adapter *adapter, u8 efusetype, bool test); +void EFUSE_ShadowRead(struct adapter *adapt, u8 type, u16 offset, u32 *val); + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_event.h b/drivers/staging/r8188eu/include/rtw_event.h new file mode 100644 index 000000000000..f7004d6a3bbb --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_event.h @@ -0,0 +1,113 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_EVENT_H_ +#define _RTW_EVENT_H_ + +#include + +#include +#include +#include + +/* +Used to report a bss has been scanned +*/ +struct survey_event { + struct wlan_bssid_ex bss; +}; + +/* +Used to report that the requested site survey has been done. + +bss_cnt indicates the number of bss that has been reported. + +*/ +struct surveydone_event { + unsigned int bss_cnt; + +}; + +/* +Used to report the link result of joinning the given bss + +join_res: +-1: authentication fail +-2: association fail +> 0: TID + +*/ +struct joinbss_event { + struct wlan_network network; +}; + +/* +Used to report a given STA has joinned the created BSS. +It is used in AP/Ad-HoC(M) mode. +*/ + +struct stassoc_event { + unsigned char macaddr[6]; + unsigned char rsvd[2]; + int cam_id; +}; + +struct stadel_event { + unsigned char macaddr[6]; + unsigned char rsvd[2]; /* for reason */ + int mac_id; +}; + +struct addba_event { + unsigned int tid; +}; + +#define GEN_EVT_CODE(event) event ## _EVT_ + +struct fwevent { + u32 parmsize; + void (*event_callback)(struct adapter *dev, u8 *pbuf); +}; + +#define C2HEVENT_SZ 32 + +struct event_node { + unsigned char *node; + unsigned char evt_code; + unsigned short evt_sz; + int *caller_ff_tail; + int caller_ff_sz; +}; + +struct c2hevent_queue { + int head; + int tail; + struct event_node nodes[C2HEVENT_SZ]; + unsigned char seq; +}; + +#define NETWORK_QUEUE_SZ 4 + +struct network_queue { + int head; + int tail; + struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ]; +}; + +#endif /* _WLANEVENT_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_ht.h b/drivers/staging/r8188eu/include/rtw_ht.h new file mode 100644 index 000000000000..80154224af92 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_ht.h @@ -0,0 +1,44 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_HT_H_ +#define _RTW_HT_H_ + +#include +#include "wifi.h" + +struct ht_priv { + u32 ht_option; + u32 ampdu_enable;/* for enable Tx A-MPDU */ + u32 tx_amsdu_enable;/* for enable Tx A-MSDU */ + u32 tx_amdsu_maxlen; /* 1: 8k, 0:4k ; default:8k, for tx */ + u32 rx_ampdu_maxlen; /* for rx reordering ctrl win_sz, + * updated when join_callback. */ + u8 bwmode;/* */ + u8 ch_offset;/* PRIME_CHNL_OFFSET */ + u8 sgi;/* short GI */ + + /* for processing Tx A-MPDU */ + u8 agg_enable_bitmap; + u8 candidate_tid_bitmap; + + struct ieee80211_ht_cap ht_cap; +}; + +#endif /* _RTL871X_HT_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_io.h b/drivers/staging/r8188eu/include/rtw_io.h new file mode 100644 index 000000000000..d7dee537c252 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_io.h @@ -0,0 +1,387 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ + +#ifndef _RTW_IO_H_ +#define _RTW_IO_H_ + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include + +#define rtw_usb_buffer_alloc(dev, size, dma) \ + usb_alloc_coherent((dev), (size), (in_interrupt() ? \ + GFP_ATOMIC : GFP_KERNEL), (dma)) +#define rtw_usb_buffer_free(dev, size, addr, dma) \ + usb_free_coherent((dev), (size), (addr), (dma)) + +#define NUM_IOREQ 8 + +#define MAX_PROT_SZ (64-16) + +#define _IOREADY 0 +#define _IO_WAIT_COMPLETE 1 +#define _IO_WAIT_RSP 2 + +/* IO COMMAND TYPE */ +#define _IOSZ_MASK_ (0x7F) +#define _IO_WRITE_ BIT(7) +#define _IO_FIXED_ BIT(8) +#define _IO_BURST_ BIT(9) +#define _IO_BYTE_ BIT(10) +#define _IO_HW_ BIT(11) +#define _IO_WORD_ BIT(12) +#define _IO_SYNC_ BIT(13) +#define _IO_CMDMASK_ (0x1F80) + +/* + For prompt mode accessing, caller shall free io_req + Otherwise, io_handler will free io_req +*/ + +/* IO STATUS TYPE */ +#define _IO_ERR_ BIT(2) +#define _IO_SUCCESS_ BIT(1) +#define _IO_DONE_ BIT(0) + +#define IO_RD32 (_IO_SYNC_ | _IO_WORD_) +#define IO_RD16 (_IO_SYNC_ | _IO_HW_) +#define IO_RD8 (_IO_SYNC_ | _IO_BYTE_) + +#define IO_RD32_ASYNC (_IO_WORD_) +#define IO_RD16_ASYNC (_IO_HW_) +#define IO_RD8_ASYNC (_IO_BYTE_) + +#define IO_WR32 (_IO_WRITE_ | _IO_SYNC_ | _IO_WORD_) +#define IO_WR16 (_IO_WRITE_ | _IO_SYNC_ | _IO_HW_) +#define IO_WR8 (_IO_WRITE_ | _IO_SYNC_ | _IO_BYTE_) + +#define IO_WR32_ASYNC (_IO_WRITE_ | _IO_WORD_) +#define IO_WR16_ASYNC (_IO_WRITE_ | _IO_HW_) +#define IO_WR8_ASYNC (_IO_WRITE_ | _IO_BYTE_) + +/* + Only Sync. burst accessing is provided. +*/ + +#define IO_WR_BURST(x) \ + (_IO_WRITE_ | _IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_)) +#define IO_RD_BURST(x) \ + (_IO_SYNC_ | _IO_BURST_ | ((x) & _IOSZ_MASK_)) + +/* below is for the intf_option bit defition... */ + +#define _INTF_ASYNC_ BIT(0) /* support async io */ + +struct intf_priv; +struct intf_hdl; +struct io_queue; + +struct _io_ops { + u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); + u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); + int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, + u8 *pdata); + int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); + int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); + int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); + void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + void (*_sync_irp_protocol_rw)(struct io_queue *pio_q); + u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); + u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, + u8 *pmem); + u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem); + void (*_read_port_cancel)(struct intf_hdl *pintfhdl); + void (*_write_port_cancel)(struct intf_hdl *pintfhdl); +}; + +struct io_req { + struct list_head list; + u32 addr; + u32 val; + u32 command; + u32 status; + u8 *pbuf; + struct semaphore sema; + + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, u8 *cnxt); + u8 *cnxt; +}; + +struct intf_hdl { + struct adapter *padapter; + struct dvobj_priv *pintf_dev; + struct _io_ops io_ops; +}; + +struct reg_protocol_rd { +#ifdef __LITTLE_ENDIAN + /* DW1 */ + u32 NumOfTrans:4; + u32 Reserved1:4; + u32 Reserved2:24; + /* DW2 */ + u32 ByteCount:7; + u32 WriteEnable:1; /* 0:read, 1:write */ + u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */ + u32 BurstMode:1; + u32 Byte1Access:1; + u32 Byte2Access:1; + u32 Byte4Access:1; + u32 Reserved3:3; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + /* DW4 */ + /* u32 Value; */ +#else +/* DW1 */ + u32 Reserved1:4; + u32 NumOfTrans:4; + u32 Reserved2:24; + /* DW2 */ + u32 WriteEnable:1; + u32 ByteCount:7; + u32 Reserved3:3; + u32 Byte4Access:1; + + u32 Byte2Access:1; + u32 Byte1Access:1; + u32 BurstMode:1; + u32 FixOrContinuous:1; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + + /* DW4 */ +#endif +}; + +struct reg_protocol_wt { +#ifdef __LITTLE_ENDIAN + /* DW1 */ + u32 NumOfTrans:4; + u32 Reserved1:4; + u32 Reserved2:24; + /* DW2 */ + u32 ByteCount:7; + u32 WriteEnable:1; /* 0:read, 1:write */ + u32 FixOrContinuous:1; /* 0:continuous, 1: Fix */ + u32 BurstMode:1; + u32 Byte1Access:1; + u32 Byte2Access:1; + u32 Byte4Access:1; + u32 Reserved3:3; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + /* DW4 */ + u32 Value; +#else + /* DW1 */ + u32 Reserved1 :4; + u32 NumOfTrans:4; + u32 Reserved2:24; + /* DW2 */ + u32 WriteEnable:1; + u32 ByteCount:7; + u32 Reserved3:3; + u32 Byte4Access:1; + u32 Byte2Access:1; + u32 Byte1Access:1; + u32 BurstMode:1; + u32 FixOrContinuous:1; + u32 Reserved4:16; + /* DW3 */ + u32 BusAddress; + /* DW4 */ + u32 Value; +#endif +}; + +/* +Below is the data structure used by _io_handler +*/ + +struct io_queue { + spinlock_t lock; + struct list_head free_ioreqs; + struct list_head pending; /* The io_req list that will be served + * in the single protocol read/write.*/ + struct list_head processing; + u8 *free_ioreqs_buf; /* 4-byte aligned */ + u8 *pallocated_free_ioreqs_buf; + struct intf_hdl intf; +}; + +struct io_priv { + struct adapter *padapter; + struct intf_hdl intf; +}; + +uint ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); +void sync_ioreq_enqueue(struct io_req *preq,struct io_queue *ioqueue); +uint sync_ioreq_flush(struct adapter *adapter, struct io_queue *ioqueue); +uint free_ioreq(struct io_req *preq, struct io_queue *pio_queue); +struct io_req *alloc_ioreq(struct io_queue *pio_q); + +uint register_intf_hdl(u8 *dev, struct intf_hdl *pintfhdl); +void unregister_intf_hdl(struct intf_hdl *pintfhdl); + +void _rtw_attrib_read(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void _rtw_attrib_write(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + +u8 _rtw_read8(struct adapter *adapter, u32 addr); +u16 _rtw_read16(struct adapter *adapter, u32 addr); +u32 _rtw_read32(struct adapter *adapter, u32 addr); +void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void _rtw_read_port_cancel(struct adapter *adapter); + +int _rtw_write8(struct adapter *adapter, u32 addr, u8 val); +int _rtw_write16(struct adapter *adapter, u32 addr, u16 val); +int _rtw_write32(struct adapter *adapter, u32 addr, u32 val); +int _rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata); + +int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val); +int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val); +int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val); + +void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, + u8 *pmem, int timeout_ms); +void _rtw_write_port_cancel(struct adapter *adapter); + +#define rtw_read8(adapter, addr) _rtw_read8((adapter), (addr)) +#define rtw_read16(adapter, addr) _rtw_read16((adapter), (addr)) +#define rtw_read32(adapter, addr) _rtw_read32((adapter), (addr)) +#define rtw_read_mem(adapter, addr, cnt, mem) \ + _rtw_read_mem((adapter), (addr), (cnt), (mem)) +#define rtw_read_port(adapter, addr, cnt, mem) \ + _rtw_read_port((adapter), (addr), (cnt), (mem)) +#define rtw_read_port_cancel(adapter) _rtw_read_port_cancel((adapter)) + +#define rtw_write8(adapter, addr, val) \ + _rtw_write8((adapter), (addr), (val)) +#define rtw_write16(adapter, addr, val) \ + _rtw_write16((adapter), (addr), (val)) +#define rtw_write32(adapter, addr, val) \ + _rtw_write32((adapter), (addr), (val)) +#define rtw_writeN(adapter, addr, length, data) \ + _rtw_writeN((adapter), (addr), (length), (data)) +#define rtw_write8_async(adapter, addr, val) \ + _rtw_write8_async((adapter), (addr), (val)) +#define rtw_write16_async(adapter, addr, val) \ + _rtw_write16_async((adapter), (addr), (val)) +#define rtw_write32_async(adapter, addr, val) \ + _rtw_write32_async((adapter), (addr), (val)) +#define rtw_write_mem(adapter, addr, cnt, mem) \ + _rtw_write_mem((adapter), (addr), (cnt), (mem)) +#define rtw_write_port(adapter, addr, cnt, mem) \ + _rtw_write_port((adapter), (addr), (cnt), (mem)) +#define rtw_write_port_and_wait(adapter, addr, cnt, mem, timeout_ms) \ + _rtw_write_port_and_wait((adapter), (addr), (cnt), (mem), (timeout_ms)) +#define rtw_write_port_cancel(adapter) _rtw_write_port_cancel((adapter)) + +void rtw_write_scsi(struct adapter *adapter, u32 cnt, u8 *pmem); + +/* ioreq */ +void ioreq_read8(struct adapter *adapter, u32 addr, u8 *pval); +void ioreq_read16(struct adapter *adapter, u32 addr, u16 *pval); +void ioreq_read32(struct adapter *adapter, u32 addr, u32 *pval); +void ioreq_write8(struct adapter *adapter, u32 addr, u8 val); +void ioreq_write16(struct adapter *adapter, u32 addr, u16 val); +void ioreq_write32(struct adapter *adapter, u32 addr, u32 val); + +uint async_read8(struct adapter *adapter, u32 addr, u8 *pbuff, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +uint async_read16(struct adapter *adapter, u32 addr, u8 *pbuff, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +uint async_read32(struct adapter *adapter, u32 addr, u8 *pbuff, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); + +void async_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void async_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + +void async_write8(struct adapter *adapter, u32 addr, u8 val, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +void async_write16(struct adapter *adapter, u32 addr, u16 val, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); +void async_write32(struct adapter *adapter, u32 addr, u32 val, + void (*_async_io_callback)(struct adapter *padater, + struct io_req *pio_req, + u8 *cnxt), u8 *cnxt); + +void async_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); +void async_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem); + +int rtw_init_io_priv(struct adapter *padapter, + void (*set_intf_ops)(struct _io_ops *pops)); + +uint alloc_io_queue(struct adapter *adapter); +void free_io_queue(struct adapter *adapter); +void async_bus_io(struct io_queue *pio_q); +void bus_sync_io(struct io_queue *pio_q); +u32 _ioreq2rwmem(struct io_queue *pio_q); +void dev_power_down(struct adapter * Adapter, u8 bpwrup); + +#define PlatformEFIOWrite1Byte(_a,_b,_c) \ + rtw_write8(_a,_b,_c) +#define PlatformEFIOWrite2Byte(_a,_b,_c) \ + rtw_write16(_a,_b,_c) +#define PlatformEFIOWrite4Byte(_a,_b,_c) \ + rtw_write32(_a,_b,_c) + +#define PlatformEFIORead1Byte(_a,_b) \ + rtw_read8(_a,_b) +#define PlatformEFIORead2Byte(_a,_b) \ + rtw_read16(_a,_b) +#define PlatformEFIORead4Byte(_a,_b) \ + rtw_read32(_a,_b) + +#endif /* _RTL8711_IO_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_ioctl.h b/drivers/staging/r8188eu/include/rtw_ioctl.h new file mode 100644 index 000000000000..8ffa73239819 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_ioctl.h @@ -0,0 +1,120 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_IOCTL_H_ +#define _RTW_IOCTL_H_ + +#include +#include + +#ifndef OID_802_11_CAPABILITY + #define OID_802_11_CAPABILITY 0x0d010122 +#endif + +#ifndef OID_802_11_PMKID + #define OID_802_11_PMKID 0x0d010123 +#endif + +/* For DDK-defined OIDs */ +#define OID_NDIS_SEG1 0x00010100 +#define OID_NDIS_SEG2 0x00010200 +#define OID_NDIS_SEG3 0x00020100 +#define OID_NDIS_SEG4 0x01010100 +#define OID_NDIS_SEG5 0x01020100 +#define OID_NDIS_SEG6 0x01020200 +#define OID_NDIS_SEG7 0xFD010100 +#define OID_NDIS_SEG8 0x0D010100 +#define OID_NDIS_SEG9 0x0D010200 +#define OID_NDIS_SEG10 0x0D020200 + +#define SZ_OID_NDIS_SEG1 23 +#define SZ_OID_NDIS_SEG2 3 +#define SZ_OID_NDIS_SEG3 6 +#define SZ_OID_NDIS_SEG4 6 +#define SZ_OID_NDIS_SEG5 4 +#define SZ_OID_NDIS_SEG6 8 +#define SZ_OID_NDIS_SEG7 7 +#define SZ_OID_NDIS_SEG8 36 +#define SZ_OID_NDIS_SEG9 24 +#define SZ_OID_NDIS_SEG10 19 + +/* For Realtek-defined OIDs */ +#define OID_MP_SEG1 0xFF871100 +#define OID_MP_SEG2 0xFF818000 + +#define OID_MP_SEG3 0xFF818700 +#define OID_MP_SEG4 0xFF011100 + +#define DEBUG_OID(dbg, str) \ + if ((!dbg)) { \ + RT_TRACE(_module_rtl871x_ioctl_c_, _drv_info_, \ + ("%s(%d): %s", __func__, __line__, str)); \ + } + +enum oid_type { + QUERY_OID, + SET_OID +}; + +struct oid_funs_node { + unsigned int oid_start; /* the starting number for OID */ + unsigned int oid_end; /* the ending number for OID */ + struct oid_obj_priv *node_array; + unsigned int array_sz; /* the size of node_array */ + int query_counter; /* count the number of query hits for this segment */ + int set_counter; /* count the number of set hits for this segment */ +}; + +struct oid_par_priv { + void *adapter_context; + NDIS_OID oid; + void *information_buf; + u32 information_buf_len; + u32 *bytes_rw; + u32 *bytes_needed; + enum oid_type type_of_oid; + u32 dbg; +}; + +struct oid_obj_priv { + unsigned char dbg; /* 0: without OID debug message + * 1: with OID debug message */ + int (*oidfuns)(struct oid_par_priv *poid_par_priv); +}; + +#if defined(_RTW_MP_IOCTL_C_) +static int oid_null_function(struct oid_par_priv *poid_par_priv) { + return NDIS_STATUS_SUCCESS; +} +#endif + +extern struct iw_handler_def rtw_handlers_def; + +int drv_query_info(struct net_device *miniportadaptercontext, NDIS_OID oid, + void *informationbuffer, u32 informationbufferlength, + u32 *byteswritten, u32 *bytesneeded); + +int drv_set_info(struct net_device *MiniportAdapterContext, + NDIS_OID oid, void *informationbuffer, + u32 informationbufferlength, u32 *bytesread, + u32 *bytesneeded); + +extern int ui_pid[3]; + +#endif /* #ifndef __INC_CEINFO_ */ diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h b/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h new file mode 100644 index 000000000000..8fa3858cb776 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h @@ -0,0 +1,79 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_IOCTL_RTL_H_ +#define _RTW_IOCTL_RTL_H_ + +#include +#include + +/* oid_rtl_seg_01_01 ************** */ +int oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv);/* 84 */ +int oid_rt_get_small_packet_crc_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_middle_packet_crc_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_large_packet_crc_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_tx_retry_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_rx_retry_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_rx_total_packet_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_tx_beacon_ok_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_tx_beacon_err_hdl(struct oid_par_priv *poid_par_priv); + +int oid_rt_pro_set_fw_dig_state_hdl(struct oid_par_priv *poid_par_priv);/* 8a */ +int oid_rt_pro_set_fw_ra_state_hdl(struct oid_par_priv *poid_par_priv); /* 8b */ + +int oid_rt_get_rx_icv_err_hdl(struct oid_par_priv *poid_par_priv);/* 93 */ +int oid_rt_set_encryption_algorithm_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_preamble_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_ap_ip_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_channelplan_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_channelplan_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_preamble_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_bcn_intvl_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_dedicate_probe_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_total_tx_bytes_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_total_rx_bytes_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_current_tx_power_level_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_enc_key_mismatch_count_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_enc_key_match_count_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_channel_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_hardware_radio_off_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_key_mismatch_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_supported_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_channel_list_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_scan_in_progress_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_forced_data_rate_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_wireless_mode_for_scan_list_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_get_bss_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_scan_with_magic_packet_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_01_03 section start ************** */ +int oid_rt_ap_get_associated_station_list_hdl(struct oid_par_priv *priv); +int oid_rt_ap_switch_into_ap_mode_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_ap_supported_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_ap_set_passphrase_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_01_11 */ +int oid_rt_pro_rf_write_registry_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_pro_rf_read_registry_hdl(struct oid_par_priv *poid_par_priv); + +/* oid_rtl_seg_03_00 section start ************** */ +int oid_rt_get_connect_state_hdl(struct oid_par_priv *poid_par_priv); +int oid_rt_set_default_key_id_hdl(struct oid_par_priv *poid_par_priv); + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_set.h b/drivers/staging/r8188eu/include/rtw_ioctl_set.h new file mode 100644 index 000000000000..794f98167c3c --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_ioctl_set.h @@ -0,0 +1,49 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_IOCTL_SET_H_ +#define __RTW_IOCTL_SET_H_ + +#include + +typedef u8 NDIS_802_11_PMKID_VALUE[16]; + +u8 rtw_set_802_11_add_key(struct adapter *adapt, struct ndis_802_11_key *key); +u8 rtw_set_802_11_authentication_mode(struct adapter *adapt, + enum ndis_802_11_auth_mode authmode); +u8 rtw_set_802_11_bssid(struct adapter*adapter, u8 *bssid); +u8 rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep); +u8 rtw_set_802_11_disassociate(struct adapter *adapter); +u8 rtw_set_802_11_bssid_list_scan(struct adapter*adapter, + struct ndis_802_11_ssid *pssid, + int ssid_max_num); +u8 rtw_set_802_11_infrastructure_mode(struct adapter *adapter, + enum ndis_802_11_network_infra type); +u8 rtw_set_802_11_remove_wep(struct adapter *adapter, u32 keyindex); +u8 rtw_set_802_11_ssid(struct adapter *adapt, struct ndis_802_11_ssid *ssid); +u8 rtw_set_802_11_remove_key(struct adapter *adapt, + struct ndis_802_11_remove_key *key); +u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid); +u16 rtw_get_cur_max_rate(struct adapter *adapter); +int rtw_set_scan_mode(struct adapter *adapter, enum rt_scan_type scan_mode); +int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan); +int rtw_set_country(struct adapter *adapter, const char *country_code); +int rtw_change_ifname(struct adapter *padapter, const char *ifname); + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_iol.h b/drivers/staging/r8188eu/include/rtw_iol.h new file mode 100644 index 000000000000..6949922baa65 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_iol.h @@ -0,0 +1,84 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_IOL_H_ +#define __RTW_IOL_H_ + +#include +#include + +#define IOREG_CMD_END_LEN 4 + +struct ioreg_cfg { + u8 length; + u8 cmd_id; + __le16 address; + __le32 data; + __le32 mask; +}; + +enum ioreg_cmd { + IOREG_CMD_LLT = 0x01, + IOREG_CMD_REFUSE = 0x02, + IOREG_CMD_EFUSE_PATH = 0x03, + IOREG_CMD_WB_REG = 0x04, + IOREG_CMD_WW_REG = 0x05, + IOREG_CMD_WD_REG = 0x06, + IOREG_CMD_W_RF = 0x07, + IOREG_CMD_DELAY_US = 0x10, + IOREG_CMD_DELAY_MS = 0x11, + IOREG_CMD_END = 0xFF, +}; + +struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter); +int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, + u32 cmd_len); +int rtw_IOL_append_LLT_cmd(struct xmit_frame *xmit_frame, u8 page_boundary); +int rtw_IOL_exec_cmds_sync(struct adapter *adapter, + struct xmit_frame *xmit_frame, u32 max_wating_ms, + u32 bndy_cnt); +bool rtw_IOL_applied(struct adapter *adapter); +int rtw_IOL_append_DELAY_US_cmd(struct xmit_frame *xmit_frame, u16 us); +int rtw_IOL_append_DELAY_MS_cmd(struct xmit_frame *xmit_frame, u16 ms); +int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame); + +void read_efuse_from_txpktbuf(struct adapter *adapter, int bcnhead, + u8 *content, u16 *size); + +int _rtw_IOL_append_WB_cmd(struct xmit_frame *xmit_frame, u16 addr, + u8 value, u8 mask); +int _rtw_IOL_append_WW_cmd(struct xmit_frame *xmit_frame, u16 addr, + u16 value, u16 mask); +int _rtw_IOL_append_WD_cmd(struct xmit_frame *xmit_frame, u16 addr, + u32 value, u32 mask); +int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, + u16 addr, u32 value, u32 mask); +#define rtw_IOL_append_WB_cmd(xmit_frame, addr, value, mask) \ + _rtw_IOL_append_WB_cmd((xmit_frame), (addr), (value) ,(mask)) +#define rtw_IOL_append_WW_cmd(xmit_frame, addr, value, mask) \ + _rtw_IOL_append_WW_cmd((xmit_frame), (addr), (value),(mask)) +#define rtw_IOL_append_WD_cmd(xmit_frame, addr, value, mask) \ + _rtw_IOL_append_WD_cmd((xmit_frame), (addr), (value), (mask)) +#define rtw_IOL_append_WRF_cmd(xmit_frame, rf_path, addr, value, mask) \ + _rtw_IOL_append_WRF_cmd((xmit_frame),(rf_path), (addr), (value), (mask)) + +u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame); +void rtw_IOL_cmd_buf_dump(struct adapter *Adapter,int buf_len,u8 *pbuf); + +#endif /* __RTW_IOL_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_led.h b/drivers/staging/r8188eu/include/rtw_led.h new file mode 100644 index 000000000000..1e6a8090a753 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_led.h @@ -0,0 +1,201 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_LED_H_ +#define __RTW_LED_H_ + +#include +#include + +#define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) + +#define LED_BLINK_NORMAL_INTERVAL 100 +#define LED_BLINK_SLOWLY_INTERVAL 200 +#define LED_BLINK_LONG_INTERVAL 400 + +#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000 +#define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ +#define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ +#define LED_BLINK_FASTER_INTERVAL_ALPHA 50 +#define LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA 5000 + +#define LED_BLINK_NORMAL_INTERVAL_NETTRONIX 100 +#define LED_BLINK_SLOWLY_INTERVAL_NETTRONIX 2000 + +#define LED_BLINK_SLOWLY_INTERVAL_PORNET 1000 +#define LED_BLINK_NORMAL_INTERVAL_PORNET 100 + +#define LED_BLINK_FAST_INTERVAL_BITLAND 30 + +/* 060403, rcnjko: Customized for AzWave. */ +#define LED_CM2_BLINK_ON_INTERVAL 250 +#define LED_CM2_BLINK_OFF_INTERVAL 4750 + +#define LED_CM8_BLINK_INTERVAL 500 /* for QMI */ +#define LED_CM8_BLINK_OFF_INTERVAL 3750 /* for QMI */ + +/* 080124, lanhsin: Customized for RunTop */ +#define LED_RunTop_BLINK_INTERVAL 300 + +/* 060421, rcnjko: Customized for Sercomm Printer Server case. */ +#define LED_CM3_BLINK_INTERVAL 1500 + +enum LED_CTL_MODE { + LED_CTL_POWER_ON = 1, + LED_CTL_LINK = 2, + LED_CTL_NO_LINK = 3, + LED_CTL_TX = 4, + LED_CTL_RX = 5, + LED_CTL_SITE_SURVEY = 6, + LED_CTL_POWER_OFF = 7, + LED_CTL_START_TO_LINK = 8, + LED_CTL_START_WPS = 9, + LED_CTL_STOP_WPS = 10, + LED_CTL_START_WPS_BOTTON = 11, /* added for runtop */ + LED_CTL_STOP_WPS_FAIL = 12, /* added for ALPHA */ + LED_CTL_STOP_WPS_FAIL_OVERLAP = 13, /* added for BELKIN */ + LED_CTL_CONNECTION_NO_TRANSFER = 14, +}; + +enum LED_STATE_871x { + LED_UNKNOWN = 0, + RTW_LED_ON = 1, + RTW_LED_OFF = 2, + LED_BLINK_NORMAL = 3, + LED_BLINK_SLOWLY = 4, + LED_BLINK_POWER_ON = 5, + LED_BLINK_SCAN = 6, /* LED is blinking during scanning period, + * the # of times to blink is depend on time + * for scanning. */ + LED_BLINK_NO_LINK = 7, /* LED is blinking during no link state. */ + LED_BLINK_StartToBlink = 8,/* Customzied for Sercomm Printer + * Server case */ + LED_BLINK_TXRX = 9, + LED_BLINK_WPS = 10, /* LED is blinkg during WPS communication */ + LED_BLINK_WPS_STOP = 11, /* for ALPHA */ + LED_BLINK_WPS_STOP_OVERLAP = 12, /* for BELKIN */ + LED_BLINK_RUNTOP = 13, /* Customized for RunTop */ + LED_BLINK_CAMEO = 14, + LED_BLINK_XAVI = 15, + LED_BLINK_ALWAYS_ON = 16, +}; + +enum LED_PIN_871x { + LED_PIN_NULL = 0, + LED_PIN_LED0 = 1, + LED_PIN_LED1 = 2, + LED_PIN_LED2 = 3, + LED_PIN_GPIO0 = 4, +}; + +struct LED_871x { + struct adapter *padapter; + + enum LED_PIN_871x LedPin; /* Identify how to implement this + * SW led. */ + enum LED_STATE_871x CurrLedState; /* Current LED state. */ + enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, + * either RTW_LED_ON or RTW_LED_OFF are. */ + + u8 bLedOn; /* true if LED is ON, false if LED is OFF. */ + + u8 bLedBlinkInProgress; /* true if it is blinking, false o.w.. */ + + u8 bLedWPSBlinkInProgress; + + u32 BlinkTimes; /* Number of times to toggle led state for blinking. */ + + struct timer_list BlinkTimer; /* Timer object for led blinking. */ + + u8 bSWLedCtrl; + + /* ALPHA, added by chiyoko, 20090106 */ + u8 bLedNoLinkBlinkInProgress; + u8 bLedLinkBlinkInProgress; + u8 bLedStartToLinkBlinkInProgress; + u8 bLedScanBlinkInProgress; + struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to + * manipulate H/W to blink LED. */ +}; + +#define IS_LED_WPS_BLINKING(_LED_871x) \ + (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \ + ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \ + ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress) + +#define IS_LED_BLINKING(_LED_871x) \ + (((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress || \ + ((struct LED_871x *)_LED_871x)->bLedScanBlinkInProgress) + +/* LED customization. */ + +enum LED_STRATEGY_871x { + SW_LED_MODE0 = 0, /* SW control 1 LED via GPIO0. It is default option.*/ + SW_LED_MODE1= 1, /* 2 LEDs, through LED0 and LED1. For ALPHA. */ + SW_LED_MODE2 = 2, /* SW control 1 LED via GPIO0, customized for AzWave + * 8187 minicard. */ + SW_LED_MODE3 = 3, /* SW control 1 LED via GPIO0, customized for Sercomm + * Printer Server case. */ + SW_LED_MODE4 = 4, /* for Edimax / Belkin */ + SW_LED_MODE5 = 5, /* for Sercomm / Belkin */ + SW_LED_MODE6 = 6, /* for 88CU minicard, porting from ce SW_LED_MODE7 */ + HW_LED = 50, /* HW control 2 LEDs, LED0 and LED1 (there are 4 + * different control modes, see MAC.CONFIG1 for details.)*/ + LED_ST_NONE = 99, +}; + +void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); + +struct led_priv{ + /* add for led control */ + struct LED_871x SwLed0; + struct LED_871x SwLed1; + enum LED_STRATEGY_871x LedStrategy; + u8 bRegUseLed; + void (*LedControlHandler)(struct adapter *padapter, + enum LED_CTL_MODE LedAction); + /* add for led control */ +}; + +#define rtw_led_control(adapt, action) \ + do { \ + if ((adapt)->ledpriv.LedControlHandler) \ + (adapt)->ledpriv.LedControlHandler((adapt), (action)); \ + } while (0) + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) +void BlinkTimerCallback(struct timer_list *t); +#else +void BlinkTimerCallback(void *data); +#endif +void BlinkWorkItemCallback(struct work_struct *work); + +void ResetLedStatus(struct LED_871x * pLed); + +void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, + enum LED_PIN_871x LedPin); + +void DeInitLed871x(struct LED_871x *pLed); + +/* hal... */ +void BlinkHandler(struct LED_871x * pLed); +void SwLedOn(struct adapter *padapter, struct LED_871x *pLed); +void SwLedOff(struct adapter *padapter, struct LED_871x *pLed); + +#endif /* __RTW_LED_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h new file mode 100644 index 000000000000..a53a567b2960 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -0,0 +1,649 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_MLME_H_ +#define __RTW_MLME_H_ + +#include +#include +#include +#include + +#define MAX_BSS_CNT 128 +#define MAX_JOIN_TIMEOUT 6500 + +/* Increase the scanning timeout because of increasing the SURVEY_TO value. */ + +#define SCANNING_TIMEOUT 8000 + +#define SCAN_INTERVAL (30) /* unit:2sec, 30*2=60sec */ + +#define SCANQUEUE_LIFETIME 20 /* unit:sec */ + +#define WIFI_NULL_STATE 0x00000000 + +#define WIFI_ASOC_STATE 0x00000001 /* Under Linked state */ +#define WIFI_REASOC_STATE 0x00000002 +#define WIFI_SLEEP_STATE 0x00000004 +#define WIFI_STATION_STATE 0x00000008 + +#define WIFI_AP_STATE 0x00000010 +#define WIFI_ADHOC_STATE 0x00000020 +#define WIFI_ADHOC_MASTER_STATE 0x00000040 +#define WIFI_UNDER_LINKING 0x00000080 + +#define WIFI_UNDER_WPS 0x00000100 +#define WIFI_STA_ALIVE_CHK_STATE 0x00000400 +#define WIFI_SITE_MONITOR 0x00000800 /* to indicate the station is under site surveying */ + +#define WIFI_MP_STATE 0x00010000 +#define WIFI_MP_CTX_BACKGROUND 0x00020000 /* in continuous tx background */ +#define WIFI_MP_CTX_ST 0x00040000 /* in continuous tx with single-tone */ +#define WIFI_MP_CTX_BACKGROUND_PENDING 0x00080000 /* pending in continuous tx background due to out of skb */ +#define WIFI_MP_CTX_CCK_HW 0x00100000 /* in continuous tx */ +#define WIFI_MP_CTX_CCK_CS 0x00200000 /* in continuous tx with carrier suppression */ +#define WIFI_MP_LPBK_STATE 0x00400000 + +#define _FW_UNDER_LINKING WIFI_UNDER_LINKING +#define _FW_LINKED WIFI_ASOC_STATE +#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR + +enum dot11AuthAlgrthmNum { + dot11AuthAlgrthm_Open = 0, + dot11AuthAlgrthm_Shared, + dot11AuthAlgrthm_8021X, + dot11AuthAlgrthm_Auto, + dot11AuthAlgrthm_WAPI, + dot11AuthAlgrthm_MaxNum +}; + +/* Scan type including active and passive scan. */ +enum rt_scan_type { + SCAN_PASSIVE, + SCAN_ACTIVE, + SCAN_MIX, +}; + +enum SCAN_RESULT_TYPE { + SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ + SCAN_RESULT_ALL = 1, /* Will return all the scanned device, + * include AP. */ + SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD + * device. */ + /* If this device is Miracast sink + * device, it will just return all the + * Miracast source devices. */ +}; + +/* +there are several "locks" in mlme_priv, +since mlme_priv is a shared resource between many threads, +like ISR/Call-Back functions, the OID handlers, and even timer functions. + +Each _queue has its own locks, already. +Other items are protected by mlme_priv.lock. + +To avoid possible dead lock, any thread trying to modifiying mlme_priv +SHALL not lock up more than one lock at a time! +*/ + +#define traffic_threshold 10 +#define traffic_scan_period 500 + +struct sitesurvey_ctrl { + u64 last_tx_pkts; + uint last_rx_pkts; + int traffic_busy; + struct timer_list sitesurvey_ctrl_timer; +}; + +struct rt_link_detect { + u32 NumTxOkInPeriod; + u32 NumRxOkInPeriod; + u32 NumRxUnicastOkInPeriod; + bool bBusyTraffic; + bool bTxBusyTraffic; + bool bRxBusyTraffic; + bool bHigherBusyTraffic; /* For interrupt migration purpose. */ + bool bHigherBusyRxTraffic; /* We may disable Tx interrupt according + * to Rx traffic. */ + bool bHigherBusyTxTraffic; /* We may disable Tx interrupt according + * to Tx traffic. */ +}; + +struct profile_info { + u8 ssidlen; + u8 ssid[ WLAN_SSID_MAXLEN ]; + u8 peermac[ ETH_ALEN ]; +}; + +struct tx_invite_req_info { + u8 token; + u8 benable; + u8 go_ssid[ WLAN_SSID_MAXLEN ]; + u8 ssidlen; + u8 go_bssid[ ETH_ALEN ]; + u8 peer_macaddr[ ETH_ALEN ]; + u8 operating_ch; /* This information will be set by using the + * p2p_set op_ch=x */ + u8 peer_ch; /* The listen channel for peer P2P device */ +}; + +struct tx_invite_resp_info { + u8 token; /* Used to record the dialog token of p2p invitation + * request frame. */ +}; + +struct tx_provdisc_req_info { + u16 wps_config_method_request; /* Used when sending the + * provisioning request frame*/ + u16 peer_channel_num[2]; /* The channel number which the + * receiver stands. */ + struct ndis_802_11_ssid ssid; + u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ + u8 peerIFAddr[ETH_ALEN]; /* Peer interface address */ + u8 benable; /* This provision discovery + * request frame is trigger + * to send or not */ +}; + +/* When peer device issue prov_disc_req first, we should store the following + * information */ +/* The UI must know this information to know which config method the + * remote p2p device needs. */ +struct rx_provdisc_req_info { + u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ + u8 strconfig_method_desc_of_prov_disc_req[4]; /* description + * for the config method located in the provisioning + * discovery request frame. */ +}; + +struct tx_nego_req_info { + u16 peer_channel_num[2]; /* The channel number. */ + u8 peerDevAddr[ETH_ALEN]; /* Peer device address */ + u8 benable; /* This negotiation request frame is + * trigger to send or not */ +}; + +struct group_id_info { + u8 go_device_addr[ ETH_ALEN ]; /* The GO's device address of + * this P2P group */ + u8 ssid[ WLAN_SSID_MAXLEN ]; /* The SSID of this P2P group */ +}; + +struct scan_limit_info { + u8 scan_op_ch_only; /* When this flag is set, the driver + * should only scan the op. channel */ + u8 operation_ch[2]; /* Store the op. chan of invitation */ +}; + +struct wifidirect_info { + struct adapter *padapter; + struct timer_list find_phase_timer; + struct timer_list restore_p2p_state_timer; + + /* Used to do the scanning. After confirming the peer is availalble, + * the driver transmits the P2P frame to peer. */ + struct timer_list pre_tx_scan_timer; + struct timer_list reset_ch_sitesurvey; + struct timer_list reset_ch_sitesurvey2; /* Just for resetting the scan + * limit function by using p2p nego */ + struct tx_provdisc_req_info tx_prov_disc_info; + struct rx_provdisc_req_info rx_prov_disc_info; + struct tx_invite_req_info invitereq_info; + /* Store the profile information of persistent group */ + struct profile_info profileinfo[P2P_MAX_PERSISTENT_GROUP_NUM]; + struct tx_invite_resp_info inviteresp_info; + struct tx_nego_req_info nego_req_info; + /* Store the group id info when doing the group negot handshake. */ + struct group_id_info groupid_info; + /* Used for get the limit scan channel from the Invitation procedure */ + struct scan_limit_info rx_invitereq_info; + /* Used for get the limit scan chan from the P2P negotiation handshake*/ + struct scan_limit_info p2p_info; + enum P2P_ROLE role; + enum P2P_STATE pre_p2p_state; + enum P2P_STATE p2p_state; + /* The device address should be the mac address of this device. */ + u8 device_addr[ETH_ALEN]; + u8 interface_addr[ETH_ALEN]; + u8 social_chan[4]; + u8 listen_channel; + u8 operating_channel; + u8 listen_dwell; /* This value should be between 1 and 3 */ + u8 support_rate[8]; + u8 p2p_wildcard_ssid[P2P_WILDCARD_SSID_LEN]; + u8 intent; /* should only include the intent value. */ + u8 p2p_peer_interface_addr[ETH_ALEN]; + u8 p2p_peer_device_addr[ETH_ALEN]; + u8 peer_intent; /* Included the intent value and tie breaker value. */ + /* Device name for displaying on searching device screen */ + u8 device_name[WPS_MAX_DEVICE_NAME_LEN]; + u8 device_name_len; + u8 profileindex; /* Used to point to the index of profileinfo array */ + u8 peer_operating_ch; + u8 find_phase_state_exchange_cnt; + /* The device password ID for group negotiation */ + u16 device_password_id_for_nego; + u8 negotiation_dialog_token; + /* SSID information for group negotitation */ + u8 nego_ssid[WLAN_SSID_MAXLEN]; + u8 nego_ssidlen; + u8 p2p_group_ssid[WLAN_SSID_MAXLEN]; + u8 p2p_group_ssid_len; + /* Flag to know if the persistent function should be supported or not.*/ + u8 persistent_supported; + /* In the Sigma test, the Sigma will provide this enable from the + * sta_set_p2p CAPI. */ + /* 0: disable */ + /* 1: enable */ + u8 session_available; /* Flag to set the WFD session available to + * enable or disable "by Sigma" */ + /* In the Sigma test, the Sigma will disable the session available + * by using the sta_preset CAPI. */ + /* 0: disable */ + /* 1: enable */ + u8 wfd_tdls_enable; /* Flag to enable or disable the TDLS by WFD Sigma*/ + /* 0: disable */ + /* 1: enable */ + u8 wfd_tdls_weaksec; /* Flag to enable or disable the weak security + * function for TDLS by WFD Sigma */ + /* 0: disable */ + /* In this case, the driver can't issue the tdsl + * setup request frame. */ + /* 1: enable */ + /* In this case, the driver can issue the tdls + * setup request frame */ + /* even the current security is weak security. */ + + /* This field will store the WPS value (PIN value or PBC) that UI had + * got from the user. */ + enum P2P_WPSINFO ui_got_wps_info; + u16 supported_wps_cm; /* This field describes the WPS config method + * which this driver supported. */ + /* The value should be the combination of config + * method defined in page104 of WPS v2.0 spec.*/ + /* This field will contain the length of body of P2P Channel List + * attribute of group negotiation response frame. */ + uint channel_list_attr_len; + /* This field will contain the body of P2P Channel List attribute of + * group negotitation response frame. */ + /* We will use the channel_cnt and channel_list fields when constructing + * the group negotiation confirm frame. */ + u8 channel_list_attr[100]; + enum P2P_PS_MODE p2p_ps_mode; /* indicate p2p ps mode */ + enum P2P_PS_STATE p2p_ps_state; /* indicate p2p ps state */ + u8 noa_index; /* Identifies and instance of Notice of Absence timing. */ + u8 ctwindow; /* Client traffic window. A period of time in TU after TBTT. */ + u8 opp_ps; /* opportunistic power save. */ + u8 noa_num; /* number of NoA descriptor in P2P IE. */ + u8 noa_count[P2P_MAX_NOA_NUM]; /* Count for owner, Type of client. */ + /* Max duration for owner, preferred or min acceptable duration for + * client. */ + u32 noa_duration[P2P_MAX_NOA_NUM]; + /* Length of interval for owner, preferred or max acceptable interval + * of client. */ + u32 noa_interval[P2P_MAX_NOA_NUM]; + /* schedule expressed in terms of the lower 4 bytes of the TSF timer. */ + u32 noa_start_time[P2P_MAX_NOA_NUM]; +}; + +struct tdls_ss_record { /* signal strength record */ + u8 macaddr[ETH_ALEN]; + u8 RxPWDBAll; + u8 is_tdls_sta; /* true: direct link sta, false: else */ +}; + +struct tdls_info { + u8 ap_prohibited; + uint setup_state; + u8 sta_cnt; + u8 sta_maximum; /* 1:tdls sta is equal (NUM_STA-1), reach max direct link number; 0: else; */ + struct tdls_ss_record ss_record; + u8 macid_index; /* macid entry that is ready to write */ + u8 clear_cam; /* cam entry that is trying to clear, using it in direct link teardown */ + u8 ch_sensing; + u8 cur_channel; + u8 candidate_ch; + u8 collect_pkt_num[MAX_CHANNEL_NUM]; + spinlock_t cmd_lock; + spinlock_t hdl_lock; + u8 watchdog_count; + u8 dev_discovered; /* WFD_TDLS: for sigma test */ + u8 enable; +}; + +struct mlme_priv { + spinlock_t lock; + int fw_state; /* shall we protect this variable? maybe not necessarily... */ + u8 bScanInProcess; + u8 to_join; /* flag */ + u8 to_roaming; /* roaming trying times */ + + u8 *nic_hdl; + + u8 not_indic_disco; + struct list_head *pscanned; + struct __queue free_bss_pool; + struct __queue scanned_queue; + u8 *free_bss_buf; + u8 key_mask; /* use to restore wep key after hal_init */ + u32 num_of_scanned; + + struct ndis_802_11_ssid assoc_ssid; + u8 assoc_bssid[6]; + + struct wlan_network cur_network; + struct wlan_network *cur_network_scanned; + + u32 scan_interval; + + struct timer_list assoc_timer; + + uint assoc_by_bssid; + uint assoc_by_rssi; + + struct timer_list scan_to_timer; /* driver itself handles scan_timeout status. */ + u32 scan_start_time; /* used to evaluate the time spent in scanning */ + + struct qos_priv qospriv; + + /* Number of non-HT AP/stations */ + int num_sta_no_ht; + + /* Number of HT AP/stations 20 MHz */ + /* int num_sta_ht_20mhz; */ + + int num_FortyMHzIntolerant; + struct ht_priv htpriv; + struct rt_link_detect LinkDetectInfo; + struct timer_list dynamic_chk_timer; /* dynamic/periodic check timer */ + + u8 acm_mask; /* for wmm acm mask */ + u8 ChannelPlan; + enum rt_scan_type scan_mode; /* active: 1, passive: 0 */ + + /* u8 probereq_wpsie[MAX_WPS_IE_LEN];added in probe req */ + /* int probereq_wpsie_len; */ + u8 *wps_probe_req_ie; + u32 wps_probe_req_ie_len; + + u8 *assoc_req; + u32 assoc_req_len; + u8 *assoc_rsp; + u32 assoc_rsp_len; + +#if defined (CONFIG_88EU_AP_MODE) + /* Number of associated Non-ERP stations (i.e., stations using 802.11b + * in 802.11g BSS) */ + int num_sta_non_erp; + + /* Number of associated stations that do not support Short Slot Time */ + int num_sta_no_short_slot_time; + + /* Number of associated stations that do not support Short Preamble */ + int num_sta_no_short_preamble; + + int olbc; /* Overlapping Legacy BSS Condition */ + + /* Number of HT assoc sta that do not support greenfield */ + int num_sta_ht_no_gf; + + /* Number of associated non-HT stations */ + /* int num_sta_no_ht; */ + + /* Number of HT associated stations 20 MHz */ + int num_sta_ht_20mhz; + + /* Overlapping BSS information */ + int olbc_ht; + + u16 ht_op_mode; + + u8 *wps_beacon_ie; + /* u8 *wps_probe_req_ie; */ + u8 *wps_probe_resp_ie; + u8 *wps_assoc_resp_ie; + + u32 wps_beacon_ie_len; + u32 wps_probe_resp_ie_len; + u32 wps_assoc_resp_ie_len; + + u8 *p2p_beacon_ie; + u8 *p2p_probe_req_ie; + u8 *p2p_probe_resp_ie; + u8 *p2p_go_probe_resp_ie; /* for GO */ + u8 *p2p_assoc_req_ie; + + u32 p2p_beacon_ie_len; + u32 p2p_probe_req_ie_len; + u32 p2p_probe_resp_ie_len; + u32 p2p_go_probe_resp_ie_len; /* for GO */ + u32 p2p_assoc_req_ie_len; + spinlock_t bcn_update_lock; + u8 update_bcn; +#endif /* if defined (CONFIG_88EU_AP_MODE) */ +}; + +#ifdef CONFIG_88EU_AP_MODE + +struct hostapd_priv { + struct adapter *padapter; +}; + +int hostapd_mode_init(struct adapter *padapter); +void hostapd_mode_unload(struct adapter *padapter); +#endif + +extern unsigned char WPA_TKIP_CIPHER[4]; +extern unsigned char RSN_TKIP_CIPHER[4]; +extern unsigned char REALTEK_96B_IE[]; +extern unsigned char MCS_rate_2R[16]; +extern unsigned char MCS_rate_1R[16]; + +void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf); +void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf); +void indicate_wx_scan_complete_event(struct adapter *padapter); +void rtw_indicate_wx_assoc_event(struct adapter *padapter); +void rtw_indicate_wx_disassoc_event(struct adapter *padapter); +int event_thread(void *context); +#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) +void rtw_join_timeout_handler (void *FunctionContext); +void _rtw_scan_timeout_handler(void *FunctionContext); +#else +void rtw_join_timeout_handler (struct timer_list *t); +void _rtw_scan_timeout_handler (struct timer_list *t); +#endif +void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall); +int rtw_init_mlme_priv(struct adapter *adapter); +void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv); +int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv); +int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, + int keyid, u8 set_tx); +int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv); + +static inline u8 *get_bssid(struct mlme_priv *pmlmepriv) +{ /* if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid */ + /* if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address */ + return pmlmepriv->cur_network.network.MacAddress; +} + +static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state) +{ + if (pmlmepriv->fw_state & state) + return true; + + return false; +} + +static inline int get_fwstate(struct mlme_priv *pmlmepriv) +{ + return pmlmepriv->fw_state; +} + +/* + * No Limit on the calling context, + * therefore set it to be the critical section... + * + * ### NOTE:#### (!!!!) + * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock + */ +static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state) +{ + pmlmepriv->fw_state |= state; + /* FOR HW integration */ + if (_FW_UNDER_SURVEY==state) + pmlmepriv->bScanInProcess = true; +} + +static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) +{ + pmlmepriv->fw_state &= ~state; + /* FOR HW integration */ + if (_FW_UNDER_SURVEY==state) + pmlmepriv->bScanInProcess = false; +} + +/* + * No Limit on the calling context, + * therefore set it to be the critical section... + */ +static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state) +{ + spin_lock_bh(&pmlmepriv->lock); + if (check_fwstate(pmlmepriv, state) == true) + pmlmepriv->fw_state ^= state; + spin_unlock_bh(&pmlmepriv->lock); +} + +static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state) +{ + spin_lock_bh(&pmlmepriv->lock); + _clr_fwstate_(pmlmepriv, state); + spin_unlock_bh(&pmlmepriv->lock); +} + +static inline void up_scanned_network(struct mlme_priv *pmlmepriv) +{ + spin_lock_bh(&pmlmepriv->lock); + pmlmepriv->num_of_scanned++; + spin_unlock_bh(&pmlmepriv->lock); +} + +static inline void down_scanned_network(struct mlme_priv *pmlmepriv) +{ + spin_lock_bh(&pmlmepriv->lock); + pmlmepriv->num_of_scanned--; + spin_unlock_bh(&pmlmepriv->lock); +} + +static inline void set_scanned_network_val(struct mlme_priv *pmlmepriv, int val) +{ + spin_lock_bh(&pmlmepriv->lock); + pmlmepriv->num_of_scanned = val; + spin_unlock_bh(&pmlmepriv->lock); +} + +u16 rtw_get_capability(struct wlan_bssid_ex *bss); +void rtw_update_scanned_network(struct adapter *adapter, + struct wlan_bssid_ex *target); +void rtw_disconnect_hdl_under_linked(struct adapter *adapter, + struct sta_info *psta, u8 free_assoc); +void rtw_generate_random_ibss(u8 *pibss); +struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr); +struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); + +void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue); +void rtw_indicate_disconnect(struct adapter *adapter); +void rtw_indicate_connect(struct adapter *adapter); +void rtw_indicate_scan_done( struct adapter *padapter, bool aborted); +void rtw_scan_abort(struct adapter *adapter); + +int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, + uint in_len); +int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, + uint in_len, uint initial_out_len); +void rtw_init_registrypriv_dev_network(struct adapter *adapter); + +void rtw_update_registrypriv_dev_network(struct adapter *adapter); + +void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); + +void _rtw_join_timeout_handler(struct adapter *adapter); +void rtw_scan_timeout_handler(struct adapter *adapter); + + void rtw_dynamic_check_timer_handlder(struct adapter *adapter); +#define rtw_is_scan_deny(adapter) false +#define rtw_clear_scan_deny(adapter) do {} while (0) +#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0) +#define rtw_set_scan_deny(adapter, ms) do {} while (0) + +int _rtw_init_mlme_priv(struct adapter *padapter); + +void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); + +void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv); + +int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork); + +struct wlan_network *_rtw_dequeue_network(struct __queue *queue); + + struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv); + +void _rtw_free_network(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork, u8 isfreeall); +void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, + struct wlan_network *pnetwork); + +struct wlan_network* _rtw_find_network(struct __queue *scanned_queue, u8 *addr); + +void _rtw_free_network_queue(struct adapter *padapter, u8 isfreeall); + +int rtw_if_up(struct adapter *padapter); + +u8 *rtw_get_capability_from_ie(u8 *ie); +u8 *rtw_get_timestampe_from_ie(u8 *ie); +u8 *rtw_get_beacon_interval_from_ie(u8 *ie); + +void rtw_joinbss_reset(struct adapter *padapter); + +unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, + u8 *out_ie, uint in_len, uint *pout_len); +void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len); +void rtw_issue_addbareq_cmd(struct adapter *padapter, + struct xmit_frame *pxmitframe); + +int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork); +int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst); + +void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); +void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); +void rtw_set_roaming(struct adapter *adapter, u8 to_roaming); +u8 rtw_to_roaming(struct adapter *adapter); + +void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, + u32 mstatus); + +#endif /* __RTL871X_MLME_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h new file mode 100644 index 000000000000..fdb79587762e --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -0,0 +1,874 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_MLME_EXT_H_ +#define __RTW_MLME_EXT_H_ + +#include +#include +#include + +/* Commented by Albert 20101105 */ +/* Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms ) */ +/* The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */ +/* So, this driver tried to extend the dwell time for each scanning channel. */ +/* This will increase the chance to receive the probe response from SoftAP. */ + +#define SURVEY_TO (100) +#define REAUTH_TO (300) /* 50) */ +#define REASSOC_TO (300) /* 50) */ +/* define DISCONNECT_TO (3000) */ +#define ADDBA_TO (2000) + +#define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */ + +#define REAUTH_LIMIT (4) +#define REASSOC_LIMIT (4) +#define READDBA_LIMIT (2) + +#define ROAMING_LIMIT 8 + +#define DYNAMIC_FUNC_DISABLE (0x0) + +/* ====== ODM_ABILITY_E ======== */ +/* BB ODM section BIT 0-15 */ +#define DYNAMIC_BB_DIG BIT(0) +#define DYNAMIC_BB_RA_MASK BIT(1) +#define DYNAMIC_BB_DYNAMIC_TXPWR BIT(2) +#define DYNAMIC_BB_BB_FA_CNT BIT(3) + +#define DYNAMIC_BB_RSSI_MONITOR BIT(4) +#define DYNAMIC_BB_CCK_PD BIT(5) +#define DYNAMIC_BB_ANT_DIV BIT(6) +#define DYNAMIC_BB_PWR_SAVE BIT(7) +#define DYNAMIC_BB_PWR_TRA BIT(8) +#define DYNAMIC_BB_RATE_ADAPTIVE BIT(9) +#define DYNAMIC_BB_PATH_DIV BIT(10) +#define DYNAMIC_BB_PSD BIT(11) + +/* MAC DM section BIT 16-23 */ +#define DYNAMIC_MAC_EDCA_TURBO BIT(16) +#define DYNAMIC_MAC_EARLY_MODE BIT(17) + +/* RF ODM section BIT 24-31 */ +#define DYNAMIC_RF_TX_PWR_TRACK BIT(24) +#define DYNAMIC_RF_RX_GAIN_TRACK BIT(25) +#define DYNAMIC_RF_CALIBRATION BIT(26) + +#define DYNAMIC_ALL_FUNC_ENABLE 0xFFFFFFF + +#define _HW_STATE_NOLINK_ 0x00 +#define _HW_STATE_ADHOC_ 0x01 +#define _HW_STATE_STATION_ 0x02 +#define _HW_STATE_AP_ 0x03 + +#define _1M_RATE_ 0 +#define _2M_RATE_ 1 +#define _5M_RATE_ 2 +#define _11M_RATE_ 3 +#define _6M_RATE_ 4 +#define _9M_RATE_ 5 +#define _12M_RATE_ 6 +#define _18M_RATE_ 7 +#define _24M_RATE_ 8 +#define _36M_RATE_ 9 +#define _48M_RATE_ 10 +#define _54M_RATE_ 11 + +extern unsigned char RTW_WPA_OUI[]; +extern unsigned char WMM_OUI[]; +extern unsigned char WPS_OUI[]; +extern unsigned char WFD_OUI[]; +extern unsigned char P2P_OUI[]; + +extern unsigned char WMM_INFO_OUI[]; +extern unsigned char WMM_PARA_OUI[]; + +/* Channel Plan Type. */ +/* Note: */ +/* We just add new channel plan when the new channel plan is different + * from any of the following channel plan. */ +/* If you just want to customize the actions(scan period or join actions) + * about one of the channel plan, */ +/* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */ +enum RT_CHANNEL_DOMAIN { + /* old channel plan mapping ===== */ + RT_CHANNEL_DOMAIN_FCC = 0x00, + RT_CHANNEL_DOMAIN_IC = 0x01, + RT_CHANNEL_DOMAIN_ETSI = 0x02, + RT_CHANNEL_DOMAIN_SPAIN = 0x03, + RT_CHANNEL_DOMAIN_FRANCE = 0x04, + RT_CHANNEL_DOMAIN_MKK = 0x05, + RT_CHANNEL_DOMAIN_MKK1 = 0x06, + RT_CHANNEL_DOMAIN_ISRAEL = 0x07, + RT_CHANNEL_DOMAIN_TELEC = 0x08, + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09, + RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A, + RT_CHANNEL_DOMAIN_TAIWAN = 0x0B, + RT_CHANNEL_DOMAIN_CHINA = 0x0C, + RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D, + RT_CHANNEL_DOMAIN_KOREA = 0x0E, + RT_CHANNEL_DOMAIN_TURKEY = 0x0F, + RT_CHANNEL_DOMAIN_JAPAN = 0x10, + RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11, + RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12, + RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13, + RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14, + + /* new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */ + RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20, + RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21, + RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22, + RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23, + RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24, + RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25, + RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26, + RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27, + RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28, + RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29, + RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30, + RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31, + RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32, + RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33, + RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34, + RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35, + RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36, + RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37, + RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38, + RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39, + RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40, + RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41, + /* Add new channel plan above this line=============== */ + RT_CHANNEL_DOMAIN_MAX, + RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F, +}; + +enum RT_CHANNEL_DOMAIN_2G { + RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwide 13 */ + RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */ + RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */ + RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03, /* Japan */ + RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04, /* France */ + RT_CHANNEL_DOMAIN_2G_NULL = 0x05, + /* Add new channel plan above this line=============== */ + RT_CHANNEL_DOMAIN_2G_MAX, +}; + +#define rtw_is_channel_plan_valid(chplan) \ + (chplan < RT_CHANNEL_DOMAIN_MAX || \ + chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) + +struct rt_channel_plan { + unsigned char Channel[MAX_CHANNEL_NUM]; + unsigned char Len; +}; + +struct rt_channel_plan_2g { + unsigned char Channel[MAX_CHANNEL_NUM_2G]; + unsigned char Len; +}; + +struct rt_channel_plan_map { + unsigned char Index2G; +}; + +enum Associated_AP { + atherosAP = 0, + broadcomAP = 1, + ciscoAP = 2, + marvellAP = 3, + ralinkAP = 4, + realtekAP = 5, + airgocapAP = 6, + unknownAP = 7, + maxAP, +}; + +enum HT_IOT_PEER { + HT_IOT_PEER_UNKNOWN = 0, + HT_IOT_PEER_REALTEK = 1, + HT_IOT_PEER_REALTEK_92SE = 2, + HT_IOT_PEER_BROADCOM = 3, + HT_IOT_PEER_RALINK = 4, + HT_IOT_PEER_ATHEROS = 5, + HT_IOT_PEER_CISCO = 6, + HT_IOT_PEER_MERU = 7, + HT_IOT_PEER_MARVELL = 8, + HT_IOT_PEER_REALTEK_SOFTAP = 9,/* peer is RealTek SOFT_AP */ + HT_IOT_PEER_SELF_SOFTAP = 10, /* Self is SoftAP */ + HT_IOT_PEER_AIRGO = 11, + HT_IOT_PEER_INTEL = 12, + HT_IOT_PEER_RTK_APCLIENT = 13, + HT_IOT_PEER_REALTEK_81XX = 14, + HT_IOT_PEER_REALTEK_WOW = 15, + HT_IOT_PEER_TENDA = 16, + HT_IOT_PEER_MAX = 17 +}; + +enum SCAN_STATE { + SCAN_DISABLE = 0, + SCAN_START = 1, + SCAN_TXNULL = 2, + SCAN_PROCESS = 3, + SCAN_COMPLETE = 4, + SCAN_STATE_MAX, +}; + +struct mlme_handler { + unsigned int num; + char *str; + unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); +}; + +struct action_handler { + unsigned int num; + char* str; + unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); +}; + +struct ss_res { + int state; + int bss_cnt; + int channel_idx; + int scan_mode; + u8 ssid_num; + u8 ch_num; + struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; + struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; +}; + +/* define AP_MODE 0x0C */ +/* define STATION_MODE 0x08 */ +/* define AD_HOC_MODE 0x04 */ +/* define NO_LINK_MODE 0x00 */ + +#define WIFI_FW_NULL_STATE _HW_STATE_NOLINK_ +#define WIFI_FW_STATION_STATE _HW_STATE_STATION_ +#define WIFI_FW_AP_STATE _HW_STATE_AP_ +#define WIFI_FW_ADHOC_STATE _HW_STATE_ADHOC_ + +#define WIFI_FW_AUTH_NULL 0x00000100 +#define WIFI_FW_AUTH_STATE 0x00000200 +#define WIFI_FW_AUTH_SUCCESS 0x00000400 + +#define WIFI_FW_ASSOC_STATE 0x00002000 +#define WIFI_FW_ASSOC_SUCCESS 0x00004000 + +#define WIFI_FW_LINKING_STATE (WIFI_FW_AUTH_NULL | \ + WIFI_FW_AUTH_STATE | \ + WIFI_FW_AUTH_SUCCESS | \ + WIFI_FW_ASSOC_STATE) + +struct FW_Sta_Info { + struct sta_info *psta; + u32 status; + u32 rx_pkt; + u32 retry; + unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; +}; + +/* + * Usage: + * When one iface acted as AP mode and the other iface is STA mode and scanning, + * it should switch back to AP's operating channel periodically. + * Parameters info: + * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to + * AP's operating channel for + * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds. + * Example: + * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1, + * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100. + * When it's STA mode gets set_scan command, + * it would + * 1. Doing the scan on channel 1.2.3.4.5.6.7.8 + * 2. Back to channel 1 for 300 milliseconds + * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52 + * 4. Back to channel 1 for 300 milliseconds + * 5. ... and so on, till survey done. + */ + +struct mlme_ext_info { + u32 state; + u32 reauth_count; + u32 reassoc_count; + u32 link_count; + u32 auth_seq; + u32 auth_algo; /* 802.11 auth, could be open, shared, auto */ + u32 authModeToggle; + u32 enc_algo;/* encrypt algorithm; */ + u32 key_index; /* this is only valid for legacy wep, + * 0~3 for key id. */ + u32 iv; + u8 chg_txt[128]; + u16 aid; + u16 bcn_interval; + u16 capability; + u8 assoc_AP_vendor; + u8 slotTime; + u8 preamble_mode; + u8 WMM_enable; + u8 ERP_enable; + u8 ERP_IE; + u8 HT_enable; + u8 HT_caps_enable; + u8 HT_info_enable; + u8 HT_protection; + u8 turboMode_cts2self; + u8 turboMode_rtsen; + u8 SM_PS; + u8 agg_enable_bitmap; + u8 ADDBA_retry_count; + u8 candidate_tid_bitmap; + u8 dialogToken; + /* Accept ADDBA Request */ + bool bAcceptAddbaReq; + u8 bwmode_updated; + u8 hidden_ssid_mode; + + struct ADDBA_request ADDBA_req; + struct WMM_para_element WMM_param; + struct HT_caps_element HT_caps; + struct HT_info_element HT_info; + struct wlan_bssid_ex network;/* join network or bss_network, + * if in ap mode, it is the same + * as cur_network.network */ + struct FW_Sta_Info FW_sta_info[NUM_STA]; +}; + +/* The channel information about this channel including joining, + * scanning, and power constraints. */ +struct rt_channel_info { + u8 ChannelNum; /* The channel number. */ + enum rt_scan_type ScanType; /* Scan type such as passive + * or active scan. */ + u32 rx_count; +}; + +int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch); + +/* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */ +#define P2P_MAX_REG_CLASSES 10 + +/* P2P_MAX_REG_CLASS_CHANNELS - Maximum number of chan per regulatory class */ +#define P2P_MAX_REG_CLASS_CHANNELS 20 + +/* struct p2p_channels - List of supported channels */ +struct p2p_channels { + /* struct p2p_reg_class - Supported regulatory class */ + struct p2p_reg_class { + /* reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */ + u8 reg_class; + + /* channel - Supported channels */ + u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; + + /* channels - Number of channel entries in use */ + size_t channels; + } reg_class[P2P_MAX_REG_CLASSES]; + + /* reg_classes - Number of reg_class entries in use */ + size_t reg_classes; +}; + +struct p2p_oper_class_map { + enum hw_mode {IEEE80211G} mode; + u8 op_class; + u8 min_chan; + u8 max_chan; + u8 inc; + enum {BW20, BW40PLUS, BW40MINUS} bw; +}; + +struct mlme_ext_priv { + struct adapter *padapter; + u8 mlmeext_init; + ATOMIC_T event_seq; + u16 mgnt_seq; + + unsigned char cur_channel; + unsigned char cur_bwmode; + unsigned char cur_ch_offset;/* PRIME_CHNL_OFFSET */ + unsigned char cur_wireless_mode; /* NETWORK_TYPE */ + + unsigned char oper_channel; /* saved chan info when call + * set_channel_bw */ + unsigned char oper_bwmode; + unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */ + + unsigned char max_chan_nums; + struct rt_channel_info channel_set[MAX_CHANNEL_NUM]; + struct p2p_channels channel_list; + unsigned char basicrate[NumRates]; + unsigned char datarate[NumRates]; + + struct ss_res sitesurvey_res; + struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including + * current scan/connecting/connected + * related info. For ap mode, + * network includes ap's cap_info*/ + struct timer_list survey_timer; + struct timer_list link_timer; + u16 chan_scan_time; + + u8 scan_abort; + u8 tx_rate; /* TXRATE when USERATE is set. */ + + u32 retry; /* retry for issue probereq */ + + u64 TSFValue; + +#ifdef CONFIG_88EU_AP_MODE + unsigned char bstart_bss; +#endif + u8 update_channel_plan_by_ap_done; + /* recv_decache check for Action_public frame */ + u8 action_public_dialog_token; + u16 action_public_rxseq; + u8 active_keep_alive_check; +}; + +int init_mlme_ext_priv(struct adapter *adapter); +int init_hw_mlme_ext(struct adapter *padapter); +void free_mlme_ext_priv (struct mlme_ext_priv *pmlmeext); +extern void init_mlme_ext_timer(struct adapter *padapter); +extern void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta); +extern struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); + +unsigned char networktype_to_raid(unsigned char network_type); +u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int len); +void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len); +void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS); +void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen); + +void Save_DM_Func_Flag(struct adapter *padapter); +void Restore_DM_Func_Flag(struct adapter *padapter); +void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable); + +void Set_MSR(struct adapter *padapter, u8 type); + +u8 rtw_get_oper_ch(struct adapter *adapter); +void rtw_set_oper_ch(struct adapter *adapter, u8 ch); +u8 rtw_get_oper_bw(struct adapter *adapter); +void rtw_set_oper_bw(struct adapter *adapter, u8 bw); +u8 rtw_get_oper_choffset(struct adapter *adapter); +void rtw_set_oper_choffset(struct adapter *adapter, u8 offset); + +void set_channel_bwmode(struct adapter *padapter, unsigned char channel, + unsigned char channel_offset, unsigned short bwmode); +void SelectChannel(struct adapter *padapter, unsigned char channel); +void SetBWMode(struct adapter *padapter, unsigned short bwmode, + unsigned char channel_offset); + +unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval); + +void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); +void clear_cam_entry(struct adapter *padapter, u8 entry); + +void invalidate_cam_all(struct adapter *padapter); +void CAM_empty_entry(struct adapter * Adapter, u8 ucIndex); + +int allocate_fw_sta_entry(struct adapter *padapter); +void flush_all_cam_entry(struct adapter *padapter); + +void site_survey(struct adapter *padapter); +u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, + struct wlan_bssid_ex *bssid); +void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, + struct adapter *adapter, bool update_ie); + +int get_bsstype(unsigned short capability); +u8 *get_my_bssid(struct wlan_bssid_ex *pnetwork); +u16 get_beacon_interval(struct wlan_bssid_ex *bss); + +int is_client_associated_to_ap(struct adapter *padapter); +int is_client_associated_to_ibss(struct adapter *padapter); +int is_IBSS_empty(struct adapter *padapter); + +unsigned char check_assoc_AP(u8 *pframe, uint len); + +int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void WMMOnAssocRsp(struct adapter *padapter); + +void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void HTOnAssocRsp(struct adapter *padapter); + +void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); +void VCS_update(struct adapter *padapter, struct sta_info *psta); + +void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, + struct sta_info *psta); +int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len); +void update_IOT_info(struct adapter *padapter); +void update_capinfo(struct adapter *adapter, u16 updatecap); +void update_wireless_mode(struct adapter *padapter); +void update_tx_basic_rate(struct adapter *padapter, u8 modulation); +void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id); +int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, + uint var_ie_len, int cam_idx); + +/* for sta/adhoc mode */ +void update_sta_info(struct adapter *padapter, struct sta_info *psta); +unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz); +unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz); +unsigned int update_MSC_rate(struct HT_caps_element *pHT_caps); +void Update_RA_Entry(struct adapter *padapter, u32 mac_id); +void set_sta_rate(struct adapter *padapter, struct sta_info *psta); + +unsigned int receive_disconnect(struct adapter *padapter, + unsigned char *macaddr, unsigned short reason); + +unsigned char get_highest_rate_idx(u32 mask); +int support_short_GI(struct adapter *padapter, struct HT_caps_element *caps); +unsigned int is_ap_in_tkip(struct adapter *padapter); +unsigned int is_ap_in_wep(struct adapter *padapter); +unsigned int should_forbid_n_rate(struct adapter *padapter); + +void report_join_res(struct adapter *padapter, int res); +void report_survey_event(struct adapter *padapter, struct recv_frame *precv_frame); +void report_surveydone_event(struct adapter *padapter); +void report_del_sta_event(struct adapter *padapter, + unsigned char *addr, unsigned short reason); +void report_add_sta_event(struct adapter *padapter, unsigned char* addr, + int cam_idx); + +void beacon_timing_control(struct adapter *padapter); +extern u8 set_tx_beacon_cmd(struct adapter*padapter); +unsigned int setup_beacon_frame(struct adapter *padapter, + unsigned char *beacon_frame); +void update_mgnt_tx_rate(struct adapter *padapter, u8 rate); +void update_mgntframe_attrib(struct adapter *padapter, + struct pkt_attrib *pattrib); +void dump_mgntframe(struct adapter *padapter, struct xmit_frame *pmgntframe); +s32 dump_mgntframe_and_wait(struct adapter *padapter, + struct xmit_frame *pmgntframe, int timeout_ms); +s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, + struct xmit_frame *pmgntframe); + +#ifdef CONFIG_88EU_P2P +void issue_probersp_p2p(struct adapter *padapter, unsigned char *da); +void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, + u8 ussidlen, u8 *pdev_raddr); +void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr); +void issue_probereq_p2p(struct adapter *padapter, u8 *da); +int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, + int wait_ms); +void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, + u8 dialogToken, u8 success); +void issue_p2p_invitation_request(struct adapter *padapter, u8* raddr); +#endif /* CONFIG_88EU_P2P */ +void issue_beacon(struct adapter *padapter, int timeout_ms); +void issue_probersp(struct adapter *padapter, unsigned char *da, + u8 is_valid_p2p_probereq); +void issue_assocreq(struct adapter *padapter); +void issue_asocrsp(struct adapter *padapter, unsigned short status, + struct sta_info *pstat, int pkt_type); +void issue_auth(struct adapter *padapter, struct sta_info *psta, + unsigned short status); +void issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, + u8 *da); +s32 issue_probereq_ex(struct adapter *adapter, struct ndis_802_11_ssid *pssid, + u8* da, int try_cnt, int wait_ms); +int issue_nulldata(struct adapter *padapter, unsigned char *da, + unsigned int power_mode, int try_cnt, int wait_ms); +int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, + u16 tid, int try_cnt, int wait_ms); +int issue_deauth(struct adapter *padapter, unsigned char *da, + unsigned short reason); +int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, + int try_cnt, int wait_ms); +void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, + u8 ch_offset); +void issue_action_BA(struct adapter *padapter, unsigned char *raddr, + unsigned char action, unsigned short status); +unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr); +unsigned int send_beacon(struct adapter *padapter); + +void start_clnt_assoc(struct adapter *padapter); +void start_clnt_auth(struct adapter *padapter); +void start_clnt_join(struct adapter *padapter); +void start_create_ibss(struct adapter *padapter); + +unsigned int OnAssocReq(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAssocRsp(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnProbeReq(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnProbeRsp(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int DoReserved(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnBeacon(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAtim(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnDisassoc(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAuth(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAuthClient(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnDeAuth(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction(struct adapter *padapter, + struct recv_frame *precv_frame); + +unsigned int on_action_spct(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction_qos(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction_dls(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction_back(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int on_action_public(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction_ht(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction_wmm(struct adapter *padapter, + struct recv_frame *precv_frame); +unsigned int OnAction_p2p(struct adapter *padapter, + struct recv_frame *precv_frame); + +void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); +void mlmeext_sta_del_event_callback(struct adapter *padapter); +void mlmeext_sta_add_event_callback(struct adapter *padapter, + struct sta_info *psta); + +void linked_status_chk(struct adapter *padapter); + +void survey_timer_hdl (struct adapter *padapter); +void link_timer_hdl (struct adapter *padapter); +void addba_timer_hdl(struct sta_info *psta); + +#define set_survey_timer(mlmeext, ms) \ + do { \ + _set_timer(&(mlmeext)->survey_timer, (ms)); \ + } while (0) + +#define set_link_timer(mlmeext, ms) \ + do { \ + _set_timer(&(mlmeext)->link_timer, (ms)); \ + } while (0) + +int cckrates_included(unsigned char *rate, int ratelen); +int cckratesonly_included(unsigned char *rate, int ratelen); + +void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr); + +void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len); +void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext); + +struct cmd_hdl { + uint parmsize; + u8 (*h2cfuns)(struct adapter *padapter, u8 *pbuf); +}; + +u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf); +u8 NULL_hdl(struct adapter *padapter, u8 *pbuf); +u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf); +u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf); +u8 createbss_hdl(struct adapter *padapter, u8 *pbuf); +u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf); +u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf); +u8 setauth_hdl(struct adapter *padapter, u8 *pbuf); +u8 setkey_hdl(struct adapter *padapter, u8 *pbuf); +u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf); +u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf); +u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf); +u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf); + +u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf); +u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf); +/* Handling DFS channel switch announcement ie. */ +u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf); +u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf); + +#define GEN_DRV_CMD_HANDLER(size, cmd) {size, &cmd ## _hdl}, +#define GEN_MLME_EXT_HANDLER(size, cmd) {size, cmd}, + +#ifdef _RTW_CMD_C_ + +static struct cmd_hdl wlancmds[] = { + GEN_DRV_CMD_HANDLER(0, NULL) /*0*/ + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_DRV_CMD_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) /*10*/ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct joinbss_parm), join_cmd_hdl) /*14*/ + GEN_MLME_EXT_HANDLER(sizeof (struct disconnect_parm), disconnect_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct createbss_parm), createbss_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct setopmode_parm), setopmode_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct sitesurvey_parm), + sitesurvey_cmd_hdl) /*18*/ + GEN_MLME_EXT_HANDLER(sizeof (struct setauth_parm), setauth_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct setkey_parm), setkey_hdl) /*20*/ + GEN_MLME_EXT_HANDLER(sizeof (struct set_stakey_parm), set_stakey_hdl) + GEN_MLME_EXT_HANDLER(sizeof (struct set_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct del_assocsta_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setstapwrstate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setbasicrate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getbasicrate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setdatarate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getdatarate_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct setphyinfo_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getphyinfo_parm), NULL) /*30*/ + GEN_MLME_EXT_HANDLER(sizeof (struct setphy_parm), NULL) + GEN_MLME_EXT_HANDLER(sizeof (struct getphy_parm), NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) /*40*/ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct addBaReq_parm), add_ba_hdl) + GEN_MLME_EXT_HANDLER(sizeof(struct set_ch_parm), set_ch_hdl) /* 46 */ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) /*50*/ + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(0, NULL) + GEN_MLME_EXT_HANDLER(sizeof(struct Tx_Beacon_param), + tx_beacon_hdl) /*55*/ + + GEN_MLME_EXT_HANDLER(0, mlme_evt_hdl) /*56*/ + GEN_MLME_EXT_HANDLER(0, rtw_drvextra_cmd_hdl) /*57*/ + + GEN_MLME_EXT_HANDLER(0, h2c_msg_hdl) /*58*/ + GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelPlan_param), + set_chplan_hdl) /*59*/ + GEN_MLME_EXT_HANDLER(sizeof(struct LedBlink_param), + led_blink_hdl) /*60*/ + + GEN_MLME_EXT_HANDLER(sizeof(struct SetChannelSwitch_param), + set_csa_hdl) /*61*/ + GEN_MLME_EXT_HANDLER(sizeof(struct TDLSoption_param), + tdls_hdl) /*62*/ +}; + +#endif + +struct C2HEvent_Header { +#ifdef __LITTLE_ENDIAN + unsigned int len:16; + unsigned int ID:8; + unsigned int seq:8; +#elif defined(__BIG_ENDIAN) + unsigned int seq:8; + unsigned int ID:8; + unsigned int len:16; +#endif + unsigned int rsvd; +}; + +void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf); +void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf); + +enum rtw_c2h_event { + GEN_EVT_CODE(_Read_MACREG) = 0, /*0*/ + GEN_EVT_CODE(_Read_BBREG), + GEN_EVT_CODE(_Read_RFREG), + GEN_EVT_CODE(_Read_EEPROM), + GEN_EVT_CODE(_Read_EFUSE), + GEN_EVT_CODE(_Read_CAM), /*5*/ + GEN_EVT_CODE(_Get_BasicRate), + GEN_EVT_CODE(_Get_DataRate), + GEN_EVT_CODE(_Survey), /*8*/ + GEN_EVT_CODE(_SurveyDone), /*9*/ + + GEN_EVT_CODE(_JoinBss) , /*10*/ + GEN_EVT_CODE(_AddSTA), + GEN_EVT_CODE(_DelSTA), + GEN_EVT_CODE(_AtimDone), + GEN_EVT_CODE(_TX_Report), + GEN_EVT_CODE(_CCX_Report), /*15*/ + GEN_EVT_CODE(_DTM_Report), + GEN_EVT_CODE(_TX_Rate_Statistics), + GEN_EVT_CODE(_C2HLBK), + GEN_EVT_CODE(_FWDBG), + GEN_EVT_CODE(_C2HFEEDBACK), /*20*/ + GEN_EVT_CODE(_ADDBA), + GEN_EVT_CODE(_C2HBCN), + GEN_EVT_CODE(_ReportPwrState), /* filen: only for PCIE, USB */ + GEN_EVT_CODE(_CloseRF), /* filen: only for PCIE, + * work around ASPM */ + MAX_C2HEVT +}; + +#ifdef _RTW_MLME_EXT_C_ + +static struct fwevent wlanevents[] = { + {0, rtw_dummy_event_callback}, /*0*/ + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, &rtw_survey_event_callback}, /*8*/ + {sizeof (struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ + {0, &rtw_joinbss_event_callback}, /*10*/ + {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, + {sizeof(struct stadel_event), &rtw_stadel_event_callback}, + {0, &rtw_atimdone_event_callback}, + {0, rtw_dummy_event_callback}, + {0, NULL}, /*15*/ + {0, NULL}, + {0, NULL}, + {0, NULL}, + {0, rtw_fwdbg_event_callback}, + {0, NULL}, /*20*/ + {0, NULL}, + {0, NULL}, + {0, &rtw_cpwm_event_callback}, + {0, NULL}, +}; + +#endif/* _RTL_MLME_EXT_C_ */ + +#endif /* __RTW_MLME_EXT_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_mp.h b/drivers/staging/r8188eu/include/rtw_mp.h new file mode 100644 index 000000000000..9111e58e0598 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_mp.h @@ -0,0 +1,492 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_MP_H_ +#define _RTW_MP_H_ + +/* 00 - Success */ +/* 11 - Error */ +#define STATUS_SUCCESS (0x00000000L) +#define STATUS_PENDING (0x00000103L) + +#define STATUS_UNSUCCESSFUL (0xC0000001L) +#define STATUS_INSUFFICIENT_RESOURCES (0xC000009AL) +#define STATUS_NOT_SUPPORTED (0xC00000BBL) + +#define NDIS_STATUS_SUCCESS ((int)STATUS_SUCCESS) +#define NDIS_STATUS_PENDING ((int)STATUS_PENDING) +#define NDIS_STATUS_NOT_RECOGNIZED ((int)0x00010001L) +#define NDIS_STATUS_NOT_COPIED ((int)0x00010002L) +#define NDIS_STATUS_NOT_ACCEPTED ((int)0x00010003L) +#define NDIS_STATUS_CALL_ACTIVE ((int)0x00010007L) + +#define NDIS_STATUS_FAILURE ((int)STATUS_UNSUCCESSFUL) +#define NDIS_STATUS_RESOURCES ((int)STATUS_INSUFFICIENT_RESOURCES) +#define NDIS_STATUS_CLOSING ((int)0xC0010002L) +#define NDIS_STATUS_BAD_VERSION ((int)0xC0010004L) +#define NDIS_STATUS_BAD_CHARACTERISTICS ((int)0xC0010005L) +#define NDIS_STATUS_ADAPTER_NOT_FOUND ((int)0xC0010006L) +#define NDIS_STATUS_OPEN_FAILED ((int)0xC0010007L) +#define NDIS_STATUS_DEVICE_FAILED ((int)0xC0010008L) +#define NDIS_STATUS_MULTICAST_FULL ((int)0xC0010009L) +#define NDIS_STATUS_MULTICAST_EXISTS ((int)0xC001000AL) +#define NDIS_STATUS_MULTICAST_NOT_FOUND ((int)0xC001000BL) +#define NDIS_STATUS_REQUEST_ABORTED ((int)0xC001000CL) +#define NDIS_STATUS_RESET_IN_PROGRESS ((int)0xC001000DL) +#define NDIS_STATUS_CLOSING_INDICATING ((int)0xC001000EL) +#define NDIS_STATUS_NOT_SUPPORTED ((int)STATUS_NOT_SUPPORTED) +#define NDIS_STATUS_INVALID_PACKET ((int)0xC001000FL) +#define NDIS_STATUS_OPEN_LIST_FULL ((int)0xC0010010L) +#define NDIS_STATUS_ADAPTER_NOT_READY ((int)0xC0010011L) +#define NDIS_STATUS_ADAPTER_NOT_OPEN ((int)0xC0010012L) +#define NDIS_STATUS_NOT_INDICATING ((int)0xC0010013L) +#define NDIS_STATUS_INVALID_LENGTH ((int)0xC0010014L) +#define NDIS_STATUS_INVALID_DATA ((int)0xC0010015L) +#define NDIS_STATUS_BUFFER_TOO_SHORT ((int)0xC0010016L) +#define NDIS_STATUS_INVALID_OID ((int)0xC0010017L) +#define NDIS_STATUS_ADAPTER_REMOVED ((int)0xC0010018L) +#define NDIS_STATUS_UNSUPPORTED_MEDIA ((int)0xC0010019L) +#define NDIS_STATUS_GROUP_ADDRESS_IN_USE ((int)0xC001001AL) +#define NDIS_STATUS_FILE_NOT_FOUND ((int)0xC001001BL) +#define NDIS_STATUS_ERROR_READING_FILE ((int)0xC001001CL) +#define NDIS_STATUS_ALREADY_MAPPED ((int)0xC001001DL) +#define NDIS_STATUS_RESOURCE_CONFLICT ((int)0xC001001EL) +#define NDIS_STATUS_NO_CABLE ((int)0xC001001FL) + +#define NDIS_STATUS_INVALID_SAP ((int)0xC0010020L) +#define NDIS_STATUS_SAP_IN_USE ((int)0xC0010021L) +#define NDIS_STATUS_INVALID_ADDRESS ((int)0xC0010022L) +#define NDIS_STATUS_VC_NOT_ACTIVATED ((int)0xC0010023L) +#define NDIS_STATUS_DEST_OUT_OF_ORDER ((int)0xC0010024L) /*cause 27*/ +#define NDIS_STATUS_VC_NOT_AVAILABLE ((int)0xC0010025L) /*cause 35,45 */ +#define NDIS_STATUS_CELLRATE_NOT_AVAILABLE ((int)0xC0010026L) /*cause 37*/ +#define NDIS_STATUS_INCOMPATABLE_QOS ((int)0xC0010027L) /*cause 49*/ +#define NDIS_STATUS_AAL_PARAMS_UNSUPPORTED ((int)0xC0010028L) /*cause 93*/ +#define NDIS_STATUS_NO_ROUTE_TO_DESTINATION ((int)0xC0010029L) /*cause 3 */ + +enum antenna_path { + ANTENNA_NONE = 0x00, + ANTENNA_D, + ANTENNA_C, + ANTENNA_CD, + ANTENNA_B, + ANTENNA_BD, + ANTENNA_BC, + ANTENNA_BCD, + ANTENNA_A, + ANTENNA_AD, + ANTENNA_AC, + ANTENNA_ACD, + ANTENNA_AB, + ANTENNA_ABD, + ANTENNA_ABC, + ANTENNA_ABCD +}; + +#define MAX_MP_XMITBUF_SZ 2048 +#define NR_MP_XMITFRAME 8 + +struct mp_xmit_frame { + struct list_head list; + struct pkt_attrib attrib; + struct sk_buff *pkt; + int frame_tag; + struct adapter *padapter; + struct urb *pxmit_urb[8]; + /* insert urb, irp, and irpcnt info below... */ + u8 *mem_addr; + u32 sz[8]; + u8 bpending[8]; + int ac_tag[8]; + int last[8]; + uint irpcnt; + uint fragcnt; + uint mem[(MAX_MP_XMITBUF_SZ >> 2)]; +}; + +struct mp_wiparam { + u32 bcompleted; + u32 act_type; + u32 io_offset; + u32 io_value; +}; + +typedef void(*wi_act_func)(void *padapter); + +struct mp_tx { + u8 stop; + u32 count, sended; + u8 payload; + struct pkt_attrib attrib; + struct tx_desc desc; + u8 *pallocated_buf; + u8 *buf; + u32 buf_size, write_size; + void *PktTxThread; +}; + +#include + +#define MP_MAX_LINES 1000 +#define MP_MAX_LINES_BYTES 256 + +typedef void (*MPT_WORK_ITEM_HANDLER)(void *Adapter); + +struct mpt_context { + /* Indicate if we have started Mass Production Test. */ + bool bMassProdTest; + + /* Indicate if the driver is unloading or unloaded. */ + bool bMptDrvUnload; + + struct semaphore MPh2c_Sema; + struct timer_list MPh2c_timeout_timer; +/* Event used to sync H2c for BT control */ + + bool MptH2cRspEvent; + bool MptBtC2hEvent; + bool bMPh2c_timeout; + + /* 8190 PCI does not support NDIS_WORK_ITEM. */ + /* Work Item for Mass Production Test. */ + /* Event used to sync the case unloading driver and MptWorkItem + * is still in progress. */ + /* Indicate a MptWorkItem is scheduled and not yet finished. */ + bool bMptWorkItemInProgress; + /* An instance which implements function and context of MptWorkItem. */ + MPT_WORK_ITEM_HANDLER CurrMptAct; + + /* 1=Start, 0=Stop from UI. */ + u32 MptTestStart; + /* _TEST_MODE, defined in MPT_Req2.h */ + u32 MptTestItem; + /* Variable needed in each implementation of CurrMptAct. */ + u32 MptActType; /* Type of action performed in CurrMptAct. */ + /* The Offset of IO operation is depend of MptActType. */ + u32 MptIoOffset; + /* The Value of IO operation is depend of MptActType. */ + u32 MptIoValue; + /* The RfPath of IO operation is depend of MptActType. */ + u32 MptRfPath; + + enum wireless_mode MptWirelessModeToSw; /* Wireless mode to switch. */ + u8 MptChannelToSw; /* Channel to switch. */ + u8 MptInitGainToSet; /* Initial gain to set. */ + u32 MptBandWidth; /* bandwidth to switch. */ + u32 MptRateIndex; /* rate index. */ + /* Register value kept for Single Carrier Tx test. */ + u8 btMpCckTxPower; + /* Register value kept for Single Carrier Tx test. */ + u8 btMpOfdmTxPower; + /* For MP Tx Power index */ + u8 TxPwrLevel[2]; /* rf-A, rf-B */ + + /* Content of RCR Regsiter for Mass Production Test. */ + u32 MptRCR; + /* true if we only receive packets with specific pattern. */ + bool bMptFilterPattern; + /* Rx OK count, statistics used in Mass Production Test. */ + u32 MptRxOkCnt; + /* Rx CRC32 error count, statistics used in Mass Production Test. */ + u32 MptRxCrcErrCnt; + + bool bCckContTx; /* true if we are in CCK Continuous Tx test. */ + bool bOfdmContTx; /* true if we are in OFDM Continuous Tx test. */ + bool bStartContTx; /* true if we have start Continuous Tx test. */ + /* true if we are in Single Carrier Tx test. */ + bool bSingleCarrier; + /* true if we are in Carrier Suppression Tx Test. */ + bool bCarrierSuppression; + /* true if we are in Single Tone Tx test. */ + bool bSingleTone; + + /* ACK counter asked by K.Y.. */ + bool bMptEnableAckCounter; + u32 MptAckCounter; + + u8 APK_bound[2]; /* for APK path A/path B */ + bool bMptIndexEven; + + u8 backup0xc50; + u8 backup0xc58; + u8 backup0xc30; + u8 backup0x52_RF_A; + u8 backup0x52_RF_B; + + u8 h2cReqNum; + u8 c2hBuf[20]; + + u8 btInBuf[100]; + u32 mptOutLen; + u8 mptOutBuf[100]; +}; + +enum { + WRITE_REG = 1, + READ_REG, + WRITE_RF, + READ_RF, + MP_START, + MP_STOP, + MP_RATE, + MP_CHANNEL, + MP_BANDWIDTH, + MP_TXPOWER, + MP_ANT_TX, + MP_ANT_RX, + MP_CTX, + MP_QUERY, + MP_ARX, + MP_PSD, + MP_PWRTRK, + MP_THER, + MP_IOCTL, + EFUSE_GET, + EFUSE_SET, + MP_RESET_STATS, + MP_DUMP, + MP_PHYPARA, + MP_SetRFPathSwh, + MP_QueryDrvStats, + MP_SetBT, + CTA_TEST, + MP_NULL, +}; + +struct mp_priv { + struct adapter *papdater; + + /* Testing Flag */ + /* 0 for normal type packet, 1 for loopback packet (16bytes TXCMD) */ + u32 mode; + + u32 prev_fw_state; + + /* OID cmd handler */ + struct mp_wiparam workparam; + + /* Tx Section */ + u8 TID; + u32 tx_pktcount; + struct mp_tx tx; + + /* Rx Section */ + u32 rx_pktcount; + u32 rx_crcerrpktcount; + u32 rx_pktloss; + + struct recv_stat rxstat; + + /* RF/BB relative */ + u8 channel; + u8 bandwidth; + u8 prime_channel_offset; + u8 txpoweridx; + u8 txpoweridx_b; + u8 rateidx; + u32 preamble; + u32 CrystalCap; + + u16 antenna_tx; + u16 antenna_rx; + + u8 check_mp_pkt; + + u8 bSetTxPower; + + struct wlan_network mp_network; + unsigned char network_macaddr[ETH_ALEN]; + + u8 *pallocated_mp_xmitframe_buf; + u8 *pmp_xmtframe_buf; + struct __queue free_mp_xmitqueue; + u32 free_mp_xmitframe_cnt; + + struct mpt_context MptCtx; +}; + +struct iocmd_struct { + u8 cmdclass; + u16 value; + u8 index; +}; + +struct rf_reg_param { + u32 path; + u32 offset; + u32 value; +}; + +struct bb_reg_param { + u32 offset; + u32 value; +}; +/* */ + +#define LOWER true +#define RAISE false + +/* Hardware Registers */ +#define BB_REG_BASE_ADDR 0x800 + +/* MP variables */ +enum mp_mode_{ + MP_OFF, + MP_ON, + MP_ERR, + MP_CONTINUOUS_TX, + MP_SINGLE_CARRIER_TX, + MP_CARRIER_SUPPRISSION_TX, + MP_SINGLE_TONE_TX, + MP_PACKET_TX, + MP_PACKET_RX +}; + +extern u8 mpdatarate[NumRates]; + +/* MP set force data rate base on the definition. */ +enum mpt_rate_index { + /* CCK rate. */ + MPT_RATE_1M, /* 0 */ + MPT_RATE_2M, + MPT_RATE_55M, + MPT_RATE_11M, /* 3 */ + + /* OFDM rate. */ + MPT_RATE_6M, /* 4 */ + MPT_RATE_9M, + MPT_RATE_12M, + MPT_RATE_18M, + MPT_RATE_24M, + MPT_RATE_36M, + MPT_RATE_48M, + MPT_RATE_54M, /* 11 */ + + /* HT rate. */ + MPT_RATE_MCS0, /* 12 */ + MPT_RATE_MCS1, + MPT_RATE_MCS2, + MPT_RATE_MCS3, + MPT_RATE_MCS4, + MPT_RATE_MCS5, + MPT_RATE_MCS6, + MPT_RATE_MCS7, /* 19 */ + MPT_RATE_MCS8, + MPT_RATE_MCS9, + MPT_RATE_MCS10, + MPT_RATE_MCS11, + MPT_RATE_MCS12, + MPT_RATE_MCS13, + MPT_RATE_MCS14, + MPT_RATE_MCS15, /* 27 */ + MPT_RATE_LAST +}; + +#define MAX_TX_PWR_INDEX_N_MODE 64 /* 0x3F */ + +enum power_mode { + POWER_LOW = 0, + POWER_NORMAL +}; + +#define RX_PKT_BROADCAST 1 +#define RX_PKT_DEST_ADDR 2 +#define RX_PKT_PHY_MATCH 3 + +enum encry_ctrl_state { + HW_CONTROL, /* hw encryption& decryption */ + SW_CONTROL, /* sw encryption& decryption */ + HW_ENCRY_SW_DECRY, /* hw encryption & sw decryption */ + SW_ENCRY_HW_DECRY /* sw encryption & hw decryption */ +}; + +s32 init_mp_priv(struct adapter *padapter); +void free_mp_priv(struct mp_priv *pmp_priv); +s32 MPT_InitializeAdapter(struct adapter *padapter, u8 Channel); +void MPT_DeInitAdapter(struct adapter *padapter); +s32 mp_start_test(struct adapter *padapter); +void mp_stop_test(struct adapter *padapter); + +u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask); +void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val); + +u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz); +void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz); +u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask); +void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val); +u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr); +void write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 val); + +void SetChannel(struct adapter *pAdapter); +void SetBandwidth(struct adapter *pAdapter); +void SetTxPower(struct adapter *pAdapter); +void SetAntennaPathPower(struct adapter *pAdapter); +void SetDataRate(struct adapter *pAdapter); + +void SetAntenna(struct adapter *pAdapter); + +s32 SetThermalMeter(struct adapter *pAdapter, u8 target_ther); +void GetThermalMeter(struct adapter *pAdapter, u8 *value); + +void SetContinuousTx(struct adapter *pAdapter, u8 bStart); +void SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart); +void SetSingleToneTx(struct adapter *pAdapter, u8 bStart); +void SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart); +void PhySetTxPowerLevel(struct adapter *pAdapter); + +void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc); +void SetPacketTx(struct adapter *padapter); +void SetPacketRx(struct adapter *pAdapter, u8 bStartRx); + +void ResetPhyRxPktCount(struct adapter *pAdapter); +u32 GetPhyRxPktReceived(struct adapter *pAdapter); +u32 GetPhyRxPktCRC32Error(struct adapter *pAdapter); + +s32 SetPowerTracking(struct adapter *padapter, u8 enable); +void GetPowerTracking(struct adapter *padapter, u8 *enable); +u32 mp_query_psd(struct adapter *pAdapter, u8 *data); +void Hal_SetAntenna(struct adapter *pAdapter); +void Hal_SetBandwidth(struct adapter *pAdapter); +void Hal_SetTxPower(struct adapter *pAdapter); +void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart); +void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart); +void Hal_SetSingleCarrierTx (struct adapter *pAdapter, u8 bStart); +void Hal_SetContinuousTx (struct adapter *pAdapter, u8 bStart); +void Hal_SetBandwidth(struct adapter *pAdapter); +void Hal_SetDataRate(struct adapter *pAdapter); +void Hal_SetChannel(struct adapter *pAdapter); +void Hal_SetAntennaPathPower(struct adapter *pAdapter); +s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther); +s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable); +void Hal_GetPowerTracking(struct adapter *padapter, u8 * enable); +void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value); +void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter); +void Hal_MPT_CCKTxPowerAdjust(struct adapter * Adapter, bool bInCH14); +void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven); +void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 * TxPower); +void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 * TxPower); +void Hal_TriggerRFThermalMeter(struct adapter *pAdapter); +u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter); +void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart); +void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart); +void Hal_ProSetCrystalCap (struct adapter *pAdapter , u32 CrystalCapVal); +void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv); +void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter ,bool bMain); + +#endif /* _RTW_MP_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h new file mode 100644 index 000000000000..12835e448d80 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h @@ -0,0 +1,339 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_MP_IOCTL_H_ +#define _RTW_MP_IOCTL_H_ + +#include +#include +#include +#include +#include +#include + +/* */ +struct cfg_dbg_msg_struct { + u32 DebugLevel; + u32 DebugComponent_H32; + u32 DebugComponent_L32; +}; + +struct mp_rw_reg { + u32 offset; + u32 width; + u32 value; +}; + +struct efuse_access_struct { + u16 start_addr; + u16 cnts; + u8 data[0]; +}; + +struct burst_rw_reg { + u32 offset; + u32 len; + u8 Data[256]; +}; + +struct usb_vendor_req { + u8 bRequest; + u16 wValue; + u16 wIndex; + u16 wLength; + u8 u8Dir;/* 0:OUT, 1:IN */ + u8 u8InData; +}; + +struct dr_variable_struct { + u8 offset; + u32 variable; +}; + +#define _irqlevel_changed_(a, b) + +/* rtl8188eu_oid_rtl_seg_81_80_00 */ +int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_81_80_20 */ +int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_pro_set_modulation_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_81_87 */ +int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_81_85 */ +int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_87_11_00 */ +int rtl8188eu_oid_rt_pro8711_join_bss_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_burst_read_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_burst_write_register_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_txcmd_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro8711_wi_poll_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro8711_pkt_loss_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_rf_intfs_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_poll_rx_status_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_87_11_20 */ +int rtl8188eu_oid_rt_pro_cfg_debug_message_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_basic_rate_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_tssi_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_87_11_50 */ +int rtl8188eu_oid_rt_pro_qry_pwrstate_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_pwrstate_hdl(struct oid_par_priv *poid_par_priv); +/* rtl8188eu_oid_rtl_seg_87_11_F0 */ +int rtl8188eu_oid_rt_pro_h2c_set_rate_table_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_h2c_get_rate_table_hdl(struct oid_par_priv *poid_par_priv); + +/* rtl8188eu_oid_rtl_seg_87_12_00 */ +int rtl8188eu_oid_rt_pro_encryption_ctrl_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_add_sta_info_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_dele_sta_info_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_query_dr_variable_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_efuse_current_size_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_tx_agc_offset_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_set_pkt_test_mode_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_reset_phy_rx_packet_count_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); +int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv); +int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv); + +#ifdef _RTW_MP_IOCTL_C_ + +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_00[] = { + {1, &oid_null_function}, /* 0x00 OID_RT_PRO_RESET_DUT */ + {1, &rtl8188eu_oid_rt_pro_set_data_rate_hdl}, /* 0x01 */ + {1, &rtl8188eu_oid_rt_pro_start_test_hdl}, /* 0x02 */ + {1, &rtl8188eu_oid_rt_pro_stop_test_hdl}, /* 0x03 */ + {1, &oid_null_function}, /* 0x04 OID_RT_PRO_SET_PREAMBLE */ + {1, &oid_null_function}, /* 0x05 OID_RT_PRO_SET_SCRAMBLER */ + {1, &oid_null_function}, /* 0x06 OID_RT_PRO_SET_FILTER_BB */ + {1, &oid_null_function},/* 0x07 OID_RT_PRO_SET_MANUAL_DIVERSITY_BB */ + {1, &rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl}, /* 0x08 */ + {1, &oid_null_function},/* 0x09 OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL */ + {1, &oid_null_function},/* 0x0A OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL */ + {1, &rtl8188eu_oid_rt_pro_set_continuous_tx_hdl}, /* 0x0B OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL */ + {1, &rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl},/* 0x0C OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS */ + {1, &oid_null_function}, /* 0x0D OID_RT_PRO_SET_TX_ANTENNA_BB */ + {1, &rtl8188eu_oid_rt_pro_set_antenna_bb_hdl}, /* 0x0E */ + {1, &oid_null_function}, /* 0x0F OID_RT_PRO_SET_CR_SCRAMBLER */ + {1, &oid_null_function}, /* 0x10 OID_RT_PRO_SET_CR_NEW_FILTER */ + {1, &rtl8188eu_oid_rt_pro_set_tx_power_control_hdl},/* 0x11 OID_RT_PRO_SET_TX_POWER_CONTROL */ + {1, &oid_null_function}, /* 0x12 OID_RT_PRO_SET_CR_TX_CONFIG */ + {1, &oid_null_function}, /* 0x13 OID_RT_PRO_GET_TX_POWER_CONTROL */ + {1, &oid_null_function}, /* 0x14 OID_RT_PRO_GET_CR_SIGNAL_QUALITY */ + {1, &oid_null_function}, /* 0x15 OID_RT_PRO_SET_CR_SETPOINT */ + {1, &oid_null_function}, /* 0x16 OID_RT_PRO_SET_INTEGRATOR */ + {1, &oid_null_function}, /* 0x17 OID_RT_PRO_SET_SIGNAL_QUALITY */ + {1, &oid_null_function}, /* 0x18 OID_RT_PRO_GET_INTEGRATOR */ + {1, &oid_null_function}, /* 0x19 OID_RT_PRO_GET_SIGNAL_QUALITY */ + {1, &oid_null_function}, /* 0x1A OID_RT_PRO_QUERY_EEPROM_TYPE */ + {1, &oid_null_function}, /* 0x1B OID_RT_PRO_WRITE_MAC_ADDRESS */ + {1, &oid_null_function}, /* 0x1C OID_RT_PRO_READ_MAC_ADDRESS */ + {1, &oid_null_function}, /* 0x1D OID_RT_PRO_WRITE_CIS_DATA */ + {1, &oid_null_function}, /* 0x1E OID_RT_PRO_READ_CIS_DATA */ + {1, &oid_null_function} /* 0x1F OID_RT_PRO_WRITE_POWER_CONTROL */ +}; + +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_20[] = { + {1, &oid_null_function}, /* 0x20 OID_RT_PRO_READ_POWER_CONTROL */ + {1, &oid_null_function}, /* 0x21 OID_RT_PRO_WRITE_EEPROM */ + {1, &oid_null_function}, /* 0x22 OID_RT_PRO_READ_EEPROM */ + {1, &rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl}, /* 0x23 */ + {1, &rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl}, /* 0x24 */ + {1, &rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl}, /* 0x25 */ + {1, &rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl}, /* 0x26 */ + {1, &rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl}, /* 0x27 */ + {1, &oid_null_function}, /* 0x28 OID_RT_PRO_QUERY_CURRENT_ADDRESS */ + {1, &oid_null_function}, /* 0x29 OID_RT_PRO_QUERY_PERMANENT_ADDRESS */ + {1, &oid_null_function}, /* 0x2A OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS */ + {1, &rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl},/* 0x2B OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX */ + {1, &oid_null_function}, /* 0x2C OID_RT_PRO_RECEIVE_PACKET */ + {1, &oid_null_function}, /* 0x2D OID_RT_PRO_WRITE_EEPROM_BYTE */ + {1, &oid_null_function}, /* 0x2E OID_RT_PRO_READ_EEPROM_BYTE */ + {1, &rtl8188eu_oid_rt_pro_set_modulation_hdl} /* 0x2F */ +}; + +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_40[] = { + {1, &oid_null_function}, /* 0x40 */ + {1, &oid_null_function}, /* 0x41 */ + {1, &oid_null_function}, /* 0x42 */ + {1, &rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl}, /* 0x43 */ + {1, &oid_null_function}, /* 0x44 */ + {1, &oid_null_function} /* 0x45 */ +}; + +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_80[] = { + {1, &oid_null_function}, /* 0x80 OID_RT_DRIVER_OPTION */ + {1, &oid_null_function}, /* 0x81 OID_RT_RF_OFF */ + {1, &oid_null_function} /* 0x82 OID_RT_AUTH_STATUS */ +}; + +static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_85[] = { + {1, &rtl8188eu_oid_rt_wireless_mode_hdl} /* 0x00 OID_RT_WIRELESS_MODE */ +}; + +#endif /* _RTL871X_MP_IOCTL_C_ */ + +struct rwreg_param { + u32 offset; + u32 width; + u32 value; +}; + +struct bbreg_param { + u32 offset; + u32 phymask; + u32 value; +}; + +struct txpower_param { + u32 pwr_index; +}; + +struct datarate_param { + u32 rate_index; +}; + +struct rfintfs_parm { + u32 rfintfs; +}; + +struct mp_xmit_parm { + u8 enable; + u32 count; + u16 length; + u8 payload_type; + u8 da[ETH_ALEN]; +}; + +struct mp_xmit_packet { + u32 len; + u32 mem[MAX_MP_XMITBUF_SZ >> 2]; +}; + +struct psmode_param { + u32 ps_mode; + u32 smart_ps; +}; + +/* for OID_RT_PRO_READ16_EEPROM & OID_RT_PRO_WRITE16_EEPROM */ +struct eeprom_rw_param { + u32 offset; + u16 value; +}; + +struct mp_ioctl_handler { + u32 paramsize; + s32 (*handler)(struct oid_par_priv* poid_par_priv); + u32 oid; +}; + +struct mp_ioctl_param{ + u32 subcode; + u32 len; + u8 data[0]; +}; + +#define GEN_MP_IOCTL_SUBCODE(code) _MP_IOCTL_ ## code ## _CMD_ + +enum RTL871X_MP_IOCTL_SUBCODE { + GEN_MP_IOCTL_SUBCODE(MP_START), /*0*/ + GEN_MP_IOCTL_SUBCODE(MP_STOP), + GEN_MP_IOCTL_SUBCODE(READ_REG), + GEN_MP_IOCTL_SUBCODE(WRITE_REG), + GEN_MP_IOCTL_SUBCODE(READ_BB_REG), + GEN_MP_IOCTL_SUBCODE(WRITE_BB_REG), /*5*/ + GEN_MP_IOCTL_SUBCODE(READ_RF_REG), + GEN_MP_IOCTL_SUBCODE(WRITE_RF_REG), + GEN_MP_IOCTL_SUBCODE(SET_CHANNEL), + GEN_MP_IOCTL_SUBCODE(SET_TXPOWER), + GEN_MP_IOCTL_SUBCODE(SET_DATARATE), /*10*/ + GEN_MP_IOCTL_SUBCODE(SET_BANDWIDTH), + GEN_MP_IOCTL_SUBCODE(SET_ANTENNA), + GEN_MP_IOCTL_SUBCODE(CNTU_TX), + GEN_MP_IOCTL_SUBCODE(SC_TX), + GEN_MP_IOCTL_SUBCODE(CS_TX), /*15*/ + GEN_MP_IOCTL_SUBCODE(ST_TX), + GEN_MP_IOCTL_SUBCODE(IOCTL_XMIT_PACKET), + GEN_MP_IOCTL_SUBCODE(SET_RX_PKT_TYPE), + GEN_MP_IOCTL_SUBCODE(RESET_PHY_RX_PKT_CNT), + GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_RECV), /*20*/ + GEN_MP_IOCTL_SUBCODE(GET_PHY_RX_PKT_ERROR), + GEN_MP_IOCTL_SUBCODE(READ16_EEPROM), + GEN_MP_IOCTL_SUBCODE(WRITE16_EEPROM), + GEN_MP_IOCTL_SUBCODE(EFUSE), + GEN_MP_IOCTL_SUBCODE(EFUSE_MAP), /*25*/ + GEN_MP_IOCTL_SUBCODE(GET_EFUSE_MAX_SIZE), + GEN_MP_IOCTL_SUBCODE(GET_EFUSE_CURRENT_SIZE), + GEN_MP_IOCTL_SUBCODE(GET_THERMAL_METER), + GEN_MP_IOCTL_SUBCODE(SET_PTM), + GEN_MP_IOCTL_SUBCODE(SET_POWER_DOWN), /*30*/ + GEN_MP_IOCTL_SUBCODE(TRIGGER_GPIO), + GEN_MP_IOCTL_SUBCODE(SET_DM_BT), /*35*/ + GEN_MP_IOCTL_SUBCODE(DEL_BA), /*36*/ + GEN_MP_IOCTL_SUBCODE(GET_WIFI_STATUS), /*37*/ + MAX_MP_IOCTL_SUBCODE, +}; + +s32 rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv); + +#define GEN_HANDLER(sz, hdl, oid) {sz, hdl, oid}, + +#define EXT_MP_IOCTL_HANDLER(sz, subcode, oid) \ + {sz, rtl8188eu_mp_ioctl_##subcode##_hdl, oid}, + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h b/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h new file mode 100644 index 000000000000..ae4c9df7f42a --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h @@ -0,0 +1,1079 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +/***************************************************************************** + * + * Module: __RTW_MP_PHY_REGDEF_H_ + * + * + * Note: 1. Define PMAC/BB register map + * 2. Define RF register map + * 3. PMAC/BB register bit mask. + * 4. RF reg bit mask. + * 5. Other BB/RF relative definition. + * + * + * Export: Constants, macro, functions(API), global variables(None). + * + * Abbrev: + * + * History: + * Data Who Remark + * 08/07/2007 MHC 1. Porting from 9x series PHYCFG.h. + * 2. Reorganize code architecture. + * 09/25/2008 MH 1. Add RL6052 register definition + * + *****************************************************************************/ +#ifndef __RTW_MP_PHY_REGDEF_H_ +#define __RTW_MP_PHY_REGDEF_H_ + +/*--------------------------Define Parameters-------------------------------*/ + +/* */ +/* 8192S Regsiter offset definition */ +/* */ + +/* */ +/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ +/* 3. RF register 0x00-2E */ +/* 4. Bit Mask for BB/RF register */ +/* 5. Other definition for BB/RF R/W */ +/* */ + +/* */ +/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ +/* 1. Page1(0x100) */ +/* */ +#define rPMAC_Reset 0x100 +#define rPMAC_TxStart 0x104 +#define rPMAC_TxLegacySIG 0x108 +#define rPMAC_TxHTSIG1 0x10c +#define rPMAC_TxHTSIG2 0x110 +#define rPMAC_PHYDebug 0x114 +#define rPMAC_TxPacketNum 0x118 +#define rPMAC_TxIdle 0x11c +#define rPMAC_TxMACHeader0 0x120 +#define rPMAC_TxMACHeader1 0x124 +#define rPMAC_TxMACHeader2 0x128 +#define rPMAC_TxMACHeader3 0x12c +#define rPMAC_TxMACHeader4 0x130 +#define rPMAC_TxMACHeader5 0x134 +#define rPMAC_TxDataType 0x138 +#define rPMAC_TxRandomSeed 0x13c +#define rPMAC_CCKPLCPPreamble 0x140 +#define rPMAC_CCKPLCPHeader 0x144 +#define rPMAC_CCKCRC16 0x148 +#define rPMAC_OFDMRxCRC32OK 0x170 +#define rPMAC_OFDMRxCRC32Er 0x174 +#define rPMAC_OFDMRxParityEr 0x178 +#define rPMAC_OFDMRxCRC8Er 0x17c +#define rPMAC_CCKCRxRC16Er 0x180 +#define rPMAC_CCKCRxRC32Er 0x184 +#define rPMAC_CCKCRxRC32OK 0x188 +#define rPMAC_TxStatus 0x18c + +/* */ +/* 2. Page2(0x200) */ +/* */ +/* The following two definition are only used for USB interface. */ +/* define RF_BB_CMD_ADDR 0x02c0 RF/BB read/write command address. */ +/* define RF_BB_CMD_DATA 0x02c4 RF/BB read/write command data. */ + +/* */ +/* 3. Page8(0x800) */ +/* */ +#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC RF BW Setting?? */ + +#define rFPGA0_TxInfo 0x804 /* Status report?? */ +#define rFPGA0_PSDFunction 0x808 + +#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */ + +#define rFPGA0_RFTiming1 0x810 /* Useless now */ +#define rFPGA0_RFTiming2 0x814 +/* define rFPGA0_XC_RFTiming 0x818 */ +/* define rFPGA0_XD_RFTiming 0x81c */ + +#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */ +#define rFPGA0_XA_HSSIParameter2 0x824 +#define rFPGA0_XB_HSSIParameter1 0x828 +#define rFPGA0_XB_HSSIParameter2 0x82c +#define rFPGA0_XC_HSSIParameter1 0x830 +#define rFPGA0_XC_HSSIParameter2 0x834 +#define rFPGA0_XD_HSSIParameter1 0x838 +#define rFPGA0_XD_HSSIParameter2 0x83c +#define rFPGA0_XA_LSSIParameter 0x840 +#define rFPGA0_XB_LSSIParameter 0x844 +#define rFPGA0_XC_LSSIParameter 0x848 +#define rFPGA0_XD_LSSIParameter 0x84c + +#define rFPGA0_RFWakeUpParameter 0x850 /* Useless now */ +#define rFPGA0_RFSleepUpParameter 0x854 + +#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */ +#define rFPGA0_XCD_SwitchControl 0x85c + +#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ +#define rFPGA0_XB_RFInterfaceOE 0x864 +#define rFPGA0_XC_RFInterfaceOE 0x868 +#define rFPGA0_XD_RFInterfaceOE 0x86c + +#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Interface Software Control */ +#define rFPGA0_XCD_RFInterfaceSW 0x874 + +#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */ +#define rFPGA0_XCD_RFParameter 0x87c + +#define rFPGA0_AnalogParameter1 0x880 /* Crystal cap setting RF-R/W protection for parameter4?? */ +#define rFPGA0_AnalogParameter2 0x884 +#define rFPGA0_AnalogParameter3 0x888 /* Useless now */ +#define rFPGA0_AnalogParameter4 0x88c + +#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */ +#define rFPGA0_XB_LSSIReadBack 0x8a4 +#define rFPGA0_XC_LSSIReadBack 0x8a8 +#define rFPGA0_XD_LSSIReadBack 0x8ac + +#define rFPGA0_PSDReport 0x8b4 /* Useless now */ +#define rFPGA0_XAB_RFInterfaceRB 0x8e0 /* Useless now RF Interface Readback Value */ +#define rFPGA0_XCD_RFInterfaceRB 0x8e4 /* Useless now */ + +/* */ +/* 4. Page9(0x900) */ +/* */ +#define rFPGA1_RFMOD 0x900 /* RF mode & OFDM TxSC RF BW Setting?? */ + +#define rFPGA1_TxBlock 0x904 /* Useless now */ +#define rFPGA1_DebugSelect 0x908 /* Useless now */ +#define rFPGA1_TxInfo 0x90c /* Useless now Status report?? */ + +/* */ +/* 5. PageA(0xA00) */ +/* */ +/* Set Control channel to upper or lower. These settings are required only for 40MHz */ +#define rCCK0_System 0xa00 + +#define rCCK0_AFESetting 0xa04 /* Disable init gain now Select RX path by RSSI */ +#define rCCK0_CCA 0xa08 /* Disable init gain now Init gain */ + +#define rCCK0_RxAGC1 0xa0c /* AGC default value, saturation level Antenna Diversity, RX AGC, LNA Threshold, RX LNA Threshold useless now. Not the same as 90 series */ +#define rCCK0_RxAGC2 0xa10 /* AGC & DAGC */ + +#define rCCK0_RxHP 0xa14 + +#define rCCK0_DSPParameter1 0xa18 /* Timing recovery & Channel estimation threshold */ +#define rCCK0_DSPParameter2 0xa1c /* SQ threshold */ + +#define rCCK0_TxFilter1 0xa20 +#define rCCK0_TxFilter2 0xa24 +#define rCCK0_DebugPort 0xa28 /* debug port and Tx filter3 */ +#define rCCK0_FalseAlarmReport 0xa2c /* 0xa2d useless now 0xa30-a4f channel report */ +#define rCCK0_TRSSIReport 0xa50 +#define rCCK0_RxReport 0xa54 /* 0xa57 */ +#define rCCK0_FACounterLower 0xa5c /* 0xa5b */ +#define rCCK0_FACounterUpper 0xa58 /* 0xa5c */ + +/* */ +/* 6. PageC(0xC00) */ +/* */ +#define rOFDM0_LSTF 0xc00 + +#define rOFDM0_TRxPathEnable 0xc04 +#define rOFDM0_TRMuxPar 0xc08 +#define rOFDM0_TRSWIsolation 0xc0c + +#define rOFDM0_XARxAFE 0xc10 /* RxIQ DC offset, Rx digital filter, DC notch filter */ +#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imblance matrix */ +#define rOFDM0_XBRxAFE 0xc18 +#define rOFDM0_XBRxIQImbalance 0xc1c +#define rOFDM0_XCRxAFE 0xc20 +#define rOFDM0_XCRxIQImbalance 0xc24 +#define rOFDM0_XDRxAFE 0xc28 +#define rOFDM0_XDRxIQImbalance 0xc2c + +#define rOFDM0_RxDetector1 0xc30 /* PD,BW & SBD DM tune init gain */ +#define rOFDM0_RxDetector2 0xc34 /* SBD & Fame Sync. */ +#define rOFDM0_RxDetector3 0xc38 /* Frame Sync. */ +#define rOFDM0_RxDetector4 0xc3c /* PD, SBD, Frame Sync & Short-GI */ + +#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ +#define rOFDM0_CFOandDAGC 0xc44 /* CFO & DAGC */ +#define rOFDM0_CCADropThreshold 0xc48 /* CCA Drop threshold */ +#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ + +#define rOFDM0_XAAGCCore1 0xc50 /* DIG */ +#define rOFDM0_XAAGCCore2 0xc54 +#define rOFDM0_XBAGCCore1 0xc58 +#define rOFDM0_XBAGCCore2 0xc5c +#define rOFDM0_XCAGCCore1 0xc60 +#define rOFDM0_XCAGCCore2 0xc64 +#define rOFDM0_XDAGCCore1 0xc68 +#define rOFDM0_XDAGCCore2 0xc6c + +#define rOFDM0_AGCParameter1 0xc70 +#define rOFDM0_AGCParameter2 0xc74 +#define rOFDM0_AGCRSSITable 0xc78 +#define rOFDM0_HTSTFAGC 0xc7c + +#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */ +#define rOFDM0_XATxAFE 0xc84 +#define rOFDM0_XBTxIQImbalance 0xc88 +#define rOFDM0_XBTxAFE 0xc8c +#define rOFDM0_XCTxIQImbalance 0xc90 +#define rOFDM0_XCTxAFE 0xc94 +#define rOFDM0_XDTxIQImbalance 0xc98 +#define rOFDM0_XDTxAFE 0xc9c +#define rOFDM0_RxIQExtAnta 0xca0 + +#define rOFDM0_RxHPParameter 0xce0 +#define rOFDM0_TxPseudoNoiseWgt 0xce4 +#define rOFDM0_FrameSync 0xcf0 +#define rOFDM0_DFSReport 0xcf4 +#define rOFDM0_TxCoeff1 0xca4 +#define rOFDM0_TxCoeff2 0xca8 +#define rOFDM0_TxCoeff3 0xcac +#define rOFDM0_TxCoeff4 0xcb0 +#define rOFDM0_TxCoeff5 0xcb4 +#define rOFDM0_TxCoeff6 0xcb8 + +/* 7. PageD(0xD00) */ +#define rOFDM1_LSTF 0xd00 +#define rOFDM1_TRxPathEnable 0xd04 + +#define rOFDM1_CFO 0xd08 /* No setting now */ +#define rOFDM1_CSI1 0xd10 +#define rOFDM1_SBD 0xd14 +#define rOFDM1_CSI2 0xd18 +#define rOFDM1_CFOTracking 0xd2c +#define rOFDM1_TRxMesaure1 0xd34 +#define rOFDM1_IntfDet 0xd3c +#define rOFDM1_PseudoNoiseStateAB 0xd50 +#define rOFDM1_PseudoNoiseStateCD 0xd54 +#define rOFDM1_RxPseudoNoiseWgt 0xd58 + +#define rOFDM_PHYCounter1 0xda0 /* cca, parity fail */ +#define rOFDM_PHYCounter2 0xda4 /* rate illegal, crc8 fail */ +#define rOFDM_PHYCounter3 0xda8 /* MCS not support */ + +#define rOFDM_ShortCFOAB 0xdac /* No setting now */ +#define rOFDM_ShortCFOCD 0xdb0 +#define rOFDM_LongCFOAB 0xdb4 +#define rOFDM_LongCFOCD 0xdb8 +#define rOFDM_TailCFOAB 0xdbc +#define rOFDM_TailCFOCD 0xdc0 +#define rOFDM_PWMeasure1 0xdc4 +#define rOFDM_PWMeasure2 0xdc8 +#define rOFDM_BWReport 0xdcc +#define rOFDM_AGCReport 0xdd0 +#define rOFDM_RxSNR 0xdd4 +#define rOFDM_RxEVMCSI 0xdd8 +#define rOFDM_SIGReport 0xddc + +/* */ +/* 8. PageE(0xE00) */ +/* */ +#define rTxAGC_Rate18_06 0xe00 +#define rTxAGC_Rate54_24 0xe04 +#define rTxAGC_CCK_Mcs32 0xe08 +#define rTxAGC_Mcs03_Mcs00 0xe10 +#define rTxAGC_Mcs07_Mcs04 0xe14 +#define rTxAGC_Mcs11_Mcs08 0xe18 +#define rTxAGC_Mcs15_Mcs12 0xe1c + +/* Analog- control in RX_WAIT_CCA : REG: EE0 [Analog- Power & Control Register] */ +#define rRx_Wait_CCCA 0xe70 +#define rAnapar_Ctrl_BB 0xee0 + +/* */ +/* 7. RF Register 0x00-0x2E (RF 8256) */ +/* RF-0222D 0x00-3F */ +/* */ +/* Zebra1 */ +#define RTL92SE_FPGA_VERIFY 0 +#define rZebra1_HSSIEnable 0x0 /* Useless now */ +#define rZebra1_TRxEnable1 0x1 +#define rZebra1_TRxEnable2 0x2 +#define rZebra1_AGC 0x4 +#define rZebra1_ChargePump 0x5 +/* if (RTL92SE_FPGA_VERIFY == 1) */ +#define rZebra1_Channel 0x7 /* RF channel switch */ +/* else */ + +/* endif */ +#define rZebra1_TxGain 0x8 /* Useless now */ +#define rZebra1_TxLPF 0x9 +#define rZebra1_RxLPF 0xb +#define rZebra1_RxHPFCorner 0xc + +/* Zebra4 */ +#define rGlobalCtrl 0 /* Useless now */ +#define rRTL8256_TxLPF 19 +#define rRTL8256_RxLPF 11 + +/* RTL8258 */ +#define rRTL8258_TxLPF 0x11 /* Useless now */ +#define rRTL8258_RxLPF 0x13 +#define rRTL8258_RSSILPF 0xa + +/* */ +/* RL6052 Register definition */ +#define RF_AC 0x00 /* */ + +#define RF_IQADJ_G1 0x01 /* */ +#define RF_IQADJ_G2 0x02 /* */ +#define RF_POW_TRSW 0x05 /* */ + +#define RF_GAIN_RX 0x06 /* */ +#define RF_GAIN_TX 0x07 /* */ + +#define RF_TXM_IDAC 0x08 /* */ +#define RF_BS_IQGEN 0x0F /* */ + +#define RF_MODE1 0x10 /* */ +#define RF_MODE2 0x11 /* */ + +#define RF_RX_AGC_HP 0x12 /* */ +#define RF_TX_AGC 0x13 /* */ +#define RF_BIAS 0x14 /* */ +#define RF_IPA 0x15 /* */ +#define RF_TXBIAS 0x16 /* */ +#define RF_POW_ABILITY 0x17 /* */ +#define RF_MODE_AG 0x18 /* */ +#define rRfChannel 0x18 /* RF channel and BW switch */ +#define RF_CHNLBW 0x18 /* RF channel and BW switch */ +#define RF_TOP 0x19 /* */ + +#define RF_RX_G1 0x1A /* */ +#define RF_RX_G2 0x1B /* */ + +#define RF_RX_BB2 0x1C /* */ +#define RF_RX_BB1 0x1D /* */ + +#define RF_RCK1 0x1E /* */ +#define RF_RCK2 0x1F /* */ + +#define RF_TX_G1 0x20 /* */ +#define RF_TX_G2 0x21 /* */ +#define RF_TX_G3 0x22 /* */ + +#define RF_TX_BB1 0x23 /* */ + +#define RF_T_METER 0x24 /* */ + +#define RF_SYN_G1 0x25 /* RF TX Power control */ +#define RF_SYN_G2 0x26 /* RF TX Power control */ +#define RF_SYN_G3 0x27 /* RF TX Power control */ +#define RF_SYN_G4 0x28 /* RF TX Power control */ +#define RF_SYN_G5 0x29 /* RF TX Power control */ +#define RF_SYN_G6 0x2A /* RF TX Power control */ +#define RF_SYN_G7 0x2B /* RF TX Power control */ +#define RF_SYN_G8 0x2C /* RF TX Power control */ + +#define RF_RCK_OS 0x30 /* RF TX PA control */ +#define RF_TXPA_G1 0x31 /* RF TX PA control */ +#define RF_TXPA_G2 0x32 /* RF TX PA control */ +#define RF_TXPA_G3 0x33 /* RF TX PA control */ + +/* */ +/* Bit Mask */ +/* */ +/* 1. Page1(0x100) */ +#define bBBResetB 0x100 /* Useless now? */ +#define bGlobalResetB 0x200 +#define bOFDMTxStart 0x4 +#define bCCKTxStart 0x8 +#define bCRC32Debug 0x100 +#define bPMACLoopback 0x10 +#define bTxLSIG 0xffffff +#define bOFDMTxRate 0xf +#define bOFDMTxReserved 0x10 +#define bOFDMTxLength 0x1ffe0 +#define bOFDMTxParity 0x20000 +#define bTxHTSIG1 0xffffff +#define bTxHTMCSRate 0x7f +#define bTxHTBW 0x80 +#define bTxHTLength 0xffff00 +#define bTxHTSIG2 0xffffff +#define bTxHTSmoothing 0x1 +#define bTxHTSounding 0x2 +#define bTxHTReserved 0x4 +#define bTxHTAggreation 0x8 +#define bTxHTSTBC 0x30 +#define bTxHTAdvanceCoding 0x40 +#define bTxHTShortGI 0x80 +#define bTxHTNumberHT_LTF 0x300 +#define bTxHTCRC8 0x3fc00 +#define bCounterReset 0x10000 +#define bNumOfOFDMTx 0xffff +#define bNumOfCCKTx 0xffff0000 +#define bTxIdleInterval 0xffff +#define bOFDMService 0xffff0000 +#define bTxMACHeader 0xffffffff +#define bTxDataInit 0xff +#define bTxHTMode 0x100 +#define bTxDataType 0x30000 +#define bTxRandomSeed 0xffffffff +#define bCCKTxPreamble 0x1 +#define bCCKTxSFD 0xffff0000 +#define bCCKTxSIG 0xff +#define bCCKTxService 0xff00 +#define bCCKLengthExt 0x8000 +#define bCCKTxLength 0xffff0000 +#define bCCKTxCRC16 0xffff +#define bCCKTxStatus 0x1 +#define bOFDMTxStatus 0x2 + +#define IS_BB_REG_OFFSET_92S(_Offset) ((_Offset >= 0x800) && (_Offset <= 0xfff)) + +/* 2. Page8(0x800) */ +#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */ +#define bJapanMode 0x2 +#define bCCKTxSC 0x30 +#define bCCKEn 0x1000000 +#define bOFDMEn 0x2000000 + +#define bOFDMRxADCPhase 0x10000 /* Useless now */ +#define bOFDMTxDACPhase 0x40000 +#define bXATxAGC 0x3f + +#define bXBTxAGC 0xf00 /* Reg 80c rFPGA0_TxGainStage */ +#define bXCTxAGC 0xf000 +#define bXDTxAGC 0xf0000 + +#define bPAStart 0xf0000000 /* Useless now */ +#define bTRStart 0x00f00000 +#define bRFStart 0x0000f000 +#define bBBStart 0x000000f0 +#define bBBCCKStart 0x0000000f +#define bPAEnd 0xf /* Reg0x814 */ +#define bTREnd 0x0f000000 +#define bRFEnd 0x000f0000 +#define bCCAMask 0x000000f0 /* T2R */ +#define bR2RCCAMask 0x00000f00 +#define bHSSI_R2TDelay 0xf8000000 +#define bHSSI_T2RDelay 0xf80000 +#define bContTxHSSI 0x400 /* chane gain at continue Tx */ +#define bIGFromCCK 0x200 +#define bAGCAddress 0x3f +#define bRxHPTx 0x7000 +#define bRxHPT2R 0x38000 +#define bRxHPCCKIni 0xc0000 +#define bAGCTxCode 0xc00000 +#define bAGCRxCode 0x300000 + +#define b3WireDataLength 0x800 /* Reg 0x820~84f rFPGA0_XA_HSSIParameter1 */ +#define b3WireAddressLength 0x400 + +#define b3WireRFPowerDown 0x1 /* Useless now */ +/* define bHWSISelect 0x8 */ +#define b5GPAPEPolarity 0x40000000 +#define b2GPAPEPolarity 0x80000000 +#define bRFSW_TxDefaultAnt 0x3 +#define bRFSW_TxOptionAnt 0x30 +#define bRFSW_RxDefaultAnt 0x300 +#define bRFSW_RxOptionAnt 0x3000 +#define bRFSI_3WireData 0x1 +#define bRFSI_3WireClock 0x2 +#define bRFSI_3WireLoad 0x4 +#define bRFSI_3WireRW 0x8 +#define bRFSI_3Wire 0xf + +#define bRFSI_RFENV 0x10 /* Reg 0x870 rFPGA0_XAB_RFInterfaceSW */ + +#define bRFSI_TRSW 0x20 /* Useless now */ +#define bRFSI_TRSWB 0x40 +#define bRFSI_ANTSW 0x100 +#define bRFSI_ANTSWB 0x200 +#define bRFSI_PAPE 0x400 +#define bRFSI_PAPE5G 0x800 +#define bBandSelect 0x1 +#define bHTSIG2_GI 0x80 +#define bHTSIG2_Smoothing 0x01 +#define bHTSIG2_Sounding 0x02 +#define bHTSIG2_Aggreaton 0x08 +#define bHTSIG2_STBC 0x30 +#define bHTSIG2_AdvCoding 0x40 +#define bHTSIG2_NumOfHTLTF 0x300 +#define bHTSIG2_CRC8 0x3fc +#define bHTSIG1_MCS 0x7f +#define bHTSIG1_BandWidth 0x80 +#define bHTSIG1_HTLength 0xffff +#define bLSIG_Rate 0xf +#define bLSIG_Reserved 0x10 +#define bLSIG_Length 0x1fffe +#define bLSIG_Parity 0x20 +#define bCCKRxPhase 0x4 +#if (RTL92SE_FPGA_VERIFY == 1) +#define bLSSIReadAddress 0x3f000000 /* LSSI "Read" Address + Reg 0x824 rFPGA0_XA_HSSIParameter2 */ +#else +#define bLSSIReadAddress 0x7f800000 /* T65 RF */ +#endif +#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ +#if (RTL92SE_FPGA_VERIFY == 1) +#define bLSSIReadBackData 0xfff /* Reg 0x8a0 + rFPGA0_XA_LSSIReadBack */ +#else +#define bLSSIReadBackData 0xfffff /* T65 RF */ +#endif +#define bLSSIReadOKFlag 0x1000 /* Useless now */ +#define bCCKSampleRate 0x8 /* 0: 44MHz, 1:88MHz */ +#define bRegulator0Standby 0x1 +#define bRegulatorPLLStandby 0x2 +#define bRegulator1Standby 0x4 +#define bPLLPowerUp 0x8 +#define bDPLLPowerUp 0x10 +#define bDA10PowerUp 0x20 +#define bAD7PowerUp 0x200 +#define bDA6PowerUp 0x2000 +#define bXtalPowerUp 0x4000 +#define b40MDClkPowerUP 0x8000 +#define bDA6DebugMode 0x20000 +#define bDA6Swing 0x380000 + +#define bADClkPhase 0x4000000 /* Reg 0x880 + rFPGA0_AnalogParameter1 20/40 CCK support switch 40/80 BB MHZ */ + +#define b80MClkDelay 0x18000000 /* Useless */ +#define bAFEWatchDogEnable 0x20000000 + +#define bXtalCap01 0xc0000000 /* Reg 0x884 + rFPGA0_AnalogParameter2 Crystal cap */ +#define bXtalCap23 0x3 +#define bXtalCap92x 0x0f000000 +#define bXtalCap 0x0f000000 + +#define bIntDifClkEnable 0x400 /* Useless */ +#define bExtSigClkEnable 0x800 +#define bBandgapMbiasPowerUp 0x10000 +#define bAD11SHGain 0xc0000 +#define bAD11InputRange 0x700000 +#define bAD11OPCurrent 0x3800000 +#define bIPathLoopback 0x4000000 +#define bQPathLoopback 0x8000000 +#define bAFELoopback 0x10000000 +#define bDA10Swing 0x7e0 +#define bDA10Reverse 0x800 +#define bDAClkSource 0x1000 +#define bAD7InputRange 0x6000 +#define bAD7Gain 0x38000 +#define bAD7OutputCMMode 0x40000 +#define bAD7InputCMMode 0x380000 +#define bAD7Current 0xc00000 +#define bRegulatorAdjust 0x7000000 +#define bAD11PowerUpAtTx 0x1 +#define bDA10PSAtTx 0x10 +#define bAD11PowerUpAtRx 0x100 +#define bDA10PSAtRx 0x1000 +#define bCCKRxAGCFormat 0x200 +#define bPSDFFTSamplepPoint 0xc000 +#define bPSDAverageNum 0x3000 +#define bIQPathControl 0xc00 +#define bPSDFreq 0x3ff +#define bPSDAntennaPath 0x30 +#define bPSDIQSwitch 0x40 +#define bPSDRxTrigger 0x400000 +#define bPSDTxTrigger 0x80000000 +#define bPSDSineToneScale 0x7f000000 +#define bPSDReport 0xffff + +/* 3. Page9(0x900) */ +#define bOFDMTxSC 0x30000000 /* Useless */ +#define bCCKTxOn 0x1 +#define bOFDMTxOn 0x2 +#define bDebugPage 0xfff /* reset debug page and HWord, + * LWord */ +#define bDebugItem 0xff /* reset debug page and LWord */ +#define bAntL 0x10 +#define bAntNonHT 0x100 +#define bAntHT1 0x1000 +#define bAntHT2 0x10000 +#define bAntHT1S1 0x100000 +#define bAntNonHTS1 0x1000000 + +/* 4. PageA(0xA00) */ +#define bCCKBBMode 0x3 /* Useless */ +#define bCCKTxPowerSaving 0x80 +#define bCCKRxPowerSaving 0x40 + +#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0 20/40 sw */ + +#define bCCKScramble 0x8 /* Useless */ +#define bCCKAntDiversity 0x8000 +#define bCCKCarrierRecovery 0x4000 +#define bCCKTxRate 0x3000 +#define bCCKDCCancel 0x0800 +#define bCCKISICancel 0x0400 +#define bCCKMatchFilter 0x0200 +#define bCCKEqualizer 0x0100 +#define bCCKPreambleDetect 0x800000 +#define bCCKFastFalseCCA 0x400000 +#define bCCKChEstStart 0x300000 +#define bCCKCCACount 0x080000 +#define bCCKcs_lim 0x070000 +#define bCCKBistMode 0x80000000 +#define bCCKCCAMask 0x40000000 +#define bCCKTxDACPhase 0x4 +#define bCCKRxADCPhase 0x20000000 /* r_rx_clk */ +#define bCCKr_cp_mode0 0x0100 +#define bCCKTxDCOffset 0xf0 +#define bCCKRxDCOffset 0xf +#define bCCKCCAMode 0xc000 +#define bCCKFalseCS_lim 0x3f00 +#define bCCKCS_ratio 0xc00000 +#define bCCKCorgBit_sel 0x300000 +#define bCCKPD_lim 0x0f0000 +#define bCCKNewCCA 0x80000000 +#define bCCKRxHPofIG 0x8000 +#define bCCKRxIG 0x7f00 +#define bCCKLNAPolarity 0x800000 +#define bCCKRx1stGain 0x7f0000 +#define bCCKRFExtend 0x20000000 /* CCK Rx init gain polar */ +#define bCCKRxAGCSatLevel 0x1f000000 +#define bCCKRxAGCSatCount 0xe0 +#define bCCKRxRFSettle 0x1f /* AGCsamp_dly */ +#define bCCKFixedRxAGC 0x8000 +#define bCCKAntennaPolarity 0x2000 +#define bCCKTxFilterType 0x0c00 +#define bCCKRxAGCReportType 0x0300 +#define bCCKRxDAGCEn 0x80000000 +#define bCCKRxDAGCPeriod 0x20000000 +#define bCCKRxDAGCSatLevel 0x1f000000 +#define bCCKTimingRecovery 0x800000 +#define bCCKTxC0 0x3f0000 +#define bCCKTxC1 0x3f000000 +#define bCCKTxC2 0x3f +#define bCCKTxC3 0x3f00 +#define bCCKTxC4 0x3f0000 +#define bCCKTxC5 0x3f000000 +#define bCCKTxC6 0x3f +#define bCCKTxC7 0x3f00 +#define bCCKDebugPort 0xff0000 +#define bCCKDACDebug 0x0f000000 +#define bCCKFalseAlarmEnable 0x8000 +#define bCCKFalseAlarmRead 0x4000 +#define bCCKTRSSI 0x7f +#define bCCKRxAGCReport 0xfe +#define bCCKRxReport_AntSel 0x80000000 +#define bCCKRxReport_MFOff 0x40000000 +#define bCCKRxRxReport_SQLoss 0x20000000 +#define bCCKRxReport_Pktloss 0x10000000 +#define bCCKRxReport_Lockedbit 0x08000000 +#define bCCKRxReport_RateError 0x04000000 +#define bCCKRxReport_RxRate 0x03000000 +#define bCCKRxFACounterLower 0xff +#define bCCKRxFACounterUpper 0xff000000 +#define bCCKRxHPAGCStart 0xe000 +#define bCCKRxHPAGCFinal 0x1c00 +#define bCCKRxFalseAlarmEnable 0x8000 +#define bCCKFACounterFreeze 0x4000 +#define bCCKTxPathSel 0x10000000 +#define bCCKDefaultRxPath 0xc000000 +#define bCCKOptionRxPath 0x3000000 + +/* 5. PageC(0xC00) */ +#define bNumOfSTF 0x3 /* Useless */ +#define bShift_L 0xc0 +#define bGI_TH 0xc +#define bRxPathA 0x1 +#define bRxPathB 0x2 +#define bRxPathC 0x4 +#define bRxPathD 0x8 +#define bTxPathA 0x1 +#define bTxPathB 0x2 +#define bTxPathC 0x4 +#define bTxPathD 0x8 +#define bTRSSIFreq 0x200 +#define bADCBackoff 0x3000 +#define bDFIRBackoff 0xc000 +#define bTRSSILatchPhase 0x10000 +#define bRxIDCOffset 0xff +#define bRxQDCOffset 0xff00 +#define bRxDFIRMode 0x1800000 +#define bRxDCNFType 0xe000000 +#define bRXIQImb_A 0x3ff +#define bRXIQImb_B 0xfc00 +#define bRXIQImb_C 0x3f0000 +#define bRXIQImb_D 0xffc00000 +#define bDC_dc_Notch 0x60000 +#define bRxNBINotch 0x1f000000 +#define bPD_TH 0xf +#define bPD_TH_Opt2 0xc000 +#define bPWED_TH 0x700 +#define bIfMF_Win_L 0x800 +#define bPD_Option 0x1000 +#define bMF_Win_L 0xe000 +#define bBW_Search_L 0x30000 +#define bwin_enh_L 0xc0000 +#define bBW_TH 0x700000 +#define bED_TH2 0x3800000 +#define bBW_option 0x4000000 +#define bRatio_TH 0x18000000 +#define bWindow_L 0xe0000000 +#define bSBD_Option 0x1 +#define bFrame_TH 0x1c +#define bFS_Option 0x60 +#define bDC_Slope_check 0x80 +#define bFGuard_Counter_DC_L 0xe00 +#define bFrame_Weight_Short 0x7000 +#define bSub_Tune 0xe00000 +#define bFrame_DC_Length 0xe000000 +#define bSBD_start_offset 0x30000000 +#define bFrame_TH_2 0x7 +#define bFrame_GI2_TH 0x38 +#define bGI2_Sync_en 0x40 +#define bSarch_Short_Early 0x300 +#define bSarch_Short_Late 0xc00 +#define bSarch_GI2_Late 0x70000 +#define bCFOAntSum 0x1 +#define bCFOAcc 0x2 +#define bCFOStartOffset 0xc +#define bCFOLookBack 0x70 +#define bCFOSumWeight 0x80 +#define bDAGCEnable 0x10000 +#define bTXIQImb_A 0x3ff +#define bTXIQImb_B 0xfc00 +#define bTXIQImb_C 0x3f0000 +#define bTXIQImb_D 0xffc00000 +#define bTxIDCOffset 0xff +#define bTxQDCOffset 0xff00 +#define bTxDFIRMode 0x10000 +#define bTxPesudoNoiseOn 0x4000000 +#define bTxPesudoNoise_A 0xff +#define bTxPesudoNoise_B 0xff00 +#define bTxPesudoNoise_C 0xff0000 +#define bTxPesudoNoise_D 0xff000000 +#define bCCADropOption 0x20000 +#define bCCADropThres 0xfff00000 +#define bEDCCA_H 0xf +#define bEDCCA_L 0xf0 +#define bLambda_ED 0x300 +#define bRxInitialGain 0x7f +#define bRxAntDivEn 0x80 +#define bRxAGCAddressForLNA 0x7f00 +#define bRxHighPowerFlow 0x8000 +#define bRxAGCFreezeThres 0xc0000 +#define bRxFreezeStep_AGC1 0x300000 +#define bRxFreezeStep_AGC2 0xc00000 +#define bRxFreezeStep_AGC3 0x3000000 +#define bRxFreezeStep_AGC0 0xc000000 +#define bRxRssi_Cmp_En 0x10000000 +#define bRxQuickAGCEn 0x20000000 +#define bRxAGCFreezeThresMode 0x40000000 +#define bRxOverFlowCheckType 0x80000000 +#define bRxAGCShift 0x7f +#define bTRSW_Tri_Only 0x80 +#define bPowerThres 0x300 +#define bRxAGCEn 0x1 +#define bRxAGCTogetherEn 0x2 +#define bRxAGCMin 0x4 +#define bRxHP_Ini 0x7 +#define bRxHP_TRLNA 0x70 +#define bRxHP_RSSI 0x700 +#define bRxHP_BBP1 0x7000 +#define bRxHP_BBP2 0x70000 +#define bRxHP_BBP3 0x700000 +#define bRSSI_H 0x7f0000 /* thresh for hi power */ +#define bRSSI_Gen 0x7f000000 /* thresh for ant div */ +#define bRxSettle_TRSW 0x7 +#define bRxSettle_LNA 0x38 +#define bRxSettle_RSSI 0x1c0 +#define bRxSettle_BBP 0xe00 +#define bRxSettle_RxHP 0x7000 +#define bRxSettle_AntSW_RSSI 0x38000 +#define bRxSettle_AntSW 0xc0000 +#define bRxProcessTime_DAGC 0x300000 +#define bRxSettle_HSSI 0x400000 +#define bRxProcessTime_BBPPW 0x800000 +#define bRxAntennaPowerShift 0x3000000 +#define bRSSITableSelect 0xc000000 +#define bRxHP_Final 0x7000000 +#define bRxHTSettle_BBP 0x7 +#define bRxHTSettle_HSSI 0x8 +#define bRxHTSettle_RxHP 0x70 +#define bRxHTSettle_BBPPW 0x80 +#define bRxHTSettle_Idle 0x300 +#define bRxHTSettle_Reserved 0x1c00 +#define bRxHTRxHPEn 0x8000 +#define bRxHTAGCFreezeThres 0x30000 +#define bRxHTAGCTogetherEn 0x40000 +#define bRxHTAGCMin 0x80000 +#define bRxHTAGCEn 0x100000 +#define bRxHTDAGCEn 0x200000 +#define bRxHTRxHP_BBP 0x1c00000 +#define bRxHTRxHP_Final 0xe0000000 +#define bRxPWRatioTH 0x3 +#define bRxPWRatioEn 0x4 +#define bRxMFHold 0x3800 +#define bRxPD_Delay_TH1 0x38 +#define bRxPD_Delay_TH2 0x1c0 +#define bRxPD_DC_COUNT_MAX 0x600 +/* define bRxMF_Hold 0x3800 */ +#define bRxPD_Delay_TH 0x8000 +#define bRxProcess_Delay 0xf0000 +#define bRxSearchrange_GI2_Early 0x700000 +#define bRxFrame_Guard_Counter_L 0x3800000 +#define bRxSGI_Guard_L 0xc000000 +#define bRxSGI_Search_L 0x30000000 +#define bRxSGI_TH 0xc0000000 +#define bDFSCnt0 0xff +#define bDFSCnt1 0xff00 +#define bDFSFlag 0xf0000 +#define bMFWeightSum 0x300000 +#define bMinIdxTH 0x7f000000 +#define bDAFormat 0x40000 +#define bTxChEmuEnable 0x01000000 +#define bTRSWIsolation_A 0x7f +#define bTRSWIsolation_B 0x7f00 +#define bTRSWIsolation_C 0x7f0000 +#define bTRSWIsolation_D 0x7f000000 +#define bExtLNAGain 0x7c00 + +/* 6. PageE(0xE00) */ +#define bSTBCEn 0x4 /* Useless */ +#define bAntennaMapping 0x10 +#define bNss 0x20 +#define bCFOAntSumD 0x200 +#define bPHYCounterReset 0x8000000 +#define bCFOReportGet 0x4000000 +#define bOFDMContinueTx 0x10000000 +#define bOFDMSingleCarrier 0x20000000 +#define bOFDMSingleTone 0x40000000 +/* define bRxPath1 0x01 */ +/* define bRxPath2 0x02 */ +/* define bRxPath3 0x04 */ +/* define bRxPath4 0x08 */ +/* define bTxPath1 0x10 */ +/* define bTxPath2 0x20 */ +#define bHTDetect 0x100 +#define bCFOEn 0x10000 +#define bCFOValue 0xfff00000 +#define bSigTone_Re 0x3f +#define bSigTone_Im 0x7f00 +#define bCounter_CCA 0xffff +#define bCounter_ParityFail 0xffff0000 +#define bCounter_RateIllegal 0xffff +#define bCounter_CRC8Fail 0xffff0000 +#define bCounter_MCSNoSupport 0xffff +#define bCounter_FastSync 0xffff +#define bShortCFO 0xfff +#define bShortCFOTLength 12 /* total */ +#define bShortCFOFLength 11 /* fraction */ +#define bLongCFO 0x7ff +#define bLongCFOTLength 11 +#define bLongCFOFLength 11 +#define bTailCFO 0x1fff +#define bTailCFOTLength 13 +#define bTailCFOFLength 12 +#define bmax_en_pwdB 0xffff +#define bCC_power_dB 0xffff0000 +#define bnoise_pwdB 0xffff +#define bPowerMeasTLength 10 +#define bPowerMeasFLength 3 +#define bRx_HT_BW 0x1 +#define bRxSC 0x6 +#define bRx_HT 0x8 +#define bNB_intf_det_on 0x1 +#define bIntf_win_len_cfg 0x30 +#define bNB_Intf_TH_cfg 0x1c0 +#define bRFGain 0x3f +#define bTableSel 0x40 +#define bTRSW 0x80 +#define bRxSNR_A 0xff +#define bRxSNR_B 0xff00 +#define bRxSNR_C 0xff0000 +#define bRxSNR_D 0xff000000 +#define bSNREVMTLength 8 +#define bSNREVMFLength 1 +#define bCSI1st 0xff +#define bCSI2nd 0xff00 +#define bRxEVM1st 0xff0000 +#define bRxEVM2nd 0xff000000 +#define bSIGEVM 0xff +#define bPWDB 0xff00 +#define bSGIEN 0x10000 + +#define bSFactorQAM1 0xf /* Useless */ +#define bSFactorQAM2 0xf0 +#define bSFactorQAM3 0xf00 +#define bSFactorQAM4 0xf000 +#define bSFactorQAM5 0xf0000 +#define bSFactorQAM6 0xf0000 +#define bSFactorQAM7 0xf00000 +#define bSFactorQAM8 0xf000000 +#define bSFactorQAM9 0xf0000000 +#define bCSIScheme 0x100000 + +#define bNoiseLvlTopSet 0x3 /* Useless */ +#define bChSmooth 0x4 +#define bChSmoothCfg1 0x38 +#define bChSmoothCfg2 0x1c0 +#define bChSmoothCfg3 0xe00 +#define bChSmoothCfg4 0x7000 +#define bMRCMode 0x800000 +#define bTHEVMCfg 0x7000000 + +#define bLoopFitType 0x1 /* Useless */ +#define bUpdCFO 0x40 +#define bUpdCFOOffData 0x80 +#define bAdvUpdCFO 0x100 +#define bAdvTimeCtrl 0x800 +#define bUpdClko 0x1000 +#define bFC 0x6000 +#define bTrackingMode 0x8000 +#define bPhCmpEnable 0x10000 +#define bUpdClkoLTF 0x20000 +#define bComChCFO 0x40000 +#define bCSIEstiMode 0x80000 +#define bAdvUpdEqz 0x100000 +#define bUChCfg 0x7000000 +#define bUpdEqz 0x8000000 + +#define bTxAGCRate18_06 0x7f7f7f7f /* Useless */ +#define bTxAGCRate54_24 0x7f7f7f7f +#define bTxAGCRateMCS32 0x7f +#define bTxAGCRateCCK 0x7f00 +#define bTxAGCRateMCS3_MCS0 0x7f7f7f7f +#define bTxAGCRateMCS7_MCS4 0x7f7f7f7f +#define bTxAGCRateMCS11_MCS8 0x7f7f7f7f +#define bTxAGCRateMCS15_MCS12 0x7f7f7f7f + +/* Rx Pseduo noise */ +#define bRxPesudoNoiseOn 0x20000000 /* Useless */ +#define bRxPesudoNoise_A 0xff +#define bRxPesudoNoise_B 0xff00 +#define bRxPesudoNoise_C 0xff0000 +#define bRxPesudoNoise_D 0xff000000 +#define bPesudoNoiseState_A 0xffff +#define bPesudoNoiseState_B 0xffff0000 +#define bPesudoNoiseState_C 0xffff +#define bPesudoNoiseState_D 0xffff0000 + +/* 7. RF Register */ +/* Zebra1 */ +#define bZebra1_HSSIEnable 0x8 /* Useless */ +#define bZebra1_TRxControl 0xc00 +#define bZebra1_TRxGainSetting 0x07f +#define bZebra1_RxCorner 0xc00 +#define bZebra1_TxChargePump 0x38 +#define bZebra1_RxChargePump 0x7 +#define bZebra1_ChannelNum 0xf80 +#define bZebra1_TxLPFBW 0x400 +#define bZebra1_RxLPFBW 0x600 + +/* Zebra4 */ +#define bRTL8256RegModeCtrl1 0x100 /* Useless */ +#define bRTL8256RegModeCtrl0 0x40 +#define bRTL8256_TxLPFBW 0x18 +#define bRTL8256_RxLPFBW 0x600 + +/* RTL8258 */ +#define bRTL8258_TxLPFBW 0xc /* Useless */ +#define bRTL8258_RxLPFBW 0xc00 +#define bRTL8258_RSSILPFBW 0xc0 + +/* */ +/* Other Definition */ +/* */ + +/* byte endable for sb_write */ +#define bByte0 0x1 /* Useless */ +#define bByte1 0x2 +#define bByte2 0x4 +#define bByte3 0x8 +#define bWord0 0x3 +#define bWord1 0xc +#define bDWord 0xf + +/* for PutRegsetting & GetRegSetting BitMask */ +#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */ +#define bMaskByte1 0xff00 +#define bMaskByte2 0xff0000 +#define bMaskByte3 0xff000000 +#define bMaskHWord 0xffff0000 +#define bMaskLWord 0x0000ffff +#define bMaskDWord 0xffffffff +#define bMaskH4Bits 0xf0000000 +#define bMaskOFDM_D 0xffc00000 +#define bMaskCCK 0x3f3f3f3f +#define bMask12Bits 0xfff + +/* for PutRFRegsetting & GetRFRegSetting BitMask */ +#if (RTL92SE_FPGA_VERIFY == 1) +#define bRFRegOffsetMask 0xfff +#else +#define bRFRegOffsetMask 0xfffff +#endif +#define bEnable 0x1 /* Useless */ +#define bDisabl 0x0 + +#define LeftAntenna 0x0 /* Useless */ +#define RightAntenna 0x1 + +#define tCheckTxStatus 500 /* 500ms Useless */ +#define tUpdateRxCounter 100 /* 100ms */ + +#define rateCCK 0 /* Useless */ +#define rateOFDM 1 +#define rateHT 2 + +/* define Register-End */ +#define bPMAC_End 0x1ff /* Useless */ +#define bFPGAPHY0_End 0x8ff +#define bFPGAPHY1_End 0x9ff +#define bCCKPHY0_End 0xaff +#define bOFDMPHY0_End 0xcff +#define bOFDMPHY1_End 0xdff + +/* define max debug item in each debug page */ +/* define bMaxItem_FPGA_PHY0 0x9 */ +/* define bMaxItem_FPGA_PHY1 0x3 */ +/* define bMaxItem_PHY_11B 0x16 */ +/* define bMaxItem_OFDM_PHY0 0x29 */ +/* define bMaxItem_OFDM_PHY1 0x0 */ + +#define bPMACControl 0x0 /* Useless */ +#define bWMACControl 0x1 +#define bWNICControl 0x2 + +#define RCR_AAP BIT(0) /* accept all physical address */ +#define RCR_APM BIT(1) /* accept physical match */ +#define RCR_AM BIT(2) /* accept multicast */ +#define RCR_AB BIT(3) /* accept broadcast */ +#define RCR_ACRC32 BIT(5) /* accept error packet */ +#define RCR_9356SEL BIT(6) +#define RCR_AICV BIT(12) /* Accept ICV error packet */ +#define RCR_RXFTH0 (BIT(13)|BIT(14)|BIT(15)) /* Rx FIFO threshold */ +#define RCR_ADF BIT(18) /* Accept Data(frame type) frame */ +#define RCR_ACF BIT(19) /* Accept control frame */ +#define RCR_AMF BIT(20) /* Accept management frame */ +#define RCR_ADD3 BIT(21) +#define RCR_APWRMGT BIT(22) /* Accept power management packet */ +#define RCR_CBSSID BIT(23) /* Accept BSSID match packet */ +#define RCR_ENMARP BIT(28) /* enable mac auto reset phy */ +#define RCR_EnCS1 BIT(29) /* enable carrier sense method 1 */ +#define RCR_EnCS2 BIT(30) /* enable carrier sense method 2 */ +#define RCR_OnlyErlPkt BIT(31) /* Rx Early mode is performed for + * packet size greater than 1536 */ + +/*--------------------------Define Parameters-------------------------------*/ + +#endif /* __INC_HAL8192SPHYREG_H */ diff --git a/drivers/staging/r8188eu/include/rtw_p2p.h b/drivers/staging/r8188eu/include/rtw_p2p.h new file mode 100644 index 000000000000..a3e3adc92b99 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_p2p.h @@ -0,0 +1,135 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_P2P_H_ +#define __RTW_P2P_H_ + +#include + +u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); +u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); +u32 build_prov_disc_request_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pbuf, u8 *pssid, u8 ussidlen, + u8 *pdev_raddr); +u32 build_assoc_resp_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pbuf, u8 status_code); +u32 build_deauth_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); +u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len, struct sta_info *psta); +u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u32 process_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_provdisc_req(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_provdisc_resp(struct wifidirect_info *pwdinfo, u8 *pframe); +u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, + u8 *pframe, uint len); +u8 process_p2p_presence_req(struct wifidirect_info *pwdinfo, u8 *pframe, + uint len); +void p2p_protocol_wk_hdl(struct adapter *padapter, int intcmdtype); +void process_p2p_ps_ie(struct adapter *padapter, u8 *ies, u32 ielength); +void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state); +u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue); +void reset_global_wifidirect_info(struct adapter *padapter); +int rtw_init_wifi_display_info(struct adapter *padapter); +void rtw_init_wifidirect_timers(struct adapter *padapter); +void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, + u8 *iface_addr); +void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role); +int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role); + +static inline void _rtw_p2p_set_state(struct wifidirect_info *wdinfo, + enum P2P_STATE state) +{ + if (wdinfo->p2p_state != state) + wdinfo->p2p_state = state; +} + +static inline void _rtw_p2p_set_pre_state(struct wifidirect_info *wdinfo, + enum P2P_STATE state) +{ + if (wdinfo->pre_p2p_state != state) + wdinfo->pre_p2p_state = state; +} + +static inline void _rtw_p2p_set_role(struct wifidirect_info *wdinfo, + enum P2P_ROLE role) +{ + if (wdinfo->role != role) + wdinfo->role = role; +} + +static inline int _rtw_p2p_state(struct wifidirect_info *wdinfo) +{ + return wdinfo->p2p_state; +} + +static inline int _rtw_p2p_pre_state(struct wifidirect_info *wdinfo) +{ + return wdinfo->pre_p2p_state; +} + +static inline int _rtw_p2p_role(struct wifidirect_info *wdinfo) +{ + return wdinfo->role; +} + +static inline bool _rtw_p2p_chk_state(struct wifidirect_info *wdinfo, + enum P2P_STATE state) +{ + return wdinfo->p2p_state == state; +} + +static inline bool _rtw_p2p_chk_role(struct wifidirect_info *wdinfo, + enum P2P_ROLE role) +{ + return wdinfo->role == role; +} + +#define rtw_p2p_set_state(wdinfo, state) _rtw_p2p_set_state(wdinfo, state) +#define rtw_p2p_set_pre_state(wdinfo, state) \ + _rtw_p2p_set_pre_state(wdinfo, state) +#define rtw_p2p_set_role(wdinfo, role) _rtw_p2p_set_role(wdinfo, role) + +#define rtw_p2p_state(wdinfo) _rtw_p2p_state(wdinfo) +#define rtw_p2p_pre_state(wdinfo) _rtw_p2p_pre_state(wdinfo) +#define rtw_p2p_role(wdinfo) _rtw_p2p_role(wdinfo) +#define rtw_p2p_chk_state(wdinfo, state) _rtw_p2p_chk_state(wdinfo, state) +#define rtw_p2p_chk_role(wdinfo, role) _rtw_p2p_chk_role(wdinfo, role) + +#define rtw_p2p_findphase_ex_set(wdinfo, value) \ + ((wdinfo)->find_phase_state_exchange_cnt = (value)) + +/* is this find phase exchange for social channel scan? */ +#define rtw_p2p_findphase_ex_is_social(wdinfo) \ +((wdinfo)->find_phase_state_exchange_cnt >= P2P_FINDPHASE_EX_SOCIAL_FIRST) + +/* should we need find phase exchange anymore? */ +#define rtw_p2p_findphase_ex_is_needed(wdinfo) \ + ((wdinfo)->find_phase_state_exchange_cnt < P2P_FINDPHASE_EX_MAX && \ + (wdinfo)->find_phase_state_exchange_cnt != P2P_FINDPHASE_EX_NONE) + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h new file mode 100644 index 000000000000..3db33cd9fee7 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h @@ -0,0 +1,282 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_PWRCTRL_H_ +#define __RTW_PWRCTRL_H_ + +#include +#include + +#define FW_PWR0 0 +#define FW_PWR1 1 +#define FW_PWR2 2 +#define FW_PWR3 3 +#define HW_PWR0 7 +#define HW_PWR1 6 +#define HW_PWR2 2 +#define HW_PWR3 0 +#define HW_PWR4 8 + +#define FW_PWRMSK 0x7 + +#define XMIT_ALIVE BIT(0) +#define RECV_ALIVE BIT(1) +#define CMD_ALIVE BIT(2) +#define EVT_ALIVE BIT(3) + +enum power_mgnt { + PS_MODE_ACTIVE = 0, + PS_MODE_MIN, + PS_MODE_MAX, + PS_MODE_DTIM, + PS_MODE_VOIP, + PS_MODE_UAPSD_WMM, + PS_MODE_UAPSD, + PS_MODE_IBSS, + PS_MODE_WWLAN, + PM_Radio_Off, + PM_Card_Disable, + PS_MODE_NUM +}; + +/* + BIT[2:0] = HW state + BIT[3] = Protocol PS state, 0: register active state, + 1: register sleep state + BIT[4] = sub-state +*/ + +#define PS_DPS BIT(0) +#define PS_LCLK (PS_DPS) +#define PS_RF_OFF BIT(1) +#define PS_ALL_ON BIT(2) +#define PS_ST_ACTIVE BIT(3) + +#define PS_ISR_ENABLE BIT(4) +#define PS_IMR_ENABLE BIT(5) +#define PS_ACK BIT(6) +#define PS_TOGGLE BIT(7) + +#define PS_STATE_MASK (0x0F) +#define PS_STATE_HW_MASK (0x07) +#define PS_SEQ_MASK (0xc0) + +#define PS_STATE(x) (PS_STATE_MASK & (x)) +#define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x)) +#define PS_SEQ(x) (PS_SEQ_MASK & (x)) + +#define PS_STATE_S0 (PS_DPS) +#define PS_STATE_S1 (PS_LCLK) +#define PS_STATE_S2 (PS_RF_OFF) +#define PS_STATE_S3 (PS_ALL_ON) +#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON)) + +#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON)) +#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE)) +#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0))) + +struct reportpwrstate_parm { + unsigned char mode; + unsigned char state; /* the CPWM value */ + unsigned short rsvd; +}; + +static inline void _init_pwrlock(struct semaphore *plock) +{ + sema_init(plock, 1); +} + +static inline void _free_pwrlock(struct semaphore *plock) +{ +} + +static inline void _enter_pwrlock(struct semaphore *plock) +{ + _rtw_down_sema(plock); +} + +static inline void _exit_pwrlock(struct semaphore *plock) +{ + up(plock); +} + +#define LPS_DELAY_TIME 1*HZ /* 1 sec */ + +#define EXE_PWR_NONE 0x01 +#define EXE_PWR_IPS 0x02 +#define EXE_PWR_LPS 0x04 + +/* RF state. */ +enum rt_rf_power_state { + rf_on, /* RF is on after RFSleep or RFOff */ + rf_sleep, /* 802.11 Power Save mode */ + rf_off, /* HW/SW Radio OFF or Inactive Power Save */ + /* Add the new RF state above this line===== */ + rf_max +}; + +/* RF Off Level for IPS or HW/SW radio off */ +#define RT_RF_OFF_LEVL_ASPM BIT(0) /* PCI ASPM */ +#define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /* PCI clock request */ +#define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /* PCI D3 mode */ +#define RT_RF_OFF_LEVL_HALT_NIC BIT(3) /* NIC halt, re-init hw param*/ +#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /* FW free, re-download the FW*/ +#define RT_RF_OFF_LEVL_FW_32K BIT(5) /* FW in 32k */ +#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) /* Always enable ASPM and Clock + * Req in initialization. */ +#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R + * if no packet is RX or TX. */ +#define RT_RF_LPS_LEVEL_ASPM BIT(31) /* LPS with ASPM */ + +#define RT_IN_PS_LEVEL(ppsc, _PS_FLAG) \ + ((ppsc->cur_ps_level & _PS_FLAG) ? true : false) +#define RT_CLEAR_PS_LEVEL(ppsc, _PS_FLAG) \ + (ppsc->cur_ps_level &= (~(_PS_FLAG))) +#define RT_SET_PS_LEVEL(ppsc, _PS_FLAG) \ + (ppsc->cur_ps_level |= _PS_FLAG) + +enum _PS_BBRegBackup_ { + PSBBREG_RF0 = 0, + PSBBREG_RF1, + PSBBREG_RF2, + PSBBREG_AFE0, + PSBBREG_TOTALCNT +}; + +enum { /* for ips_mode */ + IPS_NONE = 0, + IPS_NORMAL, + IPS_LEVEL_2, +}; + +struct pwrctrl_priv { + struct semaphore lock; + volatile u8 rpwm; /* requested power state for fw */ + volatile u8 cpwm; /* fw current power state. updated when + * 1. read from HCPWM 2. driver lowers power level */ + volatile u8 tog; /* toggling */ + volatile u8 cpwm_tog; /* toggling */ + + u8 pwr_mode; + u8 smart_ps; + u8 bcn_ant_mode; + + u32 alives; + struct work_struct cpwm_event; + u8 bpower_saving; + + u8 b_hw_radio_off; + u8 reg_rfoff; + u8 reg_pdnmode; /* powerdown mode */ + u32 rfoff_reason; + + /* RF OFF Level */ + u32 cur_ps_level; + u32 reg_rfps_level; + uint ips_enter_cnts; + uint ips_leave_cnts; + + u8 ips_mode; + u8 ips_mode_req; /* used to accept the mode setting request, + * will update to ipsmode later */ + uint bips_processing; + u32 ips_deny_time; /* will deny IPS when system time less than this */ + u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ + + u8 bLeisurePs; + u8 LpsIdleCount; + u8 power_mgnt; + u8 bFwCurrentInPSMode; + u32 DelayLPSLastTimeStamp; + u8 btcoex_rfon; + s32 pnp_current_pwr_state; + u8 pnp_bstop_trx; + + u8 bInternalAutoSuspend; + u8 bInSuspend; +#ifdef CONFIG_BT_COEXIST + u8 bAutoResume; + u8 autopm_cnt; +#endif + u8 bSupportRemoteWakeup; + struct timer_list pwr_state_check_timer; + int pwr_state_check_interval; + u8 pwr_state_check_cnts; + + int ps_flag; + + enum rt_rf_power_state rf_pwrstate;/* cur power state */ + enum rt_rf_power_state change_rfpwrstate; + + u8 wepkeymask; + u8 bHWPowerdown;/* if support hw power down */ + u8 bHWPwrPindetect; + u8 bkeepfwalive; + u8 brfoffbyhw; + unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT]; +}; + +#define rtw_get_ips_mode_req(pwrctrlpriv) \ + (pwrctrlpriv)->ips_mode_req + +#define rtw_ips_mode_req(pwrctrlpriv, ips_mode) \ + ((pwrctrlpriv)->ips_mode_req = (ips_mode)) + +#define RTW_PWR_STATE_CHK_INTERVAL 2000 + +#define _rtw_set_pwr_state_check_timer(pwrctrlpriv, ms) \ + do { \ + _set_timer(&(pwrctrlpriv)->pwr_state_check_timer, (ms)); \ + } while (0) + +#define rtw_set_pwr_state_check_timer(pwrctrl) \ + _rtw_set_pwr_state_check_timer((pwrctrl), \ + (pwrctrl)->pwr_state_check_interval) + +void rtw_init_pwrctrl_priv(struct adapter *adapter); +void rtw_free_pwrctrl_priv(struct adapter *adapter); + +void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps, + u8 bcn_ant_mode); +void rtw_set_rpwm(struct adapter *adapter, u8 val8); +void LeaveAllPowerSaveMode(struct adapter *adapter); +void ips_enter(struct adapter *padapter); +int ips_leave(struct adapter *padapter); + +void rtw_ps_processor(struct adapter *padapter); + +enum rt_rf_power_state RfOnOffDetect(struct adapter *iadapter); + +s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms); +void LPS_Enter(struct adapter *adapter); +void LPS_Leave(struct adapter *adapter); + +u8 rtw_interface_ps_func(struct adapter *adapter, + enum hal_intf_ps_func efunc_id, u8 *val); +void rtw_set_ips_deny(struct adapter *adapter, u32 ms); +int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms, + const char *caller); +#define rtw_pwr_wakeup(adapter) \ + _rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __func__) +#define rtw_pwr_wakeup_ex(adapter, ips_deffer_ms) \ + _rtw_pwr_wakeup(adapter, ips_deffer_ms, __func__) +int rtw_pm_set_ips(struct adapter *adapter, u8 mode); +int rtw_pm_set_lps(struct adapter *adapter, u8 mode); + +#endif /* __RTL871X_PWRCTRL_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_qos.h b/drivers/staging/r8188eu/include/rtw_qos.h new file mode 100644 index 000000000000..bbee1ddc00bb --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_qos.h @@ -0,0 +1,30 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_QOS_H_ +#define _RTW_QOS_H_ + +#include + +struct qos_priv { + unsigned int qos_option; /* bit mask option: u-apsd, + * s-apsd, ts, block ack... */ +}; + +#endif /* _RTL871X_QOS_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h new file mode 100644 index 000000000000..bc097ed7f966 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -0,0 +1,473 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_RECV_H_ +#define _RTW_RECV_H_ + +#include +#include + +#define NR_RECVFRAME 256 + +#define RXFRAME_ALIGN 8 +#define RXFRAME_ALIGN_SZ (1<signal_stat_timer, \ + (recvpriv)->signal_stat_sampling_interval) + +struct sta_recv_priv { + spinlock_t lock; + int option; + struct __queue defrag_q; /* keeping the fragment frame until defrag */ + struct stainfo_rxcache rxcache; +}; + +struct recv_buf { + struct list_head list; + spinlock_t recvbuf_lock; + u32 ref_cnt; + struct adapter *adapter; + u8 *pbuf; + u8 *pallocated_buf; + u32 len; + u8 *phead; + u8 *pdata; + u8 *ptail; + u8 *pend; + struct urb *purb; + dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ + u32 alloc_sz; + u8 irp_pending; + int transfer_len; + struct sk_buff *pskb; + u8 reuse; +}; + +/* + head -----> + + data -----> + + payload + + tail -----> + + end -----> + + len = (unsigned int )(tail - data); + +*/ +struct recv_frame { + struct list_head list; + struct sk_buff *pkt; + struct sk_buff *pkt_newalloc; + struct adapter *adapter; + u8 fragcnt; + int frame_tag; + struct rx_pkt_attrib attrib; + uint len; + u8 *rx_head; + u8 *rx_data; + u8 *rx_tail; + u8 *rx_end; + void *precvbuf; + struct sta_info *psta; + /* for A-MPDU Rx reordering buffer control */ + struct recv_reorder_ctrl *preorder_ctrl; +}; + +struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); +void rtw_init_recvframe(struct recv_frame *precvframe, + struct recv_priv *precvpriv); +int rtw_free_recvframe(struct recv_frame *precvframe, + struct __queue *pfree_recv_queue); +#define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue) +int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); +int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); +void rtw_free_recvframe_queue(struct __queue *pframequeue, + struct __queue *pfree_recv_queue); +u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); +int rtw_enqueue_recvbuf_to_head(struct recv_buf *buf, struct __queue *queue); +int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue); +struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue); + +void rtw_reordering_ctrl_timeout_handler(void *pcontext); + +static inline u8 *get_rxmem(struct recv_frame *precvframe) +{ + /* always return rx_head... */ + if (precvframe == NULL) + return NULL; + return precvframe->rx_head; +} + +static inline u8 *get_rx_status(struct recv_frame *precvframe) +{ + return get_rxmem(precvframe); +} + +static inline u8 *get_recvframe_data(struct recv_frame *precvframe) +{ + /* always return rx_data */ + if (precvframe == NULL) + return NULL; + + return precvframe->rx_data; +} + +static inline u8 *recvframe_push(struct recv_frame *precvframe, int sz) +{ + /* append data before rx_data */ + + /* add data to the start of recv_frame + * + * This function extends the used data area of the recv_frame at the buffer + * start. rx_data must be still larger than rx_head, after pushing. + */ + if (precvframe == NULL) + return NULL; + precvframe->rx_data -= sz ; + if (precvframe->rx_data < precvframe->rx_head) { + precvframe->rx_data += sz; + return NULL; + } + precvframe->len += sz; + return precvframe->rx_data; +} + +static inline u8 *recvframe_pull(struct recv_frame *precvframe, int sz) +{ + /* rx_data += sz; move rx_data sz bytes hereafter */ + + /* used for extract sz bytes from rx_data, update rx_data and return + * the updated rx_data to the caller */ + + if (precvframe == NULL) + return NULL; + precvframe->rx_data += sz; + if (precvframe->rx_data > precvframe->rx_tail) { + precvframe->rx_data -= sz; + return NULL; + } + precvframe->len -= sz; + return precvframe->rx_data; +} + +static inline u8 *recvframe_put(struct recv_frame *precvframe, int sz) +{ + /* used for append sz bytes from ptr to rx_tail, update rx_tail + * and return the updated rx_tail to the caller */ + /* after putting, rx_tail must be still larger than rx_end. */ + + if (precvframe == NULL) + return NULL; + + precvframe->rx_tail += sz; + + if (precvframe->rx_tail > precvframe->rx_end) { + precvframe->rx_tail -= sz; + return NULL; + } + precvframe->len += sz; + return precvframe->rx_tail; +} + +static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) +{ + /* rmv data from rx_tail (by yitsen) */ + + /* used for extract sz bytes from rx_end, update rx_end and return + * the updated rx_end to the caller */ + /* after pulling, rx_end must be still larger than rx_data. */ + + if (precvframe == NULL) + return NULL; + precvframe->rx_tail -= sz; + if (precvframe->rx_tail < precvframe->rx_data) { + precvframe->rx_tail += sz; + return NULL; + } + precvframe->len -= sz; + return precvframe->rx_tail; +} + +static inline unsigned char *get_rxbuf_desc(struct recv_frame *precvframe) +{ + unsigned char *buf_desc; + + if (precvframe == NULL) + return NULL; + return buf_desc; +} + +static inline struct recv_frame *rxmem_to_recvframe(u8 *rxmem) +{ + /* due to the design of 2048 bytes alignment of recv_frame, + * we can reference the struct recv_frame */ + /* from any given member of recv_frame. */ + /* rxmem indicates the any member/address in recv_frame */ + + return (struct recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); +} + +static inline struct recv_frame *pkt_to_recvframe(struct sk_buff *pkt) +{ + u8 *buf_star; + struct recv_frame *precv_frame; + precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); + + return precv_frame; +} + +static inline u8 *pkt_to_recvmem(struct sk_buff *pkt) +{ + /* return the rx_head */ + + struct recv_frame *precv_frame = pkt_to_recvframe(pkt); + + return precv_frame->rx_head; +} + +static inline u8 *pkt_to_recvdata(struct sk_buff *pkt) +{ + /* return the rx_data */ + + struct recv_frame *precv_frame = pkt_to_recvframe(pkt); + + return precv_frame->rx_data; +} + +static inline int get_recvframe_len(struct recv_frame *precvframe) +{ + return precvframe->len; +} + +static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) +{ + s32 power; /* in dBm. */ + + /* Translate to dBm (x=0.5y-95). */ + power = (s32)((sig_stren_index + 1) >> 1); + power -= 95; + + return power; +} + +struct sta_info; + +void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); + +void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame); + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_rf.h b/drivers/staging/r8188eu/include/rtw_rf.h new file mode 100644 index 000000000000..d4415e8115b2 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_rf.h @@ -0,0 +1,145 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_RF_H_ +#define __RTW_RF_H_ + +#include + +#define OFDM_PHY 1 +#define MIXED_PHY 2 +#define CCK_PHY 3 + +#define NumRates (13) + +/* slot time for 11g */ +#define SHORT_SLOT_TIME 9 +#define NON_SHORT_SLOT_TIME 20 + +#define RTL8711_RF_MAX_SENS 6 +#define RTL8711_RF_DEF_SENS 4 + +/* We now define the following channels as the max channels in each + * channel plan. */ +/* 2G, total 14 chnls */ +/* {1,2,3,4,5,6,7,8,9,10,11,12,13,14} */ +#define MAX_CHANNEL_NUM_2G 14 +#define MAX_CHANNEL_NUM 14 /* 2.4 GHz only */ + +#define NUM_REGULATORYS 1 + +/* Country codes */ +#define USA 0x555320 +#define EUROPE 0x1 /* temp, should be provided later */ +#define JAPAN 0x2 /* temp, should be provided later */ + +struct regulatory_class { + u32 starting_freq; /* MHz, */ + u8 channel_set[MAX_CHANNEL_NUM]; + u8 channel_cck_power[MAX_CHANNEL_NUM]; /* dbm */ + u8 channel_ofdm_power[MAX_CHANNEL_NUM]; /* dbm */ + u8 txpower_limit; /* dbm */ + u8 channel_spacing; /* MHz */ + u8 modem; +}; + +enum capability { + cESS = 0x0001, + cIBSS = 0x0002, + cPollable = 0x0004, + cPollReq = 0x0008, + cPrivacy = 0x0010, + cShortPreamble = 0x0020, + cPBCC = 0x0040, + cChannelAgility = 0x0080, + cSpectrumMgnt = 0x0100, + cQos = 0x0200, /* For HCCA, use with CF-Pollable + * and CF-PollReq */ + cShortSlotTime = 0x0400, + cAPSD = 0x0800, + cRM = 0x1000, /* RRM (Radio Request Measurement) */ + cDSSS_OFDM = 0x2000, + cDelayedBA = 0x4000, + cImmediateBA = 0x8000, +}; + +enum _REG_PREAMBLE_MODE { + PREAMBLE_LONG = 1, + PREAMBLE_AUTO = 2, + PREAMBLE_SHORT = 3, +}; + +enum _RTL8712_RF_MIMO_CONFIG_ { + RTL8712_RFCONFIG_1T = 0x10, + RTL8712_RFCONFIG_2T = 0x20, + RTL8712_RFCONFIG_1R = 0x01, + RTL8712_RFCONFIG_2R = 0x02, + RTL8712_RFCONFIG_1T1R = 0x11, + RTL8712_RFCONFIG_1T2R = 0x12, + RTL8712_RFCONFIG_TURBO = 0x92, + RTL8712_RFCONFIG_2T2R = 0x22 +}; + +enum rf90_radio_path { + RF90_PATH_A = 0, /* Radio Path A */ + RF90_PATH_B = 1, /* Radio Path B */ + RF90_PATH_C = 2, /* Radio Path C */ + RF90_PATH_D = 3 /* Radio Path D */ +}; + +/* Bandwidth Offset */ +#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 +#define HAL_PRIME_CHNL_OFFSET_LOWER 1 +#define HAL_PRIME_CHNL_OFFSET_UPPER 2 + +/* Represent Channel Width in HT Capabilities */ +/* */ +enum ht_channel_width { + HT_CHANNEL_WIDTH_20 = 0, + HT_CHANNEL_WIDTH_40 = 1, + HT_CHANNEL_WIDTH_80 = 2, + HT_CHANNEL_WIDTH_160 = 3, + HT_CHANNEL_WIDTH_10 = 4, +}; + +/* */ +/* Represent Extension Channel Offset in HT Capabilities */ +/* This is available only in 40Mhz mode. */ +/* */ +enum ht_extchnl_offset { + HT_EXTCHNL_OFFSET_NO_EXT = 0, + HT_EXTCHNL_OFFSET_UPPER = 1, + HT_EXTCHNL_OFFSET_NO_DEF = 2, + HT_EXTCHNL_OFFSET_LOWER = 3, +}; + +/* 2007/11/15 MH Define different RF type. */ +enum rt_rf_type_def { + RF_1T2R = 0, + RF_2T4R = 1, + RF_2T2R = 2, + RF_1T1R = 3, + RF_2T2R_GREEN = 4, + RF_819X_MAX_TYPE = 5, +}; + +u32 rtw_ch2freq(u32 ch); +u32 rtw_freq2ch(u32 freq); + +#endif /* _RTL8711_RF_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_security.h b/drivers/staging/r8188eu/include/rtw_security.h new file mode 100644 index 000000000000..c720ed1117db --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_security.h @@ -0,0 +1,382 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __RTW_SECURITY_H_ +#define __RTW_SECURITY_H_ + +#include +#include + +#define _NO_PRIVACY_ 0x0 +#define _WEP40_ 0x1 +#define _TKIP_ 0x2 +#define _TKIP_WTMIC_ 0x3 +#define _AES_ 0x4 +#define _WEP104_ 0x5 +#define _WEP_WPA_MIXED_ 0x07 /* WEP + WPA */ +#define _SMS4_ 0x06 + +#define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) + +#define _WPA_IE_ID_ 0xdd +#define _WPA2_IE_ID_ 0x30 + +#define SHA256_MAC_LEN 32 +#define AES_BLOCK_SIZE 16 +#define AES_PRIV_SIZE (4 * 44) + +enum { + ENCRYP_PROTOCOL_OPENSYS, /* open system */ + ENCRYP_PROTOCOL_WEP, /* WEP */ + ENCRYP_PROTOCOL_WPA, /* WPA */ + ENCRYP_PROTOCOL_WPA2, /* WPA2 */ + ENCRYP_PROTOCOL_WAPI, /* WAPI: Not support in this version */ + ENCRYP_PROTOCOL_MAX +}; + +#ifndef Ndis802_11AuthModeWPA2 +#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1) +#endif + +#ifndef Ndis802_11AuthModeWPA2PSK +#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2) +#endif + +union pn48 { + u64 val; + +#ifdef __LITTLE_ENDIAN + struct { + u8 TSC0; + u8 TSC1; + u8 TSC2; + u8 TSC3; + u8 TSC4; + u8 TSC5; + u8 TSC6; + u8 TSC7; + } _byte_; + +#elif defined(__BIG_ENDIAN) + + struct { + u8 TSC7; + u8 TSC6; + u8 TSC5; + u8 TSC4; + u8 TSC3; + u8 TSC2; + u8 TSC1; + u8 TSC0; + } _byte_; +#endif +}; + +union Keytype { + u8 skey[16]; + u32 lkey[4]; +}; + +struct rt_pmkid_list { + u8 bUsed; + u8 Bssid[6]; + u8 PMKID[16]; + u8 SsidBuf[33]; + u8 *ssid_octet; + u16 ssid_length; +}; + +struct security_priv { + u32 dot11AuthAlgrthm; /* 802.11 auth, could be open, + * shared, 8021x and authswitch */ + u32 dot11PrivacyAlgrthm; /* This specify the privacy for + * shared auth. algorithm. */ + /* WEP */ + u32 dot11PrivacyKeyIndex; /* this is only valid for legendary + * wep, 0~3 for key id.(tx key index) */ + union Keytype dot11DefKey[4]; /* this is only valid for def. key */ + u32 dot11DefKeylen[4]; + u32 dot118021XGrpPrivacy; /* This specify the privacy algthm. + * used for Grp key */ + u32 dot118021XGrpKeyid; /* key id used for Grp Key + * ( tx key index) */ + union Keytype dot118021XGrpKey[4]; /* 802.1x Group Key, + * for inx0 and inx1 */ + union Keytype dot118021XGrptxmickey[4]; + union Keytype dot118021XGrprxmickey[4]; + union pn48 dot11Grptxpn; /* PN48 used for Grp Key xmit.*/ + union pn48 dot11Grprxpn; /* PN48 used for Grp Key recv.*/ +#ifdef CONFIG_88EU_AP_MODE + /* extend security capabilities for AP_MODE */ + unsigned int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */ + unsigned int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */ + unsigned int wpa_group_cipher; + unsigned int wpa2_group_cipher; + unsigned int wpa_pairwise_cipher; + unsigned int wpa2_pairwise_cipher; +#endif + u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */ + int wps_ie_len; + u8 binstallGrpkey; + u8 busetkipkey; + u8 bcheck_grpkey; + u8 bgrpkey_handshake; + s32 sw_encrypt;/* from registry_priv */ + s32 sw_decrypt;/* from registry_priv */ + s32 hw_decrypted;/* if the rx packets is hw_decrypted==false,i + * it means the hw has not been ready. */ + + /* keeps the auth_type & enc_status from upper layer + * ioctl(wpa_supplicant or wzc) */ + u32 ndisauthtype; /* NDIS_802_11_AUTHENTICATION_MODE */ + u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ + struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ + struct ndis_802_11_wep ndiswep; + u8 assoc_info[600]; + u8 szofcapability[256]; /* for wpa2 usage */ + u8 oidassociation[512]; /* for wpa/wpa2 usage */ + u8 authenticator_ie[256]; /* store ap security information element */ + u8 supplicant_ie[256]; /* store sta security information element */ + + /* for tkip countermeasure */ + u32 last_mic_err_time; + u8 btkip_countermeasure; + u8 btkip_wait_report; + u32 btkip_countermeasure_time; + + /* */ + /* For WPA2 Pre-Authentication. */ + /* */ + struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; + u8 PMKIDIndex; + u8 bWepDefaultKeyIdxSet; +}; + +#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0) +struct sha256_state { + u64 length; + u32 state[8], curlen; + u8 buf[64]; +}; +#endif + +#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \ +do { \ + switch (psecuritypriv->dot11AuthAlgrthm) { \ + case dot11AuthAlgrthm_Open: \ + case dot11AuthAlgrthm_Shared: \ + case dot11AuthAlgrthm_Auto: \ + encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm; \ + break; \ + case dot11AuthAlgrthm_8021X: \ + if (bmcst) \ + encry_algo = (u8)psecuritypriv->dot118021XGrpPrivacy;\ + else \ + encry_algo = (u8)psta->dot118021XPrivacy; \ + break; \ + case dot11AuthAlgrthm_WAPI: \ + encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm; \ + break; \ + } \ +} while (0) + +#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt) \ +do { \ + switch (encrypt) { \ + case _WEP40_: \ + case _WEP104_: \ + iv_len = 4; \ + icv_len = 4; \ + break; \ + case _TKIP_: \ + iv_len = 8; \ + icv_len = 4; \ + break; \ + case _AES_: \ + iv_len = 8; \ + icv_len = 8; \ + break; \ + case _SMS4_: \ + iv_len = 18; \ + icv_len = 16; \ + break; \ + default: \ + iv_len = 0; \ + icv_len = 0; \ + break; \ + } \ +} while (0) + +#define GET_TKIP_PN(iv, dot11txpn) \ +do { \ + dot11txpn._byte_.TSC0 = iv[2]; \ + dot11txpn._byte_.TSC1 = iv[0]; \ + dot11txpn._byte_.TSC2 = iv[4]; \ + dot11txpn._byte_.TSC3 = iv[5]; \ + dot11txpn._byte_.TSC4 = iv[6]; \ + dot11txpn._byte_.TSC5 = iv[7]; \ +} while (0) + +#define ROL32(A, n) (((A) << (n)) | (((A)>>(32-(n))) & ((1UL << (n)) - 1))) +#define ROR32(A, n) ROL32((A), 32-(n)) + +struct mic_data { + u32 K0, K1; /* Key */ + u32 L, R; /* Current state */ + u32 M; /* Message accumulator (single word) */ + u32 nBytesInM; /* # bytes in M */ +}; + +extern const u32 Te0[256]; +extern const u32 Te1[256]; +extern const u32 Te2[256]; +extern const u32 Te3[256]; +extern const u32 Te4[256]; +extern const u32 Td0[256]; +extern const u32 Td1[256]; +extern const u32 Td2[256]; +extern const u32 Td3[256]; +extern const u32 Td4[256]; +extern const u32 rcon[10]; +extern const u8 Td4s[256]; +extern const u8 rcons[10]; + +#define RCON(i) (rcons[(i)] << 24) + +static inline u32 rotr(u32 val, int bits) +{ + return (val >> bits) | (val << (32 - bits)); +} + +#define TE0(i) Te0[((i) >> 24) & 0xff] +#define TE1(i) rotr(Te0[((i) >> 16) & 0xff], 8) +#define TE2(i) rotr(Te0[((i) >> 8) & 0xff], 16) +#define TE3(i) rotr(Te0[(i) & 0xff], 24) +#define TE41(i) ((Te0[((i) >> 24) & 0xff] << 8) & 0xff000000) +#define TE42(i) (Te0[((i) >> 16) & 0xff] & 0x00ff0000) +#define TE43(i) (Te0[((i) >> 8) & 0xff] & 0x0000ff00) +#define TE44(i) ((Te0[(i) & 0xff] >> 8) & 0x000000ff) +#define TE421(i) ((Te0[((i) >> 16) & 0xff] << 8) & 0xff000000) +#define TE432(i) (Te0[((i) >> 8) & 0xff] & 0x00ff0000) +#define TE443(i) (Te0[(i) & 0xff] & 0x0000ff00) +#define TE414(i) ((Te0[((i) >> 24) & 0xff] >> 8) & 0x000000ff) +#define TE4(i) ((Te0[(i)] >> 8) & 0x000000ff) + +#define TD0(i) Td0[((i) >> 24) & 0xff] +#define TD1(i) rotr(Td0[((i) >> 16) & 0xff], 8) +#define TD2(i) rotr(Td0[((i) >> 8) & 0xff], 16) +#define TD3(i) rotr(Td0[(i) & 0xff], 24) +#define TD41(i) (Td4s[((i) >> 24) & 0xff] << 24) +#define TD42(i) (Td4s[((i) >> 16) & 0xff] << 16) +#define TD43(i) (Td4s[((i) >> 8) & 0xff] << 8) +#define TD44(i) (Td4s[(i) & 0xff]) +#define TD0_(i) Td0[(i) & 0xff] +#define TD1_(i) rotr(Td0[(i) & 0xff], 8) +#define TD2_(i) rotr(Td0[(i) & 0xff], 16) +#define TD3_(i) rotr(Td0[(i) & 0xff], 24) + +#define GETU32(pt) (((u32)(pt)[0] << 24) ^ ((u32)(pt)[1] << 16) ^ \ + ((u32)(pt)[2] << 8) ^ ((u32)(pt)[3])) + +#define PUTU32(ct, st) { \ +(ct)[0] = (u8)((st) >> 24); (ct)[1] = (u8)((st) >> 16); \ +(ct)[2] = (u8)((st) >> 8); (ct)[3] = (u8)(st); } + +#define WPA_GET_BE32(a) ((((u32)(a)[0]) << 24) | (((u32)(a)[1]) << 16) | \ + (((u32)(a)[2]) << 8) | ((u32)(a)[3])) + +#define WPA_PUT_LE16(a, val) \ + do { \ + (a)[1] = ((u16)(val)) >> 8; \ + (a)[0] = ((u16)(val)) & 0xff; \ + } while (0) + +#define WPA_PUT_BE32(a, val) \ + do { \ + (a)[0] = (u8)((((u32)(val)) >> 24) & 0xff); \ + (a)[1] = (u8)((((u32)(val)) >> 16) & 0xff); \ + (a)[2] = (u8)((((u32)(val)) >> 8) & 0xff); \ + (a)[3] = (u8)(((u32)(val)) & 0xff); \ + } while (0) + +#define WPA_PUT_BE64(a, val) \ + do { \ + (a)[0] = (u8)(((u64)(val)) >> 56); \ + (a)[1] = (u8)(((u64)(val)) >> 48); \ + (a)[2] = (u8)(((u64)(val)) >> 40); \ + (a)[3] = (u8)(((u64)(val)) >> 32); \ + (a)[4] = (u8)(((u64)(val)) >> 24); \ + (a)[5] = (u8)(((u64)(val)) >> 16); \ + (a)[6] = (u8)(((u64)(val)) >> 8); \ + (a)[7] = (u8)(((u64)(val)) & 0xff); \ + } while (0) + +/* ===== start - public domain SHA256 implementation ===== */ + +/* This is based on SHA256 implementation in LibTomCrypt that was released into + * public domain by Tom St Denis. */ + +/* the K array */ +static const unsigned long K[64] = { + 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, + 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, + 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, + 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, + 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, + 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, + 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, + 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, + 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, + 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, + 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, + 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, + 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL +}; + +/* Various logical functions */ +#define RORc(x, y) \ + (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y)&31)) | \ + ((unsigned long)(x) << (unsigned long)(32-((y)&31)))) & 0xFFFFFFFFUL) +#define Ch(x, y ,z) (z ^ (x & (y ^ z))) +#define Maj(x, y, z) (((x | y) & z) | (x & y)) +#define S(x, n) RORc((x), (n)) +#define R(x, n) (((x)&0xFFFFFFFFUL)>>(n)) +#define Sigma0(x) (S(x, 2) ^ S(x, 13) ^ S(x, 22)) +#define Sigma1(x) (S(x, 6) ^ S(x, 11) ^ S(x, 25)) +#define Gamma0(x) (S(x, 7) ^ S(x, 18) ^ R(x, 3)) +#define Gamma1(x) (S(x, 17) ^ S(x, 19) ^ R(x, 10)) +#ifndef MIN +#define MIN(x, y) (((x) < (y)) ? (x) : (y)) +#endif + +void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key); +void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b); +void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes); +void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst); +void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, + u8 *Miccode, u8 priority); +u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe); +u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe); +void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe); +u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe); +u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe); +void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe); +void rtw_use_tkipkey_handler(void *FunctionContext); + +#endif /* __RTL871X_SECURITY_H_ */ diff --git a/drivers/staging/r8188eu/include/rtw_sreset.h b/drivers/staging/r8188eu/include/rtw_sreset.h new file mode 100644 index 000000000000..2a1244f75790 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_sreset.h @@ -0,0 +1,50 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_SRESET_C_ +#define _RTW_SRESET_C_ + +#include +#include + +struct sreset_priv { + struct mutex silentreset_mutex; + u8 silent_reset_inprogress; + u8 Wifi_Error_Status; + unsigned long last_tx_time; + unsigned long last_tx_complete_time; +}; + +#include + +#define WIFI_STATUS_SUCCESS 0 +#define USB_VEN_REQ_CMD_FAIL BIT0 +#define USB_READ_PORT_FAIL BIT1 +#define USB_WRITE_PORT_FAIL BIT2 +#define WIFI_MAC_TXDMA_ERROR BIT3 +#define WIFI_TX_HANG BIT4 +#define WIFI_RX_HANG BIT5 +#define WIFI_IF_NOT_EXIST BIT6 + +void sreset_init_value(struct adapter *padapter); +void sreset_reset_value(struct adapter *padapter); +u8 sreset_get_wifi_status(struct adapter *padapter); +void sreset_set_wifi_error_status(struct adapter *padapter, u32 status); + +#endif diff --git a/drivers/staging/r8188eu/include/rtw_version.h b/drivers/staging/r8188eu/include/rtw_version.h new file mode 100644 index 000000000000..6d2d52cbb3d3 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_version.h @@ -0,0 +1 @@ +#define DRIVERVERSION "v4.1.4_6773.20130222" diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h new file mode 100644 index 000000000000..5253dd0affd7 --- /dev/null +++ b/drivers/staging/r8188eu/include/rtw_xmit.h @@ -0,0 +1,383 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _RTW_XMIT_H_ +#define _RTW_XMIT_H_ + +#include +#include + +#define MAX_XMITBUF_SZ (20480) /* 20k */ +#define NR_XMITBUFF (4) + +#define XMITBUF_ALIGN_SZ 4 + +/* xmit extension buff defination */ +#define MAX_XMIT_EXTBUF_SZ (1536) +#define NR_XMIT_EXTBUFF (32) + +#define MAX_NUMBLKS (1) + +#define XMIT_VO_QUEUE (0) +#define XMIT_VI_QUEUE (1) +#define XMIT_BE_QUEUE (2) +#define XMIT_BK_QUEUE (3) + +#define VO_QUEUE_INX 0 +#define VI_QUEUE_INX 1 +#define BE_QUEUE_INX 2 +#define BK_QUEUE_INX 3 +#define BCN_QUEUE_INX 4 +#define MGT_QUEUE_INX 5 +#define HIGH_QUEUE_INX 6 +#define TXCMD_QUEUE_INX 7 + +#define HW_QUEUE_ENTRY 8 + +#define WEP_IV(pattrib_iv, dot11txpn, keyidx)\ +do {\ + pattrib_iv[0] = dot11txpn._byte_.TSC0;\ + pattrib_iv[1] = dot11txpn._byte_.TSC1;\ + pattrib_iv[2] = dot11txpn._byte_.TSC2;\ + pattrib_iv[3] = ((keyidx & 0x3)<<6);\ + dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val+1);\ +} while (0) + +#define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\ +do {\ + pattrib_iv[0] = dot11txpn._byte_.TSC1;\ + pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\ + pattrib_iv[2] = dot11txpn._byte_.TSC0;\ + pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6);\ + pattrib_iv[4] = dot11txpn._byte_.TSC2;\ + pattrib_iv[5] = dot11txpn._byte_.TSC3;\ + pattrib_iv[6] = dot11txpn._byte_.TSC4;\ + pattrib_iv[7] = dot11txpn._byte_.TSC5;\ + dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ +} while (0) + +#define AES_IV(pattrib_iv, dot11txpn, keyidx)\ +do { \ + pattrib_iv[0] = dot11txpn._byte_.TSC0; \ + pattrib_iv[1] = dot11txpn._byte_.TSC1; \ + pattrib_iv[2] = 0; \ + pattrib_iv[3] = BIT(5) | ((keyidx & 0x3)<<6); \ + pattrib_iv[4] = dot11txpn._byte_.TSC2; \ + pattrib_iv[5] = dot11txpn._byte_.TSC3; \ + pattrib_iv[6] = dot11txpn._byte_.TSC4; \ + pattrib_iv[7] = dot11txpn._byte_.TSC5; \ + dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val+1);\ +} while (0) + +#define HWXMIT_ENTRY 4 + +#define TXDESC_SIZE 32 + +#define PACKET_OFFSET_SZ (8) +#define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ) + +struct tx_desc { + /* DWORD 0 */ + __le32 txdw0; + __le32 txdw1; + __le32 txdw2; + __le32 txdw3; + __le32 txdw4; + __le32 txdw5; + __le32 txdw6; + __le32 txdw7; +}; + +union txdesc { + struct tx_desc txdesc; + unsigned int value[TXDESC_SIZE>>2]; +}; + +struct hw_xmit { + struct __queue *sta_queue; + int accnt; +}; + +/* reduce size */ +struct pkt_attrib { + u8 type; + u8 subtype; + u8 bswenc; + u8 dhcp_pkt; + u16 ether_type; + u16 seqnum; + u16 pkt_hdrlen; /* the original 802.3 pkt header len */ + u16 hdrlen; /* the WLAN Header Len */ + u32 pktlen; /* the original 802.3 pkt raw_data len (not include + * ether_hdr data) */ + u32 last_txcmdsz; + u8 nr_frags; + u8 encrypt; /* when 0 indicate no encrypt. when non-zero, + * indicate the encrypt algorith */ + u8 iv_len; + u8 icv_len; + u8 iv[18]; + u8 icv[16]; + u8 priority; + u8 ack_policy; + u8 mac_id; + u8 vcs_mode; /* virtual carrier sense method */ + u8 dst[ETH_ALEN]; + u8 src[ETH_ALEN]; + u8 ta[ETH_ALEN]; + u8 ra[ETH_ALEN]; + u8 key_idx; + u8 qos_en; + u8 ht_en; + u8 raid;/* rate adpative id */ + u8 bwmode; + u8 ch_offset;/* PRIME_CHNL_OFFSET */ + u8 sgi;/* short GI */ + u8 ampdu_en;/* tx ampdu enable */ + u8 mdata;/* more data bit */ + u8 pctrl;/* per packet txdesc control enable */ + u8 triggered;/* for ap mode handling Power Saving sta */ + u8 qsel; + u8 eosp; + u8 rate; + u8 intel_proxim; + u8 retry_ctrl; + struct sta_info *psta; +}; + +#define WLANHDR_OFFSET 64 + +#define NULL_FRAMETAG (0x0) +#define DATA_FRAMETAG 0x01 +#define L2_FRAMETAG 0x02 +#define MGNT_FRAMETAG 0x03 +#define AMSDU_FRAMETAG 0x04 + +#define EII_FRAMETAG 0x05 +#define IEEE8023_FRAMETAG 0x06 + +#define MP_FRAMETAG 0x07 + +#define TXAGG_FRAMETAG 0x08 + +struct submit_ctx { + u32 submit_time; /* */ + u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */ + int status; /* status for operation */ + struct completion done; +}; + +enum { + RTW_SCTX_SUBMITTED = -1, + RTW_SCTX_DONE_SUCCESS = 0, + RTW_SCTX_DONE_UNKNOWN, + RTW_SCTX_DONE_TIMEOUT, + RTW_SCTX_DONE_BUF_ALLOC, + RTW_SCTX_DONE_BUF_FREE, + RTW_SCTX_DONE_WRITE_PORT_ERR, + RTW_SCTX_DONE_TX_DESC_NA, + RTW_SCTX_DONE_TX_DENY, + RTW_SCTX_DONE_CCX_PKT_FAIL, + RTW_SCTX_DONE_DRV_STOP, + RTW_SCTX_DONE_DEV_REMOVE, +}; + +void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms); +int rtw_sctx_wait(struct submit_ctx *sctx); +void rtw_sctx_done_err(struct submit_ctx **sctx, int status); +void rtw_sctx_done(struct submit_ctx **sctx); + +struct xmit_buf { + struct list_head list; + struct adapter *padapter; + u8 *pallocated_buf; + u8 *pbuf; + void *priv_data; + u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ + u16 flags; + u32 alloc_sz; + u32 len; + struct submit_ctx *sctx; + u32 ff_hwaddr; + struct urb *pxmit_urb[8]; + dma_addr_t dma_transfer_addr; /* (in) dma addr for transfer_buffer */ + u8 bpending[8]; + int last[8]; +}; + +struct xmit_frame { + struct list_head list; + struct pkt_attrib attrib; + struct sk_buff *pkt; + int frame_tag; + struct adapter *padapter; + u8 *buf_addr; + struct xmit_buf *pxmitbuf; + + u8 agg_num; + s8 pkt_offset; + u8 ack_report; +}; + +struct tx_servq { + struct list_head tx_pending; + struct __queue sta_pending; + int qcnt; +}; + +struct sta_xmit_priv { + spinlock_t lock; + int option; + int apsd_setting; /* When bit mask is on, the associated edca + * queue supports APSD. */ + struct tx_servq be_q; /* priority == 0,3 */ + struct tx_servq bk_q; /* priority == 1,2 */ + struct tx_servq vi_q; /* priority == 4,5 */ + struct tx_servq vo_q; /* priority == 6,7 */ + struct list_head legacy_dz; + struct list_head apsd; + u16 txseq_tid[16]; +}; + +struct hw_txqueue { + volatile int head; + volatile int tail; + volatile int free_sz; /* in units of 64 bytes */ + volatile int free_cmdsz; + volatile int txsz[8]; + uint ff_hwaddr; + uint cmd_hwaddr; + int ac_tag; +}; + +struct agg_pkt_info { + u16 offset; + u16 pkt_len; +}; + +struct xmit_priv { + spinlock_t lock; + struct semaphore xmit_sema; + struct semaphore terminate_xmitthread_sema; + struct __queue be_pending; + struct __queue bk_pending; + struct __queue vi_pending; + struct __queue vo_pending; + struct __queue bm_pending; + u8 *pallocated_frame_buf; + u8 *pxmit_frame_buf; + uint free_xmitframe_cnt; + struct __queue free_xmit_queue; + uint frag_len; + struct adapter *adapter; + u8 vcs_setting; + u8 vcs; + u8 vcs_type; + u64 tx_bytes; + u64 tx_pkts; + u64 tx_drop; + u64 last_tx_bytes; + u64 last_tx_pkts; + struct hw_xmit *hwxmits; + u8 hwxmit_entry; + u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength + * from large to small. it's value is 0->vo, + * 1->vi, 2->be, 3->bk. */ + struct semaphore tx_retevt;/* all tx return event; */ + u8 txirp_cnt;/* */ + struct tasklet_struct xmit_tasklet; + /* per AC pending irp */ + int beq_cnt; + int bkq_cnt; + int viq_cnt; + int voq_cnt; + struct __queue free_xmitbuf_queue; + struct __queue pending_xmitbuf_queue; + u8 *pallocated_xmitbuf; + u8 *pxmitbuf; + uint free_xmitbuf_cnt; + struct __queue free_xmit_extbuf_queue; + u8 *pallocated_xmit_extbuf; + u8 *pxmit_extbuf; + uint free_xmit_extbuf_cnt; + u16 nqos_ssn; + int ack_tx; + struct mutex ack_tx_mutex; + struct submit_ctx ack_tx_ops; +}; + +struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv); +s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf); +struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv); +s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, + struct xmit_buf *pxmitbuf); +void rtw_count_tx_stats(struct adapter *padapter, + struct xmit_frame *pxmitframe, int sz); +void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len); +s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, + struct pkt_attrib *pattrib); +s32 rtw_put_snap(u8 *data, u16 h_proto); + +struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv); +s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, + struct xmit_frame *pxmitframe); +void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, + struct __queue *pframequeue); +struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, + struct sta_info *psta, int up, u8 *ac); +s32 rtw_xmitframe_enqueue(struct adapter *padapter, + struct xmit_frame *pxmitframe); +struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, + struct hw_xmit *phwxmit_i, int entry); + +s32 rtw_xmit_classifier(struct adapter *padapter, + struct xmit_frame *pxmitframe); +u32 rtw_calculate_wlan_pkt_size_by_attribue(struct pkt_attrib *pattrib); +#define rtw_wlan_pkt_size(f) rtw_calculate_wlan_pkt_size_by_attribue(&f->attrib) +s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, + struct xmit_frame *pxmitframe); +s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); +void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv); +s32 rtw_txframes_pending(struct adapter *padapter); +s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, + struct pkt_attrib *pattrib); +void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); +s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); +void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); +void rtw_alloc_hwxmits(struct adapter *padapter); +void rtw_free_hwxmits(struct adapter *padapter); +s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); + +#if defined(CONFIG_88EU_AP_MODE) +int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe); +void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta); +void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta); +void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta); +#endif + +u8 qos_acm(u8 acm_mask, u8 priority); +u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe); +int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms); +void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status); + +/* include after declaring struct xmit_buf, in order to avoid warning */ +#include + +#endif /* _RTL871X_XMIT_H_ */ diff --git a/drivers/staging/r8188eu/include/sta_info.h b/drivers/staging/r8188eu/include/sta_info.h new file mode 100644 index 000000000000..3e909db1d41a --- /dev/null +++ b/drivers/staging/r8188eu/include/sta_info.h @@ -0,0 +1,384 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __STA_INFO_H_ +#define __STA_INFO_H_ + +#include +#include +#include + +#define IBSS_START_MAC_ID 2 +#define NUM_STA 32 +#define NUM_ACL 16 + +/* if mode ==0, then the sta is allowed once the addr is hit. */ +/* if mode ==1, then the sta is rejected once the addr is non-hit. */ +struct rtw_wlan_acl_node { + struct list_head list; + u8 addr[ETH_ALEN]; + u8 valid; +}; + +/* mode=0, disable */ +/* mode=1, accept unless in deny list */ +/* mode=2, deny unless in accept list */ +struct wlan_acl_pool { + int mode; + int num; + struct rtw_wlan_acl_node aclnode[NUM_ACL]; + struct __queue acl_node_q; +}; + +struct rssi_sta { + s32 UndecoratedSmoothedPWDB; + s32 UndecoratedSmoothedCCK; + s32 UndecoratedSmoothedOFDM; + u64 PacketMap; + u8 ValidBit; +}; + +struct stainfo_stats { + u64 rx_mgnt_pkts; + u64 rx_beacon_pkts; + u64 rx_probereq_pkts; + u64 rx_probersp_pkts; + u64 rx_probersp_bm_pkts; + u64 rx_probersp_uo_pkts; + u64 rx_ctrl_pkts; + u64 rx_data_pkts; + + u64 last_rx_mgnt_pkts; + u64 last_rx_beacon_pkts; + u64 last_rx_probereq_pkts; + u64 last_rx_probersp_pkts; + u64 last_rx_probersp_bm_pkts; + u64 last_rx_probersp_uo_pkts; + u64 last_rx_ctrl_pkts; + u64 last_rx_data_pkts; + u64 rx_bytes; + u64 rx_drops; + u64 tx_pkts; + u64 tx_bytes; + u64 tx_drops; +}; + +struct sta_info { + spinlock_t lock; + struct list_head list; /* free_sta_queue */ + struct list_head hash_list; /* sta_hash */ + + struct sta_xmit_priv sta_xmitpriv; + struct sta_recv_priv sta_recvpriv; + + struct __queue sleep_q; + unsigned int sleepq_len; + + uint state; + uint aid; + uint mac_id; + uint qos_option; + u8 hwaddr[ETH_ALEN]; + + uint ieee8021x_blocked; /* 0: allowed, 1:blocked */ + uint dot118021XPrivacy; /* aes, tkip... */ + union Keytype dot11tkiptxmickey; + union Keytype dot11tkiprxmickey; + union Keytype dot118021x_UncstKey; + union pn48 dot11txpn; /* PN48 used for Unicast xmit. */ + union pn48 dot11rxpn; /* PN48 used for Unicast recv. */ + u8 bssrateset[16]; + u32 bssratelen; + s32 rssi; + s32 signal_quality; + + u8 cts2self; + u8 rtsen; + + u8 raid; + u8 init_rate; + u32 ra_mask; + u8 wireless_mode; /* NETWORK_TYPE */ + struct stainfo_stats sta_stats; + + /* for A-MPDU TX, ADDBA timeout check */ + struct timer_list addba_retry_timer; + + /* for A-MPDU Rx reordering buffer control */ + struct recv_reorder_ctrl recvreorder_ctrl[16]; + + /* for A-MPDU Tx */ + /* unsigned char ampdu_txen_bitmap; */ + u16 BA_starting_seqctrl[16]; + + struct ht_priv htpriv; + + /* Notes: */ + /* STA_Mode: */ + /* curr_network(mlme_priv/security_priv/qos/ht) + + * sta_info: (STA & AP) CAP/INFO */ + /* scan_q: AP CAP/INFO */ + + /* AP_Mode: */ + /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */ + /* sta_info: (AP & STA) CAP/INFO */ + + struct list_head asoc_list; +#ifdef CONFIG_88EU_AP_MODE + struct list_head auth_list; + + unsigned int expire_to; + unsigned int auth_seq; + unsigned int authalg; + unsigned char chg_txt[128]; + + u16 capability; + int flags; + + int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */ + int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */ + int wpa_group_cipher; + int wpa2_group_cipher; + int wpa_pairwise_cipher; + int wpa2_pairwise_cipher; + + u8 bpairwise_key_installed; + + u8 wpa_ie[32]; + + u8 nonerp_set; + u8 no_short_slot_time_set; + u8 no_short_preamble_set; + u8 no_ht_gf_set; + u8 no_ht_set; + u8 ht_20mhz_set; + + unsigned int tx_ra_bitmap; + u8 qos_info; + + u8 max_sp_len; + u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */ + u8 uapsd_be; + u8 uapsd_vi; + u8 uapsd_vo; + + u8 has_legacy_ac; + unsigned int sleepq_ac_len; +#endif /* CONFIG_88EU_AP_MODE */ + +#ifdef CONFIG_88EU_P2P + /* p2p priv data */ + u8 is_p2p_device; + u8 p2p_status_code; + + /* p2p client info */ + u8 dev_addr[ETH_ALEN]; + u8 dev_cap; + u16 config_methods; + u8 primary_dev_type[8]; + u8 num_of_secdev_type; + u8 secdev_types_list[32];/* 32/8 == 4; */ + u16 dev_name_len; + u8 dev_name[32]; +#endif /* CONFIG_88EU_P2P */ + u8 under_exist_checking; + u8 keep_alive_trycnt; + + /* for DM */ + struct rssi_sta rssi_stat; + + /* ================ODM Relative Info======================= */ + /* Please be careful, don't declare too much structure here. + * It will cost memory * STA support num. */ + /* 2011/10/20 MH Add for ODM STA info. */ + /* Driver Write */ + u8 bValid; /* record the sta status link or not? */ + u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ + u8 rssi_level; /* for Refresh RA mask */ + /* ODM Write */ + /* 1 PHY_STATUS_INFO */ + u8 RSSI_Path[4]; /* */ + u8 RSSI_Ave; + u8 RXEVM[4]; + u8 RXSNR[4]; + + /* ================ODM Relative Info======================= */ + /* */ + + /* To store the sequence number of received management frame */ + u16 RxMgmtFrameSeqNum; +}; + +#define sta_rx_pkts(sta) \ + (sta->sta_stats.rx_mgnt_pkts \ + + sta->sta_stats.rx_ctrl_pkts \ + + sta->sta_stats.rx_data_pkts) + +#define sta_last_rx_pkts(sta) \ + (sta->sta_stats.last_rx_mgnt_pkts \ + + sta->sta_stats.last_rx_ctrl_pkts \ + + sta->sta_stats.last_rx_data_pkts) + +#define sta_rx_data_pkts(sta) \ + (sta->sta_stats.rx_data_pkts) + +#define sta_last_rx_data_pkts(sta) \ + (sta->sta_stats.last_rx_data_pkts) + +#define sta_rx_mgnt_pkts(sta) \ + (sta->sta_stats.rx_mgnt_pkts) + +#define sta_last_rx_mgnt_pkts(sta) \ + (sta->sta_stats.last_rx_mgnt_pkts) + +#define sta_rx_beacon_pkts(sta) \ + (sta->sta_stats.rx_beacon_pkts) + +#define sta_last_rx_beacon_pkts(sta) \ + (sta->sta_stats.last_rx_beacon_pkts) + +#define sta_rx_probereq_pkts(sta) \ + (sta->sta_stats.rx_probereq_pkts) + +#define sta_last_rx_probereq_pkts(sta) \ + (sta->sta_stats.last_rx_probereq_pkts) + +#define sta_rx_probersp_pkts(sta) \ + (sta->sta_stats.rx_probersp_pkts) + +#define sta_last_rx_probersp_pkts(sta) \ + (sta->sta_stats.last_rx_probersp_pkts) + +#define sta_rx_probersp_bm_pkts(sta) \ + (sta->sta_stats.rx_probersp_bm_pkts) + +#define sta_last_rx_probersp_bm_pkts(sta) \ + (sta->sta_stats.last_rx_probersp_bm_pkts) + +#define sta_rx_probersp_uo_pkts(sta) \ + (sta->sta_stats.rx_probersp_uo_pkts) + +#define sta_last_rx_probersp_uo_pkts(sta) \ + (sta->sta_stats.last_rx_probersp_uo_pkts) + +#define sta_update_last_rx_pkts(sta) \ +do { \ + sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \ + sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \ + sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \ + sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \ + sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \ + sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \ + sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \ + sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \ +} while (0) + +#define STA_RX_PKTS_ARG(sta) \ + sta->sta_stats.rx_mgnt_pkts \ + , sta->sta_stats.rx_ctrl_pkts \ + , sta->sta_stats.rx_data_pkts + +#define STA_LAST_RX_PKTS_ARG(sta) \ + sta->sta_stats.last_rx_mgnt_pkts \ + , sta->sta_stats.last_rx_ctrl_pkts \ + , sta->sta_stats.last_rx_data_pkts + +#define STA_RX_PKTS_DIFF_ARG(sta) \ + sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \ + , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \ + , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts + +#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)" + +struct sta_priv { + u8 *pallocated_stainfo_buf; + u8 *pstainfo_buf; + struct __queue free_sta_queue; + + spinlock_t sta_hash_lock; + struct list_head sta_hash[NUM_STA]; + int asoc_sta_count; + struct __queue sleep_q; + struct __queue wakeup_q; + + struct adapter *padapter; + + spinlock_t asoc_list_lock; + struct list_head asoc_list; + +#ifdef CONFIG_88EU_AP_MODE + struct list_head auth_list; + spinlock_t auth_list_lock; + u8 asoc_list_cnt; + u8 auth_list_cnt; + + unsigned int auth_to; /* sec, time to expire in authenticating. */ + unsigned int assoc_to; /* sec, time to expire before associating. */ + unsigned int expire_to; /* sec , time to expire after associated. */ + + /* pointers to STA info; based on allocated AID or NULL if AID free + * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1 + * and so on + */ + struct sta_info *sta_aid[NUM_STA]; + + u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap + * for sleeping sta. */ + u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping + * bit0~bit15 */ + + u16 max_num_sta; + + struct wlan_acl_pool acl_list; +#endif + +}; + +static inline u32 wifi_mac_hash(u8 *mac) +{ + u32 x; + + x = mac[0]; + x = (x << 2) ^ mac[1]; + x = (x << 2) ^ mac[2]; + x = (x << 2) ^ mac[3]; + x = (x << 2) ^ mac[4]; + x = (x << 2) ^ mac[5]; + + x ^= x >> 8; + x = x & (NUM_STA - 1); + return x; +} + +extern u32 _rtw_init_sta_priv(struct sta_priv *pstapriv); +extern u32 _rtw_free_sta_priv(struct sta_priv *pstapriv); + +#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0) +int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta); +struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off); + +extern struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr); +extern u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta); +extern void rtw_free_all_stainfo(struct adapter *adapt); +extern struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr); +extern u32 rtw_init_bcmc_stainfo(struct adapter *adapt); +extern struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter); +extern u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); + +#endif /* _STA_INFO_H_ */ diff --git a/drivers/staging/r8188eu/include/usb_hal.h b/drivers/staging/r8188eu/include/usb_hal.h new file mode 100644 index 000000000000..8a65995d5e48 --- /dev/null +++ b/drivers/staging/r8188eu/include/usb_hal.h @@ -0,0 +1,26 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_HAL_H__ +#define __USB_HAL_H__ + +void rtl8188eu_set_hal_ops(struct adapter *padapter); +#define hal_set_hal_ops rtl8188eu_set_hal_ops + +#endif /* __USB_HAL_H__ */ diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h new file mode 100644 index 000000000000..6562082beb7a --- /dev/null +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -0,0 +1,115 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_OPS_H_ +#define __USB_OPS_H_ + +#include +#include +#include +#include + +#define REALTEK_USB_VENQT_READ 0xC0 +#define REALTEK_USB_VENQT_WRITE 0x40 +#define REALTEK_USB_VENQT_CMD_REQ 0x05 +#define REALTEK_USB_VENQT_CMD_IDX 0x00 + +enum { + VENDOR_WRITE = 0x00, + VENDOR_READ = 0x01, +}; +#define ALIGNMENT_UNIT 16 +#define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ +#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) + +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)) +#define rtw_usb_control_msg(dev, pipe, request, requesttype, \ + value, index, data, size, timeout_ms) \ + usb_control_msg((dev), (pipe), (request), (requesttype), (value),\ + (index), (data), (size), (timeout_ms)) +#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ + usb_bulk_msg((usb_dev), (pipe), (data), (len), \ + (actual_length), (timeout_ms)) +#else +#define rtw_usb_control_msg(dev, pipe, request, requesttype, \ + value, index, data, size, timeout_ms) \ + usb_control_msg((dev), (pipe), (request), (requesttype), \ + (value), (index), (data), (size), \ + ((timeout_ms) == 0) || \ + ((timeout_ms)*HZ/1000 > 0) ? \ + ((timeout_ms)*HZ/1000) : 1) +#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, \ + actual_length, timeout_ms) \ + usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \ + ((timeout_ms) == 0) || ((timeout_ms)*HZ/1000 > 0) ?\ + ((timeout_ms)*HZ/1000) : 1) +#endif +#include + +void rtl8188eu_set_hw_type(struct adapter *padapter); +#define hal_set_hw_type rtl8188eu_set_hw_type +void rtl8188eu_set_intf_ops(struct _io_ops *pops); +#define usb_set_intf_ops rtl8188eu_set_intf_ops + +/* + * Increase and check if the continual_urb_error of this @param dvobjprivei + * is larger than MAX_CONTINUAL_URB_ERR + * @return true: + * @return false: + */ +static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj) +{ + int ret = false; + int value; + value = ATOMIC_INC_RETURN(&dvobj->continual_urb_error); + if (value > MAX_CONTINUAL_URB_ERR) { + DBG_88E("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n", + dvobj, value, MAX_CONTINUAL_URB_ERR); + ret = true; + } + return ret; +} + +/* +* Set the continual_urb_error of this @param dvobjprive to 0 +*/ +static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj) +{ + ATOMIC_SET(&dvobj->continual_urb_error, 0); +} + +#define USB_HIGH_SPEED_BULK_SIZE 512 +#define USB_FULL_SPEED_BULK_SIZE 64 + +static inline u8 rtw_usb_bulk_size_boundary(struct adapter *padapter, + int buf_len) +{ + u8 rst = true; + struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter); + + if (pdvobjpriv->ishighspeed) + rst = (0 == (buf_len) % USB_HIGH_SPEED_BULK_SIZE) ? + true : false; + else + rst = (0 == (buf_len) % USB_FULL_SPEED_BULK_SIZE) ? + true : false; + return rst; +} + +#endif /* __USB_OPS_H_ */ diff --git a/drivers/staging/r8188eu/include/usb_ops_linux.h b/drivers/staging/r8188eu/include/usb_ops_linux.h new file mode 100644 index 000000000000..e5b758a81a5c --- /dev/null +++ b/drivers/staging/r8188eu/include/usb_ops_linux.h @@ -0,0 +1,55 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_OPS_LINUX_H__ +#define __USB_OPS_LINUX_H__ + +#define VENDOR_CMD_MAX_DATA_LEN 254 + +#define RTW_USB_CONTROL_MSG_TIMEOUT_TEST 10/* ms */ +#define RTW_USB_CONTROL_MSG_TIMEOUT 500/* ms */ + +#define MAX_USBCTRL_VENDORREQ_TIMES 10 + +#define RTW_USB_BULKOUT_TIME 5000/* ms */ + +#define _usbctrl_vendorreq_async_callback(urb, regs) \ + _usbctrl_vendorreq_async_callback(urb) +#define usb_bulkout_zero_complete(purb, regs) \ + usb_bulkout_zero_complete(purb) +#define usb_write_mem_complete(purb, regs) \ + usb_write_mem_complete(purb) +#define usb_write_port_complete(purb, regs) \ + usb_write_port_complete(purb) +#define usb_read_port_complete(purb, regs) \ + usb_read_port_complete(purb) +#define usb_read_interrupt_complete(purb, regs) \ + usb_read_interrupt_complete(purb) + +unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr); + +void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem); +void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); + +void usb_read_port_cancel(struct intf_hdl *pintfhdl); + +u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem); +void usb_write_port_cancel(struct intf_hdl *pintfhdl); + +#endif diff --git a/drivers/staging/r8188eu/include/usb_osintf.h b/drivers/staging/r8188eu/include/usb_osintf.h new file mode 100644 index 000000000000..9de99ca9799a --- /dev/null +++ b/drivers/staging/r8188eu/include/usb_osintf.h @@ -0,0 +1,45 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __USB_OSINTF_H +#define __USB_OSINTF_H + +#include +#include +#include + +extern char *rtw_initmac; +extern int rtw_mc2u_disable; + +#define USBD_HALTED(Status) ((u32)(Status) >> 30 == 3) + +u8 usbvendorrequest(struct dvobj_priv *pdvobjpriv, enum bt_usb_request brequest, + enum rt_usb_wvalue wvalue, u8 windex, void *data, + u8 datalen, u8 isdirectionin); +int pm_netdev_open(struct net_device *pnetdev, u8 bnormal); +void netdev_br_init(struct net_device *netdev); +void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb); +void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, + unsigned char *ipAddr); +void nat25_db_expire(struct adapter *priv); +int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method); + +int rtw_resume_process(struct adapter *padapter); + +#endif diff --git a/drivers/staging/r8188eu/include/usb_vendor_req.h b/drivers/staging/r8188eu/include/usb_vendor_req.h new file mode 100644 index 000000000000..04f1b9e267e1 --- /dev/null +++ b/drivers/staging/r8188eu/include/usb_vendor_req.h @@ -0,0 +1,51 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _USB_VENDOR_REQUEST_H_ +#define _USB_VENDOR_REQUEST_H_ + +/* 4 Set/Get Register related wIndex/Data */ +#define RT_USB_RESET_MASK_OFF 0 +#define RT_USB_RESET_MASK_ON 1 +#define RT_USB_SLEEP_MASK_OFF 0 +#define RT_USB_SLEEP_MASK_ON 1 +#define RT_USB_LDO_ON 1 +#define RT_USB_LDO_OFF 0 + +/* 4 Set/Get SYSCLK related wValue or Data */ +#define RT_USB_SYSCLK_32KHZ 0 +#define RT_USB_SYSCLK_40MHZ 1 +#define RT_USB_SYSCLK_60MHZ 2 + +enum bt_usb_request { + RT_USB_SET_REGISTER = 1, + RT_USB_SET_SYSCLK = 2, + RT_USB_GET_SYSCLK = 3, + RT_USB_GET_REGISTER = 4 +}; + +enum rt_usb_wvalue { + RT_USB_RESET_MASK = 1, + RT_USB_SLEEP_MASK = 2, + RT_USB_USB_HRCPWM = 3, + RT_USB_LDO = 4, + RT_USB_BOOT_TYPE = 5 +}; + +#endif diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h new file mode 100644 index 000000000000..33a7e6c19d04 --- /dev/null +++ b/drivers/staging/r8188eu/include/wifi.h @@ -0,0 +1,1105 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef _WIFI_H_ +#define _WIFI_H_ + +#include + +#ifdef BIT +/* error "BIT define occurred earlier elsewhere!\n" */ +#undef BIT +#endif +#define BIT(x) (1 << (x)) + +#define WLAN_ETHHDR_LEN 14 +#define WLAN_ETHADDR_LEN 6 +#define WLAN_IEEE_OUI_LEN 3 +#define WLAN_ADDR_LEN 6 +#define WLAN_CRC_LEN 4 +#define WLAN_BSSID_LEN 6 +#define WLAN_BSS_TS_LEN 8 +#define WLAN_HDR_A3_LEN 24 +#define WLAN_HDR_A4_LEN 30 +#define WLAN_HDR_A3_QOS_LEN 26 +#define WLAN_HDR_A4_QOS_LEN 32 +#define WLAN_SSID_MAXLEN 32 +#define WLAN_DATA_MAXLEN 2312 + +#define WLAN_A3_PN_OFFSET 24 +#define WLAN_A4_PN_OFFSET 30 + +#define WLAN_MIN_ETHFRM_LEN 60 +#define WLAN_MAX_ETHFRM_LEN 1514 +#define WLAN_ETHHDR_LEN 14 + +#define P80211CAPTURE_VERSION 0x80211001 + +/* This value is tested by WiFi 11n Test Plan 5.2.3. */ +/* This test verifies the WLAN NIC can update the NAV through sending + * the CTS with large duration. */ +#define WiFiNavUpperUs 30000 /* 30 ms */ + +enum WIFI_FRAME_TYPE { + WIFI_MGT_TYPE = (0), + WIFI_CTRL_TYPE = (BIT(2)), + WIFI_DATA_TYPE = (BIT(3)), + WIFI_QOS_DATA_TYPE = (BIT(7)|BIT(3)), /* QoS Data */ +}; + +enum WIFI_FRAME_SUBTYPE { + /* below is for mgt frame */ + WIFI_ASSOCREQ = (0 | WIFI_MGT_TYPE), + WIFI_ASSOCRSP = (BIT(4) | WIFI_MGT_TYPE), + WIFI_REASSOCREQ = (BIT(5) | WIFI_MGT_TYPE), + WIFI_REASSOCRSP = (BIT(5) | BIT(4) | WIFI_MGT_TYPE), + WIFI_PROBEREQ = (BIT(6) | WIFI_MGT_TYPE), + WIFI_PROBERSP = (BIT(6) | BIT(4) | WIFI_MGT_TYPE), + WIFI_BEACON = (BIT(7) | WIFI_MGT_TYPE), + WIFI_ATIM = (BIT(7) | BIT(4) | WIFI_MGT_TYPE), + WIFI_DISASSOC = (BIT(7) | BIT(5) | WIFI_MGT_TYPE), + WIFI_AUTH = (BIT(7) | BIT(5) | BIT(4) | WIFI_MGT_TYPE), + WIFI_DEAUTH = (BIT(7) | BIT(6) | WIFI_MGT_TYPE), + WIFI_ACTION = (BIT(7) | BIT(6) | BIT(4) | WIFI_MGT_TYPE), + + /* below is for control frame */ + WIFI_PSPOLL = (BIT(7) | BIT(5) | WIFI_CTRL_TYPE), + WIFI_RTS = (BIT(7) | BIT(5) | BIT(4) | WIFI_CTRL_TYPE), + WIFI_CTS = (BIT(7) | BIT(6) | WIFI_CTRL_TYPE), + WIFI_ACK = (BIT(7) | BIT(6) | BIT(4) | WIFI_CTRL_TYPE), + WIFI_CFEND = (BIT(7) | BIT(6) | BIT(5) | WIFI_CTRL_TYPE), + WIFI_CFEND_CFACK = (BIT(7) | BIT(6) | BIT(5) | BIT(4) | + WIFI_CTRL_TYPE), + + /* below is for data frame */ + WIFI_DATA = (0 | WIFI_DATA_TYPE), + WIFI_DATA_CFACK = (BIT(4) | WIFI_DATA_TYPE), + WIFI_DATA_CFPOLL = (BIT(5) | WIFI_DATA_TYPE), + WIFI_DATA_CFACKPOLL = (BIT(5) | BIT(4) | WIFI_DATA_TYPE), + WIFI_DATA_NULL = (BIT(6) | WIFI_DATA_TYPE), + WIFI_CF_ACK = (BIT(6) | BIT(4) | WIFI_DATA_TYPE), + WIFI_CF_POLL = (BIT(6) | BIT(5) | WIFI_DATA_TYPE), + WIFI_CF_ACKPOLL = (BIT(6) | BIT(5) | BIT(4) | WIFI_DATA_TYPE), + WIFI_QOS_DATA_NULL = (BIT(6) | WIFI_QOS_DATA_TYPE), +}; + +enum WIFI_REASON_CODE { + _RSON_RESERVED_ = 0, + _RSON_UNSPECIFIED_ = 1, + _RSON_AUTH_NO_LONGER_VALID_ = 2, + _RSON_DEAUTH_STA_LEAVING_ = 3, + _RSON_INACTIVITY_ = 4, + _RSON_UNABLE_HANDLE_ = 5, + _RSON_CLS2_ = 6, + _RSON_CLS3_ = 7, + _RSON_DISAOC_STA_LEAVING_ = 8, + _RSON_ASOC_NOT_AUTH_ = 9, + + /* WPA reason */ + _RSON_INVALID_IE_ = 13, + _RSON_MIC_FAILURE_ = 14, + _RSON_4WAY_HNDSHK_TIMEOUT_ = 15, + _RSON_GROUP_KEY_UPDATE_TIMEOUT_ = 16, + _RSON_DIFF_IE_ = 17, + _RSON_MLTCST_CIPHER_NOT_VALID_ = 18, + _RSON_UNICST_CIPHER_NOT_VALID_ = 19, + _RSON_AKMP_NOT_VALID_ = 20, + _RSON_UNSUPPORT_RSNE_VER_ = 21, + _RSON_INVALID_RSNE_CAP_ = 22, + _RSON_IEEE_802DOT1X_AUTH_FAIL_ = 23, + + /* belowing are Realtek definition */ + _RSON_PMK_NOT_AVAILABLE_ = 24, + _RSON_TDLS_TEAR_TOOFAR_ = 25, + _RSON_TDLS_TEAR_UN_RSN_ = 26, +}; + +/* Reason codes (IEEE 802.11-2007, 7.3.1.7, Table 7-22) + +#define WLAN_REASON_UNSPECIFIED 1 +#define WLAN_REASON_PREV_AUTH_NOT_VALID 2 +#define WLAN_REASON_DEAUTH_LEAVING 3 +#define WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY 4 +#define WLAN_REASON_DISASSOC_AP_BUSY 5 +#define WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA 6 +#define WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA 7 +#define WLAN_REASON_DISASSOC_STA_HAS_LEFT 8 +#define WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH 9 */ +/* IEEE 802.11h */ +#define WLAN_REASON_PWR_CAPABILITY_NOT_VALID 10 +#define WLAN_REASON_SUPPORTED_CHANNEL_NOT_VALID 11 + +/* IEEE 802.11i +#define WLAN_REASON_INVALID_IE 13 +#define WLAN_REASON_MICHAEL_MIC_FAILURE 14 +#define WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT 15 +#define WLAN_REASON_GROUP_KEY_UPDATE_TIMEOUT 16 +#define WLAN_REASON_IE_IN_4WAY_DIFFERS 17 +#define WLAN_REASON_GROUP_CIPHER_NOT_VALID 18 +#define WLAN_REASON_PAIRWISE_CIPHER_NOT_VALID 19 +#define WLAN_REASON_AKMP_NOT_VALID 20 +#define WLAN_REASON_UNSUPPORTED_RSN_IE_VERSION 21 +#define WLAN_REASON_INVALID_RSN_IE_CAPAB 22 +#define WLAN_REASON_IEEE_802_1X_AUTH_FAILED 23 +#define WLAN_REASON_CIPHER_SUITE_REJECTED 24 */ + +enum WIFI_STATUS_CODE { + _STATS_SUCCESSFUL_ = 0, + _STATS_FAILURE_ = 1, + _STATS_CAP_FAIL_ = 10, + _STATS_NO_ASOC_ = 11, + _STATS_OTHER_ = 12, + _STATS_NO_SUPP_ALG_ = 13, + _STATS_OUT_OF_AUTH_SEQ_ = 14, + _STATS_CHALLENGE_FAIL_ = 15, + _STATS_AUTH_TIMEOUT_ = 16, + _STATS_UNABLE_HANDLE_STA_ = 17, + _STATS_RATE_FAIL_ = 18, +}; + +/* Status codes (IEEE 802.11-2007, 7.3.1.9, Table 7-23) +#define WLAN_STATUS_SUCCESS 0 +#define WLAN_STATUS_UNSPECIFIED_FAILURE 1 +#define WLAN_STATUS_CAPS_UNSUPPORTED 10 +#define WLAN_STATUS_REASSOC_NO_ASSOC 11 +#define WLAN_STATUS_ASSOC_DENIED_UNSPEC 12 +#define WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG 13 +#define WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION 14 +#define WLAN_STATUS_CHALLENGE_FAIL 15 +#define WLAN_STATUS_AUTH_TIMEOUT 16 +#define WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA 17 +#define WLAN_STATUS_ASSOC_DENIED_RATES 18 */ + +/* entended */ +/* IEEE 802.11b */ +#define WLAN_STATUS_ASSOC_DENIED_NOSHORT 19 +#define WLAN_STATUS_ASSOC_DENIED_NOPBCC 20 +#define WLAN_STATUS_ASSOC_DENIED_NOAGILITY 21 +/* IEEE 802.11h */ +#define WLAN_STATUS_SPEC_MGMT_REQUIRED 22 +#define WLAN_STATUS_PWR_CAPABILITY_NOT_VALID 23 +#define WLAN_STATUS_SUPPORTED_CHANNEL_NOT_VALID 24 +/* IEEE 802.11g */ +#define WLAN_STATUS_ASSOC_DENIED_NO_SHORT_SLOT_TIME 25 +#define WLAN_STATUS_ASSOC_DENIED_NO_ER_PBCC 26 +#define WLAN_STATUS_ASSOC_DENIED_NO_DSSS_OFDM 27 +/* IEEE 802.11w */ +#define WLAN_STATUS_ASSOC_REJECTED_TEMPORARILY 30 +#define WLAN_STATUS_ROBUST_MGMT_FRAME_POLICY_VIOLATION 31 +/* IEEE 802.11i */ +#define WLAN_STATUS_INVALID_IE 40 +#define WLAN_STATUS_GROUP_CIPHER_NOT_VALID 41 +#define WLAN_STATUS_PAIRWISE_CIPHER_NOT_VALID 42 +#define WLAN_STATUS_AKMP_NOT_VALID 43 +#define WLAN_STATUS_UNSUPPORTED_RSN_IE_VERSION 44 +#define WLAN_STATUS_INVALID_RSN_IE_CAPAB 45 +#define WLAN_STATUS_CIPHER_REJECTED_PER_POLICY 46 +#define WLAN_STATUS_TS_NOT_CREATED 47 +#define WLAN_STATUS_DIRECT_LINK_NOT_ALLOWED 48 +#define WLAN_STATUS_DEST_STA_NOT_PRESENT 49 +#define WLAN_STATUS_DEST_STA_NOT_QOS_STA 50 +#define WLAN_STATUS_ASSOC_DENIED_LISTEN_INT_TOO_LARGE 51 +/* IEEE 802.11r */ +#define WLAN_STATUS_INVALID_FT_ACTION_FRAME_COUNT 52 +#define WLAN_STATUS_INVALID_PMKID 53 +#define WLAN_STATUS_INVALID_MDIE 54 +#define WLAN_STATUS_INVALID_FTIE 55 + +enum WIFI_REG_DOMAIN { + DOMAIN_FCC = 1, + DOMAIN_IC = 2, + DOMAIN_ETSI = 3, + DOMAIN_SPA = 4, + DOMAIN_FRANCE = 5, + DOMAIN_MKK = 6, + DOMAIN_ISRAEL = 7, + DOMAIN_MKK1 = 8, + DOMAIN_MKK2 = 9, + DOMAIN_MKK3 = 10, + DOMAIN_MAX +}; + +#define _TO_DS_ BIT(8) +#define _FROM_DS_ BIT(9) +#define _MORE_FRAG_ BIT(10) +#define _RETRY_ BIT(11) +#define _PWRMGT_ BIT(12) +#define _MORE_DATA_ BIT(13) +#define _PRIVACY_ BIT(14) +#define _ORDER_ BIT(15) + +#define SetToDs(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_TO_DS_) + +#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_TO_DS_)) != 0) + +#define ClearToDs(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_TO_DS_)) + +#define SetFrDs(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_FROM_DS_) + +#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_FROM_DS_)) != 0) + +#define ClearFrDs(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_FROM_DS_)) + +#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) + +#define SetMFrag(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_FRAG_) + +#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_FRAG_)) != 0) + +#define ClearMFrag(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_FRAG_)) + +#define SetRetry(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_RETRY_) + +#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_RETRY_)) != 0) + +#define ClearRetry(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_RETRY_)) + +#define SetPwrMgt(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_PWRMGT_) + +#define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_PWRMGT_)) != 0) + +#define ClearPwrMgt(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_PWRMGT_)) + +#define SetMData(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_MORE_DATA_) + +#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(_MORE_DATA_)) != 0) + +#define ClearMData(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_MORE_DATA_)) + +#define SetPrivacy(pbuf) \ + *(__le16 *)(pbuf) |= cpu_to_le16(_PRIVACY_) + +#define GetPrivacy(pbuf) \ + (((*(__le16 *)(pbuf)) & cpu_to_le16(_PRIVACY_)) != 0) + +#define ClearPrivacy(pbuf) \ + *(__le16 *)(pbuf) &= (~cpu_to_le16(_PRIVACY_)) + +#define GetOrder(pbuf) \ + (((*(__le16 *)(pbuf)) & cpu_to_le16(_ORDER_)) != 0) + +#define GetFrameType(pbuf) \ + (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2))) + +#define SetFrameType(pbuf, type) \ + do { \ + *(unsigned short *)(pbuf) &= __constant_cpu_to_le16(~(BIT(3) | BIT(2))); \ + *(unsigned short *)(pbuf) |= __constant_cpu_to_le16(type); \ + } while (0) + +#define GetFrameSubType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\ + BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))) + +#define SetFrameSubType(pbuf, type) \ + do { \ + *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \ + BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ + *(__le16 *)(pbuf) |= cpu_to_le16(type); \ + } while (0) + +#define GetSequence(pbuf) \ + (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4) + +#define GetFragNum(pbuf) \ + (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f) + +#define GetTupleCache(pbuf) \ + (cpu_to_le16(*(unsigned short *)((size_t)(pbuf) + 22))) + +#define SetFragNum(pbuf, num) \ + do { \ + *(unsigned short *)((size_t)(pbuf) + 22) = \ + ((*(unsigned short *)((size_t)(pbuf) + 22)) & \ + le16_to_cpu(~(0x000f))) | \ + cpu_to_le16(0x0f & (num)); \ + } while (0) + +#define SetSeqNum(pbuf, num) \ + do { \ + *(__le16 *)((size_t)(pbuf) + 22) = \ + ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ + cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ + } while (0) + +#define SetDuration(pbuf, dur) \ + *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)) + +#define SetPriority(pbuf, tid) \ + *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf) + +#define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf) + +#define SetEOSP(pbuf, eosp) \ + *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4) + +#define SetAckpolicy(pbuf, ack) \ + *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5) + +#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3) + +#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1) + +#define SetAMsdu(pbuf, amsdu) \ + *(__le16 *)(pbuf) |= cpu_to_le16((amsdu & 1) << 7) + +#define GetAid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff) + +#define GetTid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + \ + (((GetToDs(pbuf)<<1) | GetFrDs(pbuf)) == 3 ? \ + 30 : 24))) & 0x000f) + +#define GetAddr1Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 4)) + +#define GetAddr2Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 10)) + +#define GetAddr3Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 16)) + +#define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24)) + +#define MacAddr_isBcst(addr) \ + ( \ + ((addr[0] == 0xff) && (addr[1] == 0xff) && \ + (addr[2] == 0xff) && (addr[3] == 0xff) && \ + (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ +) + +static inline int IS_MCAST(unsigned char *da) +{ + if ((*da) & 0x01) + return true; + else + return false; +} + +static inline unsigned char *get_da(unsigned char *pframe) +{ + unsigned char *da; + unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); + + switch (to_fr_ds) { + case 0x00: /* ToDs=0, FromDs=0 */ + da = GetAddr1Ptr(pframe); + break; + case 0x01: /* ToDs=0, FromDs=1 */ + da = GetAddr1Ptr(pframe); + break; + case 0x02: /* ToDs=1, FromDs=0 */ + da = GetAddr3Ptr(pframe); + break; + default: /* ToDs=1, FromDs=1 */ + da = GetAddr3Ptr(pframe); + break; + } + return da; +} + +static inline unsigned char *get_sa(unsigned char *pframe) +{ + unsigned char *sa; + unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); + + switch (to_fr_ds) { + case 0x00: /* ToDs=0, FromDs=0 */ + sa = GetAddr2Ptr(pframe); + break; + case 0x01: /* ToDs=0, FromDs=1 */ + sa = GetAddr3Ptr(pframe); + break; + case 0x02: /* ToDs=1, FromDs=0 */ + sa = GetAddr2Ptr(pframe); + break; + default: /* ToDs=1, FromDs=1 */ + sa = GetAddr4Ptr(pframe); + break; + } + return sa; +} + +static inline unsigned char *get_hdr_bssid(unsigned char *pframe) +{ + unsigned char *sa; + unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); + + switch (to_fr_ds) { + case 0x00: /* ToDs=0, FromDs=0 */ + sa = GetAddr3Ptr(pframe); + break; + case 0x01: /* ToDs=0, FromDs=1 */ + sa = GetAddr2Ptr(pframe); + break; + case 0x02: /* ToDs=1, FromDs=0 */ + sa = GetAddr1Ptr(pframe); + break; + case 0x03: /* ToDs=1, FromDs=1 */ + sa = GetAddr1Ptr(pframe); + break; + default: + sa = NULL; /* */ + break; + } + return sa; +} + +static inline int IsFrameTypeCtrl(unsigned char *pframe) +{ + if (WIFI_CTRL_TYPE == GetFrameType(pframe)) + return true; + else + return false; +} +/*----------------------------------------------------------------------------- + Below is for the security related definition +------------------------------------------------------------------------------*/ +#define _RESERVED_FRAME_TYPE_ 0 +#define _SKB_FRAME_TYPE_ 2 +#define _PRE_ALLOCMEM_ 1 +#define _PRE_ALLOCHDR_ 3 +#define _PRE_ALLOCLLCHDR_ 4 +#define _PRE_ALLOCICVHDR_ 5 +#define _PRE_ALLOCMICHDR_ 6 + +#define _SIFSTIME_ \ + ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10) +#define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */ +#define _CRCLNG_ 4 + +#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ +#define _ASOCRSP_IE_OFFSET_ 6 +#define _REASOCREQ_IE_OFFSET_ 10 +#define _REASOCRSP_IE_OFFSET_ 6 +#define _PROBEREQ_IE_OFFSET_ 0 +#define _PROBERSP_IE_OFFSET_ 12 +#define _AUTH_IE_OFFSET_ 6 +#define _DEAUTH_IE_OFFSET_ 0 +#define _BEACON_IE_OFFSET_ 12 +#define _PUBLIC_ACTION_IE_OFFSET_ 8 + +#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ + +#define _SSID_IE_ 0 +#define _SUPPORTEDRATES_IE_ 1 +#define _DSSET_IE_ 3 +#define _TIM_IE_ 5 +#define _IBSS_PARA_IE_ 6 +#define _COUNTRY_IE_ 7 +#define _CHLGETXT_IE_ 16 +#define _SUPPORTED_CH_IE_ 36 +#define _CH_SWTICH_ANNOUNCE_ 37 /* Secondary Channel Offset */ +#define _RSN_IE_2_ 48 +#define _SSN_IE_1_ 221 +#define _ERPINFO_IE_ 42 +#define _EXT_SUPPORTEDRATES_IE_ 50 + +#define _HT_CAPABILITY_IE_ 45 +#define _FTIE_ 55 +#define _TIMEOUT_ITVL_IE_ 56 +#define _SRC_IE_ 59 +#define _HT_EXTRA_INFO_IE_ 61 +#define _HT_ADD_INFO_IE_ 61 /* _HT_EXTRA_INFO_IE_ */ +#define _WAPI_IE_ 68 + +#define EID_BSSCoexistence 72 /* 20/40 BSS Coexistence */ +#define EID_BSSIntolerantChlReport 73 +#define _RIC_Descriptor_IE_ 75 + +#define _LINK_ID_IE_ 101 +#define _CH_SWITCH_TIMING_ 104 +#define _PTI_BUFFER_STATUS_ 106 +#define _EXT_CAP_IE_ 127 +#define _VENDOR_SPECIFIC_IE_ 221 + +#define _RESERVED47_ 47 + +/* --------------------------------------------------------------------------- + Below is the fixed elements... +-----------------------------------------------------------------------------*/ +#define _AUTH_ALGM_NUM_ 2 +#define _AUTH_SEQ_NUM_ 2 +#define _BEACON_ITERVAL_ 2 +#define _CAPABILITY_ 2 +#define _CURRENT_APADDR_ 6 +#define _LISTEN_INTERVAL_ 2 +#define _RSON_CODE_ 2 +#define _ASOC_ID_ 2 +#define _STATUS_CODE_ 2 +#define _TIMESTAMP_ 8 + +#define AUTH_ODD_TO 0 +#define AUTH_EVEN_TO 1 + +#define WLAN_ETHCONV_ENCAP 1 +#define WLAN_ETHCONV_RFC1042 2 +#define WLAN_ETHCONV_8021h 3 + +#define cap_ESS BIT(0) +#define cap_IBSS BIT(1) +#define cap_CFPollable BIT(2) +#define cap_CFRequest BIT(3) +#define cap_Privacy BIT(4) +#define cap_ShortPremble BIT(5) +#define cap_PBCC BIT(6) +#define cap_ChAgility BIT(7) +#define cap_SpecMgmt BIT(8) +#define cap_QoSi BIT(9) +#define cap_ShortSlot BIT(10) + +/*----------------------------------------------------------------------------- + Below is the definition for 802.11i / 802.1x +------------------------------------------------------------------------------*/ +#define _IEEE8021X_MGT_ 1 /* WPA */ +#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ + +/* +#define _NO_PRIVACY_ 0 +#define _WEP_40_PRIVACY_ 1 +#define _TKIP_PRIVACY_ 2 +#define _WRAP_PRIVACY_ 3 +#define _CCMP_PRIVACY_ 4 +#define _WEP_104_PRIVACY_ 5 +#define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA +*/ + +/*----------------------------------------------------------------------------- + Below is the definition for WMM +------------------------------------------------------------------------------*/ +#define _WMM_IE_Length_ 7 /* for WMM STA */ +#define _WMM_Para_Element_Length_ 24 + +/*----------------------------------------------------------------------------- + Below is the definition for 802.11n +------------------------------------------------------------------------------*/ + +#define SetOrderBit(pbuf) \ + do { \ + *(unsigned short *)(pbuf) |= cpu_to_le16(_ORDER_); \ + } while (0) + +#define GetOrderBit(pbuf) \ + (((*(unsigned short *)(pbuf)) & le16_to_cpu(_ORDER_)) != 0) + +/** + * struct rtw_ieee80211_bar - HT Block Ack Request + * + * This structure refers to "HT BlockAckReq" as + * described in 802.11n draft section 7.2.1.7.1 + */ +struct rtw_ieee80211_bar { + __le16 frame_control; + __le16 duration; + unsigned char ra[ETH_ALEN]; + unsigned char ta[ETH_ALEN]; + __le16 control; + __le16 start_seq_num; +} __packed; + +/* 802.11 BAR control masks */ +#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 +#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 + +/** + * struct ieee80211_ht_cap - HT additional information + * + * This structure refers to "HT information element" as + * described in 802.11n draft section 7.3.2.53 + */ +struct ieee80211_ht_addt_info { + unsigned char control_chan; + unsigned char ht_param; + __le16 operation_mode; + __le16 stbc_param; + unsigned char basic_set[16]; +} __packed; + +struct HT_caps_element { + union { + struct { + __le16 HT_caps_info; + unsigned char AMPDU_para; + unsigned char MCS_rate[16]; + __le16 HT_ext_caps; + __le16 Beamforming_caps; + unsigned char ASEL_caps; + } HT_cap_element; + unsigned char HT_cap[26]; + } u; +} __packed; + +struct HT_info_element { + unsigned char primary_channel; + unsigned char infos[5]; + unsigned char MCS_rate[16]; +} __packed; + +struct AC_param { + unsigned char ACI_AIFSN; + unsigned char CW; + __le16 TXOP_limit; +} __packed; + +struct WMM_para_element { + unsigned char QoS_info; + unsigned char reserved; + struct AC_param ac_param[4]; +} __packed; + +struct ADDBA_request { + unsigned char action_code; + unsigned char dialog_token; + __le16 BA_para_set; + __le16 BA_timeout_value; + __le16 BA_starting_seqctrl; +} __packed; + +enum ht_cap_ampdu_factor { + MAX_AMPDU_FACTOR_8K = 0, + MAX_AMPDU_FACTOR_16K = 1, + MAX_AMPDU_FACTOR_32K = 2, + MAX_AMPDU_FACTOR_64K = 3, +}; + +/* 802.11n HT capabilities masks */ +#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 +#define IEEE80211_HT_CAP_SM_PS 0x000C +#define IEEE80211_HT_CAP_GRN_FLD 0x0010 +#define IEEE80211_HT_CAP_SGI_20 0x0020 +#define IEEE80211_HT_CAP_SGI_40 0x0040 +#define IEEE80211_HT_CAP_TX_STBC 0x0080 +#define IEEE80211_HT_CAP_RX_STBC 0x0300 +#define IEEE80211_HT_CAP_DELAY_BA 0x0400 +#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 +#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 +/* 802.11n HT capability AMPDU settings */ +#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 +#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C +/* 802.11n HT capability MSC set */ +#define IEEE80211_SUPP_MCS_SET_UEQM 4 +#define IEEE80211_HT_CAP_MAX_STREAMS 4 +#define IEEE80211_SUPP_MCS_SET_LEN 10 +/* maximum streams the spec allows */ +#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 +#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 +#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C +#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 +/* 802.11n HT IE masks */ +#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 +#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 +#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 +#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 +#define IEEE80211_HT_IE_CHA_WIDTH 0x04 +#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 +#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 +#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 + +/* block-ack parameters */ +#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 +#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C +#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 +#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 +#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 + +/* + * A-PMDU buffer sizes + * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) + */ +#define IEEE80211_MIN_AMPDU_BUF 0x8 +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0)) +#define IEEE80211_MAX_AMPDU_BUF 0x40 +#endif + +/* Spatial Multiplexing Power Save Modes */ +#define WLAN_HT_CAP_SM_PS_STATIC 0 +#define WLAN_HT_CAP_SM_PS_DYNAMIC 1 +#define WLAN_HT_CAP_SM_PS_INVALID 2 +#define WLAN_HT_CAP_SM_PS_DISABLED 3 + +#define OP_MODE_PURE 0 +#define OP_MODE_MAY_BE_LEGACY_STAS 1 +#define OP_MODE_20MHZ_HT_STA_ASSOCED 2 +#define OP_MODE_MIXED 3 + +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8) BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8) BIT(0)) +#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8) BIT(0) | BIT(1)) +#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8) BIT(2)) +#define HT_INFO_HT_PARAM_RIFS_MODE ((u8) BIT(3)) +#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8) BIT(4)) +#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8) BIT(5)) + +#define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ + ((u16) (0x0001 | 0x0002)) +#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 +#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8) BIT(2)) +#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8) BIT(3)) +#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8) BIT(4)) + +#define HT_INFO_STBC_PARAM_DUAL_BEACON ((u16) BIT(6)) +#define HT_INFO_STBC_PARAM_DUAL_STBC_PROTECT ((u16) BIT(7)) +#define HT_INFO_STBC_PARAM_SECONDARY_BC ((u16) BIT(8)) +#define HT_INFO_STBC_PARAM_LSIG_TXOP_PROTECT_ALLOWED ((u16) BIT(9)) +#define HT_INFO_STBC_PARAM_PCO_ACTIVE ((u16) BIT(10)) +#define HT_INFO_STBC_PARAM_PCO_PHASE ((u16) BIT(11)) + +/* ===============WPS Section=============== */ +/* For WPSv1.0 */ +#define WPSOUI 0x0050f204 +/* WPS attribute ID */ +#define WPS_ATTR_VER1 0x104A +#define WPS_ATTR_SIMPLE_CONF_STATE 0x1044 +#define WPS_ATTR_RESP_TYPE 0x103B +#define WPS_ATTR_UUID_E 0x1047 +#define WPS_ATTR_MANUFACTURER 0x1021 +#define WPS_ATTR_MODEL_NAME 0x1023 +#define WPS_ATTR_MODEL_NUMBER 0x1024 +#define WPS_ATTR_SERIAL_NUMBER 0x1042 +#define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054 +#define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055 +#define WPS_ATTR_DEVICE_NAME 0x1011 +#define WPS_ATTR_CONF_METHOD 0x1008 +#define WPS_ATTR_RF_BANDS 0x103C +#define WPS_ATTR_DEVICE_PWID 0x1012 +#define WPS_ATTR_REQUEST_TYPE 0x103A +#define WPS_ATTR_ASSOCIATION_STATE 0x1002 +#define WPS_ATTR_CONFIG_ERROR 0x1009 +#define WPS_ATTR_VENDOR_EXT 0x1049 +#define WPS_ATTR_SELECTED_REGISTRAR 0x1041 + +/* Value of WPS attribute "WPS_ATTR_DEVICE_NAME */ +#define WPS_MAX_DEVICE_NAME_LEN 32 + +/* Value of WPS Request Type Attribute */ +#define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00 +#define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01 +#define WPS_REQ_TYPE_REGISTRAR 0x02 +#define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03 + +/* Value of WPS Response Type Attribute */ +#define WPS_RESPONSE_TYPE_INFO_ONLY 0x00 +#define WPS_RESPONSE_TYPE_8021X 0x01 +#define WPS_RESPONSE_TYPE_REGISTRAR 0x02 +#define WPS_RESPONSE_TYPE_AP 0x03 + +/* Value of WPS WiFi Simple Configuration State Attribute */ +#define WPS_WSC_STATE_NOT_CONFIG 0x01 +#define WPS_WSC_STATE_CONFIG 0x02 + +/* Value of WPS Version Attribute */ +#define WPS_VERSION_1 0x10 + +/* Value of WPS Configuration Method Attribute */ +#define WPS_CONFIG_METHOD_FLASH 0x0001 +#define WPS_CONFIG_METHOD_ETHERNET 0x0002 +#define WPS_CONFIG_METHOD_LABEL 0x0004 +#define WPS_CONFIG_METHOD_DISPLAY 0x0008 +#define WPS_CONFIG_METHOD_E_NFC 0x0010 +#define WPS_CONFIG_METHOD_I_NFC 0x0020 +#define WPS_CONFIG_METHOD_NFC 0x0040 +#define WPS_CONFIG_METHOD_PBC 0x0080 +#define WPS_CONFIG_METHOD_KEYPAD 0x0100 +#define WPS_CONFIG_METHOD_VPBC 0x0280 +#define WPS_CONFIG_METHOD_PPBC 0x0480 +#define WPS_CONFIG_METHOD_VDISPLAY 0x2008 +#define WPS_CONFIG_METHOD_PDISPLAY 0x4008 + +/* Value of Category ID of WPS Primary Device Type Attribute */ +#define WPS_PDT_CID_DISPLAYS 0x0007 +#define WPS_PDT_CID_MULIT_MEDIA 0x0008 +#define WPS_PDT_CID_RTK_WIDI WPS_PDT_CID_MULIT_MEDIA + +/* Value of Sub Category ID of WPS Primary Device Type Attribute */ +#define WPS_PDT_SCID_MEDIA_SERVER 0x0005 +#define WPS_PDT_SCID_RTK_DMP WPS_PDT_SCID_MEDIA_SERVER + +/* Value of Device Password ID */ +#define WPS_DPID_P 0x0000 +#define WPS_DPID_USER_SPEC 0x0001 +#define WPS_DPID_MACHINE_SPEC 0x0002 +#define WPS_DPID_REKEY 0x0003 +#define WPS_DPID_PBC 0x0004 +#define WPS_DPID_REGISTRAR_SPEC 0x0005 + +/* Value of WPS RF Bands Attribute */ +#define WPS_RF_BANDS_2_4_GHZ 0x01 +#define WPS_RF_BANDS_5_GHZ 0x02 + +/* Value of WPS Association State Attribute */ +#define WPS_ASSOC_STATE_NOT_ASSOCIATED 0x00 +#define WPS_ASSOC_STATE_CONNECTION_SUCCESS 0x01 +#define WPS_ASSOC_STATE_CONFIGURATION_FAILURE 0x02 +#define WPS_ASSOC_STATE_ASSOCIATION_FAILURE 0x03 +#define WPS_ASSOC_STATE_IP_FAILURE 0x04 + +/* =====================P2P Section===================== */ +/* For P2P */ +#define P2POUI 0x506F9A09 + +/* P2P Attribute ID */ +#define P2P_ATTR_STATUS 0x00 +#define P2P_ATTR_MINOR_REASON_CODE 0x01 +#define P2P_ATTR_CAPABILITY 0x02 +#define P2P_ATTR_DEVICE_ID 0x03 +#define P2P_ATTR_GO_INTENT 0x04 +#define P2P_ATTR_CONF_TIMEOUT 0x05 +#define P2P_ATTR_LISTEN_CH 0x06 +#define P2P_ATTR_GROUP_BSSID 0x07 +#define P2P_ATTR_EX_LISTEN_TIMING 0x08 +#define P2P_ATTR_INTENTED_IF_ADDR 0x09 +#define P2P_ATTR_MANAGEABILITY 0x0A +#define P2P_ATTR_CH_LIST 0x0B +#define P2P_ATTR_NOA 0x0C +#define P2P_ATTR_DEVICE_INFO 0x0D +#define P2P_ATTR_GROUP_INFO 0x0E +#define P2P_ATTR_GROUP_ID 0x0F +#define P2P_ATTR_INTERFACE 0x10 +#define P2P_ATTR_OPERATING_CH 0x11 +#define P2P_ATTR_INVITATION_FLAGS 0x12 + +/* Value of Status Attribute */ +#define P2P_STATUS_SUCCESS 0x00 +#define P2P_STATUS_FAIL_INFO_UNAVAILABLE 0x01 +#define P2P_STATUS_FAIL_INCOMPATIBLE_PARAM 0x02 +#define P2P_STATUS_FAIL_LIMIT_REACHED 0x03 +#define P2P_STATUS_FAIL_INVALID_PARAM 0x04 +#define P2P_STATUS_FAIL_REQUEST_UNABLE 0x05 +#define P2P_STATUS_FAIL_PREVOUS_PROTO_ERR 0x06 +#define P2P_STATUS_FAIL_NO_COMMON_CH 0x07 +#define P2P_STATUS_FAIL_UNKNOWN_P2PGROUP 0x08 +#define P2P_STATUS_FAIL_BOTH_GOINTENT_15 0x09 +#define P2P_STATUS_FAIL_INCOMPATIBLE_PROVSION 0x0A +#define P2P_STATUS_FAIL_USER_REJECT 0x0B + +/* Value of Inviation Flags Attribute */ +#define P2P_INVITATION_FLAGS_PERSISTENT BIT(0) + +#define DMP_P2P_DEVCAP_SUPPORT (P2P_DEVCAP_SERVICE_DISCOVERY | \ + P2P_DEVCAP_CLIENT_DISCOVERABILITY | \ + P2P_DEVCAP_CONCURRENT_OPERATION | \ + P2P_DEVCAP_INVITATION_PROC) + +#define DMP_P2P_GRPCAP_SUPPORT (P2P_GRPCAP_INTRABSS) + +/* Value of Device Capability Bitmap */ +#define P2P_DEVCAP_SERVICE_DISCOVERY BIT(0) +#define P2P_DEVCAP_CLIENT_DISCOVERABILITY BIT(1) +#define P2P_DEVCAP_CONCURRENT_OPERATION BIT(2) +#define P2P_DEVCAP_INFRA_MANAGED BIT(3) +#define P2P_DEVCAP_DEVICE_LIMIT BIT(4) +#define P2P_DEVCAP_INVITATION_PROC BIT(5) + +/* Value of Group Capability Bitmap */ +#define P2P_GRPCAP_GO BIT(0) +#define P2P_GRPCAP_PERSISTENT_GROUP BIT(1) +#define P2P_GRPCAP_GROUP_LIMIT BIT(2) +#define P2P_GRPCAP_INTRABSS BIT(3) +#define P2P_GRPCAP_CROSS_CONN BIT(4) +#define P2P_GRPCAP_PERSISTENT_RECONN BIT(5) +#define P2P_GRPCAP_GROUP_FORMATION BIT(6) + +/* P2P Public Action Frame (Management Frame) */ +#define P2P_PUB_ACTION_ACTION 0x09 + +/* P2P Public Action Frame Type */ +#define P2P_GO_NEGO_REQ 0 +#define P2P_GO_NEGO_RESP 1 +#define P2P_GO_NEGO_CONF 2 +#define P2P_INVIT_REQ 3 +#define P2P_INVIT_RESP 4 +#define P2P_DEVDISC_REQ 5 +#define P2P_DEVDISC_RESP 6 +#define P2P_PROVISION_DISC_REQ 7 +#define P2P_PROVISION_DISC_RESP 8 + +/* P2P Action Frame Type */ +#define P2P_NOTICE_OF_ABSENCE 0 +#define P2P_PRESENCE_REQUEST 1 +#define P2P_PRESENCE_RESPONSE 2 +#define P2P_GO_DISC_REQUEST 3 + +#define P2P_MAX_PERSISTENT_GROUP_NUM 10 + +#define P2P_PROVISIONING_SCAN_CNT 3 + +#define P2P_WILDCARD_SSID_LEN 7 + +/* default value, used when: (1)p2p disabed or (2)p2p enabled + * but only do 1 scan phase */ +#define P2P_FINDPHASE_EX_NONE 0 +/* used when p2p enabled and want to do 1 scan phase and + * P2P_FINDPHASE_EX_MAX-1 find phase */ +#define P2P_FINDPHASE_EX_FULL 1 +#define P2P_FINDPHASE_EX_SOCIAL_FIRST (P2P_FINDPHASE_EX_FULL+1) +#define P2P_FINDPHASE_EX_MAX 4 +#define P2P_FINDPHASE_EX_SOCIAL_LAST P2P_FINDPHASE_EX_MAX + +/* 5 seconds timeout for sending the provision discovery request */ +#define P2P_PROVISION_TIMEOUT 5000 +/* 3 seconds timeout for sending the prov disc request concurrent mode */ +#define P2P_CONCURRENT_PROVISION_TIME 3000 +/* 5 seconds timeout for receiving the group negotiation response */ +#define P2P_GO_NEGO_TIMEOUT 5000 +/* 3 seconds timeout for sending the negotiation request under concurrent mode */ +#define P2P_CONCURRENT_GO_NEGO_TIME 3000 +/* 100ms */ +#define P2P_TX_PRESCAN_TIMEOUT 100 +/* 5 seconds timeout for sending the invitation request */ +#define P2P_INVITE_TIMEOUT 5000 +/* 3 seconds timeout for sending the invitation request under concurrent mode */ +#define P2P_CONCURRENT_INVITE_TIME 3000 +/* 25 seconds timeout to reset the scan channel (based on channel plan) */ +#define P2P_RESET_SCAN_CH 25000 +#define P2P_MAX_INTENT 15 + +#define P2P_MAX_NOA_NUM 2 + +/* WPS Configuration Method */ +#define WPS_CM_NONE 0x0000 +#define WPS_CM_LABEL 0x0004 +#define WPS_CM_DISPLYA 0x0008 +#define WPS_CM_EXTERNAL_NFC_TOKEN 0x0010 +#define WPS_CM_INTEGRATED_NFC_TOKEN 0x0020 +#define WPS_CM_NFC_INTERFACE 0x0040 +#define WPS_CM_PUSH_BUTTON 0x0080 +#define WPS_CM_KEYPAD 0x0100 +#define WPS_CM_SW_PUHS_BUTTON 0x0280 +#define WPS_CM_HW_PUHS_BUTTON 0x0480 +#define WPS_CM_SW_DISPLAY_P 0x2008 +#define WPS_CM_LCD_DISPLAY_P 0x4008 + +enum P2P_ROLE { + P2P_ROLE_DISABLE = 0, + P2P_ROLE_DEVICE = 1, + P2P_ROLE_CLIENT = 2, + P2P_ROLE_GO = 3 +}; + +enum P2P_STATE { + P2P_STATE_NONE = 0, /* P2P disable */ + /* P2P had enabled and do nothing */ + P2P_STATE_IDLE = 1, + P2P_STATE_LISTEN = 2, /* In pure listen state */ + P2P_STATE_SCAN = 3, /* In scan phase */ + /* In the listen state of find phase */ + P2P_STATE_FIND_PHASE_LISTEN = 4, + /* In the search state of find phase */ + P2P_STATE_FIND_PHASE_SEARCH = 5, + /* In P2P provisioning discovery */ + P2P_STATE_TX_PROVISION_DIS_REQ = 6, + P2P_STATE_RX_PROVISION_DIS_RSP = 7, + P2P_STATE_RX_PROVISION_DIS_REQ = 8, + /* Doing the group owner negoitation handshake */ + P2P_STATE_GONEGO_ING = 9, + /* finish the group negoitation handshake with success */ + P2P_STATE_GONEGO_OK = 10, + /* finish the group negoitation handshake with failure */ + P2P_STATE_GONEGO_FAIL = 11, + /* receiving the P2P Inviation request and match with the profile. */ + P2P_STATE_RECV_INVITE_REQ_MATCH = 12, + /* Doing the P2P WPS */ + P2P_STATE_PROVISIONING_ING = 13, + /* Finish the P2P WPS */ + P2P_STATE_PROVISIONING_DONE = 14, + /* Transmit the P2P Invitation request */ + P2P_STATE_TX_INVITE_REQ = 15, + /* Receiving the P2P Invitation response */ + P2P_STATE_RX_INVITE_RESP_OK = 16, + /* receiving the P2P Inviation request and dismatch with the profile. */ + P2P_STATE_RECV_INVITE_REQ_DISMATCH = 17, + /* receiving the P2P Inviation request and this wifi is GO. */ + P2P_STATE_RECV_INVITE_REQ_GO = 18, + /* receiving the P2P Inviation request to join an existing P2P Group. */ + P2P_STATE_RECV_INVITE_REQ_JOIN = 19, + /* recveing the P2P Inviation response with failure */ + P2P_STATE_RX_INVITE_RESP_FAIL = 20, + /* receiving p2p negoitation response with information is not available */ + P2P_STATE_RX_INFOR_NOREADY = 21, + /* sending p2p negoitation response with information is not available */ + P2P_STATE_TX_INFOR_NOREADY = 22, +}; + +enum P2P_WPSINFO { + P2P_NO_WPSINFO = 0, + P2P_GOT_WPSINFO_PEER_DISPLAY_PIN = 1, + P2P_GOT_WPSINFO_SELF_DISPLAY_PIN = 2, + P2P_GOT_WPSINFO_PBC = 3, +}; + +#define P2P_PRIVATE_IOCTL_SET_LEN 64 + +enum P2P_PROTO_WK_ID { + P2P_FIND_PHASE_WK = 0, + P2P_RESTORE_STATE_WK = 1, + P2P_PRE_TX_PROVDISC_PROCESS_WK = 2, + P2P_PRE_TX_NEGOREQ_PROCESS_WK = 3, + P2P_PRE_TX_INVITEREQ_PROCESS_WK = 4, + P2P_AP_P2P_CH_SWITCH_PROCESS_WK =5, + P2P_RO_CH_WK = 6, +}; + +enum P2P_PS_STATE { + P2P_PS_DISABLE = 0, + P2P_PS_ENABLE = 1, + P2P_PS_SCAN = 2, + P2P_PS_SCAN_DONE = 3, + P2P_PS_ALLSTASLEEP = 4, /* for P2P GO */ +}; + +enum P2P_PS_MODE { + P2P_PS_NONE = 0, + P2P_PS_CTWINDOW = 1, + P2P_PS_NOA = 2, + P2P_PS_MIX = 3, /* CTWindow and NoA */ +}; + +/* =====================WFD Section===================== */ +/* For Wi-Fi Display */ +#define WFD_ATTR_DEVICE_INFO 0x00 +#define WFD_ATTR_ASSOC_BSSID 0x01 +#define WFD_ATTR_COUPLED_SINK_INFO 0x06 +#define WFD_ATTR_LOCAL_IP_ADDR 0x08 +#define WFD_ATTR_SESSION_INFO 0x09 +#define WFD_ATTR_ALTER_MAC 0x0a + +/* For WFD Device Information Attribute */ +#define WFD_DEVINFO_SOURCE 0x0000 +#define WFD_DEVINFO_PSINK 0x0001 +#define WFD_DEVINFO_SSINK 0x0002 +#define WFD_DEVINFO_DUAL 0x0003 + +#define WFD_DEVINFO_SESSION_AVAIL 0x0010 +#define WFD_DEVINFO_WSD 0x0040 +#define WFD_DEVINFO_PC_TDLS 0x0080 +#define WFD_DEVINFO_HDCP_SUPPORT 0x0100 + +#define IP_MCAST_MAC(mac) \ + ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e)) +#define ICMPV6_MCAST_MAC(mac) \ + ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff)) + +#endif /* _WIFI_H_ */ diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h new file mode 100644 index 000000000000..eae8bac175b2 --- /dev/null +++ b/drivers/staging/r8188eu/include/wlan_bssdef.h @@ -0,0 +1,343 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __WLAN_BSSDEF_H__ +#define __WLAN_BSSDEF_H__ + +#define MAX_IE_SZ 768 + +#define NDIS_802_11_LENGTH_SSID 32 +#define NDIS_802_11_LENGTH_RATES 8 +#define NDIS_802_11_LENGTH_RATES_EX 16 + +#define NDIS_802_11_RSSI long /* in dBm */ + +struct ndis_802_11_ssid { + u32 SsidLength; + u8 Ssid[32]; +}; + +enum NDIS_802_11_NETWORK_TYPE { + Ndis802_11FH, + Ndis802_11DS, + Ndis802_11OFDM5, + Ndis802_11OFDM24, + Ndis802_11NetworkTypeMax /* dummy upper bound */ +}; + +struct ndis_802_11_config_fh { + u32 Length; /* Length of structure */ + u32 HopPattern; /* As defined by 802.11, MSB set */ + u32 HopSet; /* to one if non-802.11 */ + u32 DwellTime; /* units are Kusec */ +}; + +/* + * FW will only save the channel number in DSConfig. + * ODI Handler will convert the channel number to freq. number. + */ +struct ndis_802_11_config { + u32 Length; /* Length of structure */ + u32 BeaconPeriod; /* units are Kusec */ + u32 ATIMWindow; /* units are Kusec */ + u32 DSConfig; /* Frequency, units are kHz */ + struct ndis_802_11_config_fh FHConfig; +}; + +enum ndis_802_11_network_infra { + Ndis802_11IBSS, + Ndis802_11Infrastructure, + Ndis802_11AutoUnknown, + Ndis802_11InfrastructureMax, /* dummy upper bound */ + Ndis802_11APMode +}; + +struct ndis_802_11_fixed_ie { + u8 Timestamp[8]; + u16 BeaconInterval; + u16 Capabilities; +}; + +struct ndis_802_11_var_ie { + u8 ElementID; + u8 Length; + u8 data[1]; +}; + +/* + * Length is the 4 bytes multiples of the sume of + * [ETH_ALEN] + 2 + sizeof (struct ndis_802_11_ssid) + sizeof (u32) + * + sizeof (NDIS_802_11_RSSI) + sizeof (enum NDIS_802_11_NETWORK_TYPE) + * + sizeof (struct ndis_802_11_config) + * + NDIS_802_11_LENGTH_RATES_EX + IELength + * + * Except the IELength, all other fields are fixed length. + * Therefore, we can define a macro to represent the partial sum. */ + +enum ndis_802_11_auth_mode { + Ndis802_11AuthModeOpen, + Ndis802_11AuthModeShared, + Ndis802_11AuthModeAutoSwitch, + Ndis802_11AuthModeWPA, + Ndis802_11AuthModeWPAPSK, + Ndis802_11AuthModeWPANone, + Ndis802_11AuthModeWAPI, + Ndis802_11AuthModeMax /* Not a real mode, upper bound */ +}; + +enum ndis_802_11_wep_status { + Ndis802_11WEPEnabled, + Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled, + Ndis802_11WEPDisabled, + Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled, + Ndis802_11WEPKeyAbsent, + Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent, + Ndis802_11WEPNotSupported, + Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported, + Ndis802_11Encryption2Enabled, + Ndis802_11Encryption2KeyAbsent, + Ndis802_11Encryption3Enabled, + Ndis802_11Encryption3KeyAbsent, + Ndis802_11_EncryptionWAPI +}; + +#define NDIS_802_11_AI_REQFI_CAPABILITIES 1 +#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2 +#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4 + +#define NDIS_802_11_AI_RESFI_CAPABILITIES 1 +#define NDIS_802_11_AI_RESFI_STATUSCODE 2 +#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4 + +struct ndis_802_11_ai_reqfi { + u16 Capabilities; + u16 ListenInterval; + unsigned char CurrentAPAddress[ETH_ALEN]; +}; + +struct ndis_802_11_ai_resfi { + u16 Capabilities; + u16 StatusCode; + u16 AssociationId; +}; + +struct ndis_802_11_assoc_info { + u32 Length; + u16 AvailableRequestFixedIEs; + struct ndis_802_11_ai_reqfi RequestFixedIEs; + u32 RequestIELength; + u32 OffsetRequestIEs; + u16 AvailableResponseFixedIEs; + struct ndis_802_11_ai_resfi ResponseFixedIEs; + u32 ResponseIELength; + u32 OffsetResponseIEs; +}; + +enum ndis_802_11_reload_def { + Ndis802_11ReloadWEPKeys +}; + +/* Key mapping keys require a BSSID */ +struct ndis_802_11_key { + u32 Length; /* Length of this structure */ + u32 KeyIndex; + u32 KeyLength; /* length of key in bytes */ + unsigned char BSSID[ETH_ALEN]; + unsigned long long KeyRSC; + u8 KeyMaterial[32]; /* var len depending on above field */ +}; + +struct ndis_802_11_remove_key { + u32 Length; /* Length */ + u32 KeyIndex; + unsigned char BSSID[ETH_ALEN]; +}; + +struct ndis_802_11_wep { + u32 Length; /* Length of this structure */ + u32 KeyIndex; /* 0 is the per-client key, + * 1-N are the global keys */ + u32 KeyLength; /* length of key in bytes */ + u8 KeyMaterial[16];/* variable len depending on above field */ +}; + +struct ndis_802_11_auth_req { + u32 Length; /* Length of structure */ + unsigned char Bssid[ETH_ALEN]; + u32 Flags; +}; + +enum ndis_802_11_status_type { + Ndis802_11StatusType_Authentication, + Ndis802_11StatusType_MediaStreamMode, + Ndis802_11StatusType_PMKID_CandidateList, + Ndis802_11StatusTypeMax /* not a real type, defined as + * an upper bound */ +}; + +struct ndis_802_11_status_ind { + enum ndis_802_11_status_type StatusType; +}; + +/* mask for authentication/integrity fields */ +#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f +#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01 +#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02 +#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06 +#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E + +/* MIC check time, 60 seconds. */ +#define MIC_CHECK_TIME 60000000 + +struct ndis_802_11_auth_evt { + struct ndis_802_11_status_ind Status; + struct ndis_802_11_auth_req Request[1]; +}; + +struct ndis_802_11_test { + u32 Length; + u32 Type; + union { + struct ndis_802_11_auth_evt AuthenticationEvent; + NDIS_802_11_RSSI RssiTrigger; + } tt; +}; + +#ifndef Ndis802_11APMode +#define Ndis802_11APMode (Ndis802_11InfrastructureMax+1) +#endif + +struct wlan_phy_info { + u8 SignalStrength;/* in percentage) */ + u8 SignalQuality;/* in percentage) */ + u8 Optimum_antenna; /* for Antenna diversity */ + u8 Reserved_0; +}; + +struct wlan_bcn_info { + /* these infor get from rtw_get_encrypt_info when + * * translate scan to UI */ + u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */ + int group_cipher; /* WPA/WPA2 group cipher */ + int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */ + int is_8021x; + + /* bwmode 20/40 and ch_offset UP/LOW */ + unsigned short ht_cap_info; + unsigned char ht_info_infos_0; +}; + +/* temporally add #pragma pack for structure alignment issue of +* struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz() +*/ +struct wlan_bssid_ex { + u32 Length; + unsigned char MacAddress[ETH_ALEN]; + u8 Reserved[2];/* 0]: IS beacon frame */ + struct ndis_802_11_ssid Ssid; + u32 Privacy; + NDIS_802_11_RSSI Rssi;/* in dBM,raw data ,get from PHY) */ + enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse; + struct ndis_802_11_config Configuration; + enum ndis_802_11_network_infra InfrastructureMode; + unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; + struct wlan_phy_info PhyInfo; + u32 IELength; + u8 IEs[MAX_IE_SZ]; /* timestamp, beacon interval, and + * capability information) */ +} __packed; + +static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) +{ + return sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->IELength; +} + +struct wlan_network { + struct list_head list; + int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */ + int fixed; /* set fixed when not to be removed + * in site-surveying */ + unsigned long last_scanned; /* timestamp for the network */ + int aid; /* will only be valid when a BSS is joinned. */ + int join_res; + struct wlan_bssid_ex network; /* must be the last item */ + struct wlan_bcn_info BcnInfo; +}; + +enum VRTL_CARRIER_SENSE { + DISABLE_VCS, + ENABLE_VCS, + AUTO_VCS +}; + +enum VCS_TYPE { + NONE_VCS, + RTS_CTS, + CTS_TO_SELF +}; + +#define PWR_CAM 0 +#define PWR_MINPS 1 +#define PWR_MAXPS 2 +#define PWR_UAPSD 3 +#define PWR_VOIP 4 + +enum UAPSD_MAX_SP { + NO_LIMIT, + TWO_MSDU, + FOUR_MSDU, + SIX_MSDU +}; + +#define NUM_PRE_AUTH_KEY 16 +#define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY + +/* +* WPA2 +*/ + +struct pmkid_candidate { + unsigned char BSSID[ETH_ALEN]; + u32 Flags; +}; + +struct ndis_802_11_pmkid_list { + u32 Version; /* Version of the structure */ + u32 NumCandidates; /* No. of pmkid candidates */ + struct pmkid_candidate CandidateList[1]; +}; + +struct ndis_802_11_auth_encrypt { + enum ndis_802_11_auth_mode AuthModeSupported; + enum ndis_802_11_wep_status EncryptStatusSupported; +}; + +struct ndis_802_11_cap { + u32 Length; + u32 Version; + u32 NoOfPMKIDs; + u32 NoOfAuthEncryptPairsSupported; + struct ndis_802_11_auth_encrypt AuthenticationEncryptionSupported[1]; +}; + +u8 key_2char2num(u8 hch, u8 lch); +u8 key_char2num(u8 ch); +u8 str_2char2num(u8 hch, u8 lch); + +#endif /* ifndef WLAN_BSSDEF_H_ */ diff --git a/drivers/staging/r8188eu/include/xmit_osdep.h b/drivers/staging/r8188eu/include/xmit_osdep.h new file mode 100644 index 000000000000..2ff622ba24f0 --- /dev/null +++ b/drivers/staging/r8188eu/include/xmit_osdep.h @@ -0,0 +1,67 @@ +/****************************************************************************** + * + * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + ******************************************************************************/ +#ifndef __XMIT_OSDEP_H_ +#define __XMIT_OSDEP_H_ + +#include +#include + +struct pkt_file { + struct sk_buff *pkt; + size_t pkt_len; /* the remainder length of the open_file */ + unsigned char *cur_buffer; + u8 *buf_start; + u8 *cur_addr; + size_t buf_len; +}; + +extern int rtw_ht_enable; +extern int rtw_cbw40_enable; +extern int rtw_ampdu_enable;/* for enable tx_ampdu */ + +#define NR_XMITFRAME 256 + +struct xmit_priv; +struct pkt_attrib; +struct sta_xmit_priv; +struct xmit_frame; +struct xmit_buf; + +int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); + +void rtw_os_xmit_schedule(struct adapter *padapter); + +int rtw_os_xmit_resource_alloc(struct adapter *padapter, + struct xmit_buf *pxmitbuf, u32 alloc_sz); +void rtw_os_xmit_resource_free(struct adapter *padapter, + struct xmit_buf *pxmitbuf, u32 free_sz); + +void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib); + +uint rtw_remainder_len(struct pkt_file *pfile); +void _rtw_open_pktfile(struct sk_buff *pkt, struct pkt_file *pfile); +uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen); +int rtw_endofpktfile(struct pkt_file *pfile); + +void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt); +void rtw_os_xmit_complete(struct adapter *padapter, + struct xmit_frame *pxframe); + +#endif /* __XMIT_OSDEP_H_ */ -- cgit v1.2.3 From 3c56618e6691ca6adf8451a343d1ac2ca0c5e32b Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 28 Jul 2021 00:22:18 +0100 Subject: staging: r8188eu: introduce new supporting files for RTL8188eu driver This patchset is split in order to keep the file sizes down. These supporting files are part of the newer/better driver from GitHub modified by Larry Finger. Import this as the basis for all future work going forward. Also, modify Makefile so that driver has same module filename as original rtl8188eu driver from staging, and rename config params to fit the Kconfig file taken from the old driver. Finally, reword Kconfig description to make it clear this is a newer driver. Suggested-by: Larry Finger Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210727232219.2948-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Kconfig | 25 ++++++++ drivers/staging/r8188eu/Makefile | 129 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 154 insertions(+) create mode 100644 drivers/staging/r8188eu/Kconfig create mode 100644 drivers/staging/r8188eu/Makefile (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Kconfig b/drivers/staging/r8188eu/Kconfig new file mode 100644 index 000000000000..6323d63a4a1b --- /dev/null +++ b/drivers/staging/r8188eu/Kconfig @@ -0,0 +1,25 @@ +# SPDX-License-Identifier: GPL-2.0 +config R8188EU + tristate "Realtek RTL8188EU Wireless LAN NIC driver" + depends on WLAN && USB && CFG80211 + select WIRELESS_EXT + select WEXT_PRIV + select LIB80211 + select LIB80211_CRYPT_WEP + select LIB80211_CRYPT_CCMP + help + This option adds support for the Realtek RTL8188EU chipset, used in USB + devices such as the ASUS USB-N10 Nano. This newer driver is based on GitHub + sources for version v4.1.4_6773.20130222, and contains modifications for + newer kernel features. If built as a module, it will be called r8188eu. + +if R8188EU + +config 88EU_AP_MODE + bool "Realtek RTL8188EU AP mode" + help + This option enables Access Point mode. Unless you know that your system + will never be used as an AP, or the target system has limited memory, + "Y" should be selected. + +endif diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile new file mode 100644 index 000000000000..6db1376e9768 --- /dev/null +++ b/drivers/staging/r8188eu/Makefile @@ -0,0 +1,129 @@ +SHELL := /bin/bash +EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS) +EXTRA_CFLAGS += -O1 + +EXTRA_CFLAGS += -Wno-unused-variable +EXTRA_CFLAGS += -Wno-unused-value +EXTRA_CFLAGS += -Wno-unused-label +EXTRA_CFLAGS += -Wno-unused-parameter +EXTRA_CFLAGS += -Wno-unused-function +EXTRA_CFLAGS += -Wno-unused + +EXTRA_CFLAGS += -Wno-uninitialized + +EXTRA_CFLAGS += -I$(src)/include + +ccflags-y += -D__CHECK_ENDIAN__ + +CONFIG_AUTOCFG_CP = n + +CONFIG_R8188EU = m + +CONFIG_USB_HCI = y + +CONFIG_BT_COEXIST = n +CONFIG_WOWLAN = n + +OUTSRC_FILES := \ + hal/HalHWImg8188E_MAC.o \ + hal/HalHWImg8188E_BB.o \ + hal/HalHWImg8188E_RF.o \ + hal/HalPhyRf.o \ + hal/HalPhyRf_8188e.o \ + hal/HalPwrSeqCmd.o \ + hal/Hal8188EPwrSeq.o \ + hal/Hal8188ERateAdaptive.o\ + hal/hal_intf.o \ + hal/hal_com.o \ + hal/odm.o \ + hal/odm_debug.o \ + hal/odm_interface.o \ + hal/odm_HWConfig.o \ + hal/odm_RegConfig8188E.o\ + hal/odm_RTL8188E.o \ + hal/rtl8188e_cmd.o \ + hal/rtl8188e_dm.o \ + hal/rtl8188e_hal_init.o \ + hal/rtl8188e_mp.o \ + hal/rtl8188e_phycfg.o \ + hal/rtl8188e_rf6052.o \ + hal/rtl8188e_rxdesc.o \ + hal/rtl8188e_sreset.o \ + hal/rtl8188e_xmit.o \ + hal/rtl8188eu_led.o \ + hal/rtl8188eu_recv.o \ + hal/rtl8188eu_xmit.o \ + hal/usb_halinit.o \ + hal/usb_ops_linux.o + +RTL871X = rtl8188e + +HCI_NAME = usb + +_OS_INTFS_FILES := \ + os_dep/ioctl_linux.o \ + os_dep/mlme_linux.o \ + os_dep/os_intfs.o \ + os_dep/osdep_service.o \ + os_dep/recv_linux.o \ + os_dep/rtw_android.o \ + os_dep/usb_intf.o \ + os_dep/usb_ops_linux.o \ + os_dep/xmit_linux.o + +_HAL_INTFS_FILES += $(OUTSRC_FILES) + +ifeq ($(CONFIG_AUTOCFG_CP), y) + +$(shell cp $(TopDIR)/autoconf_rtl8188e_usb_linux.h $(TopDIR)/include/autoconf.h) +endif + +ifeq ($(CONFIG_BT_COEXIST), y) +EXTRA_CFLAGS += -DCONFIG_BT_COEXIST +endif + +ifeq ($(CONFIG_WOWLAN), y) +EXTRA_CFLAGS += -DCONFIG_WOWLAN +endif + +SUBARCH := $(shell uname -m | sed -e "s/i.86/i386/; s/ppc.*/powerpc/; s/armv.l/arm/; s/aarch64/arm64/;") + +ARCH ?= $(SUBARCH) +CROSS_COMPILE ?= +KVER ?= $(if $(KERNELRELEASE),$(KERNELRELEASE),$(shell uname -r)) +KSRC ?= $(if $(KERNEL_SRC),$(KERNEL_SRC),/lib/modules/$(KVER)/build) +MODDESTDIR := /lib/modules/$(KVER)/kernel/drivers/net/wireless +INSTALL_PREFIX := + +rtk_core := \ + core/rtw_ap.o \ + core/rtw_br_ext.o \ + core/rtw_cmd.o \ + core/rtw_debug.o \ + core/rtw_efuse.o \ + core/rtw_ieee80211.o \ + core/rtw_io.o \ + core/rtw_ioctl_set.o \ + core/rtw_iol.o \ + core/rtw_led.o \ + core/rtw_mlme.o \ + core/rtw_mlme_ext.o \ + core/rtw_mp.o \ + core/rtw_mp_ioctl.o \ + core/rtw_pwrctrl.o \ + core/rtw_p2p.o \ + core/rtw_recv.o \ + core/rtw_rf.o \ + core/rtw_security.o \ + core/rtw_sreset.o \ + core/rtw_sta_mgt.o \ + core/rtw_wlan_util.o \ + core/rtw_xmit.o + +r8188eu-y += $(rtk_core) + +r8188eu-y += $(_HAL_INTFS_FILES) + +r8188eu-y += $(_OS_INTFS_FILES) + +obj-$(CONFIG_R8188EU) := r8188eu.o -- cgit v1.2.3 From d8133ef655d25f483c2853d5e6a61fce7c912a4e Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 28 Jul 2021 00:22:19 +0100 Subject: staging: r8188eu: attach newly imported driver to build system Modify Kconfig and Makefile to import new r8188eu driver into build system, and allow it to build alongside deprecated older driver, by tweaking build parameters and module name for the older driver at the same time. Suggested-by: Larry Finger Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210727232219.2948-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 ++ drivers/staging/Makefile | 3 ++- drivers/staging/rtl8188eu/Kconfig | 9 +++++---- drivers/staging/rtl8188eu/Makefile | 4 ++-- 4 files changed, 11 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 03ee99d98945..73fd57bfa95a 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -38,6 +38,8 @@ source "drivers/staging/rtl8712/Kconfig" source "drivers/staging/rtl8188eu/Kconfig" +source "drivers/staging/r8188eu/Kconfig" + source "drivers/staging/rts5208/Kconfig" source "drivers/staging/octeon/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 9a4c0e6f34d5..47672260293e 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -8,7 +8,8 @@ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_RTL8723BS) += rtl8723bs/ obj-$(CONFIG_R8712U) += rtl8712/ -obj-$(CONFIG_R8188EU) += rtl8188eu/ +obj-$(CONFIG_R8188EU_OLD) += rtl8188eu/ +obj-$(CONFIG_R8188EU) += r8188eu/ obj-$(CONFIG_RTS5208) += rts5208/ obj-$(CONFIG_NETLOGIC_XLR_NET) += netlogic/ obj-$(CONFIG_OCTEON_ETHERNET) += octeon/ diff --git a/drivers/staging/rtl8188eu/Kconfig b/drivers/staging/rtl8188eu/Kconfig index 970d5abd6336..acdf0f9f374c 100644 --- a/drivers/staging/rtl8188eu/Kconfig +++ b/drivers/staging/rtl8188eu/Kconfig @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 -config R8188EU - tristate "Realtek RTL8188EU Wireless LAN NIC driver" +config R8188EU_OLD + tristate "Realtek RTL8188EU Wireless LAN NIC driver (DEPRECATED)" depends on WLAN && USB && CFG80211 depends on m select WIRELESS_EXT @@ -10,9 +10,10 @@ config R8188EU select LIB80211_CRYPT_CCMP help This option adds the Realtek RTL8188EU USB device such as TP-Link TL-WN725N. - If built as a module, it will be called r8188eu. + If built as a module, it will be called rtl8188eu. This driver is now due to + be dropped due to the import of a newer version. -if R8188EU +if R8188EU_OLD config 88EU_AP_MODE bool "Realtek RTL8188EU AP mode" diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile index 2799ec5a7fda..20d88983f4e2 100644 --- a/drivers/staging/rtl8188eu/Makefile +++ b/drivers/staging/rtl8188eu/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 -r8188eu-y := \ +rtl8188eu-y := \ core/mac_cfg.o \ core/rtw_ap.o \ core/rtw_cmd.o \ @@ -51,6 +51,6 @@ r8188eu-y := \ os_dep/usb_ops_linux.o \ os_dep/xmit_linux.o -obj-$(CONFIG_R8188EU) := r8188eu.o +obj-$(CONFIG_R8188EU_OLD) := rtl8188eu.o ccflags-y += -I$(srctree)/$(src)/include -- cgit v1.2.3 From 274f4e78e5c8adf7d820c22553b22be79e517887 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Wed, 28 Jul 2021 16:18:58 +0200 Subject: staging: rtl8723bs: remove BT debug code remove BT dead debug code, probably it was intended for a specific command line interface. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/20210728141858.13024-1-fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c | 458 ------------------------ drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h | 1 - drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c | 408 --------------------- drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h | 1 - drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h | 8 - drivers/staging/rtl8723bs/hal/Mp_Precomp.h | 2 - drivers/staging/rtl8723bs/hal/hal_btcoex.c | 104 ------ drivers/staging/rtl8723bs/include/hal_btcoex.h | 3 - 8 files changed, 985 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c index dc58bb87f1b0..242c14959176 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c @@ -19,9 +19,6 @@ static const char *const GLBtInfoSrc8723b1Ant[] = { "BT Info[bt auto report]", }; -static u32 GLCoexVerDate8723b1Ant = 20140507; -static u32 GLCoexVer8723b1Ant = 0x4e; - /* local function proto type if needed */ /* local function start with halbtc8723b1ant_ */ static u8 halbtc8723b1ant_BtRssiState( @@ -2210,461 +2207,6 @@ void EXhalbtc8723b1ant_InitCoexDm(struct btc_coexist *pBtCoexist) halbtc8723b1ant_QueryBtInfo(pBtCoexist); } -void EXhalbtc8723b1ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist) -{ - struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo; - struct btc_stack_info *pStackInfo = &pBtCoexist->stackInfo; - struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo; - u8 *cliBuf = pBtCoexist->cliBuf; - u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0; - u16 u2Tmp[4]; - u32 u4Tmp[4]; - bool bRoam = false; - bool bScan = false; - bool bLink = false; - bool bWifiUnderBMode = false; - bool bBtHsOn = false; - bool bWifiBusy = false; - s32 wifiRssi = 0, btHsRssi = 0; - u32 wifiBw, wifiTrafficDir, faOfdm, faCck, wifiLinkStatus; - u8 wifiDot11Chnl, wifiHsChnl; - u32 fwVer = 0, btPatchVer = 0; - static u8 PopReportIn10s; - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n ============[BT Coexist info]============" - ); - CL_PRINTF(cliBuf); - - if (pBtCoexist->bManualControl) { - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n ============[Under Manual Control]============" - ); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, - BT_TMP_BUF_SIZE, - "\r\n ==========================================" - ); - CL_PRINTF(cliBuf); - } - if (pBtCoexist->bStopCoexDm) { - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n ============[Coex is STOPPED]============" - ); - CL_PRINTF(cliBuf); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n ==========================================" - ); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d", "Ant PG Num/ Ant Mech/ Ant Pos:", - pBoardInfo->pgAntNum, - pBoardInfo->btdmAntNum, - pBoardInfo->btdmAntPos - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", - ((pStackInfo->bProfileNotified) ? "Yes" : "No"), - pStackInfo->hciVersion - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", - GLCoexVerDate8723b1Ant, - GLCoexVer8723b1Ant, - fwVer, - btPatchVer, - btPatchVer - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", - wifiDot11Chnl, - wifiHsChnl, - bBtHsOn - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", - pCoexDm->wifiChnlInfo[0], - pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2] - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d", "Wifi rssi/ HS rssi", - wifiRssi - 100, btHsRssi - 100 - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d/ %s", "Wifi bLink/ bRoam/ bScan/ bHi-Pri", - bLink, bRoam, bScan, ((pCoexSta->bWiFiIsHighPriTask) ? "1" : "0") - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet( - pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir - ); - pBtCoexist->fBtcGet( - pBtCoexist, BTC_GET_BL_WIFI_UNDER_B_MODE, &bWifiUnderBMode - ); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s / %s/ %s/ AP =%d/ %s ", "Wifi status", - ("2.4G"), - ((bWifiUnderBMode) ? "11b" : ((wifiBw == BTC_WIFI_BW_LEGACY) ? "11bg" : (((wifiBw == BTC_WIFI_BW_HT40) ? "HT40" : "HT20")))), - ((!bWifiBusy) ? "idle" : ((wifiTrafficDir == BTC_WIFI_TRAFFIC_TX) ? "uplink" : "downlink")), - pCoexSta->nScanAPNum, - (pCoexSta->bCCKLock) ? "Lock" : "noLock" - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet( - pBtCoexist, BTC_GET_U4_WIFI_LINK_STATUS, &wifiLinkStatus - ); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d/ %d/ %d", "sta/vwifi/hs/p2pGo/p2pGc", - ((wifiLinkStatus & WIFI_STA_CONNECTED) ? 1 : 0), - ((wifiLinkStatus & WIFI_AP_CONNECTED) ? 1 : 0), - ((wifiLinkStatus & WIFI_HS_CONNECTED) ? 1 : 0), - ((wifiLinkStatus & WIFI_P2P_GO_CONNECTED) ? 1 : 0), - ((wifiLinkStatus & WIFI_P2P_GC_CONNECTED) ? 1 : 0) - ); - CL_PRINTF(cliBuf); - - - PopReportIn10s++; - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = [%s/ %d/ %d/ %d] ", "BT [status/ rssi/ retryCnt/ popCnt]", - ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_NON_CONNECTED_IDLE) ? "non-connected idle" : - ((pCoexDm->btStatus == BT_8723B_1ANT_BT_STATUS_CONNECTED_IDLE) ? "connected-idle" : "busy")))), - pCoexSta->btRssi, pCoexSta->btRetryCnt, pCoexSta->popEventCnt - ); - CL_PRINTF(cliBuf); - - if (PopReportIn10s >= 5) { - pCoexSta->popEventCnt = 0; - PopReportIn10s = 0; - } - - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", - pBtLinkInfo->bScoExist, - pBtLinkInfo->bHidExist, - pBtLinkInfo->bPanExist, - pBtLinkInfo->bA2dpExist - ); - CL_PRINTF(cliBuf); - - if (pStackInfo->bProfileNotified) { - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - } else { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %s", "BT Role", - (pBtLinkInfo->bSlaveRole) ? "Slave" : "Master"); - CL_PRINTF(cliBuf); - } - - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s", "BT Info A2DP rate", - (btInfoExt & BIT0) ? "Basic rate" : "EDR rate" - ); - CL_PRINTF(cliBuf); - - for (i = 0; i < BT_INFO_SRC_8723B_1ANT_MAX; i++) { - if (pCoexSta->btInfoC2hCnt[i]) { - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b1Ant[i], - pCoexSta->btInfoC2h[i][0], pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], pCoexSta->btInfoC2hCnt[i] - ); - CL_PRINTF(cliBuf); - } - } - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s/%s, (0x%x/0x%x)", "PS state, IPS/LPS, (lps/rpwm)", - (pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF"), - (pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF"), - pBtCoexist->btInfo.lpsVal, - pBtCoexist->btInfo.rpwmVal - ); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); - - if (!pBtCoexist->bManualControl) { - /* Sw mechanism */ - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s", "============[Sw mechanism]============" - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d", "SM[LowPenaltyRA]", - pCoexDm->bCurLowPenaltyRa - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s/ %s/ %d ", "DelBA/ BtCtrlAgg/ AggSize", - (pBtCoexist->btInfo.bRejectAggPkt ? "Yes" : "No"), - (pBtCoexist->btInfo.bBtCtrlAggBufSize ? "Yes" : "No"), - pBtCoexist->btInfo.aggBufSize - ); - CL_PRINTF(cliBuf); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x ", "Rate Mask", - pBtCoexist->btInfo.raMask - ); - CL_PRINTF(cliBuf); - - /* Fw mechanism */ - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", - pCoexDm->psTdmaPara[0], pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], psTdmaCase, pCoexDm->bAutoTdmaAdjust); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "Coex Table Type", - pCoexSta->nCoexTableType); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d", "IgnWlanAct", - pCoexDm->bCurIgnoreWlanAct); - CL_PRINTF(cliBuf); - } - - /* Hw setting */ - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "backup ARFR1/ARFR2/RL/AMaxTime", - pCoexDm->backupArfrCnt1, pCoexDm->backupArfrCnt2, pCoexDm->backupRetryLimit, pCoexDm->backupAmpduMaxTime); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x430); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x434); - u2Tmp[0] = pBtCoexist->fBtcRead2Byte(pBtCoexist, 0x42a); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x456); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = 0x%x/0x%x/0x%x/0x%x", "0x430/0x434/0x42a/0x456", - u4Tmp[0], u4Tmp[1], u2Tmp[0], u1Tmp[0]); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6cc); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF( - cliBuf, BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x778/0x6cc/0x880[29:25]", - u1Tmp[0], u4Tmp[0], (u4Tmp[1] & 0x3e000000) >> 25 - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x764); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x76e); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x764 / 0x76e", - u4Tmp[0], ((u1Tmp[0] & 0x20) >> 5), (u4Tmp[1] & 0xffff), u1Tmp[1] - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", - u4Tmp[0] & 0x3, u4Tmp[1] & 0xff, u4Tmp[2] & 0x3 - ); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", - ((u1Tmp[0] & 0x8) >> 3), - u1Tmp[1], - ((u4Tmp[0] & 0x01800000) >> 23), - u1Tmp[2] & 0x1 - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", - u4Tmp[0], u1Tmp[0] - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", - u4Tmp[0] & 0xff, u1Tmp[0] - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = - ((u4Tmp[0] & 0xffff0000) >> 16) + - ((u4Tmp[1] & 0xffff0000) >> 16) + - (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + - ((u4Tmp[3] & 0xffff0000) >> 16) + (u4Tmp[3] & 0xffff); - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", - u4Tmp[0] & 0xffff, faOfdm, faCck - ); - CL_PRINTF(cliBuf); - - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_OK CCK/11g/11n/11n-Agg", - pCoexSta->nCRCOK_CCK, - pCoexSta->nCRCOK_11g, - pCoexSta->nCRCOK_11n, - pCoexSta->nCRCOK_11nAgg - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d/ %d", "CRC_Err CCK/11g/11n/11n-Agg", - pCoexSta->nCRCErr_CCK, - pCoexSta->nCRCErr_11g, - pCoexSta->nCRCErr_11n, - pCoexSta->nCRCErr_11nAgg - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8(coexTable)", - u4Tmp[0], u4Tmp[1], u4Tmp[2]); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", - pCoexSta->highPriorityRx, pCoexSta->highPriorityTx - ); - CL_PRINTF(cliBuf); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", - pCoexSta->lowPriorityRx, pCoexSta->lowPriorityTx - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - void EXhalbtc8723b1ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type) { if (pBtCoexist->bManualControl || pBtCoexist->bStopCoexDm) diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h index 719e19420a3b..de471e27a185 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.h @@ -182,4 +182,3 @@ void EXhalbtc8723b1ant_BtInfoNotify( void EXhalbtc8723b1ant_HaltNotify(struct btc_coexist *pBtCoexist); void EXhalbtc8723b1ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState); void EXhalbtc8723b1ant_Periodical(struct btc_coexist *pBtCoexist); -void EXhalbtc8723b1ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist); diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c index 84241619fb3a..3e36a7dc72a6 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c @@ -26,9 +26,6 @@ static const char *const GLBtInfoSrc8723b2Ant[] = { "BT Info[bt auto report]", }; -static u32 GLCoexVerDate8723b2Ant = 20131211; -static u32 GLCoexVer8723b2Ant = 0x40; - /* local function start with halbtc8723b2ant_ */ static u8 halbtc8723b2ant_BtRssiState( u8 levelNum, u8 rssiThresh, u8 rssiThresh1 @@ -188,31 +185,6 @@ static void halbtc8723b2ant_LimitedRx( pBtCoexist->fBtcSet(pBtCoexist, BTC_SET_ACT_AGGREGATE_CTRL, NULL); } -static void halbtc8723b2ant_MonitorBtCtr(struct btc_coexist *pBtCoexist) -{ - u32 regHPTxRx, regLPTxRx, u4Tmp; - u32 regHPTx = 0, regHPRx = 0, regLPTx = 0, regLPRx = 0; - - regHPTxRx = 0x770; - regLPTxRx = 0x774; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regHPTxRx); - regHPTx = u4Tmp & bMaskLWord; - regHPRx = (u4Tmp & bMaskHWord) >> 16; - - u4Tmp = pBtCoexist->fBtcRead4Byte(pBtCoexist, regLPTxRx); - regLPTx = u4Tmp & bMaskLWord; - regLPRx = (u4Tmp & bMaskHWord) >> 16; - - pCoexSta->highPriorityTx = regHPTx; - pCoexSta->highPriorityRx = regHPRx; - pCoexSta->lowPriorityTx = regLPTx; - pCoexSta->lowPriorityRx = regLPRx; - - /* reset counter */ - pBtCoexist->fBtcWrite1Byte(pBtCoexist, 0x76e, 0xc); -} - static void halbtc8723b2ant_QueryBtInfo(struct btc_coexist *pBtCoexist) { u8 H2C_Parameter[1] = {0}; @@ -2423,386 +2395,6 @@ void EXhalbtc8723b2ant_InitCoexDm(struct btc_coexist *pBtCoexist) halbtc8723b2ant_InitCoexDm(pBtCoexist); } -void EXhalbtc8723b2ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist) -{ - struct btc_board_info *pBoardInfo = &pBtCoexist->boardInfo; - struct btc_stack_info *pStackInfo = &pBtCoexist->stackInfo; - struct btc_bt_link_info *pBtLinkInfo = &pBtCoexist->btLinkInfo; - u8 *cliBuf = pBtCoexist->cliBuf; - u8 u1Tmp[4], i, btInfoExt, psTdmaCase = 0; - u32 u4Tmp[4]; - bool bRoam = false, bScan = false, bLink = false; - bool bBtHsOn = false, bWifiBusy = false; - s32 wifiRssi = 0, btHsRssi = 0; - u32 wifiBw, wifiTrafficDir, faOfdm, faCck; - u8 wifiDot11Chnl, wifiHsChnl; - u32 fwVer = 0, btPatchVer = 0; - u8 apNum = 0; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[BT Coexist info]============"); - CL_PRINTF(cliBuf); - - if (pBtCoexist->bManualControl) { - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n ============[Under Manual Control]============"); - CL_PRINTF(cliBuf); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n =========================================="); - CL_PRINTF(cliBuf); - } - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d ", "Ant PG number/ Ant mechanism:", \ - pBoardInfo->pgAntNum, - pBoardInfo->btdmAntNum - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s / %d", "BT stack/ hci ext ver", \ - (pStackInfo->bProfileNotified ? "Yes" : "No"), - pStackInfo->hciVersion - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_BT_PATCH_VER, &btPatchVer); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_FW_VER, &fwVer); - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %d_%x/ 0x%x/ 0x%x(%d)", "CoexVer/ FwVer/ PatchVer", \ - GLCoexVerDate8723b2Ant, GLCoexVer8723b2Ant, fwVer, btPatchVer, btPatchVer); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_HS_OPERATION, &bBtHsOn); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_DOT11_CHNL, &wifiDot11Chnl); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_WIFI_HS_CHNL, &wifiHsChnl); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d / %d(%d)", "Dot11 channel / HsChnl(HsMode)", \ - wifiDot11Chnl, - wifiHsChnl, - bBtHsOn - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %02x %02x %02x ", "H2C Wifi inform bt chnl Info", \ - pCoexDm->wifiChnlInfo[0], - pCoexDm->wifiChnlInfo[1], - pCoexDm->wifiChnlInfo[2] - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_WIFI_RSSI, &wifiRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_S4_HS_RSSI, &btHsRssi); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U1_AP_NUM, &apNum); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d", "Wifi rssi/ HS rssi/ AP#", \ - wifiRssi, - btHsRssi, - apNum - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_SCAN, &bScan); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_LINK, &bLink); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_ROAM, &bRoam); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d ", "Wifi bLink/ bRoam/ bScan", \ - bLink, - bRoam, - bScan - ); - CL_PRINTF(cliBuf); - - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_BW, &wifiBw); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_BL_WIFI_BUSY, &bWifiBusy); - pBtCoexist->fBtcGet(pBtCoexist, BTC_GET_U4_WIFI_TRAFFIC_DIRECTION, &wifiTrafficDir); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s / %s/ %s ", "Wifi status", \ - ("2.4G"), - ((BTC_WIFI_BW_LEGACY == wifiBw) ? "Legacy" : (((BTC_WIFI_BW_HT40 == wifiBw) ? "HT40" : "HT20"))), - ((!bWifiBusy) ? "idle" : ((BTC_WIFI_TRAFFIC_TX == wifiTrafficDir) ? "uplink" : "downlink")) - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = [%s/ %d/ %d] ", "BT [status/ rssi/ retryCnt]", \ - ((pBtCoexist->btInfo.bBtDisabled) ? ("disabled") : ((pCoexSta->bC2hBtInquiryPage) ? ("inquiry/page scan") : ((BT_8723B_2ANT_BT_STATUS_NON_CONNECTED_IDLE == pCoexDm->btStatus) ? "non-connected idle" : - ((BT_8723B_2ANT_BT_STATUS_CONNECTED_IDLE == pCoexDm->btStatus) ? "connected-idle" : "busy")))), - pCoexSta->btRssi, - pCoexSta->btRetryCnt - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d / %d / %d / %d", "SCO/HID/PAN/A2DP", \ - pBtLinkInfo->bScoExist, - pBtLinkInfo->bHidExist, - pBtLinkInfo->bPanExist, - pBtLinkInfo->bA2dpExist - ); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_BT_LINK_INFO); - - btInfoExt = pCoexSta->btInfoExt; - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s", "BT Info A2DP rate", \ - (btInfoExt & BIT0) ? "Basic rate" : "EDR rate" - ); - CL_PRINTF(cliBuf); - - for (i = 0; i < BT_INFO_SRC_8723B_2ANT_MAX; i++) { - if (pCoexSta->btInfoC2hCnt[i]) { - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %02x %02x %02x %02x %02x %02x %02x(%d)", GLBtInfoSrc8723b2Ant[i], \ - pCoexSta->btInfoC2h[i][0], - pCoexSta->btInfoC2h[i][1], - pCoexSta->btInfoC2h[i][2], - pCoexSta->btInfoC2h[i][3], - pCoexSta->btInfoC2h[i][4], - pCoexSta->btInfoC2h[i][5], - pCoexSta->btInfoC2h[i][6], - pCoexSta->btInfoC2hCnt[i] - ); - CL_PRINTF(cliBuf); - } - } - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %s/%s", "PS state, IPS/LPS", \ - ((pCoexSta->bUnderIps ? "IPS ON" : "IPS OFF")), - ((pCoexSta->bUnderLps ? "LPS ON" : "LPS OFF")) - ); - CL_PRINTF(cliBuf); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_FW_PWR_MODE_CMD); - - /* Sw mechanism */ - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s", "============[Sw mechanism]============" - ); - CL_PRINTF(cliBuf); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d ", "SM1[ShRf/ LpRA/ LimDig]", \ - pCoexDm->bCurRfRxLpfShrink, - pCoexDm->bCurLowPenaltyRa, - pCoexDm->bLimitedDig - ); - CL_PRINTF(cliBuf); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d/ %d(0x%x) ", - "SM2[AgcT/ AdcB/ SwDacSwing(lvl)]", \ - pCoexDm->bCurAgcTableEn, - pCoexDm->bCurAdcBackOff, - pCoexDm->bCurDacSwingOn, - pCoexDm->curDacSwingLvl - ); - CL_PRINTF(cliBuf); - - /* Fw mechanism */ - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Fw mechanism]============"); - CL_PRINTF(cliBuf); - - psTdmaCase = pCoexDm->curPsTdma; - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %02x %02x %02x %02x %02x case-%d (auto:%d)", "PS TDMA", \ - pCoexDm->psTdmaPara[0], - pCoexDm->psTdmaPara[1], - pCoexDm->psTdmaPara[2], - pCoexDm->psTdmaPara[3], - pCoexDm->psTdmaPara[4], - psTdmaCase, pCoexDm->bAutoTdmaAdjust - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d ", "DecBtPwr/ IgnWlanAct", \ - pCoexDm->curBtDecPwrLvl, - pCoexDm->bCurIgnoreWlanAct - ); - CL_PRINTF(cliBuf); - - /* Hw setting */ - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s", "============[Hw setting]============"); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x", "RF-A, 0x1e initVal", \ - pCoexDm->btRf0x1eBackup - ); - CL_PRINTF(cliBuf); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x778); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x880); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x", "0x778/0x880[29:25]", \ - u1Tmp[0], - (u4Tmp[0] & 0x3e000000) >> 25 - ); - CL_PRINTF(cliBuf); - - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x948); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x67); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x765); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x948/ 0x67[5] / 0x765", \ - u4Tmp[0], - ((u1Tmp[0] & 0x20) >> 5), - u1Tmp[1] - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x92c); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x930); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x944); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "0x92c[1:0]/ 0x930[7:0]/0x944[1:0]", \ - u4Tmp[0] & 0x3, - u4Tmp[1] & 0xff, - u4Tmp[2] & 0x3 - ); - CL_PRINTF(cliBuf); - - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x39); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x40); - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x4c); - u1Tmp[2] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x64); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x38[11]/0x40/0x4c[24:23]/0x64[0]", \ - ((u1Tmp[0] & 0x8) >> 3), - u1Tmp[1], - ((u4Tmp[0] & 0x01800000) >> 23), - u1Tmp[2] & 0x1 - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x550); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x522); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x", "0x550(bcn ctrl)/0x522", \ - u4Tmp[0], - u1Tmp[0] - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xc50); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x49c); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x", "0xc50(dig)/0x49c(null-drop)", \ - u4Tmp[0] & 0xff, - u1Tmp[0] - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xda8); - u4Tmp[3] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0xcf0); - - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5b); - u1Tmp[1] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0xa5c); - - faOfdm = - ((u4Tmp[0] & 0xffff0000) >> 16) + - ((u4Tmp[1] & 0xffff0000) >> 16) + - (u4Tmp[1] & 0xffff) + (u4Tmp[2] & 0xffff) + \ - ((u4Tmp[3] & 0xffff0000) >> 16) + - (u4Tmp[3] & 0xffff); - - faCck = (u1Tmp[0] << 8) + u1Tmp[1]; - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x", "OFDM-CCA/OFDM-FA/CCK-FA", \ - u4Tmp[0] & 0xffff, - faOfdm, - faCck - ); - CL_PRINTF(cliBuf); - - u4Tmp[0] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c0); - u4Tmp[1] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c4); - u4Tmp[2] = pBtCoexist->fBtcRead4Byte(pBtCoexist, 0x6c8); - u1Tmp[0] = pBtCoexist->fBtcRead1Byte(pBtCoexist, 0x6cc); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = 0x%x/ 0x%x/ 0x%x/ 0x%x", "0x6c0/0x6c4/0x6c8/0x6cc(coexTable)", \ - u4Tmp[0], - u4Tmp[1], - u4Tmp[2], - u1Tmp[0] - ); - CL_PRINTF(cliBuf); - - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d", "0x770(high-pri rx/tx)", \ - pCoexSta->highPriorityRx, - pCoexSta->highPriorityTx - ); - CL_PRINTF(cliBuf); - CL_SPRINTF( - cliBuf, - BT_TMP_BUF_SIZE, - "\r\n %-35s = %d/ %d", "0x774(low-pri rx/tx)", \ - pCoexSta->lowPriorityRx, - pCoexSta->lowPriorityTx - ); - CL_PRINTF(cliBuf); - - halbtc8723b2ant_MonitorBtCtr(pBtCoexist); - pBtCoexist->fBtcDispDbgMsg(pBtCoexist, BTC_DBG_DISP_COEX_STATISTICS); -} - - void EXhalbtc8723b2ant_IpsNotify(struct btc_coexist *pBtCoexist, u8 type) { if (BTC_IPS_ENTER == type) { diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h index 80db3ba34a3f..1896ac54614c 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.h @@ -144,4 +144,3 @@ void EXhalbtc8723b2ant_BtInfoNotify( void EXhalbtc8723b2ant_HaltNotify(struct btc_coexist *pBtCoexist); void EXhalbtc8723b2ant_PnpNotify(struct btc_coexist *pBtCoexist, u8 pnpState); void EXhalbtc8723b2ant_Periodical(struct btc_coexist *pBtCoexist); -void EXhalbtc8723b2ant_DisplayCoexInfo(struct btc_coexist *pBtCoexist); diff --git a/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h b/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h index deb57fa15eaf..af50674b2a65 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h +++ b/drivers/staging/rtl8723bs/hal/HalBtcOutSrc.h @@ -85,10 +85,6 @@ enum { #define WIFI_P2P_GO_CONNECTED BIT3 #define WIFI_P2P_GC_CONNECTED BIT4 -/* following is for command line utility */ -#define CL_SPRINTF snprintf -#define CL_PRINTF DCMD_Printf - struct btc_board_info { /* The following is some board information */ u8 btChipType; @@ -384,7 +380,6 @@ struct btc_coexist { bool bInitilized; bool bStopCoexDm; bool bManualControl; - u8 *cliBuf; struct btc_statistics statistics; u8 pwrModeVal[10]; @@ -408,8 +403,6 @@ struct btc_coexist { /* fill h2c related */ BFP_BTC_FILL_H2C fBtcFillH2c; - /* other */ - BFP_BTC_DISP_DBG_MSG fBtcDispDbgMsg; /* normal get/set related */ BFP_BTC_GET fBtcGet; BFP_BTC_SET fBtcSet; @@ -440,6 +433,5 @@ void EXhalbtcoutsrc_Periodical(struct btc_coexist *pBtCoexist); void EXhalbtcoutsrc_SetChipType(u8 chipType); void EXhalbtcoutsrc_SetAntNum(u8 type, u8 antNum); void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath); -void EXhalbtcoutsrc_DisplayBtCoexInfo(struct btc_coexist *pBtCoexist); #endif diff --git a/drivers/staging/rtl8723bs/hal/Mp_Precomp.h b/drivers/staging/rtl8723bs/hal/Mp_Precomp.h index 3ed1142a9896..f08823a8dd7b 100644 --- a/drivers/staging/rtl8723bs/hal/Mp_Precomp.h +++ b/drivers/staging/rtl8723bs/hal/Mp_Precomp.h @@ -12,8 +12,6 @@ #define BT_TMP_BUF_SIZE 100 -#define DCMD_Printf DBG_BT_INFO - #ifdef bEnable #undef bEnable #endif diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 472005537b1b..6e165d808bbd 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -17,52 +17,8 @@ struct btc_coexist GLBtCoexist; static u8 GLBtcWiFiInScanState; static u8 GLBtcWiFiInIQKState; -static u8 GLBtcDbgBuf[BT_TMP_BUF_SIZE]; - -struct btcdbginfo { /* _btcoexdbginfo */ - u8 *info; - u32 size; /* buffer total size */ - u32 len; /* now used length */ -}; - -static struct btcdbginfo GLBtcDbgInfo; - #define BT_Operation(Adapter) false -static void DBG_BT_INFO_INIT(struct btcdbginfo *pinfo, u8 *pbuf, u32 size) -{ - if (!pinfo) - return; - - memset(pinfo, 0, sizeof(struct btcdbginfo)); - - if (pbuf && size) { - pinfo->info = pbuf; - pinfo->size = size; - } -} - -void DBG_BT_INFO(u8 *dbgmsg) -{ - struct btcdbginfo *pinfo; - u32 msglen; - u8 *pbuf; - - - pinfo = &GLBtcDbgInfo; - - if (!pinfo->info) - return; - - msglen = strlen(dbgmsg); - if (pinfo->len + msglen > pinfo->size) - return; - - pbuf = pinfo->info + pinfo->len; - memcpy(pbuf, dbgmsg, msglen); - pinfo->len += msglen; -} - /* */ /* Debug related function */ /* */ @@ -608,17 +564,6 @@ static u8 halbtcoutsrc_Set(void *pBtcContext, u8 setType, void *pInBuf) return ret; } -static void halbtcoutsrc_DisplayFwPwrModeCmd(struct btc_coexist *pBtCoexist) -{ - u8 *cliBuf = pBtCoexist->cliBuf; - - CL_SPRINTF(cliBuf, BT_TMP_BUF_SIZE, "\r\n %-35s = %02x %02x %02x %02x %02x %02x ", "Power mode cmd ", \ - pBtCoexist->pwrModeVal[0], pBtCoexist->pwrModeVal[1], - pBtCoexist->pwrModeVal[2], pBtCoexist->pwrModeVal[3], - pBtCoexist->pwrModeVal[4], pBtCoexist->pwrModeVal[5]); - CL_PRINTF(cliBuf); -} - /* */ /* IO related function */ /* */ @@ -830,25 +775,6 @@ static void halbtcoutsrc_FillH2cCmd(void *pBtcContext, u8 elementId, u32 cmdLen, rtw_hal_fill_h2c_cmd(padapter, elementId, cmdLen, pCmdBuffer); } -static void halbtcoutsrc_DisplayDbgMsg(void *pBtcContext, u8 dispType) -{ - struct btc_coexist *pBtCoexist; - - - pBtCoexist = (struct btc_coexist *)pBtcContext; - switch (dispType) { - case BTC_DBG_DISP_COEX_STATISTICS: - break; - case BTC_DBG_DISP_BT_LINK_INFO: - break; - case BTC_DBG_DISP_FW_PWR_MODE_CMD: - halbtcoutsrc_DisplayFwPwrModeCmd(pBtCoexist); - break; - default: - break; - } -} - /* */ /* Extern functions called by other module */ /* */ @@ -908,15 +834,12 @@ void hal_btcoex_Initialize(void *padapter) pBtCoexist->fBtcGetRfReg = halbtcoutsrc_GetRfReg; pBtCoexist->fBtcFillH2c = halbtcoutsrc_FillH2cCmd; - pBtCoexist->fBtcDispDbgMsg = halbtcoutsrc_DisplayDbgMsg; pBtCoexist->fBtcGet = halbtcoutsrc_Get; pBtCoexist->fBtcSet = halbtcoutsrc_Set; pBtCoexist->fBtcGetBtReg = halbtcoutsrc_GetBtReg; pBtCoexist->fBtcSetBtReg = halbtcoutsrc_SetBtReg; - pBtCoexist->cliBuf = &GLBtcDbgBuf[0]; - pBtCoexist->boardInfo.singleAntPath = 0; GLBtcWiFiInScanState = false; @@ -1220,21 +1143,6 @@ void EXhalbtcoutsrc_SetSingleAntPath(u8 singleAntPath) GLBtCoexist.boardInfo.singleAntPath = singleAntPath; } -void EXhalbtcoutsrc_DisplayBtCoexInfo(struct btc_coexist *pBtCoexist) -{ - if (!halbtcoutsrc_IsBtCoexistAvailable(pBtCoexist)) - return; - - halbtcoutsrc_LeaveLowPower(pBtCoexist); - - if (pBtCoexist->boardInfo.btdmAntNum == 2) - EXhalbtc8723b2ant_DisplayCoexInfo(pBtCoexist); - else if (pBtCoexist->boardInfo.btdmAntNum == 1) - EXhalbtc8723b1ant_DisplayCoexInfo(pBtCoexist); - - halbtcoutsrc_NormalLowPower(pBtCoexist); -} - /* * Description: *Run BT-Coexist mechanism or not @@ -1447,15 +1355,3 @@ void hal_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen) { memcpy(GLBtCoexist.pwrModeVal, pCmdBuf, cmdLen); } - -void hal_btcoex_DisplayBtCoexInfo(struct adapter *padapter, u8 *pbuf, u32 bufsize) -{ - struct btcdbginfo *pinfo; - - - pinfo = &GLBtcDbgInfo; - DBG_BT_INFO_INIT(pinfo, pbuf, bufsize); - EXhalbtcoutsrc_DisplayBtCoexInfo(&GLBtCoexist); - DBG_BT_INFO_INIT(pinfo, NULL, 0); -} - diff --git a/drivers/staging/rtl8723bs/include/hal_btcoex.h b/drivers/staging/rtl8723bs/include/hal_btcoex.h index 849fb90b43b7..78599d3521bf 100644 --- a/drivers/staging/rtl8723bs/include/hal_btcoex.h +++ b/drivers/staging/rtl8723bs/include/hal_btcoex.h @@ -20,8 +20,6 @@ struct bt_coexist { u8 bInitlized; }; -void DBG_BT_INFO(u8 *dbgmsg); - void hal_btcoex_SetBTCoexist(struct adapter *padapter, u8 bBtExist); bool hal_btcoex_IsBtExist(struct adapter *padapter); bool hal_btcoex_IsBtDisabled(struct adapter *); @@ -54,6 +52,5 @@ u8 hal_btcoex_RpwmVal(struct adapter *); u8 hal_btcoex_LpsVal(struct adapter *); u32 hal_btcoex_GetRaMask(struct adapter *); void hal_btcoex_RecordPwrMode(struct adapter *padapter, u8 *pCmdBuf, u8 cmdLen); -void hal_btcoex_DisplayBtCoexInfo(struct adapter *, u8 *pbuf, u32 bufsize); #endif /* !__HAL_BTCOEX_H__ */ -- cgit v1.2.3 From aef1c966a36407e24f9cf2293e0c1941fc32cdb1 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Wed, 28 Jul 2021 11:11:17 +0200 Subject: staging: rtl8723bs: core: Fix incorrect type in assignment Fix sparse warnings: incorrect type in assignment (different base types). Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210728091117.6235-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_security.c | 31 ++++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index a99f439328f1..8b507f6a447e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -35,8 +35,10 @@ const char *security_type_str(u8 value) */ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) { /* exclude ICV */ - - unsigned char crc[4]; + union { + __le32 f0; + unsigned char f1[4]; + } crc; signed int curfragnum, length; u32 keylength; @@ -69,18 +71,18 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = ~crc32_le(~0, payload, length); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arc4_setkey(ctx, wepkey, 3 + keylength); arc4_crypt(ctx, payload, payload, length); - arc4_crypt(ctx, payload + length, crc, 4); + arc4_crypt(ctx, payload + length, crc.f1, 4); } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = ~crc32_le(~0, payload, length); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arc4_setkey(ctx, wepkey, 3 + keylength); arc4_crypt(ctx, payload, payload, length); - arc4_crypt(ctx, payload + length, crc, 4); + arc4_crypt(ctx, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4); @@ -121,7 +123,7 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) arc4_crypt(ctx, payload, payload, length); /* calculate icv and compare the icv */ - *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4)); + *((u32 *)crc) = ~crc32_le(~0, payload, length - 4); } } @@ -464,7 +466,10 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u32 pnh; u8 rc4key[16]; u8 ttkey[16]; - u8 crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; u8 hw_hdr_offset = 0; signed int curfragnum, length; @@ -506,19 +511,19 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = ~crc32_le(~0, payload, length); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arc4_setkey(ctx, rc4key, 16); arc4_crypt(ctx, payload, payload, length); - arc4_crypt(ctx, payload + length, crc, 4); + arc4_crypt(ctx, payload + length, crc.f1, 4); } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = ~crc32_le(~0, payload, length); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arc4_setkey(ctx, rc4key, 16); arc4_crypt(ctx, payload, payload, length); - arc4_crypt(ctx, payload + length, crc, 4); + arc4_crypt(ctx, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)round_up((SIZE_PTR)(pframe), 4); @@ -618,7 +623,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) arc4_setkey(ctx, rc4key, 16); arc4_crypt(ctx, payload, payload, length); - *((u32 *)crc) = le32_to_cpu(~crc32_le(~0, payload, length - 4)); + *((u32 *)crc) = ~crc32_le(~0, payload, length - 4); if (crc[3] != payload[length - 1] || crc[2] != payload[length - 2] || crc[1] != payload[length - 3] || crc[0] != payload[length - 4]) -- cgit v1.2.3 From fdc234d85210d91881119df4818dfb4bbf1ceffc Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Wed, 28 Jul 2021 00:49:50 +0530 Subject: staging: sm750fb: Rename oScreen to o_screen in lynxfb_crtc The struct lynxfb_crtc has a member named oScreen. This name is CamelCase and is frowned upon. This commit renames it to o_screen and makes the necessary changes for the module to build. This change also fixes the following checkpatch CHECKs: CHECK: Avoid CamelCase: 138: FILE: sm750.h:138: + int oScreen; /* onscreen address offset in vidmem */ CHECK: Avoid CamelCase: 178: FILE: sm750.c:178: + base = par->crtc.oScreen; Signed-off-by: Benjamin Philip Link: https://lore.kernel.org/r/8d7c72027f7bc31a1c35a34f9909fa04f4cf8972.1627413010.git.benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 30 +++++++++--------- drivers/staging/sm750fb/sm750.h | 2 +- drivers/staging/sm750fb/sm750_hw.c | 62 +++++++++++++++++++------------------- 3 files changed, 47 insertions(+), 47 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 4f5f68e6aa60..202d8f47365c 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -175,7 +175,7 @@ static void lynxfb_ops_fillrect(struct fb_info *info, * each time 2d function begin to work,below three variable always need * be set, seems we can put them together in some place */ - base = par->crtc.oScreen; + base = par->crtc.o_screen; pitch = info->fix.line_length; Bpp = info->var.bits_per_pixel >> 3; @@ -213,7 +213,7 @@ static void lynxfb_ops_copyarea(struct fb_info *info, * each time 2d function begin to work,below three variable always need * be set, seems we can put them together in some place */ - base = par->crtc.oScreen; + base = par->crtc.o_screen; pitch = info->fix.line_length; Bpp = info->var.bits_per_pixel >> 3; @@ -247,7 +247,7 @@ static void lynxfb_ops_imageblit(struct fb_info *info, * each time 2d function begin to work,below three variable always need * be set, seems we can put them together in some place */ - base = par->crtc.oScreen; + base = par->crtc.o_screen; pitch = info->fix.line_length; Bpp = info->var.bits_per_pixel >> 3; @@ -614,44 +614,44 @@ static int sm750fb_set_drv(struct lynxfb_par *par) case sm750_simul_pri: output->paths = sm750_pnc; crtc->channel = sm750_primary; - crtc->oScreen = 0; + crtc->o_screen = 0; crtc->vScreen = sm750_dev->pvMem; pr_info("use simul primary mode\n"); break; case sm750_simul_sec: output->paths = sm750_pnc; crtc->channel = sm750_secondary; - crtc->oScreen = 0; + crtc->o_screen = 0; crtc->vScreen = sm750_dev->pvMem; break; case sm750_dual_normal: if (par->index == 0) { output->paths = sm750_panel; crtc->channel = sm750_primary; - crtc->oScreen = 0; + crtc->o_screen = 0; crtc->vScreen = sm750_dev->pvMem; } else { output->paths = sm750_crt; crtc->channel = sm750_secondary; - /* not consider of padding stuffs for oScreen,need fix */ - crtc->oScreen = sm750_dev->vidmem_size >> 1; - crtc->vScreen = sm750_dev->pvMem + crtc->oScreen; + /* not consider of padding stuffs for o_screen,need fix */ + crtc->o_screen = sm750_dev->vidmem_size >> 1; + crtc->vScreen = sm750_dev->pvMem + crtc->o_screen; } break; case sm750_dual_swap: if (par->index == 0) { output->paths = sm750_panel; crtc->channel = sm750_secondary; - crtc->oScreen = 0; + crtc->o_screen = 0; crtc->vScreen = sm750_dev->pvMem; } else { output->paths = sm750_crt; crtc->channel = sm750_primary; - /* not consider of padding stuffs for oScreen, + /* not consider of padding stuffs for o_screen, * need fix */ - crtc->oScreen = sm750_dev->vidmem_size >> 1; - crtc->vScreen = sm750_dev->pvMem + crtc->oScreen; + crtc->o_screen = sm750_dev->vidmem_size >> 1; + crtc->vScreen = sm750_dev->pvMem + crtc->o_screen; } break; default: @@ -718,7 +718,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) * set current cursor variable and proc pointer, * must be set after crtc member initialized */ - crtc->cursor.offset = crtc->oScreen + crtc->vidmem_size - 1024; + crtc->cursor.offset = crtc->o_screen + crtc->vidmem_size - 1024; crtc->cursor.mmio = sm750_dev->pvReg + 0x800f0 + (int)crtc->channel * 0x140; @@ -816,7 +816,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) strscpy(fix->id, fixId[index], sizeof(fix->id)); - fix->smem_start = crtc->oScreen + sm750_dev->vidmem_start; + fix->smem_start = crtc->o_screen + sm750_dev->vidmem_start; pr_info("fix->smem_start = %lx\n", fix->smem_start); /* * according to mmap experiment from user space application, diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 8271cf7c89f3..08c1048be541 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -135,7 +135,7 @@ struct lynxfb_crtc { unsigned char __iomem *vCursor; /* virtual address of cursor */ unsigned char __iomem *vScreen; /* virtual address of on_screen */ int oCursor; /* cursor address offset in vidmem */ - int oScreen; /* onscreen address offset in vidmem */ + int o_screen; /* onscreen address offset in vidmem */ int channel;/* which channel this crtc stands for*/ resource_size_t vidmem_size;/* this view's video memory max size */ diff --git a/drivers/staging/sm750fb/sm750_hw.c b/drivers/staging/sm750fb/sm750_hw.c index 7136d751cff5..a7c6eb07b62e 100644 --- a/drivers/staging/sm750fb/sm750_hw.c +++ b/drivers/staging/sm750fb/sm750_hw.c @@ -32,7 +32,7 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev) ret = 0; - sm750_dev->vidreg_start = pci_resource_start(pdev, 1); + sm750_dev->vidreg_start = pci_resource_start(pdev, 1); sm750_dev->vidreg_size = SZ_2M; pr_info("mmio phyAddr = %lx\n", sm750_dev->vidreg_start); @@ -50,8 +50,8 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev) } /* now map mmio and vidmem */ - sm750_dev->pvReg = ioremap(sm750_dev->vidreg_start, - sm750_dev->vidreg_size); + sm750_dev->pvReg = + ioremap(sm750_dev->vidreg_start, sm750_dev->vidreg_size); if (!sm750_dev->pvReg) { pr_err("mmio failed\n"); ret = -EFAULT; @@ -78,8 +78,8 @@ int hw_sm750_map(struct sm750_dev *sm750_dev, struct pci_dev *pdev) sm750_dev->vidmem_start, sm750_dev->vidmem_size); /* reserve the vidmem space of smi adaptor */ - sm750_dev->pvMem = ioremap_wc(sm750_dev->vidmem_start, - sm750_dev->vidmem_size); + sm750_dev->pvMem = + ioremap_wc(sm750_dev->vidmem_start, sm750_dev->vidmem_size); if (!sm750_dev->pvMem) { pr_err("Map video memory failed\n"); ret = -EFAULT; @@ -98,8 +98,8 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev) parm = &sm750_dev->initParm; if (parm->chip_clk == 0) parm->chip_clk = (sm750_get_chip_type() == SM750LE) ? - DEFAULT_SM750LE_CHIP_CLOCK : - DEFAULT_SM750_CHIP_CLOCK; + DEFAULT_SM750LE_CHIP_CLOCK : + DEFAULT_SM750_CHIP_CLOCK; if (parm->mem_clk == 0) parm->mem_clk = parm->chip_clk; @@ -133,8 +133,8 @@ int hw_sm750_inithw(struct sm750_dev *sm750_dev, struct pci_dev *pdev) } val = peek32(PANEL_DISPLAY_CTRL) & - ~(PANEL_DISPLAY_CTRL_DUAL_DISPLAY | - PANEL_DISPLAY_CTRL_DOUBLE_PIXEL); + ~(PANEL_DISPLAY_CTRL_DUAL_DISPLAY | + PANEL_DISPLAY_CTRL_DOUBLE_PIXEL); switch (sm750_dev->pnltype) { case sm750_24TFT: break; @@ -281,12 +281,12 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, /* set timing */ modparm.pixel_clock = ps_to_hz(var->pixclock); - modparm.vertical_sync_polarity = (var->sync & FB_SYNC_HOR_HIGH_ACT) - ? POS : NEG; - modparm.horizontal_sync_polarity = (var->sync & FB_SYNC_VERT_HIGH_ACT) - ? POS : NEG; - modparm.clock_phase_polarity = (var->sync & FB_SYNC_COMP_HIGH_ACT) - ? POS : NEG; + modparm.vertical_sync_polarity = + (var->sync & FB_SYNC_HOR_HIGH_ACT) ? POS : NEG; + modparm.horizontal_sync_polarity = + (var->sync & FB_SYNC_VERT_HIGH_ACT) ? POS : NEG; + modparm.clock_phase_polarity = + (var->sync & FB_SYNC_COMP_HIGH_ACT) ? POS : NEG; modparm.horizontal_display_end = var->xres; modparm.horizontal_sync_width = var->hsync_len; modparm.horizontal_sync_start = var->xres + var->right_margin; @@ -314,7 +314,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, if (crtc->channel != sm750_secondary) { /* set pitch, offset, width, start address, etc... */ poke32(PANEL_FB_ADDRESS, - crtc->oScreen & PANEL_FB_ADDRESS_ADDRESS_MASK); + crtc->o_screen & PANEL_FB_ADDRESS_ADDRESS_MASK); reg = var->xres * (var->bits_per_pixel >> 3); /* @@ -323,17 +323,17 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, */ reg = ALIGN(reg, crtc->line_pad); reg = (reg << PANEL_FB_WIDTH_WIDTH_SHIFT) & - PANEL_FB_WIDTH_WIDTH_MASK; + PANEL_FB_WIDTH_WIDTH_MASK; reg |= (fix->line_length & PANEL_FB_WIDTH_OFFSET_MASK); poke32(PANEL_FB_WIDTH, reg); reg = ((var->xres - 1) << PANEL_WINDOW_WIDTH_WIDTH_SHIFT) & - PANEL_WINDOW_WIDTH_WIDTH_MASK; + PANEL_WINDOW_WIDTH_WIDTH_MASK; reg |= (var->xoffset & PANEL_WINDOW_WIDTH_X_MASK); poke32(PANEL_WINDOW_WIDTH, reg); - reg = (var->yres_virtual - 1) << - PANEL_WINDOW_HEIGHT_HEIGHT_SHIFT; + reg = (var->yres_virtual - 1) + << PANEL_WINDOW_HEIGHT_HEIGHT_SHIFT; reg &= PANEL_WINDOW_HEIGHT_HEIGHT_MASK; reg |= (var->yoffset & PANEL_WINDOW_HEIGHT_Y_MASK); poke32(PANEL_WINDOW_HEIGHT, reg); @@ -341,7 +341,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, poke32(PANEL_PLANE_TL, 0); reg = ((var->yres - 1) << PANEL_PLANE_BR_BOTTOM_SHIFT) & - PANEL_PLANE_BR_BOTTOM_MASK; + PANEL_PLANE_BR_BOTTOM_MASK; reg |= ((var->xres - 1) & PANEL_PLANE_BR_RIGHT_MASK); poke32(PANEL_PLANE_BR, reg); @@ -350,7 +350,7 @@ int hw_sm750_crtc_setMode(struct lynxfb_crtc *crtc, poke32(PANEL_DISPLAY_CTRL, reg | (var->bits_per_pixel >> 4)); } else { /* not implemented now */ - poke32(CRT_FB_ADDRESS, crtc->oScreen); + poke32(CRT_FB_ADDRESS, crtc->o_screen); reg = var->xres * (var->bits_per_pixel >> 3); /* * crtc->channel is not equal to par->index on numeric, @@ -372,10 +372,10 @@ exit: return ret; } -int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index, - ushort red, ushort green, ushort blue) +int hw_sm750_setColReg(struct lynxfb_crtc *crtc, ushort index, ushort red, + ushort green, ushort blue) { - static unsigned int add[] = {PANEL_PALETTE_RAM, CRT_PALETTE_RAM}; + static unsigned int add[] = { PANEL_PALETTE_RAM, CRT_PALETTE_RAM }; poke32(add[crtc->channel] + index * 4, (red << 16) | (green << 8) | blue); @@ -510,7 +510,7 @@ int hw_sm750le_deWait(void) { int i = 0x10000000; unsigned int mask = DE_STATE2_DE_STATUS_BUSY | DE_STATE2_DE_FIFO_EMPTY | - DE_STATE2_DE_MEM_FIFO_EMPTY; + DE_STATE2_DE_MEM_FIFO_EMPTY; while (i--) { unsigned int val = peek32(DE_STATE2); @@ -527,8 +527,8 @@ int hw_sm750_deWait(void) { int i = 0x10000000; unsigned int mask = SYSTEM_CTRL_DE_STATUS_BUSY | - SYSTEM_CTRL_DE_FIFO_EMPTY | - SYSTEM_CTRL_DE_MEM_FIFO_EMPTY; + SYSTEM_CTRL_DE_FIFO_EMPTY | + SYSTEM_CTRL_DE_MEM_FIFO_EMPTY; while (i--) { unsigned int val = peek32(SYSTEM_CTRL); @@ -554,15 +554,15 @@ int hw_sm750_pan_display(struct lynxfb_crtc *crtc, total = var->yoffset * info->fix.line_length + ((var->xoffset * var->bits_per_pixel) >> 3); - total += crtc->oScreen; + total += crtc->o_screen; if (crtc->channel == sm750_primary) { poke32(PANEL_FB_ADDRESS, peek32(PANEL_FB_ADDRESS) | - (total & PANEL_FB_ADDRESS_ADDRESS_MASK)); + (total & PANEL_FB_ADDRESS_ADDRESS_MASK)); } else { poke32(CRT_FB_ADDRESS, peek32(CRT_FB_ADDRESS) | - (total & CRT_FB_ADDRESS_ADDRESS_MASK)); + (total & CRT_FB_ADDRESS_ADDRESS_MASK)); } return 0; } -- cgit v1.2.3 From 547265b8873fd8f3efef747316a31b22fbbe9c7c Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Wed, 28 Jul 2021 00:49:51 +0530 Subject: staging: sm750fb: Rename oCursor to o_cursor in lynxfb_crtc The struct lynxfb_crtc has a member named oCursor. This name is CamelCase and is frowned upon. This commit renames it to o_cursor and makes the necessary changes for the module to build. This change also fixes the following checkpatch CHECK: CHECK: Avoid CamelCase: 137: FILE: sm750.h:137: + int oCursor; /* cursor address offset in vidmem */ Signed-off-by: Benjamin Philip Link: https://lore.kernel.org/r/aec911b055687892897feb4899644b9463245f1e.1627413010.git.benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 08c1048be541..4093d5e898c6 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -134,7 +134,7 @@ struct lynx_cursor { struct lynxfb_crtc { unsigned char __iomem *vCursor; /* virtual address of cursor */ unsigned char __iomem *vScreen; /* virtual address of on_screen */ - int oCursor; /* cursor address offset in vidmem */ + int o_cursor; /* cursor address offset in vidmem */ int o_screen; /* onscreen address offset in vidmem */ int channel;/* which channel this crtc stands for*/ resource_size_t vidmem_size;/* this view's video memory max size */ -- cgit v1.2.3 From 7bca9543512e66c5de1c62f855febeae98801587 Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Wed, 28 Jul 2021 00:49:52 +0530 Subject: staging: sm750fb: Rename vCursor to v_cursor in lynxfb_crtc The struct lynxfb_crtc has a member named vCursor. This name is CamelCase and is frowned upon. This commit renames it to v_cursor and makes the necessary changes for the module to build. This change also fixes the following checkpatch CHECK: + unsigned char __iomem *vCursor; /* virtual address of cursor */ Signed-off-by: Benjamin Philip CHECK: Avoid CamelCase: 135: FILE: sm750.h:135: Link: https://lore.kernel.org/r/58dfc3f12deabe3a786ff2b9c75ac24f51724974.1627413010.git.benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 4093d5e898c6..8952154739ac 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -132,7 +132,7 @@ struct lynx_cursor { }; struct lynxfb_crtc { - unsigned char __iomem *vCursor; /* virtual address of cursor */ + unsigned char __iomem *v_cursor; /* virtual address of cursor */ unsigned char __iomem *vScreen; /* virtual address of on_screen */ int o_cursor; /* cursor address offset in vidmem */ int o_screen; /* onscreen address offset in vidmem */ -- cgit v1.2.3 From cc59bde1c920ab6689d40eba1a6fcd4edbec2455 Mon Sep 17 00:00:00 2001 From: Benjamin Philip Date: Wed, 28 Jul 2021 00:49:53 +0530 Subject: staging: sm750fb: Rename vScreen to v_screen in lynxfb_crtc The struct lynxfb_crtc has a member named vScreen. This name is CamelCase and is frowned upon. This commit renames it to v_screen and makes the necessary changes for the module to build. This change also fixes the following checkpatch CHECKs: CHECK: Avoid CamelCase: 454: FILE: sm750.c:454: + memset_io(crtc->vScreen, 0x0, crtc->vidmem_size); CHECK: Avoid CamelCase: 136: FILE: sm750.h:136: + unsigned char __iomem *vScreen; /* virtual address of on_screen */ Signed-off-by: Benjamin Philip Link: https://lore.kernel.org/r/52db14bfc2f39e246aed7fdf866845a72e503b36.1627413010.git.benjamin.philip495@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/sm750fb/sm750.c | 18 +++++++++--------- drivers/staging/sm750fb/sm750.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 202d8f47365c..dbd1159a2ef0 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -451,7 +451,7 @@ static int __maybe_unused lynxfb_resume(struct device *dev) crtc = &par->crtc; cursor = &crtc->cursor; memset_io(cursor->vstart, 0x0, cursor->size); - memset_io(crtc->vScreen, 0x0, crtc->vidmem_size); + memset_io(crtc->v_screen, 0x0, crtc->vidmem_size); lynxfb_ops_set_par(info); fb_set_suspend(info, 0); } @@ -463,7 +463,7 @@ static int __maybe_unused lynxfb_resume(struct device *dev) crtc = &par->crtc; cursor = &crtc->cursor; memset_io(cursor->vstart, 0x0, cursor->size); - memset_io(crtc->vScreen, 0x0, crtc->vidmem_size); + memset_io(crtc->v_screen, 0x0, crtc->vidmem_size); lynxfb_ops_set_par(info); fb_set_suspend(info, 0); } @@ -615,27 +615,27 @@ static int sm750fb_set_drv(struct lynxfb_par *par) output->paths = sm750_pnc; crtc->channel = sm750_primary; crtc->o_screen = 0; - crtc->vScreen = sm750_dev->pvMem; + crtc->v_screen = sm750_dev->pvMem; pr_info("use simul primary mode\n"); break; case sm750_simul_sec: output->paths = sm750_pnc; crtc->channel = sm750_secondary; crtc->o_screen = 0; - crtc->vScreen = sm750_dev->pvMem; + crtc->v_screen = sm750_dev->pvMem; break; case sm750_dual_normal: if (par->index == 0) { output->paths = sm750_panel; crtc->channel = sm750_primary; crtc->o_screen = 0; - crtc->vScreen = sm750_dev->pvMem; + crtc->v_screen = sm750_dev->pvMem; } else { output->paths = sm750_crt; crtc->channel = sm750_secondary; /* not consider of padding stuffs for o_screen,need fix */ crtc->o_screen = sm750_dev->vidmem_size >> 1; - crtc->vScreen = sm750_dev->pvMem + crtc->o_screen; + crtc->v_screen = sm750_dev->pvMem + crtc->o_screen; } break; case sm750_dual_swap: @@ -643,7 +643,7 @@ static int sm750fb_set_drv(struct lynxfb_par *par) output->paths = sm750_panel; crtc->channel = sm750_secondary; crtc->o_screen = 0; - crtc->vScreen = sm750_dev->pvMem; + crtc->v_screen = sm750_dev->pvMem; } else { output->paths = sm750_crt; crtc->channel = sm750_primary; @@ -651,7 +651,7 @@ static int sm750fb_set_drv(struct lynxfb_par *par) * need fix */ crtc->o_screen = sm750_dev->vidmem_size >> 1; - crtc->vScreen = sm750_dev->pvMem + crtc->o_screen; + crtc->v_screen = sm750_dev->pvMem + crtc->o_screen; } break; default: @@ -801,7 +801,7 @@ static int lynxfb_set_fbinfo(struct fb_info *info, int index) crtc->line_pad); info->pseudo_palette = &par->pseudo_palette[0]; - info->screen_base = crtc->vScreen; + info->screen_base = crtc->v_screen; pr_debug("screen_base vaddr = %p\n", info->screen_base); info->screen_size = line_length * var->yres_virtual; info->flags = FBINFO_FLAG_DEFAULT | 0; diff --git a/drivers/staging/sm750fb/sm750.h b/drivers/staging/sm750fb/sm750.h index 8952154739ac..aff69661c8e6 100644 --- a/drivers/staging/sm750fb/sm750.h +++ b/drivers/staging/sm750fb/sm750.h @@ -133,7 +133,7 @@ struct lynx_cursor { struct lynxfb_crtc { unsigned char __iomem *v_cursor; /* virtual address of cursor */ - unsigned char __iomem *vScreen; /* virtual address of on_screen */ + unsigned char __iomem *v_screen; /* virtual address of on_screen */ int o_cursor; /* cursor address offset in vidmem */ int o_screen; /* onscreen address offset in vidmem */ int channel;/* which channel this crtc stands for*/ -- cgit v1.2.3 From 041878d46ba37157814e6b650c9eff6efa7070d6 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Thu, 29 Jul 2021 14:54:17 +0200 Subject: staging: rtl8723bs: remove unused BT static variables remove some unused static variables. One of them is used to toggle on the BT coexistence mechanism, but it is always enabled and it's not conditioned to the value of the related parameter. Remove unused field of the registry_priv struct as well, they were intended for hosting the parameters this patch rids. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/20210729125417.4380-1-fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/drv_types.h | 4 ---- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 10 ---------- 2 files changed, 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index 895c41526164..d49009c75d2e 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -139,10 +139,6 @@ struct registry_priv { u8 channel_plan; - u8 btcoex; - u8 bt_iso; - u8 bt_sco; - u8 bt_ampdu; s8 ant_num; /* false:Reject AP's Add BA req, true:accept AP's Add BA req */ diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index b042df319c98..7359f0861cce 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -95,12 +95,6 @@ static int rtw_low_power; static int rtw_wifi_spec; static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; -static int rtw_btcoex_enable = 1; -module_param(rtw_btcoex_enable, int, 0644); -MODULE_PARM_DESC(rtw_btcoex_enable, "Enable BT co-existence mechanism"); -static int rtw_bt_iso = 2;/* 0:Low, 1:High, 2:From Efuse */ -static int rtw_bt_sco = 3;/* 0:Idle, 1:None-SCO, 2:SCO, 3:From Counter, 4.Busy, 5.OtherBusy */ -static int rtw_bt_ampdu = 1 ;/* 0:Disable BT control A-MPDU, 1:Enable BT control A-MPDU. */ static int rtw_ant_num = -1; /* <0: undefined, >0: Antenna number */ module_param(rtw_ant_num, int, 0644); MODULE_PARM_DESC(rtw_ant_num, "Antenna number setting"); @@ -263,10 +257,6 @@ static void loadparam(struct adapter *padapter, struct net_device *pnetdev) registry_par->channel_plan = (u8)rtw_channel_plan; - registry_par->btcoex = (u8)rtw_btcoex_enable; - registry_par->bt_iso = (u8)rtw_bt_iso; - registry_par->bt_sco = (u8)rtw_bt_sco; - registry_par->bt_ampdu = (u8)rtw_bt_ampdu; registry_par->ant_num = (s8)rtw_ant_num; registry_par->accept_addba_req = true; -- cgit v1.2.3 From 7aaabc37943f383ec8d8e51b7fc43ae60fac4206 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sun, 18 Jul 2021 15:12:17 +0200 Subject: staging/vc04_services: Remove all strcpy() uses in favor of strscpy() strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210718131217.3806-1-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c | 2 +- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c index df90c1f9d148..1b184d5c6b82 100644 --- a/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c +++ b/drivers/staging/vc04_services/bcm2835-camera/bcm2835-camera.c @@ -884,7 +884,7 @@ static int vidioc_querycap(struct file *file, void *priv, vchiq_mmal_version(dev->instance, &major, &minor); - strcpy((char *)cap->driver, "bm2835 mmal"); + strscpy(cap->driver, "bm2835 mmal", sizeof(cap->driver)); snprintf((char *)cap->card, sizeof(cap->card), "mmal service %d.%d", major, minor); diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c index 4f43e4213bfe..9429b8a642fb 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.c @@ -3716,7 +3716,7 @@ int vchiq_dump_service_state(void *dump_context, struct vchiq_service *service) sizeof(remoteport) - len2, " (client %x)", service->client_id); } else { - strcpy(remoteport, "n/a"); + strscpy(remoteport, "n/a", sizeof(remoteport)); } len += scnprintf(buf + len, sizeof(buf) - len, -- cgit v1.2.3 From ece42658c85df4c2d6c9b3ddb116003a2de4ecef Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 29 Jul 2021 11:58:12 +0200 Subject: staging: vt665X: remove unused CONFIG_PATH The vt6655 and vt6656 drivers have an unused CONFIG_PATH define floating around in the code, but it is never used. Remove it as drivers should never be reading from config files anyway, even if these were valid files. Reported-by: Joe Perches Reported-by: Randy Dunlap Acked-by: Randy Dunlap Link: https://lore.kernel.org/r/20210729095812.1693061-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/device_cfg.h | 3 --- drivers/staging/vt6656/device.h | 2 -- 2 files changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/device_cfg.h b/drivers/staging/vt6655/device_cfg.h index db0304f6e21c..2d647a3619ba 100644 --- a/drivers/staging/vt6655/device_cfg.h +++ b/drivers/staging/vt6655/device_cfg.h @@ -38,9 +38,6 @@ #include #include -#ifndef CONFIG_PATH -#define CONFIG_PATH "/etc/vntconfiguration.dat" -#endif #define PKT_BUF_SZ 2390 diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 947530fefe94..2c93a2e66c8a 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -77,8 +77,6 @@ #define FIRMWARE_NAME "vntwusb.fw" #define FIRMWARE_CHUNK_SIZE 0x400 -#define CONFIG_PATH "/etc/vntconfiguration.dat" - #define MAX_UINTS 8 #define OPTION_DEFAULT { [0 ... MAX_UINTS - 1] = -1} -- cgit v1.2.3 From d27252b2c69c53a5b81121faf59d6b4b368e365d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 11:48:09 -0500 Subject: staging: r8188eu: Convert header copyright info to SPDX format, part 1 Before this driver can be incorporated in the drivers/net/wireless tree, the copyright info in all files must be converted to SPDX notation. This patch converts the first 20 files. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729164814.32097-2-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/Hal8188EPhyCfg.h | 22 +++------------ drivers/staging/r8188eu/include/Hal8188EPhyReg.h | 22 +++------------ drivers/staging/r8188eu/include/Hal8188EPwrSeq.h | 22 ++------------- .../staging/r8188eu/include/Hal8188ERateAdaptive.h | 4 ++- drivers/staging/r8188eu/include/Hal8188EReg.h | 31 +++------------------- drivers/staging/r8188eu/include/HalHWImg8188E_BB.h | 21 ++------------- drivers/staging/r8188eu/include/HalHWImg8188E_FW.h | 21 ++------------- .../staging/r8188eu/include/HalHWImg8188E_MAC.h | 21 ++------------- drivers/staging/r8188eu/include/HalHWImg8188E_RF.h | 21 ++------------- drivers/staging/r8188eu/include/HalPhyRf.h | 25 +++-------------- drivers/staging/r8188eu/include/HalPhyRf_8188e.h | 21 ++------------- drivers/staging/r8188eu/include/autoconf.h | 21 ++------------- drivers/staging/r8188eu/include/basic_types.h | 22 +++------------ drivers/staging/r8188eu/include/cmd_osdep.h | 22 +++------------ drivers/staging/r8188eu/include/drv_types.h | 22 +++------------ drivers/staging/r8188eu/include/drv_types_linux.h | 22 +++------------ drivers/staging/r8188eu/include/ethernet.h | 23 +++------------- drivers/staging/r8188eu/include/h2clbk.h | 21 ++------------- drivers/staging/r8188eu/include/hal_com.h | 22 +++------------ drivers/staging/r8188eu/include/hal_intf.h | 22 +++------------ 20 files changed, 53 insertions(+), 375 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h index 6fb059576a67..63b068fa9f4d 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __INC_HAL8188EPHYCFG_H__ #define __INC_HAL8188EPHYCFG_H__ diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyReg.h b/drivers/staging/r8188eu/include/Hal8188EPhyReg.h index c324970171cd..8b8c75a1f149 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPhyReg.h +++ b/drivers/staging/r8188eu/include/Hal8188EPhyReg.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __INC_HAL8188EPHYREG_H__ #define __INC_HAL8188EPHYREG_H__ /*--------------------------Define Parameters-------------------------------*/ diff --git a/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h b/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h index df151b76f302..43f41e77a939 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h +++ b/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h @@ -1,23 +1,5 @@ - -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __HAL8188EPWRSEQ_H__ #define __HAL8188EPWRSEQ_H__ diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h index 21996a1173ef..ce4c96d4b84a 100644 --- a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h +++ b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h @@ -1,7 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright (c) 2011 Realtek Semiconductor Corp. */ + #ifndef __INC_RA_H #define __INC_RA_H /*++ -Copyright (c) Realtek Semiconductor Corp. All rights reserved. Module Name: RateAdaptive.h diff --git a/drivers/staging/r8188eu/include/Hal8188EReg.h b/drivers/staging/r8188eu/include/Hal8188EReg.h index 06818ac6c330..e04fae68fa4b 100644 --- a/drivers/staging/r8188eu/include/Hal8188EReg.h +++ b/drivers/staging/r8188eu/include/Hal8188EReg.h @@ -1,31 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/* */ -/* File Name: Hal8188EReg.h */ -/* */ -/* Description: */ -/* */ -/* This file is for RTL8188E register definition. */ -/* */ -/* */ -/* */ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __HAL_8188E_REG_H__ #define __HAL_8188E_REG_H__ diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h index e57452104bfb..8270fdbc2844 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_BB.h @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __INC_BB_8188E_HW_IMG_H #define __INC_BB_8188E_HW_IMG_H diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h b/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h index ce81fea401a1..5ddcd283097b 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_FW.h @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __INC_FW_8188E_HW_IMG_H #define __INC_FW_8188E_HW_IMG_H diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h index acf78b94fddb..391c1754b0b6 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_MAC.h @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __INC_MAC_8188E_HW_IMG_H #define __INC_MAC_8188E_HW_IMG_H diff --git a/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h index 8ecb40d26c70..0c67c3df20b9 100644 --- a/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h +++ b/drivers/staging/r8188eu/include/HalHWImg8188E_RF.h @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __INC_RF_8188E_HW_IMG_H #define __INC_RF_8188E_HW_IMG_H diff --git a/drivers/staging/r8188eu/include/HalPhyRf.h b/drivers/staging/r8188eu/include/HalPhyRf.h index 1ec497100da1..ba3b6133fc13 100644 --- a/drivers/staging/r8188eu/include/HalPhyRf.h +++ b/drivers/staging/r8188eu/include/HalPhyRf.h @@ -1,25 +1,8 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - #ifndef __HAL_PHY_RF_H__ - #define __HAL_PHY_RF_H__ +#ifndef __HAL_PHY_RF_H__ +#define __HAL_PHY_RF_H__ #define ODM_TARGET_CHNL_NUM_2G_5G 59 diff --git a/drivers/staging/r8188eu/include/HalPhyRf_8188e.h b/drivers/staging/r8188eu/include/HalPhyRf_8188e.h index 807c301a86e4..d4a27662309f 100644 --- a/drivers/staging/r8188eu/include/HalPhyRf_8188e.h +++ b/drivers/staging/r8188eu/include/HalPhyRf_8188e.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __HAL_PHY_RF_8188E_H__ #define __HAL_PHY_RF_8188E_H__ diff --git a/drivers/staging/r8188eu/include/autoconf.h b/drivers/staging/r8188eu/include/autoconf.h index cfa790794fd3..fcbfc60fad5a 100644 --- a/drivers/staging/r8188eu/include/autoconf.h +++ b/drivers/staging/r8188eu/include/autoconf.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation.*/ /* temporarily flag ******* */ /* diff --git a/drivers/staging/r8188eu/include/basic_types.h b/drivers/staging/r8188eu/include/basic_types.h index 8a7ca992674a..9c34e2dad6bb 100644 --- a/drivers/staging/r8188eu/include/basic_types.h +++ b/drivers/staging/r8188eu/include/basic_types.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __BASIC_TYPES_H__ #define __BASIC_TYPES_H__ diff --git a/drivers/staging/r8188eu/include/cmd_osdep.h b/drivers/staging/r8188eu/include/cmd_osdep.h index 5a8465e147b3..75ba595f2301 100644 --- a/drivers/staging/r8188eu/include/cmd_osdep.h +++ b/drivers/staging/r8188eu/include/cmd_osdep.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __CMD_OSDEP_H_ #define __CMD_OSDEP_H_ diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index 9aa72a91d467..dce4c602ffe6 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + /*----------------------------------------------------------------------------- For type defines and data structure defines diff --git a/drivers/staging/r8188eu/include/drv_types_linux.h b/drivers/staging/r8188eu/include/drv_types_linux.h index f5db1dd14317..068a7bcee82f 100644 --- a/drivers/staging/r8188eu/include/drv_types_linux.h +++ b/drivers/staging/r8188eu/include/drv_types_linux.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __DRV_TYPES_LINUX_H__ #define __DRV_TYPES_LINUX_H__ diff --git a/drivers/staging/r8188eu/include/ethernet.h b/drivers/staging/r8188eu/include/ethernet.h index 5b17dcf143a4..898eb296013c 100644 --- a/drivers/staging/r8188eu/include/ethernet.h +++ b/drivers/staging/r8188eu/include/ethernet.h @@ -1,23 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/*! \file */ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __INC_ETHERNET_H #define __INC_ETHERNET_H diff --git a/drivers/staging/r8188eu/include/h2clbk.h b/drivers/staging/r8188eu/include/h2clbk.h index 72b67827bc6e..412b611760b3 100644 --- a/drivers/staging/r8188eu/include/h2clbk.h +++ b/drivers/staging/r8188eu/include/h2clbk.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #define _H2CLBK_H_ diff --git a/drivers/staging/r8188eu/include/hal_com.h b/drivers/staging/r8188eu/include/hal_com.h index 652f645d54ff..95167f0b327f 100644 --- a/drivers/staging/r8188eu/include/hal_com.h +++ b/drivers/staging/r8188eu/include/hal_com.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __HAL_COMMON_H__ #define __HAL_COMMON_H__ diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index 49539b862863..c829aee518dd 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #ifndef __HAL_INTF_H__ #define __HAL_INTF_H__ -- cgit v1.2.3 From d521be8ed93b89364c9334184a43af6a2a759165 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 11:48:10 -0500 Subject: staging: r8188eu: Convert header copyright info to SPDX format, part 2 Before this driver can be incorporated in the drivers/net/wireless tree, the copyright info in all files must be converted to SPDX notation. This patch converts the next 23 files. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729164814.32097-3-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/HalPwrSeqCmd.h | 22 ++------------- drivers/staging/r8188eu/include/HalVerDef.h | 21 ++------------ drivers/staging/r8188eu/include/ieee80211.h | 22 ++------------- drivers/staging/r8188eu/include/ieee80211_ext.h | 22 ++------------- drivers/staging/r8188eu/include/if_ether.h | 21 ++------------ drivers/staging/r8188eu/include/ioctl_cfg80211.h | 22 ++------------- drivers/staging/r8188eu/include/ip.h | 22 ++------------- drivers/staging/r8188eu/include/mlme_osdep.h | 22 ++------------- drivers/staging/r8188eu/include/mp_custom_oid.h | 22 ++------------- drivers/staging/r8188eu/include/nic_spec.h | 21 ++------------ drivers/staging/r8188eu/include/odm.h | 21 ++------------ drivers/staging/r8188eu/include/odm_HWConfig.h | 21 ++------------ drivers/staging/r8188eu/include/odm_RTL8188E.h | 22 ++------------- .../staging/r8188eu/include/odm_RegConfig8188E.h | 22 ++------------- .../staging/r8188eu/include/odm_RegDefine11AC.h | 21 ++------------ drivers/staging/r8188eu/include/odm_RegDefine11N.h | 21 ++------------ drivers/staging/r8188eu/include/odm_debug.h | 21 ++------------ drivers/staging/r8188eu/include/odm_interface.h | 21 ++------------ drivers/staging/r8188eu/include/odm_precomp.h | 21 ++------------ drivers/staging/r8188eu/include/odm_reg.h | 33 ++-------------------- drivers/staging/r8188eu/include/odm_types.h | 22 ++------------- drivers/staging/r8188eu/include/osdep_intf.h | 21 ++------------ drivers/staging/r8188eu/include/osdep_service.h | 22 ++------------- 23 files changed, 58 insertions(+), 448 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/HalPwrSeqCmd.h b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h index c591e9d1c23b..3b8e263ea6e1 100644 --- a/drivers/staging/r8188eu/include/HalPwrSeqCmd.h +++ b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __HALPWRSEQCMD_H__ #define __HALPWRSEQCMD_H__ diff --git a/drivers/staging/r8188eu/include/HalVerDef.h b/drivers/staging/r8188eu/include/HalVerDef.h index 2a7dc28b8de7..a0f5bf52e75a 100644 --- a/drivers/staging/r8188eu/include/HalVerDef.h +++ b/drivers/staging/r8188eu/include/HalVerDef.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __HAL_VERSION_DEF_H__ #define __HAL_VERSION_DEF_H__ diff --git a/drivers/staging/r8188eu/include/ieee80211.h b/drivers/staging/r8188eu/include/ieee80211.h index 0e6beaebeb0f..bc9a875cdf35 100644 --- a/drivers/staging/r8188eu/include/ieee80211.h +++ b/drivers/staging/r8188eu/include/ieee80211.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __IEEE80211_H #define __IEEE80211_H diff --git a/drivers/staging/r8188eu/include/ieee80211_ext.h b/drivers/staging/r8188eu/include/ieee80211_ext.h index fa9e52572fe9..cc53c71d2d8b 100644 --- a/drivers/staging/r8188eu/include/ieee80211_ext.h +++ b/drivers/staging/r8188eu/include/ieee80211_ext.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __IEEE80211_EXT_H #define __IEEE80211_EXT_H diff --git a/drivers/staging/r8188eu/include/if_ether.h b/drivers/staging/r8188eu/include/if_ether.h index db157712a203..5bb79fddeec6 100644 --- a/drivers/staging/r8188eu/include/if_ether.h +++ b/drivers/staging/r8188eu/include/if_ether.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef _LINUX_IF_ETHER_H #define _LINUX_IF_ETHER_H diff --git a/drivers/staging/r8188eu/include/ioctl_cfg80211.h b/drivers/staging/r8188eu/include/ioctl_cfg80211.h index 037e9a5e5af9..e22481050ef8 100644 --- a/drivers/staging/r8188eu/include/ioctl_cfg80211.h +++ b/drivers/staging/r8188eu/include/ioctl_cfg80211.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ + #ifndef __IOCTL_CFG80211_H__ #define __IOCTL_CFG80211_H__ diff --git a/drivers/staging/r8188eu/include/ip.h b/drivers/staging/r8188eu/include/ip.h index 0107ac15c6ed..b7388c8c1b8a 100644 --- a/drivers/staging/r8188eu/include/ip.h +++ b/drivers/staging/r8188eu/include/ip.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _LINUX_IP_H #define _LINUX_IP_H diff --git a/drivers/staging/r8188eu/include/mlme_osdep.h b/drivers/staging/r8188eu/include/mlme_osdep.h index ae1722c67032..096232b0f95b 100644 --- a/drivers/staging/r8188eu/include/mlme_osdep.h +++ b/drivers/staging/r8188eu/include/mlme_osdep.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __MLME_OSDEP_H_ #define __MLME_OSDEP_H_ diff --git a/drivers/staging/r8188eu/include/mp_custom_oid.h b/drivers/staging/r8188eu/include/mp_custom_oid.h index be4f11864f63..7bcb857c795d 100644 --- a/drivers/staging/r8188eu/include/mp_custom_oid.h +++ b/drivers/staging/r8188eu/include/mp_custom_oid.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __CUSTOM_OID_H #define __CUSTOM_OID_H diff --git a/drivers/staging/r8188eu/include/nic_spec.h b/drivers/staging/r8188eu/include/nic_spec.h index cee6f06a4570..77e865398fd1 100644 --- a/drivers/staging/r8188eu/include/nic_spec.h +++ b/drivers/staging/r8188eu/include/nic_spec.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __NIC_SPEC_H__ #define __NIC_SPEC_H__ diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index b282b750de7c..8c1d15eed259 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __HALDMOUTSRC_H__ #define __HALDMOUTSRC_H__ diff --git a/drivers/staging/r8188eu/include/odm_HWConfig.h b/drivers/staging/r8188eu/include/odm_HWConfig.h index 80f549f196e2..9b2ab3bcf992 100644 --- a/drivers/staging/r8188eu/include/odm_HWConfig.h +++ b/drivers/staging/r8188eu/include/odm_HWConfig.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __HALHWOUTSRC_H__ #define __HALHWOUTSRC_H__ diff --git a/drivers/staging/r8188eu/include/odm_RTL8188E.h b/drivers/staging/r8188eu/include/odm_RTL8188E.h index f96ad5af4bd5..d6718186f2d6 100644 --- a/drivers/staging/r8188eu/include/odm_RTL8188E.h +++ b/drivers/staging/r8188eu/include/odm_RTL8188E.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __ODM_RTL8188E_H__ #define __ODM_RTL8188E_H__ diff --git a/drivers/staging/r8188eu/include/odm_RegConfig8188E.h b/drivers/staging/r8188eu/include/odm_RegConfig8188E.h index f2bf7a0d9867..86b5b2d24210 100644 --- a/drivers/staging/r8188eu/include/odm_RegConfig8188E.h +++ b/drivers/staging/r8188eu/include/odm_RegConfig8188E.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __INC_ODM_REGCONFIG_H_8188E #define __INC_ODM_REGCONFIG_H_8188E diff --git a/drivers/staging/r8188eu/include/odm_RegDefine11AC.h b/drivers/staging/r8188eu/include/odm_RegDefine11AC.h index 01425f36634c..bba7511cf244 100644 --- a/drivers/staging/r8188eu/include/odm_RegDefine11AC.h +++ b/drivers/staging/r8188eu/include/odm_RegDefine11AC.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __ODM_REGDEFINE11AC_H__ #define __ODM_REGDEFINE11AC_H__ diff --git a/drivers/staging/r8188eu/include/odm_RegDefine11N.h b/drivers/staging/r8188eu/include/odm_RegDefine11N.h index 2b888dee3dd5..5d1d73490c1c 100644 --- a/drivers/staging/r8188eu/include/odm_RegDefine11N.h +++ b/drivers/staging/r8188eu/include/odm_RegDefine11N.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __ODM_REGDEFINE11N_H__ #define __ODM_REGDEFINE11N_H__ diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index 5e58b603d6ac..171fc5cbf27c 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __ODM_DBG_H__ #define __ODM_DBG_H__ diff --git a/drivers/staging/r8188eu/include/odm_interface.h b/drivers/staging/r8188eu/include/odm_interface.h index 0abfa6febb7e..6b589413d56c 100644 --- a/drivers/staging/r8188eu/include/odm_interface.h +++ b/drivers/staging/r8188eu/include/odm_interface.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __ODM_INTERFACE_H__ #define __ODM_INTERFACE_H__ diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index b2fbb5d5ea77..ff2dae597d5b 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ #ifndef __ODM_PRECOMP_H__ #define __ODM_PRECOMP_H__ diff --git a/drivers/staging/r8188eu/include/odm_reg.h b/drivers/staging/r8188eu/include/odm_reg.h index 4221855e333c..81e633fcc0ac 100644 --- a/drivers/staging/r8188eu/include/odm_reg.h +++ b/drivers/staging/r8188eu/include/odm_reg.h @@ -1,37 +1,10 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/* */ -/* File Name: odm_reg.h */ -/* */ -/* Description: */ -/* */ -/* This file is for general register definition. */ -/* */ -/* */ -/* */ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ + #ifndef __HAL_ODM_REG_H__ #define __HAL_ODM_REG_H__ -/* */ /* Register Definition */ -/* */ /* MAC REG */ #define ODM_BB_RESET 0x002 diff --git a/drivers/staging/r8188eu/include/odm_types.h b/drivers/staging/r8188eu/include/odm_types.h index f62d8b486a28..4a6c4d33e20e 100644 --- a/drivers/staging/r8188eu/include/odm_types.h +++ b/drivers/staging/r8188eu/include/odm_types.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __ODM_TYPES_H__ #define __ODM_TYPES_H__ diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h index c4599c583b59..b585c239c64e 100644 --- a/drivers/staging/r8188eu/include/osdep_intf.h +++ b/drivers/staging/r8188eu/include/osdep_intf.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __OSDEP_INTF_H_ #define __OSDEP_INTF_H_ diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index ce76a2c99bbd..5b08e985257a 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __OSDEP_SERVICE_H_ #define __OSDEP_SERVICE_H_ -- cgit v1.2.3 From b5f3122d22d581f3e037f73a300c12070b5b6b74 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 11:48:11 -0500 Subject: staging: r8188eu: Convert header copyright info to SPDX format, part 3 Before this driver can be incorporated in the drivers/net/wireless tree, the copyright info in all files must be converted to SPDX notation. This patch converts the next 49 files. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729164814.32097-4-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/recv_osdep.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_cmd.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_dm.h | 23 ++++------------------ drivers/staging/r8188eu/include/rtl8188e_hal.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_led.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_recv.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_rf.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_spec.h | 21 +++----------------- drivers/staging/r8188eu/include/rtl8188e_sreset.h | 22 +++------------------ drivers/staging/r8188eu/include/rtl8188e_xmit.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_android.h | 21 ++------------------ drivers/staging/r8188eu/include/rtw_ap.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_br_ext.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_cmd.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_debug.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_eeprom.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_efuse.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_event.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_ht.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_io.h | 21 ++------------------ drivers/staging/r8188eu/include/rtw_ioctl.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_ioctl_rtl.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_ioctl_set.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_iol.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_led.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_mlme.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_mlme_ext.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_mp.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_mp_ioctl.h | 22 +++------------------ .../staging/r8188eu/include/rtw_mp_phy_regdef.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_p2p.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_pwrctrl.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_qos.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_recv.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_rf.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_security.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_sreset.h | 22 +++------------------ drivers/staging/r8188eu/include/rtw_version.h | 1 + drivers/staging/r8188eu/include/rtw_xmit.h | 22 +++------------------ drivers/staging/r8188eu/include/sta_info.h | 22 +++------------------ drivers/staging/r8188eu/include/usb_hal.h | 22 +++------------------ drivers/staging/r8188eu/include/usb_ops.h | 22 +++------------------ drivers/staging/r8188eu/include/usb_ops_linux.h | 22 +++------------------ drivers/staging/r8188eu/include/usb_osintf.h | 22 +++------------------ drivers/staging/r8188eu/include/usb_vendor_req.h | 22 +++------------------ drivers/staging/r8188eu/include/wifi.h | 22 +++------------------ drivers/staging/r8188eu/include/wlan_bssdef.h | 22 +++------------------ drivers/staging/r8188eu/include/xmit_osdep.h | 22 +++------------------ 48 files changed, 141 insertions(+), 892 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/recv_osdep.h b/drivers/staging/r8188eu/include/recv_osdep.h index b6ddf0ba2dde..eebd06e6329e 100644 --- a/drivers/staging/r8188eu/include/recv_osdep.h +++ b/drivers/staging/r8188eu/include/recv_osdep.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RECV_OSDEP_H_ #define __RECV_OSDEP_H_ diff --git a/drivers/staging/r8188eu/include/rtl8188e_cmd.h b/drivers/staging/r8188eu/include/rtl8188e_cmd.h index b32bc28503d0..6fbf9a47430b 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_cmd.h +++ b/drivers/staging/r8188eu/include/rtl8188e_cmd.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_CMD_H__ #define __RTL8188E_CMD_H__ diff --git a/drivers/staging/r8188eu/include/rtl8188e_dm.h b/drivers/staging/r8188eu/include/rtl8188e_dm.h index 97a3175250ef..3ead20b321a9 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_dm.h +++ b/drivers/staging/r8188eu/include/rtl8188e_dm.h @@ -1,24 +1,9 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_DM_H__ #define __RTL8188E_DM_H__ + enum{ UP_LINK, DOWN_LINK, diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h index 09368a5cd6e8..ea879572d6e1 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_HAL_H__ #define __RTL8188E_HAL_H__ diff --git a/drivers/staging/r8188eu/include/rtl8188e_led.h b/drivers/staging/r8188eu/include/rtl8188e_led.h index 9cb03d6565d3..e1b4e078fd8b 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_led.h +++ b/drivers/staging/r8188eu/include/rtl8188e_led.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_LED_H__ #define __RTL8188E_LED_H__ diff --git a/drivers/staging/r8188eu/include/rtl8188e_recv.h b/drivers/staging/r8188eu/include/rtl8188e_recv.h index e2ef281c2c44..bc1d532592b9 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/r8188eu/include/rtl8188e_recv.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_RECV_H__ #define __RTL8188E_RECV_H__ diff --git a/drivers/staging/r8188eu/include/rtl8188e_rf.h b/drivers/staging/r8188eu/include/rtl8188e_rf.h index 0ebdc369b542..da6b7f8212a3 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_rf.h +++ b/drivers/staging/r8188eu/include/rtl8188e_rf.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_RF_H__ #define __RTL8188E_RF_H__ diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h index 3956f770a951..85e66d6ca2ba 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h @@ -1,21 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - *******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_SPEC_H__ #define __RTL8188E_SPEC_H__ diff --git a/drivers/staging/r8188eu/include/rtl8188e_sreset.h b/drivers/staging/r8188eu/include/rtl8188e_sreset.h index a29e69519794..6158ba19a920 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_sreset.h +++ b/drivers/staging/r8188eu/include/rtl8188e_sreset.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTL8188E_SRESET_H_ #define _RTL8188E_SRESET_H_ diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index 5e586058826d..e9b71de0d165 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTL8188E_XMIT_H__ #define __RTL8188E_XMIT_H__ diff --git a/drivers/staging/r8188eu/include/rtw_android.h b/drivers/staging/r8188eu/include/rtw_android.h index e85bf1ff01f8..f60cf1c82984 100644 --- a/drivers/staging/r8188eu/include/rtw_android.h +++ b/drivers/staging/r8188eu/include/rtw_android.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef __RTW_ANDROID_H__ #define __RTW_ANDROID_H__ diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h index bf3c9fb60153..3662941ce9a8 100644 --- a/drivers/staging/r8188eu/include/rtw_ap.h +++ b/drivers/staging/r8188eu/include/rtw_ap.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #ifndef __RTW_AP_H_ #define __RTW_AP_H_ diff --git a/drivers/staging/r8188eu/include/rtw_br_ext.h b/drivers/staging/r8188eu/include/rtw_br_ext.h index f21e7a4515d0..00d461c4c6fa 100644 --- a/drivers/staging/r8188eu/include/rtw_br_ext.h +++ b/drivers/staging/r8188eu/include/rtw_br_ext.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_BR_EXT_H_ #define _RTW_BR_EXT_H_ diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h index 357e732ac046..9eefafd7ad7d 100644 --- a/drivers/staging/r8188eu/include/rtw_cmd.h +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_CMD_H_ #define __RTW_CMD_H_ diff --git a/drivers/staging/r8188eu/include/rtw_debug.h b/drivers/staging/r8188eu/include/rtw_debug.h index d94639a8dc63..f8a969e339b1 100644 --- a/drivers/staging/r8188eu/include/rtw_debug.h +++ b/drivers/staging/r8188eu/include/rtw_debug.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_DEBUG_H__ #define __RTW_DEBUG_H__ diff --git a/drivers/staging/r8188eu/include/rtw_eeprom.h b/drivers/staging/r8188eu/include/rtw_eeprom.h index 0b27eb7325c5..dcd6b8523865 100644 --- a/drivers/staging/r8188eu/include/rtw_eeprom.h +++ b/drivers/staging/r8188eu/include/rtw_eeprom.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_EEPROM_H__ #define __RTW_EEPROM_H__ diff --git a/drivers/staging/r8188eu/include/rtw_efuse.h b/drivers/staging/r8188eu/include/rtw_efuse.h index cee6b5e8b070..60f9f59d1efd 100644 --- a/drivers/staging/r8188eu/include/rtw_efuse.h +++ b/drivers/staging/r8188eu/include/rtw_efuse.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_EFUSE_H__ #define __RTW_EFUSE_H__ diff --git a/drivers/staging/r8188eu/include/rtw_event.h b/drivers/staging/r8188eu/include/rtw_event.h index f7004d6a3bbb..c0fa91591b9e 100644 --- a/drivers/staging/r8188eu/include/rtw_event.h +++ b/drivers/staging/r8188eu/include/rtw_event.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_EVENT_H_ #define _RTW_EVENT_H_ diff --git a/drivers/staging/r8188eu/include/rtw_ht.h b/drivers/staging/r8188eu/include/rtw_ht.h index 80154224af92..b3a978e905d0 100644 --- a/drivers/staging/r8188eu/include/rtw_ht.h +++ b/drivers/staging/r8188eu/include/rtw_ht.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_HT_H_ #define _RTW_HT_H_ diff --git a/drivers/staging/r8188eu/include/rtw_io.h b/drivers/staging/r8188eu/include/rtw_io.h index d7dee537c252..e2aae349d8fd 100644 --- a/drivers/staging/r8188eu/include/rtw_io.h +++ b/drivers/staging/r8188eu/include/rtw_io.h @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #ifndef _RTW_IO_H_ #define _RTW_IO_H_ diff --git a/drivers/staging/r8188eu/include/rtw_ioctl.h b/drivers/staging/r8188eu/include/rtw_ioctl.h index 8ffa73239819..2cdeb244d23e 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_IOCTL_H_ #define _RTW_IOCTL_H_ diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h b/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h index 8fa3858cb776..18014dd8476f 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_IOCTL_RTL_H_ #define _RTW_IOCTL_RTL_H_ diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_set.h b/drivers/staging/r8188eu/include/rtw_ioctl_set.h index 794f98167c3c..2214cee35ae7 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl_set.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl_set.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_IOCTL_SET_H_ #define __RTW_IOCTL_SET_H_ diff --git a/drivers/staging/r8188eu/include/rtw_iol.h b/drivers/staging/r8188eu/include/rtw_iol.h index 6949922baa65..89668122a876 100644 --- a/drivers/staging/r8188eu/include/rtw_iol.h +++ b/drivers/staging/r8188eu/include/rtw_iol.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_IOL_H_ #define __RTW_IOL_H_ diff --git a/drivers/staging/r8188eu/include/rtw_led.h b/drivers/staging/r8188eu/include/rtw_led.h index 1e6a8090a753..128cdc10b9b5 100644 --- a/drivers/staging/r8188eu/include/rtw_led.h +++ b/drivers/staging/r8188eu/include/rtw_led.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_LED_H_ #define __RTW_LED_H_ diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index a53a567b2960..7cab18047cef 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_MLME_H_ #define __RTW_MLME_H_ diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index fdb79587762e..eaaedf7d7305 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_MLME_EXT_H_ #define __RTW_MLME_EXT_H_ diff --git a/drivers/staging/r8188eu/include/rtw_mp.h b/drivers/staging/r8188eu/include/rtw_mp.h index 9111e58e0598..c0974189e92d 100644 --- a/drivers/staging/r8188eu/include/rtw_mp.h +++ b/drivers/staging/r8188eu/include/rtw_mp.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_MP_H_ #define _RTW_MP_H_ diff --git a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h index 12835e448d80..b23ca88ceb9e 100644 --- a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_MP_IOCTL_H_ #define _RTW_MP_IOCTL_H_ diff --git a/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h b/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h index ae4c9df7f42a..c2be770a5f5d 100644 --- a/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h +++ b/drivers/staging/r8188eu/include/rtw_mp_phy_regdef.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + /***************************************************************************** * * Module: __RTW_MP_PHY_REGDEF_H_ diff --git a/drivers/staging/r8188eu/include/rtw_p2p.h b/drivers/staging/r8188eu/include/rtw_p2p.h index a3e3adc92b99..29f908f36598 100644 --- a/drivers/staging/r8188eu/include/rtw_p2p.h +++ b/drivers/staging/r8188eu/include/rtw_p2p.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_P2P_H_ #define __RTW_P2P_H_ diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h index 3db33cd9fee7..bd86666d0f66 100644 --- a/drivers/staging/r8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #ifndef __RTW_PWRCTRL_H_ #define __RTW_PWRCTRL_H_ diff --git a/drivers/staging/r8188eu/include/rtw_qos.h b/drivers/staging/r8188eu/include/rtw_qos.h index bbee1ddc00bb..3150e00b8d3a 100644 --- a/drivers/staging/r8188eu/include/rtw_qos.h +++ b/drivers/staging/r8188eu/include/rtw_qos.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_QOS_H_ #define _RTW_QOS_H_ diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index bc097ed7f966..9a81e66d93fd 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #ifndef _RTW_RECV_H_ #define _RTW_RECV_H_ diff --git a/drivers/staging/r8188eu/include/rtw_rf.h b/drivers/staging/r8188eu/include/rtw_rf.h index d4415e8115b2..17d34dead8e0 100644 --- a/drivers/staging/r8188eu/include/rtw_rf.h +++ b/drivers/staging/r8188eu/include/rtw_rf.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_RF_H_ #define __RTW_RF_H_ diff --git a/drivers/staging/r8188eu/include/rtw_security.h b/drivers/staging/r8188eu/include/rtw_security.h index c720ed1117db..6e039e87b04d 100644 --- a/drivers/staging/r8188eu/include/rtw_security.h +++ b/drivers/staging/r8188eu/include/rtw_security.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __RTW_SECURITY_H_ #define __RTW_SECURITY_H_ diff --git a/drivers/staging/r8188eu/include/rtw_sreset.h b/drivers/staging/r8188eu/include/rtw_sreset.h index 2a1244f75790..1ac7d566362a 100644 --- a/drivers/staging/r8188eu/include/rtw_sreset.h +++ b/drivers/staging/r8188eu/include/rtw_sreset.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #ifndef _RTW_SRESET_C_ #define _RTW_SRESET_C_ diff --git a/drivers/staging/r8188eu/include/rtw_version.h b/drivers/staging/r8188eu/include/rtw_version.h index 6d2d52cbb3d3..4ca74a9465fe 100644 --- a/drivers/staging/r8188eu/include/rtw_version.h +++ b/drivers/staging/r8188eu/include/rtw_version.h @@ -1 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ #define DRIVERVERSION "v4.1.4_6773.20130222" diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h index 5253dd0affd7..7155d3fa4bb5 100644 --- a/drivers/staging/r8188eu/include/rtw_xmit.h +++ b/drivers/staging/r8188eu/include/rtw_xmit.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _RTW_XMIT_H_ #define _RTW_XMIT_H_ diff --git a/drivers/staging/r8188eu/include/sta_info.h b/drivers/staging/r8188eu/include/sta_info.h index 3e909db1d41a..97233f85c4bd 100644 --- a/drivers/staging/r8188eu/include/sta_info.h +++ b/drivers/staging/r8188eu/include/sta_info.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __STA_INFO_H_ #define __STA_INFO_H_ diff --git a/drivers/staging/r8188eu/include/usb_hal.h b/drivers/staging/r8188eu/include/usb_hal.h index 8a65995d5e48..584602c40cca 100644 --- a/drivers/staging/r8188eu/include/usb_hal.h +++ b/drivers/staging/r8188eu/include/usb_hal.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __USB_HAL_H__ #define __USB_HAL_H__ diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index 6562082beb7a..40e834390a10 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __USB_OPS_H_ #define __USB_OPS_H_ diff --git a/drivers/staging/r8188eu/include/usb_ops_linux.h b/drivers/staging/r8188eu/include/usb_ops_linux.h index e5b758a81a5c..c357a3b1560e 100644 --- a/drivers/staging/r8188eu/include/usb_ops_linux.h +++ b/drivers/staging/r8188eu/include/usb_ops_linux.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __USB_OPS_LINUX_H__ #define __USB_OPS_LINUX_H__ diff --git a/drivers/staging/r8188eu/include/usb_osintf.h b/drivers/staging/r8188eu/include/usb_osintf.h index 9de99ca9799a..71f6273e69c5 100644 --- a/drivers/staging/r8188eu/include/usb_osintf.h +++ b/drivers/staging/r8188eu/include/usb_osintf.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __USB_OSINTF_H #define __USB_OSINTF_H diff --git a/drivers/staging/r8188eu/include/usb_vendor_req.h b/drivers/staging/r8188eu/include/usb_vendor_req.h index 04f1b9e267e1..7337b1b7419f 100644 --- a/drivers/staging/r8188eu/include/usb_vendor_req.h +++ b/drivers/staging/r8188eu/include/usb_vendor_req.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef _USB_VENDOR_REQUEST_H_ #define _USB_VENDOR_REQUEST_H_ diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h index 33a7e6c19d04..9760989ffc4c 100644 --- a/drivers/staging/r8188eu/include/wifi.h +++ b/drivers/staging/r8188eu/include/wifi.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #ifndef _WIFI_H_ #define _WIFI_H_ diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h index eae8bac175b2..bada3e168c42 100644 --- a/drivers/staging/r8188eu/include/wlan_bssdef.h +++ b/drivers/staging/r8188eu/include/wlan_bssdef.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __WLAN_BSSDEF_H__ #define __WLAN_BSSDEF_H__ diff --git a/drivers/staging/r8188eu/include/xmit_osdep.h b/drivers/staging/r8188eu/include/xmit_osdep.h index 2ff622ba24f0..4a6685d93582 100644 --- a/drivers/staging/r8188eu/include/xmit_osdep.h +++ b/drivers/staging/r8188eu/include/xmit_osdep.h @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #ifndef __XMIT_OSDEP_H_ #define __XMIT_OSDEP_H_ -- cgit v1.2.3 From 762b759a4232714f75bdcdf291a64003d5d3292f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 11:48:12 -0500 Subject: staging: r8188eu: Convert header copyright info to SPDX format, part 4 Before this driver can be incorporated in the drivers/net/wireless tree, the copyright info in all files must be converted to SPDX notation. This patch converts the 23 C source files in core/. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729164814.32097-5-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_br_ext.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_cmd.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_debug.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_efuse.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_ieee80211.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_io.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_iol.c | 21 ++------------------- drivers/staging/r8188eu/core/rtw_led.c | 21 ++------------------- drivers/staging/r8188eu/core/rtw_mlme.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_mp.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_p2p.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_recv.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_rf.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_security.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_sreset.c | 21 ++------------------- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_wlan_util.c | 22 +++------------------- drivers/staging/r8188eu/core/rtw_xmit.c | 22 +++------------------- 23 files changed, 66 insertions(+), 437 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index ba475a4933ec..407c62cf803c 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_AP_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 1236f50dc22f..e00302137a60 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ + #define _RTW_BR_EXT_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 3b76634f2090..0302aa101de6 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_CMD_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c index 47e5f7cf8453..522fd59c2d50 100644 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_DEBUG_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index 53b73f442699..216ec4036c1a 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_EFUSE_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index 7159ce4c1acd..7f98ffc7442d 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _IEEE80211_C #include diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index db593503e26e..ca7d27a24080 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + /* The purpose of rtw_io.c diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 78974325d8bd..34c27ecbd55a 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_IOCTL_SET_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index e6fdd32f9a3f..e93610d7c8c6 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 6422dc57853a..37c9766b4c64 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ #include #include "rtw_led.h" diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index a30c2bd69313..887e3a89bd27 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_MLME_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 6c420d5238a8..021044768b61 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_MLME_EXT_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 30bcac68f8e9..ece34de548f9 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - *published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_MP_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index 87c3f29b16ef..3dd7dff233ee 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_MP_IOCTL_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 2e21496fe71b..0c97c42eb420 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_P2P_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 50e8b5e6aed8..56980998e094 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_PWRCTRL_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 16a38a2fbe87..f3cbf71a3a4a 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_RECV_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c index 40c0f5aa0731..caa3d68d93e2 100644 --- a/drivers/staging/r8188eu/core/rtw_rf.c +++ b/drivers/staging/r8188eu/core/rtw_rf.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_RF_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 1da908694e18..5df970994e23 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_SECURITY_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_sreset.c b/drivers/staging/r8188eu/core/rtw_sreset.c index 298f75400c8f..a4705736a153 100644 --- a/drivers/staging/r8188eu/core/rtw_sreset.c +++ b/drivers/staging/r8188eu/core/rtw_sreset.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ #include diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 30a1dd369112..9a459eef861d 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTW_STA_MGT_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 335d6a2c93ec..738298ebbc3c 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_WLAN_UTIL_C_ #include diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 867cd3bbd135..27d82f91c8a7 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _RTW_XMIT_C_ #include -- cgit v1.2.3 From 8f97409846950db835a3c03f9accfd04c36daeea Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 11:48:13 -0500 Subject: staging: r8188eu: Convert header copyright info to SPDX format, part 5 Before this driver can be incorporated in the drivers/net/wireless tree, the copyright info in all files must be converted to SPDX notation. This patch converts the 9 C source files in os_dep/. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729164814.32097-6-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 22 +++------------------- drivers/staging/r8188eu/os_dep/mlme_linux.c | 21 ++------------------- drivers/staging/r8188eu/os_dep/os_intfs.c | 22 +++------------------- drivers/staging/r8188eu/os_dep/osdep_service.c | 21 ++------------------- drivers/staging/r8188eu/os_dep/recv_linux.c | 22 +++------------------- drivers/staging/r8188eu/os_dep/rtw_android.c | 21 ++------------------- drivers/staging/r8188eu/os_dep/usb_intf.c | 22 +++------------------- drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 21 +++------------------ drivers/staging/r8188eu/os_dep/xmit_linux.c | 22 +++------------------- 9 files changed, 24 insertions(+), 170 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index faced0d0af1d..37973930845d 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _IOCTL_LINUX_C_ #include diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index 97c2b62f8fd4..22d37e994101 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. i*/ #define _MLME_OSDEP_C_ diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 8c8ef9063b0c..2cf91516d739 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _OS_INTFS_C_ #include diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 541af56515ac..bec784dda81b 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ #define _OSDEP_SERVICE_C_ diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 44c5fcbafa6a..558050c62bb1 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RECV_OSDEP_C_ #include diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index a20d900d85ca..56fd19138218 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include #include diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index fd16afa1de33..9be70ed65072 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _HCI_INTF_C_ #include diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c index 9cce79d412b9..399d7d91eb4a 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -1,21 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _USB_OPS_LINUX_C_ #include diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index c6c5b2aabefb..622735148efb 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ + #define _XMIT_OSDEP_C_ #include -- cgit v1.2.3 From 19de0225b84838bcf98dbc2033efb3bd414b8e93 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 11:48:14 -0500 Subject: staging: r8188eu: Convert copyright header info to SPDX format, part 6 Before this driver can be incorporated in the drivers/net/wireless tree, the copyright info in all files must be converted to SPDX notation. This patch converts the C source files in hal/. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729164814.32097-7-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c | 21 ++-------------- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 5 ++-- drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 21 ++-------------- drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c | 21 ++-------------- drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 21 ++-------------- drivers/staging/r8188eu/hal/HalPhyRf.c | 21 ++-------------- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 22 ++--------------- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 23 +++--------------- drivers/staging/r8188eu/hal/hal_com.c | 22 +++-------------- drivers/staging/r8188eu/hal/hal_intf.c | 21 ++-------------- drivers/staging/r8188eu/hal/odm.c | 21 ++-------------- drivers/staging/r8188eu/hal/odm_HWConfig.c | 23 ++---------------- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 21 ++-------------- drivers/staging/r8188eu/hal/odm_RegConfig8188E.c | 21 ++-------------- drivers/staging/r8188eu/hal/odm_debug.c | 23 ++---------------- drivers/staging/r8188eu/hal/odm_interface.c | 21 ++-------------- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 28 +++------------------- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_sreset.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188e_xmit.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188eu_led.c | 21 ++-------------- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 22 +++-------------- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 22 +++-------------- drivers/staging/r8188eu/hal/usb_halinit.c | 22 +++-------------- drivers/staging/r8188eu/hal/usb_ops_linux.c | 22 +++-------------- 30 files changed, 75 insertions(+), 566 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c b/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c index fc23bf159345..7df715ab2f6e 100644 --- a/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c +++ b/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "Hal8188EPwrSeq.h" #include diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index e9b12128b6b1..8db90778ab6c 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -1,6 +1,5 @@ -/*++ -Copyright (c) Realtek Semiconductor Corp. All rights reserved. - +// SPDX-License-Identifier: GPL-2.0 +/* Copyright (c) Realtek Semiconductor Corp. Module Name: RateAdaptive.c diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c index f06c14cd4e04..5eaf79ae6c93 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c index bac0238e314c..dc9ef87af99a 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" #include diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c index b5d5050c0a17..b0df4eb8413d 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -1,22 +1,5 @@ -/****************************************************************************** -* -* Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of version 2 of the GNU General Public License as -* published by the Free Software Foundation. -* -* This program is distributed in the hope that it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., -* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA -* -* -******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/HalPhyRf.c b/drivers/staging/r8188eu/hal/HalPhyRf.c index 980f7da8ab3b..257940202f13 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index 8a7947d8de7f..af32210bf359 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -1,23 +1,5 @@ - -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index 5700dbce5b8c..77bb61ab9789 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -1,24 +1,7 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + /*++ -Copyright (c) Realtek Semiconductor Corp. All rights reserved. Module Name: HalPwrSeqCmd.c diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index 60ff30f1c3ac..9094aba21379 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #include #include diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index ce37c7594f2d..4dda247e386a 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2012 Realtek Corporation. */ #define _HAL_INTF_C_ #include diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 8b8754c42bc1..81fe727115d9 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ /* include files */ diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 523801cabb43..4c9317833fbc 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -1,24 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -/* include files */ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 858fc39de6aa..17dca886b17c 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c index 0ff31370fb98..132f5cbd0697 100644 --- a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/odm_debug.c b/drivers/staging/r8188eu/hal/odm_debug.c index 84caadd6c8e5..a969ba48ddb9 100644 --- a/drivers/staging/r8188eu/hal/odm_debug.c +++ b/drivers/staging/r8188eu/hal/odm_debug.c @@ -1,24 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ - -/* include files */ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index 3be5a5f8d873..8875a9954981 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include "odm_precomp.h" /* ODM IO Relative API. */ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index d60db45a6f0b..dc4d790837ce 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_CMD_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index 2590277b95ba..88ae9c5a8507 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -1,29 +1,7 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ -/* */ -/* Description: */ -/* */ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + /* This file is for 92CE/92CU dynamic mechanism only */ -/* */ -/* */ -/* */ #define _RTL8188E_DM_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index d9f115d187c9..af7977165c3c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _HAL_INIT_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index 66388902ab94..3937c1f5d588 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_MP_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index 36ad9dbbd8b0..f23e69ebee35 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_PHYCFG_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index 0ed6ff67ad57..0bba0130cfa6 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + /****************************************************************************** * * diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c index a07ad95ad84b..9ce6527cb75a 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_REDESC_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_sreset.c b/drivers/staging/r8188eu/hal/rtl8188e_sreset.c index 047b53482e67..88bc607b3698 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_sreset.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_sreset.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_SRESET_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c index 7ecbcf731ea9..fe32ba366338 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_XMIT_C_ #include diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_led.c b/drivers/staging/r8188eu/hal/rtl8188eu_led.c index 08dfd94163e6..29aee1345577 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_led.c @@ -1,22 +1,5 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ #include #include diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index ab0853ceeb61..7ca1a101e100 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188EU_RECV_C_ #include #include diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index 7f5d677b1d6f..ca543bdc119d 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _RTL8188E_XMIT_C_ #include #include diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 144cc5f6787d..8ecb94728462 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _HCI_HAL_INIT_C_ #include diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index d31f0be4c8a6..dd6138dfebb6 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -1,22 +1,6 @@ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - * This program is free software; you can redistribute it and/or modify it - * under the terms of version 2 of the GNU General Public License as - * published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - * more details. - * - * You should have received a copy of the GNU General Public License along with - * this program; if not, write to the Free Software Foundation, Inc., - * 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA - * - * - ******************************************************************************/ +// SPDX-License-Identifier: GPL-2.0 +/* Copyright(c) 2007 - 2011 Realtek Corporation. */ + #define _HCI_OPS_OS_C_ #include -- cgit v1.2.3 From 9a730283aec2d6e51f7cc923b04f2d279bc2313c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 12:09:25 -0500 Subject: staging: r8188eu: Remove empty header file File include/drv_types_linux.h is empty. Remove it. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729170930.23171-2-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/drv_types.h | 1 - drivers/staging/r8188eu/include/drv_types_linux.h | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/drv_types_linux.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index dce4c602ffe6..eed807d5dbc2 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -16,7 +16,6 @@ #include #include -#include #include #include #include diff --git a/drivers/staging/r8188eu/include/drv_types_linux.h b/drivers/staging/r8188eu/include/drv_types_linux.h deleted file mode 100644 index 068a7bcee82f..000000000000 --- a/drivers/staging/r8188eu/include/drv_types_linux.h +++ /dev/null @@ -1,7 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __DRV_TYPES_LINUX_H__ -#define __DRV_TYPES_LINUX_H__ - -#endif -- cgit v1.2.3 From efb8bc8683f20c9f80a9b3239934ccc85e7ed59a Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 12:09:26 -0500 Subject: staging: r8188eu: Remove tests of kernel version In the GitHub repository from which this driver was derived, old kernels had to be supported. Now that the driver is included in the kernel, this code can be removed as well as all mention of version.h. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729170930.23171-3-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_led.c | 12 ----- drivers/staging/r8188eu/core/rtw_p2p.c | 53 --------------------- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 12 ----- drivers/staging/r8188eu/core/rtw_recv.c | 16 ------- drivers/staging/r8188eu/core/rtw_xmit.c | 8 ---- drivers/staging/r8188eu/hal/odm.c | 9 ---- drivers/staging/r8188eu/hal/odm_interface.c | 10 ---- drivers/staging/r8188eu/include/odm_precomp.h | 4 -- drivers/staging/r8188eu/include/osdep_service.h | 12 ----- drivers/staging/r8188eu/include/rtw_led.h | 4 -- drivers/staging/r8188eu/include/rtw_mlme.h | 5 -- drivers/staging/r8188eu/include/rtw_security.h | 8 ---- drivers/staging/r8188eu/include/usb_ops.h | 16 ------- drivers/staging/r8188eu/include/wifi.h | 3 -- drivers/staging/r8188eu/os_dep/mlme_linux.c | 63 ------------------------- drivers/staging/r8188eu/os_dep/os_intfs.c | 1 - drivers/staging/r8188eu/os_dep/recv_linux.c | 16 ------- 17 files changed, 252 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 37c9766b4c64..ee90e52adc90 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -9,17 +9,9 @@ /* Callback function of LED BlinkTimer, */ /* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ /* */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) void BlinkTimerCallback(struct timer_list *t) -#else -void BlinkTimerCallback(void *data) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct LED_871x *pLed = from_timer(pLed, t, BlinkTimer); -#else - struct LED_871x *pLed = (struct LED_871x *)data; -#endif struct adapter *padapter = pLed->padapter; if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) @@ -69,11 +61,7 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_8 ResetLedStatus(pLed); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) timer_setup(&pLed->BlinkTimer, BlinkTimerCallback, 0); -#else - _init_timer(&(pLed->BlinkTimer), padapter->pnetdev, BlinkTimerCallback, pLed); -#endif _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed); } diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 0c97c42eb420..3ec988fad6ea 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1728,17 +1728,9 @@ exit: return res; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static void reset_ch_sitesurvey_timer_process(struct timer_list *t) -#else -static void reset_ch_sitesurvey_timer_process (void *FunctionContext) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer); -#else - struct adapter *adapter = (struct adapter *)FunctionContext; -#endif struct wifidirect_info *pwdinfo = &adapter->wdinfo; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) @@ -1750,17 +1742,9 @@ static void reset_ch_sitesurvey_timer_process (void *FunctionContext) pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static void reset_ch_sitesurvey_timer_process2 (struct timer_list *t) -#else -static void reset_ch_sitesurvey_timer_process2 (void *FunctionContext) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer); -#else - struct adapter *adapter = (struct adapter *)FunctionContext; -#endif struct wifidirect_info *pwdinfo = &adapter->wdinfo; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) @@ -1772,17 +1756,9 @@ static void reset_ch_sitesurvey_timer_process2 (void *FunctionContext) pwdinfo->p2p_info.scan_op_ch_only = 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static void restore_p2p_state_timer_process(struct timer_list *t) -#else -static void restore_p2p_state_timer_process (void *FunctionContext) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *adapter = from_timer(adapter, t, wdinfo.restore_p2p_state_timer); -#else - struct adapter *adapter = (struct adapter *)FunctionContext; -#endif struct wifidirect_info *pwdinfo = &adapter->wdinfo; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) @@ -1791,17 +1767,9 @@ static void restore_p2p_state_timer_process (void *FunctionContext) p2p_protocol_wk_cmd(adapter, P2P_RESTORE_STATE_WK); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static void pre_tx_scan_timer_process(struct timer_list *t) -#else -static void pre_tx_scan_timer_process(void *FunctionContext) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *adapter = from_timer(adapter, t, wdinfo.pre_tx_scan_timer); -#else - struct adapter *adapter = (struct adapter *)FunctionContext; -#endif struct wifidirect_info *pwdinfo = &adapter->wdinfo; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; @@ -1829,17 +1797,9 @@ static void pre_tx_scan_timer_process(void *FunctionContext) spin_unlock_bh(&pmlmepriv->lock); } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static void find_phase_timer_process(struct timer_list *t) -#else -static void find_phase_timer_process(void *FunctionContext) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *adapter = from_timer(adapter, t, wdinfo.find_phase_timer); -#else - struct adapter *adapter = (struct adapter *)FunctionContext; -#endif struct wifidirect_info *pwdinfo = &adapter->wdinfo; if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) @@ -1865,19 +1825,11 @@ void rtw_init_wifidirect_timers(struct adapter *padapter) { struct wifidirect_info *pwdinfo = &padapter->wdinfo; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) timer_setup(&pwdinfo->find_phase_timer, find_phase_timer_process, 0); timer_setup(&pwdinfo->restore_p2p_state_timer, restore_p2p_state_timer_process, 0); timer_setup(&pwdinfo->pre_tx_scan_timer, pre_tx_scan_timer_process, 0); timer_setup(&pwdinfo->reset_ch_sitesurvey, reset_ch_sitesurvey_timer_process, 0); timer_setup(&pwdinfo->reset_ch_sitesurvey2, reset_ch_sitesurvey_timer_process2, 0); -#else - _init_timer(&pwdinfo->find_phase_timer, padapter->pnetdev, find_phase_timer_process, padapter); - _init_timer(&pwdinfo->restore_p2p_state_timer, padapter->pnetdev, restore_p2p_state_timer_process, padapter); - _init_timer(&pwdinfo->pre_tx_scan_timer, padapter->pnetdev, pre_tx_scan_timer_process, padapter); - _init_timer(&pwdinfo->reset_ch_sitesurvey, padapter->pnetdev, reset_ch_sitesurvey_timer_process, padapter); - _init_timer(&pwdinfo->reset_ch_sitesurvey2, padapter->pnetdev, reset_ch_sitesurvey_timer_process2, padapter); -#endif } void rtw_init_wifidirect_addrs(struct adapter *padapter, u8 *dev_addr, u8 *iface_addr) @@ -2019,11 +1971,6 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) _cancel_timer_ex(&pwdinfo->pre_tx_scan_timer); _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey); _cancel_timer_ex(&pwdinfo->reset_ch_sitesurvey2); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) -#else - reset_ch_sitesurvey_timer_process(padapter); - reset_ch_sitesurvey_timer_process2(padapter); -#endif rtw_p2p_set_state(pwdinfo, P2P_STATE_NONE); rtw_p2p_set_role(pwdinfo, P2P_ROLE_DISABLE); memset(&pwdinfo->rx_prov_disc_info, 0x00, sizeof(struct rx_provdisc_req_info)); diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 56980998e094..a7b63413000b 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -192,19 +192,11 @@ exit: return; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) static void pwr_state_check_handler(struct timer_list *t) -#else -static void pwr_state_check_handler(void *FunctionContext) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *padapter = from_timer(padapter, t, pwrctrlpriv.pwr_state_check_timer); -#else - struct adapter *padapter = (struct adapter *)FunctionContext; -#endif rtw_ps_cmd(padapter); } @@ -492,11 +484,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->btcoex_rfon = false; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) timer_setup(&pwrctrlpriv->pwr_state_check_timer, pwr_state_check_handler, 0); -#else - _init_timer(&(pwrctrlpriv->pwr_state_check_timer), padapter->pnetdev, pwr_state_check_handler, (u8 *)padapter); -#endif } void rtw_free_pwrctrl_priv(struct adapter *adapter) diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index f3cbf71a3a4a..3872aa5cb982 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -25,11 +25,7 @@ static u8 rtw_rfc1042_header[] = { 0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00 }; -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) void rtw_signal_stat_timer_hdl(struct timer_list *); -#else -void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS); -#endif void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { @@ -91,11 +87,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) res = rtw_hal_init_recv_priv(padapter); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, 0); -#else - _init_timer(&precvpriv->signal_stat_timer, padapter->pnetdev, RTW_TIMER_HDL_NAME(signal_stat), padapter); -#endif precvpriv->signal_stat_sampling_interval = 1000; /* ms */ rtw_set_signal_stat_timer(precvpriv); @@ -2174,17 +2166,9 @@ _recv_entry_drop: return ret; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) void rtw_signal_stat_timer_hdl(struct timer_list *t) -#else -void rtw_signal_stat_timer_hdl(RTW_TIMER_HDL_ARGS) -#endif { -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) struct adapter *adapter = from_timer(adapter, t, recvpriv.signal_stat_timer); -#else - struct adapter *adapter = (struct adapter *)FunctionContext; -#endif struct recv_priv *recvpriv = &adapter->recvpriv; u32 tmp_s, tmp_q; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 27d82f91c8a7..c2a3d62facd1 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -1671,11 +1671,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) void *br_port = NULL; rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); -#else - br_port = rcu_dereference(padapter->pnetdev->br_port); -#endif rcu_read_unlock(); spin_lock_bh(&padapter->br_ext_lock); if (!(skb->data[0] & 1) && br_port && @@ -1859,11 +1855,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) } rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); -#else - br_port = rcu_dereference(padapter->pnetdev->br_port); -#endif rcu_read_unlock(); if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 81fe727115d9..a26b2ae35b73 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1563,12 +1563,7 @@ void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm) void ODM_InitAllTimers(struct odm_dm_struct *pDM_Odm) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - ODM_InitializeTimer(pDM_Odm, &pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, - (void *)odm_SwAntDivChkAntSwitchCallback, NULL, "SwAntennaSwitchTimer"); -#else timer_setup(&pDM_Odm->DM_SWAT_Table.SwAntennaSwitchTimer, odm_SwAntDivChkAntSwitchCallback, 0); -#endif } void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm) @@ -1677,11 +1672,7 @@ void ODM_SwAntDivRestAfterLink(struct odm_dm_struct *pDM_Odm) { } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext) -#else void odm_SwAntDivChkAntSwitchCallback(struct timer_list *t) -#endif { } diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index 8875a9954981..e26a6461e70b 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -160,16 +160,6 @@ void ODM_SetTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, u32 _set_timer(pTimer, msDelay); /* ms */ } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -void ODM_InitializeTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer, - void *CallBackFunc, void *pContext, - const char *szID) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - _init_timer(pTimer, Adapter->pnetdev, CallBackFunc, pDM_Odm); -} -#endif - void ODM_CancelTimer(struct odm_dm_struct *pDM_Odm, struct timer_list *pTimer) { _cancel_timer_ex(pTimer); diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index ff2dae597d5b..cec1035e4fe0 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -75,11 +75,7 @@ void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingCheckMP(struct odm_dm_struct *pDM_Odm); void odm_TXPowerTrackingCheckAP(struct odm_dm_struct *pDM_Odm); -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); -#else void odm_SwAntDivChkAntSwitchCallback(struct timer_list *t); -#endif void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm); void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 5b08e985257a..e61113c2608c 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -4,10 +4,7 @@ #ifndef __OSDEP_SERVICE_H_ #define __OSDEP_SERVICE_H_ -#include -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0) #include -#endif #include #define _FAIL 0 @@ -76,15 +73,6 @@ static inline void rtw_list_delete(struct list_head *plist) list_del_init(plist); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -static inline void _init_timer(struct timer_list *ptimer,struct net_device *nic_hdl,void *pfunc,void* cntx) -{ - ptimer->function = pfunc; - ptimer->data = (unsigned long)cntx; - init_timer(ptimer); -} -#endif - static inline void _set_timer(struct timer_list *ptimer,u32 delay_time) { mod_timer(ptimer , (jiffies+(delay_time*HZ/1000))); diff --git a/drivers/staging/r8188eu/include/rtw_led.h b/drivers/staging/r8188eu/include/rtw_led.h index 128cdc10b9b5..def9d04a20ce 100644 --- a/drivers/staging/r8188eu/include/rtw_led.h +++ b/drivers/staging/r8188eu/include/rtw_led.h @@ -163,11 +163,7 @@ struct led_priv{ (adapt)->ledpriv.LedControlHandler((adapt), (action)); \ } while (0) -#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0) void BlinkTimerCallback(struct timer_list *t); -#else -void BlinkTimerCallback(void *data); -#endif void BlinkWorkItemCallback(struct work_struct *work); void ResetLedStatus(struct LED_871x * pLed); diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index 7cab18047cef..3ef1a008c602 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -453,13 +453,8 @@ void indicate_wx_scan_complete_event(struct adapter *padapter); void rtw_indicate_wx_assoc_event(struct adapter *padapter); void rtw_indicate_wx_disassoc_event(struct adapter *padapter); int event_thread(void *context); -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -void rtw_join_timeout_handler (void *FunctionContext); -void _rtw_scan_timeout_handler(void *FunctionContext); -#else void rtw_join_timeout_handler (struct timer_list *t); void _rtw_scan_timeout_handler (struct timer_list *t); -#endif void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall); int rtw_init_mlme_priv(struct adapter *adapter); void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv); diff --git a/drivers/staging/r8188eu/include/rtw_security.h b/drivers/staging/r8188eu/include/rtw_security.h index 6e039e87b04d..2d8522c01027 100644 --- a/drivers/staging/r8188eu/include/rtw_security.h +++ b/drivers/staging/r8188eu/include/rtw_security.h @@ -152,14 +152,6 @@ struct security_priv { u8 bWepDefaultKeyIdxSet; }; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 8, 0) -struct sha256_state { - u64 length; - u32 state[8], curlen; - u8 buf[64]; -}; -#endif - #define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \ do { \ switch (psecuritypriv->dot11AuthAlgrthm) { \ diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index 40e834390a10..9e60b3a9a02a 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -4,7 +4,6 @@ #ifndef __USB_OPS_H_ #define __USB_OPS_H_ -#include #include #include #include @@ -22,7 +21,6 @@ enum { #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 12)) #define rtw_usb_control_msg(dev, pipe, request, requesttype, \ value, index, data, size, timeout_ms) \ usb_control_msg((dev), (pipe), (request), (requesttype), (value),\ @@ -30,20 +28,6 @@ enum { #define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ usb_bulk_msg((usb_dev), (pipe), (data), (len), \ (actual_length), (timeout_ms)) -#else -#define rtw_usb_control_msg(dev, pipe, request, requesttype, \ - value, index, data, size, timeout_ms) \ - usb_control_msg((dev), (pipe), (request), (requesttype), \ - (value), (index), (data), (size), \ - ((timeout_ms) == 0) || \ - ((timeout_ms)*HZ/1000 > 0) ? \ - ((timeout_ms)*HZ/1000) : 1) -#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, \ - actual_length, timeout_ms) \ - usb_bulk_msg((usb_dev), (pipe), (data), (len), (actual_length), \ - ((timeout_ms) == 0) || ((timeout_ms)*HZ/1000 > 0) ?\ - ((timeout_ms)*HZ/1000) : 1) -#endif #include void rtl8188eu_set_hw_type(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h index 9760989ffc4c..2c56d1d70d03 100644 --- a/drivers/staging/r8188eu/include/wifi.h +++ b/drivers/staging/r8188eu/include/wifi.h @@ -714,9 +714,6 @@ enum ht_cap_ampdu_factor { * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) */ #define IEEE80211_MIN_AMPDU_BUF 0x8 -#if (LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0)) -#define IEEE80211_MAX_AMPDU_BUF 0x40 -#endif /* Spatial Multiplexing Power Save Modes */ #define WLAN_HT_CAP_SM_PS_STATIC 0 diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index 22d37e994101..8d78b8697016 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -7,47 +7,23 @@ #include #include -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -void rtw_join_timeout_handler (void *FunctionContext) -#else void rtw_join_timeout_handler (struct timer_list *t) -#endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - struct adapter *adapter = (struct adapter *)FunctionContext; -#else struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer); -#endif _rtw_join_timeout_handler(adapter); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -void _rtw_scan_timeout_handler (void *FunctionContext) -#else void _rtw_scan_timeout_handler (struct timer_list *t) -#endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - struct adapter *adapter = (struct adapter *)FunctionContext; -#else struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer); -#endif rtw_scan_timeout_handler(adapter); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -static void _dynamic_check_timer_handlder(void *FunctionContext) -#else static void _dynamic_check_timer_handlder(struct timer_list *t) -#endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - struct adapter *adapter = (struct adapter *)FunctionContext; -#else struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer); -#endif if (adapter->registrypriv.mp_mode == 1) return; @@ -59,15 +35,9 @@ void rtw_init_mlme_timer(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - _init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, rtw_join_timeout_handler, padapter); - _init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, _rtw_scan_timeout_handler, padapter); - _init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter); -#else timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0); timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0); timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0); -#endif } void rtw_os_indicate_connect(struct adapter *adapter) @@ -169,69 +139,36 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) } } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -static void _survey_timer_hdl(void *FunctionContext) -#else static void _survey_timer_hdl(struct timer_list *t) -#endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - struct adapter *padapter = (struct adapter *)FunctionContext; -#else struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer); -#endif survey_timer_hdl(padapter); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -static void _link_timer_hdl(void *FunctionContext) -#else static void _link_timer_hdl(struct timer_list *t) -#endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - struct adapter *padapter = (struct adapter *)FunctionContext; -#else struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer); -#endif link_timer_hdl(padapter); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -static void _addba_timer_hdl(void *FunctionContext) -#else static void _addba_timer_hdl(struct timer_list *t) -#endif { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - struct sta_info *psta = (struct sta_info *)FunctionContext; -#else struct sta_info *psta = from_timer(psta, t, addba_retry_timer); -#endif addba_timer_hdl(psta); } void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) { -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - _init_timer(&psta->addba_retry_timer, padapter->pnetdev, _addba_timer_hdl, psta); -#else timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0); -#endif } void init_mlme_ext_timer(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - _init_timer(&pmlmeext->survey_timer, padapter->pnetdev, _survey_timer_hdl, padapter); - _init_timer(&pmlmeext->link_timer, padapter->pnetdev, _link_timer_hdl, padapter); -#else timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0); timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0); -#endif } #ifdef CONFIG_88EU_AP_MODE diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 2cf91516d739..454b94b037f3 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -3,7 +3,6 @@ #define _OS_INTFS_C_ -#include #include #include #include diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 558050c62bb1..5af8ffac870b 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -179,11 +179,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, } rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) rcu_dereference(padapter->pnetdev->rx_handler_data); -#else - rcu_dereference(padapter->pnetdev->br_port); -#endif rcu_read_unlock(); skb->ip_summed = CHECKSUM_NONE; @@ -226,19 +222,11 @@ void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf) (unsigned char *)precvbuf); } -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) -static void _rtw_reordering_ctrl_timeout_handler(void *func_context) -#else static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t) -#endif { struct recv_reorder_ctrl *preorder_ctrl; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - preorder_ctrl = (struct recv_reorder_ctrl *)func_context; -#else preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer); -#endif rtw_reordering_ctrl_timeout_handler(preorder_ctrl); } @@ -246,9 +234,5 @@ void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) { struct adapter *padapter = preorder_ctrl->padapter; -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0) - _init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl); -#else timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0); -#endif } -- cgit v1.2.3 From a14c876f76b5cdde6915f49d14ca421d0ae0c1ca Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 12:09:27 -0500 Subject: staging: r8188eu: Remove include/rtw_qos.h This header file merely defines a single struct. Move that definition to the header file that uses it, and delete rtw_qos.h. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729170930.23171-4-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/drv_types.h | 1 - drivers/staging/r8188eu/include/rtw_mlme.h | 6 ++++++ drivers/staging/r8188eu/include/rtw_qos.h | 14 -------------- 3 files changed, 6 insertions(+), 15 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/rtw_qos.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index eed807d5dbc2..0acc5847a602 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index 3ef1a008c602..d5b479ae7799 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -313,6 +313,12 @@ struct tdls_info { u8 enable; }; +struct qos_priv { + /* bit mask option: u-apsd, + * s-apsd, ts, block ack... */ + unsigned int qos_option; +}; + struct mlme_priv { spinlock_t lock; int fw_state; /* shall we protect this variable? maybe not necessarily... */ diff --git a/drivers/staging/r8188eu/include/rtw_qos.h b/drivers/staging/r8188eu/include/rtw_qos.h deleted file mode 100644 index 3150e00b8d3a..000000000000 --- a/drivers/staging/r8188eu/include/rtw_qos.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef _RTW_QOS_H_ -#define _RTW_QOS_H_ - -#include - -struct qos_priv { - unsigned int qos_option; /* bit mask option: u-apsd, - * s-apsd, ts, block ack... */ -}; - -#endif /* _RTL871X_QOS_H_ */ -- cgit v1.2.3 From 9f50d13fbb2bd02dcb16859c6f61c76399a7893d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 12:09:28 -0500 Subject: staging: r8188eu: Remove header file include/usb_hal.h This header only includes one prototype and one define statement. The new definition is used once, thus it can be removed. The prototype is moved to a header that is already called by the supplier and the user of that routine, thus the small header is removed. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729170930.23171-5-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/hal_intf.c | 1 - drivers/staging/r8188eu/hal/usb_halinit.c | 1 - drivers/staging/r8188eu/include/hal_intf.h | 1 + drivers/staging/r8188eu/include/usb_hal.h | 10 ---------- drivers/staging/r8188eu/os_dep/os_intfs.c | 1 - drivers/staging/r8188eu/os_dep/usb_intf.c | 3 +-- 6 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/usb_hal.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 4dda247e386a..02d76ac782d8 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -5,7 +5,6 @@ #include #include #include -#include void rtw_hal_chip_configure(struct adapter *adapt) { diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 8ecb94728462..f784d8dcdd34 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #define HAL_MAC_ENABLE 1 diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index c829aee518dd..d64fcda37100 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -309,6 +309,7 @@ enum hardware_type { #define is_boot_from_eeprom(adapter) (adapter->eeprompriv.EepromOrEfuse) +void rtl8188eu_set_hal_ops(struct adapter *padapter); void rtw_hal_def_value_init(struct adapter *padapter); void rtw_hal_free_data(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/usb_hal.h b/drivers/staging/r8188eu/include/usb_hal.h deleted file mode 100644 index 584602c40cca..000000000000 --- a/drivers/staging/r8188eu/include/usb_hal.h +++ /dev/null @@ -1,10 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __USB_HAL_H__ -#define __USB_HAL_H__ - -void rtl8188eu_set_hal_ops(struct adapter *padapter); -#define hal_set_hal_ops rtl8188eu_set_hal_ops - -#endif /* __USB_HAL_H__ */ diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 454b94b037f3..34af5237d9e6 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -12,7 +12,6 @@ #include #include -#include #include #include diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 9be70ed65072..905a08ebd80d 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -15,7 +15,6 @@ #include #include #include -#include #include int ui_pid[3] = {0, 0, 0}; @@ -628,7 +627,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, padapter = rtw_netdev_priv(pnetdev); /* step 2. hook HalFunc, allocate HalData */ - hal_set_hal_ops(padapter); + rtl8188eu_set_hal_ops(padapter); padapter->intf_start = &usb_intf_start; padapter->intf_stop = &usb_intf_stop; -- cgit v1.2.3 From 3cb9b23d8b16434e7ec3c086e885f5de63ee60ff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 12:09:29 -0500 Subject: staging: r8188eu: Remove header file include/rtw_version.h This file contains only the definition of the driver version. This statement is moved into a header called by all the affected source files, and the now empty header is deleted. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729170930.23171-6-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_debug.c | 2 +- drivers/staging/r8188eu/include/drv_types.h | 2 ++ drivers/staging/r8188eu/include/rtw_version.h | 2 -- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 1 - drivers/staging/r8188eu/os_dep/os_intfs.c | 1 - drivers/staging/r8188eu/os_dep/usb_intf.c | 1 - 6 files changed, 3 insertions(+), 6 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/rtw_version.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c index 522fd59c2d50..a0ca61d8c3b8 100644 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -4,7 +4,7 @@ #define _RTW_DEBUG_C_ #include -#include +#include int proc_get_drv_version(char *page, char **start, off_t offset, int count, diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index 0acc5847a602..d407d9274a78 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -38,6 +38,8 @@ #include #include +#define DRIVERVERSION "v4.1.4_6773.20130222" + enum _NIC_VERSION { RTL8711_NIC, RTL8712_NIC, diff --git a/drivers/staging/r8188eu/include/rtw_version.h b/drivers/staging/r8188eu/include/rtw_version.h deleted file mode 100644 index 4ca74a9465fe..000000000000 --- a/drivers/staging/r8188eu/include/rtw_version.h +++ /dev/null @@ -1,2 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -#define DRIVERVERSION "v4.1.4_6773.20130222" diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 37973930845d..109389549435 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -14,7 +14,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 34af5237d9e6..cf92dc2a4fcc 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 905a08ebd80d..7db33946e418 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -8,7 +8,6 @@ #include #include #include -#include #include #include -- cgit v1.2.3 From 38baa95e55483108aa14bcf36374d93ed19ea2a4 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 12:09:30 -0500 Subject: staging: r8188eu: Add "fallthrough" statement to quiet compiler Compiler gcc11, and possibly others, emit a warning when a fall-through case is found in a switch statement. Add a "fallthrough" statement to eliminate this warning. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210729170930.23171-7-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 021044768b61..488a18133e59 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -460,7 +460,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) ptable->func = &OnAuth; else ptable->func = &OnAuthClient; - /* fall through */ + fallthrough; case WIFI_ASSOCREQ: case WIFI_REASSOCREQ: _mgt_dispatcher(padapter, ptable, precv_frame); -- cgit v1.2.3 From b5385c77a71c48414c3f8caf777bf277f42d1516 Mon Sep 17 00:00:00 2001 From: Agam Kohli Date: Thu, 29 Jul 2021 14:12:08 -0400 Subject: Staging: rt18712: hal_init: removed filename from beginning comment block Fixed a coding style issue Signed-off-by: Agam Kohli Link: https://lore.kernel.org/r/YQLveNI2UrnpeeAt@Agam.localdomain Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8712/hal_init.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8712/hal_init.c b/drivers/staging/rtl8712/hal_init.c index 22974277afa0..dc138fe7d2de 100644 --- a/drivers/staging/rtl8712/hal_init.c +++ b/drivers/staging/rtl8712/hal_init.c @@ -1,6 +1,5 @@ // SPDX-License-Identifier: GPL-2.0 /****************************************************************************** - * hal_init.c * * Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved. * Linux device driver for RTL8192SU -- cgit v1.2.3 From f5d845be9d1fbeef22173053660ba010b9704c36 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 29 Jul 2021 19:38:22 -0500 Subject: staging: r8188eu: Fix sleeping function called from invalid context The driver can call rtw_addbareq_cmd() from an interrupt routine. resulting in the following splat: [21760.582207] BUG: sleeping function called from invalid context at include/linux/sched/mm.h:201 [21760.582219] in_atomic(): 1, irqs_disabled(): 0, non_block: 0, pid: 0, name: swapper/0 [21760.582224] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G C O 5.14.0-rc2-00135-g774ba5f0db67 #3 [21760.582228] Hardware name: TOSHIBA TECRA A50-A/TECRA A50-A, BIOS Version 4.50 09/29/2014 [21760.582230] Call Trace: [21760.582232] [21760.582233] dump_stack_lvl+0x34/0x44 [21760.582245] ? rtw_addbareq_cmd+0x2a/0xba [r8188eu] [21760.582306] ___might_sleep.cold+0x88/0x95 [21760.582311] kmem_cache_alloc_trace+0x25a/0x2d0 [21760.582315] rtw_addbareq_cmd+0x2a/0xba [r8188eu] [21760.582368] rtw_issue_addbareq_cmd+0xda/0x17f [r8188eu] [21760.582404] rtw_dump_xframe+0xa6/0x266 [r8188eu] [21760.582433] xmitframe_direct+0x40/0x57 [r8188eu] [21760.582459] pre_xmitframe+0x72/0x110 [r8188eu] [21760.582485] rtl8188eu_hal_xmit+0xa/0xb [r8188eu] [21760.582508] rtw_hal_xmit+0x1b/0x1c [r8188eu] [21760.582539] rtw_xmit+0xd6/0x1cb [r8188eu] [21760.582564] rtw_xmit_entry+0xe4/0x1d2 [r8188eu] [21760.582584] xmit_one.constprop.0+0x98/0x170 [21760.582588] dev_hard_start_xmit+0x40/0x90 [21760.582591] sch_direct_xmit+0xfa/0x230 [21760.582596] __dev_xmit_skb+0x27c/0x530 [21760.582598] __dev_queue_xmit+0x327/0x4e0 [21760.582602] ip_finish_output2+0x279/0x5c0 [21760.582605] __ip_queue_xmit+0x167/0x3f0 [21760.582607] __tcp_transmit_skb+0x4ff/0x9a0 [21760.582610] tcp_rcv_established+0x5c1/0x6f0 [21760.582613] tcp_v4_do_rcv+0x13e/0x240 [21760.582616] tcp_v4_rcv+0xbad/0xc70 [21760.582618] ? ip_rcv_finish_core.constprop.0+0x13c/0x2f0 [21760.582621] ip_protocol_deliver_rcu+0x30/0x1f0 [21760.582623] ip_local_deliver_finish+0x4b/0x60 [21760.582625] __netif_receive_skb_one_core+0x63/0x90 [21760.582628] process_backlog+0x8f/0x140 [21760.582631] __napi_poll+0x2e/0x180 [21760.582634] net_rx_action+0x11b/0x260 [21760.582637] __do_softirq+0xcb/0x2f5 [21760.582640] irq_exit_rcu+0x9e/0xc0 [21760.582643] common_interrupt+0x83/0xa0 [21760.582647] [21760.582647] asm_common_interrupt+0x1e/0x40 [21760.582650] RIP: 0010:cpuidle_enter_state+0xdf/0x5c0 [21760.582655] Code: 49 89 c6 0f 1f 44 00 00 31 ff e8 4c a1 98 ff 45 84 ff 74 12 9c 58 f6 c4 02 0f 85 10 03 00 00 31 ff e8 d5 73 9f ff fb 45 85 ed <0f> 88 59 01 00 00 4d 63 e5 49 83 fc 09 0f 87 05 04 00 00 4b 8d 04 Fix by changing kmalloc() flags argument from GFP_KERNEL to GFP_ATOMIC. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210730003822.12471-1-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 0302aa101de6..159346d97110 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -1240,13 +1240,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) struct addBaReq_parm *paddbareq_parm; u8 res = _SUCCESS; - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (ph2c == NULL) { res = _FAIL; goto exit; } - paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_KERNEL); + paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC); if (paddbareq_parm == NULL) { kfree(ph2c); res = _FAIL; -- cgit v1.2.3 From 40791b94c1b784b4ed8c5dc4a27f2a337fb066fc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 30 Jul 2021 11:09:46 +0200 Subject: staging: r8188eu: rename odm_EVMdbToPercentage() Rename odm_EVMdbToPercentage() to avoid camel case. odm_EVMdbToPercentage() -> odm_evm_db_to_percentage() Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210730090948.32759-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_HWConfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 4c9317833fbc..6afe3f9bc47c 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -77,7 +77,7 @@ static u8 odm_SQ_process_patch_RT_CID_819x_Lenovo(struct odm_dm_struct *dm_odm, return 0; } -static u8 odm_EVMdbToPercentage(s8 Value) +static u8 odm_evm_db_to_percentage(s8 Value) { /* -33dB~0dB to 0%~99% */ s8 ret_val; @@ -338,7 +338,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ - EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ + EVM = odm_evm_db_to_percentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ if (pPktinfo->bPacketMatchBSSID) { if (i == RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ -- cgit v1.2.3 From 6342a4fa1a188dae1f13f729fd333229681062ca Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 30 Jul 2021 11:09:47 +0200 Subject: staging: r8188eu: rename parameter of odm_evm_db_to_percentage() Rename parameter of odm_evm_db_to_percentage() to avoid camel case. Value -> value Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210730090948.32759-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_HWConfig.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 6afe3f9bc47c..51ae02805149 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -77,12 +77,12 @@ static u8 odm_SQ_process_patch_RT_CID_819x_Lenovo(struct odm_dm_struct *dm_odm, return 0; } -static u8 odm_evm_db_to_percentage(s8 Value) +static u8 odm_evm_db_to_percentage(s8 value) { /* -33dB~0dB to 0%~99% */ s8 ret_val; - ret_val = Value; + ret_val = value; if (ret_val >= 0) ret_val = 0; -- cgit v1.2.3 From 7bfeeb4f065dc5ccf793cafbc110be064ae682ab Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 30 Jul 2021 11:09:48 +0200 Subject: staging: r8188eu: simplify odm_evm_db_to_percentage() Use clamp() to simplify odm_evm_db_to_percentage(). Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210730090948.32759-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_HWConfig.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 51ae02805149..19222c0eddf7 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -80,20 +80,11 @@ static u8 odm_SQ_process_patch_RT_CID_819x_Lenovo(struct odm_dm_struct *dm_odm, static u8 odm_evm_db_to_percentage(s8 value) { /* -33dB~0dB to 0%~99% */ - s8 ret_val; - - ret_val = value; - - if (ret_val >= 0) - ret_val = 0; - if (ret_val <= -33) - ret_val = -33; - - ret_val = 0 - ret_val; - ret_val *= 3; + s8 ret_val = clamp(-value, 0, 33) * 3; if (ret_val == 99) ret_val = 100; + return ret_val; } -- cgit v1.2.3 From f52cc32dee4f5eb807237202819d80079a2483a6 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 30 Jul 2021 12:37:15 +0200 Subject: staging: r8188eu: Replace a custom function with crc32_le() Use crc32_le() in place of the custom getcrc32(). Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210730103716.27210-2-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_security.c | 74 ++++++++++++++--------------- 1 file changed, 35 insertions(+), 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 5df970994e23..9625beea4b3c 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -111,29 +111,15 @@ static void crc32_init(void) } } -static __le32 getcrc32(u8 *buf, int len) -{ - u8 *p; - u32 crc; - - if (bcrc32initialized == 0) - crc32_init(); - - crc = 0xffffffff; /* preload shift register, per CRC-32 spec */ - - for (p = buf; len > 0; ++p, --len) - crc = crc32_table[(crc ^ *p) & 0xff] ^ (crc >> 8); - - return cpu_to_le32(~crc); /* transmit complement, per CRC-32 spec */ -} - /* Need to consider the fragment situation */ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) { /* exclude ICV */ - - unsigned char crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; struct arc4context mycontext; int curfragnum, length; @@ -167,17 +153,17 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = getcrc32(payload, length); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, wepkey, 3+keylength); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - *((__le32 *)crc) = getcrc32(payload, length); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, wepkey, 3+keylength); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((size_t)(pframe)); @@ -190,7 +176,10 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) { /* exclude ICV */ - u8 crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; struct arc4context mycontext; int length; u32 keylength; @@ -217,12 +206,12 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) arcfour_encrypt(&mycontext, payload, payload, length); /* calculate icv and compare the icv */ - *((__le32 *)crc) = getcrc32(payload, length - 4); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - if (crc[3] != payload[length-1] || - crc[2] != payload[length-2] || - crc[1] != payload[length-3] || - crc[0] != payload[length-4]) { + if (crc.f1[3] != payload[length-1] || + crc.f1[2] != payload[length-2] || + crc.f1[1] != payload[length-3] || + crc.f1[0] != payload[length-4]) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", &crc, &payload[length-4])); @@ -574,7 +563,10 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) u32 pnh; u8 rc4key[16]; u8 ttkey[16]; - u8 crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; u8 hw_hdr_offset = 0; struct arc4context mycontext; int curfragnum, length; @@ -624,17 +616,18 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) RT_TRACE(_module_rtl871x_security_c_, _drv_info_, ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", pattrib->iv_len, pattrib->icv_len)); - *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; - *((__le32 *)crc) = getcrc32(payload, length);/* modified by Amy*/ + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); + arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc, 4); + arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((size_t)(pframe)); @@ -656,7 +649,10 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) u32 pnh; u8 rc4key[16]; u8 ttkey[16]; - u8 crc[4]; + union { + __le32 f0; + u8 f1[4]; + } crc; struct arc4context mycontext; int length; @@ -702,12 +698,12 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - *((__le32 *)crc) = getcrc32(payload, length-4); + crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - if (crc[3] != payload[length-1] || - crc[2] != payload[length-2] || - crc[1] != payload[length-3] || - crc[0] != payload[length-4]) { + if (crc.f1[3] != payload[length-1] || + crc.f1[2] != payload[length-2] || + crc.f1[1] != payload[length-3] || + crc.f1[0] != payload[length-4]) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", &crc, &payload[length-4])); -- cgit v1.2.3 From 792a00c16597415e8058c1f4ff8226866e8accf8 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 30 Jul 2021 12:37:16 +0200 Subject: staging: r8188eu: Remove no more used functions and variables Remove the functions and variables from rtw_security.c that are no more necessary since the patch that replaces getcrc32() with crc32_le(). Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210730103716.27210-3-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_security.c | 37 ----------------------------- 1 file changed, 37 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 9625beea4b3c..136ba1e61dca 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -74,43 +74,6 @@ static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 } -static int bcrc32initialized; -static u32 crc32_table[256]; - -static u8 crc32_reverseBit(u8 data) -{ - return (u8)((data<<7)&0x80) | ((data<<5)&0x40) | ((data<<3)&0x20) | - ((data<<1)&0x10) | ((data>>1)&0x08) | ((data>>3)&0x04) | - ((data>>5)&0x02) | ((data>>7)&0x01); -} - -static void crc32_init(void) -{ - if (bcrc32initialized == 1) { - return; - } else { - int i, j; - u32 c; - u8 *p = (u8 *)&c, *p1; - u8 k; - - c = 0x12340000; - - for (i = 0; i < 256; ++i) { - k = crc32_reverseBit((u8)i); - for (c = ((u32)k) << 24, j = 8; j > 0; --j) - c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1); - p1 = (u8 *)&crc32_table[i]; - - p1[0] = crc32_reverseBit(p[3]); - p1[1] = crc32_reverseBit(p[2]); - p1[2] = crc32_reverseBit(p[1]); - p1[3] = crc32_reverseBit(p[0]); - } - bcrc32initialized = 1; - } -} - /* Need to consider the fragment situation */ -- cgit v1.2.3 From d8062f6adca1ef13a0bab70ddcd67881d483338e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 30 Jul 2021 15:02:04 +0200 Subject: staging: r8188eu: clean up comparsions to NULL in os_dep directory Clean up comparsions to NULL in the os_dep directory reported by checkpatch. x == NULL -> !x x != NULL -> x Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210730130204.18229-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 108 ++++++++++++------------- drivers/staging/r8188eu/os_dep/mlme_linux.c | 4 +- drivers/staging/r8188eu/os_dep/os_intfs.c | 12 +-- drivers/staging/r8188eu/os_dep/osdep_service.c | 6 +- drivers/staging/r8188eu/os_dep/recv_linux.c | 4 +- drivers/staging/r8188eu/os_dep/usb_intf.c | 12 +-- drivers/staging/r8188eu/os_dep/xmit_linux.c | 4 +- 7 files changed, 75 insertions(+), 75 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 109389549435..100369a79666 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -523,7 +523,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); - if (pwep == NULL) { + if (!pwep) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; } @@ -564,7 +564,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_MP_STATE)) { /* sta mode */ psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); - if (psta == NULL) { + if (!psta) { ; } else { if (strcmp(param->u.crypt.alg, "none") != 0) @@ -603,7 +603,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, } } pbcmc_sta = rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta == NULL) { + if (!pbcmc_sta) { ; } else { /* Jeff: don't disable ieee8021x_blocked while clearing key */ @@ -633,9 +633,9 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ - if ((ielen > MAX_WPA_IE_LEN) || (pie == NULL)) { + if (ielen > MAX_WPA_IE_LEN || !pie) { _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); - if (pie == NULL) + if (!pie) return ret; else return -EINVAL; @@ -643,7 +643,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie if (ielen) { buf = rtw_zmalloc(ielen); - if (buf == NULL) { + if (!buf) { ret = -ENOMEM; goto exit; } @@ -1217,7 +1217,7 @@ static int rtw_wx_set_mlme(struct net_device *dev, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct iw_mlme *mlme = (struct iw_mlme *)extra; - if (mlme == NULL) + if (!mlme) return -1; DBG_88E("%s\n", __func__); @@ -2110,7 +2110,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, param_len = sizeof(struct ieee_param) + pext->key_len; param = (struct ieee_param *)rtw_malloc(param_len); - if (param == NULL) + if (!param) return -1; memset(param, 0, param_len); @@ -2465,7 +2465,7 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info bset = (u8)(p->flags & 0xFFFF); len = p->length; pparmbuf = (u8 *)rtw_malloc(len); - if (pparmbuf == NULL) { + if (!pparmbuf) { ret = -ENOMEM; goto _rtw_mp_ioctl_hdl_exit; } @@ -2562,7 +2562,7 @@ static int rtw_get_ap_info(struct net_device *dev, DBG_88E("+rtw_get_aplist_info\n"); - if ((padapter->bDriverStopped) || (pdata == NULL)) { + if (padapter->bDriverStopped || !pdata) { ret = -EINVAL; goto exit; } @@ -2641,7 +2641,7 @@ static int rtw_set_pid(struct net_device *dev, int *pdata = (int *)wrqu; int selector; - if ((padapter->bDriverStopped) || (pdata == NULL)) { + if (padapter->bDriverStopped || !pdata) { ret = -EINVAL; goto exit; } @@ -2673,7 +2673,7 @@ static int rtw_wps_start(struct net_device *dev, goto exit; } - if ((padapter->bDriverStopped) || (pdata == NULL)) { + if (padapter->bDriverStopped || !pdata) { ret = -EINVAL; goto exit; } @@ -4161,7 +4161,7 @@ static int rtw_dbg_port(struct net_device *dev, struct xmit_frame *xmit_frame; xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { + if (!xmit_frame) { ret = -ENOMEM; break; } @@ -4181,7 +4181,7 @@ static int rtw_dbg_port(struct net_device *dev, struct xmit_frame *xmit_frame; xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { + if (!xmit_frame) { ret = -ENOMEM; break; } @@ -4207,7 +4207,7 @@ static int rtw_dbg_port(struct net_device *dev, struct xmit_frame *xmit_frame; xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { + if (!xmit_frame) { ret = -ENOMEM; break; } @@ -4236,7 +4236,7 @@ static int rtw_dbg_port(struct net_device *dev, struct xmit_frame *xmit_frame; xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { + if (!xmit_frame) { ret = -ENOMEM; break; } @@ -4264,7 +4264,7 @@ static int rtw_dbg_port(struct net_device *dev, struct xmit_frame *xmit_frame; xmit_frame = rtw_IOL_accquire_xmit_frame(padapter); - if (xmit_frame == NULL) { + if (!xmit_frame) { ret = -ENOMEM; break; } @@ -4702,7 +4702,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) } param = (struct ieee_param *)rtw_malloc(p->length); - if (param == NULL) { + if (!param) { ret = -ENOMEM; goto out; } @@ -4756,13 +4756,13 @@ static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) u8 res = _SUCCESS; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); - if (psetstakey_para == NULL) { + if (!psetstakey_para) { kfree(ph2c); res = _FAIL; goto exit; @@ -4794,12 +4794,12 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) DBG_88E("%s\n", __func__); pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; goto exit; } psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); - if (psetkeyparm == NULL) { + if (!psetkeyparm) { kfree(pcmd); res = _FAIL; goto exit; @@ -4895,13 +4895,13 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, } } - if (strcmp(param->u.crypt.alg, "none") == 0 && (psta == NULL)) { + if (strcmp(param->u.crypt.alg, "none") == 0 && !psta) { /* todo:clear default encryption keys */ DBG_88E("clear default encryption keys, keyid =%d\n", param->u.crypt.idx); goto exit; } - if (strcmp(param->u.crypt.alg, "WEP") == 0 && (psta == NULL)) { + if (strcmp(param->u.crypt.alg, "WEP") == 0 && !psta) { DBG_88E("r871x_set_encryption, crypt.alg = WEP\n"); wep_key_idx = param->u.crypt.idx; wep_key_len = param->u.crypt.key_len; @@ -4915,7 +4915,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); - if (pwep == NULL) { + if (!pwep) { DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); goto exit; } @@ -5344,7 +5344,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, if (ie_len > 0) { pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); pmlmepriv->wps_beacon_ie_len = ie_len; - if (pmlmepriv->wps_beacon_ie == NULL) { + if (!pmlmepriv->wps_beacon_ie) { DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); return -EINVAL; } @@ -5381,7 +5381,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par if (ie_len > 0) { pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_probe_resp_ie_len = ie_len; - if (pmlmepriv->wps_probe_resp_ie == NULL) { + if (!pmlmepriv->wps_probe_resp_ie) { DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); return -EINVAL; } @@ -5413,7 +5413,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par if (ie_len > 0) { pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); pmlmepriv->wps_assoc_resp_ie_len = ie_len; - if (pmlmepriv->wps_assoc_resp_ie == NULL) { + if (!pmlmepriv->wps_assoc_resp_ie) { DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); return -EINVAL; } @@ -5519,7 +5519,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) } param = (struct ieee_param *)rtw_malloc(p->length); - if (param == NULL) { + if (!param) { ret = -ENOMEM; goto out; } @@ -5629,7 +5629,7 @@ static int rtw_wx_set_priv(struct net_device *dev, pmlmepriv->wps_probe_req_ie = NULL; pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); - if (pmlmepriv->wps_probe_req_ie == NULL) { + if (!pmlmepriv->wps_probe_req_ie) { pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); ret = -EINVAL; goto FREE_EXT; @@ -5703,12 +5703,12 @@ static int rtw_mp_efuse_get(struct net_device *dev, err = 0; data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); - if (data == NULL) { + if (!data) { err = -ENOMEM; goto exit; } rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); - if (rawdata == NULL) { + if (!rawdata) { err = -ENOMEM; goto exit; } @@ -5772,7 +5772,7 @@ static int rtw_mp_efuse_get(struct net_device *dev, sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "rmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { DBG_88E("%s: rmap Fail!! Parameters error!\n", __func__); err = -EINVAL; goto exit; @@ -5911,7 +5911,7 @@ static int rtw_mp_efuse_get(struct net_device *dev, sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "btrmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { err = -EINVAL; goto exit; } @@ -6018,22 +6018,22 @@ static int rtw_mp_efuse_set(struct net_device *dev, pEfuseHal = &haldata->EfuseHal; err = 0; setdata = _rtw_zmalloc(1024); - if (setdata == NULL) { + if (!setdata) { err = -ENOMEM; goto exit; } ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); - if (ShadowMapBT == NULL) { + if (!ShadowMapBT) { err = -ENOMEM; goto exit; } ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); - if (ShadowMapWiFi == NULL) { + if (!ShadowMapWiFi) { err = -ENOMEM; goto exit; } setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); - if (setrawdata == NULL) { + if (!setrawdata) { err = -ENOMEM; goto exit; } @@ -6058,7 +6058,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, /* tmp[0],[1],[2] */ /* wmap, addr, 00e04c871200 */ if (strcmp(tmp[0], "wmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { err = -EINVAL; goto exit; } @@ -6097,7 +6097,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } } else if (strcmp(tmp[0], "wraw") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { err = -EINVAL; goto exit; } @@ -6129,7 +6129,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } } else if (strcmp(tmp[0], "mac") == 0) { - if (tmp[1] == NULL) { + if (!tmp[1]) { err = -EINVAL; goto exit; } @@ -6172,7 +6172,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } } else if (strcmp(tmp[0], "vidpid") == 0) { - if (tmp[1] == NULL) { + if (!tmp[1]) { err = -EINVAL; goto exit; } @@ -6210,7 +6210,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } } else if (strcmp(tmp[0], "btwmap") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { err = -EINVAL; goto exit; } @@ -6249,7 +6249,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } } else if (strcmp(tmp[0], "btwfake") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { err = -EINVAL; goto exit; } @@ -6315,7 +6315,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, goto exit; } } else if (strcmp(tmp[0], "wlwfake") == 0) { - if ((tmp[1] == NULL) || (tmp[2] == NULL)) { + if (!tmp[1] || !tmp[2]) { err = -EINVAL; goto exit; } @@ -6376,14 +6376,14 @@ static int rtw_mp_write_reg(struct net_device *dev, pch = extra; pnext = strpbrk(pch, ",.-"); - if (pnext == NULL) + if (!pnext) return -EINVAL; *pnext = 0; width_str = pch; pch = pnext + 1; pnext = strpbrk(pch, ",.-"); - if (pnext == NULL) + if (!pnext) return -EINVAL; *pnext = 0; addr = simple_strtoul(pch, &ptmp, 16); @@ -6462,7 +6462,7 @@ static int rtw_mp_read_reg(struct net_device *dev, pch = input; pnext = strpbrk(pch, ",.-"); - if (pnext == NULL) { + if (!pnext) { kfree(input); return -EINVAL; } @@ -7350,10 +7350,10 @@ static int rtw_mp_set(struct net_device *dev, u32 subcmd = wrqu->flags; struct adapter *padapter = rtw_netdev_priv(dev); - if (padapter == NULL) + if (!padapter) return -ENETDOWN; - if (extra == NULL) { + if (!extra) { wrqu->length = 0; return -EIO; } @@ -7396,9 +7396,9 @@ static int rtw_mp_get(struct net_device *dev, u32 subcmd = wrqu->flags; struct adapter *padapter = rtw_netdev_priv(dev); - if (padapter == NULL) + if (!padapter) return -ENETDOWN; - if (extra == NULL) { + if (!extra) { wrqu->length = 0; return -EIO; } @@ -7515,7 +7515,7 @@ static int rtw_test( len = wrqu->data.length; pbuf = (u8 *)rtw_zmalloc(len); - if (pbuf == NULL) { + if (!pbuf) { DBG_88E("%s: no memory!\n", __func__); return -ENOMEM; } @@ -7529,7 +7529,7 @@ static int rtw_test( ptmp = (char *)pbuf; pch = strsep(&ptmp, delim); - if ((pch == NULL) || (strlen(pch) == 0)) { + if (!pch || strlen(pch) == 0) { kfree(pbuf); DBG_88E("%s: parameter error(level 1)!\n", __func__); return -EFAULT; diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index 8d78b8697016..fe434c8c167c 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -178,7 +178,7 @@ void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *pst union iwreq_data wrqu; struct sta_priv *pstapriv = &padapter->stapriv; - if (psta == NULL) + if (!psta) return; if (psta->aid > NUM_STA) @@ -201,7 +201,7 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info * union iwreq_data wrqu; struct sta_priv *pstapriv = &padapter->stapriv; - if (psta == NULL) + if (!psta) return; if (psta->aid > NUM_STA) diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index cf92dc2a4fcc..fa20d0f753db 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -175,11 +175,11 @@ void rtw_proc_init_one(struct net_device *dev) struct adapter *padapter = rtw_netdev_priv(dev); u8 rf_type; - if (rtw_proc == NULL) { + if (!rtw_proc) { memcpy(rtw_proc_name, DRV_NAME, sizeof(DRV_NAME)); rtw_proc = create_proc_entry(rtw_proc_name, S_IFDIR, init_net.proc_net); - if (rtw_proc == NULL) { + if (!rtw_proc) { DBG_88E(KERN_ERR "Unable to create rtw_proc directory\n"); return; } @@ -191,12 +191,12 @@ void rtw_proc_init_one(struct net_device *dev) } } - if (padapter->dir_dev == NULL) { + if (!padapter->dir_dev) { padapter->dir_dev = create_proc_entry(dev->name, S_IFDIR | S_IRUGO | S_IXUGO, rtw_proc); dir_dev = padapter->dir_dev; - if (dir_dev == NULL) { + if (!dir_dev) { if (rtw_proc_cnt == 0) { if (rtw_proc) { remove_proc_entry(rtw_proc_name, init_net.proc_net); @@ -721,7 +721,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); - if (old_padapter != NULL) + if (old_padapter) pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); else pnetdev = rtw_alloc_etherdev(sizeof(struct adapter)); @@ -1007,7 +1007,7 @@ u8 rtw_free_drv_sw(struct adapter *padapter) } /* clear pbuddystruct adapter to avoid access wrong pointer. */ - if (padapter->pbuddy_adapter != NULL) + if (padapter->pbuddy_adapter) padapter->pbuddy_adapter->pbuddy_adapter = NULL; RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n")); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index bec784dda81b..66db8d6907d2 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -48,7 +48,7 @@ inline u8 *_rtw_zvmalloc(u32 sz) { u8 *pbuf; pbuf = _rtw_vmalloc(sz); - if (pbuf != NULL) + if (pbuf) memset(pbuf, 0, sz); return pbuf; } @@ -70,7 +70,7 @@ u8 *_rtw_zmalloc(u32 sz) { u8 *pbuf = _rtw_malloc(sz); - if (pbuf != NULL) + if (pbuf) memset(pbuf, 0, sz); return pbuf; } @@ -80,7 +80,7 @@ void *rtw_malloc2d(int h, int w, int size) int j; void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size); - if (a == NULL) { + if (!a) { pr_info("%s: alloc memory fail!\n", __func__); return NULL; } diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 5af8ffac870b..410bfbb8a187 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -42,7 +42,7 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, precvbuf->irp_pending = false; precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); - if (precvbuf->purb == NULL) + if (!precvbuf->purb) res = _FAIL; precvbuf->pskb = NULL; precvbuf->reuse = false; @@ -118,7 +118,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, pfree_recv_queue = &(precvpriv->free_recv_queue); skb = precv_frame->pkt; - if (skb == NULL) { + if (!skb) { RT_TRACE(_module_recv_osdep_c_, _drv_err_, ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); goto _recv_indicatepkt_drop; diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 7db33946e418..314a3504168e 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -120,7 +120,7 @@ static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) _rtw_mutex_init(&dvobj->usb_vendor_req_mutex); dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); - if (dvobj->usb_alloc_vendor_req_buf == NULL) { + if (!dvobj->usb_alloc_vendor_req_buf) { DBG_88E("alloc usb_vendor_req_buf failed... /n"); rst = _FAIL; goto exit; @@ -152,7 +152,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_device *pusbd; pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); - if (pdvobjpriv == NULL) + if (!pdvobjpriv) goto exit; pdvobjpriv->pusbintf = usb_intf; @@ -603,7 +603,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, int status = _FAIL; padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter)); - if (padapter == NULL) + if (!padapter) goto exit; padapter->dvobj = dvobj; dvobj->if1 = padapter; @@ -620,7 +620,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, goto free_adapter; pnetdev = rtw_init_netdev(padapter); - if (pnetdev == NULL) + if (!pnetdev) goto handle_dualmac; SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); padapter = rtw_netdev_priv(pnetdev); @@ -753,14 +753,14 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); - if (dvobj == NULL) { + if (!dvobj) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("initialize device object priv Failed!\n")); goto exit; } if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid); - if (if1 == NULL) { + if (!if1) { DBG_88E("rtw_init_primarystruct adapter Failed!\n"); goto free_dvobj; } diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 622735148efb..c82ae1fdd0d2 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -78,7 +78,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb int i; pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); - if (pxmitbuf->pallocated_buf == NULL) + if (!pxmitbuf->pallocated_buf) return _FAIL; pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ); @@ -86,7 +86,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb for (i = 0; i < 8; i++) { pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); - if (pxmitbuf->pxmit_urb[i] == NULL) { + if (!pxmitbuf->pxmit_urb[i]) { DBG_88E("pxmitbuf->pxmit_urb[i]==NULL"); return _FAIL; } -- cgit v1.2.3 From 658dfbec96620ff08ef17c87b35b6a6bb8d52fc0 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Fri, 30 Jul 2021 15:40:48 +0200 Subject: staging: rtl8723bs: remove unused BIT macros definitions BIT(x) macro used all over the driver is defined in include/vsdo/bit.h as - #define BIT(nr) (UL(1) << (nr)) which is safer than the local BIT macros declared. Local macros shift a signed integer which brings unespected results. For example: (unsigned long)(1 << 31) => 0xffffffff80000000 shift.c: int main() { printf("%lx\n", (unsigned long)(1 << 31)); printf("%lx\n", (unsigned long)(1U << 31)); return 0; } ... $ ./shift ffffffff80000000 80000000 ... So just remove redundant, less safe macro declarations. Suggested-by: David Sterba Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/20210730134048.8736-1-fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/osdep_service.h | 4 ---- drivers/staging/rtl8723bs/include/wifi.h | 8 -------- 2 files changed, 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/osdep_service.h b/drivers/staging/rtl8723bs/include/osdep_service.h index b49838c7e457..bde415db4114 100644 --- a/drivers/staging/rtl8723bs/include/osdep_service.h +++ b/drivers/staging/rtl8723bs/include/osdep_service.h @@ -14,10 +14,6 @@ #include -#ifndef BIT - #define BIT(x) (1 << (x)) -#endif - #define BIT0 0x00000001 #define BIT1 0x00000002 #define BIT2 0x00000004 diff --git a/drivers/staging/rtl8723bs/include/wifi.h b/drivers/staging/rtl8723bs/include/wifi.h index 0bd7b662b972..f03e26818d45 100644 --- a/drivers/staging/rtl8723bs/include/wifi.h +++ b/drivers/staging/rtl8723bs/include/wifi.h @@ -7,14 +7,6 @@ #ifndef _WIFI_H_ #define _WIFI_H_ - -#ifdef BIT -/* error "BIT define occurred earlier elsewhere!\n" */ -#undef BIT -#endif -#define BIT(x) (1 << (x)) - - #define WLAN_ETHHDR_LEN 14 #define WLAN_ETHADDR_LEN 6 #define WLAN_IEEE_OUI_LEN 3 -- cgit v1.2.3 From cea32de203f2dc4eccd4dc3d9ef0f833efe534d1 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:06 +0200 Subject: staging: r8188eu: remove empty ODM_ResetIQKResult() function ODM_ResetIQKResult() is empty and does nothing, so remove it. Link: https://lore.kernel.org/r/20210730092417.1014392-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/HalPhyRf.c | 4 ---- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 2 -- drivers/staging/r8188eu/include/HalPhyRf.h | 2 -- drivers/staging/r8188eu/include/odm.h | 2 -- 4 files changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/HalPhyRf.c b/drivers/staging/r8188eu/hal/HalPhyRf.c index 257940202f13..1805fdfbad48 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf.c @@ -7,10 +7,6 @@ /* 3 IQ Calibration */ /* 3============================================================ */ -void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm) -{ -} - u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) { u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index af32210bf359..df9bd4cdf575 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -437,8 +437,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( } if (delta_IQK >= 8) { /* Delta temperature is equal to or larger than 20 centigrade. */ - ODM_ResetIQKResult(dm_odm); - dm_odm->RFCalibrateInfo.ThermalValue_IQK = ThermalValue; PHY_IQCalibrate_8188E(Adapter, false); } diff --git a/drivers/staging/r8188eu/include/HalPhyRf.h b/drivers/staging/r8188eu/include/HalPhyRf.h index ba3b6133fc13..54af312509a0 100644 --- a/drivers/staging/r8188eu/include/HalPhyRf.h +++ b/drivers/staging/r8188eu/include/HalPhyRf.h @@ -6,8 +6,6 @@ #define ODM_TARGET_CHNL_NUM_2G_5G 59 -void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); - u8 ODM_GetRightChnlPlaceforIQK(u8 chnl); #endif /* #ifndef __HAL_PHY_RF_H__ */ diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index 8c1d15eed259..15827b6a5729 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -1151,8 +1151,6 @@ void ODM_CancelAllTimers(struct odm_dm_struct *pDM_Odm); void ODM_ReleaseAllTimers(struct odm_dm_struct *pDM_Odm); -void ODM_ResetIQKResult(struct odm_dm_struct *pDM_Odm); - void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, u32 PWDBAll, bool isCCKrate); -- cgit v1.2.3 From 67431f25259aec381c8d3b983718d7fcb892d49f Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:07 +0200 Subject: staging: r8188eu: move ODM_TARGET_CHNL_NUM_2G_5G The ODM_TARGET_CHNL_NUM_2G_5G define is only used in one place, so move it to the .c file it is used in instead of being in a .h file. Link: https://lore.kernel.org/r/20210730092417.1014392-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/HalPhyRf.c | 2 ++ drivers/staging/r8188eu/include/HalPhyRf.h | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/HalPhyRf.c b/drivers/staging/r8188eu/hal/HalPhyRf.c index 1805fdfbad48..e5a58ee156b7 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf.c @@ -7,6 +7,8 @@ /* 3 IQ Calibration */ /* 3============================================================ */ +#define ODM_TARGET_CHNL_NUM_2G_5G 59 + u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) { u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { diff --git a/drivers/staging/r8188eu/include/HalPhyRf.h b/drivers/staging/r8188eu/include/HalPhyRf.h index 54af312509a0..ba877eb7e801 100644 --- a/drivers/staging/r8188eu/include/HalPhyRf.h +++ b/drivers/staging/r8188eu/include/HalPhyRf.h @@ -4,8 +4,6 @@ #ifndef __HAL_PHY_RF_H__ #define __HAL_PHY_RF_H__ -#define ODM_TARGET_CHNL_NUM_2G_5G 59 - u8 ODM_GetRightChnlPlaceforIQK(u8 chnl); #endif /* #ifndef __HAL_PHY_RF_H__ */ -- cgit v1.2.3 From f624b4f1cae3383d843b8044522f46e13eec4482 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:08 +0200 Subject: staging: r8188eu: move ODM_GetRightChnlPlaceforIQK() ODM_GetRightChnlPlaceforIQK() is only called in one place, so move the call to the single location and make the file static. This lets us remove the hal/HalPhyRf.c and include/HalPhyRf.h files as they are now empty. Link: https://lore.kernel.org/r/20210730092417.1014392-3-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Makefile | 1 - drivers/staging/r8188eu/hal/HalPhyRf.c | 30 --------------------------- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 21 +++++++++++++++++++ drivers/staging/r8188eu/include/HalPhyRf.h | 9 -------- drivers/staging/r8188eu/include/odm_precomp.h | 1 - 5 files changed, 21 insertions(+), 41 deletions(-) delete mode 100644 drivers/staging/r8188eu/hal/HalPhyRf.c delete mode 100644 drivers/staging/r8188eu/include/HalPhyRf.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index 6db1376e9768..ea455b0939bf 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -28,7 +28,6 @@ OUTSRC_FILES := \ hal/HalHWImg8188E_MAC.o \ hal/HalHWImg8188E_BB.o \ hal/HalHWImg8188E_RF.o \ - hal/HalPhyRf.o \ hal/HalPhyRf_8188e.o \ hal/HalPwrSeqCmd.o \ hal/Hal8188EPwrSeq.o \ diff --git a/drivers/staging/r8188eu/hal/HalPhyRf.c b/drivers/staging/r8188eu/hal/HalPhyRf.c deleted file mode 100644 index e5a58ee156b7..000000000000 --- a/drivers/staging/r8188eu/hal/HalPhyRf.c +++ /dev/null @@ -1,30 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - - #include "odm_precomp.h" - -/* 3============================================================ */ -/* 3 IQ Calibration */ -/* 3============================================================ */ - -#define ODM_TARGET_CHNL_NUM_2G_5G 59 - -u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) -{ - u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, - 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, - 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, - 155, 157, 159, 161, 163, 165 - }; - u8 place = chnl; - - if (chnl > 14) { - for (place = 14; place < sizeof(channel_all); place++) { - if (channel_all[place] == chnl) - return place-13; - } - } - return 0; -} diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index df9bd4cdf575..8b34842b4a30 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -1199,6 +1199,27 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_IQCalibrate_8188E() <==\n")); } +#define ODM_TARGET_CHNL_NUM_2G_5G 59 +static u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) +{ + u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, + 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, + 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, + 155, 157, 159, 161, 163, 165 + }; + u8 place = chnl; + + if (chnl > 14) { + for (place = 14; place < sizeof(channel_all); place++) { + if (channel_all[place] == chnl) + return place-13; + } + } + return 0; +} + static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) { u8 tmpreg; diff --git a/drivers/staging/r8188eu/include/HalPhyRf.h b/drivers/staging/r8188eu/include/HalPhyRf.h deleted file mode 100644 index ba877eb7e801..000000000000 --- a/drivers/staging/r8188eu/include/HalPhyRf.h +++ /dev/null @@ -1,9 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __HAL_PHY_RF_H__ -#define __HAL_PHY_RF_H__ - -u8 ODM_GetRightChnlPlaceforIQK(u8 chnl); - -#endif /* #ifndef __HAL_PHY_RF_H__ */ diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index cec1035e4fe0..7e5db893c1ea 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -22,7 +22,6 @@ #include "odm_RegDefine11AC.h" #include "odm_RegDefine11N.h" -#include "HalPhyRf.h" #include "HalPhyRf_8188e.h"/* for IQK,LCK,Power-tracking */ #include "Hal8188ERateAdaptive.h"/* for RA,Power training */ #include "rtl8188e_hal.h" -- cgit v1.2.3 From 099a6ee02488d5a98f8e10d82aaa8213af897fcc Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:09 +0200 Subject: staging: r8188eu: remove include/h2clbk.h No one uses this file, so remove it from the tree. Link: https://lore.kernel.org/r/20210730092417.1014392-4-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/h2clbk.h | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/h2clbk.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/h2clbk.h b/drivers/staging/r8188eu/include/h2clbk.h deleted file mode 100644 index 412b611760b3..000000000000 --- a/drivers/staging/r8188eu/include/h2clbk.h +++ /dev/null @@ -1,15 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#define _H2CLBK_H_ - -#include -#include - -void _lbk_cmd(struct adapter *adapter); - -void _lbk_rsp(struct adapter *adapter); - -void _lbk_evt(IN struct adapter *adapter); - -void h2c_event_callback(unsigned char *dev, unsigned char *pbuf); -- cgit v1.2.3 From 4cd1746aa746916db5aa5e351dcbfd54f2538637 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:10 +0200 Subject: staging: r8188eu: remove include/autoconf.h No one uses this file, so just remove it. Also remove the pointless Makefile rule that was attempting to create it. Link: https://lore.kernel.org/r/20210730092417.1014392-5-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Makefile | 7 ------- drivers/staging/r8188eu/include/autoconf.h | 26 -------------------------- 2 files changed, 33 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/autoconf.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index ea455b0939bf..a97cced2e61a 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -15,8 +15,6 @@ EXTRA_CFLAGS += -I$(src)/include ccflags-y += -D__CHECK_ENDIAN__ -CONFIG_AUTOCFG_CP = n - CONFIG_R8188EU = m CONFIG_USB_HCI = y @@ -72,11 +70,6 @@ _OS_INTFS_FILES := \ _HAL_INTFS_FILES += $(OUTSRC_FILES) -ifeq ($(CONFIG_AUTOCFG_CP), y) - -$(shell cp $(TopDIR)/autoconf_rtl8188e_usb_linux.h $(TopDIR)/include/autoconf.h) -endif - ifeq ($(CONFIG_BT_COEXIST), y) EXTRA_CFLAGS += -DCONFIG_BT_COEXIST endif diff --git a/drivers/staging/r8188eu/include/autoconf.h b/drivers/staging/r8188eu/include/autoconf.h deleted file mode 100644 index fcbfc60fad5a..000000000000 --- a/drivers/staging/r8188eu/include/autoconf.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation.*/ - -/* temporarily flag ******* */ -/* - * Public General Config - */ -#define RTL871X_MODULE_NAME "88EU" -#define DRV_NAME "rtl8188eu" - -/* - * Internal General Config - */ - -#define CONFIG_AP_MODE - -#define CONFIG_P2P - -#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ - -#define CONFIG_BR_EXT_BRNAME "br0" - -/* - * Debug Related Config - */ -#define DBG 1 -- cgit v1.2.3 From b3e8e29bc262def7540a4979888ef96c85924b49 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:11 +0200 Subject: staging: r8188eu: remove include/Hal8188EReg.h No one is using the defines in this file, so remove it as it is not needed anywhere. Link: https://lore.kernel.org/r/20210730092417.1014392-6-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/Hal8188EReg.h | 19 ------------------- drivers/staging/r8188eu/include/odm_precomp.h | 1 - 2 files changed, 20 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/Hal8188EReg.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/Hal8188EReg.h b/drivers/staging/r8188eu/include/Hal8188EReg.h deleted file mode 100644 index e04fae68fa4b..000000000000 --- a/drivers/staging/r8188eu/include/Hal8188EReg.h +++ /dev/null @@ -1,19 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __HAL_8188E_REG_H__ -#define __HAL_8188E_REG_H__ - -/* */ -/* Register Definition */ -/* */ -#define TRX_ANTDIV_PATH 0x860 -#define RX_ANTDIV_PATH 0xb2c -#define ODM_R_A_AGC_CORE1_8188E 0xc50 - -/* */ -/* Bitmap Definition */ -/* */ -#define BIT_FA_RESET_8188E BIT0 - -#endif diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index 7e5db893c1ea..b3d8f6463658 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -32,7 +32,6 @@ #include "HalHWImg8188E_MAC.h" #include "HalHWImg8188E_RF.h" #include "HalHWImg8188E_BB.h" -#include "Hal8188EReg.h" #include "odm_RegConfig8188E.h" #include "odm_RTL8188E.h" -- cgit v1.2.3 From b6f700b4b12ea3abcde3726de7483190a06c9ddd Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:12 +0200 Subject: staging: r8188eu: remove rtw_mfree2d() function It is just a wrapper around kfree(), so remove it and just call kfree() instead. Link: https://lore.kernel.org/r/20210730092417.1014392-7-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 8 ++------ drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 3 files changed, 2 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index af7977165c3c..02ba495b6d2c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -187,9 +187,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) exit: kfree(efuseTbl); - - if (eFuseWord) - rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + kfree(eFuseWord); } static void efuse_read_phymap_from_txpktbuf( @@ -921,9 +919,7 @@ static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, exit: kfree(efuseTbl); - - if (eFuseWord) - rtw_mfree2d((void *)eFuseWord, EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + kfree(eFuseWord); } static void ReadEFuseByIC(struct adapter *Adapter, u8 efuseType, u16 _offset, u16 _size_byte, u8 *pbuf, bool bPseudoTest) diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index e61113c2608c..ac45eec75153 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -226,7 +226,6 @@ void _rtw_mfree(u8 *pbuf, u32 sz); #define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) void *rtw_malloc2d(int h, int w, int size); -void rtw_mfree2d(void *pbuf, int h, int w, int size); u32 _rtw_down_sema(struct semaphore *sema); void _rtw_mutex_init(struct mutex *pmutex); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 66db8d6907d2..526e8d2d49a7 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -91,11 +91,6 @@ void *rtw_malloc2d(int h, int w, int size) return a; } -void rtw_mfree2d(void *pbuf, int h, int w, int size) -{ - kfree(pbuf); -} - /* For the following list_xxx operations, caller must guarantee the atomic context. -- cgit v1.2.3 From c7e88ecbe328e2bcd892d84c4b26eff86cb776ef Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:13 +0200 Subject: staging: r8188eu: remove rtw_buf_free() function It is just a wrapper around kfree(), so just replace all calls with kfree() instead. The pointer is also set to NULL and the length set to 0 to emulate the original logic, just to be "safe" as I do not have a device to test with, but odds are that can be removed later on. Link: https://lore.kernel.org/r/20210730092417.1014392-8-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 8 ++++++-- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 11 ++++++++--- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 7 ------- 4 files changed, 14 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 887e3a89bd27..8266e9a88e01 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -102,8 +102,12 @@ static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) { - rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + kfree(&pmlmepriv->assoc_req); + pmlmepriv->assoc_req = NULL; + pmlmepriv->assoc_req_len = 0; + kfree(&pmlmepriv->assoc_rsp); + pmlmepriv->assoc_rsp = NULL; + pmlmepriv->assoc_rsp_len = 0; rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 488a18133e59..36b4e073d24c 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -1522,7 +1522,9 @@ report_assoc_result: if (res > 0) { rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); } else { - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + kfree(&pmlmepriv->assoc_rsp); + pmlmepriv->assoc_rsp = NULL; + pmlmepriv->assoc_rsp_len = 0; } report_join_res(padapter, res); @@ -5549,8 +5551,11 @@ void issue_assocreq(struct adapter *padapter) exit: if (ret == _SUCCESS) rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); - else - rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + else { + kfree(&pmlmepriv->assoc_req); + pmlmepriv->assoc_req = NULL; + pmlmepriv->assoc_req_len = 0; + } return; } diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index ac45eec75153..df59fa325e6e 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -440,7 +440,6 @@ u64 rtw_division64(u64 x, u64 y); (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ (((u64) (a)[1]) << 8) | ((u64) (a)[0])) -void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); struct rtw_cbuf { diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 526e8d2d49a7..c7e83c87ad4a 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -388,13 +388,6 @@ u64 rtw_division64(u64 x, u64 y) return x; } -void rtw_buf_free(u8 **buf, u32 *buf_len) -{ - *buf_len = 0; - kfree(*buf); - *buf = NULL; -} - void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) { u32 ori_len = 0, dup_len = 0; -- cgit v1.2.3 From 3130547cac53835fa8d7d56f772f8dab2ad69fd7 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:14 +0200 Subject: staging: r8188eu: remove unused enum _NIC_VERSION None of these enumerated values were used anywhere in the driver, so just remove them all. Link: https://lore.kernel.org/r/20210730092417.1014392-9-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/drv_types.h | 7 ------- 1 file changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index d407d9274a78..d8faea4f6045 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -40,13 +40,6 @@ #define DRIVERVERSION "v4.1.4_6773.20130222" -enum _NIC_VERSION { - RTL8711_NIC, - RTL8712_NIC, - RTL8713_NIC, - RTL8716_NIC -}; - #define SPEC_DEV_ID_NONE BIT(0) #define SPEC_DEV_ID_DISABLE_HT BIT(1) #define SPEC_DEV_ID_ENABLE_PS BIT(2) -- cgit v1.2.3 From 18e94ed5f99cde4874b83b9f9f4b1895aea84990 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:15 +0200 Subject: staging: r8188eu: remove include/nic_spec.h No one was including this file, so just remove it. Link: https://lore.kernel.org/r/20210730092417.1014392-10-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/nic_spec.h | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/nic_spec.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/nic_spec.h b/drivers/staging/r8188eu/include/nic_spec.h deleted file mode 100644 index 77e865398fd1..000000000000 --- a/drivers/staging/r8188eu/include/nic_spec.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __NIC_SPEC_H__ -#define __NIC_SPEC_H__ - -#define RTL8711_MCTRL_ (0x20000) -#define RTL8711_UART_ (0x30000) -#define RTL8711_TIMER_ (0x40000) -#define RTL8711_FINT_ (0x50000) -#define RTL8711_HINT_ (0x50000) -#define RTL8711_GPIO_ (0x60000) -#define RTL8711_WLANCTRL_ (0x200000) -#define RTL8711_WLANFF_ (0xe00000) -#define RTL8711_HCICTRL_ (0x600000) -#define RTL8711_SYSCFG_ (0x620000) -#define RTL8711_SYSCTRL_ (0x620000) -#define RTL8711_MCCTRL_ (0x020000) - -#include - -#include - -#endif /* __RTL8711_SPEC_H__ */ -- cgit v1.2.3 From 48f1f36ae153e3e83680ad3d0e65be2d7f8dfd89 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:16 +0200 Subject: staging: r8188eu: remove rtw_usb_bulk_msg() macro No one is using this wrapper macro, so just remove it as it is pointless. Link: https://lore.kernel.org/r/20210730092417.1014392-11-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/usb_ops.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index 9e60b3a9a02a..d5b31e31b62d 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -25,9 +25,6 @@ enum { value, index, data, size, timeout_ms) \ usb_control_msg((dev), (pipe), (request), (requesttype), (value),\ (index), (data), (size), (timeout_ms)) -#define rtw_usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout_ms) \ - usb_bulk_msg((usb_dev), (pipe), (data), (len), \ - (actual_length), (timeout_ms)) #include void rtl8188eu_set_hw_type(struct adapter *padapter); -- cgit v1.2.3 From 86949b521fa4e4c88e6ff7be6a1ce2c7c064a0f0 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 11:24:17 +0200 Subject: staging: r8188eu: remove rtw_usb_control_msg() macro It is a wrapper around usb_control_msg() that does nothing, so remove the macro and just call the correct USB function instead in the one place it is used. Link: https://lore.kernel.org/r/20210730092417.1014392-12-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 2 +- drivers/staging/r8188eu/include/usb_ops.h | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index dd6138dfebb6..3c6abedb313d 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -56,7 +56,7 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u memcpy(pIo_buf, pdata, len); } - status = rtw_usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_urb_error(dvobjpriv); diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index d5b31e31b62d..6267d0999400 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -21,10 +21,6 @@ enum { #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) -#define rtw_usb_control_msg(dev, pipe, request, requesttype, \ - value, index, data, size, timeout_ms) \ - usb_control_msg((dev), (pipe), (request), (requesttype), (value),\ - (index), (data), (size), (timeout_ms)) #include void rtl8188eu_set_hw_type(struct adapter *padapter); -- cgit v1.2.3 From 78f2b22efc8f7649dcde44143e78149457f1162c Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Fri, 30 Jul 2021 16:39:21 +0200 Subject: staging: r8188eu: fix include directory mess The driver seems to want to include a specific directory for all include files on the build path, but that breaks when trying to build only the module directory, or when building with "O=" option. Fix this up by making all includes for the driver be relative locations. Reported-by: Mark Brown Link: https://lore.kernel.org/r/20210730144227.1770212-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Makefile | 2 - drivers/staging/r8188eu/core/rtw_ap.c | 8 ++-- drivers/staging/r8188eu/core/rtw_br_ext.c | 32 +++++++-------- drivers/staging/r8188eu/core/rtw_cmd.c | 14 +++---- drivers/staging/r8188eu/core/rtw_debug.c | 4 +- drivers/staging/r8188eu/core/rtw_efuse.c | 6 +-- drivers/staging/r8188eu/core/rtw_ieee80211.c | 12 +++--- drivers/staging/r8188eu/core/rtw_io.c | 10 ++--- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 12 +++--- drivers/staging/r8188eu/core/rtw_iol.c | 2 +- drivers/staging/r8188eu/core/rtw_led.c | 4 +- drivers/staging/r8188eu/core/rtw_mlme.c | 22 +++++------ drivers/staging/r8188eu/core/rtw_mlme_ext.c | 14 +++---- drivers/staging/r8188eu/core/rtw_mp.c | 7 ++-- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 10 ++--- drivers/staging/r8188eu/core/rtw_p2p.c | 6 +-- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 8 ++-- drivers/staging/r8188eu/core/rtw_recv.c | 18 ++++----- drivers/staging/r8188eu/core/rtw_rf.c | 8 ++-- drivers/staging/r8188eu/core/rtw_security.c | 8 ++-- drivers/staging/r8188eu/core/rtw_sreset.c | 2 +- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 12 +++--- drivers/staging/r8188eu/core/rtw_wlan_util.c | 6 +-- drivers/staging/r8188eu/core/rtw_xmit.c | 14 +++---- drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c | 4 +- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 2 +- drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 5 +-- drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c | 4 +- drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 5 +-- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 2 +- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 2 +- drivers/staging/r8188eu/hal/hal_com.c | 10 ++--- drivers/staging/r8188eu/hal/hal_intf.c | 6 +-- drivers/staging/r8188eu/hal/odm.c | 2 +- drivers/staging/r8188eu/hal/odm_HWConfig.c | 2 +- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 2 +- drivers/staging/r8188eu/hal/odm_RegConfig8188E.c | 2 +- drivers/staging/r8188eu/hal/odm_debug.c | 2 +- drivers/staging/r8188eu/hal/odm_interface.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 16 ++++---- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 7 ++-- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 15 +++---- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 8 ++-- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 8 ++-- drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 7 ++-- drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 6 +-- drivers/staging/r8188eu/hal/rtl8188e_sreset.c | 4 +- drivers/staging/r8188eu/hal/rtl8188e_xmit.c | 6 +-- drivers/staging/r8188eu/hal/rtl8188eu_led.c | 8 ++-- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 24 +++++------ drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 12 +++--- drivers/staging/r8188eu/hal/usb_halinit.c | 18 ++++----- drivers/staging/r8188eu/hal/usb_ops_linux.c | 12 +++--- drivers/staging/r8188eu/include/HalPwrSeqCmd.h | 2 +- drivers/staging/r8188eu/include/cmd_osdep.h | 4 +- drivers/staging/r8188eu/include/drv_types.h | 46 +++++++++++----------- drivers/staging/r8188eu/include/hal_intf.h | 6 +-- drivers/staging/r8188eu/include/ieee80211.h | 4 +- drivers/staging/r8188eu/include/ieee80211_ext.h | 4 +- drivers/staging/r8188eu/include/mlme_osdep.h | 4 +- drivers/staging/r8188eu/include/odm_precomp.h | 6 +-- drivers/staging/r8188eu/include/odm_types.h | 2 +- drivers/staging/r8188eu/include/osdep_intf.h | 4 +- drivers/staging/r8188eu/include/osdep_service.h | 2 +- drivers/staging/r8188eu/include/recv_osdep.h | 4 +- drivers/staging/r8188eu/include/rtl8188e_led.h | 4 +- drivers/staging/r8188eu/include/rtl8188e_sreset.h | 6 +-- drivers/staging/r8188eu/include/rtw_ap.h | 4 +- drivers/staging/r8188eu/include/rtw_cmd.h | 10 ++--- drivers/staging/r8188eu/include/rtw_debug.h | 4 +- drivers/staging/r8188eu/include/rtw_eeprom.h | 4 +- drivers/staging/r8188eu/include/rtw_efuse.h | 2 +- drivers/staging/r8188eu/include/rtw_event.h | 4 +- drivers/staging/r8188eu/include/rtw_ht.h | 2 +- drivers/staging/r8188eu/include/rtw_io.h | 4 +- drivers/staging/r8188eu/include/rtw_ioctl.h | 4 +- drivers/staging/r8188eu/include/rtw_ioctl_rtl.h | 4 +- drivers/staging/r8188eu/include/rtw_ioctl_set.h | 2 +- drivers/staging/r8188eu/include/rtw_iol.h | 4 +- drivers/staging/r8188eu/include/rtw_led.h | 4 +- drivers/staging/r8188eu/include/rtw_mlme.h | 8 ++-- drivers/staging/r8188eu/include/rtw_mlme_ext.h | 6 +-- drivers/staging/r8188eu/include/rtw_mp.h | 2 +- drivers/staging/r8188eu/include/rtw_mp_ioctl.h | 12 +++--- drivers/staging/r8188eu/include/rtw_p2p.h | 2 +- drivers/staging/r8188eu/include/rtw_pwrctrl.h | 4 +- drivers/staging/r8188eu/include/rtw_recv.h | 4 +- drivers/staging/r8188eu/include/rtw_rf.h | 2 +- drivers/staging/r8188eu/include/rtw_security.h | 4 +- drivers/staging/r8188eu/include/rtw_sreset.h | 6 +-- drivers/staging/r8188eu/include/rtw_xmit.h | 6 +-- drivers/staging/r8188eu/include/sta_info.h | 6 +-- drivers/staging/r8188eu/include/usb_ops.h | 8 ++-- drivers/staging/r8188eu/include/usb_osintf.h | 6 +-- drivers/staging/r8188eu/include/xmit_osdep.h | 4 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 34 ++++++++-------- drivers/staging/r8188eu/os_dep/mlme_linux.c | 6 +-- drivers/staging/r8188eu/os_dep/os_intfs.c | 18 ++++----- drivers/staging/r8188eu/os_dep/osdep_service.c | 10 ++--- drivers/staging/r8188eu/os_dep/recv_linux.c | 14 +++---- drivers/staging/r8188eu/os_dep/rtw_android.c | 11 +++--- drivers/staging/r8188eu/os_dep/usb_intf.c | 21 +++++----- drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 6 +-- drivers/staging/r8188eu/os_dep/xmit_linux.c | 19 +++++---- 104 files changed, 399 insertions(+), 414 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index a97cced2e61a..152d6325b4d9 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -11,8 +11,6 @@ EXTRA_CFLAGS += -Wno-unused EXTRA_CFLAGS += -Wno-uninitialized -EXTRA_CFLAGS += -I$(src)/include - ccflags-y += -D__CHECK_ENDIAN__ CONFIG_R8188EU = m diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 407c62cf803c..c7c892ab4ae6 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -3,10 +3,10 @@ #define _RTW_AP_C_ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wifi.h" +#include "../include/ieee80211.h" #ifdef CONFIG_88EU_AP_MODE diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index e00302137a60..6e42ecd0b53f 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -3,26 +3,26 @@ #define _RTW_BR_EXT_C_ -#include -#include -#include -#include -#include -#include - -#include -#include "rtw_br_ext.h" -#include -#include +#include "../include/linux/if_arp.h" +#include "../include/net/ip.h" +#include "../include/net/ipx.h" +#include "../include/linux/atalk.h" +#include "../include/linux/udp.h" +#include "../include/linux/if_pppox.h" + +#include "../include/drv_types.h" +#include "../include/rtw_br_ext.h" +#include "../include/usb_osintf.h" +#include "../include/recv_osdep.h" #ifndef csum_ipv6_magic -#include +#include "../include/net/ip6_checksum.h" #endif -#include -#include -#include -#include +#include "../include/linux/ipv6.h" +#include "../include/linux/icmpv6.h" +#include "../include/net/ndisc.h" +#include "../include/net/checksum.h" #define NAT25_IPV4 01 #define NAT25_IPV6 02 diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 159346d97110..4e17972ee66e 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -3,13 +3,13 @@ #define _RTW_CMD_C_ -#include -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/cmd_osdep.h" +#include "../include/mlme_osdep.h" +#include "../include/rtw_br_ext.h" +#include "../include/rtw_mlme_ext.h" /* Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c index a0ca61d8c3b8..30ef77842787 100644 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -3,8 +3,8 @@ #define _RTW_DEBUG_C_ -#include -#include +#include "../include/rtw_debug.h" +#include "../include/drv_types.h" int proc_get_drv_version(char *page, char **start, off_t offset, int count, diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index 216ec4036c1a..82eb2134c1e4 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -3,9 +3,9 @@ #define _RTW_EFUSE_C_ -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtw_efuse.h" /*------------------------Define local variable------------------------------*/ u8 fakeEfuseBank; diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index 7f98ffc7442d..270a3848c3d6 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -3,12 +3,12 @@ #define _IEEE80211_C -#include -#include -#include -#include -#include -#include +#include "../include/drv_types.h" +#include "../include/ieee80211.h" +#include "../include/wifi.h" +#include "../include/osdep_service.h" +#include "../include/wlan_bssdef.h" +#include "../include/usb_osintf.h" u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; u16 RTW_WPA_VERSION = 1; diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index ca7d27a24080..e0909d3d6307 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -23,11 +23,11 @@ jackson@realtek.com.tw */ #define _RTW_IO_C_ -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtw_io.h" +#include "../include/osdep_intf.h" +#include "../include/usb_ops.h" #define rtw_le16_to_cpu(val) le16_to_cpu(val) #define rtw_le32_to_cpu(val) le32_to_cpu(val) diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 34c27ecbd55a..12a99588fbe2 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -3,13 +3,13 @@ #define _RTW_IOCTL_SET_C_ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtw_ioctl_set.h" +#include "../include/hal_intf.h" -#include -#include +#include "../include/usb_osintf.h" +#include "../include/usb_ops.h" extern void indicate_wx_scan_complete_event(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index e93610d7c8c6..2f38ff8cacef 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include +#include "../include/rtw_iol.h" struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) { diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index ee90e52adc90..70e989d11e44 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2012 Realtek Corporation. */ -#include -#include "rtw_led.h" +#include "../include/drv_types.h" +#include "../include/rtw_led.h" /* */ /* Description: */ diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 8266e9a88e01..fe826e5831a3 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -4,17 +4,17 @@ #define _RTW_MLME_C_ #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/xmit_osdep.h" +#include "../include/hal_intf.h" +#include "../include/mlme_osdep.h" +#include "../include/sta_info.h" +#include "../include/wifi.h" +#include "../include/wlan_bssdef.h" +#include "../include/rtw_ioctl_set.h" +#include "../include/usb_osintf.h" extern unsigned char MCS_rate_2R[16]; extern unsigned char MCS_rate_1R[16]; diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 36b4e073d24c..3fa89ef293d1 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -3,13 +3,13 @@ #define _RTW_MLME_EXT_C_ -#include -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wifi.h" +#include "../include/rtw_mlme_ext.h" +#include "../include/wlan_bssdef.h" +#include "../include/mlme_osdep.h" +#include "../include/recv_osdep.h" static struct mlme_handler mlme_sta_tbl[] = { {WIFI_ASSOCREQ, "OnAssocReq", &OnAssocReq}, diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index ece34de548f9..c300af4eee8d 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -3,10 +3,9 @@ #define _RTW_MP_C_ -#include - -#include "odm_precomp.h" -#include "rtl8188e_hal.h" +#include "../include/drv_types.h" +#include "../include/odm_precomp.h" +#include "../include/rtl8188e_hal.h" u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz) { diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index 3dd7dff233ee..b6145c7b5893 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -3,12 +3,10 @@ #define _RTW_MP_IOCTL_C_ -#include -#include -#include - -/* include */ -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/mlme_osdep.h" +#include "../include/rtw_mp_ioctl.h" /* rtl8188eu_oid_rtl_seg_81_85 section start **************** */ int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 3ec988fad6ea..f94fc7ba9a01 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -3,9 +3,9 @@ #define _RTW_P2P_C_ -#include -#include -#include +#include "../include/drv_types.h" +#include "../include/rtw_p2p.h" +#include "../include/wifi.h" #ifdef CONFIG_88EU_P2P diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index a7b63413000b..d67eeb045002 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -3,10 +3,10 @@ #define _RTW_PWRCTRL_C_ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/osdep_intf.h" +#include "../include/linux/usb.h" void ips_enter(struct adapter *padapter) { diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 3872aa5cb982..610cc699caf9 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -3,15 +3,15 @@ #define _RTW_RECV_C_ -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/mlme_osdep.h" +#include "../include/ip.h" +#include "../include/if_ether.h" +#include "../include/ethernet.h" +#include "../include/usb_ops.h" +#include "../include/wifi.h" static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; diff --git a/drivers/staging/r8188eu/core/rtw_rf.c b/drivers/staging/r8188eu/core/rtw_rf.c index caa3d68d93e2..321546c40446 100644 --- a/drivers/staging/r8188eu/core/rtw_rf.c +++ b/drivers/staging/r8188eu/core/rtw_rf.c @@ -3,10 +3,10 @@ #define _RTW_RF_C_ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/xmit_osdep.h" struct ch_freq { u32 channel; diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 136ba1e61dca..ee4775b8284b 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -3,10 +3,10 @@ #define _RTW_SECURITY_C_ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wifi.h" +#include "../include/osdep_intf.h" /* WEP related ===== */ diff --git a/drivers/staging/r8188eu/core/rtw_sreset.c b/drivers/staging/r8188eu/core/rtw_sreset.c index a4705736a153..5084bc036424 100644 --- a/drivers/staging/r8188eu/core/rtw_sreset.c +++ b/drivers/staging/r8188eu/core/rtw_sreset.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2012 Realtek Corporation. */ -#include +#include "../include/rtw_sreset.h" void sreset_init_value(struct adapter *padapter) { diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 9a459eef861d..dc72b78877b0 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -3,12 +3,12 @@ #define _RTW_STA_MGT_C_ -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/xmit_osdep.h" +#include "../include/mlme_osdep.h" +#include "../include/sta_info.h" static void _rtw_init_stainfo(struct sta_info *psta) { diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 738298ebbc3c..15edccef9f1d 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -3,9 +3,9 @@ #define _RTW_WLAN_UTIL_C_ -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wifi.h" static unsigned char ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; static unsigned char ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index c2a3d62facd1..7ecffadcb61f 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -3,13 +3,13 @@ #define _RTW_XMIT_C_ -#include -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wifi.h" +#include "../include/osdep_intf.h" +#include "../include/ip.h" +#include "../include/usb_ops.h" +#include "../include/usb_osintf.h" static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; diff --git a/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c b/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c index 7df715ab2f6e..48ede610cd28 100644 --- a/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c +++ b/drivers/staging/r8188eu/hal/Hal8188EPwrSeq.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "Hal8188EPwrSeq.h" -#include +#include "../include/Hal8188EPwrSeq.h" +#include "../include/rtl8188e_hal.h" /* drivers should parse below arrays and do the corresponding actions diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index 8db90778ab6c..2baea6141fe2 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -12,7 +12,7 @@ Major Change History: 2011-08-12 Page Create. --*/ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" /* Rate adaptive parameters */ diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c index 5eaf79ae6c93..fc58d5fb1264 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -1,9 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" - -#include +#include "../include/odm_precomp.h" +#include "../include/rtw_iol.h" #define read_next_pair(array, v1, v2, i) \ do { \ diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c index dc9ef87af99a..06ef2c04cebf 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c @@ -1,8 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" -#include +#include "../include/odm_precomp.h" +#include "../include/rtw_iol.h" static bool Checkcondition(const u32 condition, const u32 hex) { diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c index b0df4eb8413d..7659b0953100 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -1,9 +1,8 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" - -#include +#include "../include/odm_precomp.h" +#include "../include/rtw_iol.h" static bool CheckCondition(const u32 Condition, const u32 Hex) { diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index 8b34842b4a30..1eb459532da5 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" /*---------------------------Define Local Constant---------------------------*/ /* 2010/04/25 MH Define the max tx power tracking tx agc power. */ diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index 77bb61ab9789..c31f01c0fdd2 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -17,7 +17,7 @@ Major Change History: --*/ -#include +#include "../include/HalPwrSeqCmd.h" /* Description: */ /* This routine deals with the Power Configuration CMDs parsing diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index 9094aba21379..ca50c3c85578 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -1,12 +1,12 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" -#include -#include -#include +#include "../include/hal_intf.h" +#include "../include/hal_com.h" +#include "../include/rtl8188e_hal.h" #define _HAL_INIT_C_ diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 02d76ac782d8..cb0635850aa8 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -2,9 +2,9 @@ /* Copyright(c) 2007 - 2012 Realtek Corporation. */ #define _HAL_INTF_C_ -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/hal_intf.h" void rtw_hal_chip_configure(struct adapter *adapt) { diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index a26b2ae35b73..c6c184d95fee 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -3,7 +3,7 @@ /* include files */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" static const u16 dB_Invert_Table[8][12] = { {1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4, 4}, diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 19222c0eddf7..93a91cce21ec 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" #define READ_AND_CONFIG READ_AND_CONFIG_MP diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 17dca886b17c..baa9c1c977c7 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) { diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c index 132f5cbd0697..a26c36cf8786 100644 --- a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data, enum rf_radio_path RF_PATH, diff --git a/drivers/staging/r8188eu/hal/odm_debug.c b/drivers/staging/r8188eu/hal/odm_debug.c index a969ba48ddb9..fad1c3cca25b 100644 --- a/drivers/staging/r8188eu/hal/odm_debug.c +++ b/drivers/staging/r8188eu/hal/odm_debug.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm) { diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index e26a6461e70b..507baf9fd913 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include "odm_precomp.h" +#include "../include/odm_precomp.h" /* ODM IO Relative API. */ u8 ODM_Read1Byte(struct odm_dm_struct *pDM_Odm, u32 RegAddr) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index dc4d790837ce..4bd471873531 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -3,14 +3,14 @@ #define _RTL8188E_CMD_C_ -#include -#include -#include -#include -#include -#include - -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/cmd_osdep.h" +#include "../include/mlme_osdep.h" +#include "../include/rtw_ioctl_set.h" + +#include "../include/rtl8188e_hal.h" #define RTL88E_MAX_H2C_BOX_NUMS 4 #define RTL88E_MAX_CMD_LEN 7 diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index 88ae9c5a8507..294b082a6c09 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -4,10 +4,9 @@ /* This file is for 92CE/92CU dynamic mechanism only */ #define _RTL8188E_DM_C_ -#include -#include - -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtl8188e_hal.h" static void dm_CheckStatistics(struct adapter *Adapter) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 02ba495b6d2c..27bc1db07f55 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -3,15 +3,12 @@ #define _HAL_INIT_C_ -#include -#include -#include - -#include - -#include - -#include +#include "../include/linux/firmware.h" +#include "../include/drv_types.h" +#include "../include/rtw_efuse.h" +#include "../include/rtl8188e_hal.h" +#include "../include/rtw_iol.h" +#include "../include/usb_ops.h" static void iol_mode_enable(struct adapter *padapter, u8 enable) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index 3937c1f5d588..626741087391 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -3,10 +3,10 @@ #define _RTL8188E_MP_C_ -#include -#include -#include -#include +#include "../include/drv_types.h" +#include "../include/rtw_mp.h" +#include "../include/rtl8188e_hal.h" +#include "../include/rtl8188e_dm.h" s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index f23e69ebee35..37f2342ddbaa 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -3,10 +3,10 @@ #define _RTL8188E_PHYCFG_C_ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtw_iol.h" +#include "../include/rtl8188e_hal.h" /*---------------------------Define Local Constant---------------------------*/ /* Channel switch:The size of command tables for switch channel*/ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index 0bba0130cfa6..335b120ce603 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -25,10 +25,9 @@ #define _RTL8188E_RF6052_C_ -#include -#include - -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtl8188e_hal.h" /*---------------------------Define Local Constant---------------------------*/ /* Define local structure for debug!!!!! */ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c index 9ce6527cb75a..20f7f449b106 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -3,9 +3,9 @@ #define _RTL8188E_REDESC_C_ -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtl8188e_hal.h" static void process_rssi(struct adapter *padapter, struct recv_frame *prframe) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_sreset.c b/drivers/staging/r8188eu/hal/rtl8188e_sreset.c index 88bc607b3698..16fa249e35d3 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_sreset.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_sreset.c @@ -3,8 +3,8 @@ #define _RTL8188E_SRESET_C_ -#include -#include +#include "../include/rtl8188e_sreset.h" +#include "../include/rtl8188e_hal.h" void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c index fe32ba366338..164ec6650dec 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c @@ -3,9 +3,9 @@ #define _RTL8188E_XMIT_C_ -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtl8188e_hal.h" void dump_txrpt_ccx_88e(void *buf) { diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_led.c b/drivers/staging/r8188eu/hal/rtl8188eu_led.c index 29aee1345577..51fd30b25a5f 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_led.c @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtl8188e_hal.h" +#include "../include/rtl8188e_led.h" /* LED object. */ diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 7ca1a101e100..2e3f624d0f22 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -2,18 +2,18 @@ /* Copyright(c) 2007 - 2011 Realtek Corporation. */ #define _RTL8188EU_RECV_C_ -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/mlme_osdep.h" +#include "../include/ip.h" +#include "../include/if_ether.h" +#include "../include/ethernet.h" + +#include "../include/usb_ops.h" +#include "../include/wifi.h" + +#include "../include/rtl8188e_hal.h" void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *precvbuf) { diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index ca543bdc119d..e44a01af7f5c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -2,12 +2,12 @@ /* Copyright(c) 2007 - 2011 Realtek Corporation. */ #define _RTL8188E_XMIT_C_ -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wifi.h" +#include "../include/osdep_intf.h" +#include "../include/usb_ops.h" +#include "../include/rtl8188e_hal.h" s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) { diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index f784d8dcdd34..d50a887ad7ea 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -3,15 +3,15 @@ #define _HCI_HAL_INIT_C_ -#include -#include -#include - -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/rtw_efuse.h" + +#include "../include/rtl8188e_hal.h" +#include "../include/rtl8188e_led.h" +#include "../include/rtw_iol.h" +#include "../include/usb_ops.h" +#include "../include/usb_osintf.h" #define HAL_MAC_ENABLE 1 #define HAL_BB_ENABLE 1 diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 3c6abedb313d..577090db84be 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -3,12 +3,12 @@ #define _HCI_OPS_OS_C_ -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/osdep_intf.h" +#include "../include/usb_ops.h" +#include "../include/recv_osdep.h" +#include "../include/rtl8188e_hal.h" static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { diff --git a/drivers/staging/r8188eu/include/HalPwrSeqCmd.h b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h index 3b8e263ea6e1..fe7ac910beb8 100644 --- a/drivers/staging/r8188eu/include/HalPwrSeqCmd.h +++ b/drivers/staging/r8188eu/include/HalPwrSeqCmd.h @@ -4,7 +4,7 @@ #ifndef __HALPWRSEQCMD_H__ #define __HALPWRSEQCMD_H__ -#include +#include "drv_types.h" /*---------------------------------------------*/ /* 3 The value of cmd: 4 bits */ diff --git a/drivers/staging/r8188eu/include/cmd_osdep.h b/drivers/staging/r8188eu/include/cmd_osdep.h index 75ba595f2301..3954d6350cc6 100644 --- a/drivers/staging/r8188eu/include/cmd_osdep.h +++ b/drivers/staging/r8188eu/include/cmd_osdep.h @@ -4,8 +4,8 @@ #ifndef __CMD_OSDEP_H_ #define __CMD_OSDEP_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" extern int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); extern int _rtw_init_evt_priv(struct evt_priv *pevtpriv); diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index d8faea4f6045..8cefb5c288f3 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -14,29 +14,29 @@ #define CONFIG_88EU_AP_MODE 1 #define CONFIG_88EU_P2P 1 -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include "osdep_service.h" +#include "wlan_bssdef.h" +#include "rtw_ht.h" +#include "rtw_cmd.h" +#include "rtw_xmit.h" +#include "rtw_recv.h" +#include "hal_intf.h" +#include "hal_com.h" +#include "rtw_security.h" +#include "rtw_pwrctrl.h" +#include "rtw_io.h" +#include "rtw_eeprom.h" +#include "sta_info.h" +#include "rtw_mlme.h" +#include "rtw_debug.h" +#include "rtw_rf.h" +#include "rtw_event.h" +#include "rtw_led.h" +#include "rtw_mlme_ext.h" +#include "rtw_p2p.h" +#include "rtw_ap.h" +#include "rtw_mp.h" +#include "rtw_br_ext.h" #define DRIVERVERSION "v4.1.4_6773.20130222" diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index d64fcda37100..81d959c6fd4e 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -4,9 +4,9 @@ #ifndef __HAL_INTF_H__ #define __HAL_INTF_H__ -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "Hal8188EPhyCfg.h" enum RTL871X_HCI_TYPE { RTW_PCIE = BIT0, diff --git a/drivers/staging/r8188eu/include/ieee80211.h b/drivers/staging/r8188eu/include/ieee80211.h index bc9a875cdf35..4dfa817175e7 100644 --- a/drivers/staging/r8188eu/include/ieee80211.h +++ b/drivers/staging/r8188eu/include/ieee80211.h @@ -4,8 +4,8 @@ #ifndef __IEEE80211_H #define __IEEE80211_H -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #include "wifi.h" #include diff --git a/drivers/staging/r8188eu/include/ieee80211_ext.h b/drivers/staging/r8188eu/include/ieee80211_ext.h index cc53c71d2d8b..e7ade835d478 100644 --- a/drivers/staging/r8188eu/include/ieee80211_ext.h +++ b/drivers/staging/r8188eu/include/ieee80211_ext.h @@ -4,8 +4,8 @@ #ifndef __IEEE80211_EXT_H #define __IEEE80211_EXT_H -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define WMM_OUI_TYPE 2 #define WMM_OUI_SUBTYPE_INFORMATION_ELEMENT 0 diff --git a/drivers/staging/r8188eu/include/mlme_osdep.h b/drivers/staging/r8188eu/include/mlme_osdep.h index 096232b0f95b..5b9f688f9424 100644 --- a/drivers/staging/r8188eu/include/mlme_osdep.h +++ b/drivers/staging/r8188eu/include/mlme_osdep.h @@ -4,8 +4,8 @@ #ifndef __MLME_OSDEP_H_ #define __MLME_OSDEP_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" void rtw_init_mlme_timer(struct adapter *padapter); void rtw_os_indicate_disconnect(struct adapter *adapter); diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index b3d8f6463658..2ff2e93a759c 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -10,9 +10,9 @@ /* 2 Config Flags and Structs - defined by each ODM Type */ -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "hal_intf.h" /* 2 OutSrc Header Files */ diff --git a/drivers/staging/r8188eu/include/odm_types.h b/drivers/staging/r8188eu/include/odm_types.h index 4a6c4d33e20e..e2e5aa8e8054 100644 --- a/drivers/staging/r8188eu/include/odm_types.h +++ b/drivers/staging/r8188eu/include/odm_types.h @@ -25,7 +25,7 @@ enum RT_SPINLOCK_TYPE { RT_TEMP = 1, }; -#include +#include "basic_types.h" #define DEV_BUS_TYPE RT_USB_INTERFACE diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h index b585c239c64e..1915c926faac 100644 --- a/drivers/staging/r8188eu/include/osdep_intf.h +++ b/drivers/staging/r8188eu/include/osdep_intf.h @@ -4,8 +4,8 @@ #ifndef __OSDEP_INTF_H_ #define __OSDEP_INTF_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" struct intf_priv { u8 *intf_dev; diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index df59fa325e6e..05cbc9b0dadd 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -5,7 +5,7 @@ #define __OSDEP_SERVICE_H_ #include -#include +#include "basic_types.h" #define _FAIL 0 #define _SUCCESS 1 diff --git a/drivers/staging/r8188eu/include/recv_osdep.h b/drivers/staging/r8188eu/include/recv_osdep.h index eebd06e6329e..7308f21c428f 100644 --- a/drivers/staging/r8188eu/include/recv_osdep.h +++ b/drivers/staging/r8188eu/include/recv_osdep.h @@ -4,8 +4,8 @@ #ifndef __RECV_OSDEP_H_ #define __RECV_OSDEP_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); void _rtw_free_recv_priv(struct recv_priv *precvpriv); diff --git a/drivers/staging/r8188eu/include/rtl8188e_led.h b/drivers/staging/r8188eu/include/rtl8188e_led.h index e1b4e078fd8b..b00954198764 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_led.h +++ b/drivers/staging/r8188eu/include/rtl8188e_led.h @@ -4,8 +4,8 @@ #ifndef __RTL8188E_LED_H__ #define __RTL8188E_LED_H__ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" /* */ /* Interface to manipulate LED objects. */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_sreset.h b/drivers/staging/r8188eu/include/rtl8188e_sreset.h index 6158ba19a920..880c5792d5dd 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_sreset.h +++ b/drivers/staging/r8188eu/include/rtl8188e_sreset.h @@ -4,9 +4,9 @@ #ifndef _RTL8188E_SRESET_H_ #define _RTL8188E_SRESET_H_ -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "rtw_sreset.h" void rtl8188e_silentreset_for_specific_platform(struct adapter *padapter); void rtl8188e_sreset_xmit_status_check(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h index 3662941ce9a8..b20edab3bb00 100644 --- a/drivers/staging/r8188eu/include/rtw_ap.h +++ b/drivers/staging/r8188eu/include/rtw_ap.h @@ -4,8 +4,8 @@ #ifndef __RTW_AP_H_ #define __RTW_AP_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #ifdef CONFIG_88EU_AP_MODE diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h index 9eefafd7ad7d..0f64b72bb5de 100644 --- a/drivers/staging/r8188eu/include/rtw_cmd.h +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -4,14 +4,14 @@ #ifndef __RTW_CMD_H_ #define __RTW_CMD_H_ -#include -#include -#include +#include "wlan_bssdef.h" +#include "rtw_rf.h" +#include "rtw_led.h" #define C2H_MEM_SZ (16*1024) -#include -#include /* */ +#include "osdep_service.h" +#include "ieee80211.h" /* */ #define FREE_CMDOBJ_SZ 128 diff --git a/drivers/staging/r8188eu/include/rtw_debug.h b/drivers/staging/r8188eu/include/rtw_debug.h index f8a969e339b1..56af0751f70e 100644 --- a/drivers/staging/r8188eu/include/rtw_debug.h +++ b/drivers/staging/r8188eu/include/rtw_debug.h @@ -4,8 +4,8 @@ #ifndef __RTW_DEBUG_H__ #define __RTW_DEBUG_H__ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define _drv_always_ 1 #define _drv_emerg_ 2 diff --git a/drivers/staging/r8188eu/include/rtw_eeprom.h b/drivers/staging/r8188eu/include/rtw_eeprom.h index dcd6b8523865..9f8a9c070339 100644 --- a/drivers/staging/r8188eu/include/rtw_eeprom.h +++ b/drivers/staging/r8188eu/include/rtw_eeprom.h @@ -4,8 +4,8 @@ #ifndef __RTW_EEPROM_H__ #define __RTW_EEPROM_H__ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define RTL8712_EEPROM_ID 0x8712 diff --git a/drivers/staging/r8188eu/include/rtw_efuse.h b/drivers/staging/r8188eu/include/rtw_efuse.h index 60f9f59d1efd..b3ff46db2091 100644 --- a/drivers/staging/r8188eu/include/rtw_efuse.h +++ b/drivers/staging/r8188eu/include/rtw_efuse.h @@ -4,7 +4,7 @@ #ifndef __RTW_EFUSE_H__ #define __RTW_EFUSE_H__ -#include +#include "osdep_service.h" #define EFUSE_ERROE_HANDLE 1 diff --git a/drivers/staging/r8188eu/include/rtw_event.h b/drivers/staging/r8188eu/include/rtw_event.h index c0fa91591b9e..54dc1ea437fc 100644 --- a/drivers/staging/r8188eu/include/rtw_event.h +++ b/drivers/staging/r8188eu/include/rtw_event.h @@ -4,9 +4,9 @@ #ifndef _RTW_EVENT_H_ #define _RTW_EVENT_H_ -#include +#include "osdep_service.h" -#include +#include "wlan_bssdef.h" #include #include diff --git a/drivers/staging/r8188eu/include/rtw_ht.h b/drivers/staging/r8188eu/include/rtw_ht.h index b3a978e905d0..2b56b7c38c86 100644 --- a/drivers/staging/r8188eu/include/rtw_ht.h +++ b/drivers/staging/r8188eu/include/rtw_ht.h @@ -4,7 +4,7 @@ #ifndef _RTW_HT_H_ #define _RTW_HT_H_ -#include +#include "osdep_service.h" #include "wifi.h" struct ht_priv { diff --git a/drivers/staging/r8188eu/include/rtw_io.h b/drivers/staging/r8188eu/include/rtw_io.h index e2aae349d8fd..f1b3074fa075 100644 --- a/drivers/staging/r8188eu/include/rtw_io.h +++ b/drivers/staging/r8188eu/include/rtw_io.h @@ -4,8 +4,8 @@ #ifndef _RTW_IO_H_ #define _RTW_IO_H_ -#include -#include +#include "osdep_service.h" +#include "osdep_intf.h" #include #include diff --git a/drivers/staging/r8188eu/include/rtw_ioctl.h b/drivers/staging/r8188eu/include/rtw_ioctl.h index 2cdeb244d23e..8c03c16bb998 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl.h @@ -4,8 +4,8 @@ #ifndef _RTW_IOCTL_H_ #define _RTW_IOCTL_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #ifndef OID_802_11_CAPABILITY #define OID_802_11_CAPABILITY 0x0d010122 diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h b/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h index 18014dd8476f..6d3d1ef923f6 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl_rtl.h @@ -4,8 +4,8 @@ #ifndef _RTW_IOCTL_RTL_H_ #define _RTW_IOCTL_RTL_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" /* oid_rtl_seg_01_01 ************** */ int oid_rt_get_signal_quality_hdl(struct oid_par_priv *poid_par_priv);/* 84 */ diff --git a/drivers/staging/r8188eu/include/rtw_ioctl_set.h b/drivers/staging/r8188eu/include/rtw_ioctl_set.h index 2214cee35ae7..6216b8ab3a79 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl_set.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl_set.h @@ -4,7 +4,7 @@ #ifndef __RTW_IOCTL_SET_H_ #define __RTW_IOCTL_SET_H_ -#include +#include "drv_types.h" typedef u8 NDIS_802_11_PMKID_VALUE[16]; diff --git a/drivers/staging/r8188eu/include/rtw_iol.h b/drivers/staging/r8188eu/include/rtw_iol.h index 89668122a876..471f9ca092a8 100644 --- a/drivers/staging/r8188eu/include/rtw_iol.h +++ b/drivers/staging/r8188eu/include/rtw_iol.h @@ -4,8 +4,8 @@ #ifndef __RTW_IOL_H_ #define __RTW_IOL_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define IOREG_CMD_END_LEN 4 diff --git a/drivers/staging/r8188eu/include/rtw_led.h b/drivers/staging/r8188eu/include/rtw_led.h index def9d04a20ce..f0965aa5b470 100644 --- a/drivers/staging/r8188eu/include/rtw_led.h +++ b/drivers/staging/r8188eu/include/rtw_led.h @@ -4,8 +4,8 @@ #ifndef __RTW_LED_H_ #define __RTW_LED_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define MSECS(t) (HZ * ((t) / 1000) + (HZ * ((t) % 1000)) / 1000) diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index d5b479ae7799..8c54da73f1a7 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -4,10 +4,10 @@ #ifndef __RTW_MLME_H_ #define __RTW_MLME_H_ -#include -#include -#include -#include +#include "osdep_service.h" +#include "mlme_osdep.h" +#include "drv_types.h" +#include "wlan_bssdef.h" #define MAX_BSS_CNT 128 #define MAX_JOIN_TIMEOUT 6500 diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index eaaedf7d7305..b9c76f04445c 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -4,9 +4,9 @@ #ifndef __RTW_MLME_EXT_H_ #define __RTW_MLME_EXT_H_ -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "wlan_bssdef.h" /* Commented by Albert 20101105 */ /* Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms ) */ diff --git a/drivers/staging/r8188eu/include/rtw_mp.h b/drivers/staging/r8188eu/include/rtw_mp.h index c0974189e92d..b64b16554343 100644 --- a/drivers/staging/r8188eu/include/rtw_mp.h +++ b/drivers/staging/r8188eu/include/rtw_mp.h @@ -125,7 +125,7 @@ struct mp_tx { void *PktTxThread; }; -#include +#include "Hal8188EPhyCfg.h" #define MP_MAX_LINES 1000 #define MP_MAX_LINES_BYTES 256 diff --git a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h index b23ca88ceb9e..e856fd0ad036 100644 --- a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h @@ -4,12 +4,12 @@ #ifndef _RTW_MP_IOCTL_H_ #define _RTW_MP_IOCTL_H_ -#include -#include -#include -#include -#include -#include +#include "drv_types.h" +#include "mp_custom_oid.h" +#include "rtw_ioctl.h" +#include "rtw_ioctl_rtl.h" +#include "rtw_efuse.h" +#include "rtw_mp.h" /* */ struct cfg_dbg_msg_struct { diff --git a/drivers/staging/r8188eu/include/rtw_p2p.h b/drivers/staging/r8188eu/include/rtw_p2p.h index 29f908f36598..92b9bfe3ea0b 100644 --- a/drivers/staging/r8188eu/include/rtw_p2p.h +++ b/drivers/staging/r8188eu/include/rtw_p2p.h @@ -4,7 +4,7 @@ #ifndef __RTW_P2P_H_ #define __RTW_P2P_H_ -#include +#include "drv_types.h" u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); u32 build_probe_resp_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf); diff --git a/drivers/staging/r8188eu/include/rtw_pwrctrl.h b/drivers/staging/r8188eu/include/rtw_pwrctrl.h index bd86666d0f66..543f928e8089 100644 --- a/drivers/staging/r8188eu/include/rtw_pwrctrl.h +++ b/drivers/staging/r8188eu/include/rtw_pwrctrl.h @@ -4,8 +4,8 @@ #ifndef __RTW_PWRCTRL_H_ #define __RTW_PWRCTRL_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define FW_PWR0 0 #define FW_PWR1 1 diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index 9a81e66d93fd..857269ae4209 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -4,8 +4,8 @@ #ifndef _RTW_RECV_H_ #define _RTW_RECV_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define NR_RECVFRAME 256 diff --git a/drivers/staging/r8188eu/include/rtw_rf.h b/drivers/staging/r8188eu/include/rtw_rf.h index 17d34dead8e0..0f790da7e0aa 100644 --- a/drivers/staging/r8188eu/include/rtw_rf.h +++ b/drivers/staging/r8188eu/include/rtw_rf.h @@ -4,7 +4,7 @@ #ifndef __RTW_RF_H_ #define __RTW_RF_H_ -#include +#include "rtw_cmd.h" #define OFDM_PHY 1 #define MIXED_PHY 2 diff --git a/drivers/staging/r8188eu/include/rtw_security.h b/drivers/staging/r8188eu/include/rtw_security.h index 2d8522c01027..f8863926c905 100644 --- a/drivers/staging/r8188eu/include/rtw_security.h +++ b/drivers/staging/r8188eu/include/rtw_security.h @@ -4,8 +4,8 @@ #ifndef __RTW_SECURITY_H_ #define __RTW_SECURITY_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define _NO_PRIVACY_ 0x0 #define _WEP40_ 0x1 diff --git a/drivers/staging/r8188eu/include/rtw_sreset.h b/drivers/staging/r8188eu/include/rtw_sreset.h index 1ac7d566362a..9ecd75258310 100644 --- a/drivers/staging/r8188eu/include/rtw_sreset.h +++ b/drivers/staging/r8188eu/include/rtw_sreset.h @@ -4,8 +4,8 @@ #ifndef _RTW_SRESET_C_ #define _RTW_SRESET_C_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" struct sreset_priv { struct mutex silentreset_mutex; @@ -15,7 +15,7 @@ struct sreset_priv { unsigned long last_tx_complete_time; }; -#include +#include "rtl8188e_hal.h" #define WIFI_STATUS_SUCCESS 0 #define USB_VEN_REQ_CMD_FAIL BIT0 diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h index 7155d3fa4bb5..e1418a3f7ed1 100644 --- a/drivers/staging/r8188eu/include/rtw_xmit.h +++ b/drivers/staging/r8188eu/include/rtw_xmit.h @@ -4,8 +4,8 @@ #ifndef _RTW_XMIT_H_ #define _RTW_XMIT_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" #define MAX_XMITBUF_SZ (20480) /* 20k */ #define NR_XMITBUFF (4) @@ -362,6 +362,6 @@ int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms); void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status); /* include after declaring struct xmit_buf, in order to avoid warning */ -#include +#include "xmit_osdep.h" #endif /* _RTL871X_XMIT_H_ */ diff --git a/drivers/staging/r8188eu/include/sta_info.h b/drivers/staging/r8188eu/include/sta_info.h index 97233f85c4bd..8ff99fc6381d 100644 --- a/drivers/staging/r8188eu/include/sta_info.h +++ b/drivers/staging/r8188eu/include/sta_info.h @@ -4,9 +4,9 @@ #ifndef __STA_INFO_H_ #define __STA_INFO_H_ -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "wifi.h" #define IBSS_START_MAC_ID 2 #define NUM_STA 32 diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index 6267d0999400..273bc2705558 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -4,9 +4,9 @@ #ifndef __USB_OPS_H_ #define __USB_OPS_H_ -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "osdep_intf.h" #define REALTEK_USB_VENQT_READ 0xC0 #define REALTEK_USB_VENQT_WRITE 0x40 @@ -21,7 +21,7 @@ enum { #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) -#include +#include "usb_ops_linux.h" void rtl8188eu_set_hw_type(struct adapter *padapter); #define hal_set_hw_type rtl8188eu_set_hw_type diff --git a/drivers/staging/r8188eu/include/usb_osintf.h b/drivers/staging/r8188eu/include/usb_osintf.h index 71f6273e69c5..d1a1f739309c 100644 --- a/drivers/staging/r8188eu/include/usb_osintf.h +++ b/drivers/staging/r8188eu/include/usb_osintf.h @@ -4,9 +4,9 @@ #ifndef __USB_OSINTF_H #define __USB_OSINTF_H -#include -#include -#include +#include "osdep_service.h" +#include "drv_types.h" +#include "usb_vendor_req.h" extern char *rtw_initmac; extern int rtw_mc2u_disable; diff --git a/drivers/staging/r8188eu/include/xmit_osdep.h b/drivers/staging/r8188eu/include/xmit_osdep.h index 4a6685d93582..191c36361b63 100644 --- a/drivers/staging/r8188eu/include/xmit_osdep.h +++ b/drivers/staging/r8188eu/include/xmit_osdep.h @@ -4,8 +4,8 @@ #ifndef __XMIT_OSDEP_H_ #define __XMIT_OSDEP_H_ -#include -#include +#include "osdep_service.h" +#include "drv_types.h" struct pkt_file { struct sk_buff *pkt; diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 100369a79666..ffce43f99dd6 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -3,21 +3,21 @@ #define _IOCTL_LINUX_C_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/wlan_bssdef.h" +#include "../include/rtw_debug.h" +#include "../include/wifi.h" +#include "../include/rtw_mlme.h" +#include "../include/rtw_mlme_ext.h" +#include "../include/rtw_ioctl.h" +#include "../include/rtw_ioctl_set.h" +#include "../include/rtw_mp_ioctl.h" +#include "../include/usb_ops.h" +#include "../include/rtl8188e_hal.h" + +#include "../include/rtw_mp.h" +#include "../include/rtw_iol.h" #define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) @@ -5587,7 +5587,7 @@ out: } #endif -#include +#include "../include/rtw_android.h" static int rtw_wx_set_priv(struct net_device *dev, struct iw_request_info *info, union iwreq_data *awrq, @@ -8132,7 +8132,7 @@ exit: return err; } -#include +#include "../include/rtw_android.h" int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct iwreq *wrq = (struct iwreq *)rq; diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index fe434c8c167c..766b346afbb8 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -3,9 +3,9 @@ #define _MLME_OSDEP_C_ -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/mlme_osdep.h" void rtw_join_timeout_handler (struct timer_list *t) { diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index fa20d0f753db..5f1ec883d6ed 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -3,15 +3,15 @@ #define _OS_INTFS_C_ -#include -#include -#include -#include -#include -#include - -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/xmit_osdep.h" +#include "../include/recv_osdep.h" +#include "../include/hal_intf.h" +#include "../include/rtw_ioctl.h" + +#include "../include/usb_osintf.h" +#include "../include/rtw_br_ext.h" #include MODULE_LICENSE("GPL"); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index c7e83c87ad4a..99ddc535e5ea 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -3,11 +3,11 @@ #define _OSDEP_SERVICE_C_ -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/linux/vmalloc.h" +#include "../include/rtw_ioctl_set.h" /* * Translate the OS dependent @param error_code to OS independent RTW_STATUS_CODE diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 410bfbb8a187..1fd3f1bf1fe5 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -3,15 +3,15 @@ #define _RECV_OSDEP_C_ -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" -#include -#include +#include "../include/wifi.h" +#include "../include/recv_osdep.h" -#include -#include -#include +#include "../include/osdep_intf.h" +#include "../include/ethernet.h" +#include "../include/usb_ops.h" /* init os related resource in struct recv_priv */ int rtw_os_recv_resource_init(struct recv_priv *precvpriv, diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index 56fd19138218..ce02bfc6d02a 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -4,12 +4,11 @@ #include #include #include - -#include -#include -#include -#include -#include +#include "../include/rtw_android.h" +#include "../include/osdep_service.h" +#include "../include/rtw_debug.h" +#include "../include/ioctl_cfg80211.h" +#include "../include/rtw_ioctl_set.h" static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { "START", diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 314a3504168e..bc7f4bd7ce0b 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -3,18 +3,17 @@ #define _HCI_INTF_C_ -#include -#include -#include -#include -#include #include -#include - -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/recv_osdep.h" +#include "../include/xmit_osdep.h" +#include "../include/hal_intf.h" +#include "../include/osdep_intf.h" +#include "../include/usb_vendor_req.h" +#include "../include/usb_ops.h" +#include "../include/usb_osintf.h" +#include "../include/rtw_ioctl.h" int ui_pid[3] = {0, 0, 0}; diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c index 399d7d91eb4a..dd4bd14b76c2 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -3,9 +3,9 @@ #define _USB_OPS_LINUX_C_ -#include -#include -#include +#include "../include/drv_types.h" +#include "../include/usb_ops_linux.h" +#include "../include/rtw_sreset.h" unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) { diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index c82ae1fdd0d2..421328173984 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -4,16 +4,15 @@ #define _XMIT_OSDEP_C_ #include -#include -#include - -#include -#include -#include -#include -#include -#include -#include +#include "../include/osdep_service.h" +#include "../include/drv_types.h" +#include "../include/if_ether.h" +#include "../include/ip.h" +#include "../include/wifi.h" +#include "../include/mlme_osdep.h" +#include "../include/xmit_osdep.h" +#include "../include/osdep_intf.h" +#include "../include/usb_osintf.h" uint rtw_remainder_len(struct pkt_file *pfile) { -- cgit v1.2.3 From 76ac3b19a702d346674c7b2082af9654b2e58c50 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Fri, 30 Jul 2021 16:54:05 +0200 Subject: staging: rtl8723bs: fix camel case issue in struct wlan_bssid_ex fix camel case issue in field Reserved in struct wlan_bssid_ex Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/a70fd91a46fd2c75eb27824ea57ae0d87d65bf81.1627656773.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 12 ++++++------ drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 8 ++++---- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 2 +- drivers/staging/rtl8723bs/include/wlan_bssdef.h | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 ++++++------ 6 files changed, 19 insertions(+), 19 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index a0c19253095d..9f97986e8680 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -483,8 +483,8 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, } if (update_ie) { - dst->Reserved[0] = src->Reserved[0]; - dst->Reserved[1] = src->Reserved[1]; + dst->reserved[0] = src->reserved[0]; + dst->reserved[1] = src->reserved[1]; memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); } @@ -600,13 +600,13 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork->last_scanned = jiffies; - /* target.Reserved[0]== 1, means that scanned network is a bcn frame. */ - if ((pnetwork->network.ie_length > target->ie_length) && (target->Reserved[0] == 1)) + /* target.reserved[0]== 1, means that scanned network is a bcn frame. */ + if ((pnetwork->network.ie_length > target->ie_length) && (target->reserved[0] == 1)) update_ie = false; /* probe resp(3) > beacon(1) > probe req(2) */ - if ((target->Reserved[0] != 2) && - (target->Reserved[0] >= pnetwork->network.Reserved[0]) + if ((target->reserved[0] != 2) && + (target->reserved[0] >= pnetwork->network.reserved[0]) ) { update_ie = true; } else { diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c index 07986eeafe08..375d2a742dd2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme_ext.c @@ -3971,18 +3971,18 @@ u8 collect_bss_info(struct adapter *padapter, union recv_frame *precv_frame, str subtype = GetFrameSubType(pframe); if (subtype == WIFI_BEACON) { - bssid->Reserved[0] = 1; + bssid->reserved[0] = 1; ie_offset = _BEACON_IE_OFFSET_; } else { /* FIXME : more type */ if (subtype == WIFI_PROBERSP) { ie_offset = _PROBERSP_IE_OFFSET_; - bssid->Reserved[0] = 3; + bssid->reserved[0] = 3; } else if (subtype == WIFI_PROBEREQ) { ie_offset = _PROBEREQ_IE_OFFSET_; - bssid->Reserved[0] = 2; + bssid->reserved[0] = 2; } else { - bssid->Reserved[0] = 0; + bssid->reserved[0] = 0; ie_offset = _FIXED_IE_LENGTH_; } } diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 2a2a8634beb7..865a82d5cedb 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -1223,7 +1223,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) subtype = GetFrameSubType(pframe) >> 4; if (subtype == WIFI_BEACON) - bssid->Reserved[0] = 1; + bssid->reserved[0] = 1; bssid->length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; diff --git a/drivers/staging/rtl8723bs/include/wlan_bssdef.h b/drivers/staging/rtl8723bs/include/wlan_bssdef.h index 530c95275c1e..eb38594c8f5c 100644 --- a/drivers/staging/rtl8723bs/include/wlan_bssdef.h +++ b/drivers/staging/rtl8723bs/include/wlan_bssdef.h @@ -156,7 +156,7 @@ struct wlan_bcn_info { struct wlan_bssid_ex { u32 length; NDIS_802_11_MAC_ADDRESS mac_address; - u8 Reserved[2];/* 0]: IS beacon frame */ + u8 reserved[2];/* 0]: IS beacon frame */ struct ndis_802_11_ssid ssid; u32 privacy; long rssi;/* in dBM, raw data , get from PHY) */ diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index dc23470fcdef..12b8e1773a84 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -305,7 +305,7 @@ struct cfg80211_bss *rtw_cfg80211_inform_bss(struct adapter *padapter, struct wl SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); /* pmlmeext->mgnt_seq++; */ - if (pnetwork->network.Reserved[0] == 1) { /* WIFI_BEACON */ + if (pnetwork->network.reserved[0] == 1) { /* WIFI_BEACON */ eth_broadcast_addr(pwlanhdr->addr1); SetFrameSubType(pbuf, WIFI_BEACON); } else { diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 1383f84a4425..19c5c7e8f403 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -84,7 +84,7 @@ static char *translate_scan(struct adapter *padapter, u32 i = 0; u8 bw_40MHz = 0, short_GI = 0; u16 mcs_rate = 0, vht_data_rate = 0; - u8 ie_offset = (pnetwork->network.Reserved[0] == 2 ? 0 : 12); + u8 ie_offset = (pnetwork->network.reserved[0] == 2 ? 0 : 12); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); u8 ss, sq; @@ -102,7 +102,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); /* parsing HT_CAP_IE */ - if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ + if (pnetwork->network.reserved[0] == 2) { /* Probe Request */ p = rtw_get_ie(&pnetwork->network.ies[0], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length); } else { p = rtw_get_ie(&pnetwork->network.ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length-12); @@ -140,7 +140,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); /* Add mode */ - if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ + if (pnetwork->network.reserved[0] == 2) { /* Probe Request */ cap = 0; } else { __le16 le_tmp; @@ -211,7 +211,7 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); /* parsing WPA/WPA2 IE */ - if (pnetwork->network.Reserved[0] != 2) { /* Probe Request */ + if (pnetwork->network.reserved[0] != 2) { /* Probe Request */ u8 *buf; u8 wpa_ie[255], rsn_ie[255]; u16 wpa_len = 0, rsn_len = 0; @@ -274,7 +274,7 @@ static char *translate_scan(struct adapter *padapter, u8 *ie_ptr; total_ielen = pnetwork->network.ie_length - ie_offset; - if (pnetwork->network.Reserved[0] == 2) { /* Probe Request */ + if (pnetwork->network.reserved[0] == 2) { /* Probe Request */ ie_ptr = pnetwork->network.ies; total_ielen = pnetwork->network.ie_length; } else { /* Beacon or Probe Respones */ @@ -324,7 +324,7 @@ static char *translate_scan(struct adapter *padapter, if (!buf) goto exit; - pos = pnetwork->network.Reserved; + pos = pnetwork->network.reserved; memset(&iwe, 0, sizeof(iwe)); iwe.cmd = IWEVCUSTOM; iwe.u.data.length = scnprintf(buf, MAX_WPA_IE_LEN, "fm =%02X%02X", pos[1], pos[0]); -- cgit v1.2.3 From 8255017976dec902e25fe7669605aa58a6e7c0ac Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Fri, 30 Jul 2021 16:54:06 +0200 Subject: staging: rtl8723bs: remove unnecessary parentheses fix the following checkpatch issues: CHECK: Unnecessary parentheses around 'pnetwork->network.ie_length > target->ie_length' 33: FILE: drivers/staging/rtl8723bs/core/rtw_mlme.c:604: + if ((pnetwork->network.ie_length > target->ie_length) && (target->reserved[0] == 1)) CHECK: Unnecessary parentheses around 'target->reserved[0] == 1' 33: FILE: drivers/staging/rtl8723bs/core/rtw_mlme.c:604: + if ((pnetwork->network.ie_length > target->ie_length) && (target->reserved[0] == 1)) CHECK: Unnecessary parentheses around 'target->reserved[0] != 2' 39: FILE: drivers/staging/rtl8723bs/core/rtw_mlme.c:608: + if ((target->reserved[0] != 2) && + (target->reserved[0] >= pnetwork->network.reserved[0]) ) { CHECK: Unnecessary parentheses around 'target->reserved[0] >= pnetwork->network.reserved[0]' 39: FILE: drivers/staging/rtl8723bs/core/rtw_mlme.c:608: + if ((target->reserved[0] != 2) && + (target->reserved[0] >= pnetwork->network.reserved[0]) ) { Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/fca83a857ebb158cf395ea31f1834c04402c39e4.1627656773.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 9f97986e8680..df599c2009b3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -601,12 +601,12 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork->last_scanned = jiffies; /* target.reserved[0]== 1, means that scanned network is a bcn frame. */ - if ((pnetwork->network.ie_length > target->ie_length) && (target->reserved[0] == 1)) + if (pnetwork->network.ie_length > target->ie_length && target->reserved[0] == 1) update_ie = false; /* probe resp(3) > beacon(1) > probe req(2) */ - if ((target->reserved[0] != 2) && - (target->reserved[0] >= pnetwork->network.reserved[0]) + if (target->reserved[0] != 2 && + target->reserved[0] >= pnetwork->network.reserved[0] ) { update_ie = true; } else { -- cgit v1.2.3 From b8afef0e13720739d41808f0b88970b84c1ec3ff Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Fri, 30 Jul 2021 16:54:07 +0200 Subject: staging: rtl8723bs: align condition to match open parentheses fix following checkpatch issue: CHECK: Alignment should match open parenthesis 54: FILE: drivers/staging/rtl8723bs/core/rtw_mlme.c:609: + if (target->reserved[0] != 2 && + target->reserved[0] >= pnetwork->network.reserved[0] Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/941bd42ef6b7d76e80685b133046669a0ca82d8e.1627656773.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index df599c2009b3..d3d068babb5e 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -606,7 +606,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t /* probe resp(3) > beacon(1) > probe req(2) */ if (target->reserved[0] != 2 && - target->reserved[0] >= pnetwork->network.reserved[0] + target->reserved[0] >= pnetwork->network.reserved[0] ) { update_ie = true; } else { -- cgit v1.2.3 From 9b6818c1ac0e545c632265e4bf0aa1171347ebea Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Fri, 30 Jul 2021 16:54:08 +0200 Subject: staging: rtl8723bs: put condition parentheses at the end of a line put the closing parenthese at the end of a line Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/295a41c98cd475ae25f9288d99a929b75492db3f.1627656773.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index d3d068babb5e..5ed13bf765d2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -606,8 +606,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t /* probe resp(3) > beacon(1) > probe req(2) */ if (target->reserved[0] != 2 && - target->reserved[0] >= pnetwork->network.reserved[0] - ) { + target->reserved[0] >= pnetwork->network.reserved[0]) { update_ie = true; } else { update_ie = false; -- cgit v1.2.3 From 56febcc2595e2bf2546c5bb4c35740ce883771a2 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 30 Jul 2021 20:14:52 +0200 Subject: staging: r8188eu: Fix different base types in assignments and parameters Fix sparse warnings of different base types in assignments and in passing function parameters. Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210730181452.23062-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 46 ++++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 6e42ecd0b53f..8f434768dd15 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -71,7 +71,7 @@ static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *t struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; - data_len = tag->tag_len + TAG_HDR_LEN; + data_len = be16_to_cpu(tag->tag_len) + TAG_HDR_LEN; if (skb_tailroom(skb) < data_len) { _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n"); return -1; @@ -134,42 +134,68 @@ static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr } static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) + __be32 *ipxNetAddr, unsigned char *ipxNodeAddr) { + union { + unsigned int f0; + unsigned char f1[IPX_NODE_LEN]; + } addr; + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + addr.f0 = be32_to_cpu(*ipxNetAddr); + memcpy(networkAddr+1, addr.f1, 4); memcpy(networkAddr+5, ipxNodeAddr, 6); } static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) + __be32 *ipxNetAddr, __be16 *ipxSocketAddr) { + union { + unsigned int f0; + unsigned char f1[4]; + } addr; + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); - memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); + addr.f0 = be32_to_cpu(*ipxNetAddr); + memcpy(networkAddr+1, addr.f1, 4); + addr.f0 ^= addr.f0; + addr.f0 = be16_to_cpu(*ipxSocketAddr); + memcpy(networkAddr+5, addr.f1, 2); } static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, - unsigned short *network, unsigned char *node) + __be16 *network, unsigned char *node) { + union { + unsigned short f0; + unsigned char f1[2]; + } addr; + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_APPLE; - memcpy(networkAddr+1, (unsigned char *)network, 2); + addr.f0 = be16_to_cpu(*network); + memcpy(networkAddr+1, addr.f1, 2); networkAddr[3] = *node; } static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, - unsigned char *ac_mac, unsigned short *sid) + unsigned char *ac_mac, __be16 *sid) { + union { + unsigned short f0; + unsigned char f1[2]; + } addr; + memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_PPPOE; - memcpy(networkAddr+1, (unsigned char *)sid, 2); + addr.f0 = be16_to_cpu(*sid); + memcpy(networkAddr+1, addr.f1, 2); memcpy(networkAddr+3, (unsigned char *)ac_mac, 6); } -- cgit v1.2.3 From 33852468aa6447fef16c9c3ec79298c8878b7998 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 30 Jul 2021 22:41:52 +0200 Subject: staging: r8188eu: remove spaces before ',' and ')' Remove spaces to clear checkpatch errors. ERROR: space prohibited before that ',' (ctx:WxW) ERROR: space prohibited before that close parenthesis ')' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210730204153.27270-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 2 +- drivers/staging/r8188eu/core/rtw_efuse.c | 4 +- drivers/staging/r8188eu/core/rtw_ieee80211.c | 14 +++--- drivers/staging/r8188eu/core/rtw_io.c | 2 +- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/r8188eu/core/rtw_iol.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme.c | 18 ++++---- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 52 +++++++++++----------- drivers/staging/r8188eu/core/rtw_mp.c | 2 +- drivers/staging/r8188eu/core/rtw_p2p.c | 12 ++--- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 14 +++--- drivers/staging/r8188eu/core/rtw_xmit.c | 6 +-- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 4 +- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 14 +++--- drivers/staging/r8188eu/hal/hal_com.c | 2 +- drivers/staging/r8188eu/hal/odm.c | 10 ++--- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 12 ++--- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 2 +- drivers/staging/r8188eu/hal/usb_halinit.c | 2 +- 19 files changed, 88 insertions(+), 88 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index c7c892ab4ae6..463c9ca40492 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -492,7 +492,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) tx_ra_bitmap |= ((raid<<28)&0xf0000000); DBG_88E("%s => mac_id:%d , raid:%d , bitmap = 0x%x, arg = 0x%x\n", - __func__ , psta->mac_id, raid , tx_ra_bitmap, arg); + __func__, psta->mac_id, raid, tx_ra_bitmap, arg); /* bitmap[0:27] = tx_rate_bitmap */ /* bitmap[28:31]= Rate Adaptive id */ diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index 82eb2134c1e4..e84540a7d2c5 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -245,7 +245,7 @@ u8 EFUSE_Read1Byte(struct adapter *Adapter, u16 Address) u32 k = 0; u16 contentLen = 0; - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI , TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); + EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&contentLen, false); if (Address < contentLen) { /* E-fuse 512Byte */ /* Write E-fuse Register address bit0~7 */ @@ -470,7 +470,7 @@ u8 rtw_efuse_access(struct adapter *padapter, u8 write, u16 start_addr, u16 cnts u16 efuse_GetMaxSize(struct adapter *padapter) { u16 max_size; - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI , TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, false); + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_size, false); return max_size; } /* */ diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index 270a3848c3d6..f5ea93e2fff9 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -772,7 +772,7 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) * * Returns: the address of the specific WPS attribute found, or NULL */ -u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_attr, u32 *len_attr) +u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr) { u8 *attr_ptr = NULL; u8 *target_attr_ptr = NULL; @@ -782,7 +782,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at *len_attr = 0; if ((wps_ie[0] != _VENDOR_SPECIFIC_IE_) || - (memcmp(wps_ie + 2, wps_oui , 4))) + (memcmp(wps_ie + 2, wps_oui, 4))) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ @@ -818,7 +818,7 @@ u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_at * * Returns: the address of the specific WPS attribute content found, or NULL */ -u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id , u8 *buf_content, uint *len_content) +u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content) { u8 *attr_ptr; u32 attr_len; @@ -1217,7 +1217,7 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) * * Returns: the address of the specific WPS attribute found, or NULL */ -u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_attr, u32 *len_attr) +u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_attr, u32 *len_attr) { u8 *attr_ptr = NULL; u8 *target_attr_ptr = NULL; @@ -1227,7 +1227,7 @@ u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_att *len_attr = 0; if (!p2p_ie || (p2p_ie[0] != _VENDOR_SPECIFIC_IE_) || - memcmp(p2p_ie + 2, p2p_oui , 4)) + memcmp(p2p_ie + 2, p2p_oui, 4)) return attr_ptr; /* 6 = 1(Element ID) + 1(Length) + 3 (OUI) + 1(OUI Type) */ @@ -1264,7 +1264,7 @@ u8 *rtw_get_p2p_attr(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_att * * Returns: the address of the specific P2P attribute content found, or NULL */ -u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id , u8 *buf_content, uint *len_content) +u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 *buf_content, uint *len_content) { u8 *attr_ptr; u32 attr_len; @@ -1452,7 +1452,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) } else { pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; } - rtw_get_sec_ie(pnetwork->network.IEs , pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); + rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index e0909d3d6307..2c8e7707c9fa 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -120,7 +120,7 @@ int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) return RTW_STATUS_CODE(ret); } -int _rtw_writeN(struct adapter *adapter, u32 addr , u32 length , u8 *pdata) +int _rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata) { struct io_priv *pio_priv = &adapter->iopriv; struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_priv->intf)); diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 12a99588fbe2..778da7c86995 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -1011,7 +1011,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) if (p && ht_ielen > 0) { pht_capie = (struct ieee80211_ht_cap *)(p+2); - memcpy(&mcs_rate , pht_capie->mcs.rx_mask, 2); + memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */ bw_40MHz = (pmlmeext->cur_bwmode && (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo->HT_info.infos[0])) ? 1 : 0; diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index 2f38ff8cacef..0382ff524657 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -51,7 +51,7 @@ int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len /* check if the io_buf can accommodate new cmds */ if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) { DBG_88E("%s %u is large than MAX_XMITBUF_SZ:%u, can't accommodate new cmds\n", - __func__ , ori_len + cmd_len + 8, MAX_XMITBUF_SZ); + __func__, ori_len + cmd_len + 8, MAX_XMITBUF_SZ); return _FAIL; } diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index fe826e5831a3..f07e4e233788 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -190,7 +190,7 @@ struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *f } plist = (&(free_queue->queue))->next; - pnetwork = container_of(plist , struct wlan_network, list); + pnetwork = container_of(plist, struct wlan_network, list); list_del_init(&pnetwork->list); @@ -209,7 +209,7 @@ exit: return pnetwork; } -void _rtw_free_network(struct mlme_priv *pmlmepriv , struct wlan_network *pnetwork, u8 isfreeall) +void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall) { u32 curr_time, delta_time; u32 lifetime = SCANQUEUE_LIFETIME; @@ -268,7 +268,7 @@ struct wlan_network *_rtw_find_network(struct __queue *scanned_queue, u8 *addr) plist = phead->next; while (plist != phead) { - pnetwork = container_of(plist, struct wlan_network , list); + pnetwork = container_of(plist, struct wlan_network, list); if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) break; plist = plist->next; @@ -700,7 +700,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * } /* TODO: Perry: For Power Management */ -void rtw_atimdone_event_callback(struct adapter *adapter , u8 *pbuf) +void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); @@ -734,7 +734,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) spin_lock_bh(&pmlmepriv->scanned_queue.lock); ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); if (ibss_wlan) { - memcpy(ibss_wlan->network.IEs , pnetwork->IEs, 8); + memcpy(ibss_wlan->network.IEs, pnetwork->IEs, 8); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto exit; } @@ -859,11 +859,11 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) } -void rtw_dummy_event_callback(struct adapter *adapter , u8 *pbuf) +void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf) { } -void rtw_fwdbg_event_callback(struct adapter *adapter , u8 *pbuf) +void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf) { } @@ -1524,7 +1524,7 @@ void _rtw_join_timeout_handler (struct adapter *adapter) DBG_88E("%s try another roaming\n", __func__); do_join_r = rtw_do_join(adapter); if (_SUCCESS != do_join_r) { - DBG_88E("%s roaming do_join return %d\n", __func__ , do_join_r); + DBG_88E("%s roaming do_join return %d\n", __func__, do_join_r); continue; } break; @@ -2169,7 +2169,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ p = rtw_get_ie(in_ie+12, _HT_ADD_INFO_IE_, &ielen, in_len-12); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; - rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2 , pout_len); + rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2, pout_len); } } return phtpriv->ht_option; diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 3fa89ef293d1..1160b7caffdd 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -847,7 +847,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) /* checking for challenging txt... */ DBG_88E("checking for challenging txt...\n"); - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_ , _CHLGETXT_IE_, (int *)&ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&ie_len, len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); if ((p == NULL) || (ie_len <= 0)) { @@ -889,7 +889,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) auth_fail: if (pstat) - rtw_free_stainfo(padapter , pstat); + rtw_free_stainfo(padapter, pstat); pstat = &stat; memset((char *)pstat, '\0', sizeof(stat)); @@ -1096,7 +1096,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame memcpy(supportRate, p+2, ie_len); supportRateNum = ie_len; - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_ , &ie_len, + p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p != NULL) { if (supportRateNum <= sizeof(supportRate)) { @@ -1195,7 +1195,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame if (pmlmepriv->wps_beacon_ie) { u8 selected_registrar = 0; - rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR , &selected_registrar, NULL); + rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL); if (!selected_registrar) { DBG_88E("selected_registrar is false , or AP is not ready to do WPS\n"); @@ -1332,7 +1332,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame #ifdef CONFIG_88EU_P2P pstat->is_p2p_device = false; if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + ie_offset , pkt_len - WLAN_HDR_A3_LEN - ie_offset , NULL, &p2pielen); + p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, pkt_len - WLAN_HDR_A3_LEN - ie_offset, NULL, &p2pielen); if (p2pie) { pstat->is_p2p_device = true; p2p_status_code = (u8)process_assoc_req_p2p_ie(pwdinfo, pframe, pkt_len, pstat); @@ -1593,7 +1593,7 @@ unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) * Added the following code to avoid this case. */ if ((pmlmeinfo->state & WIFI_FW_AUTH_STATE) || - (pmlmeinfo->state & WIFI_FW_ASSOC_STATE )) { + (pmlmeinfo->state & WIFI_FW_ASSOC_STATE)) { if (reason == WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA) { ignore_received_deauth = 1; } else if (WLAN_REASON_PREV_AUTH_NOT_VALID == reason) { @@ -2118,7 +2118,7 @@ void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) p2pielen += 2; /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); p2pielen += pwdinfo->device_name_len; /* Operating Channel */ @@ -2487,7 +2487,7 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame p2pielen += 2; /* Value: */ - memcpy(p2pie + p2pielen, pwdinfo->device_name , pwdinfo->device_name_len); + memcpy(p2pie + p2pielen, pwdinfo->device_name, pwdinfo->device_name_len); p2pielen += pwdinfo->device_name_len; if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { @@ -2501,7 +2501,7 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame /* Value: */ /* p2P Device Address */ - memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); p2pielen += ETH_ALEN; /* SSID */ @@ -2667,7 +2667,7 @@ static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) /* Value: */ /* p2P Device Address */ - memcpy(p2pie + p2pielen , pwdinfo->device_addr, ETH_ALEN); + memcpy(p2pie + p2pielen, pwdinfo->device_addr, ETH_ALEN); p2pielen += ETH_ALEN; /* SSID */ @@ -3418,7 +3418,7 @@ void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) wpsielen += 2; /* Value: */ - memcpy(wpsie + wpsielen, "123456" , ETH_ALEN); + memcpy(wpsie + wpsielen, "123456", ETH_ALEN); wpsielen += ETH_ALEN; /* Primary Device Type */ @@ -4042,7 +4042,7 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) /* The peer device address should be the destination address for the provisioning discovery request. */ /* Then, this Wi-Fi device should use the iwpriv command to get the peer interface address. */ /* The peer interface address should be the address for WPS mac address */ - memcpy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr , ETH_ALEN); + memcpy(pwdinfo->p2p_peer_device_addr, group_id.go_device_addr, ETH_ALEN); rtw_p2p_set_role(pwdinfo, P2P_ROLE_CLIENT); rtw_p2p_set_state(pwdinfo, P2P_STATE_RECV_INVITE_REQ_JOIN); status_code = P2P_STATUS_SUCCESS; @@ -4880,10 +4880,10 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps get_rate_set(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); } /* add wps_ie for wps2.0 */ @@ -5144,13 +5144,13 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* capability */ val = *(unsigned short *)rtw_get_capability_from_ie(ie); - pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_ , (unsigned char *)&val, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_, (unsigned char *)&val, &(pattrib->pktlen)); lestatus = cpu_to_le16(status); - pframe = rtw_set_fixed_ie(pframe , _STATUS_CODE_ , (unsigned char *)&lestatus, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&lestatus, &(pattrib->pktlen)); leval = cpu_to_le16(pstat->aid | BIT(14) | BIT(15)); - pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_ , (unsigned char *)&leval, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, (unsigned char *)&leval, &(pattrib->pktlen)); if (pstat->bssratelen <= 8) { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); @@ -5199,7 +5199,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); /* add WPS IE ie for wps 2.0 */ if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { @@ -5283,7 +5283,7 @@ void issue_assocreq(struct adapter *padapter) /* listen interval */ /* todo: listen interval for power saving */ le_tmp = cpu_to_le16(3); - memcpy(pframe , (unsigned char *)&le_tmp, 2); + memcpy(pframe, (unsigned char *)&le_tmp, 2); pframe += 2; pattrib->pktlen += 2; @@ -5335,10 +5335,10 @@ void issue_assocreq(struct adapter *padapter) } if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_ , (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_ , bssrate_len , bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); } /* RSN */ @@ -5380,7 +5380,7 @@ void issue_assocreq(struct adapter *padapter) memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_2R, 16); break; } - pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len , (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); } } @@ -5410,7 +5410,7 @@ void issue_assocreq(struct adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6 , REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); #ifdef CONFIG_88EU_P2P @@ -5849,7 +5849,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); le_tmp = cpu_to_le16(reason); - pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_ , (unsigned char *)&le_tmp, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); pattrib->last_txcmdsz = pattrib->pktlen; diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index c300af4eee8d..1b4e9bbc394b 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -488,7 +488,7 @@ void SetDataRate(struct adapter *pAdapter) Hal_SetDataRate(pAdapter); } -void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter , bool bMain) +void MP_PHY_SetRFPathSwitch(struct adapter *pAdapter, bool bMain) { PHY_SetRFPathSwitch(pAdapter, bMain); } diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index f94fc7ba9a01..30823bfdd1b5 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -790,9 +790,9 @@ u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l ssid_len &= 0xff; /* Just last 1 byte is valid for ssid len of the probe request */ if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { - p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_ , len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_ , NULL, &p2pielen); + p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen); if (p2pie) { - if ((p != NULL) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid , 7)) { + if ((p != NULL) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) { /* todo: */ /* Check Requested Device Type attributes in WSC IE. */ /* Check Device ID attribute in P2P IE */ @@ -835,7 +835,7 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l ies = pframe + WLAN_HDR_A3_LEN + ie_offset; ies_len = len - WLAN_HDR_A3_LEN - ie_offset; - p2p_ie = rtw_get_p2p_ie(ies , ies_len , NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(ies, ies_len, NULL, &p2p_ielen); if (!p2p_ie) { DBG_88E("[%s] P2P IE not Found!!\n", __func__); @@ -863,7 +863,7 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l u8 num_of_secdev_type; u16 dev_name_len; - rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO , pattr_content, (uint *)&attr_contentlen); + rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, pattr_content, (uint *)&attr_contentlen); memcpy(psta->dev_addr, pattr_content, ETH_ALEN);/* P2P Device Address */ @@ -1129,7 +1129,7 @@ u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) { DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ @@ -1269,7 +1269,7 @@ u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe /* Try to get the peer's intent and tie breaker value. */ attr_content = 0x00; attr_contentlen = 0; - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT , &attr_content, &attr_contentlen)) { + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) { DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index dc72b78877b0..feaf39fddf7c 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -174,7 +174,7 @@ void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) plist = phead->next; while (phead != plist) { - psta = container_of(plist, struct sta_info , list); + psta = container_of(plist, struct sta_info, list); plist = plist->next; } @@ -218,7 +218,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) while (phead != plist) { int i; - psta = container_of(plist, struct sta_info , hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = plist->next; for (i = 0; i < 16; i++) { @@ -289,7 +289,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("alloc number_%d stainfo with hwaddr = %pM\n", - pstapriv->asoc_sta_count , hwaddr)); + pstapriv->asoc_sta_count, hwaddr)); init_addba_retry_timer(pstapriv->padapter, psta); @@ -324,7 +324,7 @@ exit: } /* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) +u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) { int i; struct __queue *pfree_sta_queue; @@ -364,7 +364,7 @@ u32 rtw_free_stainfo(struct adapter *padapter , struct sta_info *psta) spin_unlock_bh(&pxmitpriv->lock); list_del_init(&psta->hash_list); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count , psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); + RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count, psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); pstapriv->asoc_sta_count--; /* re-init sta_info; 20061114 */ @@ -468,12 +468,12 @@ void rtw_free_all_stainfo(struct adapter *padapter) plist = phead->next; while (phead != plist) { - psta = container_of(plist, struct sta_info , hash_list); + psta = container_of(plist, struct sta_info, hash_list); plist = plist->next; if (pbcmc_stainfo != psta) - rtw_free_stainfo(padapter , psta); + rtw_free_stainfo(padapter, psta); } } spin_unlock_bh(&pstapriv->sta_hash_lock); diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 7ecffadcb61f..5a45df5531ef 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -650,7 +650,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr if (pattrib->psta) stainfo = pattrib->psta; else - stainfo = rtw_get_stainfo(&padapter->stapriv , &pattrib->ra[0]); + stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);; @@ -778,7 +778,7 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi return _SUCCESS; } -s32 rtw_make_wlanhdr (struct adapter *padapter , u8 *hdr, struct pkt_attrib *pattrib) +s32 rtw_make_wlanhdr (struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { u16 *qc; @@ -1826,7 +1826,7 @@ static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib u8 qsel; qsel = pattrib->priority; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority=%d , qsel = %d\n", pattrib->priority , qsel)); + RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority=%d , qsel = %d\n", pattrib->priority, qsel)); pattrib->qsel = qsel; } diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index 2baea6141fe2..436cf866012a 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -86,7 +86,7 @@ static u8 DROPING_NECESSARY[RATESIZE] = { static u8 PendingForRateUpFail[5] = {2, 10, 24, 40, 60}; static u16 DynamicTxRPTTiming[6] = { - 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12 , 0x927c}; /* 200ms-1200ms */ + 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12, 0x927c}; /* 200ms-1200ms */ /* End Rate adaptive parameters */ @@ -712,7 +712,7 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 pRAInfo->RTY[0], pRAInfo->RTY[1], pRAInfo->RTY[2], pRAInfo->RTY[3], pRAInfo->RTY[4], pRAInfo->DROP, - macid_entry0 , macid_entry1)); + macid_entry0, macid_entry1)); if (pRAInfo->PTActive) { if (pRAInfo->RAstage < 5) odm_RateDecision_8188E(dm_odm, pRAInfo); diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index c31f01c0fdd2..e1059c5dd711 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -39,7 +39,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, do { pwrcfgcmd = pwrseqcmd[aryidx]; - RT_TRACE(_module_hal_init_c_ , _drv_info_, + RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", GET_PWR_CFG_OFFSET(pwrcfgcmd), GET_PWR_CFG_CUT_MASK(pwrcfgcmd), @@ -56,10 +56,10 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, (GET_PWR_CFG_INTF_MASK(pwrcfgcmd) & ifacetype)) { switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { case PWR_CMD_READ: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); break; case PWR_CMD_WRITE: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); /* Read the value from system register */ @@ -72,7 +72,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, rtw_write8(padapter, offset, value); break; case PWR_CMD_POLLING: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); poll_bit = false; offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); @@ -92,7 +92,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, } while (!poll_bit); break; case PWR_CMD_DELAY: - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else @@ -100,11 +100,11 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, break; case PWR_CMD_END: /* When this command is parsed, end the process */ - RT_TRACE(_module_hal_init_c_ , _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); + RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); return true; break; default: - RT_TRACE(_module_hal_init_c_ , _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); + RT_TRACE(_module_hal_init_c_, _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); break; } } diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index ca50c3c85578..66a2f3d6d9e7 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -340,7 +340,7 @@ s32 c2h_evt_read(struct adapter *adapter, u8 *buf) *(buf+1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): ", - &c2h_evt , sizeof(c2h_evt)); + &c2h_evt, sizeof(c2h_evt)); /* Read the content */ for (i = 0; i < c2h_evt->plen; i++) diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index c6c184d95fee..49e4c8bfc6ef 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1153,8 +1153,8 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) /* 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode. */ /* Suggested by SD3 Yu-Nan. 2011.01.20. */ if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874 , BIT5, 0x1); /* Reg874[5]=1b'1 */ - ODM_SetBBReg(pDM_Odm, 0x874 , 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ + ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x1); /* Reg874[5]=1b'1 */ + ODM_SetBBReg(pDM_Odm, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); /* RegC70[3]=1'b0 */ ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ @@ -1162,7 +1162,7 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); /* Reg818[28]=1'b0 */ ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); /* Reg818[28]=1'b1 */ } else { - ODM_SetBBReg(pDM_Odm, 0x874 , 0x1CC000, pDM_PSTable->Reg874); + ODM_SetBBReg(pDM_Odm, 0x874, 0x1CC000, pDM_PSTable->Reg874); ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70); ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); @@ -1334,7 +1334,7 @@ void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; if (IS_STA_VALID(pstat)) { - if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false , &pstat->rssi_level)) { + if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) { ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI:%d, RSSI_LEVEL:%d\n", pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level)); @@ -1554,7 +1554,7 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; FindMinimumRSSI(Adapter); - ODM_CmnInfoUpdate(&pHalData->odmpriv , ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); + ODM_CmnInfoUpdate(&pHalData->odmpriv, ODM_CMNINFO_RSSI_MIN, pdmpriv->MinUndecoratedPWDBForDM); } void odm_RSSIMonitorCheckAP(struct odm_dm_struct *pDM_Odm) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 27bc1db07f55..fa6c092e714d 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -431,7 +431,7 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) if (blockCount_p2) { RT_TRACE(_module_hal_init_c_, _drv_notice_, ("_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", - (buffSize-offset), blockSize_p2 , blockCount_p2, remainSize_p2)); + (buffSize-offset), blockSize_p2, blockCount_p2, remainSize_p2)); } for (i = 0; i < blockCount_p2; i++) { @@ -702,7 +702,7 @@ static void rtl8188e_free_hal_data(struct adapter *padapter) /* */ enum{ VOLTAGE_V25 = 0x03, - LDOE25_SHIFT = 28 , + LDOE25_SHIFT = 28, }; static bool @@ -1112,7 +1112,7 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr , &tmpdata[2], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[2], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) badworden &= (~BIT1); @@ -2152,7 +2152,7 @@ void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1) ? true : false; DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) , bSupportRemoteWakeup(%x)\n", __func__, - padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown , padapter->pwrctrlpriv.bSupportRemoteWakeup); + padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown, padapter->pwrctrlpriv.bSupportRemoteWakeup); DBG_88E("### PS params => power_mgnt(%x), usbss_enable(%x) ###\n", padapter->registrypriv.power_mgnt, padapter->registrypriv.usbss_enable); } @@ -2182,8 +2182,8 @@ void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool Auto } if (bIn24G) { DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch); - DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_CCK_Base[rfPath][ch]); - DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch , pHalData->Index24G_BW40_Base[rfPath][ch]); + DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_CCK_Base[rfPath][ch]); + DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_BW40_Base[rfPath][ch]); } } for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index 626741087391..510906cc6007 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -545,7 +545,7 @@ s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) void Hal_TriggerRFThermalMeter(struct adapter *pAdapter) { - _write_rfreg(pAdapter, RF_PATH_A , RF_T_METER_88E , BIT17 | BIT16 , 0x03); + _write_rfreg(pAdapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); } u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter) diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index d50a887ad7ea..c90a7574b1cf 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -1886,7 +1886,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) } break; case HW_VAR_H2C_MEDIA_STATUS_RPT: - rtl8188e_set_FwMediaStatus_cmd(Adapter , (*(__le16 *)val)); + rtl8188e_set_FwMediaStatus_cmd(Adapter, (*(__le16 *)val)); break; case HW_VAR_BCN_VALID: /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ -- cgit v1.2.3 From bf99a7ce2f2f159ffc18749407df526ad469e9a8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 30 Jul 2021 22:41:53 +0200 Subject: staging: r8188eu: add missing spaces after ',' and before braces Add missing spaces to clear checkpatch errors. ERROR: space required before the open parenthesis '(' ERROR: space required before the open brace '{' ERROR: space required after that ',' (ctx:ExV) Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210730204153.27270-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme.c | 10 +++++----- drivers/staging/r8188eu/core/rtw_security.c | 4 ++-- drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 2 +- drivers/staging/r8188eu/hal/hal_intf.c | 2 +- drivers/staging/r8188eu/hal/odm_RegConfig8188E.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/os_dep/rtw_android.c | 4 ++-- 8 files changed, 14 insertions(+), 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 463c9ca40492..0bb545135206 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -1028,7 +1028,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* set Max Rx AMPDU size to 64K */ pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); - if(rf_type == RF_1T1R) { + if (rf_type == RF_1T1R) { pht_cap->mcs.rx_mask[0] = 0xff; pht_cap->mcs.rx_mask[1] = 0x0; } diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index f07e4e233788..d692f1477cc8 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1317,7 +1317,7 @@ static u8 search_max_mac_id(struct adapter *padapter) } /* FOR AP , AD-HOC mode */ -void rtw_sta_media_status_rpt(struct adapter *adapter,struct sta_info *psta, +void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u32 mstatus) { u16 media_status_rpt; @@ -1330,7 +1330,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter,struct sta_info *psta, rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); /* MACID|OPMODE:1 connect */ media_status_rpt = (u16)((psta->mac_id<<8) | mstatus); - rtw_hal_set_hwreg(adapter,HW_VAR_H2C_MEDIA_STATUS_RPT, + rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status_rpt); } @@ -1428,7 +1428,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if(adapter->registrypriv.wifi_spec == 1) + if (adapter->registrypriv.wifi_spec == 1) rtw_set_roaming(adapter, 0); /* don't roam */ else if (rtw_to_roaming(adapter) > 0) pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ @@ -1651,7 +1651,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv if (rtw_is_desired_network(adapter, competitor) == false) goto exit; - if(rtw_to_roaming(adapter) > 0) { + if (rtw_to_roaming(adapter) > 0) { if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= RTW_SCAN_RESULT_EXPIRE || is_same_ess(&competitor->network, &pmlmepriv->cur_network.network) == false) goto exit; @@ -1668,7 +1668,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv (*candidate)->network.Ssid.Ssid, (*candidate)->network.MacAddress, (int)(*candidate)->network.Rssi); - DBG_88E("[to_roaming:%u]\n",rtw_to_roaming(adapter)); + DBG_88E("[to_roaming:%u]\n", rtw_to_roaming(adapter)); } exit: diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index ee4775b8284b..2c1b9a6dcdf2 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -1229,7 +1229,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); - } else{ + } else { length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); @@ -1237,7 +1237,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) pframe = (u8 *)RND4((size_t)(pframe)); } } - } else{ + } else { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); res = _FAIL; } diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c index fc58d5fb1264..f90827577059 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -539,7 +539,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 5); } else if (v1 == 0xf9) { rtw_IOL_append_DELAY_US_cmd(pxmit_frame, 1); - } else{ + } else { if (v1 == 0xa24) dm_odm->RFCalibrateInfo.RegA24 = v2; diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index cb0635850aa8..1d813b6c3678 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -201,7 +201,7 @@ u8 rtw_hal_intf_ps_func(struct adapter *adapt, s32 rtw_hal_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) { - if(padapter->HalFunc.hal_xmitframe_enqueue) + if (padapter->HalFunc.hal_xmitframe_enqueue) return padapter->HalFunc.hal_xmitframe_enqueue(padapter, pxmitframe); return false; } diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c index a26c36cf8786..1a2055249192 100644 --- a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c @@ -77,7 +77,7 @@ void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, ODM_delay_us(5); } else if (Addr == 0xf9) { ODM_delay_us(1); - } else{ + } else { ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===> @@@@@@@ ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", Addr, Bitmask, Data)); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index fa6c092e714d..1a7a62dd8504 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -1741,7 +1741,7 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) } else if (IS_2T2R(ChipVersion)) { pHalData->rf_type = RF_2T2R; pHalData->NumTotalRFPath = 2; - } else{ + } else { pHalData->rf_type = RF_1T1R; pHalData->NumTotalRFPath = 1; } diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index ce02bfc6d02a..2b9e719e2a51 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -62,12 +62,12 @@ static int g_wifi_on = true; int rtw_android_cmdstr_to_num(char *cmdstr) { int cmd_num; - for(cmd_num=0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) + for (cmd_num=0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) #if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) #else - if(0 == strnicmp(cmdstr, android_wifi_cmd_str[cmd_num], + if (0 == strnicmp(cmdstr, android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) #endif break; -- cgit v1.2.3 From 15e4539f58c4b96a7706cab77e58941ca7eb4748 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:24 +0100 Subject: staging: r8188eu: remove ODM_PRINT_ADDR macro definition Remove ODM_PRINT_ADDR macro definition from include/odm_debug.h, as it is called from nowhere and is therefore superfluous. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/odm_debug.h | 13 ------------- 1 file changed, 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index 171fc5cbf27c..53ab6debb6f3 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -108,19 +108,6 @@ #define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } #define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } -#define ODM_PRINT_ADDR(pDM_Odm, comp, level, title_str, ptr) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ - int __i; \ - u8 *__ptr = (u8 *)ptr; \ - DbgPrint("[ODM] "); \ - DbgPrint(title_str); \ - DbgPrint(" "); \ - for (__i = 0; __i < 6; __i++) \ - DbgPrint("%02X%s", __ptr[__i], (__i==5)?"":"-");\ - DbgPrint("\n"); \ - } - void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); #endif /* __ODM_DBG_H__ */ -- cgit v1.2.3 From 6a6580673e0b65c45b1bf1e0c866be5de998e1dc Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:25 +0100 Subject: staging: r8188eu: remove ODM_dbg_* macro definitions Remove ODM_dbg_* macro definitions from include/odm_debug.h, as they are called from nowhere and are therefore superfluous. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/odm_debug.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index 53ab6debb6f3..73fdea598707 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -104,9 +104,6 @@ RT_PRINTK fmt; \ ASSERT(false); \ } -#define ODM_dbg_enter() { DbgPrint("==> %s\n", __func__); } -#define ODM_dbg_exit() { DbgPrint("<== %s\n", __func__); } -#define ODM_dbg_trace(str) { DbgPrint("%s:%s\n", __func__, str); } void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); -- cgit v1.2.3 From c32641183bbcf6c000f114c010085c72b15a8796 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:26 +0100 Subject: staging: r8188eu: remove ODM_RT_ASSERT macro definition and caller Remove ODM_RT_ASSERT macro definition from include/odm_debug.h and its one caller in hal/odm.c, as this debug code is against best practice. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm.c | 1 - drivers/staging/r8188eu/include/odm_debug.h | 9 --------- 2 files changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 49e4c8bfc6ef..9ddd8c94cc98 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1373,7 +1373,6 @@ bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate LowRSSIThreshForRA += GoUpGap; break; default: - ODM_RT_ASSERT(pDM_Odm, false, ("wrong rssi level setting %d !", *pRATRState)); break; } diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index 73fdea598707..c11d8925952c 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -96,15 +96,6 @@ RT_PRINTK fmt; \ } -#define ODM_RT_ASSERT(pDM_Odm, expr, fmt) \ - if (!(expr)) { \ - DbgPrint( "Assertion failed! %s at ......\n", #expr); \ - DbgPrint( " ......%s,%s,line=%d\n", __FILE__, \ - __func__, __LINE__); \ - RT_PRINTK fmt; \ - ASSERT(false); \ - } - void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); #endif /* __ODM_DBG_H__ */ -- cgit v1.2.3 From 6a772eabd4014bf7d846a9a661016e9c1deb1dd6 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:27 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE_F macro definition Remove ODM_RT_TRACE_F macro definition from include/odm_debug.h, as it is called from nowhere and is therefore superfluous. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/odm_debug.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index c11d8925952c..ef0d6b84b2d5 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -90,12 +90,6 @@ RT_PRINTK fmt; \ } -#define ODM_RT_TRACE_F(pDM_Odm, comp, level, fmt) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ - RT_PRINTK fmt; \ - } - void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); #endif /* __ODM_DBG_H__ */ -- cgit v1.2.3 From 8362f65afa3391ba71786114983da7b485876db0 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:28 +0100 Subject: staging: r8188eu: remove ASSERT ifndef and macro definition Remove ASSERT ifndef and macro definition from include/odm_debug.h, as these are unused and therefore superfluous. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/odm_debug.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index ef0d6b84b2d5..c70fe73e3339 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -68,10 +68,6 @@ #define RT_PRINTK(fmt, args...) \ DbgPrint( "%s(): " fmt, __func__, ## args); -#ifndef ASSERT - #define ASSERT(expr) -#endif - #define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ if (((comp) & pDM_Odm->DebugComponents) && \ (level <= pDM_Odm->DebugLevel)) { \ -- cgit v1.2.3 From 8bde3b8aaf3d3b4abf3e3f07cf85c377ddc2bbad Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:29 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE calls from hal/Hal8188ERateAdaptive.c Remove ODM_RT_TRACE calls from hal/Hal8188ERateAdaptive.c, as by removing these calls in this file and others, we can ultimately then remove the macro definition itself, which does not follow best practice. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 99 +--------------------- 1 file changed, 2 insertions(+), 97 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index 436cf866012a..d41bfbe8ec9c 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -113,8 +113,6 @@ static void odm_SetTxRPTTiming_8188E( idx -= 1; } pRaInfo->RptTime = DynamicTxRPTTiming[idx]; - - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("pRaInfo->RptTime = 0x%x\n", pRaInfo->RptTime)); } static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) @@ -122,18 +120,12 @@ static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info * u8 RateID, LowestRate, HighestRate; u8 i; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDown_8188E()\n")); - if (NULL == pRaInfo) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateDown_8188E(): pRaInfo is NULL\n")); + if (NULL == pRaInfo) return -1; - } RateID = pRaInfo->PreRate; LowestRate = pRaInfo->LowestRate; HighestRate = pRaInfo->HighestRate; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" RateID =%d LowestRate =%d HighestRate =%d RateSGI =%d\n", - RateID, LowestRate, HighestRate, pRaInfo->RateSGI)); if (RateID > HighestRate) { RateID = HighestRate; } else if (pRaInfo->RateSGI) { @@ -166,10 +158,6 @@ RateDownFinish: pRaInfo->DecisionRate = RateID; odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down, RPT Timing default\n")); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate down to RateID %d RateSGI %d\n", RateID, pRaInfo->RateSGI)); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDown_8188E()\n")); return 0; } @@ -181,16 +169,10 @@ static int odm_RateUp_8188E( u8 RateID, HighestRate; u8 i; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateUp_8188E()\n")); - if (NULL == pRaInfo) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E(): pRaInfo is NULL\n")); + if (NULL == pRaInfo) return -1; - } RateID = pRaInfo->PreRate; HighestRate = pRaInfo->HighestRate; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" RateID =%d HighestRate =%d\n", - RateID, HighestRate)); if (pRaInfo->RAWaitingCounter == 1) { pRaInfo->RAWaitingCounter = 0; pRaInfo->RAPendingCounter = 0; @@ -199,7 +181,6 @@ static int odm_RateUp_8188E( goto RateUpfinish; } odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("odm_RateUp_8188E():Decrease RPT Timing\n")); if (RateID < HighestRate) { for (i = RateID+1; i <= HighestRate; i++) { @@ -223,9 +204,6 @@ RateUpfinish: pRaInfo->RAWaitingCounter++; pRaInfo->DecisionRate = RateID; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("Rate up to RateID %d\n", RateID)); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("RAWaitingCounter %d, RAPendingCounter %d", pRaInfo->RAWaitingCounter, pRaInfo->RAPendingCounter)); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateUp_8188E()\n")); return 0; } @@ -246,8 +224,6 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, /* u32 pool_retry; */ static u8 DynamicTxRPTTimingCounter; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("=====>odm_RateDecision_8188E()\n")); - if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || (pRaInfo->RssiStaRA > (pRaInfo->PreRssiStaRA + 3))) { @@ -265,16 +241,11 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, RtyPtID = 1; PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */ - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" NscDown init is %d\n", pRaInfo->NscDown)); pRaInfo->NscDown += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID1][0]; pRaInfo->NscDown += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID1][1]; pRaInfo->NscDown += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID1][2]; pRaInfo->NscDown += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID1][3]; pRaInfo->NscDown += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID1][4]; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" NscDown is %d, total*penalty[5] is %d\n", - pRaInfo->NscDown, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]))); if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])) pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]; else @@ -282,24 +253,16 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, /* rate up */ PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID]; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" NscUp init is %d\n", pRaInfo->NscUp)); pRaInfo->NscUp += pRaInfo->RTY[0] * RETRY_PENALTY[PenaltyID2][0]; pRaInfo->NscUp += pRaInfo->RTY[1] * RETRY_PENALTY[PenaltyID2][1]; pRaInfo->NscUp += pRaInfo->RTY[2] * RETRY_PENALTY[PenaltyID2][2]; pRaInfo->NscUp += pRaInfo->RTY[3] * RETRY_PENALTY[PenaltyID2][3]; pRaInfo->NscUp += pRaInfo->RTY[4] * RETRY_PENALTY[PenaltyID2][4]; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("NscUp is %d, total*up[5] is %d\n", - pRaInfo->NscUp, (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]))); if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5])) pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]; else pRaInfo->NscUp = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE|ODM_COMP_INIT, ODM_DBG_LOUD, - (" RssiStaRa = %d RtyPtID =%d PenaltyID1 = 0x%x PenaltyID2 = 0x%x RateID =%d NscDown =%d NscUp =%d SGI =%d\n", - pRaInfo->RssiStaRA, RtyPtID, PenaltyID1, PenaltyID2, RateID, pRaInfo->NscDown, pRaInfo->NscUp, pRaInfo->RateSGI)); if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) || (pRaInfo->DROP > DROPING_NECESSARY[RateID])) odm_RateDown_8188E(dm_odm, pRaInfo); @@ -316,8 +279,6 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, if (DynamicTxRPTTimingCounter >= 4) { odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 1); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, - ODM_DBG_LOUD, ("<===== Rate don't change 4 times, Extend RPT Timing\n")); DynamicTxRPTTimingCounter = 0; } @@ -325,7 +286,6 @@ static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, odm_ResetRaCounter_8188E(pRaInfo); } - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, ("<===== odm_RateDecision_8188E()\n")); } static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) @@ -405,15 +365,10 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf pRaInfo->PTModeSS = 1; else pRaInfo->PTModeSS = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("ODM_ARFBRefresh_8188E(): PTModeSS =%d\n", pRaInfo->PTModeSS)); if (pRaInfo->DecisionRate > pRaInfo->HighestRate) pRaInfo->DecisionRate = pRaInfo->HighestRate; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("ODM_ARFBRefresh_8188E(): RateID =%d RateMask =%8.8x RAUseRate =%8.8x HighestRate =%d, DecisionRate =%d\n", - pRaInfo->RateID, pRaInfo->RateMask, pRaInfo->RAUseRate, pRaInfo->HighestRate, pRaInfo->DecisionRate)); return 0; } @@ -510,15 +465,10 @@ odm_RATxRPTTimerSetting( u16 minRptTime ) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" =====>odm_RATxRPTTimerSetting()\n")); - if (dm_odm->CurrminRptTime != minRptTime) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - (" CurrminRptTime = 0x%04x minRptTime = 0x%04x\n", dm_odm->CurrminRptTime, minRptTime)); rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime); dm_odm->CurrminRptTime = minRptTime; } - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, (" <===== odm_RATxRPTTimerSetting()\n")); } void @@ -526,8 +476,6 @@ ODM_RASupport_Init( struct odm_dm_struct *dm_odm ) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>ODM_RASupport_Init()\n")); - /* 2012/02/14 MH Be noticed, the init must be after IC type is recognized!!!!! */ if (dm_odm->SupportICType == ODM_RTL8188E) dm_odm->RaSupport88E = true; @@ -550,10 +498,6 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) max_rate_idx = 0x03; } - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("ODM_RAInfo_Init(): WirelessMode:0x%08x , max_raid_idx:0x%02x\n", - WirelessMode, max_rate_idx)); - pRaInfo->DecisionRate = max_rate_idx; pRaInfo->PreRate = max_rate_idx; pRaInfo->HighestRate = max_rate_idx; @@ -594,7 +538,6 @@ int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm) { u8 macid = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("=====>\n")); dm_odm->CurrminRptTime = 0; for (macid = 0; macid < ODM_ASSOCIATE_ENTRY_NUM; macid++) @@ -607,8 +550,6 @@ u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 macid) { if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("macid =%d SGI =%d\n", macid, dm_odm->RAInfo[macid].RateSGI)); return dm_odm->RAInfo[macid].RateSGI; } @@ -619,8 +560,6 @@ u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid) if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return 0; DecisionRate = (dm_odm->RAInfo[macid].DecisionRate); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" macid =%d DecisionRate = 0x%x\n", macid, DecisionRate)); return DecisionRate; } @@ -631,8 +570,6 @@ u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 macid) if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return 0; PTStage = (dm_odm->RAInfo[macid].PTStage); - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - ("macid =%d PTStage = 0x%x\n", macid, PTStage)); return PTStage; } @@ -640,9 +577,6 @@ void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rate { struct odm_ra_info *pRaInfo = NULL; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("macid =%d RateID = 0x%x RateMask = 0x%x SGIEnable =%d\n", - macid, RateID, RateMask, SGIEnable)); if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return; @@ -657,8 +591,6 @@ void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) { struct odm_ra_info *pRaInfo = NULL; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_TRACE, - (" macid =%d Rssi =%d\n", macid, Rssi)); if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return; @@ -679,10 +611,6 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 u32 valid = 0, ItemNum = 0; u16 minRptTime = 0x927c; - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("=====>ODM_RA_TxRPT2Handle_8188E(): valid0 =%d valid1 =%d BufferLength =%d\n", - macid_entry0, macid_entry1, TxRPT_Len)); - ItemNum = TxRPT_Len >> 3; pBuffer = TxRPT_Buf; @@ -706,13 +634,6 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 pRAInfo->RTY[2] + pRAInfo->RTY[3] + pRAInfo->RTY[4] + pRAInfo->DROP; if (pRAInfo->TOTAL != 0) { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, - ("macid =%d Total =%d R0 =%d R1 =%d R2 =%d R3 =%d R4 =%d D0 =%d valid0 =%x valid1 =%x\n", - MacId, pRAInfo->TOTAL, - pRAInfo->RTY[0], pRAInfo->RTY[1], - pRAInfo->RTY[2], pRAInfo->RTY[3], - pRAInfo->RTY[4], pRAInfo->DROP, - macid_entry0, macid_entry1)); if (pRAInfo->PTActive) { if (pRAInfo->RAstage < 5) odm_RateDecision_8188E(dm_odm, pRAInfo); @@ -729,20 +650,6 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 } else { odm_RateDecision_8188E(dm_odm, pRAInfo); } - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, - ("macid =%d R0 =%d R1 =%d R2 =%d R3 =%d R4 =%d drop =%d valid0 =%x RateID =%d SGI =%d\n", - MacId, - pRAInfo->RTY[0], - pRAInfo->RTY[1], - pRAInfo->RTY[2], - pRAInfo->RTY[3], - pRAInfo->RTY[4], - pRAInfo->DROP, - macid_entry0, - pRAInfo->DecisionRate, - pRAInfo->RateSGI)); - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, (" TOTAL = 0!!!!\n")); } } @@ -754,6 +661,4 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 } while (MacId < ItemNum); odm_RATxRPTTimerSetting(dm_odm, minRptTime); - - ODM_RT_TRACE(dm_odm, ODM_COMP_RATE_ADAPTIVE, ODM_DBG_LOUD, ("<===== ODM_RA_TxRPT2Handle_8188E()\n")); } -- cgit v1.2.3 From 73f1e06f55d44ef1f29feb9d52c04f3d428a3b20 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:30 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE calls from hal/HalPhyRf_8188e.c Remove ODM_RT_TRACE calls from hal/HalPhyRf_8188e.c, as by removing these calls in this file and others, we can ultimately then remove the macro definition itself, which does not follow best practice. Reported-by: kernel test robot Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-8-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 228 +-------------------------- 1 file changed, 7 insertions(+), 221 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index 1eb459532da5..d1613a9278c4 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -39,10 +39,6 @@ void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, /* Tx power tracking BB swing table. */ /* The base index = 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB */ if (Type == 0) { /* For OFDM afjust */ - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", - dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); - if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) { *pDirection = 1; pwr_value = (dm_odm->BbSwingIdxOfdmBase - dm_odm->BbSwingIdxOfdm); @@ -50,15 +46,7 @@ void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, *pDirection = 2; pwr_value = (dm_odm->BbSwingIdxOfdm - dm_odm->BbSwingIdxOfdmBase); } - - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("BbSwingIdxOfdm = %d BbSwingFlagOfdm=%d\n", - dm_odm->BbSwingIdxOfdm, dm_odm->BbSwingFlagOfdm)); } else if (Type == 1) { /* For CCK adjust. */ - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, - ("dm_odm->BbSwingIdxCck = %d dm_odm->BbSwingIdxCckBase = %d\n", - dm_odm->BbSwingIdxCck, dm_odm->BbSwingIdxCckBase)); - if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) { *pDirection = 1; pwr_value = (dm_odm->BbSwingIdxCckBase - dm_odm->BbSwingIdxCck); @@ -98,7 +86,6 @@ void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, static void odm_TxPwrTrackSetPwr88E(struct odm_dm_struct *dm_odm) { if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { - ODM_RT_TRACE(dm_odm, ODM_COMP_TX_PWR_TRACK, ODM_DBG_LOUD, ("odm_TxPwrTrackSetPwr88E CH=%d\n", *(dm_odm->pChannel))); PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *(dm_odm->pChannel)); dm_odm->BbSwingFlagOfdm = false; dm_odm->BbSwingFlagCck = false; @@ -151,16 +138,8 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( /* RFCalibrateInfo.RegA24 will be initialized when ODM HW configuring, but MP configures with para files. */ dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("===>dm_TXPowerTrackingCallback_ThermalMeter_8188E txpowercontrol %d\n", - dm_odm->RFCalibrateInfo.TxPowerTrackControl)); - ThermalValue = (u8)ODM_GetRFReg(dm_odm, RF_PATH_A, RF_T_METER_88E, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x\n", - ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, pHalData->EEPROMThermalMeter)); - if (is2t) rf = 2; else @@ -173,9 +152,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { OFDM_index_old[0] = (u8)i; dm_odm->BbSwingIdxOfdmBase = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial pathA ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", - rOFDM0_XATxIQImbalance, ele_D, OFDM_index_old[0])); break; } } @@ -186,9 +162,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { OFDM_index_old[1] = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial pathB ele_D reg0x%x = 0x%x, OFDM_index=0x%x\n", - rOFDM0_XBTxIQImbalance, ele_D, OFDM_index_old[1])); break; } } @@ -202,21 +175,12 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch14[i][2], 4) == 0) { CCK_index_old = (u8)i; dm_odm->BbSwingIdxCckBase = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch 14 %d\n", - rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); break; } } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("RegA24: 0x%X, CCKSwingTable_Ch1_Ch13[%d][2]: CCKSwingTable_Ch1_Ch13[i][2]: 0x%X\n", - TempCCk, i, CCKSwingTable_Ch1_Ch13[i][2])); if (ODM_CompareMemory(dm_odm, (void *)&TempCCk, (void *)&CCKSwingTable_Ch1_Ch13[i][2], 4) == 0) { CCK_index_old = (u8)i; dm_odm->BbSwingIdxCckBase = (u8)i; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Initial reg0x%x = 0x%x, CCK_index=0x%x, ch14 %d\n", - rCCK0_TxFilter2, TempCCk, CCK_index_old, dm_odm->RFCalibrateInfo.bCCKinCH14)); break; } } @@ -232,10 +196,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( dm_odm->RFCalibrateInfo.CCK_index = CCK_index_old; } - if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("reload ofdm index for band switch\n")); - /* calculate average thermal meter */ dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = ThermalValue; dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++; @@ -249,11 +209,8 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( } } - if (ThermalValue_AVG_count) { + if (ThermalValue_AVG_count) ThermalValue = (u8)(ThermalValue_AVG / ThermalValue_AVG_count); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("AVG Thermal Meter = 0x%x\n", ThermalValue)); - } if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { delta = ThermalValue > pHalData->EEPROMThermalMeter ? @@ -276,16 +233,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( delta_IQK = (ThermalValue > dm_odm->RFCalibrateInfo.ThermalValue_IQK) ? (ThermalValue - dm_odm->RFCalibrateInfo.ThermalValue_IQK) : (dm_odm->RFCalibrateInfo.ThermalValue_IQK - ThermalValue); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Readback Thermal Meter = 0x%x pre thermal meter 0x%x EEPROMthermalmeter 0x%x delta 0x%x delta_LCK 0x%x delta_IQK 0x%x\n", - ThermalValue, dm_odm->RFCalibrateInfo.ThermalValue, - pHalData->EEPROMThermalMeter, delta, delta_LCK, delta_IQK)); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("pre thermal meter LCK 0x%x pre thermal meter IQK 0x%x delta_LCK_bound 0x%x delta_IQK_bound 0x%x\n", - dm_odm->RFCalibrateInfo.ThermalValue_LCK, - dm_odm->RFCalibrateInfo.ThermalValue_IQK, - dm_odm->RFCalibrateInfo.Delta_LCK, - dm_odm->RFCalibrateInfo.Delta_IQK)); if ((delta_LCK >= 8)) { /* Delta temperature is equal to or larger than 20 centigrade. */ dm_odm->RFCalibrateInfo.ThermalValue_LCK = ThermalValue; @@ -314,19 +261,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( OFDM_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + OFDM_index_mapping[j][offset]; CCK_index = dm_odm->RFCalibrateInfo.CCK_index + OFDM_index_mapping[j][offset]; - if (is2t) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("temp OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", - dm_odm->RFCalibrateInfo.OFDM_index[0], - dm_odm->RFCalibrateInfo.OFDM_index[1], - dm_odm->RFCalibrateInfo.CCK_index)); - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("temp OFDM_A_index=0x%x, CCK_index=0x%x\n", - dm_odm->RFCalibrateInfo.OFDM_index[0], - dm_odm->RFCalibrateInfo.CCK_index)); - } - for (i = 0; i < rf; i++) { if (OFDM_index[i] > OFDM_TABLE_SIZE_92D-1) OFDM_index[i] = OFDM_TABLE_SIZE_92D-1; @@ -339,16 +273,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( else if (CCK_index < 0) CCK_index = 0; - if (is2t) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("new OFDM_A_index=0x%x, OFDM_B_index=0x%x, CCK_index=0x%x\n", - OFDM_index[0], OFDM_index[1], CCK_index)); - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("new OFDM_A_index=0x%x, CCK_index=0x%x\n", - OFDM_index[0], CCK_index)); - } - /* 2 temporarily remove bNOPG */ /* Config by SwingTable */ if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) { @@ -387,10 +311,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( /* to increase TX power. Otherwise, EVM will be bad. */ } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("TxPwrTracking for path A: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xe94=0x%x 0xe9c=0x%x\n", - (u32)X, (u32)Y, (u32)ele_A, (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); - if (is2t) { ele_D = (OFDMSwingTable[(u8)OFDM_index[1]] & 0xFFC00000)>>22; @@ -422,17 +342,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, 0x00); } - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("TxPwrTracking path B: X=0x%x, Y=0x%x ele_A=0x%x ele_C=0x%x ele_D=0x%x 0xeb4=0x%x 0xebc=0x%x\n", - (u32)X, (u32)Y, (u32)ele_A, - (u32)ele_C, (u32)ele_D, (u32)X, (u32)Y)); } - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("TxPwrTracking 0xc80 = 0x%x, 0xc94 = 0x%x RF 0x24 = 0x%x\n", - ODM_GetBBReg(dm_odm, 0xc80, bMaskDWord), ODM_GetBBReg(dm_odm, - 0xc94, bMaskDWord), ODM_GetRFReg(dm_odm, RF_PATH_A, 0x24, bRFRegOffsetMask))); } } @@ -444,8 +354,6 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) dm_odm->RFCalibrateInfo.ThermalValue = ThermalValue; } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("<===dm_TXPowerTrackingCallback_ThermalMeter_8188E\n")); dm_odm->RFCalibrateInfo.TXPowercount = 0; } @@ -460,39 +368,30 @@ phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) u8 result = 0x00; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK!\n")); /* 1 Tx IQK */ /* path-A IQK setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A IQK setting!\n")); ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); ODM_SetBBReg(dm_odm, rTx_IQK_PI_A, bMaskDWord, 0x8214032a); ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); /* LO calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); /* One shot, path A LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ ODM_delay_ms(IQK_DELAY_TIME_88E); /* Check failed */ regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); if (!(regeac & BIT28) && (((regE94 & 0x03FF0000)>>16) != 0x142) && @@ -508,11 +407,9 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) u8 result = 0x00; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK!\n")); /* 1 Get TXIMR setting */ /* modify RXIQK mode table */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table!\n")); ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); @@ -536,30 +433,19 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160000); /* LO calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); /* One shot, path A LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Delay %d ms for One shot, path A LOK & IQK.\n", - IQK_DELAY_TIME_88E)); ODM_delay_ms(IQK_DELAY_TIME_88E); /* Check failed */ regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xeac = 0x%x\n", regeac)); regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xe94 = 0x%x\n", regE94)); regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xe9c = 0x%x\n", regE9C)); if (!(regeac & BIT28) && (((regE94 & 0x03FF0000)>>16) != 0x142) && @@ -570,11 +456,9 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, u4tmp); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe40 = 0x%x u4tmp = 0x%x\n", ODM_GetBBReg(dm_odm, rTx_IQK, bMaskDWord), u4tmp)); /* 1 RX IQK */ /* modify RXIQK mode table */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A Rx IQK modify RXIQK mode table 2!\n")); ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); ODM_SetRFReg(dm_odm, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); ODM_SetRFReg(dm_odm, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); @@ -592,28 +476,21 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) ODM_SetBBReg(dm_odm, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f); /* LO calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("LO calibration setting!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); /* One shot, path A LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); ODM_SetBBReg(dm_odm, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Delay %d ms for One shot, path A LOK & IQK.\n", IQK_DELAY_TIME_88E)); /* PlatformStallExecution(IQK_DELAY_TIME_88E*1000); */ ODM_delay_ms(IQK_DELAY_TIME_88E); /* Check failed */ regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xeac = 0x%x\n", regeac)); regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe94 = 0x%x\n", regE94)); regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xe9c = 0x%x\n", regE9C)); regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("0xea4 = 0x%x\n", regEA4)); /* reload RF 0xdf */ ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); @@ -623,8 +500,6 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) (((regEA4 & 0x03FF0000)>>16) != 0x132) && (((regeac & 0x03FF0000)>>16) != 0x36)) result |= 0x02; - else - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK fail!!\n")); return result; } @@ -636,35 +511,20 @@ phy_PathB_IQK_8188E(struct adapter *adapt) u8 result = 0x00; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK!\n")); /* One shot, path B LOK & IQK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("One shot, path A LOK & IQK!\n")); ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000002); ODM_SetBBReg(dm_odm, rIQK_AGC_Cont, bMaskDWord, 0x00000000); /* delay x ms */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Delay %d ms for One shot, path B LOK & IQK.\n", - IQK_DELAY_TIME_88E)); ODM_delay_ms(IQK_DELAY_TIME_88E); /* Check failed */ regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xeac = 0x%x\n", regeac)); regeb4 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xeb4 = 0x%x\n", regeb4)); regebc = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xebc = 0x%x\n", regebc)); regec4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xec4 = 0x%x\n", regec4)); regecc = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("0xecc = 0x%x\n", regecc)); if (!(regeac & BIT31) && (((regeb4 & 0x03FF0000)>>16) != 0x142) && @@ -677,8 +537,7 @@ phy_PathB_IQK_8188E(struct adapter *adapt) (((regec4 & 0x03FF0000)>>16) != 0x132) && (((regecc & 0x03FF0000)>>16) != 0x36)) result |= 0x02; - else - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Rx IQK fail!!\n")); + return result; } @@ -688,9 +547,6 @@ static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u s32 Y, TX0_C; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Path A IQ Calibration %s !\n", - (iqkok) ? "Success" : "Failed")); if (final_candidate == 0xFF) { return; @@ -701,9 +557,6 @@ static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u if ((X & 0x00000200) != 0) X = X | 0xFFFFFC00; TX0_A = (X * Oldval_0) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("X = 0x%x, TX0_A = 0x%x, Oldval_0 0x%x\n", - X, TX0_A, Oldval_0)); ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1)); @@ -713,16 +566,13 @@ static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u Y = Y | 0xFFFFFC00; TX0_C = (Y * Oldval_0) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX = 0x%x\n", Y, TX0_C)); ODM_SetBBReg(dm_odm, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6)); ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F)); ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1)); - if (txonly) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("patha_fill_iqk only Tx OK\n")); + if (txonly) return; - } reg = result[final_candidate][2]; ODM_SetBBReg(dm_odm, rOFDM0_XARxIQImbalance, 0x3FF, reg); @@ -741,9 +591,6 @@ static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u s32 Y, TX1_C; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("Path B IQ Calibration %s !\n", - (iqkok) ? "Success" : "Failed")); if (final_candidate == 0xFF) { return; @@ -754,7 +601,6 @@ static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u if ((X & 0x00000200) != 0) X = X | 0xFFFFFC00; TX1_A = (X * Oldval_1) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("X = 0x%x, TX1_A = 0x%x\n", X, TX1_A)); ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1)); @@ -764,7 +610,6 @@ static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u Y = Y | 0xFFFFFC00; TX1_C = (Y * Oldval_1) >> 8; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Y = 0x%x, TX1_C = 0x%x\n", Y, TX1_C)); ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6)); ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F)); @@ -802,7 +647,6 @@ void _PHY_SaveADDARegisters(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup if (!ODM_CheckPowerStatus(adapt)) return; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save ADDA parameters.\n")); for (i = 0; i < RegisterNum; i++) { ADDABackup[i] = ODM_GetBBReg(dm_odm, ADDAReg[i], bMaskDWord); } @@ -817,7 +661,6 @@ static void _PHY_SaveMACRegisters( u32 i; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Save MAC parameters.\n")); for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { MACBackup[i] = ODM_Read1Byte(dm_odm, MACReg[i]); } @@ -830,7 +673,6 @@ static void reload_adda_reg(struct adapter *adapt, u32 *ADDAReg, u32 *ADDABackup struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload ADDA power saving parameters !\n")); for (i = 0; i < RegiesterNum; i++) ODM_SetBBReg(dm_odm, ADDAReg[i], bMaskDWord, ADDABackup[i]); } @@ -846,7 +688,6 @@ _PHY_ReloadMACRegisters( struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Reload MAC parameters !\n")); for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) { ODM_Write1Byte(dm_odm, MACReg[i], (u8)MACBackup[i]); } @@ -865,7 +706,6 @@ _PHY_PathADDAOn( u32 i; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("ADDA ON.\n")); pathOn = isPathAOn ? 0x04db25a4 : 0x0b1b25a4; if (!is2t) { @@ -890,8 +730,6 @@ _PHY_MACSettingCalibration( struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("MAC settings for Calibration.\n")); - ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { @@ -908,8 +746,6 @@ _PHY_PathAStandBy( struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path-A standby mode!\n")); - ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x0); ODM_SetBBReg(dm_odm, 0x840, bMaskDWord, 0x00010000); ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); @@ -924,8 +760,6 @@ static void _PHY_PIModeSwitch( struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("BB Switch to %s mode!\n", (PIMode ? "PI" : "SI"))); - mode = PIMode ? 0x01000100 : 0x01000000; ODM_SetBBReg(dm_odm, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode); ODM_SetBBReg(dm_odm, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode); @@ -956,8 +790,6 @@ static bool phy_SimularityCompare_8188E( else bound = 4; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("===> IQK:phy_SimularityCompare_8188E c1 %d c2 %d!!!\n", c1, c2)); - sim_bitmap = 0; for (i = 0; i < bound; i++) { @@ -979,10 +811,6 @@ static bool phy_SimularityCompare_8188E( diff = (tmp1 > tmp2) ? (tmp1 - tmp2) : (tmp2 - tmp1); if (diff > MAX_TOLERANCE) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK:phy_SimularityCompare_8188E differnece overflow index %d compare1 0x%x compare2 0x%x!!!\n", - i, resulta[c1][i], resulta[c2][i])); - if ((i == 2 || i == 6) && !sim_bitmap) { if (resulta[c1][i] + resulta[c1][i+1] == 0) final_candidate[(i/4)] = c2; @@ -996,8 +824,6 @@ static bool phy_SimularityCompare_8188E( } } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:phy_SimularityCompare_8188E sim_bitmap %d !!!\n", sim_bitmap)); - if (sim_bitmap == 0) { for (i = 0; i < (bound/4); i++) { if (final_candidate[i] != 0xFF) { @@ -1066,14 +892,11 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, /* PHY_REG.txt , and radio_a, radio_b.txt */ if (t == 0) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); - /* Save ADDA parameters, turn Path A ADDA on */ _PHY_SaveADDARegisters(adapt, ADDA_REG, dm_odm->RFCalibrateInfo.ADDA_backup, IQK_ADDA_REG_NUM); _PHY_SaveMACRegisters(adapt, IQK_MAC_REG, dm_odm->RFCalibrateInfo.IQK_MAC_backup); _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQ Calibration for %s for %d times\n", (is2t ? "2T2R" : "1T1R"), t)); _PHY_PathADDAOn(adapt, ADDA_REG, true, is2t); if (t == 0) @@ -1111,7 +934,6 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, ODM_SetBBReg(dm_odm, rConfig_AntB, bMaskDWord, 0x0f600000); /* IQ calibration setting */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK setting!\n")); ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x80800000); ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, 0x01007c00); ODM_SetBBReg(dm_odm, rRx_IQK, bMaskDWord, 0x81004800); @@ -1119,9 +941,8 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, for (i = 0; i < retryCount; i++) { PathAOK = phy_PathA_IQK_8188E(adapt, is2t); if (PathAOK == 0x01) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Tx IQK Success!!\n")); - result[t][0] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; - result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; + result[t][0] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; + result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; break; } } @@ -1129,19 +950,12 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, for (i = 0; i < retryCount; i++) { PathAOK = phy_PathA_RxIQK(adapt, is2t); if (PathAOK == 0x03) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Success!!\n")); - result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; - result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; break; - } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A Rx IQK Fail!!\n")); } } - if (0x00 == PathAOK) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path A IQK failed!!\n")); - } - if (is2t) { _PHY_PathAStandBy(adapt); @@ -1151,26 +965,19 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, for (i = 0; i < retryCount; i++) { PathBOK = phy_PathB_IQK_8188E(adapt); if (PathBOK == 0x03) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK Success!!\n")); result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; result[t][6] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; result[t][7] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; break; } else if (i == (retryCount - 1) && PathBOK == 0x01) { /* Tx IQK OK */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B Only Tx IQK Success!!\n")); result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; } } - - if (0x00 == PathBOK) { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("Path B IQK failed!!\n")); - } } /* Back to BB mode, load original value */ - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Back to BB mode, load original value!\n")); ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0); if (t != 0) { @@ -1196,7 +1003,6 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, ODM_SetBBReg(dm_odm, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); ODM_SetBBReg(dm_odm, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("phy_IQCalibrate_8188E() <==\n")); } #define ODM_TARGET_CHNL_NUM_2G_5G 59 @@ -1313,11 +1119,9 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) return; if (recovery) { - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("PHY_IQCalibrate_8188E: Return due to recovery!\n")); reload_adda_reg(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); return; } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK:Start!!!\n")); for (i = 0; i < 8; i++) { result[0][i] = 0; @@ -1342,7 +1146,6 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) is12simular = phy_SimularityCompare_8188E(adapt, result, 0, 1); if (is12simular) { final_candidate = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is12simular final_candidate is %x\n", final_candidate)); break; } } @@ -1351,14 +1154,12 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) is13simular = phy_SimularityCompare_8188E(adapt, result, 0, 2); if (is13simular) { final_candidate = 0; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is13simular final_candidate is %x\n", final_candidate)); break; } is23simular = phy_SimularityCompare_8188E(adapt, result, 1, 2); if (is23simular) { final_candidate = 1; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: is23simular final_candidate is %x\n", final_candidate)); } else { final_candidate = 3; } @@ -1374,9 +1175,6 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) RegEBC = result[i][5]; RegEC4 = result[i][6]; RegECC = result[i][7]; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", - RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); } if (final_candidate != 0xff) { @@ -1392,15 +1190,9 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) dm_odm->RFCalibrateInfo.RegEBC = RegEBC; RegEC4 = result[final_candidate][6]; RegECC = result[final_candidate][7]; - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK: final_candidate is %x\n", final_candidate)); - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("IQK: RegE94=%x RegE9C=%x RegEA4=%x RegEAC=%x RegEB4=%x RegEBC=%x RegEC4=%x RegECC=%x\n", - RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC)); pathaok = true; pathbok = true; } else { - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK: FAIL use default value\n")); dm_odm->RFCalibrateInfo.RegE94 = 0x100; dm_odm->RFCalibrateInfo.RegEB4 = 0x100; /* X default value */ dm_odm->RFCalibrateInfo.RegE9C = 0x0; @@ -1422,11 +1214,8 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][i] = result[final_candidate][i]; dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].bIQKDone = true; } - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("\nIQK OK Indexforchannel %d.\n", Indexforchannel)); _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, ("IQK finished\n")); } void PHY_LCCalibrate_8188E(struct adapter *adapt) @@ -1462,9 +1251,6 @@ void PHY_LCCalibrate_8188E(struct adapter *adapt) } dm_odm->RFCalibrateInfo.bLCKInProgress = false; - - ODM_RT_TRACE(dm_odm, ODM_COMP_CALIBRATION, ODM_DBG_LOUD, - ("LCK:Finish!!!interface %d\n", dm_odm->InterfaceIndex)); } static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2t) -- cgit v1.2.3 From da232ccb973ac154c1d294ff668eb56fb8dad867 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:31 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE calls from hal/odm_HWConfig.c Remove ODM_RT_TRACE calls from hal/odm_HWConfig.c, as by removing these calls in this file and others, we can ultimately then remove the macro definition itself, which does not follow best practice. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-9-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_HWConfig.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 93a91cce21ec..5f29535590cd 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -535,15 +535,11 @@ enum HAL_STATUS ODM_ConfigRFWithHeaderFile(struct odm_dm_struct *dm_odm, enum rf_radio_path content, enum rf_radio_path rfpath) { - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("===>ODM_ConfigRFWithHeaderFile\n")); if (dm_odm->SupportICType == ODM_RTL8188E) { if (rfpath == RF_PATH_A) READ_AND_CONFIG(8188E, _RadioA_1T_); - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_A:Rtl8188ERadioA_1TArray\n")); - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, (" ===> ODM_ConfigRFWithHeaderFile() Radio_B:Rtl8188ERadioB_1TArray\n")); } - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("ODM_ConfigRFWithHeaderFile: Radio No %x\n", rfpath)); return HAL_STATUS_SUCCESS; } @@ -557,8 +553,6 @@ enum HAL_STATUS ODM_ConfigBBWithHeaderFile(struct odm_dm_struct *dm_odm, READ_AND_CONFIG(8188E, _AGC_TAB_1T_); } else if (config_tp == CONFIG_BB_PHY_REG_PG) { READ_AND_CONFIG(8188E, _PHY_REG_PG_); - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, - (" ===> phy_ConfigBBWithHeaderFile() agc:Rtl8188EPHY_REG_PGArray\n")); } } return HAL_STATUS_SUCCESS; -- cgit v1.2.3 From 40677a39a6dfc61c937ef6344beb41d56b5217f0 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:32 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE calls from hal/odm_RTL8188E.c Remove ODM_RT_TRACE calls from hal/odm_RTL8188E.c, as by removing these calls in this file and others, we can ultimately then remove the macro definition itself, which does not follow best practice. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-10-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 38 ++---------------------------- 1 file changed, 2 insertions(+), 36 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index baa9c1c977c7..62219a908097 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -7,11 +7,8 @@ void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) { struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { + if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) pDM_DigTable->rx_gain_range_min = (u8) pDM_DigTable->AntDiv_RSSI_max; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("ODM_DIG_LowerBound_88E(): pDM_DigTable->AntDiv_RSSI_max=%d\n", pDM_DigTable->AntDiv_RSSI_max)); - } /* If only one Entry connected */ } @@ -25,7 +22,6 @@ static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* 1:CG, 0:CS */ return; } - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_RX_HWAntDivInit()\n")); /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); @@ -54,7 +50,6 @@ static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, 0); /* Default RX (0/1) */ return; } - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_TRX_HWAntDivInit()\n")); /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); @@ -88,12 +83,8 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; u32 AntCombination = 2; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("odm_FastAntTrainingInit()\n")); - - if (*(dm_odm->mp_mode) == 1) { - ODM_RT_TRACE(dm_odm, ODM_COMP_INIT, ODM_DBG_LOUD, ("dm_odm->AntDivType: %d\n", dm_odm->AntDivType)); + if (*(dm_odm->mp_mode) == 1) return; - } for (i = 0; i < 6; i++) { dm_fat_tbl->Bssid[i] = 0; @@ -167,9 +158,6 @@ void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *dm_odm) if (dm_odm->SupportICType != ODM_RTL8188E) return; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->AntDivType=%d\n", dm_odm->AntDivType)); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("dm_odm->bIsMPChip=%s\n", (dm_odm->bIsMPChip ? "true" : "false"))); - if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) odm_RX_HWAntDivInit(dm_odm); else if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) @@ -184,7 +172,6 @@ void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) u32 DefaultAnt, OptionalAnt; if (dm_fat_tbl->RxIdleAnt != Ant) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Update Rx Idle Ant\n")); if (Ant == MAIN_ANT) { DefaultAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; OptionalAnt = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; @@ -204,7 +191,6 @@ void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) } } dm_fat_tbl->RxIdleAnt = Ant; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("RxIdleAnt=%s\n", (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); if (Ant != MAIN_ANT) pr_info("RxIdleAnt=AUX_ANT\n"); } @@ -221,13 +207,6 @@ static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId) dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT0; dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT1)>>1; dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT2)>>2; - - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("Tx from TxInfo, TargetAnt=%s\n", - (Ant == MAIN_ANT) ? "MAIN_ANT" : "AUX_ANT")); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("antsel_tr_mux=3'b%d%d%d\n", - dm_fat_tbl->antsel_c[MacId], dm_fat_tbl->antsel_b[MacId], dm_fat_tbl->antsel_a[MacId])); } void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId) @@ -279,16 +258,6 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("MacID=%d, MainAnt_Sum=%d, MainAnt_Cnt=%d\n", - i, dm_fat_tbl->MainAnt_Sum[i], - dm_fat_tbl->MainAnt_Cnt[i])); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("MacID=%d, AuxAnt_Sum=%d, AuxAnt_Cnt=%d\n", - i, dm_fat_tbl->AuxAnt_Sum[i], dm_fat_tbl->AuxAnt_Cnt[i])); - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("MacID=%d, Main_RSSI= %d, Aux_RSSI= %d\n", - i, Main_RSSI, Aux_RSSI)); /* 2 Select MaxRSSI for DIG */ LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; if ((LocalMaxRSSI > AntDivMaxRSSI) && (LocalMaxRSSI < 40)) @@ -330,9 +299,7 @@ void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) if ((dm_odm->SupportICType != ODM_RTL8188E) || (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV))) return; if (!dm_odm->bLinked) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_AntennaDiversity_88E(): No Link.\n")); if (dm_fat_tbl->bBecomeLinked) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn off HW AntDiv\n")); ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* RegC50[7]=1'b1 enable HW AntDiv */ ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 0); /* Enable CCK AntDiv */ if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) @@ -342,7 +309,6 @@ void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) return; } else { if (!dm_fat_tbl->bBecomeLinked) { - ODM_RT_TRACE(dm_odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Need to Turn on HW AntDiv\n")); /* Because HW AntDiv is disabled before Link, we enable HW AntDiv after link */ ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 1); /* Enable CCK AntDiv */ -- cgit v1.2.3 From a04e78c3711eddde9706871441a4eaefad3d71f7 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:33 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE calls from hal/odm_RegConfig8188E.c Remove ODM_RT_TRACE calls from hal/odm_RegConfig8188E.c, as by removing these calls in this file and others, we can ultimately then remove the macro definition itself, which does not follow best practice. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-11-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_RegConfig8188E.c | 29 ++++++------------------ 1 file changed, 7 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c index 1a2055249192..ec8158e37cb3 100644 --- a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c @@ -32,7 +32,6 @@ void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data u32 maskforPhySet = (u32)(content&0xE000); odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_A, Addr|maskforPhySet); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioA] %08X %08X\n", Addr, Data)); } void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) @@ -41,14 +40,11 @@ void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data u32 maskforPhySet = (u32)(content&0xE000); odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_B, Addr|maskforPhySet); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigRFWithHeaderFile: [RadioB] %08X %08X\n", Addr, Data)); } void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) { ODM_Write1Byte(pDM_Odm, Addr, Data); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, ("===> ODM_ConfigMACWithHeaderFile: [MAC_REG] %08X %08X\n", Addr, Data)); } void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) @@ -56,33 +52,25 @@ void odm_ConfigBB_AGC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask ODM_SetBBReg(pDM_Odm, Addr, Bitmask, Data); /* Add 1us delay between BB/RF register setting. */ ODM_delay_us(1); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, - ("===> ODM_ConfigBBWithHeaderFile: [AGC_TAB] %08X %08X\n", - Addr, Data)); } void odm_ConfigBB_PHY_REG_PG_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) { - if (Addr == 0xfe) { + if (Addr == 0xfe) ODM_sleep_ms(50); - } else if (Addr == 0xfd) { + else if (Addr == 0xfd) ODM_delay_ms(5); - } else if (Addr == 0xfc) { + else if (Addr == 0xfc) ODM_delay_ms(1); - } else if (Addr == 0xfb) { + else if (Addr == 0xfb) ODM_delay_us(50); - } else if (Addr == 0xfa) { + else if (Addr == 0xfa) ODM_delay_us(5); - } else if (Addr == 0xf9) { + else if (Addr == 0xf9) ODM_delay_us(1); - } else { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_LOUD, - ("===> @@@@@@@ ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X %08X\n", - Addr, Bitmask, Data)); + else storePwrIndexDiffRateOffset(pDM_Odm->Adapter, Addr, Bitmask, Data); - } } void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask, u32 Data) @@ -106,8 +94,5 @@ void odm_ConfigBB_PHY_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Bitmask /* Add 1us delay between BB/RF register setting. */ ODM_delay_us(1); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_INIT, ODM_DBG_TRACE, - ("===> ODM_ConfigBBWithHeaderFile: [PHY_REG] %08X %08X\n", - Addr, Data)); } } -- cgit v1.2.3 From b08c473f3e1534b1f80addc5751daa18321e7124 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:34 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE calls from hal/odm.c Remove ODM_RT_TRACE calls from hal/odm.c, as by removing these calls in this file and others, we can ultimately then remove the macro definition itself, which does not follow best practice. Also remove three empty functions and their calls from hal/odm.c, as they only contained ODM_RT_TRACE calls, and remove the corresponding include/odm_precomp.h declarations. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-12-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm.c | 190 +++----------------------- drivers/staging/r8188eu/include/odm_precomp.h | 3 - 2 files changed, 17 insertions(+), 176 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 9ddd8c94cc98..783d4f4a53a5 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -160,7 +160,6 @@ void ODM_DMInit(struct odm_dm_struct *pDM_Odm) { /* 2012.05.03 Luke: For all IC series */ odm_CommonInfoSelfInit(pDM_Odm); - odm_CmnInfoInit_Debug(pDM_Odm); odm_DIGInit(pDM_Odm); odm_RateAdaptiveMaskInit(pDM_Odm); @@ -189,8 +188,6 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) { /* 2012.05.03 Luke: For all IC series */ odm_GlobalAdapterCheck(); - odm_CmnInfoHook_Debug(pDM_Odm); - odm_CmnInfoUpdate_Debug(pDM_Odm); odm_CommonInfoSelfUpdate(pDM_Odm); odm_FalseAlarmCounterStatistics(pDM_Odm); odm_RSSIMonitorCheck(pDM_Odm); @@ -202,13 +199,10 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) if ((pDM_Odm->Adapter->pwrctrlpriv.pwr_mode != PS_MODE_ACTIVE) &&/* in LPS mode */ ((pDM_Odm->SupportICType & (ODM_RTL8723A)) || (pDM_Odm->SupportICType & (ODM_RTL8188E) && - ((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))))) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("----Step1: odm_DIG is in LPS mode\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Step2: 8723AS is in LPS mode\n")); + ((pDM_Odm->SupportInterface == ODM_ITRF_SDIO))))) odm_DIGbyRSSI_LPS(pDM_Odm); - } else { + else odm_DIG(pDM_Odm); - } odm_CCKPacketDetectionThresh(pDM_Odm); if (*(pDM_Odm->pbPowerSaving)) @@ -475,53 +469,6 @@ void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm) pDM_Odm->bOneEntryOnly = false; } -void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm) -{ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoInit_Debug==>\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportPlatform=%d\n", pDM_Odm->SupportPlatform)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportAbility=0x%x\n", pDM_Odm->SupportAbility)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportInterface=%d\n", pDM_Odm->SupportInterface)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("SupportICType=0x%x\n", pDM_Odm->SupportICType)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("CutVersion=%d\n", pDM_Odm->CutVersion)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("FabVersion=%d\n", pDM_Odm->FabVersion)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RFType=%d\n", pDM_Odm->RFType)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("BoardType=%d\n", pDM_Odm->BoardType)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtLNA=%d\n", pDM_Odm->ExtLNA)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtPA=%d\n", pDM_Odm->ExtPA)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("ExtTRSW=%d\n", pDM_Odm->ExtTRSW)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("PatchID=%d\n", pDM_Odm->PatchID)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bInHctTest=%d\n", pDM_Odm->bInHctTest)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFITest=%d\n", pDM_Odm->bWIFITest)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bDualMacSmartConcurrent=%d\n", pDM_Odm->bDualMacSmartConcurrent)); -} - -void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm) -{ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoHook_Debug==>\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumTxBytesUnicast=%llu\n", *(pDM_Odm->pNumTxBytesUnicast))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pNumRxBytesUnicast=%llu\n", *(pDM_Odm->pNumRxBytesUnicast))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pWirelessMode=0x%x\n", *(pDM_Odm->pWirelessMode))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecChOffset=%d\n", *(pDM_Odm->pSecChOffset))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pSecurity=%d\n", *(pDM_Odm->pSecurity))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pBandWidth=%d\n", *(pDM_Odm->pBandWidth))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pChannel=%d\n", *(pDM_Odm->pChannel))); - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbScanInProcess=%d\n", *(pDM_Odm->pbScanInProcess))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pbPowerSaving=%d\n", *(pDM_Odm->pbPowerSaving))); - - if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("pOnePathCCA=%d\n", *(pDM_Odm->pOnePathCCA))); -} - -void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm) -{ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("odm_CmnInfoUpdate_Debug==>\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Direct=%d\n", pDM_Odm->bWIFI_Direct)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bWIFI_Display=%d\n", pDM_Odm->bWIFI_Display)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("bLinked=%d\n", pDM_Odm->bLinked)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_COMMON, ODM_DBG_LOUD, ("RSSI_Min=%d\n", pDM_Odm->RSSI_Min)); -} - static int getIGIForDiff(int value_IGI) { #define ONERCCA_LOW_TH 0x30 @@ -541,10 +488,6 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) { struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("ODM_REG(IGI_A,pDM_Odm)=0x%x, ODM_BIT(IGI,pDM_Odm)=0x%x\n", - ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm))); - if (pDM_DigTable->CurIGValue != CurrentIGI) { if (pDM_Odm->SupportPlatform & (ODM_CE|ODM_MP)) { ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); @@ -569,12 +512,9 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) break; } } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("CurrentIGI(0x%02x).\n", CurrentIGI)); /* pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue; */ pDM_DigTable->CurIGValue = CurrentIGI; } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("ODM_Write_DIG():CurrentIGI=0x%x\n", CurrentIGI)); - /* Add by Neil Chen to enable edcca to MP Platform */ } @@ -597,7 +537,6 @@ void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) /* Using FW PS mode to make IGI */ if (bFwCurrentInPSMode) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("---Neil---odm_DIG is in LPS mode\n")); /* Adjust by FA in LPS MODE */ if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) CurrentIGI = CurrentIGI+2; @@ -669,23 +608,15 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) u8 dm_dig_max, dm_dig_min; u8 CurrentIGI = pDM_DigTable->CurIGValue; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG()==>\n")); - if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG() Return: SupportAbility ODM_BB_DIG or ODM_BB_FA_CNT is disabled\n")); + if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) return; - } - if (*(pDM_Odm->pbScanInProcess)) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: In Scan Progress\n")); + if (*(pDM_Odm->pbScanInProcess)) return; - } /* add by Neil Chen to avoid PSD is processing */ - if (pDM_Odm->bDMInitialGainEnable == false) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() Return: PSD is Processing\n")); + if (pDM_Odm->bDMInitialGainEnable == false) return; - } if (pDM_Odm->SupportICType == ODM_RTL8192D) { if (*(pDM_Odm->pMacPhyMode) == ODM_DMSP) { @@ -765,21 +696,11 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) DIG_Dynamic_MIN = DIG_MaxOfMin; else DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG() : bOneEntryOnly=true, DIG_Dynamic_MIN=0x%x\n", - DIG_Dynamic_MIN)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG() : pDM_Odm->RSSI_Min=%d\n", - pDM_Odm->RSSI_Min)); } else if ((pDM_Odm->SupportICType == ODM_RTL8188E) && (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { /* 1 Lower Bound for 88E AntDiv */ - if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) { + if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("odm_DIG(): pDM_DigTable->AntDiv_RSSI_max=%d\n", - pDM_DigTable->AntDiv_RSSI_max)); - } } else { DIG_Dynamic_MIN = dm_dig_min; } @@ -787,13 +708,10 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } else { pDM_DigTable->rx_gain_range_max = dm_dig_max; DIG_Dynamic_MIN = dm_dig_min; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG() : No Link\n")); } /* 1 Modify DIG lower bound, deal with abnormally large false alarm */ if (pFalseAlmCnt->Cnt_all > 10000) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("dm_DIG(): Abnornally false alarm case.\n")); - if (pDM_DigTable->LargeFAHit != 3) pDM_DigTable->LargeFAHit++; if (pDM_DigTable->ForbiddenIGI < CurrentIGI) { @@ -818,27 +736,20 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) if ((pDM_DigTable->ForbiddenIGI-1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: At Lower Bound\n")); } else { pDM_DigTable->ForbiddenIGI--; pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): Normal Case: Approach Lower Bound\n")); } } else { pDM_DigTable->LargeFAHit = 0; } } } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG(): pDM_DigTable->LargeFAHit=%d\n", - pDM_DigTable->LargeFAHit)); /* 1 Adjust initial gain by false alarm */ if (pDM_Odm->bLinked) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG AfterLink\n")); if (FirstConnect) { CurrentIGI = pDM_Odm->RSSI_Min; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("DIG: First Connect\n")); } else { if (pDM_Odm->SupportICType == ODM_RTL8192D) { if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_92D) @@ -857,10 +768,8 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } } } else { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG BeforeLink\n")); if (FirstDisConnect) { CurrentIGI = pDM_DigTable->rx_gain_range_min; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): First DisConnect\n")); } else { /* 2012.03.30 LukeLee: enable DIG before link but with very high thresholds */ if (pFalseAlmCnt->Cnt_all > 10000) @@ -869,22 +778,14 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) CurrentIGI = CurrentIGI + 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ else if (pFalseAlmCnt->Cnt_all < 500) CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): England DIG\n")); } } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): DIG End Adjust IGI\n")); /* 1 Check initial gain by upper/lower bound */ if (CurrentIGI > pDM_DigTable->rx_gain_range_max) CurrentIGI = pDM_DigTable->rx_gain_range_max; if (CurrentIGI < pDM_DigTable->rx_gain_range_min) CurrentIGI = pDM_DigTable->rx_gain_range_min; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, - ("odm_DIG(): rx_gain_range_max=0x%x, rx_gain_range_min=0x%x\n", - pDM_DigTable->rx_gain_range_max, pDM_DigTable->rx_gain_range_min)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): TotalFA=%d\n", pFalseAlmCnt->Cnt_all)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_DIG, ODM_DBG_LOUD, ("odm_DIG(): CurIGValue=0x%x\n", CurrentIGI)); - /* 2 High power RSSI threshold */ ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ @@ -970,17 +871,6 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0); ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2); } - - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Enter odm_FalseAlarmCounterStatistics\n")); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, - ("Cnt_Fast_Fsync=%d, Cnt_SB_Search_fail=%d\n", - FalseAlmCnt->Cnt_Fast_Fsync, FalseAlmCnt->Cnt_SB_Search_fail)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, - ("Cnt_Parity_Fail=%d, Cnt_Rate_Illegal=%d\n", - FalseAlmCnt->Cnt_Parity_Fail, FalseAlmCnt->Cnt_Rate_Illegal)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, - ("Cnt_Crc8_fail=%d, Cnt_Mcs_fail=%d\n", - FalseAlmCnt->Cnt_Crc8_fail, FalseAlmCnt->Cnt_Mcs_fail)); } else { /* FOR ODM_IC_11AC_SERIES */ /* read OFDM FA counter */ FalseAlmCnt->Cnt_Ofdm_fail = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_11AC, bMaskLWord); @@ -994,9 +884,6 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0); ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1); } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Cck_fail=%d\n", FalseAlmCnt->Cnt_Cck_fail)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Cnt_Ofdm_fail=%d\n", FalseAlmCnt->Cnt_Ofdm_fail)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_FA_CNT, ODM_DBG_LOUD, ("Total False Alarm=%d\n", FalseAlmCnt->Cnt_all)); } /* 3============================================================ */ @@ -1266,10 +1153,6 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u break; } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, - (" ==> rssi_level:0x%02x, WirelessMode:0x%02x, rate_bitmap:0x%08x\n", - rssi_level, WirelessMode, rate_bitmap)); - return rate_bitmap; } @@ -1321,25 +1204,17 @@ void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) u8 i; struct adapter *pAdapter = pDM_Odm->Adapter; - if (pAdapter->bDriverStopped) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_TRACE, ("<---- odm_RefreshRateAdaptiveMask(): driver is going to unload\n")); + if (pAdapter->bDriverStopped) return; - } - if (!pDM_Odm->bUseRAMask) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("<---- odm_RefreshRateAdaptiveMask(): driver does not control rate adaptive mask\n")); + if (!pDM_Odm->bUseRAMask) return; - } for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; if (IS_STA_VALID(pstat)) { - if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, - ("RSSI:%d, RSSI_LEVEL:%d\n", - pstat->rssi_stat.UndecoratedSmoothedPWDB, pstat->rssi_level)); + if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) rtw_hal_update_ra_mask(pAdapter, i, pstat->rssi_level); - } } } } @@ -1385,7 +1260,6 @@ bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate RATRState = DM_RATR_STA_LOW; if (*pRATRState != RATRState || bForceUpdate) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_RA_MASK, ODM_DBG_LOUD, ("RSSI Level %d -> %d\n", *pRATRState, RATRState)); *pRATRState = RATRState; return true; } @@ -1681,10 +1555,8 @@ void odm_SwAntDivChkAntSwitchCallback(struct timer_list *t) void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm) { - if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Return: Not Support HW AntDiv\n")); + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) return; - } if (pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D)) ; @@ -1715,10 +1587,8 @@ void ODM_AntselStatistics_88C(struct odm_dm_struct *pDM_Odm, u8 MacId, u32 PWDBA void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm) { - if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Return: Not Support HW AntDiv\n")); + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) return; - } if (pDM_Odm->SupportICType == ODM_RTL8188E) ODM_AntennaDiversity_88E(pDM_Odm); @@ -1732,10 +1602,6 @@ void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; Adapter->recvpriv.bIsAnyNonBEPkts = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VO PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VO_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial VI PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_VI_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BE PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BE_PARAM))); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("Orginial BK PARAM: 0x%x\n", ODM_Read4Byte(pDM_Odm, ODM_EDCA_BK_PARAM))); } /* ODM_InitEdcaTurbo */ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) @@ -1743,8 +1609,6 @@ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ /* HW dynamic mechanism. */ - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("odm_EdcaTurboCheck========================>\n")); - if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO)) return; @@ -1758,7 +1622,6 @@ void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) case ODM_ADSL: break; } - ODM_RT_TRACE(pDM_Odm, ODM_COMP_EDCA_TURBO, ODM_DBG_LOUD, ("<========================odm_EdcaTurboCheck\n")); } /* odm_CheckEdcaTurbo */ void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) @@ -2073,44 +1936,30 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) /* Reload AFE Registers */ odm_PHY_ReloadAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_A[%d]= %d\n", 2416, AntA_report)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_B[%d]= %d\n", 2416, AntB_report)); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("psd_report_O[%d]= %d\n", 2416, AntO_report)); - if (pDM_Odm->SupportICType == ODM_RTL8723A) { /* 2 Test Ant B based on Ant A is ON */ if (mode == ANTTESTB) { if (AntA_report >= 100) { - if (AntB_report > (AntA_report+1)) { + if (AntB_report > (AntA_report+1)) pDM_SWAT_Table->ANTB_ON = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); - } else { + else pDM_SWAT_Table->ANTB_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Dual Antenna is A and B\n")); - } } else { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ bResult = false; } } else if (mode == ANTTESTALL) { /* 2 Test Ant A and B based on DPDT Open */ if ((AntO_report >= 100)&(AntO_report < 118)) { - if (AntA_report > (AntO_report+1)) { + if (AntA_report > (AntO_report+1)) pDM_SWAT_Table->ANTA_ON = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is OFF")); - } else { + else pDM_SWAT_Table->ANTA_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant A is ON")); - } - if (AntB_report > (AntO_report+2)) { + if (AntB_report > (AntO_report+2)) pDM_SWAT_Table->ANTB_ON = false; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is OFF")); - } else { + else pDM_SWAT_Table->ANTB_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("Ant B is ON")); - } } } } else if (pDM_Odm->SupportICType == ODM_RTL8192C) { @@ -2119,20 +1968,15 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) pDM_SWAT_Table->ANTA_ON = false; pDM_SWAT_Table->ANTB_ON = true; ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna B\n")); } else if (AntA_report > (AntB_report+2)) { pDM_SWAT_Table->ANTA_ON = true; pDM_SWAT_Table->ANTB_ON = false; ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Single Antenna A\n")); } else { pDM_SWAT_Table->ANTA_ON = true; pDM_SWAT_Table->ANTB_ON = true; - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, - ("ODM_SingleDualAntennaDetection(): Dual Antenna\n")); } } else { - ODM_RT_TRACE(pDM_Odm, ODM_COMP_ANT_DIV, ODM_DBG_LOUD, ("ODM_SingleDualAntennaDetection(): Need to check again\n")); pDM_SWAT_Table->ANTA_ON = true; /* Set Antenna A on as default */ pDM_SWAT_Table->ANTB_ON = false; /* Set Antenna B off as default */ bResult = false; diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index 2ff2e93a759c..9072acd26386 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -36,8 +36,6 @@ #include "odm_RegConfig8188E.h" #include "odm_RTL8188E.h" -void odm_CmnInfoHook_Debug(struct odm_dm_struct *pDM_Odm); -void odm_CmnInfoInit_Debug(struct odm_dm_struct *pDM_Odm); void odm_DIGInit(struct odm_dm_struct *pDM_Odm); void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm); void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm); @@ -46,7 +44,6 @@ void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm); void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm); void odm_SwAntDivInit_NIC(struct odm_dm_struct *pDM_Odm); void odm_GlobalAdapterCheck(void); -void odm_CmnInfoUpdate_Debug(struct odm_dm_struct *pDM_Odm); void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm); void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm); void odm_DIG(struct odm_dm_struct *pDM_Odm); -- cgit v1.2.3 From 5225e772acd7a69e87e14df99539ac1ab47ff71c Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:35 +0100 Subject: staging: r8188eu: remove ODM_RT_TRACE macro definition Remove ODM_RT_TRACE macro definition from include/odm_debug.h, as it is called from nowhere and is therefore superfluous. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-13-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/odm_debug.h | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index c70fe73e3339..38b07664b07c 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -68,24 +68,6 @@ #define RT_PRINTK(fmt, args...) \ DbgPrint( "%s(): " fmt, __func__, ## args); -#define ODM_RT_TRACE(pDM_Odm, comp, level, fmt) \ - if (((comp) & pDM_Odm->DebugComponents) && \ - (level <= pDM_Odm->DebugLevel)) { \ - if (pDM_Odm->SupportICType == ODM_RTL8192C) \ - DbgPrint("[ODM-92C] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8192D) \ - DbgPrint("[ODM-92D] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8723A) \ - DbgPrint("[ODM-8723A] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8188E) \ - DbgPrint("[ODM-8188E] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8812) \ - DbgPrint("[ODM-8812] "); \ - else if (pDM_Odm->SupportICType == ODM_RTL8821) \ - DbgPrint("[ODM-8821] "); \ - RT_PRINTK fmt; \ - } - void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); #endif /* __ODM_DBG_H__ */ -- cgit v1.2.3 From f8a846911d83e94a59016c72c503b22fcb4483c7 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:36 +0100 Subject: staging: r8188eu: remove DbgPrint and RT_PRINTK macro definitions Remove DbgPrint and RT_PRINTK macro definitions from include/odm_debug.h, as they are called from nowhere and are therefore superfluous. Also remove comment in core/rtw_xmit.c referring to DbgPrint so that future confusion is prevented. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-14-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 1 - drivers/staging/r8188eu/include/odm_debug.h | 4 ---- 2 files changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 5a45df5531ef..4a5393184737 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -670,7 +670,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) { - /* DbgPrint("\nxmitframe_addmic:stainfo->dot11tkiptxmickey == 0\n"); */ /* rtw_msleep_os(10); */ return _FAIL; } diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h index 38b07664b07c..c71d890ac552 100644 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ b/drivers/staging/r8188eu/include/odm_debug.h @@ -64,10 +64,6 @@ #define ODM_COMP_INIT BIT31 /*------------------------Export Marco Definition---------------------------*/ -#define DbgPrint pr_info -#define RT_PRINTK(fmt, args...) \ - DbgPrint( "%s(): " fmt, __func__, ## args); - void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); #endif /* __ODM_DBG_H__ */ -- cgit v1.2.3 From fc577e46eb96b9c2d767c13801591f7a7e27d853 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 01:39:37 +0100 Subject: staging: r8188eu: remove include/odm_debug.h Remove include/odm_debug.h in its entirety. To do this, first: (1) Remove DebugLevel and DebugComponents members from the struct odm_dm_struct definition, and any uses of these elsewhere in the driver. (2) Remove the function ODM_InitDebugSetting from hal/odm_debug.c whilst leaving the file in place for now as it contains a global which is still used and will be removed by further cleanup code. Also remove all of its callers. All the function does is set the members mentioned above. (3) Remove the now redundant constants and their usages: ODM_CMNINFO_DBG_LEVEL ODM_CMNINFO_DBG_COMP HW_DEF_ODM_DBG_FLAG HW_DEF_FA_CNT_DUMP This includes usage within a few hexadecimal ioctl switch cases in os_dep/ioctl_linux.c (although only the call itself within 0x11 as it contains additional code currently). (4) Finally, remove the file itself and its inclusion within include/odm_precomp.h, as none of the remaining content is used from anywhere else in the driver. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731003937.68615-15-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm.c | 8 ---- drivers/staging/r8188eu/hal/odm_debug.c | 7 --- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 1 - drivers/staging/r8188eu/hal/usb_halinit.c | 23 --------- drivers/staging/r8188eu/include/hal_intf.h | 2 - drivers/staging/r8188eu/include/odm.h | 4 -- drivers/staging/r8188eu/include/odm_debug.h | 69 --------------------------- drivers/staging/r8188eu/include/odm_precomp.h | 1 - drivers/staging/r8188eu/os_dep/ioctl_linux.c | 27 ----------- 9 files changed, 142 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/odm_debug.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 783d4f4a53a5..0bc836311036 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -416,12 +416,6 @@ void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value) case ODM_CMNINFO_RSSI_MIN: pDM_Odm->RSSI_Min = (u8)Value; break; - case ODM_CMNINFO_DBG_COMP: - pDM_Odm->DebugComponents = Value; - break; - case ODM_CMNINFO_DBG_LEVEL: - pDM_Odm->DebugLevel = (u32)Value; - break; case ODM_CMNINFO_RA_THRESHOLD_HIGH: pDM_Odm->RateAdaptive.HighRSSIThresh = (u8)Value; break; @@ -439,8 +433,6 @@ void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV; if (pDM_Odm->SupportICType & (ODM_RTL8723A)) pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV; - - ODM_InitDebugSetting(pDM_Odm); } void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm) diff --git a/drivers/staging/r8188eu/hal/odm_debug.c b/drivers/staging/r8188eu/hal/odm_debug.c index fad1c3cca25b..7029ec4f771e 100644 --- a/drivers/staging/r8188eu/hal/odm_debug.c +++ b/drivers/staging/r8188eu/hal/odm_debug.c @@ -3,11 +3,4 @@ #include "../include/odm_precomp.h" -void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm) -{ - pDM_Odm->DebugLevel = ODM_DBG_TRACE; - - pDM_Odm->DebugComponents = 0; -} - u32 GlobalDebugLevel; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index 294b082a6c09..0e264c39d636 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -193,7 +193,6 @@ void rtl8188e_init_dm_priv(struct adapter *Adapter) memset(pdmpriv, 0, sizeof(struct dm_priv)); Init_ODM_ComInfo_88E(Adapter); - ODM_InitDebugSetting(podmpriv); } void rtl8188e_deinit_dm_priv(struct adapter *Adapter) diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index c90a7574b1cf..d985894c0f30 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -2035,12 +2035,6 @@ GetHalDefVar8188EUsb( } } break; - case HW_DEF_ODM_DBG_FLAG: - { - struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); - pr_info("dm_ocm->DebugComponents = 0x%llx\n", dm_ocm->DebugComponents); - } - break; case HAL_DEF_DBG_DUMP_RXPKT: *((u8 *)pValue) = haldata->bDumpRxPkt; break; @@ -2099,23 +2093,6 @@ static u8 SetHalDefVar8188EUsb(struct adapter *Adapter, enum hal_def_variable eV case HAL_DEF_DBG_DUMP_TXPKT: haldata->bDumpTxPkt = *((u8 *)pValue); break; - case HW_DEF_FA_CNT_DUMP: - { - u8 bRSSIDump = *((u8 *)pValue); - struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); - if (bRSSIDump) - dm_ocm->DebugComponents = ODM_COMP_DIG|ODM_COMP_FA_CNT ; - else - dm_ocm->DebugComponents = 0; - } - break; - case HW_DEF_ODM_DBG_FLAG: - { - u64 DebugComponents = *((u64 *)pValue); - struct odm_dm_struct *dm_ocm = &(haldata->odmpriv); - dm_ocm->DebugComponents = DebugComponents; - } - break; default: bResult = _FAIL; break; diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index 81d959c6fd4e..8f62cbe9ba37 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -113,8 +113,6 @@ enum hal_def_variable { HW_VAR_MAX_RX_AMPDU_FACTOR, HW_DEF_RA_INFO_DUMP, HAL_DEF_DBG_DUMP_TXPKT, - HW_DEF_FA_CNT_DUMP, - HW_DEF_ODM_DBG_FLAG, }; enum hal_odm_variable { diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index 15827b6a5729..2a6fd4072e00 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -388,8 +388,6 @@ enum odm_common_info_def { ODM_CMNINFO_WIFI_DISPLAY, ODM_CMNINFO_LINK, ODM_CMNINFO_RSSI_MIN, - ODM_CMNINFO_DBG_COMP, /* u64 */ - ODM_CMNINFO_DBG_LEVEL, /* u32 */ ODM_CMNINFO_RA_THRESHOLD_HIGH, /* u8 */ ODM_CMNINFO_RA_THRESHOLD_LOW, /* u8 */ ODM_CMNINFO_RF_ANTENNA_TYPE, /* u8 */ @@ -748,8 +746,6 @@ struct odm_dm_struct { bool odm_ready; struct rtl8192cd_priv *fake_priv; - u64 DebugComponents; - u32 DebugLevel; /* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ bool bCckHighPower; diff --git a/drivers/staging/r8188eu/include/odm_debug.h b/drivers/staging/r8188eu/include/odm_debug.h deleted file mode 100644 index c71d890ac552..000000000000 --- a/drivers/staging/r8188eu/include/odm_debug.h +++ /dev/null @@ -1,69 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __ODM_DBG_H__ -#define __ODM_DBG_H__ - -/* */ -/* Define the debug levels */ -/* */ -/* 1. DBG_TRACE and DBG_LOUD are used for normal cases. */ -/* They can help SW engineer to develop or trace states changed */ -/* and also help HW enginner to trace every operation to and from HW, */ -/* e.g IO, Tx, Rx. */ -/* */ -/* 2. DBG_WARNNING and DBG_SERIOUS are used for unusual or error cases, */ -/* which help us to debug SW or HW. */ - -/* Never used in a call to ODM_RT_TRACE()! */ -#define ODM_DBG_OFF 1 - -/* Fatal bug. */ -/* For example, Tx/Rx/IO locked up, OS hangs, memory access violation, */ -/* resource allocation failed, unexpected HW behavior, HW BUG and so on. */ -#define ODM_DBG_SERIOUS 2 - -/* Abnormal, rare, or unexpeted cases. */ -/* For example, IRP/Packet/OID canceled, device suprisely unremoved and so on. */ -#define ODM_DBG_WARNING 3 - -/* Normal case with useful information about current SW or HW state. */ -/* For example, Tx/Rx descriptor to fill, Tx/Rx descr. completed status, */ -/* SW protocol state change, dynamic mechanism state change and so on. */ -/* */ -#define ODM_DBG_LOUD 4 - -/* Normal case with detail execution flow or information. */ -#define ODM_DBG_TRACE 5 - -/* Define the tracing components */ -/* BB Functions */ -#define ODM_COMP_DIG BIT0 -#define ODM_COMP_RA_MASK BIT1 -#define ODM_COMP_DYNAMIC_TXPWR BIT2 -#define ODM_COMP_FA_CNT BIT3 -#define ODM_COMP_RSSI_MONITOR BIT4 -#define ODM_COMP_CCK_PD BIT5 -#define ODM_COMP_ANT_DIV BIT6 -#define ODM_COMP_PWR_SAVE BIT7 -#define ODM_COMP_PWR_TRA BIT8 -#define ODM_COMP_RATE_ADAPTIVE BIT9 -#define ODM_COMP_PATH_DIV BIT10 -#define ODM_COMP_PSD BIT11 -#define ODM_COMP_DYNAMIC_PRICCA BIT12 -#define ODM_COMP_RXHP BIT13 -/* MAC Functions */ -#define ODM_COMP_EDCA_TURBO BIT16 -#define ODM_COMP_EARLY_MODE BIT17 -/* RF Functions */ -#define ODM_COMP_TX_PWR_TRACK BIT24 -#define ODM_COMP_RX_GAIN_TRACK BIT25 -#define ODM_COMP_CALIBRATION BIT26 -/* Common Functions */ -#define ODM_COMP_COMMON BIT30 -#define ODM_COMP_INIT BIT31 - -/*------------------------Export Marco Definition---------------------------*/ -void ODM_InitDebugSetting(struct odm_dm_struct *pDM_Odm); - -#endif /* __ODM_DBG_H__ */ diff --git a/drivers/staging/r8188eu/include/odm_precomp.h b/drivers/staging/r8188eu/include/odm_precomp.h index 9072acd26386..a1d6d674bda6 100644 --- a/drivers/staging/r8188eu/include/odm_precomp.h +++ b/drivers/staging/r8188eu/include/odm_precomp.h @@ -18,7 +18,6 @@ #include "odm.h" #include "odm_HWConfig.h" -#include "odm_debug.h" #include "odm_RegDefine11AC.h" #include "odm_RegDefine11N.h" diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index ffce43f99dd6..c763714cda58 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -4455,7 +4455,6 @@ static int rtw_dbg_port(struct net_device *dev, case 0x11: DBG_88E("turn %s Rx RSSI display function\n", (extra_arg == 1) ? "on" : "off"); padapter->bRxRSSIDisplay = extra_arg; - rtw_hal_set_def_var(padapter, HW_DEF_FA_CNT_DUMP, &extra_arg); break; case 0x12: /* set rx_stbc */ { @@ -4492,32 +4491,6 @@ static int rtw_dbg_port(struct net_device *dev, DBG_88E("get wifi_spec =%d\n", pregpriv->wifi_spec); } break; - case 0x16: - if (arg == 0xff) { - pr_info("ODM_COMP_DIG\t\tBIT0\n"); - pr_info("ODM_COMP_RA_MASK\t\tBIT1\n"); - pr_info("ODM_COMP_DYNAMIC_TXPWR\tBIT2\n"); - pr_info("ODM_COMP_FA_CNT\t\tBIT3\n"); - pr_info("ODM_COMP_RSSI_MONITOR\tBIT4\n"); - pr_info("ODM_COMP_CCK_PD\t\tBIT5\n"); - pr_info("ODM_COMP_ANT_DIV\t\tBIT6\n"); - pr_info("ODM_COMP_PWR_SAVE\t\tBIT7\n"); - pr_info("ODM_COMP_PWR_TRAIN\tBIT8\n"); - pr_info("ODM_COMP_RATE_ADAPTIVE\tBIT9\n"); - pr_info("ODM_COMP_PATH_DIV\t\tBIT10\n"); - pr_info("ODM_COMP_PSD \tBIT11\n"); - pr_info("ODM_COMP_DYNAMIC_PRICCA\tBIT12\n"); - pr_info("ODM_COMP_RXHP\t\tBIT13\n"); - pr_info("ODM_COMP_EDCA_TURBO\tBIT16\n"); - pr_info("ODM_COMP_EARLY_MODE\tBIT17\n"); - pr_info("ODM_COMP_TX_PWR_TRACK\tBIT24\n"); - pr_info("ODM_COMP_RX_GAIN_TRACK\tBIT25\n"); - pr_info("ODM_COMP_CALIBRATION\tBIT26\n"); - rtw_hal_get_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); - } else { - rtw_hal_set_def_var(padapter, HW_DEF_ODM_DBG_FLAG, &extra_arg); - } - break; case 0x23: DBG_88E("turn %s the bNotifyChannelChange Variable\n", (extra_arg == 1) ? "on" : "off"); padapter->bNotifyChannelChange = extra_arg; -- cgit v1.2.3 From afc56237fd5e4fe2cb708f84e6e390cbaea4c439 Mon Sep 17 00:00:00 2001 From: kernel test robot Date: Sat, 31 Jul 2021 20:18:43 +0800 Subject: staging: r8188eu: fix duplicated inclusion Generated by: scripts/checkincludes.pl Reported-by: kernel test robot Signed-off-by: kernel test robot Link: https://lore.kernel.org/r/20210731121843.GA54722@fdce12c5ae77 Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index c763714cda58..8ba2b81e32b8 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -5560,7 +5560,6 @@ out: } #endif -#include "../include/rtw_android.h" static int rtw_wx_set_priv(struct net_device *dev, struct iw_request_info *info, union iwreq_data *awrq, -- cgit v1.2.3 From 06889446a78fb9655332954a2288ecbacc7f0ff8 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 14:38:04 +0100 Subject: staging: r8188eu: correct set/defined but unused warnings from debug cleanup The recent include/odm_debug.h removal series caused a few kernel test robot warnings. This patch fixes them as well as an existing warning related to an array within include/rtw_security.h not being used. Reported-by: kernel test robot Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731133804.196631-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 9 ++------- drivers/staging/r8188eu/include/rtw_security.h | 17 ----------------- 2 files changed, 2 insertions(+), 24 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index d1613a9278c4..166adaac371a 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -364,7 +364,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( static u8 /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) { - u32 regeac, regE94, regE9C, regEA4; + u32 regeac, regE94, regE9C; u8 result = 0x00; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; @@ -391,7 +391,6 @@ phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) regeac = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord); regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - regEA4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord); if (!(regeac & BIT28) && (((regE94 & 0x03FF0000)>>16) != 0x142) && @@ -1091,7 +1090,7 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) s32 result[4][8]; /* last is final result */ u8 i, final_candidate, Indexforchannel; bool pathaok, pathbok; - s32 RegE94, RegE9C, RegEA4, RegEAC, RegEB4, RegEBC, RegEC4, RegECC; + s32 RegE94, RegE9C, RegEA4, RegEB4, RegEBC, RegEC4; bool is12simular, is13simular, is23simular; bool singletone = false, carrier_sup = false; u32 IQK_BB_REG_92C[IQK_BB_REG_NUM] = { @@ -1170,18 +1169,15 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) RegE94 = result[i][0]; RegE9C = result[i][1]; RegEA4 = result[i][2]; - RegEAC = result[i][3]; RegEB4 = result[i][4]; RegEBC = result[i][5]; RegEC4 = result[i][6]; - RegECC = result[i][7]; } if (final_candidate != 0xff) { RegE94 = result[final_candidate][0]; RegE9C = result[final_candidate][1]; RegEA4 = result[final_candidate][2]; - RegEAC = result[final_candidate][3]; RegEB4 = result[final_candidate][4]; RegEBC = result[final_candidate][5]; dm_odm->RFCalibrateInfo.RegE94 = RegE94; @@ -1189,7 +1185,6 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) dm_odm->RFCalibrateInfo.RegEB4 = RegEB4; dm_odm->RFCalibrateInfo.RegEBC = RegEBC; RegEC4 = result[final_candidate][6]; - RegECC = result[final_candidate][7]; pathaok = true; pathbok = true; } else { diff --git a/drivers/staging/r8188eu/include/rtw_security.h b/drivers/staging/r8188eu/include/rtw_security.h index f8863926c905..ec6ecdb7bc98 100644 --- a/drivers/staging/r8188eu/include/rtw_security.h +++ b/drivers/staging/r8188eu/include/rtw_security.h @@ -308,23 +308,6 @@ static inline u32 rotr(u32 val, int bits) /* This is based on SHA256 implementation in LibTomCrypt that was released into * public domain by Tom St Denis. */ -/* the K array */ -static const unsigned long K[64] = { - 0x428a2f98UL, 0x71374491UL, 0xb5c0fbcfUL, 0xe9b5dba5UL, 0x3956c25bUL, - 0x59f111f1UL, 0x923f82a4UL, 0xab1c5ed5UL, 0xd807aa98UL, 0x12835b01UL, - 0x243185beUL, 0x550c7dc3UL, 0x72be5d74UL, 0x80deb1feUL, 0x9bdc06a7UL, - 0xc19bf174UL, 0xe49b69c1UL, 0xefbe4786UL, 0x0fc19dc6UL, 0x240ca1ccUL, - 0x2de92c6fUL, 0x4a7484aaUL, 0x5cb0a9dcUL, 0x76f988daUL, 0x983e5152UL, - 0xa831c66dUL, 0xb00327c8UL, 0xbf597fc7UL, 0xc6e00bf3UL, 0xd5a79147UL, - 0x06ca6351UL, 0x14292967UL, 0x27b70a85UL, 0x2e1b2138UL, 0x4d2c6dfcUL, - 0x53380d13UL, 0x650a7354UL, 0x766a0abbUL, 0x81c2c92eUL, 0x92722c85UL, - 0xa2bfe8a1UL, 0xa81a664bUL, 0xc24b8b70UL, 0xc76c51a3UL, 0xd192e819UL, - 0xd6990624UL, 0xf40e3585UL, 0x106aa070UL, 0x19a4c116UL, 0x1e376c08UL, - 0x2748774cUL, 0x34b0bcb5UL, 0x391c0cb3UL, 0x4ed8aa4aUL, 0x5b9cca4fUL, - 0x682e6ff3UL, 0x748f82eeUL, 0x78a5636fUL, 0x84c87814UL, 0x8cc70208UL, - 0x90befffaUL, 0xa4506cebUL, 0xbef9a3f7UL, 0xc67178f2UL -}; - /* Various logical functions */ #define RORc(x, y) \ (((((unsigned long)(x) & 0xFFFFFFFFUL) >> (unsigned long)((y)&31)) | \ -- cgit v1.2.3 From 55dfa29b43d23bab37d98f087615ff46d38241df Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 31 Jul 2021 14:38:09 +0100 Subject: staging: rtl8188eu: remove rtl8188eu driver from staging dir This driver was deprecated with the introduction of the r8188eu driver, based upon Realtek sources that were modified for CFG80211 support and other fixes on GitHub by Larry Finger. As that driver is now progressing at pace, we should remove this one. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731133809.196681-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/Kconfig | 2 - drivers/staging/Makefile | 1 - drivers/staging/rtl8188eu/Kconfig | 26 - drivers/staging/rtl8188eu/Makefile | 56 - drivers/staging/rtl8188eu/TODO | 14 - drivers/staging/rtl8188eu/core/mac_cfg.c | 120 - drivers/staging/rtl8188eu/core/rtw_ap.c | 1665 ------- drivers/staging/rtl8188eu/core/rtw_cmd.c | 1218 ----- drivers/staging/rtl8188eu/core/rtw_efuse.c | 850 ---- drivers/staging/rtl8188eu/core/rtw_ieee80211.c | 990 ---- drivers/staging/rtl8188eu/core/rtw_ioctl_set.c | 512 -- drivers/staging/rtl8188eu/core/rtw_iol.c | 19 - drivers/staging/rtl8188eu/core/rtw_led.c | 460 -- drivers/staging/rtl8188eu/core/rtw_mlme.c | 1886 ------- drivers/staging/rtl8188eu/core/rtw_mlme_ext.c | 5171 -------------------- drivers/staging/rtl8188eu/core/rtw_pwrctrl.c | 578 --- drivers/staging/rtl8188eu/core/rtw_recv.c | 1812 ------- drivers/staging/rtl8188eu/core/rtw_rf.c | 58 - drivers/staging/rtl8188eu/core/rtw_security.c | 826 ---- drivers/staging/rtl8188eu/core/rtw_sreset.c | 21 - drivers/staging/rtl8188eu/core/rtw_sta_mgt.c | 479 -- drivers/staging/rtl8188eu/core/rtw_wlan_util.c | 1373 ------ drivers/staging/rtl8188eu/core/rtw_xmit.c | 1927 -------- drivers/staging/rtl8188eu/hal/bb_cfg.c | 681 --- drivers/staging/rtl8188eu/hal/fw.c | 202 - .../staging/rtl8188eu/hal/hal8188e_rate_adaptive.c | 646 --- drivers/staging/rtl8188eu/hal/hal_com.c | 285 -- drivers/staging/rtl8188eu/hal/hal_intf.c | 59 - drivers/staging/rtl8188eu/hal/odm.c | 966 ---- drivers/staging/rtl8188eu/hal/odm_hwconfig.c | 397 -- drivers/staging/rtl8188eu/hal/odm_rtl8188e.c | 335 -- drivers/staging/rtl8188eu/hal/phy.c | 1112 ----- drivers/staging/rtl8188eu/hal/pwrseq.c | 36 - drivers/staging/rtl8188eu/hal/pwrseqcmd.c | 72 - drivers/staging/rtl8188eu/hal/rf.c | 289 -- drivers/staging/rtl8188eu/hal/rf_cfg.c | 247 - drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c | 591 --- drivers/staging/rtl8188eu/hal/rtl8188e_dm.c | 217 - drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c | 512 -- drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c | 193 - drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c | 25 - drivers/staging/rtl8188eu/hal/rtl8188eu_led.c | 55 - drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c | 83 - drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c | 638 --- drivers/staging/rtl8188eu/hal/usb_halinit.c | 1818 ------- drivers/staging/rtl8188eu/include/HalVerDef.h | 37 - drivers/staging/rtl8188eu/include/basic_types.h | 134 - drivers/staging/rtl8188eu/include/drv_types.h | 176 - drivers/staging/rtl8188eu/include/fw.h | 44 - .../staging/rtl8188eu/include/hal8188e_phy_cfg.h | 175 - .../staging/rtl8188eu/include/hal8188e_phy_reg.h | 201 - .../rtl8188eu/include/hal8188e_rate_adaptive.h | 74 - drivers/staging/rtl8188eu/include/hal_com.h | 150 - drivers/staging/rtl8188eu/include/hal_intf.h | 181 - drivers/staging/rtl8188eu/include/ieee80211.h | 742 --- drivers/staging/rtl8188eu/include/mlme_osdep.h | 21 - drivers/staging/rtl8188eu/include/mon.h | 28 - drivers/staging/rtl8188eu/include/odm.h | 1052 ---- drivers/staging/rtl8188eu/include/odm_hwconfig.h | 101 - drivers/staging/rtl8188eu/include/odm_precomp.h | 63 - drivers/staging/rtl8188eu/include/odm_rtl8188e.h | 39 - drivers/staging/rtl8188eu/include/odm_types.h | 24 - drivers/staging/rtl8188eu/include/osdep_intf.h | 35 - drivers/staging/rtl8188eu/include/osdep_service.h | 81 - drivers/staging/rtl8188eu/include/phy.h | 26 - drivers/staging/rtl8188eu/include/phydm_reg.h | 22 - .../staging/rtl8188eu/include/phydm_regdefine11n.h | 53 - drivers/staging/rtl8188eu/include/pwrseq.h | 130 - drivers/staging/rtl8188eu/include/pwrseqcmd.h | 37 - drivers/staging/rtl8188eu/include/recv_osdep.h | 26 - drivers/staging/rtl8188eu/include/rf.h | 12 - drivers/staging/rtl8188eu/include/rtl8188e_cmd.h | 70 - drivers/staging/rtl8188eu/include/rtl8188e_dm.h | 40 - drivers/staging/rtl8188eu/include/rtl8188e_hal.h | 319 -- drivers/staging/rtl8188eu/include/rtl8188e_recv.h | 53 - drivers/staging/rtl8188eu/include/rtl8188e_spec.h | 1116 ----- drivers/staging/rtl8188eu/include/rtl8188e_xmit.h | 157 - drivers/staging/rtl8188eu/include/rtw_android.h | 50 - drivers/staging/rtl8188eu/include/rtw_ap.h | 45 - drivers/staging/rtl8188eu/include/rtw_cmd.h | 361 -- drivers/staging/rtl8188eu/include/rtw_eeprom.h | 114 - drivers/staging/rtl8188eu/include/rtw_efuse.h | 67 - drivers/staging/rtl8188eu/include/rtw_event.h | 81 - drivers/staging/rtl8188eu/include/rtw_ht.h | 26 - drivers/staging/rtl8188eu/include/rtw_ioctl.h | 85 - drivers/staging/rtl8188eu/include/rtw_ioctl_set.h | 28 - drivers/staging/rtl8188eu/include/rtw_iol.h | 14 - drivers/staging/rtl8188eu/include/rtw_led.h | 98 - drivers/staging/rtl8188eu/include/rtw_mlme.h | 355 -- drivers/staging/rtl8188eu/include/rtw_mlme_ext.h | 680 --- drivers/staging/rtl8188eu/include/rtw_pwrctrl.h | 244 - drivers/staging/rtl8188eu/include/rtw_recv.h | 262 - drivers/staging/rtl8188eu/include/rtw_rf.h | 117 - drivers/staging/rtl8188eu/include/rtw_security.h | 241 - drivers/staging/rtl8188eu/include/rtw_sreset.h | 30 - drivers/staging/rtl8188eu/include/rtw_xmit.h | 352 -- drivers/staging/rtl8188eu/include/sta_info.h | 359 -- drivers/staging/rtl8188eu/include/usb_ops_linux.h | 26 - drivers/staging/rtl8188eu/include/wifi.h | 355 -- drivers/staging/rtl8188eu/include/wlan_bssdef.h | 240 - drivers/staging/rtl8188eu/include/xmit_osdep.h | 32 - drivers/staging/rtl8188eu/os_dep/ioctl_linux.c | 2699 ---------- drivers/staging/rtl8188eu/os_dep/mlme_linux.c | 167 - drivers/staging/rtl8188eu/os_dep/mon.c | 183 - drivers/staging/rtl8188eu/os_dep/os_intfs.c | 657 --- drivers/staging/rtl8188eu/os_dep/osdep_service.c | 63 - drivers/staging/rtl8188eu/os_dep/recv_linux.c | 138 - drivers/staging/rtl8188eu/os_dep/rtw_android.c | 223 - drivers/staging/rtl8188eu/os_dep/usb_intf.c | 479 -- drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c | 644 --- drivers/staging/rtl8188eu/os_dep/xmit_linux.c | 189 - 111 files changed, 44646 deletions(-) delete mode 100644 drivers/staging/rtl8188eu/Kconfig delete mode 100644 drivers/staging/rtl8188eu/Makefile delete mode 100644 drivers/staging/rtl8188eu/TODO delete mode 100644 drivers/staging/rtl8188eu/core/mac_cfg.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_ap.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_cmd.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_efuse.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_ieee80211.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_ioctl_set.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_iol.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_led.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_mlme.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_mlme_ext.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_pwrctrl.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_recv.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_rf.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_security.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_sreset.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_sta_mgt.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_wlan_util.c delete mode 100644 drivers/staging/rtl8188eu/core/rtw_xmit.c delete mode 100644 drivers/staging/rtl8188eu/hal/bb_cfg.c delete mode 100644 drivers/staging/rtl8188eu/hal/fw.c delete mode 100644 drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c delete mode 100644 drivers/staging/rtl8188eu/hal/hal_com.c delete mode 100644 drivers/staging/rtl8188eu/hal/hal_intf.c delete mode 100644 drivers/staging/rtl8188eu/hal/odm.c delete mode 100644 drivers/staging/rtl8188eu/hal/odm_hwconfig.c delete mode 100644 drivers/staging/rtl8188eu/hal/odm_rtl8188e.c delete mode 100644 drivers/staging/rtl8188eu/hal/phy.c delete mode 100644 drivers/staging/rtl8188eu/hal/pwrseq.c delete mode 100644 drivers/staging/rtl8188eu/hal/pwrseqcmd.c delete mode 100644 drivers/staging/rtl8188eu/hal/rf.c delete mode 100644 drivers/staging/rtl8188eu/hal/rf_cfg.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_dm.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188eu_led.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c delete mode 100644 drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c delete mode 100644 drivers/staging/rtl8188eu/hal/usb_halinit.c delete mode 100644 drivers/staging/rtl8188eu/include/HalVerDef.h delete mode 100644 drivers/staging/rtl8188eu/include/basic_types.h delete mode 100644 drivers/staging/rtl8188eu/include/drv_types.h delete mode 100644 drivers/staging/rtl8188eu/include/fw.h delete mode 100644 drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h delete mode 100644 drivers/staging/rtl8188eu/include/hal8188e_phy_reg.h delete mode 100644 drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h delete mode 100644 drivers/staging/rtl8188eu/include/hal_com.h delete mode 100644 drivers/staging/rtl8188eu/include/hal_intf.h delete mode 100644 drivers/staging/rtl8188eu/include/ieee80211.h delete mode 100644 drivers/staging/rtl8188eu/include/mlme_osdep.h delete mode 100644 drivers/staging/rtl8188eu/include/mon.h delete mode 100644 drivers/staging/rtl8188eu/include/odm.h delete mode 100644 drivers/staging/rtl8188eu/include/odm_hwconfig.h delete mode 100644 drivers/staging/rtl8188eu/include/odm_precomp.h delete mode 100644 drivers/staging/rtl8188eu/include/odm_rtl8188e.h delete mode 100644 drivers/staging/rtl8188eu/include/odm_types.h delete mode 100644 drivers/staging/rtl8188eu/include/osdep_intf.h delete mode 100644 drivers/staging/rtl8188eu/include/osdep_service.h delete mode 100644 drivers/staging/rtl8188eu/include/phy.h delete mode 100644 drivers/staging/rtl8188eu/include/phydm_reg.h delete mode 100644 drivers/staging/rtl8188eu/include/phydm_regdefine11n.h delete mode 100644 drivers/staging/rtl8188eu/include/pwrseq.h delete mode 100644 drivers/staging/rtl8188eu/include/pwrseqcmd.h delete mode 100644 drivers/staging/rtl8188eu/include/recv_osdep.h delete mode 100644 drivers/staging/rtl8188eu/include/rf.h delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_cmd.h delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_dm.h delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_hal.h delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_recv.h delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_spec.h delete mode 100644 drivers/staging/rtl8188eu/include/rtl8188e_xmit.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_android.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_ap.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_cmd.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_eeprom.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_efuse.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_event.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_ht.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_ioctl.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_ioctl_set.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_iol.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_led.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_mlme.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_mlme_ext.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_pwrctrl.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_recv.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_rf.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_security.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_sreset.h delete mode 100644 drivers/staging/rtl8188eu/include/rtw_xmit.h delete mode 100644 drivers/staging/rtl8188eu/include/sta_info.h delete mode 100644 drivers/staging/rtl8188eu/include/usb_ops_linux.h delete mode 100644 drivers/staging/rtl8188eu/include/wifi.h delete mode 100644 drivers/staging/rtl8188eu/include/wlan_bssdef.h delete mode 100644 drivers/staging/rtl8188eu/include/xmit_osdep.h delete mode 100644 drivers/staging/rtl8188eu/os_dep/ioctl_linux.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/mlme_linux.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/mon.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/os_intfs.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/osdep_service.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/recv_linux.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/rtw_android.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/usb_intf.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c delete mode 100644 drivers/staging/rtl8188eu/os_dep/xmit_linux.c (limited to 'drivers/staging') diff --git a/drivers/staging/Kconfig b/drivers/staging/Kconfig index 73fd57bfa95a..e03627ad4460 100644 --- a/drivers/staging/Kconfig +++ b/drivers/staging/Kconfig @@ -36,8 +36,6 @@ source "drivers/staging/rtl8723bs/Kconfig" source "drivers/staging/rtl8712/Kconfig" -source "drivers/staging/rtl8188eu/Kconfig" - source "drivers/staging/r8188eu/Kconfig" source "drivers/staging/rts5208/Kconfig" diff --git a/drivers/staging/Makefile b/drivers/staging/Makefile index 47672260293e..c7f8d8d8dd11 100644 --- a/drivers/staging/Makefile +++ b/drivers/staging/Makefile @@ -8,7 +8,6 @@ obj-$(CONFIG_RTL8192U) += rtl8192u/ obj-$(CONFIG_RTL8192E) += rtl8192e/ obj-$(CONFIG_RTL8723BS) += rtl8723bs/ obj-$(CONFIG_R8712U) += rtl8712/ -obj-$(CONFIG_R8188EU_OLD) += rtl8188eu/ obj-$(CONFIG_R8188EU) += r8188eu/ obj-$(CONFIG_RTS5208) += rts5208/ obj-$(CONFIG_NETLOGIC_XLR_NET) += netlogic/ diff --git a/drivers/staging/rtl8188eu/Kconfig b/drivers/staging/rtl8188eu/Kconfig deleted file mode 100644 index acdf0f9f374c..000000000000 --- a/drivers/staging/rtl8188eu/Kconfig +++ /dev/null @@ -1,26 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -config R8188EU_OLD - tristate "Realtek RTL8188EU Wireless LAN NIC driver (DEPRECATED)" - depends on WLAN && USB && CFG80211 - depends on m - select WIRELESS_EXT - select WEXT_PRIV - select LIB80211 - select LIB80211_CRYPT_WEP - select LIB80211_CRYPT_CCMP - help - This option adds the Realtek RTL8188EU USB device such as TP-Link TL-WN725N. - If built as a module, it will be called rtl8188eu. This driver is now due to - be dropped due to the import of a newer version. - -if R8188EU_OLD - -config 88EU_AP_MODE - bool "Realtek RTL8188EU AP mode" - default y - help - This option enables Access Point mode. Unless you know that your system - will never be used as an AP, or the target system has limited memory, - "Y" should be selected. - -endif diff --git a/drivers/staging/rtl8188eu/Makefile b/drivers/staging/rtl8188eu/Makefile deleted file mode 100644 index 20d88983f4e2..000000000000 --- a/drivers/staging/rtl8188eu/Makefile +++ /dev/null @@ -1,56 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -rtl8188eu-y := \ - core/mac_cfg.o \ - core/rtw_ap.o \ - core/rtw_cmd.o \ - core/rtw_efuse.o \ - core/rtw_ieee80211.o \ - core/rtw_ioctl_set.o \ - core/rtw_iol.o \ - core/rtw_led.o \ - core/rtw_mlme.o \ - core/rtw_mlme_ext.o \ - core/rtw_pwrctrl.o \ - core/rtw_recv.o \ - core/rtw_rf.o \ - core/rtw_security.o \ - core/rtw_sreset.o \ - core/rtw_sta_mgt.o \ - core/rtw_wlan_util.o \ - core/rtw_xmit.o \ - hal/fw.o \ - hal/bb_cfg.o \ - hal/rf_cfg.o \ - hal/pwrseqcmd.o \ - hal/pwrseq.o \ - hal/hal8188e_rate_adaptive.o \ - hal/hal_intf.o \ - hal/hal_com.o \ - hal/odm.o \ - hal/odm_hwconfig.o \ - hal/odm_rtl8188e.o \ - hal/rtl8188e_cmd.o \ - hal/rtl8188e_dm.o \ - hal/rtl8188e_hal_init.o \ - hal/phy.o \ - hal/rf.o \ - hal/rtl8188e_rxdesc.o \ - hal/rtl8188e_xmit.o \ - hal/rtl8188eu_led.o \ - hal/rtl8188eu_recv.o \ - hal/rtl8188eu_xmit.o \ - hal/usb_halinit.o \ - os_dep/ioctl_linux.o \ - os_dep/mlme_linux.o \ - os_dep/mon.o \ - os_dep/os_intfs.o \ - os_dep/osdep_service.o \ - os_dep/recv_linux.o \ - os_dep/rtw_android.o \ - os_dep/usb_intf.o \ - os_dep/usb_ops_linux.o \ - os_dep/xmit_linux.o - -obj-$(CONFIG_R8188EU_OLD) := rtl8188eu.o - -ccflags-y += -I$(srctree)/$(src)/include diff --git a/drivers/staging/rtl8188eu/TODO b/drivers/staging/rtl8188eu/TODO deleted file mode 100644 index 5faa0a9bba25..000000000000 --- a/drivers/staging/rtl8188eu/TODO +++ /dev/null @@ -1,14 +0,0 @@ -TODO: -- find and remove remaining code valid only for 5 GHz. Most of the obvious - ones have been removed, but things like channel > 14 still exist. -- find and remove any code for other chips that is left over -- convert any remaining unusual variable types -- find codes that can use %pM and %Nph formatting -- checkpatch.pl fixes - most of the remaining ones are lines too long. Many - of them will require refactoring -- merge Realtek's bugfixes and new features into the driver -- switch to use LIB80211 -- switch to use MAC80211 - -Please send any patches to Greg Kroah-Hartman , -and Larry Finger . diff --git a/drivers/staging/rtl8188eu/core/mac_cfg.c b/drivers/staging/rtl8188eu/core/mac_cfg.c deleted file mode 100644 index a94c6ad472c5..000000000000 --- a/drivers/staging/rtl8188eu/core/mac_cfg.c +++ /dev/null @@ -1,120 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" -#include "phy.h" - -/* MAC_REG.TXT */ - -static u32 array_MAC_REG[] = { - 0x026, 0x00000041, - 0x027, 0x00000035, - 0x428, 0x0000000A, - 0x429, 0x00000010, - 0x430, 0x00000000, - 0x431, 0x00000001, - 0x432, 0x00000002, - 0x433, 0x00000004, - 0x434, 0x00000005, - 0x435, 0x00000006, - 0x436, 0x00000007, - 0x437, 0x00000008, - 0x438, 0x00000000, - 0x439, 0x00000000, - 0x43A, 0x00000001, - 0x43B, 0x00000002, - 0x43C, 0x00000004, - 0x43D, 0x00000005, - 0x43E, 0x00000006, - 0x43F, 0x00000007, - 0x440, 0x0000005D, - 0x441, 0x00000001, - 0x442, 0x00000000, - 0x444, 0x00000015, - 0x445, 0x000000F0, - 0x446, 0x0000000F, - 0x447, 0x00000000, - 0x458, 0x00000041, - 0x459, 0x000000A8, - 0x45A, 0x00000072, - 0x45B, 0x000000B9, - 0x460, 0x00000066, - 0x461, 0x00000066, - 0x480, 0x00000008, - 0x4C8, 0x000000FF, - 0x4C9, 0x00000008, - 0x4CC, 0x000000FF, - 0x4CD, 0x000000FF, - 0x4CE, 0x00000001, - 0x4D3, 0x00000001, - 0x500, 0x00000026, - 0x501, 0x000000A2, - 0x502, 0x0000002F, - 0x503, 0x00000000, - 0x504, 0x00000028, - 0x505, 0x000000A3, - 0x506, 0x0000005E, - 0x507, 0x00000000, - 0x508, 0x0000002B, - 0x509, 0x000000A4, - 0x50A, 0x0000005E, - 0x50B, 0x00000000, - 0x50C, 0x0000004F, - 0x50D, 0x000000A4, - 0x50E, 0x00000000, - 0x50F, 0x00000000, - 0x512, 0x0000001C, - 0x514, 0x0000000A, - 0x516, 0x0000000A, - 0x525, 0x0000004F, - 0x550, 0x00000010, - 0x551, 0x00000010, - 0x559, 0x00000002, - 0x55D, 0x000000FF, - 0x605, 0x00000030, - 0x608, 0x0000000E, - 0x609, 0x0000002A, - 0x620, 0x000000FF, - 0x621, 0x000000FF, - 0x622, 0x000000FF, - 0x623, 0x000000FF, - 0x624, 0x000000FF, - 0x625, 0x000000FF, - 0x626, 0x000000FF, - 0x627, 0x000000FF, - 0x652, 0x00000020, - 0x63C, 0x0000000A, - 0x63D, 0x0000000A, - 0x63E, 0x0000000E, - 0x63F, 0x0000000E, - 0x640, 0x00000040, - 0x66E, 0x00000005, - 0x700, 0x00000021, - 0x701, 0x00000043, - 0x702, 0x00000065, - 0x703, 0x00000087, - 0x708, 0x00000021, - 0x709, 0x00000043, - 0x70A, 0x00000065, - 0x70B, 0x00000087, -}; - -bool phy_mac_config(struct adapter *adapt) -{ - u32 i; - u32 arraylength; - u32 *ptrarray; - - arraylength = ARRAY_SIZE(array_MAC_REG); - ptrarray = array_MAC_REG; - - for (i = 0; i < arraylength; i += 2) - usb_write8(adapt, ptrarray[i], (u8)ptrarray[i + 1]); - - usb_write8(adapt, REG_MAX_AGGR_NUM, MAX_AGGR_NUM); - return true; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c deleted file mode 100644 index 309e7ab59331..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_ap.c +++ /dev/null @@ -1,1665 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_AP_C_ - -#include - -#include -#include -#include -#include -#include - -#ifdef CONFIG_88EU_AP_MODE - -void init_mlme_ap_info(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - - spin_lock_init(&pmlmepriv->bcn_update_lock); - - /* for ACL */ - _rtw_init_queue(&pacl_list->acl_node_q); - - start_ap_mode(padapter); -} - -void free_mlme_ap_info(struct adapter *padapter) -{ - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - pmlmepriv->update_bcn = false; - pmlmeext->bstart_bss = false; - - rtw_sta_flush(padapter); - - pmlmeinfo->state = _HW_STATE_NOLINK_; - - /* free_assoc_sta_resources */ - rtw_free_all_stainfo(padapter); - - /* free bc/mc sta_info */ - psta = rtw_get_bcmc_stainfo(padapter); - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(padapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); -} - -static void update_BCNTIM(struct adapter *padapter) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; - unsigned char *pie = pnetwork_mlmeext->ies; - u8 *p, *dst_ie, *premainder_ie = NULL; - u8 *pbackup_remainder_ie = NULL; - uint offset, tmp_len, tim_ielen, tim_ie_offset, remainder_ielen; - - /* update TIM IE */ - p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, WLAN_EID_TIM, &tim_ielen, - pnetwork_mlmeext->ie_length - _FIXED_IE_LENGTH_); - if (p && tim_ielen > 0) { - tim_ielen += 2; - premainder_ie = p + tim_ielen; - tim_ie_offset = (int)(p - pie); - remainder_ielen = pnetwork_mlmeext->ie_length - - tim_ie_offset - tim_ielen; - /* append TIM IE from dst_ie offset */ - dst_ie = p; - } else { - tim_ielen = 0; - - /* calculate head_len */ - offset = _FIXED_IE_LENGTH_; - offset += pnetwork_mlmeext->ssid.ssid_length + 2; - - /* get supported rates len */ - p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, - &tmp_len, (pnetwork_mlmeext->ie_length - - _BEACON_IE_OFFSET_)); - if (p) - offset += tmp_len + 2; - - /* DS Parameter Set IE, len = 3 */ - offset += 3; - - premainder_ie = pie + offset; - - remainder_ielen = pnetwork_mlmeext->ie_length - - offset - tim_ielen; - - /* append TIM IE from offset */ - dst_ie = pie + offset; - } - - if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); - if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, - remainder_ielen); - } - *dst_ie++ = WLAN_EID_TIM; - - if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 0x00fc)) - tim_ielen = 5; - else - tim_ielen = 4; - - *dst_ie++ = tim_ielen; - - *dst_ie++ = 0;/* DTIM count */ - *dst_ie++ = 1;/* DTIM period */ - - if (pstapriv->tim_bitmap & BIT(0))/* for bc/mc frames */ - *dst_ie++ = BIT(0);/* bitmap ctrl */ - else - *dst_ie++ = 0; - - if (tim_ielen == 4) { - *dst_ie++ = pstapriv->tim_bitmap & 0xff; - } else if (tim_ielen == 5) { - put_unaligned_le16(pstapriv->tim_bitmap, dst_ie); - dst_ie += 2; - } - - /* copy remainder IE */ - if (pbackup_remainder_ie) { - memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); - - kfree(pbackup_remainder_ie); - } - offset = (uint)(dst_ie - pie); - pnetwork_mlmeext->ie_length = offset + remainder_ielen; - - set_tx_beacon_cmd(padapter); -} - -static u8 chk_sta_is_alive(struct sta_info *psta) -{ - u8 ret = false; - - if ((psta->sta_stats.last_rx_data_pkts + - psta->sta_stats.last_rx_ctrl_pkts) == - (psta->sta_stats.rx_data_pkts + - psta->sta_stats.rx_ctrl_pkts)) - ; - else - ret = true; - - sta_update_last_rx_pkts(psta); - - return ret; -} - -void expire_timeout_chk(struct adapter *padapter) -{ - struct list_head *phead; - u8 updated = 0; - struct sta_info *psta, *temp; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 chk_alive_num = 0; - char chk_alive_list[NUM_STA]; - int i; - - spin_lock_bh(&pstapriv->auth_list_lock); - - phead = &pstapriv->auth_list; - /* check auth_queue */ - list_for_each_entry_safe(psta, temp, phead, auth_list) { - if (psta->expire_to > 0) { - psta->expire_to--; - if (psta->expire_to == 0) { - list_del_init(&psta->auth_list); - pstapriv->auth_list_cnt--; - - spin_unlock_bh(&pstapriv->auth_list_lock); - - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(padapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - - spin_lock_bh(&pstapriv->auth_list_lock); - } - } - } - spin_unlock_bh(&pstapriv->auth_list_lock); - - psta = NULL; - - spin_lock_bh(&pstapriv->asoc_list_lock); - - phead = &pstapriv->asoc_list; - /* check asoc_queue */ - list_for_each_entry_safe(psta, temp, phead, asoc_list) { - if (chk_sta_is_alive(psta) || !psta->expire_to) { - psta->expire_to = pstapriv->expire_to; - psta->keep_alive_trycnt = 0; - psta->under_exist_checking = 0; - } else { - psta->expire_to--; - } - - if (psta->expire_to <= 0) { - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (padapter->registrypriv.wifi_spec == 1) { - psta->expire_to = pstapriv->expire_to; - continue; - } - - if (psta->state & WIFI_SLEEP_STATE) { - if (!(psta->state & WIFI_STA_ALIVE_CHK_STATE)) { - /* to check if alive by another methods - * if station is at ps mode. - */ - psta->expire_to = pstapriv->expire_to; - psta->state |= WIFI_STA_ALIVE_CHK_STATE; - - /* to update bcn with tim_bitmap - * for this station - */ - pstapriv->tim_bitmap |= BIT(psta->aid); - update_beacon(padapter, WLAN_EID_TIM, NULL, - false); - - if (!pmlmeext->active_keep_alive_check) - continue; - } - } - if (pmlmeext->active_keep_alive_check) { - int stainfo_offset; - - stainfo_offset = - rtw_stainfo_offset(pstapriv, psta); - if (stainfo_offset_valid(stainfo_offset)) - chk_alive_list[chk_alive_num++] = - stainfo_offset; - continue; - } - - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - - updated = ap_free_sta(padapter, psta, true, - WLAN_REASON_DEAUTH_LEAVING); - } else { - /* TODO: Aging mechanism to digest frames in - * sleep_q to avoid running out of xmitframe - */ - if (psta->sleepq_len > (NR_XMITFRAME / pstapriv->asoc_list_cnt) && - padapter->xmitpriv.free_xmitframe_cnt < - (NR_XMITFRAME / pstapriv->asoc_list_cnt / 2)) - wakeup_sta_to_xmit(padapter, psta); - } - } - - spin_unlock_bh(&pstapriv->asoc_list_lock); - - if (chk_alive_num) { - u8 backup_oper_channel = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - /* switch to correct channel of current network before issue keep-alive frames */ - if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { - backup_oper_channel = rtw_get_oper_ch(padapter); - SelectChannel(padapter, pmlmeext->cur_channel); - } - - /* issue null data to check sta alive*/ - for (i = 0; i < chk_alive_num; i++) { - int ret = _FAIL; - - psta = rtw_get_stainfo_by_offset(pstapriv, - chk_alive_list[i]); - - if (psta->state & WIFI_SLEEP_STATE) { - ret = issue_nulldata(padapter, psta->hwaddr, - 0, 1, 50); - } else { - ret = issue_nulldata(padapter, psta->hwaddr, - 0, 3, 50); - } - - psta->keep_alive_trycnt++; - if (ret == _SUCCESS) { - psta->expire_to = pstapriv->expire_to; - psta->keep_alive_trycnt = 0; - continue; - } else if (psta->keep_alive_trycnt <= 3) { - psta->expire_to = 1; - continue; - } - - psta->keep_alive_trycnt = 0; - - spin_lock_bh(&pstapriv->asoc_list_lock); - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, true, - WLAN_REASON_DEAUTH_LEAVING); - spin_unlock_bh(&pstapriv->asoc_list_lock); - } - - if (backup_oper_channel > 0) /* back to the original operation channel */ - SelectChannel(padapter, backup_oper_channel); - } - - associated_clients_update(padapter, updated); -} - -void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) -{ - int i; - u32 init_rate = 0; - unsigned char sta_band = 0, raid, shortGIrate = false; - unsigned int tx_ra_bitmap = 0; - struct ht_priv *psta_ht = NULL; - - if (psta) - psta_ht = &psta->htpriv; - else - return; - - if (!(psta->state & _FW_LINKED)) - return; - - /* b/g mode ra_bitmap */ - for (i = 0; i < sizeof(psta->bssrateset); i++) { - if (psta->bssrateset[i]) - tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f); - } - /* n mode ra_bitmap */ - if (psta_ht->ht_option) { - for (i = 0; i < 8; i++) - if (psta_ht->ht_cap.mcs.rx_mask[0] & BIT(i)) - tx_ra_bitmap |= BIT(i + 12); - - /* max short GI rate */ - shortGIrate = psta_ht->sgi; - } - - if (tx_ra_bitmap & 0xffff000) - sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B; - else if (tx_ra_bitmap & 0xff0) - sta_band |= WIRELESS_11G | WIRELESS_11B; - else - sta_band |= WIRELESS_11B; - - psta->wireless_mode = sta_band; - - raid = networktype_to_raid(sta_band); - init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f; - - if (psta->aid < NUM_STA) { - u8 arg = 0; - - arg = psta->mac_id & 0x1f; - - arg |= BIT(7);/* support entry 2~31 */ - - if (shortGIrate) - arg |= BIT(5); - - tx_ra_bitmap |= ((raid << 28) & 0xf0000000); - - /* bitmap[0:27] = tx_rate_bitmap */ - /* bitmap[28:31]= Rate Adaptive id */ - /* arg[0:4] = macid */ - /* arg[5] = Short GI */ - rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, rssi_level); - - if (shortGIrate) - init_rate |= BIT(6); - - /* set ra_id, init_rate */ - psta->raid = raid; - psta->init_rate = init_rate; - } -} - -static void update_bmc_sta(struct adapter *padapter) -{ - u32 init_rate = 0; - unsigned char network_type, raid; - int i, supportRateNum = 0; - unsigned int tx_ra_bitmap = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_network = &pmlmepriv->cur_network.network; - struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); - - if (psta) { - psta->aid = 0;/* default set to 0 */ - psta->mac_id = psta->aid + 1; - - psta->qos_option = 0; - psta->htpriv.ht_option = false; - - psta->ieee8021x_blocked = 0; - - memset(&psta->sta_stats, 0, sizeof(struct stainfo_stats)); - - /* prepare for add_RATid */ - supportRateNum = rtw_get_rateset_len((u8 *)&pcur_network->SupportedRates); - network_type = rtw_check_network_type((u8 *)&pcur_network->SupportedRates); - - memcpy(psta->bssrateset, &pcur_network->SupportedRates, - supportRateNum); - psta->bssratelen = supportRateNum; - - /* b/g mode ra_bitmap */ - for (i = 0; i < supportRateNum; i++) { - if (psta->bssrateset[i]) - tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f); - } - - /* force to b mode */ - network_type = WIRELESS_11B; - tx_ra_bitmap = 0xf; - - raid = networktype_to_raid(network_type); - init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & - 0x3f; - - /* ap mode */ - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); - - { - u8 arg = 0; - - arg = psta->mac_id & 0x1f; - arg |= BIT(7); - tx_ra_bitmap |= ((raid << 28) & 0xf0000000); - - /* bitmap[0:27] = tx_rate_bitmap */ - /* bitmap[28:31]= Rate Adaptive id */ - /* arg[0:4] = macid */ - /* arg[5] = Short GI */ - rtw_hal_add_ra_tid(padapter, tx_ra_bitmap, arg, 0); - } - /* set ra_id, init_rate */ - psta->raid = raid; - psta->init_rate = init_rate; - - rtw_stassoc_hw_rpt(padapter, psta); - - spin_lock_bh(&psta->lock); - psta->state = _FW_LINKED; - spin_unlock_bh(&psta->lock); - } -} - -/* notes: */ -/* AID: 1~MAX for sta and 0 for bc/mc in ap/adhoc mode */ -/* MAC_ID = AID+1 for sta in ap/adhoc mode */ -/* MAC_ID = 1 for bc/mc for sta/ap/adhoc */ -/* MAC_ID = 0 for bssid for sta/ap/adhoc */ -/* CAM_ID = 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ - -void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; - struct ht_priv *phtpriv_sta = &psta->htpriv; - - psta->mac_id = psta->aid + 1; - - /* ap mode */ - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); - - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - psta->ieee8021x_blocked = true; - else - psta->ieee8021x_blocked = false; - - /* update sta's cap */ - - /* ERP */ - VCS_update(padapter, psta); - /* HT related cap */ - if (phtpriv_sta->ht_option) { - /* check if sta supports rx ampdu */ - phtpriv_sta->ampdu_enable = phtpriv_ap->ampdu_enable; - - /* check if sta support s Short GI */ - if (le16_to_cpu(phtpriv_sta->ht_cap.cap_info & - phtpriv_ap->ht_cap.cap_info) & - (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) - phtpriv_sta->sgi = true; - - /* bwmode */ - if (le16_to_cpu(phtpriv_sta->ht_cap.cap_info & - phtpriv_ap->ht_cap.cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH_20_40) { - phtpriv_sta->bwmode = pmlmeext->cur_bwmode; - phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; - } - psta->qos_option = true; - } else { - phtpriv_sta->ampdu_enable = false; - phtpriv_sta->sgi = false; - phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; - phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - } - - /* Rx AMPDU */ - send_delba(padapter, 0, psta->hwaddr);/* recipient */ - - /* TX AMPDU */ - send_delba(padapter, 1, psta->hwaddr);/* originator */ - phtpriv_sta->agg_enable_bitmap = 0x0;/* reset */ - phtpriv_sta->candidate_tid_bitmap = 0x0;/* reset */ - - /* todo: init other variables */ - - memset(&psta->sta_stats, 0, sizeof(struct stainfo_stats)); - - spin_lock_bh(&psta->lock); - psta->state |= _FW_LINKED; - spin_unlock_bh(&psta->lock); -} - -static void update_hw_ht_param(struct adapter *padapter) -{ - u8 max_ampdu_len; - u8 min_mpdu_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - /* handle A-MPDU parameter field - * ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k - * ampdu_params_info [4:2]:Min MPDU Start Spacing - */ - max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; - min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; - - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); - - /* Config SM Power Save setting */ - pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & 0x0C) >> 2; -} - -static void start_bss_network(struct adapter *padapter, u8 *pbuf) -{ - u8 *p; - u8 val8, cur_channel, cur_bwmode, cur_ch_offset; - u16 bcn_interval; - u32 acparm; - uint ie_len; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct wlan_bssid_ex *pnetwork = &pmlmepriv->cur_network.network; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; - struct HT_info_element *pht_info = NULL; - - bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; - cur_channel = pnetwork->Configuration.DSConfig; - cur_bwmode = HT_CHANNEL_WIDTH_20; - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - /* check if there is wps ie, - * if there is wpsie in beacon, the hostapd will update - * beacon twice when stating hostapd, and at first time the - * security ie (RSN/WPA IE) will not include in beacon. - */ - if (!rtw_get_wps_ie(pnetwork->ies + _FIXED_IE_LENGTH_, pnetwork->ie_length - _FIXED_IE_LENGTH_, NULL, NULL)) - pmlmeext->bstart_bss = true; - - /* todo: update wmm, ht cap */ - if (pmlmepriv->qospriv.qos_option) - pmlmeinfo->WMM_enable = true; - if (pmlmepriv->htpriv.ht_option) { - pmlmeinfo->WMM_enable = true; - pmlmeinfo->HT_enable = true; - - update_hw_ht_param(padapter); - } - - /* setting only at first time */ - if (!pmlmepriv->cur_network.join_res) { - /* WEP Key will be set before this function, do not - * clear CAM. - */ - if ((psecuritypriv->dot11PrivacyAlgrthm != _WEP40_) && - (psecuritypriv->dot11PrivacyAlgrthm != _WEP104_)) - flush_all_cam_entry(padapter); /* clear CAM */ - } - - /* set MSR to AP_Mode */ - Set_MSR(padapter, _HW_STATE_AP_); - - /* Set BSSID REG */ - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pnetwork->MacAddress); - - /* Set EDCA param reg */ - acparm = 0x002F3217; /* VO */ - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acparm)); - acparm = 0x005E4317; /* VI */ - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acparm)); - acparm = 0x005ea42b; - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acparm)); - acparm = 0x0000A444; /* BK */ - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acparm)); - - /* Set Security */ - val8 = (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); - - /* Beacon Control related register */ - rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, - (u8 *)(&bcn_interval)); - - UpdateBrateTbl(padapter, pnetwork->SupportedRates); - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, pnetwork->SupportedRates); - - if (!pmlmepriv->cur_network.join_res) { /* setting only at first time */ - /* turn on all dynamic functions */ - Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); - } - /* set channel, bwmode */ - p = rtw_get_ie(pnetwork->ies + sizeof(struct ndis_802_11_fixed_ie), - WLAN_EID_HT_OPERATION, &ie_len, - pnetwork->ie_length - - sizeof(struct ndis_802_11_fixed_ie)); - if (p && ie_len) { - pht_info = (struct HT_info_element *)(p + 2); - - if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { - /* switch to the 40M Hz mode */ - cur_bwmode = HT_CHANNEL_WIDTH_40; - switch (pht_info->infos[0] & 0x3) { - case 1: - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; - case 3: - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; - default: - cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; - } - } - } - /* TODO: need to judge the phy parameters on concurrent - * mode for single phy - */ - set_channel_bwmode(padapter, cur_channel, cur_ch_offset, cur_bwmode); - - /* */ - pmlmeext->cur_channel = cur_channel; - pmlmeext->cur_bwmode = cur_bwmode; - pmlmeext->cur_ch_offset = cur_ch_offset; - pmlmeext->cur_wireless_mode = pmlmepriv->cur_network.network_type; - - /* update cur_wireless_mode */ - update_wireless_mode(padapter); - - /* update capability after cur_wireless_mode updated */ - update_capinfo(padapter, rtw_get_capability(pnetwork)); - - /* let pnetwork_mlmeext == pnetwork_mlme. */ - memcpy(pnetwork_mlmeext, pnetwork, pnetwork->Length); - - if (pmlmeext->bstart_bss) { - update_beacon(padapter, WLAN_EID_TIM, NULL, false); - - /* issue beacon frame */ - send_beacon(padapter); - } - - /* update bc/mc sta_info */ - update_bmc_sta(padapter); -} - -int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) -{ - int ret = _SUCCESS; - u8 *p; - u8 *pHT_caps_ie = NULL; - u8 *pHT_info_ie = NULL; - struct sta_info *psta = NULL; - u16 cap, ht_cap = false; - uint ie_len = 0; - int group_cipher, pairwise_cipher; - u8 channel, network_type, supportRate[NDIS_802_11_LENGTH_RATES_EX]; - int supportRateNum = 0; - u8 OUI1[] = {0x00, 0x50, 0xf2, 0x01}; - u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pbss_network = &pmlmepriv->cur_network.network; - u8 *ie = pbss_network->ies; - - /* SSID */ - /* Supported rates */ - /* DS Params */ - /* WLAN_EID_COUNTRY */ - /* ERP Information element */ - /* Extended supported rates */ - /* WPA/WPA2 */ - /* Wi-Fi Wireless Multimedia Extensions */ - /* ht_capab, ht_oper */ - /* WPS IE */ - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return _FAIL; - - if (len < 0 || len > MAX_IE_SZ) - return _FAIL; - - pbss_network->ie_length = len; - - memset(ie, 0, MAX_IE_SZ); - - memcpy(ie, pbuf, pbss_network->ie_length); - - if (pbss_network->InfrastructureMode != Ndis802_11APMode) - return _FAIL; - - pbss_network->Rssi = 0; - - ether_addr_copy(pbss_network->MacAddress, myid(&padapter->eeprompriv)); - - /* beacon interval */ - p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ - pbss_network->Configuration.BeaconPeriod = get_unaligned_le16(p); - - /* capability */ - cap = get_unaligned_le16(ie); - - /* SSID */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SSID, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p && ie_len > 0) { - ie_len = min_t(int, ie_len, sizeof(pbss_network->ssid.ssid)); - memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(pbss_network->ssid.ssid, p + 2, ie_len); - pbss_network->ssid.ssid_length = ie_len; - } - - /* channel */ - channel = 0; - pbss_network->Configuration.Length = 0; - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_DS_PARAMS, &ie_len, - (pbss_network->ie_length - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) - channel = *(p + 2); - - pbss_network->Configuration.DSConfig = channel; - - memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); - /* get supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_SUPP_RATES, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p) { - ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX); - memcpy(supportRate, p + 2, ie_len); - supportRateNum = ie_len; - } - - /* get ext_supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_EXT_SUPP_RATES, - &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p) { - ie_len = min_t(int, ie_len, - NDIS_802_11_LENGTH_RATES_EX - supportRateNum); - memcpy(supportRate + supportRateNum, p + 2, ie_len); - supportRateNum += ie_len; - } - - network_type = rtw_check_network_type(supportRate); - - rtw_set_supported_rate(pbss_network->SupportedRates, network_type); - - /* parsing ERP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p && ie_len > 0) - ERP_IE_handler(padapter, (struct ndis_802_11_var_ie *)p); - - /* update privacy/security */ - if (cap & BIT(4)) - pbss_network->Privacy = 1; - else - pbss_network->Privacy = 0; - - psecuritypriv->wpa_psk = 0; - - /* wpa2 */ - group_cipher = 0; - pairwise_cipher = 0; - psecuritypriv->wpa2_group_cipher = _NO_PRIVACY_; - psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_RSN, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p && ie_len > 0) { - if (rtw_parse_wpa2_ie(p, ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - - psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ - psecuritypriv->wpa_psk |= BIT(1); - - psecuritypriv->wpa2_group_cipher = group_cipher; - psecuritypriv->wpa2_pairwise_cipher = pairwise_cipher; - } - } - /* wpa */ - ie_len = 0; - group_cipher = 0; - pairwise_cipher = 0; - psecuritypriv->wpa_group_cipher = _NO_PRIVACY_; - psecuritypriv->wpa_pairwise_cipher = _NO_PRIVACY_; - for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { - p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2)); - if ((p) && (!memcmp(p + 2, OUI1, 4))) { - if (rtw_parse_wpa_ie(p, ie_len + 2, &group_cipher, - &pairwise_cipher, NULL) == _SUCCESS) { - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - - psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ - - psecuritypriv->wpa_psk |= BIT(0); - - psecuritypriv->wpa_group_cipher = group_cipher; - psecuritypriv->wpa_pairwise_cipher = pairwise_cipher; - } - break; - } - if ((!p) || (ie_len == 0)) - break; - } - - /* wmm */ - ie_len = 0; - pmlmepriv->qospriv.qos_option = 0; - if (pregistrypriv->wmm_enable) { - for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { - p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2)); - if ((p) && !memcmp(p + 2, WMM_PARA_IE, 6)) { - pmlmepriv->qospriv.qos_option = 1; - - /* QoS Info, support U-APSD */ - *(p + 8) |= BIT(7); - - /* disable all ACM bits since the WMM - * admission control is not supported - */ - *(p + 10) &= ~BIT(4); /* BE */ - *(p + 14) &= ~BIT(4); /* BK */ - *(p + 18) &= ~BIT(4); /* VI */ - *(p + 22) &= ~BIT(4); /* VO */ - break; - } - - if ((!p) || (ie_len == 0)) - break; - } - } - /* parsing HT_CAP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p && ie_len > 0) { - struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p + 2); - - pHT_caps_ie = p; - ht_cap = true; - network_type |= WIRELESS_11_24N; - - if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || - (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) - pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2)); - else - pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); - - /* set Max Rx AMPDU size to 64K */ - pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & 0x03); - - pht_cap->mcs.rx_mask[0] = 0xff; - pht_cap->mcs.rx_mask[1] = 0x0; - ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap)); - memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); - } - - /* parsing HT_INFO_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, - pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p && ie_len > 0) - pHT_info_ie = p; - switch (network_type) { - case WIRELESS_11B: - pbss_network->NetworkTypeInUse = Ndis802_11DS; - break; - case WIRELESS_11G: - case WIRELESS_11BG: - case WIRELESS_11G_24N: - case WIRELESS_11BG_24N: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - case WIRELESS_11A: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; - break; - default: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - } - - pmlmepriv->cur_network.network_type = network_type; - - pmlmepriv->htpriv.ht_option = false; - - if ((psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) || - (psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_TKIP)) { - /* todo: */ - /* ht_cap = false; */ - } - - /* ht_cap */ - if (pregistrypriv->ht_enable && ht_cap) { - pmlmepriv->htpriv.ht_option = true; - pmlmepriv->qospriv.qos_option = 1; - - if (pregistrypriv->ampdu_enable == 1) - pmlmepriv->htpriv.ampdu_enable = true; - HT_caps_handler(padapter, (struct ndis_802_11_var_ie *)pHT_caps_ie); - - HT_info_handler(padapter, (struct ndis_802_11_var_ie *)pHT_info_ie); - } - - pbss_network->Length = get_wlan_bssid_ex_sz(pbss_network); - - /* issue beacon to start bss network */ - start_bss_network(padapter, (u8 *)pbss_network); - - /* alloc sta_info for ap itself */ - psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); - if (!psta) { - psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); - if (!psta) - return _FAIL; - } - - /* fix bug of flush_cam_entry at STOP AP mode */ - psta->state |= WIFI_AP_STATE; - rtw_indicate_connect(padapter); - pmlmepriv->cur_network.join_res = true;/* for check if already set beacon */ - return ret; -} - -void rtw_set_macaddr_acl(struct adapter *padapter, int mode) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - - pacl_list->mode = mode; -} - -int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) -{ - struct list_head *plist, *phead; - u8 added = false; - int i, ret = 0; - struct rtw_wlan_acl_node *paclnode; - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - struct __queue *pacl_node_q = &pacl_list->acl_node_q; - - if ((NUM_ACL - 1) < pacl_list->num) - return -1; - - spin_lock_bh(&pacl_node_q->lock); - - phead = get_list_head(pacl_node_q); - list_for_each(plist, phead) { - paclnode = list_entry(plist, struct rtw_wlan_acl_node, list); - - if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { - if (paclnode->valid) { - added = true; - break; - } - } - } - - spin_unlock_bh(&pacl_node_q->lock); - - if (added) - return ret; - - spin_lock_bh(&pacl_node_q->lock); - - for (i = 0; i < NUM_ACL; i++) { - paclnode = &pacl_list->aclnode[i]; - - if (!paclnode->valid) { - INIT_LIST_HEAD(&paclnode->list); - - ether_addr_copy(paclnode->addr, addr); - - paclnode->valid = true; - - list_add_tail(&paclnode->list, get_list_head(pacl_node_q)); - - pacl_list->num++; - - break; - } - } - - spin_unlock_bh(&pacl_node_q->lock); - - return ret; -} - -int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr) -{ - struct list_head *phead; - struct rtw_wlan_acl_node *paclnode, *temp; - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - struct __queue *pacl_node_q = &pacl_list->acl_node_q; - - spin_lock_bh(&pacl_node_q->lock); - - phead = get_list_head(pacl_node_q); - list_for_each_entry_safe(paclnode, temp, phead, list) { - if (!memcmp(paclnode->addr, addr, ETH_ALEN)) { - if (paclnode->valid) { - paclnode->valid = false; - - list_del_init(&paclnode->list); - - pacl_list->num--; - } - } - } - - spin_unlock_bh(&pacl_node_q->lock); - - return 0; -} - -static void update_bcn_erpinfo_ie(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - unsigned char *p, *ie = pnetwork->ies; - u32 len = 0; - - if (!pmlmeinfo->ERP_enable) - return; - - /* parsing ERP_IE */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_ERP_INFO, &len, - (pnetwork->ie_length - _BEACON_IE_OFFSET_)); - if (p && len > 0) { - struct ndis_802_11_var_ie *pIE = (struct ndis_802_11_var_ie *)p; - - if (pmlmepriv->num_sta_non_erp == 1) - pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT | - RTW_ERP_INFO_USE_PROTECTION; - else - pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT | - RTW_ERP_INFO_USE_PROTECTION); - - if (pmlmepriv->num_sta_no_short_preamble > 0) - pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE; - else - pIE->data[0] &= ~(RTW_ERP_INFO_BARKER_PREAMBLE_MODE); - - ERP_IE_handler(padapter, pIE); - } -} - -static void update_bcn_wps_ie(struct adapter *padapter) -{ - u8 *pwps_ie = NULL, *pwps_ie_src; - u8 *premainder_ie, *pbackup_remainder_ie = NULL; - uint wps_ielen = 0, wps_offset, remainder_ielen; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - unsigned char *ie = pnetwork->ies; - u32 ielen = pnetwork->ie_length; - - pwps_ie_src = pmlmepriv->wps_beacon_ie; - if (!pwps_ie_src) - return; - - pwps_ie = rtw_get_wps_ie(ie + _FIXED_IE_LENGTH_, - ielen - _FIXED_IE_LENGTH_, NULL, &wps_ielen); - - if (!pwps_ie || wps_ielen == 0) - return; - - wps_offset = (uint)(pwps_ie - ie); - - premainder_ie = pwps_ie + wps_ielen; - - remainder_ielen = ielen - wps_offset - wps_ielen; - - if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); - if (pbackup_remainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); - } - - wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ - if (wps_offset + wps_ielen + 2 + remainder_ielen <= MAX_IE_SZ) { - memcpy(pwps_ie, pwps_ie_src, wps_ielen + 2); - pwps_ie += wps_ielen + 2; - - if (pbackup_remainder_ie) - memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen); - - /* update ie_length */ - pnetwork->ie_length = wps_offset + wps_ielen + 2 + remainder_ielen; - } - - kfree(pbackup_remainder_ie); -} - -static void update_bcn_vendor_spec_ie(struct adapter *padapter, u8 *oui) -{ - if (!memcmp(WPS_OUI, oui, 4)) - update_bcn_wps_ie(padapter); -} - -void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) -{ - struct mlme_priv *pmlmepriv; - struct mlme_ext_priv *pmlmeext; - - if (!padapter) - return; - - pmlmepriv = &padapter->mlmepriv; - pmlmeext = &padapter->mlmeextpriv; - - if (!pmlmeext->bstart_bss) - return; - - spin_lock_bh(&pmlmepriv->bcn_update_lock); - - switch (ie_id) { - case WLAN_EID_TIM: - update_BCNTIM(padapter); - break; - case WLAN_EID_ERP_INFO: - update_bcn_erpinfo_ie(padapter); - break; - case WLAN_EID_VENDOR_SPECIFIC: - update_bcn_vendor_spec_ie(padapter, oui); - break; - default: - break; - } - - pmlmepriv->update_bcn = true; - - spin_unlock_bh(&pmlmepriv->bcn_update_lock); - - if (tx) - set_tx_beacon_cmd(padapter); -} - -/* - * op_mode - * Set to 0 (HT pure) under the following conditions - * - all STAs in the BSS are 20/40 MHz HT in 20/40 MHz BSS or - * - all STAs in the BSS are 20 MHz HT in 20 MHz BSS - * Set to 1 (HT non-member protection) if there may be non-HT STAs - * in both the primary and the secondary channel - * Set to 2 if only HT STAs are associated in BSS, - * however and at least one 20 MHz HT STA is associated - * Set to 3 (HT mixed mode) when one or more non-HT STAs are associated - * (currently non-GF HT station is considered as non-HT STA also) - */ -static int rtw_ht_operation_update(struct adapter *padapter) -{ - u16 cur_op_mode, new_op_mode; - int op_mode_changes = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; - - if (pmlmepriv->htpriv.ht_option) - return 0; - - if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && - pmlmepriv->num_sta_ht_no_gf) { - pmlmepriv->ht_op_mode |= - HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; - op_mode_changes++; - } else if ((pmlmepriv->ht_op_mode & - HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT) && - pmlmepriv->num_sta_ht_no_gf == 0) { - pmlmepriv->ht_op_mode &= - ~HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT; - op_mode_changes++; - } - - if (!(pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && - (pmlmepriv->num_sta_no_ht || pmlmepriv->olbc_ht)) { - pmlmepriv->ht_op_mode |= HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; - op_mode_changes++; - } else if ((pmlmepriv->ht_op_mode & - HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT) && - (pmlmepriv->num_sta_no_ht == 0 && !pmlmepriv->olbc_ht)) { - pmlmepriv->ht_op_mode &= - ~HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT; - op_mode_changes++; - } - - /* Note: currently we switch to the MIXED op mode if HT non-greenfield - * station is associated. Probably it's a theoretical case, since - * it looks like all known HT STAs support greenfield. - */ - new_op_mode = 0; - if (pmlmepriv->num_sta_no_ht || - (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) - new_op_mode = OP_MODE_MIXED; - else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH_20_40) && - pmlmepriv->num_sta_ht_20mhz) - new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; - else if (pmlmepriv->olbc_ht) - new_op_mode = OP_MODE_MAY_BE_LEGACY_STAS; - else - new_op_mode = OP_MODE_PURE; - - cur_op_mode = pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_OP_MODE_MASK; - if (cur_op_mode != new_op_mode) { - pmlmepriv->ht_op_mode &= ~HT_INFO_OPERATION_MODE_OP_MODE_MASK; - pmlmepriv->ht_op_mode |= new_op_mode; - op_mode_changes++; - } - - return op_mode_changes; -} - -void associated_clients_update(struct adapter *padapter, u8 updated) -{ - /* update associated stations cap. */ - if (updated) { - struct list_head *phead, *plist; - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - - spin_lock_bh(&pstapriv->asoc_list_lock); - - phead = &pstapriv->asoc_list; - /* check asoc_queue */ - list_for_each(plist, phead) { - psta = list_entry(plist, struct sta_info, asoc_list); - - VCS_update(padapter, psta); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - } -} - -/* called > TSR LEVEL for USB or SDIO Interface*/ -void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) -{ - u8 beacon_updated = false; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { - if (!psta->no_short_preamble_set) { - psta->no_short_preamble_set = 1; - - pmlmepriv->num_sta_no_short_preamble++; - - if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_preamble == 1)) { - beacon_updated = true; - update_beacon(padapter, 0xFF, NULL, true); - } - } - } else { - if (psta->no_short_preamble_set) { - psta->no_short_preamble_set = 0; - - pmlmepriv->num_sta_no_short_preamble--; - - if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_preamble == 0)) { - beacon_updated = true; - update_beacon(padapter, 0xFF, NULL, true); - } - } - } - - if (psta->flags & WLAN_STA_NONERP) { - if (!psta->nonerp_set) { - psta->nonerp_set = 1; - - pmlmepriv->num_sta_non_erp++; - - if (pmlmepriv->num_sta_non_erp == 1) { - beacon_updated = true; - update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); - } - } - } else { - if (psta->nonerp_set) { - psta->nonerp_set = 0; - - pmlmepriv->num_sta_non_erp--; - - if (pmlmepriv->num_sta_non_erp == 0) { - beacon_updated = true; - update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); - } - } - } - - if (!(psta->capability & WLAN_CAPABILITY_SHORT_SLOT_TIME)) { - if (!psta->no_short_slot_time_set) { - psta->no_short_slot_time_set = 1; - - pmlmepriv->num_sta_no_short_slot_time++; - - if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_slot_time == 1)) { - beacon_updated = true; - update_beacon(padapter, 0xFF, NULL, true); - } - } - } else { - if (psta->no_short_slot_time_set) { - psta->no_short_slot_time_set = 0; - - pmlmepriv->num_sta_no_short_slot_time--; - - if ((pmlmeext->cur_wireless_mode > WIRELESS_11B) && - (pmlmepriv->num_sta_no_short_slot_time == 0)) { - beacon_updated = true; - update_beacon(padapter, 0xFF, NULL, true); - } - } - } - - if (psta->flags & WLAN_STA_HT) { - u16 ht_capab = le16_to_cpu(psta->htpriv.ht_cap.cap_info); - - if (psta->no_ht_set) { - psta->no_ht_set = 0; - pmlmepriv->num_sta_no_ht--; - } - - if ((ht_capab & IEEE80211_HT_CAP_GRN_FLD) == 0) { - if (!psta->no_ht_gf_set) { - psta->no_ht_gf_set = 1; - pmlmepriv->num_sta_ht_no_gf++; - } - } - - if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) { - if (!psta->ht_20mhz_set) { - psta->ht_20mhz_set = 1; - pmlmepriv->num_sta_ht_20mhz++; - } - } - } else { - if (!psta->no_ht_set) { - psta->no_ht_set = 1; - pmlmepriv->num_sta_no_ht++; - } - } - - if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); - update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true); - } - - /* update associated stations cap. */ - associated_clients_update(padapter, beacon_updated); -} - -u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) -{ - u8 beacon_updated = false; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (!psta) - return beacon_updated; - - if (psta->no_short_preamble_set) { - psta->no_short_preamble_set = 0; - pmlmepriv->num_sta_no_short_preamble--; - if (pmlmeext->cur_wireless_mode > WIRELESS_11B && - pmlmepriv->num_sta_no_short_preamble == 0) { - beacon_updated = true; - update_beacon(padapter, 0xFF, NULL, true); - } - } - - if (psta->nonerp_set) { - psta->nonerp_set = 0; - pmlmepriv->num_sta_non_erp--; - if (pmlmepriv->num_sta_non_erp == 0) { - beacon_updated = true; - update_beacon(padapter, WLAN_EID_ERP_INFO, NULL, true); - } - } - - if (psta->no_short_slot_time_set) { - psta->no_short_slot_time_set = 0; - pmlmepriv->num_sta_no_short_slot_time--; - if (pmlmeext->cur_wireless_mode > WIRELESS_11B && - pmlmepriv->num_sta_no_short_slot_time == 0) { - beacon_updated = true; - update_beacon(padapter, 0xFF, NULL, true); - } - } - - if (psta->no_ht_gf_set) { - psta->no_ht_gf_set = 0; - pmlmepriv->num_sta_ht_no_gf--; - } - - if (psta->no_ht_set) { - psta->no_ht_set = 0; - pmlmepriv->num_sta_no_ht--; - } - - if (psta->ht_20mhz_set) { - psta->ht_20mhz_set = 0; - pmlmepriv->num_sta_ht_20mhz--; - } - - if (rtw_ht_operation_update(padapter) > 0) { - update_beacon(padapter, WLAN_EID_HT_CAPABILITY, NULL, false); - update_beacon(padapter, WLAN_EID_HT_OPERATION, NULL, true); - } - - /* update associated stations cap. */ - - return beacon_updated; -} - -u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, - bool active, u16 reason) -{ - u8 beacon_updated = false; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!psta) - return beacon_updated; - - /* tear down Rx AMPDU */ - send_delba(padapter, 0, psta->hwaddr);/* recipient */ - - /* tear down TX AMPDU */ - send_delba(padapter, 1, psta->hwaddr);/* originator */ - psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ - psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ - - if (active) - issue_deauth(padapter, psta->hwaddr, reason); - - /* clear cam entry / key */ - rtw_clearstakey_cmd(padapter, (u8 *)psta, (u8)(psta->mac_id + 3), true); - - spin_lock_bh(&psta->lock); - psta->state &= ~_FW_LINKED; - spin_unlock_bh(&psta->lock); - - rtw_indicate_sta_disassoc_event(padapter, psta); - - report_del_sta_event(padapter, psta->hwaddr, reason); - - beacon_updated = bss_cap_update_on_sta_leave(padapter, psta); - - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(padapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - - return beacon_updated; -} - -int rtw_sta_flush(struct adapter *padapter) -{ - struct list_head *phead; - struct sta_info *psta, *temp; - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) - return 0; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - /* free sta asoc_queue */ - list_for_each_entry_safe(psta, temp, phead, asoc_list) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - - ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - issue_deauth(padapter, bc_addr, WLAN_REASON_DEAUTH_LEAVING); - - associated_clients_update(padapter, true); - - return 0; -} - -/* called > TSR LEVEL for USB or SDIO Interface*/ -void sta_info_update(struct adapter *padapter, struct sta_info *psta) -{ - int flags = psta->flags; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - /* update wmm cap. */ - if (WLAN_STA_WME & flags) - psta->qos_option = 1; - else - psta->qos_option = 0; - - if (pmlmepriv->qospriv.qos_option == 0) - psta->qos_option = 0; - - /* update 802.11n ht cap. */ - if (WLAN_STA_HT & flags) { - psta->htpriv.ht_option = true; - psta->qos_option = 1; - } else { - psta->htpriv.ht_option = false; - } - - if (!pmlmepriv->htpriv.ht_option) - psta->htpriv.ht_option = false; - - update_sta_info_apmode(padapter, psta); -} - -/* called >= TSR LEVEL for USB or SDIO Interface*/ -void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) -{ - if (psta->state & _FW_LINKED) { - /* add ratid */ - add_RATid(padapter, psta, 0);/* DM_RATR_STA_INIT */ - } -} - -void start_ap_mode(struct adapter *padapter) -{ - int i; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - - pmlmepriv->update_bcn = false; - - pmlmeext->bstart_bss = false; - - pmlmepriv->num_sta_non_erp = 0; - - pmlmepriv->num_sta_no_short_slot_time = 0; - - pmlmepriv->num_sta_no_short_preamble = 0; - - pmlmepriv->num_sta_ht_no_gf = 0; - pmlmepriv->num_sta_no_ht = 0; - pmlmepriv->num_sta_ht_20mhz = 0; - - pmlmepriv->olbc = false; - - pmlmepriv->olbc_ht = false; - - pmlmepriv->ht_op_mode = 0; - - for (i = 0; i < NUM_STA; i++) - pstapriv->sta_aid[i] = NULL; - - pmlmepriv->wps_beacon_ie = NULL; - pmlmepriv->wps_probe_resp_ie = NULL; - pmlmepriv->wps_assoc_resp_ie = NULL; - - /* for ACL */ - INIT_LIST_HEAD(&pacl_list->acl_node_q.queue); - pacl_list->num = 0; - pacl_list->mode = 0; - for (i = 0; i < NUM_ACL; i++) { - INIT_LIST_HEAD(&pacl_list->aclnode[i].list); - pacl_list->aclnode[i].valid = false; - } -} - -void stop_ap_mode(struct adapter *padapter) -{ - struct rtw_wlan_acl_node *paclnode, *n; - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - struct __queue *pacl_node_q = &pacl_list->acl_node_q; - - pmlmepriv->update_bcn = false; - pmlmeext->bstart_bss = false; - - /* reset and init security priv , this can refine with - * rtw_reset_securitypriv - */ - memset((unsigned char *)&padapter->securitypriv, 0, sizeof(struct security_priv)); - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled; - - /* for ACL */ - spin_lock_bh(&pacl_node_q->lock); - list_for_each_entry_safe(paclnode, n, &pacl_node_q->queue, list) { - if (paclnode->valid) { - paclnode->valid = false; - - list_del_init(&paclnode->list); - - pacl_list->num--; - } - } - spin_unlock_bh(&pacl_node_q->lock); - - rtw_sta_flush(padapter); - - /* free_assoc_sta_resources */ - rtw_free_all_stainfo(padapter); - - psta = rtw_get_bcmc_stainfo(padapter); - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(padapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - - rtw_init_bcmc_stainfo(padapter); - - rtw_free_mlme_priv_ie_data(pmlmepriv); -} - -#endif /* CONFIG_88EU_AP_MODE */ diff --git a/drivers/staging/rtl8188eu/core/rtw_cmd.c b/drivers/staging/rtl8188eu/core/rtw_cmd.c deleted file mode 100644 index 56ece839c9ca..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_cmd.c +++ /dev/null @@ -1,1218 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include -#include -#include -#include - -static struct cmd_hdl wlancmds[] = { - {sizeof(struct wlan_bssid_ex), join_cmd_hdl}, - {sizeof(struct disconnect_parm), disconnect_hdl}, - {sizeof(struct wlan_bssid_ex), createbss_hdl}, - {sizeof(struct setopmode_parm), setopmode_hdl}, - {sizeof(struct sitesurvey_parm), sitesurvey_cmd_hdl}, - {sizeof(struct setauth_parm), setauth_hdl}, - {sizeof(struct setkey_parm), setkey_hdl}, - {sizeof(struct set_stakey_parm), set_stakey_hdl}, - {sizeof(struct set_assocsta_parm), NULL}, - {sizeof(struct addBaReq_parm), add_ba_hdl}, - {sizeof(struct set_ch_parm), set_ch_hdl}, - {sizeof(struct wlan_bssid_ex), tx_beacon_hdl}, - {0, mlme_evt_hdl}, - {0, rtw_drvextra_cmd_hdl}, - {sizeof(struct SetChannelPlan_param), set_chplan_hdl} -}; - -static struct _cmd_callback rtw_cmd_callback[] = { - {_JoinBss_CMD_, &rtw_joinbss_cmd_callback}, - {_DisConnect_CMD_, &rtw_disassoc_cmd_callback}, - {_CreateBss_CMD_, &rtw_createbss_cmd_callback}, - {_SetOpMode_CMD_, NULL}, - {_SiteSurvey_CMD_, &rtw_survey_cmd_callback}, - {_SetAuth_CMD_, NULL}, - {_SetKey_CMD_, NULL}, - {_SetStaKey_CMD_, NULL}, - {_SetAssocSta_CMD_, &rtw_setassocsta_cmdrsp_callback}, - {_AddBAReq_CMD_, NULL}, - {_SetChannel_CMD_, NULL}, - {_TX_Beacon_CMD_, NULL}, - {_Set_MLME_EVT_CMD_, NULL}, - {_Set_Drv_Extra_CMD_, NULL}, - {_SetChannelPlan_CMD_, NULL}, -}; - -/* - * Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. - * No irqsave is necessary. - */ - -void rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) -{ - init_completion(&pcmdpriv->cmd_queue_comp); - - _rtw_init_queue(&pcmdpriv->cmd_queue); -} - -/* - * Calling Context: - * - * rtw_enqueue_cmd can only be called between kernel thread, - * since only spin_lock is used. - * - * ISR/Call-Back functions can't call this sub-function. - */ - -static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) -{ - unsigned long irqL; - - spin_lock_irqsave(&queue->lock, irqL); - - list_add_tail(&obj->list, &queue->queue); - - spin_unlock_irqrestore(&queue->lock, irqL); - - return _SUCCESS; -} - -struct cmd_obj *rtw_dequeue_cmd(struct __queue *queue) -{ - unsigned long irqL; - struct cmd_obj *obj; - - spin_lock_irqsave(&queue->lock, irqL); - obj = list_first_entry_or_null(&queue->queue, struct cmd_obj, list); - if (obj) - list_del_init(&obj->list); - spin_unlock_irqrestore(&queue->lock, irqL); - - return obj; -} - -static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) -{ - struct adapter *padapter = container_of(pcmdpriv, struct adapter, cmdpriv); - u8 bAllow = false; /* set to true to allow enqueuing cmd when hw_init_completed is false */ - - /* To decide allow or not */ - if ((padapter->pwrctrlpriv.bHWPwrPindetect) && - (!padapter->registrypriv.usbss_enable)) { - if (cmd_obj->cmdcode == _Set_Drv_Extra_CMD_) { - struct drvextra_cmd_parm *pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)cmd_obj->parmbuf; - - if (pdrvextra_cmd_parm->ec_id == POWER_SAVING_CTRL_WK_CID) - bAllow = true; - } - } - - if (cmd_obj->cmdcode == _SetChannelPlan_CMD_) - bAllow = true; - - if ((!padapter->hw_init_completed && !bAllow) || - !padapter->cmdThread) /* com_thread not running */ - return _FAIL; - return _SUCCESS; -} - -u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) -{ - int res = _FAIL; - struct adapter *padapter = container_of(pcmdpriv, struct adapter, cmdpriv); - - if (!cmd_obj) - goto exit; - - cmd_obj->padapter = padapter; - - res = rtw_cmd_filter(pcmdpriv, cmd_obj); - if (res == _FAIL) { - rtw_free_cmd_obj(cmd_obj); - goto exit; - } - - res = _rtw_enqueue_cmd(&pcmdpriv->cmd_queue, cmd_obj); - - if (res == _SUCCESS) - complete(&pcmdpriv->cmd_queue_comp); - -exit: - - return res; -} - -void rtw_free_cmd_obj(struct cmd_obj *pcmd) -{ - if ((pcmd->cmdcode != _JoinBss_CMD_) && (pcmd->cmdcode != _CreateBss_CMD_)) { - /* free parmbuf in cmd_obj */ - kfree(pcmd->parmbuf); - } - - if (pcmd->rsp) { - if (pcmd->rspsz != 0) { - /* free rsp in cmd_obj */ - kfree(pcmd->rsp); - } - } - - /* free cmd_obj */ - kfree(pcmd); -} - -int rtw_cmd_thread(void *context) -{ - u8 ret; - struct cmd_obj *pcmd; - u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf); - void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd); - struct adapter *padapter = context; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - allow_signal(SIGTERM); - - do { - if (padapter->bDriverStopped || padapter->bSurpriseRemoved) - break; - - pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue); - if (!pcmd) { - /* The queue is empty. Wait until someone enqueues a command. */ - if (wait_for_completion_interruptible(&pcmdpriv->cmd_queue_comp)) - break; - - continue; - } - - if (rtw_cmd_filter(pcmdpriv, pcmd) == _FAIL) { - pcmd->res = H2C_DROPPED; - } else { - if (pcmd->cmdcode < ARRAY_SIZE(wlancmds)) { - cmd_hdl = wlancmds[pcmd->cmdcode].h2cfuns; - - if (cmd_hdl) { - ret = cmd_hdl(pcmd->padapter, pcmd->parmbuf); - pcmd->res = ret; - } - } else { - pcmd->res = H2C_PARAMETERS_ERROR; - } - } - - /* call callback function for post-processed */ - if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { - pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; - if (pcmd_callback) { - /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ - pcmd_callback(pcmd->padapter, pcmd); - } - } - rtw_free_cmd_obj(pcmd); - - if (signal_pending(current)) - flush_signals(current); - } while (!kthread_should_stop()); - - /* free all cmd_obj resources */ - while ((pcmd = rtw_dequeue_cmd(&pcmdpriv->cmd_queue))) - rtw_free_cmd_obj(pcmd); - - padapter->cmdThread = NULL; - return 0; -} - -/* - * rtw_sitesurvey_cmd(~) - * ### NOTE:#### (!!!!) - * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE - * LOCKED pmlmepriv->lock - */ -u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, int ssid_num, - struct rtw_ieee80211_channel *ch, int ch_num) -{ - u8 res = _FAIL; - struct cmd_obj *ph2c; - struct sitesurvey_parm *psurveyPara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); - - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) - return _FAIL; - - psurveyPara = kzalloc(sizeof(*psurveyPara), GFP_ATOMIC); - if (!psurveyPara) { - kfree(ph2c); - return _FAIL; - } - - rtw_free_network_queue(padapter, false); - - init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, _SiteSurvey_CMD_); - - psurveyPara->scan_mode = pmlmepriv->scan_mode; - - /* prepare ssid list */ - if (ssid) { - int i; - - for (i = 0; i < ssid_num && i < RTW_SSID_SCAN_AMOUNT; i++) { - if (ssid[i].ssid_length) { - memcpy(&psurveyPara->ssid[i], &ssid[i], - sizeof(struct ndis_802_11_ssid)); - psurveyPara->ssid_num++; - } - } - } - - /* prepare channel list */ - if (ch) { - int i; - - for (i = 0; i < ch_num && i < RTW_CHANNEL_SCAN_AMOUNT; i++) { - if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) { - memcpy(&psurveyPara->ch[i], &ch[i], - sizeof(struct rtw_ieee80211_channel)); - psurveyPara->ch_num++; - } - } - } - - set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - - if (res == _SUCCESS) { - mod_timer(&pmlmepriv->scan_to_timer, - jiffies + msecs_to_jiffies(SCANNING_TIMEOUT)); - - led_control_8188eu(padapter, LED_CTL_SITE_SURVEY); - - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ - } else { - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - } - - return res; -} - -void rtw_readtssi_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - kfree(pcmd->parmbuf); - kfree(pcmd); -} - -u8 rtw_createbss_cmd(struct adapter *padapter) -{ - struct cmd_obj *pcmd; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; - u8 res = _SUCCESS; - - led_control_8188eu(padapter, LED_CTL_START_TO_LINK); - - pcmd = kzalloc(sizeof(*pcmd), GFP_ATOMIC); - if (!pcmd) { - res = _FAIL; - goto exit; - } - - INIT_LIST_HEAD(&pcmd->list); - pcmd->cmdcode = _CreateBss_CMD_; - pcmd->parmbuf = (unsigned char *)pdev_network; - pcmd->cmdsz = get_wlan_bssid_ex_sz(pdev_network); - pcmd->rsp = NULL; - pcmd->rspsz = 0; - pdev_network->Length = pcmd->cmdsz; - res = rtw_enqueue_cmd(pcmdpriv, pcmd); -exit: - - return res; -} - -u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) -{ - u8 res = _SUCCESS; - uint t_len = 0; - struct wlan_bssid_ex *psecnetwork; - struct cmd_obj *pcmd; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - enum ndis_802_11_network_infra ndis_network_mode = pnetwork->network.InfrastructureMode; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - led_control_8188eu(padapter, LED_CTL_START_TO_LINK); - - pcmd = kzalloc(sizeof(*pcmd), GFP_ATOMIC); - if (!pcmd) { - res = _FAIL; - goto exit; - } - /* for ies is fix buf size */ - t_len = sizeof(struct wlan_bssid_ex); - - /* for hidden ap to set fw_state here */ - if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) { - switch (ndis_network_mode) { - case Ndis802_11IBSS: - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - break; - case Ndis802_11Infrastructure: - set_fwstate(pmlmepriv, WIFI_STATION_STATE); - break; - case Ndis802_11APMode: - case Ndis802_11AutoUnknown: - case Ndis802_11InfrastructureMax: - break; - } - } - - psecnetwork = &psecuritypriv->sec_bss; - if (!psecnetwork) { - kfree(pcmd); - - res = _FAIL; - - goto exit; - } - - memset(psecnetwork, 0, t_len); - - memcpy(psecnetwork, &pnetwork->network, get_wlan_bssid_ex_sz(&pnetwork->network)); - - psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->ie_length; - - if (psecnetwork->ie_length - 12 < 255) - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->ies[12], - psecnetwork->ie_length - 12); - else - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->ies[12], 255); - - psecnetwork->ie_length = 0; - /* Added by Albert 2009/02/18 */ - /* If the driver wants to use the bssid to create the connection. */ - /* If not, we have to copy the connecting AP's MAC address to it so that */ - /* the driver just has the bssid information for PMKIDList searching. */ - - if (!pmlmepriv->assoc_by_bssid) - memcpy(&pmlmepriv->assoc_bssid[0], &pnetwork->network.MacAddress[0], ETH_ALEN); - - psecnetwork->ie_length = rtw_restruct_sec_ie(padapter, &pnetwork->network.ies[0], - &psecnetwork->ies[0], - pnetwork->network.ie_length); - - pqospriv->qos_option = 0; - - if (pregistrypriv->wmm_enable) { - u32 tmp_len; - - tmp_len = rtw_restruct_wmm_ie(padapter, &pnetwork->network.ies[0], - &psecnetwork->ies[0], - pnetwork->network.ie_length, - psecnetwork->ie_length); - - if (psecnetwork->ie_length != tmp_len) { - psecnetwork->ie_length = tmp_len; - pqospriv->qos_option = 1; /* There is WMM IE in this corresp. beacon */ - } else { - pqospriv->qos_option = 0;/* There is no WMM IE in this corresp. beacon */ - } - } - - phtpriv->ht_option = false; - if (pregistrypriv->ht_enable) { - /* - * Added by Albert 2010/06/23 - * For the WEP mode, we will use the bg mode to do - * the connection to avoid some IOT issue. - * Especially for Realtek 8192u SoftAP. - */ - if ((padapter->securitypriv.dot11PrivacyAlgrthm != _WEP40_) && - (padapter->securitypriv.dot11PrivacyAlgrthm != _WEP104_) && - (padapter->securitypriv.dot11PrivacyAlgrthm != _TKIP_)) { - /* rtw_restructure_ht_ie */ - rtw_restructure_ht_ie(padapter, &pnetwork->network.ies[0], - &psecnetwork->ies[0], - pnetwork->network.ie_length, &psecnetwork->ie_length); - } - } - - pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pnetwork->network.ies, pnetwork->network.ie_length); - - if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_TENDA) - padapter->pwrctrlpriv.smart_ps = 0; - else - padapter->pwrctrlpriv.smart_ps = padapter->registrypriv.smart_ps; - - pcmd->cmdsz = get_wlan_bssid_ex_sz(psecnetwork);/* get cmdsz before endian conversion */ - - INIT_LIST_HEAD(&pcmd->list); - pcmd->cmdcode = _JoinBss_CMD_; - pcmd->parmbuf = (unsigned char *)psecnetwork; - pcmd->rsp = NULL; - pcmd->rspsz = 0; - - res = rtw_enqueue_cmd(pcmdpriv, pcmd); - -exit: - - return res; -} - -u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueue) /* for sta_mode */ -{ - struct cmd_obj *cmdobj = NULL; - struct disconnect_parm *param = NULL; - struct cmd_priv *cmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - /* prepare cmd parameter */ - param = kzalloc(sizeof(*param), GFP_ATOMIC); - if (!param) { - res = _FAIL; - goto exit; - } - param->deauth_timeout_ms = deauth_timeout_ms; - - if (enqueue) { - /* need enqueue, prepare cmd_obj and enqueue */ - cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC); - if (!cmdobj) { - res = _FAIL; - kfree(param); - goto exit; - } - init_h2fwcmd_w_parm_no_rsp(cmdobj, param, _DisConnect_CMD_); - res = rtw_enqueue_cmd(cmdpriv, cmdobj); - } else { - /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (disconnect_hdl(padapter, (u8 *)param) != H2C_SUCCESS) - res = _FAIL; - kfree(param); - } - -exit: - - return res; -} - -u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra networktype) -{ - struct cmd_obj *ph2c; - struct setopmode_parm *psetop; - - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ph2c = kzalloc(sizeof(*ph2c), GFP_KERNEL); - psetop = kzalloc(sizeof(*psetop), GFP_KERNEL); - if (!ph2c || !psetop) { - kfree(ph2c); - kfree(psetop); - return false; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetop, _SetOpMode_CMD_); - psetop->mode = (u8)networktype; - - return rtw_enqueue_cmd(pcmdpriv, ph2c); -} - -u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) -{ - struct cmd_obj *ph2c; - struct set_stakey_parm *psetstakey_para; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct set_stakey_rsp *psetstakey_rsp = NULL; - - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sta_info *sta = (struct sta_info *)psta; - - ph2c = kzalloc(sizeof(*ph2c), GFP_KERNEL); - psetstakey_para = kzalloc(sizeof(*psetstakey_para), GFP_KERNEL); - psetstakey_rsp = kzalloc(sizeof(*psetstakey_rsp), GFP_KERNEL); - - if (!ph2c || !psetstakey_para || !psetstakey_rsp) { - kfree(ph2c); - kfree(psetstakey_para); - kfree(psetstakey_rsp); - return _FAIL; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - ph2c->rsp = (u8 *)psetstakey_rsp; - ph2c->rspsz = sizeof(struct set_stakey_rsp); - - ether_addr_copy(psetstakey_para->addr, sta->hwaddr); - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - psetstakey_para->algorithm = (unsigned char)psecuritypriv->dot11PrivacyAlgrthm; - else - GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); - - if (unicast_key) - memcpy(&psetstakey_para->key, &sta->dot118021x_UncstKey, 16); - else - memcpy(&psetstakey_para->key, - &psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey, 16); - - /* jeff: set this because at least sw key is ready */ - padapter->securitypriv.busetkipkey = true; - - return rtw_enqueue_cmd(pcmdpriv, ph2c); -} - -u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) -{ - struct cmd_obj *ph2c; - struct set_stakey_parm *psetstakey_para; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct set_stakey_rsp *psetstakey_rsp = NULL; - struct sta_info *sta = (struct sta_info *)psta; - u8 res = _SUCCESS; - - if (!enqueue) { - clear_cam_entry(padapter, entry); - } else { - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - psetstakey_para = kzalloc(sizeof(*psetstakey_para), GFP_ATOMIC); - if (!psetstakey_para) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - psetstakey_rsp = kzalloc(sizeof(*psetstakey_rsp), GFP_ATOMIC); - if (!psetstakey_rsp) { - kfree(ph2c); - kfree(psetstakey_para); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - ph2c->rsp = (u8 *)psetstakey_rsp; - ph2c->rspsz = sizeof(struct set_stakey_rsp); - - ether_addr_copy(psetstakey_para->addr, sta->hwaddr); - - psetstakey_para->algorithm = _NO_PRIVACY_; - - psetstakey_para->id = entry; - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - } -exit: - - return res; -} - -u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) -{ - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct cmd_obj *ph2c; - struct addBaReq_parm *paddbareq_parm; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - paddbareq_parm = kzalloc(sizeof(*paddbareq_parm), GFP_ATOMIC); - if (!paddbareq_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - paddbareq_parm->tid = tid; - memcpy(paddbareq_parm->addr, addr, ETH_ALEN); - - init_h2fwcmd_w_parm_no_rsp(ph2c, paddbareq_parm, _AddBAReq_CMD_); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - return res; -} - -u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); - if (!pdrvextra_cmd_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = DYNAMIC_CHK_WK_CID; - pdrvextra_cmd_parm->type_size = 0; - pdrvextra_cmd_parm->pbuf = (u8 *)padapter; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - return res; -} - -u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) -{ - struct cmd_obj *pcmdobj; - struct SetChannelPlan_param *setChannelPlan_param; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - /* check input parameter */ - if (!rtw_is_channel_plan_valid(chplan)) { - res = _FAIL; - goto exit; - } - - /* prepare cmd parameter */ - setChannelPlan_param = kzalloc(sizeof(*setChannelPlan_param), GFP_KERNEL); - if (!setChannelPlan_param) { - res = _FAIL; - goto exit; - } - setChannelPlan_param->channel_plan = chplan; - - if (enqueue) { - /* need enqueue, prepare cmd_obj and enqueue */ - pcmdobj = kzalloc(sizeof(*pcmdobj), GFP_KERNEL); - if (!pcmdobj) { - kfree(setChannelPlan_param); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(pcmdobj, setChannelPlan_param, _SetChannelPlan_CMD_); - res = rtw_enqueue_cmd(pcmdpriv, pcmdobj); - } else { - /* no need to enqueue, do the cmd hdl directly and free cmd parameter */ - if (set_chplan_hdl(padapter, (unsigned char *)setChannelPlan_param) != H2C_SUCCESS) - res = _FAIL; - - kfree(setChannelPlan_param); - } - - if (res == _SUCCESS) - padapter->mlmepriv.ChannelPlan = chplan; - -exit: - - return res; -} - -static void traffic_status_watchdog(struct adapter *padapter) -{ - u8 bEnterPS; - u8 bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false; - u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false, bHigherBusyTxTraffic = false; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - /* */ - /* Determine if our traffic is busy now */ - /* */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 100 || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 100) { - bBusyTraffic = true; - - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) - bRxBusyTraffic = true; - else - bTxBusyTraffic = true; - } - - /* Higher Tx/Rx data. */ - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > 4000 || - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod > 4000) { - bHigherBusyTraffic = true; - - if (pmlmepriv->LinkDetectInfo.NumRxOkInPeriod > - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) - bHigherBusyRxTraffic = true; - else - bHigherBusyTxTraffic = true; - } - - /* check traffic for powersaving. */ - if (((pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod + pmlmepriv->LinkDetectInfo.NumTxOkInPeriod) > 8) || - (pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod > 2)) - bEnterPS = false; - else - bEnterPS = true; - - /* LeisurePS only work in infra mode. */ - if (bEnterPS) - LPS_Enter(padapter); - else - LPS_Leave(padapter); - } else { - LPS_Leave(padapter); - } - - pmlmepriv->LinkDetectInfo.NumRxOkInPeriod = 0; - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod = 0; - pmlmepriv->LinkDetectInfo.NumRxUnicastOkInPeriod = 0; - pmlmepriv->LinkDetectInfo.bBusyTraffic = bBusyTraffic; - pmlmepriv->LinkDetectInfo.bTxBusyTraffic = bTxBusyTraffic; - pmlmepriv->LinkDetectInfo.bRxBusyTraffic = bRxBusyTraffic; - pmlmepriv->LinkDetectInfo.bHigherBusyTraffic = bHigherBusyTraffic; - pmlmepriv->LinkDetectInfo.bHigherBusyRxTraffic = bHigherBusyRxTraffic; - pmlmepriv->LinkDetectInfo.bHigherBusyTxTraffic = bHigherBusyTxTraffic; -} - -static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) -{ - struct mlme_priv *pmlmepriv; - - padapter = (struct adapter *)pbuf; - pmlmepriv = &padapter->mlmepriv; - -#ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - expire_timeout_chk(padapter); -#endif - - linked_status_chk(padapter); - traffic_status_watchdog(padapter); - - rtw_hal_dm_watchdog(padapter); -} - -static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 mstatus; - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) - return; - - switch (lps_ctrl_type) { - case LPS_CTRL_SCAN: - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - /* connect */ - LPS_Leave(padapter); - } - break; - case LPS_CTRL_JOINBSS: - LPS_Leave(padapter); - break; - case LPS_CTRL_CONNECT: - mstatus = 1;/* connect */ - /* Reset LPS Setting */ - padapter->pwrctrlpriv.LpsIdleCount = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); - break; - case LPS_CTRL_DISCONNECT: - mstatus = 0;/* disconnect */ - LPS_Leave(padapter); - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_JOINBSSRPT, (u8 *)(&mstatus)); - break; - case LPS_CTRL_SPECIAL_PACKET: - pwrpriv->DelayLPSLastTimeStamp = jiffies; - LPS_Leave(padapter); - break; - case LPS_CTRL_LEAVE: - LPS_Leave(padapter); - break; - default: - break; - } -} - -u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) -{ - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_obj *ph2c; - - if (!enqueue) { - lps_ctrl_wk_hdl(padapter, lps_ctrl_type); - return _SUCCESS; - } - - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); - if (!ph2c || !pdrvextra_cmd_parm) { - kfree(ph2c); - kfree(pdrvextra_cmd_parm); - return _FAIL; - } - - pdrvextra_cmd_parm->ec_id = LPS_CTRL_WK_CID; - pdrvextra_cmd_parm->type_size = lps_ctrl_type; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - return rtw_enqueue_cmd(pcmdpriv, ph2c); -} - -static void rpt_timer_setting_wk_hdl(struct adapter *padapter, u16 min_time) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_RPT_TIMER_SETTING, (u8 *)(&min_time)); -} - -u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); - if (!pdrvextra_cmd_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = RTP_TIMER_CFG_WK_CID; - pdrvextra_cmd_parm->type_size = min_time; - pdrvextra_cmd_parm->pbuf = NULL; - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - - return res; -} - -static void antenna_select_wk_hdl(struct adapter *padapter, u8 antenna) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_ANTENNA_DIVERSITY_SELECT, (u8 *)(&antenna)); -} - -u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 support_ant_div; - u8 res = _SUCCESS; - - rtw_hal_get_def_var(padapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &support_ant_div); - if (!support_ant_div) - return res; - - if (enqueue) { - ph2c = kzalloc(sizeof(*ph2c), GFP_KERNEL); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_KERNEL); - if (!pdrvextra_cmd_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = ANT_SELECT_WK_CID; - pdrvextra_cmd_parm->type_size = antenna; - pdrvextra_cmd_parm->pbuf = NULL; - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - } else { - antenna_select_wk_hdl(padapter, antenna); - } -exit: - - return res; -} - -u8 rtw_ps_cmd(struct adapter *padapter) -{ - struct cmd_obj *ppscmd; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - ppscmd = kzalloc(sizeof(*ppscmd), GFP_ATOMIC); - pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); - if (!ppscmd || !pdrvextra_cmd_parm) { - kfree(ppscmd); - kfree(pdrvextra_cmd_parm); - return _FAIL; - } - - pdrvextra_cmd_parm->ec_id = POWER_SAVING_CTRL_WK_CID; - pdrvextra_cmd_parm->pbuf = NULL; - init_h2fwcmd_w_parm_no_rsp(ppscmd, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - - return rtw_enqueue_cmd(pcmdpriv, ppscmd); -} - -#ifdef CONFIG_88EU_AP_MODE - -static void rtw_chk_hi_queue_hdl(struct adapter *padapter) -{ - int cnt = 0; - struct sta_info *psta_bmc; - struct sta_priv *pstapriv = &padapter->stapriv; - - psta_bmc = rtw_get_bcmc_stainfo(padapter); - if (!psta_bmc) - return; - - if (psta_bmc->sleepq_len == 0) { - u8 val = 0; - - rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); - - while (!val) { - msleep(100); - - cnt++; - - if (cnt > 10) - break; - - rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); - } - - if (cnt <= 10) { - pstapriv->tim_bitmap &= ~BIT(0); - pstapriv->sta_dz_bitmap &= ~BIT(0); - - update_beacon(padapter, WLAN_EID_TIM, NULL, false); - } else { /* re check again */ - rtw_chk_hi_queue_cmd(padapter); - } - } -} - -u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) -{ - struct cmd_obj *ph2c; - struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(*ph2c), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm = kzalloc(sizeof(*pdrvextra_cmd_parm), GFP_ATOMIC); - if (!pdrvextra_cmd_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - pdrvextra_cmd_parm->ec_id = CHECK_HIQ_WK_CID; - pdrvextra_cmd_parm->type_size = 0; - pdrvextra_cmd_parm->pbuf = NULL; - - init_h2fwcmd_w_parm_no_rsp(ph2c, pdrvextra_cmd_parm, _Set_Drv_Extra_CMD_); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); -exit: - return res; -} -#endif - -u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - struct drvextra_cmd_parm *pdrvextra_cmd; - - if (!pbuf) - return H2C_PARAMETERS_ERROR; - - pdrvextra_cmd = (struct drvextra_cmd_parm *)pbuf; - - switch (pdrvextra_cmd->ec_id) { - case DYNAMIC_CHK_WK_CID: - dynamic_chk_wk_hdl(padapter, pdrvextra_cmd->pbuf, pdrvextra_cmd->type_size); - break; - case POWER_SAVING_CTRL_WK_CID: - rtw_ps_processor(padapter); - break; - case LPS_CTRL_WK_CID: - lps_ctrl_wk_hdl(padapter, (u8)pdrvextra_cmd->type_size); - break; - case RTP_TIMER_CFG_WK_CID: - rpt_timer_setting_wk_hdl(padapter, pdrvextra_cmd->type_size); - break; - case ANT_SELECT_WK_CID: - antenna_select_wk_hdl(padapter, pdrvextra_cmd->type_size); - break; -#ifdef CONFIG_88EU_AP_MODE - case CHECK_HIQ_WK_CID: - rtw_chk_hi_queue_hdl(padapter); - break; -#endif /* CONFIG_88EU_AP_MODE */ - default: - break; - } - - if (pdrvextra_cmd->pbuf && pdrvextra_cmd->type_size > 0) - kfree(pdrvextra_cmd->pbuf); - - return H2C_SUCCESS; -} - -void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (pcmd->res == H2C_DROPPED) { - /* TODO: cancel timer and do timeout handler directly... */ - /* need to make timeout handlerOS independent */ - mod_timer(&pmlmepriv->scan_to_timer, - jiffies + msecs_to_jiffies(1)); - } else if (pcmd->res != H2C_SUCCESS) { - mod_timer(&pmlmepriv->scan_to_timer, - jiffies + msecs_to_jiffies(1)); - } -} - -void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (pcmd->res != H2C_SUCCESS) { - spin_lock_bh(&pmlmepriv->lock); - set_fwstate(pmlmepriv, _FW_LINKED); - spin_unlock_bh(&pmlmepriv->lock); - } -} - -void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (pcmd->res == H2C_DROPPED) { - /* TODO: cancel timer and do timeout handler directly... */ - /* need to make timeout handlerOS independent */ - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(1)); - } else if (pcmd->res != H2C_SUCCESS) { - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(1)); - } -} - -void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - struct sta_info *psta = NULL; - struct wlan_network *pwlan = NULL; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; - struct wlan_network *tgt_network = &pmlmepriv->cur_network; - - if (pcmd->res != H2C_SUCCESS) { - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(1)); - } - - del_timer_sync(&pmlmepriv->assoc_timer); - - spin_lock_bh(&pmlmepriv->lock); - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); - if (!psta) { - psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); - if (!psta) - goto createbss_cmd_fail; - } - - rtw_indicate_connect(padapter); - } else { - pwlan = rtw_alloc_network(pmlmepriv); - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - if (!pwlan) { - pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); - if (!pwlan) { - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - goto createbss_cmd_fail; - } - pwlan->last_scanned = jiffies; - } else { - list_add_tail(&pwlan->list, - &pmlmepriv->scanned_queue.queue); - } - - pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); - memcpy(&pwlan->network, pnetwork, pnetwork->Length); - - memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork))); - - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - /* we will set _FW_LINKED when there is one more sat to - * join us (rtw_stassoc_event_callback) - */ - } - -createbss_cmd_fail: - - spin_unlock_bh(&pmlmepriv->lock); -} - -void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pcmd) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct set_assocsta_parm *passocsta_parm = (struct set_assocsta_parm *)(pcmd->parmbuf); - struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); - struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); - - if (!psta) - return; - - psta->aid = passocsta_rsp->cam_id; - psta->mac_id = passocsta_rsp->cam_id; - - spin_lock_bh(&pmlmepriv->lock); - - set_fwstate(pmlmepriv, _FW_LINKED); - spin_unlock_bh(&pmlmepriv->lock); -} diff --git a/drivers/staging/rtl8188eu/core/rtw_efuse.c b/drivers/staging/rtl8188eu/core/rtw_efuse.c deleted file mode 100644 index 0b821df58b77..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_efuse.c +++ /dev/null @@ -1,850 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_EFUSE_C_ - -#include -#include -#include -#include -#include -#include - -#define REG_EFUSE_CTRL 0x0030 -#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ - -static void efuse_power_switch(struct adapter *pAdapter, u8 pwrstate) -{ - u16 tmpv16; - - if (pwrstate) { - usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_ON); - - /* 1.2V Power: From VDDON with Power Cut(0x0000h[15]), default valid */ - tmpv16 = usb_read16(pAdapter, REG_SYS_ISO_CTRL); - if (!(tmpv16 & PWC_EV12V)) { - tmpv16 |= PWC_EV12V; - usb_write16(pAdapter, REG_SYS_ISO_CTRL, tmpv16); - } - /* Reset: 0x0000h[28], default valid */ - tmpv16 = usb_read16(pAdapter, REG_SYS_FUNC_EN); - if (!(tmpv16 & FEN_ELDR)) { - tmpv16 |= FEN_ELDR; - usb_write16(pAdapter, REG_SYS_FUNC_EN, tmpv16); - } - - /* Clock: Gated(0x0008h[5]) 8M(0x0008h[1]) clock from ANA, default valid */ - tmpv16 = usb_read16(pAdapter, REG_SYS_CLKR); - if ((!(tmpv16 & LOADER_CLK_EN)) || (!(tmpv16 & ANA8M))) { - tmpv16 |= (LOADER_CLK_EN | ANA8M); - usb_write16(pAdapter, REG_SYS_CLKR, tmpv16); - } - } else { - usb_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); - } -} - -static void -efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) -{ - u8 *efuseTbl = NULL; - u8 rtemp8; - u16 eFuse_Addr = 0; - u8 offset, wren; - u16 i, j; - u16 **eFuseWord = NULL; - u16 efuse_utilized = 0; - u8 u1temp = 0; - void **tmp = NULL; - - efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); - if (!efuseTbl) - return; - - tmp = kcalloc(EFUSE_MAX_SECTION_88E, - sizeof(void *) + EFUSE_MAX_WORD_UNIT * sizeof(u16), - GFP_KERNEL); - if (!tmp) - goto eFuseWord_failed; - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) - tmp[i] = ((char *)(tmp + EFUSE_MAX_SECTION_88E)) + i * EFUSE_MAX_WORD_UNIT * sizeof(u16); - eFuseWord = (u16 **)tmp; - - /* 0. Refresh efuse init map as all oxFF. */ - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) - for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) - eFuseWord[i][j] = 0xFFFF; - - /* */ - /* 1. Read the first byte to check if efuse is empty!!! */ - /* */ - /* */ - rtemp8 = *(phymap + eFuse_Addr); - if (rtemp8 != 0xFF) { - efuse_utilized++; - eFuse_Addr++; - } else { - goto exit; - } - - /* */ - /* 2. Read real efuse content. Filter PG header and every section data. */ - /* */ - while ((rtemp8 != 0xFF) && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { - /* Check PG header for section num. */ - if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ - u1temp = (rtemp8 & 0xE0) >> 5; - rtemp8 = *(phymap + eFuse_Addr); - if ((rtemp8 & 0x0F) == 0x0F) { - eFuse_Addr++; - rtemp8 = *(phymap + eFuse_Addr); - - if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) - eFuse_Addr++; - continue; - } else { - offset = ((rtemp8 & 0xF0) >> 1) | u1temp; - wren = rtemp8 & 0x0F; - eFuse_Addr++; - } - } else { - offset = (rtemp8 >> 4) & 0x0f; - wren = rtemp8 & 0x0f; - } - - if (offset < EFUSE_MAX_SECTION_88E) { - /* Get word enable value from PG header */ - for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { - /* Check word enable condition in the section */ - if (!(wren & 0x01)) { - rtemp8 = *(phymap + eFuse_Addr); - eFuse_Addr++; - efuse_utilized++; - eFuseWord[offset][i] = (rtemp8 & 0xff); - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) - break; - rtemp8 = *(phymap + eFuse_Addr); - eFuse_Addr++; - efuse_utilized++; - eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00); - - if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) - break; - } - wren >>= 1; - } - } - /* Read next PG header */ - rtemp8 = *(phymap + eFuse_Addr); - - if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { - efuse_utilized++; - eFuse_Addr++; - } - } - - /* */ - /* 3. Collect 16 sections and 4 word unit into Efuse map. */ - /* */ - for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { - for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { - efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff); - efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff); - } - } - - /* */ - /* 4. Copy from Efuse map to output pointer memory!!! */ - /* */ - for (i = 0; i < _size_byte; i++) - pbuf[i] = efuseTbl[_offset + i]; - - /* */ - /* 5. Calculate Efuse utilization. */ - /* */ - -exit: - kfree(eFuseWord); - -eFuseWord_failed: - kfree(efuseTbl); -} - -static void efuse_read_phymap_from_txpktbuf( - struct adapter *adapter, - int bcnhead, /* beacon head, where FW store len(2-byte) and efuse physical map. */ - u8 *content, /* buffer to store efuse physical map */ - u16 *size /* for efuse content: the max byte to read. will update to byte read */ - ) -{ - u16 dbg_addr = 0; - unsigned long start = 0; - u8 reg_0x143 = 0; - u32 lo32 = 0, hi32 = 0; - u16 len = 0, count = 0; - int i = 0; - u16 limit = *size; - - u8 *pos = content; - - if (bcnhead < 0) /* if not valid */ - bcnhead = usb_read8(adapter, REG_TDECTRL + 1); - - usb_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); - - dbg_addr = bcnhead * 128 / 8; /* 8-bytes addressing */ - - while (1) { - usb_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr + i); - - usb_write8(adapter, REG_TXPKTBUF_DBG, 0); - start = jiffies; - while (!(reg_0x143 = usb_read8(adapter, REG_TXPKTBUF_DBG)) && - jiffies_to_msecs(jiffies - start) < 1000) - usleep_range(1000, 2000); - - lo32 = usb_read32(adapter, REG_PKTBUF_DBG_DATA_L); - hi32 = usb_read32(adapter, REG_PKTBUF_DBG_DATA_H); - - if (i == 0) { - usb_read8(adapter, REG_PKTBUF_DBG_DATA_L); - usb_read8(adapter, REG_PKTBUF_DBG_DATA_L + 1); - - len = le16_to_cpu(*((__le16 *)&lo32)); - - limit = min_t(u16, len - 2, limit); - - memcpy(pos, ((u8 *)&lo32) + 2, (limit >= count + 2) ? 2 : limit - count); - count += (limit >= count + 2) ? 2 : limit - count; - pos = content + count; - - } else { - memcpy(pos, ((u8 *)&lo32), (limit >= count + 4) ? 4 : limit - count); - count += (limit >= count + 4) ? 4 : limit - count; - pos = content + count; - } - - if (limit > count && len - 2 > count) { - memcpy(pos, (u8 *)&hi32, (limit >= count + 4) ? 4 : limit - count); - count += (limit >= count + 4) ? 4 : limit - count; - pos = content + count; - } - - if (limit <= count || len - 2 <= count) - break; - i++; - } - usb_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, DISABLE_TRXPKT_BUF_ACCESS); - *size = count; -} - -static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset, u16 size_byte, u8 *logical_map) -{ - s32 status = _FAIL; - u8 physical_map[512]; - u16 size = 512; - - usb_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); - memset(physical_map, 0xFF, 512); - usb_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); - status = iol_execute(padapter, CMD_READ_EFUSE_MAP); - if (status == _SUCCESS) - efuse_read_phymap_from_txpktbuf(padapter, txpktbuf_bndy, physical_map, &size); - efuse_phymap_to_logical(physical_map, offset, size_byte, logical_map); - return status; -} - -static void efuse_ReadEFuse(struct adapter *Adapter, u16 _offset, u16 _size_byte, u8 *pbuf) -{ - if (rtw_iol_applied(Adapter)) { - rtw_hal_power_on(Adapter); - iol_mode_enable(Adapter, 1); - iol_read_efuse(Adapter, 0, _offset, _size_byte, pbuf); - iol_mode_enable(Adapter, 0); - } -} - -u8 Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, u8 word_en, u8 *data) -{ - u16 tmpaddr = 0; - u16 start_addr = efuse_addr; - u8 badworden = 0x0F; - u8 tmpdata[8]; - - memset(tmpdata, 0xff, PGPKT_DATA_SIZE); - - if (!(word_en & BIT(0))) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[0]); - efuse_OneByteWrite(pAdapter, start_addr++, data[1]); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0]); - efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[1]); - if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) - badworden &= (~BIT(0)); - } - if (!(word_en & BIT(1))) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[2]); - efuse_OneByteWrite(pAdapter, start_addr++, data[3]); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[2]); - efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[3]); - if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) - badworden &= (~BIT(1)); - } - if (!(word_en & BIT(2))) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[4]); - efuse_OneByteWrite(pAdapter, start_addr++, data[5]); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4]); - efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[5]); - if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) - badworden &= (~BIT(2)); - } - if (!(word_en & BIT(3))) { - tmpaddr = start_addr; - efuse_OneByteWrite(pAdapter, start_addr++, data[6]); - efuse_OneByteWrite(pAdapter, start_addr++, data[7]); - - efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6]); - efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[7]); - if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) - badworden &= (~BIT(3)); - } - return badworden; -} - -static u16 Efuse_GetCurrentSize(struct adapter *pAdapter) -{ - u16 efuse_addr = 0; - u8 hoffset = 0, hworden = 0; - u8 efuse_data, word_cnts = 0; - - rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); - - while (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data) && - AVAILABLE_EFUSE_ADDR(efuse_addr)) { - if (efuse_data == 0xFF) - break; - if ((efuse_data & 0x1F) == 0x0F) { /* extended header */ - hoffset = efuse_data; - efuse_addr++; - efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data); - if ((efuse_data & 0x0F) == 0x0F) { - efuse_addr++; - continue; - } else { - hoffset = ((hoffset & 0xE0) >> 5) | - ((efuse_data & 0xF0) >> 1); - hworden = efuse_data & 0x0F; - } - } else { - hoffset = (efuse_data >> 4) & 0x0F; - hworden = efuse_data & 0x0F; - } - word_cnts = Efuse_CalculateWordCnts(hworden); - /* read next header */ - efuse_addr = efuse_addr + (word_cnts * 2) + 1; - } - - rtw_hal_set_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&efuse_addr); - - return efuse_addr; -} - -int Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 *data) -{ - u8 ReadState = PG_STATE_HEADER; - int bDataEmpty = true; - u8 efuse_data, word_cnts = 0; - u16 efuse_addr = 0; - u8 hoffset = 0, hworden = 0; - u8 tmpidx = 0; - u8 tmpdata[8]; - u8 tmp_header = 0; - - if (!data) - return false; - if (offset > EFUSE_MAX_SECTION_88E) - return false; - - memset(data, 0xff, sizeof(u8) * PGPKT_DATA_SIZE); - memset(tmpdata, 0xff, sizeof(u8) * PGPKT_DATA_SIZE); - - /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ - /* Skip dummy parts to prevent unexpected data read from Efuse. */ - /* By pass right now. 2009.02.19. */ - while (AVAILABLE_EFUSE_ADDR(efuse_addr)) { - /* Header Read ------------- */ - if (ReadState & PG_STATE_HEADER) { - if (efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data) && (efuse_data != 0xFF)) { - if (EXT_HEADER(efuse_data)) { - tmp_header = efuse_data; - efuse_addr++; - efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data); - if (!ALL_WORDS_DISABLED(efuse_data)) { - hoffset = ((tmp_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); - hworden = efuse_data & 0x0F; - } else { - efuse_addr++; - continue; - } - } else { - hoffset = (efuse_data >> 4) & 0x0F; - hworden = efuse_data & 0x0F; - } - word_cnts = Efuse_CalculateWordCnts(hworden); - bDataEmpty = true; - - if (hoffset == offset) { - for (tmpidx = 0; tmpidx < word_cnts * 2; tmpidx++) { - if (efuse_OneByteRead(pAdapter, efuse_addr + 1 + tmpidx, &efuse_data)) { - tmpdata[tmpidx] = efuse_data; - if (efuse_data != 0xff) - bDataEmpty = false; - } - } - if (!bDataEmpty) { - ReadState = PG_STATE_DATA; - } else {/* read next header */ - efuse_addr = efuse_addr + (word_cnts * 2) + 1; - ReadState = PG_STATE_HEADER; - } - } else {/* read next header */ - efuse_addr = efuse_addr + (word_cnts * 2) + 1; - ReadState = PG_STATE_HEADER; - } - } else { - break; - } - } else if (ReadState & PG_STATE_DATA) { - /* Data section Read ------------- */ - efuse_WordEnableDataRead(hworden, tmpdata, data); - efuse_addr = efuse_addr + (word_cnts * 2) + 1; - ReadState = PG_STATE_HEADER; - } - } - - if ((data[0] == 0xff) && (data[1] == 0xff) && (data[2] == 0xff) && (data[3] == 0xff) && - (data[4] == 0xff) && (data[5] == 0xff) && (data[6] == 0xff) && (data[7] == 0xff)) - return false; - else - return true; -} - -static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, struct pgpkt *pFixPkt, u16 *pAddr) -{ - u8 originaldata[8], badworden = 0; - u16 efuse_addr = *pAddr; - u32 PgWriteSuccess = 0; - - memset(originaldata, 0xff, 8); - - if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata)) { - /* check if data exist */ - badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr + 1, pFixPkt->word_en, originaldata); - - if (badworden != 0xf) { /* write fail */ - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata); - - if (!PgWriteSuccess) - return false; - - efuse_addr = Efuse_GetCurrentSize(pAdapter); - } else { - efuse_addr = efuse_addr + (pFixPkt->word_cnts * 2) + 1; - } - } else { - efuse_addr = efuse_addr + (pFixPkt->word_cnts * 2) + 1; - } - *pAddr = efuse_addr; - return true; -} - -static bool hal_EfusePgPacketWrite2ByteHeader(struct adapter *pAdapter, u16 *pAddr, struct pgpkt *pTargetPkt) -{ - bool ret = false; - u16 efuse_addr = *pAddr; - u16 efuse_max_available_len = - EFUSE_REAL_CONTENT_LEN_88E - EFUSE_OOB_PROTECT_BYTES_88E; - u8 pg_header = 0, tmp_header = 0, pg_header_temp = 0; - u8 repeatcnt = 0; - - while (efuse_addr < efuse_max_available_len) { - pg_header = ((pTargetPkt->offset & 0x07) << 5) | 0x0F; - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); - - while (tmp_header == 0xFF) { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); - } - - /* to write ext_header */ - if (tmp_header == pg_header) { - efuse_addr++; - pg_header_temp = pg_header; - pg_header = ((pTargetPkt->offset & 0x78) << 1) | pTargetPkt->word_en; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); - - while (tmp_header == 0xFF) { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); - } - - if ((tmp_header & 0x0F) == 0x0F) { /* word_en PG fail */ - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - - efuse_addr++; - continue; - } else if (pg_header != tmp_header) { /* offset PG fail */ - struct pgpkt fixPkt; - - fixPkt.offset = ((pg_header_temp & 0xE0) >> 5) | ((tmp_header & 0xF0) >> 1); - fixPkt.word_en = tmp_header & 0x0F; - fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); - if (!hal_EfuseFixHeaderProcess(pAdapter, &fixPkt, &efuse_addr)) - return false; - } else { - ret = true; - break; - } - } else if ((tmp_header & 0x1F) == 0x0F) { /* wrong extended header */ - efuse_addr += 2; - continue; - } - } - - *pAddr = efuse_addr; - return ret; -} - -static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u16 *pAddr, struct pgpkt *pTargetPkt) -{ - bool ret = false; - u8 pg_header = 0, tmp_header = 0; - u16 efuse_addr = *pAddr; - u8 repeatcnt = 0; - - pg_header = ((pTargetPkt->offset << 4) & 0xf0) | pTargetPkt->word_en; - - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); - - while (tmp_header == 0xFF) { - if (repeatcnt++ > EFUSE_REPEAT_THRESHOLD_) - return false; - efuse_OneByteWrite(pAdapter, efuse_addr, pg_header); - efuse_OneByteRead(pAdapter, efuse_addr, &tmp_header); - } - - if (pg_header == tmp_header) { - ret = true; - } else { - struct pgpkt fixPkt; - - fixPkt.offset = (tmp_header >> 4) & 0x0F; - fixPkt.word_en = tmp_header & 0x0F; - fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); - if (!hal_EfuseFixHeaderProcess(pAdapter, &fixPkt, &efuse_addr)) - return false; - } - - *pAddr = efuse_addr; - return ret; -} - -static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u16 *pAddr, struct pgpkt *pTargetPkt) -{ - u16 efuse_addr = *pAddr; - u8 badworden; - u32 PgWriteSuccess = 0; - - badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr + 1, pTargetPkt->word_en, pTargetPkt->data); - if (badworden == 0x0F) { - /* write ok */ - return true; - } - /* reorganize other pg packet */ - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data); - if (!PgWriteSuccess) - return false; - else - return true; -} - -static bool -hal_EfusePgPacketWriteHeader( - struct adapter *pAdapter, - u16 *pAddr, - struct pgpkt *pTargetPkt) -{ - bool ret = false; - - if (pTargetPkt->offset >= EFUSE_MAX_SECTION_BASE) - ret = hal_EfusePgPacketWrite2ByteHeader(pAdapter, pAddr, pTargetPkt); - else - ret = hal_EfusePgPacketWrite1ByteHeader(pAdapter, pAddr, pTargetPkt); - - return ret; -} - -static bool wordEnMatched(struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, - u8 *pWden) -{ - u8 match_word_en = 0x0F; /* default all words are disabled */ - - /* check if the same words are enabled both target and current PG packet */ - if (((pTargetPkt->word_en & BIT(0)) == 0) && - ((pCurPkt->word_en & BIT(0)) == 0)) - match_word_en &= ~BIT(0); /* enable word 0 */ - if (((pTargetPkt->word_en & BIT(1)) == 0) && - ((pCurPkt->word_en & BIT(1)) == 0)) - match_word_en &= ~BIT(1); /* enable word 1 */ - if (((pTargetPkt->word_en & BIT(2)) == 0) && - ((pCurPkt->word_en & BIT(2)) == 0)) - match_word_en &= ~BIT(2); /* enable word 2 */ - if (((pTargetPkt->word_en & BIT(3)) == 0) && - ((pCurPkt->word_en & BIT(3)) == 0)) - match_word_en &= ~BIT(3); /* enable word 3 */ - - *pWden = match_word_en; - - if (match_word_en != 0xf) - return true; - else - return false; -} - -static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, u16 startAddr) -{ - bool ret = false; - u8 i, efuse_data; - - for (i = 0; i < (word_cnts * 2); i++) { - if (efuse_OneByteRead(pAdapter, (startAddr + i), &efuse_data) && (efuse_data != 0xFF)) - ret = true; - } - return ret; -} - -static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u16 *pAddr, struct pgpkt *pTargetPkt) -{ - bool ret = false; - u8 i, efuse_data = 0, cur_header = 0; - u8 matched_wden = 0, badworden = 0; - u16 startAddr = 0; - u16 efuse_max_available_len = - EFUSE_REAL_CONTENT_LEN_88E - EFUSE_OOB_PROTECT_BYTES_88E; - struct pgpkt curPkt; - - rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); - startAddr %= EFUSE_REAL_CONTENT_LEN; - - while (1) { - if (startAddr >= efuse_max_available_len) { - ret = false; - break; - } - - if (efuse_OneByteRead(pAdapter, startAddr, &efuse_data) && (efuse_data != 0xFF)) { - if (EXT_HEADER(efuse_data)) { - cur_header = efuse_data; - startAddr++; - efuse_OneByteRead(pAdapter, startAddr, &efuse_data); - if (ALL_WORDS_DISABLED(efuse_data)) { - ret = false; - break; - } - curPkt.offset = ((cur_header & 0xE0) >> 5) | ((efuse_data & 0xF0) >> 1); - curPkt.word_en = efuse_data & 0x0F; - } else { - cur_header = efuse_data; - curPkt.offset = (cur_header >> 4) & 0x0F; - curPkt.word_en = cur_header & 0x0F; - } - - curPkt.word_cnts = Efuse_CalculateWordCnts(curPkt.word_en); - /* if same header is found but no data followed */ - /* write some part of data followed by the header. */ - if ((curPkt.offset == pTargetPkt->offset) && - (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr + 1)) && - wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { - /* Here to write partial data */ - badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr + 1, matched_wden, pTargetPkt->data); - if (badworden != 0x0F) { - u32 PgWriteSuccess = 0; - /* if write fail on some words, write these bad words again */ - - PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pTargetPkt->offset, badworden, pTargetPkt->data); - - if (!PgWriteSuccess) { - ret = false; /* write fail, return */ - break; - } - } - /* partial write ok, update the target packet for later use */ - for (i = 0; i < 4; i++) { - if ((matched_wden & (0x1 << i)) == 0) /* this word has been written */ - pTargetPkt->word_en |= (0x1 << i); /* disable the word */ - } - pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); - } - /* read from next header */ - startAddr = startAddr + (curPkt.word_cnts * 2) + 1; - } else { - /* not used header, 0xff */ - *pAddr = startAddr; - ret = true; - break; - } - } - return ret; -} - -static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) -{ - memset((void *)pTargetPkt->data, 0xFF, sizeof(u8) * 8); - pTargetPkt->offset = offset; - pTargetPkt->word_en = word_en; - efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); - pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); -} - -bool Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 word_en, u8 *pData) -{ - struct pgpkt targetPkt; - u16 startAddr = 0; - - if (Efuse_GetCurrentSize(pAdapter) >= EFUSE_MAP_LEN_88E) - return false; - - hal_EfuseConstructPGPkt(offset, word_en, pData, &targetPkt); - - if (!hal_EfusePartialWriteCheck(pAdapter, &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteHeader(pAdapter, &startAddr, &targetPkt)) - return false; - - if (!hal_EfusePgPacketWriteData(pAdapter, &startAddr, &targetPkt)) - return false; - - return true; -} - -u8 Efuse_CalculateWordCnts(u8 word_en) -{ - u8 word_cnts = 0; - - if (!(word_en & BIT(0))) - word_cnts++; /* 0 : write enable */ - if (!(word_en & BIT(1))) - word_cnts++; - if (!(word_en & BIT(2))) - word_cnts++; - if (!(word_en & BIT(3))) - word_cnts++; - return word_cnts; -} - -u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data) -{ - u8 tmpidx = 0; - u8 result; - - usb_write8(pAdapter, EFUSE_CTRL + 1, (u8)(addr & 0xff)); - usb_write8(pAdapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | - (usb_read8(pAdapter, EFUSE_CTRL + 2) & 0xFC)); - - usb_write8(pAdapter, EFUSE_CTRL + 3, 0x72);/* read cmd */ - - while (!(0x80 & usb_read8(pAdapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) - tmpidx++; - if (tmpidx < 100) { - *data = usb_read8(pAdapter, EFUSE_CTRL); - result = true; - } else { - *data = 0xff; - result = false; - } - return result; -} - -u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data) -{ - u8 tmpidx = 0; - u8 result; - - usb_write8(pAdapter, EFUSE_CTRL + 1, (u8)(addr & 0xff)); - usb_write8(pAdapter, EFUSE_CTRL + 2, - (usb_read8(pAdapter, EFUSE_CTRL + 2) & 0xFC) | - (u8)((addr >> 8) & 0x03)); - usb_write8(pAdapter, EFUSE_CTRL, data);/* data */ - - usb_write8(pAdapter, EFUSE_CTRL + 3, 0xF2);/* write cmd */ - - while ((0x80 & usb_read8(pAdapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) - tmpidx++; - - if (tmpidx < 100) - result = true; - else - result = false; - - return result; -} - -/* Read allowed word in current efuse section data. */ -void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) -{ - if (!(word_en & BIT(0))) { - targetdata[0] = sourdata[0]; - targetdata[1] = sourdata[1]; - } - if (!(word_en & BIT(1))) { - targetdata[2] = sourdata[2]; - targetdata[3] = sourdata[3]; - } - if (!(word_en & BIT(2))) { - targetdata[4] = sourdata[4]; - targetdata[5] = sourdata[5]; - } - if (!(word_en & BIT(3))) { - targetdata[6] = sourdata[6]; - targetdata[7] = sourdata[7]; - } -} - -/* Read All Efuse content */ -static void Efuse_ReadAllMap(struct adapter *pAdapter, u8 *Efuse) -{ - efuse_power_switch(pAdapter, true); - efuse_ReadEFuse(pAdapter, 0, EFUSE_MAP_LEN_88E, Efuse); - efuse_power_switch(pAdapter, false); -} - -/* Transfer current EFUSE content to shadow init and modify map. */ -void EFUSE_ShadowMapUpdate(struct adapter *pAdapter) -{ - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); - - if (pEEPROM->bautoload_fail_flag) - memset(pEEPROM->efuse_eeprom_data, 0xFF, EFUSE_MAP_LEN_88E); - else - Efuse_ReadAllMap(pAdapter, pEEPROM->efuse_eeprom_data); -} diff --git a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c b/drivers/staging/rtl8188eu/core/rtw_ieee80211.c deleted file mode 100644 index ce82b866c633..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_ieee80211.c +++ /dev/null @@ -1,990 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _IEEE80211_C - -#include - -#include -#include -#include -#include -#include -#include - -u8 RTW_WPA_OUI_TYPE[] = { 0x00, 0x50, 0xf2, 1 }; -u8 WPA_AUTH_KEY_MGMT_NONE[] = { 0x00, 0x50, 0xf2, 0 }; -u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x50, 0xf2, 1 }; -u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x50, 0xf2, 2 }; -u8 WPA_CIPHER_SUITE_NONE[] = { 0x00, 0x50, 0xf2, 0 }; -u8 WPA_CIPHER_SUITE_WEP40[] = { 0x00, 0x50, 0xf2, 1 }; -u8 WPA_CIPHER_SUITE_TKIP[] = { 0x00, 0x50, 0xf2, 2 }; -u8 WPA_CIPHER_SUITE_WRAP[] = { 0x00, 0x50, 0xf2, 3 }; -u8 WPA_CIPHER_SUITE_CCMP[] = { 0x00, 0x50, 0xf2, 4 }; -u8 WPA_CIPHER_SUITE_WEP104[] = { 0x00, 0x50, 0xf2, 5 }; - -u16 RSN_VERSION_BSD = 1; -u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[] = { 0x00, 0x0f, 0xac, 1 }; -u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[] = { 0x00, 0x0f, 0xac, 2 }; -u8 RSN_CIPHER_SUITE_NONE[] = { 0x00, 0x0f, 0xac, 0 }; -u8 RSN_CIPHER_SUITE_WEP40[] = { 0x00, 0x0f, 0xac, 1 }; -u8 RSN_CIPHER_SUITE_TKIP[] = { 0x00, 0x0f, 0xac, 2 }; -u8 RSN_CIPHER_SUITE_WRAP[] = { 0x00, 0x0f, 0xac, 3 }; -u8 RSN_CIPHER_SUITE_CCMP[] = { 0x00, 0x0f, 0xac, 4 }; -u8 RSN_CIPHER_SUITE_WEP104[] = { 0x00, 0x0f, 0xac, 5 }; -/* */ -/* for adhoc-master to generate ie and provide supported-rate to fw */ -/* */ - -static u8 WIFI_CCKRATES[] = { - IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK -}; - -static u8 WIFI_OFDMRATES[] = { - IEEE80211_OFDM_RATE_6MB, - IEEE80211_OFDM_RATE_9MB, - IEEE80211_OFDM_RATE_12MB, - IEEE80211_OFDM_RATE_18MB, - IEEE80211_OFDM_RATE_24MB, - IEEE80211_OFDM_RATE_36MB, - IEEE80211_OFDM_RATE_48MB, - IEEE80211_OFDM_RATE_54MB -}; - -int rtw_get_bit_value_from_ieee_value(u8 val) -{ - static const unsigned char dot11_rate_table[] = { - 2, 4, 11, 22, 12, 18, 24, 36, 48, - 72, 96, 108, 0}; /* last element must be zero!! */ - int i = 0; - - while (dot11_rate_table[i] != 0) { - if (dot11_rate_table[i] == val) - return BIT(i); - i++; - } - return 0; -} - -bool rtw_is_cckrates_included(u8 *rate) -{ - while (*rate) { - u8 r = *rate & 0x7f; - - if (r == 2 || r == 4 || r == 11 || r == 22) - return true; - rate++; - } - - return false; -} - -bool rtw_is_cckratesonly_included(u8 *rate) -{ - while (*rate) { - u8 r = *rate & 0x7f; - - if (r != 2 && r != 4 && r != 11 && r != 22) - return false; - rate++; - } - - return true; -} - -int rtw_check_network_type(unsigned char *rate) -{ - /* could be pure B, pure G, or B/G */ - if (rtw_is_cckratesonly_included(rate)) - return WIRELESS_11B; - else if (rtw_is_cckrates_included(rate)) - return WIRELESS_11BG; - else - return WIRELESS_11G; -} - -u8 *rtw_set_fixed_ie(void *pbuf, unsigned int len, void *source, - unsigned int *frlen) -{ - memcpy(pbuf, source, len); - *frlen = *frlen + len; - return ((u8 *)pbuf) + len; -} - -/* rtw_set_ie will update frame length */ -u8 *rtw_set_ie -( - u8 *pbuf, - int index, - uint len, - u8 *source, - uint *frlen /* frame length */ -) -{ - *pbuf = (u8)index; - - *(pbuf + 1) = (u8)len; - - if (len > 0) - memcpy((void *)(pbuf + 2), (void *)source, len); - - *frlen = *frlen + (len + 2); - - return pbuf + len + 2; -} - -/* - * ---------------------------------------------------------------------------- - * index: the information element id index, limit is the limit for search - * ---------------------------------------------------------------------------- - */ -u8 *rtw_get_ie(u8 *pbuf, int index, uint *len, int limit) -{ - int tmp, i; - u8 *p; - - if (limit < 1) - return NULL; - - p = pbuf; - i = 0; - *len = 0; - while (1) { - if (*p == index) { - *len = *(p + 1); - return p; - } - tmp = *(p + 1); - p += (tmp + 2); - i += (tmp + 2); - if (i >= limit) - break; - } - return NULL; -} - -void rtw_set_supported_rate(u8 *SupportedRates, uint mode) -{ - memset(SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); - - switch (mode) { - case WIRELESS_11B: - memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); - break; - case WIRELESS_11G: - case WIRELESS_11A: - case WIRELESS_11_5N: - case WIRELESS_11A_5N:/* Todo: no basic rate for ofdm ? */ - memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); - break; - case WIRELESS_11BG: - case WIRELESS_11G_24N: - case WIRELESS_11_24N: - case WIRELESS_11BG_24N: - memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); - memcpy(SupportedRates + IEEE80211_CCK_RATE_LEN, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); - break; - } -} - -uint rtw_get_rateset_len(u8 *rateset) -{ - uint i; - - for (i = 0; i < 13; i++) - if (rateset[i] == 0) - break; - return i; -} - -int rtw_generate_ie(struct registry_priv *pregistrypriv) -{ - u8 wireless_mode; - int rateLen; - uint sz = 0; - struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; - u8 *ie = pdev_network->ies; - - /* timestamp will be inserted by hardware */ - sz += 8; - ie += sz; - - /* beacon interval : 2bytes */ - *(__le16 *)ie = cpu_to_le16((u16)pdev_network->Configuration.BeaconPeriod);/* BCN_INTERVAL; */ - sz += 2; - ie += 2; - - /* capability info */ - *(u16 *)ie = 0; - - *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_IBSS); - - if (pregistrypriv->preamble == PREAMBLE_SHORT) - *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); - - if (pdev_network->Privacy) - *(__le16 *)ie |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); - - sz += 2; - ie += 2; - - /* SSID */ - ie = rtw_set_ie(ie, WLAN_EID_SSID, pdev_network->ssid.ssid_length, pdev_network->ssid.ssid, &sz); - - /* supported rates */ - if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) - wireless_mode = WIRELESS_11BG_24N; - else - wireless_mode = pregistrypriv->wireless_mode; - - rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); - - rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); - - if (rateLen > 8) { - ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, 8, pdev_network->SupportedRates, &sz); - /* ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); */ - } else { - ie = rtw_set_ie(ie, WLAN_EID_SUPP_RATES, rateLen, pdev_network->SupportedRates, &sz); - } - - /* DS parameter set */ - ie = rtw_set_ie(ie, WLAN_EID_DS_PARAMS, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz); - - /* IBSS Parameter Set */ - - ie = rtw_set_ie(ie, WLAN_EID_IBSS_PARAMS, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); - - if (rateLen > 8) - ie = rtw_set_ie(ie, WLAN_EID_EXT_SUPP_RATES, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); - - return sz; -} - -unsigned char *rtw_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit) -{ - uint len; - u16 val16; - __le16 le_tmp; - static const unsigned char wpa_oui_type[] = {0x00, 0x50, 0xf2, 0x01}; - u8 *pbuf = pie; - int limit_new = limit; - - while (1) { - pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &len, limit_new); - - if (pbuf) { - /* check if oui matches... */ - if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type))) - goto check_next_ie; - - /* check version... */ - memcpy((u8 *)&le_tmp, (pbuf + 6), sizeof(val16)); - - val16 = le16_to_cpu(le_tmp); - if (val16 != 0x0001) - goto check_next_ie; - *wpa_ie_len = *(pbuf + 1); - return pbuf; - } - *wpa_ie_len = 0; - return NULL; - -check_next_ie: - limit_new = limit - (pbuf - pie) - 2 - len; - if (limit_new <= 0) - break; - pbuf += (2 + len); - } - *wpa_ie_len = 0; - return NULL; -} - -unsigned char *rtw_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len, int limit) -{ - return rtw_get_ie(pie, WLAN_EID_RSN, rsn_ie_len, limit); -} - -int rtw_get_wpa_cipher_suite(u8 *s) -{ - if (!memcmp(s, WPA_CIPHER_SUITE_NONE, WPA_SELECTOR_LEN)) - return WPA_CIPHER_NONE; - if (!memcmp(s, WPA_CIPHER_SUITE_WEP40, WPA_SELECTOR_LEN)) - return WPA_CIPHER_WEP40; - if (!memcmp(s, WPA_CIPHER_SUITE_TKIP, WPA_SELECTOR_LEN)) - return WPA_CIPHER_TKIP; - if (!memcmp(s, WPA_CIPHER_SUITE_CCMP, WPA_SELECTOR_LEN)) - return WPA_CIPHER_CCMP; - if (!memcmp(s, WPA_CIPHER_SUITE_WEP104, WPA_SELECTOR_LEN)) - return WPA_CIPHER_WEP104; - - return 0; -} - -int rtw_get_wpa2_cipher_suite(u8 *s) -{ - if (!memcmp(s, RSN_CIPHER_SUITE_NONE, RSN_SELECTOR_LEN)) - return WPA_CIPHER_NONE; - if (!memcmp(s, RSN_CIPHER_SUITE_WEP40, RSN_SELECTOR_LEN)) - return WPA_CIPHER_WEP40; - if (!memcmp(s, RSN_CIPHER_SUITE_TKIP, RSN_SELECTOR_LEN)) - return WPA_CIPHER_TKIP; - if (!memcmp(s, RSN_CIPHER_SUITE_CCMP, RSN_SELECTOR_LEN)) - return WPA_CIPHER_CCMP; - if (!memcmp(s, RSN_CIPHER_SUITE_WEP104, RSN_SELECTOR_LEN)) - return WPA_CIPHER_WEP104; - - return 0; -} - -int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) -{ - int i, ret = _SUCCESS; - int left, count; - u8 *pos; - u8 SUITE_1X[4] = {0x00, 0x50, 0xf2, 1}; - - if (wpa_ie_len <= 0) { - /* No WPA IE - fail silently */ - return _FAIL; - } - - if ((*wpa_ie != WLAN_EID_VENDOR_SPECIFIC) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || - (memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) - return _FAIL; - - pos = wpa_ie; - - pos += 8; - left = wpa_ie_len - 8; - - /* group_cipher */ - if (left >= WPA_SELECTOR_LEN) { - *group_cipher = rtw_get_wpa_cipher_suite(pos); - pos += WPA_SELECTOR_LEN; - left -= WPA_SELECTOR_LEN; - } else if (left > 0) { - return _FAIL; - } - - /* pairwise_cipher */ - if (left >= 2) { - count = get_unaligned_le16(pos); - pos += 2; - left -= 2; - - if (count == 0 || left < count * WPA_SELECTOR_LEN) - return _FAIL; - - for (i = 0; i < count; i++) { - *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos); - - pos += WPA_SELECTOR_LEN; - left -= WPA_SELECTOR_LEN; - } - } else if (left == 1) { - return _FAIL; - } - - if (is_8021x) { - if (left >= 6) { - pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) - *is_8021x = 1; - } - } - - return ret; -} - -int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwise_cipher, int *is_8021x) -{ - int i, ret = _SUCCESS; - int left, count; - u8 *pos; - u8 SUITE_1X[4] = {0x00, 0x0f, 0xac, 0x01}; - - if (rsn_ie_len <= 0) { - /* No RSN IE - fail silently */ - return _FAIL; - } - - if ((*rsn_ie != WLAN_EID_RSN) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) - return _FAIL; - - pos = rsn_ie; - pos += 4; - left = rsn_ie_len - 4; - - /* group_cipher */ - if (left >= RSN_SELECTOR_LEN) { - *group_cipher = rtw_get_wpa2_cipher_suite(pos); - - pos += RSN_SELECTOR_LEN; - left -= RSN_SELECTOR_LEN; - - } else if (left > 0) { - return _FAIL; - } - - /* pairwise_cipher */ - if (left >= 2) { - count = get_unaligned_le16(pos); - pos += 2; - left -= 2; - - if (count == 0 || left < count * RSN_SELECTOR_LEN) - return _FAIL; - - for (i = 0; i < count; i++) { - *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos); - - pos += RSN_SELECTOR_LEN; - left -= RSN_SELECTOR_LEN; - } - - } else if (left == 1) { - return _FAIL; - } - - if (is_8021x) { - if (left >= 6) { - pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) - *is_8021x = 1; - } - } - return ret; -} - -void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) -{ - u8 authmode; - u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; - uint cnt; - - /* Search required WPA or WPA2 IE and copy to sec_ie[] */ - - cnt = _TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_; - - while (cnt < in_len) { - authmode = in_ie[cnt]; - - if ((authmode == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { - if (wpa_ie) - memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - - *wpa_len = in_ie[cnt + 1] + 2; - cnt += in_ie[cnt + 1] + 2; /* get next */ - } else { - if (authmode == WLAN_EID_RSN) { - if (rsn_ie) - memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - - *rsn_len = in_ie[cnt + 1] + 2; - cnt += in_ie[cnt + 1] + 2; /* get next */ - } else { - cnt += in_ie[cnt + 1] + 2; /* get next */ - } - } - } -} - -u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) -{ - u8 match = false; - u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - if (!ie_ptr) - return match; - - eid = ie_ptr[0]; - - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { - *wps_ielen = ie_ptr[1] + 2; - match = true; - } - return match; -} - -/** - * rtw_get_wps_ie - Search WPS IE from a series of ies - * @in_ie: Address of ies to search - * @in_len: Length limit from in_ie - * @wps_ie: If not NULL and WPS IE is found, WPS IE will be copied to the buf starting from wps_ie - * @wps_ielen: If not NULL and WPS IE is found, will set to the length of the entire WPS IE - * - * Returns: The address of the WPS IE found, or NULL - */ -u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) -{ - uint cnt; - u8 *wpsie_ptr = NULL; - u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - if (wps_ielen) - *wps_ielen = 0; - - if (!in_ie || in_len <= 0) - return wpsie_ptr; - - cnt = 0; - - while (cnt < in_len) { - eid = in_ie[cnt]; - - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { - wpsie_ptr = &in_ie[cnt]; - - if (wps_ie) - memcpy(wps_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - - if (wps_ielen) - *wps_ielen = in_ie[cnt + 1] + 2; - - cnt += in_ie[cnt + 1] + 2; - - break; - } - cnt += in_ie[cnt + 1] + 2; /* goto next */ - } - return wpsie_ptr; -} - -/** - * rtw_get_wps_attr - Search a specific WPS attribute from a given WPS IE - * @wps_ie: Address of WPS IE to search - * @wps_ielen: Length limit from wps_ie - * @target_attr_id: The attribute ID of WPS attribute to search - * @buf_attr: If not NULL and the WPS attribute is found, WPS attribute will be copied to the buf starting from buf_attr - * @len_attr: If not NULL and the WPS attribute is found, will set to the length of the entire WPS attribute - * - * Returns: the address of the specific WPS attribute found, or NULL - */ -u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_attr, u32 *len_attr) -{ - u8 *attr_ptr = NULL; - u8 *target_attr_ptr = NULL; - u8 wps_oui[4] = {0x00, 0x50, 0xF2, 0x04}; - - if (len_attr) - *len_attr = 0; - - if ((wps_ie[0] != WLAN_EID_VENDOR_SPECIFIC) || - (memcmp(wps_ie + 2, wps_oui, 4))) - return attr_ptr; - - /* 6 = 1(Element ID) + 1(Length) + 4(WPS OUI) */ - attr_ptr = wps_ie + 6; /* goto first attr */ - - while (attr_ptr - wps_ie < wps_ielen) { - /* 4 = 2(Attribute ID) + 2(Length) */ - u16 attr_id = get_unaligned_be16(attr_ptr); - u16 attr_data_len = get_unaligned_be16(attr_ptr + 2); - u16 attr_len = attr_data_len + 4; - - if (attr_id == target_attr_id) { - target_attr_ptr = attr_ptr; - if (buf_attr) - memcpy(buf_attr, attr_ptr, attr_len); - if (len_attr) - *len_attr = attr_len; - break; - } - attr_ptr += attr_len; /* goto next */ - } - return target_attr_ptr; -} - -/** - * rtw_get_wps_attr_content - Search a specific WPS attribute content from a given WPS IE - * @wps_ie: Address of WPS IE to search - * @wps_ielen: Length limit from wps_ie - * @target_attr_id: The attribute ID of WPS attribute to search - * @buf_content: If not NULL and the WPS attribute is found, WPS attribute content will be copied to the buf starting from buf_content - * @len_content: If not NULL and the WPS attribute is found, will set to the length of the WPS attribute content - * - * Returns: the address of the specific WPS attribute content found, or NULL - */ -u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 *buf_content, uint *len_content) -{ - u8 *attr_ptr; - u32 attr_len; - - if (len_content) - *len_content = 0; - - attr_ptr = rtw_get_wps_attr(wps_ie, wps_ielen, target_attr_id, NULL, &attr_len); - - if (attr_ptr && attr_len) { - if (buf_content) - memcpy(buf_content, attr_ptr + 4, attr_len - 4); - - if (len_content) - *len_content = attr_len - 4; - - return attr_ptr + 4; - } - - return NULL; -} - -static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, - struct rtw_ieee802_11_elems *elems, int show_errors) -{ - unsigned int oui; - - /* - * first 3 bytes in vendor specific information element are the IEEE - * OUI of the vendor. The following byte is used a vendor specific - * sub-type. - */ - if (elen < 4) - return -1; - - oui = RTW_GET_BE24(pos); - switch (oui) { - case OUI_MICROSOFT: - /* - * Microsoft/Wi-Fi information elements are further typed and - * subtyped - */ - switch (pos[3]) { - case 1: - /* - * Microsoft OUI (00:50:F2) with OUI Type 1: - * real WPA information element - */ - elems->wpa_ie = pos; - elems->wpa_ie_len = elen; - break; - case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ - if (elen < 5) - return -1; - - switch (pos[4]) { - case WME_OUI_SUBTYPE_INFORMATION_ELEMENT: - case WME_OUI_SUBTYPE_PARAMETER_ELEMENT: - elems->wme = pos; - elems->wme_len = elen; - break; - case WME_OUI_SUBTYPE_TSPEC_ELEMENT: - elems->wme_tspec = pos; - elems->wme_tspec_len = elen; - break; - default: - return -1; - } - break; - case 4: - /* Wi-Fi Protected Setup (WPS) IE */ - elems->wps_ie = pos; - elems->wps_ie_len = elen; - break; - default: - return -1; - } - break; - - case OUI_BROADCOM: - switch (pos[3]) { - case VENDOR_HT_CAPAB_OUI_TYPE: - elems->vendor_ht_cap = pos; - elems->vendor_ht_cap_len = elen; - break; - default: - return -1; - } - break; - default: - return -1; - } - return 0; -} - -/** - * rtw_ieee802_11_parse_elems - Parse information elements in management frames - * @start: Pointer to the start of ies - * @len: Length of IE buffer in octets - * @elems: Data structure for parsed elements - * @show_errors: Whether to show parsing errors in debug log - * Returns: Parsing result - */ -enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors) -{ - uint left = len; - u8 *pos = start; - int unknown = 0; - - memset(elems, 0, sizeof(*elems)); - - while (left >= 2) { - u8 id, elen; - - id = *pos++; - elen = *pos++; - left -= 2; - - if (elen > left) - return ParseFailed; - - switch (id) { - case WLAN_EID_SSID: - elems->ssid = pos; - elems->ssid_len = elen; - break; - case WLAN_EID_SUPP_RATES: - elems->supp_rates = pos; - elems->supp_rates_len = elen; - break; - case WLAN_EID_FH_PARAMS: - elems->fh_params = pos; - elems->fh_params_len = elen; - break; - case WLAN_EID_DS_PARAMS: - elems->ds_params = pos; - elems->ds_params_len = elen; - break; - case WLAN_EID_CF_PARAMS: - elems->cf_params = pos; - elems->cf_params_len = elen; - break; - case WLAN_EID_TIM: - elems->tim = pos; - elems->tim_len = elen; - break; - case WLAN_EID_IBSS_PARAMS: - elems->ibss_params = pos; - elems->ibss_params_len = elen; - break; - case WLAN_EID_CHALLENGE: - elems->challenge = pos; - elems->challenge_len = elen; - break; - case WLAN_EID_ERP_INFO: - elems->erp_info = pos; - elems->erp_info_len = elen; - break; - case WLAN_EID_EXT_SUPP_RATES: - elems->ext_supp_rates = pos; - elems->ext_supp_rates_len = elen; - break; - case WLAN_EID_VENDOR_SPECIFIC: - if (rtw_ieee802_11_parse_vendor_specific(pos, elen, elems, show_errors)) - unknown++; - break; - case WLAN_EID_RSN: - elems->rsn_ie = pos; - elems->rsn_ie_len = elen; - break; - case WLAN_EID_PWR_CAPABILITY: - elems->power_cap = pos; - elems->power_cap_len = elen; - break; - case WLAN_EID_SUPPORTED_CHANNELS: - elems->supp_channels = pos; - elems->supp_channels_len = elen; - break; - case WLAN_EID_MOBILITY_DOMAIN: - elems->mdie = pos; - elems->mdie_len = elen; - break; - case WLAN_EID_FAST_BSS_TRANSITION: - elems->ftie = pos; - elems->ftie_len = elen; - break; - case WLAN_EID_TIMEOUT_INTERVAL: - elems->timeout_int = pos; - elems->timeout_int_len = elen; - break; - case WLAN_EID_HT_CAPABILITY: - elems->ht_capabilities = pos; - elems->ht_capabilities_len = elen; - break; - case WLAN_EID_HT_OPERATION: - elems->ht_operation = pos; - elems->ht_operation_len = elen; - break; - default: - unknown++; - break; - } - left -= elen; - pos += elen; - } - if (left) - return ParseFailed; - return unknown ? ParseUnknown : ParseOK; -} - -void rtw_macaddr_cfg(u8 *mac_addr) -{ - u8 mac[ETH_ALEN]; - - if (!mac_addr) - return; - - if (rtw_initmac && mac_pton(rtw_initmac, mac)) { - /* Users specify the mac address */ - ether_addr_copy(mac_addr, mac); - } else { - /* Use the mac address stored in the Efuse */ - ether_addr_copy(mac, mac_addr); - } - - if (is_broadcast_ether_addr(mac) || is_zero_ether_addr(mac)) - eth_random_addr(mac_addr); -} - -static int rtw_get_cipher_info(struct wlan_network *pnetwork) -{ - uint wpa_ielen; - unsigned char *pbuf; - int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; - int ret = _FAIL; - - pbuf = rtw_get_wpa_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length - 12); - - if (pbuf && (wpa_ielen > 0)) { - if (rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is8021x) == _SUCCESS) { - pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; - pnetwork->BcnInfo.group_cipher = group_cipher; - pnetwork->BcnInfo.is_8021x = is8021x; - ret = _SUCCESS; - } - } else { - pbuf = rtw_get_wpa2_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length - 12); - - if (pbuf && (wpa_ielen > 0)) { - if (rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is8021x) == _SUCCESS) { - pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; - pnetwork->BcnInfo.group_cipher = group_cipher; - pnetwork->BcnInfo.is_8021x = is8021x; - ret = _SUCCESS; - } - } - } - - return ret; -} - -void rtw_get_bcn_info(struct wlan_network *pnetwork) -{ - unsigned short cap = 0; - u8 bencrypt = 0; - __le16 le_tmp; - u16 wpa_len = 0, rsn_len = 0; - struct HT_info_element *pht_info = NULL; - uint len; - unsigned char *p; - - memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.ies), 2); - cap = le16_to_cpu(le_tmp); - if (cap & WLAN_CAPABILITY_PRIVACY) { - bencrypt = 1; - pnetwork->network.Privacy = 1; - } else { - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; - } - rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, NULL, &rsn_len, NULL, &wpa_len); - - if (rsn_len > 0) { - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; - } else if (wpa_len > 0) { - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA; - } else { - if (bencrypt) - pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; - } - rtw_get_cipher_info(pnetwork); - - /* get bwmode and ch_offset */ - /* parsing HT_CAP_IE */ - p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); - if (p && len > 0) { - struct ieee80211_ht_cap *ht_cap = - (struct ieee80211_ht_cap *)(p + 2); - - pnetwork->BcnInfo.ht_cap_info = le16_to_cpu(ht_cap->cap_info); - } else { - pnetwork->BcnInfo.ht_cap_info = 0; - } - /* parsing HT_INFO_IE */ - p = rtw_get_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, pnetwork->network.ie_length - _FIXED_IE_LENGTH_); - if (p && len > 0) { - pht_info = (struct HT_info_element *)(p + 2); - pnetwork->BcnInfo.ht_info_infos_0 = pht_info->infos[0]; - } else { - pnetwork->BcnInfo.ht_info_infos_0 = 0; - } -} - -/* show MCS rate, unit: 100Kbps */ -u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, unsigned char *MCS_rate) -{ - u16 max_rate = 0; - - if (rf_type == RF_1T1R) { - if (MCS_rate[0] & BIT(7)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650); - else if (MCS_rate[0] & BIT(6)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585); - else if (MCS_rate[0] & BIT(5)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); - else if (MCS_rate[0] & BIT(4)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); - else if (MCS_rate[0] & BIT(3)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); - else if (MCS_rate[0] & BIT(2)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195); - else if (MCS_rate[0] & BIT(1)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); - else if (MCS_rate[0] & BIT(0)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65); - } else { - if (MCS_rate[1]) { - if (MCS_rate[1] & BIT(7)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 3000 : 2700) : ((short_GI_20) ? 1444 : 1300); - else if (MCS_rate[1] & BIT(6)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 2700 : 2430) : ((short_GI_20) ? 1300 : 1170); - else if (MCS_rate[1] & BIT(5)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 2400 : 2160) : ((short_GI_20) ? 1156 : 1040); - else if (MCS_rate[1] & BIT(4)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1800 : 1620) : ((short_GI_20) ? 867 : 780); - else if (MCS_rate[1] & BIT(3)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); - else if (MCS_rate[1] & BIT(2)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); - else if (MCS_rate[1] & BIT(1)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); - else if (MCS_rate[1] & BIT(0)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); - } else { - if (MCS_rate[0] & BIT(7)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1500 : 1350) : ((short_GI_20) ? 722 : 650); - else if (MCS_rate[0] & BIT(6)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1350 : 1215) : ((short_GI_20) ? 650 : 585); - else if (MCS_rate[0] & BIT(5)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 1200 : 1080) : ((short_GI_20) ? 578 : 520); - else if (MCS_rate[0] & BIT(4)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 900 : 810) : ((short_GI_20) ? 433 : 390); - else if (MCS_rate[0] & BIT(3)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 600 : 540) : ((short_GI_20) ? 289 : 260); - else if (MCS_rate[0] & BIT(2)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 450 : 405) : ((short_GI_20) ? 217 : 195); - else if (MCS_rate[0] & BIT(1)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 300 : 270) : ((short_GI_20) ? 144 : 130); - else if (MCS_rate[0] & BIT(0)) - max_rate = (bw_40MHz) ? ((short_GI_40) ? 150 : 135) : ((short_GI_20) ? 72 : 65); - } - } - return max_rate; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c b/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c deleted file mode 100644 index f679a7f8fe75..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_ioctl_set.c +++ /dev/null @@ -1,512 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_IOCTL_SET_C_ - -#include -#include -#include -#include - -static const struct { - int channel_plan; - char *name; -} channel_table[] = { { RT_CHANNEL_DOMAIN_FCC, "US" }, - { RT_CHANNEL_DOMAIN_ETSI, "EU" }, - { RT_CHANNEL_DOMAIN_MKK, "JP" }, - { RT_CHANNEL_DOMAIN_CHINA, "CN"} }; - -extern void indicate_wx_scan_complete_event(struct adapter *padapter); - -u8 rtw_do_join(struct adapter *padapter) -{ - struct list_head *plist, *phead; - u8 *pibss = NULL; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct __queue *queue = &pmlmepriv->scanned_queue; - u8 ret = _SUCCESS; - - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - phead = get_list_head(queue); - plist = phead->next; - - pmlmepriv->cur_network.join_res = -2; - - set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - - pmlmepriv->pscanned = plist; - - pmlmepriv->to_join = true; - - if (list_empty(&queue->queue)) { - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - - /* when set_ssid/set_bssid for rtw_do_join(), but scanning queue is empty */ - /* we try to issue sitesurvey firstly */ - - if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || - pmlmepriv->to_roaming > 0) { - /* submit site_survey_cmd */ - ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (ret != _SUCCESS) - pmlmepriv->to_join = false; - } else { - pmlmepriv->to_join = false; - ret = _FAIL; - } - - goto exit; - } else { - int select_ret; - - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - select_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); - if (select_ret == _SUCCESS) { - pmlmepriv->to_join = false; - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); - } else { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - /* submit createbss_cmd to change to a ADHOC_MASTER */ - - /* pmlmepriv->lock has been acquired by caller... */ - struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; - - pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; - - pibss = padapter->registrypriv.dev_network.MacAddress; - - memcpy(&pdev_network->ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); - - rtw_update_registrypriv_dev_network(padapter); - - rtw_generate_random_ibss(pibss); - - if (rtw_createbss_cmd(padapter) != _SUCCESS) { - ret = false; - goto exit; - } - pmlmepriv->to_join = false; - } else { - /* can't associate ; reset under-linking */ - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - - /* when set_ssid/set_bssid for rtw_do_join(), but there are no desired bss in scanning queue */ - /* we try to issue sitesurvey firstly */ - if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || - pmlmepriv->to_roaming > 0) { - ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (ret != _SUCCESS) - pmlmepriv->to_join = false; - } else { - ret = _FAIL; - pmlmepriv->to_join = false; - } - } - } - } - -exit: - return ret; -} - -u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) -{ - u8 status = _SUCCESS; - u32 cur_time = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && - bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) || - (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && - bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) { - status = _FAIL; - goto exit; - } - - spin_lock_bh(&pmlmepriv->lock); - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - goto handle_tkip_countermeasure; - else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) - goto release_mlme_lock; - - if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { - if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { - if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ - } else { - rtw_disassoc_cmd(padapter, 0, true); - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_indicate_disconnect(padapter); - - rtw_free_assoc_resources(padapter); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - } - } - } - -handle_tkip_countermeasure: - /* should we add something here...? */ - - if (padapter->securitypriv.btkip_countermeasure) { - cur_time = jiffies; - - if (cur_time - padapter->securitypriv.btkip_countermeasure_time > 60 * HZ) { - padapter->securitypriv.btkip_countermeasure = false; - padapter->securitypriv.btkip_countermeasure_time = 0; - } else { - status = _FAIL; - goto release_mlme_lock; - } - } - - memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); - pmlmepriv->assoc_by_bssid = true; - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - pmlmepriv->to_join = true; - else - status = rtw_do_join(padapter); - -release_mlme_lock: - spin_unlock_bh(&pmlmepriv->lock); - -exit: - return status; -} - -u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) -{ - u8 status = _SUCCESS; - u32 cur_time = 0; - - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *pnetwork = &pmlmepriv->cur_network; - - if (!padapter->hw_init_completed) { - status = _FAIL; - goto exit; - } - - spin_lock_bh(&pmlmepriv->lock); - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - goto handle_tkip_countermeasure; - else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) - goto release_mlme_lock; - - if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { - if (pmlmepriv->assoc_ssid.ssid_length == ssid->ssid_length && - !memcmp(&pmlmepriv->assoc_ssid.ssid, ssid->ssid, ssid->ssid_length)) { - if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (!rtw_is_same_ibss(padapter, pnetwork)) { - /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ - rtw_disassoc_cmd(padapter, 0, true); - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_indicate_disconnect(padapter); - - rtw_free_assoc_resources(padapter); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - } - } else { - goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ - } - } else { - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); - } - } else { - rtw_disassoc_cmd(padapter, 0, true); - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_indicate_disconnect(padapter); - - rtw_free_assoc_resources(padapter); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - } - } - } - -handle_tkip_countermeasure: - - if (padapter->securitypriv.btkip_countermeasure) { - cur_time = jiffies; - - if (cur_time - padapter->securitypriv.btkip_countermeasure_time > 60 * HZ) { - padapter->securitypriv.btkip_countermeasure = false; - padapter->securitypriv.btkip_countermeasure_time = 0; - } else { - status = _FAIL; - goto release_mlme_lock; - } - } - - memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); - pmlmepriv->assoc_by_bssid = false; - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - pmlmepriv->to_join = true; - else - status = rtw_do_join(padapter); - -release_mlme_lock: - spin_unlock_bh(&pmlmepriv->lock); - -exit: - return status; -} - -u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, - enum ndis_802_11_network_infra networktype) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - enum ndis_802_11_network_infra *pold_state = &cur_network->network.InfrastructureMode; - - if (*pold_state != networktype) { - spin_lock_bh(&pmlmepriv->lock); - - if (*pold_state == Ndis802_11APMode) { - /* change to other mode from Ndis802_11APMode */ - cur_network->join_res = -1; - -#ifdef CONFIG_88EU_AP_MODE - stop_ap_mode(padapter); -#endif - } - - if (check_fwstate(pmlmepriv, _FW_LINKED) || - *pold_state == Ndis802_11IBSS) - rtw_disassoc_cmd(padapter, 0, true); - - if (check_fwstate(pmlmepriv, _FW_LINKED) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) - rtw_free_assoc_resources(padapter); - - if (*pold_state == Ndis802_11Infrastructure || - *pold_state == Ndis802_11IBSS) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have checked whether issue dis-assoc_cmd or not */ - } - - *pold_state = networktype; - - _clr_fwstate_(pmlmepriv, ~WIFI_NULL_STATE); - - switch (networktype) { - case Ndis802_11IBSS: - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - break; - case Ndis802_11Infrastructure: - set_fwstate(pmlmepriv, WIFI_STATION_STATE); - break; - case Ndis802_11APMode: - set_fwstate(pmlmepriv, WIFI_AP_STATE); -#ifdef CONFIG_88EU_AP_MODE - start_ap_mode(padapter); -#endif - break; - case Ndis802_11AutoUnknown: - case Ndis802_11InfrastructureMax: - break; - } - spin_unlock_bh(&pmlmepriv->lock); - } - - return true; -} - -u8 rtw_set_802_11_disassociate(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->lock); - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - rtw_disassoc_cmd(padapter, 0, true); - rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter); - rtw_pwr_wakeup(padapter); - } - - spin_unlock_bh(&pmlmepriv->lock); - - return true; -} - -u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 res = true; - - if (!padapter) { - res = false; - goto exit; - } - if (!padapter->hw_init_completed) { - res = false; - goto exit; - } - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING) || - pmlmepriv->LinkDetectInfo.bBusyTraffic) { - /* Scan or linking is in progress, do nothing. */ - res = true; - } else { - if (rtw_is_scan_deny(padapter)) { - indicate_wx_scan_complete_event(padapter); - return _SUCCESS; - } - - spin_lock_bh(&pmlmepriv->lock); - - res = rtw_sitesurvey_cmd(padapter, pssid, ssid_max_num, NULL, 0); - - spin_unlock_bh(&pmlmepriv->lock); - } -exit: - return res; -} - -u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11_auth_mode authmode) -{ - struct security_priv *psecuritypriv = &padapter->securitypriv; - int res; - u8 ret; - - psecuritypriv->ndisauthtype = authmode; - - if (psecuritypriv->ndisauthtype > 3) - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - - res = rtw_set_auth(padapter, psecuritypriv); - - if (res == _SUCCESS) - ret = true; - else - ret = false; - - return ret; -} - -u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) -{ - int keyid, res; - struct security_priv *psecuritypriv = &padapter->securitypriv; - u8 ret = _SUCCESS; - - keyid = wep->KeyIndex & 0x3fffffff; - - if (keyid >= 4) { - ret = false; - goto exit; - } - - switch (wep->KeyLength) { - case 5: - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - break; - case 13: - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - break; - default: - psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; - break; - } - - memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], - &wep->KeyMaterial, wep->KeyLength); - - psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; - - psecuritypriv->dot11PrivacyKeyIndex = keyid; - - res = rtw_set_key(padapter, psecuritypriv, keyid, 1); - - if (res == _FAIL) - ret = false; -exit: - return ret; -} - -/* Return 0 or 100Kbps */ -u16 rtw_get_cur_max_rate(struct adapter *adapter) -{ - int i = 0; - u8 *p; - u16 rate = 0, max_rate = 0; - struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct registry_priv *pregistrypriv = &adapter->registrypriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - u8 bw_40MHz = 0, short_GI_20 = 0, short_GI_40 = 0; - u32 ht_ielen = 0; - - if (!check_fwstate(pmlmepriv, _FW_LINKED) && - !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) - return 0; - - if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N | WIRELESS_11_5N)) { - p = rtw_get_ie(&pcur_bss->ies[12], WLAN_EID_HT_CAPABILITY, - &ht_ielen, pcur_bss->ie_length - 12); - if (p && ht_ielen > 0) { - /* cur_bwmod is updated by beacon, pmlmeinfo is updated by association response */ - bw_40MHz = (pmlmeext->cur_bwmode && (HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH & pmlmeinfo->HT_info.infos[0])) ? 1 : 0; - - short_GI_20 = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & IEEE80211_HT_CAP_SGI_20) ? 1 : 0; - short_GI_40 = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & IEEE80211_HT_CAP_SGI_40) ? 1 : 0; - - max_rate = rtw_mcs_rate( - RF_1T1R, - bw_40MHz & pregistrypriv->cbw40_enable, - short_GI_20, - short_GI_40, - pmlmeinfo->HT_caps.mcs.rx_mask - ); - } - } else { - while (pcur_bss->SupportedRates[i] != 0 && - pcur_bss->SupportedRates[i] != 0xFF) { - rate = pcur_bss->SupportedRates[i] & 0x7F; - if (rate > max_rate) - max_rate = rate; - i++; - } - - max_rate *= 5; - } - - return max_rate; -} - -/* Return _SUCCESS or _FAIL */ -int rtw_set_country(struct adapter *adapter, const char *country_code) -{ - int i; - int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G; - - for (i = 0; i < ARRAY_SIZE(channel_table); i++) { - if (strcmp(channel_table[i].name, country_code) == 0) { - channel_plan = channel_table[i].channel_plan; - break; - } - } - - return rtw_set_chplan_cmd(adapter, channel_plan, 1); -} diff --git a/drivers/staging/rtl8188eu/core/rtw_iol.c b/drivers/staging/rtl8188eu/core/rtw_iol.c deleted file mode 100644 index fc3c66201e59..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_iol.c +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include - -bool rtw_iol_applied(struct adapter *adapter) -{ - if (adapter->registrypriv.fw_iol == 1) - return true; - - if (adapter->registrypriv.fw_iol == 2 && - !adapter_to_dvobj(adapter)->ishighspeed) - return true; - return false; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_led.c b/drivers/staging/rtl8188eu/core/rtw_led.c deleted file mode 100644 index be868f386204..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_led.c +++ /dev/null @@ -1,460 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include "rtw_led.h" - -/* */ -/* Description: */ -/* Callback function of LED BlinkTimer, */ -/* it just schedules to corresponding BlinkWorkItem/led_blink_hdl */ -/* */ -static void BlinkTimerCallback(struct timer_list *t) -{ - struct LED_871x *pLed = from_timer(pLed, t, BlinkTimer); - struct adapter *padapter = pLed->padapter; - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return; - - schedule_work(&pLed->BlinkWorkItem); -} - -/* */ -/* Description: */ -/* Callback function of LED BlinkWorkItem. */ -/* */ -void BlinkWorkItemCallback(struct work_struct *work) -{ - struct LED_871x *pLed = container_of(work, struct LED_871x, - BlinkWorkItem); - - blink_handler(pLed); -} - -/* */ -/* Description: */ -/* Reset status of LED_871x object. */ -/* */ -void ResetLedStatus(struct LED_871x *pLed) -{ - pLed->CurrLedState = RTW_LED_OFF; /* Current LED state. */ - pLed->led_on = false; /* true if LED is ON, false if LED is OFF. */ - - pLed->bLedBlinkInProgress = false; /* true if it is blinking, false o.w.. */ - pLed->bLedWPSBlinkInProgress = false; - - pLed->BlinkTimes = 0; /* Number of times to toggle led state for blinking. */ - pLed->BlinkingLedState = LED_UNKNOWN; /* Next state for blinking, either RTW_LED_ON or RTW_LED_OFF are. */ - - pLed->bLedNoLinkBlinkInProgress = false; - pLed->bLedLinkBlinkInProgress = false; - pLed->bLedScanBlinkInProgress = false; -} - -/*Description: */ -/* Initialize an LED_871x object. */ -void InitLed871x(struct adapter *padapter, struct LED_871x *pLed) -{ - pLed->padapter = padapter; - - ResetLedStatus(pLed); - - timer_setup(&pLed->BlinkTimer, BlinkTimerCallback, 0); - - INIT_WORK(&pLed->BlinkWorkItem, BlinkWorkItemCallback); -} - -/* */ -/* Description: */ -/* DeInitialize an LED_871x object. */ -/* */ -void DeInitLed871x(struct LED_871x *pLed) -{ - cancel_work_sync(&pLed->BlinkWorkItem); - del_timer_sync(&pLed->BlinkTimer); - ResetLedStatus(pLed); -} - -/* */ -/* Description: */ -/* Implementation of LED blinking behavior. */ -/* It toggle off LED and schedule corresponding timer if necessary. */ -/* */ - -static void SwLedBlink1(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) - sw_led_on(padapter, pLed); - else - sw_led_off(padapter, pLed); - - if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { - sw_led_off(padapter, pLed); - ResetLedStatus(pLed); - return; - } - - switch (pLed->CurrLedState) { - case LED_BLINK_SLOWLY: - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - break; - case LED_BLINK_NORMAL: - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA)); - break; - case LED_BLINK_SCAN: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - } - pLed->bLedScanBlinkInProgress = false; - } else { - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - } - break; - case LED_BLINK_TXRX: - pLed->BlinkTimes--; - if (pLed->BlinkTimes == 0) { - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - } - pLed->bLedBlinkInProgress = false; - } else { - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA)); - } - break; - case LED_BLINK_WPS: - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - break; - case LED_BLINK_WPS_STOP: /* WPS success */ - if (pLed->BlinkingLedState != RTW_LED_ON) { - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA)); - - pLed->bLedWPSBlinkInProgress = false; - } else { - pLed->BlinkingLedState = RTW_LED_OFF; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA)); - } - break; - default: - break; - } -} - - /* ALPHA, added by chiyoko, 20090106 */ -static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - struct LED_871x *pLed = &ledpriv->sw_led; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - switch (LedAction) { - case LED_CTL_POWER_ON: - case LED_CTL_START_TO_LINK: - case LED_CTL_NO_LINK: - if (pLed->bLedNoLinkBlinkInProgress) - break; - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - break; - case LED_CTL_LINK: - if (pLed->bLedLinkBlinkInProgress) - break; - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_NORMAL; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_LINK_INTERVAL_ALPHA)); - break; - case LED_CTL_SITE_SURVEY: - if (pmlmepriv->LinkDetectInfo.bBusyTraffic && - check_fwstate(pmlmepriv, _FW_LINKED)) - break; - if (pLed->bLedScanBlinkInProgress) - break; - if (IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - pLed->bLedScanBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SCAN; - pLed->BlinkTimes = 24; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - break; - case LED_CTL_TX: - case LED_CTL_RX: - if (pLed->bLedBlinkInProgress) - break; - if (pLed->CurrLedState == LED_BLINK_SCAN || - IS_LED_WPS_BLINKING(pLed)) - return; - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - pLed->bLedBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_TXRX; - pLed->BlinkTimes = 2; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_FASTER_INTERVAL_ALPHA)); - break; - case LED_CTL_START_WPS: /* wait until xinpin finish */ - case LED_CTL_START_WPS_BOTTON: - if (pLed->bLedWPSBlinkInProgress) - break; - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_SCAN_INTERVAL_ALPHA)); - break; - case LED_CTL_STOP_WPS: - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) - del_timer_sync(&pLed->BlinkTimer); - else - pLed->bLedWPSBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_WPS_STOP; - if (pLed->led_on) { - pLed->BlinkingLedState = RTW_LED_OFF; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA)); - } else { - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, - jiffies + msecs_to_jiffies(0)); - } - break; - case LED_CTL_STOP_WPS_FAIL: - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - pLed->bLedNoLinkBlinkInProgress = true; - pLed->CurrLedState = LED_BLINK_SLOWLY; - if (pLed->led_on) - pLed->BlinkingLedState = RTW_LED_OFF; - else - pLed->BlinkingLedState = RTW_LED_ON; - mod_timer(&pLed->BlinkTimer, jiffies + - msecs_to_jiffies(LED_BLINK_NO_LINK_INTERVAL_ALPHA)); - break; - case LED_CTL_POWER_OFF: - pLed->CurrLedState = RTW_LED_OFF; - pLed->BlinkingLedState = RTW_LED_OFF; - if (pLed->bLedNoLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedNoLinkBlinkInProgress = false; - } - if (pLed->bLedLinkBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; - } - if (pLed->bLedBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedBlinkInProgress = false; - } - if (pLed->bLedWPSBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedWPSBlinkInProgress = false; - } - if (pLed->bLedScanBlinkInProgress) { - del_timer_sync(&pLed->BlinkTimer); - pLed->bLedScanBlinkInProgress = false; - } - sw_led_off(padapter, pLed); - break; - default: - break; - } -} - -void blink_handler(struct LED_871x *pLed) -{ - struct adapter *padapter = pLed->padapter; - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return; - - SwLedBlink1(pLed); -} - -void led_control_8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) -{ - if (padapter->bSurpriseRemoved || padapter->bDriverStopped || - !padapter->hw_init_completed) - return; - - if ((padapter->pwrctrlpriv.rf_pwrstate != rf_on && - padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) && - (LedAction == LED_CTL_TX || LedAction == LED_CTL_RX || - LedAction == LED_CTL_SITE_SURVEY || - LedAction == LED_CTL_LINK || - LedAction == LED_CTL_NO_LINK || - LedAction == LED_CTL_POWER_ON)) - return; - - SwLedControlMode1(padapter, LedAction); -} diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c deleted file mode 100644 index 0d334aba9a3f..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ /dev/null @@ -1,1886 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_MLME_C_ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -extern const u8 MCS_rate_1R[16]; - -int rtw_init_mlme_priv(struct adapter *padapter) -{ - int i; - u8 *pbuf; - struct wlan_network *pnetwork; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int res = _SUCCESS; - - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ - - pmlmepriv->pscanned = NULL; - pmlmepriv->fw_state = 0; - pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; - pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: passive. Maybe someday we should rename this variable to "active_mode" (Jeff) */ - - spin_lock_init(&pmlmepriv->lock); - _rtw_init_queue(&pmlmepriv->free_bss_pool); - _rtw_init_queue(&pmlmepriv->scanned_queue); - - memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - - pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network))); - - if (!pbuf) { - res = _FAIL; - goto exit; - } - pmlmepriv->free_bss_buf = pbuf; - - pnetwork = (struct wlan_network *)pbuf; - - for (i = 0; i < MAX_BSS_CNT; i++) { - INIT_LIST_HEAD(&pnetwork->list); - - list_add_tail(&pnetwork->list, &pmlmepriv->free_bss_pool.queue); - - pnetwork++; - } - - /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - - rtw_clear_scan_deny(padapter); - - rtw_init_mlme_timer(padapter); - -exit: - return res; -} - -#if defined(CONFIG_88EU_AP_MODE) -static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) -{ - kfree(*ppie); - *plen = 0; - *ppie = NULL; -} - -void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) -{ - rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); - rtw_free_mlme_ie_data(&pmlmepriv->wps_assoc_resp_ie, &pmlmepriv->wps_assoc_resp_ie_len); -} -#else -void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) -{ -} -#endif - -void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) -{ - if (pmlmepriv) { - rtw_free_mlme_priv_ie_data(pmlmepriv); - vfree(pmlmepriv->free_bss_buf); - } -} - -struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) - /* _queue *free_queue) */ -{ - struct wlan_network *pnetwork; - struct __queue *free_queue = &pmlmepriv->free_bss_pool; - - spin_lock_bh(&free_queue->lock); - pnetwork = list_first_entry_or_null(&free_queue->queue, - struct wlan_network, list); - if (!pnetwork) - goto exit; - - list_del_init(&pnetwork->list); - - pnetwork->network_type = 0; - pnetwork->fixed = false; - pnetwork->last_scanned = jiffies; - pnetwork->aid = 0; - pnetwork->join_res = 0; - -exit: - spin_unlock_bh(&free_queue->lock); - - return pnetwork; -} - -static void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork, u8 isfreeall) -{ - unsigned long curr_time; - u32 delta_time; - u32 lifetime = SCANQUEUE_LIFETIME; - struct __queue *free_queue = &pmlmepriv->free_bss_pool; - - if (!pnetwork) - return; - - if (pnetwork->fixed) - return; - curr_time = jiffies; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) - lifetime = 1; - if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned) / HZ; - if (delta_time < lifetime)/* unit:sec */ - return; - } - spin_lock_bh(&free_queue->lock); - list_del_init(&pnetwork->list); - list_add_tail(&pnetwork->list, &free_queue->queue); - spin_unlock_bh(&free_queue->lock); -} - -static void rtw_free_network_nolock(struct mlme_priv *pmlmepriv, - struct wlan_network *pnetwork) -{ - struct __queue *free_queue = &pmlmepriv->free_bss_pool; - - if (!pnetwork) - return; - if (pnetwork->fixed) - return; - list_del_init(&pnetwork->list); - list_add_tail(&pnetwork->list, get_list_head(free_queue)); -} - -/* - * return the wlan_network with the matching addr - * - * Shall be called under atomic context... to avoid possible racing condition... - */ -struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr) -{ - struct list_head *phead, *plist; - struct wlan_network *pnetwork = NULL; - - if (is_zero_ether_addr(addr)) { - pnetwork = NULL; - goto exit; - } - phead = get_list_head(scanned_queue); - list_for_each(plist, phead) { - pnetwork = list_entry(plist, struct wlan_network, list); - if (!memcmp(addr, pnetwork->network.MacAddress, ETH_ALEN)) - break; - } - if (plist == phead) - pnetwork = NULL; -exit: - return pnetwork; -} - -void rtw_free_network_queue(struct adapter *padapter, u8 isfreeall) -{ - struct list_head *phead; - struct wlan_network *pnetwork, *temp; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct __queue *scanned_queue = &pmlmepriv->scanned_queue; - - spin_lock_bh(&scanned_queue->lock); - - phead = get_list_head(scanned_queue); - list_for_each_entry_safe(pnetwork, temp, phead, list) - _rtw_free_network(pmlmepriv, pnetwork, isfreeall); - - spin_unlock_bh(&scanned_queue->lock); -} - -int rtw_if_up(struct adapter *padapter) -{ - int res; - - if (padapter->bDriverStopped || padapter->bSurpriseRemoved || - !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) - res = false; - else - res = true; - return res; -} - -void rtw_generate_random_ibss(u8 *pibss) -{ - unsigned long curtime = jiffies; - - pibss[0] = 0x02; /* in ad-hoc mode bit1 must set to 1 */ - pibss[1] = 0x11; - pibss[2] = 0x87; - pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ -} - -u8 *rtw_get_capability_from_ie(u8 *ie) -{ - return ie + 8 + 2; -} - -u16 rtw_get_capability(struct wlan_bssid_ex *bss) -{ - __le16 val; - - memcpy((u8 *)&val, rtw_get_capability_from_ie(bss->ies), 2); - - return le16_to_cpu(val); -} - -u8 *rtw_get_beacon_interval_from_ie(u8 *ie) -{ - return ie + 8; -} - -int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork) -{ - int ret = true; - struct security_priv *psecuritypriv = &adapter->securitypriv; - - if ((psecuritypriv->dot11PrivacyAlgrthm != _NO_PRIVACY_) && - (pnetwork->network.Privacy == 0)) - ret = false; - else if ((psecuritypriv->dot11PrivacyAlgrthm == _NO_PRIVACY_) && - (pnetwork->network.Privacy == 1)) - ret = false; - else - ret = true; - return ret; -} - -static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) -{ - return (a->ssid.ssid_length == b->ssid.ssid_length) && - !memcmp(a->ssid.ssid, b->ssid.ssid, a->ssid.ssid_length); -} - -int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) -{ - u16 s_cap, d_cap; - __le16 le_scap, le_dcap; - - memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->ies), 2); - memcpy((u8 *)&le_dcap, rtw_get_capability_from_ie(dst->ies), 2); - - s_cap = le16_to_cpu(le_scap); - d_cap = le16_to_cpu(le_dcap); - - return ((src->ssid.ssid_length == dst->ssid.ssid_length) && - (!memcmp(src->MacAddress, dst->MacAddress, ETH_ALEN)) && - (!memcmp(src->ssid.ssid, dst->ssid.ssid, src->ssid.ssid_length)) && - ((s_cap & WLAN_CAPABILITY_IBSS) == - (d_cap & WLAN_CAPABILITY_IBSS)) && - ((s_cap & WLAN_CAPABILITY_ESS) == - (d_cap & WLAN_CAPABILITY_ESS))); -} - -struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) -{ - struct list_head *plist, *phead; - struct wlan_network *pwlan = NULL; - struct wlan_network *oldest = NULL; - - phead = get_list_head(scanned_queue); - - for (plist = phead->next; plist != phead; plist = plist->next) { - pwlan = container_of(plist, struct wlan_network, list); - - if (!pwlan->fixed) { - if (!oldest || time_after(oldest->last_scanned, pwlan->last_scanned)) - oldest = pwlan; - } - } - return oldest; -} - -void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, - struct adapter *padapter, bool update_ie) -{ - long rssi_ori = dst->Rssi; - u8 sq_smp = src->PhyInfo.SignalQuality; - u8 ss_final; - u8 sq_final; - long rssi_final; - - rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ - - /* The rule below is 1/5 for sample value, 4/5 for history value */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && - is_same_network(&padapter->mlmepriv.cur_network.network, src)) { - /* Take the recvpriv's value for the connected AP*/ - ss_final = padapter->recvpriv.signal_strength; - sq_final = padapter->recvpriv.signal_qual; - /* the rssi value here is undecorated, and will be used for antenna diversity */ - if (sq_smp != 101) /* from the right channel */ - rssi_final = (src->Rssi + dst->Rssi * 4) / 5; - else - rssi_final = rssi_ori; - } else { - if (sq_smp != 101) { /* from the right channel */ - ss_final = ((u32)(src->PhyInfo.SignalStrength) + (u32)(dst->PhyInfo.SignalStrength) * 4) / 5; - sq_final = ((u32)(src->PhyInfo.SignalQuality) + (u32)(dst->PhyInfo.SignalQuality) * 4) / 5; - rssi_final = (src->Rssi + dst->Rssi * 4) / 5; - } else { - /* bss info not receiving from the right channel, use the original RX signal infos */ - ss_final = dst->PhyInfo.SignalStrength; - sq_final = dst->PhyInfo.SignalQuality; - rssi_final = dst->Rssi; - } - } - if (update_ie) - memcpy((u8 *)dst, (u8 *)src, get_wlan_bssid_ex_sz(src)); - dst->PhyInfo.SignalStrength = ss_final; - dst->PhyInfo.SignalQuality = sq_final; - dst->Rssi = rssi_final; -} - -static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) -{ - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED) && - is_same_network(&pmlmepriv->cur_network.network, pnetwork)) { - update_network(&pmlmepriv->cur_network.network, pnetwork, adapter, true); - rtw_update_protection(adapter, (pmlmepriv->cur_network.network.ies) + sizeof(struct ndis_802_11_fixed_ie), - pmlmepriv->cur_network.network.ie_length); - } -} - -/* - * Caller must hold pmlmepriv->lock first. - */ -void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *target) -{ - struct list_head *plist, *phead; - u32 bssid_ex_sz; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct __queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *oldest = NULL; - - spin_lock_bh(&queue->lock); - phead = get_list_head(queue); - list_for_each(plist, phead) { - pnetwork = list_entry(plist, struct wlan_network, list); - - if (is_same_network(&pnetwork->network, target)) - break; - if ((oldest == ((struct wlan_network *)0)) || - time_after(oldest->last_scanned, pnetwork->last_scanned)) - oldest = pnetwork; - } - /* If we didn't find a match, then get a new network slot to initialize - * with this beacon's information - */ - if (phead == plist) { - if (list_empty(&pmlmepriv->free_bss_pool.queue)) { - /* If there are no more slots, expire the oldest */ - pnetwork = oldest; - - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, - &target->PhyInfo.Optimum_antenna); - memcpy(&pnetwork->network, target, - get_wlan_bssid_ex_sz(target)); - /* variable initialize */ - pnetwork->fixed = false; - pnetwork->last_scanned = jiffies; - - pnetwork->network_type = 0; - pnetwork->aid = 0; - pnetwork->join_res = 0; - - /* bss info not receiving from the right channel */ - if (pnetwork->network.PhyInfo.SignalQuality == 101) - pnetwork->network.PhyInfo.SignalQuality = 0; - } else { - /* Otherwise just pull from the free list */ - - pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ - - if (!pnetwork) - goto exit; - - bssid_ex_sz = get_wlan_bssid_ex_sz(target); - target->Length = bssid_ex_sz; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, - &target->PhyInfo.Optimum_antenna); - memcpy(&pnetwork->network, target, bssid_ex_sz); - - pnetwork->last_scanned = jiffies; - - /* bss info not receiving from the right channel */ - if (pnetwork->network.PhyInfo.SignalQuality == 101) - pnetwork->network.PhyInfo.SignalQuality = 0; - list_add_tail(&pnetwork->list, &queue->queue); - } - } else { - /* we have an entry and we are going to update it. But this - * entry may be already expired. In this case we do the same - * as we found a new net and call the new_net handler - */ - bool update_ie = true; - - pnetwork->last_scanned = jiffies; - - /* target.Reserved[0]== 1, means that scanned network is a bcn frame. */ - if ((pnetwork->network.ie_length > target->ie_length) && (target->Reserved[0] == 1)) - update_ie = false; - - update_network(&pnetwork->network, target, adapter, update_ie); - } - -exit: - spin_unlock_bh(&queue->lock); -} - -static void rtw_add_network(struct adapter *adapter, - struct wlan_bssid_ex *pnetwork) -{ - update_current_network(adapter, pnetwork); - rtw_update_scanned_network(adapter, pnetwork); -} - -/* - * select the desired network based on the capability of the (i)bss. - * check items: (1) security - * (2) network_type - * (3) WMM - * (4) HT - * (5) others - */ -static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network *pnetwork) -{ - struct security_priv *psecuritypriv = &adapter->securitypriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u32 desired_encmode; - u32 privacy; - - /* u8 wps_ie[512]; */ - uint wps_ielen; - - int bselected = true; - - desired_encmode = psecuritypriv->ndisencryptstatus; - privacy = pnetwork->network.Privacy; - - if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.ies + _FIXED_IE_LENGTH_, pnetwork->network.ie_length - _FIXED_IE_LENGTH_, NULL, &wps_ielen)) - return true; - else - return false; - } - if (adapter->registrypriv.wifi_spec == 1) { /* for correct flow of 8021X to do.... */ - if ((desired_encmode == Ndis802_11EncryptionDisabled) && (privacy != 0)) - bselected = false; - } - - if ((desired_encmode != Ndis802_11EncryptionDisabled) && (privacy == 0)) - bselected = false; - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) - bselected = false; - } - - return bselected; -} - -void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) -{ - u32 len; - struct wlan_bssid_ex *pnetwork; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - pnetwork = (struct wlan_bssid_ex *)pbuf; - - len = get_wlan_bssid_ex_sz(pnetwork); - if (len > (sizeof(struct wlan_bssid_ex))) - return; - spin_lock_bh(&pmlmepriv->lock); - - /* update IBSS_network 's timestamp */ - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress, ETH_ALEN)) { - struct wlan_network *ibss_wlan = NULL; - - memcpy(pmlmepriv->cur_network.network.ies, pnetwork->ies, 8); - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ibss_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->MacAddress); - if (ibss_wlan) { - memcpy(ibss_wlan->network.ies, pnetwork->ies, 8); - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - goto exit; - } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - } - } - - /* lock pmlmepriv->lock when you accessing network_q */ - if (!check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { - if (pnetwork->ssid.ssid[0] == 0) - pnetwork->ssid.ssid_length = 0; - rtw_add_network(adapter, pnetwork); - } - -exit: - spin_unlock_bh(&pmlmepriv->lock); -} - -void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) -{ - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->lock); - - if (pmlmepriv->wps_probe_req_ie) { - pmlmepriv->wps_probe_req_ie_len = 0; - kfree(pmlmepriv->wps_probe_req_ie); - pmlmepriv->wps_probe_req_ie = NULL; - } - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { - del_timer_sync(&pmlmepriv->scan_to_timer); - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - } - - rtw_set_signal_stat_timer(&adapter->recvpriv); - - if (pmlmepriv->to_join) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - - if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); - } else { - struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network; - u8 *pibss = adapter->registrypriv.dev_network.MacAddress; - - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - - memcpy(&pdev_network->ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); - - rtw_update_registrypriv_dev_network(adapter); - rtw_generate_random_ibss(pibss); - - pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; - - rtw_createbss_cmd(adapter); - pmlmepriv->to_join = false; - } - } - } else { - int s_ret; - - set_fwstate(pmlmepriv, _FW_UNDER_LINKING); - pmlmepriv->to_join = false; - s_ret = rtw_select_and_join_from_scanned_queue(pmlmepriv); - if (s_ret == _SUCCESS) { - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(MAX_JOIN_TIMEOUT)); - } else if (s_ret == 2) { /* there is no need to wait for join */ - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - rtw_indicate_connect(adapter); - } else { - if (pmlmepriv->to_roaming != 0) { - if (--pmlmepriv->to_roaming == 0 || - rtw_sitesurvey_cmd(adapter, &pmlmepriv->assoc_ssid, 1, NULL, 0) != _SUCCESS) { - pmlmepriv->to_roaming = 0; - rtw_free_assoc_resources(adapter); - rtw_indicate_disconnect(adapter); - } else { - pmlmepriv->to_join = true; - } - } - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - } - } - } - - indicate_wx_scan_complete_event(adapter); - - spin_unlock_bh(&pmlmepriv->lock); - - rtw_os_xmit_schedule(adapter); -} - -void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf) -{ -} - -void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf) -{ -} - -static void free_scanqueue(struct mlme_priv *pmlmepriv) -{ - struct __queue *free_queue = &pmlmepriv->free_bss_pool; - struct __queue *scan_queue = &pmlmepriv->scanned_queue; - struct list_head *plist, *phead, *ptemp; - - spin_lock_bh(&scan_queue->lock); - spin_lock_bh(&free_queue->lock); - - phead = get_list_head(scan_queue); - plist = phead->next; - - while (plist != phead) { - ptemp = plist->next; - list_del_init(plist); - list_add_tail(plist, &free_queue->queue); - plist = ptemp; - } - - spin_unlock_bh(&free_queue->lock); - spin_unlock_bh(&scan_queue->lock); -} - -/* - * rtw_free_assoc_resources: the caller has to lock pmlmepriv->lock - */ -void rtw_free_assoc_resources(struct adapter *adapter) -{ - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - rtw_free_assoc_resources_locked(adapter); - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); -} - -/* - * rtw_free_assoc_resources_locked: the caller has to lock pmlmepriv->lock - */ -void rtw_free_assoc_resources_locked(struct adapter *adapter) -{ - struct wlan_network *pwlan = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct sta_priv *pstapriv = &adapter->stapriv; - struct wlan_network *tgt_network = &pmlmepriv->cur_network; - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE)) { - struct sta_info *psta; - - psta = rtw_get_stainfo(&adapter->stapriv, tgt_network->network.MacAddress); - - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(adapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - } - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) { - struct sta_info *psta; - - rtw_free_all_stainfo(adapter); - - psta = rtw_get_bcmc_stainfo(adapter); - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(adapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - - rtw_init_bcmc_stainfo(adapter); - } - - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (pwlan) - pwlan->fixed = false; - - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))) - rtw_free_network_nolock(pmlmepriv, pwlan); - - pmlmepriv->key_mask = 0; -} - -/* - * rtw_indicate_connect: the caller has to lock pmlmepriv->lock - */ -void rtw_indicate_connect(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - pmlmepriv->to_join = false; - - if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { - set_fwstate(pmlmepriv, _FW_LINKED); - - led_control_8188eu(padapter, LED_CTL_LINK); - - rtw_os_indicate_connect(padapter); - } - - pmlmepriv->to_roaming = 0; - - rtw_set_scan_deny(padapter, 3000); -} - -/* - * rtw_indicate_disconnect: the caller has to lock pmlmepriv->lock - */ -void rtw_indicate_disconnect(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); - - if (pmlmepriv->to_roaming > 0) - _clr_fwstate_(pmlmepriv, _FW_LINKED); - - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) || - (pmlmepriv->to_roaming <= 0)) { - rtw_os_indicate_disconnect(padapter); - - _clr_fwstate_(pmlmepriv, _FW_LINKED); - led_control_8188eu(padapter, LED_CTL_NO_LINK); - rtw_clear_scan_deny(padapter); - } - - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 1); -} - -inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) -{ - indicate_wx_scan_complete_event(padapter); -} - -static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, struct wlan_network *pnetwork) -{ - int i; - struct sta_info *bmc_sta, *psta = NULL; - struct recv_reorder_ctrl *preorder_ctrl; - struct sta_priv *pstapriv = &padapter->stapriv; - - psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); - if (!psta) - psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); - - if (psta) { /* update ptarget_sta */ - psta->aid = pnetwork->join_res; - psta->mac_id = 0; - /* sta mode */ - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); - /* security related */ - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { - padapter->securitypriv.binstallGrpkey = false; - padapter->securitypriv.busetkipkey = false; - padapter->securitypriv.bgrpkey_handshake = false; - psta->ieee8021x_blocked = true; - psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; - memset((u8 *)&psta->dot118021x_UncstKey, 0, sizeof(union Keytype)); - memset((u8 *)&psta->dot11tkiprxmickey, 0, sizeof(union Keytype)); - memset((u8 *)&psta->dot11tkiptxmickey, 0, sizeof(union Keytype)); - memset((u8 *)&psta->dot11txpn, 0, sizeof(union pn48)); - memset((u8 *)&psta->dot11rxpn, 0, sizeof(union pn48)); - } - /* - * Commented by Albert 2012/07/21 - * When doing the WPS, the wps_ie_len won't equal to 0 - * And the Wi-Fi driver shouldn't allow the data - * packet to be transmitted. - */ - if (padapter->securitypriv.wps_ie_len != 0) { - psta->ieee8021x_blocked = true; - padapter->securitypriv.wps_ie_len = 0; - } - /* for A-MPDU Rx reordering buffer control for bmc_sta & sta_info */ - /* if A-MPDU Rx is enabled, resetting rx_ordering_ctrl wstart_b(indicate_seq) to default value = 0xffff */ - /* todo: check if AP can send A-MPDU packets */ - for (i = 0; i < 16; i++) { - /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ - preorder_ctrl = &psta->recvreorder_ctrl[i]; - preorder_ctrl->enable = false; - preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ - } - bmc_sta = rtw_get_bcmc_stainfo(padapter); - if (bmc_sta) { - for (i = 0; i < 16; i++) { - /* preorder_ctrl = &precvpriv->recvreorder_ctrl[i]; */ - preorder_ctrl = &bmc_sta->recvreorder_ctrl[i]; - preorder_ctrl->enable = false; - preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* max_ampdu_sz; ex. 32(kbytes) -> wsize_b = 32 */ - } - } - /* misc. */ - update_sta_info(padapter, psta); - } - return psta; -} - -/* pnetwork: returns from rtw_joinbss_event_callback */ -/* ptarget_wlan: found from scanned_queue */ -static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - - /* why not use ptarget_wlan?? */ - memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); - /* some ies in pnetwork is wrong, so we should use ptarget_wlan ies */ - cur_network->network.ie_length = ptarget_wlan->network.ie_length; - memcpy(&cur_network->network.ies[0], &ptarget_wlan->network.ies[0], MAX_IE_SZ); - - cur_network->aid = pnetwork->join_res; - - rtw_set_signal_stat_timer(&padapter->recvpriv); - padapter->recvpriv.signal_strength = ptarget_wlan->network.PhyInfo.SignalStrength; - padapter->recvpriv.signal_qual = ptarget_wlan->network.PhyInfo.SignalQuality; - /* the ptarget_wlan->network.Rssi is raw data, we use ptarget_wlan->network.PhyInfo.SignalStrength instead (has scaled) */ - padapter->recvpriv.rssi = translate_percentage_to_dbm(ptarget_wlan->network.PhyInfo.SignalStrength); - rtw_set_signal_stat_timer(&padapter->recvpriv); - - /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ - switch (pnetwork->network.InfrastructureMode) { - case Ndis802_11Infrastructure: - if (pmlmepriv->fw_state & WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; - else - pmlmepriv->fw_state = WIFI_STATION_STATE; - break; - case Ndis802_11IBSS: - pmlmepriv->fw_state = WIFI_ADHOC_STATE; - break; - default: - pmlmepriv->fw_state = WIFI_NULL_STATE; - break; - } - - rtw_update_protection(padapter, (cur_network->network.ies) + - sizeof(struct ndis_802_11_fixed_ie), - (cur_network->network.ie_length)); - rtw_update_ht_cap(padapter, cur_network->network.ies, cur_network->network.ie_length); -} - -/* Notes: the function could be > passive_level (the same context as Rx tasklet) */ -/* pnetwork: returns from rtw_joinbss_event_callback */ -/* ptarget_wlan: found from scanned_queue */ -/* if join_res > 0, for (fw_state == WIFI_STATION_STATE), we check if "ptarget_sta" & "ptarget_wlan" exist. */ -/* if join_res > 0, for (fw_state == WIFI_ADHOC_STATE), we only check if "ptarget_wlan" exist. */ -/* if join_res > 0, update "cur_network->network" from "pnetwork->network" if (ptarget_wlan != NULL). */ - -void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) -{ - struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; - unsigned int the_same_macaddr = false; - - rtw_get_encrypt_decrypt_from_registrypriv(adapter); - - the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); - - pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); - if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) - return; - - spin_lock_bh(&pmlmepriv->lock); - - if (pnetwork->join_res > 0) { - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { - /* s1. find ptarget_wlan */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - if (the_same_macaddr) { - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - } else { - pcur_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if (pcur_wlan) - pcur_wlan->fixed = false; - - pcur_sta = rtw_get_stainfo(pstapriv, cur_network->network.MacAddress); - if (pcur_sta) { - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(adapter, pcur_sta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - } - - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (ptarget_wlan) - ptarget_wlan->fixed = true; - } - } - } else { - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (ptarget_wlan) - ptarget_wlan->fixed = true; - } - } - - /* s2. update cur_network */ - if (ptarget_wlan) { - rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); - } else { - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - goto ignore_joinbss_callback; - } - - /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); - if (!ptarget_sta) { - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - goto ignore_joinbss_callback; - } - } - - /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - rtw_indicate_connect(adapter); - - /* s5. Cancel assoc_timer */ - del_timer_sync(&pmlmepriv->assoc_timer); - } else { - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - goto ignore_joinbss_callback; - } - - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - - } else if (pnetwork->join_res == -4) { - rtw_reset_securitypriv(adapter); - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(1)); - - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - } else { /* if join_res < 0 (join fails), then try again */ - mod_timer(&pmlmepriv->assoc_timer, - jiffies + msecs_to_jiffies(1)); - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - } - -ignore_joinbss_callback: - spin_unlock_bh(&pmlmepriv->lock); -} - -void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) -{ - struct wlan_network *pnetwork = (struct wlan_network *)pbuf; - - mlmeext_joinbss_event_callback(adapter, pnetwork->join_res); - - rtw_os_xmit_schedule(adapter); -} - -static u8 search_max_mac_id(struct adapter *padapter) -{ - u8 mac_id; -#if defined(CONFIG_88EU_AP_MODE) - u8 aid; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; -#endif - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - -#if defined(CONFIG_88EU_AP_MODE) - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - for (aid = pstapriv->max_num_sta; aid > 0; aid--) { - if (pstapriv->sta_aid[aid - 1]) - break; - } - mac_id = aid + 1; - } else -#endif - {/* adhoc id = 31~2 */ - for (mac_id = NUM_STA - 1; mac_id >= IBSS_START_MAC_ID; mac_id--) { - if (pmlmeinfo->FW_sta_info[mac_id].status == 1) - break; - } - } - return mac_id; -} - -/* FOR AP , AD-HOC mode */ -void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta) -{ - u16 media_status; - u8 macid; - - if (!psta) - return; - - macid = search_max_mac_id(adapter); - rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); - media_status = (psta->mac_id << 8) | 1; /* MACID|OPMODE:1 connect */ - rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); -} - -void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) -{ - struct sta_info *psta; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct wlan_network *ptarget_wlan = NULL; - - if (!rtw_access_ctrl(adapter, pstassoc->macaddr)) - return; - -#if defined(CONFIG_88EU_AP_MODE) - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta) { - ap_sta_info_defer_update(adapter, psta); - rtw_stassoc_hw_rpt(adapter, psta); - } - return; - } -#endif - /* for AD-HOC mode */ - psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta) - /* the sta have been in sta_info_queue => do nothing */ - return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ - psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (!psta) - return; - - /* to do: init sta_info variable */ - psta->qos_option = 0; - psta->mac_id = (uint)pstassoc->cam_id; - /* for ad-hoc mode */ - rtw_hal_set_odm_var(adapter, HAL_ODM_STA_INFO, psta, true); - rtw_stassoc_hw_rpt(adapter, psta); - if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - psta->dot118021XPrivacy = adapter->securitypriv.dot11PrivacyAlgrthm; - psta->ieee8021x_blocked = false; - spin_lock_bh(&pmlmepriv->lock); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) { - if (adapter->stapriv.asoc_sta_count == 2) { - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, cur_network->network.MacAddress); - if (ptarget_wlan) - ptarget_wlan->fixed = true; - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - rtw_indicate_connect(adapter); - } - } - spin_unlock_bh(&pmlmepriv->lock); - mlmeext_sta_add_event_callback(adapter, psta); -} - -void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) -{ - int mac_id = -1; - struct sta_info *psta; - struct wlan_network *pwlan = NULL; - struct wlan_bssid_ex *pdev_network = NULL; - u8 *pibss = NULL; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct stadel_event *pstadel = (struct stadel_event *)pbuf; - struct sta_priv *pstapriv = &adapter->stapriv; - struct wlan_network *tgt_network = &pmlmepriv->cur_network; - - psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); - if (psta) - mac_id = psta->mac_id; - else - mac_id = pstadel->mac_id; - - if (mac_id >= 0) { - u16 media_status; - - media_status = (mac_id << 8) | 0; /* MACID|OPMODE:0 means disconnect */ - /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ - rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); - } - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return; - - mlmeext_sta_del_event_callback(adapter); - - spin_lock_bh(&pmlmepriv->lock); - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - if (pmlmepriv->to_roaming > 0) - pmlmepriv->to_roaming--; /* this stadel_event is caused by roaming, decrease to_roaming */ - else if (pmlmepriv->to_roaming == 0) - pmlmepriv->to_roaming = adapter->registrypriv.max_roaming_times; - - if (*((unsigned short *)(pstadel->rsvd)) != WLAN_REASON_EXPIRATION_CHK) - pmlmepriv->to_roaming = 0; /* don't roam */ - - rtw_free_uc_swdec_pending_queue(adapter); - - rtw_free_assoc_resources(adapter); - rtw_indicate_disconnect(adapter); - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - /* remove the network entry in scanned_queue */ - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (pwlan) { - pwlan->fixed = false; - rtw_free_network_nolock(pmlmepriv, pwlan); - } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - _rtw_roaming(adapter, tgt_network); - } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - spin_lock_bh(&pstapriv->sta_hash_lock); - rtw_free_stainfo(adapter, psta); - spin_unlock_bh(&pstapriv->sta_hash_lock); - - if (adapter->stapriv.asoc_sta_count == 1) { /* a sta + bc/mc_stainfo (not Ibss_stainfo) */ - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - /* free old ibss network */ - pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); - if (pwlan) { - pwlan->fixed = false; - rtw_free_network_nolock(pmlmepriv, pwlan); - } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - /* re-create ibss */ - pdev_network = &adapter->registrypriv.dev_network; - pibss = adapter->registrypriv.dev_network.MacAddress; - - memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); - - memcpy(&pdev_network->ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); - - rtw_update_registrypriv_dev_network(adapter); - - rtw_generate_random_ibss(pibss); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - set_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE); - _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); - } - - rtw_createbss_cmd(adapter); - } - } - spin_unlock_bh(&pmlmepriv->lock); -} - -/* - * _rtw_join_timeout_handler - Timeout/failure handler for CMD JoinBss - * @adapter: pointer to struct adapter structure - */ -void _rtw_join_timeout_handler (struct timer_list *t) -{ - struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer); - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - int do_join_r; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) - return; - - spin_lock_bh(&pmlmepriv->lock); - - if (pmlmepriv->to_roaming > 0) { /* join timeout caused by roaming */ - while (1) { - pmlmepriv->to_roaming--; - if (pmlmepriv->to_roaming != 0) { /* try another , */ - do_join_r = rtw_do_join(adapter); - if (do_join_r != _SUCCESS) - continue; - break; - } - rtw_indicate_disconnect(adapter); - break; - } - } else { - rtw_indicate_disconnect(adapter); - free_scanqueue(pmlmepriv);/* */ - } - spin_unlock_bh(&pmlmepriv->lock); -} - -/* - * rtw_scan_timeout_handler - Timeout/Failure handler for CMD SiteSurvey - * @adapter: pointer to struct adapter structure - */ -void rtw_scan_timeout_handler (struct timer_list *t) -{ - struct adapter *adapter = from_timer(adapter, t, - mlmepriv.scan_to_timer); - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->lock); - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - spin_unlock_bh(&pmlmepriv->lock); - rtw_indicate_scan_done(adapter, true); -} - -static void rtw_auto_scan_handler(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - /* auto site survey per 60sec */ - if (pmlmepriv->scan_interval > 0) { - pmlmepriv->scan_interval--; - if (pmlmepriv->scan_interval == 0) { - rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ - } - } -} - -void rtw_dynamic_check_timer_handlder(struct timer_list *t) -{ - struct adapter *adapter = from_timer(adapter, t, - mlmepriv.dynamic_chk_timer); - struct registry_priv *pregistrypriv = &adapter->registrypriv; - - if (!adapter) - return; - if (!adapter->hw_init_completed) - goto exit; - if ((adapter->bDriverStopped) || (adapter->bSurpriseRemoved)) - goto exit; - if (adapter->net_closed) - goto exit; - rtw_dynamic_chk_wk_cmd(adapter); - - if (pregistrypriv->wifi_spec == 1) { - /* auto site survey */ - rtw_auto_scan_handler(adapter); - } -exit: - mod_timer(&adapter->mlmepriv.dynamic_chk_timer, - jiffies + msecs_to_jiffies(2000)); -} - -#define RTW_SCAN_RESULT_EXPIRE 2000 - -/* - * Select a new join candidate from the original @param candidate and @param competitor - * @return true: candidate is updated - * @return false: candidate is not updated - */ -static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv - , struct wlan_network **candidate, struct wlan_network *competitor) -{ - int updated = false; - unsigned long since_scan; - struct adapter *adapter = container_of(pmlmepriv, struct adapter, - mlmepriv); - - /* check bssid, if needed */ - if (pmlmepriv->assoc_by_bssid) { - if (memcmp(competitor->network.MacAddress, pmlmepriv->assoc_bssid, ETH_ALEN)) - goto exit; - } - - /* check ssid, if needed */ - if (pmlmepriv->assoc_ssid.ssid_length) { - if (competitor->network.ssid.ssid_length != pmlmepriv->assoc_ssid.ssid_length || - memcmp(competitor->network.ssid.ssid, pmlmepriv->assoc_ssid.ssid, pmlmepriv->assoc_ssid.ssid_length)) - goto exit; - } - - if (!rtw_is_desired_network(adapter, competitor)) - goto exit; - - if (pmlmepriv->to_roaming) { - since_scan = jiffies - competitor->last_scanned; - if (jiffies_to_msecs(since_scan) >= RTW_SCAN_RESULT_EXPIRE || - !is_same_ess(&competitor->network, &pmlmepriv->cur_network.network)) - goto exit; - } - - if (!*candidate || (*candidate)->network.Rssi < competitor->network.Rssi) { - *candidate = competitor; - updated = true; - } - -exit: - return updated; -} - -/* - * Calling context: - * The caller of the sub-routine will be in critical section... - * The caller must hold the following spinlock - * pmlmepriv->lock - */ - -int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) -{ - int ret; - struct list_head *phead; - struct adapter *adapter = container_of(pmlmepriv, struct adapter, mlmepriv); - struct __queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - struct wlan_network *candidate = NULL; - u8 supp_ant_div = false; - - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - phead = get_list_head(queue); - list_for_each(pmlmepriv->pscanned, phead) { - pnetwork = list_entry(pmlmepriv->pscanned, - struct wlan_network, list); - rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); - } - if (!candidate) { - ret = _FAIL; - goto exit; - } - - /* check for situation of _FW_LINKED */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - rtw_disassoc_cmd(adapter, 0, true); - rtw_indicate_disconnect(adapter); - rtw_free_assoc_resources_locked(adapter); - } - - rtw_hal_get_def_var(adapter, HAL_DEF_IS_SUPPORT_ANT_DIV, &(supp_ant_div)); - if (supp_ant_div) { - u8 cur_ant; - - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(cur_ant)); - } - - ret = rtw_joinbss_cmd(adapter, candidate); - -exit: - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - return ret; -} - -int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) -{ - struct cmd_obj *pcmd; - struct setauth_parm *psetauthparm; - struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - int res = _SUCCESS; - - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd) { - res = _FAIL; /* try again */ - goto exit; - } - - psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL); - if (!psetauthparm) { - kfree(pcmd); - res = _FAIL; - goto exit; - } - psetauthparm->mode = (unsigned char)psecuritypriv->dot11AuthAlgrthm; - pcmd->cmdcode = _SetAuth_CMD_; - pcmd->parmbuf = (unsigned char *)psetauthparm; - pcmd->cmdsz = sizeof(struct setauth_parm); - pcmd->rsp = NULL; - pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); - res = rtw_enqueue_cmd(pcmdpriv, pcmd); -exit: - return res; -} - -int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, int keyid, u8 set_tx) -{ - u8 keylen; - struct cmd_obj *pcmd; - struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv = &adapter->cmdpriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - int res = _SUCCESS; - - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd) - return _FAIL; /* try again */ - - psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); - if (!psetkeyparm) { - res = _FAIL; - goto err_free_cmd; - } - - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) - psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; - else - psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; - psetkeyparm->keyid = (u8)keyid;/* 0~3 */ - psetkeyparm->set_tx = set_tx; - pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); - - switch (psetkeyparm->algorithm) { - case _WEP40_: - keylen = 5; - memcpy(&psetkeyparm->key[0], - &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); - break; - case _WEP104_: - keylen = 13; - memcpy(&psetkeyparm->key[0], - &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); - break; - case _TKIP_: - keylen = 16; - memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); - psetkeyparm->grpkey = 1; - break; - case _AES_: - keylen = 16; - memcpy(&psetkeyparm->key, &psecuritypriv->dot118021XGrpKey[keyid], keylen); - psetkeyparm->grpkey = 1; - break; - default: - res = _FAIL; - goto err_free_parm; - } - pcmd->cmdcode = _SetKey_CMD_; - pcmd->parmbuf = (u8 *)psetkeyparm; - pcmd->cmdsz = sizeof(struct setkey_parm); - pcmd->rsp = NULL; - pcmd->rspsz = 0; - INIT_LIST_HEAD(&pcmd->list); - return rtw_enqueue_cmd(pcmdpriv, pcmd); - -err_free_parm: - kfree(psetkeyparm); -err_free_cmd: - kfree(pcmd); - return res; -} - -/* adjust ies for rtw_joinbss_cmd in WMM */ -int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len, uint initial_out_len) -{ - unsigned int ielength = 0; - unsigned int i, j; - - /* i = 12; after the fixed IE */ - for (i = 12; i < in_len; i += (in_ie[i + 1] + 2) /* to the next IE element */) { - ielength = initial_out_len; - - if (in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 && in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 && in_ie[i + 5] == 0x02 && i + 5 < in_len) { - /* WMM element ID and OUI */ - /* Append WMM IE to the last index of out_ie */ - - for (j = i; j < i + 9; j++) { - out_ie[ielength] = in_ie[j]; - ielength++; - } - out_ie[initial_out_len + 1] = 0x07; - out_ie[initial_out_len + 6] = 0x00; - out_ie[initial_out_len + 8] = 0x00; - break; - } - } - return ielength; -} - -/* - * Ported from 8185: IsInPreAuthKeyList(). - * (Renamed from SecIsInPreAuthKeyList(), 2006-10-13.) - * Added by Annie, 2006-05-07. - * Search by BSSID, - * Return Value: - * -1 :if there is no pre-auth key in the table - * >= 0 :if there is pre-auth key, and return the entry id - */ -static int SecIsInPMKIDList(struct adapter *Adapter, u8 *bssid) -{ - struct security_priv *psecuritypriv = &Adapter->securitypriv; - int i = 0; - - do { - if ((psecuritypriv->PMKIDList[i].used) && - (!memcmp(psecuritypriv->PMKIDList[i].bssid, bssid, ETH_ALEN))) - break; - } while (++i < NUM_PMKID_CACHE); - - if (i == NUM_PMKID_CACHE) - i = -1;/* Could not find. */ - - return i; -} - -/* */ -/* Check the RSN IE length */ -/* If the RSN IE length <= 20, the RSN IE didn't include the PMKID information */ -/* 0-11th element in the array are the fixed IE */ -/* 12th element in the array is the IE */ -/* 13th element in the array is the IE length */ -/* */ - -static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie_len) -{ - struct security_priv *psecuritypriv = &Adapter->securitypriv; - - if (ie[13] <= 20) { - /* The RSN IE didn't include the PMK ID, append the PMK information */ - ie[ie_len] = 1; - ie_len++; - ie[ie_len] = 0; /* PMKID count = 0x0100 */ - ie_len++; - memcpy(&ie[ie_len], &psecuritypriv->PMKIDList[iEntry].PMKID, 16); - - ie_len += 16; - ie[13] += 18;/* PMKID length = 2+16 */ - } - return ie_len; -} - -int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) -{ - u8 authmode; - uint ielength; - int iEntry; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - struct security_priv *psecuritypriv = &adapter->securitypriv; - uint ndisauthmode = psecuritypriv->ndisauthtype; - - /* copy fixed ie only */ - memcpy(out_ie, in_ie, 12); - ielength = 12; - if ((ndisauthmode == Ndis802_11AuthModeWPA) || - (ndisauthmode == Ndis802_11AuthModeWPAPSK)) - authmode = WLAN_EID_VENDOR_SPECIFIC; - else if ((ndisauthmode == Ndis802_11AuthModeWPA2) || - (ndisauthmode == Ndis802_11AuthModeWPA2PSK)) - authmode = WLAN_EID_RSN; - else - authmode = 0x0; - - if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); - - ielength += psecuritypriv->wps_ie_len; - } else if ((authmode == WLAN_EID_VENDOR_SPECIFIC) || (authmode == WLAN_EID_RSN)) { - /* copy RSN or SSN */ - memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); - ielength += psecuritypriv->supplicant_ie[1] + 2; - rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie); - } - - iEntry = SecIsInPMKIDList(adapter, pmlmepriv->assoc_bssid); - if (iEntry >= 0 && authmode == WLAN_EID_RSN) - ielength = rtw_append_pmkid(adapter, iEntry, out_ie, ielength); - - return ielength; -} - -void rtw_init_registrypriv_dev_network(struct adapter *adapter) -{ - struct registry_priv *pregistrypriv = &adapter->registrypriv; - struct eeprom_priv *peepriv = &adapter->eeprompriv; - struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; - u8 *myhwaddr = myid(peepriv); - - memcpy(pdev_network->MacAddress, myhwaddr, ETH_ALEN); - - memcpy(&pdev_network->ssid, &pregistrypriv->ssid, sizeof(struct ndis_802_11_ssid)); - - pdev_network->Configuration.Length = sizeof(struct ndis_802_11_config); - pdev_network->Configuration.BeaconPeriod = 100; - pdev_network->Configuration.FHConfig.Length = 0; - pdev_network->Configuration.FHConfig.HopPattern = 0; - pdev_network->Configuration.FHConfig.HopSet = 0; - pdev_network->Configuration.FHConfig.DwellTime = 0; -} - -void rtw_update_registrypriv_dev_network(struct adapter *adapter) -{ - int sz = 0; - struct registry_priv *pregistrypriv = &adapter->registrypriv; - struct wlan_bssid_ex *pdev_network = &pregistrypriv->dev_network; - struct security_priv *psecuritypriv = &adapter->securitypriv; - struct wlan_network *cur_network = &adapter->mlmepriv.cur_network; - - pdev_network->Privacy = psecuritypriv->dot11PrivacyAlgrthm > 0 ? 1 : 0; /* adhoc no 802.1x */ - - pdev_network->Rssi = 0; - - switch (pregistrypriv->wireless_mode) { - case WIRELESS_11B: - pdev_network->NetworkTypeInUse = Ndis802_11DS; - break; - case WIRELESS_11G: - case WIRELESS_11BG: - case WIRELESS_11_24N: - case WIRELESS_11G_24N: - case WIRELESS_11BG_24N: - pdev_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - default: - pdev_network->NetworkTypeInUse = Ndis802_11OFDM24; - break; - } - - pdev_network->Configuration.DSConfig = pregistrypriv->channel; - - if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) - pdev_network->Configuration.ATIMWindow = 0; - - pdev_network->InfrastructureMode = cur_network->network.InfrastructureMode; - - /* 1. Supported rates */ - /* 2. IE */ - - sz = rtw_generate_ie(pregistrypriv); - pdev_network->ie_length = sz; - pdev_network->Length = get_wlan_bssid_ex_sz(pdev_network); - - /* notes: translate ie_length & Length after assign the Length to cmdsz in createbss_cmd(); */ - /* pdev_network->ie_length = cpu_to_le32(sz); */ -} - -void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter) -{ -} - -/* the function is at passive_level */ -void rtw_joinbss_reset(struct adapter *padapter) -{ - u8 threshold; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - - /* todo: if you want to do something io/reg/hw setting before join_bss, please add code here */ - pmlmepriv->num_FortyMHzIntolerant = 0; - - pmlmepriv->num_sta_no_ht = 0; - - phtpriv->ampdu_enable = false;/* reset to disabled */ - - /* TH = 1 => means that invalidate usb rx aggregation */ - /* TH = 0 => means that validate usb rx aggregation, use init value. */ - if (phtpriv->ht_option) { - if (padapter->registrypriv.wifi_spec == 1) - threshold = 1; - else - threshold = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } else { - threshold = 1; - rtw_hal_set_hwreg(padapter, HW_VAR_RXDMA_AGG_PG_TH, (u8 *)(&threshold)); - } -} - -/* the function is >= passive_level */ -unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ie, uint in_len, uint *pout_len) -{ - u32 ielen, out_len; - enum ht_cap_ampdu_factor max_rx_ampdu_factor; - unsigned char *p; - unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01, 0x00}; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - u32 rx_packet_offset, max_recvbuf_sz; - - phtpriv->ht_option = false; - - p = rtw_get_ie(in_ie + 12, WLAN_EID_HT_CAPABILITY, &ielen, in_len - 12); - - if (p && ielen > 0) { - struct ieee80211_ht_cap ht_cap; - - if (pqospriv->qos_option == 0) { - out_len = *pout_len; - rtw_set_ie(out_ie + out_len, WLAN_EID_VENDOR_SPECIFIC, - _WMM_IE_Length_, WMM_IE, pout_len); - - pqospriv->qos_option = 1; - } - - out_len = *pout_len; - - memset(&ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - - ht_cap.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 | - IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40 | - IEEE80211_HT_CAP_TX_STBC | - IEEE80211_HT_CAP_DSSSCCK40); - - rtw_hal_get_def_var(padapter, HAL_DEF_RX_PACKET_OFFSET, &rx_packet_offset); - rtw_hal_get_def_var(padapter, HAL_DEF_MAX_RECVBUF_SZ, &max_recvbuf_sz); - - /* - * ampdu_params_info [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k - * ampdu_params_info [4:2]:Min MPDU Start Spacing - */ - - rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); - ht_cap.ampdu_params_info = max_rx_ampdu_factor & 0x03; - - if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) - ht_cap.ampdu_params_info |= IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2); - else - ht_cap.ampdu_params_info |= IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00; - - rtw_set_ie(out_ie + out_len, WLAN_EID_HT_CAPABILITY, - sizeof(struct ieee80211_ht_cap), - (unsigned char *)&ht_cap, pout_len); - - phtpriv->ht_option = true; - - p = rtw_get_ie(in_ie + 12, WLAN_EID_HT_OPERATION, &ielen, in_len - 12); - if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { - out_len = *pout_len; - rtw_set_ie(out_ie + out_len, WLAN_EID_HT_OPERATION, ielen, p + 2, pout_len); - } - } - return phtpriv->ht_option; -} - -/* the function is > passive_level (in critical_section) */ -void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (!phtpriv->ht_option) - return; - - if ((!pmlmeinfo->HT_info_enable) || (!pmlmeinfo->HT_caps_enable)) - return; - - /* maybe needs check if ap supports rx ampdu. */ - if ((!phtpriv->ampdu_enable) && (pregistrypriv->ampdu_enable == 1)) { - if (pregistrypriv->wifi_spec == 1) - phtpriv->ampdu_enable = false; - else - phtpriv->ampdu_enable = true; - } else if (pregistrypriv->ampdu_enable == 2) { - phtpriv->ampdu_enable = true; - } - - /* update cur_bwmode & cur_ch_offset */ - if ((pregistrypriv->cbw40_enable) && - (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & BIT(1)) && - (pmlmeinfo->HT_info.infos[0] & BIT(2))) { - int i; - - /* update the MCS rates */ - for (i = 0; i < 16; i++) - ((u8 *)&pmlmeinfo->HT_caps.mcs)[i] &= MCS_rate_1R[i]; - /* switch to the 40M Hz mode according to the AP */ - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; - switch ((pmlmeinfo->HT_info.infos[0] & 0x3)) { - case HT_EXTCHNL_OFFSET_UPPER: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; - case HT_EXTCHNL_OFFSET_LOWER: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; - default: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; - } - } - - /* Config SM Power Save setting */ - pmlmeinfo->SM_PS = (le16_to_cpu(pmlmeinfo->HT_caps.cap_info) & 0x0C) >> 2; - - /* Config current HT Protection mode. */ - pmlmeinfo->HT_protection = pmlmeinfo->HT_info.infos[1] & 0x3; -} - -void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - u8 issued; - int priority; - struct sta_info *psta = NULL; - struct ht_priv *phtpriv; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - - if (is_multicast_ether_addr(pattrib->ra) || - padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) - return; - - priority = pattrib->priority; - - if (pattrib->psta) - psta = pattrib->psta; - else - psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - - if (!psta) - return; - - phtpriv = &psta->htpriv; - - if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { - issued = (phtpriv->agg_enable_bitmap >> priority) & 0x1; - issued |= (phtpriv->candidate_tid_bitmap >> priority) & 0x1; - - if (issued == 0) { - psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); - rtw_addbareq_cmd(padapter, (u8)priority, pattrib->ra); - } - } -} - -void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - spin_lock_bh(&pmlmepriv->lock); - _rtw_roaming(padapter, tgt_network); - spin_unlock_bh(&pmlmepriv->lock); -} - -void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int do_join_r; - struct wlan_network *pnetwork; - - if (tgt_network) - pnetwork = tgt_network; - else - pnetwork = &pmlmepriv->cur_network; - - if (pmlmepriv->to_roaming > 0) { - memcpy(&pmlmepriv->assoc_ssid, &pnetwork->network.ssid, sizeof(struct ndis_802_11_ssid)); - - pmlmepriv->assoc_by_bssid = false; - - while (1) { - do_join_r = rtw_do_join(padapter); - if (do_join_r == _SUCCESS) - break; - - pmlmepriv->to_roaming--; - - if (pmlmepriv->to_roaming > 0) { - continue; - } else { - rtw_indicate_disconnect(padapter); - break; - } - } - } -} diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c b/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c deleted file mode 100644 index b1fe30e9a2b4..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_mlme_ext.c +++ /dev/null @@ -1,5171 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_MLME_EXT_C_ - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -static u8 null_addr[ETH_ALEN] = {}; - -/* OUI definitions for the vendor specific IE */ -const u8 RTW_WPA_OUI[] = {0x00, 0x50, 0xf2, 0x01}; -const u8 WPS_OUI[] = {0x00, 0x50, 0xf2, 0x04}; -static const u8 WMM_OUI[] = {0x00, 0x50, 0xf2, 0x02}; -static const u8 P2P_OUI[] = {0x50, 0x6F, 0x9A, 0x09}; - -static const u8 WMM_PARA_OUI[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; - -const u8 WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; -const u8 RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; - -/* MCS rate definitions */ -const u8 MCS_rate_1R[16] = { - 0xff, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 -}; - -/* ChannelPlan definitions */ -static struct rt_channel_plan_2g RTW_ChannelPlan2G[RT_CHANNEL_DOMAIN_2G_MAX] = { - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x00, RT_CHANNEL_DOMAIN_2G_WORLD , Passive scan CH 12, 13 */ - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, /* 0x01, RT_CHANNEL_DOMAIN_2G_ETSI1 */ - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, /* 0x02, RT_CHANNEL_DOMAIN_2G_FCC1 */ - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, /* 0x03, RT_CHANNEL_DOMAIN_2G_MIKK1 */ - {{10, 11, 12, 13}, 4}, /* 0x04, RT_CHANNEL_DOMAIN_2G_ETSI2 */ - {{}, 0}, /* 0x05, RT_CHANNEL_DOMAIN_2G_NULL */ -}; - -static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { - /* 0x00 ~ 0x1F , Old Define ===== */ - {0x02}, /* 0x00, RT_CHANNEL_DOMAIN_FCC */ - {0x02}, /* 0x01, RT_CHANNEL_DOMAIN_IC */ - {0x01}, /* 0x02, RT_CHANNEL_DOMAIN_ETSI */ - {0x01}, /* 0x03, RT_CHANNEL_DOMAIN_SPAIN */ - {0x01}, /* 0x04, RT_CHANNEL_DOMAIN_FRANCE */ - {0x03}, /* 0x05, RT_CHANNEL_DOMAIN_MKK */ - {0x03}, /* 0x06, RT_CHANNEL_DOMAIN_MKK1 */ - {0x01}, /* 0x07, RT_CHANNEL_DOMAIN_ISRAEL */ - {0x03}, /* 0x08, RT_CHANNEL_DOMAIN_TELEC */ - {0x03}, /* 0x09, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN */ - {0x00}, /* 0x0A, RT_CHANNEL_DOMAIN_WORLD_WIDE_13 */ - {0x02}, /* 0x0B, RT_CHANNEL_DOMAIN_TAIWAN */ - {0x01}, /* 0x0C, RT_CHANNEL_DOMAIN_CHINA */ - {0x02}, /* 0x0D, RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO */ - {0x02}, /* 0x0E, RT_CHANNEL_DOMAIN_KOREA */ - {0x02}, /* 0x0F, RT_CHANNEL_DOMAIN_TURKEY */ - {0x01}, /* 0x10, RT_CHANNEL_DOMAIN_JAPAN */ - {0x02}, /* 0x11, RT_CHANNEL_DOMAIN_FCC_NO_DFS */ - {0x01}, /* 0x12, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ - {0x00}, /* 0x13, RT_CHANNEL_DOMAIN_WORLD_WIDE_5G */ - {0x02}, /* 0x14, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS */ - {0x00}, /* 0x15, RT_CHANNEL_DOMAIN_ETSI_NO_DFS */ - {0x00}, /* 0x16, RT_CHANNEL_DOMAIN_KOREA_NO_DFS */ - {0x03}, /* 0x17, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ - {0x05}, /* 0x18, RT_CHANNEL_DOMAIN_PAKISTAN_NO_DFS */ - {0x02}, /* 0x19, RT_CHANNEL_DOMAIN_TAIWAN2_NO_DFS */ - {0x00}, /* 0x1A, */ - {0x00}, /* 0x1B, */ - {0x00}, /* 0x1C, */ - {0x00}, /* 0x1D, */ - {0x00}, /* 0x1E, */ - {0x05}, /* 0x1F, RT_CHANNEL_DOMAIN_WORLD_WIDE_ONLY_5G */ - /* 0x20 ~ 0x7F , New Define ===== */ - {0x00}, /* 0x20, RT_CHANNEL_DOMAIN_WORLD_NULL */ - {0x01}, /* 0x21, RT_CHANNEL_DOMAIN_ETSI1_NULL */ - {0x02}, /* 0x22, RT_CHANNEL_DOMAIN_FCC1_NULL */ - {0x03}, /* 0x23, RT_CHANNEL_DOMAIN_MKK1_NULL */ - {0x04}, /* 0x24, RT_CHANNEL_DOMAIN_ETSI2_NULL */ - {0x02}, /* 0x25, RT_CHANNEL_DOMAIN_FCC1_FCC1 */ - {0x00}, /* 0x26, RT_CHANNEL_DOMAIN_WORLD_ETSI1 */ - {0x03}, /* 0x27, RT_CHANNEL_DOMAIN_MKK1_MKK1 */ - {0x00}, /* 0x28, RT_CHANNEL_DOMAIN_WORLD_KCC1 */ - {0x00}, /* 0x29, RT_CHANNEL_DOMAIN_WORLD_FCC2 */ - {0x00}, /* 0x2A, */ - {0x00}, /* 0x2B, */ - {0x00}, /* 0x2C, */ - {0x00}, /* 0x2D, */ - {0x00}, /* 0x2E, */ - {0x00}, /* 0x2F, */ - {0x00}, /* 0x30, RT_CHANNEL_DOMAIN_WORLD_FCC3 */ - {0x00}, /* 0x31, RT_CHANNEL_DOMAIN_WORLD_FCC4 */ - {0x00}, /* 0x32, RT_CHANNEL_DOMAIN_WORLD_FCC5 */ - {0x00}, /* 0x33, RT_CHANNEL_DOMAIN_WORLD_FCC6 */ - {0x02}, /* 0x34, RT_CHANNEL_DOMAIN_FCC1_FCC7 */ - {0x00}, /* 0x35, RT_CHANNEL_DOMAIN_WORLD_ETSI2 */ - {0x00}, /* 0x36, RT_CHANNEL_DOMAIN_WORLD_ETSI3 */ - {0x03}, /* 0x37, RT_CHANNEL_DOMAIN_MKK1_MKK2 */ - {0x03}, /* 0x38, RT_CHANNEL_DOMAIN_MKK1_MKK3 */ - {0x02}, /* 0x39, RT_CHANNEL_DOMAIN_FCC1_NCC1 */ - {0x00}, /* 0x3A, */ - {0x00}, /* 0x3B, */ - {0x00}, /* 0x3C, */ - {0x00}, /* 0x3D, */ - {0x00}, /* 0x3E, */ - {0x00}, /* 0x3F, */ - {0x02}, /* 0x40, RT_CHANNEL_DOMAIN_FCC1_NCC2 */ - {0x03}, /* 0x41, RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G */ -}; - -static const struct rt_channel_plan_map RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE = { - 0x03 -}; /* use the combination for max channel numbers */ - -/* - * Search the @param channel_num in given @param channel_set - * @ch_set: the given channel set - * @ch: the given channel number - * - * return the index of channel_num in channel_set, -1 if not found - */ -int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch) -{ - int i; - - for (i = 0; ch_set[i].ChannelNum != 0; i++) { - if (ch == ch_set[i].ChannelNum) - break; - } - - if (i >= ch_set[i].ChannelNum) - return -1; - return i; -} - -struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) -{ - struct xmit_frame *pmgntframe; - struct xmit_buf *pxmitbuf; - - pmgntframe = rtw_alloc_xmitframe(pxmitpriv); - if (!pmgntframe) - return NULL; - - pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv); - if (!pxmitbuf) { - rtw_free_xmitframe(pxmitpriv, pmgntframe); - return NULL; - } - pmgntframe->frame_tag = MGNT_FRAMETAG; - pmgntframe->pxmitbuf = pxmitbuf; - pmgntframe->buf_addr = pxmitbuf->pbuf; - pxmitbuf->priv_data = pmgntframe; - return pmgntframe; -} - -/**************************************************************************** - -Following are some TX functions for WiFi MLME - -*****************************************************************************/ - -void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - pmlmeext->tx_rate = rate; -} - -void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); - - pattrib->hdrlen = 24; - pattrib->nr_frags = 1; - pattrib->priority = 7; - pattrib->mac_id = 0; - pattrib->qsel = 0x12; - - pattrib->pktlen = 0; - - if (pmlmeext->cur_wireless_mode & WIRELESS_11B) - pattrib->raid = 6;/* b mode */ - else - pattrib->raid = 5;/* a/g mode */ - - pattrib->encrypt = _NO_PRIVACY_; - pattrib->bswenc = false; - - pattrib->qos_en = false; - pattrib->ht_en = false; - pattrib->bwmode = HT_CHANNEL_WIDTH_20; - pattrib->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pattrib->sgi = false; - - pattrib->seqnum = pmlmeext->mgnt_seq; - - pattrib->retry_ctrl = true; -} - -static void dump_mgntframe(struct adapter *padapter, - struct xmit_frame *pmgntframe) -{ - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return; - - rtw_hal_mgnt_xmit(padapter, pmgntframe); -} - -static s32 dump_mgntframe_and_wait(struct adapter *padapter, - struct xmit_frame *pmgntframe, - int timeout_ms) -{ - s32 ret = _FAIL; - struct xmit_buf *pxmitbuf = pmgntframe->pxmitbuf; - struct submit_ctx sctx; - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return ret; - - rtw_sctx_init(&sctx, timeout_ms); - pxmitbuf->sctx = &sctx; - - ret = rtw_hal_mgnt_xmit(padapter, pmgntframe); - - if (ret == _SUCCESS) - ret = rtw_sctx_wait(&sctx); - - return ret; -} - -static s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, - struct xmit_frame *pmgntframe) -{ - s32 ret = _FAIL; - u32 timeout_ms = 500;/* 500ms */ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return -1; - - if (mutex_lock_interruptible(&pxmitpriv->ack_tx_mutex)) - return _FAIL; - pxmitpriv->ack_tx = true; - - pmgntframe->ack_report = 1; - if (rtw_hal_mgnt_xmit(padapter, pmgntframe) == _SUCCESS) - ret = rtw_ack_tx_wait(pxmitpriv, timeout_ms); - - pxmitpriv->ack_tx = false; - mutex_unlock(&pxmitpriv->ack_tx_mutex); - - return ret; -} - -static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) -{ - u8 *ssid_ie; - uint ssid_len_ori; - int len_diff = 0; - - ssid_ie = rtw_get_ie(ies, WLAN_EID_SSID, &ssid_len_ori, ies_len); - - if (ssid_ie && ssid_len_ori > 0) { - switch (hidden_ssid_mode) { - case 1: { - u8 *next_ie = ssid_ie + 2 + ssid_len_ori; - u32 remain_len = 0; - - remain_len = ies_len - (next_ie - ies); - - ssid_ie[1] = 0; - memcpy(ssid_ie + 2, next_ie, remain_len); - len_diff -= ssid_len_ori; - - break; - } - case 2: - memset(&ssid_ie[2], 0, ssid_len_ori); - break; - default: - break; - } - } - - return len_diff; -} - -static void issue_beacon(struct adapter *padapter, int timeout_ms) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned int rate_len; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; -#if defined(CONFIG_88EU_AP_MODE) - spin_lock_bh(&pmlmepriv->bcn_update_lock); -#endif - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - pattrib->qsel = 0x10; - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - eth_broadcast_addr(pwlanhdr->addr1); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress); - - SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); - /* pmlmeext->mgnt_seq++; */ - SetFrameSubType(pframe, IEEE80211_STYPE_BEACON); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { - int len_diff; - u8 *wps_ie; - uint wps_ielen; - u8 sr = 0; - - memcpy(pframe, cur_network->ies, cur_network->ie_length); - len_diff = update_hidden_ssid( - pframe + _BEACON_IE_OFFSET_ - , cur_network->ie_length - _BEACON_IE_OFFSET_ - , pmlmeinfo->hidden_ssid_mode - ); - pframe += (cur_network->ie_length + len_diff); - pattrib->pktlen += (cur_network->ie_length + len_diff); - wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, - pattrib->pktlen - sizeof(struct ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_, NULL, &wps_ielen); - if (wps_ie && wps_ielen > 0) - rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); - if (sr != 0) - set_fwstate(pmlmepriv, WIFI_UNDER_WPS); - else - _clr_fwstate_(pmlmepriv, WIFI_UNDER_WPS); - - goto _issue_bcn; - } - - /* below for ad-hoc mode */ - - /* timestamp will be inserted by hardware */ - pframe += 8; - pattrib->pktlen += 8; - - /* beacon interval: 2 bytes */ - - memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->ies)), 2); - - pframe += 2; - pattrib->pktlen += 2; - - /* capability info: 2 bytes */ - - memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->ies)), 2); - - pframe += 2; - pattrib->pktlen += 2; - - /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); - - /* supported rates... */ - rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); - - /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); - - { - u8 erpinfo = 0; - u32 ATIMWindow; - /* IBSS Parameter Set... */ - ATIMWindow = 0; - pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); - - /* ERP IE */ - pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); - } - - /* EXTERNDED SUPPORTED RATE */ - if (rate_len > 8) - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); - /* todo:HT for adhoc */ -_issue_bcn: - -#if defined(CONFIG_88EU_AP_MODE) - pmlmepriv->update_bcn = false; - - spin_unlock_bh(&pmlmepriv->bcn_update_lock); -#endif - - if ((pattrib->pktlen + TXDESC_SIZE) > 512) - return; - - pattrib->last_txcmdsz = pattrib->pktlen; - - if (timeout_ms > 0) - dump_mgntframe_and_wait(padapter, pmgntframe, timeout_ms); - else - dump_mgntframe(padapter, pmgntframe); -} - -static void issue_probersp(struct adapter *padapter, unsigned char *da) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned char *mac, *bssid; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -#if defined(CONFIG_88EU_AP_MODE) - u8 *pwps_ie; - uint wps_ielen; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - unsigned int rate_len; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&padapter->eeprompriv); - bssid = cur_network->MacAddress; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, mac); - ether_addr_copy(pwlanhdr->addr3, bssid); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(fctrl, IEEE80211_STYPE_PROBE_RESP); - - pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = pattrib->hdrlen; - pframe += pattrib->hdrlen; - - if (cur_network->ie_length > MAX_IE_SZ) - return; - -#if defined(CONFIG_88EU_AP_MODE) - if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { - pwps_ie = rtw_get_wps_ie(cur_network->ies + _FIXED_IE_LENGTH_, cur_network->ie_length - _FIXED_IE_LENGTH_, NULL, &wps_ielen); - - /* inerset & update wps_probe_resp_ie */ - if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) { - uint wps_offset, remainder_ielen; - u8 *premainder_ie; - - wps_offset = (uint)(pwps_ie - cur_network->ies); - - premainder_ie = pwps_ie + wps_ielen; - - remainder_ielen = cur_network->ie_length - wps_offset - wps_ielen; - - memcpy(pframe, cur_network->ies, wps_offset); - pframe += wps_offset; - pattrib->pktlen += wps_offset; - - wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */ - if ((wps_offset + wps_ielen + 2) <= MAX_IE_SZ) { - memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen + 2); - pframe += wps_ielen + 2; - pattrib->pktlen += wps_ielen + 2; - } - - if ((wps_offset + wps_ielen + 2 + remainder_ielen) <= MAX_IE_SZ) { - memcpy(pframe, premainder_ie, remainder_ielen); - pframe += remainder_ielen; - pattrib->pktlen += remainder_ielen; - } - } else { - memcpy(pframe, cur_network->ies, cur_network->ie_length); - pframe += cur_network->ie_length; - pattrib->pktlen += cur_network->ie_length; - } - } else -#endif - { - /* timestamp will be inserted by hardware */ - pframe += 8; - pattrib->pktlen += 8; - - /* beacon interval: 2 bytes */ - - memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->ies)), 2); - - pframe += 2; - pattrib->pktlen += 2; - - /* capability info: 2 bytes */ - - memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->ies)), 2); - - pframe += 2; - pattrib->pktlen += 2; - - /* below for ad-hoc mode */ - - /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pattrib->pktlen); - - /* supported rates... */ - rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, min_t(unsigned int, rate_len, 8), cur_network->SupportedRates, &pattrib->pktlen); - - /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - u8 erpinfo = 0; - u32 ATIMWindow; - /* IBSS Parameter Set... */ - /* ATIMWindow = cur->Configuration.ATIMWindow; */ - ATIMWindow = 0; - pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pattrib->pktlen); - - /* ERP IE */ - pframe = rtw_set_ie(pframe, WLAN_EID_ERP_INFO, 1, &erpinfo, &pattrib->pktlen); - } - - /* EXTERNDED SUPPORTED RATE */ - if (rate_len > 8) - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pattrib->pktlen); - /* todo:HT for adhoc */ - } - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - -static int issue_probereq(struct adapter *padapter, - struct ndis_802_11_ssid *pssid, u8 *da, - bool wait_ack) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned char *mac; - unsigned char bssrate[NumRates]; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - int bssrate_len = 0; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&padapter->eeprompriv); - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - if (da) { - /* unicast probe request frame */ - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr3, da); - } else { - /* broadcast probe request frame */ - eth_broadcast_addr(pwlanhdr->addr1); - eth_broadcast_addr(pwlanhdr->addr3); - } - - ether_addr_copy(pwlanhdr->addr2, mac); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_STYPE_PROBE_REQ); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - if (pssid) - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pssid->ssid_length, pssid->ssid, &pattrib->pktlen); - else - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, 0, NULL, &pattrib->pktlen); - - get_rate_set(padapter, bssrate, &bssrate_len); - - if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); - } else { - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); - } - - /* add wps_ie for wps2.0 */ - if (pmlmepriv->wps_probe_req_ie_len > 0 && pmlmepriv->wps_probe_req_ie) { - memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); - pframe += pmlmepriv->wps_probe_req_ie_len; - pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; - } - - pattrib->last_txcmdsz = pattrib->pktlen; - - if (wait_ack) { - ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else { - dump_mgntframe(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -static int issue_probereq_ex(struct adapter *padapter, - struct ndis_802_11_ssid *pssid, u8 *da, - int try_cnt, int wait_ms) -{ - int ret; - int i = 0; - - do { - ret = issue_probereq(padapter, pssid, da, wait_ms > 0); - - i++; - - if (padapter->bDriverStopped || padapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - msleep(wait_ms); - - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); - - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } -exit: - return ret; -} - -/* if psta == NULL, indicate we are station(client) now... */ -static void issue_auth(struct adapter *padapter, struct sta_info *psta, - unsigned short status) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned int val32; - u16 val16; -#ifdef CONFIG_88EU_AP_MODE - __le16 le_val16; -#endif - int use_shared_key = 0; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_STYPE_AUTH); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - if (psta) {/* for AP mode */ -#ifdef CONFIG_88EU_AP_MODE - - ether_addr_copy(pwlanhdr->addr1, psta->hwaddr); - ether_addr_copy(pwlanhdr->addr2, - myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, - myid(&padapter->eeprompriv)); - - /* setting auth algo number */ - val16 = (u16)psta->authalg; - - if (status != WLAN_STATUS_SUCCESS) - val16 = 0; - - if (val16) { - le_val16 = cpu_to_le16(val16); - use_shared_key = 1; - } else { - le_val16 = 0; - } - - pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, &le_val16, - &pattrib->pktlen); - - /* setting auth seq number */ - val16 = (u16)psta->auth_seq; - le_val16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, &le_val16, - &pattrib->pktlen); - - /* setting status code... */ - val16 = status; - le_val16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, - &le_val16, &pattrib->pktlen); - - /* added challenging text... */ - if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) - pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, psta->chg_txt, &pattrib->pktlen); -#endif - } else { - __le32 le_tmp32; - __le16 le_tmp16; - - ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - - /* setting auth algo number */ - val16 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) ? 1 : 0;/* 0:OPEN System, 1:Shared key */ - if (val16) - use_shared_key = 1; - - /* setting IV for auth seq #3 */ - if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - val32 = (pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30); - le_tmp32 = cpu_to_le32(val32); - pframe = rtw_set_fixed_ie(pframe, 4, &le_tmp32, - &pattrib->pktlen); - - pattrib->iv_len = 4; - } - - le_tmp16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, &le_tmp16, - &pattrib->pktlen); - - /* setting auth seq number */ - val16 = pmlmeinfo->auth_seq; - le_tmp16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, &le_tmp16, - &pattrib->pktlen); - - /* setting status code... */ - le_tmp16 = cpu_to_le16(status); - pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, &le_tmp16, - &pattrib->pktlen); - - /* then checking to see if sending challenging text... */ - if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie(pframe, WLAN_EID_CHALLENGE, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); - - SetPrivacy(fctrl); - - pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - - pattrib->encrypt = _WEP40_; - - pattrib->icv_len = 4; - - pattrib->pktlen += pattrib->icv_len; - } - } - - pattrib->last_txcmdsz = pattrib->pktlen; - - rtw_wep_encrypt(padapter, pmgntframe); - dump_mgntframe(padapter, pmgntframe); -} - -#ifdef CONFIG_88EU_AP_MODE -static void issue_asocrsp(struct adapter *padapter, unsigned short status, - struct sta_info *pstat, int pkt_type) -{ - struct xmit_frame *pmgntframe; - struct ieee80211_hdr *pwlanhdr; - struct pkt_attrib *pattrib; - unsigned char *pbuf, *pframe; - unsigned short val; - __le16 *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - u8 *ie = pnetwork->ies; - __le16 lestatus, leval; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - ether_addr_copy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr); - ether_addr_copy((void *)GetAddr2Ptr(pwlanhdr), - myid(&padapter->eeprompriv)); - ether_addr_copy((void *)GetAddr3Ptr(pwlanhdr), pnetwork->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - if ((pkt_type == IEEE80211_STYPE_ASSOC_RESP) || (pkt_type == IEEE80211_STYPE_REASSOC_RESP)) - SetFrameSubType(pwlanhdr, pkt_type); - else - return; - - pattrib->hdrlen = sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen += pattrib->hdrlen; - pframe += pattrib->hdrlen; - - /* capability */ - val = *(unsigned short *)rtw_get_capability_from_ie(ie); - - pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_, &val, &pattrib->pktlen); - - lestatus = cpu_to_le16(status); - pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, &lestatus, - &pattrib->pktlen); - - leval = cpu_to_le16(pstat->aid | BIT(14) | BIT(15)); - pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, &leval, &pattrib->pktlen); - - if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); - } else { - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, pstat->bssrateset, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen); - } - - if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { - uint ie_len = 0; - - /* FILL HT CAP INFO IE */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_CAPABILITY, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); - if (pbuf && ie_len > 0) { - memcpy(pframe, pbuf, ie_len + 2); - pframe += (ie_len + 2); - pattrib->pktlen += (ie_len + 2); - } - - /* FILL HT ADD INFO IE */ - pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, WLAN_EID_HT_OPERATION, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_)); - if (pbuf && ie_len > 0) { - memcpy(pframe, pbuf, ie_len + 2); - pframe += (ie_len + 2); - pattrib->pktlen += (ie_len + 2); - } - } - - /* FILL WMM IE */ - if ((pstat->flags & WLAN_STA_WME) && (pmlmepriv->qospriv.qos_option)) { - uint ie_len = 0; - unsigned char WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; - - for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { - pbuf = rtw_get_ie(pbuf, WLAN_EID_VENDOR_SPECIFIC, &ie_len, (pnetwork->ie_length - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if (pbuf && !memcmp(pbuf + 2, WMM_PARA_IE, 6)) { - memcpy(pframe, pbuf, ie_len + 2); - pframe += (ie_len + 2); - pattrib->pktlen += (ie_len + 2); - break; - } - - if (!pbuf || ie_len == 0) - break; - } - } - - if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &pattrib->pktlen); - - /* add WPS IE ie for wps 2.0 */ - if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { - memcpy(pframe, pmlmepriv->wps_assoc_resp_ie, pmlmepriv->wps_assoc_resp_ie_len); - - pframe += pmlmepriv->wps_assoc_resp_ie_len; - pattrib->pktlen += pmlmepriv->wps_assoc_resp_ie_len; - } - - pattrib->last_txcmdsz = pattrib->pktlen; - dump_mgntframe(padapter, pmgntframe); -} -#endif /* CONFIG_88EU_AP_MODE */ - -static void issue_assocreq(struct adapter *padapter) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe, *p; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned int i, j, ie_len, index = 0; - unsigned char bssrate[NumRates], sta_bssrate[NumRates]; - struct ndis_802_11_var_ie *pIE; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - int bssrate_len = 0, sta_bssrate_len = 0; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_STYPE_ASSOC_REQ); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* caps */ - - memcpy(pframe, rtw_get_capability_from_ie(pmlmeinfo->network.ies), 2); - - pframe += 2; - pattrib->pktlen += 2; - - /* listen interval */ - /* todo: listen interval for power saving */ - put_unaligned_le16(3, pframe); - pframe += 2; - pattrib->pktlen += 2; - - /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, pmlmeinfo->network.ssid.ssid_length, pmlmeinfo->network.ssid.ssid, &pattrib->pktlen); - - /* supported rate & extended supported rate */ - - /* Check if the AP's supported rates are also supported by STA. */ - get_rate_set(padapter, sta_bssrate, &sta_bssrate_len); - - if (pmlmeext->cur_channel == 14)/* for JAPAN, channel 14 can only uses B Mode(CCK) */ - sta_bssrate_len = 4; - - for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - if (pmlmeinfo->network.SupportedRates[i] == 0) - break; - } - - for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - if (pmlmeinfo->network.SupportedRates[i] == 0) - break; - - /* Check if the AP's supported rates are also supported by STA. */ - for (j = 0; j < sta_bssrate_len; j++) { - /* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */ - if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK) - == (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) - break; - } - - if (j != sta_bssrate_len) - /* the rate is supported by STA */ - bssrate[index++] = pmlmeinfo->network.SupportedRates[i]; - } - - bssrate_len = index; - - if (bssrate_len == 0) { - rtw_free_xmitbuf(pxmitpriv, pmgntframe->pxmitbuf); - rtw_free_xmitframe(pxmitpriv, pmgntframe); - goto exit; /* don't connect to AP if no joint supported rate */ - } - - if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, 8, bssrate, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); - } else { - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, bssrate_len, bssrate, &pattrib->pktlen); - } - - /* RSN */ - p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), WLAN_EID_RSN, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); - if (p) - pframe = rtw_set_ie(pframe, WLAN_EID_RSN, ie_len, p + 2, &pattrib->pktlen); - - /* HT caps */ - if (padapter->mlmepriv.htpriv.ht_option) { - p = rtw_get_ie((pmlmeinfo->network.ies + sizeof(struct ndis_802_11_fixed_ie)), WLAN_EID_HT_CAPABILITY, &ie_len, (pmlmeinfo->network.ie_length - sizeof(struct ndis_802_11_fixed_ie))); - if (p && !is_ap_in_tkip(padapter)) { - memcpy(&pmlmeinfo->HT_caps, p + 2, sizeof(struct ieee80211_ht_cap)); - - /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ - if (pregpriv->cbw40_enable == 0) - pmlmeinfo->HT_caps.cap_info &= cpu_to_le16(~(BIT(6) | BIT(1))); - else - pmlmeinfo->HT_caps.cap_info |= cpu_to_le16(BIT(1)); - - /* todo: disable SM power save mode */ - pmlmeinfo->HT_caps.cap_info |= cpu_to_le16(0x000c); - - if (pregpriv->rx_stbc) - pmlmeinfo->HT_caps.cap_info |= cpu_to_le16(0x0100);/* RX STBC One spatial stream */ - memcpy((u8 *)&pmlmeinfo->HT_caps.mcs, MCS_rate_1R, 16); - pframe = rtw_set_ie(pframe, WLAN_EID_HT_CAPABILITY, ie_len, (u8 *)(&pmlmeinfo->HT_caps), &pattrib->pktlen); - } - } - - /* vendor specific IE, such as WPA, WMM, WPS */ - for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.ie_length; i += (pIE->Length + 2)) { - pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.ies + i); - - switch (pIE->ElementID) { - case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) || - (!memcmp(pIE->data, WMM_OUI, 4)) || - (!memcmp(pIE->data, WPS_OUI, 4))) { - if (!padapter->registrypriv.wifi_spec) { - /* Commented by Kurt 20110629 */ - /* In some older APs, WPS handshake */ - /* would be fail if we append vender extensions information to AP */ - if (!memcmp(pIE->data, WPS_OUI, 4)) - pIE->Length = 14; - } - pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, pIE->Length, pIE->data, &pattrib->pktlen); - } - break; - default: - break; - } - } - - if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, WLAN_EID_VENDOR_SPECIFIC, 6, REALTEK_96B_IE, &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - dump_mgntframe(padapter, pmgntframe); - - ret = _SUCCESS; - -exit: - if (ret == _SUCCESS) - rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); - else - rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); -} - -/* when wait_ack is true, this function should be called at process context */ -static int _issue_nulldata(struct adapter *padapter, unsigned char *da, - unsigned int power_mode, bool wait_ack) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct xmit_priv *pxmitpriv; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - struct wlan_bssid_ex *pnetwork; - - if (!padapter) - goto exit; - - pxmitpriv = &padapter->xmitpriv; - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - pnetwork = &pmlmeinfo->network; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - pattrib->retry_ctrl = false; - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) - SetFrDs(fctrl); - else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) - SetToDs(fctrl); - - if (power_mode) - SetPwrMgt(fctrl); - - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pattrib->last_txcmdsz = pattrib->pktlen; - - if (wait_ack) { - ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else { - dump_mgntframe(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -/* when wait_ms > 0 , this function should be called at process context */ -/* da == NULL for station mode */ -int issue_nulldata(struct adapter *padapter, unsigned char *da, - unsigned int power_mode, int try_cnt, int wait_ms) -{ - int ret; - int i = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - /* da == NULL, assume it's null data for sta to ap*/ - if (!da) - da = pnetwork->MacAddress; - - do { - ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0); - - i++; - - if (padapter->bDriverStopped || padapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - msleep(wait_ms); - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); - - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } -exit: - return ret; -} - -/* when wait_ack is true, this function should be called at process context */ -static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, - u16 tid, bool wait_ack) -{ - int ret = _FAIL; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - unsigned short *qc; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - pattrib->hdrlen += 2; - pattrib->qos_en = true; - pattrib->eosp = 1; - pattrib->ack_policy = 0; - pattrib->mdata = 0; - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) - SetFrDs(fctrl); - else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) - SetToDs(fctrl); - - if (pattrib->mdata) - SetMData(fctrl); - - qc = (unsigned short *)(pframe + pattrib->hdrlen - 2); - - SetPriority(qc, tid); - - SetEOSP(qc, pattrib->eosp); - - SetAckpolicy(qc, pattrib->ack_policy); - - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC); - - pframe += sizeof(struct ieee80211_qos_hdr); - pattrib->pktlen = sizeof(struct ieee80211_qos_hdr); - - pattrib->last_txcmdsz = pattrib->pktlen; - - if (wait_ack) { - ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else { - dump_mgntframe(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -/* when wait_ms > 0 , this function should be called at process context */ -/* da == NULL for station mode */ -int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, - u16 tid, int try_cnt, int wait_ms) -{ - int ret; - int i = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - /* da == NULL, assume it's null data for sta to ap*/ - if (!da) - da = pnetwork->MacAddress; - - do { - ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0); - - i++; - - if (padapter->bDriverStopped || padapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - msleep(wait_ms); - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); - - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } -exit: - return ret; -} - -static int _issue_deauth(struct adapter *padapter, unsigned char *da, - unsigned short reason, bool wait_ack) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - int ret = _FAIL; - __le16 le_tmp; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - pattrib->retry_ctrl = false; - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - ether_addr_copy(pwlanhdr->addr1, da); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_STYPE_DEAUTH); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - le_tmp = cpu_to_le16(reason); - pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_, &le_tmp, - &pattrib->pktlen); - - pattrib->last_txcmdsz = pattrib->pktlen; - - if (wait_ack) { - ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); - } else { - dump_mgntframe(padapter, pmgntframe); - ret = _SUCCESS; - } - -exit: - return ret; -} - -int issue_deauth(struct adapter *padapter, unsigned char *da, - unsigned short reason) -{ - return _issue_deauth(padapter, da, reason, false); -} - -static int issue_deauth_ex(struct adapter *padapter, u8 *da, - unsigned short reason, int try_cnt, - int wait_ms) -{ - int ret; - int i = 0; - - do { - ret = _issue_deauth(padapter, da, reason, wait_ms > 0); - - i++; - - if (padapter->bDriverStopped || padapter->bSurpriseRemoved) - break; - - if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - mdelay(wait_ms); - } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); - - if (ret != _FAIL) { - ret = _SUCCESS; - goto exit; - } -exit: - return ret; -} - -static void issue_action_BA(struct adapter *padapter, unsigned char *raddr, - unsigned char action, unsigned short status) -{ - u8 category = RTW_WLAN_CATEGORY_BACK; - u16 start_seq; - u16 BA_para_set; - u16 reason_code; - u16 BA_timeout_value; - __le16 le_tmp; - u16 BA_starting_seqctrl = 0; - enum ht_cap_ampdu_factor max_rx_ampdu_factor; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - u8 *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - ether_addr_copy(pwlanhdr->addr1, raddr); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_STYPE_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); - - if (category == 3) { - switch (action) { - case 0: /* ADDBA req */ - do { - pmlmeinfo->dialogToken++; - } while (pmlmeinfo->dialogToken == 0); - pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen); - - BA_para_set = 0x1002 | ((status & 0xf) << 2); /* immediate ack & 64 buffer size */ - le_tmp = cpu_to_le16(BA_para_set); - pframe = rtw_set_fixed_ie(pframe, 2, &(le_tmp), - &pattrib->pktlen); - - BA_timeout_value = 5000;/* 5ms */ - le_tmp = cpu_to_le16(BA_timeout_value); - pframe = rtw_set_fixed_ie(pframe, 2, &(le_tmp), - &pattrib->pktlen); - - psta = rtw_get_stainfo(pstapriv, raddr); - if (psta) { - start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1; - - psta->BA_starting_seqctrl[status & 0x07] = start_seq; - - BA_starting_seqctrl = start_seq << 4; - } - le_tmp = cpu_to_le16(BA_starting_seqctrl); - pframe = rtw_set_fixed_ie(pframe, 2, &(le_tmp), - &pattrib->pktlen); - break; - case 1: /* ADDBA rsp */ - { - struct ADDBA_request *ADDBA_req = &pmlmeinfo->ADDBA_req; - - pframe = rtw_set_fixed_ie(pframe, 1, - &ADDBA_req->dialog_token, - &pattrib->pktlen); - pframe = rtw_set_fixed_ie(pframe, 2, &status, - &pattrib->pktlen); - - BA_para_set = le16_to_cpu(ADDBA_req->BA_para_set) & - 0x3f; - rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); - switch (max_rx_ampdu_factor) { - case MAX_AMPDU_FACTOR_64K: - BA_para_set |= 0x1000; /* 64 buffer size */ - break; - case MAX_AMPDU_FACTOR_32K: - BA_para_set |= 0x0800; /* 32 buffer size */ - break; - case MAX_AMPDU_FACTOR_16K: - BA_para_set |= 0x0400; /* 16 buffer size */ - break; - case MAX_AMPDU_FACTOR_8K: - BA_para_set |= 0x0200; /* 8 buffer size */ - break; - default: - BA_para_set |= 0x1000; /* 64 buffer size */ - break; - } - - if (pregpriv->ampdu_amsdu == 0)/* disabled */ - BA_para_set = BA_para_set & ~BIT(0); - else if (pregpriv->ampdu_amsdu == 1)/* enabled */ - BA_para_set = BA_para_set | BIT(0); - le_tmp = cpu_to_le16(BA_para_set); - - pframe = rtw_set_fixed_ie(pframe, 2, &(le_tmp), - &pattrib->pktlen); - pframe = rtw_set_fixed_ie(pframe, 2, - &ADDBA_req->BA_timeout_value, - &pattrib->pktlen); - break; - } - case 2:/* DELBA */ - BA_para_set = (status & 0x1F) << 3; - le_tmp = cpu_to_le16(BA_para_set); - pframe = rtw_set_fixed_ie(pframe, 2, &(le_tmp), - &pattrib->pktlen); - - reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */ - le_tmp = cpu_to_le16(reason_code); - pframe = rtw_set_fixed_ie(pframe, 2, &(le_tmp), - &pattrib->pktlen); - break; - default: - break; - } - } - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - -static void issue_action_BSSCoexistPacket(struct adapter *padapter) -{ - struct list_head *plist, *phead; - unsigned char category, action; - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - unsigned char *pframe; - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - struct wlan_network *pnetwork = NULL; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct __queue *queue = &pmlmepriv->scanned_queue; - u8 InfoContent[16] = {0}; - u8 ICS[8][15]; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - - if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) - return; - - if (pmlmeinfo->bwmode_updated) - return; - - category = RTW_WLAN_CATEGORY_PUBLIC; - action = ACT_PUBLIC_BSSCOEXIST; - - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - return; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(padapter, pattrib); - - memset(pmgntframe->buf_addr, 0, WLANHDR_OFFSET + TXDESC_OFFSET); - - pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - ether_addr_copy(pwlanhdr->addr1, cur_network->MacAddress); - ether_addr_copy(pwlanhdr->addr2, myid(&padapter->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress); - - SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); - pmlmeext->mgnt_seq++; - SetFrameSubType(pframe, IEEE80211_STYPE_ACTION); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pattrib->pktlen = sizeof(struct ieee80211_hdr_3addr); - - pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); - pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); - - /* */ - if (pmlmepriv->num_FortyMHzIntolerant > 0) { - u8 iedata = 0; - - iedata |= BIT(2);/* 20 MHz BSS Width Request */ - - pframe = rtw_set_ie(pframe, WLAN_EID_BSS_COEX_2040, 1, &iedata, &pattrib->pktlen); - } - - /* */ - memset(ICS, 0, sizeof(ICS)); - if (pmlmepriv->num_sta_no_ht > 0) { - int i; - - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - - phead = get_list_head(queue); - list_for_each(plist, phead) { - uint len; - u8 *p; - struct wlan_bssid_ex *pbss_network; - - pnetwork = list_entry(plist, struct wlan_network, - list); - - pbss_network = &pnetwork->network; - - p = rtw_get_ie(pbss_network->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, pbss_network->ie_length - _FIXED_IE_LENGTH_); - if (!p || len == 0) { /* non-HT */ - if (pbss_network->Configuration.DSConfig <= 0) - continue; - - ICS[0][pbss_network->Configuration.DSConfig] = 1; - - if (ICS[0][0] == 0) - ICS[0][0] = 1; - } - } - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - - for (i = 0; i < 8; i++) { - if (ICS[i][0] == 1) { - int j, k = 0; - - InfoContent[k] = i; - /* SET_BSS_INTOLERANT_ELE_REG_CLASS(InfoContent, i); */ - k++; - - for (j = 1; j <= 14; j++) { - if (ICS[i][j] == 1) { - if (k < 16) { - InfoContent[k] = j; /* channel number */ - /* SET_BSS_INTOLERANT_ELE_CHANNEL(InfoContent+k, j); */ - k++; - } - } - } - - pframe = rtw_set_ie(pframe, WLAN_EID_BSS_INTOLERANT_CHL_REPORT, k, InfoContent, &pattrib->pktlen); - } - } - } - - pattrib->last_txcmdsz = pattrib->pktlen; - - dump_mgntframe(padapter, pmgntframe); -} - -unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct sta_info *psta = NULL; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u16 tid; - - if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) - if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) - return _SUCCESS; - - psta = rtw_get_stainfo(pstapriv, addr); - if (!psta) - return _SUCCESS; - - if (initiator == 0) { /* recipient */ - for (tid = 0; tid < MAXTID; tid++) { - if (psta->recvreorder_ctrl[tid].enable) { - issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F)); - psta->recvreorder_ctrl[tid].enable = false; - psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; - } - } - } else if (initiator == 1) { /* originator */ - for (tid = 0; tid < MAXTID; tid++) { - if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { - issue_action_BA(padapter, addr, WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F)); - psta->htpriv.agg_enable_bitmap &= ~BIT(tid); - psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); - } - } - } - - return _SUCCESS; -} - -unsigned int send_beacon(struct adapter *padapter) -{ - u8 bxmitok = false; - int issue = 0; - int poll = 0; - - rtw_hal_set_hwreg(padapter, HW_VAR_BCN_VALID, NULL); - do { - issue_beacon(padapter, 100); - issue++; - do { - yield(); - rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); - poll++; - } while ((poll % 10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); - } while (!bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return _FAIL; - if (!bxmitok) - return _FAIL; - - return _SUCCESS; -} - -/**************************************************************************** - -Following are some utility functions for WiFi MLME - -*****************************************************************************/ - -static void site_survey(struct adapter *padapter) -{ - unsigned char survey_channel = 0, val8; - enum rt_scan_type ScanType = SCAN_PASSIVE; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u32 initialgain = 0; - struct rtw_ieee80211_channel *ch; - - if (pmlmeext->sitesurvey_res.channel_idx < pmlmeext->sitesurvey_res.ch_num) { - ch = &pmlmeext->sitesurvey_res.ch[pmlmeext->sitesurvey_res.channel_idx]; - survey_channel = ch->hw_value; - ScanType = (ch->flags & RTW_IEEE80211_CHAN_PASSIVE_SCAN) ? SCAN_PASSIVE : SCAN_ACTIVE; - } - - if (survey_channel != 0) { - /* PAUSE 4-AC Queue when site_survey */ - /* rtw_hal_get_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - /* val8 |= 0x0f; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - if (pmlmeext->sitesurvey_res.channel_idx == 0) - set_channel_bwmode(padapter, survey_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - else - SelectChannel(padapter, survey_channel); - - if (ScanType == SCAN_ACTIVE) { /* obey the channel plan setting... */ - int i; - - for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { - if (pmlmeext->sitesurvey_res.ssid[i].ssid_length) { - /* todo: to issue two probe req??? */ - issue_probereq(padapter, - &pmlmeext->sitesurvey_res.ssid[i], - NULL, false); - /* msleep(SURVEY_TO>>1); */ - issue_probereq(padapter, - &pmlmeext->sitesurvey_res.ssid[i], - NULL, false); - } - } - - if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { - /* todo: to issue two probe req??? */ - issue_probereq(padapter, NULL, NULL, false); - /* msleep(SURVEY_TO>>1); */ - issue_probereq(padapter, NULL, NULL, false); - } - - if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { - /* todo: to issue two probe req??? */ - issue_probereq(padapter, NULL, NULL, false); - /* msleep(SURVEY_TO>>1); */ - issue_probereq(padapter, NULL, NULL, false); - } - } - - set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); - } else { - /* 20100721:Interrupt scan operation here. */ - /* For SW antenna diversity before link, it needs to switch to another antenna and scan again. */ - /* It compares the scan result and select better one to do connection. */ - if (rtw_hal_antdiv_before_linked(padapter)) { - pmlmeext->sitesurvey_res.bss_cnt = 0; - pmlmeext->sitesurvey_res.channel_idx = -1; - pmlmeext->chan_scan_time = SURVEY_TO / 2; - set_survey_timer(pmlmeext, pmlmeext->chan_scan_time); - return; - } - - pmlmeext->sitesurvey_res.state = SCAN_COMPLETE; - - /* switch back to the original channel */ - - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - /* flush 4-AC Queue after site_survey */ - /* val8 = 0; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_TXPAUSE, (u8 *)(&val8)); */ - - /* config MSR */ - Set_MSR(padapter, (pmlmeinfo->state & 0x3)); - - initialgain = 0xff; /* restore RX GAIN */ - rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); - /* turn on dynamic functions */ - Restore_DM_Func_Flag(padapter); - /* Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); */ - - if (is_client_associated_to_ap(padapter)) - issue_nulldata(padapter, NULL, 0, 3, 500); - - val8 = 0; /* survey done */ - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); - - report_surveydone_event(padapter); - - pmlmeext->chan_scan_time = SURVEY_TO; - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); - issue_action_BSSCoexistPacket(padapter); - } -} - -/* collect bss info from Beacon and Probe request/response frames. */ -static u8 collect_bss_info(struct adapter *padapter, - struct recv_frame *precv_frame, - struct wlan_bssid_ex *bssid) -{ - int i; - u32 len; - u8 *p; - u16 val16, subtype; - u8 *pframe = precv_frame->pkt->data; - u32 packet_len = precv_frame->pkt->len; - u8 ie_offset; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - len = packet_len - sizeof(struct ieee80211_hdr_3addr); - - if (len > MAX_IE_SZ) - return _FAIL; - - memset(bssid, 0, sizeof(struct wlan_bssid_ex)); - - subtype = GetFrameSubType(pframe); - - if (subtype == IEEE80211_STYPE_BEACON) { - bssid->Reserved[0] = 1; - ie_offset = _BEACON_IE_OFFSET_; - } else { - /* FIXME : more type */ - if (subtype == IEEE80211_STYPE_PROBE_REQ) { - ie_offset = _PROBEREQ_IE_OFFSET_; - bssid->Reserved[0] = 2; - } else if (subtype == IEEE80211_STYPE_PROBE_RESP) { - ie_offset = _PROBERSP_IE_OFFSET_; - bssid->Reserved[0] = 3; - } else { - bssid->Reserved[0] = 0; - ie_offset = _FIXED_IE_LENGTH_; - } - } - - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; - - /* below is to copy the information element */ - bssid->ie_length = len; - memcpy(bssid->ies, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->ie_length); - - /* get the signal strength in dBM.raw data */ - bssid->Rssi = precv_frame->attrib.phy_info.recvpower; - bssid->PhyInfo.SignalQuality = precv_frame->attrib.phy_info.SignalQuality;/* in percentage */ - bssid->PhyInfo.SignalStrength = precv_frame->attrib.phy_info.SignalStrength;/* in percentage */ - rtw_hal_get_def_var(padapter, HAL_DEF_CURRENT_ANTENNA, &bssid->PhyInfo.Optimum_antenna); - - /* checking SSID */ - p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SSID, &len, bssid->ie_length - ie_offset); - if (!p) - return _FAIL; - - if (len) { - if (len > NDIS_802_11_LENGTH_SSID) - return _FAIL; - memcpy(bssid->ssid.ssid, (p + 2), len); - bssid->ssid.ssid_length = len; - } else { - bssid->ssid.ssid_length = 0; - } - - memset(bssid->SupportedRates, 0, NDIS_802_11_LENGTH_RATES_EX); - - /* checking rate info... */ - i = 0; - p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_SUPP_RATES, &len, bssid->ie_length - ie_offset); - if (p) { - if (len > NDIS_802_11_LENGTH_RATES_EX) - return _FAIL; - memcpy(bssid->SupportedRates, (p + 2), len); - i = len; - } - - p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_EXT_SUPP_RATES, &len, bssid->ie_length - ie_offset); - if (p) { - if (len > (NDIS_802_11_LENGTH_RATES_EX - i)) - return _FAIL; - memcpy(bssid->SupportedRates + i, (p + 2), len); - } - - /* todo: */ - bssid->NetworkTypeInUse = Ndis802_11OFDM24; - - if (bssid->ie_length < 12) - return _FAIL; - - /* Checking for DSConfig */ - p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - ie_offset); - - bssid->Configuration.DSConfig = 0; - bssid->Configuration.Length = 0; - - if (p) { - bssid->Configuration.DSConfig = *(p + 2); - } else {/* In 5G, some ap do not have DSSET IE */ - /* checking HT info for channel */ - p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - ie_offset); - if (p) { - struct HT_info_element *HT_info = (struct HT_info_element *)(p + 2); - - bssid->Configuration.DSConfig = HT_info->primary_channel; - } else { /* use current channel */ - bssid->Configuration.DSConfig = rtw_get_oper_ch(padapter); - } - } - - if (subtype == IEEE80211_STYPE_PROBE_REQ) { - /* FIXME */ - bssid->InfrastructureMode = Ndis802_11Infrastructure; - ether_addr_copy(bssid->MacAddress, GetAddr2Ptr(pframe)); - bssid->Privacy = 1; - return _SUCCESS; - } - - bssid->Configuration.BeaconPeriod = - get_unaligned_le16(rtw_get_beacon_interval_from_ie(bssid->ies)); - - val16 = rtw_get_capability(bssid); - - if (val16 & BIT(0)) { - bssid->InfrastructureMode = Ndis802_11Infrastructure; - ether_addr_copy(bssid->MacAddress, GetAddr2Ptr(pframe)); - } else { - bssid->InfrastructureMode = Ndis802_11IBSS; - ether_addr_copy(bssid->MacAddress, GetAddr3Ptr(pframe)); - } - - if (val16 & BIT(4)) - bssid->Privacy = 1; - else - bssid->Privacy = 0; - - bssid->Configuration.ATIMWindow = 0; - - /* 20/40 BSS Coexistence check */ - if ((pregistrypriv->wifi_spec == 1) && (!pmlmeinfo->bwmode_updated)) { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - p = rtw_get_ie(bssid->ies + ie_offset, WLAN_EID_HT_CAPABILITY, &len, bssid->ie_length - ie_offset); - if (p && len > 0) { - struct ieee80211_ht_cap *pHT_caps = - (struct ieee80211_ht_cap *)(p + 2); - - if (le16_to_cpu(pHT_caps->cap_info) & BIT(14)) - pmlmepriv->num_FortyMHzIntolerant++; - } else { - pmlmepriv->num_sta_no_ht++; - } - } - - /* mark bss info receiving from nearby channel as SignalQuality 101 */ - if (bssid->Configuration.DSConfig != rtw_get_oper_ch(padapter)) - bssid->PhyInfo.SignalQuality = 101; - return _SUCCESS; -} - -static void start_create_ibss(struct adapter *padapter) -{ - unsigned short caps; - u8 val8; - u8 join_type; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; - pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); - - /* update wireless mode */ - update_wireless_mode(padapter); - - /* update capability */ - caps = rtw_get_capability(pnetwork); - update_capinfo(padapter, caps); - if (caps & WLAN_CAPABILITY_IBSS) {/* adhoc master */ - val8 = 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); - - /* switch channel */ - /* SelectChannel(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE); */ - set_channel_bwmode(padapter, pmlmeext->cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - - beacon_timing_control(padapter); - - /* set msr to WIFI_FW_ADHOC_STATE */ - pmlmeinfo->state = WIFI_FW_ADHOC_STATE; - Set_MSR(padapter, (pmlmeinfo->state & 0x3)); - - /* issue beacon */ - if (send_beacon(padapter) == _FAIL) { - report_join_res(padapter, -1); - pmlmeinfo->state = WIFI_FW_NULL_STATE; - } else { - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, padapter->registrypriv.dev_network.MacAddress); - join_type = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - - report_join_res(padapter, 1); - pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; - } - } else { - return; - } -} - -static void start_clnt_join(struct adapter *padapter) -{ - unsigned short caps; - u8 val8; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - int beacon_timeout; - - pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; - pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); - - /* update wireless mode */ - update_wireless_mode(padapter); - - /* update capability */ - caps = rtw_get_capability(pnetwork); - update_capinfo(padapter, caps); - if (caps & WLAN_CAPABILITY_ESS) { - Set_MSR(padapter, WIFI_FW_STATION_STATE); - - val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; - - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); - - /* switch channel */ - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - /* here wait for receiving the beacon to start auth */ - /* and enable a timer */ - beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval); - set_link_timer(pmlmeext, beacon_timeout); - mod_timer(&padapter->mlmepriv.assoc_timer, jiffies + - msecs_to_jiffies((REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout)); - - pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; - } else if (caps & WLAN_CAPABILITY_IBSS) { /* adhoc client */ - Set_MSR(padapter, WIFI_FW_ADHOC_STATE); - - val8 = 0xcf; - rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); - - /* switch channel */ - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - beacon_timing_control(padapter); - - pmlmeinfo->state = WIFI_FW_ADHOC_STATE; - - report_join_res(padapter, 1); - } else { - return; - } -} - -static void start_clnt_auth(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - del_timer_sync(&pmlmeext->link_timer); - - pmlmeinfo->state &= (~WIFI_FW_AUTH_NULL); - pmlmeinfo->state |= WIFI_FW_AUTH_STATE; - - pmlmeinfo->auth_seq = 1; - pmlmeinfo->reauth_count = 0; - pmlmeinfo->reassoc_count = 0; - pmlmeinfo->link_count = 0; - pmlmeext->retry = 0; - - /* Because of AP's not receiving deauth before */ - /* AP may: 1)not response auth or 2)deauth us after link is complete */ - /* issue deauth before issuing auth to deal with the situation */ - /* Commented by Albert 2012/07/21 */ - /* For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */ - issue_deauth(padapter, (&pmlmeinfo->network)->MacAddress, WLAN_REASON_DEAUTH_LEAVING); - - issue_auth(padapter, NULL, 0); - - set_link_timer(pmlmeext, REAUTH_TO); -} - -static void start_clnt_assoc(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - del_timer_sync(&pmlmeext->link_timer); - - pmlmeinfo->state &= (~(WIFI_FW_AUTH_NULL | WIFI_FW_AUTH_STATE)); - pmlmeinfo->state |= (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE); - - issue_assocreq(padapter); - - set_link_timer(pmlmeext, REASSOC_TO); -} - -static unsigned int receive_disconnect(struct adapter *padapter, - unsigned char *MacAddr, - unsigned short reason) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - /* check A3 */ - if (memcmp(MacAddr, pnetwork->MacAddress, ETH_ALEN)) - return _SUCCESS; - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { - pmlmeinfo->state = WIFI_FW_NULL_STATE; - report_del_sta_event(padapter, MacAddr, reason); - } else if (pmlmeinfo->state & WIFI_FW_LINKING_STATE) { - pmlmeinfo->state = WIFI_FW_NULL_STATE; - report_join_res(padapter, -2); - } - } - return _SUCCESS; -} - -static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid) -{ - struct registry_priv *pregistrypriv; - struct mlme_ext_priv *pmlmeext; - struct rt_channel_info *chplan_new; - u8 channel; - u8 i; - - pregistrypriv = &padapter->registrypriv; - pmlmeext = &padapter->mlmeextpriv; - - /* Adjust channel plan by AP Country IE */ - if (pregistrypriv->enable80211d && - (!pmlmeext->update_channel_plan_by_ap_done)) { - u8 *ie, *p; - u32 len; - struct rt_channel_plan chplan_ap; - struct rt_channel_info chplan_sta[MAX_CHANNEL_NUM]; - u8 country[4]; - u8 fcn; /* first channel number */ - u8 noc; /* number of channel */ - u8 j, k; - - ie = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_COUNTRY, &len, bssid->ie_length - _FIXED_IE_LENGTH_); - if (!ie) - return; - if (len < 6) - return; - ie += 2; - p = ie; - ie += len; - - memset(country, 0, 4); - memcpy(country, p, 3); - p += 3; - i = 0; - while ((ie - p) >= 3) { - fcn = *(p++); - noc = *(p++); - p++; - - for (j = 0; j < noc; j++) { - channel = fcn + j; - - chplan_ap.Channel[i++] = channel; - } - } - chplan_ap.Len = i; - - memcpy(chplan_sta, pmlmeext->channel_set, sizeof(chplan_sta)); - - memset(pmlmeext->channel_set, 0, sizeof(pmlmeext->channel_set)); - chplan_new = pmlmeext->channel_set; - - i = 0; - j = 0; - k = 0; - if (pregistrypriv->wireless_mode & WIRELESS_11G) { - do { - if ((i == MAX_CHANNEL_NUM) || - (chplan_sta[i].ChannelNum == 0) || - (chplan_sta[i].ChannelNum > 14)) - break; - - if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) - break; - - if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; - chplan_new[k].ScanType = SCAN_ACTIVE; - i++; - j++; - k++; - } else if (chplan_sta[i].ChannelNum < chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; - chplan_new[k].ScanType = SCAN_PASSIVE; - i++; - k++; - } else if (chplan_sta[i].ChannelNum > chplan_ap.Channel[j]) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; - chplan_new[k].ScanType = SCAN_ACTIVE; - j++; - k++; - } - } while (1); - - /* change AP not support channel to Passive scan */ - while ((i < MAX_CHANNEL_NUM) && - (chplan_sta[i].ChannelNum != 0) && - (chplan_sta[i].ChannelNum <= 14)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; - chplan_new[k].ScanType = SCAN_PASSIVE; - i++; - k++; - } - - /* add channel AP supported */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) { - chplan_new[k].ChannelNum = chplan_ap.Channel[j]; - chplan_new[k].ScanType = SCAN_ACTIVE; - j++; - k++; - } - } else { - /* keep original STA 2.4G channel plan */ - while ((i < MAX_CHANNEL_NUM) && - (chplan_sta[i].ChannelNum != 0) && - (chplan_sta[i].ChannelNum <= 14)) { - chplan_new[k].ChannelNum = chplan_sta[i].ChannelNum; - chplan_new[k].ScanType = chplan_sta[i].ScanType; - i++; - k++; - } - - /* skip AP 2.4G channel plan */ - while ((j < chplan_ap.Len) && (chplan_ap.Channel[j] <= 14)) - j++; - } - - pmlmeext->update_channel_plan_by_ap_done = 1; - } - - /* If channel is used by AP, set channel scan type to active */ - channel = bssid->Configuration.DSConfig; - chplan_new = pmlmeext->channel_set; - i = 0; - while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { - if (chplan_new[i].ChannelNum == channel) { - if (chplan_new[i].ScanType == SCAN_PASSIVE) - chplan_new[i].ScanType = SCAN_ACTIVE; - break; - } - i++; - } -} - -/**************************************************************************** - -Following are the callback functions for each subtype of the management frames - -*****************************************************************************/ - -static unsigned int OnProbeReq(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - unsigned int ielen; - unsigned char *p; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur = &pmlmeinfo->network; - u8 *pframe = precv_frame->pkt->data; - uint len = precv_frame->pkt->len; - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - return _SUCCESS; - - if (!check_fwstate(pmlmepriv, _FW_LINKED) && - !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) - return _SUCCESS; - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, WLAN_EID_SSID, &ielen, - len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); - - /* check (wildcard) SSID */ - if (p) { - if ((ielen != 0 && memcmp((void *)(p + 2), (void *)cur->ssid.ssid, cur->ssid.ssid_length)) || - (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) - return _SUCCESS; - - if (check_fwstate(pmlmepriv, _FW_LINKED) && - pmlmepriv->cur_network.join_res) - issue_probersp(padapter, ieee80211_get_SA((struct ieee80211_hdr *)pframe)); - } - return _SUCCESS; -} - -static unsigned int OnProbeRsp(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - report_survey_event(padapter, precv_frame); - return _SUCCESS; - } - - return _SUCCESS; -} - -static unsigned int OnBeacon(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - int cam_idx; - struct sta_info *psta; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->pkt->data; - uint len = precv_frame->pkt->len; - struct wlan_bssid_ex *pbss; - int ret = _SUCCESS; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - report_survey_event(padapter, precv_frame); - return _SUCCESS; - } - - if (!memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) { - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - /* we should update current network before auth, or some IE is wrong */ - pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); - if (pbss) { - if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { - update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); - rtw_get_bcn_info(&pmlmepriv->cur_network); - } - kfree(pbss); - } - - /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct ieee80211_hdr_3addr), len - sizeof(struct ieee80211_hdr_3addr)); - - /* update TSF Value */ - update_TSF(pmlmeext, pframe, len); - - /* start auth */ - start_clnt_auth(padapter); - - return _SUCCESS; - } - - if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta) { - ret = rtw_check_bcn_info(padapter, pframe, len); - if (!ret) { - receive_disconnect(padapter, pmlmeinfo->network.MacAddress, 65535); - return _SUCCESS; - } - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, pframe, len, psta); - } - } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta) { - /* update WMM, ERP in the beacon */ - /* todo: the timer is used instead of the number of the beacon received */ - if ((sta_rx_pkts(psta) & 0xf) == 0) - update_beacon_info(padapter, pframe, len, psta); - } else { - /* allocate a new CAM entry for IBSS station */ - cam_idx = allocate_fw_sta_entry(padapter); - if (cam_idx == NUM_STA) - goto _END_ONBEACON_; - - /* get supported rate */ - if (update_sta_support_rate(padapter, (pframe + WLAN_HDR_A3_LEN + _BEACON_IE_OFFSET_), (len - WLAN_HDR_A3_LEN - _BEACON_IE_OFFSET_), cam_idx) == _FAIL) { - pmlmeinfo->FW_sta_info[cam_idx].status = 0; - goto _END_ONBEACON_; - } - - /* update TSF Value */ - update_TSF(pmlmeext, pframe, len); - - /* report sta add event */ - report_add_sta_event(padapter, GetAddr2Ptr(pframe), cam_idx); - } - } - } - -_END_ONBEACON_: - - return _SUCCESS; -} - -#ifdef CONFIG_88EU_AP_MODE -static unsigned int OnAuth(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - unsigned int auth_mode, ie_len; - u16 seq; - unsigned char *sa, *p; - u16 algorithm; - int status; - static struct sta_info stat; - struct sta_info *pstat = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 *pframe = precv_frame->pkt->data; - uint len = precv_frame->pkt->len; - - if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) - return _FAIL; - - sa = GetAddr2Ptr(pframe); - - auth_mode = psecuritypriv->dot11AuthAlgrthm; - seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + 2)); - algorithm = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN)); - - if (auth_mode == 2 && psecuritypriv->dot11PrivacyAlgrthm != _WEP40_ && - psecuritypriv->dot11PrivacyAlgrthm != _WEP104_) - auth_mode = 0; - - if ((algorithm > 0 && auth_mode == 0) || /* rx a shared-key auth but shared not enabled */ - (algorithm == 0 && auth_mode == 1)) { /* rx a open-system auth but shared-key is enabled */ - status = WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; - - goto auth_fail; - } - - if (!rtw_access_ctrl(padapter, sa)) { - status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - goto auth_fail; - } - - pstat = rtw_get_stainfo(pstapriv, sa); - if (!pstat) { - /* allocate a new one */ - pstat = rtw_alloc_stainfo(pstapriv, sa); - if (!pstat) { - status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - goto auth_fail; - } - - pstat->state = WIFI_FW_AUTH_NULL; - pstat->auth_seq = 0; - } else { - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&pstat->asoc_list)) { - list_del_init(&pstat->asoc_list); - pstapriv->asoc_list_cnt--; - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - if (seq == 1) { - /* TODO: STA re_auth and auth timeout */ - } - } - - spin_lock_bh(&pstapriv->auth_list_lock); - if (list_empty(&pstat->auth_list)) { - list_add_tail(&pstat->auth_list, &pstapriv->auth_list); - pstapriv->auth_list_cnt++; - } - spin_unlock_bh(&pstapriv->auth_list_lock); - - if (pstat->auth_seq == 0) - pstat->expire_to = pstapriv->auth_to; - - if ((pstat->auth_seq + 1) != seq) { - status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; - goto auth_fail; - } - - if (algorithm == 0 && (auth_mode == 0 || auth_mode == 2)) { - if (seq == 1) { - pstat->state &= ~WIFI_FW_AUTH_NULL; - pstat->state |= WIFI_FW_AUTH_SUCCESS; - pstat->expire_to = pstapriv->assoc_to; - pstat->authalg = algorithm; - } else { - status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; - goto auth_fail; - } - } else { /* shared system or auto authentication */ - if (seq == 1) { - /* prepare for the challenging txt... */ - - pstat->state &= ~WIFI_FW_AUTH_NULL; - pstat->state |= WIFI_FW_AUTH_STATE; - pstat->authalg = algorithm; - pstat->auth_seq = 2; - } else if (seq == 3) { - /* checking for challenging txt... */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, &ie_len, - len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); - - if (!p || ie_len <= 0) { - status = WLAN_STATUS_CHALLENGE_FAIL; - goto auth_fail; - } - - if (!memcmp((void *)(p + 2), pstat->chg_txt, 128)) { - pstat->state &= (~WIFI_FW_AUTH_STATE); - pstat->state |= WIFI_FW_AUTH_SUCCESS; - /* challenging txt is correct... */ - pstat->expire_to = pstapriv->assoc_to; - } else { - status = WLAN_STATUS_CHALLENGE_FAIL; - goto auth_fail; - } - } else { - status = WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION; - goto auth_fail; - } - } - - /* Now, we are going to issue_auth... */ - pstat->auth_seq = seq + 1; - - issue_auth(padapter, pstat, (unsigned short)(WLAN_STATUS_SUCCESS)); - - if (pstat->state & WIFI_FW_AUTH_SUCCESS) - pstat->auth_seq = 0; - - return _SUCCESS; - -auth_fail: - - if (pstat) - rtw_free_stainfo(padapter, pstat); - - pstat = &stat; - memset((char *)pstat, '\0', sizeof(stat)); - pstat->auth_seq = 2; - memcpy(pstat->hwaddr, sa, 6); - - issue_auth(padapter, pstat, (unsigned short)status); - - return _FAIL; -} -#endif /* CONFIG_88EU_AP_MODE */ - -static unsigned int OnAuthClient(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - unsigned int seq, len, status, offset; - unsigned char *p; - unsigned int go2asoc = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 *pframe = precv_frame->pkt->data; - uint pkt_len = precv_frame->pkt->len; - - /* check A1 matches or not */ - if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA((struct ieee80211_hdr *)pframe), ETH_ALEN)) - return _SUCCESS; - - if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) - return _SUCCESS; - - offset = (GetPrivacy(pframe)) ? 4 : 0; - - seq = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 2)); - status = le16_to_cpu(*(__le16 *)((size_t)pframe + WLAN_HDR_A3_LEN + offset + 4)); - - if (status != 0) { - if (status == 13) { /* pmlmeinfo->auth_algo == dot11AuthAlgrthm_Auto) */ - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; - else - pmlmeinfo->auth_algo = dot11AuthAlgrthm_Shared; - } - - set_link_timer(pmlmeext, 1); - goto authclnt_fail; - } - - if (seq == 2) { - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) { - /* legendary shared system */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, WLAN_EID_CHALLENGE, &len, - pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); - - if (!p) - goto authclnt_fail; - - memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); - pmlmeinfo->auth_seq = 3; - issue_auth(padapter, NULL, 0); - set_link_timer(pmlmeext, REAUTH_TO); - - return _SUCCESS; - } - /* open system */ - go2asoc = 1; - } else if (seq == 4) { - if (pmlmeinfo->auth_algo == dot11AuthAlgrthm_Shared) - go2asoc = 1; - else - goto authclnt_fail; - } else { - /* this is also illegal */ - goto authclnt_fail; - } - - if (go2asoc) { - start_clnt_assoc(padapter); - return _SUCCESS; - } -authclnt_fail: - return _FAIL; -} - -static unsigned int OnAssocReq(struct adapter *padapter, - struct recv_frame *precv_frame) -{ -#ifdef CONFIG_88EU_AP_MODE - u16 capab_info; - struct rtw_ieee802_11_elems elems; - struct sta_info *pstat; - unsigned char *p, *pos, *wpa_ie; - unsigned char WMM_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x00, 0x01}; - int i, wpa_ie_len, left; - unsigned char supportRate[16]; - int supportRateNum; - unsigned short status = WLAN_STATUS_SUCCESS; - unsigned short frame_type, ie_offset = 0; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur = &pmlmeinfo->network; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->pkt->data; - uint ie_len, pkt_len = precv_frame->pkt->len; - - if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) - return _FAIL; - - frame_type = GetFrameSubType(pframe); - if (frame_type == IEEE80211_STYPE_ASSOC_REQ) - ie_offset = _ASOCREQ_IE_OFFSET_; - else /* IEEE80211_STYPE_REASSOC_REQ */ - ie_offset = _REASOCREQ_IE_OFFSET_; - - if (pkt_len < IEEE80211_3ADDR_LEN + ie_offset) - return _FAIL; - - pstat = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (!pstat) { - status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; - goto asoc_class2_error; - } - - capab_info = get_unaligned_le16(pframe + WLAN_HDR_A3_LEN); - - left = pkt_len - (IEEE80211_3ADDR_LEN + ie_offset); - pos = pframe + (IEEE80211_3ADDR_LEN + ie_offset); - - /* check if this stat has been successfully authenticated/assocated */ - if (!((pstat->state) & WIFI_FW_AUTH_SUCCESS)) { - if (!((pstat->state) & WIFI_FW_ASSOC_SUCCESS)) { - status = WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA; - goto asoc_class2_error; - } else { - pstat->state &= (~WIFI_FW_ASSOC_SUCCESS); - pstat->state |= WIFI_FW_ASSOC_STATE; - } - } else { - pstat->state &= (~WIFI_FW_AUTH_SUCCESS); - pstat->state |= WIFI_FW_ASSOC_STATE; - } - pstat->capability = capab_info; - /* now parse all ieee802_11 ie to point to elems */ - if (rtw_ieee802_11_parse_elems(pos, left, &elems, 1) == ParseFailed || - !elems.ssid) { - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - goto OnAssocReqFail; - } - - /* now we should check all the fields... */ - /* checking SSID */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SSID, &ie_len, - pkt_len - WLAN_HDR_A3_LEN - ie_offset); - - if (!p || ie_len == 0) { - /* broadcast ssid, however it is not allowed in assocreq */ - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - goto OnAssocReqFail; - } else { - /* check if ssid match */ - if (memcmp((void *)(p + 2), cur->ssid.ssid, cur->ssid.ssid_length)) - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - - if (ie_len != cur->ssid.ssid_length) - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - } - - if (status != WLAN_STATUS_SUCCESS) - goto OnAssocReqFail; - - /* check if the supported rate is ok */ - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_SUPP_RATES, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (!p) { - /* use our own rate set as statoin used */ - /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ - /* supportRateNum = AP_BSSRATE_LEN; */ - - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - goto OnAssocReqFail; - } else { - memcpy(supportRate, p + 2, ie_len); - supportRateNum = ie_len; - - p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, WLAN_EID_EXT_SUPP_RATES, &ie_len, - pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p) { - if (supportRateNum <= sizeof(supportRate)) { - memcpy(supportRate + supportRateNum, - p + 2, ie_len); - supportRateNum += ie_len; - } - } - } - - /* todo: mask supportRate between AP & STA -> move to update raid */ - /* get_matched_rate(pmlmeext, supportRate, &supportRateNum, 0); */ - - /* update station supportRate */ - pstat->bssratelen = supportRateNum; - memcpy(pstat->bssrateset, supportRate, supportRateNum); - UpdateBrateTblForSoftAP(pstat->bssrateset, pstat->bssratelen); - - /* check RSN/WPA/WPS */ - pstat->dot8021xalg = 0; - pstat->wpa_psk = 0; - pstat->wpa_group_cipher = 0; - pstat->wpa2_group_cipher = 0; - pstat->wpa_pairwise_cipher = 0; - pstat->wpa2_pairwise_cipher = 0; - memset(pstat->wpa_ie, 0, sizeof(pstat->wpa_ie)); - if ((psecuritypriv->wpa_psk & BIT(1)) && elems.rsn_ie) { - int group_cipher = 0, pairwise_cipher = 0; - - wpa_ie = elems.rsn_ie; - wpa_ie_len = elems.rsn_ie_len; - - if (rtw_parse_wpa2_ie(wpa_ie - 2, wpa_ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { - pstat->dot8021xalg = 1;/* psk, todo:802.1x */ - pstat->wpa_psk |= BIT(1); - - pstat->wpa2_group_cipher = group_cipher & psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa2_pairwise_cipher; - - if (!pstat->wpa2_group_cipher) - status = WLAN_STATUS_INVALID_GROUP_CIPHER; - - if (!pstat->wpa2_pairwise_cipher) - status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - } else { - status = WLAN_STATUS_INVALID_IE; - } - } else if ((psecuritypriv->wpa_psk & BIT(0)) && elems.wpa_ie) { - int group_cipher = 0, pairwise_cipher = 0; - - wpa_ie = elems.wpa_ie; - wpa_ie_len = elems.wpa_ie_len; - - if (rtw_parse_wpa_ie(wpa_ie - 2, wpa_ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { - pstat->dot8021xalg = 1;/* psk, todo:802.1x */ - pstat->wpa_psk |= BIT(0); - - pstat->wpa_group_cipher = group_cipher & psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa_pairwise_cipher; - - if (!pstat->wpa_group_cipher) - status = WLAN_STATUS_INVALID_GROUP_CIPHER; - - if (!pstat->wpa_pairwise_cipher) - status = WLAN_STATUS_INVALID_PAIRWISE_CIPHER; - } else { - status = WLAN_STATUS_INVALID_IE; - } - } else { - wpa_ie = NULL; - wpa_ie_len = 0; - } - - if (status != WLAN_STATUS_SUCCESS) - goto OnAssocReqFail; - - pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); - if (!wpa_ie) { - if (elems.wps_ie) { - pstat->flags |= WLAN_STA_WPS; - /* wpabuf_free(sta->wps_ie); */ - /* sta->wps_ie = wpabuf_alloc_copy(elems.wps_ie + 4, */ - /* elems.wps_ie_len - 4); */ - } else { - pstat->flags |= WLAN_STA_MAYBE_WPS; - } - - /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ - /* that the selected registrar of AP is _FLASE */ - if ((psecuritypriv->wpa_psk > 0) && (pstat->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) { - if (pmlmepriv->wps_beacon_ie) { - u8 selected_registrar = 0; - - rtw_get_wps_attr_content(pmlmepriv->wps_beacon_ie, pmlmepriv->wps_beacon_ie_len, WPS_ATTR_SELECTED_REGISTRAR, &selected_registrar, NULL); - - if (!selected_registrar) { - status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - - goto OnAssocReqFail; - } - } - } - } else { - int copy_len; - - if (psecuritypriv->wpa_psk == 0) { - status = WLAN_STATUS_INVALID_IE; - - goto OnAssocReqFail; - } - - if (elems.wps_ie) { - pstat->flags |= WLAN_STA_WPS; - copy_len = 0; - } else { - copy_len = min_t(int, wpa_ie_len + 2, sizeof(pstat->wpa_ie)); - } - if (copy_len > 0) - memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len); - } - /* check if there is WMM IE & support WWM-PS */ - pstat->flags &= ~WLAN_STA_WME; - pstat->qos_option = 0; - pstat->qos_info = 0; - pstat->has_legacy_ac = true; - pstat->uapsd_vo = 0; - pstat->uapsd_vi = 0; - pstat->uapsd_be = 0; - pstat->uapsd_bk = 0; - if (pmlmepriv->qospriv.qos_option) { - p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; - for (;;) { - p = rtw_get_ie(p, WLAN_EID_VENDOR_SPECIFIC, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p) { - if (!memcmp(p + 2, WMM_IE, 6)) { - pstat->flags |= WLAN_STA_WME; - - pstat->qos_option = 1; - pstat->qos_info = *(p + 8); - - pstat->max_sp_len = (pstat->qos_info >> 5) & 0x3; - - if ((pstat->qos_info & 0xf) != 0xf) - pstat->has_legacy_ac = true; - else - pstat->has_legacy_ac = false; - - if (pstat->qos_info & 0xf) { - if (pstat->qos_info & BIT(0)) - pstat->uapsd_vo = BIT(0) | BIT(1); - else - pstat->uapsd_vo = 0; - - if (pstat->qos_info & BIT(1)) - pstat->uapsd_vi = BIT(0) | BIT(1); - else - pstat->uapsd_vi = 0; - - if (pstat->qos_info & BIT(2)) - pstat->uapsd_bk = BIT(0) | BIT(1); - else - pstat->uapsd_bk = 0; - - if (pstat->qos_info & BIT(3)) - pstat->uapsd_be = BIT(0) | BIT(1); - else - pstat->uapsd_be = 0; - } - break; - } - } else { - break; - } - p = p + ie_len + 2; - } - } - - /* save HT capabilities in the sta object */ - memset(&pstat->htpriv.ht_cap, 0, sizeof(struct ieee80211_ht_cap)); - if (elems.ht_capabilities && - elems.ht_capabilities_len >= sizeof(struct ieee80211_ht_cap)) { - pstat->flags |= WLAN_STA_HT; - - pstat->flags |= WLAN_STA_WME; - - memcpy(&pstat->htpriv.ht_cap, - elems.ht_capabilities, sizeof(struct ieee80211_ht_cap)); - } else { - pstat->flags &= ~WLAN_STA_HT; - } - if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags & WLAN_STA_HT)) { - status = WLAN_STATUS_UNSPECIFIED_FAILURE; - goto OnAssocReqFail; - } - - pstat->flags |= WLAN_STA_NONERP; - for (i = 0; i < pstat->bssratelen; i++) { - if ((pstat->bssrateset[i] & 0x7f) > 22) { - pstat->flags &= ~WLAN_STA_NONERP; - break; - } - } - - if (pstat->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) - pstat->flags |= WLAN_STA_SHORT_PREAMBLE; - else - pstat->flags &= ~WLAN_STA_SHORT_PREAMBLE; - - if (status != WLAN_STATUS_SUCCESS) - goto OnAssocReqFail; - - /* TODO: identify_proprietary_vendor_ie(); */ - /* Realtek proprietary IE */ - /* identify if this is Broadcom sta */ - /* identify if this is ralink sta */ - /* Customer proprietary IE */ - - /* get a unique AID */ - if (pstat->aid <= 0) { - for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++) - if (!pstapriv->sta_aid[pstat->aid - 1]) - break; - - /* if (pstat->aid > NUM_STA) { */ - if (pstat->aid > pstapriv->max_num_sta) { - pstat->aid = 0; - - status = WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA; - - goto OnAssocReqFail; - } else { - pstapriv->sta_aid[pstat->aid - 1] = pstat; - } - } - - pstat->state &= (~WIFI_FW_ASSOC_STATE); - pstat->state |= WIFI_FW_ASSOC_SUCCESS; - - spin_lock_bh(&pstapriv->auth_list_lock); - if (!list_empty(&pstat->auth_list)) { - list_del_init(&pstat->auth_list); - pstapriv->auth_list_cnt--; - } - spin_unlock_bh(&pstapriv->auth_list_lock); - - spin_lock_bh(&pstapriv->asoc_list_lock); - if (list_empty(&pstat->asoc_list)) { - pstat->expire_to = pstapriv->expire_to; - list_add_tail(&pstat->asoc_list, &pstapriv->asoc_list); - pstapriv->asoc_list_cnt++; - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - /* now the station is qualified to join our BSS... */ - if ((pstat->state & WIFI_FW_ASSOC_SUCCESS) && (status == WLAN_STATUS_SUCCESS)) { - /* 1 bss_cap_update & sta_info_update */ - bss_cap_update_on_sta_join(padapter, pstat); - sta_info_update(padapter, pstat); - - /* issue assoc rsp before notify station join event. */ - if (frame_type == IEEE80211_STYPE_ASSOC_REQ) - issue_asocrsp(padapter, status, pstat, IEEE80211_STYPE_ASSOC_RESP); - else - issue_asocrsp(padapter, status, pstat, IEEE80211_STYPE_REASSOC_RESP); - - /* 2 - report to upper layer */ - rtw_indicate_sta_assoc_event(padapter, pstat); - - /* 3-(1) report sta add event */ - report_add_sta_event(padapter, pstat->hwaddr, pstat->aid); - } - - return _SUCCESS; - -asoc_class2_error: - - issue_deauth(padapter, (void *)GetAddr2Ptr(pframe), status); - - return _FAIL; - -OnAssocReqFail: - - pstat->aid = 0; - if (frame_type == IEEE80211_STYPE_ASSOC_REQ) - issue_asocrsp(padapter, status, pstat, IEEE80211_STYPE_ASSOC_RESP); - else - issue_asocrsp(padapter, status, pstat, IEEE80211_STYPE_REASSOC_RESP); - -#endif /* CONFIG_88EU_AP_MODE */ - - return _FAIL; -} - -static unsigned int OnAssocRsp(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - uint i; - int res; - unsigned short status; - struct ndis_802_11_var_ie *pIE; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 *pframe = precv_frame->pkt->data; - uint pkt_len = precv_frame->pkt->len; - - /* check A1 matches or not */ - if (memcmp(myid(&padapter->eeprompriv), ieee80211_get_DA((struct ieee80211_hdr *)pframe), ETH_ALEN)) - return _SUCCESS; - - if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) - return _SUCCESS; - - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) - return _SUCCESS; - - del_timer_sync(&pmlmeext->link_timer); - - /* status */ - status = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 2)); - if (status > 0) { - pmlmeinfo->state = WIFI_FW_NULL_STATE; - res = -4; - goto report_assoc_result; - } - - /* get capabilities */ - pmlmeinfo->capability = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); - - /* set slot time */ - pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; - - /* AID */ - pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4)) & 0x3fff); - res = pmlmeinfo->aid; - - /* following are moved to join event callback function */ - /* to handle HT, WMM, rate adaptive, update MAC reg */ - /* for not to handle the synchronous IO in the tasklet */ - for (i = 6 + WLAN_HDR_A3_LEN; i < pkt_len;) { - pIE = (struct ndis_802_11_var_ie *)(pframe + i); - - switch (pIE->ElementID) { - case WLAN_EID_VENDOR_SPECIFIC: - if (!memcmp(pIE->data, WMM_PARA_OUI, 6)) /* WMM */ - WMM_param_handler(padapter, pIE); - break; - case WLAN_EID_HT_CAPABILITY: /* HT caps */ - HT_caps_handler(padapter, pIE); - break; - case WLAN_EID_HT_OPERATION: /* HT info */ - HT_info_handler(padapter, pIE); - break; - case WLAN_EID_ERP_INFO: - ERP_IE_handler(padapter, pIE); - break; - default: - break; - } - - i += (pIE->Length + 2); - } - - pmlmeinfo->state &= (~WIFI_FW_ASSOC_STATE); - pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; - - UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); - -report_assoc_result: - if (res > 0) - rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); - else - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); - - report_join_res(padapter, res); - - return _SUCCESS; -} - -static unsigned int OnDeAuth(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - unsigned short reason; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 *pframe = precv_frame->pkt->data; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - /* check A3 */ - if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) - return _SUCCESS; - - reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); - -#ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; - - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta) { - u8 updated = 0; - - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&psta->asoc_list)) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, false, reason); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - associated_clients_update(padapter, updated); - } - - return _SUCCESS; - } -#endif - receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); - - pmlmepriv->LinkDetectInfo.bBusyTraffic = false; - return _SUCCESS; -} - -static unsigned int OnDisassoc(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - u16 reason; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 *pframe = precv_frame->pkt->data; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - /* check A3 */ - if (memcmp(GetAddr3Ptr(pframe), pnetwork->MacAddress, ETH_ALEN)) - return _SUCCESS; - - reason = le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN)); - -#ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; - - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta) { - u8 updated = 0; - - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&psta->asoc_list)) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, false, reason); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - - associated_clients_update(padapter, updated); - } - - return _SUCCESS; - } -#endif - receive_disconnect(padapter, GetAddr3Ptr(pframe), reason); - - pmlmepriv->LinkDetectInfo.bBusyTraffic = false; - return _SUCCESS; -} - -static unsigned int OnAtim(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static unsigned int on_action_spct(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->pkt->data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - u8 category; - u8 action; - - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - - if (!psta) - goto exit; - - category = frame_body[0]; - if (category != RTW_WLAN_CATEGORY_SPECTRUM_MGMT) - goto exit; - - action = frame_body[1]; - switch (action) { - case WLAN_ACTION_SPCT_MSR_REQ: - case WLAN_ACTION_SPCT_MSR_RPRT: - case WLAN_ACTION_SPCT_TPC_REQ: - case WLAN_ACTION_SPCT_TPC_RPRT: - break; - case WLAN_ACTION_SPCT_CHL_SWITCH: - break; - default: - break; - } - -exit: - return _FAIL; -} - -static unsigned int OnAction_qos(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static unsigned int OnAction_dls(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static unsigned int OnAction_back(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - u8 *addr; - struct sta_info *psta = NULL; - struct recv_reorder_ctrl *preorder_ctrl; - unsigned char *frame_body; - unsigned char category, action; - unsigned short tid, status; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 *pframe = precv_frame->pkt->data; - struct sta_priv *pstapriv = &padapter->stapriv; - - /* check RA matches or not */ - if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), - ETH_ALEN))/* for if1, sta/ap mode */ - return _SUCCESS; - - if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) - if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) - return _SUCCESS; - - addr = GetAddr2Ptr(pframe); - psta = rtw_get_stainfo(pstapriv, addr); - - if (!psta) - return _SUCCESS; - - frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); - - category = frame_body[0]; - if (category == RTW_WLAN_CATEGORY_BACK) { /* representing Block Ack */ - if (!pmlmeinfo->HT_enable) - return _SUCCESS; - action = frame_body[1]; - switch (action) { - case WLAN_ACTION_ADDBA_REQ: - memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2], sizeof(struct ADDBA_request)); - process_addba_req(padapter, (u8 *)&pmlmeinfo->ADDBA_req, addr); - - /* 37 = reject ADDBA Req */ - issue_action_BA(padapter, addr, - WLAN_ACTION_ADDBA_RESP, - pmlmeinfo->accept_addba_req ? 0 : 37); - break; - case WLAN_ACTION_ADDBA_RESP: - status = get_unaligned_le16(&frame_body[3]); - tid = (frame_body[5] >> 2) & 0x7; - if (status == 0) { /* successful */ - psta->htpriv.agg_enable_bitmap |= 1 << tid; - psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); - } else { - psta->htpriv.agg_enable_bitmap &= ~BIT(tid); - } - break; - case WLAN_ACTION_DELBA: - if ((frame_body[3] & BIT(3)) == 0) { - psta->htpriv.agg_enable_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); - psta->htpriv.candidate_tid_bitmap &= ~(1 << ((frame_body[3] >> 4) & 0xf)); - } else if ((frame_body[3] & BIT(3)) == BIT(3)) { - tid = (frame_body[3] >> 4) & 0x0F; - preorder_ctrl = &psta->recvreorder_ctrl[tid]; - preorder_ctrl->enable = false; - preorder_ctrl->indicate_seq = 0xffff; - } - /* todo: how to notify the host while receiving DELETE BA */ - break; - default: - break; - } - } - return _SUCCESS; -} - -static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) -{ - struct adapter *adapter = recv_frame->adapter; - struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; - u8 *frame = recv_frame->pkt->data; - u16 seq_ctrl = ((recv_frame->attrib.seq_num & 0xffff) << 4) | - (recv_frame->attrib.frag_num & 0xf); - - if (GetRetry(frame)) { - if (token >= 0) { - if ((seq_ctrl == mlmeext->action_public_rxseq) && (token == mlmeext->action_public_dialog_token)) - return _FAIL; - } else { - if (seq_ctrl == mlmeext->action_public_rxseq) - return _FAIL; - } - } - - mlmeext->action_public_rxseq = seq_ctrl; - - if (token >= 0) - mlmeext->action_public_dialog_token = token; - - return _SUCCESS; -} - -static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) -{ - u8 *pframe = precv_frame->pkt->data; - u8 *frame_body; - u8 dialogToken = 0; - - frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); - dialogToken = frame_body[7]; - - if (rtw_action_public_decache(precv_frame, dialogToken) == _FAIL) - return _FAIL; - - return _SUCCESS; -} - -static unsigned int on_action_public_vendor(struct recv_frame *precv_frame) -{ - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->pkt->data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - - if (!memcmp(frame_body + 2, P2P_OUI, 4)) - ret = on_action_public_p2p(precv_frame); - - return ret; -} - -static unsigned int on_action_public_default(struct recv_frame *precv_frame, - u8 action) -{ - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->pkt->data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - u8 token; - - token = frame_body[2]; - - if (rtw_action_public_decache(precv_frame, token) == _FAIL) - goto exit; - - ret = _SUCCESS; - -exit: - return ret; -} - -static unsigned int on_action_public(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - unsigned int ret = _FAIL; - u8 *pframe = precv_frame->pkt->data; - u8 *frame_body = pframe + sizeof(struct ieee80211_hdr_3addr); - u8 category, action; - - /* check RA matches or not */ - if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), ETH_ALEN)) - goto exit; - - category = frame_body[0]; - if (category != RTW_WLAN_CATEGORY_PUBLIC) - goto exit; - - action = frame_body[1]; - switch (action) { - case ACT_PUBLIC_VENDOR: - ret = on_action_public_vendor(precv_frame); - break; - default: - ret = on_action_public_default(precv_frame, action); - break; - } - -exit: - return ret; -} - -static unsigned int OnAction_ht(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static unsigned int OnAction_wmm(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static unsigned int OnAction_p2p(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static unsigned int DoReserved(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - return _SUCCESS; -} - -static struct action_handler OnAction_tbl[] = { - {RTW_WLAN_CATEGORY_SPECTRUM_MGMT, "ACTION_SPECTRUM_MGMT", on_action_spct}, - {RTW_WLAN_CATEGORY_QOS, "ACTION_QOS", &OnAction_qos}, - {RTW_WLAN_CATEGORY_DLS, "ACTION_DLS", &OnAction_dls}, - {RTW_WLAN_CATEGORY_BACK, "ACTION_BACK", &OnAction_back}, - {RTW_WLAN_CATEGORY_PUBLIC, "ACTION_PUBLIC", on_action_public}, - {RTW_WLAN_CATEGORY_RADIO_MEASUREMENT, "ACTION_RADIO_MEASUREMENT", &DoReserved}, - {RTW_WLAN_CATEGORY_FT, "ACTION_FT", &DoReserved}, - {RTW_WLAN_CATEGORY_HT, "ACTION_HT", &OnAction_ht}, - {RTW_WLAN_CATEGORY_SA_QUERY, "ACTION_SA_QUERY", &DoReserved}, - {RTW_WLAN_CATEGORY_WMM, "ACTION_WMM", &OnAction_wmm}, - {RTW_WLAN_CATEGORY_P2P, "ACTION_P2P", &OnAction_p2p}, -}; - -static unsigned int OnAction(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - int i; - unsigned char category; - struct action_handler *ptable; - unsigned char *frame_body; - u8 *pframe = precv_frame->pkt->data; - - frame_body = (unsigned char *)(pframe + sizeof(struct ieee80211_hdr_3addr)); - - category = frame_body[0]; - - for (i = 0; i < ARRAY_SIZE(OnAction_tbl); i++) { - ptable = &OnAction_tbl[i]; - if (category == ptable->num) - ptable->func(padapter, precv_frame); - } - return _SUCCESS; -} - -/**************************************************************************** - -Following are the initialization functions for WiFi MLME - -*****************************************************************************/ - -static struct mlme_handler mlme_sta_tbl[] = { - {IEEE80211_STYPE_ASSOC_REQ, "OnAssocReq", &OnAssocReq}, - {IEEE80211_STYPE_ASSOC_RESP, "OnAssocRsp", &OnAssocRsp}, - {IEEE80211_STYPE_REASSOC_REQ, "OnReAssocReq", &OnAssocReq}, - {IEEE80211_STYPE_REASSOC_RESP, "OnReAssocRsp", &OnAssocRsp}, - {IEEE80211_STYPE_PROBE_REQ, "OnProbeReq", &OnProbeReq}, - {IEEE80211_STYPE_PROBE_RESP, "OnProbeRsp", &OnProbeRsp}, - {0, "DoReserved", &DoReserved}, - {0, "DoReserved", &DoReserved}, - {IEEE80211_STYPE_BEACON, "OnBeacon", &OnBeacon}, - {IEEE80211_STYPE_ATIM, "OnATIM", &OnAtim}, - {IEEE80211_STYPE_DISASSOC, "OnDisassoc", &OnDisassoc}, - {IEEE80211_STYPE_AUTH, "OnAuth", &OnAuthClient}, - {IEEE80211_STYPE_DEAUTH, "OnDeAuth", &OnDeAuth}, - {IEEE80211_STYPE_ACTION, "OnAction", &OnAction}, -}; - -int init_hw_mlme_ext(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - return _SUCCESS; -} - -static void init_mlme_ext_priv_value(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - unsigned char mixed_datarate[NumRates] = { - _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, - _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, - _48M_RATE_, _54M_RATE_, 0xff - }; - unsigned char mixed_basicrate[NumRates] = { - _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, - _12M_RATE_, _24M_RATE_, 0xff, - }; - - atomic_set(&pmlmeext->event_seq, 0); - pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ - - pmlmeext->cur_channel = padapter->registrypriv.channel; - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmlmeext->oper_channel = pmlmeext->cur_channel; - pmlmeext->oper_bwmode = pmlmeext->cur_bwmode; - pmlmeext->oper_ch_offset = pmlmeext->cur_ch_offset; - pmlmeext->retry = 0; - - pmlmeext->cur_wireless_mode = padapter->registrypriv.wireless_mode; - - memcpy(pmlmeext->datarate, mixed_datarate, NumRates); - memcpy(pmlmeext->basicrate, mixed_basicrate, NumRates); - - pmlmeext->tx_rate = IEEE80211_CCK_RATE_1MB; - - pmlmeext->sitesurvey_res.state = SCAN_DISABLE; - pmlmeext->sitesurvey_res.channel_idx = 0; - pmlmeext->sitesurvey_res.bss_cnt = 0; - pmlmeext->scan_abort = false; - - pmlmeinfo->state = WIFI_FW_NULL_STATE; - pmlmeinfo->reauth_count = 0; - pmlmeinfo->reassoc_count = 0; - pmlmeinfo->link_count = 0; - pmlmeinfo->auth_seq = 0; - pmlmeinfo->auth_algo = dot11AuthAlgrthm_Open; - pmlmeinfo->key_index = 0; - pmlmeinfo->iv = 0; - - pmlmeinfo->enc_algo = _NO_PRIVACY_; - pmlmeinfo->authModeToggle = 0; - - memset(pmlmeinfo->chg_txt, 0, 128); - - pmlmeinfo->slotTime = SHORT_SLOT_TIME; - pmlmeinfo->preamble_mode = PREAMBLE_AUTO; - - pmlmeinfo->dialogToken = 0; - - pmlmeext->action_public_rxseq = 0xffff; - pmlmeext->action_public_dialog_token = 0xff; -} - -static int has_channel(struct rt_channel_info *channel_set, - u8 chanset_size, u8 chan) -{ - int i; - - for (i = 0; i < chanset_size; i++) { - if (channel_set[i].ChannelNum == chan) - return 1; - } - return 0; -} - -static void init_channel_list(struct adapter *padapter, - struct rt_channel_info *channel_set, - u8 chanset_size, - struct p2p_channels *channel_list) -{ - struct p2p_oper_class_map op_class[] = { - { IEEE80211G, 81, 1, 13, 1, BW20 }, - { IEEE80211G, 82, 14, 14, 1, BW20 }, - { -1, 0, 0, 0, 0, BW20 } - }; - - int cla, op; - - cla = 0; - - for (op = 0; op_class[op].op_class; op++) { - u8 ch; - struct p2p_oper_class_map *o = &op_class[op]; - struct p2p_reg_class *reg = NULL; - - for (ch = o->min_chan; ch <= o->max_chan; ch += o->inc) { - if (!has_channel(channel_set, chanset_size, ch)) - continue; - - if (!padapter->registrypriv.ht_enable && o->inc == 8) - continue; - - if ((0 == (padapter->registrypriv.cbw40_enable & BIT(1))) && - ((o->bw == BW40MINUS) || (o->bw == BW40PLUS))) - continue; - - if (!reg) { - reg = &channel_list->reg_class[cla]; - cla++; - reg->reg_class = o->op_class; - reg->channels = 0; - } - reg->channel[reg->channels] = ch; - reg->channels++; - } - } - channel_list->reg_classes = cla; -} - -static u8 init_channel_set(struct adapter *padapter, u8 ChannelPlan, - struct rt_channel_info *channel_set) -{ - u8 index, chanset_size = 0; - u8 b2_4GBand = false; - u8 Index2G = 0; - - memset(channel_set, 0, sizeof(struct rt_channel_info) * MAX_CHANNEL_NUM); - - if (ChannelPlan >= RT_CHANNEL_DOMAIN_MAX && ChannelPlan != RT_CHANNEL_DOMAIN_REALTEK_DEFINE) - return chanset_size; - - if (padapter->registrypriv.wireless_mode & WIRELESS_11G) { - b2_4GBand = true; - if (ChannelPlan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) - Index2G = RTW_CHANNEL_PLAN_MAP_REALTEK_DEFINE.Index2G; - else - Index2G = RTW_ChannelPlanMap[ChannelPlan].Index2G; - } - - if (b2_4GBand) { - for (index = 0; index < RTW_ChannelPlan2G[Index2G].Len; index++) { - channel_set[chanset_size].ChannelNum = RTW_ChannelPlan2G[Index2G].Channel[index]; - - if ((ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN) ||/* Channel 1~11 is active, and 12~14 is passive */ - (ChannelPlan == RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G)) { - if (channel_set[chanset_size].ChannelNum >= 1 && channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - else if ((channel_set[chanset_size].ChannelNum >= 12 && channel_set[chanset_size].ChannelNum <= 14)) - channel_set[chanset_size].ScanType = SCAN_PASSIVE; - } else if (ChannelPlan == RT_CHANNEL_DOMAIN_WORLD_WIDE_13 || - Index2G == RT_CHANNEL_DOMAIN_2G_WORLD) {/* channel 12~13, passive scan */ - if (channel_set[chanset_size].ChannelNum <= 11) - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - else - channel_set[chanset_size].ScanType = SCAN_PASSIVE; - } else { - channel_set[chanset_size].ScanType = SCAN_ACTIVE; - } - - chanset_size++; - } - } - return chanset_size; -} - -int init_mlme_ext_priv(struct adapter *padapter) -{ - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - init_mlme_ext_priv_value(padapter); - pmlmeinfo->accept_addba_req = pregistrypriv->accept_addba_req; - - init_mlme_ext_timer(padapter); - -#ifdef CONFIG_88EU_AP_MODE - init_mlme_ap_info(padapter); -#endif - - pmlmeext->max_chan_nums = init_channel_set(padapter, pmlmepriv->ChannelPlan, pmlmeext->channel_set); - init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); - - pmlmeext->chan_scan_time = SURVEY_TO; - pmlmeext->mlmeext_init = true; - - pmlmeext->active_keep_alive_check = true; - - return _SUCCESS; -} - -void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext) -{ - struct adapter *padapter = container_of(pmlmeext, struct adapter, mlmeextpriv); - - if (padapter->bDriverStopped) { - del_timer_sync(&pmlmeext->survey_timer); - del_timer_sync(&pmlmeext->link_timer); - } -} - -static void _mgt_dispatcher(struct adapter *padapter, - struct mlme_handler *ptable, - struct recv_frame *precv_frame) -{ - u8 *pframe = precv_frame->pkt->data; - - if (ptable->func) { - /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) - return; - ptable->func(padapter, precv_frame); - } -} - -void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) -{ - int index; - struct mlme_handler *ptable; -#ifdef CONFIG_88EU_AP_MODE - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; -#endif - u8 *pframe = precv_frame->pkt->data; - struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); - - if (GetFrameType(pframe) != WIFI_MGT_TYPE) - return; - - /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ - if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && - !is_broadcast_ether_addr(GetAddr1Ptr(pframe))) - return; - - ptable = mlme_sta_tbl; - - index = GetFrameSubType(pframe) >> 4; - - if (index > 13) - return; - ptable += index; - - if (psta) { - if (GetRetry(pframe)) { - if (precv_frame->attrib.seq_num == - psta->RxMgmtFrameSeqNum) - /* drop the duplicate management frame */ - return; - } - psta->RxMgmtFrameSeqNum = precv_frame->attrib.seq_num; - } - -#ifdef CONFIG_88EU_AP_MODE - switch (GetFrameSubType(pframe)) { - case IEEE80211_STYPE_AUTH: - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - ptable->func = &OnAuth; - else - ptable->func = &OnAuthClient; - fallthrough; - case IEEE80211_STYPE_ASSOC_REQ: - case IEEE80211_STYPE_REASSOC_REQ: - case IEEE80211_STYPE_PROBE_REQ: - case IEEE80211_STYPE_BEACON: - case IEEE80211_STYPE_ACTION: - _mgt_dispatcher(padapter, ptable, precv_frame); - break; - default: - _mgt_dispatcher(padapter, ptable, precv_frame); - break; - } -#else - _mgt_dispatcher(padapter, ptable, precv_frame); -#endif -} - -/**************************************************************************** - -Following are the functions to report events - -*****************************************************************************/ - -void report_survey_event(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct cmd_obj *pcmd_obj; - u8 *pevtcmd; - u32 cmdsz; - struct survey_event *psurvey_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext; - struct cmd_priv *pcmdpriv; - - if (!padapter) - return; - - pmlmeext = &padapter->mlmeextpriv; - pcmdpriv = &padapter->cmdpriv; - - pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!pcmd_obj) - return; - - cmdsz = sizeof(struct survey_event) + sizeof(struct C2HEvent_Header); - pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); - if (!pevtcmd) { - kfree(pcmd_obj); - return; - } - - INIT_LIST_HEAD(&pcmd_obj->list); - - pcmd_obj->cmdcode = _Set_MLME_EVT_CMD_; - pcmd_obj->cmdsz = cmdsz; - pcmd_obj->parmbuf = pevtcmd; - - pcmd_obj->rsp = NULL; - pcmd_obj->rspsz = 0; - - pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); - pc2h_evt_hdr->len = sizeof(struct survey_event); - pc2h_evt_hdr->ID = _Survey_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); - - psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - - if (collect_bss_info(padapter, precv_frame, &psurvey_evt->bss) == _FAIL) { - kfree(pcmd_obj); - kfree(pevtcmd); - return; - } - - process_80211d(padapter, &psurvey_evt->bss); - - rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - pmlmeext->sitesurvey_res.bss_cnt++; -} - -void report_surveydone_event(struct adapter *padapter) -{ - struct cmd_obj *pcmd_obj; - u8 *pevtcmd; - u32 cmdsz; - struct surveydone_event *psurveydone_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd_obj) - return; - - cmdsz = sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header); - pevtcmd = kzalloc(cmdsz, GFP_KERNEL); - if (!pevtcmd) { - kfree(pcmd_obj); - return; - } - - INIT_LIST_HEAD(&pcmd_obj->list); - - pcmd_obj->cmdcode = _Set_MLME_EVT_CMD_; - pcmd_obj->cmdsz = cmdsz; - pcmd_obj->parmbuf = pevtcmd; - - pcmd_obj->rsp = NULL; - pcmd_obj->rspsz = 0; - - pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); - pc2h_evt_hdr->len = sizeof(struct surveydone_event); - pc2h_evt_hdr->ID = _SurveyDone_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); - - psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; - - rtw_enqueue_cmd(pcmdpriv, pcmd_obj); -} - -void report_join_res(struct adapter *padapter, int res) -{ - struct cmd_obj *pcmd_obj; - u8 *pevtcmd; - u32 cmdsz; - struct joinbss_event *pjoinbss_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!pcmd_obj) - return; - - cmdsz = sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header); - pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); - if (!pevtcmd) { - kfree(pcmd_obj); - return; - } - - INIT_LIST_HEAD(&pcmd_obj->list); - - pcmd_obj->cmdcode = _Set_MLME_EVT_CMD_; - pcmd_obj->cmdsz = cmdsz; - pcmd_obj->parmbuf = pevtcmd; - - pcmd_obj->rsp = NULL; - pcmd_obj->rspsz = 0; - - pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); - pc2h_evt_hdr->len = sizeof(struct joinbss_event); - pc2h_evt_hdr->ID = _JoinBss_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); - - pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - memcpy((unsigned char *)(&pjoinbss_evt->network.network), &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); - pjoinbss_evt->network.join_res = res; - pjoinbss_evt->network.aid = res; - - rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network); - - rtw_enqueue_cmd(pcmdpriv, pcmd_obj); -} - -void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, - unsigned short reason) -{ - struct cmd_obj *pcmd_obj; - u8 *pevtcmd; - u32 cmdsz; - struct sta_info *psta; - int mac_id; - struct stadel_event *pdel_sta_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd_obj) - return; - - cmdsz = sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header); - pevtcmd = kzalloc(cmdsz, GFP_KERNEL); - if (!pevtcmd) { - kfree(pcmd_obj); - return; - } - - INIT_LIST_HEAD(&pcmd_obj->list); - - pcmd_obj->cmdcode = _Set_MLME_EVT_CMD_; - pcmd_obj->cmdsz = cmdsz; - pcmd_obj->parmbuf = pevtcmd; - - pcmd_obj->rsp = NULL; - pcmd_obj->rspsz = 0; - - pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); - pc2h_evt_hdr->len = sizeof(struct stadel_event); - pc2h_evt_hdr->ID = _DelSTA_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); - - pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - ether_addr_copy((unsigned char *)(&pdel_sta_evt->macaddr), MacAddr); - memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); - - psta = rtw_get_stainfo(&padapter->stapriv, MacAddr); - if (psta) - mac_id = (int)psta->mac_id; - else - mac_id = -1; - - pdel_sta_evt->mac_id = mac_id; - - rtw_enqueue_cmd(pcmdpriv, pcmd_obj); -} - -void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, - int cam_idx) -{ - struct cmd_obj *pcmd_obj; - u8 *pevtcmd; - u32 cmdsz; - struct stassoc_event *padd_sta_evt; - struct C2HEvent_Header *pc2h_evt_hdr; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - - pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd_obj) - return; - - cmdsz = sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header); - pevtcmd = kzalloc(cmdsz, GFP_KERNEL); - if (!pevtcmd) { - kfree(pcmd_obj); - return; - } - - INIT_LIST_HEAD(&pcmd_obj->list); - - pcmd_obj->cmdcode = _Set_MLME_EVT_CMD_; - pcmd_obj->cmdsz = cmdsz; - pcmd_obj->parmbuf = pevtcmd; - - pcmd_obj->rsp = NULL; - pcmd_obj->rspsz = 0; - - pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); - pc2h_evt_hdr->len = sizeof(struct stassoc_event); - pc2h_evt_hdr->ID = _AddSTA_EVT_; - pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); - - padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - ether_addr_copy((unsigned char *)(&padd_sta_evt->macaddr), MacAddr); - padd_sta_evt->cam_id = cam_idx; - - rtw_enqueue_cmd(pcmdpriv, pcmd_obj); -} - -/**************************************************************************** - -Following are the event callback functions - -*****************************************************************************/ - -/* for sta/adhoc mode */ -void update_sta_info(struct adapter *padapter, struct sta_info *psta) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - /* ERP */ - VCS_update(padapter, psta); - - /* HT */ - if (pmlmepriv->htpriv.ht_option) { - psta->htpriv.ht_option = true; - - psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; - - if (support_short_GI(padapter, &pmlmeinfo->HT_caps)) - psta->htpriv.sgi = true; - - psta->qos_option = true; - } else { - psta->htpriv.ht_option = false; - - psta->htpriv.ampdu_enable = false; - - psta->htpriv.sgi = false; - psta->qos_option = false; - } - psta->htpriv.bwmode = pmlmeext->cur_bwmode; - psta->htpriv.ch_offset = pmlmeext->cur_ch_offset; - - psta->htpriv.agg_enable_bitmap = 0x0;/* reset */ - psta->htpriv.candidate_tid_bitmap = 0x0;/* reset */ - - /* QoS */ - if (pmlmepriv->qospriv.qos_option) - psta->qos_option = true; - - psta->state = _FW_LINKED; -} - -void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) -{ - struct sta_info *psta, *psta_bmc; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 join_type; - u16 media_status; - - if (join_res < 0) { - join_type = 1; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); - - /* restore to initial setting. */ - update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); - - return; - } - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - /* for bc/mc */ - psta_bmc = rtw_get_bcmc_stainfo(padapter); - if (psta_bmc) { - pmlmeinfo->FW_sta_info[psta_bmc->mac_id].psta = psta_bmc; - update_bmc_sta_support_rate(padapter, psta_bmc->mac_id); - Update_RA_Entry(padapter, psta_bmc->mac_id); - } - } - - /* turn on dynamic functions */ - Switch_DM_Func(padapter, DYNAMIC_ALL_FUNC_ENABLE, true); - - /* update IOT-related issue */ - update_IOT_info(padapter); - - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, cur_network->SupportedRates); - - /* BCN interval */ - rtw_hal_set_hwreg(padapter, HW_VAR_BEACON_INTERVAL, (u8 *)(&pmlmeinfo->bcn_interval)); - - /* update capability */ - update_capinfo(padapter, pmlmeinfo->capability); - - /* WMM, Update EDCA param */ - WMMOnAssocRsp(padapter); - - /* HT */ - HTOnAssocRsp(padapter); - - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); - if (psta) { /* only for infra. mode */ - pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; - - psta->wireless_mode = pmlmeext->cur_wireless_mode; - - /* set per sta rate after updating HT cap. */ - set_sta_rate(padapter, psta); - rtw_hal_set_hwreg(padapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&psta->mac_id); - media_status = (psta->mac_id << 8) | 1; /* MACID|OPMODE: 1 means connect */ - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); - } - - join_type = 2; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { - /* correcting TSF */ - correct_TSF(padapter, pmlmeext); - } - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_CONNECT, 0); -} - -void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 join_type; - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {/* adhoc master or sta_count>1 */ - /* nothing to do */ - } else { /* adhoc client */ - /* correcting TSF */ - correct_TSF(padapter, pmlmeext); - - /* start beacon */ - if (send_beacon(padapter) == _FAIL) { - pmlmeinfo->FW_sta_info[psta->mac_id].status = 0; - pmlmeinfo->state ^= WIFI_FW_ADHOC_STATE; - return; - } - pmlmeinfo->state |= WIFI_FW_ASSOC_SUCCESS; - } - - join_type = 2; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - } - - pmlmeinfo->FW_sta_info[psta->mac_id].psta = psta; - - /* rate radaptive */ - Update_RA_Entry(padapter, psta->mac_id); - - /* update adhoc sta_info */ - update_sta_info(padapter, psta); -} - -void mlmeext_sta_del_event_callback(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); - - /* restore to initial setting. */ - update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); - - /* switch to the 20M Hz mode after disconnect */ - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - /* SelectChannel(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset); */ - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - flush_all_cam_entry(padapter); - - pmlmeinfo->state = WIFI_FW_NULL_STATE; - - /* set MSR to no link state -> infra. mode */ - Set_MSR(padapter, _HW_STATE_STATION_); - - del_timer_sync(&pmlmeext->link_timer); - } -} - -/**************************************************************************** - -Following are the functions for the timer handlers - -*****************************************************************************/ - -static u8 chk_ap_is_alive(struct adapter *padapter, struct sta_info *psta) -{ - u8 ret = false; - - if ((sta_rx_data_pkts(psta) == sta_last_rx_data_pkts(psta)) && - sta_rx_beacon_pkts(psta) == sta_last_rx_beacon_pkts(psta) && - sta_rx_probersp_pkts(psta) == sta_last_rx_probersp_pkts(psta)) - ret = false; - else - ret = true; - - sta_update_last_rx_pkts(psta); - - return ret; -} - -void linked_status_chk(struct adapter *padapter) -{ - u32 i; - struct sta_info *psta; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (is_client_associated_to_ap(padapter)) { - /* linked infrastructure client mode */ - - int tx_chk = _SUCCESS, rx_chk = _SUCCESS; - int rx_chk_limit; - - rx_chk_limit = 4; - psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); - if (psta) { - bool is_p2p_enable = false; - - if (!chk_ap_is_alive(padapter, psta)) - rx_chk = _FAIL; - - if (pxmitpriv->last_tx_pkts == pxmitpriv->tx_pkts) - tx_chk = _FAIL; - - if (pmlmeext->active_keep_alive_check && (rx_chk == _FAIL || tx_chk == _FAIL)) { - u8 backup_oper_channel = 0; - - /* switch to correct channel of current network before issue keep-alive frames */ - if (rtw_get_oper_ch(padapter) != pmlmeext->cur_channel) { - backup_oper_channel = rtw_get_oper_ch(padapter); - SelectChannel(padapter, pmlmeext->cur_channel); - } - - if (rx_chk != _SUCCESS) - issue_probereq_ex(padapter, &pmlmeinfo->network.ssid, psta->hwaddr, 3, 1); - - if ((tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) || rx_chk != _SUCCESS) { - tx_chk = issue_nulldata(padapter, psta->hwaddr, 0, 3, 1); - /* if tx acked and p2p disabled, set rx_chk _SUCCESS to reset retry count */ - if (tx_chk == _SUCCESS && !is_p2p_enable) - rx_chk = _SUCCESS; - } - - /* back to the original operation channel */ - if (backup_oper_channel > 0) - SelectChannel(padapter, backup_oper_channel); - } else { - if (rx_chk != _SUCCESS) { - if (pmlmeext->retry == 0) { - issue_probereq(padapter, &pmlmeinfo->network.ssid, - pmlmeinfo->network.MacAddress, - false); - issue_probereq(padapter, &pmlmeinfo->network.ssid, - pmlmeinfo->network.MacAddress, - false); - issue_probereq(padapter, &pmlmeinfo->network.ssid, - pmlmeinfo->network.MacAddress, - false); - } - } - - if (tx_chk != _SUCCESS && pmlmeinfo->link_count++ == 0xf) - tx_chk = issue_nulldata(padapter, NULL, 0, 1, 0); - } - - if (rx_chk == _FAIL) { - pmlmeext->retry++; - if (pmlmeext->retry > rx_chk_limit) { - receive_disconnect(padapter, pmlmeinfo->network.MacAddress, - WLAN_REASON_EXPIRATION_CHK); - return; - } - } else { - pmlmeext->retry = 0; - } - - if (tx_chk == _FAIL) { - pmlmeinfo->link_count &= 0xf; - } else { - pxmitpriv->last_tx_pkts = pxmitpriv->tx_pkts; - pmlmeinfo->link_count = 0; - } - } /* end of if ((psta = rtw_get_stainfo(pstapriv, passoc_res->network.MacAddress)) != NULL) */ - } else if (is_client_associated_to_ibss(padapter)) { - /* linked IBSS mode */ - /* for each assoc list entry to check the rx pkt counter */ - for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { - if (pmlmeinfo->FW_sta_info[i].status == 1) { - psta = pmlmeinfo->FW_sta_info[i].psta; - - if (!psta) - continue; - if (pmlmeinfo->FW_sta_info[i].rx_pkt == sta_rx_pkts(psta)) { - if (pmlmeinfo->FW_sta_info[i].retry < 3) { - pmlmeinfo->FW_sta_info[i].retry++; - } else { - pmlmeinfo->FW_sta_info[i].retry = 0; - pmlmeinfo->FW_sta_info[i].status = 0; - report_del_sta_event(padapter, psta->hwaddr - , 65535/* indicate disconnect caused by no rx */ - ); - } - } else { - pmlmeinfo->FW_sta_info[i].retry = 0; - pmlmeinfo->FW_sta_info[i].rx_pkt = (u32)sta_rx_pkts(psta); - } - } - } - } -} - -void survey_timer_hdl(struct timer_list *t) -{ - struct adapter *padapter = from_timer(padapter, t, - mlmeextpriv.survey_timer); - struct cmd_obj *ph2c; - struct sitesurvey_parm *psurveyPara; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - /* issue rtw_sitesurvey_cmd */ - if (pmlmeext->sitesurvey_res.state > SCAN_START) { - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) - pmlmeext->sitesurvey_res.channel_idx++; - - if (pmlmeext->scan_abort) { - pmlmeext->sitesurvey_res.channel_idx = pmlmeext->sitesurvey_res.ch_num; - - pmlmeext->scan_abort = false;/* reset */ - } - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) - goto exit_survey_timer_hdl; - - psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); - if (!psurveyPara) { - kfree(ph2c); - goto exit_survey_timer_hdl; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, _SiteSurvey_CMD_); - rtw_enqueue_cmd(pcmdpriv, ph2c); - } - -exit_survey_timer_hdl: - return; -} - -void link_timer_hdl(struct timer_list *t) -{ - struct adapter *padapter = from_timer(padapter, t, - mlmeextpriv.link_timer); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { - pmlmeinfo->state = WIFI_FW_NULL_STATE; - report_join_res(padapter, -3); - } else if (pmlmeinfo->state & WIFI_FW_AUTH_STATE) { - /* re-auth timer */ - if (++pmlmeinfo->reauth_count > REAUTH_LIMIT) { - pmlmeinfo->state = 0; - report_join_res(padapter, -1); - return; - } - - pmlmeinfo->auth_seq = 1; - issue_auth(padapter, NULL, 0); - set_link_timer(pmlmeext, REAUTH_TO); - } else if (pmlmeinfo->state & WIFI_FW_ASSOC_STATE) { - /* re-assoc timer */ - if (++pmlmeinfo->reassoc_count > REASSOC_LIMIT) { - pmlmeinfo->state = WIFI_FW_NULL_STATE; - report_join_res(padapter, -2); - return; - } - - issue_assocreq(padapter); - set_link_timer(pmlmeext, REASSOC_TO); - } -} - -void addba_timer_hdl(struct timer_list *t) -{ - struct sta_info *psta = from_timer(psta, t, addba_retry_timer); - struct ht_priv *phtpriv; - - if (!psta) - return; - - phtpriv = &psta->htpriv; - - if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { - if (phtpriv->candidate_tid_bitmap) - phtpriv->candidate_tid_bitmap = 0x0; - } -} - -u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) -{ - u8 type; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; - - if (psetop->mode == Ndis802_11APMode) { - pmlmeinfo->state = WIFI_FW_AP_STATE; - type = _HW_STATE_AP_; - } else if (psetop->mode == Ndis802_11Infrastructure) { - pmlmeinfo->state &= ~(BIT(0) | BIT(1));/* clear state */ - pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ - type = _HW_STATE_STATION_; - } else if (psetop->mode == Ndis802_11IBSS) { - type = _HW_STATE_ADHOC_; - } else { - type = _HW_STATE_NOLINK_; - } - - rtw_hal_set_hwreg(padapter, HW_VAR_SET_OPMODE, (u8 *)(&type)); - /* Set_MSR(padapter, type); */ - - return H2C_SUCCESS; -} - -u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; - - if (pparm->InfrastructureMode == Ndis802_11APMode) { -#ifdef CONFIG_88EU_AP_MODE - - if (pmlmeinfo->state == WIFI_FW_AP_STATE) { - /* todo: */ - return H2C_SUCCESS; - } -#endif - } - - /* below is for ad-hoc master */ - if (pparm->InfrastructureMode == Ndis802_11IBSS) { - rtw_joinbss_reset(padapter); - - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmlmeinfo->ERP_enable = 0; - pmlmeinfo->WMM_enable = 0; - pmlmeinfo->HT_enable = 0; - pmlmeinfo->HT_caps_enable = 0; - pmlmeinfo->HT_info_enable = 0; - pmlmeinfo->agg_enable_bitmap = 0; - pmlmeinfo->candidate_tid_bitmap = 0; - - /* disable dynamic functions, such as high power, DIG */ - Save_DM_Func_Flag(padapter); - Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); - - /* config the initial gain under linking, need to write the BB registers */ - /* initialgain = 0x1E; */ - /* rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); */ - - /* cancel link timer */ - del_timer_sync(&pmlmeext->link_timer); - - /* clear CAM */ - flush_all_cam_entry(padapter); - - memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, ie_length)); - pnetwork->ie_length = ((struct wlan_bssid_ex *)pbuf)->ie_length; - - if (pnetwork->ie_length > MAX_IE_SZ)/* Check pbuf->ie_length */ - return H2C_PARAMETERS_ERROR; - - memcpy(pnetwork->ies, ((struct wlan_bssid_ex *)pbuf)->ies, pnetwork->ie_length); - - start_create_ibss(padapter); - } - - return H2C_SUCCESS; -} - -u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) -{ - u8 join_type; - struct ndis_802_11_var_ie *pIE; - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - struct wlan_bssid_ex *pparm = (struct wlan_bssid_ex *)pbuf; - u32 i; - - /* check already connecting to AP or not */ - if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { - if (pmlmeinfo->state & WIFI_FW_STATION_STATE) - issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, 5, 100); - - pmlmeinfo->state = WIFI_FW_NULL_STATE; - - /* clear CAM */ - flush_all_cam_entry(padapter); - - del_timer_sync(&pmlmeext->link_timer); - - /* set MSR to nolink -> infra. mode */ - Set_MSR(padapter, _HW_STATE_STATION_); - - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); - } - - rtw_antenna_select_cmd(padapter, pparm->PhyInfo.Optimum_antenna, false); - - rtw_joinbss_reset(padapter); - - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - pmlmeinfo->ERP_enable = 0; - pmlmeinfo->WMM_enable = 0; - pmlmeinfo->HT_enable = 0; - pmlmeinfo->HT_caps_enable = 0; - pmlmeinfo->HT_info_enable = 0; - pmlmeinfo->agg_enable_bitmap = 0; - pmlmeinfo->candidate_tid_bitmap = 0; - pmlmeinfo->bwmode_updated = false; - - memcpy(pnetwork, pbuf, offsetof(struct wlan_bssid_ex, ie_length)); - pnetwork->ie_length = ((struct wlan_bssid_ex *)pbuf)->ie_length; - - if (pnetwork->ie_length > MAX_IE_SZ)/* Check pbuf->ie_length */ - return H2C_PARAMETERS_ERROR; - - memcpy(pnetwork->ies, ((struct wlan_bssid_ex *)pbuf)->ies, pnetwork->ie_length); - - /* Check AP vendor to move rtw_joinbss_cmd() */ - - for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->ie_length;) { - pIE = (struct ndis_802_11_var_ie *)(pnetwork->ies + i); - - switch (pIE->ElementID) { - case WLAN_EID_VENDOR_SPECIFIC:/* Get WMM IE. */ - if (!memcmp(pIE->data, WMM_OUI, 4)) - pmlmeinfo->WMM_enable = 1; - break; - case WLAN_EID_HT_CAPABILITY: /* Get HT Cap IE. */ - pmlmeinfo->HT_caps_enable = 1; - break; - case WLAN_EID_HT_OPERATION: /* Get HT Info IE. */ - pmlmeinfo->HT_info_enable = 1; - - /* spec case only for cisco's ap because cisco's ap issue assoc rsp using mcs rate @40MHz or @20MHz */ - { - struct HT_info_element *pht_info = (struct HT_info_element *)(pIE->data); - - if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { - /* switch to the 40M Hz mode according to the AP */ - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_40; - switch (pht_info->infos[0] & 0x3) { - case 1: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; - case 3: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; - default: - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; - } - } - } - break; - default: - break; - } - - i += (pIE->Length + 2); - } - /* disable dynamic functions, such as high power, DIG */ - - /* config the initial gain under linking, need to write the BB registers */ - - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, pmlmeinfo->network.MacAddress); - join_type = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - - /* cancel link timer */ - del_timer_sync(&pmlmeext->link_timer); - - start_clnt_join(padapter); - - return H2C_SUCCESS; -} - -u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - struct disconnect_parm *param = (struct disconnect_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - u8 val8; - - if (is_client_associated_to_ap(padapter)) - issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms / 100, 100); - - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); - rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); - - /* restore to initial setting. */ - update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); - - if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { - /* Stop BCN */ - val8 = 0; - rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); - } - - /* set MSR to no link state -> infra. mode */ - Set_MSR(padapter, _HW_STATE_STATION_); - - pmlmeinfo->state = WIFI_FW_NULL_STATE; - - /* switch to the 20M Hz mode after disconnect */ - pmlmeext->cur_bwmode = HT_CHANNEL_WIDTH_20; - pmlmeext->cur_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - - set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); - - flush_all_cam_entry(padapter); - - del_timer_sync(&pmlmeext->link_timer); - - rtw_free_uc_swdec_pending_queue(padapter); - - return H2C_SUCCESS; -} - -static int rtw_scan_ch_decision(struct adapter *padapter, - struct rtw_ieee80211_channel *out, - u32 out_num, - struct rtw_ieee80211_channel *in, u32 in_num) -{ - int i, j; - int set_idx; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - /* clear out first */ - memset(out, 0, sizeof(struct rtw_ieee80211_channel) * out_num); - - /* acquire channels from in */ - j = 0; - for (i = 0; i < in_num; i++) { - set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, in[i].hw_value); - if (in[i].hw_value && !(in[i].flags & RTW_IEEE80211_CHAN_DISABLED) && - set_idx >= 0) { - out[j] = in[i]; - - if (pmlmeext->channel_set[set_idx].ScanType == SCAN_PASSIVE) - out[j].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; - - j++; - } - if (j >= out_num) - break; - } - - /* if out is empty, use channel_set as default */ - if (j == 0) { - for (i = 0; i < pmlmeext->max_chan_nums; i++) { - out[i].hw_value = pmlmeext->channel_set[i].ChannelNum; - - if (pmlmeext->channel_set[i].ScanType == SCAN_PASSIVE) - out[i].flags &= RTW_IEEE80211_CHAN_PASSIVE_SCAN; - - j++; - } - } - - return j; -} - -u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct sitesurvey_parm *pparm = (struct sitesurvey_parm *)pbuf; - u8 bdelayscan = false; - u8 val8; - u32 initialgain; - u32 i; - - if (pmlmeext->sitesurvey_res.state == SCAN_DISABLE) { - /* for first time sitesurvey_cmd */ - rtw_hal_set_hwreg(padapter, HW_VAR_CHECK_TXBUF, NULL); - - pmlmeext->sitesurvey_res.state = SCAN_START; - pmlmeext->sitesurvey_res.bss_cnt = 0; - pmlmeext->sitesurvey_res.channel_idx = 0; - - for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { - if (pparm->ssid[i].ssid_length) { - memcpy(pmlmeext->sitesurvey_res.ssid[i].ssid, pparm->ssid[i].ssid, IW_ESSID_MAX_SIZE); - pmlmeext->sitesurvey_res.ssid[i].ssid_length = pparm->ssid[i].ssid_length; - } else { - pmlmeext->sitesurvey_res.ssid[i].ssid_length = 0; - } - } - - pmlmeext->sitesurvey_res.ch_num = rtw_scan_ch_decision(padapter - , pmlmeext->sitesurvey_res.ch, RTW_CHANNEL_SCAN_AMOUNT - , pparm->ch, pparm->ch_num - ); - - pmlmeext->sitesurvey_res.scan_mode = pparm->scan_mode; - - /* issue null data if associating to the AP */ - if (is_client_associated_to_ap(padapter)) { - pmlmeext->sitesurvey_res.state = SCAN_TXNULL; - - issue_nulldata(padapter, NULL, 1, 3, 500); - - bdelayscan = true; - } - if (bdelayscan) { - /* delay 50ms to protect nulldata(1). */ - set_survey_timer(pmlmeext, 50); - return H2C_SUCCESS; - } - } - - if ((pmlmeext->sitesurvey_res.state == SCAN_START) || (pmlmeext->sitesurvey_res.state == SCAN_TXNULL)) { - /* disable dynamic functions, such as high power, DIG */ - Save_DM_Func_Flag(padapter); - Switch_DM_Func(padapter, DYNAMIC_FUNC_DISABLE, false); - - /* config the initial gain under scanning, need to write the BB registers */ - initialgain = 0x1E; - - rtw_hal_set_hwreg(padapter, HW_VAR_INITIAL_GAIN, (u8 *)(&initialgain)); - - /* set MSR to no link state */ - Set_MSR(padapter, _HW_STATE_NOLINK_); - - val8 = 1; /* under site survey */ - rtw_hal_set_hwreg(padapter, HW_VAR_MLME_SITESURVEY, (u8 *)(&val8)); - - pmlmeext->sitesurvey_res.state = SCAN_PROCESS; - } - - site_survey(padapter); - - return H2C_SUCCESS; -} - -u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - struct setauth_parm *pparm = (struct setauth_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pparm->mode < 4) - pmlmeinfo->auth_algo = pparm->mode; - return H2C_SUCCESS; -} - -u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) -{ - unsigned short ctrl; - struct setkey_parm *pparm = (struct setkey_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 null_sta[ETH_ALEN] = {}; - - /* main tx key for wep. */ - if (pparm->set_tx) - pmlmeinfo->key_index = pparm->keyid; - - /* write cam */ - ctrl = BIT(15) | ((pparm->algorithm) << 2) | pparm->keyid; - - write_cam(padapter, pparm->keyid, ctrl, null_sta, pparm->key); - - return H2C_SUCCESS; -} - -u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) -{ - u16 ctrl = 0; - u8 cam_id;/* cam_entry */ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; - - /* cam_entry: */ - /* 0~3 for default key */ - - /* for concurrent mode (ap+sta): */ - /* default key is disable, using sw encrypt/decrypt */ - /* cam_entry = 4 for sta mode (macid = 0) */ - /* cam_entry(macid+3) = 5 ~ N for ap mode (aid = 1~N, macid = 2 ~N) */ - - /* for concurrent mode (sta+sta): */ - /* default key is disable, using sw encrypt/decrypt */ - /* cam_entry = 4 mapping to macid = 0 */ - /* cam_entry = 5 mapping to macid = 2 */ - - cam_id = 4; - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { - struct sta_info *psta; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (pparm->algorithm == _NO_PRIVACY_) /* clear cam entry */ { - clear_cam_entry(padapter, pparm->id); - return H2C_SUCCESS_RSP; - } - - psta = rtw_get_stainfo(pstapriv, pparm->addr); - if (psta) { - ctrl = BIT(15) | ((pparm->algorithm) << 2); - - if ((psta->mac_id < 1) || (psta->mac_id > (NUM_STA - 4))) - return H2C_REJECTED; - - cam_id = psta->mac_id + 3;/* 0~3 for default key, cmd_id = macid + 3, macid = aid+1; */ - - write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); - - return H2C_SUCCESS_RSP; - } - - return H2C_REJECTED; - } - - /* below for sta mode */ - - if (pparm->algorithm == _NO_PRIVACY_) { /* clear cam entry */ - clear_cam_entry(padapter, pparm->id); - return H2C_SUCCESS; - } - ctrl = BIT(15) | ((pparm->algorithm) << 2); - write_cam(padapter, cam_id, ctrl, pparm->addr, pparm->key); - pmlmeinfo->enc_algo = pparm->algorithm; - return H2C_SUCCESS; -} - -u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); - - if (!psta) - return H2C_SUCCESS; - - if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || - ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { - issue_action_BA(padapter, pparm->addr, WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); - mod_timer(&psta->addba_retry_timer, - jiffies + msecs_to_jiffies(ADDBA_TO)); - } else { - psta->htpriv.candidate_tid_bitmap &= ~BIT(pparm->tid); - } - return H2C_SUCCESS; -} - -u8 set_tx_beacon_cmd(struct adapter *padapter) -{ - struct cmd_obj *ph2c; - struct wlan_bssid_ex *ptxBeacon_parm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u8 res; - int len_diff = 0; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - ptxBeacon_parm = kmemdup(&pmlmeinfo->network, - sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (!ptxBeacon_parm) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - len_diff = update_hidden_ssid(ptxBeacon_parm->ies + _BEACON_IE_OFFSET_, - ptxBeacon_parm->ie_length - _BEACON_IE_OFFSET_, - pmlmeinfo->hidden_ssid_mode); - ptxBeacon_parm->ie_length += len_diff; - - init_h2fwcmd_w_parm_no_rsp(ph2c, ptxBeacon_parm, _TX_Beacon_CMD_); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - return res; -} - -u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - u8 evt_code; - u16 evt_sz; - uint *peventbuf; - void (*event_callback)(struct adapter *dev, u8 *pbuf); - - peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf & 0xffff); - evt_code = (u8)((*peventbuf >> 16) & 0xff); - - /* checking if event code is valid */ - if (evt_code >= MAX_C2HEVT) - goto _abort_event_; - - /* checking if event size match the event parm size */ - if ((wlanevents[evt_code].parmsize != 0) && - (wlanevents[evt_code].parmsize != evt_sz)) - goto _abort_event_; - - peventbuf += 2; - - if (peventbuf) { - event_callback = wlanevents[evt_code].event_callback; - event_callback(padapter, (u8 *)peventbuf); - } - -_abort_event_: - return H2C_SUCCESS; -} - -u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - if (send_beacon(padapter) == _FAIL) - return H2C_PARAMETERS_ERROR; -#ifdef CONFIG_88EU_AP_MODE - else { /* tx bc/mc frames after update TIM */ - struct sta_info *psta_bmc; - struct list_head *xmitframe_phead; - struct xmit_frame *pxmitframe, *n; - struct sta_priv *pstapriv = &padapter->stapriv; - - /* for BC/MC Frames */ - psta_bmc = rtw_get_bcmc_stainfo(padapter); - if (!psta_bmc) - return H2C_SUCCESS; - - if ((pstapriv->tim_bitmap & BIT(0)) && (psta_bmc->sleepq_len > 0)) { - msleep(10);/* 10ms, ATIM(HIQ) Windows */ - spin_lock_bh(&psta_bmc->sleep_q.lock); - - xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - list_for_each_entry_safe(pxmitframe, n, xmitframe_phead, - list) { - list_del_init(&pxmitframe->list); - - psta_bmc->sleepq_len--; - if (psta_bmc->sleepq_len > 0) - pxmitframe->attrib.mdata = 1; - else - pxmitframe->attrib.mdata = 0; - - pxmitframe->attrib.triggered = 1; - - pxmitframe->attrib.qsel = 0x11;/* HIQ */ - - spin_unlock_bh(&psta_bmc->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); - spin_lock_bh(&psta_bmc->sleep_q.lock); - } - spin_unlock_bh(&psta_bmc->sleep_q.lock); - } - } -#endif - return H2C_SUCCESS; -} - -u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf) -{ - struct set_ch_parm *set_ch_parm; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (!pbuf) - return H2C_PARAMETERS_ERROR; - - set_ch_parm = (struct set_ch_parm *)pbuf; - - pmlmeext->cur_channel = set_ch_parm->ch; - pmlmeext->cur_ch_offset = set_ch_parm->ch_offset; - pmlmeext->cur_bwmode = set_ch_parm->bw; - - set_channel_bwmode(padapter, set_ch_parm->ch, set_ch_parm->ch_offset, set_ch_parm->bw); - - return H2C_SUCCESS; -} - -u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf) -{ - struct SetChannelPlan_param *setChannelPlan_param; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - if (!pbuf) - return H2C_PARAMETERS_ERROR; - - setChannelPlan_param = (struct SetChannelPlan_param *)pbuf; - - pmlmeext->max_chan_nums = init_channel_set(padapter, setChannelPlan_param->channel_plan, pmlmeext->channel_set); - init_channel_list(padapter, pmlmeext->channel_set, pmlmeext->max_chan_nums, &pmlmeext->channel_list); - - return H2C_SUCCESS; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c b/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c deleted file mode 100644 index f1af49af1105..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_pwrctrl.c +++ /dev/null @@ -1,578 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_PWRCTRL_C_ - -#include -#include -#include -#include -#include - -static int rtw_hw_suspend(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct net_device *pnetdev = padapter->pnetdev; - - if ((!padapter->bup) || (padapter->bDriverStopped) || - (padapter->bSurpriseRemoved)) - goto error_exit; - - /* system suspend */ - LeaveAllPowerSaveMode(padapter); - - mutex_lock(&pwrpriv->mutex_lock); - pwrpriv->bips_processing = true; - /* s1. */ - if (pnetdev) { - netif_carrier_off(pnetdev); - netif_tx_stop_all_queues(pnetdev); - } - - /* s2. */ - rtw_disassoc_cmd(padapter, 500, false); - - /* s2-2. indicate disconnect to os */ - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - _clr_fwstate_(pmlmepriv, _FW_LINKED); - - led_control_8188eu(padapter, LED_CTL_NO_LINK); - - rtw_os_indicate_disconnect(padapter); - - /* donnot enqueue cmd */ - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); - } - } - /* s2-3. */ - rtw_free_assoc_resources(padapter); - - /* s2-4. */ - rtw_free_network_queue(padapter, true); - rtw_ips_dev_unload(padapter); - pwrpriv->rf_pwrstate = rf_off; - pwrpriv->bips_processing = false; - - mutex_unlock(&pwrpriv->mutex_lock); - - return 0; - -error_exit: - return -1; -} - -static int rtw_hw_resume(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct net_device *pnetdev = padapter->pnetdev; - - /* system resume */ - mutex_lock(&pwrpriv->mutex_lock); - pwrpriv->bips_processing = true; - rtw_reset_drv_sw(padapter); - - if (ips_netdrv_open(netdev_priv(pnetdev)) != _SUCCESS) { - mutex_unlock(&pwrpriv->mutex_lock); - goto error_exit; - } - - netif_device_attach(pnetdev); - netif_carrier_on(pnetdev); - - if (!netif_queue_stopped(pnetdev)) - netif_start_queue(pnetdev); - else - netif_wake_queue(pnetdev); - - pwrpriv->bkeepfwalive = false; - pwrpriv->brfoffbyhw = false; - - pwrpriv->rf_pwrstate = rf_on; - pwrpriv->bips_processing = false; - - mutex_unlock(&pwrpriv->mutex_lock); - - return 0; -error_exit: - return -1; -} - -void ips_enter(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct xmit_priv *pxmit_priv = &padapter->xmitpriv; - - if (padapter->registrypriv.mp_mode == 1) - return; - - if (pxmit_priv->free_xmitbuf_cnt != NR_XMITBUFF || - pxmit_priv->free_xmit_extbuf_cnt != NR_XMIT_EXTBUFF) - return; - - mutex_lock(&pwrpriv->mutex_lock); - - pwrpriv->bips_processing = true; - - /* syn ips_mode with request */ - pwrpriv->ips_mode = pwrpriv->ips_mode_req; - - pwrpriv->ips_enter_cnts++; - if (rf_off == pwrpriv->change_rfpwrstate) { - pwrpriv->bpower_saving = true; - - if (pwrpriv->ips_mode == IPS_LEVEL_2) - pwrpriv->bkeepfwalive = true; - - rtw_ips_pwr_down(padapter); - pwrpriv->rf_pwrstate = rf_off; - } - pwrpriv->bips_processing = false; - - mutex_unlock(&pwrpriv->mutex_lock); -} - -int ips_leave(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int result = _SUCCESS; - int keyid; - - mutex_lock(&pwrpriv->mutex_lock); - - if ((pwrpriv->rf_pwrstate == rf_off) && (!pwrpriv->bips_processing)) { - pwrpriv->bips_processing = true; - pwrpriv->change_rfpwrstate = rf_on; - pwrpriv->ips_leave_cnts++; - - result = rtw_ips_pwr_up(padapter); - if (result == _SUCCESS) - pwrpriv->rf_pwrstate = rf_on; - - if ((psecuritypriv->dot11PrivacyAlgrthm == _WEP40_) || (psecuritypriv->dot11PrivacyAlgrthm == _WEP104_)) { - set_channel_bwmode(padapter, padapter->mlmeextpriv.cur_channel, HAL_PRIME_CHNL_OFFSET_DONT_CARE, HT_CHANNEL_WIDTH_20); - for (keyid = 0; keyid < 4; keyid++) { - if (pmlmepriv->key_mask & BIT(keyid)) { - if (keyid == psecuritypriv->dot11PrivacyKeyIndex) - result = rtw_set_key(padapter, psecuritypriv, keyid, 1); - else - result = rtw_set_key(padapter, psecuritypriv, keyid, 0); - } - } - } - - pwrpriv->bips_processing = false; - - pwrpriv->bkeepfwalive = false; - pwrpriv->bpower_saving = false; - } - - mutex_unlock(&pwrpriv->mutex_lock); - - return result; -} - -static bool rtw_pwr_unassociated_idle(struct adapter *adapter) -{ - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - - if (time_after_eq(adapter->pwrctrlpriv.ips_deny_time, jiffies)) - return false; - - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) || - check_fwstate(pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) || - check_fwstate(pmlmepriv, WIFI_AP_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE)) - return false; - - return true; -} - -void rtw_ps_processor(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - enum rt_rf_power_state rfpwrstate; - - pwrpriv->ps_processing = true; - - if (pwrpriv->bips_processing) - goto exit; - - if (padapter->pwrctrlpriv.bHWPwrPindetect) { - rfpwrstate = RfOnOffDetect(padapter); - - if (rfpwrstate != pwrpriv->rf_pwrstate) { - if (rfpwrstate == rf_off) { - pwrpriv->change_rfpwrstate = rf_off; - pwrpriv->brfoffbyhw = true; - rtw_hw_suspend(padapter); - } else { - pwrpriv->change_rfpwrstate = rf_on; - rtw_hw_resume(padapter); - } - } - pwrpriv->pwr_state_check_cnts++; - } - - if (pwrpriv->ips_mode_req == IPS_NONE) - goto exit; - - if (!rtw_pwr_unassociated_idle(padapter)) - goto exit; - - if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts % 4) == 0)) { - pwrpriv->change_rfpwrstate = rf_off; - - ips_enter(padapter); - } -exit: - rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); - pwrpriv->ps_processing = false; -} - -static void pwr_state_check_handler(struct timer_list *t) -{ - struct adapter *padapter = - from_timer(padapter, t, - pwrctrlpriv.pwr_state_check_timer); - - rtw_ps_cmd(padapter); -} - -/* - * - * Parameters - * padapter - * pslv power state level, only could be PS_STATE_S0 ~ PS_STATE_S4 - * - */ -void rtw_set_rpwm(struct adapter *padapter, u8 pslv) -{ - u8 rpwm; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - pslv = PS_STATE(pslv); - - if (pwrpriv->btcoex_rfon) { - if (pslv < PS_STATE_S4) - pslv = PS_STATE_S3; - } - - if (pwrpriv->rpwm == pslv) - return; - - if ((padapter->bSurpriseRemoved) || - (!padapter->hw_init_completed)) { - pwrpriv->cpwm = PS_STATE_S4; - - return; - } - - if (padapter->bDriverStopped) { - if (pslv < PS_STATE_S2) - return; - } - - rpwm = pslv | pwrpriv->tog; - - pwrpriv->rpwm = pslv; - - rtw_hal_set_hwreg(padapter, HW_VAR_SET_RPWM, (u8 *)(&rpwm)); - - pwrpriv->tog += 0x80; - pwrpriv->cpwm = pslv; -} - -static u8 PS_RDY_CHECK(struct adapter *padapter) -{ - unsigned long curr_time, delta_time; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - curr_time = jiffies; - delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; - - if (delta_time < LPS_DELAY_TIME) - return false; - - if ((!check_fwstate(pmlmepriv, _FW_LINKED)) || - (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) || - (check_fwstate(pmlmepriv, WIFI_AP_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) - return false; - if (pwrpriv->bInSuspend) - return false; - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && - !padapter->securitypriv.binstallGrpkey) - return false; - return true; -} - -void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_ant_mode) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - if (ps_mode > PM_Card_Disable) - return; - - if (pwrpriv->pwr_mode == ps_mode) { - if (ps_mode == PS_MODE_ACTIVE) - return; - - if ((pwrpriv->smart_ps == smart_ps) && - (pwrpriv->bcn_ant_mode == bcn_ant_mode)) - return; - } - - /* if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) */ - if (ps_mode == PS_MODE_ACTIVE) { - if (PS_RDY_CHECK(padapter)) { - pwrpriv->pwr_mode = ps_mode; - pwrpriv->smart_ps = smart_ps; - pwrpriv->bcn_ant_mode = bcn_ant_mode; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&ps_mode)); - rtw_set_rpwm(padapter, PS_STATE_S2); - } - } -} - -/* - * Return: - * 0: Leave OK - * -1: Timeout - * -2: Other error - */ -s32 LPS_RF_ON_check(struct adapter *padapter, u32 delay_ms) -{ - unsigned long start_time; - u8 bAwake = false; - s32 err = 0; - - start_time = jiffies; - while (1) { - rtw_hal_get_hwreg(padapter, HW_VAR_FWLPS_RF_ON, &bAwake); - if (bAwake) - break; - - if (padapter->bSurpriseRemoved) { - err = -2; - break; - } - - if (jiffies_to_msecs(jiffies - start_time) > delay_ms) { - err = -1; - break; - } - msleep(1); - } - - return err; -} - -/* */ -/* Description: */ -/* Enter the leisure power save mode. */ -/* */ -void LPS_Enter(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - if (!PS_RDY_CHECK(padapter)) - return; - - if (pwrpriv->bLeisurePs) { - /* Idle for a while if we connect to AP a while ago. */ - if (pwrpriv->LpsIdleCount >= 2) { /* 4 Sec */ - if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) { - pwrpriv->bpower_saving = true; - /* For Tenda W311R IOT issue */ - rtw_set_ps_mode(padapter, pwrpriv->power_mgnt, pwrpriv->smart_ps, 0); - } - } else { - pwrpriv->LpsIdleCount++; - } - } -} - -#define LPS_LEAVE_TIMEOUT_MS 100 - -/* Description: */ -/* Leave the leisure power save mode. */ -void LPS_Leave(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - if (pwrpriv->bLeisurePs) { - if (pwrpriv->pwr_mode != PS_MODE_ACTIVE) { - rtw_set_ps_mode(padapter, PS_MODE_ACTIVE, 0, 0); - - if (pwrpriv->pwr_mode == PS_MODE_ACTIVE) - LPS_RF_ON_check(padapter, LPS_LEAVE_TIMEOUT_MS); - } - } - - pwrpriv->bpower_saving = false; -} - -/* */ -/* Description: Leave all power save mode: LPS, FwLPS, IPS if needed. */ -/* Move code to function by tynli. 2010.03.26. */ -/* */ -void LeaveAllPowerSaveMode(struct adapter *Adapter) -{ - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_lps_ctrl_wk_cmd(Adapter, LPS_CTRL_LEAVE, 0); -} - -void rtw_init_pwrctrl_priv(struct adapter *padapter) -{ - struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - - mutex_init(&pwrctrlpriv->mutex_lock); - pwrctrlpriv->rf_pwrstate = rf_on; - pwrctrlpriv->ips_enter_cnts = 0; - pwrctrlpriv->ips_leave_cnts = 0; - pwrctrlpriv->bips_processing = false; - - pwrctrlpriv->ips_mode = padapter->registrypriv.ips_mode; - pwrctrlpriv->ips_mode_req = padapter->registrypriv.ips_mode; - - pwrctrlpriv->pwr_state_check_interval = RTW_PWR_STATE_CHK_INTERVAL; - pwrctrlpriv->pwr_state_check_cnts = 0; - pwrctrlpriv->bInternalAutoSuspend = false; - pwrctrlpriv->bInSuspend = false; - pwrctrlpriv->bkeepfwalive = false; - - pwrctrlpriv->LpsIdleCount = 0; - if (padapter->registrypriv.mp_mode == 1) - pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; - else - pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ - pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE); - - pwrctrlpriv->rpwm = 0; - pwrctrlpriv->cpwm = PS_STATE_S4; - - pwrctrlpriv->pwr_mode = PS_MODE_ACTIVE; - pwrctrlpriv->smart_ps = padapter->registrypriv.smart_ps; - pwrctrlpriv->bcn_ant_mode = 0; - - pwrctrlpriv->tog = 0x80; - - pwrctrlpriv->btcoex_rfon = false; - - timer_setup(&pwrctrlpriv->pwr_state_check_timer, - pwr_state_check_handler, 0); -} - -/* - * rtw_pwr_wakeup - Wake the NIC up from: 1)IPS. 2)USB autosuspend - * @adapter: pointer to struct adapter structure - * @ips_deffer_ms: the ms will prevent from falling into IPS after wakeup - * Return _SUCCESS or _FAIL - */ - -int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *caller) -{ - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - unsigned long expires; - unsigned long start; - int ret = _SUCCESS; - - expires = jiffies + msecs_to_jiffies(ips_deffer_ms); - if (time_before(pwrpriv->ips_deny_time, expires)) - pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); - - start = jiffies; - if (pwrpriv->ps_processing) { - while (pwrpriv->ps_processing && - jiffies_to_msecs(jiffies - start) <= 3000) - udelay(1500); - } - - /* System suspend is not allowed to wakeup */ - if ((!pwrpriv->bInternalAutoSuspend) && (pwrpriv->bInSuspend)) { - ret = _FAIL; - goto exit; - } - - /* block??? */ - if ((pwrpriv->bInternalAutoSuspend) && (padapter->net_closed)) { - ret = _FAIL; - goto exit; - } - - /* I think this should be check in IPS, LPS, autosuspend functions... */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - ret = _SUCCESS; - goto exit; - } - if (rf_off == pwrpriv->rf_pwrstate) { - if (ips_leave(padapter) == _FAIL) { - ret = _FAIL; - goto exit; - } - } - - /* TODO: the following checking need to be merged... */ - if (padapter->bDriverStopped || !padapter->bup || - !padapter->hw_init_completed) { - ret = false; - goto exit; - } - -exit: - expires = jiffies + msecs_to_jiffies(ips_deffer_ms); - if (time_before(pwrpriv->ips_deny_time, expires)) - pwrpriv->ips_deny_time = jiffies + msecs_to_jiffies(ips_deffer_ms); - return ret; -} - -int rtw_pm_set_lps(struct adapter *padapter, u8 mode) -{ - int ret = 0; - struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - - if (mode < PS_MODE_NUM) { - if (pwrctrlpriv->power_mgnt != mode) { - if (mode == PS_MODE_ACTIVE) - LeaveAllPowerSaveMode(padapter); - else - pwrctrlpriv->LpsIdleCount = 2; - pwrctrlpriv->power_mgnt = mode; - pwrctrlpriv->bLeisurePs = (pwrctrlpriv->power_mgnt != PS_MODE_ACTIVE); - } - } else { - ret = -EINVAL; - } - - return ret; -} - -int rtw_pm_set_ips(struct adapter *padapter, u8 mode) -{ - struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - - if (mode == IPS_NORMAL || mode == IPS_LEVEL_2) { - rtw_ips_mode_req(pwrctrlpriv, mode); - return 0; - } else if (mode == IPS_NONE) { - rtw_ips_mode_req(pwrctrlpriv, mode); - if ((padapter->bSurpriseRemoved == 0) && (rtw_pwr_wakeup(padapter) == _FAIL)) - return -EFAULT; - } else { - return -EINVAL; - } - return 0; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c deleted file mode 100644 index ff2ef36604e1..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_recv.c +++ /dev/null @@ -1,1812 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_RECV_C_ - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define LLC_HEADER_SIZE 6 /* LLC Header Length */ - -static u8 SNAP_ETH_TYPE_IPX[2] = {0x81, 0x37}; -static u8 SNAP_ETH_TYPE_APPLETALK_AARP[2] = {0x80, 0xf3}; - -static void rtw_signal_stat_timer_hdl(struct timer_list *t); - -void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) -{ - memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); - - spin_lock_init(&psta_recvpriv->lock); - - _rtw_init_queue(&psta_recvpriv->defrag_q); -} - -int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) -{ - int i; - - struct recv_frame *precvframe; - - int res = _SUCCESS; - - _rtw_init_queue(&precvpriv->free_recv_queue); - _rtw_init_queue(&precvpriv->recv_pending_queue); - _rtw_init_queue(&precvpriv->uc_swdec_pending_queue); - - precvpriv->adapter = padapter; - - precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); - - if (!precvpriv->pallocated_frame_buf) - return _FAIL; - - precvframe = PTR_ALIGN(precvpriv->pallocated_frame_buf, RXFRAME_ALIGN_SZ); - - for (i = 0; i < NR_RECVFRAME; i++) { - INIT_LIST_HEAD(&precvframe->list); - - list_add_tail(&precvframe->list, - &precvpriv->free_recv_queue.queue); - - precvframe->pkt = NULL; - - precvframe->adapter = padapter; - precvframe++; - } - res = rtw_hal_init_recv_priv(padapter); - - timer_setup(&precvpriv->signal_stat_timer, rtw_signal_stat_timer_hdl, - 0); - - precvpriv->signal_stat_sampling_interval = 1000; /* ms */ - - rtw_set_signal_stat_timer(precvpriv); - - return res; -} - -void _rtw_free_recv_priv(struct recv_priv *precvpriv) -{ - struct adapter *padapter = precvpriv->adapter; - - rtw_free_uc_swdec_pending_queue(padapter); - - vfree(precvpriv->pallocated_frame_buf); - - rtw_hal_free_recv_priv(padapter); -} - -struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) -{ - struct recv_frame *hdr; - - hdr = list_first_entry_or_null(&pfree_recv_queue->queue, - struct recv_frame, list); - if (hdr) - list_del_init(&hdr->list); - - return hdr; -} - -struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue) -{ - struct recv_frame *precvframe; - - spin_lock_bh(&pfree_recv_queue->lock); - - precvframe = _rtw_alloc_recvframe(pfree_recv_queue); - - spin_unlock_bh(&pfree_recv_queue->lock); - - return precvframe; -} - -void rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue) -{ - if (!precvframe) - return; - - if (precvframe->pkt) { - dev_kfree_skb_any(precvframe->pkt);/* free skb by driver */ - precvframe->pkt = NULL; - } - - spin_lock_bh(&pfree_recv_queue->lock); - - list_del_init(&precvframe->list); - - list_add_tail(&precvframe->list, get_list_head(pfree_recv_queue)); - - spin_unlock_bh(&pfree_recv_queue->lock); -} - -int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) -{ - list_del_init(&precvframe->list); - list_add_tail(&precvframe->list, get_list_head(queue)); - - return _SUCCESS; -} - -int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) -{ - int ret; - - spin_lock_bh(&queue->lock); - ret = _rtw_enqueue_recvframe(precvframe, queue); - spin_unlock_bh(&queue->lock); - - return ret; -} - -/* - * caller : defrag ; recvframe_chk_defrag in recv_thread (passive) - * pframequeue: defrag_queue : will be accessed in recv_thread (passive) - * - * using spinlock to protect - * - */ - -void rtw_free_recvframe_queue(struct __queue *pframequeue, struct __queue *pfree_recv_queue) -{ - struct recv_frame *hdr; - struct list_head *plist, *phead; - - spin_lock(&pframequeue->lock); - - phead = get_list_head(pframequeue); - plist = phead->next; - - while (phead != plist) { - hdr = list_entry(plist, struct recv_frame, list); - - plist = plist->next; - - rtw_free_recvframe(hdr, pfree_recv_queue); - } - - spin_unlock(&pframequeue->lock); -} - -u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter) -{ - u32 cnt = 0; - struct recv_frame *pending_frame; - - while ((pending_frame = rtw_alloc_recvframe(&adapter->recvpriv.uc_swdec_pending_queue))) { - rtw_free_recvframe(pending_frame, &adapter->recvpriv.free_recv_queue); - cnt++; - } - - return cnt; -} - -static int recvframe_chkmic(struct adapter *adapter, - struct recv_frame *precvframe) -{ - int i, res = _SUCCESS; - u32 datalen; - u8 miccode[8]; - u8 bmic_err = false, brpt_micerror = true; - u8 *pframe, *payload, *pframemic; - u8 *mickey; - struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &precvframe->attrib; - struct security_priv *psecuritypriv = &adapter->securitypriv; - - struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); - - if (prxattrib->encrypt == _TKIP_) { - /* calculate mic code */ - if (stainfo) { - if (is_multicast_ether_addr(prxattrib->ra)) { - if (!psecuritypriv) { - res = _FAIL; - goto exit; - } - mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; - } else { - mickey = &stainfo->dot11tkiprxmickey.skey[0]; - } - - /* icv_len included the mic code */ - datalen = precvframe->pkt->len - prxattrib->hdrlen - - prxattrib->iv_len - prxattrib->icv_len - 8; - pframe = precvframe->pkt->data; - payload = pframe + prxattrib->hdrlen + prxattrib->iv_len; - - rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], - (unsigned char)prxattrib->priority); /* care the length of the data */ - - pframemic = payload + datalen; - - bmic_err = false; - - for (i = 0; i < 8; i++) { - if (miccode[i] != *(pframemic + i)) - bmic_err = true; - } - - if (bmic_err) { - /* double check key_index for some timing issue , */ - /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ - if (is_multicast_ether_addr(prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index) - brpt_micerror = false; - - if ((prxattrib->bdecrypted) && (brpt_micerror)) - rtw_handle_tkip_mic_err(adapter, (u8)is_multicast_ether_addr(prxattrib->ra)); - res = _FAIL; - } else { - /* mic checked ok */ - if (!psecuritypriv->bcheck_grpkey && - is_multicast_ether_addr(prxattrib->ra)) - psecuritypriv->bcheck_grpkey = true; - } - } - - skb_trim(precvframe->pkt, precvframe->pkt->len - 8); - } - -exit: - - return res; -} - -/* decrypt and set the ivlen, icvlen of the recv_frame */ -static struct recv_frame *decryptor(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct rx_pkt_attrib *prxattrib = &precv_frame->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct recv_frame *return_packet = precv_frame; - u32 res = _SUCCESS; - - if (prxattrib->encrypt > 0) { - u8 *iv = precv_frame->pkt->data + prxattrib->hdrlen; - - prxattrib->key_index = (((iv[3]) >> 6) & 0x3); - - if (prxattrib->key_index > WEP_KEYS) { - switch (prxattrib->encrypt) { - case _WEP40_: - case _WEP104_: - prxattrib->key_index = psecuritypriv->dot11PrivacyKeyIndex; - break; - case _TKIP_: - case _AES_: - default: - prxattrib->key_index = psecuritypriv->dot118021XGrpKeyid; - break; - } - } - } - - if ((prxattrib->encrypt > 0) && (prxattrib->bdecrypted == 0)) { - psecuritypriv->hw_decrypted = false; - - switch (prxattrib->encrypt) { - case _WEP40_: - case _WEP104_: - res = rtw_wep_decrypt(padapter, precv_frame); - break; - case _TKIP_: - res = rtw_tkip_decrypt(padapter, precv_frame); - break; - case _AES_: - res = rtw_aes_decrypt(padapter, precv_frame); - break; - default: - break; - } - } else if (prxattrib->bdecrypted == 1 && prxattrib->encrypt > 0 && - (psecuritypriv->busetkipkey == 1 || prxattrib->encrypt != _TKIP_)) - psecuritypriv->hw_decrypted = true; - - if (res == _FAIL) { - rtw_free_recvframe(return_packet, &padapter->recvpriv.free_recv_queue); - return_packet = NULL; - } - - return return_packet; -} - -/* set the security information in the recv_frame */ -static struct recv_frame *portctrl(struct adapter *adapter, - struct recv_frame *precv_frame) -{ - u8 *psta_addr, *ptr; - uint auth_alg; - struct recv_frame *pfhdr; - struct sta_info *psta; - struct sta_priv *pstapriv; - struct recv_frame *prtnframe; - u16 ether_type; - u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ - struct rx_pkt_attrib *pattrib; - __be16 be_tmp; - - pstapriv = &adapter->stapriv; - - auth_alg = adapter->securitypriv.dot11AuthAlgrthm; - - ptr = precv_frame->pkt->data; - pfhdr = precv_frame; - pattrib = &pfhdr->attrib; - psta_addr = pattrib->ta; - psta = rtw_get_stainfo(pstapriv, psta_addr); - - prtnframe = NULL; - - if (auth_alg == 2) { - /* get ether_type */ - ptr = ptr + pfhdr->attrib.hdrlen + LLC_HEADER_SIZE + pfhdr->attrib.iv_len; - memcpy(&be_tmp, ptr, 2); - ether_type = ntohs(be_tmp); - - if (psta && (psta->ieee8021x_blocked)) { - /* blocked */ - /* only accept EAPOL frame */ - if (ether_type == eapol_type) { - prtnframe = precv_frame; - } else { - /* free this frame */ - rtw_free_recvframe(precv_frame, &adapter->recvpriv.free_recv_queue); - prtnframe = NULL; - } - } else { - /* allowed */ - /* check decryption status, and decrypt the frame if needed */ - prtnframe = precv_frame; - /* check is the EAPOL frame or not (Rekey) */ - if (ether_type == eapol_type) - /* check Rekey */ - prtnframe = precv_frame; - } - } else { - prtnframe = precv_frame; - } - - return prtnframe; -} - -static int recv_decache(struct recv_frame *precv_frame, u8 bretry, - struct stainfo_rxcache *prxcache) -{ - int tid = precv_frame->attrib.priority; - - u16 seq_ctrl = ((precv_frame->attrib.seq_num & 0xffff) << 4) | - (precv_frame->attrib.frag_num & 0xf); - - if (tid > 15) - return _FAIL; - - if (seq_ctrl == prxcache->tid_rxseq[tid]) - return _FAIL; - - prxcache->tid_rxseq[tid] = seq_ctrl; - - return _SUCCESS; -} - -static void process_pwrbit_data(struct adapter *padapter, - struct recv_frame *precv_frame) -{ -#ifdef CONFIG_88EU_AP_MODE - unsigned char pwrbit; - u8 *ptr = precv_frame->pkt->data; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - struct sta_priv *pstapriv = &padapter->stapriv; - struct sta_info *psta = NULL; - - psta = rtw_get_stainfo(pstapriv, pattrib->src); - - pwrbit = GetPwrMgt(ptr); - - if (psta) { - if (pwrbit) { - if (!(psta->state & WIFI_SLEEP_STATE)) - stop_sta_xmit(padapter, psta); - } else { - if (psta->state & WIFI_SLEEP_STATE) - wakeup_sta_to_xmit(padapter, psta); - } - } - -#endif -} - -static void process_wmmps_data(struct adapter *padapter, - struct recv_frame *precv_frame) -{ -#ifdef CONFIG_88EU_AP_MODE - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - struct sta_priv *pstapriv = &padapter->stapriv; - struct sta_info *psta = NULL; - - psta = rtw_get_stainfo(pstapriv, pattrib->src); - - if (!psta) - return; - - if (!psta->qos_option) - return; - - if (!(psta->qos_info & 0xf)) - return; - - if (psta->state & WIFI_SLEEP_STATE) { - u8 wmmps_ac = 0; - - switch (pattrib->priority) { - case 1: - case 2: - wmmps_ac = psta->uapsd_bk & BIT(1); - break; - case 4: - case 5: - wmmps_ac = psta->uapsd_vi & BIT(1); - break; - case 6: - case 7: - wmmps_ac = psta->uapsd_vo & BIT(1); - break; - case 0: - case 3: - default: - wmmps_ac = psta->uapsd_be & BIT(1); - break; - } - - if (wmmps_ac) { - if (psta->sleepq_ac_len > 0) { - /* process received triggered frame */ - xmit_delivery_enabled_frames(padapter, psta); - } else { - /* issue one qos null frame with More data bit = 0 and the EOSP bit set (= 1) */ - issue_qos_nulldata(padapter, psta->hwaddr, (u16)pattrib->priority, 0, 0); - } - } - } - -#endif -} - -static void count_rx_stats(struct adapter *padapter, - struct recv_frame *prframe, - struct sta_info *sta) -{ - int sz; - struct sta_info *psta = NULL; - struct stainfo_stats *pstats = NULL; - struct rx_pkt_attrib *pattrib = &prframe->attrib; - struct recv_priv *precvpriv = &padapter->recvpriv; - - sz = prframe->pkt->len; - precvpriv->rx_bytes += sz; - - padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - - if (!is_multicast_ether_addr(pattrib->dst)) - padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; - - if (sta) - psta = sta; - else - psta = prframe->psta; - - if (psta) { - pstats = &psta->sta_stats; - - pstats->rx_data_pkts++; - pstats->rx_bytes += sz; - } -} - -static int sta2sta_data_frame(struct adapter *adapter, - struct recv_frame *precv_frame, - struct sta_info **psta) -{ - int ret = _SUCCESS; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *mybssid = get_bssid(pmlmepriv); - u8 *myhwaddr = myid(&adapter->eeprompriv); - u8 *sta_addr = NULL; - bool mcast = is_multicast_ether_addr(pattrib->dst); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - /* filter packets that SA is myself or multicast or broadcast */ - if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { - ret = _FAIL; - goto exit; - } - - if (memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && !mcast) { - ret = _FAIL; - goto exit; - } - - if (is_zero_ether_addr(pattrib->bssid) || - is_zero_ether_addr(mybssid) || - memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { - ret = _FAIL; - goto exit; - } - - sta_addr = pattrib->src; - } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ - if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { - ret = _FAIL; - goto exit; - } - sta_addr = pattrib->bssid; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - if (mcast) { - /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ - if (!is_multicast_ether_addr(pattrib->bssid)) { - ret = _FAIL; - goto exit; - } - } else { /* not mc-frame */ - /* For AP mode, if DA is non-MCAST, then it must be BSSID, and bssid == BSSID */ - if (memcmp(pattrib->bssid, pattrib->dst, ETH_ALEN)) { - ret = _FAIL; - goto exit; - } - - sta_addr = pattrib->src; - } - } else { - ret = _FAIL; - } - - if (mcast) - *psta = rtw_get_bcmc_stainfo(adapter); - else - *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ - - if (!*psta) { - ret = _FAIL; - goto exit; - } - -exit: - return ret; -} - -static int ap2sta_data_frame(struct adapter *adapter, - struct recv_frame *precv_frame, - struct sta_info **psta) -{ - u8 *ptr = precv_frame->pkt->data; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - int ret = _SUCCESS; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *mybssid = get_bssid(pmlmepriv); - u8 *myhwaddr = myid(&adapter->eeprompriv); - bool mcast = is_multicast_ether_addr(pattrib->dst); - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && - (check_fwstate(pmlmepriv, _FW_LINKED) || - check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { - /* filter packets that SA is myself or multicast or broadcast */ - if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { - ret = _FAIL; - goto exit; - } - - /* da should be for me */ - if (memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && !mcast) { - ret = _FAIL; - goto exit; - } - - /* check BSSID */ - if (is_zero_ether_addr(pattrib->bssid) || - is_zero_ether_addr(mybssid) || - (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { - if (!mcast) - issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - - ret = _FAIL; - goto exit; - } - - if (mcast) - *psta = rtw_get_bcmc_stainfo(adapter); - else - *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ - - if (!*psta) { - ret = _FAIL; - goto exit; - } - - /* if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) { */ - /* */ - - if (GetFrameSubType(ptr) & BIT(6)) { - /* No data, will not indicate to upper layer, temporily count it here */ - count_rx_stats(adapter, precv_frame, *psta); - ret = RTW_RX_HANDLED; - goto exit; - } - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - /* Special case */ - ret = RTW_RX_HANDLED; - goto exit; - } else { - if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && !mcast) { - *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ - if (!*psta) - issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - } - - ret = _FAIL; - } - -exit: - - return ret; -} - -static int sta2ap_data_frame(struct adapter *adapter, - struct recv_frame *precv_frame, - struct sta_info **psta) -{ - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - u8 *ptr = precv_frame->pkt->data; - unsigned char *mybssid = get_bssid(pmlmepriv); - int ret = _SUCCESS; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ - if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { - ret = _FAIL; - goto exit; - } - - *psta = rtw_get_stainfo(pstapriv, pattrib->src); - if (!*psta) { - issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - - ret = RTW_RX_HANDLED; - goto exit; - } - - process_pwrbit_data(adapter, precv_frame); - - if ((GetFrameSubType(ptr) & WIFI_QOS_DATA_TYPE) == WIFI_QOS_DATA_TYPE) - process_wmmps_data(adapter, precv_frame); - - if (GetFrameSubType(ptr) & BIT(6)) { - /* No data, will not indicate to upper layer, temporily count it here */ - count_rx_stats(adapter, precv_frame, *psta); - ret = RTW_RX_HANDLED; - goto exit; - } - } else { - u8 *myhwaddr = myid(&adapter->eeprompriv); - - if (memcmp(pattrib->ra, myhwaddr, ETH_ALEN)) { - ret = RTW_RX_HANDLED; - goto exit; - } - issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); - ret = RTW_RX_HANDLED; - goto exit; - } - -exit: - - return ret; -} - -static int validate_recv_ctrl_frame(struct adapter *padapter, - struct recv_frame *precv_frame) -{ -#ifdef CONFIG_88EU_AP_MODE - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - struct sta_priv *pstapriv = &padapter->stapriv; - u8 *pframe = precv_frame->pkt->data; - - if (GetFrameType(pframe) != WIFI_CTRL_TYPE) - return _FAIL; - - /* receive the frames that ra(a1) is my address */ - if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN)) - return _FAIL; - - /* only handle ps-poll */ - if (GetFrameSubType(pframe) == (IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL)) { - u16 aid; - u8 wmmps_ac = 0; - struct sta_info *psta = NULL; - - aid = GetAid(pframe); - psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - - if ((!psta) || (psta->aid != aid)) - return _FAIL; - - /* for rx pkt statistics */ - psta->sta_stats.rx_ctrl_pkts++; - - switch (pattrib->priority) { - case 1: - case 2: - wmmps_ac = psta->uapsd_bk & BIT(0); - break; - case 4: - case 5: - wmmps_ac = psta->uapsd_vi & BIT(0); - break; - case 6: - case 7: - wmmps_ac = psta->uapsd_vo & BIT(0); - break; - case 0: - case 3: - default: - wmmps_ac = psta->uapsd_be & BIT(0); - break; - } - - if (wmmps_ac) - return _FAIL; - - if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { - psta->expire_to = pstapriv->expire_to; - psta->state ^= WIFI_STA_ALIVE_CHK_STATE; - } - - if ((psta->state & WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap & BIT(psta->aid))) { - struct list_head *xmitframe_plist, *xmitframe_phead; - struct xmit_frame *pxmitframe = NULL; - - spin_lock_bh(&psta->sleep_q.lock); - - xmitframe_phead = get_list_head(&psta->sleep_q); - xmitframe_plist = xmitframe_phead->next; - - if (xmitframe_phead != xmitframe_plist) { - pxmitframe = list_entry(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - - list_del_init(&pxmitframe->list); - - psta->sleepq_len--; - - if (psta->sleepq_len > 0) - pxmitframe->attrib.mdata = 1; - else - pxmitframe->attrib.mdata = 0; - - pxmitframe->attrib.triggered = 1; - - spin_unlock_bh(&psta->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); - spin_lock_bh(&psta->sleep_q.lock); - - if (psta->sleepq_len == 0) { - pstapriv->tim_bitmap &= ~BIT(psta->aid); - - /* update BCN for TIM IE */ - /* update_BCNTIM(padapter); */ - update_beacon(padapter, WLAN_EID_TIM, NULL, false); - } - } else { - if (pstapriv->tim_bitmap & BIT(psta->aid)) { - if (psta->sleepq_len == 0) - /* issue nulldata with More data bit = 0 to indicate we have no buffered packets */ - issue_nulldata(padapter, psta->hwaddr, 0, 0, 0); - else - psta->sleepq_len = 0; - - pstapriv->tim_bitmap &= ~BIT(psta->aid); - - /* update BCN for TIM IE */ - /* update_BCNTIM(padapter); */ - update_beacon(padapter, WLAN_EID_TIM, NULL, false); - } - } - - spin_unlock_bh(&psta->sleep_q.lock); - } - } - -#endif - - return _FAIL; -} - -struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, - struct recv_frame *precv_frame); - -static int validate_recv_mgnt_frame(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct sta_info *psta; - - precv_frame = recvframe_chk_defrag(padapter, precv_frame); - if (!precv_frame) - return _SUCCESS; - - /* for rx pkt statistics */ - psta = rtw_get_stainfo(&padapter->stapriv, - GetAddr2Ptr(precv_frame->pkt->data)); - if (psta) { - psta->sta_stats.rx_mgnt_pkts++; - if (GetFrameSubType(precv_frame->pkt->data) == IEEE80211_STYPE_BEACON) { - psta->sta_stats.rx_beacon_pkts++; - } else if (GetFrameSubType(precv_frame->pkt->data) == IEEE80211_STYPE_PROBE_REQ) { - psta->sta_stats.rx_probereq_pkts++; - } else if (GetFrameSubType(precv_frame->pkt->data) == IEEE80211_STYPE_PROBE_RESP) { - if (!memcmp(padapter->eeprompriv.mac_addr, - GetAddr1Ptr(precv_frame->pkt->data), ETH_ALEN)) - psta->sta_stats.rx_probersp_pkts++; - else if (is_multicast_ether_addr(GetAddr1Ptr(precv_frame->pkt->data))) - psta->sta_stats.rx_probersp_bm_pkts++; - else - psta->sta_stats.rx_probersp_uo_pkts++; - } - } - - mgt_dispatcher(padapter, precv_frame); - - return _SUCCESS; -} - -static int validate_recv_data_frame(struct adapter *adapter, - struct recv_frame *precv_frame) -{ - u8 bretry; - u8 *psa, *pda, *pbssid; - struct sta_info *psta = NULL; - u8 *ptr = precv_frame->pkt->data; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - struct security_priv *psecuritypriv = &adapter->securitypriv; - int ret = _SUCCESS; - - bretry = GetRetry(ptr); - pda = ieee80211_get_DA((struct ieee80211_hdr *)ptr); - psa = ieee80211_get_SA((struct ieee80211_hdr *)ptr); - pbssid = get_hdr_bssid(ptr); - - if (!pbssid) { - ret = _FAIL; - goto exit; - } - - memcpy(pattrib->dst, pda, ETH_ALEN); - memcpy(pattrib->src, psa, ETH_ALEN); - - memcpy(pattrib->bssid, pbssid, ETH_ALEN); - - switch (pattrib->to_fr_ds) { - case 0: - memcpy(pattrib->ra, pda, ETH_ALEN); - memcpy(pattrib->ta, psa, ETH_ALEN); - ret = sta2sta_data_frame(adapter, precv_frame, &psta); - break; - case 1: - memcpy(pattrib->ra, pda, ETH_ALEN); - memcpy(pattrib->ta, pbssid, ETH_ALEN); - ret = ap2sta_data_frame(adapter, precv_frame, &psta); - break; - case 2: - memcpy(pattrib->ra, pbssid, ETH_ALEN); - memcpy(pattrib->ta, psa, ETH_ALEN); - ret = sta2ap_data_frame(adapter, precv_frame, &psta); - break; - case 3: - memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN); - memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN); - ret = _FAIL; - break; - default: - ret = _FAIL; - break; - } - - if (ret == _FAIL) - goto exit; - else if (ret == RTW_RX_HANDLED) - goto exit; - - if (!psta) { - ret = _FAIL; - goto exit; - } - - /* psta->rssi = prxcmd->rssi; */ - /* psta->signal_quality = prxcmd->sq; */ - precv_frame->psta = psta; - - pattrib->amsdu = 0; - pattrib->ack_policy = 0; - /* parsing QC field */ - if (pattrib->qos == 1) { - pattrib->priority = GetPriority((ptr + 24)); - pattrib->ack_policy = GetAckpolicy((ptr + 24)); - pattrib->amsdu = GetAMsdu((ptr + 24)); - pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 32 : 26; - - if (pattrib->priority != 0 && pattrib->priority != 3) - adapter->recvpriv.bIsAnyNonBEPkts = true; - } else { - pattrib->priority = 0; - pattrib->hdrlen = pattrib->to_fr_ds == 3 ? 30 : 24; - } - - if (pattrib->order)/* HT-CTRL 11n */ - pattrib->hdrlen += 4; - - precv_frame->preorder_ctrl = &psta->recvreorder_ctrl[pattrib->priority]; - - /* decache, drop duplicate recv packets */ - if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { - ret = _FAIL; - goto exit; - } - - if (pattrib->privacy) { - GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, is_multicast_ether_addr(pattrib->ra)); - SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); - } else { - pattrib->encrypt = 0; - pattrib->iv_len = 0; - pattrib->icv_len = 0; - } - -exit: - - return ret; -} - -static int validate_recv_frame(struct adapter *adapter, - struct recv_frame *precv_frame) -{ - /* shall check frame subtype, to / from ds, da, bssid */ - - /* then call check if rx seq/frag. duplicated. */ - - u8 type; - u8 subtype; - int retval = _SUCCESS; - u8 bDumpRxPkt; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - u8 *ptr = precv_frame->pkt->data; - u8 ver = (unsigned char)(*ptr) & 0x3; - struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - int ch_set_idx = rtw_ch_set_search_ch(pmlmeext->channel_set, rtw_get_oper_ch(adapter)); - - if (ch_set_idx >= 0) - pmlmeext->channel_set[ch_set_idx].rx_count++; - } - - /* add version chk */ - if (ver != 0) { - retval = _FAIL; - goto exit; - } - - type = GetFrameType(ptr); - subtype = GetFrameSubType(ptr); /* bit(7)~bit(2) */ - - pattrib->to_fr_ds = get_tofr_ds(ptr); - - pattrib->frag_num = GetFragNum(ptr); - pattrib->seq_num = GetSequence(ptr); - - pattrib->pw_save = GetPwrMgt(ptr); - pattrib->mfrag = GetMFrag(ptr); - pattrib->mdata = GetMData(ptr); - pattrib->privacy = GetPrivacy(ptr); - pattrib->order = GetOrder(ptr); - - rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); - switch (type) { - case WIFI_MGT_TYPE: /* mgnt */ - retval = validate_recv_mgnt_frame(adapter, precv_frame); - retval = _FAIL; /* only data frame return _SUCCESS */ - break; - case WIFI_CTRL_TYPE: /* ctrl */ - retval = validate_recv_ctrl_frame(adapter, precv_frame); - retval = _FAIL; /* only data frame return _SUCCESS */ - break; - case WIFI_DATA_TYPE: /* data */ - led_control_8188eu(adapter, LED_CTL_RX); - pattrib->qos = (subtype & BIT(7)) ? 1 : 0; - retval = validate_recv_data_frame(adapter, precv_frame); - if (retval == _FAIL) { - struct recv_priv *precvpriv = &adapter->recvpriv; - - precvpriv->rx_drop++; - } - break; - default: - retval = _FAIL; - break; - } - - /* - * This is the last moment before management and control frames get - * discarded. So we need to forward them to the monitor now or never. - * - * At the same time data frames can still be encrypted if software - * decryption is in use. However, decryption can occur not until later - * (see recv_func()). - * - * Hence forward the frame to the monitor anyway to preserve the order - * in which frames were received. - */ - rtl88eu_mon_recv_hook(adapter->pmondev, precv_frame); - -exit: - - return retval; -} - -/* remove the wlanhdr and add the eth_hdr */ - -static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) -{ - int rmv_len; - u16 eth_type, len; - __be16 be_tmp; - u8 bsnaphdr; - u8 *psnap_type; - struct ieee80211_snap_hdr *psnap; - - u8 *ptr = precvframe->pkt->data; - struct rx_pkt_attrib *pattrib = &precvframe->attrib; - - if (pattrib->encrypt) - skb_trim(precvframe->pkt, precvframe->pkt->len - pattrib->icv_len); - - psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen + pattrib->iv_len); - psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE; - /* convert hdr + possible LLC headers into Ethernet header */ - if ((!memcmp(psnap, rfc1042_header, SNAP_SIZE) && - memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) && - memcmp(psnap_type, SNAP_ETH_TYPE_APPLETALK_AARP, 2)) || - !memcmp(psnap, bridge_tunnel_header, SNAP_SIZE)) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ - bsnaphdr = true; - } else { - /* Leave Ethernet header part of hdr and full payload */ - bsnaphdr = false; - } - - rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); - len = precvframe->pkt->len - rmv_len; - - memcpy(&be_tmp, ptr + rmv_len, 2); - eth_type = ntohs(be_tmp); /* pattrib->ether_type */ - pattrib->eth_type = eth_type; - - ptr = skb_pull(precvframe->pkt, rmv_len - sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0)); - if (!ptr) - return _FAIL; - - memcpy(ptr, pattrib->dst, ETH_ALEN); - memcpy(ptr + ETH_ALEN, pattrib->src, ETH_ALEN); - - if (!bsnaphdr) { - be_tmp = htons(len); - memcpy(ptr + 12, &be_tmp, 2); - } - - return _SUCCESS; -} - -/* perform defrag */ -static struct recv_frame *recvframe_defrag(struct adapter *adapter, - struct __queue *defrag_q) -{ - struct list_head *plist, *phead; - u8 wlanhdr_offset; - u8 curfragnum; - struct recv_frame *pnfhdr; - struct recv_frame *prframe, *pnextrframe; - struct __queue *pfree_recv_queue; - - curfragnum = 0; - pfree_recv_queue = &adapter->recvpriv.free_recv_queue; - - phead = get_list_head(defrag_q); - plist = phead->next; - prframe = list_entry(plist, struct recv_frame, list); - list_del_init(&prframe->list); - - if (curfragnum != prframe->attrib.frag_num) { - /* the first fragment number must be 0 */ - /* free the whole queue */ - rtw_free_recvframe(prframe, pfree_recv_queue); - rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); - - return NULL; - } - - curfragnum++; - - plist = get_list_head(defrag_q); - - plist = plist->next; - - while (phead != plist) { - pnfhdr = list_entry(plist, struct recv_frame, list); - pnextrframe = pnfhdr; - - /* check the fragment sequence (2nd ~n fragment frame) */ - - if (curfragnum != pnfhdr->attrib.frag_num) { - /* the fragment number must be increasing (after decache) */ - /* release the defrag_q & prframe */ - rtw_free_recvframe(prframe, pfree_recv_queue); - rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); - return NULL; - } - - curfragnum++; - - /* copy the 2nd~n fragment frame's payload to the first fragment */ - /* get the 2nd~last fragment frame's payload */ - - wlanhdr_offset = pnfhdr->attrib.hdrlen + pnfhdr->attrib.iv_len; - - skb_pull(pnextrframe->pkt, wlanhdr_offset); - - /* append to first fragment frame's tail (if privacy frame, pull the ICV) */ - skb_trim(prframe->pkt, prframe->pkt->len - prframe->attrib.icv_len); - - skb_put_data(prframe->pkt, pnfhdr->pkt->data, pnfhdr->pkt->len); - - prframe->attrib.icv_len = pnfhdr->attrib.icv_len; - plist = plist->next; - } - - /* free the defrag_q queue and return the prframe */ - rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); - - return prframe; -} - -/* check if need to defrag, if needed queue the frame to defrag_q */ -struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - u8 ismfrag; - u8 fragnum; - u8 *psta_addr; - struct recv_frame *pfhdr; - struct sta_info *psta; - struct sta_priv *pstapriv; - struct list_head *phead; - struct recv_frame *prtnframe = NULL; - struct __queue *pfree_recv_queue, *pdefrag_q; - - pstapriv = &padapter->stapriv; - - pfhdr = precv_frame; - - pfree_recv_queue = &padapter->recvpriv.free_recv_queue; - - /* need to define struct of wlan header frame ctrl */ - ismfrag = pfhdr->attrib.mfrag; - fragnum = pfhdr->attrib.frag_num; - - psta_addr = pfhdr->attrib.ta; - psta = rtw_get_stainfo(pstapriv, psta_addr); - if (!psta) { - u8 type = GetFrameType(pfhdr->pkt->data); - - if (type != WIFI_DATA_TYPE) { - psta = rtw_get_bcmc_stainfo(padapter); - pdefrag_q = &psta->sta_recvpriv.defrag_q; - } else { - pdefrag_q = NULL; - } - } else { - pdefrag_q = &psta->sta_recvpriv.defrag_q; - } - - if ((ismfrag == 0) && (fragnum == 0)) - prtnframe = precv_frame;/* isn't a fragment frame */ - - if (ismfrag == 1) { - /* 0~(n-1) fragment frame */ - /* enqueue to defraf_g */ - if (pdefrag_q) { - if (fragnum == 0) { - /* the first fragment */ - if (!list_empty(&pdefrag_q->queue)) - /* free current defrag_q */ - rtw_free_recvframe_queue(pdefrag_q, pfree_recv_queue); - } - - /* Then enqueue the 0~(n-1) fragment into the defrag_q */ - - phead = get_list_head(pdefrag_q); - list_add_tail(&pfhdr->list, phead); - - prtnframe = NULL; - } else { - /* can't find this ta's defrag_queue, so free this recv_frame */ - rtw_free_recvframe(precv_frame, pfree_recv_queue); - prtnframe = NULL; - } - } - - if ((ismfrag == 0) && (fragnum != 0)) { - /* the last fragment frame */ - /* enqueue the last fragment */ - if (pdefrag_q) { - phead = get_list_head(pdefrag_q); - list_add_tail(&pfhdr->list, phead); - - /* call recvframe_defrag to defrag */ - precv_frame = recvframe_defrag(padapter, pdefrag_q); - prtnframe = precv_frame; - } else { - /* can't find this ta's defrag_queue, so free this recv_frame */ - rtw_free_recvframe(precv_frame, pfree_recv_queue); - prtnframe = NULL; - } - } - - if (prtnframe && (prtnframe->attrib.privacy)) { - /* after defrag we must check tkip mic code */ - if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { - rtw_free_recvframe(prtnframe, pfree_recv_queue); - prtnframe = NULL; - } - } - - return prtnframe; -} - -static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) -{ - int a_len, padding_len; - u16 eth_type, nSubframe_Length; - u8 nr_subframes, i; - unsigned char *pdata; - struct rx_pkt_attrib *pattrib; - struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; - struct recv_priv *precvpriv = &padapter->recvpriv; - struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; - - nr_subframes = 0; - pattrib = &prframe->attrib; - - skb_pull(prframe->pkt, prframe->attrib.hdrlen); - - if (prframe->attrib.iv_len > 0) - skb_pull(prframe->pkt, prframe->attrib.iv_len); - - a_len = prframe->pkt->len; - - pdata = prframe->pkt->data; - - while (a_len > ETH_HLEN) { - /* Offset 12 denote 2 mac address */ - nSubframe_Length = get_unaligned_be16(pdata + 12); - - if (a_len < (ETH_HLEN + nSubframe_Length)) - goto exit; - - /* move the data point to data content */ - pdata += ETH_HLEN; - a_len -= ETH_HLEN; - - /* Allocate new skb for releasing to upper layer */ - sub_skb = dev_alloc_skb(nSubframe_Length + 12); - if (!sub_skb) - break; - - skb_reserve(sub_skb, 12); - skb_put_data(sub_skb, pdata, nSubframe_Length); - - subframes[nr_subframes++] = sub_skb; - - if (nr_subframes >= MAX_SUBFRAME_COUNT) - break; - - pdata += nSubframe_Length; - a_len -= nSubframe_Length; - if (a_len != 0) { - padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4 - 1)); - if (padding_len == 4) - padding_len = 0; - - if (a_len < padding_len) - goto exit; - - pdata += padding_len; - a_len -= padding_len; - } - } - - for (i = 0; i < nr_subframes; i++) { - sub_skb = subframes[i]; - /* convert hdr + possible LLC headers into Ethernet header */ - eth_type = get_unaligned_be16(&sub_skb->data[6]); - if (sub_skb->len >= 8 && - ((!memcmp(sub_skb->data, rfc1042_header, SNAP_SIZE) && - eth_type != ETH_P_AARP && eth_type != ETH_P_IPX) || - !memcmp(sub_skb->data, bridge_tunnel_header, SNAP_SIZE))) { - /* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */ - skb_pull(sub_skb, SNAP_SIZE); - memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN); - } else { - __be16 len; - /* Leave Ethernet header part of hdr and full payload */ - len = htons(sub_skb->len); - memcpy(skb_push(sub_skb, 2), &len, 2); - memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->src, ETH_ALEN); - memcpy(skb_push(sub_skb, ETH_ALEN), pattrib->dst, ETH_ALEN); - } - - /* Indicate the packets to upper layer */ - /* Insert NAT2.5 RX here! */ - sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); - sub_skb->dev = padapter->pnetdev; - - sub_skb->ip_summed = CHECKSUM_NONE; - - netif_rx(sub_skb); - } - -exit: - rtw_free_recvframe(prframe, pfree_recv_queue);/* free this recv_frame */ - - return _SUCCESS; -} - -static int check_indicate_seq(struct recv_reorder_ctrl *preorder_ctrl, u16 seq_num) -{ - u8 wsize = preorder_ctrl->wsize_b; - u16 wend = (preorder_ctrl->indicate_seq + wsize - 1) & 0xFFF;/* 4096; */ - - /* Rx Reorder initialize condition. */ - if (preorder_ctrl->indicate_seq == 0xFFFF) - preorder_ctrl->indicate_seq = seq_num; - - /* Drop out the packet which SeqNum is smaller than WinStart */ - if (SN_LESS(seq_num, preorder_ctrl->indicate_seq)) - return false; - - /* */ - /* Sliding window manipulation. Conditions includes: */ - /* 1. Incoming SeqNum is equal to WinStart =>Window shift 1 */ - /* 2. Incoming SeqNum is larger than the WinEnd => Window shift N */ - /* */ - if (SN_EQUAL(seq_num, preorder_ctrl->indicate_seq)) { - preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; - } else if (SN_LESS(wend, seq_num)) { - if (seq_num >= (wsize - 1)) - preorder_ctrl->indicate_seq = seq_num + 1 - wsize; - else - preorder_ctrl->indicate_seq = 0xFFF - (wsize - (seq_num + 1)) + 1; - } - - return true; -} - -static int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, - struct recv_frame *prframe) -{ - struct rx_pkt_attrib *pattrib = &prframe->attrib; - struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; - struct list_head *phead, *plist; - struct recv_frame *hdr; - struct rx_pkt_attrib *pnextattrib; - - phead = get_list_head(ppending_recvframe_queue); - plist = phead->next; - - while (phead != plist) { - hdr = list_entry(plist, struct recv_frame, list); - pnextattrib = &hdr->attrib; - - if (SN_LESS(pnextattrib->seq_num, pattrib->seq_num)) - plist = plist->next; - else if (SN_EQUAL(pnextattrib->seq_num, pattrib->seq_num)) - return false; - else - break; - } - - list_del_init(&prframe->list); - - list_add_tail(&prframe->list, plist); - return true; -} - -static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reorder_ctrl *preorder_ctrl, int bforced) -{ - struct list_head *phead, *plist; - struct recv_frame *prframe; - struct recv_frame *prhdr; - struct rx_pkt_attrib *pattrib; - int bPktInBuf = false; - struct recv_priv *precvpriv = &padapter->recvpriv; - struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; - - phead = get_list_head(ppending_recvframe_queue); - plist = phead->next; - - /* Handling some condition for forced indicate case. */ - if (bforced) { - if (list_empty(phead)) - return true; - - prhdr = list_entry(plist, struct recv_frame, list); - pattrib = &prhdr->attrib; - preorder_ctrl->indicate_seq = pattrib->seq_num; - } - - /* Prepare indication list and indication. */ - /* Check if there is any packet need indicate. */ - while (!list_empty(phead)) { - prhdr = list_entry(plist, struct recv_frame, list); - prframe = prhdr; - pattrib = &prframe->attrib; - - if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { - plist = plist->next; - list_del_init(&prframe->list); - - if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) - preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; - - /* Set this as a lock to make sure that only one thread is indicating packet. */ - - /* indicate this recv_frame */ - if (!pattrib->amsdu) { - if ((!padapter->bDriverStopped) && - (!padapter->bSurpriseRemoved)) - rtw_recv_indicatepkt(padapter, prframe);/* indicate this recv_frame */ - } else if (pattrib->amsdu == 1) { - if (amsdu_to_msdu(padapter, prframe) != _SUCCESS) - rtw_free_recvframe(prframe, &precvpriv->free_recv_queue); - } else { - /* error condition; */ - } - - /* Update local variables. */ - bPktInBuf = false; - } else { - bPktInBuf = true; - break; - } - } - return bPktInBuf; -} - -static int recv_indicatepkt_reorder(struct adapter *padapter, - struct recv_frame *prframe) -{ - int retval = _SUCCESS; - struct rx_pkt_attrib *pattrib = &prframe->attrib; - struct recv_reorder_ctrl *preorder_ctrl = prframe->preorder_ctrl; - struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; - - if (!pattrib->amsdu) { - /* s1. */ - wlanhdr_to_ethhdr(prframe); - - if ((pattrib->qos != 1) || (pattrib->eth_type == 0x0806) || - (pattrib->ack_policy != 0)) { - if ((!padapter->bDriverStopped) && - (!padapter->bSurpriseRemoved)) { - rtw_recv_indicatepkt(padapter, prframe); - return _SUCCESS; - } - - return _FAIL; - } - - if (!preorder_ctrl->enable) { - /* indicate this recv_frame */ - preorder_ctrl->indicate_seq = pattrib->seq_num; - rtw_recv_indicatepkt(padapter, prframe); - - preorder_ctrl->indicate_seq = - (preorder_ctrl->indicate_seq + 1) % 4096; - return _SUCCESS; - } - } else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */ - if (!preorder_ctrl->enable) { - preorder_ctrl->indicate_seq = pattrib->seq_num; - retval = amsdu_to_msdu(padapter, prframe); - - preorder_ctrl->indicate_seq = - (preorder_ctrl->indicate_seq + 1) % 4096; - return retval; - } - } - - spin_lock_bh(&ppending_recvframe_queue->lock); - - /* s2. check if winstart_b(indicate_seq) needs to been updated */ - if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) { - rtw_recv_indicatepkt(padapter, prframe); - - spin_unlock_bh(&ppending_recvframe_queue->lock); - - goto _success_exit; - } - - /* s3. Insert all packet into Reorder Queue to maintain its ordering. */ - if (!enqueue_reorder_recvframe(preorder_ctrl, prframe)) - goto _err_exit; - - /* s4. */ - /* Indication process. */ - /* After Packet dropping and Sliding Window shifting as above, we can now just indicate the packets */ - /* with the SeqNum smaller than latest WinStart and buffer other packets. */ - /* */ - /* For Rx Reorder condition: */ - /* 1. All packets with SeqNum smaller than WinStart => Indicate */ - /* 2. All packets with SeqNum larger than or equal to WinStart => Buffer it. */ - /* */ - - /* recv_indicatepkts_in_order(padapter, preorder_ctrl, true); */ - if (recv_indicatepkts_in_order(padapter, preorder_ctrl, false)) { - mod_timer(&preorder_ctrl->reordering_ctrl_timer, - jiffies + msecs_to_jiffies(REORDER_WAIT_TIME)); - spin_unlock_bh(&ppending_recvframe_queue->lock); - } else { - spin_unlock_bh(&ppending_recvframe_queue->lock); - del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); - } - -_success_exit: - - return _SUCCESS; - -_err_exit: - - spin_unlock_bh(&ppending_recvframe_queue->lock); - - return _FAIL; -} - -void rtw_reordering_ctrl_timeout_handler(struct timer_list *t) -{ - struct recv_reorder_ctrl *preorder_ctrl = from_timer(preorder_ctrl, t, - reordering_ctrl_timer); - struct adapter *padapter = preorder_ctrl->padapter; - struct __queue *ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; - - if (padapter->bDriverStopped || padapter->bSurpriseRemoved) - return; - - spin_lock_bh(&ppending_recvframe_queue->lock); - - if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true)) - mod_timer(&preorder_ctrl->reordering_ctrl_timer, - jiffies + msecs_to_jiffies(REORDER_WAIT_TIME)); - - spin_unlock_bh(&ppending_recvframe_queue->lock); -} - -static int process_recv_indicatepkts(struct adapter *padapter, - struct recv_frame *prframe) -{ - int retval = _SUCCESS; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - - if (phtpriv->ht_option) { /* B/G/N Mode */ - if (recv_indicatepkt_reorder(padapter, prframe) != _SUCCESS) { - /* including perform A-MPDU Rx Ordering Buffer Control */ - if ((!padapter->bDriverStopped) && - (!padapter->bSurpriseRemoved)) { - return _FAIL; - } - } - } else { /* B/G mode */ - retval = wlanhdr_to_ethhdr(prframe); - if (retval != _SUCCESS) - return retval; - - if ((!padapter->bDriverStopped) && - (!padapter->bSurpriseRemoved)) - /* indicate this recv_frame */ - rtw_recv_indicatepkt(padapter, prframe); - else - return _FAIL; - } - - return retval; -} - -static int recv_func_prehandle(struct adapter *padapter, - struct recv_frame *rframe) -{ - int ret = _SUCCESS; - struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; - - /* check the frame crtl field and decache */ - ret = validate_recv_frame(padapter, rframe); - if (ret != _SUCCESS) { - rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ - goto exit; - } - -exit: - return ret; -} - -static int recv_func_posthandle(struct adapter *padapter, - struct recv_frame *prframe) -{ - int ret = _SUCCESS; - struct recv_frame *orig_prframe = prframe; - struct recv_priv *precvpriv = &padapter->recvpriv; - struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; - - /* DATA FRAME */ - led_control_8188eu(padapter, LED_CTL_RX); - - prframe = decryptor(padapter, prframe); - if (!prframe) { - ret = _FAIL; - goto _recv_data_drop; - } - - prframe = recvframe_chk_defrag(padapter, prframe); - if (!prframe) - goto _recv_data_drop; - - prframe = portctrl(padapter, prframe); - if (!prframe) { - ret = _FAIL; - goto _recv_data_drop; - } - - count_rx_stats(padapter, prframe, NULL); - - ret = process_recv_indicatepkts(padapter, prframe); - if (ret != _SUCCESS) { - rtw_free_recvframe(orig_prframe, pfree_recv_queue);/* free this recv_frame */ - goto _recv_data_drop; - } - return ret; - -_recv_data_drop: - precvpriv->rx_drop++; - return ret; -} - -static int recv_func(struct adapter *padapter, struct recv_frame *rframe) -{ - int ret; - struct rx_pkt_attrib *prxattrib = &rframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_priv *mlmepriv = &padapter->mlmepriv; - - /* check if need to handle uc_swdec_pending_queue*/ - if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && psecuritypriv->busetkipkey) { - struct recv_frame *pending_frame; - - while ((pending_frame = rtw_alloc_recvframe(&padapter->recvpriv.uc_swdec_pending_queue))) - recv_func_posthandle(padapter, pending_frame); - } - - ret = recv_func_prehandle(padapter, rframe); - - if (ret == _SUCCESS) { - /* check if need to enqueue into uc_swdec_pending_queue*/ - if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && - !is_multicast_ether_addr(prxattrib->ra) && - prxattrib->encrypt > 0 && - prxattrib->bdecrypted == 0 && - !is_wep_enc(psecuritypriv->dot11PrivacyAlgrthm) && - !psecuritypriv->busetkipkey) { - rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue); - goto exit; - } - - ret = recv_func_posthandle(padapter, rframe); - } - -exit: - return ret; -} - -int rtw_recv_entry(struct recv_frame *precvframe) -{ - struct adapter *padapter = precvframe->adapter; - struct recv_priv *precvpriv = &padapter->recvpriv; - int ret; - - ret = recv_func(padapter, precvframe); - if (ret == _SUCCESS) - precvpriv->rx_pkts++; - - return ret; -} - -static void rtw_signal_stat_timer_hdl(struct timer_list *t) -{ - struct adapter *adapter = - from_timer(adapter, t, recvpriv.signal_stat_timer); - struct recv_priv *recvpriv = &adapter->recvpriv; - - u32 tmp_s, tmp_q; - u8 avg_signal_strength = 0; - u8 avg_signal_qual = 0; - u8 _alpha = 3; /* this value is based on converging_constant = 5000 and sampling_interval = 1000 */ - - if (recvpriv->signal_strength_data.update_req == 0) { - /* update_req is clear, means we got rx */ - avg_signal_strength = recvpriv->signal_strength_data.avg_val; - /* after avg_vals are acquired, we can re-stat the signal - * values - */ - recvpriv->signal_strength_data.update_req = 1; - } - - if (recvpriv->signal_qual_data.update_req == 0) { - /* update_req is clear, means we got rx */ - avg_signal_qual = recvpriv->signal_qual_data.avg_val; - /* after avg_vals are acquired, we can re-stat the signal - * values - */ - recvpriv->signal_qual_data.update_req = 1; - } - - /* update value of signal_strength, rssi, signal_qual */ - if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) { - tmp_s = avg_signal_strength + - (_alpha - 1) * recvpriv->signal_strength; - tmp_s = DIV_ROUND_UP(tmp_s, _alpha); - if (tmp_s > 100) - tmp_s = 100; - - tmp_q = avg_signal_qual + - (_alpha - 1) * recvpriv->signal_qual; - tmp_q = DIV_ROUND_UP(tmp_q, _alpha); - if (tmp_q > 100) - tmp_q = 100; - - recvpriv->signal_strength = tmp_s; - recvpriv->rssi = (s8)translate_percentage_to_dbm(tmp_s); - recvpriv->signal_qual = tmp_q; - } - - rtw_set_signal_stat_timer(recvpriv); -} diff --git a/drivers/staging/rtl8188eu/core/rtw_rf.c b/drivers/staging/rtl8188eu/core/rtw_rf.c deleted file mode 100644 index 094aa15efe44..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_rf.c +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_RF_C_ - -#include -#include -#include -#include - -struct ch_freq { - u32 channel; - u32 frequency; -}; - -static struct ch_freq ch_freq_map[] = { - {1, 2412}, {2, 2417}, {3, 2422}, {4, 2427}, {5, 2432}, - {6, 2437}, {7, 2442}, {8, 2447}, {9, 2452}, {10, 2457}, - {11, 2462}, {12, 2467}, {13, 2472}, {14, 2484}, - /* UNII */ - {36, 5180}, {40, 5200}, {44, 5220}, {48, 5240}, {52, 5260}, - {56, 5280}, {60, 5300}, {64, 5320}, {149, 5745}, {153, 5765}, - {157, 5785}, {161, 5805}, {165, 5825}, {167, 5835}, {169, 5845}, - {171, 5855}, {173, 5865}, - /* HiperLAN2 */ - {100, 5500}, {104, 5520}, {108, 5540}, {112, 5560}, {116, 5580}, - {120, 5600}, {124, 5620}, {128, 5640}, {132, 5660}, {136, 5680}, - {140, 5700}, - /* Japan MMAC */ - {34, 5170}, {38, 5190}, {42, 5210}, {46, 5230}, - /* Japan */ - {184, 4920}, {188, 4940}, {192, 4960}, {196, 4980}, - {208, 5040},/* Japan, means J08 */ - {212, 5060},/* Japan, means J12 */ - {216, 5080},/* Japan, means J16 */ -}; - -static int ch_freq_map_num = ARRAY_SIZE(ch_freq_map); - -u32 rtw_ch2freq(u32 channel) -{ - u8 i; - u32 freq = 0; - - for (i = 0; i < ch_freq_map_num; i++) { - if (channel == ch_freq_map[i].channel) { - freq = ch_freq_map[i].frequency; - break; - } - } - if (i == ch_freq_map_num) - freq = 2412; - - return freq; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_security.c b/drivers/staging/rtl8188eu/core/rtw_security.c deleted file mode 100644 index 7185c1ae2ab8..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_security.c +++ /dev/null @@ -1,826 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_SECURITY_C_ - -#include -#include -#include -#include -#include -#include - -/* WEP related ===== */ - -#define CRC32_POLY 0x04c11db7 - -struct arc4context { - u32 x; - u32 y; - u8 state[256]; -}; - -static void arcfour_init(struct arc4context *parc4ctx, u8 *key, u32 key_len) -{ - u32 t, u; - u32 keyindex; - u32 stateindex; - u8 *state; - u32 counter; - - state = parc4ctx->state; - parc4ctx->x = 0; - parc4ctx->y = 0; - for (counter = 0; counter < 256; counter++) - state[counter] = (u8)counter; - keyindex = 0; - stateindex = 0; - for (counter = 0; counter < 256; counter++) { - t = state[counter]; - stateindex = (stateindex + key[keyindex] + t) & 0xff; - u = state[stateindex]; - state[stateindex] = (u8)t; - state[counter] = (u8)u; - if (++keyindex >= key_len) - keyindex = 0; - } -} - -static u32 arcfour_byte(struct arc4context *parc4ctx) -{ - u32 x; - u32 y; - u32 sx, sy; - u8 *state; - - state = parc4ctx->state; - x = (parc4ctx->x + 1) & 0xff; - sx = state[x]; - y = (sx + parc4ctx->y) & 0xff; - sy = state[y]; - parc4ctx->x = x; - parc4ctx->y = y; - state[y] = (u8)sx; - state[x] = (u8)sy; - return state[(sx + sy) & 0xff]; -} - -static void arcfour_encrypt(struct arc4context *parc4ctx, u8 *dest, u8 *src, u32 len) -{ - u32 i; - - for (i = 0; i < len; i++) - dest[i] = src[i] ^ (unsigned char)arcfour_byte(parc4ctx); -} - -/* Need to consider the fragment situation */ -void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - int curfragnum, length; - u8 *pframe; - u8 hw_hdr_offset = 0; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - const int keyindex = psecuritypriv->dot11PrivacyKeyIndex; - void *crypto_private; - struct sk_buff *skb; - struct lib80211_crypto_ops *crypto_ops; - - if (!pxmitframe->buf_addr) - return; - - if ((pattrib->encrypt != _WEP40_) && (pattrib->encrypt != _WEP104_)) - return; - - hw_hdr_offset = TXDESC_SIZE + - (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - - pframe = pxmitframe->buf_addr + hw_hdr_offset; - - crypto_ops = lib80211_get_crypto_ops("WEP"); - - if (!crypto_ops) - return; - - crypto_private = crypto_ops->init(keyindex); - if (!crypto_private) - return; - - if (crypto_ops->set_key(psecuritypriv->dot11DefKey[keyindex].skey, - psecuritypriv->dot11DefKeylen[keyindex], NULL, crypto_private) < 0) - goto free_crypto_private; - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if (curfragnum + 1 == pattrib->nr_frags) - length = pattrib->last_txcmdsz; - else - length = pxmitpriv->frag_len; - skb = dev_alloc_skb(length); - if (!skb) - goto free_crypto_private; - - skb_put_data(skb, pframe, length); - - memmove(skb->data + 4, skb->data, pattrib->hdrlen); - skb_pull(skb, 4); - skb_trim(skb, skb->len - 4); - - if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { - kfree_skb(skb); - goto free_crypto_private; - } - - memcpy(pframe, skb->data, skb->len); - - pframe += skb->len; - pframe = (u8 *)round_up((size_t)(pframe), 4); - - kfree_skb(skb); - } - -free_crypto_private: - crypto_ops->deinit(crypto_private); -} - -int rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe) -{ - struct rx_pkt_attrib *prxattrib = &precvframe->attrib; - - if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sk_buff *skb = precvframe->pkt; - u8 *pframe = skb->data; - void *crypto_private = NULL; - int status = _SUCCESS; - const int keyindex = prxattrib->key_index; - struct lib80211_crypto_ops *crypto_ops = lib80211_get_crypto_ops("WEP"); - char iv[4], icv[4]; - - if (!crypto_ops) { - status = _FAIL; - goto exit; - } - - memcpy(iv, pframe + prxattrib->hdrlen, 4); - memcpy(icv, pframe + skb->len - 4, 4); - - crypto_private = crypto_ops->init(keyindex); - if (!crypto_private) { - status = _FAIL; - goto exit; - } - if (crypto_ops->set_key(psecuritypriv->dot11DefKey[keyindex].skey, - psecuritypriv->dot11DefKeylen[keyindex], NULL, crypto_private) < 0) { - status = _FAIL; - goto exit; - } - if (crypto_ops->decrypt_mpdu(skb, prxattrib->hdrlen, crypto_private)) { - status = _FAIL; - goto exit; - } - - memmove(pframe, pframe + 4, prxattrib->hdrlen); - skb_push(skb, 4); - skb_put(skb, 4); - - memcpy(pframe + prxattrib->hdrlen, iv, 4); - memcpy(pframe + skb->len - 4, icv, 4); - -exit: - if (crypto_ops && crypto_private) - crypto_ops->deinit(crypto_private); - return status; - } - - return _FAIL; -} - -/* 3 ===== TKIP related ===== */ - -static u32 secmicgetuint32(u8 *p) -/* Convert from Byte[] to Us3232 in a portable way */ -{ - s32 i; - u32 res = 0; - - for (i = 0; i < 4; i++) - res |= ((u32)(*p++)) << (8 * i); - return res; -} - -static void secmicputuint32(u8 *p, u32 val) -/* Convert from Us3232 to Byte[] in a portable way */ -{ - long i; - - for (i = 0; i < 4; i++) { - *p++ = (u8)(val & 0xff); - val >>= 8; - } -} - -static void secmicclear(struct mic_data *pmicdata) -{ -/* Reset the state to the empty message. */ - pmicdata->L = pmicdata->K0; - pmicdata->R = pmicdata->K1; - pmicdata->nBytesInM = 0; - pmicdata->M = 0; -} - -void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key) -{ - /* Set the key */ - pmicdata->K0 = secmicgetuint32(key); - pmicdata->K1 = secmicgetuint32(key + 4); - /* and reset the message */ - secmicclear(pmicdata); -} - -void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) -{ - /* Append the byte to our word-sized buffer */ - pmicdata->M |= ((unsigned long)b) << (8 * pmicdata->nBytesInM); - pmicdata->nBytesInM++; - /* Process the word if it is full. */ - if (pmicdata->nBytesInM >= 4) { - pmicdata->L ^= pmicdata->M; - pmicdata->R ^= ROL32(pmicdata->L, 17); - pmicdata->L += pmicdata->R; - pmicdata->R ^= ((pmicdata->L & 0xff00ff00) >> 8) | ((pmicdata->L & 0x00ff00ff) << 8); - pmicdata->L += pmicdata->R; - pmicdata->R ^= ROL32(pmicdata->L, 3); - pmicdata->L += pmicdata->R; - pmicdata->R ^= ROR32(pmicdata->L, 2); - pmicdata->L += pmicdata->R; - /* Clear the buffer */ - pmicdata->M = 0; - pmicdata->nBytesInM = 0; - } -} - -void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nbytes) -{ - /* This is simple */ - while (nbytes > 0) { - rtw_secmicappendbyte(pmicdata, *src++); - nbytes--; - } -} - -void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) -{ - /* Append the minimum padding */ - rtw_secmicappendbyte(pmicdata, 0x5a); - rtw_secmicappendbyte(pmicdata, 0); - rtw_secmicappendbyte(pmicdata, 0); - rtw_secmicappendbyte(pmicdata, 0); - rtw_secmicappendbyte(pmicdata, 0); - /* and then zeroes until the length is a multiple of 4 */ - while (pmicdata->nBytesInM != 0) - rtw_secmicappendbyte(pmicdata, 0); - /* The appendByte function has already computed the result. */ - secmicputuint32(dst, pmicdata->L); - secmicputuint32(dst + 4, pmicdata->R); - /* Reset to the empty message. */ - secmicclear(pmicdata); -} - -void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_code, u8 pri) -{ - struct mic_data micdata; - u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; - - rtw_secmicsetkey(&micdata, key); - priority[0] = pri; - - /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ - if (header[1] & 1) { /* ToDS == 1 */ - rtw_secmicappend(&micdata, &header[16], 6); /* DA */ - if (header[1] & 2) /* From Ds == 1 */ - rtw_secmicappend(&micdata, &header[24], 6); - else - rtw_secmicappend(&micdata, &header[10], 6); - } else { /* ToDS == 0 */ - rtw_secmicappend(&micdata, &header[4], 6); /* DA */ - if (header[1] & 2) /* From Ds == 1 */ - rtw_secmicappend(&micdata, &header[16], 6); - else - rtw_secmicappend(&micdata, &header[10], 6); - } - rtw_secmicappend(&micdata, &priority[0], 4); - - rtw_secmicappend(&micdata, data, data_len); - - rtw_secgetmic(&micdata, mic_code); -} - -/* macros for extraction/creation of unsigned char/unsigned short values */ -#define RotR1(v16) ((((v16) >> 1) & 0x7FFF) ^ (((v16) & 1) << 15)) -#define Lo8(v16) ((u8)((v16) & 0x00FF)) -#define Hi8(v16) ((u8)(((v16) >> 8) & 0x00FF)) -#define Lo16(v32) ((u16)((v32) & 0xFFFF)) -#define Hi16(v32) ((u16)(((v32) >> 16) & 0xFFFF)) -#define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8)) - -/* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ -#define TK16(N) Mk16(tk[2 * (N) + 1], tk[2 * (N)]) - -/* S-box lookup: 16 bits --> 16 bits */ -#define _S_(v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)]) - -/* fixed algorithm "parameters" */ -#define PHASE1_LOOP_CNT 8 /* this needs to be "big enough" */ -#define TA_SIZE 6 /* 48-bit transmitter address */ -#define TK_SIZE 16 /* 128-bit temporal key */ -#define P1K_SIZE 10 /* 80-bit Phase1 key */ -#define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ - -/* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ -static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ -{ - 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, - 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, - 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, - 0x41EC, 0xB367, 0x5FFD, 0x45EA, 0x23BF, 0x53F7, 0xE496, 0x9B5B, - 0x75C2, 0xE11C, 0x3DAE, 0x4C6A, 0x6C5A, 0x7E41, 0xF502, 0x834F, - 0x685C, 0x51F4, 0xD134, 0xF908, 0xE293, 0xAB73, 0x6253, 0x2A3F, - 0x080C, 0x9552, 0x4665, 0x9D5E, 0x3028, 0x37A1, 0x0A0F, 0x2FB5, - 0x0E09, 0x2436, 0x1B9B, 0xDF3D, 0xCD26, 0x4E69, 0x7FCD, 0xEA9F, - 0x121B, 0x1D9E, 0x5874, 0x342E, 0x362D, 0xDCB2, 0xB4EE, 0x5BFB, - 0xA4F6, 0x764D, 0xB761, 0x7DCE, 0x527B, 0xDD3E, 0x5E71, 0x1397, - 0xA6F5, 0xB968, 0x0000, 0xC12C, 0x4060, 0xE31F, 0x79C8, 0xB6ED, - 0xD4BE, 0x8D46, 0x67D9, 0x724B, 0x94DE, 0x98D4, 0xB0E8, 0x854A, - 0xBB6B, 0xC52A, 0x4FE5, 0xED16, 0x86C5, 0x9AD7, 0x6655, 0x1194, - 0x8ACF, 0xE910, 0x0406, 0xFE81, 0xA0F0, 0x7844, 0x25BA, 0x4BE3, - 0xA2F3, 0x5DFE, 0x80C0, 0x058A, 0x3FAD, 0x21BC, 0x7048, 0xF104, - 0x63DF, 0x77C1, 0xAF75, 0x4263, 0x2030, 0xE51A, 0xFD0E, 0xBF6D, - 0x814C, 0x1814, 0x2635, 0xC32F, 0xBEE1, 0x35A2, 0x88CC, 0x2E39, - 0x9357, 0x55F2, 0xFC82, 0x7A47, 0xC8AC, 0xBAE7, 0x322B, 0xE695, - 0xC0A0, 0x1998, 0x9ED1, 0xA37F, 0x4466, 0x547E, 0x3BAB, 0x0B83, - 0x8CCA, 0xC729, 0x6BD3, 0x283C, 0xA779, 0xBCE2, 0x161D, 0xAD76, - 0xDB3B, 0x6456, 0x744E, 0x141E, 0x92DB, 0x0C0A, 0x486C, 0xB8E4, - 0x9F5D, 0xBD6E, 0x43EF, 0xC4A6, 0x39A8, 0x31A4, 0xD337, 0xF28B, - 0xD532, 0x8B43, 0x6E59, 0xDAB7, 0x018C, 0xB164, 0x9CD2, 0x49E0, - 0xD8B4, 0xACFA, 0xF307, 0xCF25, 0xCAAF, 0xF48E, 0x47E9, 0x1018, - 0x6FD5, 0xF088, 0x4A6F, 0x5C72, 0x3824, 0x57F1, 0x73C7, 0x9751, - 0xCB23, 0xA17C, 0xE89C, 0x3E21, 0x96DD, 0x61DC, 0x0D86, 0x0F85, - 0xE090, 0x7C42, 0x71C4, 0xCCAA, 0x90D8, 0x0605, 0xF701, 0x1C12, - 0xC2A3, 0x6A5F, 0xAEF9, 0x69D0, 0x1791, 0x9958, 0x3A27, 0x27B9, - 0xD938, 0xEB13, 0x2BB3, 0x2233, 0xD2BB, 0xA970, 0x0789, 0x33A7, - 0x2DB6, 0x3C22, 0x1592, 0xC920, 0x8749, 0xAAFF, 0x5078, 0xA57A, - 0x038F, 0x59F8, 0x0980, 0x1A17, 0x65DA, 0xD731, 0x84C6, 0xD0B8, - 0x82C3, 0x29B0, 0x5A77, 0x1E11, 0x7BCB, 0xA8FC, 0x6DD6, 0x2C3A, - }, - - { /* second half of table is unsigned char-reversed version of first! */ - 0xA5C6, 0x84F8, 0x99EE, 0x8DF6, 0x0DFF, 0xBDD6, 0xB1DE, 0x5491, - 0x5060, 0x0302, 0xA9CE, 0x7D56, 0x19E7, 0x62B5, 0xE64D, 0x9AEC, - 0x458F, 0x9D1F, 0x4089, 0x87FA, 0x15EF, 0xEBB2, 0xC98E, 0x0BFB, - 0xEC41, 0x67B3, 0xFD5F, 0xEA45, 0xBF23, 0xF753, 0x96E4, 0x5B9B, - 0xC275, 0x1CE1, 0xAE3D, 0x6A4C, 0x5A6C, 0x417E, 0x02F5, 0x4F83, - 0x5C68, 0xF451, 0x34D1, 0x08F9, 0x93E2, 0x73AB, 0x5362, 0x3F2A, - 0x0C08, 0x5295, 0x6546, 0x5E9D, 0x2830, 0xA137, 0x0F0A, 0xB52F, - 0x090E, 0x3624, 0x9B1B, 0x3DDF, 0x26CD, 0x694E, 0xCD7F, 0x9FEA, - 0x1B12, 0x9E1D, 0x7458, 0x2E34, 0x2D36, 0xB2DC, 0xEEB4, 0xFB5B, - 0xF6A4, 0x4D76, 0x61B7, 0xCE7D, 0x7B52, 0x3EDD, 0x715E, 0x9713, - 0xF5A6, 0x68B9, 0x0000, 0x2CC1, 0x6040, 0x1FE3, 0xC879, 0xEDB6, - 0xBED4, 0x468D, 0xD967, 0x4B72, 0xDE94, 0xD498, 0xE8B0, 0x4A85, - 0x6BBB, 0x2AC5, 0xE54F, 0x16ED, 0xC586, 0xD79A, 0x5566, 0x9411, - 0xCF8A, 0x10E9, 0x0604, 0x81FE, 0xF0A0, 0x4478, 0xBA25, 0xE34B, - 0xF3A2, 0xFE5D, 0xC080, 0x8A05, 0xAD3F, 0xBC21, 0x4870, 0x04F1, - 0xDF63, 0xC177, 0x75AF, 0x6342, 0x3020, 0x1AE5, 0x0EFD, 0x6DBF, - 0x4C81, 0x1418, 0x3526, 0x2FC3, 0xE1BE, 0xA235, 0xCC88, 0x392E, - 0x5793, 0xF255, 0x82FC, 0x477A, 0xACC8, 0xE7BA, 0x2B32, 0x95E6, - 0xA0C0, 0x9819, 0xD19E, 0x7FA3, 0x6644, 0x7E54, 0xAB3B, 0x830B, - 0xCA8C, 0x29C7, 0xD36B, 0x3C28, 0x79A7, 0xE2BC, 0x1D16, 0x76AD, - 0x3BDB, 0x5664, 0x4E74, 0x1E14, 0xDB92, 0x0A0C, 0x6C48, 0xE4B8, - 0x5D9F, 0x6EBD, 0xEF43, 0xA6C4, 0xA839, 0xA431, 0x37D3, 0x8BF2, - 0x32D5, 0x438B, 0x596E, 0xB7DA, 0x8C01, 0x64B1, 0xD29C, 0xE049, - 0xB4D8, 0xFAAC, 0x07F3, 0x25CF, 0xAFCA, 0x8EF4, 0xE947, 0x1810, - 0xD56F, 0x88F0, 0x6F4A, 0x725C, 0x2438, 0xF157, 0xC773, 0x5197, - 0x23CB, 0x7CA1, 0x9CE8, 0x213E, 0xDD96, 0xDC61, 0x860D, 0x850F, - 0x90E0, 0x427C, 0xC471, 0xAACC, 0xD890, 0x0506, 0x01F7, 0x121C, - 0xA3C2, 0x5F6A, 0xF9AE, 0xD069, 0x9117, 0x5899, 0x273A, 0xB927, - 0x38D9, 0x13EB, 0xB32B, 0x3322, 0xBBD2, 0x70A9, 0x8907, 0xA733, - 0xB62D, 0x223C, 0x9215, 0x20C9, 0x4987, 0xFFAA, 0x7850, 0x7AA5, - 0x8F03, 0xF859, 0x8009, 0x171A, 0xDA65, 0x31D7, 0xC684, 0xB8D0, - 0xC382, 0xB029, 0x775A, 0x111E, 0xCB7B, 0xFCA8, 0xD66D, 0x3A2C, - } -}; - -/** - * phase1() - generate P1K, given TA, TK, IV32 - * @p1k: placeholder for the returned phase 1 key - * @tk: temporal key [128 bits] - * @ta: transmitter's MAC address [ 48 bits] - * @iv32: upper 32 bits of IV [ 32 bits] - * - * This function only needs to be called every 2**16 packets, - * although in theory it could be called every packet. - * - * Return: p1k[] - Phase 1 key [ 80 bits] - */ -static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) -{ - int i; - /* Initialize the 80 bits of P1K[] from IV32 and TA[0..5] */ - p1k[0] = Lo16(iv32); - p1k[1] = Hi16(iv32); - p1k[2] = Mk16(ta[1], ta[0]); /* use TA[] as little-endian */ - p1k[3] = Mk16(ta[3], ta[2]); - p1k[4] = Mk16(ta[5], ta[4]); - - /* Now compute an unbalanced Feistel cipher with 80-bit block */ - /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ - for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ - p1k[0] += _S_(p1k[4] ^ TK16((i & 1) + 0)); - p1k[1] += _S_(p1k[0] ^ TK16((i & 1) + 2)); - p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4)); - p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6)); - p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0)); - p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ - } -} - -/** - * phase2() - generate RC4KEY, given TK, P1K, IV16 - * @rc4key: Placeholder for the returned key - * @tk: Temporal key [128 bits] - * @p1k: Phase 1 output key [ 80 bits] - * @iv16: low 16 bits of IV counter [ 16 bits] - * - * The value {TA, IV32, IV16} for Phase1/Phase2 must be unique - * across all packets using the same key TK value. Then, for a - * given value of TK[], this TKIP48 construction guarantees that - * the final RC4KEY value is unique across all packets. - * - * Suggested implementation optimization: if PPK[] is "overlaid" - * appropriately on RC4KEY[], there is no need for the final - * for loop below that copies the PPK[] result into RC4KEY[]. - * - * Return: rc4key[] - the key used to encrypt the packet [128 bits] - */ -static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) -{ - int i; - u16 PPK[6]; /* temporary key for mixing */ - /* Note: all adds in the PPK[] equations below are mod 2**16 */ - for (i = 0; i < 5; i++) - PPK[i] = p1k[i]; /* first, copy P1K to PPK */ - PPK[5] = p1k[4] + iv16; /* next, add in IV16 */ - - /* Bijective non-linear mixing of the 96 bits of PPK[0..5] */ - PPK[0] += _S_(PPK[5] ^ TK16(0)); /* Mix key in each "round" */ - PPK[1] += _S_(PPK[0] ^ TK16(1)); - PPK[2] += _S_(PPK[1] ^ TK16(2)); - PPK[3] += _S_(PPK[2] ^ TK16(3)); - PPK[4] += _S_(PPK[3] ^ TK16(4)); - PPK[5] += _S_(PPK[4] ^ TK16(5)); /* Total # S-box lookups == 6 */ - - /* Final sweep: bijective, "linear". Rotates kill LSB correlations */ - PPK[0] += RotR1(PPK[5] ^ TK16(6)); - PPK[1] += RotR1(PPK[0] ^ TK16(7)); /* Use all of TK[] in Phase2 */ - PPK[2] += RotR1(PPK[1]); - PPK[3] += RotR1(PPK[2]); - PPK[4] += RotR1(PPK[3]); - PPK[5] += RotR1(PPK[4]); - /* Note: At this point, for a given key TK[0..15], the 96-bit output */ - /* value PPK[0..5] is guaranteed to be unique, as a function */ - /* of the 96-bit "input" value {TA, IV32, IV16}. That is, P1K */ - /* is now a keyed permutation of {TA, IV32, IV16}. */ - - /* Set RC4KEY[0..3], which includes "cleartext" portion of RC4 key */ - rc4key[0] = Hi8(iv16); /* RC4KEY[0..2] is the WEP IV */ - rc4key[1] = (Hi8(iv16) | 0x20) & 0x7F; /* Help avoid weak (FMS) keys */ - rc4key[2] = Lo8(iv16); - rc4key[3] = Lo8((PPK[5] ^ TK16(0)) >> 1); - - /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ - for (i = 0; i < 6; i++) { - rc4key[4 + 2 * i] = Lo8(PPK[i]); - rc4key[5 + 2 * i] = Hi8(PPK[i]); - } -} - -/* The hlen isn't include the IV */ -u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ /* exclude ICV */ - u16 pnl; - u32 pnh; - u8 rc4key[16]; - u8 ttkey[16]; - union { - __le32 f0; - u8 f1[4]; - } crc; - u8 hw_hdr_offset = 0; - struct arc4context mycontext; - int curfragnum, length; - - u8 *pframe, *payload, *iv, *prwskey; - union pn48 dot11txpn; - struct sta_info *stainfo; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u32 res = _SUCCESS; - - if (!pxmitframe->buf_addr) - return _FAIL; - - hw_hdr_offset = TXDESC_SIZE + - (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - pframe = pxmitframe->buf_addr + hw_hdr_offset; - /* 4 start to encrypt each fragment */ - if (pattrib->encrypt == _TKIP_) { - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - - if (stainfo) { - if (is_multicast_ether_addr(pattrib->ra)) - prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; - else - prwskey = &stainfo->dot118021x_UncstKey.skey[0]; - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe + pattrib->hdrlen; - payload = pframe + pattrib->iv_len + pattrib->hdrlen; - - GET_TKIP_PN(iv, dot11txpn); - - pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val >> 16); - phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); - phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); - - if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; - crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); - } else { - length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; - crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); - - pframe += pxmitpriv->frag_len; - pframe = (u8 *)round_up((size_t)(pframe), 4); - } - } - } else { - res = _FAIL; - } - } - return res; -} - -/* The hlen isn't include the IV */ -u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe) -{ /* exclude ICV */ - u16 pnl; - u32 pnh; - u8 rc4key[16]; - u8 ttkey[16]; - union { - __le32 f0; - u8 f1[4]; - } crc; - struct arc4context mycontext; - int length; - u8 *pframe, *payload, *iv, *prwskey; - union pn48 dot11txpn; - struct sta_info *stainfo; - struct rx_pkt_attrib *prxattrib = &precvframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - u32 res = _SUCCESS; - - pframe = (unsigned char *)precvframe->pkt->data; - - /* 4 start to decrypt recvframe */ - if (prxattrib->encrypt == _TKIP_) { - stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - if (stainfo) { - if (is_multicast_ether_addr(prxattrib->ra)) { - if (!psecuritypriv->binstallGrpkey) { - res = _FAIL; - goto exit; - } - prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; - } else { - prwskey = &stainfo->dot118021x_UncstKey.skey[0]; - } - - iv = pframe + prxattrib->hdrlen; - payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; - length = precvframe->pkt->len - prxattrib->hdrlen - prxattrib->iv_len; - - GET_TKIP_PN(iv, dot11txpn); - - pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val >> 16); - - phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh); - phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl); - - /* 4 decrypt payload include icv */ - - arcfour_init(&mycontext, rc4key, 16); - arcfour_encrypt(&mycontext, payload, payload, length); - - crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length - 4)); - - if (crc.f1[3] != payload[length - 1] || - crc.f1[2] != payload[length - 2] || - crc.f1[1] != payload[length - 3] || - crc.f1[0] != payload[length - 4]) - res = _FAIL; - } else { - res = _FAIL; - } - } -exit: - return res; -} - -u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - int curfragnum, length; - u8 *pframe; /* *payload,*iv */ - u8 hw_hdr_offset = 0; - struct sta_info *stainfo; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u32 res = _SUCCESS; - void *crypto_private; - struct sk_buff *skb; - struct lib80211_crypto_ops *crypto_ops; - const int key_idx = is_multicast_ether_addr(pattrib->ra) ? psecuritypriv->dot118021XGrpKeyid : 0; - const int key_length = 16; - u8 *key; - - if (!pxmitframe->buf_addr) - return _FAIL; - - hw_hdr_offset = TXDESC_SIZE + - (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - - pframe = pxmitframe->buf_addr + hw_hdr_offset; - - /* 4 start to encrypt each fragment */ - if (pattrib->encrypt != _AES_) - return res; - - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - - if (!stainfo) - return _FAIL; - - crypto_ops = lib80211_get_crypto_ops("CCMP"); - - if (is_multicast_ether_addr(pattrib->ra)) - key = psecuritypriv->dot118021XGrpKey[key_idx].skey; - else - key = stainfo->dot118021x_UncstKey.skey; - - if (!crypto_ops) { - res = _FAIL; - goto exit; - } - - crypto_private = crypto_ops->init(key_idx); - if (!crypto_private) { - res = _FAIL; - goto exit; - } - - if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if (curfragnum + 1 == pattrib->nr_frags) - length = pattrib->last_txcmdsz; - else - length = pxmitpriv->frag_len; - - skb = dev_alloc_skb(length); - if (!skb) { - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - skb_put_data(skb, pframe, length); - - memmove(skb->data + pattrib->iv_len, skb->data, pattrib->hdrlen); - skb_pull(skb, pattrib->iv_len); - skb_trim(skb, skb->len - pattrib->icv_len); - - if (crypto_ops->encrypt_mpdu(skb, pattrib->hdrlen, crypto_private)) { - kfree_skb(skb); - res = _FAIL; - goto exit_crypto_ops_deinit; - } - - memcpy(pframe, skb->data, skb->len); - - pframe += skb->len; - pframe = (u8 *)round_up((size_t)(pframe), 8); - - kfree_skb(skb); - } - -exit_crypto_ops_deinit: - crypto_ops->deinit(crypto_private); - -exit: - return res; -} - -u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe) -{ - struct rx_pkt_attrib *prxattrib = &precvframe->attrib; - u32 res = _SUCCESS; - - /* 4 start to encrypt each fragment */ - if (prxattrib->encrypt == _AES_) { - struct sta_info *stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - - if (stainfo) { - int key_idx; - const int key_length = 16, iv_len = 8, icv_len = 8; - struct sk_buff *skb = precvframe->pkt; - void *crypto_private = NULL; - u8 *key, *pframe = skb->data; - struct lib80211_crypto_ops *crypto_ops = lib80211_get_crypto_ops("CCMP"); - struct security_priv *psecuritypriv = &padapter->securitypriv; - char iv[8], icv[8]; - - if (is_multicast_ether_addr(prxattrib->ra)) { - /* in concurrent we should use sw descrypt in group key, so we remove this message */ - if (!psecuritypriv->binstallGrpkey) { - res = _FAIL; - goto exit; - } - key_idx = psecuritypriv->dot118021XGrpKeyid; - key = psecuritypriv->dot118021XGrpKey[key_idx].skey; - } else { - key_idx = 0; - key = stainfo->dot118021x_UncstKey.skey; - } - - if (!crypto_ops) { - res = _FAIL; - goto exit_lib80211_ccmp; - } - - memcpy(iv, pframe + prxattrib->hdrlen, iv_len); - memcpy(icv, pframe + skb->len - icv_len, icv_len); - - crypto_private = crypto_ops->init(key_idx); - if (!crypto_private) { - res = _FAIL; - goto exit_lib80211_ccmp; - } - if (crypto_ops->set_key(key, key_length, NULL, crypto_private) < 0) { - res = _FAIL; - goto exit_lib80211_ccmp; - } - if (crypto_ops->decrypt_mpdu(skb, prxattrib->hdrlen, crypto_private)) { - res = _FAIL; - goto exit_lib80211_ccmp; - } - - memmove(pframe, pframe + iv_len, prxattrib->hdrlen); - skb_push(skb, iv_len); - skb_put(skb, icv_len); - - memcpy(pframe + prxattrib->hdrlen, iv, iv_len); - memcpy(pframe + skb->len - icv_len, icv, icv_len); - -exit_lib80211_ccmp: - if (crypto_ops && crypto_private) - crypto_ops->deinit(crypto_private); - } else { - res = _FAIL; - } - } -exit: - return res; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_sreset.c b/drivers/staging/rtl8188eu/core/rtw_sreset.c deleted file mode 100644 index a8397b132002..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_sreset.c +++ /dev/null @@ -1,21 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include - -void rtw_hal_sreset_init(struct adapter *padapter) -{ - struct sreset_priv *psrtpriv = &padapter->HalData->srestpriv; - - psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; -} - -void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) -{ - padapter->HalData->srestpriv.wifi_error_status = status; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c b/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c deleted file mode 100644 index 19eddf573fd8..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_sta_mgt.c +++ /dev/null @@ -1,479 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_STA_MGT_C_ - -#include -#include -#include -#include -#include -#include -#include - -static void _rtw_init_stainfo(struct sta_info *psta) -{ - memset((u8 *)psta, 0, sizeof(struct sta_info)); - - spin_lock_init(&psta->lock); - INIT_LIST_HEAD(&psta->list); - INIT_LIST_HEAD(&psta->hash_list); - _rtw_init_queue(&psta->sleep_q); - psta->sleepq_len = 0; - - _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); - _rtw_init_sta_recv_priv(&psta->sta_recvpriv); - -#ifdef CONFIG_88EU_AP_MODE - - INIT_LIST_HEAD(&psta->asoc_list); - - INIT_LIST_HEAD(&psta->auth_list); - - psta->expire_to = 0; - - psta->flags = 0; - - psta->capability = 0; - - psta->bpairwise_key_installed = false; - - psta->nonerp_set = 0; - psta->no_short_slot_time_set = 0; - psta->no_short_preamble_set = 0; - psta->no_ht_gf_set = 0; - psta->no_ht_set = 0; - psta->ht_20mhz_set = 0; - - psta->under_exist_checking = 0; - - psta->keep_alive_trycnt = 0; - -#endif /* CONFIG_88EU_AP_MODE */ -} - -u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) -{ - struct sta_info *psta; - s32 i; - - pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4); - - if (!pstapriv->pallocated_stainfo_buf) - return _FAIL; - - pstapriv->pstainfo_buf = pstapriv->pallocated_stainfo_buf + 4 - - ((size_t)(pstapriv->pallocated_stainfo_buf) & 3); - - _rtw_init_queue(&pstapriv->free_sta_queue); - - spin_lock_init(&pstapriv->sta_hash_lock); - - pstapriv->asoc_sta_count = 0; - _rtw_init_queue(&pstapriv->sleep_q); - _rtw_init_queue(&pstapriv->wakeup_q); - - psta = (struct sta_info *)(pstapriv->pstainfo_buf); - - for (i = 0; i < NUM_STA; i++) { - _rtw_init_stainfo(psta); - - INIT_LIST_HEAD(&pstapriv->sta_hash[i]); - - list_add_tail(&psta->list, - get_list_head(&pstapriv->free_sta_queue)); - - psta++; - } - -#ifdef CONFIG_88EU_AP_MODE - - pstapriv->sta_dz_bitmap = 0; - pstapriv->tim_bitmap = 0; - - INIT_LIST_HEAD(&pstapriv->asoc_list); - INIT_LIST_HEAD(&pstapriv->auth_list); - spin_lock_init(&pstapriv->asoc_list_lock); - spin_lock_init(&pstapriv->auth_list_lock); - pstapriv->asoc_list_cnt = 0; - pstapriv->auth_list_cnt = 0; - - pstapriv->auth_to = 3; /* 3*2 = 6 sec */ - pstapriv->assoc_to = 3; - pstapriv->expire_to = 3; /* 3*2 = 6 sec */ - pstapriv->max_num_sta = NUM_STA; -#endif - - return _SUCCESS; -} - -inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta) -{ - int offset = (((u8 *)sta) - stapriv->pstainfo_buf) / sizeof(struct sta_info); - - return offset; -} - -inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int offset) -{ - return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); -} - -u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) -{ - struct list_head *phead, *plist; - struct sta_info *psta = NULL; - struct recv_reorder_ctrl *preorder_ctrl; - int index; - - if (!pstapriv) - return _SUCCESS; - - /* delete all reordering_ctrl_timer */ - spin_lock_bh(&pstapriv->sta_hash_lock); - for (index = 0; index < NUM_STA; index++) { - phead = &pstapriv->sta_hash[index]; - list_for_each(plist, phead) { - int i; - - psta = list_entry(plist, struct sta_info, hash_list); - - for (i = 0; i < 16; i++) { - preorder_ctrl = &psta->recvreorder_ctrl[i]; - del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); - } - } - } - spin_unlock_bh(&pstapriv->sta_hash_lock); - - vfree(pstapriv->pallocated_stainfo_buf); - - return _SUCCESS; -} - -struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) -{ - s32 index; - struct list_head *phash_list; - struct sta_info *psta; - struct __queue *pfree_sta_queue; - struct recv_reorder_ctrl *preorder_ctrl; - int i = 0; - u16 wRxSeqInitialValue = 0xffff; - - pfree_sta_queue = &pstapriv->free_sta_queue; - - spin_lock_bh(&pfree_sta_queue->lock); - psta = list_first_entry_or_null(&pfree_sta_queue->queue, - struct sta_info, list); - if (!psta) { - spin_unlock_bh(&pfree_sta_queue->lock); - return NULL; - } - - list_del_init(&psta->list); - spin_unlock_bh(&pfree_sta_queue->lock); - _rtw_init_stainfo(psta); - memcpy(psta->hwaddr, hwaddr, ETH_ALEN); - index = wifi_mac_hash(hwaddr); - if (index >= NUM_STA) - return NULL; - phash_list = &pstapriv->sta_hash[index]; - - spin_lock_bh(&pstapriv->sta_hash_lock); - list_add_tail(&psta->hash_list, phash_list); - pstapriv->asoc_sta_count++; - spin_unlock_bh(&pstapriv->sta_hash_lock); - - /* Commented by Albert 2009/08/13 - * For the SMC router, the sequence number of first packet of - * WPS handshake will be 0. In this case, this packet will be - * dropped by recv_decache function if we use the 0x00 as the - * default value for tid_rxseq variable. So, we initialize the - * tid_rxseq variable as the 0xffff. - */ - - for (i = 0; i < 16; i++) - memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], - &wRxSeqInitialValue, 2); - - init_addba_retry_timer(pstapriv->padapter, psta); - - /* for A-MPDU Rx reordering buffer control */ - for (i = 0; i < 16; i++) { - preorder_ctrl = &psta->recvreorder_ctrl[i]; - - preorder_ctrl->padapter = pstapriv->padapter; - - preorder_ctrl->enable = false; - - preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->wend_b = 0xffff; - preorder_ctrl->wsize_b = 64;/* 64; */ - - _rtw_init_queue(&preorder_ctrl->pending_recvframe_queue); - - rtw_init_recv_timer(preorder_ctrl); - } - - /* init for DM */ - psta->rssi_stat.UndecoratedSmoothedPWDB = -1; - psta->rssi_stat.UndecoratedSmoothedCCK = -1; - - /* init for the sequence number of received management frame */ - psta->RxMgmtFrameSeqNum = 0xffff; - - return psta; -} - -/* using pstapriv->sta_hash_lock to protect */ -u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) -{ - int i; - struct __queue *pfree_sta_queue; - struct recv_reorder_ctrl *preorder_ctrl; - struct sta_xmit_priv *pstaxmitpriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!psta) - goto exit; - - pfree_sta_queue = &pstapriv->free_sta_queue; - - pstaxmitpriv = &psta->sta_xmitpriv; - - spin_lock_bh(&pxmitpriv->lock); - - rtw_free_xmitframe_queue(pxmitpriv, &psta->sleep_q); - psta->sleepq_len = 0; - - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); - - list_del_init(&pstaxmitpriv->vo_q.tx_pending); - - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); - - list_del_init(&pstaxmitpriv->vi_q.tx_pending); - - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); - - list_del_init(&pstaxmitpriv->bk_q.tx_pending); - - rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); - - list_del_init(&pstaxmitpriv->be_q.tx_pending); - - spin_unlock_bh(&pxmitpriv->lock); - - list_del_init(&psta->hash_list); - pstapriv->asoc_sta_count--; - - /* re-init sta_info; 20061114 */ - _rtw_init_sta_xmit_priv(&psta->sta_xmitpriv); - _rtw_init_sta_recv_priv(&psta->sta_recvpriv); - - del_timer_sync(&psta->addba_retry_timer); - - /* for A-MPDU Rx reordering buffer control, cancel - * reordering_ctrl_timer - */ - for (i = 0; i < 16; i++) { - struct list_head *phead, *plist; - struct recv_frame *prframe; - struct __queue *ppending_recvframe_queue; - struct __queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; - - preorder_ctrl = &psta->recvreorder_ctrl[i]; - - del_timer_sync(&preorder_ctrl->reordering_ctrl_timer); - - ppending_recvframe_queue = &preorder_ctrl->pending_recvframe_queue; - - spin_lock_bh(&ppending_recvframe_queue->lock); - - phead = get_list_head(ppending_recvframe_queue); - plist = phead->next; - - while (!list_empty(phead)) { - prframe = container_of(plist, struct recv_frame, list); - - plist = plist->next; - - list_del_init(&prframe->list); - - rtw_free_recvframe(prframe, pfree_recv_queue); - } - - spin_unlock_bh(&ppending_recvframe_queue->lock); - } - - if (!(psta->state & WIFI_AP_STATE)) - rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, false); - -#ifdef CONFIG_88EU_AP_MODE - - spin_lock_bh(&pstapriv->auth_list_lock); - if (!list_empty(&psta->auth_list)) { - list_del_init(&psta->auth_list); - pstapriv->auth_list_cnt--; - } - spin_unlock_bh(&pstapriv->auth_list_lock); - - psta->expire_to = 0; - - psta->sleepq_ac_len = 0; - psta->qos_info = 0; - - psta->max_sp_len = 0; - psta->uapsd_bk = 0; - psta->uapsd_be = 0; - psta->uapsd_vi = 0; - psta->uapsd_vo = 0; - psta->has_legacy_ac = 0; - - pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); - pstapriv->tim_bitmap &= ~BIT(psta->aid); - - if ((psta->aid > 0) && (pstapriv->sta_aid[psta->aid - 1] == psta)) { - pstapriv->sta_aid[psta->aid - 1] = NULL; - psta->aid = 0; - } - - psta->under_exist_checking = 0; - -#endif /* CONFIG_88EU_AP_MODE */ - - spin_lock_bh(&pfree_sta_queue->lock); - list_add_tail(&psta->list, get_list_head(pfree_sta_queue)); - spin_unlock_bh(&pfree_sta_queue->lock); - -exit: - - return _SUCCESS; -} - -/* free all stainfo which in sta_hash[all] */ -void rtw_free_all_stainfo(struct adapter *padapter) -{ - struct list_head *phead; - s32 index; - struct sta_info *psta, *temp; - struct sta_priv *pstapriv = &padapter->stapriv; - struct sta_info *pbcmc_stainfo = rtw_get_bcmc_stainfo(padapter); - - if (pstapriv->asoc_sta_count == 1) - return; - - spin_lock_bh(&pstapriv->sta_hash_lock); - - for (index = 0; index < NUM_STA; index++) { - phead = &pstapriv->sta_hash[index]; - list_for_each_entry_safe(psta, temp, phead, hash_list) { - if (pbcmc_stainfo != psta) - rtw_free_stainfo(padapter, psta); - } - } - spin_unlock_bh(&pstapriv->sta_hash_lock); -} - -/* any station allocated can be searched by hash list */ -struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) -{ - struct list_head *plist, *phead; - struct sta_info *psta = NULL; - u32 index; - u8 *addr; - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - if (!hwaddr) - return NULL; - - if (is_multicast_ether_addr(hwaddr)) - addr = bc_addr; - else - addr = hwaddr; - - index = wifi_mac_hash(addr); - - spin_lock_bh(&pstapriv->sta_hash_lock); - - phead = &pstapriv->sta_hash[index]; - list_for_each(plist, phead) { - psta = list_entry(plist, struct sta_info, hash_list); - - if (!memcmp(psta->hwaddr, addr, ETH_ALEN)) { - /* if found the matched address */ - break; - } - psta = NULL; - } - - spin_unlock_bh(&pstapriv->sta_hash_lock); - return psta; -} - -u32 rtw_init_bcmc_stainfo(struct adapter *padapter) -{ - struct sta_info *psta; - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - struct sta_priv *pstapriv = &padapter->stapriv; - - psta = rtw_alloc_stainfo(pstapriv, bc_addr); - - if (!psta) - return _FAIL; - - /* default broadcast & multicast use macid 1 */ - psta->mac_id = 1; - - return _SUCCESS; -} - -struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - return rtw_get_stainfo(pstapriv, bc_addr); -} - -bool rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) -{ - bool res = true; -#ifdef CONFIG_88EU_AP_MODE - struct list_head *plist, *phead; - struct rtw_wlan_acl_node *paclnode; - bool match = false; - struct sta_priv *pstapriv = &padapter->stapriv; - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; - struct __queue *pacl_node_q = &pacl_list->acl_node_q; - - spin_lock_bh(&pacl_node_q->lock); - phead = get_list_head(pacl_node_q); - list_for_each(plist, phead) { - paclnode = list_entry(plist, struct rtw_wlan_acl_node, list); - - if (!memcmp(paclnode->addr, mac_addr, ETH_ALEN)) { - if (paclnode->valid) { - match = true; - break; - } - } - } - spin_unlock_bh(&pacl_node_q->lock); - - if (pacl_list->mode == 1)/* accept unless in deny list */ - res = !match; - else if (pacl_list->mode == 2)/* deny unless in accept list */ - res = match; - else - res = true; - -#endif - - return res; -} diff --git a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c b/drivers/staging/rtl8188eu/core/rtw_wlan_util.c deleted file mode 100644 index 2d4776debb97..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_wlan_util.c +++ /dev/null @@ -1,1373 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_WLAN_UTIL_C_ - -#include - -#include -#include -#include - -static const u8 ARTHEROS_OUI1[] = {0x00, 0x03, 0x7f}; -static const u8 ARTHEROS_OUI2[] = {0x00, 0x13, 0x74}; - -static const u8 BROADCOM_OUI1[] = {0x00, 0x10, 0x18}; -static const u8 BROADCOM_OUI2[] = {0x00, 0x0a, 0xf7}; - -static const u8 CISCO_OUI[] = {0x00, 0x40, 0x96}; -static const u8 MARVELL_OUI[] = {0x00, 0x50, 0x43}; -static const u8 RALINK_OUI[] = {0x00, 0x0c, 0x43}; -static const u8 REALTEK_OUI[] = {0x00, 0xe0, 0x4c}; -static const u8 AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; -static const u8 EPIGRAM_OUI[] = {0x00, 0x90, 0x4c}; - -u8 REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; - -#define WAIT_FOR_BCN_TO_MIN (6000) -#define WAIT_FOR_BCN_TO_MAX (20000) - -static const u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK -}; - -static const u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK -}; - -static const u8 rtw_basic_rate_mix[7] = { - IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK -}; - -unsigned char networktype_to_raid(unsigned char network_type) -{ - switch (network_type) { - case WIRELESS_11B: - return RATR_INX_WIRELESS_B; - case WIRELESS_11A: - case WIRELESS_11G: - return RATR_INX_WIRELESS_G; - case WIRELESS_11BG: - return RATR_INX_WIRELESS_GB; - case WIRELESS_11_24N: - case WIRELESS_11_5N: - return RATR_INX_WIRELESS_N; - case WIRELESS_11A_5N: - case WIRELESS_11G_24N: - return RATR_INX_WIRELESS_NG; - case WIRELESS_11BG_24N: - return RATR_INX_WIRELESS_NGB; - default: - return RATR_INX_WIRELESS_GB; - } -} - -u8 judge_network_type(struct adapter *padapter, unsigned char *rate) -{ - u8 network_type = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pmlmeinfo->HT_enable) - network_type = WIRELESS_11_24N; - - if (rtw_is_cckratesonly_included(rate)) - network_type |= WIRELESS_11B; - else if (rtw_is_cckrates_included(rate)) - network_type |= WIRELESS_11BG; - else - network_type |= WIRELESS_11G; - - return network_type; -} - -static unsigned char ratetbl_val_2wifirate(unsigned char rate) -{ - switch (rate & 0x7f) { - case 0: - return IEEE80211_CCK_RATE_1MB; - case 1: - return IEEE80211_CCK_RATE_2MB; - case 2: - return IEEE80211_CCK_RATE_5MB; - case 3: - return IEEE80211_CCK_RATE_11MB; - case 4: - return IEEE80211_OFDM_RATE_6MB; - case 5: - return IEEE80211_OFDM_RATE_9MB; - case 6: - return IEEE80211_OFDM_RATE_12MB; - case 7: - return IEEE80211_OFDM_RATE_18MB; - case 8: - return IEEE80211_OFDM_RATE_24MB; - case 9: - return IEEE80211_OFDM_RATE_36MB; - case 10: - return IEEE80211_OFDM_RATE_48MB; - case 11: - return IEEE80211_OFDM_RATE_54MB; - default: - return 0; - } -} - -static bool is_basicrate(struct adapter *padapter, unsigned char rate) -{ - int i; - unsigned char val; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - for (i = 0; i < NumRates; i++) { - val = pmlmeext->basicrate[i]; - - if ((val != 0xff) && (val != 0xfe)) { - if (rate == ratetbl_val_2wifirate(val)) - return true; - } - } - return false; -} - -static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rateset) -{ - int i; - unsigned char rate; - unsigned int len = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - for (i = 0; i < NumRates; i++) { - rate = pmlmeext->datarate[i]; - - switch (rate) { - case 0xff: - return len; - case 0xfe: - continue; - default: - rate = ratetbl_val_2wifirate(rate); - - if (is_basicrate(padapter, rate)) - rate |= IEEE80211_BASIC_RATE_MASK; - - rateset[len] = rate; - len++; - break; - } - } - return len; -} - -void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *bssrate_len) -{ - unsigned char supportedrates[NumRates]; - - memset(supportedrates, 0, NumRates); - *bssrate_len = ratetbl2rateset(padapter, supportedrates); - memcpy(pbssrate, supportedrates, *bssrate_len); -} - -void UpdateBrateTbl(struct adapter *Adapter, u8 *mbrate) -{ - u8 i; - u8 rate; - - /* 1M, 2M, 5.5M, 11M, 6M, 12M, 24M are mandatory. */ - for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - rate = mbrate[i] & 0x7f; - switch (rate) { - case IEEE80211_CCK_RATE_1MB: - case IEEE80211_CCK_RATE_2MB: - case IEEE80211_CCK_RATE_5MB: - case IEEE80211_CCK_RATE_11MB: - case IEEE80211_OFDM_RATE_6MB: - case IEEE80211_OFDM_RATE_12MB: - case IEEE80211_OFDM_RATE_24MB: - mbrate[i] |= IEEE80211_BASIC_RATE_MASK; - break; - } - } -} - -void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen) -{ - u8 i; - u8 rate; - - for (i = 0; i < bssratelen; i++) { - rate = bssrateset[i] & 0x7f; - switch (rate) { - case IEEE80211_CCK_RATE_1MB: - case IEEE80211_CCK_RATE_2MB: - case IEEE80211_CCK_RATE_5MB: - case IEEE80211_CCK_RATE_11MB: - bssrateset[i] |= IEEE80211_BASIC_RATE_MASK; - break; - } - } -} - -void Save_DM_Func_Flag(struct adapter *padapter) -{ - u8 saveflag = true; - - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); -} - -void Restore_DM_Func_Flag(struct adapter *padapter) -{ - u8 saveflag = false; - - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_OP, (u8 *)(&saveflag)); -} - -void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable) -{ - if (enable) - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_SET, (u8 *)(&mode)); - else - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FUNC_CLR, (u8 *)(&mode)); -} - -void Set_MSR(struct adapter *padapter, u8 type) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_MEDIA_STATUS, (u8 *)(&type)); -} - -inline u8 rtw_get_oper_ch(struct adapter *adapter) -{ - return adapter->mlmeextpriv.oper_channel; -} - -inline void rtw_set_oper_ch(struct adapter *adapter, u8 ch) -{ - adapter->mlmeextpriv.oper_channel = ch; -} - -inline void rtw_set_oper_bw(struct adapter *adapter, u8 bw) -{ - adapter->mlmeextpriv.oper_bwmode = bw; -} - -inline void rtw_set_oper_choffset(struct adapter *adapter, u8 offset) -{ - adapter->mlmeextpriv.oper_ch_offset = offset; -} - -void SelectChannel(struct adapter *padapter, unsigned char channel) -{ - /* saved channel info */ - rtw_set_oper_ch(padapter, channel); - rtw_hal_set_chan(padapter, channel); -} - -void SetBWMode(struct adapter *padapter, unsigned short bwmode, - unsigned char channel_offset) -{ - /* saved bw info */ - rtw_set_oper_bw(padapter, bwmode); - rtw_set_oper_choffset(padapter, channel_offset); - - rtw_hal_set_bwmode(padapter, (enum ht_channel_width)bwmode, channel_offset); -} - -void set_channel_bwmode(struct adapter *padapter, unsigned char channel, unsigned char channel_offset, unsigned short bwmode) -{ - u8 center_ch; - - if ((bwmode == HT_CHANNEL_WIDTH_20) || - (channel_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE)) { - /* SelectChannel(padapter, channel); */ - center_ch = channel; - } else { - /* switch to the proper channel */ - if (channel_offset == HAL_PRIME_CHNL_OFFSET_LOWER) { - /* SelectChannel(padapter, channel + 2); */ - center_ch = channel + 2; - } else { - /* SelectChannel(padapter, channel - 2); */ - center_ch = channel - 2; - } - } - - /* set Channel */ - /* saved channel/bw info */ - rtw_set_oper_ch(padapter, channel); - rtw_set_oper_bw(padapter, bwmode); - rtw_set_oper_choffset(padapter, channel_offset); - - rtw_hal_set_chan(padapter, center_ch); /* set center channel */ - SetBWMode(padapter, bwmode, channel_offset); -} - -u16 get_beacon_interval(struct wlan_bssid_ex *bss) -{ - __le16 val; - - memcpy((unsigned char *)&val, rtw_get_beacon_interval_from_ie(bss->ies), 2); - - return le16_to_cpu(val); -} - -int is_client_associated_to_ap(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - - if (!padapter) - return _FAIL; - - pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && - (pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) - return true; - else - return _FAIL; -} - -int is_client_associated_to_ibss(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && - (pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) - return true; - else - return _FAIL; -} - -int is_IBSS_empty(struct adapter *padapter) -{ - unsigned int i; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { - if (pmlmeinfo->FW_sta_info[i].status == 1) - return _FAIL; - } - return true; -} - -unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval) -{ - if ((bcn_interval << 2) < WAIT_FOR_BCN_TO_MIN) - return WAIT_FOR_BCN_TO_MIN; - else if ((bcn_interval << 2) > WAIT_FOR_BCN_TO_MAX) - return WAIT_FOR_BCN_TO_MAX; - else - return bcn_interval << 2; -} - -void invalidate_cam_all(struct adapter *padapter) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); -} - -void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) -{ - unsigned int i, val, addr; - int j; - u32 cam_val[2]; - - addr = entry << 3; - - for (j = 5; j >= 0; j--) { - switch (j) { - case 0: - val = ctrl | (mac[0] << 16) | (mac[1] << 24); - break; - case 1: - val = mac[2] | (mac[3] << 8) | (mac[4] << 16) | (mac[5] << 24); - break; - default: - i = (j - 2) << 2; - val = key[i] | (key[i + 1] << 8) | (key[i + 2] << 16) | - (key[i + 3] << 24); - break; - } - - cam_val[0] = val; - cam_val[1] = addr + (unsigned int)j; - - rtw_hal_set_hwreg(padapter, HW_VAR_CAM_WRITE, (u8 *)cam_val); - } -} - -void clear_cam_entry(struct adapter *padapter, u8 entry) -{ - u8 null_sta[ETH_ALEN] = {}; - u8 null_key[16] = {}; - - write_cam(padapter, entry, 0, null_sta, null_key); -} - -int allocate_fw_sta_entry(struct adapter *padapter) -{ - unsigned int mac_id; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { - if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { - pmlmeinfo->FW_sta_info[mac_id].status = 1; - pmlmeinfo->FW_sta_info[mac_id].retry = 0; - break; - } - } - - return mac_id; -} - -void flush_all_cam_entry(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); - - memset((u8 *)(pmlmeinfo->FW_sta_info), 0, sizeof(pmlmeinfo->FW_sta_info)); -} - -int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pmlmepriv->qospriv.qos_option == 0) { - pmlmeinfo->WMM_enable = 0; - return _FAIL; - } - - pmlmeinfo->WMM_enable = 1; - memcpy(&pmlmeinfo->WMM_param, pIE->data + 6, sizeof(struct WMM_para_element)); - return true; -} - -void WMMOnAssocRsp(struct adapter *padapter) -{ - u8 ACI, ACM, AIFS, ECWMin, ECWMax, aSifsTime; - u8 acm_mask; - u16 TXOP; - u32 acParm, i; - u32 edca[4], inx[4]; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregpriv = &padapter->registrypriv; - - if (pmlmeinfo->WMM_enable == 0) { - padapter->mlmepriv.acm_mask = 0; - return; - } - - acm_mask = 0; - - if (pmlmeext->cur_wireless_mode == WIRELESS_11B) - aSifsTime = 10; - else - aSifsTime = 16; - - for (i = 0; i < 4; i++) { - ACI = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 5) & 0x03; - ACM = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN >> 4) & 0x01; - - /* AIFS = AIFSN * slot time + SIFS - r2t phy delay */ - AIFS = (pmlmeinfo->WMM_param.ac_param[i].ACI_AIFSN & 0x0f) * pmlmeinfo->slotTime + aSifsTime; - - ECWMin = pmlmeinfo->WMM_param.ac_param[i].CW & 0x0f; - ECWMax = (pmlmeinfo->WMM_param.ac_param[i].CW & 0xf0) >> 4; - TXOP = le16_to_cpu(pmlmeinfo->WMM_param.ac_param[i].TXOP_limit); - - acParm = AIFS | (ECWMin << 8) | (ECWMax << 12) | (TXOP << 16); - - switch (ACI) { - case 0x0: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BE, (u8 *)(&acParm)); - acm_mask |= (ACM ? BIT(1) : 0); - edca[XMIT_BE_QUEUE] = acParm; - break; - case 0x1: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_BK, (u8 *)(&acParm)); - edca[XMIT_BK_QUEUE] = acParm; - break; - case 0x2: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VI, (u8 *)(&acParm)); - acm_mask |= (ACM ? BIT(2) : 0); - edca[XMIT_VI_QUEUE] = acParm; - break; - case 0x3: - rtw_hal_set_hwreg(padapter, HW_VAR_AC_PARAM_VO, (u8 *)(&acParm)); - acm_mask |= (ACM ? BIT(3) : 0); - edca[XMIT_VO_QUEUE] = acParm; - break; - } - } - - if (padapter->registrypriv.acm_method == 1) - rtw_hal_set_hwreg(padapter, HW_VAR_ACM_CTRL, (u8 *)(&acm_mask)); - else - padapter->mlmepriv.acm_mask = acm_mask; - - inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; - - if (pregpriv->wifi_spec == 1) { - u32 j, change_inx = false; - - /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ - for (i = 0; i < 4; i++) { - for (j = i + 1; j < 4; j++) { - /* compare CW and AIFS */ - if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { - change_inx = true; - } else if ((edca[j] & 0xFFFF) == (edca[i] & 0xFFFF)) { - /* compare TXOP */ - if ((edca[j] >> 16) > (edca[i] >> 16)) - change_inx = true; - } - - if (change_inx) { - swap(edca[i], edca[j]); - swap(inx[i], inx[j]); - change_inx = false; - } - } - } - } - - for (i = 0; i < 4; i++) - pxmitpriv->wmm_para_seq[i] = inx[i]; -} - -static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -{ - unsigned char new_bwmode; - unsigned char new_ch_offset; - struct HT_info_element *pHT_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - - if (!pIE) - return; - - if (!phtpriv) - return; - - if (pIE->Length > sizeof(struct HT_info_element)) - return; - - pHT_info = (struct HT_info_element *)pIE->data; - - if ((pHT_info->infos[0] & BIT(2)) && pregistrypriv->cbw40_enable) { - new_bwmode = HT_CHANNEL_WIDTH_40; - - switch (pHT_info->infos[0] & 0x3) { - case 1: - new_ch_offset = HAL_PRIME_CHNL_OFFSET_LOWER; - break; - case 3: - new_ch_offset = HAL_PRIME_CHNL_OFFSET_UPPER; - break; - default: - new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - break; - } - } else { - new_bwmode = HT_CHANNEL_WIDTH_20; - new_ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - } - - if ((new_bwmode != pmlmeext->cur_bwmode) || - (new_ch_offset != pmlmeext->cur_ch_offset)) { - pmlmeinfo->bwmode_updated = true; - - pmlmeext->cur_bwmode = new_bwmode; - pmlmeext->cur_ch_offset = new_ch_offset; - - /* update HT info also */ - HT_info_handler(padapter, pIE); - } else { - pmlmeinfo->bwmode_updated = false; - } - - if (pmlmeinfo->bwmode_updated) { - struct sta_info *psta; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - struct sta_priv *pstapriv = &padapter->stapriv; - - /* update ap's stainfo */ - psta = rtw_get_stainfo(pstapriv, cur_network->MacAddress); - if (psta) { - struct ht_priv *phtpriv_sta = &psta->htpriv; - - if (phtpriv_sta->ht_option) { - /* bwmode */ - phtpriv_sta->bwmode = pmlmeext->cur_bwmode; - phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; - } else { - phtpriv_sta->bwmode = HT_CHANNEL_WIDTH_20; - phtpriv_sta->ch_offset = HAL_PRIME_CHNL_OFFSET_DONT_CARE; - } - } - } -} - -void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -{ - unsigned int i; - u8 max_ampdu_len, min_mpdu_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - u8 *HT_cap = (u8 *)(&pmlmeinfo->HT_caps); - - if (!pIE) - return; - - if (!phtpriv->ht_option) - return; - - pmlmeinfo->HT_caps_enable = 1; - - for (i = 0; i < (pIE->Length); i++) { - if (i != 2) { - /* Got the endian issue here. */ - HT_cap[i] &= (pIE->data[i]); - } else { - /* modify from fw by Thomas 2010/11/17 */ - if ((pmlmeinfo->HT_caps.ampdu_params_info & 0x3) > (pIE->data[i] & 0x3)) - max_ampdu_len = pIE->data[i] & 0x3; - else - max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x3; - - if ((pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) > (pIE->data[i] & 0x1c)) - min_mpdu_spacing = pmlmeinfo->HT_caps.ampdu_params_info & 0x1c; - else - min_mpdu_spacing = pIE->data[i] & 0x1c; - - pmlmeinfo->HT_caps.ampdu_params_info = max_ampdu_len | min_mpdu_spacing; - } - } - - /* update the MCS rates */ - for (i = 0; i < 16; i++) - ((u8 *)&pmlmeinfo->HT_caps.mcs)[i] &= MCS_rate_1R[i]; -} - -void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ht_priv *phtpriv = &pmlmepriv->htpriv; - - if (!pIE) - return; - - if (!phtpriv->ht_option) - return; - - if (pIE->Length > sizeof(struct HT_info_element)) - return; - - pmlmeinfo->HT_info_enable = 1; - memcpy(&pmlmeinfo->HT_info, pIE->data, pIE->Length); -} - -void HTOnAssocRsp(struct adapter *padapter) -{ - u8 max_ampdu_len; - u8 min_mpdu_spacing; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if ((pmlmeinfo->HT_info_enable) && (pmlmeinfo->HT_caps_enable)) { - pmlmeinfo->HT_enable = 1; - } else { - pmlmeinfo->HT_enable = 0; - return; - } - - /* handle A-MPDU parameter field - * - * AMPDU_para [1:0]:Max AMPDU Len => 0:8k , 1:16k, 2:32k, 3:64k - * AMPDU_para [4:2]:Min MPDU Start Spacing - */ - max_ampdu_len = pmlmeinfo->HT_caps.ampdu_params_info & 0x03; - min_mpdu_spacing = (pmlmeinfo->HT_caps.ampdu_params_info & 0x1c) >> 2; - - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_MIN_SPACE, &min_mpdu_spacing); - rtw_hal_set_hwreg(padapter, HW_VAR_AMPDU_FACTOR, &max_ampdu_len); -} - -void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pIE->Length > 1) - return; - - pmlmeinfo->ERP_enable = 1; - memcpy(&pmlmeinfo->ERP_IE, pIE->data, pIE->Length); -} - -void VCS_update(struct adapter *padapter, struct sta_info *psta) -{ - struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ - case 0: /* off */ - psta->rtsen = 0; - psta->cts2self = 0; - break; - case 1: /* on */ - if (pregpriv->vcs_type == 1) { /* 1:RTS/CTS 2:CTS to self */ - psta->rtsen = 1; - psta->cts2self = 0; - } else { - psta->rtsen = 0; - psta->cts2self = 1; - } - break; - case 2: /* auto */ - default: - if ((pmlmeinfo->ERP_enable) && (pmlmeinfo->ERP_IE & BIT(1))) { - if (pregpriv->vcs_type == 1) { - psta->rtsen = 1; - psta->cts2self = 0; - } else { - psta->rtsen = 0; - psta->cts2self = 1; - } - } else { - psta->rtsen = 0; - psta->cts2self = 0; - } - break; - } -} - -int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) -{ - unsigned int len; - unsigned char *p; - unsigned short val16, subtype; - struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; - u16 wpa_len = 0, rsn_len = 0; - u8 encryp_protocol = 0; - struct wlan_bssid_ex *bssid; - int group_cipher = 0, pairwise_cipher = 0, is_8021x = 0; - unsigned char *pbuf; - u32 wpa_ielen = 0; - u8 *pbssid = GetAddr3Ptr(pframe); - struct HT_info_element *pht_info = NULL; - u32 bcn_channel; - unsigned short ht_cap_info; - unsigned char ht_info_infos_0; - int ssid_len; - - if (!is_client_associated_to_ap(Adapter)) - return true; - - len = packet_len - sizeof(struct ieee80211_hdr_3addr); - - if (len > MAX_IE_SZ) - return _FAIL; - - if (memcmp(cur_network->network.MacAddress, pbssid, 6)) - return true; - - bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); - if (!bssid) - return _FAIL; - - subtype = GetFrameSubType(pframe) >> 4; - - if (subtype == IEEE80211_STYPE_BEACON) - bssid->Reserved[0] = 1; - - bssid->Length = sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + len; - - /* below is to copy the information element */ - bssid->ie_length = len; - memcpy(bssid->ies, (pframe + sizeof(struct ieee80211_hdr_3addr)), bssid->ie_length); - - /* check bw and channel offset */ - /* parsing HT_CAP_IE */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_CAPABILITY, &len, bssid->ie_length - _FIXED_IE_LENGTH_); - if (p && len > 0) { - struct ieee80211_ht_cap *ht_cap = - (struct ieee80211_ht_cap *)(p + 2); - - ht_cap_info = le16_to_cpu(ht_cap->cap_info); - } else { - ht_cap_info = 0; - } - /* parsing HT_INFO_IE */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - _FIXED_IE_LENGTH_); - if (p && len > 0) { - pht_info = (struct HT_info_element *)(p + 2); - ht_info_infos_0 = pht_info->infos[0]; - } else { - ht_info_infos_0 = 0; - } - if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || - ((ht_info_infos_0 & 0x03) != (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) { - /* bcn_info_update */ - cur_network->BcnInfo.ht_cap_info = ht_cap_info; - cur_network->BcnInfo.ht_info_infos_0 = ht_info_infos_0; - /* to do : need to check that whether modify related register of BB or not */ - /* goto _mismatch; */ - } - - /* Checking for channel */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_DS_PARAMS, &len, bssid->ie_length - _FIXED_IE_LENGTH_); - if (p) { - bcn_channel = *(p + 2); - } else {/* In 5G, some ap do not have DSSET IE checking HT info for channel */ - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_HT_OPERATION, &len, bssid->ie_length - _FIXED_IE_LENGTH_); - if (pht_info) - bcn_channel = pht_info->primary_channel; - else /* we don't find channel IE, so don't check it */ - bcn_channel = Adapter->mlmeextpriv.cur_channel; - } - if (bcn_channel != Adapter->mlmeextpriv.cur_channel) - goto _mismatch; - - /* checking SSID */ - ssid_len = 0; - p = rtw_get_ie(bssid->ies + _FIXED_IE_LENGTH_, WLAN_EID_SSID, &len, bssid->ie_length - _FIXED_IE_LENGTH_); - if (p) { - ssid_len = *(p + 1); - if (ssid_len > NDIS_802_11_LENGTH_SSID) - ssid_len = 0; - } - memcpy(bssid->ssid.ssid, (p + 2), ssid_len); - bssid->ssid.ssid_length = ssid_len; - - if (memcmp(bssid->ssid.ssid, cur_network->network.ssid.ssid, 32) || - bssid->ssid.ssid_length != cur_network->network.ssid.ssid_length) { - if (bssid->ssid.ssid[0] != '\0' && bssid->ssid.ssid_length != 0) /* not hidden ssid */ - goto _mismatch; - } - - /* check encryption info */ - val16 = rtw_get_capability(bssid); - - if (val16 & BIT(4)) - bssid->Privacy = 1; - else - bssid->Privacy = 0; - - if (cur_network->network.Privacy != bssid->Privacy) - goto _mismatch; - - rtw_get_sec_ie(bssid->ies, bssid->ie_length, NULL, &rsn_len, NULL, &wpa_len); - - if (rsn_len > 0) { - encryp_protocol = ENCRYP_PROTOCOL_WPA2; - } else if (wpa_len > 0) { - encryp_protocol = ENCRYP_PROTOCOL_WPA; - } else { - if (bssid->Privacy) - encryp_protocol = ENCRYP_PROTOCOL_WEP; - } - - if (cur_network->BcnInfo.encryp_protocol != encryp_protocol) - goto _mismatch; - - if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { - pbuf = rtw_get_wpa_ie(&bssid->ies[12], &wpa_ielen, - bssid->ie_length - 12); - if (pbuf && (wpa_ielen > 0)) { - rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, - &pairwise_cipher, &is_8021x); - } else { - pbuf = rtw_get_wpa2_ie(&bssid->ies[12], &wpa_ielen, - bssid->ie_length - 12); - - if (pbuf && (wpa_ielen > 0)) - rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, - &pairwise_cipher, &is_8021x); - } - - if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) - goto _mismatch; - - if (is_8021x != cur_network->BcnInfo.is_8021x) - goto _mismatch; - } - - kfree(bssid); - return _SUCCESS; - -_mismatch: - kfree(bssid); - return _FAIL; -} - -void update_beacon_info(struct adapter *padapter, u8 *pframe, uint pkt_len, struct sta_info *psta) -{ - unsigned int i; - unsigned int len; - struct ndis_802_11_var_ie *pIE; - - len = pkt_len - (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN); - - for (i = 0; i < len;) { - pIE = (struct ndis_802_11_var_ie *)(pframe + (_BEACON_IE_OFFSET_ + WLAN_HDR_A3_LEN) + i); - - switch (pIE->ElementID) { - case WLAN_EID_HT_OPERATION: /* HT info */ - bwmode_update_check(padapter, pIE); - break; - case WLAN_EID_ERP_INFO: - ERP_IE_handler(padapter, pIE); - VCS_update(padapter, psta); - break; - default: - break; - } - - i += (pIE->Length + 2); - } -} - -unsigned int is_ap_in_tkip(struct adapter *padapter) -{ - u32 i; - struct ndis_802_11_var_ie *pIE; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - - if (rtw_get_capability(cur_network) & WLAN_CAPABILITY_PRIVACY) { - for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.ie_length;) { - pIE = (struct ndis_802_11_var_ie *)(pmlmeinfo->network.ies + i); - - switch (pIE->ElementID) { - case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, RTW_WPA_OUI, 4)) && (!memcmp((pIE->data + 12), WPA_TKIP_CIPHER, 4))) - return true; - break; - case WLAN_EID_RSN: - if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) - return true; - break; - default: - break; - } - - i += (pIE->Length + 2); - } - return false; - } else { - return false; - } -} - -static int wifirate2_ratetbl_inx(unsigned char rate) -{ - rate = rate & 0x7f; - - switch (rate) { - case 108: - return 11; - case 96: - return 10; - case 72: - return 9; - case 48: - return 8; - case 36: - return 7; - case 24: - return 6; - case 18: - return 5; - case 12: - return 4; - case 22: - return 3; - case 11: - return 2; - case 4: - return 1; - case 2: - return 0; - default: - return 0; - } -} - -unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz) -{ - unsigned int i, num_of_rate; - unsigned int mask = 0; - - num_of_rate = min_t(unsigned int, ptn_sz, NumRates); - - for (i = 0; i < num_of_rate; i++) { - if ((*(ptn + i)) & 0x80) - mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i)); - } - return mask; -} - -unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz) -{ - unsigned int i, num_of_rate; - unsigned int mask = 0; - - num_of_rate = min_t(unsigned int, ptn_sz, NumRates); - - for (i = 0; i < num_of_rate; i++) - mask |= 0x1 << wifirate2_ratetbl_inx(*(ptn + i)); - return mask; -} - -unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps) -{ - return (pHT_caps->mcs.rx_mask[0] << 12) | - (pHT_caps->mcs.rx_mask[1] << 20); -} - -int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *pHT_caps) -{ - unsigned char bit_offset; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (!(pmlmeinfo->HT_enable)) - return _FAIL; - - if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) - return _FAIL; - - bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40) ? 6 : 5; - - if (__le16_to_cpu(pHT_caps->cap_info) & (0x1 << bit_offset)) - return _SUCCESS; - else - return _FAIL; -} - -unsigned char get_highest_rate_idx(u32 mask) -{ - int i; - unsigned char rate_idx = 0; - - for (i = 27; i >= 0; i--) { - if (mask & BIT(i)) { - rate_idx = i; - break; - } - } - return rate_idx; -} - -void Update_RA_Entry(struct adapter *padapter, u32 mac_id) -{ - rtw_hal_update_ra_mask(padapter, mac_id, 0); -} - -void set_sta_rate(struct adapter *padapter, struct sta_info *psta) -{ - /* rate adaptive */ - Update_RA_Entry(padapter, psta->mac_id); -} - -/* Update RRSR and Rate for USERATE */ -void update_tx_basic_rate(struct adapter *padapter, u8 wirelessmode) -{ - unsigned char supported_rates[NDIS_802_11_LENGTH_RATES_EX]; - - memset(supported_rates, 0, NDIS_802_11_LENGTH_RATES_EX); - - if ((wirelessmode & WIRELESS_11B) && (wirelessmode == WIRELESS_11B)) - memcpy(supported_rates, rtw_basic_rate_cck, 4); - else if (wirelessmode & WIRELESS_11B) - memcpy(supported_rates, rtw_basic_rate_mix, 7); - else - memcpy(supported_rates, rtw_basic_rate_ofdm, 3); - - if (wirelessmode & WIRELESS_11B) - update_mgnt_tx_rate(padapter, IEEE80211_CCK_RATE_1MB); - else - update_mgnt_tx_rate(padapter, IEEE80211_OFDM_RATE_6MB); - - rtw_hal_set_hwreg(padapter, HW_VAR_BASIC_RATE, supported_rates); -} - -unsigned char check_assoc_AP(u8 *pframe, uint len) -{ - unsigned int i; - struct ndis_802_11_var_ie *pIE; - u8 epigram_vendor_flag; - u8 ralink_vendor_flag; - - epigram_vendor_flag = 0; - ralink_vendor_flag = 0; - - for (i = sizeof(struct ndis_802_11_fixed_ie); i < len;) { - pIE = (struct ndis_802_11_var_ie *)(pframe + i); - - switch (pIE->ElementID) { - case WLAN_EID_VENDOR_SPECIFIC: - if ((!memcmp(pIE->data, ARTHEROS_OUI1, 3)) || - (!memcmp(pIE->data, ARTHEROS_OUI2, 3))) { - return HT_IOT_PEER_ATHEROS; - } else if ((!memcmp(pIE->data, BROADCOM_OUI1, 3)) || - (!memcmp(pIE->data, BROADCOM_OUI2, 3))) { - return HT_IOT_PEER_BROADCOM; - } else if (!memcmp(pIE->data, MARVELL_OUI, 3)) { - return HT_IOT_PEER_MARVELL; - } else if (!memcmp(pIE->data, RALINK_OUI, 3)) { - if (!ralink_vendor_flag) - ralink_vendor_flag = 1; - else - return HT_IOT_PEER_RALINK; - } else if (!memcmp(pIE->data, CISCO_OUI, 3)) { - return HT_IOT_PEER_CISCO; - } else if (!memcmp(pIE->data, REALTEK_OUI, 3)) { - return HT_IOT_PEER_REALTEK; - } else if (!memcmp(pIE->data, AIRGOCAP_OUI, 3)) { - return HT_IOT_PEER_AIRGO; - } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) { - epigram_vendor_flag = 1; - if (ralink_vendor_flag) - return HT_IOT_PEER_TENDA; - } else { - break; - } - break; - - default: - break; - } - i += (pIE->Length + 2); - } - - if (ralink_vendor_flag && !epigram_vendor_flag) - return HT_IOT_PEER_RALINK; - else if (ralink_vendor_flag && epigram_vendor_flag) - return HT_IOT_PEER_TENDA; - return HT_IOT_PEER_UNKNOWN; -} - -void update_IOT_info(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - switch (pmlmeinfo->assoc_AP_vendor) { - case HT_IOT_PEER_MARVELL: - pmlmeinfo->turboMode_cts2self = 1; - pmlmeinfo->turboMode_rtsen = 0; - break; - case HT_IOT_PEER_RALINK: - pmlmeinfo->turboMode_cts2self = 0; - pmlmeinfo->turboMode_rtsen = 1; - /* disable high power */ - Switch_DM_Func(padapter, (u32)(~DYNAMIC_BB_DYNAMIC_TXPWR), - false); - break; - case HT_IOT_PEER_REALTEK: - /* disable high power */ - Switch_DM_Func(padapter, (u32)(~DYNAMIC_BB_DYNAMIC_TXPWR), - false); - break; - default: - pmlmeinfo->turboMode_cts2self = 0; - pmlmeinfo->turboMode_rtsen = 1; - break; - } -} - -void update_capinfo(struct adapter *Adapter, u16 updateCap) -{ - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - bool ShortPreamble; - - /* Check preamble mode, 2005.01.06, by rcnjko. */ - /* Mark to update preamble value forever, 2008.03.18 by lanhsin */ - - if (updateCap & cShortPreamble) { /* Short Preamble */ - if (pmlmeinfo->preamble_mode != PREAMBLE_SHORT) { /* PREAMBLE_LONG or PREAMBLE_AUTO */ - ShortPreamble = true; - pmlmeinfo->preamble_mode = PREAMBLE_SHORT; - rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); - } - } else { /* Long Preamble */ - if (pmlmeinfo->preamble_mode != PREAMBLE_LONG) { /* PREAMBLE_SHORT or PREAMBLE_AUTO */ - ShortPreamble = false; - pmlmeinfo->preamble_mode = PREAMBLE_LONG; - rtw_hal_set_hwreg(Adapter, HW_VAR_ACK_PREAMBLE, (u8 *)&ShortPreamble); - } - } - - if (updateCap & cIBSS) { - /* Filen: See 802.11-2007 p.91 */ - pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; - } else { /* Filen: See 802.11-2007 p.90 */ - if (pmlmeext->cur_wireless_mode & (WIRELESS_11G | WIRELESS_11_24N)) { - if (updateCap & cShortSlotTime) { /* Short Slot Time */ - if (pmlmeinfo->slotTime != SHORT_SLOT_TIME) - pmlmeinfo->slotTime = SHORT_SLOT_TIME; - } else { /* Long Slot Time */ - if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME) - pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; - } - } else if (pmlmeext->cur_wireless_mode & (WIRELESS_11A | WIRELESS_11_5N)) { - pmlmeinfo->slotTime = SHORT_SLOT_TIME; - } else { - /* B Mode */ - pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; - } - } - - rtw_hal_set_hwreg(Adapter, HW_VAR_SLOT_TIME, &pmlmeinfo->slotTime); -} - -void update_wireless_mode(struct adapter *padapter) -{ - int network_type = 0; - u32 SIFS_Timer; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - unsigned char *rate = cur_network->SupportedRates; - - if (pmlmeinfo->HT_info_enable && pmlmeinfo->HT_caps_enable) - pmlmeinfo->HT_enable = 1; - - if (pmlmeinfo->HT_enable) - network_type = WIRELESS_11_24N; - - if (rtw_is_cckratesonly_included(rate)) - network_type |= WIRELESS_11B; - else if (rtw_is_cckrates_included(rate)) - network_type |= WIRELESS_11BG; - else - network_type |= WIRELESS_11G; - - pmlmeext->cur_wireless_mode = network_type & padapter->registrypriv.wireless_mode; - - SIFS_Timer = 0x0a0a0808;/* 0x0808 -> for CCK, 0x0a0a -> for OFDM */ - /* change this value if having IOT issues. */ - - rtw_hal_set_hwreg(padapter, HW_VAR_RESP_SIFS, (u8 *)&SIFS_Timer); - - update_mgnt_tx_rate(padapter, - pmlmeext->cur_wireless_mode & WIRELESS_11B ? - IEEE80211_CCK_RATE_1MB : IEEE80211_OFDM_RATE_6MB); -} - -void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { - /* Only B, B/G, and B/G/N AP could use CCK rate */ - memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_cck, 4); - } else { - memcpy((pmlmeinfo->FW_sta_info[mac_id].SupportedRates), rtw_basic_rate_ofdm, 3); - } -} - -int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_len, int cam_idx) -{ - unsigned int ie_len; - struct ndis_802_11_var_ie *pIE; - int supportRateNum = 0; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, WLAN_EID_SUPP_RATES, &ie_len, var_ie_len); - if (!pIE) - return _FAIL; - if (ie_len > NDIS_802_11_LENGTH_RATES_EX) - return _FAIL; - - memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); - supportRateNum = ie_len; - - pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, WLAN_EID_EXT_SUPP_RATES, &ie_len, var_ie_len); - if (pIE) { - if (supportRateNum + ie_len > NDIS_802_11_LENGTH_RATES_EX) - return _FAIL; - memcpy((pmlmeinfo->FW_sta_info[cam_idx].SupportedRates + supportRateNum), pIE->data, ie_len); - } - - return _SUCCESS; -} - -void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) -{ - struct sta_info *psta; - u16 tid; - u16 param; - struct recv_reorder_ctrl *preorder_ctrl; - struct sta_priv *pstapriv = &padapter->stapriv; - struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - psta = rtw_get_stainfo(pstapriv, addr); - - if (psta) { - param = le16_to_cpu(preq->BA_para_set); - tid = (param >> 2) & 0x0f; - preorder_ctrl = &psta->recvreorder_ctrl[tid]; - preorder_ctrl->indicate_seq = 0xffff; - preorder_ctrl->enable = pmlmeinfo->accept_addba_req; - } -} - -void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) -{ - u8 *pIE; - __le32 *pbuf; - - pIE = pframe + sizeof(struct ieee80211_hdr_3addr); - pbuf = (__le32 *)pIE; - - pmlmeext->TSFValue = le32_to_cpu(*(pbuf + 1)); - - pmlmeext->TSFValue = pmlmeext->TSFValue << 32; - - pmlmeext->TSFValue |= le32_to_cpu(*pbuf); -} - -void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_CORRECT_TSF, NULL); -} diff --git a/drivers/staging/rtl8188eu/core/rtw_xmit.c b/drivers/staging/rtl8188eu/core/rtw_xmit.c deleted file mode 100644 index c77ebd18f40c..000000000000 --- a/drivers/staging/rtl8188eu/core/rtw_xmit.c +++ /dev/null @@ -1,1927 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTW_XMIT_C_ - -#include -#include -#include -#include -#include -#include - -static u8 P802_1H_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0xf8 }; -static u8 RFC1042_OUI[P80211_OUI_LEN] = { 0x00, 0x00, 0x00 }; - -static void _init_txservq(struct tx_servq *ptxservq) -{ - INIT_LIST_HEAD(&ptxservq->tx_pending); - _rtw_init_queue(&ptxservq->sta_pending); - ptxservq->qcnt = 0; -} - -void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) -{ - memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv)); - spin_lock_init(&psta_xmitpriv->lock); - _init_txservq(&psta_xmitpriv->be_q); - _init_txservq(&psta_xmitpriv->bk_q); - _init_txservq(&psta_xmitpriv->vi_q); - _init_txservq(&psta_xmitpriv->vo_q); - INIT_LIST_HEAD(&psta_xmitpriv->legacy_dz); - INIT_LIST_HEAD(&psta_xmitpriv->apsd); -} - -s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) -{ - int i; - struct xmit_buf *pxmitbuf; - struct xmit_frame *pxframe; - int res = _SUCCESS; - u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; - u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - - /* - * We don't need to memset padapter->XXX to zero because adapter is - * allocated by alloc_etherdev_mq, which eventually calls kvzalloc. - */ - - spin_lock_init(&pxmitpriv->lock); - - /* - * Please insert all the queue initializaiton using _rtw_init_queue below - */ - - pxmitpriv->adapter = padapter; - - _rtw_init_queue(&pxmitpriv->be_pending); - _rtw_init_queue(&pxmitpriv->bk_pending); - _rtw_init_queue(&pxmitpriv->vi_pending); - _rtw_init_queue(&pxmitpriv->vo_pending); - _rtw_init_queue(&pxmitpriv->bm_pending); - - _rtw_init_queue(&pxmitpriv->free_xmit_queue); - - /* - * Please allocate memory with the sz = (struct xmit_frame) * NR_XMITFRAME, - * and initialize free_xmit_frame below. - * Please also apply free_txobj to link_up all the xmit_frames... - */ - - pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); - - if (!pxmitpriv->pallocated_frame_buf) { - pxmitpriv->pxmit_frame_buf = NULL; - res = _FAIL; - goto exit; - } - pxmitpriv->pxmit_frame_buf = PTR_ALIGN(pxmitpriv->pallocated_frame_buf, 4); - - pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; - - for (i = 0; i < NR_XMITFRAME; i++) { - INIT_LIST_HEAD(&pxframe->list); - - pxframe->padapter = padapter; - pxframe->frame_tag = NULL_FRAMETAG; - - pxframe->pkt = NULL; - - pxframe->buf_addr = NULL; - pxframe->pxmitbuf = NULL; - - list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue); - - pxframe++; - } - - pxmitpriv->free_xmitframe_cnt = NR_XMITFRAME; - - pxmitpriv->frag_len = MAX_FRAG_THRESHOLD; - - /* init xmit_buf */ - _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); - _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); - - pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); - - if (!pxmitpriv->pallocated_xmitbuf) { - res = _FAIL; - goto exit; - } - - pxmitpriv->pxmitbuf = PTR_ALIGN(pxmitpriv->pallocated_xmitbuf, 4); - - pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; - - for (i = 0; i < NR_XMITBUFF; i++) { - INIT_LIST_HEAD(&pxmitbuf->list); - - pxmitbuf->priv_data = NULL; - pxmitbuf->padapter = padapter; - pxmitbuf->ext_tag = false; - - /* Tx buf allocation may fail sometimes, so sleep and retry. */ - res = rtw_os_xmit_resource_alloc(pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); - if (res == _FAIL) { - msleep(10); - res = rtw_os_xmit_resource_alloc(pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); - if (res == _FAIL) - goto exit; - } - - pxmitbuf->flags = XMIT_VO_QUEUE; - - list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue); - pxmitbuf++; - } - - pxmitpriv->free_xmitbuf_cnt = NR_XMITBUFF; - - /* Init xmit extension buff */ - _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - - pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - - if (!pxmitpriv->pallocated_xmit_extbuf) { - res = _FAIL; - goto exit; - } - - pxmitpriv->pxmit_extbuf = PTR_ALIGN(pxmitpriv->pallocated_xmit_extbuf, 4); - - pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; - - for (i = 0; i < num_xmit_extbuf; i++) { - INIT_LIST_HEAD(&pxmitbuf->list); - - pxmitbuf->priv_data = NULL; - pxmitbuf->padapter = padapter; - pxmitbuf->ext_tag = true; - - res = rtw_os_xmit_resource_alloc(pxmitbuf, max_xmit_extbuf_size + XMITBUF_ALIGN_SZ); - if (res == _FAIL) { - res = _FAIL; - goto exit; - } - - list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); - pxmitbuf++; - } - - pxmitpriv->free_xmit_extbuf_cnt = num_xmit_extbuf; - - res = rtw_alloc_hwxmits(padapter); - if (res == _FAIL) - goto exit; - rtw_init_hwxmits(pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); - - for (i = 0; i < 4; i++) - pxmitpriv->wmm_para_seq[i] = i; - - pxmitpriv->txirp_cnt = 1; - - /* per AC pending irp */ - pxmitpriv->beq_cnt = 0; - pxmitpriv->bkq_cnt = 0; - pxmitpriv->viq_cnt = 0; - pxmitpriv->voq_cnt = 0; - - pxmitpriv->ack_tx = false; - mutex_init(&pxmitpriv->ack_tx_mutex); - rtw_sctx_init(&pxmitpriv->ack_tx_ops, 0); - - rtw_hal_init_xmit_priv(padapter); - -exit: - return res; -} - -void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) -{ - int i; - struct adapter *padapter = pxmitpriv->adapter; - struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; - struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; - u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - - if (!pxmitpriv->pxmit_frame_buf) - return; - - for (i = 0; i < NR_XMITFRAME; i++) { - rtw_os_xmit_complete(padapter, pxmitframe); - - pxmitframe++; - } - - for (i = 0; i < NR_XMITBUFF; i++) { - rtw_os_xmit_resource_free(pxmitbuf); - pxmitbuf++; - } - - vfree(pxmitpriv->pallocated_frame_buf); - vfree(pxmitpriv->pallocated_xmitbuf); - - /* free xmit extension buff */ - pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; - for (i = 0; i < num_xmit_extbuf; i++) { - rtw_os_xmit_resource_free(pxmitbuf); - pxmitbuf++; - } - - vfree(pxmitpriv->pallocated_xmit_extbuf); - - rtw_free_hwxmits(padapter); - - mutex_destroy(&pxmitpriv->ack_tx_mutex); -} - -static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - u32 sz; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct sta_info *psta = pattrib->psta; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pattrib->nr_frags != 1) - sz = padapter->xmitpriv.frag_len; - else /* no frag */ - sz = pattrib->last_txcmdsz; - - /* (1) RTS_Threshold is compared to the MPDU, not MSDU. - * (2) If there are more than one frag in this MSDU, - * only the first frag uses protection frame. - * Other fragments are protected by previous fragment. - * So we only need to check the length of first fragment. - */ - if (pmlmeext->cur_wireless_mode < WIRELESS_11_24N || padapter->registrypriv.wifi_spec) { - if (sz > padapter->registrypriv.rts_thresh) { - pattrib->vcs_mode = RTS_CTS; - } else { - if (psta->rtsen) - pattrib->vcs_mode = RTS_CTS; - else if (psta->cts2self) - pattrib->vcs_mode = CTS_TO_SELF; - else - pattrib->vcs_mode = NONE_VCS; - } - } else { - while (true) { - /* IOT action */ - if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS) && pattrib->ampdu_en && - (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)) { - pattrib->vcs_mode = CTS_TO_SELF; - break; - } - - /* check ERP protection */ - if (psta->rtsen || psta->cts2self) { - if (psta->rtsen) - pattrib->vcs_mode = RTS_CTS; - else if (psta->cts2self) - pattrib->vcs_mode = CTS_TO_SELF; - - break; - } - - /* check HT op mode */ - if (pattrib->ht_en) { - u8 htopmode = pmlmeinfo->HT_protection; - - if ((pmlmeext->cur_bwmode && (htopmode == 2 || htopmode == 3)) || - (!pmlmeext->cur_bwmode && htopmode == 3)) { - pattrib->vcs_mode = RTS_CTS; - break; - } - } - - /* check rts */ - if (sz > padapter->registrypriv.rts_thresh) { - pattrib->vcs_mode = RTS_CTS; - break; - } - - /* to do list: check MIMO power save condition. */ - - /* check AMPDU aggregation for TXOP */ - if (pattrib->ampdu_en) { - pattrib->vcs_mode = RTS_CTS; - break; - } - - pattrib->vcs_mode = NONE_VCS; - break; - } - } -} - -static void update_attrib_phy_info(struct pkt_attrib *pattrib, struct sta_info *psta) -{ - pattrib->mdata = 0; - pattrib->eosp = 0; - pattrib->triggered = 0; - - /* qos_en, ht_en, init rate, , bw, ch_offset, sgi */ - pattrib->qos_en = psta->qos_option; - - pattrib->raid = psta->raid; - pattrib->ht_en = psta->htpriv.ht_option; - pattrib->bwmode = psta->htpriv.bwmode; - pattrib->ch_offset = psta->htpriv.ch_offset; - pattrib->sgi = psta->htpriv.sgi; - pattrib->ampdu_en = false; - pattrib->retry_ctrl = false; -} - -u8 qos_acm(u8 acm_mask, u8 priority) -{ - u8 change_priority = priority; - - switch (priority) { - case 0: - case 3: - if (acm_mask & BIT(1)) - change_priority = 1; - break; - case 1: - case 2: - break; - case 4: - case 5: - if (acm_mask & BIT(2)) - change_priority = 0; - break; - case 6: - case 7: - if (acm_mask & BIT(3)) - change_priority = 5; - break; - default: - break; - } - - return change_priority; -} - -static void set_qos(struct sk_buff *skb, struct pkt_attrib *pattrib) -{ - if (pattrib->ether_type == 0x0800) { - struct iphdr ip_hdr; - - skb_copy_bits(skb, ETH_HLEN, &ip_hdr, sizeof(ip_hdr)); - pattrib->priority = ip_hdr.tos >> 5; - } else if (pattrib->ether_type == ETH_P_PAE) { - /* When priority processing of data frames is supported, - * a STA's SME should send EAPOL-Key frames at the highest - * priority. - */ - pattrib->priority = 7; - } else { - pattrib->priority = 0; - } - - pattrib->hdrlen = WLAN_HDR_A3_QOS_LEN; - pattrib->subtype = WIFI_QOS_DATA_TYPE; -} - -static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct pkt_attrib *pattrib) -{ - struct sta_info *psta = NULL; - struct ethhdr etherhdr; - - bool mcast; - struct sta_priv *pstapriv = &padapter->stapriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; - int res = _SUCCESS; - - skb_copy_bits(pkt, 0, ðerhdr, ETH_HLEN); - - pattrib->ether_type = ntohs(etherhdr.h_proto); - - memcpy(pattrib->dst, ðerhdr.h_dest, ETH_ALEN); - memcpy(pattrib->src, ðerhdr.h_source, ETH_ALEN); - - pattrib->pctrl = 0; - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); - } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - memcpy(pattrib->ra, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pattrib->ta, pattrib->src, ETH_ALEN); - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - memcpy(pattrib->ta, get_bssid(pmlmepriv), ETH_ALEN); - } - - pattrib->pktlen = pkt->len - ETH_HLEN; - - if (pattrib->ether_type == ETH_P_IP) { - /* The following is for DHCP and ARP packet, we use - * cck1M to tx these packets and let LPS awake some - * time to prevent DHCP protocol fail. - */ - u8 tmp[24]; - - skb_copy_bits(pkt, ETH_HLEN, tmp, 24); - - pattrib->dhcp_pkt = 0; - if (pkt->len > ETH_HLEN + 24 + 282) {/* MINIMUM_DHCP_PACKET_SIZE) { */ - if (pattrib->ether_type == ETH_P_IP) {/* IP header */ - if (((tmp[21] == 68) && (tmp[23] == 67)) || - ((tmp[21] == 67) && (tmp[23] == 68))) { - /* 68 : UDP BOOTP client */ - /* 67 : UDP BOOTP server */ - /* Use low rate to send DHCP packet. */ - pattrib->dhcp_pkt = 1; - } - } - } - } - - if ((pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) - rtw_set_scan_deny(padapter, 3000); - - /* If EAPOL , ARP , OR DHCP packet, driver must be in active mode. */ - if ((pattrib->ether_type == ETH_P_ARP) || (pattrib->ether_type == ETH_P_PAE) || (pattrib->dhcp_pkt == 1)) - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1); - - mcast = is_multicast_ether_addr(pattrib->ra); - - /* get sta_info */ - if (mcast) { - psta = rtw_get_bcmc_stainfo(padapter); - } else { - psta = rtw_get_stainfo(pstapriv, pattrib->ra); - if (!psta) { /* if we cannot get psta => drrp the pkt */ - res = _FAIL; - goto exit; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && - !(psta->state & _FW_LINKED)) { - res = _FAIL; - goto exit; - } - } - - if (psta) { - pattrib->mac_id = psta->mac_id; - pattrib->psta = psta; - } else { - /* if we cannot get psta => drop the pkt */ - res = _FAIL; - goto exit; - } - - pattrib->ack_policy = 0; - - pattrib->hdrlen = WLAN_HDR_A3_LEN; - pattrib->subtype = WIFI_DATA_TYPE; - pattrib->priority = 0; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE | - WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { - if (psta->qos_option) - set_qos(pkt, pattrib); - } else { - if (pqospriv->qos_option) { - set_qos(pkt, pattrib); - - if (pmlmepriv->acm_mask != 0) - pattrib->priority = qos_acm(pmlmepriv->acm_mask, pattrib->priority); - } - } - - if (psta->ieee8021x_blocked) { - pattrib->encrypt = 0; - - if (pattrib->ether_type != ETH_P_PAE) { - res = _FAIL; - goto exit; - } - } else { - GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, mcast); - - switch (psecuritypriv->dot11AuthAlgrthm) { - case dot11AuthAlgrthm_Open: - case dot11AuthAlgrthm_Shared: - case dot11AuthAlgrthm_Auto: - pattrib->key_idx = (u8)psecuritypriv->dot11PrivacyKeyIndex; - break; - case dot11AuthAlgrthm_8021X: - if (mcast) - pattrib->key_idx = (u8)psecuritypriv->dot118021XGrpKeyid; - else - pattrib->key_idx = 0; - break; - default: - pattrib->key_idx = 0; - break; - } - } - - switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: - pattrib->iv_len = 4; - pattrib->icv_len = 4; - break; - case _TKIP_: - pattrib->iv_len = 8; - pattrib->icv_len = 4; - - if (padapter->securitypriv.busetkipkey == _FAIL) { - res = _FAIL; - goto exit; - } - break; - case _AES_: - pattrib->iv_len = 8; - pattrib->icv_len = 8; - break; - default: - pattrib->iv_len = 0; - pattrib->icv_len = 0; - break; - } - - if (pattrib->encrypt && !psecuritypriv->hw_decrypted) - pattrib->bswenc = true; - else - pattrib->bswenc = false; - - update_attrib_phy_info(pattrib, psta); - -exit: - return res; -} - -static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - int curfragnum, length; - u8 *pframe, *payload, mic[8]; - struct mic_data micdata; - struct sta_info *stainfo; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u8 priority[4] = {}; - u8 hw_hdr_offset = 0; - - if (pattrib->psta) - stainfo = pattrib->psta; - else - stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - - hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - - if (pattrib->encrypt == _TKIP_) { - /* encode mic code */ - if (stainfo) { - u8 null_key[16] = {}; - - pframe = pxmitframe->buf_addr + hw_hdr_offset; - - if (is_multicast_ether_addr(pattrib->ra)) { - if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) - return _FAIL; - /* start to calculate the mic code */ - rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); - } else { - if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) - return _FAIL; - /* start to calculate the mic code */ - rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]); - } - - if (pframe[1] & 1) { /* ToDS == 1 */ - rtw_secmicappend(&micdata, &pframe[16], 6); /* DA */ - if (pframe[1] & 2) /* From Ds == 1 */ - rtw_secmicappend(&micdata, &pframe[24], 6); - else - rtw_secmicappend(&micdata, &pframe[10], 6); - } else { /* ToDS == 0 */ - rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */ - if (pframe[1] & 2) /* From Ds == 1 */ - rtw_secmicappend(&micdata, &pframe[16], 6); - else - rtw_secmicappend(&micdata, &pframe[10], 6); - } - - if (pattrib->qos_en) - priority[0] = (u8)pxmitframe->attrib.priority; - - rtw_secmicappend(&micdata, &priority[0], 4); - - payload = pframe; - - for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - payload = (u8 *)round_up((size_t)(payload), 4); - - payload += pattrib->hdrlen + pattrib->iv_len; - if (curfragnum + 1 == pattrib->nr_frags) { - length = pattrib->last_txcmdsz - - pattrib->hdrlen - - pattrib->iv_len - - ((pattrib->bswenc) ? - pattrib->icv_len : 0); - rtw_secmicappend(&micdata, payload, length); - payload += length; - } else { - length = pxmitpriv->frag_len - - pattrib->hdrlen - - pattrib->iv_len - - ((pattrib->bswenc) ? - pattrib->icv_len : 0); - rtw_secmicappend(&micdata, payload, length); - payload += length + pattrib->icv_len; - } - } - rtw_secgetmic(&micdata, &mic[0]); - /* add mic code and add the mic code length in last_txcmdsz */ - - memcpy(payload, &mic[0], 8); - pattrib->last_txcmdsz += 8; - - payload -= pattrib->last_txcmdsz + 8; - } - } - - return _SUCCESS; -} - -static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - struct pkt_attrib *pattrib = &pxmitframe->attrib; - - if (pattrib->bswenc) { - switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: - rtw_wep_encrypt(padapter, pxmitframe); - break; - case _TKIP_: - rtw_tkip_encrypt(padapter, pxmitframe); - break; - case _AES_: - rtw_aes_encrypt(padapter, pxmitframe); - break; - default: - break; - } - } - - return _SUCCESS; -} - -s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) -{ - u16 *qc; - - struct ieee80211_hdr *pwlanhdr = (struct ieee80211_hdr *)hdr; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct qos_priv *pqospriv = &pmlmepriv->qospriv; - u8 qos_option = false; - - int res = _SUCCESS; - __le16 *fctrl = &pwlanhdr->frame_control; - - struct sta_info *psta; - - if (pattrib->psta) { - psta = pattrib->psta; - } else { - if (is_multicast_ether_addr(pattrib->ra)) - psta = rtw_get_bcmc_stainfo(padapter); - else - psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - } - - memset(hdr, 0, WLANHDR_OFFSET); - - SetFrameSubType(fctrl, pattrib->subtype); - - if (pattrib->subtype & WIFI_DATA_TYPE) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { - /* to_ds = 1, fr_ds = 0; */ - /* Data transfer to AP */ - SetToDs(fctrl); - memcpy(pwlanhdr->addr1, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->dst, ETH_ALEN); - - if (pqospriv->qos_option) - qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - /* to_ds = 0, fr_ds = 1; */ - SetFrDs(fctrl); - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, get_bssid(pmlmepriv), ETH_ALEN); - memcpy(pwlanhdr->addr3, pattrib->src, ETH_ALEN); - - if (psta && psta->qos_option) - qos_option = true; - } else if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - memcpy(pwlanhdr->addr1, pattrib->dst, ETH_ALEN); - memcpy(pwlanhdr->addr2, pattrib->src, ETH_ALEN); - memcpy(pwlanhdr->addr3, get_bssid(pmlmepriv), ETH_ALEN); - - if (psta && psta->qos_option) - qos_option = true; - } else { - res = _FAIL; - goto exit; - } - - if (pattrib->mdata) - SetMData(fctrl); - - if (pattrib->encrypt) - SetPrivacy(fctrl); - - if (qos_option) { - qc = (unsigned short *)(hdr + pattrib->hdrlen - 2); - - if (pattrib->priority) - SetPriority(qc, pattrib->priority); - - SetEOSP(qc, pattrib->eosp); - - SetAckpolicy(qc, pattrib->ack_policy); - } - - /* TODO: fill HT Control Field */ - - /* Update Seq Num will be handled by f/w */ - if (psta) { - psta->sta_xmitpriv.txseq_tid[pattrib->priority]++; - psta->sta_xmitpriv.txseq_tid[pattrib->priority] &= 0xFFF; - - pattrib->seqnum = psta->sta_xmitpriv.txseq_tid[pattrib->priority]; - - SetSeqNum(hdr, pattrib->seqnum); - - /* check if enable ampdu */ - if (pattrib->ht_en && psta->htpriv.ampdu_enable) { - if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) - pattrib->ampdu_en = true; - } - - /* re-check if enable ampdu by BA_starting_seqctrl */ - if (pattrib->ampdu_en) { - u16 tx_seq; - - tx_seq = psta->BA_starting_seqctrl[pattrib->priority & 0x0f]; - - /* check BA_starting_seqctrl */ - if (SN_LESS(pattrib->seqnum, tx_seq)) { - pattrib->ampdu_en = false;/* AGG BK */ - } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff; - - pattrib->ampdu_en = true;/* AGG EN */ - } else { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff; - pattrib->ampdu_en = true;/* AGG EN */ - } - } - } - } -exit: - - return res; -} - -s32 rtw_txframes_pending(struct adapter *padapter) -{ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - return (!list_empty(&pxmitpriv->be_pending.queue) || - !list_empty(&pxmitpriv->bk_pending.queue) || - !list_empty(&pxmitpriv->vi_pending.queue) || - !list_empty(&pxmitpriv->vo_pending.queue)); -} - -s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pattrib) -{ - struct sta_info *psta; - struct tx_servq *ptxservq; - int priority = pattrib->priority; - - psta = pattrib->psta; - - switch (priority) { - case 1: - case 2: - ptxservq = &psta->sta_xmitpriv.bk_q; - break; - case 4: - case 5: - ptxservq = &psta->sta_xmitpriv.vi_q; - break; - case 6: - case 7: - ptxservq = &psta->sta_xmitpriv.vo_q; - break; - case 0: - case 3: - default: - ptxservq = &psta->sta_xmitpriv.be_q; - break; - } - - return ptxservq->qcnt; -} - -/* - * - * This sub-routine will perform all the following: - * - * 1. remove 802.3 header. - * 2. create wlan_header, based on the info in pxmitframe - * 3. append sta's iv/ext-iv - * 4. append LLC - * 5. move frag chunk from pframe to pxmitframe->mem - * 6. apply sw-encrypt, if necessary. - * - */ -s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct xmit_frame *pxmitframe) -{ - s32 frg_inx, frg_len, mpdu_len, llc_sz, mem_sz; - size_t addr; - u8 *pframe, *mem_start; - u8 hw_hdr_offset; - struct sta_info *psta; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - u8 *pbuf_start; - bool mcast = is_multicast_ether_addr(pattrib->ra); - s32 res = _SUCCESS; - size_t remainder = pkt->len - ETH_HLEN; - - psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - - if (!psta) - return _FAIL; - - if (!pxmitframe->buf_addr) - return _FAIL; - - pbuf_start = pxmitframe->buf_addr; - - hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - - mem_start = pbuf_start + hw_hdr_offset; - - if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) { - res = _FAIL; - goto exit; - } - - frg_inx = 0; - frg_len = pxmitpriv->frag_len - 4;/* 2346-4 = 2342 */ - - while (1) { - llc_sz = 0; - - mpdu_len = frg_len; - - pframe = mem_start; - - SetMFrag(mem_start); - - pframe += pattrib->hdrlen; - mpdu_len -= pattrib->hdrlen; - - /* adding icv, if necessary... */ - if (pattrib->iv_len) { - switch (pattrib->encrypt) { - case _WEP40_: - case _WEP104_: - WEP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); - break; - case _TKIP_: - if (mcast) - TKIP_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); - else - TKIP_IV(pattrib->iv, psta->dot11txpn, 0); - break; - case _AES_: - if (mcast) - AES_IV(pattrib->iv, psta->dot11txpn, pattrib->key_idx); - else - AES_IV(pattrib->iv, psta->dot11txpn, 0); - break; - } - - memcpy(pframe, pattrib->iv, pattrib->iv_len); - - pframe += pattrib->iv_len; - - mpdu_len -= pattrib->iv_len; - } - - if (frg_inx == 0) { - llc_sz = rtw_put_snap(pframe, pattrib->ether_type); - pframe += llc_sz; - mpdu_len -= llc_sz; - } - - if ((pattrib->icv_len > 0) && (pattrib->bswenc)) - mpdu_len -= pattrib->icv_len; - - mem_sz = min_t(size_t, mcast ? pattrib->pktlen : mpdu_len, remainder); - skb_copy_bits(pkt, pkt->len - remainder, pframe, mem_sz); - remainder -= mem_sz; - - pframe += mem_sz; - - if ((pattrib->icv_len > 0) && (pattrib->bswenc)) { - memcpy(pframe, pattrib->icv, pattrib->icv_len); - pframe += pattrib->icv_len; - } - - frg_inx++; - - if (mcast || remainder == 0) { - pattrib->nr_frags = frg_inx; - - pattrib->last_txcmdsz = pattrib->hdrlen + pattrib->iv_len + ((pattrib->nr_frags == 1) ? llc_sz : 0) + - ((pattrib->bswenc) ? pattrib->icv_len : 0) + mem_sz; - - ClearMFrag(mem_start); - - break; - } - - addr = (size_t)(pframe); - - mem_start = (unsigned char *)round_up(addr, 4) + hw_hdr_offset; - memcpy(mem_start, pbuf_start + hw_hdr_offset, pattrib->hdrlen); - } - - /* Frame is about to be encrypted. Forward it to the monitor first. */ - rtl88eu_mon_xmit_hook(padapter->pmondev, pxmitframe, frg_len); - - if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { - res = _FAIL; - goto exit; - } - - xmitframe_swencrypt(padapter, pxmitframe); - - if (!mcast) - update_attrib_vcs_info(padapter, pxmitframe); - else - pattrib->vcs_mode = NONE_VCS; - -exit: - return res; -} - -/* Logical Link Control(LLC) SubNetwork Attachment Point(SNAP) header - * IEEE LLC/SNAP header contains 8 octets - * First 3 octets comprise the LLC portion - * SNAP portion, 5 octets, is divided into two fields: - * Organizationally Unique Identifier(OUI), 3 octets, - * type, defined by that organization, 2 octets. - */ -s32 rtw_put_snap(u8 *data, u16 h_proto) -{ - struct ieee80211_snap_hdr *snap; - u8 *oui; - - snap = (struct ieee80211_snap_hdr *)data; - snap->dsap = 0xaa; - snap->ssap = 0xaa; - snap->ctrl = 0x03; - - if (h_proto == 0x8137 || h_proto == 0x80f3) - oui = P802_1H_OUI; - else - oui = RFC1042_OUI; - - snap->oui[0] = oui[0]; - snap->oui[1] = oui[1]; - snap->oui[2] = oui[2]; - - *(__be16 *)(data + SNAP_SIZE) = htons(h_proto); - - return SNAP_SIZE + sizeof(u16); -} - -void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) -{ - uint protection, erp_len; - u8 *perp; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct registry_priv *pregistrypriv = &padapter->registrypriv; - - switch (pxmitpriv->vcs_setting) { - case DISABLE_VCS: - pxmitpriv->vcs = NONE_VCS; - break; - case ENABLE_VCS: - break; - case AUTO_VCS: - default: - perp = rtw_get_ie(ie, WLAN_EID_ERP_INFO, &erp_len, ie_len); - if (!perp) { - pxmitpriv->vcs = NONE_VCS; - } else { - protection = (*(perp + 2)) & BIT(1); - if (protection) { - if (pregistrypriv->vcs_type == RTS_CTS) - pxmitpriv->vcs = RTS_CTS; - else - pxmitpriv->vcs = CTS_TO_SELF; - } else { - pxmitpriv->vcs = NONE_VCS; - } - } - break; - } -} - -void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, int sz) -{ - struct sta_info *psta = NULL; - struct stainfo_stats *pstats = NULL; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) { - pxmitpriv->tx_bytes += sz; - pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num; - - psta = pxmitframe->attrib.psta; - if (psta) { - pstats = &psta->sta_stats; - pstats->tx_pkts += pxmitframe->agg_num; - pstats->tx_bytes += sz; - } - } -} - -struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) -{ - unsigned long irql; - struct xmit_buf *pxmitbuf; - struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; - - spin_lock_irqsave(&pfree_queue->lock, irql); - pxmitbuf = list_first_entry_or_null(&pfree_queue->queue, - struct xmit_buf, list); - if (pxmitbuf) { - list_del_init(&pxmitbuf->list); - pxmitpriv->free_xmit_extbuf_cnt--; - pxmitbuf->priv_data = NULL; - if (pxmitbuf->sctx) - rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); - } - spin_unlock_irqrestore(&pfree_queue->lock, irql); - - return pxmitbuf; -} - -s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) -{ - unsigned long irql; - struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; - - if (!pxmitbuf) - return _FAIL; - - spin_lock_irqsave(&pfree_queue->lock, irql); - - list_del_init(&pxmitbuf->list); - - list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue)); - pxmitpriv->free_xmit_extbuf_cnt++; - - spin_unlock_irqrestore(&pfree_queue->lock, irql); - - return _SUCCESS; -} - -struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) -{ - unsigned long irql; - struct xmit_buf *pxmitbuf; - struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; - - spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irql); - pxmitbuf = list_first_entry_or_null(&pfree_xmitbuf_queue->queue, - struct xmit_buf, list); - if (pxmitbuf) { - list_del_init(&pxmitbuf->list); - pxmitpriv->free_xmitbuf_cnt--; - pxmitbuf->priv_data = NULL; - if (pxmitbuf->sctx) - rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_ALLOC); - } - spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); - - return pxmitbuf; -} - -s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) -{ - unsigned long irql; - struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; - - if (!pxmitbuf) - return _FAIL; - - if (pxmitbuf->sctx) - rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_BUF_FREE); - - if (pxmitbuf->ext_tag) { - rtw_free_xmitbuf_ext(pxmitpriv, pxmitbuf); - } else { - spin_lock_irqsave(&pfree_xmitbuf_queue->lock, irql); - - list_del_init(&pxmitbuf->list); - - list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue)); - - pxmitpriv->free_xmitbuf_cnt++; - spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, irql); - } - - return _SUCCESS; -} - -/* - * Calling context: - * 1. OS_TXENTRY - * 2. RXENTRY (rx_thread or RX_ISR/RX_CallBack) - * - * If we turn on USE_RXTHREAD, then, no need for critical section. - * Otherwise, we must use _enter/_exit critical to protect free_xmit_queue... - * - * Must be very, very cautious... - * - */ - -struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv) - /* _queue *pfree_xmit_queue) */ -{ - /* - * Please remember to use all the osdep_service api, - * and lock/unlock or _enter/_exit critical to protect - * pfree_xmit_queue - */ - struct xmit_frame *pxframe; - struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; - - spin_lock_bh(&pfree_xmit_queue->lock); - pxframe = list_first_entry_or_null(&pfree_xmit_queue->queue, - struct xmit_frame, list); - if (pxframe) { - list_del_init(&pxframe->list); - - /* default value setting */ - pxmitpriv->free_xmitframe_cnt--; - - pxframe->buf_addr = NULL; - pxframe->pxmitbuf = NULL; - - memset(&pxframe->attrib, 0, sizeof(struct pkt_attrib)); - - pxframe->frame_tag = DATA_FRAMETAG; - - pxframe->pkt = NULL; - pxframe->pkt_offset = 1;/* default use pkt_offset to fill tx desc */ - - pxframe->agg_num = 1; - pxframe->ack_report = 0; - } - spin_unlock_bh(&pfree_xmit_queue->lock); - - return pxframe; -} - -s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitframe) -{ - struct __queue *pfree_xmit_queue = &pxmitpriv->free_xmit_queue; - struct adapter *padapter = pxmitpriv->adapter; - struct sk_buff *pndis_pkt = NULL; - - if (!pxmitframe) - goto exit; - - spin_lock_bh(&pfree_xmit_queue->lock); - - list_del_init(&pxmitframe->list); - - if (pxmitframe->pkt) { - pndis_pkt = pxmitframe->pkt; - pxmitframe->pkt = NULL; - } - - list_add_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); - - pxmitpriv->free_xmitframe_cnt++; - - spin_unlock_bh(&pfree_xmit_queue->lock); - - if (pndis_pkt) - rtw_os_pkt_complete(padapter, pndis_pkt); - -exit: - return _SUCCESS; -} - -void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pframequeue) -{ - struct list_head *phead; - struct xmit_frame *pxmitframe, *temp; - - spin_lock_bh(&pframequeue->lock); - - phead = get_list_head(pframequeue); - list_for_each_entry_safe(pxmitframe, temp, phead, list) - rtw_free_xmitframe(pxmitpriv, pxmitframe); - - spin_unlock_bh(&pframequeue->lock); -} - -s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) - return _FAIL; - - return _SUCCESS; -} - -static struct xmit_frame *dequeue_one_xmitframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit, struct tx_servq *ptxservq, struct __queue *pframe_queue) -{ - struct list_head *xmitframe_plist, *xmitframe_phead; - struct xmit_frame *pxmitframe = NULL; - - xmitframe_phead = get_list_head(pframe_queue); - xmitframe_plist = xmitframe_phead->next; - - if (xmitframe_phead != xmitframe_plist) { - pxmitframe = container_of(xmitframe_plist, struct xmit_frame, list); - - xmitframe_plist = xmitframe_plist->next; - - list_del_init(&pxmitframe->list); - - ptxservq->qcnt--; - } - return pxmitframe; -} - -struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, struct hw_xmit *phwxmit_i, int entry) -{ - struct list_head *sta_plist, *sta_phead; - struct hw_xmit *phwxmit; - struct tx_servq *ptxservq = NULL; - struct __queue *pframe_queue = NULL; - struct xmit_frame *pxmitframe = NULL; - struct adapter *padapter = pxmitpriv->adapter; - struct registry_priv *pregpriv = &padapter->registrypriv; - int i, inx[4]; - - inx[0] = 0; inx[1] = 1; inx[2] = 2; inx[3] = 3; - - if (pregpriv->wifi_spec == 1) { - int j; - - for (j = 0; j < 4; j++) - inx[j] = pxmitpriv->wmm_para_seq[j]; - } - - spin_lock_bh(&pxmitpriv->lock); - - for (i = 0; i < entry; i++) { - phwxmit = phwxmit_i + inx[i]; - - sta_phead = get_list_head(phwxmit->sta_queue); - list_for_each(sta_plist, sta_phead) { - ptxservq = list_entry(sta_plist, struct tx_servq, - tx_pending); - - pframe_queue = &ptxservq->sta_pending; - - pxmitframe = dequeue_one_xmitframe(pxmitpriv, phwxmit, ptxservq, pframe_queue); - - if (pxmitframe) { - phwxmit->accnt--; - - /* Remove sta node when there are no pending packets. */ - if (list_empty(&pframe_queue->queue)) /* must be done after get_next and before break */ - list_del_init(&ptxservq->tx_pending); - goto exit; - } - } - } -exit: - spin_unlock_bh(&pxmitpriv->lock); - return pxmitframe; -} - -struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, - struct sta_info *psta, int up, u8 *ac) -{ - struct tx_servq *ptxservq; - - switch (up) { - case 1: - case 2: - ptxservq = &psta->sta_xmitpriv.bk_q; - *(ac) = 3; - break; - case 4: - case 5: - ptxservq = &psta->sta_xmitpriv.vi_q; - *(ac) = 1; - break; - case 6: - case 7: - ptxservq = &psta->sta_xmitpriv.vo_q; - *(ac) = 0; - break; - case 0: - case 3: - default: - ptxservq = &psta->sta_xmitpriv.be_q; - *(ac) = 2; - break; - } - - return ptxservq; -} - -/* - * Will enqueue pxmitframe to the proper queue, - * and indicate it to xx_pending list..... - */ -s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - u8 ac_index; - struct sta_info *psta; - struct tx_servq *ptxservq; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct sta_priv *pstapriv = &padapter->stapriv; - struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; - int res = _SUCCESS; - - if (pattrib->psta) - psta = pattrib->psta; - else - psta = rtw_get_stainfo(pstapriv, pattrib->ra); - - if (!psta) { - res = _FAIL; - goto exit; - } - - ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); - - if (list_empty(&ptxservq->tx_pending)) - list_add_tail(&ptxservq->tx_pending, get_list_head(phwxmits[ac_index].sta_queue)); - - list_add_tail(&pxmitframe->list, get_list_head(&ptxservq->sta_pending)); - ptxservq->qcnt++; - phwxmits[ac_index].accnt++; -exit: - return res; -} - -s32 rtw_alloc_hwxmits(struct adapter *padapter) -{ - struct hw_xmit *hwxmits; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; - - pxmitpriv->hwxmits = kcalloc(pxmitpriv->hwxmit_entry, - sizeof(struct hw_xmit), GFP_KERNEL); - if (!pxmitpriv->hwxmits) - return _FAIL; - - hwxmits = pxmitpriv->hwxmits; - - hwxmits[0] .sta_queue = &pxmitpriv->vo_pending; - hwxmits[1] .sta_queue = &pxmitpriv->vi_pending; - hwxmits[2] .sta_queue = &pxmitpriv->be_pending; - hwxmits[3] .sta_queue = &pxmitpriv->bk_pending; - return _SUCCESS; -} - -void rtw_free_hwxmits(struct adapter *padapter) -{ - struct hw_xmit *hwxmits; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - hwxmits = pxmitpriv->hwxmits; - kfree(hwxmits); -} - -void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry) -{ - int i; - - for (i = 0; i < entry; i++, phwxmit++) - phwxmit->accnt = 0; -} - -u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe) -{ - u32 addr; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - - switch (pattrib->qsel) { - case 0: - case 3: - addr = BE_QUEUE_INX; - break; - case 1: - case 2: - addr = BK_QUEUE_INX; - break; - case 4: - case 5: - addr = VI_QUEUE_INX; - break; - case 6: - case 7: - addr = VO_QUEUE_INX; - break; - case 0x10: - addr = BCN_QUEUE_INX; - break; - case 0x11:/* BC/MC in PS (HIQ) */ - addr = HIGH_QUEUE_INX; - break; - case 0x12: - default: - addr = MGT_QUEUE_INX; - break; - } - - return addr; -} - -/* - * The main transmit(tx) entry - * - * Return - * 1 enqueue - * 0 success, hardware will handle this xmit frame(packet) - * <0 fail - */ -s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) -{ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct xmit_frame *pxmitframe = NULL; - s32 res; - - pxmitframe = rtw_alloc_xmitframe(pxmitpriv); - if (!pxmitframe) - return -1; - - res = update_attrib(padapter, *ppkt, &pxmitframe->attrib); - - if (res == _FAIL) { - rtw_free_xmitframe(pxmitpriv, pxmitframe); - return -1; - } - pxmitframe->pkt = *ppkt; - - led_control_8188eu(padapter, LED_CTL_TX); - - pxmitframe->attrib.qsel = pxmitframe->attrib.priority; - -#ifdef CONFIG_88EU_AP_MODE - spin_lock_bh(&pxmitpriv->lock); - if (xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe)) { - spin_unlock_bh(&pxmitpriv->lock); - return 1; - } - spin_unlock_bh(&pxmitpriv->lock); -#endif - - if (!rtw_hal_xmit(padapter, pxmitframe)) - return 1; - - return 0; -} - -#if defined(CONFIG_88EU_AP_MODE) - -int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe) -{ - int ret = false; - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - bool mcast = is_multicast_ether_addr(pattrib->ra); - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return ret; - - if (pattrib->psta) - psta = pattrib->psta; - else - psta = rtw_get_stainfo(pstapriv, pattrib->ra); - - if (!psta) - return ret; - - if (pattrib->triggered == 1) { - if (mcast) - pattrib->qsel = 0x11;/* HIQ */ - return ret; - } - - if (mcast) { - spin_lock_bh(&psta->sleep_q.lock); - - if (pstapriv->sta_dz_bitmap) {/* if any one sta is in ps mode */ - list_del_init(&pxmitframe->list); - - list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); - - psta->sleepq_len++; - - pstapriv->tim_bitmap |= BIT(0);/* */ - pstapriv->sta_dz_bitmap |= BIT(0); - - update_beacon(padapter, WLAN_EID_TIM, NULL, false);/* tx bc/mc packets after update bcn */ - - ret = true; - } - - spin_unlock_bh(&psta->sleep_q.lock); - - return ret; - } - - spin_lock_bh(&psta->sleep_q.lock); - - if (psta->state & WIFI_SLEEP_STATE) { - u8 wmmps_ac = 0; - - if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) { - list_del_init(&pxmitframe->list); - - list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); - - psta->sleepq_len++; - - switch (pattrib->priority) { - case 1: - case 2: - wmmps_ac = psta->uapsd_bk & BIT(0); - break; - case 4: - case 5: - wmmps_ac = psta->uapsd_vi & BIT(0); - break; - case 6: - case 7: - wmmps_ac = psta->uapsd_vo & BIT(0); - break; - case 0: - case 3: - default: - wmmps_ac = psta->uapsd_be & BIT(0); - break; - } - - if (wmmps_ac) - psta->sleepq_ac_len++; - - if (((psta->has_legacy_ac) && (!wmmps_ac)) || - ((!psta->has_legacy_ac) && (wmmps_ac))) { - pstapriv->tim_bitmap |= BIT(psta->aid); - - if (psta->sleepq_len == 1) { - /* update BCN for TIM IE */ - update_beacon(padapter, WLAN_EID_TIM, NULL, false); - } - } - ret = true; - } - } - - spin_unlock_bh(&psta->sleep_q.lock); - - return ret; -} - -static void dequeue_xmitframes_to_sleeping_queue(struct adapter *padapter, struct sta_info *psta, struct __queue *pframequeue) -{ - struct list_head *phead; - u8 ac_index; - struct tx_servq *ptxservq; - struct pkt_attrib *pattrib; - struct xmit_frame *pxmitframe, *n; - struct hw_xmit *phwxmits = padapter->xmitpriv.hwxmits; - - phead = get_list_head(pframequeue); - list_for_each_entry_safe(pxmitframe, n, phead, list) { - xmitframe_enqueue_for_sleeping_sta(padapter, pxmitframe); - - pattrib = &pxmitframe->attrib; - - ptxservq = rtw_get_sta_pending(padapter, psta, pattrib->priority, (u8 *)(&ac_index)); - - ptxservq->qcnt--; - phwxmits[ac_index].accnt--; - } -} - -void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) -{ - struct sta_info *psta_bmc; - struct sta_xmit_priv *pstaxmitpriv; - struct sta_priv *pstapriv = &padapter->stapriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - pstaxmitpriv = &psta->sta_xmitpriv; - - /* for BC/MC Frames */ - psta_bmc = rtw_get_bcmc_stainfo(padapter); - - spin_lock_bh(&pxmitpriv->lock); - - psta->state |= WIFI_SLEEP_STATE; - - pstapriv->sta_dz_bitmap |= BIT(psta->aid); - - dequeue_xmitframes_to_sleeping_queue(padapter, psta, - &pstaxmitpriv->vo_q.sta_pending); - list_del_init(&pstaxmitpriv->vo_q.tx_pending); - - dequeue_xmitframes_to_sleeping_queue(padapter, psta, - &pstaxmitpriv->vi_q.sta_pending); - list_del_init(&pstaxmitpriv->vi_q.tx_pending); - - dequeue_xmitframes_to_sleeping_queue(padapter, psta, - &pstaxmitpriv->be_q.sta_pending); - list_del_init(&pstaxmitpriv->be_q.tx_pending); - - dequeue_xmitframes_to_sleeping_queue(padapter, psta, - &pstaxmitpriv->bk_q.sta_pending); - list_del_init(&pstaxmitpriv->bk_q.tx_pending); - - /* for BC/MC Frames */ - pstaxmitpriv = &psta_bmc->sta_xmitpriv; - dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, - &pstaxmitpriv->be_q.sta_pending); - list_del_init(&pstaxmitpriv->be_q.tx_pending); - - spin_unlock_bh(&pxmitpriv->lock); -} - -void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) -{ - u8 update_mask = 0, wmmps_ac = 0; - struct sta_info *psta_bmc; - struct list_head *xmitframe_phead; - struct xmit_frame *pxmitframe, *n; - struct sta_priv *pstapriv = &padapter->stapriv; - - spin_lock_bh(&psta->sleep_q.lock); - - xmitframe_phead = get_list_head(&psta->sleep_q); - list_for_each_entry_safe(pxmitframe, n, xmitframe_phead, list) { - list_del_init(&pxmitframe->list); - - switch (pxmitframe->attrib.priority) { - case 1: - case 2: - wmmps_ac = psta->uapsd_bk & BIT(1); - break; - case 4: - case 5: - wmmps_ac = psta->uapsd_vi & BIT(1); - break; - case 6: - case 7: - wmmps_ac = psta->uapsd_vo & BIT(1); - break; - case 0: - case 3: - default: - wmmps_ac = psta->uapsd_be & BIT(1); - break; - } - - psta->sleepq_len--; - if (psta->sleepq_len > 0) - pxmitframe->attrib.mdata = 1; - else - pxmitframe->attrib.mdata = 0; - - if (wmmps_ac) { - psta->sleepq_ac_len--; - if (psta->sleepq_ac_len > 0) { - pxmitframe->attrib.mdata = 1; - pxmitframe->attrib.eosp = 0; - } else { - pxmitframe->attrib.mdata = 0; - pxmitframe->attrib.eosp = 1; - } - } - - pxmitframe->attrib.triggered = 1; - - spin_unlock_bh(&psta->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); - spin_lock_bh(&psta->sleep_q.lock); - } - - if (psta->sleepq_len == 0) { - pstapriv->tim_bitmap &= ~BIT(psta->aid); - - update_mask = BIT(0); - - if (psta->state & WIFI_SLEEP_STATE) - psta->state ^= WIFI_SLEEP_STATE; - - if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { - psta->expire_to = pstapriv->expire_to; - psta->state ^= WIFI_STA_ALIVE_CHK_STATE; - } - - pstapriv->sta_dz_bitmap &= ~BIT(psta->aid); - } - - spin_unlock_bh(&psta->sleep_q.lock); - - /* for BC/MC Frames */ - psta_bmc = rtw_get_bcmc_stainfo(padapter); - if (!psta_bmc) - return; - - if ((pstapriv->sta_dz_bitmap & 0xfffe) == 0x0) { /* no any sta in ps mode */ - spin_lock_bh(&psta_bmc->sleep_q.lock); - - xmitframe_phead = get_list_head(&psta_bmc->sleep_q); - list_for_each_entry_safe(pxmitframe, n, xmitframe_phead, list) { - list_del_init(&pxmitframe->list); - - psta_bmc->sleepq_len--; - if (psta_bmc->sleepq_len > 0) - pxmitframe->attrib.mdata = 1; - else - pxmitframe->attrib.mdata = 0; - - pxmitframe->attrib.triggered = 1; - - spin_unlock_bh(&psta_bmc->sleep_q.lock); - if (rtw_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); - spin_lock_bh(&psta_bmc->sleep_q.lock); - } - - if (psta_bmc->sleepq_len == 0) { - pstapriv->tim_bitmap &= ~BIT(0); - pstapriv->sta_dz_bitmap &= ~BIT(0); - - update_mask |= BIT(1); - } - - spin_unlock_bh(&psta_bmc->sleep_q.lock); - } - - if (update_mask) - update_beacon(padapter, WLAN_EID_TIM, NULL, false); -} - -void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta) -{ - u8 wmmps_ac = 0; - struct list_head *xmitframe_phead; - struct xmit_frame *pxmitframe, *n; - struct sta_priv *pstapriv = &padapter->stapriv; - - spin_lock_bh(&psta->sleep_q.lock); - - xmitframe_phead = get_list_head(&psta->sleep_q); - list_for_each_entry_safe(pxmitframe, n, xmitframe_phead, list) { - switch (pxmitframe->attrib.priority) { - case 1: - case 2: - wmmps_ac = psta->uapsd_bk & BIT(1); - break; - case 4: - case 5: - wmmps_ac = psta->uapsd_vi & BIT(1); - break; - case 6: - case 7: - wmmps_ac = psta->uapsd_vo & BIT(1); - break; - case 0: - case 3: - default: - wmmps_ac = psta->uapsd_be & BIT(1); - break; - } - - if (!wmmps_ac) - continue; - - list_del_init(&pxmitframe->list); - - psta->sleepq_len--; - psta->sleepq_ac_len--; - - if (psta->sleepq_ac_len > 0) { - pxmitframe->attrib.mdata = 1; - pxmitframe->attrib.eosp = 0; - } else { - pxmitframe->attrib.mdata = 0; - pxmitframe->attrib.eosp = 1; - } - - pxmitframe->attrib.triggered = 1; - - if (rtw_hal_xmit(padapter, pxmitframe)) - rtw_os_xmit_complete(padapter, pxmitframe); - - if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { - pstapriv->tim_bitmap &= ~BIT(psta->aid); - - /* update BCN for TIM IE */ - update_beacon(padapter, WLAN_EID_TIM, NULL, false); - } - } - - spin_unlock_bh(&psta->sleep_q.lock); -} - -#endif - -void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms) -{ - sctx->timeout_ms = timeout_ms; - sctx->submit_time = jiffies; - init_completion(&sctx->done); - sctx->status = RTW_SCTX_SUBMITTED; -} - -int rtw_sctx_wait(struct submit_ctx *sctx) -{ - int ret = _FAIL; - unsigned long expire; - int status = 0; - - expire = sctx->timeout_ms ? msecs_to_jiffies(sctx->timeout_ms) : MAX_SCHEDULE_TIMEOUT; - if (!wait_for_completion_timeout(&sctx->done, expire)) { - /* timeout, do something?? */ - status = RTW_SCTX_DONE_TIMEOUT; - } else { - status = sctx->status; - } - - if (status == RTW_SCTX_DONE_SUCCESS) - ret = _SUCCESS; - - return ret; -} - -void rtw_sctx_done_err(struct submit_ctx **sctx, int status) -{ - if (*sctx) { - (*sctx)->status = status; - complete(&((*sctx)->done)); - *sctx = NULL; - } -} - -int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms) -{ - struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; - - pack_tx_ops->submit_time = jiffies; - pack_tx_ops->timeout_ms = timeout_ms; - pack_tx_ops->status = RTW_SCTX_SUBMITTED; - - return rtw_sctx_wait(pack_tx_ops); -} - -void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status) -{ - struct submit_ctx *pack_tx_ops = &pxmitpriv->ack_tx_ops; - - if (pxmitpriv->ack_tx) - rtw_sctx_done_err(&pack_tx_ops, status); -} diff --git a/drivers/staging/rtl8188eu/hal/bb_cfg.c b/drivers/staging/rtl8188eu/hal/bb_cfg.c deleted file mode 100644 index 51882858fcf0..000000000000 --- a/drivers/staging/rtl8188eu/hal/bb_cfg.c +++ /dev/null @@ -1,681 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" - -#include - -/* AGC_TAB_1T.TXT */ - -static u32 array_agc_tab_1t_8188e[] = { - 0xC78, 0xFB000001, - 0xC78, 0xFB010001, - 0xC78, 0xFB020001, - 0xC78, 0xFB030001, - 0xC78, 0xFB040001, - 0xC78, 0xFB050001, - 0xC78, 0xFA060001, - 0xC78, 0xF9070001, - 0xC78, 0xF8080001, - 0xC78, 0xF7090001, - 0xC78, 0xF60A0001, - 0xC78, 0xF50B0001, - 0xC78, 0xF40C0001, - 0xC78, 0xF30D0001, - 0xC78, 0xF20E0001, - 0xC78, 0xF10F0001, - 0xC78, 0xF0100001, - 0xC78, 0xEF110001, - 0xC78, 0xEE120001, - 0xC78, 0xED130001, - 0xC78, 0xEC140001, - 0xC78, 0xEB150001, - 0xC78, 0xEA160001, - 0xC78, 0xE9170001, - 0xC78, 0xE8180001, - 0xC78, 0xE7190001, - 0xC78, 0xE61A0001, - 0xC78, 0xE51B0001, - 0xC78, 0xE41C0001, - 0xC78, 0xE31D0001, - 0xC78, 0xE21E0001, - 0xC78, 0xE11F0001, - 0xC78, 0x8A200001, - 0xC78, 0x89210001, - 0xC78, 0x88220001, - 0xC78, 0x87230001, - 0xC78, 0x86240001, - 0xC78, 0x85250001, - 0xC78, 0x84260001, - 0xC78, 0x83270001, - 0xC78, 0x82280001, - 0xC78, 0x6B290001, - 0xC78, 0x6A2A0001, - 0xC78, 0x692B0001, - 0xC78, 0x682C0001, - 0xC78, 0x672D0001, - 0xC78, 0x662E0001, - 0xC78, 0x652F0001, - 0xC78, 0x64300001, - 0xC78, 0x63310001, - 0xC78, 0x62320001, - 0xC78, 0x61330001, - 0xC78, 0x46340001, - 0xC78, 0x45350001, - 0xC78, 0x44360001, - 0xC78, 0x43370001, - 0xC78, 0x42380001, - 0xC78, 0x41390001, - 0xC78, 0x403A0001, - 0xC78, 0x403B0001, - 0xC78, 0x403C0001, - 0xC78, 0x403D0001, - 0xC78, 0x403E0001, - 0xC78, 0x403F0001, - 0xC78, 0xFB400001, - 0xC78, 0xFB410001, - 0xC78, 0xFB420001, - 0xC78, 0xFB430001, - 0xC78, 0xFB440001, - 0xC78, 0xFB450001, - 0xC78, 0xFB460001, - 0xC78, 0xFB470001, - 0xC78, 0xFB480001, - 0xC78, 0xFA490001, - 0xC78, 0xF94A0001, - 0xC78, 0xF84B0001, - 0xC78, 0xF74C0001, - 0xC78, 0xF64D0001, - 0xC78, 0xF54E0001, - 0xC78, 0xF44F0001, - 0xC78, 0xF3500001, - 0xC78, 0xF2510001, - 0xC78, 0xF1520001, - 0xC78, 0xF0530001, - 0xC78, 0xEF540001, - 0xC78, 0xEE550001, - 0xC78, 0xED560001, - 0xC78, 0xEC570001, - 0xC78, 0xEB580001, - 0xC78, 0xEA590001, - 0xC78, 0xE95A0001, - 0xC78, 0xE85B0001, - 0xC78, 0xE75C0001, - 0xC78, 0xE65D0001, - 0xC78, 0xE55E0001, - 0xC78, 0xE45F0001, - 0xC78, 0xE3600001, - 0xC78, 0xE2610001, - 0xC78, 0xC3620001, - 0xC78, 0xC2630001, - 0xC78, 0xC1640001, - 0xC78, 0x8B650001, - 0xC78, 0x8A660001, - 0xC78, 0x89670001, - 0xC78, 0x88680001, - 0xC78, 0x87690001, - 0xC78, 0x866A0001, - 0xC78, 0x856B0001, - 0xC78, 0x846C0001, - 0xC78, 0x676D0001, - 0xC78, 0x666E0001, - 0xC78, 0x656F0001, - 0xC78, 0x64700001, - 0xC78, 0x63710001, - 0xC78, 0x62720001, - 0xC78, 0x61730001, - 0xC78, 0x60740001, - 0xC78, 0x46750001, - 0xC78, 0x45760001, - 0xC78, 0x44770001, - 0xC78, 0x43780001, - 0xC78, 0x42790001, - 0xC78, 0x417A0001, - 0xC78, 0x407B0001, - 0xC78, 0x407C0001, - 0xC78, 0x407D0001, - 0xC78, 0x407E0001, - 0xC78, 0x407F0001, -}; - -static bool set_baseband_agc_config(struct adapter *adapt) -{ - u32 i; - const u32 arraylen = ARRAY_SIZE(array_agc_tab_1t_8188e); - u32 *array = array_agc_tab_1t_8188e; - - for (i = 0; i < arraylen; i += 2) { - u32 v1 = array[i]; - u32 v2 = array[i + 1]; - - if (v1 < 0xCDCDCDCD) { - phy_set_bb_reg(adapt, v1, bMaskDWord, v2); - udelay(1); - } - } - return true; -} - -/* PHY_REG_1T.TXT */ - -static u32 array_phy_reg_1t_8188e[] = { - 0x800, 0x80040000, - 0x804, 0x00000003, - 0x808, 0x0000FC00, - 0x80C, 0x0000000A, - 0x810, 0x10001331, - 0x814, 0x020C3D10, - 0x818, 0x02200385, - 0x81C, 0x00000000, - 0x820, 0x01000100, - 0x824, 0x00390204, - 0x828, 0x00000000, - 0x82C, 0x00000000, - 0x830, 0x00000000, - 0x834, 0x00000000, - 0x838, 0x00000000, - 0x83C, 0x00000000, - 0x840, 0x00010000, - 0x844, 0x00000000, - 0x848, 0x00000000, - 0x84C, 0x00000000, - 0x850, 0x00000000, - 0x854, 0x00000000, - 0x858, 0x569A11A9, - 0x85C, 0x01000014, - 0x860, 0x66F60110, - 0x864, 0x061F0649, - 0x868, 0x00000000, - 0x86C, 0x27272700, - 0x870, 0x07000760, - 0x874, 0x25004000, - 0x878, 0x00000808, - 0x87C, 0x00000000, - 0x880, 0xB0000C1C, - 0x884, 0x00000001, - 0x888, 0x00000000, - 0x88C, 0xCCC000C0, - 0x890, 0x00000800, - 0x894, 0xFFFFFFFE, - 0x898, 0x40302010, - 0x89C, 0x00706050, - 0x900, 0x00000000, - 0x904, 0x00000023, - 0x908, 0x00000000, - 0x90C, 0x81121111, - 0x910, 0x00000002, - 0x914, 0x00000201, - 0xA00, 0x00D047C8, - 0xA04, 0x80FF000C, - 0xA08, 0x8C838300, - 0xA0C, 0x2E7F120F, - 0xA10, 0x9500BB78, - 0xA14, 0x1114D028, - 0xA18, 0x00881117, - 0xA1C, 0x89140F00, - 0xA20, 0x1A1B0000, - 0xA24, 0x090E1317, - 0xA28, 0x00000204, - 0xA2C, 0x00D30000, - 0xA70, 0x101FBF00, - 0xA74, 0x00000007, - 0xA78, 0x00000900, - 0xA7C, 0x225B0606, - 0xA80, 0x218075B1, - 0xB2C, 0x80000000, - 0xC00, 0x48071D40, - 0xC04, 0x03A05611, - 0xC08, 0x000000E4, - 0xC0C, 0x6C6C6C6C, - 0xC10, 0x08800000, - 0xC14, 0x40000100, - 0xC18, 0x08800000, - 0xC1C, 0x40000100, - 0xC20, 0x00000000, - 0xC24, 0x00000000, - 0xC28, 0x00000000, - 0xC2C, 0x00000000, - 0xC30, 0x69E9AC47, - 0xC34, 0x469652AF, - 0xC38, 0x49795994, - 0xC3C, 0x0A97971C, - 0xC40, 0x1F7C403F, - 0xC44, 0x000100B7, - 0xC48, 0xEC020107, - 0xC4C, 0x007F037F, - 0xC50, 0x69553420, - 0xC54, 0x43BC0094, - 0xC58, 0x00013169, - 0xC5C, 0x00250492, - 0xC60, 0x00000000, - 0xC64, 0x7112848B, - 0xC68, 0x47C00BFF, - 0xC6C, 0x00000036, - 0xC70, 0x2C7F000D, - 0xC74, 0x020610DB, - 0xC78, 0x0000001F, - 0xC7C, 0x00B91612, - 0xC80, 0x390000E4, - 0xC84, 0x20F60000, - 0xC88, 0x40000100, - 0xC8C, 0x20200000, - 0xC90, 0x00091521, - 0xC94, 0x00000000, - 0xC98, 0x00121820, - 0xC9C, 0x00007F7F, - 0xCA0, 0x00000000, - 0xCA4, 0x000300A0, - 0xCA8, 0x00000000, - 0xCAC, 0x00000000, - 0xCB0, 0x00000000, - 0xCB4, 0x00000000, - 0xCB8, 0x00000000, - 0xCBC, 0x28000000, - 0xCC0, 0x00000000, - 0xCC4, 0x00000000, - 0xCC8, 0x00000000, - 0xCCC, 0x00000000, - 0xCD0, 0x00000000, - 0xCD4, 0x00000000, - 0xCD8, 0x64B22427, - 0xCDC, 0x00766932, - 0xCE0, 0x00222222, - 0xCE4, 0x00000000, - 0xCE8, 0x37644302, - 0xCEC, 0x2F97D40C, - 0xD00, 0x00000740, - 0xD04, 0x00020401, - 0xD08, 0x0000907F, - 0xD0C, 0x20010201, - 0xD10, 0xA0633333, - 0xD14, 0x3333BC43, - 0xD18, 0x7A8F5B6F, - 0xD2C, 0xCC979975, - 0xD30, 0x00000000, - 0xD34, 0x80608000, - 0xD38, 0x00000000, - 0xD3C, 0x00127353, - 0xD40, 0x00000000, - 0xD44, 0x00000000, - 0xD48, 0x00000000, - 0xD4C, 0x00000000, - 0xD50, 0x6437140A, - 0xD54, 0x00000000, - 0xD58, 0x00000282, - 0xD5C, 0x30032064, - 0xD60, 0x4653DE68, - 0xD64, 0x04518A3C, - 0xD68, 0x00002101, - 0xD6C, 0x2A201C16, - 0xD70, 0x1812362E, - 0xD74, 0x322C2220, - 0xD78, 0x000E3C24, - 0xE00, 0x2D2D2D2D, - 0xE04, 0x2D2D2D2D, - 0xE08, 0x0390272D, - 0xE10, 0x2D2D2D2D, - 0xE14, 0x2D2D2D2D, - 0xE18, 0x2D2D2D2D, - 0xE1C, 0x2D2D2D2D, - 0xE28, 0x00000000, - 0xE30, 0x1000DC1F, - 0xE34, 0x10008C1F, - 0xE38, 0x02140102, - 0xE3C, 0x681604C2, - 0xE40, 0x01007C00, - 0xE44, 0x01004800, - 0xE48, 0xFB000000, - 0xE4C, 0x000028D1, - 0xE50, 0x1000DC1F, - 0xE54, 0x10008C1F, - 0xE58, 0x02140102, - 0xE5C, 0x28160D05, - 0xE60, 0x00000008, - 0xE68, 0x001B25A4, - 0xE6C, 0x00C00014, - 0xE70, 0x00C00014, - 0xE74, 0x01000014, - 0xE78, 0x01000014, - 0xE7C, 0x01000014, - 0xE80, 0x01000014, - 0xE84, 0x00C00014, - 0xE88, 0x01000014, - 0xE8C, 0x00C00014, - 0xED0, 0x00C00014, - 0xED4, 0x00C00014, - 0xED8, 0x00C00014, - 0xEDC, 0x00000014, - 0xEE0, 0x00000014, - 0xEEC, 0x01C00014, - 0xF14, 0x00000003, - 0xF4C, 0x00000000, - 0xF00, 0x00000300, -}; - -static void rtl_bb_delay(struct adapter *adapt, u32 addr, u32 data) -{ - if (addr == 0xfe) { - msleep(50); - } else if (addr == 0xfd) { - mdelay(5); - } else if (addr == 0xfc) { - mdelay(1); - } else if (addr == 0xfb) { - udelay(50); - } else if (addr == 0xfa) { - udelay(5); - } else if (addr == 0xf9) { - udelay(1); - } else { - phy_set_bb_reg(adapt, addr, bMaskDWord, data); - /* Add 1us delay between BB/RF register setting. */ - udelay(1); - } -} - -static bool set_baseband_phy_config(struct adapter *adapt) -{ - u32 i; - const u32 arraylen = ARRAY_SIZE(array_phy_reg_1t_8188e); - u32 *array = array_phy_reg_1t_8188e; - - for (i = 0; i < arraylen; i += 2) { - u32 v1 = array[i]; - u32 v2 = array[i + 1]; - - if (v1 < 0xCDCDCDCD) - rtl_bb_delay(adapt, v1, v2); - } - return true; -} - -/* PHY_REG_PG.TXT */ - -static u32 array_phy_reg_pg_8188e[] = { - 0xE00, 0xFFFFFFFF, 0x06070809, - 0xE04, 0xFFFFFFFF, 0x02020405, - 0xE08, 0x0000FF00, 0x00000006, - 0x86C, 0xFFFFFF00, 0x00020400, - 0xE10, 0xFFFFFFFF, 0x08090A0B, - 0xE14, 0xFFFFFFFF, 0x01030607, - 0xE18, 0xFFFFFFFF, 0x08090A0B, - 0xE1C, 0xFFFFFFFF, 0x01030607, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x02020202, - 0xE04, 0xFFFFFFFF, 0x00020202, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x04040404, - 0xE14, 0xFFFFFFFF, 0x00020404, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x02020202, - 0xE04, 0xFFFFFFFF, 0x00020202, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x04040404, - 0xE14, 0xFFFFFFFF, 0x00020404, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x02020202, - 0xE04, 0xFFFFFFFF, 0x00020202, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x04040404, - 0xE14, 0xFFFFFFFF, 0x00020404, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - 0xE00, 0xFFFFFFFF, 0x00000000, - 0xE04, 0xFFFFFFFF, 0x00000000, - 0xE08, 0x0000FF00, 0x00000000, - 0x86C, 0xFFFFFF00, 0x00000000, - 0xE10, 0xFFFFFFFF, 0x00000000, - 0xE14, 0xFFFFFFFF, 0x00000000, - 0xE18, 0xFFFFFFFF, 0x00000000, - 0xE1C, 0xFFFFFFFF, 0x00000000, - -}; - -static void store_pwrindex_offset(struct adapter *adapter, - u32 regaddr, u32 bitmask, u32 data) -{ - struct hal_data_8188e *hal_data = adapter->HalData; - u32 * const power_level_offset = - hal_data->MCSTxPowerLevelOriginalOffset[hal_data->pwrGroupCnt]; - - if (regaddr == rTxAGC_A_Rate18_06) - power_level_offset[0] = data; - if (regaddr == rTxAGC_A_Rate54_24) - power_level_offset[1] = data; - if (regaddr == rTxAGC_A_CCK1_Mcs32) - power_level_offset[6] = data; - if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0xffffff00) - power_level_offset[7] = data; - if (regaddr == rTxAGC_A_Mcs03_Mcs00) - power_level_offset[2] = data; - if (regaddr == rTxAGC_A_Mcs07_Mcs04) - power_level_offset[3] = data; - if (regaddr == rTxAGC_A_Mcs11_Mcs08) - power_level_offset[4] = data; - if (regaddr == rTxAGC_A_Mcs15_Mcs12) { - power_level_offset[5] = data; - hal_data->pwrGroupCnt++; - } - if (regaddr == rTxAGC_B_Rate18_06) - power_level_offset[8] = data; - if (regaddr == rTxAGC_B_Rate54_24) - power_level_offset[9] = data; - if (regaddr == rTxAGC_B_CCK1_55_Mcs32) - power_level_offset[14] = data; - if (regaddr == rTxAGC_B_CCK11_A_CCK2_11 && bitmask == 0x000000ff) - power_level_offset[15] = data; - if (regaddr == rTxAGC_B_Mcs03_Mcs00) - power_level_offset[10] = data; - if (regaddr == rTxAGC_B_Mcs07_Mcs04) - power_level_offset[11] = data; - if (regaddr == rTxAGC_B_Mcs11_Mcs08) - power_level_offset[12] = data; - if (regaddr == rTxAGC_B_Mcs15_Mcs12) - power_level_offset[13] = data; -} - -static void rtl_addr_delay(struct adapter *adapt, - u32 addr, u32 bit_mask, u32 data) -{ - switch (addr) { - case 0xfe: - msleep(50); - break; - case 0xfd: - mdelay(5); - break; - case 0xfc: - mdelay(1); - break; - case 0xfb: - udelay(50); - break; - case 0xfa: - udelay(5); - break; - case 0xf9: - udelay(1); - break; - default: - store_pwrindex_offset(adapt, addr, bit_mask, data); - } -} - -static bool config_bb_with_pgheader(struct adapter *adapt) -{ - u32 i; - const u32 arraylen = ARRAY_SIZE(array_phy_reg_pg_8188e); - u32 *array = array_phy_reg_pg_8188e; - - for (i = 0; i < arraylen; i += 3) { - u32 v1 = array[i]; - u32 v2 = array[i + 1]; - u32 v3 = array[i + 2]; - - if (v1 < 0xCDCDCDCD) - rtl_addr_delay(adapt, v1, v2, v3); - } - return true; -} - -static void rtl88e_phy_init_bb_rf_register_definition(struct adapter *adapter) -{ - struct bb_reg_def *reg[4]; - - reg[RF_PATH_A] = &adapter->HalData->PHYRegDef[RF_PATH_A]; - reg[RF_PATH_B] = &adapter->HalData->PHYRegDef[RF_PATH_B]; - - reg[RF_PATH_A]->rfintfs = rFPGA0_XAB_RFInterfaceSW; - reg[RF_PATH_B]->rfintfs = rFPGA0_XAB_RFInterfaceSW; - - reg[RF_PATH_A]->rfintfi = rFPGA0_XAB_RFInterfaceRB; - reg[RF_PATH_B]->rfintfi = rFPGA0_XAB_RFInterfaceRB; - - reg[RF_PATH_A]->rfintfo = rFPGA0_XA_RFInterfaceOE; - reg[RF_PATH_B]->rfintfo = rFPGA0_XB_RFInterfaceOE; - - reg[RF_PATH_A]->rfintfe = rFPGA0_XA_RFInterfaceOE; - reg[RF_PATH_B]->rfintfe = rFPGA0_XB_RFInterfaceOE; - - reg[RF_PATH_A]->rf3wireOffset = rFPGA0_XA_LSSIParameter; - reg[RF_PATH_B]->rf3wireOffset = rFPGA0_XB_LSSIParameter; - - reg[RF_PATH_A]->rfLSSI_Select = rFPGA0_XAB_RFParameter; - reg[RF_PATH_B]->rfLSSI_Select = rFPGA0_XAB_RFParameter; - - reg[RF_PATH_A]->rfTxGainStage = rFPGA0_TxGainStage; - reg[RF_PATH_B]->rfTxGainStage = rFPGA0_TxGainStage; - - reg[RF_PATH_A]->rfHSSIPara1 = rFPGA0_XA_HSSIParameter1; - reg[RF_PATH_B]->rfHSSIPara1 = rFPGA0_XB_HSSIParameter1; - - reg[RF_PATH_A]->rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; - reg[RF_PATH_B]->rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; - - reg[RF_PATH_A]->rfSwitchControl = rFPGA0_XAB_SwitchControl; - reg[RF_PATH_B]->rfSwitchControl = rFPGA0_XAB_SwitchControl; - - reg[RF_PATH_A]->rfAGCControl1 = rOFDM0_XAAGCCore1; - reg[RF_PATH_B]->rfAGCControl1 = rOFDM0_XBAGCCore1; - - reg[RF_PATH_A]->rfAGCControl2 = rOFDM0_XAAGCCore2; - reg[RF_PATH_B]->rfAGCControl2 = rOFDM0_XBAGCCore2; - - reg[RF_PATH_A]->rfRxIQImbalance = rOFDM0_XARxIQImbalance; - reg[RF_PATH_B]->rfRxIQImbalance = rOFDM0_XBRxIQImbalance; - - reg[RF_PATH_A]->rfRxAFE = rOFDM0_XARxAFE; - reg[RF_PATH_B]->rfRxAFE = rOFDM0_XBRxAFE; - - reg[RF_PATH_A]->rfTxIQImbalance = rOFDM0_XATxIQImbalance; - reg[RF_PATH_B]->rfTxIQImbalance = rOFDM0_XBTxIQImbalance; - - reg[RF_PATH_A]->rfTxAFE = rOFDM0_XATxAFE; - reg[RF_PATH_B]->rfTxAFE = rOFDM0_XBTxAFE; - - reg[RF_PATH_A]->rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; - reg[RF_PATH_B]->rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; - - reg[RF_PATH_A]->rfLSSIReadBackPi = TransceiverA_HSPI_Readback; - reg[RF_PATH_B]->rfLSSIReadBackPi = TransceiverB_HSPI_Readback; -} - -static bool config_parafile(struct adapter *adapt) -{ - struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); - - set_baseband_phy_config(adapt); - - /* If EEPROM or EFUSE autoload OK, We must config by PHY_REG_PG.txt */ - if (!eeprom->bautoload_fail_flag) { - adapt->HalData->pwrGroupCnt = 0; - config_bb_with_pgheader(adapt); - } - set_baseband_agc_config(adapt); - return true; -} - -bool rtl88eu_phy_bb_config(struct adapter *adapt) -{ - bool rtstatus; - u32 regval; - u8 crystal_cap; - - rtl88e_phy_init_bb_rf_register_definition(adapt); - - /* Enable BB and RF */ - regval = usb_read16(adapt, REG_SYS_FUNC_EN); - usb_write16(adapt, REG_SYS_FUNC_EN, - (u16)(regval | BIT(13) | BIT(0) | BIT(1))); - - usb_write8(adapt, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB); - - usb_write8(adapt, REG_SYS_FUNC_EN, FEN_USBA | - FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); - - /* Config BB and AGC */ - rtstatus = config_parafile(adapt); - - /* write 0x24[16:11] = 0x24[22:17] = crystal_cap */ - crystal_cap = adapt->HalData->CrystalCap & 0x3F; - phy_set_bb_reg(adapt, REG_AFE_XTAL_CTRL, 0x7ff800, - (crystal_cap | (crystal_cap << 6))); - - return rtstatus; -} diff --git a/drivers/staging/rtl8188eu/hal/fw.c b/drivers/staging/rtl8188eu/hal/fw.c deleted file mode 100644 index 3d1d29e9f8e0..000000000000 --- a/drivers/staging/rtl8188eu/hal/fw.c +++ /dev/null @@ -1,202 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2009-2013 Realtek Corporation. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#include "fw.h" -#include "drv_types.h" -#include "usb_ops_linux.h" -#include "rtl8188e_spec.h" -#include "rtl8188e_hal.h" - -#include -#include - -static void _rtl88e_enable_fw_download(struct adapter *adapt, bool enable) -{ - u8 tmp; - - if (enable) { - tmp = usb_read8(adapt, REG_MCUFWDL); - usb_write8(adapt, REG_MCUFWDL, tmp | 0x01); - - tmp = usb_read8(adapt, REG_MCUFWDL + 2); - usb_write8(adapt, REG_MCUFWDL + 2, tmp & 0xf7); - } else { - tmp = usb_read8(adapt, REG_MCUFWDL); - usb_write8(adapt, REG_MCUFWDL, tmp & 0xfe); - - usb_write8(adapt, REG_MCUFWDL + 1, 0x00); - } -} - -static void _rtl88e_fw_block_write(struct adapter *adapt, - const u8 *buffer, u32 size) -{ - u32 blk_sz = sizeof(u32); - const u8 *byte_buffer; - const u32 *dword_buffer = (u32 *)buffer; - u32 i, write_address, blk_cnt, remain; - - blk_cnt = size / blk_sz; - remain = size % blk_sz; - - write_address = FW_8192C_START_ADDRESS; - - for (i = 0; i < blk_cnt; i++, write_address += blk_sz) - usb_write32(adapt, write_address, dword_buffer[i]); - - byte_buffer = buffer + blk_cnt * blk_sz; - for (i = 0; i < remain; i++, write_address++) - usb_write8(adapt, write_address, byte_buffer[i]); -} - -static void _rtl88e_fw_page_write(struct adapter *adapt, - u32 page, const u8 *buffer, u32 size) -{ - u8 value8; - u8 u8page = (u8)(page & 0x07); - - value8 = (usb_read8(adapt, REG_MCUFWDL + 2) & 0xF8) | u8page; - - usb_write8(adapt, (REG_MCUFWDL + 2), value8); - _rtl88e_fw_block_write(adapt, buffer, size); -} - -static void _rtl88e_write_fw(struct adapter *adapt, u8 *buffer, u32 size) -{ - u8 *buf_ptr = buffer; - u32 page_no, remain; - u32 page, offset; - - page_no = size / FW_8192C_PAGE_SIZE; - remain = size % FW_8192C_PAGE_SIZE; - - for (page = 0; page < page_no; page++) { - offset = page * FW_8192C_PAGE_SIZE; - _rtl88e_fw_page_write(adapt, page, (buf_ptr + offset), - FW_8192C_PAGE_SIZE); - } - - if (remain) { - offset = page_no * FW_8192C_PAGE_SIZE; - page = page_no; - _rtl88e_fw_page_write(adapt, page, (buf_ptr + offset), remain); - } -} - -static void rtl88e_firmware_selfreset(struct adapter *adapt) -{ - u8 u1b_tmp; - - u1b_tmp = usb_read8(adapt, REG_SYS_FUNC_EN + 1); - usb_write8(adapt, REG_SYS_FUNC_EN + 1, (u1b_tmp & (~BIT(2)))); - usb_write8(adapt, REG_SYS_FUNC_EN + 1, (u1b_tmp | BIT(2))); -} - -static int _rtl88e_fw_free_to_go(struct adapter *adapt) -{ - int err = -EIO; - u32 counter = 0; - u32 value32; - - do { - value32 = usb_read32(adapt, REG_MCUFWDL); - if (value32 & FWDL_CHKSUM_RPT) - break; - } while (counter++ < POLLING_READY_TIMEOUT_COUNT); - - if (counter >= POLLING_READY_TIMEOUT_COUNT) - goto exit; - - value32 = usb_read32(adapt, REG_MCUFWDL); - value32 |= MCUFWDL_RDY; - value32 &= ~WINTINI_RDY; - usb_write32(adapt, REG_MCUFWDL, value32); - - rtl88e_firmware_selfreset(adapt); - counter = 0; - - do { - value32 = usb_read32(adapt, REG_MCUFWDL); - if (value32 & WINTINI_RDY) { - err = 0; - goto exit; - } - - udelay(FW_8192C_POLLING_DELAY); - - } while (counter++ < POLLING_READY_TIMEOUT_COUNT); - -exit: - return err; -} - -int rtl88eu_download_fw(struct adapter *adapt) -{ - struct dvobj_priv *dvobj = adapter_to_dvobj(adapt); - struct device *device = dvobj_to_dev(dvobj); - const struct firmware *fw; - static const char fw_name[] = "rtlwifi/rtl8188eufw.bin"; - struct rtl92c_firmware_header *pfwheader = NULL; - u8 *download_data, *fw_data; - size_t download_size; - unsigned int trailing_zeros_length; - - if (request_firmware(&fw, fw_name, device)) { - dev_err(device, "Firmware %s not available\n", fw_name); - return -ENOENT; - } - - if (fw->size > FW_8188E_SIZE) { - dev_err(device, "Firmware size exceed 0x%X. Check it.\n", - FW_8188E_SIZE); - release_firmware(fw); - return -1; - } - - trailing_zeros_length = (4 - fw->size % 4) % 4; - - fw_data = kmalloc(fw->size + trailing_zeros_length, GFP_KERNEL); - if (!fw_data) { - release_firmware(fw); - return -ENOMEM; - } - - memcpy(fw_data, fw->data, fw->size); - memset(fw_data + fw->size, 0, trailing_zeros_length); - - pfwheader = (struct rtl92c_firmware_header *)fw_data; - - if (IS_FW_HEADER_EXIST(pfwheader)) { - download_data = fw_data + 32; - download_size = fw->size + trailing_zeros_length - 32; - } else { - download_data = fw_data; - download_size = fw->size + trailing_zeros_length; - } - - release_firmware(fw); - - if (usb_read8(adapt, REG_MCUFWDL) & RAM_DL_SEL) { - usb_write8(adapt, REG_MCUFWDL, 0); - rtl88e_firmware_selfreset(adapt); - } - _rtl88e_enable_fw_download(adapt, true); - usb_write8(adapt, REG_MCUFWDL, - usb_read8(adapt, REG_MCUFWDL) | FWDL_CHKSUM_RPT); - _rtl88e_write_fw(adapt, download_data, download_size); - _rtl88e_enable_fw_download(adapt, false); - - kfree(fw_data); - return _rtl88e_fw_free_to_go(adapt); -} diff --git a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c b/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c deleted file mode 100644 index 74fff76af16d..000000000000 --- a/drivers/staging/rtl8188eu/hal/hal8188e_rate_adaptive.c +++ /dev/null @@ -1,646 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * Copyright (c) Realtek Semiconductor Corp. All rights reserved. - */ - -#include "odm_precomp.h" - -/* Rate adaptive parameters */ - -static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE + 1] = { - {5, 4, 3, 2, 0, 3}, /* 92 , idx = 0 */ - {6, 5, 4, 3, 0, 4}, /* 86 , idx = 1 */ - {6, 5, 4, 2, 0, 4}, /* 81 , idx = 2 */ - {8, 7, 6, 4, 0, 6}, /* 75 , idx = 3 */ - {10, 9, 8, 6, 0, 8}, /* 71 , idx = 4 */ - {10, 9, 8, 4, 0, 8}, /* 66 , idx = 5 */ - {10, 9, 8, 2, 0, 8}, /* 62 , idx = 6 */ - {10, 9, 8, 0, 0, 8}, /* 59 , idx = 7 */ - {18, 17, 16, 8, 0, 16}, /* 53 , idx = 8 */ - {26, 25, 24, 16, 0, 24}, /* 50 , idx = 9 */ - {34, 33, 32, 24, 0, 32}, /* 47 , idx = 0x0a */ - {34, 31, 28, 20, 0, 32}, /* 43 , idx = 0x0b */ - {34, 31, 27, 18, 0, 32}, /* 40 , idx = 0x0c */ - {34, 31, 26, 16, 0, 32}, /* 37 , idx = 0x0d */ - {34, 30, 22, 16, 0, 32}, /* 32 , idx = 0x0e */ - {34, 30, 24, 16, 0, 32}, /* 26 , idx = 0x0f */ - {49, 46, 40, 16, 0, 48}, /* 20 , idx = 0x10 */ - {49, 45, 32, 0, 0, 48}, /* 17 , idx = 0x11 */ - {49, 45, 22, 18, 0, 48}, /* 15 , idx = 0x12 */ - {49, 40, 24, 16, 0, 48}, /* 12 , idx = 0x13 */ - {49, 32, 18, 12, 0, 48}, /* 9 , idx = 0x14 */ - {49, 22, 18, 14, 0, 48}, /* 6 , idx = 0x15 */ - {49, 16, 16, 0, 0, 48} - }; /* 3, idx = 0x16 */ - -static u8 PT_PENALTY[RETRYSIZE + 1] = {34, 31, 30, 24, 0, 32}; - -/* wilson modify */ -static u8 RETRY_PENALTY_IDX[2][RATESIZE] = { - {4, 4, 4, 5, 4, 4, 5, 7, 7, 7, 8, 0x0a, /* SS>TH */ - 4, 4, 4, 4, 6, 0x0a, 0x0b, 0x0d, - 5, 5, 7, 7, 8, 0x0b, 0x0d, 0x0f}, /* 0329 R01 */ - {0x0a, 0x0a, 0x0b, 0x0c, 0x0a, - 0x0a, 0x0b, 0x0c, 0x0d, 0x10, 0x13, 0x14, /* SSTH */ - 0x0f, 0x10, 0x10, 0x12, 0x12, 0x13, 0x14, 0x15, - 0x11, 0x11, 0x12, 0x13, 0x13, 0x13, 0x14, 0x15}; - -static u8 RSSI_THRESHOLD[RATESIZE] = { - 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0x24, 0x26, 0x2a, - 0x18, 0x1a, 0x1d, 0x1f, 0x21, 0x27, 0x29, 0x2a, - 0, 0, 0, 0x1f, 0x23, 0x28, 0x2a, 0x2c}; - -static u16 N_THRESHOLD_HIGH[RATESIZE] = { - 4, 4, 8, 16, - 24, 36, 48, 72, 96, 144, 192, 216, - 60, 80, 100, 160, 240, 400, 560, 640, - 300, 320, 480, 720, 1000, 1200, 1600, 2000}; -static u16 N_THRESHOLD_LOW[RATESIZE] = { - 2, 2, 4, 8, - 12, 18, 24, 36, 48, 72, 96, 108, - 30, 40, 50, 80, 120, 200, 280, 320, - 150, 160, 240, 360, 500, 600, 800, 1000}; - -static u8 DROPING_NECESSARY[RATESIZE] = { - 1, 1, 1, 1, - 1, 2, 3, 4, 5, 6, 7, 8, - 1, 2, 3, 4, 5, 6, 7, 8, - 5, 6, 7, 8, 9, 10, 11, 12}; - -static u8 PendingForRateUpFail[5] = {2, 10, 24, 40, 60}; -static u16 DynamicTxRPTTiming[6] = { - 0x186a, 0x30d4, 0x493e, 0x61a8, 0x7a12, 0x927c}; /* 200ms-1200ms */ - -/* End Rate adaptive parameters */ - -static void odm_SetTxRPTTiming_8188E(struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo, u8 extend) -{ - u8 idx = 0; - - for (idx = 0; idx < 5; idx++) - if (DynamicTxRPTTiming[idx] == pRaInfo->RptTime) - break; - - if (extend == 0) { /* back to default timing */ - idx = 0; /* 200ms */ - } else if (extend == 1) {/* increase the timing */ - idx += 1; - if (idx > 5) - idx = 5; - } else if (extend == 2) {/* decrease the timing */ - if (idx != 0) - idx -= 1; - } - pRaInfo->RptTime = DynamicTxRPTTiming[idx]; -} - -static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo) -{ - u8 RateID, LowestRate, HighestRate; - u8 i; - - if (!pRaInfo) - return -1; - - RateID = pRaInfo->PreRate; - LowestRate = pRaInfo->LowestRate; - HighestRate = pRaInfo->HighestRate; - - if (RateID > HighestRate) { - RateID = HighestRate; - } else if (pRaInfo->RateSGI) { - pRaInfo->RateSGI = 0; - } else if (RateID > LowestRate) { - if (RateID > 0) { - for (i = RateID - 1; i > LowestRate; i--) { - if (pRaInfo->RAUseRate & BIT(i)) { - RateID = i; - goto RateDownFinish; - } - } - } - } else if (RateID <= LowestRate) { - RateID = LowestRate; - } -RateDownFinish: - if (pRaInfo->RAWaitingCounter == 1) { - pRaInfo->RAWaitingCounter += 1; - pRaInfo->RAPendingCounter += 1; - } else if (pRaInfo->RAWaitingCounter == 0) { - ; - } else { - pRaInfo->RAWaitingCounter = 0; - pRaInfo->RAPendingCounter = 0; - } - - if (pRaInfo->RAPendingCounter >= 4) - pRaInfo->RAPendingCounter = 4; - - pRaInfo->DecisionRate = RateID; - odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 2); - return 0; -} - -static int odm_RateUp_8188E(struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo) -{ - u8 RateID, HighestRate; - u8 i; - - if (!pRaInfo) - return -1; - - RateID = pRaInfo->PreRate; - HighestRate = pRaInfo->HighestRate; - if (pRaInfo->RAWaitingCounter == 1) { - pRaInfo->RAWaitingCounter = 0; - pRaInfo->RAPendingCounter = 0; - } else if (pRaInfo->RAWaitingCounter > 1) { - pRaInfo->PreRssiStaRA = pRaInfo->RssiStaRA; - goto RateUpfinish; - } - odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); - - if (RateID < HighestRate) { - for (i = RateID + 1; i <= HighestRate; i++) { - if (pRaInfo->RAUseRate & BIT(i)) { - RateID = i; - goto RateUpfinish; - } - } - } else if (RateID == HighestRate) { - if (pRaInfo->SGIEnable && (pRaInfo->RateSGI != 1)) - pRaInfo->RateSGI = 1; - else if ((pRaInfo->SGIEnable) != 1) - pRaInfo->RateSGI = 0; - } else { - RateID = HighestRate; - } -RateUpfinish: - if (pRaInfo->RAWaitingCounter == - (4 + PendingForRateUpFail[pRaInfo->RAPendingCounter])) - pRaInfo->RAWaitingCounter = 0; - else - pRaInfo->RAWaitingCounter++; - - pRaInfo->DecisionRate = RateID; - return 0; -} - -static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) -{ - u8 RateID; - - RateID = pRaInfo->DecisionRate; - pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID] + - N_THRESHOLD_LOW[RateID]) >> 1; - pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID] + - N_THRESHOLD_LOW[RateID]) >> 1; -} - -static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, - struct odm_ra_info *pRaInfo) -{ - u8 RateID = 0, RtyPtID = 0, PenaltyID1 = 0, PenaltyID2 = 0, i = 0; - /* u32 pool_retry; */ - static u8 DynamicTxRPTTimingCounter; - - if (pRaInfo->Active && (pRaInfo->TOTAL > 0)) { /* STA used and data packet exits */ - if ((pRaInfo->RssiStaRA < (pRaInfo->PreRssiStaRA - 3)) || - (pRaInfo->RssiStaRA > (pRaInfo->PreRssiStaRA + 3))) { - pRaInfo->RAWaitingCounter = 0; - pRaInfo->RAPendingCounter = 0; - } - /* Start RA decision */ - if (pRaInfo->PreRate > pRaInfo->HighestRate) - RateID = pRaInfo->HighestRate; - else - RateID = pRaInfo->PreRate; - if (pRaInfo->RssiStaRA > RSSI_THRESHOLD[RateID]) - RtyPtID = 0; - else - RtyPtID = 1; - PenaltyID1 = RETRY_PENALTY_IDX[RtyPtID][RateID]; /* TODO by page */ - - for (i = 0 ; i <= 4 ; i++) - pRaInfo->NscDown += pRaInfo->RTY[i] * RETRY_PENALTY[PenaltyID1][i]; - - if (pRaInfo->NscDown > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5])) - pRaInfo->NscDown -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID1][5]; - else - pRaInfo->NscDown = 0; - - /* rate up */ - PenaltyID2 = RETRY_PENALTY_UP_IDX[RateID]; - - for (i = 0 ; i <= 4 ; i++) - pRaInfo->NscUp += pRaInfo->RTY[i] * RETRY_PENALTY[PenaltyID2][i]; - - if (pRaInfo->NscUp > (pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5])) - pRaInfo->NscUp -= pRaInfo->TOTAL * RETRY_PENALTY[PenaltyID2][5]; - else - pRaInfo->NscUp = 0; - - if ((pRaInfo->NscDown < N_THRESHOLD_LOW[RateID]) || - (pRaInfo->DROP > DROPING_NECESSARY[RateID])) - odm_RateDown_8188E(dm_odm, pRaInfo); - else if (pRaInfo->NscUp > N_THRESHOLD_HIGH[RateID]) - odm_RateUp_8188E(dm_odm, pRaInfo); - - if (pRaInfo->DecisionRate > pRaInfo->HighestRate) - pRaInfo->DecisionRate = pRaInfo->HighestRate; - - if ((pRaInfo->DecisionRate) == (pRaInfo->PreRate)) - DynamicTxRPTTimingCounter += 1; - else - DynamicTxRPTTimingCounter = 0; - - if (DynamicTxRPTTimingCounter >= 4) { - odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 1); - DynamicTxRPTTimingCounter = 0; - } - - pRaInfo->PreRate = pRaInfo->DecisionRate; /* YJ, add, 120120 */ - - odm_ResetRaCounter_8188E(pRaInfo); - } -} - -static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info *pRaInfo) -{ /* Wilson 2011/10/26 */ - struct adapter *adapt = dm_odm->Adapter; - u32 MaskFromReg; - s8 i; - - switch (pRaInfo->RateID) { - case RATR_INX_WIRELESS_NGB: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff015; - break; - case RATR_INX_WIRELESS_NG: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff010; - break; - case RATR_INX_WIRELESS_NB: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff005; - break; - case RATR_INX_WIRELESS_N: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0f8ff000; - break; - case RATR_INX_WIRELESS_GB: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x00000ff5; - break; - case RATR_INX_WIRELESS_G: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x00000ff0; - break; - case RATR_INX_WIRELESS_B: - pRaInfo->RAUseRate = pRaInfo->RateMask & 0x0000000d; - break; - case 12: - MaskFromReg = usb_read32(adapt, REG_ARFR0); - pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; - break; - case 13: - MaskFromReg = usb_read32(adapt, REG_ARFR1); - pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; - break; - case 14: - MaskFromReg = usb_read32(adapt, REG_ARFR2); - pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; - break; - case 15: - MaskFromReg = usb_read32(adapt, REG_ARFR3); - pRaInfo->RAUseRate = pRaInfo->RateMask & MaskFromReg; - break; - default: - pRaInfo->RAUseRate = (pRaInfo->RateMask); - break; - } - /* Highest rate */ - if (pRaInfo->RAUseRate) { - for (i = RATESIZE; i >= 0; i--) { - if (pRaInfo->RAUseRate & BIT(i)) { - pRaInfo->HighestRate = i; - break; - } - } - } else { - pRaInfo->HighestRate = 0; - } - /* Lowest rate */ - if (pRaInfo->RAUseRate) { - for (i = 0; i < RATESIZE; i++) { - if ((pRaInfo->RAUseRate) & BIT(i)) { - pRaInfo->LowestRate = i; - break; - } - } - } else { - pRaInfo->LowestRate = 0; - } - - if (pRaInfo->HighestRate > 0x13) - pRaInfo->PTModeSS = 3; - else if (pRaInfo->HighestRate > 0x0b) - pRaInfo->PTModeSS = 2; - else if (pRaInfo->HighestRate > 0x03) - pRaInfo->PTModeSS = 1; - else - pRaInfo->PTModeSS = 0; - - if (pRaInfo->DecisionRate > pRaInfo->HighestRate) - pRaInfo->DecisionRate = pRaInfo->HighestRate; - - return 0; -} - -static void odm_PTTryState_8188E(struct odm_ra_info *pRaInfo) -{ - pRaInfo->PTTryState = 0; - switch (pRaInfo->PTModeSS) { - case 3: - if (pRaInfo->DecisionRate >= 0x19) - pRaInfo->PTTryState = 1; - break; - case 2: - if (pRaInfo->DecisionRate >= 0x11) - pRaInfo->PTTryState = 1; - break; - case 1: - if (pRaInfo->DecisionRate >= 0x0a) - pRaInfo->PTTryState = 1; - break; - case 0: - if (pRaInfo->DecisionRate >= 0x03) - pRaInfo->PTTryState = 1; - break; - default: - pRaInfo->PTTryState = 0; - break; - } - - if (pRaInfo->RssiStaRA < 48) { - pRaInfo->PTStage = 0; - } else if (pRaInfo->PTTryState == 1) { - if ((pRaInfo->PTStopCount >= 10) || - (pRaInfo->PTPreRssi > pRaInfo->RssiStaRA + 5) || - (pRaInfo->PTPreRssi < pRaInfo->RssiStaRA - 5) || - (pRaInfo->DecisionRate != pRaInfo->PTPreRate)) { - if (pRaInfo->PTStage == 0) - pRaInfo->PTStage = 1; - else if (pRaInfo->PTStage == 1) - pRaInfo->PTStage = 3; - else - pRaInfo->PTStage = 5; - - pRaInfo->PTPreRssi = pRaInfo->RssiStaRA; - pRaInfo->PTStopCount = 0; - } else { - pRaInfo->RAstage = 0; - pRaInfo->PTStopCount++; - } - } else { - pRaInfo->PTStage = 0; - pRaInfo->RAstage = 0; - } - pRaInfo->PTPreRate = pRaInfo->DecisionRate; -} - -static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) -{ - u8 j; - u8 temp_stage; - u32 numsc; - u32 num_total; - u8 stage_id; - - numsc = 0; - num_total = pRaInfo->TOTAL * PT_PENALTY[5]; - for (j = 0; j <= 4; j++) { - numsc += pRaInfo->RTY[j] * PT_PENALTY[j]; - if (numsc > num_total) - break; - } - - j >>= 1; - temp_stage = (pRaInfo->PTStage + 1) >> 1; - if (temp_stage > j) - stage_id = temp_stage - j; - else - stage_id = 0; - - pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor >> 1) + - (pRaInfo->PTSmoothFactor >> 2) + - stage_id * 16 + 2; - if (pRaInfo->PTSmoothFactor > 192) - pRaInfo->PTSmoothFactor = 192; - stage_id = pRaInfo->PTSmoothFactor >> 6; - temp_stage = stage_id * 2; - if (temp_stage != 0) - temp_stage -= 1; - if (pRaInfo->DROP > 3) - temp_stage = 0; - pRaInfo->PTStage = temp_stage; -} - -static void odm_RATxRPTTimerSetting(struct odm_dm_struct *dm_odm, - u16 minRptTime) -{ - if (dm_odm->CurrminRptTime != minRptTime) { - rtw_rpt_timer_cfg_cmd(dm_odm->Adapter, minRptTime); - dm_odm->CurrminRptTime = minRptTime; - } -} - -int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) -{ - struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid]; - u8 WirelessMode = 0xFF; /* invalid value */ - u8 max_rate_idx = 0x13; /* MCS7 */ - - if (dm_odm->pWirelessMode) - WirelessMode = *dm_odm->pWirelessMode; - - if (WirelessMode != 0xFF) { - if (WirelessMode & ODM_WM_N24G) - max_rate_idx = 0x13; - else if (WirelessMode & ODM_WM_G) - max_rate_idx = 0x0b; - else if (WirelessMode & ODM_WM_B) - max_rate_idx = 0x03; - } - - pRaInfo->DecisionRate = max_rate_idx; - pRaInfo->PreRate = max_rate_idx; - pRaInfo->HighestRate = max_rate_idx; - pRaInfo->LowestRate = 0; - pRaInfo->RateID = 0; - pRaInfo->RateMask = 0xffffffff; - pRaInfo->RssiStaRA = 0; - pRaInfo->PreRssiStaRA = 0; - pRaInfo->SGIEnable = 0; - pRaInfo->RAUseRate = 0xffffffff; - pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2; - pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2; - pRaInfo->RateSGI = 0; - pRaInfo->Active = 1; /* Active is not used at present. by page, 110819 */ - pRaInfo->RptTime = 0x927c; - pRaInfo->DROP = 0; - pRaInfo->RTY[0] = 0; - pRaInfo->RTY[1] = 0; - pRaInfo->RTY[2] = 0; - pRaInfo->RTY[3] = 0; - pRaInfo->RTY[4] = 0; - pRaInfo->TOTAL = 0; - pRaInfo->RAWaitingCounter = 0; - pRaInfo->RAPendingCounter = 0; - pRaInfo->PTActive = 1; /* Active when this STA is use */ - pRaInfo->PTTryState = 0; - pRaInfo->PTStage = 5; /* Need to fill into HW_PWR_STATUS */ - pRaInfo->PTSmoothFactor = 192; - pRaInfo->PTStopCount = 0; - pRaInfo->PTPreRate = 0; - pRaInfo->PTPreRssi = 0; - pRaInfo->PTModeSS = 0; - pRaInfo->RAstage = 0; - return 0; -} - -int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm) -{ - u8 macid = 0; - - dm_odm->CurrminRptTime = 0; - - for (macid = 0; macid < ODM_ASSOCIATE_ENTRY_NUM; macid++) - ODM_RAInfo_Init(dm_odm, macid); - - return 0; -} - -u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 macid) -{ - if ((!dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) - return 0; - return dm_odm->RAInfo[macid].RateSGI; -} - -u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 macid) -{ - u8 DecisionRate = 0; - - if ((!dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) - return 0; - DecisionRate = dm_odm->RAInfo[macid].DecisionRate; - return DecisionRate; -} - -u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 macid) -{ - u8 PTStage = 5; - - if ((!dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) - return 0; - PTStage = dm_odm->RAInfo[macid].PTStage; - return PTStage; -} - -void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 RateID, u32 RateMask, u8 SGIEnable) -{ - struct odm_ra_info *pRaInfo = NULL; - - if ((!dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) - return; - - pRaInfo = &dm_odm->RAInfo[macid]; - pRaInfo->RateID = RateID; - pRaInfo->RateMask = RateMask; - pRaInfo->SGIEnable = SGIEnable; - odm_ARFBRefresh_8188E(dm_odm, pRaInfo); -} - -void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) -{ - struct odm_ra_info *pRaInfo = NULL; - - if ((!dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) - return; - - pRaInfo = &dm_odm->RAInfo[macid]; - pRaInfo->RssiStaRA = Rssi; -} - -void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime) -{ - struct adapter *adapt = dm_odm->Adapter; - - usb_write16(adapt, REG_TX_RPT_TIME, minRptTime); -} - -void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 TxRPT_Len, u32 macid_entry0, u32 macid_entry1) -{ - struct odm_ra_info *pRAInfo = NULL; - u8 MacId = 0; - u8 *pBuffer = NULL; - u32 valid = 0, ItemNum = 0; - u16 minRptTime = 0x927c; - - ItemNum = TxRPT_Len >> 3; - pBuffer = TxRPT_Buf; - - do { - if (MacId >= ASSOCIATE_ENTRY_NUM) - valid = 0; - else if (MacId >= 32) - valid = (1 << (MacId - 32)) & macid_entry1; - else - valid = (1 << MacId) & macid_entry0; - - pRAInfo = &dm_odm->RAInfo[MacId]; - if (valid) { - pRAInfo->RTY[0] = (u16)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer); - pRAInfo->RTY[1] = (u16)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer); - pRAInfo->RTY[2] = (u16)GET_TX_REPORT_TYPE1_RERTY_2(pBuffer); - pRAInfo->RTY[3] = (u16)GET_TX_REPORT_TYPE1_RERTY_3(pBuffer); - pRAInfo->RTY[4] = (u16)GET_TX_REPORT_TYPE1_RERTY_4(pBuffer); - pRAInfo->DROP = (u16)GET_TX_REPORT_TYPE1_DROP_0(pBuffer); - pRAInfo->TOTAL = pRAInfo->RTY[0] + pRAInfo->RTY[1] + - pRAInfo->RTY[2] + pRAInfo->RTY[3] + - pRAInfo->RTY[4] + pRAInfo->DROP; - if (pRAInfo->TOTAL != 0) { - if (pRAInfo->PTActive) { - if (pRAInfo->RAstage < 5) - odm_RateDecision_8188E(dm_odm, pRAInfo); - else if (pRAInfo->RAstage == 5) /* Power training try state */ - odm_PTTryState_8188E(pRAInfo); - else /* RAstage == 6 */ - odm_PTDecision_8188E(pRAInfo); - - /* Stage_RA counter */ - if (pRAInfo->RAstage <= 5) - pRAInfo->RAstage++; - else - pRAInfo->RAstage = 0; - } else { - odm_RateDecision_8188E(dm_odm, pRAInfo); - } - } - } - - if (minRptTime > pRAInfo->RptTime) - minRptTime = pRAInfo->RptTime; - - pBuffer += TX_RPT2_ITEM_SIZE; - MacId++; - } while (MacId < ItemNum); - - odm_RATxRPTTimerSetting(dm_odm, minRptTime); -} diff --git a/drivers/staging/rtl8188eu/hal/hal_com.c b/drivers/staging/rtl8188eu/hal/hal_com.c deleted file mode 100644 index ebe19e076ff2..000000000000 --- a/drivers/staging/rtl8188eu/hal/hal_com.c +++ /dev/null @@ -1,285 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#include -#include - -#include -#include -#include - -#define _HAL_INIT_C_ - -void dump_chip_info(struct HAL_VERSION chip_vers) -{ - uint cnt = 0; - char buf[128]; - - cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_"); - cnt += sprintf((buf + cnt), "%s_", chip_vers.ChipType == NORMAL_CHIP ? - "Normal_Chip" : "Test_Chip"); - cnt += sprintf((buf + cnt), "%s_", chip_vers.VendorType == CHIP_VENDOR_TSMC ? - "TSMC" : "UMC"); - if (chip_vers.CUTVersion == A_CUT_VERSION) - cnt += sprintf((buf + cnt), "A_CUT_"); - else if (chip_vers.CUTVersion == B_CUT_VERSION) - cnt += sprintf((buf + cnt), "B_CUT_"); - else if (chip_vers.CUTVersion == C_CUT_VERSION) - cnt += sprintf((buf + cnt), "C_CUT_"); - else if (chip_vers.CUTVersion == D_CUT_VERSION) - cnt += sprintf((buf + cnt), "D_CUT_"); - else if (chip_vers.CUTVersion == E_CUT_VERSION) - cnt += sprintf((buf + cnt), "E_CUT_"); - else - cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", - chip_vers.CUTVersion); - cnt += sprintf((buf + cnt), "1T1R_"); - cnt += sprintf((buf + cnt), "RomVer(0)\n"); - - pr_info("%s", buf); -} - -#define CHAN_PLAN_HW 0x80 - -/* return the final channel plan decision */ -u8 hal_com_get_channel_plan(u8 hw_channel_plan, u8 sw_channel_plan, - u8 def_channel_plan, bool load_fail) -{ - u8 sw_cfg; - u8 chnlplan; - - sw_cfg = true; - if (!load_fail) { - if (!rtw_is_channel_plan_valid(sw_channel_plan)) - sw_cfg = false; - if (hw_channel_plan & CHAN_PLAN_HW) - sw_cfg = false; - } - - if (sw_cfg) - chnlplan = sw_channel_plan; - else - chnlplan = hw_channel_plan & (~CHAN_PLAN_HW); - - if (!rtw_is_channel_plan_valid(chnlplan)) - chnlplan = def_channel_plan; - - return chnlplan; -} - -u8 MRateToHwRate(u8 rate) -{ - u8 ret = DESC_RATE1M; - - switch (rate) { - /* CCK and OFDM non-HT rates */ - case IEEE80211_CCK_RATE_1MB: - ret = DESC_RATE1M; - break; - case IEEE80211_CCK_RATE_2MB: - ret = DESC_RATE2M; - break; - case IEEE80211_CCK_RATE_5MB: - ret = DESC_RATE5_5M; - break; - case IEEE80211_CCK_RATE_11MB: - ret = DESC_RATE11M; - break; - case IEEE80211_OFDM_RATE_6MB: - ret = DESC_RATE6M; - break; - case IEEE80211_OFDM_RATE_9MB: - ret = DESC_RATE9M; - break; - case IEEE80211_OFDM_RATE_12MB: - ret = DESC_RATE12M; - break; - case IEEE80211_OFDM_RATE_18MB: - ret = DESC_RATE18M; - break; - case IEEE80211_OFDM_RATE_24MB: - ret = DESC_RATE24M; - break; - case IEEE80211_OFDM_RATE_36MB: - ret = DESC_RATE36M; - break; - case IEEE80211_OFDM_RATE_48MB: - ret = DESC_RATE48M; - break; - case IEEE80211_OFDM_RATE_54MB: - ret = DESC_RATE54M; - break; - default: - break; - } - return ret; -} - -void hal_set_brate_cfg(u8 *brates, u16 *rate_cfg) -{ - u8 i, is_brate, brate; - - for (i = 0; i < NDIS_802_11_LENGTH_RATES_EX; i++) { - is_brate = brates[i] & IEEE80211_BASIC_RATE_MASK; - brate = brates[i] & 0x7f; - - if (is_brate) { - switch (brate) { - case IEEE80211_CCK_RATE_1MB: - *rate_cfg |= RATE_1M; - break; - case IEEE80211_CCK_RATE_2MB: - *rate_cfg |= RATE_2M; - break; - case IEEE80211_CCK_RATE_5MB: - *rate_cfg |= RATE_5_5M; - break; - case IEEE80211_CCK_RATE_11MB: - *rate_cfg |= RATE_11M; - break; - case IEEE80211_OFDM_RATE_6MB: - *rate_cfg |= RATE_6M; - break; - case IEEE80211_OFDM_RATE_9MB: - *rate_cfg |= RATE_9M; - break; - case IEEE80211_OFDM_RATE_12MB: - *rate_cfg |= RATE_12M; - break; - case IEEE80211_OFDM_RATE_18MB: - *rate_cfg |= RATE_18M; - break; - case IEEE80211_OFDM_RATE_24MB: - *rate_cfg |= RATE_24M; - break; - case IEEE80211_OFDM_RATE_36MB: - *rate_cfg |= RATE_36M; - break; - case IEEE80211_OFDM_RATE_48MB: - *rate_cfg |= RATE_48M; - break; - case IEEE80211_OFDM_RATE_54MB: - *rate_cfg |= RATE_54M; - break; - } - } - } -} - -static void one_out_pipe(struct adapter *adapter) -{ - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[0];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ -} - -static void two_out_pipe(struct adapter *adapter, bool wifi_cfg) -{ - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - - if (wifi_cfg) { - /* - * WMM - * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA - * 0, 1, 0, 1, 0, 0, 0, 0, 0 - * 0:H, 1:L - */ - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[1];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[0];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - } else { - /* - * typical setting - * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA - * 1, 1, 0, 0, 0, 0, 0, 0, 0 - * 0:H, 1:L - */ - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[0];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[1];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - } -} - -static void three_out_pipe(struct adapter *adapter, bool wifi_cfg) -{ - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapter); - - if (wifi_cfg) { - /* - * for WMM - * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA - * 1, 2, 1, 0, 0, 0, 0, 0, 0 - * 0:H, 1:N, 2:L - */ - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[1];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - } else { - /* - * typical setting - * BK, BE, VI, VO, BCN, CMD, MGT, HIGH, HCCA - * 2, 2, 1, 0, 0, 0, 0, 0, 0 - * 0:H, 1:N, 2:L - */ - pdvobjpriv->Queue2Pipe[0] = pdvobjpriv->RtOutPipe[0];/* VO */ - pdvobjpriv->Queue2Pipe[1] = pdvobjpriv->RtOutPipe[1];/* VI */ - pdvobjpriv->Queue2Pipe[2] = pdvobjpriv->RtOutPipe[2];/* BE */ - pdvobjpriv->Queue2Pipe[3] = pdvobjpriv->RtOutPipe[2];/* BK */ - - pdvobjpriv->Queue2Pipe[4] = pdvobjpriv->RtOutPipe[0];/* BCN */ - pdvobjpriv->Queue2Pipe[5] = pdvobjpriv->RtOutPipe[0];/* MGT */ - pdvobjpriv->Queue2Pipe[6] = pdvobjpriv->RtOutPipe[0];/* HIGH */ - pdvobjpriv->Queue2Pipe[7] = pdvobjpriv->RtOutPipe[0];/* TXCMD */ - } -} - -bool hal_mapping_out_pipe(struct adapter *adapter, u8 numoutpipe) -{ - struct registry_priv *pregistrypriv = &adapter->registrypriv; - bool wifi_cfg = (pregistrypriv->wifi_spec) ? true : false; - bool result = true; - - switch (numoutpipe) { - case 1: - one_out_pipe(adapter); - break; - case 2: - two_out_pipe(adapter, wifi_cfg); - break; - case 3: - three_out_pipe(adapter, wifi_cfg); - break; - default: - result = false; - } - return result; -} diff --git a/drivers/staging/rtl8188eu/hal/hal_intf.c b/drivers/staging/rtl8188eu/hal/hal_intf.c deleted file mode 100644 index 3e132e00c81c..000000000000 --- a/drivers/staging/rtl8188eu/hal/hal_intf.c +++ /dev/null @@ -1,59 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include - -uint rtw_hal_init(struct adapter *adapt) -{ - uint status = _SUCCESS; - - adapt->hw_init_completed = false; - - status = rtl8188eu_hal_init(adapt); - - if (status == _SUCCESS) { - adapt->hw_init_completed = true; - - if (adapt->registrypriv.notch_filter == 1) - rtw_hal_notch_filter(adapt, 1); - } else { - adapt->hw_init_completed = false; - } - - return status; -} - -uint rtw_hal_deinit(struct adapter *adapt) -{ - uint status = _SUCCESS; - - status = rtl8188eu_hal_deinit(adapt); - - if (status == _SUCCESS) - adapt->hw_init_completed = false; - - return status; -} - -void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) -{ - struct mlme_priv *pmlmepriv = &adapt->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { -#ifdef CONFIG_88EU_AP_MODE - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &adapt->stapriv; - - if (mac_id - 1 > 0) - psta = pstapriv->sta_aid[mac_id - 2]; - if (psta) - add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/ -#endif - } else { - UpdateHalRAMask8188EUsb(adapt, mac_id, rssi_level); - } -} diff --git a/drivers/staging/rtl8188eu/hal/odm.c b/drivers/staging/rtl8188eu/hal/odm.c deleted file mode 100644 index ffc5394d5bb9..000000000000 --- a/drivers/staging/rtl8188eu/hal/odm.c +++ /dev/null @@ -1,966 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include - -#include "odm_precomp.h" -#include "phy.h" - -/* avoid to warn in FreeBSD ==> To DO modify */ -static u32 EDCAParam[HT_IOT_PEER_MAX][3] = { - /* UL DL */ - {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 0:unknown AP */ - {0xa44f, 0x5ea44f, 0x5e431c}, /* 1:realtek AP */ - {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 2:unknown AP => realtek_92SE */ - {0x5ea32b, 0x5ea42b, 0x5e4322}, /* 3:broadcom AP */ - {0x5ea422, 0x00a44f, 0x00a44f}, /* 4:ralink AP */ - {0x5ea322, 0x00a630, 0x00a44f}, /* 5:atheros AP */ - {0x5e4322, 0x5e4322, 0x5e4322},/* 6:cisco AP */ - {0x5ea44f, 0x00a44f, 0x5ea42b}, /* 8:marvell AP */ - {0x5ea42b, 0x5ea42b, 0x5ea42b}, /* 10:unknown AP=> 92U AP */ - {0x5ea42b, 0xa630, 0x5e431c}, /* 11:airgocap AP */ -}; - -/* Global var */ -u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D] = { - 0x7f8001fe, /* 0, +6.0dB */ - 0x788001e2, /* 1, +5.5dB */ - 0x71c001c7, /* 2, +5.0dB */ - 0x6b8001ae, /* 3, +4.5dB */ - 0x65400195, /* 4, +4.0dB */ - 0x5fc0017f, /* 5, +3.5dB */ - 0x5a400169, /* 6, +3.0dB */ - 0x55400155, /* 7, +2.5dB */ - 0x50800142, /* 8, +2.0dB */ - 0x4c000130, /* 9, +1.5dB */ - 0x47c0011f, /* 10, +1.0dB */ - 0x43c0010f, /* 11, +0.5dB */ - 0x40000100, /* 12, +0dB */ - 0x3c8000f2, /* 13, -0.5dB */ - 0x390000e4, /* 14, -1.0dB */ - 0x35c000d7, /* 15, -1.5dB */ - 0x32c000cb, /* 16, -2.0dB */ - 0x300000c0, /* 17, -2.5dB */ - 0x2d4000b5, /* 18, -3.0dB */ - 0x2ac000ab, /* 19, -3.5dB */ - 0x288000a2, /* 20, -4.0dB */ - 0x26000098, /* 21, -4.5dB */ - 0x24000090, /* 22, -5.0dB */ - 0x22000088, /* 23, -5.5dB */ - 0x20000080, /* 24, -6.0dB */ - 0x1e400079, /* 25, -6.5dB */ - 0x1c800072, /* 26, -7.0dB */ - 0x1b00006c, /* 27. -7.5dB */ - 0x19800066, /* 28, -8.0dB */ - 0x18000060, /* 29, -8.5dB */ - 0x16c0005b, /* 30, -9.0dB */ - 0x15800056, /* 31, -9.5dB */ - 0x14400051, /* 32, -10.0dB */ - 0x1300004c, /* 33, -10.5dB */ - 0x12000048, /* 34, -11.0dB */ - 0x11000044, /* 35, -11.5dB */ - 0x10000040, /* 36, -12.0dB */ - 0x0f00003c,/* 37, -12.5dB */ - 0x0e400039,/* 38, -13.0dB */ - 0x0d800036,/* 39, -13.5dB */ - 0x0cc00033,/* 40, -14.0dB */ - 0x0c000030,/* 41, -14.5dB */ - 0x0b40002d,/* 42, -15.0dB */ -}; - -u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8] = { - {0x36, 0x35, 0x2e, 0x25, 0x1c, 0x12, 0x09, 0x04}, /* 0, +0dB */ - {0x33, 0x32, 0x2b, 0x23, 0x1a, 0x11, 0x08, 0x04}, /* 1, -0.5dB */ - {0x30, 0x2f, 0x29, 0x21, 0x19, 0x10, 0x08, 0x03}, /* 2, -1.0dB */ - {0x2d, 0x2d, 0x27, 0x1f, 0x18, 0x0f, 0x08, 0x03}, /* 3, -1.5dB */ - {0x2b, 0x2a, 0x25, 0x1e, 0x16, 0x0e, 0x07, 0x03}, /* 4, -2.0dB */ - {0x28, 0x28, 0x22, 0x1c, 0x15, 0x0d, 0x07, 0x03}, /* 5, -2.5dB */ - {0x26, 0x25, 0x21, 0x1b, 0x14, 0x0d, 0x06, 0x03}, /* 6, -3.0dB */ - {0x24, 0x23, 0x1f, 0x19, 0x13, 0x0c, 0x06, 0x03}, /* 7, -3.5dB */ - {0x22, 0x21, 0x1d, 0x18, 0x11, 0x0b, 0x06, 0x02}, /* 8, -4.0dB */ - {0x20, 0x20, 0x1b, 0x16, 0x11, 0x08, 0x05, 0x02}, /* 9, -4.5dB */ - {0x1f, 0x1e, 0x1a, 0x15, 0x10, 0x0a, 0x05, 0x02}, /* 10, -5.0dB */ - {0x1d, 0x1c, 0x18, 0x14, 0x0f, 0x0a, 0x05, 0x02}, /* 11, -5.5dB */ - {0x1b, 0x1a, 0x17, 0x13, 0x0e, 0x09, 0x04, 0x02}, /* 12, -6.0dB */ - {0x1a, 0x19, 0x16, 0x12, 0x0d, 0x09, 0x04, 0x02}, /* 13, -6.5dB */ - {0x18, 0x17, 0x15, 0x11, 0x0c, 0x08, 0x04, 0x02}, /* 14, -7.0dB */ - {0x17, 0x16, 0x13, 0x10, 0x0c, 0x08, 0x04, 0x02}, /* 15, -7.5dB */ - {0x16, 0x15, 0x12, 0x0f, 0x0b, 0x07, 0x04, 0x01}, /* 16, -8.0dB */ - {0x14, 0x14, 0x11, 0x0e, 0x0b, 0x07, 0x03, 0x02}, /* 17, -8.5dB */ - {0x13, 0x13, 0x10, 0x0d, 0x0a, 0x06, 0x03, 0x01}, /* 18, -9.0dB */ - {0x12, 0x12, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 19, -9.5dB */ - {0x11, 0x11, 0x0f, 0x0c, 0x09, 0x06, 0x03, 0x01}, /* 20, -10.0dB */ - {0x10, 0x10, 0x0e, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 21, -10.5dB */ - {0x0f, 0x0f, 0x0d, 0x0b, 0x08, 0x05, 0x03, 0x01}, /* 22, -11.0dB */ - {0x0e, 0x0e, 0x0c, 0x0a, 0x08, 0x05, 0x02, 0x01}, /* 23, -11.5dB */ - {0x0d, 0x0d, 0x0c, 0x0a, 0x07, 0x05, 0x02, 0x01}, /* 24, -12.0dB */ - {0x0d, 0x0c, 0x0b, 0x09, 0x07, 0x04, 0x02, 0x01}, /* 25, -12.5dB */ - {0x0c, 0x0c, 0x0a, 0x09, 0x06, 0x04, 0x02, 0x01}, /* 26, -13.0dB */ - {0x0b, 0x0b, 0x0a, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 27, -13.5dB */ - {0x0b, 0x0a, 0x09, 0x08, 0x06, 0x04, 0x02, 0x01}, /* 28, -14.0dB */ - {0x0a, 0x0a, 0x09, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 29, -14.5dB */ - {0x0a, 0x09, 0x08, 0x07, 0x05, 0x03, 0x02, 0x01}, /* 30, -15.0dB */ - {0x09, 0x09, 0x08, 0x06, 0x05, 0x03, 0x01, 0x01}, /* 31, -15.5dB */ - {0x09, 0x08, 0x07, 0x06, 0x04, 0x03, 0x01, 0x01} /* 32, -16.0dB */ -}; - -u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8] = { - {0x36, 0x35, 0x2e, 0x1b, 0x00, 0x00, 0x00, 0x00}, /* 0, +0dB */ - {0x33, 0x32, 0x2b, 0x19, 0x00, 0x00, 0x00, 0x00}, /* 1, -0.5dB */ - {0x30, 0x2f, 0x29, 0x18, 0x00, 0x00, 0x00, 0x00}, /* 2, -1.0dB */ - {0x2d, 0x2d, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00}, /* 3, -1.5dB */ - {0x2b, 0x2a, 0x25, 0x15, 0x00, 0x00, 0x00, 0x00}, /* 4, -2.0dB */ - {0x28, 0x28, 0x24, 0x14, 0x00, 0x00, 0x00, 0x00}, /* 5, -2.5dB */ - {0x26, 0x25, 0x21, 0x13, 0x00, 0x00, 0x00, 0x00}, /* 6, -3.0dB */ - {0x24, 0x23, 0x1f, 0x12, 0x00, 0x00, 0x00, 0x00}, /* 7, -3.5dB */ - {0x22, 0x21, 0x1d, 0x11, 0x00, 0x00, 0x00, 0x00}, /* 8, -4.0dB */ - {0x20, 0x20, 0x1b, 0x10, 0x00, 0x00, 0x00, 0x00}, /* 9, -4.5dB */ - {0x1f, 0x1e, 0x1a, 0x0f, 0x00, 0x00, 0x00, 0x00}, /* 10, -5.0dB */ - {0x1d, 0x1c, 0x18, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 11, -5.5dB */ - {0x1b, 0x1a, 0x17, 0x0e, 0x00, 0x00, 0x00, 0x00}, /* 12, -6.0dB */ - {0x1a, 0x19, 0x16, 0x0d, 0x00, 0x00, 0x00, 0x00}, /* 13, -6.5dB */ - {0x18, 0x17, 0x15, 0x0c, 0x00, 0x00, 0x00, 0x00}, /* 14, -7.0dB */ - {0x17, 0x16, 0x13, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 15, -7.5dB */ - {0x16, 0x15, 0x12, 0x0b, 0x00, 0x00, 0x00, 0x00}, /* 16, -8.0dB */ - {0x14, 0x14, 0x11, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 17, -8.5dB */ - {0x13, 0x13, 0x10, 0x0a, 0x00, 0x00, 0x00, 0x00}, /* 18, -9.0dB */ - {0x12, 0x12, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 19, -9.5dB */ - {0x11, 0x11, 0x0f, 0x09, 0x00, 0x00, 0x00, 0x00}, /* 20, -10.0dB */ - {0x10, 0x10, 0x0e, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 21, -10.5dB */ - {0x0f, 0x0f, 0x0d, 0x08, 0x00, 0x00, 0x00, 0x00}, /* 22, -11.0dB */ - {0x0e, 0x0e, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 23, -11.5dB */ - {0x0d, 0x0d, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00}, /* 24, -12.0dB */ - {0x0d, 0x0c, 0x0b, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 25, -12.5dB */ - {0x0c, 0x0c, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 26, -13.0dB */ - {0x0b, 0x0b, 0x0a, 0x06, 0x00, 0x00, 0x00, 0x00}, /* 27, -13.5dB */ - {0x0b, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 28, -14.0dB */ - {0x0a, 0x0a, 0x09, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 29, -14.5dB */ - {0x0a, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 30, -15.0dB */ - {0x09, 0x09, 0x08, 0x05, 0x00, 0x00, 0x00, 0x00}, /* 31, -15.5dB */ - {0x09, 0x08, 0x07, 0x04, 0x00, 0x00, 0x00, 0x00} /* 32, -16.0dB */ -}; - -#define RxDefaultAnt1 0x65a9 -#define RxDefaultAnt2 0x569a - -/* 3 Export Interface */ - -/* 2011/09/21 MH Add to describe different team necessary resource allocate?? */ -void ODM_DMInit(struct odm_dm_struct *pDM_Odm) -{ - /* 2012.05.03 Luke: For all IC series */ - odm_CommonInfoSelfInit(pDM_Odm); - odm_DIGInit(pDM_Odm); - odm_RateAdaptiveMaskInit(pDM_Odm); - - odm_DynamicTxPowerInit(pDM_Odm); - odm_TXPowerTrackingInit(pDM_Odm); - ODM_EdcaTurboInit(pDM_Odm); - ODM_RAInfo_Init_all(pDM_Odm); - if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || - (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || - (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) - odm_InitHybridAntDiv(pDM_Odm); -} - -/* 2011/09/20 MH This is the entry pointer for all team to execute HW out source DM. */ -/* You can not add any dummy function here, be care, you can only use DM structure */ -/* to perform any new ODM_DM. */ -void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) -{ - /* 2012.05.03 Luke: For all IC series */ - odm_CommonInfoSelfUpdate(pDM_Odm); - odm_FalseAlarmCounterStatistics(pDM_Odm); - odm_RSSIMonitorCheck(pDM_Odm); - - /* Fix Leave LPS issue */ - odm_DIG(pDM_Odm); - odm_CCKPacketDetectionThresh(pDM_Odm); - - if (*pDM_Odm->pbPowerSaving) - return; - - odm_RefreshRateAdaptiveMask(pDM_Odm); - - if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || - (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || - (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) - odm_HwAntDiv(pDM_Odm); - - ODM_TXPowerTrackingCheck(pDM_Odm); - odm_EdcaTurboCheck(pDM_Odm); -} - -void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, enum odm_common_info_def CmnInfo, u16 Index, void *pValue) -{ - if (CmnInfo == ODM_CMNINFO_STA_STATUS) - pDM_Odm->pODM_StaInfo[Index] = (struct sta_info *)pValue; -} - -void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *adapter = pDM_Odm->Adapter; - - pDM_Odm->bCckHighPower = (bool)phy_query_bb_reg(adapter, 0x824, BIT(9)); - pDM_Odm->RFPathRxEnable = (u8)phy_query_bb_reg(adapter, 0xc04, 0x0F); -} - -void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm) -{ - u8 EntryCnt = 0; - u8 i; - struct sta_info *pEntry; - - if (*pDM_Odm->pBandWidth == ODM_BW40M) { - if (*pDM_Odm->pSecChOffset == 1) - pDM_Odm->ControlChannel = *pDM_Odm->pChannel - 2; - else if (*pDM_Odm->pSecChOffset == 2) - pDM_Odm->ControlChannel = *pDM_Odm->pChannel + 2; - } else { - pDM_Odm->ControlChannel = *pDM_Odm->pChannel; - } - - for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { - pEntry = pDM_Odm->pODM_StaInfo[i]; - if (IS_STA_VALID(pEntry)) - EntryCnt++; - } - if (EntryCnt == 1) - pDM_Odm->bOneEntryOnly = true; - else - pDM_Odm->bOneEntryOnly = false; -} - -void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) -{ - struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - struct adapter *adapter = pDM_Odm->Adapter; - - if (pDM_DigTable->CurIGValue != CurrentIGI) { - phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N, CurrentIGI); - pDM_DigTable->CurIGValue = CurrentIGI; - } -} - -void odm_DIGInit(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *adapter = pDM_Odm->Adapter; - struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - - pDM_DigTable->CurIGValue = (u8)phy_query_bb_reg(adapter, ODM_REG_IGI_A_11N, ODM_BIT_IGI_11N); - pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; - pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; - pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; - pDM_DigTable->FAHighThresh = DM_false_ALARM_THRESH_HIGH; - pDM_DigTable->rx_gain_range_max = DM_DIG_MAX_NIC; - pDM_DigTable->rx_gain_range_min = DM_DIG_MIN_NIC; - pDM_DigTable->BackoffVal = DM_DIG_BACKOFF_DEFAULT; - pDM_DigTable->BackoffVal_range_max = DM_DIG_BACKOFF_MAX; - pDM_DigTable->BackoffVal_range_min = DM_DIG_BACKOFF_MIN; - pDM_DigTable->PreCCK_CCAThres = 0xFF; - pDM_DigTable->CurCCK_CCAThres = 0x83; - pDM_DigTable->ForbiddenIGI = DM_DIG_MIN_NIC; - pDM_DigTable->LargeFAHit = 0; - pDM_DigTable->Recover_cnt = 0; - pDM_DigTable->DIG_Dynamic_MIN_0 = DM_DIG_MIN_NIC; - pDM_DigTable->DIG_Dynamic_MIN_1 = DM_DIG_MIN_NIC; - pDM_DigTable->bMediaConnect_0 = false; - pDM_DigTable->bMediaConnect_1 = false; - - /* To Initialize pDM_Odm->bDMInitialGainEnable == false to avoid DIG error */ - pDM_Odm->bDMInitialGainEnable = true; -} - -void odm_DIG(struct odm_dm_struct *pDM_Odm) -{ - struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - struct false_alarm_stats *pFalseAlmCnt = &pDM_Odm->FalseAlmCnt; - u8 DIG_Dynamic_MIN; - u8 DIG_MaxOfMin; - bool FirstConnect, FirstDisConnect; - u8 dm_dig_max, dm_dig_min; - u8 CurrentIGI = pDM_DigTable->CurIGValue; - - if ((!(pDM_Odm->SupportAbility & ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) - return; - - if (*pDM_Odm->pbScanInProcess) - return; - - /* add by Neil Chen to avoid PSD is processing */ - if (!pDM_Odm->bDMInitialGainEnable) - return; - - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); - - /* 1 Boundary Decision */ - dm_dig_max = DM_DIG_MAX_NIC; - dm_dig_min = DM_DIG_MIN_NIC; - DIG_MaxOfMin = DM_DIG_MAX_AP; - - if (pDM_Odm->bLinked) { - /* 2 Modify DIG upper bound */ - if ((pDM_Odm->RSSI_Min + 20) > dm_dig_max) - pDM_DigTable->rx_gain_range_max = dm_dig_max; - else if ((pDM_Odm->RSSI_Min + 20) < dm_dig_min) - pDM_DigTable->rx_gain_range_max = dm_dig_min; - else - pDM_DigTable->rx_gain_range_max = pDM_Odm->RSSI_Min + 20; - /* 2 Modify DIG lower bound */ - if (pDM_Odm->bOneEntryOnly) { - if (pDM_Odm->RSSI_Min < dm_dig_min) - DIG_Dynamic_MIN = dm_dig_min; - else if (pDM_Odm->RSSI_Min > DIG_MaxOfMin) - DIG_Dynamic_MIN = DIG_MaxOfMin; - else - DIG_Dynamic_MIN = pDM_Odm->RSSI_Min; - } else if (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV) { - /* 1 Lower Bound for 88E AntDiv */ - if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) - DIG_Dynamic_MIN = (u8)pDM_DigTable->AntDiv_RSSI_max; - } else { - DIG_Dynamic_MIN = dm_dig_min; - } - } else { - pDM_DigTable->rx_gain_range_max = dm_dig_max; - DIG_Dynamic_MIN = dm_dig_min; - } - - /* 1 Modify DIG lower bound, deal with abnormally large false alarm */ - if (pFalseAlmCnt->Cnt_all > 10000) { - if (pDM_DigTable->LargeFAHit != 3) - pDM_DigTable->LargeFAHit++; - if (pDM_DigTable->ForbiddenIGI < CurrentIGI) { - pDM_DigTable->ForbiddenIGI = CurrentIGI; - pDM_DigTable->LargeFAHit = 1; - } - - if (pDM_DigTable->LargeFAHit >= 3) { - if ((pDM_DigTable->ForbiddenIGI + 1) > pDM_DigTable->rx_gain_range_max) - pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; - else - pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); - pDM_DigTable->Recover_cnt = 3600; /* 3600=2hr */ - } - - } else { - /* Recovery mechanism for IGI lower bound */ - if (pDM_DigTable->Recover_cnt != 0) { - pDM_DigTable->Recover_cnt--; - } else { - if (pDM_DigTable->LargeFAHit < 3) { - if ((pDM_DigTable->ForbiddenIGI - 1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ - pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ - pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ - } else { - pDM_DigTable->ForbiddenIGI--; - pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); - } - } else { - pDM_DigTable->LargeFAHit = 0; - } - } - } - - /* 1 Adjust initial gain by false alarm */ - if (pDM_Odm->bLinked) { - if (FirstConnect) { - CurrentIGI = pDM_Odm->RSSI_Min; - } else { - if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2) - CurrentIGI = CurrentIGI + 4;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ - else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1) - CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ - else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0) - CurrentIGI = CurrentIGI - 2;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ - } - } else { - if (FirstDisConnect) { - CurrentIGI = pDM_DigTable->rx_gain_range_min; - } else { - /* 2012.03.30 LukeLee: enable DIG before link but with very high thresholds */ - if (pFalseAlmCnt->Cnt_all > 10000) - CurrentIGI = CurrentIGI + 2;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+2; */ - else if (pFalseAlmCnt->Cnt_all > 8000) - CurrentIGI = CurrentIGI + 1;/* pDM_DigTable->CurIGValue = pDM_DigTable->PreIGValue+1; */ - else if (pFalseAlmCnt->Cnt_all < 500) - CurrentIGI = CurrentIGI - 1;/* pDM_DigTable->CurIGValue =pDM_DigTable->PreIGValue-1; */ - } - } - /* 1 Check initial gain by upper/lower bound */ - if (CurrentIGI > pDM_DigTable->rx_gain_range_max) - CurrentIGI = pDM_DigTable->rx_gain_range_max; - if (CurrentIGI < pDM_DigTable->rx_gain_range_min) - CurrentIGI = pDM_DigTable->rx_gain_range_min; - - /* 2 High power RSSI threshold */ - ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ - pDM_DigTable->bMediaConnect_0 = pDM_Odm->bLinked; - pDM_DigTable->DIG_Dynamic_MIN_0 = DIG_Dynamic_MIN; -} - -/* 3============================================================ */ -/* 3 FASLE ALARM CHECK */ -/* 3============================================================ */ - -void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *adapter = pDM_Odm->Adapter; - u32 ret_value; - struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; - - if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) - return; - - /* hold ofdm counter */ - phy_set_bb_reg(adapter, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1); /* hold page C counter */ - phy_set_bb_reg(adapter, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */ - - ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); - FalseAlmCnt->Cnt_Fast_Fsync = (ret_value & 0xffff); - FalseAlmCnt->Cnt_SB_Search_fail = (ret_value & 0xffff0000) >> 16; - ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); - FalseAlmCnt->Cnt_OFDM_CCA = (ret_value & 0xffff); - FalseAlmCnt->Cnt_Parity_Fail = (ret_value & 0xffff0000) >> 16; - ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value & 0xffff); - FalseAlmCnt->Cnt_Crc8_fail = (ret_value & 0xffff0000) >> 16; - ret_value = phy_query_bb_reg(adapter, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value & 0xffff); - - FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail; - - ret_value = phy_query_bb_reg(adapter, ODM_REG_SC_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_BW_LSC = (ret_value & 0xffff); - FalseAlmCnt->Cnt_BW_USC = (ret_value & 0xffff0000) >> 16; - - /* hold cck counter */ - phy_set_bb_reg(adapter, ODM_REG_CCK_FA_RST_11N, BIT(12), 1); - phy_set_bb_reg(adapter, ODM_REG_CCK_FA_RST_11N, BIT(14), 1); - - ret_value = phy_query_bb_reg(adapter, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); - FalseAlmCnt->Cnt_Cck_fail = ret_value; - ret_value = phy_query_bb_reg(adapter, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); - FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff) << 8; - - ret_value = phy_query_bb_reg(adapter, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_CCK_CCA = ((ret_value & 0xFF) << 8) | ((ret_value & 0xFF00) >> 8); - - FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + - FalseAlmCnt->Cnt_SB_Search_fail + - FalseAlmCnt->Cnt_Parity_Fail + - FalseAlmCnt->Cnt_Rate_Illegal + - FalseAlmCnt->Cnt_Crc8_fail + - FalseAlmCnt->Cnt_Mcs_fail + - FalseAlmCnt->Cnt_Cck_fail); - - FalseAlmCnt->Cnt_CCA_all = FalseAlmCnt->Cnt_OFDM_CCA + FalseAlmCnt->Cnt_CCK_CCA; -} - -/* 3============================================================ */ -/* 3 CCK Packet Detect Threshold */ -/* 3============================================================ */ - -void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) -{ - u8 CurCCK_CCAThres; - struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; - - if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD | ODM_BB_FA_CNT))) - return; - if (pDM_Odm->ExtLNA) - return; - if (pDM_Odm->bLinked) { - if (pDM_Odm->RSSI_Min > 25) { - CurCCK_CCAThres = 0xcd; - } else if (pDM_Odm->RSSI_Min > 10) { - CurCCK_CCAThres = 0x83; - } else { - if (FalseAlmCnt->Cnt_Cck_fail > 1000) - CurCCK_CCAThres = 0x83; - else - CurCCK_CCAThres = 0x40; - } - } else { - if (FalseAlmCnt->Cnt_Cck_fail > 1000) - CurCCK_CCAThres = 0x83; - else - CurCCK_CCAThres = 0x40; - } - ODM_Write_CCK_CCA_Thres(pDM_Odm, CurCCK_CCAThres); -} - -void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres) -{ - struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - struct adapter *adapt = pDM_Odm->Adapter; - - if (pDM_DigTable->CurCCK_CCAThres != CurCCK_CCAThres) /* modify by Guo.Mingzhi 2012-01-03 */ - usb_write8(adapt, ODM_REG_CCK_CCA_11N, CurCCK_CCAThres); - pDM_DigTable->PreCCK_CCAThres = pDM_DigTable->CurCCK_CCAThres; - pDM_DigTable->CurCCK_CCAThres = CurCCK_CCAThres; -} - -void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) -{ - struct adapter *adapter = pDM_Odm->Adapter; - struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; - u8 Rssi_Up_bound = 30; - u8 Rssi_Low_bound = 25; - - if (pDM_Odm->PatchID == 40) { /* RT_CID_819x_FUNAI_TV */ - Rssi_Up_bound = 50; - Rssi_Low_bound = 45; - } - if (pDM_PSTable->initialize == 0) { - pDM_PSTable->Reg874 = (phy_query_bb_reg(adapter, 0x874, bMaskDWord) & 0x1CC000) >> 14; - pDM_PSTable->RegC70 = (phy_query_bb_reg(adapter, 0xc70, bMaskDWord) & BIT(3)) >> 3; - pDM_PSTable->Reg85C = (phy_query_bb_reg(adapter, 0x85c, bMaskDWord) & 0xFF000000) >> 24; - pDM_PSTable->RegA74 = (phy_query_bb_reg(adapter, 0xa74, bMaskDWord) & 0xF000) >> 12; - pDM_PSTable->initialize = 1; - } - - if (!bForceInNormal) { - if (pDM_Odm->RSSI_Min != 0xFF) { - if (pDM_PSTable->PreRFState == RF_Normal) { - if (pDM_Odm->RSSI_Min >= Rssi_Up_bound) - pDM_PSTable->CurRFState = RF_Save; - else - pDM_PSTable->CurRFState = RF_Normal; - } else { - if (pDM_Odm->RSSI_Min <= Rssi_Low_bound) - pDM_PSTable->CurRFState = RF_Normal; - else - pDM_PSTable->CurRFState = RF_Save; - } - } else { - pDM_PSTable->CurRFState = RF_MAX; - } - } else { - pDM_PSTable->CurRFState = RF_Normal; - } - - if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { - if (pDM_PSTable->CurRFState == RF_Save) { - phy_set_bb_reg(adapter, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ - phy_set_bb_reg(adapter, 0xc70, BIT(3), 0); /* RegC70[3]=1'b0 */ - phy_set_bb_reg(adapter, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ - phy_set_bb_reg(adapter, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ - phy_set_bb_reg(adapter, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */ - phy_set_bb_reg(adapter, 0x818, BIT(28), 0x0); /* Reg818[28]=1'b0 */ - phy_set_bb_reg(adapter, 0x818, BIT(28), 0x1); /* Reg818[28]=1'b1 */ - } else { - phy_set_bb_reg(adapter, 0x874, 0x1CC000, pDM_PSTable->Reg874); - phy_set_bb_reg(adapter, 0xc70, BIT(3), pDM_PSTable->RegC70); - phy_set_bb_reg(adapter, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); - phy_set_bb_reg(adapter, 0xa74, 0xF000, pDM_PSTable->RegA74); - phy_set_bb_reg(adapter, 0x818, BIT(28), 0x0); - } - pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; - } -} - -/* 3============================================================ */ -/* 3 RATR MASK */ -/* 3============================================================ */ -/* 3============================================================ */ -/* 3 Rate Adaptive */ -/* 3============================================================ */ - -void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm) -{ - struct odm_rate_adapt *pOdmRA = &pDM_Odm->RateAdaptive; - - pOdmRA->Type = DM_Type_ByDriver; - if (pOdmRA->Type == DM_Type_ByDriver) - pDM_Odm->bUseRAMask = true; - else - pDM_Odm->bUseRAMask = false; - - pOdmRA->RATRState = DM_RATR_STA_INIT; - pOdmRA->HighRSSIThresh = 50; - pOdmRA->LowRSSIThresh = 20; -} - -u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u8 rssi_level) -{ - struct sta_info *pEntry; - u32 rate_bitmap = 0x0fffffff; - u8 WirelessMode; - - pEntry = pDM_Odm->pODM_StaInfo[macid]; - if (!IS_STA_VALID(pEntry)) - return ra_mask; - - WirelessMode = pEntry->wireless_mode; - - switch (WirelessMode) { - case ODM_WM_B: - if (ra_mask & 0x0000000c) /* 11M or 5.5M enable */ - rate_bitmap = 0x0000000d; - else - rate_bitmap = 0x0000000f; - break; - case (ODM_WM_A | ODM_WM_G): - if (rssi_level == DM_RATR_STA_HIGH) - rate_bitmap = 0x00000f00; - else - rate_bitmap = 0x00000ff0; - break; - case (ODM_WM_B | ODM_WM_G): - if (rssi_level == DM_RATR_STA_HIGH) - rate_bitmap = 0x00000f00; - else if (rssi_level == DM_RATR_STA_MIDDLE) - rate_bitmap = 0x00000ff0; - else - rate_bitmap = 0x00000ff5; - break; - case (ODM_WM_B | ODM_WM_G | ODM_WM_N24G): - case (ODM_WM_A | ODM_WM_B | ODM_WM_G | ODM_WM_N24G): - if (rssi_level == DM_RATR_STA_HIGH) { - rate_bitmap = 0x000f0000; - } else if (rssi_level == DM_RATR_STA_MIDDLE) { - rate_bitmap = 0x000ff000; - } else { - if (*pDM_Odm->pBandWidth == ODM_BW40M) - rate_bitmap = 0x000ff015; - else - rate_bitmap = 0x000ff005; - } - break; - default: - /* case WIRELESS_11_24N: */ - /* case WIRELESS_11_5N: */ - rate_bitmap = 0x0fffffff; - break; - } - - return rate_bitmap; -} - -/* Update rate table mask according to rssi */ -void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm) -{ - if (!(pDM_Odm->SupportAbility & ODM_BB_RA_MASK)) - return; - /* */ - /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ - /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ - /* HW dynamic mechanism. */ - /* */ - odm_RefreshRateAdaptiveMaskCE(pDM_Odm); -} - -void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm) -{ - u8 i; - struct adapter *pAdapter = pDM_Odm->Adapter; - - if (pAdapter->bDriverStopped) - return; - - if (!pDM_Odm->bUseRAMask) - return; - - for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { - struct sta_info *pstat = pDM_Odm->pODM_StaInfo[i]; - - if (IS_STA_VALID(pstat)) { - if (ODM_RAStateCheck(pDM_Odm, pstat->rssi_stat.UndecoratedSmoothedPWDB, false, &pstat->rssi_level)) - rtw_hal_update_ra_mask(pAdapter, i, pstat->rssi_level); - } - } -} - -/* Return Value: bool */ -/* - true: RATRState is changed. */ -bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, bool bForceUpdate, u8 *pRATRState) -{ - struct odm_rate_adapt *pRA = &pDM_Odm->RateAdaptive; - const u8 GoUpGap = 5; - u8 HighRSSIThreshForRA = pRA->HighRSSIThresh; - u8 LowRSSIThreshForRA = pRA->LowRSSIThresh; - u8 RATRState; - struct device *dev = dvobj_to_dev(adapter_to_dvobj(pDM_Odm->Adapter)); - - /* Threshold Adjustment: */ - /* when RSSI state trends to go up one or two levels, make sure RSSI is high enough. */ - /* Here GoUpGap is added to solve the boundary's level alternation issue. */ - switch (*pRATRState) { - case DM_RATR_STA_INIT: - case DM_RATR_STA_HIGH: - break; - case DM_RATR_STA_MIDDLE: - HighRSSIThreshForRA += GoUpGap; - break; - case DM_RATR_STA_LOW: - HighRSSIThreshForRA += GoUpGap; - LowRSSIThreshForRA += GoUpGap; - break; - default: - dev_err(dev, "%s(): wrong rssi level setting %d!\n", __func__, *pRATRState); - break; - } - - /* Decide RATRState by RSSI. */ - if (HighRSSIThreshForRA < RSSI) - RATRState = DM_RATR_STA_HIGH; - else if (LowRSSIThreshForRA < RSSI) - RATRState = DM_RATR_STA_MIDDLE; - else - RATRState = DM_RATR_STA_LOW; - - if (*pRATRState != RATRState || bForceUpdate) { - *pRATRState = RATRState; - return true; - } - return false; -} - -/* 3============================================================ */ -/* 3 Dynamic Tx Power */ -/* 3============================================================ */ - -void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - struct dm_priv *pdmpriv = &Adapter->HalData->dmpriv; - - pdmpriv->bDynamicTxPowerEnable = false; - pdmpriv->LastDTPLvl = TxHighPwrLevel_Normal; - pdmpriv->DynamicTxHighPowerLvl = TxHighPwrLevel_Normal; -} - -/* 3============================================================ */ -/* 3 RSSI Monitor */ -/* 3============================================================ */ - -void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm) -{ - if (!(pDM_Odm->SupportAbility & ODM_BB_RSSI_MONITOR)) - return; - - /* */ - /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ - /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ - /* HW dynamic mechanism. */ - /* */ - odm_RSSIMonitorCheckCE(pDM_Odm); -} /* odm_RSSIMonitorCheck */ - -static void FindMinimumRSSI(struct adapter *pAdapter) -{ - struct dm_priv *pdmpriv = &pAdapter->HalData->dmpriv; - - /* 1 1.Unconditionally set RSSI */ - pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; -} - -void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - struct dm_priv *pdmpriv = &Adapter->HalData->dmpriv; - int i; - int tmpEntryMaxPWDB = 0, tmpEntryMinPWDB = 0xff; - u8 sta_cnt = 0; - u32 PWDB_rssi[NUM_STA] = {0};/* 0~15]:MACID, [16~31]:PWDB_rssi */ - struct sta_info *psta; - - if (!check_fwstate(&Adapter->mlmepriv, _FW_LINKED)) - return; - - for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { - psta = pDM_Odm->pODM_StaInfo[i]; - if (IS_STA_VALID(psta) && - (psta->state & WIFI_ASOC_STATE) && - !is_broadcast_ether_addr(psta->hwaddr) && - memcmp(psta->hwaddr, myid(&Adapter->eeprompriv), ETH_ALEN)) { - if (psta->rssi_stat.UndecoratedSmoothedPWDB < tmpEntryMinPWDB) - tmpEntryMinPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; - - if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) - tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; - if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) - PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB << 16)); - } - } - - for (i = 0; i < sta_cnt; i++) { - if (PWDB_rssi[i] != 0) { - ODM_RA_SetRSSI_8188E(&Adapter->HalData->odmpriv, - PWDB_rssi[i] & 0xFF, - (PWDB_rssi[i] >> 16) & 0xFF); - } - } - - if (tmpEntryMaxPWDB != 0) /* If associated entry is found */ - pdmpriv->EntryMaxUndecoratedSmoothedPWDB = tmpEntryMaxPWDB; - else - pdmpriv->EntryMaxUndecoratedSmoothedPWDB = 0; - - if (tmpEntryMinPWDB != 0xff) /* If associated entry is found */ - pdmpriv->EntryMinUndecoratedSmoothedPWDB = tmpEntryMinPWDB; - else - pdmpriv->EntryMinUndecoratedSmoothedPWDB = 0; - - FindMinimumRSSI(Adapter); - Adapter->HalData->odmpriv.RSSI_Min = pdmpriv->MinUndecoratedPWDBForDM; -} - -/* 3============================================================ */ -/* 3 Tx Power Tracking */ -/* 3============================================================ */ - -void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm) -{ - pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; - pDM_Odm->RFCalibrateInfo.TXPowercount = 0; - if (*pDM_Odm->mp_mode != 1) - pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; - - pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; -} - -void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm) -{ - /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ - /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ - /* HW dynamic mechanism. */ - struct adapter *Adapter = pDM_Odm->Adapter; - - if (!(pDM_Odm->SupportAbility & ODM_RF_TX_PWR_TRACK)) - return; - - if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ - phy_set_rf_reg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT(17) | BIT(16), 0x03); - - pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; - return; - } - - rtl88eu_dm_txpower_tracking_callback_thermalmeter(Adapter); - pDM_Odm->RFCalibrateInfo.TM_Trigger = 0; -} - -/* 3============================================================ */ -/* 3 SW Antenna Diversity */ -/* 3============================================================ */ - -void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm) -{ - if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) - return; - - rtl88eu_dm_antenna_div_init(pDM_Odm); -} - -void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm) -{ - if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) - return; - - rtl88eu_dm_antenna_diversity(pDM_Odm); -} - -/* EDCA Turbo */ -void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - - pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; - pDM_Odm->DM_EDCA_Table.bIsCurRDLState = false; - Adapter->recvpriv.bIsAnyNonBEPkts = false; -} /* ODM_InitEdcaTurbo */ - -void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm) -{ - /* 2011/09/29 MH In HW integration first stage, we provide 4 different handle to operate */ - /* at the same time. In the stage2/3, we need to prive universal interface and merge all */ - /* HW dynamic mechanism. */ - if (!(pDM_Odm->SupportAbility & ODM_MAC_EDCA_TURBO)) - return; - - odm_EdcaTurboCheckCE(pDM_Odm); -} /* odm_CheckEdcaTurbo */ - -void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) -{ - struct adapter *Adapter = pDM_Odm->Adapter; - u32 trafficIndex; - u32 edca_param; - u64 cur_tx_bytes = 0; - u64 cur_rx_bytes = 0; - u8 bbtchange = false; - struct xmit_priv *pxmitpriv = &Adapter->xmitpriv; - struct recv_priv *precvpriv = &Adapter->recvpriv; - struct registry_priv *pregpriv = &Adapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (pregpriv->wifi_spec == 1) /* (pmlmeinfo->HT_enable == 0)) */ - goto dm_CheckEdcaTurbo_EXIT; - - if (pmlmeinfo->assoc_AP_vendor >= HT_IOT_PEER_MAX) - goto dm_CheckEdcaTurbo_EXIT; - - /* Check if the status needs to be changed. */ - if ((bbtchange) || (!precvpriv->bIsAnyNonBEPkts)) { - cur_tx_bytes = pxmitpriv->tx_bytes - pxmitpriv->last_tx_bytes; - cur_rx_bytes = precvpriv->rx_bytes - precvpriv->last_rx_bytes; - - /* traffic, TX or RX */ - if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) || - (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_ATHEROS)) { - if (cur_tx_bytes > (cur_rx_bytes << 2)) { - /* Uplink TP is present. */ - trafficIndex = UP_LINK; - } else { - /* Balance TP is present. */ - trafficIndex = DOWN_LINK; - } - } else { - if (cur_rx_bytes > (cur_tx_bytes << 2)) { - /* Downlink TP is present. */ - trafficIndex = DOWN_LINK; - } else { - /* Balance TP is present. */ - trafficIndex = UP_LINK; - } - } - - if ((pDM_Odm->DM_EDCA_Table.prv_traffic_idx != trafficIndex) || (!pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA)) { - if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_CISCO) && (pmlmeext->cur_wireless_mode & WIRELESS_11_24N)) - edca_param = EDCAParam[pmlmeinfo->assoc_AP_vendor][trafficIndex]; - else - edca_param = EDCAParam[HT_IOT_PEER_UNKNOWN][trafficIndex]; - - usb_write32(Adapter, REG_EDCA_BE_PARAM, edca_param); - - pDM_Odm->DM_EDCA_Table.prv_traffic_idx = trafficIndex; - } - - pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = true; - } else { - /* Turn Off EDCA turbo here. */ - /* Restore original EDCA according to the declaration of AP. */ - if (pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA) { - usb_write32(Adapter, REG_EDCA_BE_PARAM, - Adapter->HalData->AcParam_BE); - pDM_Odm->DM_EDCA_Table.bCurrentTurboEDCA = false; - } - } - -dm_CheckEdcaTurbo_EXIT: - /* Set variables for next time. */ - precvpriv->bIsAnyNonBEPkts = false; - pxmitpriv->last_tx_bytes = pxmitpriv->tx_bytes; - precvpriv->last_rx_bytes = precvpriv->rx_bytes; -} diff --git a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c b/drivers/staging/rtl8188eu/hal/odm_hwconfig.c deleted file mode 100644 index 684b6cec0f09..000000000000 --- a/drivers/staging/rtl8188eu/hal/odm_hwconfig.c +++ /dev/null @@ -1,397 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" - -#define READ_AND_CONFIG READ_AND_CONFIG_MP - -#define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig##txt##ic(dm_odm)) -#define READ_AND_CONFIG_TC(ic, txt) (ODM_ReadAndConfig_TC##txt##ic(dm_odm)) - -static u8 odm_query_rxpwrpercentage(s8 antpower) -{ - if ((antpower <= -100) || (antpower >= 20)) - return 0; - else if (antpower >= 0) - return 100; - else - return 100 + antpower; -} - -/* 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer. */ -/* IF other SW team do not support the feature, remove this section.?? */ -static s32 odm_signal_scale_mapping(struct odm_dm_struct *dm_odm, s32 currsig) -{ - s32 retsig = 0; - - if (currsig >= 51 && currsig <= 100) - retsig = 100; - else if (currsig >= 41 && currsig <= 50) - retsig = 80 + ((currsig - 40) * 2); - else if (currsig >= 31 && currsig <= 40) - retsig = 66 + (currsig - 30); - else if (currsig >= 21 && currsig <= 30) - retsig = 54 + (currsig - 20); - else if (currsig >= 10 && currsig <= 20) - retsig = 42 + (((currsig - 10) * 2) / 3); - else if (currsig >= 5 && currsig <= 9) - retsig = 22 + (((currsig - 5) * 3) / 2); - else if (currsig >= 1 && currsig <= 4) - retsig = 6 + (((currsig - 1) * 3) / 2); - else - retsig = currsig; - - return retsig; -} - -static u8 odm_evm_db_to_percentage(s8 value) -{ - /* -33dB~0dB to 0%~99% */ - s8 ret_val = clamp(-value, 0, 33) * 3; - - if (ret_val == 99) - ret_val = 100; - - return ret_val; -} - -static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, - struct odm_phy_status_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_per_pkt_info *pPktinfo) -{ - struct sw_ant_switch *pDM_SWAT_Table = &dm_odm->DM_SWAT_Table; - u8 i, max_spatial_stream; - s8 rx_pwr[4], rx_pwr_all = 0; - u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; - u8 RSSI, total_rssi = 0; - bool is_cck_rate; - u8 rf_rx_num = 0; - u8 cck_highpwr = 0; - u8 LNA_idx, VGA_idx; - - struct phy_status_rpt *pPhyStaRpt = (struct phy_status_rpt *)pPhyStatus; - - is_cck_rate = pPktinfo->Rate >= DESC92C_RATE1M && - pPktinfo->Rate <= DESC92C_RATE11M; - - pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = -1; - pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; - - if (is_cck_rate) { - u8 cck_agc_rpt; - - dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; - /* (1)Hardware does not provide RSSI for CCK */ - /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ - - cck_highpwr = dm_odm->bCckHighPower; - - cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a; - - /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ - /* The RSSI formula should be modified according to the gain table */ - /* In 88E, cck_highpwr is always set to 1 */ - LNA_idx = (cck_agc_rpt & 0xE0) >> 5; - VGA_idx = cck_agc_rpt & 0x1F; - switch (LNA_idx) { - case 7: - if (VGA_idx <= 27) - rx_pwr_all = -100 + 2 * (27 - VGA_idx); /* VGA_idx = 27~2 */ - else - rx_pwr_all = -100; - break; - case 6: - rx_pwr_all = -48 + 2 * (2 - VGA_idx); /* VGA_idx = 2~0 */ - break; - case 5: - rx_pwr_all = -42 + 2 * (7 - VGA_idx); /* VGA_idx = 7~5 */ - break; - case 4: - rx_pwr_all = -36 + 2 * (7 - VGA_idx); /* VGA_idx = 7~4 */ - break; - case 3: - rx_pwr_all = -24 + 2 * (7 - VGA_idx); /* VGA_idx = 7~0 */ - break; - case 2: - if (cck_highpwr) - rx_pwr_all = -12 + 2 * (5 - VGA_idx); /* VGA_idx = 5~0 */ - else - rx_pwr_all = -6 + 2 * (5 - VGA_idx); - break; - case 1: - rx_pwr_all = 8 - 2 * VGA_idx; - break; - case 0: - rx_pwr_all = 14 - 2 * VGA_idx; - break; - default: - break; - } - rx_pwr_all += 6; - PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all); - if (!cck_highpwr) { - if (PWDB_ALL >= 80) - PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80; - else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) - PWDB_ALL += 3; - if (PWDB_ALL > 100) - PWDB_ALL = 100; - } - - pPhyInfo->RxPWDBAll = PWDB_ALL; - pPhyInfo->BTRxRSSIPercentage = PWDB_ALL; - pPhyInfo->RecvSignalPower = rx_pwr_all; - /* (3) Get Signal Quality (EVM) */ - if (pPktinfo->bPacketMatchBSSID) { - u8 SQ, SQ_rpt; - - if (pPhyInfo->RxPWDBAll > 40 && !dm_odm->bInHctTest) { - SQ = 100; - } else { - SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all; - - if (SQ_rpt > 64) - SQ = 0; - else if (SQ_rpt < 20) - SQ = 100; - else - SQ = ((64 - SQ_rpt) * 100) / 44; - } - pPhyInfo->SignalQuality = SQ; - pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = SQ; - pPhyInfo->RxMIMOSignalQuality[RF_PATH_B] = -1; - } - } else { /* is OFDM rate */ - dm_odm->PhyDbgInfo.NumQryPhyStatusOFDM++; - - /* (1)Get RSSI for HT rate */ - - for (i = RF_PATH_A; i < RF_PATH_MAX; i++) { - /* 2008/01/30 MH we will judge RF RX path now. */ - if (dm_odm->RFPathRxEnable & BIT(i)) - rf_rx_num++; - - rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F) * 2) - 110; - - pPhyInfo->RxPwr[i] = rx_pwr[i]; - - /* Translate DBM to percentage. */ - RSSI = odm_query_rxpwrpercentage(rx_pwr[i]); - total_rssi += RSSI; - - /* Modification for ext-LNA board */ - if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { - if ((pPhyStaRpt->path_agc[i].trsw) == 1) - RSSI = (RSSI > 94) ? 100 : (RSSI + 6); - else - RSSI = (RSSI <= 16) ? (RSSI >> 3) : (RSSI - 16); - - if ((RSSI <= 34) && (RSSI >= 4)) - RSSI -= 4; - } - - pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; - - /* Get Rx snr value in DB */ - pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); - dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); - } - /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ - rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1) & 0x7f) - 110; - - PWDB_ALL = odm_query_rxpwrpercentage(rx_pwr_all); - PWDB_ALL_BT = PWDB_ALL; - - pPhyInfo->RxPWDBAll = PWDB_ALL; - pPhyInfo->BTRxRSSIPercentage = PWDB_ALL_BT; - pPhyInfo->RxPower = rx_pwr_all; - pPhyInfo->RecvSignalPower = rx_pwr_all; - - /* (3)EVM of HT rate */ - if (pPktinfo->Rate >= DESC92C_RATEMCS8 && pPktinfo->Rate <= DESC92C_RATEMCS15) - max_spatial_stream = 2; /* both spatial stream make sense */ - else - max_spatial_stream = 1; /* only spatial stream 1 makes sense */ - - for (i = 0; i < max_spatial_stream; i++) { - /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ - /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ - /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ - EVM = odm_evm_db_to_percentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ - - if (pPktinfo->bPacketMatchBSSID) { - if (i == RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ - pPhyInfo->SignalQuality = (u8)(EVM & 0xff); - pPhyInfo->RxMIMOSignalQuality[i] = (u8)(EVM & 0xff); - } - } - } - /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ - /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ - if (is_cck_rate) { - pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, PWDB_ALL));/* PWDB_ALL; */ - } else { - if (rf_rx_num != 0) - pPhyInfo->SignalStrength = (u8)(odm_signal_scale_mapping(dm_odm, total_rssi /= rf_rx_num)); - } - - /* For 92C/92D HW (Hybrid) Antenna Diversity */ - pDM_SWAT_Table->antsel = pPhyStaRpt->ant_sel; - /* For 88E HW Antenna Diversity */ - dm_odm->DM_FatTable.antsel_rx_keep_0 = pPhyStaRpt->ant_sel; - dm_odm->DM_FatTable.antsel_rx_keep_1 = pPhyStaRpt->ant_sel_b; - dm_odm->DM_FatTable.antsel_rx_keep_2 = pPhyStaRpt->antsel_rx_keep_2; -} - -static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, - struct odm_phy_status_info *pPhyInfo, - struct odm_per_pkt_info *pPktinfo) -{ - s32 UndecoratedSmoothedPWDB, UndecoratedSmoothedCCK; - s32 UndecoratedSmoothedOFDM, RSSI_Ave; - bool is_cck_rate; - u8 RSSI_max, RSSI_min, i; - u32 OFDM_pkt = 0; - u32 Weighting = 0; - struct sta_info *pEntry; - u8 antsel_tr_mux; - struct fast_ant_train *pDM_FatTable = &dm_odm->DM_FatTable; - - if (pPktinfo->StationID == 0xFF) - return; - pEntry = dm_odm->pODM_StaInfo[pPktinfo->StationID]; - if (!IS_STA_VALID(pEntry)) - return; - if ((!pPktinfo->bPacketMatchBSSID)) - return; - - is_cck_rate = pPktinfo->Rate >= DESC92C_RATE1M && - pPktinfo->Rate <= DESC92C_RATE11M; - - /* Smart Antenna Debug Message------------------ */ - - if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) { - if (pDM_FatTable->FAT_State == FAT_TRAINING_STATE) { - if (pPktinfo->bPacketToSelf) { - antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2 << 2) | - (pDM_FatTable->antsel_rx_keep_1 << 1) | - pDM_FatTable->antsel_rx_keep_0; - pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll; - pDM_FatTable->antRSSIcnt[antsel_tr_mux]++; - } - } - } else if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) { - if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { - antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2 << 2) | - (pDM_FatTable->antsel_rx_keep_1 << 1) | pDM_FatTable->antsel_rx_keep_0; - rtl88eu_dm_ant_sel_statistics(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll); - } - } - /* Smart Antenna Debug Message------------------ */ - - UndecoratedSmoothedCCK = pEntry->rssi_stat.UndecoratedSmoothedCCK; - UndecoratedSmoothedOFDM = pEntry->rssi_stat.UndecoratedSmoothedOFDM; - UndecoratedSmoothedPWDB = pEntry->rssi_stat.UndecoratedSmoothedPWDB; - - if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { - if (!is_cck_rate) { /* ofdm rate */ - if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_B] == 0) { - RSSI_Ave = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; - } else { - if (pPhyInfo->RxMIMOSignalStrength[RF_PATH_A] > pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]) { - RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; - RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]; - } else { - RSSI_max = pPhyInfo->RxMIMOSignalStrength[RF_PATH_B]; - RSSI_min = pPhyInfo->RxMIMOSignalStrength[RF_PATH_A]; - } - if ((RSSI_max - RSSI_min) < 3) - RSSI_Ave = RSSI_max; - else if ((RSSI_max - RSSI_min) < 6) - RSSI_Ave = RSSI_max - 1; - else if ((RSSI_max - RSSI_min) < 10) - RSSI_Ave = RSSI_max - 2; - else - RSSI_Ave = RSSI_max - 3; - } - - /* 1 Process OFDM RSSI */ - if (UndecoratedSmoothedOFDM <= 0) { /* initialize */ - UndecoratedSmoothedOFDM = pPhyInfo->RxPWDBAll; - } else { - if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) { - UndecoratedSmoothedOFDM = - (((UndecoratedSmoothedOFDM) * (Rx_Smooth_Factor - 1)) + - (RSSI_Ave)) / (Rx_Smooth_Factor); - UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1; - } else { - UndecoratedSmoothedOFDM = - (((UndecoratedSmoothedOFDM) * (Rx_Smooth_Factor - 1)) + - (RSSI_Ave)) / (Rx_Smooth_Factor); - } - } - - pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap << 1) | BIT(0); - - } else { - RSSI_Ave = pPhyInfo->RxPWDBAll; - - /* 1 Process CCK RSSI */ - if (UndecoratedSmoothedCCK <= 0) { /* initialize */ - UndecoratedSmoothedCCK = pPhyInfo->RxPWDBAll; - } else { - if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) { - UndecoratedSmoothedCCK = - ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor - 1)) + - pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; - UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1; - } else { - UndecoratedSmoothedCCK = - ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor - 1)) + - pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; - } - } - pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap << 1; - } - /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ - if (pEntry->rssi_stat.ValidBit >= 64) - pEntry->rssi_stat.ValidBit = 64; - else - pEntry->rssi_stat.ValidBit++; - - for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) - OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap >> i) & BIT(0); - - if (pEntry->rssi_stat.ValidBit == 64) { - Weighting = min_t(u32, OFDM_pkt << 4, 64); - UndecoratedSmoothedPWDB = (Weighting * UndecoratedSmoothedOFDM + (64 - Weighting) * UndecoratedSmoothedCCK) >> 6; - } else { - if (pEntry->rssi_stat.ValidBit != 0) - UndecoratedSmoothedPWDB = (OFDM_pkt * UndecoratedSmoothedOFDM + - (pEntry->rssi_stat.ValidBit - OFDM_pkt) * - UndecoratedSmoothedCCK) / pEntry->rssi_stat.ValidBit; - else - UndecoratedSmoothedPWDB = 0; - } - pEntry->rssi_stat.UndecoratedSmoothedCCK = UndecoratedSmoothedCCK; - pEntry->rssi_stat.UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM; - pEntry->rssi_stat.UndecoratedSmoothedPWDB = UndecoratedSmoothedPWDB; - } -} - -/* Endianness before calling this API */ -void odm_phy_status_query(struct odm_dm_struct *dm_odm, - struct odm_phy_status_info *phy_info, - u8 *phy_status, struct odm_per_pkt_info *pkt_info) -{ - odm_RxPhyStatus92CSeries_Parsing(dm_odm, phy_info, phy_status, pkt_info); - if (dm_odm->RSSI_test) - ;/* Select the packets to do RSSI checking for antenna switching. */ - else - odm_Process_RSSIForDM(dm_odm, phy_info, pkt_info); -} diff --git a/drivers/staging/rtl8188eu/hal/odm_rtl8188e.c b/drivers/staging/rtl8188eu/hal/odm_rtl8188e.c deleted file mode 100644 index e29cd35a5811..000000000000 --- a/drivers/staging/rtl8188eu/hal/odm_rtl8188e.c +++ /dev/null @@ -1,335 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" -#include "phy.h" - -static void dm_rx_hw_antena_div_init(struct odm_dm_struct *dm_odm) -{ - struct adapter *adapter = dm_odm->Adapter; - u32 value32; - - if (*dm_odm->mp_mode == 1) { - dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; - phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT(7), 0); - phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); - return; - } - - /* MAC Setting */ - value32 = phy_query_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - phy_set_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, - value32 | (BIT(23) | BIT(25))); - /* Pin Settings */ - phy_set_bb_reg(adapter, ODM_REG_PIN_CTRL_11N, BIT(9) | BIT(8), 0); - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0); - phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(22), 1); - phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); - /* OFDM Settings */ - phy_set_bb_reg(adapter, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, - 0x000000a0); - /* CCK Settings */ - phy_set_bb_reg(adapter, ODM_REG_BB_PWR_SAV4_11N, BIT(7), 1); - phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT(4), 1); - rtl88eu_dm_update_rx_idle_ant(dm_odm, MAIN_ANT); - phy_set_bb_reg(adapter, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201); -} - -static void dm_trx_hw_antenna_div_init(struct odm_dm_struct *dm_odm) -{ - struct adapter *adapter = dm_odm->Adapter; - u32 value32; - - if (*dm_odm->mp_mode == 1) { - dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; - phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT(7), 0); - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, - BIT(5) | BIT(4) | BIT(3), 0); - return; - } - - /* MAC Setting */ - value32 = phy_query_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - phy_set_bb_reg(adapter, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, - value32 | (BIT(23) | BIT(25))); - /* Pin Settings */ - phy_set_bb_reg(adapter, ODM_REG_PIN_CTRL_11N, BIT(9) | BIT(8), 0); - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0); - phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(22), 0); - phy_set_bb_reg(adapter, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); - /* OFDM Settings */ - phy_set_bb_reg(adapter, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, - 0x000000a0); - /* CCK Settings */ - phy_set_bb_reg(adapter, ODM_REG_BB_PWR_SAV4_11N, BIT(7), 1); - phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT(4), 1); - /* Tx Settings */ - phy_set_bb_reg(adapter, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 0); - rtl88eu_dm_update_rx_idle_ant(dm_odm, MAIN_ANT); - - /* antenna mapping table */ - if (!dm_odm->bIsMPChip) { /* testchip */ - phy_set_bb_reg(adapter, ODM_REG_RX_DEFAULT_A_11N, - BIT(10) | BIT(9) | BIT(8), 1); - phy_set_bb_reg(adapter, ODM_REG_RX_DEFAULT_A_11N, - BIT(13) | BIT(12) | BIT(11), 2); - } else { /* MPchip */ - phy_set_bb_reg(adapter, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, - 0x0201); - } -} - -static void dm_fast_training_init(struct odm_dm_struct *dm_odm) -{ - struct adapter *adapter = dm_odm->Adapter; - u32 value32, i; - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - - if (*dm_odm->mp_mode == 1) - return; - - for (i = 0; i < 6; i++) { - dm_fat_tbl->Bssid[i] = 0; - dm_fat_tbl->antSumRSSI[i] = 0; - dm_fat_tbl->antRSSIcnt[i] = 0; - dm_fat_tbl->antAveRSSI[i] = 0; - } - dm_fat_tbl->TrainIdx = 0; - dm_fat_tbl->FAT_State = FAT_NORMAL_STATE; - - /* MAC Setting */ - value32 = phy_query_bb_reg(adapter, 0x4c, bMaskDWord); - phy_set_bb_reg(adapter, 0x4c, bMaskDWord, - value32 | (BIT(23) | BIT(25))); - value32 = phy_query_bb_reg(adapter, 0x7B4, bMaskDWord); - phy_set_bb_reg(adapter, 0x7b4, bMaskDWord, - value32 | (BIT(16) | BIT(17))); - - /* Match MAC ADDR */ - phy_set_bb_reg(adapter, 0x7b4, 0xFFFF, 0); - phy_set_bb_reg(adapter, 0x7b0, bMaskDWord, 0); - - phy_set_bb_reg(adapter, 0x870, BIT(9) | BIT(8), 0); - phy_set_bb_reg(adapter, 0x864, BIT(10), 0); - phy_set_bb_reg(adapter, 0xb2c, BIT(22), 0); - phy_set_bb_reg(adapter, 0xb2c, BIT(31), 1); - phy_set_bb_reg(adapter, 0xca4, bMaskDWord, 0x000000a0); - - /* antenna mapping table */ - if (!dm_odm->bIsMPChip) { /* testchip */ - phy_set_bb_reg(adapter, 0x858, BIT(10) | BIT(9) | BIT(8), 1); - phy_set_bb_reg(adapter, 0x858, BIT(13) | BIT(12) | BIT(11), 2); - } else { /* MPchip */ - phy_set_bb_reg(adapter, 0x914, bMaskByte0, 1); - phy_set_bb_reg(adapter, 0x914, bMaskByte1, 2); - } - - /* Default Ant Setting when no fast training */ - phy_set_bb_reg(adapter, 0x80c, BIT(21), 1); - phy_set_bb_reg(adapter, 0x864, BIT(5) | BIT(4) | BIT(3), 0); - phy_set_bb_reg(adapter, 0x864, BIT(8) | BIT(7) | BIT(6), 1); - - /* Enter Traing state */ - phy_set_bb_reg(adapter, 0x864, BIT(2) | BIT(1) | BIT(0), 1); - phy_set_bb_reg(adapter, 0xc50, BIT(7), 1); -} - -void rtl88eu_dm_antenna_div_init(struct odm_dm_struct *dm_odm) -{ - if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) - dm_rx_hw_antena_div_init(dm_odm); - else if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - dm_trx_hw_antenna_div_init(dm_odm); - else if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) - dm_fast_training_init(dm_odm); -} - -void rtl88eu_dm_update_rx_idle_ant(struct odm_dm_struct *dm_odm, u8 ant) -{ - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - struct adapter *adapter = dm_odm->Adapter; - u32 default_ant, optional_ant; - - if (dm_fat_tbl->RxIdleAnt == ant) - return; - - if (ant == MAIN_ANT) { - default_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? - MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; - optional_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? - AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; - } else { - default_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? - AUX_ANT_CG_TRX : AUX_ANT_CGCS_RX; - optional_ant = (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) ? - MAIN_ANT_CG_TRX : MAIN_ANT_CGCS_RX; - } - - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, - BIT(5) | BIT(4) | BIT(3), default_ant); - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, - BIT(8) | BIT(7) | BIT(6), optional_ant); - phy_set_bb_reg(adapter, ODM_REG_ANTSEL_CTRL_11N, - BIT(14) | BIT(13) | BIT(12), default_ant); - phy_set_bb_reg(adapter, ODM_REG_RESP_TX_11N, - BIT(6) | BIT(7), default_ant); - } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, - BIT(5) | BIT(4) | BIT(3), default_ant); - phy_set_bb_reg(adapter, ODM_REG_RX_ANT_CTRL_11N, - BIT(8) | BIT(7) | BIT(6), optional_ant); - } - - dm_fat_tbl->RxIdleAnt = ant; -} - -static void update_tx_ant_88eu(struct odm_dm_struct *dm_odm, u8 ant, u32 mac_id) -{ - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - u8 target_ant; - - if (ant == MAIN_ANT) - target_ant = MAIN_ANT_CG_TRX; - else - target_ant = AUX_ANT_CG_TRX; - dm_fat_tbl->antsel_a[mac_id] = target_ant & BIT(0); - dm_fat_tbl->antsel_b[mac_id] = (target_ant & BIT(1)) >> 1; - dm_fat_tbl->antsel_c[mac_id] = (target_ant & BIT(2)) >> 2; -} - -void rtl88eu_dm_set_tx_ant_by_tx_info(struct odm_dm_struct *dm_odm, - u8 *desc, u8 mac_id) -{ - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - - if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || - (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV)) { - SET_TX_DESC_ANTSEL_A_88E(desc, dm_fat_tbl->antsel_a[mac_id]); - SET_TX_DESC_ANTSEL_B_88E(desc, dm_fat_tbl->antsel_b[mac_id]); - SET_TX_DESC_ANTSEL_C_88E(desc, dm_fat_tbl->antsel_c[mac_id]); - } -} - -void rtl88eu_dm_ant_sel_statistics(struct odm_dm_struct *dm_odm, - u8 antsel_tr_mux, u32 mac_id, u8 rx_pwdb_all) -{ - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - if (antsel_tr_mux == MAIN_ANT_CG_TRX) { - dm_fat_tbl->MainAnt_Sum[mac_id] += rx_pwdb_all; - dm_fat_tbl->MainAnt_Cnt[mac_id]++; - } else { - dm_fat_tbl->AuxAnt_Sum[mac_id] += rx_pwdb_all; - dm_fat_tbl->AuxAnt_Cnt[mac_id]++; - } - } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { - if (antsel_tr_mux == MAIN_ANT_CGCS_RX) { - dm_fat_tbl->MainAnt_Sum[mac_id] += rx_pwdb_all; - dm_fat_tbl->MainAnt_Cnt[mac_id]++; - } else { - dm_fat_tbl->AuxAnt_Sum[mac_id] += rx_pwdb_all; - dm_fat_tbl->AuxAnt_Cnt[mac_id]++; - } - } -} - -static void rtl88eu_dm_hw_ant_div(struct odm_dm_struct *dm_odm) -{ - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - struct rtw_dig *dig_table = &dm_odm->DM_DigTable; - struct sta_info *entry; - u32 i, min_rssi = 0xFF, ant_div_max_rssi = 0, max_rssi = 0; - u32 local_min_rssi, local_max_rssi; - u32 main_rssi, aux_rssi; - u8 RxIdleAnt = 0, target_ant = 7; - - for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { - entry = dm_odm->pODM_StaInfo[i]; - if (IS_STA_VALID(entry)) { - /* 2 Calculate RSSI per Antenna */ - main_rssi = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? - (dm_fat_tbl->MainAnt_Sum[i] / - dm_fat_tbl->MainAnt_Cnt[i]) : 0; - aux_rssi = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? - (dm_fat_tbl->AuxAnt_Sum[i] / - dm_fat_tbl->AuxAnt_Cnt[i]) : 0; - target_ant = (main_rssi >= aux_rssi) ? MAIN_ANT : AUX_ANT; - /* 2 Select max_rssi for DIG */ - local_max_rssi = max(main_rssi, aux_rssi); - if ((local_max_rssi > ant_div_max_rssi) && - (local_max_rssi < 40)) - ant_div_max_rssi = local_max_rssi; - if (local_max_rssi > max_rssi) - max_rssi = local_max_rssi; - - /* 2 Select RX Idle Antenna */ - if ((dm_fat_tbl->RxIdleAnt == MAIN_ANT) && - (main_rssi == 0)) - main_rssi = aux_rssi; - else if ((dm_fat_tbl->RxIdleAnt == AUX_ANT) && - (aux_rssi == 0)) - aux_rssi = main_rssi; - - local_min_rssi = min(main_rssi, aux_rssi); - if (local_min_rssi < min_rssi) { - min_rssi = local_min_rssi; - RxIdleAnt = target_ant; - } - /* 2 Select TRX Antenna */ - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - update_tx_ant_88eu(dm_odm, target_ant, i); - } - dm_fat_tbl->MainAnt_Sum[i] = 0; - dm_fat_tbl->AuxAnt_Sum[i] = 0; - dm_fat_tbl->MainAnt_Cnt[i] = 0; - dm_fat_tbl->AuxAnt_Cnt[i] = 0; - } - - /* 2 Set RX Idle Antenna */ - rtl88eu_dm_update_rx_idle_ant(dm_odm, RxIdleAnt); - - dig_table->AntDiv_RSSI_max = ant_div_max_rssi; - dig_table->RSSI_max = max_rssi; -} - -void rtl88eu_dm_antenna_diversity(struct odm_dm_struct *dm_odm) -{ - struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; - struct adapter *adapter = dm_odm->Adapter; - - if (!(dm_odm->SupportAbility & ODM_BB_ANT_DIV)) - return; - - if (!dm_odm->bLinked) { - if (dm_fat_tbl->bBecomeLinked) { - phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT(7), 0); - phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA1_11N, - BIT(15), 0); - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - phy_set_bb_reg(adapter, ODM_REG_TX_ANT_CTRL_11N, - BIT(21), 0); - dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; - } - return; - } - - if (!dm_fat_tbl->bBecomeLinked) { - phy_set_bb_reg(adapter, ODM_REG_IGI_A_11N, BIT(7), 1); - phy_set_bb_reg(adapter, ODM_REG_CCK_ANTDIV_PARA1_11N, - BIT(15), 1); - if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - phy_set_bb_reg(adapter, ODM_REG_TX_ANT_CTRL_11N, - BIT(21), 1); - dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; - } - - if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || - (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) - rtl88eu_dm_hw_ant_div(dm_odm); -} diff --git a/drivers/staging/rtl8188eu/hal/phy.c b/drivers/staging/rtl8188eu/hal/phy.c deleted file mode 100644 index 9067f23a23ff..000000000000 --- a/drivers/staging/rtl8188eu/hal/phy.c +++ /dev/null @@ -1,1112 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTL8188E_PHYCFG_C_ - -#include -#include -#include -#include -#include - -#define MAX_PRECMD_CNT 16 -#define MAX_RFDEPENDCMD_CNT 16 -#define MAX_POSTCMD_CNT 16 - -#define MAX_DOZE_WAITING_TIMES_9x 64 - -static u32 cal_bit_shift(u32 bitmask) -{ - u32 i; - - for (i = 0; i <= 31; i++) { - if (((bitmask >> i) & 0x1) == 1) - break; - } - return i; -} - -u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask) -{ - u32 original_value, bit_shift; - - original_value = usb_read32(adapt, regaddr); - bit_shift = cal_bit_shift(bitmask); - return (original_value & bitmask) >> bit_shift; -} - -void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data) -{ - u32 original_value, bit_shift; - - if (bitmask != bMaskDWord) { /* if not "double word" write */ - original_value = usb_read32(adapt, regaddr); - bit_shift = cal_bit_shift(bitmask); - data = (original_value & (~bitmask)) | (data << bit_shift); - } - - usb_write32(adapt, regaddr, data); -} - -static u32 rf_serial_read(struct adapter *adapt, enum rf_radio_path rfpath, u32 offset) -{ - u32 ret = 0; - struct bb_reg_def *phyreg = &adapt->HalData->PHYRegDef[rfpath]; - u32 tmplong, tmplong2; - u8 rfpi_enable = 0; - - offset &= 0xff; - - tmplong = phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord); - if (rfpath == RF_PATH_A) - tmplong2 = tmplong; - else - tmplong2 = phy_query_bb_reg(adapt, phyreg->rfHSSIPara2, - bMaskDWord); - - tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | - (offset << 23) | bLSSIReadEdge; - - phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter2, bMaskDWord, - tmplong & (~bLSSIReadEdge)); - udelay(10); - - phy_set_bb_reg(adapt, phyreg->rfHSSIPara2, bMaskDWord, tmplong2); - udelay(100); - - udelay(10); - - if (rfpath == RF_PATH_A) - rfpi_enable = (u8)phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, BIT(8)); - else if (rfpath == RF_PATH_B) - rfpi_enable = (u8)phy_query_bb_reg(adapt, rFPGA0_XB_HSSIParameter1, BIT(8)); - - if (rfpi_enable) - ret = phy_query_bb_reg(adapt, phyreg->rfLSSIReadBackPi, - bLSSIReadBackData); - else - ret = phy_query_bb_reg(adapt, phyreg->rfLSSIReadBack, - bLSSIReadBackData); - return ret; -} - -static void rf_serial_write(struct adapter *adapt, - enum rf_radio_path rfpath, u32 offset, - u32 data) -{ - u32 data_and_addr = 0; - struct bb_reg_def *phyreg = &adapt->HalData->PHYRegDef[rfpath]; - - offset &= 0xff; - data_and_addr = ((offset << 20) | (data & 0x000fffff)) & 0x0fffffff; - phy_set_bb_reg(adapt, phyreg->rf3wireOffset, bMaskDWord, data_and_addr); -} - -u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rf_path, - u32 reg_addr, u32 bit_mask) -{ - u32 original_value, bit_shift; - - original_value = rf_serial_read(adapt, rf_path, reg_addr); - bit_shift = cal_bit_shift(bit_mask); - return (original_value & bit_mask) >> bit_shift; -} - -void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path, - u32 reg_addr, u32 bit_mask, u32 data) -{ - u32 original_value, bit_shift; - - /* RF data is 12 bits only */ - if (bit_mask != bRFRegOffsetMask) { - original_value = rf_serial_read(adapt, rf_path, reg_addr); - bit_shift = cal_bit_shift(bit_mask); - data = (original_value & (~bit_mask)) | (data << bit_shift); - } - - rf_serial_write(adapt, rf_path, reg_addr, data); -} - -static void get_tx_power_index(struct adapter *adapt, u8 channel, u8 *cck_pwr, - u8 *ofdm_pwr, u8 *bw20_pwr, u8 *bw40_pwr) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - u8 index = (channel - 1); - u8 TxCount = 0, path_nums; - - path_nums = 1; - - for (TxCount = 0; TxCount < path_nums; TxCount++) { - if (TxCount == RF_PATH_A) { - cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + - hal_data->OFDM_24G_Diff[TxCount][RF_PATH_A]; - - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + - hal_data->BW20_24G_Diff[TxCount][RF_PATH_A]; - bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; - } else if (TxCount == RF_PATH_B) { - cck_pwr[TxCount] = hal_data->Index24G_CCK_Base[TxCount][index]; - ofdm_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + - hal_data->BW20_24G_Diff[RF_PATH_A][index] + - hal_data->BW20_24G_Diff[TxCount][index]; - - bw20_pwr[TxCount] = hal_data->Index24G_BW40_Base[RF_PATH_A][index] + - hal_data->BW20_24G_Diff[TxCount][RF_PATH_A] + - hal_data->BW20_24G_Diff[TxCount][index]; - bw40_pwr[TxCount] = hal_data->Index24G_BW40_Base[TxCount][index]; - } - } -} - -void phy_set_tx_power_level(struct adapter *adapt, u8 channel) -{ - u8 cck_pwr[MAX_TX_COUNT] = {0}; - u8 ofdm_pwr[MAX_TX_COUNT] = {0};/* [0]:RF-A, [1]:RF-B */ - u8 bw20_pwr[MAX_TX_COUNT] = {0}; - u8 bw40_pwr[MAX_TX_COUNT] = {0}; - - get_tx_power_index(adapt, channel, &cck_pwr[0], &ofdm_pwr[0], - &bw20_pwr[0], &bw40_pwr[0]); - - rtl88eu_phy_rf6052_set_cck_txpower(adapt, &cck_pwr[0]); - rtl88eu_phy_rf6052_set_ofdm_txpower(adapt, &ofdm_pwr[0], &bw20_pwr[0], - &bw40_pwr[0], channel); -} - -static void phy_set_bw_mode_callback(struct adapter *adapt) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - u8 reg_bw_opmode; - u8 reg_prsr_rsc; - - if (adapt->bDriverStopped) - return; - - /* Set MAC register */ - - reg_bw_opmode = usb_read8(adapt, REG_BWOPMODE); - reg_prsr_rsc = usb_read8(adapt, REG_RRSR + 2); - - switch (hal_data->CurrentChannelBW) { - case HT_CHANNEL_WIDTH_20: - reg_bw_opmode |= BW_OPMODE_20MHZ; - usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode); - break; - case HT_CHANNEL_WIDTH_40: - reg_bw_opmode &= ~BW_OPMODE_20MHZ; - usb_write8(adapt, REG_BWOPMODE, reg_bw_opmode); - reg_prsr_rsc = (reg_prsr_rsc & 0x90) | - (hal_data->nCur40MhzPrimeSC << 5); - usb_write8(adapt, REG_RRSR + 2, reg_prsr_rsc); - break; - default: - break; - } - - /* Set PHY related register */ - switch (hal_data->CurrentChannelBW) { - case HT_CHANNEL_WIDTH_20: - phy_set_bb_reg(adapt, rFPGA0_RFMOD, bRFMOD, 0x0); - phy_set_bb_reg(adapt, rFPGA1_RFMOD, bRFMOD, 0x0); - break; - case HT_CHANNEL_WIDTH_40: - phy_set_bb_reg(adapt, rFPGA0_RFMOD, bRFMOD, 0x1); - phy_set_bb_reg(adapt, rFPGA1_RFMOD, bRFMOD, 0x1); - /* Set Control channel to upper or lower. - * These settings are required only for 40MHz - */ - phy_set_bb_reg(adapt, rCCK0_System, bCCKSideBand, - (hal_data->nCur40MhzPrimeSC >> 1)); - phy_set_bb_reg(adapt, rOFDM1_LSTF, 0xC00, - hal_data->nCur40MhzPrimeSC); - phy_set_bb_reg(adapt, 0x818, (BIT(26) | BIT(27)), - (hal_data->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); - break; - default: - break; - } - - /* Set RF related register */ - rtl88eu_phy_rf6052_set_bandwidth(adapt, hal_data->CurrentChannelBW); -} - -void rtw_hal_set_bwmode(struct adapter *adapt, enum ht_channel_width bandwidth, - unsigned char offset) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - enum ht_channel_width tmp_bw = hal_data->CurrentChannelBW; - - hal_data->CurrentChannelBW = bandwidth; - hal_data->nCur40MhzPrimeSC = offset; - - if ((!adapt->bDriverStopped) && (!adapt->bSurpriseRemoved)) - phy_set_bw_mode_callback(adapt); - else - hal_data->CurrentChannelBW = tmp_bw; -} - -static void phy_sw_chnl_callback(struct adapter *adapt, u8 channel) -{ - u32 param1, param2; - struct hal_data_8188e *hal_data = adapt->HalData; - - phy_set_tx_power_level(adapt, channel); - - param1 = RF_CHNLBW; - param2 = channel; - hal_data->RfRegChnlVal[0] = (hal_data->RfRegChnlVal[0] & - 0xfffffc00) | param2; - phy_set_rf_reg(adapt, 0, param1, - bRFRegOffsetMask, hal_data->RfRegChnlVal[0]); -} - -void rtw_hal_set_chan(struct adapter *adapt, u8 channel) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - u8 tmpchannel = hal_data->CurrentChannel; - - if (channel == 0) - channel = 1; - - hal_data->CurrentChannel = channel; - - if ((!adapt->bDriverStopped) && (!adapt->bSurpriseRemoved)) - phy_sw_chnl_callback(adapt, channel); - else - hal_data->CurrentChannel = tmpchannel; -} - -#define ODM_TXPWRTRACK_MAX_IDX_88E 6 - -void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, u8 type, - u8 *direction, u32 *out_write_val) -{ - u8 pwr_value = 0; - /* Tx power tracking BB swing table. */ - if (type == 0) { /* For OFDM adjust */ - if (dm_odm->BbSwingIdxOfdm <= dm_odm->BbSwingIdxOfdmBase) { - *direction = 1; - pwr_value = dm_odm->BbSwingIdxOfdmBase - - dm_odm->BbSwingIdxOfdm; - } else { - *direction = 2; - pwr_value = dm_odm->BbSwingIdxOfdm - - dm_odm->BbSwingIdxOfdmBase; - } - } else if (type == 1) { /* For CCK adjust. */ - if (dm_odm->BbSwingIdxCck <= dm_odm->BbSwingIdxCckBase) { - *direction = 1; - pwr_value = dm_odm->BbSwingIdxCckBase - - dm_odm->BbSwingIdxCck; - } else { - *direction = 2; - pwr_value = dm_odm->BbSwingIdxCck - - dm_odm->BbSwingIdxCckBase; - } - } - - if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *direction == 1) - pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E; - - *out_write_val = pwr_value | (pwr_value << 8) | (pwr_value << 16) | - (pwr_value << 24); -} - -static void dm_txpwr_track_setpwr(struct odm_dm_struct *dm_odm) -{ - if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { - phy_set_tx_power_level(dm_odm->Adapter, *dm_odm->pChannel); - dm_odm->BbSwingFlagOfdm = false; - dm_odm->BbSwingFlagCck = false; - } -} - -void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - u8 thermal_val = 0, delta, delta_lck, delta_iqk, offset; - u8 thermal_avg_count = 0; - u32 thermal_avg = 0; - s32 ele_d, temp_cck; - s8 ofdm_index[2], cck_index = 0; - s8 ofdm_index_old[2] = {0, 0}, cck_index_old = 0; - u32 i = 0, j = 0; - - u8 ofdm_min_index = 6; /* OFDM BB Swing should be less than +3.0dB */ - s8 ofdm_index_mapping[2][index_mapping_NUM_88E] = { - /* 2.4G, decrease power */ - {0, 0, 2, 3, 4, 4, 5, 6, 7, 7, 8, 9, 10, 10, 11}, - /* 2.4G, increase power */ - {0, 0, -1, -2, -3, -4, -4, -4, -4, -5, -7, -8, -9, -9, -10}, - }; - u8 thermal_mapping[2][index_mapping_NUM_88E] = { - /* 2.4G, decrease power */ - {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 27}, - /* 2.4G, increase power */ - {0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 25, 25, 25}, - }; - struct odm_dm_struct *dm_odm = &hal_data->odmpriv; - - dm_txpwr_track_setpwr(dm_odm); - - dm_odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; - - dm_odm->RFCalibrateInfo.RegA24 = 0x090e1317; - - thermal_val = (u8)rtw_hal_read_rfreg(adapt, RF_PATH_A, - RF_T_METER_88E, 0xfc00); - - if (thermal_val) { - /* Query OFDM path A default setting */ - ele_d = phy_query_bb_reg(adapt, rOFDM0_XATxIQImbalance, bMaskDWord) & bMaskOFDM_D; - for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { - if (ele_d == (OFDMSwingTable[i] & bMaskOFDM_D)) { - ofdm_index_old[0] = (u8)i; - dm_odm->BbSwingIdxOfdmBase = (u8)i; - break; - } - } - - /* Query CCK default setting From 0xa24 */ - temp_cck = dm_odm->RFCalibrateInfo.RegA24; - - for (i = 0; i < CCK_TABLE_SIZE; i++) { - if ((dm_odm->RFCalibrateInfo.bCCKinCH14 && - memcmp(&temp_cck, &CCKSwingTable_Ch14[i][2], 4)) || - memcmp(&temp_cck, &CCKSwingTable_Ch1_Ch13[i][2], 4)) { - cck_index_old = (u8)i; - dm_odm->BbSwingIdxCckBase = (u8)i; - break; - } - } - - if (!dm_odm->RFCalibrateInfo.ThermalValue) { - dm_odm->RFCalibrateInfo.ThermalValue = hal_data->EEPROMThermalMeter; - dm_odm->RFCalibrateInfo.ThermalValue_LCK = thermal_val; - dm_odm->RFCalibrateInfo.ThermalValue_IQK = thermal_val; - - dm_odm->RFCalibrateInfo.OFDM_index[0] = ofdm_index_old[0]; - dm_odm->RFCalibrateInfo.CCK_index = cck_index_old; - } - - /* calculate average thermal meter */ - dm_odm->RFCalibrateInfo.ThermalValue_AVG[dm_odm->RFCalibrateInfo.ThermalValue_AVG_index] = thermal_val; - dm_odm->RFCalibrateInfo.ThermalValue_AVG_index++; - if (dm_odm->RFCalibrateInfo.ThermalValue_AVG_index == AVG_THERMAL_NUM_88E) - dm_odm->RFCalibrateInfo.ThermalValue_AVG_index = 0; - - for (i = 0; i < AVG_THERMAL_NUM_88E; i++) { - if (dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]) { - thermal_avg += dm_odm->RFCalibrateInfo.ThermalValue_AVG[i]; - thermal_avg_count++; - } - } - - if (thermal_avg_count) - thermal_val = (u8)(thermal_avg / thermal_avg_count); - - if (dm_odm->RFCalibrateInfo.bDoneTxpower && - !dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { - delta = abs(thermal_val - dm_odm->RFCalibrateInfo.ThermalValue); - } else { - delta = abs(thermal_val - hal_data->EEPROMThermalMeter); - if (dm_odm->RFCalibrateInfo.bReloadtxpowerindex) { - dm_odm->RFCalibrateInfo.bReloadtxpowerindex = false; - dm_odm->RFCalibrateInfo.bDoneTxpower = false; - } - } - - delta_lck = abs(dm_odm->RFCalibrateInfo.ThermalValue_LCK - thermal_val); - delta_iqk = abs(dm_odm->RFCalibrateInfo.ThermalValue_IQK - thermal_val); - - /* Delta temperature is equal to or larger than 20 centigrade.*/ - if ((delta_lck >= 8)) { - dm_odm->RFCalibrateInfo.ThermalValue_LCK = thermal_val; - rtl88eu_phy_lc_calibrate(adapt); - } - - if (delta > 0 && dm_odm->RFCalibrateInfo.TxPowerTrackControl) { - delta = abs(hal_data->EEPROMThermalMeter - thermal_val); - - /* calculate new OFDM / CCK offset */ - if (thermal_val > hal_data->EEPROMThermalMeter) - j = 1; - else - j = 0; - for (offset = 0; offset < index_mapping_NUM_88E; offset++) { - if (delta < thermal_mapping[j][offset]) { - if (offset != 0) - offset--; - break; - } - } - if (offset >= index_mapping_NUM_88E) - offset = index_mapping_NUM_88E - 1; - - /* Updating ofdm_index values with new OFDM / CCK offset */ - ofdm_index[0] = dm_odm->RFCalibrateInfo.OFDM_index[0] + ofdm_index_mapping[j][offset]; - if (ofdm_index[0] > OFDM_TABLE_SIZE_92D - 1) - ofdm_index[0] = OFDM_TABLE_SIZE_92D - 1; - else if (ofdm_index[0] < ofdm_min_index) - ofdm_index[0] = ofdm_min_index; - - cck_index = dm_odm->RFCalibrateInfo.CCK_index + ofdm_index_mapping[j][offset]; - if (cck_index > CCK_TABLE_SIZE - 1) - cck_index = CCK_TABLE_SIZE - 1; - else if (cck_index < 0) - cck_index = 0; - - /* 2 temporarily remove bNOPG */ - /* Config by SwingTable */ - if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) { - dm_odm->RFCalibrateInfo.bDoneTxpower = true; - - /* Revse TX power table. */ - dm_odm->BbSwingIdxOfdm = (u8)ofdm_index[0]; - dm_odm->BbSwingIdxCck = (u8)cck_index; - - if (dm_odm->BbSwingIdxOfdmCurrent != dm_odm->BbSwingIdxOfdm) { - dm_odm->BbSwingIdxOfdmCurrent = dm_odm->BbSwingIdxOfdm; - dm_odm->BbSwingFlagOfdm = true; - } - - if (dm_odm->BbSwingIdxCckCurrent != dm_odm->BbSwingIdxCck) { - dm_odm->BbSwingIdxCckCurrent = dm_odm->BbSwingIdxCck; - dm_odm->BbSwingFlagCck = true; - } - } - } - - /* Delta temperature is equal to or larger than 20 centigrade.*/ - if (delta_iqk >= 8) { - dm_odm->RFCalibrateInfo.ThermalValue_IQK = thermal_val; - rtl88eu_phy_iq_calibrate(adapt, false); - } - /* update thermal meter value */ - if (dm_odm->RFCalibrateInfo.TxPowerTrackControl) - dm_odm->RFCalibrateInfo.ThermalValue = thermal_val; - } - dm_odm->RFCalibrateInfo.TXPowercount = 0; -} - -#define MAX_TOLERANCE 5 - -static u8 phy_path_a_iqk(struct adapter *adapt, bool config_pathb) -{ - u32 reg_eac, reg_e94, reg_e9c; - u8 result = 0x00; - - /* 1 Tx IQK */ - /* path-A IQK setting */ - phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); - phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); - phy_set_bb_reg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x8214032a); - phy_set_bb_reg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160000); - - /* LO calibration setting */ - phy_set_bb_reg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x00462911); - - /* One shot, path A LOK & IQK */ - phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - mdelay(IQK_DELAY_TIME_88E); - - reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); - reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); - reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); - - if (!(reg_eac & BIT(28)) && - (((reg_e94 & 0x03FF0000) >> 16) != 0x142) && - (((reg_e9c & 0x03FF0000) >> 16) != 0x42)) - result |= 0x01; - return result; -} - -static u8 phy_path_a_rx_iqk(struct adapter *adapt, bool configPathB) -{ - u32 reg_eac, reg_e94, reg_e9c, reg_ea4, u4tmp; - u8 result = 0x00; - - /* 1 Get TXIMR setting */ - /* modify RXIQK mode table */ - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000); - phy_set_rf_reg(adapt, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); - phy_set_rf_reg(adapt, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); - phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); - phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf117B); - - /* PA,PAD off */ - phy_set_rf_reg(adapt, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x980); - phy_set_rf_reg(adapt, RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); - - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); - - /* IQK setting */ - phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, 0x01007c00); - phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x81004800); - - /* path-A IQK setting */ - phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x10008c1c); - phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x30008c1c); - phy_set_bb_reg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x82160c1f); - phy_set_bb_reg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160000); - - /* LO calibration setting */ - phy_set_bb_reg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); - - /* One shot, path A LOK & IQK */ - phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - /* delay x ms */ - mdelay(IQK_DELAY_TIME_88E); - - /* Check failed */ - reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); - reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); - reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); - - if (!(reg_eac & BIT(28)) && - (((reg_e94 & 0x03FF0000) >> 16) != 0x142) && - (((reg_e9c & 0x03FF0000) >> 16) != 0x42)) - result |= 0x01; - else /* if Tx not OK, ignore Rx */ - return result; - - u4tmp = 0x80007C00 | (reg_e94 & 0x3FF0000) | ((reg_e9c & 0x3FF0000) >> 16); - phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, u4tmp); - - /* 1 RX IQK */ - /* modify RXIQK mode table */ - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000); - phy_set_rf_reg(adapt, RF_PATH_A, RF_WE_LUT, bRFRegOffsetMask, 0x800a0); - phy_set_rf_reg(adapt, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); - phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0000f); - phy_set_rf_reg(adapt, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7ffa); - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); - - /* IQK setting */ - phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x01004800); - - /* path-A IQK setting */ - phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x38008c1c); - phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x18008c1c); - phy_set_bb_reg(adapt, rTx_IQK_PI_A, bMaskDWord, 0x82160c05); - phy_set_bb_reg(adapt, rRx_IQK_PI_A, bMaskDWord, 0x28160c1f); - - /* LO calibration setting */ - phy_set_bb_reg(adapt, rIQK_AGC_Rsp, bMaskDWord, 0x0046a911); - - phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf9000000); - phy_set_bb_reg(adapt, rIQK_AGC_Pts, bMaskDWord, 0xf8000000); - - mdelay(IQK_DELAY_TIME_88E); - - /* Check failed */ - reg_eac = phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, bMaskDWord); - reg_e94 = phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, bMaskDWord); - reg_e9c = phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, bMaskDWord); - reg_ea4 = phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, bMaskDWord); - - /* reload RF 0xdf */ - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x00000000); - phy_set_rf_reg(adapt, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); - - if (!(reg_eac & BIT(27)) && /* if Tx is OK, check whether Rx is OK */ - (((reg_ea4 & 0x03FF0000) >> 16) != 0x132) && - (((reg_eac & 0x03FF0000) >> 16) != 0x36)) - result |= 0x02; - - return result; -} - -static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], - u8 final_candidate, bool txonly) -{ - u32 oldval_0, x, tx0_a, reg; - s32 y, tx0_c; - - if (final_candidate == 0xFF) { - return; - } else if (iqkok) { - oldval_0 = (phy_query_bb_reg(adapt, rOFDM0_XATxIQImbalance, bMaskDWord) >> 22) & 0x3FF; - - x = result[final_candidate][0]; - if ((x & 0x00000200) != 0) - x = x | 0xFFFFFC00; - - tx0_a = (x * oldval_0) >> 8; - phy_set_bb_reg(adapt, rOFDM0_XATxIQImbalance, 0x3FF, tx0_a); - phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(31), - ((x * oldval_0 >> 7) & 0x1)); - - y = result[final_candidate][1]; - if ((y & 0x00000200) != 0) - y = y | 0xFFFFFC00; - - tx0_c = (y * oldval_0) >> 8; - phy_set_bb_reg(adapt, rOFDM0_XCTxAFE, 0xF0000000, - ((tx0_c & 0x3C0) >> 6)); - phy_set_bb_reg(adapt, rOFDM0_XATxIQImbalance, 0x003F0000, - (tx0_c & 0x3F)); - phy_set_bb_reg(adapt, rOFDM0_ECCAThreshold, BIT(29), - ((y * oldval_0 >> 7) & 0x1)); - - if (txonly) - return; - - reg = result[final_candidate][2]; - phy_set_bb_reg(adapt, rOFDM0_XARxIQImbalance, 0x3FF, reg); - - reg = result[final_candidate][3] & 0x3F; - phy_set_bb_reg(adapt, rOFDM0_XARxIQImbalance, 0xFC00, reg); - - reg = (result[final_candidate][3] >> 6) & 0xF; - phy_set_bb_reg(adapt, rOFDM0_RxIQExtAnta, 0xF0000000, reg); - } -} - -static void save_adda_registers(struct adapter *adapt, const u32 *addareg, - u32 *backup, u32 register_num) -{ - u32 i; - - for (i = 0; i < register_num; i++) - backup[i] = phy_query_bb_reg(adapt, addareg[i], bMaskDWord); -} - -static void save_mac_registers(struct adapter *adapt, const u32 *mac_reg, - u32 *backup) -{ - u32 i; - - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) - backup[i] = usb_read8(adapt, mac_reg[i]); - - backup[i] = usb_read32(adapt, mac_reg[i]); -} - -static void reload_adda_reg(struct adapter *adapt, const u32 *adda_reg, - u32 *backup, u32 regiester_num) -{ - u32 i; - - for (i = 0; i < regiester_num; i++) - phy_set_bb_reg(adapt, adda_reg[i], bMaskDWord, backup[i]); -} - -static void reload_mac_registers(struct adapter *adapt, const u32 *mac_reg, - u32 *backup) -{ - u32 i; - - for (i = 0; i < (IQK_MAC_REG_NUM - 1); i++) - usb_write8(adapt, mac_reg[i], (u8)backup[i]); - - usb_write32(adapt, mac_reg[i], backup[i]); -} - -static void path_adda_on(struct adapter *adapt, const u32 *adda_reg, bool is_path_a_on) -{ - u32 path_on; - u32 i; - - path_on = 0x0bdb25a0; - phy_set_bb_reg(adapt, adda_reg[0], bMaskDWord, 0x0b1b25a0); - - for (i = 1; i < IQK_ADDA_REG_NUM; i++) - phy_set_bb_reg(adapt, adda_reg[i], bMaskDWord, path_on); -} - -static void mac_setting_calibration(struct adapter *adapt, const u32 *mac_reg, - u32 *backup) -{ - u32 i = 0; - - usb_write8(adapt, mac_reg[i], 0x3F); - - for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) - usb_write8(adapt, mac_reg[i], (u8)(backup[i] & (~BIT(3)))); - - usb_write8(adapt, mac_reg[i], (u8)(backup[i] & (~BIT(5)))); -} - -static void pi_mode_switch(struct adapter *adapt, bool pi_mode) -{ - u32 mode; - - mode = pi_mode ? 0x01000100 : 0x01000000; - phy_set_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, bMaskDWord, mode); - phy_set_bb_reg(adapt, rFPGA0_XB_HSSIParameter1, bMaskDWord, mode); -} - -static bool simularity_compare(struct adapter *adapt, s32 resulta[][8], - u8 c1, u8 c2) -{ - u32 i, j, diff, sim_bitmap = 0, bound; - u8 final_candidate[2] = {0xFF, 0xFF}; /* for path A and path B */ - bool result = true; - s32 tmp1 = 0, tmp2 = 0; - - bound = 4; - - for (i = 0; i < bound; i++) { - if ((i == 1) || (i == 3) || (i == 5) || (i == 7)) { - if ((resulta[c1][i] & 0x00000200) != 0) - tmp1 = resulta[c1][i] | 0xFFFFFC00; - else - tmp1 = resulta[c1][i]; - - if ((resulta[c2][i] & 0x00000200) != 0) - tmp2 = resulta[c2][i] | 0xFFFFFC00; - else - tmp2 = resulta[c2][i]; - } else { - tmp1 = resulta[c1][i]; - tmp2 = resulta[c2][i]; - } - - diff = abs(tmp1 - tmp2); - - if (diff > MAX_TOLERANCE) { - if ((i == 2 || i == 6) && !sim_bitmap) { - if (resulta[c1][i] + resulta[c1][i + 1] == 0) - final_candidate[(i / 4)] = c2; - else if (resulta[c2][i] + resulta[c2][i + 1] == 0) - final_candidate[(i / 4)] = c1; - else - sim_bitmap = sim_bitmap | (1 << i); - } else { - sim_bitmap = sim_bitmap | (1 << i); - } - } - } - - if (sim_bitmap == 0) { - for (i = 0; i < (bound / 4); i++) { - if (final_candidate[i] != 0xFF) { - for (j = i * 4; j < (i + 1) * 4 - 2; j++) - resulta[3][j] = resulta[final_candidate[i]][j]; - result = false; - } - } - return result; - } - - if (!(sim_bitmap & 0x03)) { /* path A TX OK */ - for (i = 0; i < 2; i++) - resulta[3][i] = resulta[c1][i]; - } - if (!(sim_bitmap & 0x0c)) { /* path A RX OK */ - for (i = 2; i < 4; i++) - resulta[3][i] = resulta[c1][i]; - } - - if (!(sim_bitmap & 0x30)) { /* path B TX OK */ - for (i = 4; i < 6; i++) - resulta[3][i] = resulta[c1][i]; - } - - if (!(sim_bitmap & 0xc0)) { /* path B RX OK */ - for (i = 6; i < 8; i++) - resulta[3][i] = resulta[c1][i]; - } - return false; -} - -static void phy_iq_calibrate(struct adapter *adapt, s32 result[][8], - u8 t) -{ - struct odm_dm_struct *dm_odm = &adapt->HalData->odmpriv; - u32 i; - u8 path_a_ok; - static const u32 adda_reg[IQK_ADDA_REG_NUM] = { - rFPGA0_XCD_SwitchControl, rBlue_Tooth, - rRx_Wait_CCA, rTx_CCK_RFON, - rTx_CCK_BBON, rTx_OFDM_RFON, - rTx_OFDM_BBON, rTx_To_Rx, - rTx_To_Tx, rRx_CCK, - rRx_OFDM, rRx_Wait_RIFS, - rRx_TO_Rx, rStandby, - rSleep, rPMPD_ANAEN - }; - static const u32 iqk_mac_reg[IQK_MAC_REG_NUM] = { - REG_TXPAUSE, REG_BCN_CTRL, - REG_BCN_CTRL_1, REG_GPIO_MUXCFG - }; - /* since 92C & 92D have the different define in IQK_BB_REG */ - static const u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { - rOFDM0_TRxPathEnable, rOFDM0_TRMuxPar, - rFPGA0_XCD_RFInterfaceSW, rConfig_AntA, rConfig_AntB, - rFPGA0_XAB_RFInterfaceSW, rFPGA0_XA_RFInterfaceOE, - rFPGA0_XB_RFInterfaceOE, rFPGA0_RFMOD - }; - - u32 retry_count = 9; - - if (*dm_odm->mp_mode == 1) - retry_count = 9; - else - retry_count = 2; - - if (t == 0) { - /* Save ADDA parameters, turn Path A ADDA on */ - save_adda_registers(adapt, adda_reg, dm_odm->RFCalibrateInfo.ADDA_backup, - IQK_ADDA_REG_NUM); - save_mac_registers(adapt, iqk_mac_reg, - dm_odm->RFCalibrateInfo.IQK_MAC_backup); - save_adda_registers(adapt, iqk_bb_reg_92c, - dm_odm->RFCalibrateInfo.IQK_BB_backup, IQK_BB_REG_NUM); - } - - path_adda_on(adapt, adda_reg, true); - if (t == 0) - dm_odm->RFCalibrateInfo.bRfPiEnable = (u8)phy_query_bb_reg(adapt, rFPGA0_XA_HSSIParameter1, - BIT(8)); - - if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { - /* Switch BB to PI mode to do IQ Calibration. */ - pi_mode_switch(adapt, true); - } - - /* BB setting */ - phy_set_bb_reg(adapt, rFPGA0_RFMOD, BIT(24), 0x00); - phy_set_bb_reg(adapt, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); - phy_set_bb_reg(adapt, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); - phy_set_bb_reg(adapt, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); - - phy_set_bb_reg(adapt, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0x01); - phy_set_bb_reg(adapt, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0x01); - phy_set_bb_reg(adapt, rFPGA0_XA_RFInterfaceOE, BIT(10), 0x00); - phy_set_bb_reg(adapt, rFPGA0_XB_RFInterfaceOE, BIT(10), 0x00); - - /* MAC settings */ - mac_setting_calibration(adapt, iqk_mac_reg, - dm_odm->RFCalibrateInfo.IQK_MAC_backup); - - /* Page B init */ - /* AP or IQK */ - phy_set_bb_reg(adapt, rConfig_AntA, bMaskDWord, 0x0f600000); - - /* IQ calibration setting */ - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0x80800000); - phy_set_bb_reg(adapt, rTx_IQK, bMaskDWord, 0x01007c00); - phy_set_bb_reg(adapt, rRx_IQK, bMaskDWord, 0x81004800); - - for (i = 0; i < retry_count; i++) { - path_a_ok = phy_path_a_iqk(adapt, false); - if (path_a_ok == 0x01) { - result[t][0] = (phy_query_bb_reg(adapt, rTx_Power_Before_IQK_A, - bMaskDWord) & 0x3FF0000) >> 16; - result[t][1] = (phy_query_bb_reg(adapt, rTx_Power_After_IQK_A, - bMaskDWord) & 0x3FF0000) >> 16; - break; - } - } - - for (i = 0; i < retry_count; i++) { - path_a_ok = phy_path_a_rx_iqk(adapt, false); - if (path_a_ok == 0x03) { - result[t][2] = (phy_query_bb_reg(adapt, rRx_Power_Before_IQK_A_2, - bMaskDWord) & 0x3FF0000) >> 16; - result[t][3] = (phy_query_bb_reg(adapt, rRx_Power_After_IQK_A_2, - bMaskDWord) & 0x3FF0000) >> 16; - break; - } - } - - /* Back to BB mode, load original value */ - phy_set_bb_reg(adapt, rFPGA0_IQK, bMaskDWord, 0); - - if (t != 0) { - if (!dm_odm->RFCalibrateInfo.bRfPiEnable) { - /* Switch back BB to SI mode after - * finish IQ Calibration. - */ - pi_mode_switch(adapt, false); - } - - /* Reload ADDA power saving parameters */ - reload_adda_reg(adapt, adda_reg, dm_odm->RFCalibrateInfo.ADDA_backup, - IQK_ADDA_REG_NUM); - - /* Reload MAC parameters */ - reload_mac_registers(adapt, iqk_mac_reg, - dm_odm->RFCalibrateInfo.IQK_MAC_backup); - - reload_adda_reg(adapt, iqk_bb_reg_92c, dm_odm->RFCalibrateInfo.IQK_BB_backup, - IQK_BB_REG_NUM); - - /* Restore RX initial gain */ - phy_set_bb_reg(adapt, rFPGA0_XA_LSSIParameter, - bMaskDWord, 0x00032ed3); - - /* load 0xe30 IQC default value */ - phy_set_bb_reg(adapt, rTx_IQK_Tone_A, bMaskDWord, 0x01008c00); - phy_set_bb_reg(adapt, rRx_IQK_Tone_A, bMaskDWord, 0x01008c00); - } -} - -static void phy_lc_calibrate(struct adapter *adapt) -{ - u8 tmpreg; - u32 rf_a_mode = 0, lc_cal; - - /* Check continuous TX and Packet TX */ - tmpreg = usb_read8(adapt, 0xd03); - - if ((tmpreg & 0x70) != 0) - usb_write8(adapt, 0xd03, tmpreg & 0x8F); - else - usb_write8(adapt, REG_TXPAUSE, 0xFF); - - if ((tmpreg & 0x70) != 0) { - /* 1. Read original RF mode */ - /* Path-A */ - rf_a_mode = rtw_hal_read_rfreg(adapt, RF_PATH_A, RF_AC, - bMask12Bits); - - /* 2. Set RF mode = standby mode */ - /* Path-A */ - phy_set_rf_reg(adapt, RF_PATH_A, RF_AC, bMask12Bits, - (rf_a_mode & 0x8FFFF) | 0x10000); - } - - /* 3. Read RF reg18 */ - lc_cal = rtw_hal_read_rfreg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits); - - /* 4. Set LC calibration begin bit15 */ - phy_set_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits, - lc_cal | 0x08000); - - msleep(100); - - /* Restore original situation */ - if ((tmpreg & 0x70) != 0) { - /* Deal with continuous TX case */ - /* Path-A */ - usb_write8(adapt, 0xd03, tmpreg); - phy_set_rf_reg(adapt, RF_PATH_A, RF_AC, bMask12Bits, rf_a_mode); - - } else { - /* Deal with Packet TX case */ - usb_write8(adapt, REG_TXPAUSE, 0x00); - } -} - -void rtl88eu_phy_iq_calibrate(struct adapter *adapt, bool recovery) -{ - struct odm_dm_struct *dm_odm = &adapt->HalData->odmpriv; - s32 result[4][8]; - u8 i, final; - bool pathaok; - s32 reg_e94, reg_e9c, reg_ea4, reg_eb4, reg_ebc; - bool is12simular, is13simular, is23simular; - u32 iqk_bb_reg_92c[IQK_BB_REG_NUM] = { - rOFDM0_XARxIQImbalance, rOFDM0_XBRxIQImbalance, - rOFDM0_ECCAThreshold, rOFDM0_AGCRSSITable, - rOFDM0_XATxIQImbalance, rOFDM0_XBTxIQImbalance, - rOFDM0_XCTxAFE, rOFDM0_XDTxAFE, - rOFDM0_RxIQExtAnta}; - - if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) - return; - - if (recovery) { - reload_adda_reg(adapt, iqk_bb_reg_92c, - dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); - return; - } - - memset(result, 0, sizeof(result)); - for (i = 0; i < 8; i += 2) - result[3][i] = 0x100; - - final = 0xff; - pathaok = false; - is12simular = false; - is23simular = false; - is13simular = false; - - for (i = 0; i < 3; i++) { - phy_iq_calibrate(adapt, result, i); - - if (i == 1) { - is12simular = simularity_compare(adapt, result, 0, 1); - if (is12simular) { - final = 0; - break; - } - } - - if (i == 2) { - is13simular = simularity_compare(adapt, result, 0, 2); - if (is13simular) { - final = 0; - break; - } - is23simular = simularity_compare(adapt, result, 1, 2); - if (is23simular) - final = 1; - else - final = 3; - } - } - - for (i = 0; i < 4; i++) { - reg_e94 = result[i][0]; - reg_e9c = result[i][1]; - reg_ea4 = result[i][2]; - reg_eb4 = result[i][4]; - reg_ebc = result[i][5]; - } - - if (final != 0xff) { - reg_e94 = result[final][0]; - reg_e9c = result[final][1]; - reg_ea4 = result[final][2]; - reg_eb4 = result[final][4]; - reg_ebc = result[final][5]; - dm_odm->RFCalibrateInfo.RegE94 = reg_e94; - dm_odm->RFCalibrateInfo.RegE9C = reg_e9c; - dm_odm->RFCalibrateInfo.RegEB4 = reg_eb4; - dm_odm->RFCalibrateInfo.RegEBC = reg_ebc; - pathaok = true; - } else { - dm_odm->RFCalibrateInfo.RegE94 = 0x100; - dm_odm->RFCalibrateInfo.RegEB4 = 0x100; - dm_odm->RFCalibrateInfo.RegE9C = 0x0; - dm_odm->RFCalibrateInfo.RegEBC = 0x0; - } - if (reg_e94 != 0) - patha_fill_iqk(adapt, pathaok, result, final, - (reg_ea4 == 0)); - - save_adda_registers(adapt, iqk_bb_reg_92c, - dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); -} - -void rtl88eu_phy_lc_calibrate(struct adapter *adapt) -{ - u32 timeout = 2000, timecount = 0; - struct odm_dm_struct *dm_odm = &adapt->HalData->odmpriv; - - if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) - return; - - while (*dm_odm->pbScanInProcess && timecount < timeout) { - mdelay(50); - timecount += 50; - } - - dm_odm->RFCalibrateInfo.bLCKInProgress = true; - - phy_lc_calibrate(adapt); - - dm_odm->RFCalibrateInfo.bLCKInProgress = false; -} diff --git a/drivers/staging/rtl8188eu/hal/pwrseq.c b/drivers/staging/rtl8188eu/hal/pwrseq.c deleted file mode 100644 index 80bf9692844f..000000000000 --- a/drivers/staging/rtl8188eu/hal/pwrseq.c +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "pwrseq.h" -#include - -/* drivers should parse below arrays and do the corresponding actions */ - -/* 3 Power on Array */ -struct wl_pwr_cfg rtl8188E_power_on_flow[RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_CARDEMU_TO_ACT - RTL8188E_TRANS_END -}; - -/* 3Card Disable Array */ -struct wl_pwr_cfg rtl8188E_card_disable_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + - RTL8188E_TRANS_END_STEPS] = { - RTL8188E_TRANS_ACT_TO_CARDEMU - RTL8188E_TRANS_CARDEMU_TO_CARDDIS - RTL8188E_TRANS_END -}; - -/* 3 Enter LPS */ -struct wl_pwr_cfg rtl8188E_enter_lps_flow[RTL8188E_TRANS_ACT_TO_LPS_STEPS + - RTL8188E_TRANS_END_STEPS] = { - /* FW behavior */ - RTL8188E_TRANS_ACT_TO_LPS - RTL8188E_TRANS_END -}; diff --git a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c b/drivers/staging/rtl8188eu/hal/pwrseqcmd.c deleted file mode 100644 index cab774e31c60..000000000000 --- a/drivers/staging/rtl8188eu/hal/pwrseqcmd.c +++ /dev/null @@ -1,72 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include - -/* This routine deals with the Power Configuration CMDs parsing - * for RTL8723/RTL8188E Series IC. - */ -u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, struct wl_pwr_cfg pwrseqcmd[]) -{ - struct wl_pwr_cfg pwrcfgcmd; - u8 poll_bit = false; - u32 aryidx = 0; - u8 value = 0; - u32 offset = 0; - u32 poll_count = 0; /* polling autoload done. */ - u32 max_poll_count = 5000; - - do { - pwrcfgcmd = pwrseqcmd[aryidx]; - - switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { - case PWR_CMD_WRITE: - offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); - - /* Read the value from system register */ - value = usb_read8(padapter, offset); - - value &= ~(GET_PWR_CFG_MASK(pwrcfgcmd)); - value |= (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd)); - - /* Write the value back to system register */ - usb_write8(padapter, offset, value); - break; - case PWR_CMD_POLLING: - poll_bit = false; - offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); - do { - value = usb_read8(padapter, offset); - value &= GET_PWR_CFG_MASK(pwrcfgcmd); - - if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) - poll_bit = true; - else - udelay(10); - - if (poll_count++ > max_poll_count) - return false; - } while (!poll_bit); - break; - case PWR_CMD_DELAY: - if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); - else - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); - break; - case PWR_CMD_END: - /* When this command is parsed, end the process */ - return true; - default: - break; - } - - aryidx++;/* Add Array Index */ - } while (1); - return true; -} diff --git a/drivers/staging/rtl8188eu/hal/rf.c b/drivers/staging/rtl8188eu/hal/rf.c deleted file mode 100644 index aab0f54a75fc..000000000000 --- a/drivers/staging/rtl8188eu/hal/rf.c +++ /dev/null @@ -1,289 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include -#include -#include -#include - -void rtl88eu_phy_rf6052_set_bandwidth(struct adapter *adapt, - enum ht_channel_width bandwidth) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - - switch (bandwidth) { - case HT_CHANNEL_WIDTH_20: - hal_data->RfRegChnlVal[0] = ((hal_data->RfRegChnlVal[0] & - 0xfffff3ff) | BIT(10) | BIT(11)); - phy_set_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, - hal_data->RfRegChnlVal[0]); - break; - case HT_CHANNEL_WIDTH_40: - hal_data->RfRegChnlVal[0] = ((hal_data->RfRegChnlVal[0] & - 0xfffff3ff) | BIT(10)); - phy_set_rf_reg(adapt, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, - hal_data->RfRegChnlVal[0]); - break; - default: - break; - } -} - -void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, u8 *powerlevel) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - struct dm_priv *pdmpriv = &hal_data->dmpriv; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - u32 tx_agc[2] = {0, 0}, tmpval = 0, pwrtrac_value; - u8 idx1, idx2; - u8 *ptr; - u8 direction; - - if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { - tx_agc[RF_PATH_A] = 0x3f3f3f3f; - tx_agc[RF_PATH_B] = 0x3f3f3f3f; - for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - tx_agc[idx1] = powerlevel[idx1] | - (powerlevel[idx1] << 8) | - (powerlevel[idx1] << 16) | - (powerlevel[idx1] << 24); - } - } else { - if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) { - tx_agc[RF_PATH_A] = 0x10101010; - tx_agc[RF_PATH_B] = 0x10101010; - } else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) { - tx_agc[RF_PATH_A] = 0x00000000; - tx_agc[RF_PATH_B] = 0x00000000; - } else { - for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - tx_agc[idx1] = powerlevel[idx1] | - (powerlevel[idx1] << 8) | - (powerlevel[idx1] << 16) | - (powerlevel[idx1] << 24); - } - if (hal_data->EEPROMRegulatory == 0) { - tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][6] + - (hal_data->MCSTxPowerLevelOriginalOffset[0][7] << 8); - tx_agc[RF_PATH_A] += tmpval; - - tmpval = hal_data->MCSTxPowerLevelOriginalOffset[0][14] + - (hal_data->MCSTxPowerLevelOriginalOffset[0][15] << 24); - tx_agc[RF_PATH_B] += tmpval; - } - } - } - for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - ptr = (u8 *)(&tx_agc[idx1]); - for (idx2 = 0; idx2 < 4; idx2++) { - if (*ptr > RF6052_MAX_TX_PWR) - *ptr = RF6052_MAX_TX_PWR; - ptr++; - } - } - rtl88eu_dm_txpower_track_adjust(&hal_data->odmpriv, 1, &direction, - &pwrtrac_value); - - if (direction == 1) { - /* Increase TX power */ - tx_agc[0] += pwrtrac_value; - tx_agc[1] += pwrtrac_value; - } else if (direction == 2) { - /* Decrease TX power */ - tx_agc[0] -= pwrtrac_value; - tx_agc[1] -= pwrtrac_value; - } - - /* rf-A cck tx power */ - tmpval = tx_agc[RF_PATH_A] & 0xff; - phy_set_bb_reg(adapt, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); - tmpval = tx_agc[RF_PATH_A] >> 8; - phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); - - /* rf-B cck tx power */ - tmpval = tx_agc[RF_PATH_B] >> 24; - phy_set_bb_reg(adapt, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); - tmpval = tx_agc[RF_PATH_B] & 0x00ffffff; - phy_set_bb_reg(adapt, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); -} - -/* powerbase0 for OFDM rates */ -/* powerbase1 for HT MCS rates */ -static void getpowerbase88e(struct adapter *adapt, u8 *pwr_level_ofdm, - u8 *pwr_level_bw20, u8 *pwr_level_bw40, - u8 channel, u32 *ofdmbase, u32 *mcs_base) -{ - u32 powerbase0, powerbase1; - u8 i, powerlevel[2]; - - for (i = 0; i < 2; i++) { - powerbase0 = pwr_level_ofdm[i]; - - powerbase0 = (powerbase0 << 24) | (powerbase0 << 16) | - (powerbase0 << 8) | powerbase0; - *(ofdmbase + i) = powerbase0; - } - /* Check HT20 to HT40 diff */ - if (adapt->HalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - powerlevel[0] = pwr_level_bw20[0]; - else - powerlevel[0] = pwr_level_bw40[0]; - powerbase1 = powerlevel[0]; - powerbase1 = (powerbase1 << 24) | (powerbase1 << 16) | - (powerbase1 << 8) | powerbase1; - *mcs_base = powerbase1; -} - -static void get_rx_power_val_by_reg(struct adapter *adapt, u8 channel, - u8 index, u32 *powerbase0, u32 *powerbase1, - u32 *out_val) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - struct dm_priv *pdmpriv = &hal_data->dmpriv; - u8 i, chnlGroup = 0, pwr_diff_limit[4], customer_pwr_limit; - s8 pwr_diff = 0; - u32 write_val, customer_limit, rf; - u8 regulatory = hal_data->EEPROMRegulatory; - - /* Index 0 & 1= legacy OFDM, 2-5=HT_MCS rate */ - - for (rf = 0; rf < 2; rf++) { - u8 j = index + (rf ? 8 : 0); - - switch (regulatory) { - case 0: - chnlGroup = 0; - write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] + - ((index < 2) ? powerbase0[rf] : powerbase1[rf]); - break; - case 1: /* Realtek regulatory */ - /* increase power diff defined by Realtek for regulatory */ - if (hal_data->pwrGroupCnt == 1) - chnlGroup = 0; - if (hal_data->pwrGroupCnt >= hal_data->PGMaxGroup) - Hal_GetChnlGroup88E(channel, &chnlGroup); - - write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] + - ((index < 2) ? powerbase0[rf] : powerbase1[rf]); - break; - case 2: /* Better regulatory */ - /* don't increase any power diff */ - write_val = (index < 2) ? powerbase0[rf] : powerbase1[rf]; - break; - case 3: /* Customer defined power diff. */ - /* increase power diff defined by customer. */ - chnlGroup = 0; - - if (index < 2) - pwr_diff = hal_data->TxPwrLegacyHtDiff[rf][channel - 1]; - else if (hal_data->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - pwr_diff = hal_data->TxPwrHt20Diff[rf][channel - 1]; - - if (hal_data->CurrentChannelBW == HT_CHANNEL_WIDTH_40) - customer_pwr_limit = hal_data->PwrGroupHT40[rf][channel - 1]; - else - customer_pwr_limit = hal_data->PwrGroupHT20[rf][channel - 1]; - - if (pwr_diff >= customer_pwr_limit) - pwr_diff = 0; - else - pwr_diff = customer_pwr_limit - pwr_diff; - - for (i = 0; i < 4; i++) { - pwr_diff_limit[i] = (u8)((hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][j] & - (0x7f << (i * 8))) >> (i * 8)); - - if (pwr_diff_limit[i] > pwr_diff) - pwr_diff_limit[i] = pwr_diff; - } - customer_limit = (pwr_diff_limit[3] << 24) | - (pwr_diff_limit[2] << 16) | - (pwr_diff_limit[1] << 8) | - (pwr_diff_limit[0]); - write_val = customer_limit + ((index < 2) ? powerbase0[rf] : powerbase1[rf]); - break; - default: - chnlGroup = 0; - write_val = hal_data->MCSTxPowerLevelOriginalOffset[chnlGroup][j] + - ((index < 2) ? powerbase0[rf] : powerbase1[rf]); - break; - } -/* 20100427 Joseph: Driver dynamic Tx power shall not affect Tx power. It shall be determined by power training mechanism. */ -/* Currently, we cannot fully disable driver dynamic tx power mechanism because it is referenced by BT coexist mechanism. */ -/* In the future, two mechanism shall be separated from each other and maintained independently. Thanks for Lanhsin's reminder. */ - /* 92d do not need this */ - if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level1) - write_val = 0x14141414; - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_Level2) - write_val = 0x00000000; - - *(out_val + rf) = write_val; - } -} - -static void write_ofdm_pwr_reg(struct adapter *adapt, u8 index, u32 *pvalue) -{ - u16 regoffset_a[6] = { rTxAGC_A_Rate18_06, rTxAGC_A_Rate54_24, - rTxAGC_A_Mcs03_Mcs00, rTxAGC_A_Mcs07_Mcs04, - rTxAGC_A_Mcs11_Mcs08, rTxAGC_A_Mcs15_Mcs12 }; - u16 regoffset_b[6] = { rTxAGC_B_Rate18_06, rTxAGC_B_Rate54_24, - rTxAGC_B_Mcs03_Mcs00, rTxAGC_B_Mcs07_Mcs04, - rTxAGC_B_Mcs11_Mcs08, rTxAGC_B_Mcs15_Mcs12 }; - u8 i, rf, pwr_val[4]; - u32 write_val; - u16 regoffset; - - for (rf = 0; rf < 2; rf++) { - write_val = pvalue[rf]; - for (i = 0; i < 4; i++) { - pwr_val[i] = (u8)((write_val & (0x7f << (i * 8))) >> (i * 8)); - if (pwr_val[i] > RF6052_MAX_TX_PWR) - pwr_val[i] = RF6052_MAX_TX_PWR; - } - write_val = (pwr_val[3] << 24) | (pwr_val[2] << 16) | - (pwr_val[1] << 8) | pwr_val[0]; - - if (rf == 0) - regoffset = regoffset_a[index]; - else - regoffset = regoffset_b[index]; - - phy_set_bb_reg(adapt, regoffset, bMaskDWord, write_val); - } -} - -void rtl88eu_phy_rf6052_set_ofdm_txpower(struct adapter *adapt, - u8 *pwr_level_ofdm, - u8 *pwr_level_bw20, - u8 *pwr_level_bw40, u8 channel) -{ - u32 write_val[2], powerbase0[2], powerbase1[2], pwrtrac_value; - u8 direction; - u8 index = 0; - - getpowerbase88e(adapt, pwr_level_ofdm, pwr_level_bw20, pwr_level_bw40, - channel, &powerbase0[0], &powerbase1[0]); - - rtl88eu_dm_txpower_track_adjust(&adapt->HalData->odmpriv, 0, - &direction, &pwrtrac_value); - - for (index = 0; index < 6; index++) { - get_rx_power_val_by_reg(adapt, channel, index, - &powerbase0[0], &powerbase1[0], - &write_val[0]); - - if (direction == 1) { - write_val[0] += pwrtrac_value; - write_val[1] += pwrtrac_value; - } else if (direction == 2) { - write_val[0] -= pwrtrac_value; - write_val[1] -= pwrtrac_value; - } - write_ofdm_pwr_reg(adapt, index, &write_val[0]); - } -} diff --git a/drivers/staging/rtl8188eu/hal/rf_cfg.c b/drivers/staging/rtl8188eu/hal/rf_cfg.c deleted file mode 100644 index d39e1bd97f85..000000000000 --- a/drivers/staging/rtl8188eu/hal/rf_cfg.c +++ /dev/null @@ -1,247 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" - -#include - -static bool check_condition(struct adapter *adapt, const u32 condition) -{ - struct odm_dm_struct *odm = &adapt->HalData->odmpriv; - u32 _board = odm->BoardType; - u32 _platform = odm->SupportPlatform; - u32 _interface = odm->SupportInterface; - u32 cond; - - if (condition == 0xCDCDCDCD) - return true; - - cond = condition & 0x000000FF; - if ((_board == cond) && cond != 0x00) - return false; - - cond = condition & 0x0000FF00; - cond >>= 8; - if ((_interface & cond) == 0 && cond != 0x07) - return false; - - cond = condition & 0x00FF0000; - cond >>= 16; - if ((_platform & cond) == 0 && cond != 0x0F) - return false; - return true; -} - -/* RadioA_1T.TXT */ - -static u32 Array_RadioA_1T_8188E[] = { - 0x000, 0x00030000, - 0x008, 0x00084000, - 0x018, 0x00000407, - 0x019, 0x00000012, - 0x01E, 0x00080009, - 0x01F, 0x00000880, - 0x02F, 0x0001A060, - 0x03F, 0x00000000, - 0x042, 0x000060C0, - 0x057, 0x000D0000, - 0x058, 0x000BE180, - 0x067, 0x00001552, - 0x083, 0x00000000, - 0x0B0, 0x000FF8FC, - 0x0B1, 0x00054400, - 0x0B2, 0x000CCC19, - 0x0B4, 0x00043003, - 0x0B6, 0x0004953E, - 0x0B7, 0x0001C718, - 0x0B8, 0x000060FF, - 0x0B9, 0x00080001, - 0x0BA, 0x00040000, - 0x0BB, 0x00000400, - 0x0BF, 0x000C0000, - 0x0C2, 0x00002400, - 0x0C3, 0x00000009, - 0x0C4, 0x00040C91, - 0x0C5, 0x00099999, - 0x0C6, 0x000000A3, - 0x0C7, 0x00088820, - 0x0C8, 0x00076C06, - 0x0C9, 0x00000000, - 0x0CA, 0x00080000, - 0x0DF, 0x00000180, - 0x0EF, 0x000001A0, - 0x051, 0x0006B27D, - 0xFF0F041F, 0xABCD, - 0x052, 0x0007E4DD, - 0xCDCDCDCD, 0xCDCD, - 0x052, 0x0007E49D, - 0xFF0F041F, 0xDEAD, - 0x053, 0x00000073, - 0x056, 0x00051FF3, - 0x035, 0x00000086, - 0x035, 0x00000186, - 0x035, 0x00000286, - 0x036, 0x00001C25, - 0x036, 0x00009C25, - 0x036, 0x00011C25, - 0x036, 0x00019C25, - 0x0B6, 0x00048538, - 0x018, 0x00000C07, - 0x05A, 0x0004BD00, - 0x019, 0x000739D0, - 0x034, 0x0000ADF3, - 0x034, 0x00009DF0, - 0x034, 0x00008DED, - 0x034, 0x00007DEA, - 0x034, 0x00006DE7, - 0x034, 0x000054EE, - 0x034, 0x000044EB, - 0x034, 0x000034E8, - 0x034, 0x0000246B, - 0x034, 0x00001468, - 0x034, 0x0000006D, - 0x000, 0x00030159, - 0x084, 0x00068200, - 0x086, 0x000000CE, - 0x087, 0x00048A00, - 0x08E, 0x00065540, - 0x08F, 0x00088000, - 0x0EF, 0x000020A0, - 0x03B, 0x000F02B0, - 0x03B, 0x000EF7B0, - 0x03B, 0x000D4FB0, - 0x03B, 0x000CF060, - 0x03B, 0x000B0090, - 0x03B, 0x000A0080, - 0x03B, 0x00090080, - 0x03B, 0x0008F780, - 0x03B, 0x000722B0, - 0x03B, 0x0006F7B0, - 0x03B, 0x00054FB0, - 0x03B, 0x0004F060, - 0x03B, 0x00030090, - 0x03B, 0x00020080, - 0x03B, 0x00010080, - 0x03B, 0x0000F780, - 0x0EF, 0x000000A0, - 0x000, 0x00010159, - 0x018, 0x0000F407, - 0xFFE, 0x00000000, - 0xFFE, 0x00000000, - 0x01F, 0x00080003, - 0xFFE, 0x00000000, - 0xFFE, 0x00000000, - 0x01E, 0x00000001, - 0x01F, 0x00080000, - 0x000, 0x00033E60, -}; - -#define READ_NEXT_PAIR(v1, v2, i) \ -do { \ - i += 2; v1 = array[i]; \ - v2 = array[i + 1]; \ -} while (0) - -#define RFREG_OFFSET_MASK 0xfffff -#define B3WIREADDREAALENGTH 0x400 -#define B3WIREDATALENGTH 0x800 -#define BRFSI_RFENV 0x10 - -static void rtl_rfreg_delay(struct adapter *adapt, enum rf_radio_path rfpath, u32 addr, u32 mask, u32 data) -{ - if (addr == 0xfe) { - mdelay(50); - } else if (addr == 0xfd) { - mdelay(5); - } else if (addr == 0xfc) { - mdelay(1); - } else if (addr == 0xfb) { - udelay(50); - } else if (addr == 0xfa) { - udelay(5); - } else if (addr == 0xf9) { - udelay(1); - } else { - phy_set_rf_reg(adapt, rfpath, addr, mask, data); - udelay(1); - } -} - -static void rtl8188e_config_rf_reg(struct adapter *adapt, u32 addr, u32 data) -{ - u32 content = 0x1000; /*RF Content: radio_a_txt*/ - u32 maskforphyset = content & 0xE000; - - rtl_rfreg_delay(adapt, RF_PATH_A, addr | maskforphyset, - RFREG_OFFSET_MASK, - data); -} - -static bool rtl88e_phy_config_rf_with_headerfile(struct adapter *adapt) -{ - u32 i; - u32 array_len = ARRAY_SIZE(Array_RadioA_1T_8188E); - u32 *array = Array_RadioA_1T_8188E; - - for (i = 0; i < array_len; i += 2) { - u32 v1 = array[i]; - u32 v2 = array[i + 1]; - - if (v1 < 0xCDCDCDCD) { - rtl8188e_config_rf_reg(adapt, v1, v2); - continue; - } else { - if (!check_condition(adapt, array[i])) { - READ_NEXT_PAIR(v1, v2, i); - while (v2 != 0xDEAD && v2 != 0xCDEF && - v2 != 0xCDCD && i < array_len - 2) - READ_NEXT_PAIR(v1, v2, i); - i -= 2; - } else { - READ_NEXT_PAIR(v1, v2, i); - while (v2 != 0xDEAD && v2 != 0xCDEF && - v2 != 0xCDCD && i < array_len - 2) { - rtl8188e_config_rf_reg(adapt, v1, v2); - READ_NEXT_PAIR(v1, v2, i); - } - - while (v2 != 0xDEAD && i < array_len - 2) - READ_NEXT_PAIR(v1, v2, i); - } - } - } - return true; -} - -bool rtl88eu_phy_rf_config(struct adapter *adapt) -{ - struct hal_data_8188e *hal_data = adapt->HalData; - u32 u4val = 0; - bool rtstatus; - struct bb_reg_def *pphyreg; - - pphyreg = &hal_data->PHYRegDef[RF90_PATH_A]; - u4val = phy_query_bb_reg(adapt, pphyreg->rfintfs, BRFSI_RFENV); - - phy_set_bb_reg(adapt, pphyreg->rfintfe, BRFSI_RFENV << 16, 0x1); - udelay(1); - - phy_set_bb_reg(adapt, pphyreg->rfintfo, BRFSI_RFENV, 0x1); - udelay(1); - - phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, B3WIREADDREAALENGTH, 0x0); - udelay(1); - - phy_set_bb_reg(adapt, pphyreg->rfHSSIPara2, B3WIREDATALENGTH, 0x0); - udelay(1); - - rtstatus = rtl88e_phy_config_rf_with_headerfile(adapt); - - phy_set_bb_reg(adapt, pphyreg->rfintfs, BRFSI_RFENV, u4val); - - return rtstatus; -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c b/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c deleted file mode 100644 index f2969e160ac3..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_cmd.c +++ /dev/null @@ -1,591 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTL8188E_CMD_C_ - -#include -#include -#include -#include -#include - -#include - -#define RTL88E_MAX_H2C_BOX_NUMS 4 -#define RTL88E_MAX_CMD_LEN 7 -#define RTL88E_MESSAGE_BOX_SIZE 4 -#define RTL88E_EX_MESSAGE_BOX_SIZE 4 - -static u8 _is_fw_read_cmd_down(struct adapter *adapt, u8 msgbox_num) -{ - u8 read_down = false; - int retry_cnts = 100; - - u8 valid; - - do { - valid = usb_read8(adapt, REG_HMETFR) & BIT(msgbox_num); - if (valid == 0) - read_down = true; - } while ((!read_down) && (retry_cnts--)); - - return read_down; -} - -/***************************************** -* H2C Msg format : -* 0x1DF - 0x1D0 -*| 31 - 8 | 7-5 4 - 0 | -*| h2c_msg |Class_ID CMD_ID | -* -* Extend 0x1FF - 0x1F0 -*|31 - 0 | -*|ext_msg| -******************************************/ -static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *pCmdBuffer) -{ - u8 h2c_box_num; - u32 msgbox_addr; - u32 msgbox_ex_addr; - u8 cmd_idx, ext_cmd_len; - u32 h2c_cmd = 0; - u32 h2c_cmd_ex = 0; - s32 ret = _FAIL; - - if (!adapt->bFWReady) - return ret; - - if (!pCmdBuffer) - goto exit; - if (CmdLen > RTL88E_MAX_CMD_LEN) - goto exit; - if (adapt->bSurpriseRemoved) - goto exit; - - /* pay attention to if race condition happened in H2C cmd setting. */ - h2c_box_num = adapt->HalData->LastHMEBoxNum; - - if (!_is_fw_read_cmd_down(adapt, h2c_box_num)) - goto exit; - - *(u8 *)(&h2c_cmd) = ElementID; - - if (CmdLen <= 3) { - memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, CmdLen); - } else { - memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, 3); - ext_cmd_len = CmdLen - 3; - memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer + 3, ext_cmd_len); - - /* Write Ext command */ - msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); - for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) - usb_write8(adapt, msgbox_ex_addr + cmd_idx, *((u8 *)(&h2c_cmd_ex) + cmd_idx)); - } - /* Write command */ - msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); - for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) - usb_write8(adapt, msgbox_addr + cmd_idx, *((u8 *)(&h2c_cmd) + cmd_idx)); - - adapt->HalData->LastHMEBoxNum = - (h2c_box_num + 1) % RTL88E_MAX_H2C_BOX_NUMS; - - ret = _SUCCESS; - -exit: - return ret; -} - -/* bitmap[0:27] = tx_rate_bitmap */ -/* bitmap[28:31]= Rate Adaptive id */ -/* arg[0:4] = macid */ -/* arg[5] = Short GI */ -void rtw_hal_add_ra_tid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi_level) -{ - struct odm_dm_struct *odmpriv = &pAdapter->HalData->odmpriv; - u8 macid, init_rate, raid, shortGIrate = false; - - macid = arg & 0x1f; - - raid = (bitmap >> 28) & 0x0f; - bitmap &= 0x0fffffff; - - if (rssi_level != DM_RATR_STA_INIT) - bitmap = ODM_Get_Rate_Bitmap(odmpriv, macid, bitmap, rssi_level); - - bitmap |= ((raid << 28) & 0xf0000000); - - init_rate = get_highest_rate_idx(bitmap & 0x0fffffff) & 0x3f; - - shortGIrate = (arg & BIT(5)) ? true : false; - - if (shortGIrate) - init_rate |= BIT(6); - - raid = (bitmap >> 28) & 0x0f; - - bitmap &= 0x0fffffff; - - ODM_RA_UpdateRateInfo_8188E(odmpriv, macid, raid, bitmap, shortGIrate); -} - -void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) -{ - struct setpwrmode_parm H2CSetPwrMode; - struct pwrctrl_priv *pwrpriv = &adapt->pwrctrlpriv; - u8 RLBM = 0; /* 0:Min, 1:Max, 2:User define */ - - switch (Mode) { - case PS_MODE_ACTIVE: - H2CSetPwrMode.Mode = 0; - break; - case PS_MODE_MIN: - H2CSetPwrMode.Mode = 1; - break; - case PS_MODE_MAX: - RLBM = 1; - H2CSetPwrMode.Mode = 1; - break; - case PS_MODE_DTIM: - RLBM = 2; - H2CSetPwrMode.Mode = 1; - break; - case PS_MODE_UAPSD_WMM: - H2CSetPwrMode.Mode = 2; - break; - default: - H2CSetPwrMode.Mode = 0; - break; - } - - H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps << 4) & 0xf0) | (RLBM & 0x0f)); - - H2CSetPwrMode.AwakeInterval = 1; - - H2CSetPwrMode.bAllQueueUAPSD = adapt->registrypriv.uapsd_enable; - - if (Mode > 0) - H2CSetPwrMode.PwrState = 0x00;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ - else - H2CSetPwrMode.PwrState = 0x0C;/* AllON(0x0C), RFON(0x04), RFOFF(0x00) */ - - FillH2CCmd_88E(adapt, H2C_PS_PWR_MODE, sizeof(H2CSetPwrMode), (u8 *)&H2CSetPwrMode); -} - -void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) -{ - u16 mst_rpt = le16_to_cpu(mstatus_rpt); - - FillH2CCmd_88E(adapt, H2C_COM_MEDIA_STATUS_RPT, sizeof(mst_rpt), (u8 *)&mst_rpt); -} - -static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) -{ - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - u32 rate_len, pktlen; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - - ether_addr_copy(pwlanhdr->addr1, bc_addr); - ether_addr_copy(pwlanhdr->addr2, myid(&adapt->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, cur_network->MacAddress); - - SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); - SetFrameSubType(pframe, IEEE80211_STYPE_BEACON); - - pframe += sizeof(struct ieee80211_hdr_3addr); - pktlen = sizeof(struct ieee80211_hdr_3addr); - - /* timestamp will be inserted by hardware */ - pframe += 8; - pktlen += 8; - - /* beacon interval: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_beacon_interval_from_ie(cur_network->ies)), 2); - - pframe += 2; - pktlen += 2; - - /* capability info: 2 bytes */ - memcpy(pframe, (unsigned char *)(rtw_get_capability_from_ie(cur_network->ies)), 2); - - pframe += 2; - pktlen += 2; - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { - pktlen += cur_network->ie_length - sizeof(struct ndis_802_11_fixed_ie); - memcpy(pframe, cur_network->ies + sizeof(struct ndis_802_11_fixed_ie), pktlen); - - goto _ConstructBeacon; - } - - /* below for ad-hoc mode */ - - /* SSID */ - pframe = rtw_set_ie(pframe, WLAN_EID_SSID, cur_network->ssid.ssid_length, cur_network->ssid.ssid, &pktlen); - - /* supported rates... */ - rate_len = rtw_get_rateset_len(cur_network->SupportedRates); - pframe = rtw_set_ie(pframe, WLAN_EID_SUPP_RATES, min_t(u32, rate_len, 8), cur_network->SupportedRates, &pktlen); - - /* DS parameter set */ - pframe = rtw_set_ie(pframe, WLAN_EID_DS_PARAMS, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); - - if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { - u32 ATIMWindow; - /* IBSS Parameter Set... */ - ATIMWindow = 0; - pframe = rtw_set_ie(pframe, WLAN_EID_IBSS_PARAMS, 2, (unsigned char *)(&ATIMWindow), &pktlen); - } - - /* todo: ERP IE */ - - /* EXTERNDED SUPPORTED RATE */ - if (rate_len > 8) - pframe = rtw_set_ie(pframe, WLAN_EID_EXT_SUPP_RATES, (rate_len - 8), (cur_network->SupportedRates + 8), &pktlen); - - /* todo:HT for adhoc */ - -_ConstructBeacon: - - if ((pktlen + TXDESC_SIZE) > 512) - return; - - *pLength = pktlen; -} - -static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength) -{ - struct ieee80211_hdr *pwlanhdr; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - __le16 *fctrl; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pwlanhdr = (struct ieee80211_hdr *)pframe; - - /* Frame control. */ - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - SetPwrMgt(fctrl); - SetFrameSubType(pframe, IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); - - /* AID. */ - SetDuration(pframe, (pmlmeinfo->aid | 0xc000)); - - /* BSSID. */ - ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress); - - /* TA. */ - ether_addr_copy(pwlanhdr->addr2, myid(&adapt->eeprompriv)); - - *pLength = 16; -} - -static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe, - u32 *pLength, - u8 *StaAddr, - u8 bQoS, - u8 AC, - u8 bEosp, - u8 bForcePowerSave) -{ - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - u32 pktlen; - struct mlme_priv *pmlmepriv = &adapt->mlmepriv; - struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; - - pwlanhdr = (struct ieee80211_hdr *)pframe; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - if (bForcePowerSave) - SetPwrMgt(fctrl); - - switch (cur_network->network.InfrastructureMode) { - case Ndis802_11Infrastructure: - SetToDs(fctrl); - ether_addr_copy(pwlanhdr->addr1, pnetwork->MacAddress); - ether_addr_copy(pwlanhdr->addr2, myid(&adapt->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, StaAddr); - break; - case Ndis802_11APMode: - SetFrDs(fctrl); - ether_addr_copy(pwlanhdr->addr1, StaAddr); - ether_addr_copy(pwlanhdr->addr2, pnetwork->MacAddress); - ether_addr_copy(pwlanhdr->addr3, myid(&adapt->eeprompriv)); - break; - case Ndis802_11IBSS: - default: - ether_addr_copy(pwlanhdr->addr1, StaAddr); - ether_addr_copy(pwlanhdr->addr2, myid(&adapt->eeprompriv)); - ether_addr_copy(pwlanhdr->addr3, pnetwork->MacAddress); - break; - } - - SetSeqNum(pwlanhdr, 0); - - if (bQoS) { - struct ieee80211_qos_hdr *pwlanqoshdr; - - SetFrameSubType(pframe, IEEE80211_FTYPE_DATA | IEEE80211_STYPE_QOS_NULLFUNC); - - pwlanqoshdr = (struct ieee80211_qos_hdr *)pframe; - SetPriority(&pwlanqoshdr->qos_ctrl, AC); - SetEOSP(&pwlanqoshdr->qos_ctrl, bEosp); - - pktlen = sizeof(struct ieee80211_qos_hdr); - } else { - SetFrameSubType(pframe, IEEE80211_FTYPE_DATA | IEEE80211_STYPE_NULLFUNC); - - pktlen = sizeof(struct ieee80211_hdr_3addr); - } - - *pLength = pktlen; -} - -static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u8 *StaAddr, bool bHideSSID) -{ - struct ieee80211_hdr *pwlanhdr; - __le16 *fctrl; - u8 *mac, *bssid; - u32 pktlen; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - - pwlanhdr = (struct ieee80211_hdr *)pframe; - - mac = myid(&adapt->eeprompriv); - bssid = cur_network->MacAddress; - - fctrl = &pwlanhdr->frame_control; - *(fctrl) = 0; - ether_addr_copy(pwlanhdr->addr1, StaAddr); - ether_addr_copy(pwlanhdr->addr2, mac); - ether_addr_copy(pwlanhdr->addr3, bssid); - - SetSeqNum(pwlanhdr, 0); - SetFrameSubType(fctrl, IEEE80211_STYPE_PROBE_RESP); - - pktlen = sizeof(struct ieee80211_hdr_3addr); - pframe += pktlen; - - if (cur_network->ie_length > MAX_IE_SZ) - return; - - memcpy(pframe, cur_network->ies, cur_network->ie_length); - pframe += cur_network->ie_length; - pktlen += cur_network->ie_length; - - *pLength = pktlen; -} - -/* */ -/* Description: Fill the reserved packets that FW will use to RSVD page. */ -/* Now we just send 4 types packet to rsvd page. */ -/* (1)Beacon, (2)Ps-poll, (3)Null data, (4)ProbeRsp. */ -/* Input: */ -/* bDLFinished - false: At the first time we will send all the packets as a large packet to Hw, */ -/* so we need to set the packet length to total length. */ -/* true: At the second time, we should send the first packet (default:beacon) */ -/* to Hw again and set the length in descriptor to the real beacon length. */ -/* 2009.10.15 by tynli. */ -static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) -{ - struct xmit_frame *pmgntframe; - struct pkt_attrib *pattrib; - struct xmit_priv *pxmitpriv; - struct mlme_ext_priv *pmlmeext; - struct mlme_ext_info *pmlmeinfo; - u32 BeaconLength = 0, ProbeRspLength = 0, PSPollLength; - u32 NullDataLength, QosNullLength; - u8 *ReservedPagePacket; - u8 PageNum, PageNeed, TxDescLen; - u16 BufIndex; - u32 TotalPacketLen; - struct rsvdpage_loc RsvdPageLoc; - struct wlan_bssid_ex *pnetwork; - - ReservedPagePacket = kzalloc(1000, GFP_KERNEL); - if (!ReservedPagePacket) - return; - - pxmitpriv = &adapt->xmitpriv; - pmlmeext = &adapt->mlmeextpriv; - pmlmeinfo = &pmlmeext->mlmext_info; - pnetwork = &pmlmeinfo->network; - - TxDescLen = TXDESC_SIZE; - PageNum = 0; - - /* 3 (1) beacon * 2 pages */ - BufIndex = TXDESC_OFFSET; - ConstructBeacon(adapt, &ReservedPagePacket[BufIndex], &BeaconLength); - - /* When we count the first page size, we need to reserve description size for the RSVD */ - /* packet, it will be filled in front of the packet in TXPKTBUF. */ - PageNeed = (u8)PageNum_128(TxDescLen + BeaconLength); - /* To reserved 2 pages for beacon buffer. 2010.06.24. */ - if (PageNeed == 1) - PageNeed += 1; - PageNum += PageNeed; - - BufIndex += PageNeed * 128; - - /* 3 (2) ps-poll *1 page */ - RsvdPageLoc.LocPsPoll = PageNum; - ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], PSPollLength, true, false); - - PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength); - PageNum += PageNeed; - - BufIndex += PageNeed * 128; - - /* 3 (3) null data * 1 page */ - RsvdPageLoc.LocNullData = PageNum; - ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, pnetwork->MacAddress, false, 0, 0, false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], NullDataLength, false, false); - - PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); - PageNum += PageNeed; - - BufIndex += PageNeed * 128; - - /* 3 (4) probe response * 1page */ - RsvdPageLoc.LocProbeRsp = PageNum; - ConstructProbeRsp(adapt, &ReservedPagePacket[BufIndex], &ProbeRspLength, pnetwork->MacAddress, false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], ProbeRspLength, false, false); - - PageNeed = (u8)PageNum_128(TxDescLen + ProbeRspLength); - PageNum += PageNeed; - - BufIndex += PageNeed * 128; - - /* 3 (5) Qos null data */ - RsvdPageLoc.LocQosNull = PageNum; - ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], - &QosNullLength, pnetwork->MacAddress, true, 0, 0, false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], QosNullLength, false, false); - - PageNeed = (u8)PageNum_128(TxDescLen + QosNullLength); - PageNum += PageNeed; - - TotalPacketLen = BufIndex + QosNullLength; - pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (!pmgntframe) - goto exit; - - /* update attribute */ - pattrib = &pmgntframe->attrib; - update_mgntframe_attrib(adapt, pattrib); - pattrib->qsel = 0x10; - pattrib->last_txcmdsz = TotalPacketLen - TXDESC_OFFSET; - pattrib->pktlen = pattrib->last_txcmdsz; - memcpy(pmgntframe->buf_addr, ReservedPagePacket, TotalPacketLen); - - rtw_hal_mgnt_xmit(adapt, pmgntframe); - - FillH2CCmd_88E(adapt, H2C_COM_RSVD_PAGE, sizeof(RsvdPageLoc), (u8 *)&RsvdPageLoc); - -exit: - kfree(ReservedPagePacket); -} - -void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) -{ - struct hal_data_8188e *haldata = adapt->HalData; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - bool bSendBeacon = false; - bool bcn_valid = false; - u8 DLBcnCount = 0; - u32 poll = 0; - - if (mstatus == 1) { - /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ - /* Suggested by filen. Added by tynli. */ - usb_write16(adapt, REG_BCN_PSR_RPT, (0xC000 | pmlmeinfo->aid)); - /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ - - /* Set REG_CR bit 8. DMA beacon by SW. */ - haldata->RegCR_1 |= BIT(0); - usb_write8(adapt, REG_CR + 1, haldata->RegCR_1); - - /* Disable Hw protection for a time which revserd for Hw sending beacon. */ - /* Fix download reserved page packet fail that access collision with the protection time. */ - /* 2010.05.11. Added by tynli. */ - usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL) & (~BIT(3))); - usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL) | BIT(4)); - - if (haldata->RegFwHwTxQCtrl & BIT(6)) - bSendBeacon = true; - - /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ - usb_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl & (~BIT(6)))); - haldata->RegFwHwTxQCtrl &= (~BIT(6)); - - /* Clear beacon valid check bit. */ - rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); - DLBcnCount = 0; - poll = 0; - do { - /* download rsvd page. */ - SetFwRsvdPagePkt(adapt, false); - DLBcnCount++; - do { - yield(); - /* mdelay(10); */ - /* check rsvd page download OK. */ - rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); - poll++; - } while (!bcn_valid && (poll % 10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); - } while (!bcn_valid && DLBcnCount <= 100 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); - - /* */ - /* We just can send the reserved page twice during the time that Tx thread is stopped (e.g. pnpsetpower) */ - /* because we need to free the Tx BCN Desc which is used by the first reserved page packet. */ - /* At run time, we cannot get the Tx Desc until it is released in TxHandleInterrupt() so we will return */ - /* the beacon TCB in the following code. 2011.11.23. by tynli. */ - /* */ - - /* Enable Bcn */ - usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL) | BIT(3)); - usb_write8(adapt, REG_BCN_CTRL, usb_read8(adapt, REG_BCN_CTRL) & (~BIT(4))); - - /* To make sure that if there exists an adapter which would like to send beacon. */ - /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */ - /* prevent from setting 0x422[6] to 0 after download reserved page, or it will cause */ - /* the beacon cannot be sent by HW. */ - /* 2010.06.23. Added by tynli. */ - if (bSendBeacon) { - usb_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl | BIT(6))); - haldata->RegFwHwTxQCtrl |= BIT(6); - } - - /* Update RSVD page location H2C to Fw. */ - if (bcn_valid) - rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); - - /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */ - /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ - haldata->RegCR_1 &= (~BIT(0)); - usb_write8(adapt, REG_CR + 1, haldata->RegCR_1); - } -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c b/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c deleted file mode 100644 index 10e88f976163..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_dm.c +++ /dev/null @@ -1,217 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -/* */ -/* Description: */ -/* */ -/* This file is for 92CE/92CU dynamic mechanism only */ -/* */ -/* */ -/* */ -#define _RTL8188E_DM_C_ - -#include -#include - -#include - -/* Initialize GPIO setting registers */ -static void dm_InitGPIOSetting(struct adapter *Adapter) -{ - u8 tmp1byte; - - tmp1byte = usb_read8(Adapter, REG_GPIO_MUXCFG); - tmp1byte &= (GPIOSEL_GPIO | ~GPIOSEL_ENBT); - - usb_write8(Adapter, REG_GPIO_MUXCFG, tmp1byte); -} - -static void Init_ODM_ComInfo_88E(struct adapter *Adapter) -{ - struct hal_data_8188e *hal_data = Adapter->HalData; - struct dm_priv *pdmpriv = &hal_data->dmpriv; - struct odm_dm_struct *dm_odm = &hal_data->odmpriv; - - /* Init Value */ - memset(dm_odm, 0, sizeof(*dm_odm)); - - dm_odm->Adapter = Adapter; - dm_odm->SupportPlatform = ODM_CE; - dm_odm->SupportICType = ODM_RTL8188E; - dm_odm->CutVersion = ODM_CUT_A; - dm_odm->bIsMPChip = hal_data->VersionID.ChipType == NORMAL_CHIP; - dm_odm->PatchID = hal_data->CustomerID; - dm_odm->bWIFITest = Adapter->registrypriv.wifi_spec; - - dm_odm->AntDivType = hal_data->TRxAntDivType; - - /* Tx power tracking BB swing table. - * The base index = - * 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB - */ - dm_odm->BbSwingIdxOfdm = 12; /* Set default value as index 12. */ - dm_odm->BbSwingIdxOfdmCurrent = 12; - dm_odm->BbSwingFlagOfdm = false; - - pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | - ODM_RF_TX_PWR_TRACK; - - dm_odm->SupportAbility = pdmpriv->InitODMFlag; -} - -static void Update_ODM_ComInfo_88E(struct adapter *Adapter) -{ - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; - struct hal_data_8188e *hal_data = Adapter->HalData; - struct odm_dm_struct *dm_odm = &hal_data->odmpriv; - struct dm_priv *pdmpriv = &hal_data->dmpriv; - int i; - - pdmpriv->InitODMFlag = ODM_BB_DIG | - ODM_BB_RA_MASK | - ODM_BB_DYNAMIC_TXPWR | - ODM_BB_FA_CNT | - ODM_BB_RSSI_MONITOR | - ODM_BB_CCK_PD | - ODM_BB_PWR_SAVE | - ODM_MAC_EDCA_TURBO | - ODM_RF_CALIBRATION | - ODM_RF_TX_PWR_TRACK; - if (hal_data->AntDivCfg) - pdmpriv->InitODMFlag |= ODM_BB_ANT_DIV; - - if (Adapter->registrypriv.mp_mode == 1) { - pdmpriv->InitODMFlag = ODM_RF_CALIBRATION | - ODM_RF_TX_PWR_TRACK; - } - - dm_odm->SupportAbility = pdmpriv->InitODMFlag; - - dm_odm->pNumTxBytesUnicast = &Adapter->xmitpriv.tx_bytes; - dm_odm->pNumRxBytesUnicast = &Adapter->recvpriv.rx_bytes; - dm_odm->pWirelessMode = &pmlmeext->cur_wireless_mode; - dm_odm->pSecChOffset = &hal_data->nCur40MhzPrimeSC; - dm_odm->pSecurity = (u8 *)&Adapter->securitypriv.dot11PrivacyAlgrthm; - dm_odm->pBandWidth = (u8 *)&hal_data->CurrentChannelBW; - dm_odm->pChannel = &hal_data->CurrentChannel; - dm_odm->pbNet_closed = (bool *)&Adapter->net_closed; - dm_odm->mp_mode = &Adapter->registrypriv.mp_mode; - dm_odm->pbScanInProcess = (bool *)&pmlmepriv->bScanInProcess; - dm_odm->pbPowerSaving = (bool *)&pwrctrlpriv->bpower_saving; - dm_odm->AntDivType = hal_data->TRxAntDivType; - - /* Tx power tracking BB swing table. - * The base index = - * 12. +((12-n)/2)dB 13~?? = decrease tx pwr by -((n-12)/2)dB - */ - dm_odm->BbSwingIdxOfdm = 12; /* Set default value as index 12. */ - dm_odm->BbSwingIdxOfdmCurrent = 12; - dm_odm->BbSwingFlagOfdm = false; - - for (i = 0; i < NUM_STA; i++) - ODM_CmnInfoPtrArrayHook(dm_odm, ODM_CMNINFO_STA_STATUS, i, - NULL); -} - -void rtl8188e_InitHalDm(struct adapter *Adapter) -{ - struct dm_priv *pdmpriv = &Adapter->HalData->dmpriv; - struct odm_dm_struct *dm_odm = &Adapter->HalData->odmpriv; - - dm_InitGPIOSetting(Adapter); - pdmpriv->DM_Type = DM_Type_ByDriver; - pdmpriv->DMFlag = DYNAMIC_FUNC_DISABLE; - Update_ODM_ComInfo_88E(Adapter); - ODM_DMInit(dm_odm); -} - -void rtw_hal_dm_watchdog(struct adapter *Adapter) -{ - u8 hw_init_completed = false; - struct mlme_priv *pmlmepriv = NULL; - u8 bLinked = false; - - hw_init_completed = Adapter->hw_init_completed; - - if (!hw_init_completed) - goto skip_dm; - - /* ODM */ - pmlmepriv = &Adapter->mlmepriv; - - if ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | - WIFI_ADHOC_MASTER_STATE))) { - if (Adapter->stapriv.asoc_sta_count > 2) - bLinked = true; - } else {/* Station mode */ - if (check_fwstate(pmlmepriv, _FW_LINKED)) - bLinked = true; - } - - Adapter->HalData->odmpriv.bLinked = bLinked; - ODM_DMWatchdog(&Adapter->HalData->odmpriv); -skip_dm: - /* Check GPIO to determine current RF on/off and Pbc status. */ - /* Check Hardware Radio ON/OFF or not */ - return; -} - -void rtw_hal_dm_init(struct adapter *Adapter) -{ - struct dm_priv *pdmpriv = &Adapter->HalData->dmpriv; - - memset(pdmpriv, 0, sizeof(struct dm_priv)); - Init_ODM_ComInfo_88E(Adapter); -} - -/* Add new function to reset the state of antenna diversity before link. */ -/* Compare RSSI for deciding antenna */ -void rtw_hal_antdiv_rssi_compared(struct adapter *Adapter, - struct wlan_bssid_ex *dst, - struct wlan_bssid_ex *src) -{ - if (Adapter->HalData->AntDivCfg != 0) { - /* select optimum_antenna for before linked => For antenna - * diversity - */ - if (dst->Rssi >= src->Rssi) {/* keep org parameter */ - src->Rssi = dst->Rssi; - src->PhyInfo.Optimum_antenna = - dst->PhyInfo.Optimum_antenna; - } - } -} - -/* Add new function to reset the state of antenna diversity before link. */ -bool rtw_hal_antdiv_before_linked(struct adapter *Adapter) -{ - struct odm_dm_struct *dm_odm = &Adapter->HalData->odmpriv; - struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table; - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - - /* Condition that does not need to use antenna diversity. */ - if (Adapter->HalData->AntDivCfg == 0) - return false; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - return false; - - if (dm_swat_tbl->SWAS_NoLink_State != 0) { - dm_swat_tbl->SWAS_NoLink_State = 0; - return false; - } - - /* switch channel */ - dm_swat_tbl->SWAS_NoLink_State = 1; - dm_swat_tbl->CurAntenna = (dm_swat_tbl->CurAntenna == Antenna_A) ? - Antenna_B : Antenna_A; - - rtw_antenna_select_cmd(Adapter, dm_swat_tbl->CurAntenna, false); - return true; -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c deleted file mode 100644 index 7bf807e317d1..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_hal_init.c +++ /dev/null @@ -1,512 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _HAL_INIT_C_ - -#include -#include -#include -#include -#include -#include - -#include - -void iol_mode_enable(struct adapter *padapter, u8 enable) -{ - u8 reg_0xf0 = 0; - - if (enable) { - /* Enable initial offload */ - reg_0xf0 = usb_read8(padapter, REG_SYS_CFG); - usb_write8(padapter, REG_SYS_CFG, reg_0xf0 | SW_OFFLOAD_EN); - - if (!padapter->bFWReady) - _8051Reset88E(padapter); - } else { - /* disable initial offload */ - reg_0xf0 = usb_read8(padapter, REG_SYS_CFG); - usb_write8(padapter, REG_SYS_CFG, reg_0xf0 & ~SW_OFFLOAD_EN); - } -} - -s32 iol_execute(struct adapter *padapter, u8 control) -{ - s32 status = _FAIL; - u8 reg_0x88 = 0; - unsigned long start = 0; - - control = control & 0x0f; - reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); - usb_write8(padapter, REG_HMEBOX_E0, reg_0x88 | control); - - start = jiffies; - while ((reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0)) & control && - jiffies_to_msecs(jiffies - start) < 1000) { - udelay(5); - } - - reg_0x88 = usb_read8(padapter, REG_HMEBOX_E0); - status = (reg_0x88 & control) ? _FAIL : _SUCCESS; - if (reg_0x88 & control << 4) - status = _FAIL; - return status; -} - -static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) -{ - s32 rst = _SUCCESS; - - iol_mode_enable(padapter, 1); - usb_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); - rst = iol_execute(padapter, CMD_INIT_LLT); - iol_mode_enable(padapter, 0); - return rst; -} - -s32 rtl8188e_iol_efuse_patch(struct adapter *padapter) -{ - s32 result = _SUCCESS; - - if (rtw_iol_applied(padapter)) { - iol_mode_enable(padapter, 1); - result = iol_execute(padapter, CMD_READ_EFUSE_MAP); - if (result == _SUCCESS) - result = iol_execute(padapter, CMD_EFUSE_PATCH); - - iol_mode_enable(padapter, 0); - } - return result; -} - -#define MAX_REG_BOLCK_SIZE 196 - -void _8051Reset88E(struct adapter *padapter) -{ - u8 u1bTmp; - - u1bTmp = usb_read8(padapter, REG_SYS_FUNC_EN + 1); - usb_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp & (~BIT(2))); - usb_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp | (BIT(2))); -} - -void rtl8188e_InitializeFirmwareVars(struct adapter *padapter) -{ - /* Init H2C counter. by tynli. 2009.12.09. */ - padapter->HalData->LastHMEBoxNum = 0; -} - -void rtw_hal_free_data(struct adapter *padapter) -{ - kfree(padapter->HalData); - padapter->HalData = NULL; -} - -void rtw_hal_read_chip_version(struct adapter *padapter) -{ - u32 value32; - struct HAL_VERSION ChipVersion; - struct hal_data_8188e *pHalData = padapter->HalData; - - value32 = usb_read32(padapter, REG_SYS_CFG); - ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); - ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); - ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ - - dump_chip_info(ChipVersion); - - pHalData->VersionID = ChipVersion; -} - -void rtw_hal_set_odm_var(struct adapter *Adapter, enum hal_odm_variable eVariable, void *pValue1, bool bSet) -{ - struct odm_dm_struct *podmpriv = &Adapter->HalData->odmpriv; - - switch (eVariable) { - case HAL_ODM_STA_INFO: - { - struct sta_info *psta = pValue1; - - if (bSet) { - ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, psta); - ODM_RAInfo_Init(podmpriv, psta->mac_id); - } else { - ODM_CmnInfoPtrArrayHook(podmpriv, ODM_CMNINFO_STA_STATUS, psta->mac_id, NULL); - } - } - break; - case HAL_ODM_P2P_STATE: - podmpriv->bWIFI_Direct = bSet; - break; - case HAL_ODM_WIFI_DISPLAY_STATE: - podmpriv->bWIFI_Display = bSet; - break; - default: - break; - } -} - -void rtw_hal_notch_filter(struct adapter *adapter, bool enable) -{ - if (enable) - usb_write8(adapter, rOFDM0_RxDSP + 1, usb_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); - else - usb_write8(adapter, rOFDM0_RxDSP + 1, usb_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); -} - -/* */ -/* */ -/* LLT R/W/Init function */ -/* */ -/* */ -static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) -{ - s32 status = _SUCCESS; - s32 count; - u32 value = _LLT_INIT_ADDR(address) | _LLT_INIT_DATA(data) | _LLT_OP(_LLT_WRITE_ACCESS); - u16 LLTReg = REG_LLT_INIT; - - usb_write32(padapter, LLTReg, value); - - /* polling */ - for (count = 0; ; count++) { - value = usb_read32(padapter, LLTReg); - if (_LLT_OP_VALUE(value) == _LLT_NO_ACTIVE) - break; - - if (count > POLLING_LLT_THRESHOLD) { - status = _FAIL; - break; - } - udelay(5); - } - - return status; -} - -s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) -{ - s32 status = _FAIL; - u32 i; - u32 Last_Entry_Of_TxPktBuf = LAST_ENTRY_OF_TX_PKT_BUFFER;/* 176, 22k */ - - if (rtw_iol_applied(padapter)) { - status = iol_InitLLTTable(padapter, txpktbuf_bndy); - } else { - for (i = 0; i < (txpktbuf_bndy - 1); i++) { - status = _LLTWrite(padapter, i, i + 1); - if (status != _SUCCESS) - return status; - } - - /* end of list */ - status = _LLTWrite(padapter, (txpktbuf_bndy - 1), 0xFF); - if (status != _SUCCESS) - return status; - - /* Make the other pages as ring buffer */ - /* This ring buffer is used as beacon buffer if we config this MAC as two MAC transfer. */ - /* Otherwise used as local loopback buffer. */ - for (i = txpktbuf_bndy; i < Last_Entry_Of_TxPktBuf; i++) { - status = _LLTWrite(padapter, i, (i + 1)); - if (status != _SUCCESS) - return status; - } - - /* Let last entry point to the start entry of ring buffer */ - status = _LLTWrite(padapter, Last_Entry_Of_TxPktBuf, txpktbuf_bndy); - if (status != _SUCCESS) - return status; - } - - return status; -} - -void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo) -{ - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - u16 EEPROMId; - - /* Checl 0x8129 again for making sure autoload status!! */ - EEPROMId = le16_to_cpu(*((__le16 *)hwinfo)); - if (EEPROMId != RTL_EEPROM_ID) - pEEPROM->bautoload_fail_flag = true; - else - pEEPROM->bautoload_fail_flag = false; -} - -static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, u8 *PROMContent, bool AutoLoadFail) -{ - u32 rfPath, eeAddr = EEPROM_TX_PWR_INX_88E, group, TxCount = 0; - - memset(pwrInfo24G, 0, sizeof(struct txpowerinfo24g)); - - if (AutoLoadFail) { - for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { - /* 2.4G default value */ - for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { - pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; - pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; - } - for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { - if (TxCount == 0) { - pwrInfo24G->BW20_Diff[rfPath][0] = EEPROM_DEFAULT_24G_HT20_DIFF; - pwrInfo24G->OFDM_Diff[rfPath][0] = EEPROM_DEFAULT_24G_OFDM_DIFF; - } else { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - } - } - } - return; - } - - for (rfPath = 0; rfPath < MAX_RF_PATH; rfPath++) { - /* 2.4G default value */ - for (group = 0; group < MAX_CHNL_GROUP_24G; group++) { - pwrInfo24G->IndexCCK_Base[rfPath][group] = PROMContent[eeAddr++]; - if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) - pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; - } - for (group = 0; group < MAX_CHNL_GROUP_24G - 1; group++) { - pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; - if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) - pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; - } - for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { - if (TxCount == 0) { - pwrInfo24G->BW40_Diff[rfPath][TxCount] = 0; - if (PROMContent[eeAddr] == 0xFF) { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; - } else { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4; - if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ - pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; - } - - if (PROMContent[eeAddr] == 0xFF) { - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; - } else { - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f); - if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ - pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; - } - pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0; - eeAddr++; - } else { - if (PROMContent[eeAddr] == 0xFF) { - pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - } else { - pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4; - if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ - pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; - } - - if (PROMContent[eeAddr] == 0xFF) { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - } else { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f); - if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ - pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; - } - eeAddr++; - - if (PROMContent[eeAddr] == 0xFF) { - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - } else { - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4; - if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ - pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; - } - - if (PROMContent[eeAddr] == 0xFF) { - pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; - } else { - pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f); - if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ - pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; - } - eeAddr++; - } - } - } -} - -void Hal_GetChnlGroup88E(u8 chnl, u8 *group) -{ - if (chnl < 3) /* Channel 1-2 */ - *group = 0; - else if (chnl < 6) /* Channel 3-5 */ - *group = 1; - else if (chnl < 9) /* Channel 6-8 */ - *group = 2; - else if (chnl < 12) /* Channel 9-11 */ - *group = 3; - else if (chnl < 14) /* Channel 12-13 */ - *group = 4; - else if (chnl == 14) /* Channel 14 */ - *group = 5; -} - -void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -{ - if (AutoLoadFail) { - padapter->pwrctrlpriv.bHWPowerdown = false; - padapter->pwrctrlpriv.bSupportRemoteWakeup = false; - } else { - /* hw power down mode selection , 0:rf-off / 1:power down */ - - if (padapter->registrypriv.hwpdn_mode == 2) - padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT(4)); - else - padapter->pwrctrlpriv.bHWPowerdown = padapter->registrypriv.hwpdn_mode; - - /* decide hw if support remote wakeup function */ - /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT(1)) ? true : false; - } -} - -void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool AutoLoadFail) -{ - struct hal_data_8188e *pHalData = padapter->HalData; - struct txpowerinfo24g pwrInfo24G; - u8 ch, group; - u8 TxCount; - - Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail); - - if (!AutoLoadFail) - pHalData->bTXPowerDataReadFromEEPORM = true; - - for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { - Hal_GetChnlGroup88E(ch, &group); - pHalData->Index24G_CCK_Base[0][ch] = pwrInfo24G.IndexCCK_Base[0][group]; - if (ch == 14) - pHalData->Index24G_BW40_Base[0][ch] = pwrInfo24G.IndexBW40_Base[0][4]; - else - pHalData->Index24G_BW40_Base[0][ch] = pwrInfo24G.IndexBW40_Base[0][group]; - } - for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { - pHalData->CCK_24G_Diff[0][TxCount] = pwrInfo24G.CCK_Diff[0][TxCount]; - pHalData->OFDM_24G_Diff[0][TxCount] = pwrInfo24G.OFDM_Diff[0][TxCount]; - pHalData->BW20_24G_Diff[0][TxCount] = pwrInfo24G.BW20_Diff[0][TxCount]; - pHalData->BW40_24G_Diff[0][TxCount] = pwrInfo24G.BW40_Diff[0][TxCount]; - } - - /* 2010/10/19 MH Add Regulator recognize for CU. */ - if (!AutoLoadFail) { - pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x7); /* bit0~2 */ - if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) - pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION & 0x7); /* bit0~2 */ - } else { - pHalData->EEPROMRegulatory = 0; - } -} - -void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) -{ - struct hal_data_8188e *pHalData = pAdapter->HalData; - - if (!AutoLoadFail) { - pHalData->CrystalCap = hwinfo[EEPROM_XTAL_88E]; - if (pHalData->CrystalCap == 0xFF) - pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; - } else { - pHalData->CrystalCap = EEPROM_Default_CrystalCap_88E; - } -} - -void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoLoadFail) -{ - struct hal_data_8188e *pHalData = pAdapter->HalData; - - if (!AutoLoadFail) - pHalData->BoardType = (hwinfo[EEPROM_RF_BOARD_OPTION_88E] - & 0xE0) >> 5; - else - pHalData->BoardType = 0; -} - -void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -{ - struct hal_data_8188e *pHalData = padapter->HalData; - - if (!AutoLoadFail) { - pHalData->EEPROMVersion = hwinfo[EEPROM_VERSION_88E]; - if (pHalData->EEPROMVersion == 0xFF) - pHalData->EEPROMVersion = EEPROM_Default_Version; - } else { - pHalData->EEPROMVersion = 1; - } -} - -void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -{ - padapter->mlmepriv.ChannelPlan = - hal_com_get_channel_plan(hwinfo ? hwinfo[EEPROM_ChannelPlan_88E] : 0xFF, - padapter->registrypriv.channel_plan, - RT_CHANNEL_DOMAIN_WORLD_WIDE_13, AutoLoadFail); -} - -void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -{ - struct hal_data_8188e *pHalData = padapter->HalData; - - if (!AutoLoadFail) { - pHalData->EEPROMCustomerID = hwinfo[EEPROM_CUSTOMERID_88E]; - } else { - pHalData->EEPROMCustomerID = 0; - pHalData->EEPROMSubCustomerID = 0; - } -} - -void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool AutoLoadFail) -{ - struct hal_data_8188e *pHalData = pAdapter->HalData; - struct registry_priv *registry_par = &pAdapter->registrypriv; - - if (!AutoLoadFail) { - /* Antenna Diversity setting. */ - if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ - pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x18) >> 3; - if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) - pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION & 0x18) >> 3; - } else { - pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ - } - - if (registry_par->antdiv_type == 0) { - /* If TRxAntDivType is AUTO in advanced setting, use EFUSE value instead. */ - pHalData->TRxAntDivType = PROMContent[EEPROM_RF_ANTENNA_OPT_88E]; - if (pHalData->TRxAntDivType == 0xFF) - pHalData->TRxAntDivType = CG_TRX_HW_ANTDIV; /* For 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ - } else { - pHalData->TRxAntDivType = registry_par->antdiv_type; - } - - if (pHalData->TRxAntDivType == CG_TRX_HW_ANTDIV || pHalData->TRxAntDivType == CGCS_RX_HW_ANTDIV) - pHalData->AntDivCfg = 1; /* 0xC1[3] is ignored. */ - } else { - pHalData->AntDivCfg = 0; - } -} - -void Hal_ReadThermalMeter_88E(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) -{ - struct hal_data_8188e *pHalData = Adapter->HalData; - - /* ThermalMeter from EEPROM */ - if (!AutoloadFail) - pHalData->EEPROMThermalMeter = PROMContent[EEPROM_THERMAL_METER_88E]; - else - pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; - - if (pHalData->EEPROMThermalMeter == 0xff || AutoloadFail) - pHalData->EEPROMThermalMeter = EEPROM_Default_ThermalMeter_88E; -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c deleted file mode 100644 index 05dbd3f08328..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_rxdesc.c +++ /dev/null @@ -1,193 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTL8188E_REDESC_C_ - -#include -#include -#include - -static void process_rssi(struct adapter *padapter, struct recv_frame *prframe) -{ - struct rx_pkt_attrib *pattrib = &prframe->attrib; - struct signal_stat *signal_stat = &padapter->recvpriv.signal_strength_data; - - if (signal_stat->update_req) { - signal_stat->total_num = 0; - signal_stat->total_val = 0; - signal_stat->update_req = 0; - } - - signal_stat->total_num++; - signal_stat->total_val += pattrib->phy_info.SignalStrength; - signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; -} /* Process_UI_RSSI_8192C */ - -static void process_link_qual(struct adapter *padapter, - struct recv_frame *prframe) -{ - struct rx_pkt_attrib *pattrib; - struct signal_stat *signal_stat; - - if (!prframe || !padapter) - return; - - pattrib = &prframe->attrib; - signal_stat = &padapter->recvpriv.signal_qual_data; - - if (signal_stat->update_req) { - signal_stat->total_num = 0; - signal_stat->total_val = 0; - signal_stat->update_req = 0; - } - - signal_stat->total_num++; - signal_stat->total_val += pattrib->phy_info.SignalQuality; - signal_stat->avg_val = signal_stat->total_val / signal_stat->total_num; -} - -void rtl8188e_process_phy_info(struct adapter *padapter, - struct recv_frame *precvframe) -{ - /* Check RSSI */ - process_rssi(padapter, precvframe); - /* Check EVM */ - process_link_qual(padapter, precvframe); -} - -void update_recvframe_attrib_88e(struct recv_frame *precvframe, - struct recv_stat *prxstat) -{ - struct rx_pkt_attrib *pattrib; - struct recv_stat report; - - report.rxdw0 = prxstat->rxdw0; - report.rxdw1 = prxstat->rxdw1; - report.rxdw2 = prxstat->rxdw2; - report.rxdw3 = prxstat->rxdw3; - report.rxdw4 = prxstat->rxdw4; - report.rxdw5 = prxstat->rxdw5; - - pattrib = &precvframe->attrib; - memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); - - pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);/* u8)prxreport->crc32; */ - - /* update rx report to recv_frame attribute */ - pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */ - - if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ - pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ - pattrib->drvinfo_sz = (u8)((le32_to_cpu(report.rxdw0) >> 16) & 0xf) * 8;/* u8)(prxreport->drvinfosize << 3); */ - - pattrib->physt = (u8)((le32_to_cpu(report.rxdw0) >> 26) & 0x1);/* u8)prxreport->physt; */ - - pattrib->bdecrypted = (le32_to_cpu(report.rxdw0) & BIT(27)) ? 0 : 1;/* u8)(prxreport->swdec ? 0 : 1); */ - pattrib->encrypt = (u8)((le32_to_cpu(report.rxdw0) >> 20) & 0x7);/* u8)prxreport->security; */ - - pattrib->qos = (u8)((le32_to_cpu(report.rxdw0) >> 23) & 0x1);/* u8)prxreport->qos; */ - pattrib->priority = (u8)((le32_to_cpu(report.rxdw1) >> 8) & 0xf);/* u8)prxreport->tid; */ - - pattrib->amsdu = (u8)((le32_to_cpu(report.rxdw1) >> 13) & 0x1);/* u8)prxreport->amsdu; */ - - pattrib->seq_num = (u16)(le32_to_cpu(report.rxdw2) & 0x00000fff);/* u16)prxreport->seq; */ - pattrib->frag_num = (u8)((le32_to_cpu(report.rxdw2) >> 12) & 0xf);/* u8)prxreport->frag; */ - pattrib->mfrag = (u8)((le32_to_cpu(report.rxdw1) >> 27) & 0x1);/* u8)prxreport->mf; */ - pattrib->mdata = (u8)((le32_to_cpu(report.rxdw1) >> 26) & 0x1);/* u8)prxreport->md; */ - - pattrib->mcs_rate = (u8)(le32_to_cpu(report.rxdw3) & 0x3f);/* u8)prxreport->rxmcs; */ - pattrib->rxht = (u8)((le32_to_cpu(report.rxdw3) >> 6) & 0x1);/* u8)prxreport->rxht; */ - - pattrib->icv_err = (u8)((le32_to_cpu(report.rxdw0) >> 15) & 0x1);/* u8)prxreport->icverr; */ - pattrib->shift_sz = (u8)((le32_to_cpu(report.rxdw0) >> 24) & 0x3); - } else if (pattrib->pkt_rpt_type == TX_REPORT1) { /* CCX */ - pattrib->pkt_len = TX_RPT1_PKT_LEN; - pattrib->drvinfo_sz = 0; - } else if (pattrib->pkt_rpt_type == TX_REPORT2) { /* TX RPT */ - pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x3FF);/* Rx length[9:0] */ - pattrib->drvinfo_sz = 0; - - /* */ - /* Get TX report MAC ID valid. */ - /* */ - pattrib->MacIDValidEntry[0] = le32_to_cpu(report.rxdw4); - pattrib->MacIDValidEntry[1] = le32_to_cpu(report.rxdw5); - - } else if (pattrib->pkt_rpt_type == HIS_REPORT) { /* USB HISR RPT */ - pattrib->pkt_len = (u16)(le32_to_cpu(report.rxdw0) & 0x00003fff);/* u16)prxreport->pktlen; */ - } -} - -/* - * Notice: - * Before calling this function, - * precvframe->rx_data should be ready! - */ -void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, - struct phy_stat *pphy_status) -{ - struct adapter *padapter = precvframe->adapter; - struct rx_pkt_attrib *pattrib = &precvframe->attrib; - struct odm_phy_status_info *pPHYInfo = (struct odm_phy_status_info *)(&pattrib->phy_info); - u8 *wlanhdr; - struct ieee80211_hdr *hdr = - (struct ieee80211_hdr *)precvframe->pkt->data; - struct odm_per_pkt_info pkt_info; - u8 *sa = NULL; - struct sta_priv *pstapriv; - struct sta_info *psta; - - pkt_info.bPacketMatchBSSID = false; - pkt_info.bPacketToSelf = false; - pkt_info.bPacketBeacon = false; - - wlanhdr = precvframe->pkt->data; - - pkt_info.bPacketMatchBSSID = (!ieee80211_is_ctl(hdr->frame_control) && - !pattrib->icv_err && !pattrib->crc_err && - !memcmp(get_hdr_bssid(wlanhdr), - get_bssid(&padapter->mlmepriv), ETH_ALEN)); - - pkt_info.bPacketToSelf = pkt_info.bPacketMatchBSSID && - (!memcmp(ieee80211_get_DA(hdr), - myid(&padapter->eeprompriv), ETH_ALEN)); - - pkt_info.bPacketBeacon = pkt_info.bPacketMatchBSSID && - (GetFrameSubType(wlanhdr) == IEEE80211_STYPE_BEACON); - - if (pkt_info.bPacketBeacon) { - if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE)) - sa = padapter->mlmepriv.cur_network.network.MacAddress; - /* to do Ad-hoc */ - } else { - sa = ieee80211_get_SA(hdr); - } - - pstapriv = &padapter->stapriv; - pkt_info.StationID = 0xFF; - psta = rtw_get_stainfo(pstapriv, sa); - if (psta) - pkt_info.StationID = psta->mac_id; - pkt_info.Rate = pattrib->mcs_rate; - - odm_phy_status_query(&padapter->HalData->odmpriv, pPHYInfo, - (u8 *)pphy_status, &(pkt_info)); - - precvframe->psta = NULL; - if (pkt_info.bPacketMatchBSSID && - (check_fwstate(&padapter->mlmepriv, WIFI_AP_STATE))) { - if (psta) { - precvframe->psta = psta; - rtl8188e_process_phy_info(padapter, precvframe); - } - } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { - if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { - if (psta) - precvframe->psta = psta; - } - rtl8188e_process_phy_info(padapter, precvframe); - } -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c deleted file mode 100644 index efa8960a7eb5..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188e_xmit.c +++ /dev/null @@ -1,25 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTL8188E_XMIT_C_ - -#include -#include -#include - -void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) -{ - struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; - - if (txrpt_ccx->int_ccx) { - if (txrpt_ccx->pkt_ok) - rtw_ack_tx_done(&adapter->xmitpriv, - RTW_SCTX_DONE_SUCCESS); - else - rtw_ack_tx_done(&adapter->xmitpriv, - RTW_SCTX_DONE_CCX_PKT_FAIL); - } -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c deleted file mode 100644 index 25ce6db3beae..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_led.c +++ /dev/null @@ -1,55 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include -#include -#include - -void sw_led_on(struct adapter *padapter, struct LED_871x *pLed) -{ - u8 led_cfg; - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - return; - led_cfg = usb_read8(padapter, REG_LEDCFG2); - usb_write8(padapter, REG_LEDCFG2, (led_cfg & 0xf0) | BIT(5) | BIT(6)); - pLed->led_on = true; -} - -void sw_led_off(struct adapter *padapter, struct LED_871x *pLed) -{ - u8 led_cfg; - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped) - goto exit; - - led_cfg = usb_read8(padapter, REG_LEDCFG2);/* 0x4E */ - - /* Open-drain arrangement for controlling the LED) */ - led_cfg &= 0x90; /* Set to software control. */ - usb_write8(padapter, REG_LEDCFG2, (led_cfg | BIT(3))); - led_cfg = usb_read8(padapter, REG_MAC_PINMUX_CFG); - led_cfg &= 0xFE; - usb_write8(padapter, REG_MAC_PINMUX_CFG, led_cfg); -exit: - pLed->led_on = false; -} - -void rtw_hal_sw_led_init(struct adapter *padapter) -{ - struct led_priv *pledpriv = &padapter->ledpriv; - - InitLed871x(padapter, &pledpriv->sw_led); -} - -void rtw_hal_sw_led_deinit(struct adapter *padapter) -{ - struct led_priv *ledpriv = &padapter->ledpriv; - - DeInitLed871x(&ledpriv->sw_led); -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c deleted file mode 100644 index aa69fc3880b3..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_recv.c +++ /dev/null @@ -1,83 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTL8188EU_RECV_C_ -#include -#include -#include -#include -#include - -#include -#include - -#include - -int rtw_hal_init_recv_priv(struct adapter *padapter) -{ - struct recv_priv *precvpriv = &padapter->recvpriv; - int i, res = _SUCCESS; - struct recv_buf *precvbuf; - - tasklet_setup(&precvpriv->recv_tasklet, rtl8188eu_recv_tasklet); - - /* init recv_buf */ - _rtw_init_queue(&precvpriv->free_recv_buf_queue); - - precvpriv->precv_buf = - kcalloc(NR_RECVBUFF, sizeof(struct recv_buf), GFP_KERNEL); - if (!precvpriv->precv_buf) { - res = _FAIL; - goto exit; - } - precvbuf = precvpriv->precv_buf; - - for (i = 0; i < NR_RECVBUFF; i++) { - res = rtw_os_recvbuf_resource_alloc(precvbuf); - if (res == _FAIL) - break; - precvbuf->adapter = padapter; - precvbuf++; - } - skb_queue_head_init(&precvpriv->rx_skb_queue); - { - int i; - struct sk_buff *pskb = NULL; - - skb_queue_head_init(&precvpriv->free_recv_skb_queue); - - for (i = 0; i < NR_PREALLOC_RECV_SKB; i++) { - pskb = __netdev_alloc_skb(padapter->pnetdev, - MAX_RECVBUF_SZ, GFP_KERNEL); - if (pskb) { - kmemleak_not_leak(pskb); - skb_queue_tail(&precvpriv->free_recv_skb_queue, - pskb); - } - pskb = NULL; - } - } -exit: - return res; -} - -void rtw_hal_free_recv_priv(struct adapter *padapter) -{ - int i; - struct recv_buf *precvbuf; - struct recv_priv *precvpriv = &padapter->recvpriv; - - precvbuf = precvpriv->precv_buf; - - for (i = 0; i < NR_RECVBUFF; i++) { - usb_free_urb(precvbuf->purb); - precvbuf++; - } - - kfree(precvpriv->precv_buf); - skb_queue_purge(&precvpriv->rx_skb_queue); - skb_queue_purge(&precvpriv->free_recv_skb_queue); -} diff --git a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c deleted file mode 100644 index 1fa558e0de38..000000000000 --- a/drivers/staging/rtl8188eu/hal/rtl8188eu_xmit.c +++ /dev/null @@ -1,638 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _RTL8188E_XMIT_C_ -#include -#include -#include -#include -#include -#include -#include - -s32 rtw_hal_init_xmit_priv(struct adapter *adapt) -{ - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - - tasklet_setup(&pxmitpriv->xmit_tasklet, rtl8188eu_xmit_tasklet); - return _SUCCESS; -} - -static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) -{ - return !((sz + TXDESC_SIZE) % adapt->HalData->UsbBulkOutSize); -} - -static void rtl8188eu_cal_txdesc_chksum(struct tx_desc *ptxdesc) -{ - u16 *usptr = (u16 *)ptxdesc; - u32 count = 16; /* (32 bytes / 2 bytes per XOR) => 16 times */ - u32 index; - u16 checksum = 0; - - /* Clear first */ - ptxdesc->txdw7 &= cpu_to_le32(0xffff0000); - - for (index = 0; index < count; index++) - checksum = checksum ^ le16_to_cpu(*(__le16 *)(usptr + index)); - ptxdesc->txdw7 |= cpu_to_le32(0x0000ffff & checksum); -} - -/* - * In normal chip, we should send some packet to Hw which will be used by Fw - * in FW LPS mode. The function is to fill the Tx descriptor of this packets, - * then Fw can tell Hw to send these packet derectly. - */ -void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u8 ispspoll, u8 is_btqosnull) -{ - struct tx_desc *ptxdesc; - - /* Clear all status */ - ptxdesc = (struct tx_desc *)desc; - memset(desc, 0, TXDESC_SIZE); - - /* offset 0 */ - ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ - - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff0000); /* 32 bytes for TX Desc */ - - ptxdesc->txdw0 |= cpu_to_le32(BufferLen & 0x0000ffff); /* Buffer size + command header */ - - /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT << QSEL_SHT) & 0x00001f00); /* Fixed queue of Mgnt queue */ - - /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ - if (ispspoll) { - ptxdesc->txdw1 |= cpu_to_le32(NAVUSEHDR); - } else { - ptxdesc->txdw4 |= cpu_to_le32(BIT(7)); /* Hw set sequence number */ - ptxdesc->txdw3 |= cpu_to_le32((8 << 28)); /* set bit3 to 1. Suugested by TimChen. 2009.12.29. */ - } - - if (is_btqosnull) - ptxdesc->txdw2 |= cpu_to_le32(BIT(23)); /* BT NULL */ - - /* offset 16 */ - ptxdesc->txdw4 |= cpu_to_le32(BIT(8));/* driver uses rate */ - - /* USB interface drop packet if the checksum of descriptor isn't correct. */ - /* Using this checksum can let hardware recovery from packet bulk out error (e.g. Cancel URC, Bulk out error.). */ - rtl8188eu_cal_txdesc_chksum(ptxdesc); -} - -static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxdesc) -{ - if ((pattrib->encrypt > 0) && !pattrib->bswenc) { - switch (pattrib->encrypt) { - /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */ - case _WEP40_: - case _WEP104_: - ptxdesc->txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c00000); - ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; - case _TKIP_: - case _TKIP_WTMIC_: - ptxdesc->txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c00000); - ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; - case _AES_: - ptxdesc->txdw1 |= cpu_to_le32((0x03 << SEC_TYPE_SHT) & 0x00c00000); - ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); - break; - case _NO_PRIVACY_: - default: - break; - } - } -} - -static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) -{ - switch (pattrib->vcs_mode) { - case RTS_CTS: - *pdw |= cpu_to_le32(RTS_EN); - break; - case CTS_TO_SELF: - *pdw |= cpu_to_le32(CTS_2_SELF); - break; - case NONE_VCS: - default: - break; - } - if (pattrib->vcs_mode) { - *pdw |= cpu_to_le32(HW_RTS_EN); - /* Set RTS BW */ - if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; - - if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) - *pdw |= cpu_to_le32((0x01 << 28) & 0x30000000); - else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) - *pdw |= cpu_to_le32((0x02 << 28) & 0x30000000); - else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) - *pdw |= 0; - else - *pdw |= cpu_to_le32((0x03 << 28) & 0x30000000); - } - } -} - -static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) -{ - if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; - - if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) - *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f0000); - else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_UPPER) - *pdw |= cpu_to_le32((0x02 << DATA_SC_SHT) & 0x003f0000); - else if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_DONT_CARE) - *pdw |= 0; - else - *pdw |= cpu_to_le32((0x03 << DATA_SC_SHT) & 0x003f0000); - } -} - -static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bagg_pkt) -{ - int pull = 0; - uint qsel; - u8 data_rate, pwr_status, offset; - struct adapter *adapt = pxmitframe->padapter; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct odm_dm_struct *odmpriv = &adapt->HalData->odmpriv; - struct tx_desc *ptxdesc = (struct tx_desc *)pmem; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if (adapt->registrypriv.mp_mode == 0) { - if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { - ptxdesc = (struct tx_desc *)(pmem + PACKET_OFFSET_SZ); - pull = 1; - } - } - - memset(ptxdesc, 0, sizeof(struct tx_desc)); - - /* 4 offset 0 */ - ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); - ptxdesc->txdw0 |= cpu_to_le32(sz & 0x0000ffff);/* update TXPKTSIZE */ - - offset = TXDESC_SIZE + OFFSET_SZ; - - ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */ - - if (is_multicast_ether_addr(pattrib->ra)) - ptxdesc->txdw0 |= cpu_to_le32(BMC); - - if (adapt->registrypriv.mp_mode == 0) { - if (!bagg_pkt) { - if ((pull) && (pxmitframe->pkt_offset > 0)) - pxmitframe->pkt_offset = pxmitframe->pkt_offset - 1; - } - } - - /* pkt_offset, unit:8 bytes padding */ - if (pxmitframe->pkt_offset > 0) - ptxdesc->txdw1 |= cpu_to_le32((pxmitframe->pkt_offset << 26) & 0x7c000000); - - /* driver uses rate */ - ptxdesc->txdw4 |= cpu_to_le32(USERATE);/* rate control always by driver */ - - if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) { - /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3F); - - qsel = (uint)(pattrib->qsel & 0x0000001f); - ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); - - ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); - - fill_txdesc_sectype(pattrib, ptxdesc); - - if (pattrib->ampdu_en) { - ptxdesc->txdw2 |= cpu_to_le32(AGG_EN);/* AGG EN */ - ptxdesc->txdw6 = cpu_to_le32(0x6666f800); - } else { - ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ - } - - /* offset 8 */ - - /* offset 12 */ - ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000); - - /* offset 16 , offset 20 */ - if (pattrib->qos_en) - ptxdesc->txdw4 |= cpu_to_le32(QOS);/* QoS */ - - /* offset 20 */ - if (pxmitframe->agg_num > 1) - ptxdesc->txdw5 |= cpu_to_le32((pxmitframe->agg_num << USB_TXAGG_NUM_SHT) & 0xFF000000); - - if ((pattrib->ether_type != 0x888e) && - (pattrib->ether_type != 0x0806) && - (pattrib->ether_type != 0x88b4) && - (pattrib->dhcp_pkt != 1)) { - /* Non EAP & ARP & DHCP type data packet */ - - fill_txdesc_vcs(pattrib, &ptxdesc->txdw4); - fill_txdesc_phy(pattrib, &ptxdesc->txdw4); - - ptxdesc->txdw4 |= cpu_to_le32(0x00000008);/* RTS Rate=24M */ - ptxdesc->txdw5 |= cpu_to_le32(0x0001ff00);/* DATA/RTS Rate FB LMT */ - - if (pattrib->ht_en) { - if (ODM_RA_GetShortGI_8188E(odmpriv, pattrib->mac_id)) - ptxdesc->txdw5 |= cpu_to_le32(SGI);/* SGI */ - } - data_rate = ODM_RA_GetDecisionRate_8188E(odmpriv, pattrib->mac_id); - ptxdesc->txdw5 |= cpu_to_le32(data_rate & 0x3F); - pwr_status = ODM_RA_GetHwPwrStatus_8188E(odmpriv, pattrib->mac_id); - ptxdesc->txdw4 |= cpu_to_le32((pwr_status & 0x7) << PWR_STATUS_SHT); - } else { - /* EAP data packet and ARP packet and DHCP. */ - /* Use the 1M data rate to send the EAP/ARP packet. */ - /* This will maybe make the handshake smooth. */ - ptxdesc->txdw2 |= cpu_to_le32(AGG_BK);/* AGG BK */ - if (pmlmeinfo->preamble_mode == PREAMBLE_SHORT) - ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ - ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); - } - } else if ((pxmitframe->frame_tag & 0x0f) == MGNT_FRAMETAG) { - /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3f); - - qsel = (uint)(pattrib->qsel & 0x0000001f); - ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); - - ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000f0000); - - /* offset 8 */ - /* CCX-TXRPT ack for xmit mgmt frames. */ - if (pxmitframe->ack_report) - ptxdesc->txdw2 |= cpu_to_le32(BIT(19)); - - /* offset 12 */ - ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000); - - /* offset 20 */ - ptxdesc->txdw5 |= cpu_to_le32(RTY_LMT_EN);/* retry limit enable */ - if (pattrib->retry_ctrl) - ptxdesc->txdw5 |= cpu_to_le32(0x00180000);/* retry limit = 6 */ - else - ptxdesc->txdw5 |= cpu_to_le32(0x00300000);/* retry limit = 12 */ - - ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); - } else { - /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((4) & 0x3f);/* CAM_ID(MAC_ID) */ - - ptxdesc->txdw1 |= cpu_to_le32((6 << RATE_ID_SHT) & 0x000f0000);/* raid */ - - /* offset 8 */ - - /* offset 12 */ - ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0fff0000); - - /* offset 20 */ - ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); - } - - /* 2009.11.05. tynli_test. Suggested by SD4 Filen for FW LPS. */ - /* (1) The sequence number of each non-Qos frame / broadcast / multicast / */ - /* mgnt frame should be controlled by Hw because Fw will also send null data */ - /* which we cannot control when Fw LPS enable. */ - /* --> default enable non-Qos data sequense number. 2010.06.23. by tynli. */ - /* (2) Enable HW SEQ control for beacon packet, because we use Hw beacon. */ - /* (3) Use HW Qos SEQ to control the seq num of Ext port non-Qos packets. */ - /* 2010.06.23. Added by tynli. */ - if (!pattrib->qos_en) { - ptxdesc->txdw3 |= cpu_to_le32(EN_HWSEQ); /* Hw set sequence number */ - ptxdesc->txdw4 |= cpu_to_le32(HW_SSN); /* Hw set sequence number */ - } - - rtl88eu_dm_set_tx_ant_by_tx_info(odmpriv, pmem, pattrib->mac_id); - - rtl8188eu_cal_txdesc_chksum(ptxdesc); - return pull; -} - -/* for non-agg data frame or management frame */ -static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) -{ - s32 ret = _SUCCESS; - s32 inner_ret = _SUCCESS; - int t, sz, w_sz, pull = 0; - u8 *mem_addr; - u32 ff_hwaddr; - struct xmit_buf *pxmitbuf = pxmitframe->pxmitbuf; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - - if ((pxmitframe->frame_tag == DATA_FRAMETAG) && - (pxmitframe->attrib.ether_type != 0x0806) && - (pxmitframe->attrib.ether_type != 0x888e) && - (pxmitframe->attrib.ether_type != 0x88b4) && - (pxmitframe->attrib.dhcp_pkt != 1)) - rtw_issue_addbareq_cmd(adapt, pxmitframe); - mem_addr = pxmitframe->buf_addr; - - for (t = 0; t < pattrib->nr_frags; t++) { - if (inner_ret != _SUCCESS && ret == _SUCCESS) - ret = _FAIL; - - if (t != (pattrib->nr_frags - 1)) { - sz = pxmitpriv->frag_len; - sz = sz - 4 - pattrib->icv_len; - } else { - /* no frag */ - sz = pattrib->last_txcmdsz; - } - - pull = update_txdesc(pxmitframe, mem_addr, sz, false); - - if (pull) { - mem_addr += PACKET_OFFSET_SZ; /* pull txdesc head */ - pxmitframe->buf_addr = mem_addr; - w_sz = sz + TXDESC_SIZE; - } else { - w_sz = sz + TXDESC_SIZE + PACKET_OFFSET_SZ; - } - ff_hwaddr = rtw_get_ff_hwaddr(pxmitframe); - - inner_ret = usb_write_port(adapt, ff_hwaddr, w_sz, pxmitbuf); - - rtw_count_tx_stats(adapt, pxmitframe, sz); - - mem_addr += w_sz; - - mem_addr = (u8 *)round_up((size_t)mem_addr, 4); - } - - rtw_free_xmitframe(pxmitpriv, pxmitframe); - - if (ret != _SUCCESS) - rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_UNKNOWN); - - return ret; -} - -static u32 xmitframe_need_length(struct xmit_frame *pxmitframe) -{ - struct pkt_attrib *pattrib = &pxmitframe->attrib; - - u32 len; - - /* no consider fragement */ - len = pattrib->hdrlen + pattrib->iv_len + - SNAP_SIZE + sizeof(u16) + - pattrib->pktlen + - ((pattrib->bswenc) ? pattrib->icv_len : 0); - - if (pattrib->encrypt == _TKIP_) - len += 8; - - return len; -} - -bool rtl8188eu_xmitframe_complete(struct adapter *adapt, - struct xmit_priv *pxmitpriv) -{ - struct xmit_frame *pxmitframe, *n; - struct xmit_frame *pfirstframe = NULL; - struct xmit_buf *pxmitbuf; - - /* aggregate variable */ - struct hw_xmit *phwxmit; - struct sta_info *psta = NULL; - struct tx_servq *ptxservq = NULL; - - struct list_head *xmitframe_phead = NULL; - - u32 pbuf; /* next pkt address */ - u32 pbuf_tail; /* last pkt tail */ - u32 len; /* packet length, except TXDESC_SIZE and PKT_OFFSET */ - - u32 bulksize = adapt->HalData->UsbBulkOutSize; - u8 desc_cnt; - u32 bulkptr; - - /* dump frame variable */ - u32 ff_hwaddr; - - pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (!pxmitbuf) - return false; - - /* 3 1. pick up first frame */ - pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); - if (!pxmitframe) { - /* no more xmit frame, release xmit buffer */ - rtw_free_xmitbuf(pxmitpriv, pxmitbuf); - return false; - } - - pxmitframe->pxmitbuf = pxmitbuf; - pxmitframe->buf_addr = pxmitbuf->pbuf; - pxmitbuf->priv_data = pxmitframe; - - pxmitframe->agg_num = 1; /* alloc xmitframe should assign to 1. */ - pxmitframe->pkt_offset = 1; /* first frame of aggregation, reserve offset */ - - rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); - - /* always return ndis_packet after rtw_xmitframe_coalesce */ - rtw_os_xmit_complete(adapt, pxmitframe); - - /* 3 2. aggregate same priority and same DA(AP or STA) frames */ - pfirstframe = pxmitframe; - len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset * PACKET_OFFSET_SZ); - pbuf_tail = len; - pbuf = round_up(pbuf_tail, 8); - - /* check pkt amount in one bulk */ - desc_cnt = 0; - bulkptr = bulksize; - if (pbuf < bulkptr) { - desc_cnt++; - } else { - desc_cnt = 0; - bulkptr = ((pbuf / bulksize) + 1) * bulksize; /* round to next bulksize */ - } - - /* dequeue same priority packet from station tx queue */ - psta = pfirstframe->attrib.psta; - switch (pfirstframe->attrib.priority) { - case 1: - case 2: - ptxservq = &psta->sta_xmitpriv.bk_q; - phwxmit = pxmitpriv->hwxmits + 3; - break; - case 4: - case 5: - ptxservq = &psta->sta_xmitpriv.vi_q; - phwxmit = pxmitpriv->hwxmits + 1; - break; - case 6: - case 7: - ptxservq = &psta->sta_xmitpriv.vo_q; - phwxmit = pxmitpriv->hwxmits; - break; - case 0: - case 3: - default: - ptxservq = &psta->sta_xmitpriv.be_q; - phwxmit = pxmitpriv->hwxmits + 2; - break; - } - spin_lock_bh(&pxmitpriv->lock); - - xmitframe_phead = get_list_head(&ptxservq->sta_pending); - list_for_each_entry_safe(pxmitframe, n, xmitframe_phead, list) { - pxmitframe->agg_num = 0; /* not first frame of aggregation */ - pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ - - len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); - - if (round_up(pbuf + len, 8) > MAX_XMITBUF_SZ) { - pxmitframe->agg_num = 1; - pxmitframe->pkt_offset = 1; - break; - } - list_del_init(&pxmitframe->list); - ptxservq->qcnt--; - phwxmit->accnt--; - - pxmitframe->buf_addr = pxmitbuf->pbuf + pbuf; - - rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); - /* always return ndis_packet after rtw_xmitframe_coalesce */ - rtw_os_xmit_complete(adapt, pxmitframe); - - /* (len - TXDESC_SIZE) == pxmitframe->attrib.last_txcmdsz */ - update_txdesc(pxmitframe, pxmitframe->buf_addr, pxmitframe->attrib.last_txcmdsz, true); - - /* don't need xmitframe any more */ - rtw_free_xmitframe(pxmitpriv, pxmitframe); - - /* handle pointer and stop condition */ - pbuf_tail = pbuf + len; - pbuf = round_up(pbuf_tail, 8); - - pfirstframe->agg_num++; - if (pfirstframe->agg_num == MAX_TX_AGG_PACKET_NUMBER) - break; - - if (pbuf < bulkptr) { - desc_cnt++; - if (desc_cnt == adapt->HalData->UsbTxAggDescNum) - break; - } else { - desc_cnt = 0; - bulkptr = ((pbuf / bulksize) + 1) * bulksize; - } - } /* end while (aggregate same priority and same DA(AP or STA) frames) */ - - if (list_empty(&ptxservq->sta_pending.queue)) - list_del_init(&ptxservq->tx_pending); - - spin_unlock_bh(&pxmitpriv->lock); - if ((pfirstframe->attrib.ether_type != 0x0806) && - (pfirstframe->attrib.ether_type != 0x888e) && - (pfirstframe->attrib.ether_type != 0x88b4) && - (pfirstframe->attrib.dhcp_pkt != 1)) - rtw_issue_addbareq_cmd(adapt, pfirstframe); - /* 3 3. update first frame txdesc */ - if ((pbuf_tail % bulksize) == 0) { - /* remove pkt_offset */ - pbuf_tail -= PACKET_OFFSET_SZ; - pfirstframe->buf_addr += PACKET_OFFSET_SZ; - pfirstframe->pkt_offset--; - } - - update_txdesc(pfirstframe, pfirstframe->buf_addr, pfirstframe->attrib.last_txcmdsz, true); - - /* 3 4. write xmit buffer to USB FIFO */ - ff_hwaddr = rtw_get_ff_hwaddr(pfirstframe); - usb_write_port(adapt, ff_hwaddr, pbuf_tail, pxmitbuf); - - /* 3 5. update statisitc */ - pbuf_tail -= (pfirstframe->agg_num * TXDESC_SIZE); - pbuf_tail -= (pfirstframe->pkt_offset * PACKET_OFFSET_SZ); - - rtw_count_tx_stats(adapt, pfirstframe, pbuf_tail); - - rtw_free_xmitframe(pxmitpriv, pfirstframe); - - return true; -} - -/* - * Return - * true dump packet directly - * false enqueue packet - */ -bool rtw_hal_xmit(struct adapter *adapt, struct xmit_frame *pxmitframe) -{ - s32 res; - struct xmit_buf *pxmitbuf = NULL; - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - struct pkt_attrib *pattrib = &pxmitframe->attrib; - struct mlme_priv *pmlmepriv = &adapt->mlmepriv; - - spin_lock_bh(&pxmitpriv->lock); - - if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) - goto enqueue; - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) - goto enqueue; - - pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (!pxmitbuf) - goto enqueue; - - spin_unlock_bh(&pxmitpriv->lock); - - pxmitframe->pxmitbuf = pxmitbuf; - pxmitframe->buf_addr = pxmitbuf->pbuf; - pxmitbuf->priv_data = pxmitframe; - - res = rtw_xmitframe_coalesce(adapt, pxmitframe->pkt, pxmitframe); - - if (res == _SUCCESS) { - rtw_dump_xframe(adapt, pxmitframe); - } else { - rtw_free_xmitbuf(pxmitpriv, pxmitbuf); - rtw_free_xmitframe(pxmitpriv, pxmitframe); - } - - return true; - -enqueue: - res = rtw_xmitframe_enqueue(adapt, pxmitframe); - spin_unlock_bh(&pxmitpriv->lock); - - if (res != _SUCCESS) { - rtw_free_xmitframe(pxmitpriv, pxmitframe); - - /* Trick, make the statistics correct */ - pxmitpriv->tx_pkts--; - pxmitpriv->tx_drop++; - return true; - } - - return false; -} - -s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) -{ - struct xmit_priv *xmitpriv = &adapt->xmitpriv; - - rtl88eu_mon_xmit_hook(adapt->pmondev, pmgntframe, xmitpriv->frag_len); - return rtw_dump_xframe(adapt, pmgntframe); -} diff --git a/drivers/staging/rtl8188eu/hal/usb_halinit.c b/drivers/staging/rtl8188eu/hal/usb_halinit.c deleted file mode 100644 index 2de5564e8cd7..000000000000 --- a/drivers/staging/rtl8188eu/hal/usb_halinit.c +++ /dev/null @@ -1,1818 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _HCI_HAL_INIT_C_ - -#include -#include -#include -#include -#include -#include - -#define HAL_BB_ENABLE 1 - -static void _ConfigNormalChipOutEP_8188E(struct adapter *adapt, u8 NumOutPipe) -{ - struct hal_data_8188e *haldata = adapt->HalData; - - switch (NumOutPipe) { - case 3: - haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_LQ | TX_SELE_NQ; - haldata->OutEpNumber = 3; - break; - case 2: - haldata->OutEpQueueSel = TX_SELE_HQ | TX_SELE_NQ; - haldata->OutEpNumber = 2; - break; - case 1: - haldata->OutEpQueueSel = TX_SELE_HQ; - haldata->OutEpNumber = 1; - break; - default: - break; - } -} - -static bool HalUsbSetQueuePipeMapping8188EUsb(struct adapter *adapt, u8 NumInPipe, u8 NumOutPipe) -{ - bool result = false; - - _ConfigNormalChipOutEP_8188E(adapt, NumOutPipe); - - /* Normal chip with one IN and one OUT doesn't have interrupt IN EP. */ - if (adapt->HalData->OutEpNumber == 1) { - if (NumInPipe != 1) - return result; - } - - /* All config other than above support one Bulk IN and one Interrupt IN. */ - - result = hal_mapping_out_pipe(adapt, NumOutPipe); - - return result; -} - -void rtw_hal_chip_configure(struct adapter *adapt) -{ - struct hal_data_8188e *haldata = adapt->HalData; - struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(adapt); - - if (pdvobjpriv->ishighspeed) - haldata->UsbBulkOutSize = USB_HIGH_SPEED_BULK_SIZE;/* 512 bytes */ - else - haldata->UsbBulkOutSize = USB_FULL_SPEED_BULK_SIZE;/* 64 bytes */ - - haldata->interfaceIndex = pdvobjpriv->InterfaceNumber; - - haldata->UsbTxAggMode = 1; - haldata->UsbTxAggDescNum = 0x6; /* only 4 bits */ - - haldata->UsbRxAggMode = USB_RX_AGG_DMA;/* USB_RX_AGG_DMA; */ - haldata->UsbRxAggBlockCount = 8; /* unit : 512b */ - haldata->UsbRxAggBlockTimeout = 0x6; - haldata->UsbRxAggPageCount = 48; /* uint :128 b 0x0A; 10 = MAX_RX_DMA_BUFFER_SIZE/2/haldata->UsbBulkOutSize */ - haldata->UsbRxAggPageTimeout = 0x4; /* 6, absolute time = 34ms/(2^6) */ - - HalUsbSetQueuePipeMapping8188EUsb(adapt, pdvobjpriv->RtNumInPipes, - pdvobjpriv->RtNumOutPipes); -} - -u32 rtw_hal_power_on(struct adapter *adapt) -{ - u16 value16; - /* HW Power on sequence */ - if (adapt->HalData->bMacPwrCtrlOn) - return _SUCCESS; - - if (!rtl88eu_pwrseqcmdparsing(adapt, Rtl8188E_NIC_PWR_ON_FLOW)) - return _FAIL; - - /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ - /* Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - usb_write16(adapt, REG_CR, 0x00); /* suggseted by zhouzhou, by page, 20111230 */ - - /* Enable MAC DMA/WMAC/SCHEDULE/SEC block */ - value16 = usb_read16(adapt, REG_CR); - value16 |= (HCI_TXDMA_EN | HCI_RXDMA_EN | TXDMA_EN | RXDMA_EN - | PROTOCOL_EN | SCHEDULE_EN | ENSEC | CALTMR_EN); - /* for SDIO - Set CR bit10 to enable 32k calibration. Suggested by SD1 Gimmy. Added by tynli. 2011.08.31. */ - - usb_write16(adapt, REG_CR, value16); - adapt->HalData->bMacPwrCtrlOn = true; - - return _SUCCESS; -} - -/* Shall USB interface init this? */ -static void _InitInterrupt(struct adapter *Adapter) -{ - u32 imr, imr_ex; - u8 usb_opt; - - /* HISR write one to clear */ - usb_write32(Adapter, REG_HISR_88E, 0xFFFFFFFF); - /* HIMR - */ - imr = IMR_PSTIMEOUT_88E | IMR_TBDER_88E | IMR_CPWM_88E | IMR_CPWM2_88E; - usb_write32(Adapter, REG_HIMR_88E, imr); - - imr_ex = IMR_TXERR_88E | IMR_RXERR_88E | IMR_TXFOVW_88E | IMR_RXFOVW_88E; - usb_write32(Adapter, REG_HIMRE_88E, imr_ex); - - /* REG_USB_SPECIAL_OPTION - BIT(4) */ - /* 0; Use interrupt endpoint to upload interrupt pkt */ - /* 1; Use bulk endpoint to upload interrupt pkt, */ - usb_opt = usb_read8(Adapter, REG_USB_SPECIAL_OPTION); - - if (!adapter_to_dvobj(Adapter)->ishighspeed) - usb_opt = usb_opt & (~INT_BULK_SEL); - else - usb_opt = usb_opt | (INT_BULK_SEL); - - usb_write8(Adapter, REG_USB_SPECIAL_OPTION, usb_opt); -} - -static void _InitQueueReservedPage(struct adapter *Adapter) -{ - struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u32 numHQ = 0; - u32 numLQ = 0; - u32 numNQ = 0; - u32 numPubQ; - u32 value32; - u8 value8; - bool bWiFiConfig = pregistrypriv->wifi_spec; - - if (bWiFiConfig) { - if (Adapter->HalData->OutEpQueueSel & TX_SELE_HQ) - numHQ = 0x29; - - if (Adapter->HalData->OutEpQueueSel & TX_SELE_LQ) - numLQ = 0x1C; - - /* NOTE: This step shall be proceed before writing REG_RQPN. */ - if (Adapter->HalData->OutEpQueueSel & TX_SELE_NQ) - numNQ = 0x1C; - value8 = (u8)_NPQ(numNQ); - usb_write8(Adapter, REG_RQPN_NPQ, value8); - - numPubQ = 0xA8 - numHQ - numLQ - numNQ; - - /* TX DMA */ - value32 = _HPQ(numHQ) | _LPQ(numLQ) | _PUBQ(numPubQ) | LD_RQPN; - usb_write32(Adapter, REG_RQPN, value32); - } else { - usb_write16(Adapter, REG_RQPN_NPQ, 0x0000);/* Just follow MP Team,??? Georgia 03/28 */ - usb_write16(Adapter, REG_RQPN_NPQ, 0x0d); - usb_write32(Adapter, REG_RQPN, 0x808E000d);/* reserve 7 page for LPS */ - } -} - -static void _InitTxBufferBoundary(struct adapter *Adapter, u8 txpktbuf_bndy) -{ - usb_write8(Adapter, REG_TXPKTBUF_BCNQ_BDNY, txpktbuf_bndy); - usb_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); - usb_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); - usb_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); - usb_write8(Adapter, REG_TDECTRL + 1, txpktbuf_bndy); -} - -static void _InitPageBoundary(struct adapter *Adapter) -{ - /* RX Page Boundary */ - /* */ - u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E - 1; - - usb_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); -} - -static void _InitNormalChipRegPriority(struct adapter *Adapter, u16 beQ, - u16 bkQ, u16 viQ, u16 voQ, u16 mgtQ, - u16 hiQ) -{ - u16 value16 = (usb_read16(Adapter, REG_TRXDMA_CTRL) & 0x7); - - value16 |= _TXDMA_BEQ_MAP(beQ) | _TXDMA_BKQ_MAP(bkQ) | - _TXDMA_VIQ_MAP(viQ) | _TXDMA_VOQ_MAP(voQ) | - _TXDMA_MGQ_MAP(mgtQ) | _TXDMA_HIQ_MAP(hiQ); - - usb_write16(Adapter, REG_TRXDMA_CTRL, value16); -} - -static void _InitNormalChipOneOutEpPriority(struct adapter *Adapter) -{ - u16 value = 0; - - switch (Adapter->HalData->OutEpQueueSel) { - case TX_SELE_HQ: - value = QUEUE_HIGH; - break; - case TX_SELE_LQ: - value = QUEUE_LOW; - break; - case TX_SELE_NQ: - value = QUEUE_NORMAL; - break; - default: - break; - } - _InitNormalChipRegPriority(Adapter, value, value, value, value, - value, value); -} - -static void _InitNormalChipTwoOutEpPriority(struct adapter *Adapter) -{ - struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; - u16 valueHi = 0; - u16 valueLow = 0; - - switch (Adapter->HalData->OutEpQueueSel) { - case (TX_SELE_HQ | TX_SELE_LQ): - valueHi = QUEUE_HIGH; - valueLow = QUEUE_LOW; - break; - case (TX_SELE_NQ | TX_SELE_LQ): - valueHi = QUEUE_NORMAL; - valueLow = QUEUE_LOW; - break; - case (TX_SELE_HQ | TX_SELE_NQ): - valueHi = QUEUE_HIGH; - valueLow = QUEUE_NORMAL; - break; - default: - break; - } - - if (!pregistrypriv->wifi_spec) { - beQ = valueLow; - bkQ = valueLow; - viQ = valueHi; - voQ = valueHi; - mgtQ = valueHi; - hiQ = valueHi; - } else {/* for WMM ,CONFIG_OUT_EP_WIFI_MODE */ - beQ = valueLow; - bkQ = valueHi; - viQ = valueHi; - voQ = valueLow; - mgtQ = valueHi; - hiQ = valueHi; - } - _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); -} - -static void _InitNormalChipThreeOutEpPriority(struct adapter *Adapter) -{ - struct registry_priv *pregistrypriv = &Adapter->registrypriv; - u16 beQ, bkQ, viQ, voQ, mgtQ, hiQ; - - if (!pregistrypriv->wifi_spec) {/* typical setting */ - beQ = QUEUE_LOW; - bkQ = QUEUE_LOW; - viQ = QUEUE_NORMAL; - voQ = QUEUE_HIGH; - mgtQ = QUEUE_HIGH; - hiQ = QUEUE_HIGH; - } else {/* for WMM */ - beQ = QUEUE_LOW; - bkQ = QUEUE_NORMAL; - viQ = QUEUE_NORMAL; - voQ = QUEUE_HIGH; - mgtQ = QUEUE_HIGH; - hiQ = QUEUE_HIGH; - } - _InitNormalChipRegPriority(Adapter, beQ, bkQ, viQ, voQ, mgtQ, hiQ); -} - -static void _InitQueuePriority(struct adapter *Adapter) -{ - switch (Adapter->HalData->OutEpNumber) { - case 1: - _InitNormalChipOneOutEpPriority(Adapter); - break; - case 2: - _InitNormalChipTwoOutEpPriority(Adapter); - break; - case 3: - _InitNormalChipThreeOutEpPriority(Adapter); - break; - default: - break; - } -} - -static void _InitNetworkType(struct adapter *Adapter) -{ - u32 value32; - - value32 = usb_read32(Adapter, REG_CR); - /* TODO: use the other function to set network type */ - value32 = (value32 & ~MASK_NETTYPE) | _NETTYPE(NT_LINK_AP); - - usb_write32(Adapter, REG_CR, value32); -} - -static void _InitTransferPageSize(struct adapter *Adapter) -{ - /* Tx page size is always 128. */ - - u8 value8; - - value8 = _PSRX(PBP_128) | _PSTX(PBP_128); - usb_write8(Adapter, REG_PBP, value8); -} - -static void _InitDriverInfoSize(struct adapter *Adapter, u8 drvInfoSize) -{ - usb_write8(Adapter, REG_RX_DRVINFO_SZ, drvInfoSize); -} - -static void _InitWMACSetting(struct adapter *Adapter) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - - haldata->ReceiveConfig = RCR_AAP | RCR_APM | RCR_AM | RCR_AB | - RCR_CBSSID_DATA | RCR_CBSSID_BCN | - RCR_APP_ICV | RCR_AMF | RCR_HTC_LOC_CTRL | - RCR_APP_MIC | RCR_APP_PHYSTS; - - /* some REG_RCR will be modified later by phy_ConfigMACWithHeaderFile() */ - usb_write32(Adapter, REG_RCR, haldata->ReceiveConfig); - - /* Accept all multicast address */ - usb_write32(Adapter, REG_MAR, 0xFFFFFFFF); - usb_write32(Adapter, REG_MAR + 4, 0xFFFFFFFF); -} - -static void _InitAdaptiveCtrl(struct adapter *Adapter) -{ - u16 value16; - u32 value32; - - /* Response Rate Set */ - value32 = usb_read32(Adapter, REG_RRSR); - value32 &= ~RATE_BITMAP_ALL; - value32 |= RATE_RRSR_CCK_ONLY_1M; - usb_write32(Adapter, REG_RRSR, value32); - - /* CF-END Threshold */ - - /* SIFS (used in NAV) */ - value16 = _SPEC_SIFS_CCK(0x10) | _SPEC_SIFS_OFDM(0x10); - usb_write16(Adapter, REG_SPEC_SIFS, value16); - - /* Retry Limit */ - value16 = _LRL(0x30) | _SRL(0x30); - usb_write16(Adapter, REG_RL, value16); -} - -static void _InitEDCA(struct adapter *Adapter) -{ - /* Set Spec SIFS (used in NAV) */ - usb_write16(Adapter, REG_SPEC_SIFS, 0x100a); - usb_write16(Adapter, REG_MAC_SPEC_SIFS, 0x100a); - - /* Set SIFS for CCK */ - usb_write16(Adapter, REG_SIFS_CTX, 0x100a); - - /* Set SIFS for OFDM */ - usb_write16(Adapter, REG_SIFS_TRX, 0x100a); - - /* TXOP */ - usb_write32(Adapter, REG_EDCA_BE_PARAM, 0x005EA42B); - usb_write32(Adapter, REG_EDCA_BK_PARAM, 0x0000A44F); - usb_write32(Adapter, REG_EDCA_VI_PARAM, 0x005EA324); - usb_write32(Adapter, REG_EDCA_VO_PARAM, 0x002FA226); -} - -static void _InitRDGSetting(struct adapter *Adapter) -{ - usb_write8(Adapter, REG_RD_CTRL, 0xFF); - usb_write16(Adapter, REG_RD_NAV_NXT, 0x200); - usb_write8(Adapter, REG_RD_RESP_PKT_TH, 0x05); -} - -static void _InitRxSetting(struct adapter *Adapter) -{ - usb_write32(Adapter, REG_MACID, 0x87654321); - usb_write32(Adapter, 0x0700, 0x87654321); -} - -static void _InitRetryFunction(struct adapter *Adapter) -{ - u8 value8; - - value8 = usb_read8(Adapter, REG_FWHW_TXQ_CTRL); - value8 |= EN_AMPDU_RTY_NEW; - usb_write8(Adapter, REG_FWHW_TXQ_CTRL, value8); - - /* Set ACK timeout */ - usb_write8(Adapter, REG_ACKTO, 0x40); -} - -/*----------------------------------------------------------------------------- - * Function: usb_AggSettingTxUpdate() - * - * Overview: Separate TX/RX parameters update independent for TP detection and - * dynamic TX/RX aggreagtion parameters update. - * - * Input: struct adapter * - * - * Output/Return: NONE - * - * Revised History: - * When Who Remark - * 12/10/2010 MHC Separate to smaller function. - * - *--------------------------------------------------------------------------- - */ -static void usb_AggSettingTxUpdate(struct adapter *Adapter) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - u32 value32; - - if (Adapter->registrypriv.wifi_spec) - haldata->UsbTxAggMode = false; - - if (haldata->UsbTxAggMode) { - value32 = usb_read32(Adapter, REG_TDECTRL); - value32 = value32 & ~(BLK_DESC_NUM_MASK << BLK_DESC_NUM_SHIFT); - value32 |= ((haldata->UsbTxAggDescNum & BLK_DESC_NUM_MASK) << BLK_DESC_NUM_SHIFT); - - usb_write32(Adapter, REG_TDECTRL, value32); - } -} /* usb_AggSettingTxUpdate */ - -/*----------------------------------------------------------------------------- - * Function: usb_AggSettingRxUpdate() - * - * Overview: Separate TX/RX parameters update independent for TP detection and - * dynamic TX/RX aggreagtion parameters update. - * - * Input: struct adapter * - * - * Output/Return: NONE - * - * Revised History: - * When Who Remark - * 12/10/2010 MHC Separate to smaller function. - * - *--------------------------------------------------------------------------- - */ -static void usb_AggSettingRxUpdate(struct adapter *Adapter) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - u8 valueDMA; - u8 valueUSB; - - valueDMA = usb_read8(Adapter, REG_TRXDMA_CTRL); - valueUSB = usb_read8(Adapter, REG_USB_SPECIAL_OPTION); - - switch (haldata->UsbRxAggMode) { - case USB_RX_AGG_DMA: - valueDMA |= RXDMA_AGG_EN; - valueUSB &= ~USB_AGG_EN; - break; - case USB_RX_AGG_USB: - valueDMA &= ~RXDMA_AGG_EN; - valueUSB |= USB_AGG_EN; - break; - case USB_RX_AGG_MIX: - valueDMA |= RXDMA_AGG_EN; - valueUSB |= USB_AGG_EN; - break; - case USB_RX_AGG_DISABLE: - default: - valueDMA &= ~RXDMA_AGG_EN; - valueUSB &= ~USB_AGG_EN; - break; - } - - usb_write8(Adapter, REG_TRXDMA_CTRL, valueDMA); - usb_write8(Adapter, REG_USB_SPECIAL_OPTION, valueUSB); - - switch (haldata->UsbRxAggMode) { - case USB_RX_AGG_DMA: - usb_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); - usb_write8(Adapter, REG_RXDMA_AGG_PG_TH + 1, haldata->UsbRxAggPageTimeout); - break; - case USB_RX_AGG_USB: - usb_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); - usb_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); - break; - case USB_RX_AGG_MIX: - usb_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); - usb_write8(Adapter, REG_RXDMA_AGG_PG_TH + 1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ - usb_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); - usb_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); - break; - case USB_RX_AGG_DISABLE: - default: - /* TODO: */ - break; - } -} /* usb_AggSettingRxUpdate */ - -static void InitUsbAggregationSetting(struct adapter *Adapter) -{ - /* Tx aggregation setting */ - usb_AggSettingTxUpdate(Adapter); - - /* Rx aggregation setting */ - usb_AggSettingRxUpdate(Adapter); -} - -static void _InitBeaconParameters(struct adapter *Adapter) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - - usb_write16(Adapter, REG_BCN_CTRL, 0x1010); - - /* TODO: Remove these magic number */ - usb_write16(Adapter, REG_TBTT_PROHIBIT, 0x6404);/* ms */ - usb_write8(Adapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME);/* 5ms */ - usb_write8(Adapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME); /* 2ms */ - - /* Suggested by designer timchen. Change beacon AIFS to the largest number */ - /* beacause test chip does not contension before sending beacon. by tynli. 2009.11.03 */ - usb_write16(Adapter, REG_BCNTCFG, 0x660F); - - haldata->RegFwHwTxQCtrl = usb_read8(Adapter, REG_FWHW_TXQ_CTRL + 2); - haldata->RegReg542 = usb_read8(Adapter, REG_TBTT_PROHIBIT + 2); - haldata->RegCR_1 = usb_read8(Adapter, REG_CR + 1); -} - -static void _BeaconFunctionEnable(struct adapter *Adapter) -{ - usb_write8(Adapter, REG_BCN_CTRL, (BIT(4) | BIT(3) | BIT(1))); - - usb_write8(Adapter, REG_RD_CTRL + 1, 0x6F); -} - -/* Set CCK and OFDM Block "ON" */ -static void _BBTurnOnBlock(struct adapter *Adapter) -{ - phy_set_bb_reg(Adapter, rFPGA0_RFMOD, bCCKEn, 0x1); - phy_set_bb_reg(Adapter, rFPGA0_RFMOD, bOFDMEn, 0x1); -} - -static void _InitAntenna_Selection(struct adapter *Adapter) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - - if (haldata->AntDivCfg == 0) - return; - - usb_write32(Adapter, REG_LEDCFG0, usb_read32(Adapter, REG_LEDCFG0) | BIT(23)); - phy_set_bb_reg(Adapter, rFPGA0_XAB_RFParameter, BIT(13), 0x01); - - if (phy_query_bb_reg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) - haldata->CurAntenna = Antenna_A; - else - haldata->CurAntenna = Antenna_B; -} - -enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) -{ - u8 val8; - enum rt_rf_power_state rfpowerstate = rf_off; - - if (adapt->pwrctrlpriv.bHWPowerdown) { - val8 = usb_read8(adapt, REG_HSISR); - rfpowerstate = (val8 & BIT(7)) ? rf_off : rf_on; - } else { /* rf on/off */ - usb_write8(adapt, REG_MAC_PINMUX_CFG, usb_read8(adapt, REG_MAC_PINMUX_CFG) & ~(BIT(3))); - val8 = usb_read8(adapt, REG_GPIO_IO_SEL); - rfpowerstate = (val8 & BIT(3)) ? rf_on : rf_off; - } - return rfpowerstate; -} /* HalDetectPwrDownMode */ - -u32 rtl8188eu_hal_init(struct adapter *Adapter) -{ - u8 value8 = 0; - u16 value16; - u8 txpktbuf_bndy; - u32 status = _SUCCESS; - struct hal_data_8188e *haldata = Adapter->HalData; - struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; - struct registry_priv *pregistrypriv = &Adapter->registrypriv; - - if (Adapter->pwrctrlpriv.bkeepfwalive) { - if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { - rtl88eu_phy_iq_calibrate(Adapter, true); - } else { - rtl88eu_phy_iq_calibrate(Adapter, false); - haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; - } - - ODM_TXPowerTrackingCheck(&haldata->odmpriv); - rtl88eu_phy_lc_calibrate(Adapter); - - goto exit; - } - - status = rtw_hal_power_on(Adapter); - if (status == _FAIL) - goto exit; - - /* Save target channel */ - haldata->CurrentChannel = 6;/* default set to 6 */ - - if (pwrctrlpriv->reg_rfoff) - pwrctrlpriv->rf_pwrstate = rf_off; - - /* 2010/08/09 MH We need to check if we need to turnon or off RF after detecting */ - /* HW GPIO pin. Before PHY_RFConfig8192C. */ - /* 2010/08/26 MH If Efuse does not support sective suspend then disable the function. */ - - if (!pregistrypriv->wifi_spec) { - txpktbuf_bndy = TX_PAGE_BOUNDARY_88E; - } else { - /* for WMM */ - txpktbuf_bndy = WMM_NORMAL_TX_PAGE_BOUNDARY_88E; - } - - _InitQueueReservedPage(Adapter); - _InitQueuePriority(Adapter); - _InitPageBoundary(Adapter); - _InitTransferPageSize(Adapter); - - _InitTxBufferBoundary(Adapter, 0); - - if (Adapter->registrypriv.mp_mode == 1) { - _InitRxSetting(Adapter); - Adapter->bFWReady = false; - } else { - status = rtl88eu_download_fw(Adapter); - - if (status) { - Adapter->bFWReady = false; - return status; - } - Adapter->bFWReady = true; - } - rtl8188e_InitializeFirmwareVars(Adapter); - - phy_mac_config(Adapter); - - rtl88eu_phy_bb_config(Adapter); - - rtl88eu_phy_rf_config(Adapter); - - status = rtl8188e_iol_efuse_patch(Adapter); - if (status == _FAIL) - goto exit; - - _InitTxBufferBoundary(Adapter, txpktbuf_bndy); - - status = InitLLTTable(Adapter, txpktbuf_bndy); - if (status == _FAIL) - goto exit; - - /* Get Rx PHY status in order to report RSSI and others. */ - _InitDriverInfoSize(Adapter, DRVINFO_SZ); - - _InitInterrupt(Adapter); - rtw_hal_set_hwreg(Adapter, HW_VAR_MAC_ADDR, - Adapter->eeprompriv.mac_addr); - _InitNetworkType(Adapter);/* set msr */ - _InitWMACSetting(Adapter); - _InitAdaptiveCtrl(Adapter); - _InitEDCA(Adapter); - _InitRetryFunction(Adapter); - InitUsbAggregationSetting(Adapter); - _InitBeaconParameters(Adapter); - /* Init CR MACTXEN, MACRXEN after setting RxFF boundary REG_TRXFF_BNDY to patch */ - /* Hw bug which Hw initials RxFF boundary size to a value which is larger than the real Rx buffer size in 88E. */ - /* Enable MACTXEN/MACRXEN block */ - value16 = usb_read16(Adapter, REG_CR); - value16 |= (MACTXEN | MACRXEN); - usb_write8(Adapter, REG_CR, value16); - - if (haldata->bRDGEnable) - _InitRDGSetting(Adapter); - - /* Enable TX Report */ - /* Enable Tx Report Timer */ - value8 = usb_read8(Adapter, REG_TX_RPT_CTRL); - usb_write8(Adapter, REG_TX_RPT_CTRL, (value8 | BIT(1) | BIT(0))); - /* Set MAX RPT MACID */ - usb_write8(Adapter, REG_TX_RPT_CTRL + 1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ - /* Tx RPT Timer. Unit: 32us */ - usb_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0); - - usb_write8(Adapter, REG_EARLY_MODE_CONTROL, 0); - - usb_write16(Adapter, REG_PKT_VO_VI_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ - usb_write16(Adapter, REG_PKT_BE_BK_LIFE_TIME, 0x0400); /* unit: 256us. 256ms */ - - /* Keep RfRegChnlVal for later use. */ - haldata->RfRegChnlVal[0] = rtw_hal_read_rfreg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); - haldata->RfRegChnlVal[1] = rtw_hal_read_rfreg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); - - _BBTurnOnBlock(Adapter); - - invalidate_cam_all(Adapter); - - /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ - phy_set_tx_power_level(Adapter, haldata->CurrentChannel); - -/* Move by Neo for USB SS to below setp */ -/* _RfPowerSave(Adapter); */ - - _InitAntenna_Selection(Adapter); - - /* */ - /* Disable BAR, suggested by Scott */ - /* 2010.04.09 add by hpfan */ - /* */ - usb_write32(Adapter, REG_BAR_MODE_CTRL, 0x0201ffff); - - /* HW SEQ CTRL */ - /* set 0x0 to 0xFF by tynli. Default enable HW SEQ NUM. */ - usb_write8(Adapter, REG_HWSEQ_CTRL, 0xFF); - - if (pregistrypriv->wifi_spec) - usb_write16(Adapter, REG_FAST_EDCA_CTRL, 0); - - /* Nav limit , suggest by scott */ - usb_write8(Adapter, 0x652, 0x0); - - rtl8188e_InitHalDm(Adapter); - - /* 2010/08/11 MH Merge from 8192SE for Minicard init. We need to confirm current radio status */ - /* and then decide to enable RF or not.!!!??? For Selective suspend mode. We may not */ - /* call initstruct adapter. May cause some problem?? */ - /* Fix the bug that Hw/Sw radio off before S3/S4, the RF off action will not be executed */ - /* in MgntActSet_RF_State() after wake up, because the value of haldata->eRFPowerState */ - /* is the same as eRfOff, we should change it to eRfOn after we config RF parameters. */ - /* Added by tynli. 2010.03.30. */ - pwrctrlpriv->rf_pwrstate = rf_on; - - /* enable Tx report. */ - usb_write8(Adapter, REG_FWHW_TXQ_CTRL + 1, 0x0F); - - /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ - usb_write8(Adapter, REG_EARLY_MODE_CONTROL + 3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ - - /* tynli_test_tx_report. */ - usb_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); - - /* enable tx DMA to drop the redundate data of packet */ - usb_write16(Adapter, REG_TXDMA_OFFSET_CHK, (usb_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); - - /* 2010/08/26 MH Merge from 8192CE. */ - if (pwrctrlpriv->rf_pwrstate == rf_on) { - if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { - rtl88eu_phy_iq_calibrate(Adapter, true); - } else { - rtl88eu_phy_iq_calibrate(Adapter, false); - haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; - } - - ODM_TXPowerTrackingCheck(&haldata->odmpriv); - - rtl88eu_phy_lc_calibrate(Adapter); - } - -/* _InitPABias(Adapter); */ - usb_write8(Adapter, REG_USB_HRPWM, 0); - - /* ack for xmit mgmt frames. */ - usb_write32(Adapter, REG_FWHW_TXQ_CTRL, usb_read32(Adapter, REG_FWHW_TXQ_CTRL) | BIT(12)); - -exit: - - return status; -} - -static void CardDisableRTL8188EU(struct adapter *Adapter) -{ - u8 val8; - - /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ - val8 = usb_read8(Adapter, REG_TX_RPT_CTRL); - usb_write8(Adapter, REG_TX_RPT_CTRL, val8 & (~BIT(1))); - - /* stop rx */ - usb_write8(Adapter, REG_CR, 0x0); - - /* Run LPS WL RFOFF flow */ - rtl88eu_pwrseqcmdparsing(Adapter, Rtl8188E_NIC_LPS_ENTER_FLOW); - - /* 2. 0x1F[7:0] = 0 turn off RF */ - - val8 = usb_read8(Adapter, REG_MCUFWDL); - if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */ - /* Reset MCU 0x2[10]=0. */ - val8 = usb_read8(Adapter, REG_SYS_FUNC_EN + 1); - val8 &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ - usb_write8(Adapter, REG_SYS_FUNC_EN + 1, val8); - } - - /* reset MCU ready status */ - usb_write8(Adapter, REG_MCUFWDL, 0); - - /* YJ,add,111212 */ - /* Disable 32k */ - val8 = usb_read8(Adapter, REG_32K_CTRL); - usb_write8(Adapter, REG_32K_CTRL, val8 & (~BIT(0))); - - /* Card disable power action flow */ - rtl88eu_pwrseqcmdparsing(Adapter, Rtl8188E_NIC_DISABLE_FLOW); - - /* Reset MCU IO Wrapper */ - val8 = usb_read8(Adapter, REG_RSV_CTRL + 1); - usb_write8(Adapter, REG_RSV_CTRL + 1, (val8 & (~BIT(3)))); - val8 = usb_read8(Adapter, REG_RSV_CTRL + 1); - usb_write8(Adapter, REG_RSV_CTRL + 1, val8 | BIT(3)); - - /* YJ,test add, 111207. For Power Consumption. */ - val8 = usb_read8(Adapter, GPIO_IN); - usb_write8(Adapter, GPIO_OUT, val8); - usb_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */ - - val8 = usb_read8(Adapter, REG_GPIO_IO_SEL); - usb_write8(Adapter, REG_GPIO_IO_SEL, (val8 << 4)); - val8 = usb_read8(Adapter, REG_GPIO_IO_SEL + 1); - usb_write8(Adapter, REG_GPIO_IO_SEL + 1, val8 | 0x0F);/* Reg0x43 */ - usb_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ - Adapter->HalData->bMacPwrCtrlOn = false; - Adapter->bFWReady = false; -} - -static void rtl8192cu_hw_power_down(struct adapter *adapt) -{ - /* 2010/-8/09 MH For power down module, we need to enable register block contrl reg at 0x1c. */ - /* Then enable power down control bit of register 0x04 BIT4 and BIT15 as 1. */ - - /* Enable register area 0x0-0xc. */ - usb_write8(adapt, REG_RSV_CTRL, 0x0); - usb_write16(adapt, REG_APS_FSMCO, 0x8812); -} - -u32 rtl8188eu_hal_deinit(struct adapter *Adapter) -{ - usb_write32(Adapter, REG_HIMR_88E, IMR_DISABLED_88E); - usb_write32(Adapter, REG_HIMRE_88E, IMR_DISABLED_88E); - - if (Adapter->pwrctrlpriv.bkeepfwalive) { - if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) - rtl8192cu_hw_power_down(Adapter); - } else { - if (Adapter->hw_init_completed) { - CardDisableRTL8188EU(Adapter); - - if ((Adapter->pwrctrlpriv.bHWPwrPindetect) && (Adapter->pwrctrlpriv.bHWPowerdown)) - rtl8192cu_hw_power_down(Adapter); - } - } - return _SUCCESS; -} - -u32 rtw_hal_inirp_init(struct adapter *Adapter) -{ - u8 i; - struct recv_buf *precvbuf; - uint status; - struct recv_priv *precvpriv = &Adapter->recvpriv; - - status = _SUCCESS; - - /* issue Rx irp to receive data */ - precvbuf = precvpriv->precv_buf; - for (i = 0; i < NR_RECVBUFF; i++) { - if (!usb_read_port(Adapter, RECV_BULK_IN_ADDR, precvbuf)) { - status = _FAIL; - goto exit; - } - - precvbuf++; - } - -exit: - return status; -} - -/* */ -/* */ -/* EEPROM/EFUSE Content Parsing */ -/* */ -/* */ -static void Hal_EfuseParsePIDVID_8188EU(struct adapter *adapt, u8 *hwinfo, bool AutoLoadFail) -{ - struct hal_data_8188e *haldata = adapt->HalData; - - if (!AutoLoadFail) { - /* VID, PID */ - haldata->EEPROMVID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_VID_88EU]); - haldata->EEPROMPID = EF2BYTE(*(__le16 *)&hwinfo[EEPROM_PID_88EU]); - - /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ - haldata->EEPROMCustomerID = *(u8 *)&hwinfo[EEPROM_CUSTOMERID_88E]; - haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; - } else { - haldata->EEPROMVID = EEPROM_Default_VID; - haldata->EEPROMPID = EEPROM_Default_PID; - - /* Customer ID, 0x00 and 0xff are reserved for Realtek. */ - haldata->EEPROMCustomerID = EEPROM_Default_CustomerID; - haldata->EEPROMSubCustomerID = EEPROM_Default_SubCustomerID; - } -} - -static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt) -{ - u8 sMacAddr[] = {0x00, 0xE0, 0x4C, 0x81, 0x88, 0x02}; - struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); - u8 *hwinfo = eeprom->efuse_eeprom_data; - - if (eeprom->bautoload_fail_flag) - memcpy(eeprom->mac_addr, sMacAddr, sizeof(sMacAddr)); - else - memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); -} - -static void readAdapterInfo_8188EU(struct adapter *adapt) -{ - struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(adapt); - - /* parse the eeprom/efuse content */ - Hal_EfuseParseIDCode88E(adapt, eeprom->efuse_eeprom_data); - Hal_EfuseParsePIDVID_8188EU(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_EfuseParseMACAddr_8188EU(adapt); - - Hal_ReadPowerSavingMode88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_ReadTxPowerInfo88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_EfuseParseEEPROMVer88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - rtl8188e_EfuseParseChnlPlan(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_EfuseParseXtal_8188E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_EfuseParseCustomerID88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_ReadAntennaDiversity88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_EfuseParseBoardType88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); - Hal_ReadThermalMeter_88E(adapt, eeprom->efuse_eeprom_data, eeprom->bautoload_fail_flag); -} - -void rtw_hal_read_chip_info(struct adapter *Adapter) -{ - struct eeprom_priv *eeprom = GET_EEPROM_EFUSE_PRIV(Adapter); - u8 eeValue = usb_read8(Adapter, REG_9346CR); - - eeprom->bautoload_fail_flag = (eeValue & EEPROM_EN) ? false : true; - - if (eeValue & BOOT_FROM_EEPROM) - EFUSE_ShadowMapUpdate(Adapter); - - readAdapterInfo_8188EU(Adapter); -} - -static void ResumeTxBeacon(struct adapter *adapt) -{ - struct hal_data_8188e *haldata = adapt->HalData; - - /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ - /* which should be read from register to a global variable. */ - - usb_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl) | BIT(6)); - haldata->RegFwHwTxQCtrl |= BIT(6); - usb_write8(adapt, REG_TBTT_PROHIBIT + 1, 0xff); - haldata->RegReg542 |= BIT(0); - usb_write8(adapt, REG_TBTT_PROHIBIT + 2, haldata->RegReg542); -} - -static void StopTxBeacon(struct adapter *adapt) -{ - struct hal_data_8188e *haldata = adapt->HalData; - - /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ - /* which should be read from register to a global variable. */ - - usb_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl) & (~BIT(6))); - haldata->RegFwHwTxQCtrl &= (~BIT(6)); - usb_write8(adapt, REG_TBTT_PROHIBIT + 1, 0x64); - haldata->RegReg542 &= ~(BIT(0)); - usb_write8(adapt, REG_TBTT_PROHIBIT + 2, haldata->RegReg542); - - /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ -} - -static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) -{ - u8 val8; - u8 mode = *((u8 *)val); - - /* disable Port0 TSF update */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) | BIT(4)); - - /* set net_type */ - val8 = usb_read8(Adapter, MSR) & 0x0c; - val8 |= mode; - usb_write8(Adapter, MSR, val8); - - if ((mode == _HW_STATE_STATION_) || (mode == _HW_STATE_NOLINK_)) { - StopTxBeacon(Adapter); - - usb_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ - } else if (mode == _HW_STATE_ADHOC_) { - ResumeTxBeacon(Adapter); - usb_write8(Adapter, REG_BCN_CTRL, 0x1a); - } else if (mode == _HW_STATE_AP_) { - ResumeTxBeacon(Adapter); - - usb_write8(Adapter, REG_BCN_CTRL, 0x12); - - /* Set RCR */ - usb_write32(Adapter, REG_RCR, 0x7000208e);/* CBSSID_DATA must set to 0,reject ICV_ERR packet */ - /* enable to rx data frame */ - usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); - /* enable to rx ps-poll */ - usb_write16(Adapter, REG_RXFLTMAP1, 0x0400); - - /* Beacon Control related register for first time */ - usb_write8(Adapter, REG_BCNDMATIM, 0x02); /* 2ms */ - - usb_write8(Adapter, REG_ATIMWND, 0x0a); /* 10ms */ - usb_write16(Adapter, REG_BCNTCFG, 0x00); - usb_write16(Adapter, REG_TBTT_PROHIBIT, 0xff04); - usb_write16(Adapter, REG_TSFTR_SYN_OFFSET, 0x7fff);/* +32767 (~32ms) */ - - /* reset TSF */ - usb_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); - - /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ - usb_write8(Adapter, REG_MBID_NUM, usb_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); - - /* enable BCN0 Function for if1 */ - /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ - usb_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP | EN_BCN_FUNCTION | BIT(1))); - - /* dis BCN1 ATIM WND if if2 is station */ - usb_write8(Adapter, REG_BCN_CTRL_1, usb_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); - } -} - -static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val) -{ - u8 idx = 0; - u32 reg_macid; - - reg_macid = REG_MACID; - - for (idx = 0; idx < 6; idx++) - usb_write8(Adapter, (reg_macid + idx), val[idx]); -} - -static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) -{ - u8 idx = 0; - u32 reg_bssid; - - reg_bssid = REG_BSSID; - - for (idx = 0; idx < 6; idx++) - usb_write8(Adapter, (reg_bssid + idx), val[idx]); -} - -static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) -{ - u32 bcn_ctrl_reg; - - bcn_ctrl_reg = REG_BCN_CTRL; - - if (*((u8 *)val)) - usb_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); - else - usb_write8(Adapter, bcn_ctrl_reg, usb_read8(Adapter, bcn_ctrl_reg) & (~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); -} - -void rtw_hal_set_hwreg(struct adapter *Adapter, u8 variable, u8 *val) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - struct dm_priv *pdmpriv = &haldata->dmpriv; - struct odm_dm_struct *podmpriv = &haldata->odmpriv; - - switch (variable) { - case HW_VAR_MEDIA_STATUS: - { - u8 val8; - - val8 = usb_read8(Adapter, MSR) & 0x0c; - val8 |= *((u8 *)val); - usb_write8(Adapter, MSR, val8); - } - break; - case HW_VAR_SET_OPMODE: - hw_var_set_opmode(Adapter, variable, val); - break; - case HW_VAR_MAC_ADDR: - hw_var_set_macaddr(Adapter, variable, val); - break; - case HW_VAR_BSSID: - hw_var_set_bssid(Adapter, variable, val); - break; - case HW_VAR_BASIC_RATE: - { - u16 BrateCfg = 0; - u8 RateIndex = 0; - - /* 2007.01.16, by Emily */ - /* Select RRSR (in Legacy-OFDM and CCK) */ - /* For 8190, we select only 24M, 12M, 6M, 11M, 5.5M, 2M, and 1M from the Basic rate. */ - /* We do not use other rates. */ - hal_set_brate_cfg(val, &BrateCfg); - - /* 2011.03.30 add by Luke Lee */ - /* CCK 2M ACK should be disabled for some BCM and Atheros AP IOT */ - /* because CCK 2M has poor TXEVM */ - /* CCK 5.5M & 11M ACK should be enabled for better performance */ - - BrateCfg = (BrateCfg | 0xd) & 0x15d; - haldata->BasicRateSet = BrateCfg; - - BrateCfg |= 0x01; /* default enable 1M ACK rate */ - /* Set RRSR rate table. */ - usb_write8(Adapter, REG_RRSR, BrateCfg & 0xff); - usb_write8(Adapter, REG_RRSR + 1, (BrateCfg >> 8) & 0xff); - usb_write8(Adapter, REG_RRSR + 2, usb_read8(Adapter, REG_RRSR + 2) & 0xf0); - - /* Set RTS initial rate */ - while (BrateCfg > 0x1) { - BrateCfg >>= 1; - RateIndex++; - } - /* Ziv - Check */ - usb_write8(Adapter, REG_INIRTS_RATE_SEL, RateIndex); - } - break; - case HW_VAR_BCN_FUNC: - hw_var_set_bcn_func(Adapter, variable, val); - break; - case HW_VAR_CORRECT_TSF: - { - u64 tsf; - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval * 1024)) - 1024; /* us */ - - if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) - StopTxBeacon(Adapter); - - /* disable related TSF function */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) & (~BIT(3))); - - usb_write32(Adapter, REG_TSFTR, tsf); - usb_write32(Adapter, REG_TSFTR + 4, tsf >> 32); - - /* enable related TSF function */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) | BIT(3)); - - if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) - ResumeTxBeacon(Adapter); - } - break; - case HW_VAR_CHECK_BSSID: - if (*((u8 *)val)) { - usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR) | RCR_CBSSID_DATA | RCR_CBSSID_BCN); - } else { - u32 val32; - - val32 = usb_read32(Adapter, REG_RCR); - - val32 &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN); - - usb_write32(Adapter, REG_RCR, val32); - } - break; - case HW_VAR_MLME_DISCONNECT: - /* Set RCR to not to receive data frame when NO LINK state */ - /* reject all data frames */ - usb_write16(Adapter, REG_RXFLTMAP2, 0x00); - - /* reset TSF */ - usb_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0) | BIT(1))); - - /* disable update TSF */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) | BIT(4)); - break; - case HW_VAR_MLME_SITESURVEY: - if (*((u8 *)val)) { /* under sitesurvey */ - /* config RCR to receive different BSSID & not to receive data frame */ - u32 v = usb_read32(Adapter, REG_RCR); - - v &= ~(RCR_CBSSID_BCN); - usb_write32(Adapter, REG_RCR, v); - /* reject all data frame */ - usb_write16(Adapter, REG_RXFLTMAP2, 0x00); - - /* disable update TSF */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) | BIT(4)); - } else { /* sitesurvey done */ - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - if ((is_client_associated_to_ap(Adapter)) || - ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) { - /* enable to rx data frame */ - usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); - - /* enable update TSF */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) & (~BIT(4))); - } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { - usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); - /* enable update TSF */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) & (~BIT(4))); - } - - usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR) | RCR_CBSSID_BCN); - } - break; - case HW_VAR_MLME_JOIN: - { - u8 RetryLimit = 0x30; - u8 type = *((u8 *)val); - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - - if (type == 0) { /* prepare to join */ - /* enable to rx data frame.Accept all data frame */ - usb_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); - - usb_write32(Adapter, REG_RCR, usb_read32(Adapter, REG_RCR) | RCR_CBSSID_DATA | RCR_CBSSID_BCN); - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - RetryLimit = (haldata->CustomerID == RT_CID_CCX) ? 7 : 48; - else /* Ad-hoc Mode */ - RetryLimit = 0x7; - } else if (type == 1) { - /* joinbss_event call back when join res < 0 */ - usb_write16(Adapter, REG_RXFLTMAP2, 0x00); - } else if (type == 2) { - /* sta add event call back */ - /* enable update TSF */ - usb_write8(Adapter, REG_BCN_CTRL, usb_read8(Adapter, REG_BCN_CTRL) & (~BIT(4))); - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) - RetryLimit = 0x7; - } - usb_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); - } - break; - case HW_VAR_BEACON_INTERVAL: - usb_write16(Adapter, REG_BCN_INTERVAL, *((u16 *)val)); - break; - case HW_VAR_SLOT_TIME: - { - u8 u1bAIFS, aSifsTime; - struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - usb_write8(Adapter, REG_SLOT, val[0]); - - if (pmlmeinfo->WMM_enable == 0) { - if (pmlmeext->cur_wireless_mode == WIRELESS_11B) - aSifsTime = 10; - else - aSifsTime = 16; - - u1bAIFS = aSifsTime + (2 * pmlmeinfo->slotTime); - - /* Temporary removed, 2008.06.20. */ - usb_write8(Adapter, REG_EDCA_VO_PARAM, u1bAIFS); - usb_write8(Adapter, REG_EDCA_VI_PARAM, u1bAIFS); - usb_write8(Adapter, REG_EDCA_BE_PARAM, u1bAIFS); - usb_write8(Adapter, REG_EDCA_BK_PARAM, u1bAIFS); - } - } - break; - case HW_VAR_RESP_SIFS: - /* RESP_SIFS for CCK */ - usb_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ - usb_write8(Adapter, REG_R2T_SIFS + 1, val[1]); /* SIFS_R2T_CCK(0x08) */ - /* RESP_SIFS for OFDM */ - usb_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ - usb_write8(Adapter, REG_T2T_SIFS + 1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ - break; - case HW_VAR_ACK_PREAMBLE: - { - u8 regTmp; - u8 bShortPreamble = *((bool *)val); - /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ - regTmp = (haldata->nCur40MhzPrimeSC) << 5; - if (bShortPreamble) - regTmp |= 0x80; - - usb_write8(Adapter, REG_RRSR + 2, regTmp); - } - break; - case HW_VAR_SEC_CFG: - usb_write8(Adapter, REG_SECCFG, *((u8 *)val)); - break; - case HW_VAR_DM_FUNC_OP: - if (val[0]) - podmpriv->BK_SupportAbility = podmpriv->SupportAbility; - else - podmpriv->SupportAbility = podmpriv->BK_SupportAbility; - break; - case HW_VAR_DM_FUNC_SET: - if (*((u32 *)val) == DYNAMIC_ALL_FUNC_ENABLE) { - pdmpriv->DMFlag = pdmpriv->InitDMFlag; - podmpriv->SupportAbility = pdmpriv->InitODMFlag; - } else { - podmpriv->SupportAbility |= *((u32 *)val); - } - break; - case HW_VAR_DM_FUNC_CLR: - podmpriv->SupportAbility &= *((u32 *)val); - break; - case HW_VAR_CAM_EMPTY_ENTRY: - { - u8 ucIndex = *((u8 *)val); - u8 i; - u32 ulCommand = 0; - u32 ulContent = 0; - u32 ulEncAlgo = CAM_AES; - - for (i = 0; i < CAM_CONTENT_COUNT; i++) { - /* filled id in CAM config 2 byte */ - if (i == 0) - ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo) << 2); - else - ulContent = 0; - /* polling bit, and No Write enable, and address */ - ulCommand = CAM_CONTENT_COUNT * ucIndex + i; - ulCommand = ulCommand | CAM_POLLINIG | - CAM_WRITE; - /* write content 0 is equall to mark invalid */ - usb_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ - usb_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ - } - } - break; - case HW_VAR_CAM_INVALID_ALL: - usb_write32(Adapter, RWCAM, BIT(31) | BIT(30)); - break; - case HW_VAR_CAM_WRITE: - { - u32 cmd; - u32 *cam_val = (u32 *)val; - - usb_write32(Adapter, WCAMI, cam_val[0]); - - cmd = CAM_POLLINIG | CAM_WRITE | cam_val[1]; - usb_write32(Adapter, RWCAM, cmd); - } - break; - case HW_VAR_AC_PARAM_VO: - usb_write32(Adapter, REG_EDCA_VO_PARAM, ((u32 *)(val))[0]); - break; - case HW_VAR_AC_PARAM_VI: - usb_write32(Adapter, REG_EDCA_VI_PARAM, ((u32 *)(val))[0]); - break; - case HW_VAR_AC_PARAM_BE: - haldata->AcParam_BE = ((u32 *)(val))[0]; - usb_write32(Adapter, REG_EDCA_BE_PARAM, ((u32 *)(val))[0]); - break; - case HW_VAR_AC_PARAM_BK: - usb_write32(Adapter, REG_EDCA_BK_PARAM, ((u32 *)(val))[0]); - break; - case HW_VAR_ACM_CTRL: - { - u8 acm_ctrl = *((u8 *)val); - u8 AcmCtrl = usb_read8(Adapter, REG_ACMHWCTRL); - - if (acm_ctrl > 1) - AcmCtrl = AcmCtrl | 0x1; - - if (acm_ctrl & BIT(3)) - AcmCtrl |= AcmHw_VoqEn; - else - AcmCtrl &= (~AcmHw_VoqEn); - - if (acm_ctrl & BIT(2)) - AcmCtrl |= AcmHw_ViqEn; - else - AcmCtrl &= (~AcmHw_ViqEn); - - if (acm_ctrl & BIT(1)) - AcmCtrl |= AcmHw_BeqEn; - else - AcmCtrl &= (~AcmHw_BeqEn); - - usb_write8(Adapter, REG_ACMHWCTRL, AcmCtrl); - } - break; - case HW_VAR_AMPDU_MIN_SPACE: - { - u8 MinSpacingToSet; - u8 SecMinSpace; - - MinSpacingToSet = *((u8 *)val); - if (MinSpacingToSet <= 7) { - switch (Adapter->securitypriv.dot11PrivacyAlgrthm) { - case _NO_PRIVACY_: - case _AES_: - SecMinSpace = 0; - break; - case _WEP40_: - case _WEP104_: - case _TKIP_: - case _TKIP_WTMIC_: - SecMinSpace = 6; - break; - default: - SecMinSpace = 7; - break; - } - if (MinSpacingToSet < SecMinSpace) - MinSpacingToSet = SecMinSpace; - usb_write8(Adapter, REG_AMPDU_MIN_SPACE, (usb_read8(Adapter, REG_AMPDU_MIN_SPACE) & 0xf8) | MinSpacingToSet); - } - } - break; - case HW_VAR_AMPDU_FACTOR: - { - u8 RegToSet_Normal[4] = {0x41, 0xa8, 0x72, 0xb9}; - u8 FactorToSet; - u8 *pRegToSet; - u8 index = 0; - - pRegToSet = RegToSet_Normal; /* 0xb972a841; */ - FactorToSet = *((u8 *)val); - if (FactorToSet <= 3) { - FactorToSet = 1 << (FactorToSet + 2); - if (FactorToSet > 0xf) - FactorToSet = 0xf; - - for (index = 0; index < 4; index++) { - if ((pRegToSet[index] & 0xf0) > (FactorToSet << 4)) - pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet << 4); - - if ((pRegToSet[index] & 0x0f) > FactorToSet) - pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); - - usb_write8(Adapter, (REG_AGGLEN_LMT + index), pRegToSet[index]); - } - } - } - break; - case HW_VAR_RXDMA_AGG_PG_TH: - { - u8 threshold = *((u8 *)val); - - if (threshold == 0) - threshold = haldata->UsbRxAggPageCount; - usb_write8(Adapter, REG_RXDMA_AGG_PG_TH, threshold); - } - break; - case HW_VAR_SET_RPWM: - break; - case HW_VAR_H2C_FW_PWRMODE: - { - u8 psmode = (*(u8 *)val); - - /* Forece leave RF low power mode for 1T1R to prevent conficting setting in Fw power */ - /* saving sequence. 2010.06.07. Added by tynli. Suggested by SD3 yschang. */ - if (psmode != PS_MODE_ACTIVE) - ODM_RF_Saving(podmpriv, true); - rtl8188e_set_FwPwrMode_cmd(Adapter, psmode); - } - break; - case HW_VAR_H2C_FW_JOINBSSRPT: - { - u8 mstatus = (*(u8 *)val); - - rtl8188e_set_FwJoinBssReport_cmd(Adapter, mstatus); - } - break; - case HW_VAR_INITIAL_GAIN: - { - struct rtw_dig *pDigTable = &podmpriv->DM_DigTable; - u32 rx_gain = ((u32 *)(val))[0]; - - if (rx_gain == 0xff) {/* restore rx gain */ - ODM_Write_DIG(podmpriv, pDigTable->BackupIGValue); - } else { - pDigTable->BackupIGValue = pDigTable->CurIGValue; - ODM_Write_DIG(podmpriv, rx_gain); - } - } - break; - case HW_VAR_RPT_TIMER_SETTING: - { - u16 min_rpt_time = (*(u16 *)val); - - ODM_RA_Set_TxRPT_Time(podmpriv, min_rpt_time); - } - break; - case HW_VAR_ANTENNA_DIVERSITY_SELECT: - { - u8 Optimum_antenna = (*(u8 *)val); - u8 Ant; - /* switch antenna to Optimum_antenna */ - if (haldata->CurAntenna != Optimum_antenna) { - Ant = (Optimum_antenna == 2) ? MAIN_ANT : AUX_ANT; - rtl88eu_dm_update_rx_idle_ant(&haldata->odmpriv, Ant); - - haldata->CurAntenna = Optimum_antenna; - } - } - break; - case HW_VAR_EFUSE_BYTES: /* To set EFUE total used bytes, added by Roger, 2008.12.22. */ - haldata->EfuseUsedBytes = *((u16 *)val); - break; - case HW_VAR_FIFO_CLEARN_UP: - { - struct pwrctrl_priv *pwrpriv = &Adapter->pwrctrlpriv; - u8 trycnt = 100; - - /* pause tx */ - usb_write8(Adapter, REG_TXPAUSE, 0xff); - - /* keep sn */ - Adapter->xmitpriv.nqos_ssn = usb_read16(Adapter, REG_NQOS_SEQ); - - if (!pwrpriv->bkeepfwalive) { - /* RX DMA stop */ - usb_write32(Adapter, REG_RXPKT_NUM, (usb_read32(Adapter, REG_RXPKT_NUM) | RW_RELEASE_EN)); - do { - if (!(usb_read32(Adapter, REG_RXPKT_NUM) & RXDMA_IDLE)) - break; - } while (--trycnt); - - /* RQPN Load 0 */ - usb_write16(Adapter, REG_RQPN_NPQ, 0x0); - usb_write32(Adapter, REG_RQPN, 0x80000000); - mdelay(10); - } - } - break; - case HW_VAR_CHECK_TXBUF: - break; - case HW_VAR_APFM_ON_MAC: - haldata->bMacPwrCtrlOn = *val; - break; - case HW_VAR_TX_RPT_MAX_MACID: - { - u8 maxMacid = *val; - - usb_write8(Adapter, REG_TX_RPT_CTRL + 1, maxMacid + 1); - } - break; - case HW_VAR_H2C_MEDIA_STATUS_RPT: - rtl8188e_set_FwMediaStatus_cmd(Adapter, (*(__le16 *)val)); - break; - case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ - usb_write8(Adapter, REG_TDECTRL + 2, usb_read8(Adapter, REG_TDECTRL + 2) | BIT(0)); - break; - default: - break; - } -} - -void rtw_hal_get_hwreg(struct adapter *Adapter, u8 variable, u8 *val) -{ - switch (variable) { - case HW_VAR_BASIC_RATE: - *((u16 *)(val)) = Adapter->HalData->BasicRateSet; - fallthrough; - case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ - val[0] = (BIT(0) & usb_read8(Adapter, REG_TDECTRL + 2)) ? true : false; - break; - case HW_VAR_FWLPS_RF_ON: - { - /* When we halt NIC, we should check if FW LPS is leave. */ - if (Adapter->pwrctrlpriv.rf_pwrstate == rf_off) { - /* If it is in HW/SW Radio OFF or IPS state, we do not check Fw LPS Leave, */ - /* because Fw is unload. */ - val[0] = true; - } else { - u32 valRCR; - - valRCR = usb_read32(Adapter, REG_RCR); - valRCR &= 0x00070000; - if (valRCR) - val[0] = false; - else - val[0] = true; - } - } - break; - case HW_VAR_CURRENT_ANTENNA: - val[0] = Adapter->HalData->CurAntenna; - break; - case HW_VAR_EFUSE_BYTES: /* To get EFUE total used bytes, added by Roger, 2008.12.22. */ - *((u16 *)(val)) = Adapter->HalData->EfuseUsedBytes; - break; - case HW_VAR_APFM_ON_MAC: - *val = Adapter->HalData->bMacPwrCtrlOn; - break; - case HW_VAR_CHK_HI_QUEUE_EMPTY: - *val = ((usb_read32(Adapter, REG_HGQ_INFORMATION) & 0x0000ff00) == 0) ? true : false; - break; - default: - break; - } -} - -/* */ -/* Description: */ -/* Query setting of specified variable. */ -/* */ -u8 rtw_hal_get_def_var(struct adapter *Adapter, enum hal_def_variable eVariable, - void *pValue) -{ - struct hal_data_8188e *haldata = Adapter->HalData; - u8 bResult = _SUCCESS; - - switch (eVariable) { - case HAL_DEF_UNDERCORATEDSMOOTHEDPWDB: - { - struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; - struct sta_priv *pstapriv = &Adapter->stapriv; - struct sta_info *psta; - - psta = rtw_get_stainfo(pstapriv, pmlmepriv->cur_network.network.MacAddress); - if (psta) - *((int *)pValue) = psta->rssi_stat.UndecoratedSmoothedPWDB; - } - break; - case HAL_DEF_IS_SUPPORT_ANT_DIV: - *((u8 *)pValue) = (haldata->AntDivCfg == 0) ? false : true; - break; - case HAL_DEF_CURRENT_ANTENNA: - *((u8 *)pValue) = haldata->CurAntenna; - break; - case HAL_DEF_DRVINFO_SZ: - *((u32 *)pValue) = DRVINFO_SZ; - break; - case HAL_DEF_MAX_RECVBUF_SZ: - *((u32 *)pValue) = MAX_RECVBUF_SZ; - break; - case HAL_DEF_RX_PACKET_OFFSET: - *((u32 *)pValue) = RXDESC_SIZE + DRVINFO_SZ; - break; - case HAL_DEF_DBG_DM_FUNC: - *((u32 *)pValue) = haldata->odmpriv.SupportAbility; - break; - case HAL_DEF_RA_DECISION_RATE: - { - u8 MacID = *((u8 *)pValue); - - *((u8 *)pValue) = ODM_RA_GetDecisionRate_8188E(&haldata->odmpriv, MacID); - } - break; - case HAL_DEF_RA_SGI: - { - u8 MacID = *((u8 *)pValue); - - *((u8 *)pValue) = ODM_RA_GetShortGI_8188E(&haldata->odmpriv, MacID); - } - break; - case HAL_DEF_PT_PWR_STATUS: - { - u8 MacID = *((u8 *)pValue); - - *((u8 *)pValue) = ODM_RA_GetHwPwrStatus_8188E(&haldata->odmpriv, MacID); - } - break; - case HW_VAR_MAX_RX_AMPDU_FACTOR: - *((u32 *)pValue) = MAX_AMPDU_FACTOR_64K; - break; - case HW_DEF_RA_INFO_DUMP: - break; - case HAL_DEF_DBG_DUMP_RXPKT: - *((u8 *)pValue) = haldata->bDumpRxPkt; - break; - case HAL_DEF_DBG_DUMP_TXPKT: - *((u8 *)pValue) = haldata->bDumpTxPkt; - break; - default: - bResult = _FAIL; - break; - } - - return bResult; -} - -void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level) -{ - u8 init_rate = 0; - u8 networkType, raid; - u32 mask, rate_bitmap; - u8 shortGIrate = false; - int supportRateNum = 0; - struct sta_info *psta; - struct odm_dm_struct *odmpriv = &adapt->HalData->odmpriv; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; - - if (mac_id >= NUM_STA) /* CAM_SIZE */ - return; - psta = pmlmeinfo->FW_sta_info[mac_id].psta; - if (!psta) - return; - switch (mac_id) { - case 0:/* for infra mode */ - supportRateNum = rtw_get_rateset_len(cur_network->SupportedRates); - networkType = judge_network_type(adapt, cur_network->SupportedRates) & 0xf; - raid = networktype_to_raid(networkType); - mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); - mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&pmlmeinfo->HT_caps) : 0; - if (support_short_GI(adapt, &pmlmeinfo->HT_caps)) - shortGIrate = true; - break; - case 1:/* for broadcast/multicast */ - supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); - if (pmlmeext->cur_wireless_mode & WIRELESS_11B) - networkType = WIRELESS_11B; - else - networkType = WIRELESS_11G; - raid = networktype_to_raid(networkType); - mask = update_basic_rate(cur_network->SupportedRates, supportRateNum); - break; - default: /* for each sta in IBSS */ - supportRateNum = rtw_get_rateset_len(pmlmeinfo->FW_sta_info[mac_id].SupportedRates); - networkType = judge_network_type(adapt, pmlmeinfo->FW_sta_info[mac_id].SupportedRates) & 0xf; - raid = networktype_to_raid(networkType); - mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); - - /* todo: support HT in IBSS */ - break; - } - - rate_bitmap = ODM_Get_Rate_Bitmap(odmpriv, mac_id, mask, rssi_level); - - mask &= rate_bitmap; - - init_rate = get_highest_rate_idx(mask) & 0x3f; - - ODM_RA_UpdateRateInfo_8188E(odmpriv, mac_id, raid, mask, shortGIrate); - - /* set ra_id */ - psta->raid = raid; - psta->init_rate = init_rate; -} - -void beacon_timing_control(struct adapter *adapt) -{ - u32 value32; - struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - u32 bcn_ctrl_reg = REG_BCN_CTRL; - /* reset TSF, enable update TSF, correcting TSF On Beacon */ - - /* BCN interval */ - usb_write16(adapt, REG_BCN_INTERVAL, pmlmeinfo->bcn_interval); - usb_write8(adapt, REG_ATIMWND, 0x02);/* 2ms */ - - _InitBeaconParameters(adapt); - - usb_write8(adapt, REG_SLOT, 0x09); - - value32 = usb_read32(adapt, REG_TCR); - value32 &= ~TSFRST; - usb_write32(adapt, REG_TCR, value32); - - value32 |= TSFRST; - usb_write32(adapt, REG_TCR, value32); - - /* NOTE: Fix test chip's bug (about contention windows's randomness) */ - usb_write8(adapt, REG_RXTSF_OFFSET_CCK, 0x50); - usb_write8(adapt, REG_RXTSF_OFFSET_OFDM, 0x50); - - _BeaconFunctionEnable(adapt); - - ResumeTxBeacon(adapt); - - usb_write8(adapt, bcn_ctrl_reg, usb_read8(adapt, bcn_ctrl_reg) | BIT(1)); -} - -void rtw_hal_def_value_init(struct adapter *adapt) -{ - struct hal_data_8188e *haldata = adapt->HalData; - struct pwrctrl_priv *pwrctrlpriv; - u8 i; - - pwrctrlpriv = &adapt->pwrctrlpriv; - - /* init default value */ - if (!pwrctrlpriv->bkeepfwalive) - haldata->LastHMEBoxNum = 0; - - /* init dm default value */ - haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = false; - haldata->odmpriv.RFCalibrateInfo.TM_Trigger = 0;/* for IQK */ - haldata->pwrGroupCnt = 0; - haldata->PGMaxGroup = 13; - haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP_index = 0; - for (i = 0; i < HP_THERMAL_NUM; i++) - haldata->odmpriv.RFCalibrateInfo.ThermalValue_HP[i] = 0; -} diff --git a/drivers/staging/rtl8188eu/include/HalVerDef.h b/drivers/staging/rtl8188eu/include/HalVerDef.h deleted file mode 100644 index 63a144ee2183..000000000000 --- a/drivers/staging/rtl8188eu/include/HalVerDef.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __HAL_VERSION_DEF_H__ -#define __HAL_VERSION_DEF_H__ - -enum HAL_CHIP_TYPE { - TEST_CHIP = 0, - NORMAL_CHIP = 1, - FPGA = 2, -}; - -enum HAL_CUT_VERSION { - A_CUT_VERSION = 0, - B_CUT_VERSION = 1, - C_CUT_VERSION = 2, - D_CUT_VERSION = 3, - E_CUT_VERSION = 4, - F_CUT_VERSION = 5, - G_CUT_VERSION = 6, -}; - -enum HAL_VENDOR { - CHIP_VENDOR_TSMC = 0, - CHIP_VENDOR_UMC = 1, -}; - -struct HAL_VERSION { - enum HAL_CHIP_TYPE ChipType; - enum HAL_CUT_VERSION CUTVersion; - enum HAL_VENDOR VendorType; -}; - -#endif diff --git a/drivers/staging/rtl8188eu/include/basic_types.h b/drivers/staging/rtl8188eu/include/basic_types.h deleted file mode 100644 index b69b45d95402..000000000000 --- a/drivers/staging/rtl8188eu/include/basic_types.h +++ /dev/null @@ -1,134 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __BASIC_TYPES_H__ -#define __BASIC_TYPES_H__ - -#include -#define NDIS_OID uint - -/* port from fw */ -/* TODO: Macros Below are Sync from SD7-Driver. It is necessary - * to check correctness - */ - -/* - * Call endian free function when - * 1. Read/write packet content. - * 2. Before write integer to IO. - * 3. After read integer from IO. - */ - -/* Convert little data endian to host ordering */ -#define EF1BYTE(_val) \ - ((u8)(_val)) -#define EF2BYTE(_val) \ - (le16_to_cpu(_val)) -#define EF4BYTE(_val) \ - (le32_to_cpu(_val)) - -/* Create a bit mask - * Examples: - * BIT_LEN_MASK_32(0) => 0x00000000 - * BIT_LEN_MASK_32(1) => 0x00000001 - * BIT_LEN_MASK_32(2) => 0x00000003 - * BIT_LEN_MASK_32(32) => 0xFFFFFFFF - */ -#define BIT_LEN_MASK_32(__bitlen) \ - (0xFFFFFFFF >> (32 - (__bitlen))) -#define BIT_LEN_MASK_16(__bitlen) \ - (0xFFFF >> (16 - (__bitlen))) -#define BIT_LEN_MASK_8(__bitlen) \ - (0xFF >> (8 - (__bitlen))) - -/* Create an offset bit mask - * Examples: - * BIT_OFFSET_LEN_MASK_32(0, 2) => 0x00000003 - * BIT_OFFSET_LEN_MASK_32(16, 2) => 0x00030000 - */ -#define BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen) \ - (BIT_LEN_MASK_32(__bitlen) << (__bitoffset)) -#define BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen) \ - (BIT_LEN_MASK_16(__bitlen) << (__bitoffset)) -#define BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen) \ - (BIT_LEN_MASK_8(__bitlen) << (__bitoffset)) - -/*Description: - * Return 4-byte value in host byte ordering from - * 4-byte pointer in little-endian system. - */ -#define LE_P4BYTE_TO_HOST_4BYTE(__pstart) \ - (EF4BYTE(*((__le32 *)(__pstart)))) -#define LE_P2BYTE_TO_HOST_2BYTE(__pstart) \ - (EF2BYTE(*((__le16 *)(__pstart)))) -#define LE_P1BYTE_TO_HOST_1BYTE(__pstart) \ - (EF1BYTE(*((u8 *)(__pstart)))) - -/* Description: - * Translate subfield (continuous bits in little-endian) of 4-byte - * value to host byte ordering. - */ -#define LE_BITS_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - (LE_P4BYTE_TO_HOST_4BYTE(__pstart) >> (__bitoffset)) & \ - BIT_LEN_MASK_32(__bitlen) \ - ) -#define LE_BITS_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - (LE_P2BYTE_TO_HOST_2BYTE(__pstart) >> (__bitoffset)) & \ - BIT_LEN_MASK_16(__bitlen) \ - ) -#define LE_BITS_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - (LE_P1BYTE_TO_HOST_1BYTE(__pstart) >> (__bitoffset)) & \ - BIT_LEN_MASK_8(__bitlen) \ - ) - -/* Description: - * Mask subfield (continuous bits in little-endian) of 4-byte value - * and return the result in 4-byte value in host byte ordering. - */ -#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ - (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \ - ) -#define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \ - (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \ - ) -#define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \ - (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ - ) - -/* Description: - * Set subfield of little-endian 4-byte value to specified value. - */ -#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \ - *((u32 *)(__pstart)) = \ - ( \ - LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ - ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \ - ) - -#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \ - *((u16 *)(__pstart)) = \ - ( \ - LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ - ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \ - ); - -#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ - *((u8 *)(__pstart)) = EF1BYTE \ - ( \ - LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ - ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ - ) - -#endif /* __BASIC_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/drv_types.h b/drivers/staging/rtl8188eu/include/drv_types.h deleted file mode 100644 index 3609a44ed078..000000000000 --- a/drivers/staging/rtl8188eu/include/drv_types.h +++ /dev/null @@ -1,176 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -/*----------------------------------------------------------------------------- - - For type defines and data structure defines - -------------------------------------------------------------------------------*/ - -#ifndef __DRV_TYPES_H__ -#define __DRV_TYPES_H__ - -#define DRV_NAME "r8188eu" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -struct qos_priv { - /* bit mask option: u-apsd, s-apsd, ts, block ack... */ - unsigned int qos_option; -}; - -#include -#include -#include -#include -#include -#include - -#define SPEC_DEV_ID_NONE BIT(0) -#define SPEC_DEV_ID_DISABLE_HT BIT(1) -#define SPEC_DEV_ID_ENABLE_PS BIT(2) -#define SPEC_DEV_ID_RF_CONFIG_1T1R BIT(3) -#define SPEC_DEV_ID_RF_CONFIG_2T2R BIT(4) -#define SPEC_DEV_ID_ASSIGN_IFNAME BIT(5) - -struct registry_priv { - struct ndis_802_11_ssid ssid; - u8 channel;/* ad-hoc support requirement */ - u8 wireless_mode;/* A, B, G, auto */ - u8 preamble;/* long, short, auto */ - u8 vrtl_carrier_sense;/* Enable, Disable, Auto */ - u8 vcs_type;/* RTS/CTS, CTS-to-self */ - u16 rts_thresh; - u16 frag_thresh; - u8 power_mgnt; - u8 ips_mode; - u8 smart_ps; - u8 mp_mode; - u8 acm_method; - /* UAPSD */ - u8 wmm_enable; - u8 uapsd_enable; - - struct wlan_bssid_ex dev_network; - - u8 ht_enable; - u8 cbw40_enable; - u8 ampdu_enable;/* for tx */ - u8 rx_stbc; - u8 ampdu_amsdu;/* A-MPDU Supports A-MSDU is permitted */ - - u8 wifi_spec;/* !turbo_mode */ - - u8 channel_plan; - bool accept_addba_req; /* true = accept AP's Add BA req */ - - u8 antdiv_cfg; - u8 antdiv_type; - - u8 usbss_enable;/* 0:disable,1:enable */ - u8 hwpdn_mode;/* 0:disable,1:enable,2:decide by EFUSE config */ - - u8 max_roaming_times; /* the max number driver will try */ - - u8 fw_iol; /* enable iol without other concern */ - - u8 enable80211d; - - u8 ifname[16]; - u8 if2name[16]; - - u8 notch_filter; - bool monitor_enable; -}; - -#define MAX_CONTINUAL_URB_ERR 4 - -struct dvobj_priv { - struct adapter *if1; - /* For 92D, DMDP have 2 interface. */ - u8 InterfaceNumber; - u8 NumInterfaces; - - /* In /Out Pipe information */ - int RtInPipe[2]; - int RtOutPipe[3]; - u8 Queue2Pipe[HW_QUEUE_ENTRY];/* for out pipe mapping */ - -/*-------- below is for USB INTERFACE --------*/ - u8 ishighspeed; - u8 RtNumInPipes; - u8 RtNumOutPipes; - struct mutex usb_vendor_req_mutex; - - struct usb_interface *pusbintf; - struct usb_device *pusbdev; -}; - -static inline struct device *dvobj_to_dev(struct dvobj_priv *dvobj) -{ - /* todo: get interface type from dvobj and the return - * the dev accordingly - */ - return &dvobj->pusbintf->dev; -}; - -struct adapter { - struct dvobj_priv *dvobj; - struct mlme_priv mlmepriv; - struct mlme_ext_priv mlmeextpriv; - struct cmd_priv cmdpriv; - struct xmit_priv xmitpriv; - struct recv_priv recvpriv; - struct sta_priv stapriv; - struct security_priv securitypriv; - struct registry_priv registrypriv; - struct pwrctrl_priv pwrctrlpriv; - struct eeprom_priv eeprompriv; - struct led_priv ledpriv; - - struct hal_data_8188e *HalData; - - s32 bDriverStopped; - s32 bSurpriseRemoved; - - u8 hw_init_completed; - - struct task_struct *cmdThread; - struct net_device *pnetdev; - struct net_device *pmondev; - - int bup; - struct net_device_stats stats; - struct iw_statistics iwstats; - struct proc_dir_entry *dir_dev;/* for proc directory */ - - int net_closed; - u8 bFWReady; - u8 bReadPortCancel; - u8 bWritePortCancel; - - struct mutex hw_init_mutex; -}; - -#define adapter_to_dvobj(adapter) (adapter->dvobj) - -static inline u8 *myid(struct eeprom_priv *peepriv) -{ - return peepriv->mac_addr; -} - -#endif /* __DRV_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/fw.h b/drivers/staging/rtl8188eu/include/fw.h deleted file mode 100644 index 9f010c4b8f9c..000000000000 --- a/drivers/staging/rtl8188eu/include/fw.h +++ /dev/null @@ -1,44 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2009-2013 Realtek Corporation. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * Larry Finger - * - *****************************************************************************/ -#include "drv_types.h" -#include - -#ifndef __RTL92C__FW__H__ -#define __RTL92C__FW__H__ - -#define FW_8192C_START_ADDRESS 0x1000 -#define FW_8192C_PAGE_SIZE 4096 -#define FW_8192C_POLLING_DELAY 5 - -struct rtl92c_firmware_header { - __le16 signature; - u8 category; - u8 function; - u16 version; - u8 subversion; - u8 rsvd1; - u8 month; - u8 date; - u8 hour; - u8 minute; - u16 ramcodesize; - u16 rsvd2; - u32 svnindex; - u32 rsvd3; - u32 rsvd4; - u32 rsvd5; -}; - -int rtl88eu_download_fw(struct adapter *adapt); - -#endif diff --git a/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h b/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h deleted file mode 100644 index a1055ceb7206..000000000000 --- a/drivers/staging/rtl8188eu/include/hal8188e_phy_cfg.h +++ /dev/null @@ -1,175 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __INC_HAL8188EPHYCFG_H__ -#define __INC_HAL8188EPHYCFG_H__ - -#define LOOP_LIMIT 5 -#define MAX_STALL_TIME 50 /* us */ -#define AntennaDiversityValue 0x80 -#define MAX_TXPWR_IDX_NMODE_92S 63 -#define Reset_Cnt_Limit 3 - -#define MAX_AGGR_NUM 0x07 - -enum sw_chnl_cmd_id { - CmdID_End, - CmdID_SetTxPowerLevel, - CmdID_BBRegWrite10, - CmdID_WritePortUlong, - CmdID_WritePortUshort, - CmdID_WritePortUchar, - CmdID_RF_WriteReg, -}; - -/* 1. Switch channel related */ -struct sw_chnl_cmd { - enum sw_chnl_cmd_id CmdID; - u32 Para1; - u32 Para2; - u32 msDelay; -}; - -enum hw90_block { - HW90_BLOCK_MAC = 0, - HW90_BLOCK_PHY0 = 1, - HW90_BLOCK_PHY1 = 2, - HW90_BLOCK_RF = 3, - HW90_BLOCK_MAXIMUM = 4, /* Never use this */ -}; - -enum rf_radio_path { - RF_PATH_A = 0, /* Radio Path A */ - RF_PATH_B = 1, /* Radio Path B */ -}; - -#define MAX_PG_GROUP 13 - -#define RF_PATH_MAX 2 -#define MAX_RF_PATH RF_PATH_MAX -#define MAX_TX_COUNT 4 /* path numbers */ - -#define CHANNEL_MAX_NUMBER 14 /* 14 is the max chnl number */ -#define MAX_CHNL_GROUP_24G 6 /* ch1~2, ch3~5, ch6~8, - *ch9~11, ch12~13, CH 14 - * total three groups - */ -#define CHANNEL_GROUP_MAX_88E 6 - -enum wireless_mode { - WIRELESS_MODE_UNKNOWN = 0x00, - WIRELESS_MODE_A = BIT(2), - WIRELESS_MODE_B = BIT(0), - WIRELESS_MODE_G = BIT(1), - WIRELESS_MODE_AUTO = BIT(5), - WIRELESS_MODE_N_24G = BIT(3), - WIRELESS_MODE_N_5G = BIT(4), - WIRELESS_MODE_AC = BIT(6) -}; - -enum phy_rate_tx_offset_area { - RA_OFFSET_LEGACY_OFDM1, - RA_OFFSET_LEGACY_OFDM2, - RA_OFFSET_HT_OFDM1, - RA_OFFSET_HT_OFDM2, - RA_OFFSET_HT_OFDM3, - RA_OFFSET_HT_OFDM4, - RA_OFFSET_HT_CCK, -}; - -struct bb_reg_def { - u32 rfintfs; /* set software control: */ - /* 0x870~0x877[8 bytes] */ - u32 rfintfi; /* readback data: */ - /* 0x8e0~0x8e7[8 bytes] */ - u32 rfintfo; /* output data: */ - /* 0x860~0x86f [16 bytes] */ - u32 rfintfe; /* output enable: */ - /* 0x860~0x86f [16 bytes] */ - u32 rf3wireOffset; /* LSSI data: */ - /* 0x840~0x84f [16 bytes] */ - u32 rfLSSI_Select; /* BB Band Select: */ - /* 0x878~0x87f [8 bytes] */ - u32 rfTxGainStage; /* Tx gain stage: */ - /* 0x80c~0x80f [4 bytes] */ - u32 rfHSSIPara1; /* wire parameter control1 : */ - /* 0x820~0x823,0x828~0x82b, - * 0x830~0x833, 0x838~0x83b [16 bytes] - */ - u32 rfHSSIPara2; /* wire parameter control2 : */ - /* 0x824~0x827,0x82c~0x82f, 0x834~0x837, - * 0x83c~0x83f [16 bytes] - */ - u32 rfSwitchControl; /* Tx Rx antenna control : */ - /* 0x858~0x85f [16 bytes] */ - u32 rfAGCControl1; /* AGC parameter control1 : */ - /* 0xc50~0xc53,0xc58~0xc5b, 0xc60~0xc63, - * 0xc68~0xc6b [16 bytes] - */ - u32 rfAGCControl2; /* AGC parameter control2 : */ - /* 0xc54~0xc57,0xc5c~0xc5f, 0xc64~0xc67, - * 0xc6c~0xc6f [16 bytes] - */ - u32 rfRxIQImbalance; /* OFDM Rx IQ imbalance matrix : */ - /* 0xc14~0xc17,0xc1c~0xc1f, 0xc24~0xc27, - * 0xc2c~0xc2f [16 bytes] - */ - u32 rfRxAFE; /* Rx IQ DC ofset and Rx digital filter, - * Rx DC notch filter : - */ - /* 0xc10~0xc13,0xc18~0xc1b, 0xc20~0xc23, - * 0xc28~0xc2b [16 bytes] - */ - u32 rfTxIQImbalance; /* OFDM Tx IQ imbalance matrix */ - /* 0xc80~0xc83,0xc88~0xc8b, 0xc90~0xc93, - * 0xc98~0xc9b [16 bytes] - */ - u32 rfTxAFE; /* Tx IQ DC Offset and Tx DFIR type */ - /* 0xc84~0xc87,0xc8c~0xc8f, 0xc94~0xc97, - * 0xc9c~0xc9f [16 bytes] - */ - u32 rfLSSIReadBack; /* LSSI RF readback data SI mode */ - /* 0x8a0~0x8af [16 bytes] */ - u32 rfLSSIReadBackPi; /* LSSI RF readback data PI mode 0x8b8-8bc for - * Path A and B - */ -}; - -/* Read initi reg value for tx power setting. */ -void rtl8192c_PHY_GetHWRegOriginalValue(struct adapter *adapter); - -/* BB TX Power R/W */ -void PHY_GetTxPowerLevel8188E(struct adapter *adapter, u32 *powerlevel); - -void PHY_ScanOperationBackup8188E(struct adapter *Adapter, u8 Operation); - -/* Call after initialization */ -void ChkFwCmdIoDone(struct adapter *adapter); - -/* BB/MAC/RF other monitor API */ -void PHY_SetRFPathSwitch_8188E(struct adapter *adapter, bool main); - -void PHY_SwitchEphyParameter(struct adapter *adapter); - -void PHY_EnableHostClkReq(struct adapter *adapter); - -bool SetAntennaConfig92C(struct adapter *adapter, u8 defaultant); - -#define PHY_SetMacReg PHY_SetBBReg - -#define SIC_HW_SUPPORT 0 - -#define SIC_MAX_POLL_CNT 5 - -#define SIC_CMD_READY 0 -#define SIC_CMD_WRITE 1 -#define SIC_CMD_READ 2 - -#define SIC_CMD_REG 0x1EB /* 1byte */ -#define SIC_ADDR_REG 0x1E8 /* 1b9~1ba, 2 bytes */ -#define SIC_DATA_REG 0x1EC /* 1bc~1bf */ - -#endif /* __INC_HAL8192CPHYCFG_H */ diff --git a/drivers/staging/rtl8188eu/include/hal8188e_phy_reg.h b/drivers/staging/rtl8188eu/include/hal8188e_phy_reg.h deleted file mode 100644 index bd915a1f2511..000000000000 --- a/drivers/staging/rtl8188eu/include/hal8188e_phy_reg.h +++ /dev/null @@ -1,201 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __INC_HAL8188EPHYREG_H__ -#define __INC_HAL8188EPHYREG_H__ -/*--------------------------Define Parameters-------------------------------*/ -/* */ -/* BB-PHY register PMAC 0x100 PHY 0x800 - 0xEFF */ -/* 1. PMAC duplicate register due to connection: RF_Mode, TRxRN, NumOf L-STF */ -/* 2. 0x800/0x900/0xA00/0xC00/0xD00/0xE00 */ -/* 3. RF register 0x00-2E */ -/* 4. Bit Mask for BB/RF register */ -/* 5. Other definition for BB/RF R/W */ -/* */ - -/* 3. Page8(0x800) */ -#define rFPGA0_RFMOD 0x800 /* RF mode & CCK TxSC RF BW Setting */ -#define rFPGA0_TxGainStage 0x80c /* Set TX PWR init gain? */ - -#define rFPGA0_XA_HSSIParameter1 0x820 /* RF 3 wire register */ -#define rFPGA0_XA_HSSIParameter2 0x824 -#define rFPGA0_XB_HSSIParameter1 0x828 -#define rFPGA0_XB_HSSIParameter2 0x82c - -#define rFPGA0_XA_LSSIParameter 0x840 -#define rFPGA0_XB_LSSIParameter 0x844 - -#define rFPGA0_XAB_SwitchControl 0x858 /* RF Channel switch */ -#define rFPGA0_XCD_SwitchControl 0x85c - -#define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ -#define rFPGA0_XB_RFInterfaceOE 0x864 - -#define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Iface Software Control */ -#define rFPGA0_XCD_RFInterfaceSW 0x874 - -#define rFPGA0_XAB_RFParameter 0x878 /* RF Parameter */ - -#define rFPGA0_XA_LSSIReadBack 0x8a0 /* Tranceiver LSSI Readback */ -#define rFPGA0_XB_LSSIReadBack 0x8a4 - -#define TransceiverA_HSPI_Readback 0x8b8 -#define TransceiverB_HSPI_Readback 0x8bc -#define rFPGA0_XAB_RFInterfaceRB 0x8e0 - -/* 4. Page9(0x900) */ -/* RF mode & OFDM TxSC RF BW Setting?? */ -#define rFPGA1_RFMOD 0x900 - -/* 5. PageA(0xA00) */ -/* Set Control channel to upper or lower - required only for 40MHz */ -#define rCCK0_System 0xa00 - -/* */ -/* PageB(0xB00) */ -/* */ -#define rConfig_AntA 0xb68 -#define rConfig_AntB 0xb6c - -/* */ -/* 6. PageC(0xC00) */ -/* */ -#define rOFDM0_TRxPathEnable 0xc04 -#define rOFDM0_TRMuxPar 0xc08 - -/* RxIQ DC offset, Rx digital filter, DC notch filter */ -#define rOFDM0_XARxAFE 0xc10 -#define rOFDM0_XARxIQImbalance 0xc14 /* RxIQ imbalance matrix */ -#define rOFDM0_XBRxAFE 0xc18 -#define rOFDM0_XBRxIQImbalance 0xc1c - -#define rOFDM0_RxDSP 0xc40 /* Rx Sync Path */ -#define rOFDM0_ECCAThreshold 0xc4c /* energy CCA */ - -#define rOFDM0_XAAGCCore1 0xc50 /* DIG */ -#define rOFDM0_XAAGCCore2 0xc54 -#define rOFDM0_XBAGCCore1 0xc58 -#define rOFDM0_XBAGCCore2 0xc5c - -#define rOFDM0_AGCRSSITable 0xc78 - -#define rOFDM0_XATxIQImbalance 0xc80 /* TX PWR TRACK and DIG */ -#define rOFDM0_XATxAFE 0xc84 -#define rOFDM0_XBTxIQImbalance 0xc88 -#define rOFDM0_XBTxAFE 0xc8c -#define rOFDM0_XCTxAFE 0xc94 -#define rOFDM0_XDTxAFE 0xc9c - -#define rOFDM0_RxIQExtAnta 0xca0 - -/* */ -/* 7. PageD(0xD00) */ -/* */ -#define rOFDM1_LSTF 0xd00 - -/* */ -/* 8. PageE(0xE00) */ -/* */ -#define rTxAGC_A_Rate18_06 0xe00 -#define rTxAGC_A_Rate54_24 0xe04 -#define rTxAGC_A_CCK1_Mcs32 0xe08 -#define rTxAGC_A_Mcs03_Mcs00 0xe10 -#define rTxAGC_A_Mcs07_Mcs04 0xe14 -#define rTxAGC_A_Mcs11_Mcs08 0xe18 -#define rTxAGC_A_Mcs15_Mcs12 0xe1c - -#define rTxAGC_B_Rate18_06 0x830 -#define rTxAGC_B_Rate54_24 0x834 -#define rTxAGC_B_CCK1_55_Mcs32 0x838 -#define rTxAGC_B_Mcs03_Mcs00 0x83c -#define rTxAGC_B_Mcs07_Mcs04 0x848 -#define rTxAGC_B_Mcs11_Mcs08 0x84c -#define rTxAGC_B_Mcs15_Mcs12 0x868 -#define rTxAGC_B_CCK11_A_CCK2_11 0x86c - -#define rFPGA0_IQK 0xe28 -#define rTx_IQK_Tone_A 0xe30 -#define rRx_IQK_Tone_A 0xe34 -#define rTx_IQK_PI_A 0xe38 -#define rRx_IQK_PI_A 0xe3c - -#define rTx_IQK 0xe40 -#define rRx_IQK 0xe44 -#define rIQK_AGC_Pts 0xe48 -#define rIQK_AGC_Rsp 0xe4c -#define rIQK_AGC_Cont 0xe60 - -#define rBlue_Tooth 0xe6c -#define rRx_Wait_CCA 0xe70 -#define rTx_CCK_RFON 0xe74 -#define rTx_CCK_BBON 0xe78 -#define rTx_OFDM_RFON 0xe7c -#define rTx_OFDM_BBON 0xe80 -#define rTx_To_Rx 0xe84 -#define rTx_To_Tx 0xe88 -#define rRx_CCK 0xe8c - -#define rTx_Power_Before_IQK_A 0xe94 -#define rTx_Power_After_IQK_A 0xe9c - -#define rRx_Power_Before_IQK_A_2 0xea4 -#define rRx_Power_After_IQK_A_2 0xeac - -#define rTx_Power_Before_IQK_B 0xeb4 -#define rTx_Power_After_IQK_B 0xebc - -#define rRx_Power_Before_IQK_B_2 0xec4 -#define rRx_Power_After_IQK_B_2 0xecc - -#define rRx_OFDM 0xed0 -#define rRx_Wait_RIFS 0xed4 -#define rRx_TO_Rx 0xed8 -#define rStandby 0xedc -#define rSleep 0xee0 -#define rPMPD_ANAEN 0xeec - -/* */ -/* RL6052 Register definition */ -/* */ -#define RF_AC 0x00 /* */ -#define RF_CHNLBW 0x18 /* RF channel and BW switch */ -#define RF_T_METER_88E 0x42 /* */ -#define RF_RCK_OS 0x30 /* RF TX PA control */ -#define RF_TXPA_G1 0x31 /* RF TX PA control */ -#define RF_TXPA_G2 0x32 /* RF TX PA control */ -#define RF_WE_LUT 0xEF - -/* */ -/* Bit Mask */ -/* */ - -/* 2. Page8(0x800) */ -#define bRFMOD 0x1 /* Reg 0x800 rFPGA0_RFMOD */ -#define bCCKEn 0x1000000 -#define bOFDMEn 0x2000000 - -#define bLSSIReadAddress 0x7f800000 /* T65 RF */ -#define bLSSIReadEdge 0x80000000 /* LSSI "Read" edge signal */ -#define bLSSIReadBackData 0xfffff /* T65 RF */ - -#define bCCKSideBand 0x10 /* Reg 0xa00 rCCK0_System 20/40 */ - -/* */ -/* Other Definition */ -/* */ - -/* for PutRegsetting & GetRegSetting BitMask */ -#define bMaskByte0 0xff /* Reg 0xc50 rOFDM0_XAAGCCore~0xC6f */ -#define bMaskByte1 0xff00 -#define bMaskByte3 0xff000000 -#define bMaskDWord 0xffffffff -#define bMask12Bits 0xfff -#define bMaskOFDM_D 0xffc00000 - -/* for PutRFRegsetting & GetRFRegSetting BitMask */ -#define bRFRegOffsetMask 0xfffff - -#endif diff --git a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h b/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h deleted file mode 100644 index 646647feae85..000000000000 --- a/drivers/staging/rtl8188eu/include/hal8188e_rate_adaptive.h +++ /dev/null @@ -1,74 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifndef __INC_RA_H -#define __INC_RA_H -/* - * Copyright (c) Realtek Semiconductor Corp. All rights reserved. - * - * Module Name: - * RateAdaptive.h - * - * Abstract: - * Prototype of RA and related data structure. - * - * Major Change History: - * When Who What - * ---------- --------------- ------------------------------- - * 2011-08-12 Page Create. - */ - -/* Rate adaptive define */ -#define PERENTRY 23 -#define RETRYSIZE 5 -#define RATESIZE 28 -#define TX_RPT2_ITEM_SIZE 8 - -/* */ -/* TX report 2 format in Rx desc */ -/* */ -#define GET_TX_RPT2_DESC_PKT_LEN_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc, 0, 9) -#define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc + 16, 0, 32) -#define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc + 20, 0, 32) - -#define GET_TX_REPORT_TYPE1_RERTY_0(__pAddr) \ - LE_BITS_TO_4BYTE(__pAddr, 0, 16) -#define GET_TX_REPORT_TYPE1_RERTY_1(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr + 2, 0, 8) -#define GET_TX_REPORT_TYPE1_RERTY_2(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr + 3, 0, 8) -#define GET_TX_REPORT_TYPE1_RERTY_3(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr + 4, 0, 8) -#define GET_TX_REPORT_TYPE1_RERTY_4(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr + 4 + 1, 0, 8) -#define GET_TX_REPORT_TYPE1_DROP_0(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr + 4 + 2, 0, 8) -#define GET_TX_REPORT_TYPE1_DROP_1(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr + 4 + 3, 0, 8) - -/* End rate adaptive define */ - -int ODM_RAInfo_Init_all(struct odm_dm_struct *dm_odm); - -int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 MacID); - -u8 ODM_RA_GetShortGI_8188E(struct odm_dm_struct *dm_odm, u8 MacID); - -u8 ODM_RA_GetDecisionRate_8188E(struct odm_dm_struct *dm_odm, u8 MacID); - -u8 ODM_RA_GetHwPwrStatus_8188E(struct odm_dm_struct *dm_odm, u8 MacID); -void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 MacID, - u8 RateID, u32 RateMask, - u8 SGIEnable); - -void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, - u8 rssi); - -void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, - u8 *txrpt_buf, u16 txrpt_len, - u32 validentry0, u32 validentry1); - -void ODM_RA_Set_TxRPT_Time(struct odm_dm_struct *dm_odm, u16 minRptTime); - -#endif diff --git a/drivers/staging/rtl8188eu/include/hal_com.h b/drivers/staging/rtl8188eu/include/hal_com.h deleted file mode 100644 index c2019772bef0..000000000000 --- a/drivers/staging/rtl8188eu/include/hal_com.h +++ /dev/null @@ -1,150 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __HAL_COMMON_H__ -#define __HAL_COMMON_H__ - -/* */ -/* Rate Definition */ -/* */ -/* CCK */ -#define RATR_1M 0x00000001 -#define RATR_2M 0x00000002 -#define RATR_55M 0x00000004 -#define RATR_11M 0x00000008 -/* OFDM */ -#define RATR_6M 0x00000010 -#define RATR_9M 0x00000020 -#define RATR_12M 0x00000040 -#define RATR_18M 0x00000080 -#define RATR_24M 0x00000100 -#define RATR_36M 0x00000200 -#define RATR_48M 0x00000400 -#define RATR_54M 0x00000800 -/* MCS 1 Spatial Stream */ -#define RATR_MCS0 0x00001000 -#define RATR_MCS1 0x00002000 -#define RATR_MCS2 0x00004000 -#define RATR_MCS3 0x00008000 -#define RATR_MCS4 0x00010000 -#define RATR_MCS5 0x00020000 -#define RATR_MCS6 0x00040000 -#define RATR_MCS7 0x00080000 -/* MCS 2 Spatial Stream */ -#define RATR_MCS8 0x00100000 -#define RATR_MCS9 0x00200000 -#define RATR_MCS10 0x00400000 -#define RATR_MCS11 0x00800000 -#define RATR_MCS12 0x01000000 -#define RATR_MCS13 0x02000000 -#define RATR_MCS14 0x04000000 -#define RATR_MCS15 0x08000000 - -/* CCK */ -#define RATE_1M BIT(0) -#define RATE_2M BIT(1) -#define RATE_5_5M BIT(2) -#define RATE_11M BIT(3) -/* OFDM */ -#define RATE_6M BIT(4) -#define RATE_9M BIT(5) -#define RATE_12M BIT(6) -#define RATE_18M BIT(7) -#define RATE_24M BIT(8) -#define RATE_36M BIT(9) -#define RATE_48M BIT(10) -#define RATE_54M BIT(11) -/* MCS 1 Spatial Stream */ -#define RATE_MCS0 BIT(12) -#define RATE_MCS1 BIT(13) -#define RATE_MCS2 BIT(14) -#define RATE_MCS3 BIT(15) -#define RATE_MCS4 BIT(16) -#define RATE_MCS5 BIT(17) -#define RATE_MCS6 BIT(18) -#define RATE_MCS7 BIT(19) -/* MCS 2 Spatial Stream */ -#define RATE_MCS8 BIT(20) -#define RATE_MCS9 BIT(21) -#define RATE_MCS10 BIT(22) -#define RATE_MCS11 BIT(23) -#define RATE_MCS12 BIT(24) -#define RATE_MCS13 BIT(25) -#define RATE_MCS14 BIT(26) -#define RATE_MCS15 BIT(27) - -/* ALL CCK Rate */ -#define RATE_ALL_CCK (RATR_1M | RATR_2M | RATR_55M | RATR_11M) -#define RATE_ALL_OFDM_AG (RATR_6M | RATR_9M | RATR_12M | RATR_18M | \ - RATR_24M | RATR_36M | RATR_48M | RATR_54M) -#define RATE_ALL_OFDM_1SS (RATR_MCS0 | RATR_MCS1 | RATR_MCS2 | \ - RATR_MCS3 | RATR_MCS4 | RATR_MCS5 | RATR_MCS6 | \ - RATR_MCS7) -#define RATE_ALL_OFDM_2SS (RATR_MCS8 | RATR_MCS9 | RATR_MCS10 | \ - RATR_MCS11 | RATR_MCS12 | RATR_MCS13 | \ - RATR_MCS14 | RATR_MCS15) - -/*------------------------------ Tx Desc definition Macro --------------------*/ -/* pragma mark -- Tx Desc related definition. -- */ -/* Rate */ -/* CCK Rates, TxHT = 0 */ -#define DESC_RATE1M 0x00 -#define DESC_RATE2M 0x01 -#define DESC_RATE5_5M 0x02 -#define DESC_RATE11M 0x03 - -/* OFDM Rates, TxHT = 0 */ -#define DESC_RATE6M 0x04 -#define DESC_RATE9M 0x05 -#define DESC_RATE12M 0x06 -#define DESC_RATE18M 0x07 -#define DESC_RATE24M 0x08 -#define DESC_RATE36M 0x09 -#define DESC_RATE48M 0x0a -#define DESC_RATE54M 0x0b - -/* MCS Rates, TxHT = 1 */ -#define DESC_RATEMCS0 0x0c -#define DESC_RATEMCS1 0x0d -#define DESC_RATEMCS2 0x0e -#define DESC_RATEMCS3 0x0f -#define DESC_RATEMCS4 0x10 -#define DESC_RATEMCS5 0x11 -#define DESC_RATEMCS6 0x12 -#define DESC_RATEMCS7 0x13 -#define DESC_RATEMCS8 0x14 -#define DESC_RATEMCS9 0x15 -#define DESC_RATEMCS10 0x16 -#define DESC_RATEMCS11 0x17 -#define DESC_RATEMCS12 0x18 -#define DESC_RATEMCS13 0x19 -#define DESC_RATEMCS14 0x1a -#define DESC_RATEMCS15 0x1b -#define DESC_RATEMCS15_SG 0x1c -#define DESC_RATEMCS32 0x20 - -/* 1 Byte long (in unit of TU) */ -#define REG_P2P_CTWIN 0x0572 -#define REG_NOA_DESC_SEL 0x05CF -#define REG_NOA_DESC_DURATION 0x05E0 -#define REG_NOA_DESC_INTERVAL 0x05E4 -#define REG_NOA_DESC_START 0x05E8 -#define REG_NOA_DESC_COUNT 0x05EC - -#include "HalVerDef.h" -void dump_chip_info(struct HAL_VERSION ChipVersion); - -/* return the final channel plan decision */ -u8 hal_com_get_channel_plan(u8 hw_channel_plan, u8 sw_channel_plan, - u8 def_channel_plan, bool load_fail); - -u8 MRateToHwRate(u8 rate); - -void hal_set_brate_cfg(u8 *brates, u16 *rate_cfg); - -bool hal_mapping_out_pipe(struct adapter *adapter, u8 numoutpipe); - -#endif /* __HAL_COMMON_H__ */ diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h deleted file mode 100644 index 12a585c0d0f2..000000000000 --- a/drivers/staging/rtl8188eu/include/hal_intf.h +++ /dev/null @@ -1,181 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __HAL_INTF_H__ -#define __HAL_INTF_H__ - -#include -#include -#include - -enum hw_variables { - HW_VAR_MEDIA_STATUS, - HW_VAR_SET_OPMODE, - HW_VAR_MAC_ADDR, - HW_VAR_BSSID, - HW_VAR_INIT_RTS_RATE, - HW_VAR_BASIC_RATE, - HW_VAR_BCN_FUNC, - HW_VAR_CORRECT_TSF, - HW_VAR_CHECK_BSSID, - HW_VAR_MLME_DISCONNECT, - HW_VAR_MLME_SITESURVEY, - HW_VAR_MLME_JOIN, - HW_VAR_BEACON_INTERVAL, - HW_VAR_SLOT_TIME, - HW_VAR_RESP_SIFS, - HW_VAR_ACK_PREAMBLE, - HW_VAR_SEC_CFG, - HW_VAR_BCN_VALID, - HW_VAR_DM_FUNC_OP, - HW_VAR_DM_FUNC_SET, - HW_VAR_DM_FUNC_CLR, - HW_VAR_CAM_EMPTY_ENTRY, - HW_VAR_CAM_INVALID_ALL, - HW_VAR_CAM_WRITE, - HW_VAR_CAM_READ, - HW_VAR_AC_PARAM_VO, - HW_VAR_AC_PARAM_VI, - HW_VAR_AC_PARAM_BE, - HW_VAR_AC_PARAM_BK, - HW_VAR_ACM_CTRL, - HW_VAR_AMPDU_MIN_SPACE, - HW_VAR_AMPDU_FACTOR, - HW_VAR_RXDMA_AGG_PG_TH, - HW_VAR_SET_RPWM, - HW_VAR_H2C_FW_PWRMODE, - HW_VAR_H2C_FW_JOINBSSRPT, - HW_VAR_FWLPS_RF_ON, - HW_VAR_H2C_FW_P2P_PS_OFFLOAD, - HW_VAR_TDLS_WRCR, - HW_VAR_TDLS_INIT_CH_SEN, - HW_VAR_TDLS_RS_RCR, - HW_VAR_TDLS_DONE_CH_SEN, - HW_VAR_INITIAL_GAIN, - HW_VAR_BT_SET_COEXIST, - HW_VAR_BT_ISSUE_DELBA, - HW_VAR_CURRENT_ANTENNA, - HW_VAR_ANTENNA_DIVERSITY_LINK, - HW_VAR_ANTENNA_DIVERSITY_SELECT, - HW_VAR_SWITCH_EPHY_WoWLAN, - HW_VAR_EFUSE_USAGE, - HW_VAR_EFUSE_BYTES, - HW_VAR_EFUSE_BT_USAGE, - HW_VAR_EFUSE_BT_BYTES, - HW_VAR_FIFO_CLEARN_UP, - HW_VAR_CHECK_TXBUF, - HW_VAR_APFM_ON_MAC, /* Auto FSM to Turn On, include clock, isolation, - * power control for MAC only - */ - /* The valid upper nav range for the HW updating, if the true value is - * larger than the upper range, the HW won't update it. - */ - /* Unit in microsecond. 0 means disable this function. */ - HW_VAR_NAV_UPPER, - HW_VAR_RPT_TIMER_SETTING, - HW_VAR_TX_RPT_MAX_MACID, - HW_VAR_H2C_MEDIA_STATUS_RPT, - HW_VAR_CHK_HI_QUEUE_EMPTY, -}; - -enum hal_def_variable { - HAL_DEF_UNDERCORATEDSMOOTHEDPWDB, - HAL_DEF_IS_SUPPORT_ANT_DIV, - HAL_DEF_CURRENT_ANTENNA, - HAL_DEF_DRVINFO_SZ, - HAL_DEF_MAX_RECVBUF_SZ, - HAL_DEF_RX_PACKET_OFFSET, - HAL_DEF_DBG_DUMP_RXPKT,/* for dbg */ - HAL_DEF_DBG_DM_FUNC,/* for dbg */ - HAL_DEF_RA_DECISION_RATE, - HAL_DEF_RA_SGI, - HAL_DEF_PT_PWR_STATUS, - HW_VAR_MAX_RX_AMPDU_FACTOR, - HW_DEF_RA_INFO_DUMP, - HAL_DEF_DBG_DUMP_TXPKT, - HW_DEF_FA_CNT_DUMP, -}; - -enum hal_odm_variable { - HAL_ODM_STA_INFO, - HAL_ODM_P2P_STATE, - HAL_ODM_WIFI_DISPLAY_STATE, -}; - -#define RF_CHANGE_BY_PS BIT(29) - -#define GET_EEPROM_EFUSE_PRIV(adapter) (&adapter->eeprompriv) - -void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_level); -u32 rtl8188eu_hal_deinit(struct adapter *Adapter); -u32 rtl8188eu_hal_init(struct adapter *Adapter); -void rtw_hal_def_value_init(struct adapter *padapter); - -void rtw_hal_free_data(struct adapter *padapter); - -void rtw_hal_dm_init(struct adapter *padapter); -void rtw_hal_sw_led_init(struct adapter *padapter); -void rtw_hal_sw_led_deinit(struct adapter *padapter); - -u32 rtw_hal_power_on(struct adapter *padapter); -uint rtw_hal_init(struct adapter *padapter); -uint rtw_hal_deinit(struct adapter *padapter); -void rtw_hal_stop(struct adapter *padapter); -void rtw_hal_set_hwreg(struct adapter *padapter, u8 variable, u8 *val); -void rtw_hal_get_hwreg(struct adapter *padapter, u8 variable, u8 *val); - -void rtw_hal_chip_configure(struct adapter *padapter); -void rtw_hal_read_chip_info(struct adapter *padapter); -void rtw_hal_read_chip_version(struct adapter *padapter); - -u8 rtw_hal_get_def_var(struct adapter *padapter, - enum hal_def_variable eVariable, void *pValue); - -void rtw_hal_set_odm_var(struct adapter *padapter, - enum hal_odm_variable eVariable, void *pValue1, - bool bSet); - -u32 rtw_hal_inirp_init(struct adapter *padapter); -void rtw_hal_inirp_deinit(struct adapter *padapter); -void usb_intf_stop(struct adapter *padapter); - -bool rtw_hal_xmit(struct adapter *padapter, struct xmit_frame *pxmitframe); -s32 rtw_hal_mgnt_xmit(struct adapter *padapter, - struct xmit_frame *pmgntframe); - -s32 rtw_hal_init_xmit_priv(struct adapter *padapter); - -int rtw_hal_init_recv_priv(struct adapter *padapter); -void rtw_hal_free_recv_priv(struct adapter *padapter); - -void rtw_hal_update_ra_mask(struct adapter *padapter, u32 mac_id, u8 level); -void rtw_hal_add_ra_tid(struct adapter *adapt, u32 bitmap, u8 arg, u8 level); -void rtw_hal_clone_data(struct adapter *dst_adapt, - struct adapter *src_adapt); - -void beacon_timing_control(struct adapter *padapter); - -u32 rtw_hal_read_rfreg(struct adapter *padapter, enum rf_radio_path eRFPath, - u32 RegAddr, u32 BitMask); - -void rtw_hal_set_bwmode(struct adapter *padapter, - enum ht_channel_width Bandwidth, u8 Offset); -void rtw_hal_set_chan(struct adapter *padapter, u8 channel); -void rtw_hal_dm_watchdog(struct adapter *padapter); - -bool rtw_hal_antdiv_before_linked(struct adapter *padapter); -void rtw_hal_antdiv_rssi_compared(struct adapter *padapter, - struct wlan_bssid_ex *dst, - struct wlan_bssid_ex *src); - -void rtw_hal_sreset_init(struct adapter *padapter); - -void rtw_hal_notch_filter(struct adapter *adapter, bool enable); - -void indicate_wx_scan_complete_event(struct adapter *padapter); -u8 rtw_do_join(struct adapter *padapter); - -#endif /* __HAL_INTF_H__ */ diff --git a/drivers/staging/rtl8188eu/include/ieee80211.h b/drivers/staging/rtl8188eu/include/ieee80211.h deleted file mode 100644 index da6245a77d5d..000000000000 --- a/drivers/staging/rtl8188eu/include/ieee80211.h +++ /dev/null @@ -1,742 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __IEEE80211_H -#define __IEEE80211_H - -#include -#include -#include "wifi.h" -#include - -#ifdef CONFIG_88EU_AP_MODE - -#define RTL_IOCTL_HOSTAPD (SIOCIWFIRSTPRIV + 28) - -/* RTL871X_IOCTL_HOSTAPD ioctl() cmd: */ -enum { - RTL871X_HOSTAPD_FLUSH = 1, - RTL871X_HOSTAPD_ADD_STA = 2, - RTL871X_HOSTAPD_REMOVE_STA = 3, - RTL871X_HOSTAPD_GET_INFO_STA = 4, - /* REMOVED: PRISM2_HOSTAPD_RESET_TXEXC_STA = 5, */ - RTL871X_HOSTAPD_GET_WPAIE_STA = 5, - RTL871X_SET_ENCRYPTION = 6, - RTL871X_GET_ENCRYPTION = 7, - RTL871X_HOSTAPD_SET_FLAGS_STA = 8, - RTL871X_HOSTAPD_GET_RID = 9, - RTL871X_HOSTAPD_SET_RID = 10, - RTL871X_HOSTAPD_SET_ASSOC_AP_ADDR = 11, - RTL871X_HOSTAPD_SET_GENERIC_ELEMENT = 12, - RTL871X_HOSTAPD_MLME = 13, - RTL871X_HOSTAPD_SCAN_REQ = 14, - RTL871X_HOSTAPD_STA_CLEAR_STATS = 15, - RTL871X_HOSTAPD_SET_BEACON = 16, - RTL871X_HOSTAPD_SET_WPS_BEACON = 17, - RTL871X_HOSTAPD_SET_WPS_PROBE_RESP = 18, - RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP = 19, - RTL871X_HOSTAPD_SET_HIDDEN_SSID = 20, - RTL871X_HOSTAPD_SET_MACADDR_ACL = 21, - RTL871X_HOSTAPD_ACL_ADD_STA = 22, - RTL871X_HOSTAPD_ACL_REMOVE_STA = 23, -}; - -/* STA flags */ -#define WLAN_STA_AUTH BIT(0) -#define WLAN_STA_ASSOC BIT(1) -#define WLAN_STA_PS BIT(2) -#define WLAN_STA_TIM BIT(3) -#define WLAN_STA_PERM BIT(4) -#define WLAN_STA_AUTHORIZED BIT(5) -#define WLAN_STA_PENDING_POLL BIT(6) /* pending activity poll not ACKed */ -#define WLAN_STA_SHORT_PREAMBLE BIT(7) -#define WLAN_STA_PREAUTH BIT(8) -#define WLAN_STA_WME BIT(9) -#define WLAN_STA_MFP BIT(10) -#define WLAN_STA_HT BIT(11) -#define WLAN_STA_WPS BIT(12) -#define WLAN_STA_MAYBE_WPS BIT(13) -#define WLAN_STA_NONERP BIT(31) - -#endif - -#define IEEE_CMD_SET_WPA_PARAM 1 -#define IEEE_CMD_SET_WPA_IE 2 -#define IEEE_CMD_SET_ENCRYPTION 3 -#define IEEE_CMD_MLME 4 - -#define IEEE_PARAM_WPA_ENABLED 1 -#define IEEE_PARAM_TKIP_COUNTERMEASURES 2 -#define IEEE_PARAM_DROP_UNENCRYPTED 3 -#define IEEE_PARAM_PRIVACY_INVOKED 4 -#define IEEE_PARAM_AUTH_ALGS 5 -#define IEEE_PARAM_IEEE_802_1X 6 -#define IEEE_PARAM_WPAX_SELECT 7 - -#define AUTH_ALG_OPEN_SYSTEM 0x1 -#define AUTH_ALG_SHARED_KEY 0x2 -#define AUTH_ALG_LEAP 0x00000004 - -#define IEEE_MLME_STA_DEAUTH 1 -#define IEEE_MLME_STA_DISASSOC 2 - -#define IEEE_CRYPT_ERR_UNKNOWN_ALG 2 -#define IEEE_CRYPT_ERR_UNKNOWN_ADDR 3 -#define IEEE_CRYPT_ERR_CRYPT_INIT_FAILED 4 -#define IEEE_CRYPT_ERR_KEY_SET_FAILED 5 -#define IEEE_CRYPT_ERR_TX_KEY_SET_FAILED 6 -#define IEEE_CRYPT_ERR_CARD_CONF_FAILED 7 - -#define IEEE_CRYPT_ALG_NAME_LEN 16 - -#define WPA_CIPHER_NONE BIT(0) -#define WPA_CIPHER_WEP40 BIT(1) -#define WPA_CIPHER_WEP104 BIT(2) -#define WPA_CIPHER_TKIP BIT(3) -#define WPA_CIPHER_CCMP BIT(4) - -#define WPA_SELECTOR_LEN 4 -extern u8 RTW_WPA_OUI_TYPE[]; -extern u8 WPA_AUTH_KEY_MGMT_NONE[]; -extern u8 WPA_AUTH_KEY_MGMT_UNSPEC_802_1X[]; -extern u8 WPA_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; -extern u8 WPA_CIPHER_SUITE_NONE[]; -extern u8 WPA_CIPHER_SUITE_WEP40[]; -extern u8 WPA_CIPHER_SUITE_TKIP[]; -extern u8 WPA_CIPHER_SUITE_WRAP[]; -extern u8 WPA_CIPHER_SUITE_CCMP[]; -extern u8 WPA_CIPHER_SUITE_WEP104[]; - -#define RSN_HEADER_LEN 4 -#define RSN_SELECTOR_LEN 4 - -extern u16 RSN_VERSION_BSD; -extern u8 RSN_AUTH_KEY_MGMT_UNSPEC_802_1X[]; -extern u8 RSN_AUTH_KEY_MGMT_PSK_OVER_802_1X[]; -extern u8 RSN_CIPHER_SUITE_NONE[]; -extern u8 RSN_CIPHER_SUITE_WEP40[]; -extern u8 RSN_CIPHER_SUITE_TKIP[]; -extern u8 RSN_CIPHER_SUITE_WRAP[]; -extern u8 RSN_CIPHER_SUITE_CCMP[]; -extern u8 RSN_CIPHER_SUITE_WEP104[]; - -enum ratr_table_mode { - RATR_INX_WIRELESS_NGB = 0, /* BGN 40 Mhz 2SS 1SS */ - RATR_INX_WIRELESS_NG = 1, /* GN or N */ - RATR_INX_WIRELESS_NB = 2, /* BGN 20 Mhz 2SS 1SS or BN */ - RATR_INX_WIRELESS_N = 3, - RATR_INX_WIRELESS_GB = 4, - RATR_INX_WIRELESS_G = 5, - RATR_INX_WIRELESS_B = 6, - RATR_INX_WIRELESS_MC = 7, - RATR_INX_WIRELESS_AC_N = 8, -}; - -enum NETWORK_TYPE { - WIRELESS_INVALID = 0, - /* Sub-Element */ - WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */ - WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/ - WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */ - WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */ - WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */ - WIRELESS_AC = BIT(6), - - /* Combination */ - /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ - WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), - /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ - WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N), - /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ - WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N), - /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ - WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), - /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ - WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | - WIRELESS_11_5N), - WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | - WIRELESS_11_24N | WIRELESS_11_5N), -}; - -#define SUPPORTED_24G_NETTYPE_MSK \ - (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) -#define SUPPORTED_5G_NETTYPE_MSK \ - (WIRELESS_11A | WIRELESS_11_5N) - -#define IsSupported24G(NetType) \ - ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsSupported5G(NetType) \ - ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false) - -#define IsEnableHWCCK(NetType) \ - IsSupported24G(NetType) -#define IsEnableHWOFDM(NetType) \ - ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | \ - SUPPORTED_5G_NETTYPE_MSK) ? true : false) - -#define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) -#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) -#define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType) - -#define IsSupportedTxCCK(NetType) \ - ((NetType) & (WIRELESS_11B) ? true : false) -#define IsSupportedTxOFDM(NetType) \ - ((NetType) & (WIRELESS_11G | WIRELESS_11A) ? true : false) -#define IsSupportedTxMCS(NetType) \ - ((NetType) & (WIRELESS_11_24N | WIRELESS_11_5N) ? true : false) - -struct ieee_param { - u32 cmd; - u8 sta_addr[ETH_ALEN]; - union { - struct { - u8 name; - u32 value; - } wpa_param; - struct { - u32 len; - u8 reserved[32]; - u8 data[0]; - } wpa_ie; - struct { - int command; - int reason_code; - } mlme; - struct { - u8 alg[IEEE_CRYPT_ALG_NAME_LEN]; - u8 set_tx; - u32 err; - u8 idx; - u8 seq[8]; /* sequence counter (set: RX, get: TX) */ - u16 key_len; - u8 key[0]; - } crypt; -#ifdef CONFIG_88EU_AP_MODE - struct { - u16 aid; - u16 capability; - int flags; - u8 tx_supp_rates[16]; - struct ieee80211_ht_cap ht_cap; - } add_sta; - struct { - u8 reserved[2];/* for set max_num_sta */ - u8 buf[0]; - } bcn_ie; -#endif - - } u; -}; - -#ifdef CONFIG_88EU_AP_MODE -struct ieee_param_ex { - u32 cmd; - u8 sta_addr[ETH_ALEN]; - u8 data[0]; -}; - -struct sta_data { - u16 aid; - u16 capability; - int flags; - u32 sta_set; - u8 tx_supp_rates[16]; - u32 tx_supp_rates_len; - struct ieee80211_ht_cap ht_cap; - u64 rx_pkts; - u64 rx_bytes; - u64 rx_drops; - u64 tx_pkts; - u64 tx_bytes; - u64 tx_drops; -}; -#endif - -#define IEEE80211_DATA_LEN 2304 -/* Maximum size for the MA-UNITDATA primitive, 802.11 standard section - * 6.2.1.1.2. - - * The figure in section 7.1.2 suggests a body size of up to 2312 - * bytes is allowed, which is a bit confusing, I suspect this - * represents the 2304 bytes of real data, plus a possible 8 bytes of - * WEP IV and ICV. (this interpretation suggested by Ramiro Barreiro) - */ - -#define IEEE80211_HLEN 30 -#define IEEE80211_FRAME_LEN (IEEE80211_DATA_LEN + IEEE80211_HLEN) - -/* this is stolen from ipw2200 driver */ -#define IEEE_IBSS_MAC_HASH_SIZE 31 - -enum eap_type { - EAP_PACKET = 0, - EAPOL_START, - EAPOL_LOGOFF, - EAPOL_KEY, - EAPOL_ENCAP_ASF_ALERT -}; - -#define IEEE80211_3ADDR_LEN 24 -#define IEEE80211_4ADDR_LEN 30 -#define IEEE80211_FCS_LEN 4 - -#define MIN_FRAG_THRESHOLD 256U -#define MAX_FRAG_THRESHOLD 2346U - -/* sequence control field */ -#define RTW_IEEE80211_SCTL_FRAG 0x000F -#define RTW_IEEE80211_SCTL_SEQ 0xFFF0 - -#define RTW_ERP_INFO_NON_ERP_PRESENT BIT(0) -#define RTW_ERP_INFO_USE_PROTECTION BIT(1) -#define RTW_ERP_INFO_BARKER_PREAMBLE_MODE BIT(2) - -/* QoS, QOS */ -#define NORMAL_ACK 0 -#define NO_ACK 1 -#define NON_EXPLICIT_ACK 2 -#define BLOCK_ACK 3 - -#ifndef ETH_P_PAE -#define ETH_P_PAE 0x888E /* Port Access Entity (IEEE 802.1X) */ -#endif /* ETH_P_PAE */ - -#define ETH_P_PREAUTH 0x88C7 /* IEEE 802.11i pre-authentication */ - -#define ETH_P_ECONET 0x0018 - -#ifndef ETH_P_80211_RAW -#define ETH_P_80211_RAW (ETH_P_ECONET + 1) -#endif - -/* IEEE 802.11 defines */ - -#define P80211_OUI_LEN 3 - -struct ieee80211_snap_hdr { - u8 dsap; /* always 0xAA */ - u8 ssap; /* always 0xAA */ - u8 ctrl; /* always 0x03 */ - u8 oui[P80211_OUI_LEN]; /* organizational universal id */ -} __packed; - -#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) - -#define WLAN_QC_GET_TID(qc) ((qc) & 0x0f) - -#define WLAN_GET_SEQ_FRAG(seq) ((seq) & RTW_IEEE80211_SCTL_FRAG) -#define WLAN_GET_SEQ_SEQ(seq) ((seq) & RTW_IEEE80211_SCTL_SEQ) - -/* Non standard? Not in */ -#define WLAN_REASON_EXPIRATION_CHK 65535 - -#define IEEE80211_MGMT_HDR_LEN 24 -#define IEEE80211_DATA_HDR3_LEN 24 -#define IEEE80211_DATA_HDR4_LEN 30 - -#define IEEE80211_CCK_MODULATION BIT(0) -#define IEEE80211_OFDM_MODULATION BIT(1) - -#define IEEE80211_24GHZ_BAND BIT(0) -#define IEEE80211_52GHZ_BAND BIT(1) - -#define IEEE80211_CCK_RATE_LEN 4 -#define IEEE80211_NUM_OFDM_RATESLEN 8 - -#define IEEE80211_CCK_RATE_1MB 0x02 -#define IEEE80211_CCK_RATE_2MB 0x04 -#define IEEE80211_CCK_RATE_5MB 0x0B -#define IEEE80211_CCK_RATE_11MB 0x16 -#define IEEE80211_OFDM_RATE_LEN 8 -#define IEEE80211_OFDM_RATE_6MB 0x0C -#define IEEE80211_OFDM_RATE_9MB 0x12 -#define IEEE80211_OFDM_RATE_12MB 0x18 -#define IEEE80211_OFDM_RATE_18MB 0x24 -#define IEEE80211_OFDM_RATE_24MB 0x30 -#define IEEE80211_OFDM_RATE_36MB 0x48 -#define IEEE80211_OFDM_RATE_48MB 0x60 -#define IEEE80211_OFDM_RATE_54MB 0x6C -#define IEEE80211_BASIC_RATE_MASK 0x80 - -#define IEEE80211_CCK_RATE_1MB_MASK BIT(0) -#define IEEE80211_CCK_RATE_2MB_MASK BIT(1) -#define IEEE80211_CCK_RATE_5MB_MASK BIT(2) -#define IEEE80211_CCK_RATE_11MB_MASK BIT(3) -#define IEEE80211_OFDM_RATE_6MB_MASK BIT(4) -#define IEEE80211_OFDM_RATE_9MB_MASK BIT(5) -#define IEEE80211_OFDM_RATE_12MB_MASK BIT(6) -#define IEEE80211_OFDM_RATE_18MB_MASK BIT(7) -#define IEEE80211_OFDM_RATE_24MB_MASK BIT(8) -#define IEEE80211_OFDM_RATE_36MB_MASK BIT(9) -#define IEEE80211_OFDM_RATE_48MB_MASK BIT(10) -#define IEEE80211_OFDM_RATE_54MB_MASK BIT(11) - -#define IEEE80211_CCK_RATES_MASK 0x0000000F -#define IEEE80211_CCK_BASIC_RATES_MASK (IEEE80211_CCK_RATE_1MB_MASK | \ - IEEE80211_CCK_RATE_2MB_MASK) -#define IEEE80211_CCK_DEFAULT_RATES_MASK \ - (IEEE80211_CCK_BASIC_RATES_MASK | \ - IEEE80211_CCK_RATE_5MB_MASK | \ - IEEE80211_CCK_RATE_11MB_MASK) - -#define IEEE80211_OFDM_RATES_MASK 0x00000FF0 -#define IEEE80211_OFDM_BASIC_RATES_MASK (IEEE80211_OFDM_RATE_6MB_MASK | \ - IEEE80211_OFDM_RATE_12MB_MASK | \ - IEEE80211_OFDM_RATE_24MB_MASK) -#define IEEE80211_OFDM_DEFAULT_RATES_MASK \ - (IEEE80211_OFDM_BASIC_RATES_MASK | \ - IEEE80211_OFDM_RATE_9MB_MASK | \ - IEEE80211_OFDM_RATE_18MB_MASK | \ - IEEE80211_OFDM_RATE_36MB_MASK | \ - IEEE80211_OFDM_RATE_48MB_MASK | \ - IEEE80211_OFDM_RATE_54MB_MASK) - -#define IEEE80211_NUM_OFDM_RATES 8 -#define IEEE80211_NUM_CCK_RATES 4 -#define IEEE80211_OFDM_SHIFT_MASK_A 4 - -/* IEEE 802.11 requires that STA supports concurrent reception of at least - * three fragmented frames. This define can be increased to support more - * concurrent frames, but it should be noted that each entry can consume about - * 2 kB of RAM and increasing cache size will slow down frame reassembly. - */ -#define IEEE80211_FRAG_CACHE_LEN 4 - -#define SEC_KEY_1 BIT(0) -#define SEC_KEY_2 BIT(1) -#define SEC_KEY_3 BIT(2) -#define SEC_KEY_4 BIT(3) -#define SEC_ACTIVE_KEY BIT(4) -#define SEC_AUTH_MODE BIT(5) -#define SEC_UNICAST_GROUP BIT(6) -#define SEC_LEVEL BIT(7) -#define SEC_ENABLED BIT(8) - -#define SEC_LEVEL_0 0 /* None */ -#define SEC_LEVEL_1 1 /* WEP 40 and 104 bit */ -#define SEC_LEVEL_2 2 /* Level 1 + TKIP */ -#define SEC_LEVEL_2_CKIP 3 /* Level 1 + CKIP */ -#define SEC_LEVEL_3 4 /* Level 2 + CCMP */ - -#define WEP_KEYS 4 -#define WEP_KEY_LEN 13 - -/* SWEEP TABLE ENTRIES NUMBER*/ -#define MAX_SWEEP_TAB_ENTRIES 42 -#define MAX_SWEEP_TAB_ENTRIES_PER_PACKET 7 -/* MAX_RATES_LENGTH needs to be 12. The spec says 8, and many APs - * only use 8, and then use extended rates for the remaining supported - * rates. Other APs, however, stick all of their supported rates on the - * main rates information element... - */ -#define MAX_RATES_LENGTH ((u8)12) -#define MAX_RATES_EX_LENGTH ((u8)16) -#define MAX_NETWORK_COUNT 128 -#define MAX_CHANNEL_NUMBER 161 -#define IEEE80211_SOFTMAC_SCAN_TIME 400 -/* HZ / 2) */ -#define IEEE80211_SOFTMAC_ASSOC_RETRY_TIME (HZ * 2) - -#define CRC_LENGTH 4U - -#define MAX_WPA_IE_LEN (256) -#define MAX_WPS_IE_LEN (512) -#define MAX_P2P_IE_LEN (256) -#define MAX_WFD_IE_LEN (128) - -#define NETWORK_EMPTY_ESSID BIT(0) -#define NETWORK_HAS_OFDM BIT(1) -#define NETWORK_HAS_CCK BIT(2) - -#define IW_ESSID_MAX_SIZE 32 -/* - * join_res: - * -1: authentication fail - * -2: association fail - * > 0: TID - */ - -enum ieee80211_state { - /* the card is not linked at all */ - IEEE80211_NOLINK = 0, - - /* IEEE80211_ASSOCIATING* are for BSS client mode - * the driver shall not perform RX filtering unless - * the state is LINKED. - * The driver shall just check for the state LINKED and - * defaults to NOLINK for ALL the other states (including - * LINKED_SCANNING) - */ - - /* the association procedure will start (wq scheduling)*/ - IEEE80211_ASSOCIATING, - IEEE80211_ASSOCIATING_RETRY, - - /* the association procedure is sending AUTH request*/ - IEEE80211_ASSOCIATING_AUTHENTICATING, - - /* the association procedure has successfully authentcated - * and is sending association request - */ - IEEE80211_ASSOCIATING_AUTHENTICATED, - - /* the link is ok. the card associated to a BSS or linked - * to a ibss cell or acting as an AP and creating the bss - */ - IEEE80211_LINKED, - - /* same as LINKED, but the driver shall apply RX filter - * rules as we are in NO_LINK mode. As the card is still - * logically linked, but it is doing a syncro site survey - * then it will be back to LINKED state. - */ - IEEE80211_LINKED_SCANNING, - -}; - -#define DEFAULT_MAX_SCAN_AGE (15 * HZ) -#define DEFAULT_FTS 2346 - -#define CFG_IEEE80211_RESERVE_FCS BIT(0) -#define CFG_IEEE80211_COMPUTE_FCS BIT(1) - -#define MAXTID 16 - -#define IEEE_A BIT(0) -#define IEEE_B BIT(1) -#define IEEE_G BIT(2) -#define IEEE_MODE_MASK (IEEE_A | IEEE_B | IEEE_G) - -/* Action category code */ -enum rtw_ieee80211_category { - RTW_WLAN_CATEGORY_SPECTRUM_MGMT = 0, - RTW_WLAN_CATEGORY_QOS = 1, - RTW_WLAN_CATEGORY_DLS = 2, - RTW_WLAN_CATEGORY_BACK = 3, - RTW_WLAN_CATEGORY_PUBLIC = 4, /* IEEE 802.11 public action frames */ - RTW_WLAN_CATEGORY_RADIO_MEASUREMENT = 5, - RTW_WLAN_CATEGORY_FT = 6, - RTW_WLAN_CATEGORY_HT = 7, - RTW_WLAN_CATEGORY_SA_QUERY = 8, - RTW_WLAN_CATEGORY_TDLS = 12, - RTW_WLAN_CATEGORY_WMM = 17, - RTW_WLAN_CATEGORY_P2P = 0x7f,/* P2P action frames */ -}; - -enum _PUBLIC_ACTION { - ACT_PUBLIC_BSSCOEXIST = 0, /* 20/40 BSS Coexistence */ - ACT_PUBLIC_DSE_ENABLE = 1, - ACT_PUBLIC_DSE_DEENABLE = 2, - ACT_PUBLIC_DSE_REG_LOCATION = 3, - ACT_PUBLIC_EXT_CHL_SWITCH = 4, - ACT_PUBLIC_DSE_MSR_REQ = 5, - ACT_PUBLIC_DSE_MSR_RPRT = 6, - ACT_PUBLIC_MP = 7, /* Measurement Pilot */ - ACT_PUBLIC_DSE_PWR_CONSTRAINT = 8, - ACT_PUBLIC_VENDOR = 9, /* for WIFI_DIRECT */ - ACT_PUBLIC_GAS_INITIAL_REQ = 10, - ACT_PUBLIC_GAS_INITIAL_RSP = 11, - ACT_PUBLIC_GAS_COMEBACK_REQ = 12, - ACT_PUBLIC_GAS_COMEBACK_RSP = 13, - ACT_PUBLIC_TDLS_DISCOVERY_RSP = 14, - ACT_PUBLIC_LOCATION_TRACK = 15, - ACT_PUBLIC_MAX -}; - -/* HT features action code */ -enum rtw_ieee80211_ht_actioncode { - RTW_WLAN_ACTION_NOTIFY_CH_WIDTH = 0, - RTW_WLAN_ACTION_SM_PS = 1, - RTW_WLAN_ACTION_PSPM = 2, - RTW_WLAN_ACTION_PCO_PHASE = 3, - RTW_WLAN_ACTION_MIMO_CSI_MX = 4, - RTW_WLAN_ACTION_MIMO_NONCP_BF = 5, - RTW_WLAN_ACTION_MIMP_CP_BF = 6, - RTW_WLAN_ACTION_ASEL_INDICATES_FB = 7, - RTW_WLAN_ACTION_HI_INFO_EXCHG = 8, -}; - -#define OUI_MICROSOFT 0x0050f2 /* Microsoft (also used in Wi-Fi specs) - * 00:50:F2 - */ -#define WME_OUI_TYPE 2 -#define WME_OUI_SUBTYPE_INFORMATION_ELEMENT 0 -#define WME_OUI_SUBTYPE_PARAMETER_ELEMENT 1 -#define WME_OUI_SUBTYPE_TSPEC_ELEMENT 2 -#define WME_VERSION 1 - -#define WME_ACTION_CODE_SETUP_REQUEST 0 -#define WME_ACTION_CODE_SETUP_RESPONSE 1 -#define WME_ACTION_CODE_TEARDOWN 2 - -#define WME_SETUP_RESPONSE_STATUS_ADMISSION_ACCEPTED 0 -#define WME_SETUP_RESPONSE_STATUS_INVALID_PARAMETERS 1 -#define WME_SETUP_RESPONSE_STATUS_REFUSED 3 - -#define WME_TSPEC_DIRECTION_UPLINK 0 -#define WME_TSPEC_DIRECTION_DOWNLINK 1 -#define WME_TSPEC_DIRECTION_BI_DIRECTIONAL 3 - -#define OUI_BROADCOM 0x00904c /* Broadcom (Epigram) */ - -#define VENDOR_HT_CAPAB_OUI_TYPE 0x33 /* 00-90-4c:0x33 */ - -/** - * enum rtw_ieee80211_channel_flags - channel flags - * - * Channel flags set by the regulatory control code. - * - * @RTW_IEEE80211_CHAN_DISABLED: This channel is disabled. - * @RTW_IEEE80211_CHAN_PASSIVE_SCAN: Only passive scanning is permitted - * on this channel. - * @RTW_IEEE80211_CHAN_NO_IBSS: IBSS is not allowed on this channel. - * @RTW_IEEE80211_CHAN_RADAR: Radar detection is required on this channel. - * @RTW_IEEE80211_CHAN_NO_HT40PLUS: extension channel above this channel - * is not permitted. - * @RTW_IEEE80211_CHAN_NO_HT40MINUS: extension channel below this channel - * is not permitted. - */ -enum rtw_ieee80211_channel_flags { - RTW_IEEE80211_CHAN_DISABLED = BIT(0), - RTW_IEEE80211_CHAN_PASSIVE_SCAN = BIT(1), - RTW_IEEE80211_CHAN_NO_IBSS = BIT(2), - RTW_IEEE80211_CHAN_RADAR = BIT(3), - RTW_IEEE80211_CHAN_NO_HT40PLUS = BIT(4), - RTW_IEEE80211_CHAN_NO_HT40MINUS = BIT(5), -}; - -#define RTW_IEEE80211_CHAN_NO_HT40 \ - (RTW_IEEE80211_CHAN_NO_HT40PLUS | RTW_IEEE80211_CHAN_NO_HT40MINUS) - -/* Represent channel details, subset of ieee80211_channel */ -struct rtw_ieee80211_channel { - u16 hw_value; - u32 flags; -}; - -#define CHAN_FMT \ - "hw_value:%u, " \ - "flags:0x%08x" \ - -#define CHAN_ARG(channel) \ - (channel)->hw_value \ - , (channel)->flags \ - -/* Parsed Information Elements */ -struct rtw_ieee802_11_elems { - u8 *ssid; - u8 ssid_len; - u8 *supp_rates; - u8 supp_rates_len; - u8 *fh_params; - u8 fh_params_len; - u8 *ds_params; - u8 ds_params_len; - u8 *cf_params; - u8 cf_params_len; - u8 *tim; - u8 tim_len; - u8 *ibss_params; - u8 ibss_params_len; - u8 *challenge; - u8 challenge_len; - u8 *erp_info; - u8 erp_info_len; - u8 *ext_supp_rates; - u8 ext_supp_rates_len; - u8 *wpa_ie; - u8 wpa_ie_len; - u8 *rsn_ie; - u8 rsn_ie_len; - u8 *wme; - u8 wme_len; - u8 *wme_tspec; - u8 wme_tspec_len; - u8 *wps_ie; - u8 wps_ie_len; - u8 *power_cap; - u8 power_cap_len; - u8 *supp_channels; - u8 supp_channels_len; - u8 *mdie; - u8 mdie_len; - u8 *ftie; - u8 ftie_len; - u8 *timeout_int; - u8 timeout_int_len; - u8 *ht_capabilities; - u8 ht_capabilities_len; - u8 *ht_operation; - u8 ht_operation_len; - u8 *vendor_ht_cap; - u8 vendor_ht_cap_len; -}; - -enum parse_res { - ParseOK = 0, - ParseUnknown = 1, - ParseFailed = -1 -}; - -enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, - struct rtw_ieee802_11_elems *elems, - int show_errors); - -u8 *rtw_set_fixed_ie(void *pbuf, unsigned int len, - void *source, unsigned int *frlen); -u8 *rtw_set_ie(u8 *pbuf, int index, uint len, u8 *source, uint *frlen); - -enum secondary_ch_offset { - SCN = 0, /* no secondary channel */ - SCA = 1, /* secondary channel above */ - SCB = 3, /* secondary channel below */ -}; - -u8 *rtw_get_ie(u8 *pbuf, int index, uint *len, int limit); - -void rtw_set_supported_rate(u8 *SupportedRates, uint mode); - -unsigned char *rtw_get_wpa_ie(unsigned char *pie, uint *wpa_ie_len, int limit); -unsigned char *rtw_get_wpa2_ie(unsigned char *pie, uint *rsn_ie_len, int limit); -int rtw_get_wpa_cipher_suite(u8 *s); -int rtw_get_wpa2_cipher_suite(u8 *s); -int rtw_get_wapi_ie(u8 *in_ie, uint in_len, u8 *wapi_ie, u16 *wapi_len); -int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, - int *pairwise_cipher, int *is_8021x); -int rtw_parse_wpa2_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, - int *pairwise_cipher, int *is_8021x); - -void rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, - u8 *wpa_ie, u16 *wpa_len); - -u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen); -u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen); -u8 *rtw_get_wps_attr(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, - u8 *buf_attr, u32 *len_attr); -u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, - u8 *buf_content, uint *len_content); - -uint rtw_get_rateset_len(u8 *rateset); - -struct registry_priv; -int rtw_generate_ie(struct registry_priv *pregistrypriv); - -int rtw_get_bit_value_from_ieee_value(u8 val); - -bool rtw_is_cckrates_included(u8 *rate); - -bool rtw_is_cckratesonly_included(u8 *rate); - -int rtw_check_network_type(unsigned char *rate); - -void rtw_get_bcn_info(struct wlan_network *pnetwork); - -void rtw_macaddr_cfg(u8 *mac_addr); - -u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI_20, u8 short_GI_40, - unsigned char *MCS_rate); - -#endif /* IEEE80211_H */ diff --git a/drivers/staging/rtl8188eu/include/mlme_osdep.h b/drivers/staging/rtl8188eu/include/mlme_osdep.h deleted file mode 100644 index 8e919441c2aa..000000000000 --- a/drivers/staging/rtl8188eu/include/mlme_osdep.h +++ /dev/null @@ -1,21 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __MLME_OSDEP_H_ -#define __MLME_OSDEP_H_ - -#include -#include - -void rtw_init_mlme_timer(struct adapter *padapter); -void rtw_os_indicate_disconnect(struct adapter *adapter); -void rtw_os_indicate_connect(struct adapter *adapter); -void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie); - -void rtw_reset_securitypriv(struct adapter *adapter); -void indicate_wx_scan_complete_event(struct adapter *padapter); - -#endif /* _MLME_OSDEP_H_ */ diff --git a/drivers/staging/rtl8188eu/include/mon.h b/drivers/staging/rtl8188eu/include/mon.h deleted file mode 100644 index 297710626d72..000000000000 --- a/drivers/staging/rtl8188eu/include/mon.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/* - * RTL8188EU monitor interface - * - * Copyright (C) 2015 Jakub Sitnicki - */ - -/* - * Monitor interface receives all transmitted and received IEEE 802.11 - * frames, both Data and Management, and passes them up to userspace - * preserving the WLAN headers. - */ - -#ifndef _MON_H_ -#define _MON_H_ - -struct net_device; -struct recv_frame; -struct xmit_frame; - -struct net_device *rtl88eu_mon_init(void); -void rtl88eu_mon_deinit(struct net_device *dev); - -void rtl88eu_mon_recv_hook(struct net_device *dev, struct recv_frame *frame); -void rtl88eu_mon_xmit_hook(struct net_device *dev, struct xmit_frame *frame, - uint frag_len); - -#endif /* _MON_H_ */ diff --git a/drivers/staging/rtl8188eu/include/odm.h b/drivers/staging/rtl8188eu/include/odm.h deleted file mode 100644 index 9cd612414ab9..000000000000 --- a/drivers/staging/rtl8188eu/include/odm.h +++ /dev/null @@ -1,1052 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __HALDMOUTSRC_H__ -#define __HALDMOUTSRC_H__ - -/* Definition */ -/* Define all team support ability. */ - -/* Define for all teams. Please Define the constant in your precomp header. */ - -/* define DM_ODM_SUPPORT_AP 0 */ -/* define DM_ODM_SUPPORT_ADSL 0 */ -/* define DM_ODM_SUPPORT_CE 0 */ -/* define DM_ODM_SUPPORT_MP 1 */ - -/* Define ODM SW team support flag. */ - -/* Antenna Switch Relative Definition. */ - -/* Add new function SwAntDivCheck8192C(). */ -/* This is the main function of Antenna diversity function before link. */ -/* Mainly, it just retains last scan result and scan again. */ -/* After that, it compares the scan result to see which one gets better - * RSSI. It selects antenna with better receiving power and returns better - * scan result. - */ - -#define TP_MODE 0 -#define RSSI_MODE 1 -#define TRAFFIC_LOW 0 -#define TRAFFIC_HIGH 1 - -/* 3 Tx Power Tracking */ -/* 3============================================================ */ -#define DPK_DELTA_MAPPING_NUM 13 -#define index_mapping_HP_NUM 15 - -/* */ -/* 3 PSD Handler */ -/* 3============================================================ */ - -#define AFH_PSD 1 /* 0:normal PSD scan, 1: only do 20 pts PSD */ -#define MODE_40M 0 /* 0:20M, 1:40M */ -#define PSD_TH2 3 -#define PSD_CHM 20 /* Minimum channel number for BT AFH */ -#define SIR_STEP_SIZE 3 -#define Smooth_Size_1 5 -#define Smooth_TH_1 3 -#define Smooth_Size_2 10 -#define Smooth_TH_2 4 -#define Smooth_Size_3 20 -#define Smooth_TH_3 4 -#define Smooth_Step_Size 5 -#define Adaptive_SIR 1 -#define PSD_RESCAN 4 -#define PSD_SCAN_INTERVAL 700 /* ms */ - -/* 8723A High Power IGI Setting */ -#define DM_DIG_HIGH_PWR_IGI_LOWER_BOUND 0x22 -#define DM_DIG_Gmode_HIGH_PWR_IGI_LOWER_BOUND 0x28 -#define DM_DIG_HIGH_PWR_THRESHOLD 0x3a - -/* LPS define */ -#define DM_DIG_FA_TH0_LPS 4 /* 4 in lps */ -#define DM_DIG_FA_TH1_LPS 15 /* 15 lps */ -#define DM_DIG_FA_TH2_LPS 30 /* 30 lps */ -#define RSSI_OFFSET_DIG 0x05; - -struct rtw_dig { - u8 Dig_Enable_Flag; - u8 Dig_Ext_Port_Stage; - - int RssiLowThresh; - int RssiHighThresh; - - u32 FALowThresh; - u32 FAHighThresh; - - u8 CurSTAConnectState; - u8 PreSTAConnectState; - u8 CurMultiSTAConnectState; - - u8 PreIGValue; - u8 CurIGValue; - u8 BackupIGValue; - - s8 BackoffVal; - s8 BackoffVal_range_max; - s8 BackoffVal_range_min; - u8 rx_gain_range_max; - u8 rx_gain_range_min; - u8 Rssi_val_min; - - u8 PreCCK_CCAThres; - u8 CurCCK_CCAThres; - u8 PreCCKPDState; - u8 CurCCKPDState; - - u8 LargeFAHit; - u8 ForbiddenIGI; - u32 Recover_cnt; - - u8 DIG_Dynamic_MIN_0; - u8 DIG_Dynamic_MIN_1; - bool bMediaConnect_0; - bool bMediaConnect_1; - - u32 AntDiv_RSSI_max; - u32 RSSI_max; -}; - -struct rtl_ps { - u8 PreCCAState; - u8 CurCCAState; - - u8 PreRFState; - u8 CurRFState; - - int Rssi_val_min; - - u8 initialize; - u32 Reg874, RegC70, Reg85C, RegA74; - -}; - -struct false_alarm_stats { - u32 Cnt_Parity_Fail; - u32 Cnt_Rate_Illegal; - u32 Cnt_Crc8_fail; - u32 Cnt_Mcs_fail; - u32 Cnt_Ofdm_fail; - u32 Cnt_Cck_fail; - u32 Cnt_all; - u32 Cnt_Fast_Fsync; - u32 Cnt_SB_Search_fail; - u32 Cnt_OFDM_CCA; - u32 Cnt_CCK_CCA; - u32 Cnt_CCA_all; - u32 Cnt_BW_USC; /* Gary */ - u32 Cnt_BW_LSC; /* Gary */ -}; - -struct rx_hpc { - u8 RXHP_flag; - u8 PSD_func_trigger; - u8 PSD_bitmap_RXHP[80]; - u8 Pre_IGI; - u8 Cur_IGI; - u8 Pre_pw_th; - u8 Cur_pw_th; - bool First_time_enter; - bool RXHP_enable; - u8 TP_Mode; - struct timer_list PSDTimer; -}; - -#define ASSOCIATE_ENTRY_NUM 32 /* Max size of AsocEntry[]. */ -#define ODM_ASSOCIATE_ENTRY_NUM ASSOCIATE_ENTRY_NUM - -/* This indicates two different steps. */ -/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to - * the signal on the air. - */ -/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in - * SWAW_STEP_PEAK with original RSSI to determine if it is necessary to - * switch antenna. - */ - -#define SWAW_STEP_PEAK 0 -#define SWAW_STEP_DETERMINE 1 - -#define TP_MODE 0 -#define RSSI_MODE 1 -#define TRAFFIC_LOW 0 -#define TRAFFIC_HIGH 1 - -struct sw_ant_switch { - u8 try_flag; - s32 PreRSSI; - u8 CurAntenna; - u8 PreAntenna; - u8 RSSI_Trying; - u8 TestMode; - u8 bTriggerAntennaSwitch; - u8 SelectAntennaMap; - u8 RSSI_target; - - /* Before link Antenna Switch check */ - u8 SWAS_NoLink_State; - u32 SWAS_NoLink_BK_Reg860; - bool ANTA_ON; /* To indicate Ant A is or not */ - bool ANTB_ON; /* To indicate Ant B is on or not */ - - s32 RSSI_sum_A; - s32 RSSI_sum_B; - s32 RSSI_cnt_A; - s32 RSSI_cnt_B; - u64 lastTxOkCnt; - u64 lastRxOkCnt; - u64 TXByteCnt_A; - u64 TXByteCnt_B; - u64 RXByteCnt_A; - u64 RXByteCnt_B; - u8 TrafficLoad; - struct timer_list SwAntennaSwitchTimer; - /* Hybrid Antenna Diversity */ - u32 CCK_Ant1_Cnt[ASSOCIATE_ENTRY_NUM]; - u32 CCK_Ant2_Cnt[ASSOCIATE_ENTRY_NUM]; - u32 OFDM_Ant1_Cnt[ASSOCIATE_ENTRY_NUM]; - u32 OFDM_Ant2_Cnt[ASSOCIATE_ENTRY_NUM]; - u32 RSSI_Ant1_Sum[ASSOCIATE_ENTRY_NUM]; - u32 RSSI_Ant2_Sum[ASSOCIATE_ENTRY_NUM]; - u8 TxAnt[ASSOCIATE_ENTRY_NUM]; - u8 TargetSTA; - u8 antsel; - u8 RxIdleAnt; -}; - -struct edca_turbo { - bool bCurrentTurboEDCA; - bool bIsCurRDLState; - u32 prv_traffic_idx; /* edca turbo */ -}; - -struct odm_rate_adapt { - u8 Type; /* DM_Type_ByFW/DM_Type_ByDriver */ - u8 HighRSSIThresh; /* if RSSI > HighRSSIThresh => RATRState is DM_RATR_STA_HIGH */ - u8 LowRSSIThresh; /* if RSSI <= LowRSSIThresh => RATRState is DM_RATR_STA_LOW */ - u8 RATRState; /* Current RSSI level, DM_RATR_STA_HIGH/DM_RATR_STA_MIDDLE/DM_RATR_STA_LOW */ - u32 LastRATR; /* RATR Register Content */ -}; - -#define IQK_MAC_REG_NUM 4 -#define IQK_ADDA_REG_NUM 16 -#define IQK_BB_REG_NUM 9 -#define HP_THERMAL_NUM 8 - -#define AVG_THERMAL_NUM 8 -#define IQK_Matrix_Settings_NUM (1 + 24 + 21) - -#define DM_Type_ByFWi 0 -#define DM_Type_ByDriver 1 - -/* Declare for common info */ - -struct odm_phy_status_info { - u8 RxPWDBAll; - u8 SignalQuality; /* in 0-100 index. */ - u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */ - u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */ - s8 RxPower; /* in dBm Translate from PWdB */ - s8 RecvSignalPower;/* Real power in dBm for this packet, no - * beautification and aggregation. Keep this raw - * info to be used for the other procedures. - */ - u8 BTRxRSSIPercentage; - u8 SignalStrength; /* in 0-100 index. */ - u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ - u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */ -}; - -struct odm_phy_dbg_info { - /* ODM Write,debug info */ - s8 RxSNRdB[MAX_PATH_NUM_92CS]; - u64 NumQryPhyStatus; - u64 NumQryPhyStatusCCK; - u64 NumQryPhyStatusOFDM; - /* Others */ - s32 RxEVM[MAX_PATH_NUM_92CS]; -}; - -struct odm_per_pkt_info { - s8 Rate; - u8 StationID; - bool bPacketMatchBSSID; - bool bPacketToSelf; - bool bPacketBeacon; -}; - -struct odm_mac_status_info { - u8 test; -}; - -enum odm_ability { - /* BB Team */ - ODM_DIG = 0x00000001, - ODM_HIGH_POWER = 0x00000002, - ODM_CCK_CCA_TH = 0x00000004, - ODM_FA_STATISTICS = 0x00000008, - ODM_RAMASK = 0x00000010, - ODM_RSSI_MONITOR = 0x00000020, - ODM_SW_ANTDIV = 0x00000040, - ODM_HW_ANTDIV = 0x00000080, - ODM_BB_PWRSV = 0x00000100, - ODM_2TPATHDIV = 0x00000200, - ODM_1TPATHDIV = 0x00000400, - ODM_PSD2AFH = 0x00000800 -}; - -/* 2011/10/20 MH Define Common info enum for all team. */ - -enum odm_common_info_def { - /* Fixed value: */ - - /* HOOK BEFORE REG INIT----------- */ - ODM_CMNINFO_PLATFORM = 0, - ODM_CMNINFO_ABILITY, /* ODM_ABILITY_E */ - ODM_CMNINFO_INTERFACE, /* ODM_INTERFACE_E */ - ODM_CMNINFO_MP_TEST_CHIP, - ODM_CMNINFO_IC_TYPE, /* ODM_IC_TYPE_E */ - ODM_CMNINFO_CUT_VER, /* ODM_CUT_VERSION_E */ - ODM_CMNINFO_RF_TYPE, /* ODM_RF_PATH_E or ODM_RF_TYPE_E? */ - ODM_CMNINFO_BOARD_TYPE, /* ODM_BOARD_TYPE_E */ - ODM_CMNINFO_EXT_LNA, /* true */ - ODM_CMNINFO_EXT_PA, - ODM_CMNINFO_EXT_TRSW, - ODM_CMNINFO_PATCH_ID, /* CUSTOMER ID */ - ODM_CMNINFO_BINHCT_TEST, - ODM_CMNINFO_BWIFI_TEST, - ODM_CMNINFO_SMART_CONCURRENT, - /* HOOK BEFORE REG INIT----------- */ - - /* Dynamic value: */ -/* POINTER REFERENCE----------- */ - ODM_CMNINFO_MAC_PHY_MODE, /* ODM_MAC_PHY_MODE_E */ - ODM_CMNINFO_TX_UNI, - ODM_CMNINFO_RX_UNI, - ODM_CMNINFO_WM_MODE, /* ODM_WIRELESS_MODE_E */ - ODM_CMNINFO_BAND, /* ODM_BAND_TYPE_E */ - ODM_CMNINFO_SEC_CHNL_OFFSET, /* ODM_SEC_CHNL_OFFSET_E */ - ODM_CMNINFO_SEC_MODE, /* ODM_SECURITY_E */ - ODM_CMNINFO_BW, /* ODM_BW_E */ - ODM_CMNINFO_CHNL, - - ODM_CMNINFO_DMSP_GET_VALUE, - ODM_CMNINFO_BUDDY_ADAPTOR, - ODM_CMNINFO_DMSP_IS_MASTER, - ODM_CMNINFO_SCAN, - ODM_CMNINFO_POWER_SAVING, - ODM_CMNINFO_ONE_PATH_CCA, /* ODM_CCA_PATH_E */ - ODM_CMNINFO_DRV_STOP, - ODM_CMNINFO_PNP_IN, - ODM_CMNINFO_INIT_ON, - ODM_CMNINFO_ANT_TEST, - ODM_CMNINFO_NET_CLOSED, - ODM_CMNINFO_MP_MODE, -/* POINTER REFERENCE----------- */ - -/* CALL BY VALUE------------- */ - ODM_CMNINFO_WIFI_DIRECT, - ODM_CMNINFO_WIFI_DISPLAY, - ODM_CMNINFO_LINK, - ODM_CMNINFO_RSSI_MIN, - ODM_CMNINFO_DBG_COMP, /* u64 */ - ODM_CMNINFO_DBG_LEVEL, /* u32 */ - ODM_CMNINFO_RA_THRESHOLD_HIGH, /* u8 */ - ODM_CMNINFO_RA_THRESHOLD_LOW, /* u8 */ - ODM_CMNINFO_RF_ANTENNA_TYPE, /* u8 */ - ODM_CMNINFO_BT_DISABLED, - ODM_CMNINFO_BT_OPERATION, - ODM_CMNINFO_BT_DIG, - ODM_CMNINFO_BT_BUSY, /* Check Bt is using or not */ - ODM_CMNINFO_BT_DISABLE_EDCA, -/* CALL BY VALUE-------------*/ - - /* Dynamic ptr array hook itms. */ - ODM_CMNINFO_STA_STATUS, - ODM_CMNINFO_PHY_STATUS, - ODM_CMNINFO_MAC_STATUS, - ODM_CMNINFO_MAX, -}; - -/* 2011/10/20 MH Define ODM support ability. ODM_CMNINFO_ABILITY */ - -enum odm_ability_def { - /* BB ODM section BIT 0-15 */ - ODM_BB_DIG = BIT(0), - ODM_BB_RA_MASK = BIT(1), - ODM_BB_DYNAMIC_TXPWR = BIT(2), - ODM_BB_FA_CNT = BIT(3), - ODM_BB_RSSI_MONITOR = BIT(4), - ODM_BB_CCK_PD = BIT(5), - ODM_BB_ANT_DIV = BIT(6), - ODM_BB_PWR_SAVE = BIT(7), - ODM_BB_PWR_TRA = BIT(8), - ODM_BB_RATE_ADAPTIVE = BIT(9), - ODM_BB_PATH_DIV = BIT(10), - ODM_BB_PSD = BIT(11), - ODM_BB_RXHP = BIT(12), - - /* MAC DM section BIT 16-23 */ - ODM_MAC_EDCA_TURBO = BIT(16), - ODM_MAC_EARLY_MODE = BIT(17), - - /* RF ODM section BIT 24-31 */ - ODM_RF_TX_PWR_TRACK = BIT(24), - ODM_RF_RX_GAIN_TRACK = BIT(25), - ODM_RF_CALIBRATION = BIT(26), -}; - -#define ODM_RTL8188E BIT(4) - -/* ODM_CMNINFO_CUT_VER */ -enum odm_cut_version { - ODM_CUT_A = 1, - ODM_CUT_B = 2, - ODM_CUT_C = 3, - ODM_CUT_D = 4, - ODM_CUT_E = 5, - ODM_CUT_F = 6, - ODM_CUT_TEST = 7, -}; - -/* ODM_CMNINFO_RF_TYPE */ -/* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ -enum odm_rf_path { - ODM_RF_TX_A = BIT(0), - ODM_RF_TX_B = BIT(1), - ODM_RF_TX_C = BIT(2), - ODM_RF_TX_D = BIT(3), - ODM_RF_RX_A = BIT(4), - ODM_RF_RX_B = BIT(5), - ODM_RF_RX_C = BIT(6), - ODM_RF_RX_D = BIT(7), -}; - -enum odm_rf_type { - ODM_1T1R = 0, - ODM_1T2R = 1, - ODM_2T2R = 2, - ODM_2T3R = 3, - ODM_2T4R = 4, - ODM_3T3R = 5, - ODM_3T4R = 6, - ODM_4T4R = 7, -}; - -/* ODM Dynamic common info value definition */ - -enum odm_mac_phy_mode { - ODM_SMSP = 0, - ODM_DMSP = 1, - ODM_DMDP = 2, -}; - -enum odm_bt_coexist { - ODM_BT_BUSY = 1, - ODM_BT_ON = 2, - ODM_BT_OFF = 3, - ODM_BT_NONE = 4, -}; - -/* ODM_CMNINFO_OP_MODE */ -enum odm_operation_mode { - ODM_NO_LINK = BIT(0), - ODM_LINK = BIT(1), - ODM_SCAN = BIT(2), - ODM_POWERSAVE = BIT(3), - ODM_AP_MODE = BIT(4), - ODM_CLIENT_MODE = BIT(5), - ODM_AD_HOC = BIT(6), - ODM_WIFI_DIRECT = BIT(7), - ODM_WIFI_DISPLAY = BIT(8), -}; - -/* ODM_CMNINFO_WM_MODE */ -enum odm_wireless_mode { - ODM_WM_UNKNOWN = 0x0, - ODM_WM_B = BIT(0), - ODM_WM_G = BIT(1), - ODM_WM_A = BIT(2), - ODM_WM_N24G = BIT(3), - ODM_WM_N5G = BIT(4), - ODM_WM_AUTO = BIT(5), - ODM_WM_AC = BIT(6), -}; - -/* ODM_CMNINFO_BAND */ -enum odm_band_type { - ODM_BAND_2_4G = BIT(0), - ODM_BAND_5G = BIT(1), -}; - -/* ODM_CMNINFO_SEC_CHNL_OFFSET */ -enum odm_sec_chnl_offset { - ODM_DONT_CARE = 0, - ODM_BELOW = 1, - ODM_ABOVE = 2 -}; - -/* ODM_CMNINFO_SEC_MODE */ -enum odm_security { - ODM_SEC_OPEN = 0, - ODM_SEC_WEP40 = 1, - ODM_SEC_TKIP = 2, - ODM_SEC_RESERVE = 3, - ODM_SEC_AESCCMP = 4, - ODM_SEC_WEP104 = 5, - ODM_WEP_WPA_MIXED = 6, /* WEP + WPA */ - ODM_SEC_SMS4 = 7, -}; - -/* ODM_CMNINFO_BW */ -enum odm_bw { - ODM_BW20M = 0, - ODM_BW40M = 1, - ODM_BW80M = 2, - ODM_BW160M = 3, - ODM_BW10M = 4, -}; - -/* ODM_CMNINFO_BOARD_TYPE */ -enum odm_board_type { - ODM_BOARD_NORMAL = 0, - ODM_BOARD_HIGHPWR = 1, - ODM_BOARD_MINICARD = 2, - ODM_BOARD_SLIM = 3, - ODM_BOARD_COMBO = 4, -}; - -/* ODM_CMNINFO_ONE_PATH_CCA */ -enum odm_cca_path { - ODM_CCA_2R = 0, - ODM_CCA_1R_A = 1, - ODM_CCA_1R_B = 2, -}; - -struct odm_ra_info { - u8 RateID; - u32 RateMask; - u32 RAUseRate; - u8 RateSGI; - u8 RssiStaRA; - u8 PreRssiStaRA; - u8 SGIEnable; - u8 DecisionRate; - u8 PreRate; - u8 HighestRate; - u8 LowestRate; - u32 NscUp; - u32 NscDown; - u16 RTY[5]; - u32 TOTAL; - u16 DROP; - u8 Active; - u16 RptTime; - u8 RAWaitingCounter; - u8 RAPendingCounter; - u8 PTActive; /* on or off */ - u8 PTTryState; /* 0 trying state, 1 for decision state */ - u8 PTStage; /* 0~6 */ - u8 PTStopCount; /* Stop PT counter */ - u8 PTPreRate; /* if rate change do PT */ - u8 PTPreRssi; /* if RSSI change 5% do PT */ - u8 PTModeSS; /* decide whitch rate should do PT */ - u8 RAstage; /* StageRA, decide how many times RA will be done - * between PT - */ - u8 PTSmoothFactor; -}; - -struct odm_rf_cal { - /* for tx power tracking */ - u32 RegA24; /* for TempCCK */ - s32 RegE94; - s32 RegE9C; - s32 RegEB4; - s32 RegEBC; - - u8 TXPowercount; - bool bTXPowerTracking; - u8 TxPowerTrackControl; /* for mp mode, turn off txpwrtracking - * as default - */ - u8 TM_Trigger; - u8 InternalPA5G[2]; /* pathA / pathB */ - - u8 ThermalMeter[2]; /* ThermalMeter, index 0 for RFIC0, - * and 1 for RFIC1 - */ - u8 ThermalValue; - u8 ThermalValue_LCK; - u8 ThermalValue_IQK; - u8 ThermalValue_DPK; - u8 ThermalValue_AVG[AVG_THERMAL_NUM]; - u8 ThermalValue_AVG_index; - u8 ThermalValue_RxGain; - u8 ThermalValue_Crystal; - u8 ThermalValue_DPKstore; - u8 ThermalValue_DPKtrack; - bool TxPowerTrackingInProgress; - bool bDPKenable; - - bool bReloadtxpowerindex; - u8 bRfPiEnable; - u32 TXPowerTrackingCallbackCnt; /* cosa add for debug */ - - u8 bCCKinCH14; - u8 CCK_index; - u8 OFDM_index[2]; - bool bDoneTxpower; - - u8 ThermalValue_HP[HP_THERMAL_NUM]; - u8 ThermalValue_HP_index; - - u8 Delta_IQK; - u8 Delta_LCK; - - /* for IQK */ - u32 RegC04; - u32 Reg874; - u32 RegC08; - u32 RegB68; - u32 RegB6C; - u32 Reg870; - u32 Reg860; - u32 Reg864; - - bool bIQKInitialized; - bool bLCKInProgress; - bool bAntennaDetected; - u32 ADDA_backup[IQK_ADDA_REG_NUM]; - u32 IQK_MAC_backup[IQK_MAC_REG_NUM]; - u32 IQK_BB_backup_recover[9]; - u32 IQK_BB_backup[IQK_BB_REG_NUM]; - - /* for APK */ - u32 APKoutput[2][2]; /* path A/B; output1_1a/output1_2a */ - u8 bAPKdone; - u8 bAPKThermalMeterIgnore; - u8 bDPdone; - u8 bDPPathAOK; - u8 bDPPathBOK; -}; - -/* ODM Dynamic common info value definition */ - -struct fast_ant_train { - u8 Bssid[6]; - u8 antsel_rx_keep_0; - u8 antsel_rx_keep_1; - u8 antsel_rx_keep_2; - u32 antSumRSSI[7]; - u32 antRSSIcnt[7]; - u32 antAveRSSI[7]; - u8 FAT_State; - u32 TrainIdx; - u8 antsel_a[ODM_ASSOCIATE_ENTRY_NUM]; - u8 antsel_b[ODM_ASSOCIATE_ENTRY_NUM]; - u8 antsel_c[ODM_ASSOCIATE_ENTRY_NUM]; - u32 MainAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM]; - u32 AuxAnt_Sum[ODM_ASSOCIATE_ENTRY_NUM]; - u32 MainAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; - u32 AuxAnt_Cnt[ODM_ASSOCIATE_ENTRY_NUM]; - u8 RxIdleAnt; - bool bBecomeLinked; -}; - -enum fat_state { - FAT_NORMAL_STATE = 0, - FAT_TRAINING_STATE = 1, -}; - -enum ant_div_type { - NO_ANTDIV = 0xFF, - CG_TRX_HW_ANTDIV = 0x01, - CGCS_RX_HW_ANTDIV = 0x02, - FIXED_HW_ANTDIV = 0x03, - CG_TRX_SMART_ANTDIV = 0x04, - CGCS_RX_SW_ANTDIV = 0x05, -}; - -/* Copy from SD4 defined structure. We use to support PHY DM integration. */ -struct odm_dm_struct { - /* Add for different team use temporarily */ - struct adapter *Adapter; /* For CE/NIC team */ - struct rtl8192cd_priv *priv; /* For AP/ADSL team */ - /* WHen you use above pointers, they must be initialized. */ - bool odm_ready; - - struct rtl8192cd_priv *fake_priv; - -/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ - bool bCckHighPower; - u8 RFPathRxEnable; /* ODM_CMNINFO_RFPATH_ENABLE */ - u8 ControlChannel; -/* ODM HANDLE, DRIVER NEEDS NOT TO HOOK------ */ - -/* 1 COMMON INFORMATION */ - /* Init Value */ -/* HOOK BEFORE REG INIT----------- */ - /* ODM Platform info AP/ADSL/CE/MP = 1/2/3/4 */ - u8 SupportPlatform; - /* ODM Support Ability DIG/RATR/TX_PWR_TRACK/... = 1/2/3/... */ - u32 SupportAbility; - /* ODM PCIE/USB/SDIO/GSPI = 0/1/2/3 */ - u8 SupportInterface; - /* ODM composite or independent. Bit oriented/ 92C+92D+ .... or any - * other type = 1/2/3/... - */ - u32 SupportICType; - /* Cut Version TestChip/A-cut/B-cut... = 0/1/2/3/... */ - u8 CutVersion; - /* Board Type Normal/HighPower/MiniCard/SLIM/Combo/. = 0/1/2/3/4/. */ - u8 BoardType; - /* with external LNA NO/Yes = 0/1 */ - u8 ExtLNA; - /* with external PA NO/Yes = 0/1 */ - u8 ExtPA; - /* with external TRSW NO/Yes = 0/1 */ - u8 ExtTRSW; - u8 PatchID; /* Customer ID */ - bool bInHctTest; - bool bWIFITest; - - bool bDualMacSmartConcurrent; - u32 BK_SupportAbility; - u8 AntDivType; -/* HOOK BEFORE REG INIT----------- */ - - /* Dynamic Value */ -/* POINTER REFERENCE----------- */ - - u8 u8_temp; - bool bool_temp; - struct adapter *adapter_temp; - - /* MAC PHY Mode SMSP/DMSP/DMDP = 0/1/2 */ - u8 *pMacPhyMode; - /* TX Unicast byte count */ - u64 *pNumTxBytesUnicast; - /* RX Unicast byte count */ - u64 *pNumRxBytesUnicast; - /* Wireless mode B/G/A/N = BIT0/BIT1/BIT2/BIT3 */ - u8 *pWirelessMode; /* ODM_WIRELESS_MODE_E */ - /* Frequence band 2.4G/5G = 0/1 */ - u8 *pBandType; - /* Secondary channel offset don't_care/below/above = 0/1/2 */ - u8 *pSecChOffset; - /* Security mode Open/WEP/AES/TKIP = 0/1/2/3 */ - u8 *pSecurity; - /* BW info 20M/40M/80M = 0/1/2 */ - u8 *pBandWidth; - /* Central channel location Ch1/Ch2/.... */ - u8 *pChannel; /* central channel number */ - /* Common info for 92D DMSP */ - - bool *pbGetValueFromOtherMac; - struct adapter **pBuddyAdapter; - bool *pbMasterOfDMSP; /* MAC0: master, MAC1: slave */ - /* Common info for Status */ - bool *pbScanInProcess; - bool *pbPowerSaving; - /* CCA Path 2-path/path-A/path-B = 0/1/2; using ODM_CCA_PATH_E. */ - u8 *pOnePathCCA; - /* pMgntInfo->AntennaTest */ - u8 *pAntennaTest; - bool *pbNet_closed; -/* POINTER REFERENCE----------- */ - /* */ -/* CALL BY VALUE------------- */ - bool bWIFI_Direct; - bool bWIFI_Display; - bool bLinked; - u8 RSSI_Min; - u8 InterfaceIndex; /* Add for 92D dual MAC: 0--Mac0 1--Mac1 */ - bool bIsMPChip; - bool bOneEntryOnly; - /* Common info for BTDM */ - bool bBtDisabled; /* BT is disabled */ - bool bBtHsOperation; /* BT HS mode is under progress */ - u8 btHsDigVal; /* use BT rssi to decide the DIG value */ - bool bBtDisableEdcaTurbo;/* Under some condition, don't enable the - * EDCA Turbo - */ - bool bBtBusy; /* BT is busy. */ -/* CALL BY VALUE------------- */ - - /* 2 Define STA info. */ - /* _ODM_STA_INFO */ - /* For MP, we need to reduce one array pointer for default port.??*/ - struct sta_info *pODM_StaInfo[ODM_ASSOCIATE_ENTRY_NUM]; - - u16 CurrminRptTime; - struct odm_ra_info RAInfo[ODM_ASSOCIATE_ENTRY_NUM]; /* Use MacID as - * array index. STA MacID=0, - * VWiFi Client MacID={1, ODM_ASSOCIATE_ENTRY_NUM-1} - */ - /* */ - /* 2012/02/14 MH Add to share 88E ra with other SW team. */ - /* We need to colelct all support abilit to a proper area. */ - /* */ - bool RaSupport88E; - - /* Define ........... */ - - /* Latest packet phy info (ODM write) */ - struct odm_phy_dbg_info PhyDbgInfo; - - /* Latest packet phy info (ODM write) */ - struct odm_mac_status_info *pMacInfo; - - /* Different Team independt structure?? */ - - /* ODM Structure */ - struct fast_ant_train DM_FatTable; - struct rtw_dig DM_DigTable; - struct rtl_ps DM_PSTable; - struct rx_hpc DM_RXHP_Table; - struct false_alarm_stats FalseAlmCnt; - struct false_alarm_stats FlaseAlmCntBuddyAdapter; - struct sw_ant_switch DM_SWAT_Table; - bool RSSI_test; - - struct edca_turbo DM_EDCA_Table; - u32 WMMEDCA_BE; - /* Copy from SD4 structure */ - /* */ - /* ================================================== */ - /* */ - - bool *pbDriverStopped; - bool *pbDriverIsGoingToPnpSetPowerSleep; - bool *pinit_adpt_in_progress; - - /* PSD */ - bool bUserAssignLevel; - struct timer_list PSDTimer; - u8 RSSI_BT; /* come from BT */ - bool bPSDinProcess; - bool bDMInitialGainEnable; - - /* for rate adaptive, in fact, 88c/92c fw will handle this */ - u8 bUseRAMask; - - struct odm_rate_adapt RateAdaptive; - - struct odm_rf_cal RFCalibrateInfo; - - /* TX power tracking */ - u8 BbSwingIdxOfdm; - u8 BbSwingIdxOfdmCurrent; - u8 BbSwingIdxOfdmBase; - bool BbSwingFlagOfdm; - u8 BbSwingIdxCck; - u8 BbSwingIdxCckCurrent; - u8 BbSwingIdxCckBase; - bool BbSwingFlagCck; - u8 *mp_mode; - /* ODM system resource. */ - - /* ODM relative time. */ - struct timer_list PathDivSwitchTimer; - /* 2011.09.27 add for Path Diversity */ - struct timer_list CCKPathDiversityTimer; - struct timer_list FastAntTrainingTimer; -}; /* DM_Dynamic_Mechanism_Structure */ - -#define ODM_RF_PATH_MAX 3 - -enum ODM_RF_CONTENT { - odm_radioa_txt = 0x1000, - odm_radiob_txt = 0x1001, - odm_radioc_txt = 0x1002, - odm_radiod_txt = 0x1003 -}; - -/* Status code */ -enum rt_status { - RT_STATUS_SUCCESS, - RT_STATUS_FAILURE, - RT_STATUS_PENDING, - RT_STATUS_RESOURCE, - RT_STATUS_INVALID_CONTEXT, - RT_STATUS_INVALID_PARAMETER, - RT_STATUS_NOT_SUPPORT, - RT_STATUS_OS_API_FAILED, -}; - -/* 3=========================================================== */ -/* 3 DIG */ -/* 3=========================================================== */ - -enum dm_dig_op { - RT_TYPE_THRESH_HIGH = 0, - RT_TYPE_THRESH_LOW = 1, - RT_TYPE_BACKOFF = 2, - RT_TYPE_RX_GAIN_MIN = 3, - RT_TYPE_RX_GAIN_MAX = 4, - RT_TYPE_ENABLE = 5, - RT_TYPE_DISABLE = 6, - DIG_OP_TYPE_MAX -}; - -#define DM_DIG_THRESH_HIGH 40 -#define DM_DIG_THRESH_LOW 35 - -#define DM_SCAN_RSSI_TH 0x14 /* scan return issue for LC */ - -#define DM_false_ALARM_THRESH_LOW 400 -#define DM_false_ALARM_THRESH_HIGH 1000 - -#define DM_DIG_MAX_NIC 0x4e -#define DM_DIG_MIN_NIC 0x1e /* 0x22/0x1c */ - -#define DM_DIG_MAX_AP 0x32 -#define DM_DIG_MIN_AP 0x20 - -#define DM_DIG_MAX_NIC_HP 0x46 -#define DM_DIG_MIN_NIC_HP 0x2e - -#define DM_DIG_MAX_AP_HP 0x42 -#define DM_DIG_MIN_AP_HP 0x30 - -/* vivi 92c&92d has different definition, 20110504 */ -/* this is for 92c */ -#define DM_DIG_FA_TH0 0x200/* 0x20 */ -#define DM_DIG_FA_TH1 0x300/* 0x100 */ -#define DM_DIG_FA_TH2 0x400/* 0x200 */ -/* this is for 92d */ -#define DM_DIG_FA_TH0_92D 0x100 -#define DM_DIG_FA_TH1_92D 0x400 -#define DM_DIG_FA_TH2_92D 0x600 - -#define DM_DIG_BACKOFF_MAX 12 -#define DM_DIG_BACKOFF_MIN -4 -#define DM_DIG_BACKOFF_DEFAULT 10 - -/* 3=========================================================== */ -/* 3 AGC RX High Power Mode */ -/* 3=========================================================== */ -#define LNA_Low_Gain_1 0x64 -#define LNA_Low_Gain_2 0x5A -#define LNA_Low_Gain_3 0x58 - -#define FA_RXHP_TH1 5000 -#define FA_RXHP_TH2 1500 -#define FA_RXHP_TH3 800 -#define FA_RXHP_TH4 600 -#define FA_RXHP_TH5 500 - -/* 3=========================================================== */ -/* 3 EDCA */ -/* 3=========================================================== */ - -/* 3=========================================================== */ -/* 3 Dynamic Tx Power */ -/* 3=========================================================== */ -/* Dynamic Tx Power Control Threshold */ -#define TX_POWER_NEAR_FIELD_THRESH_LVL2 74 -#define TX_POWER_NEAR_FIELD_THRESH_LVL1 67 -#define TX_POWER_NEAR_FIELD_THRESH_AP 0x3F - -#define TxHighPwrLevel_Normal 0 -#define TxHighPwrLevel_Level1 1 -#define TxHighPwrLevel_Level2 2 -#define TxHighPwrLevel_BT1 3 -#define TxHighPwrLevel_BT2 4 -#define TxHighPwrLevel_15 5 -#define TxHighPwrLevel_35 6 -#define TxHighPwrLevel_50 7 -#define TxHighPwrLevel_70 8 -#define TxHighPwrLevel_100 9 - -/* 3=========================================================== */ -/* 3 Rate Adaptive */ -/* 3=========================================================== */ -#define DM_RATR_STA_INIT 0 -#define DM_RATR_STA_HIGH 1 -#define DM_RATR_STA_MIDDLE 2 -#define DM_RATR_STA_LOW 3 - -/* 3=========================================================== */ -/* 3 BB Power Save */ -/* 3=========================================================== */ - -enum dm_1r_cca { - CCA_1R = 0, - CCA_2R = 1, - CCA_MAX = 2, -}; - -enum dm_rf { - RF_Save = 0, - RF_Normal = 1, - RF_MAX = 2, -}; - -/* 3=========================================================== */ -/* 3 Antenna Diversity */ -/* 3=========================================================== */ -enum dm_swas { - Antenna_A = 1, - Antenna_B = 2, - Antenna_MAX = 3, -}; - -/* Maximal number of antenna detection mechanism needs to perform. */ -#define MAX_ANTENNA_DETECTION_CNT 10 - -/* Extern Global Variables. */ -#define OFDM_TABLE_SIZE_92C 37 -#define OFDM_TABLE_SIZE_92D 43 -#define CCK_TABLE_SIZE 33 - -extern u32 OFDMSwingTable[OFDM_TABLE_SIZE_92D]; -extern u8 CCKSwingTable_Ch1_Ch13[CCK_TABLE_SIZE][8]; -extern u8 CCKSwingTable_Ch14[CCK_TABLE_SIZE][8]; - -/* check Sta pointer valid or not */ -#define IS_STA_VALID(pSta) (pSta) -/* 20100514 Joseph: Add definition for antenna switching test after link. */ -/* This indicates two different the steps. */ -/* In SWAW_STEP_PEAK, driver needs to switch antenna and listen to the - * signal on the air. - */ -/* In SWAW_STEP_DETERMINE, driver just compares the signal captured in - * SWAW_STEP_PEAK - */ -/* with original RSSI to determine if it is necessary to switch antenna. */ -#define SWAW_STEP_PEAK 0 -#define SWAW_STEP_DETERMINE 1 - -#define dm_CheckTXPowerTracking ODM_TXPowerTrackingCheck -#define dm_RF_Saving ODM_RF_Saving - -void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal); -void ODM_TXPowerTrackingCheck(struct odm_dm_struct *pDM_Odm); -void ODM_Write_CCK_CCA_Thres(struct odm_dm_struct *pDM_Odm, u8 CurCCK_CCAThres); -bool ODM_RAStateCheck(struct odm_dm_struct *pDM_Odm, s32 RSSI, - bool bForceUpdate, u8 *pRATRState); -u32 ConvertTo_dB(u32 Value); -u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, - u32 ra_mask, u8 rssi_level); -void ODM_CmnInfoInit(struct odm_dm_struct *pDM_Odm, - enum odm_common_info_def CmnInfo, u32 Value); -void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value); -void ODM_CmnInfoHook(struct odm_dm_struct *pDM_Odm, - enum odm_common_info_def CmnInfo, void *pValue); -void ODM_CmnInfoPtrArrayHook(struct odm_dm_struct *pDM_Odm, - enum odm_common_info_def CmnInfo, - u16 Index, void *pValue); -void ODM_DMInit(struct odm_dm_struct *pDM_Odm); -void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm); -void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI); - -#endif diff --git a/drivers/staging/rtl8188eu/include/odm_hwconfig.h b/drivers/staging/rtl8188eu/include/odm_hwconfig.h deleted file mode 100644 index 4f4d3cfb6c77..000000000000 --- a/drivers/staging/rtl8188eu/include/odm_hwconfig.h +++ /dev/null @@ -1,101 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __HALHWOUTSRC_H__ -#define __HALHWOUTSRC_H__ - -/* Definition */ -/* CCK Rates, TxHT = 0 */ -#define DESC92C_RATE1M 0x00 -#define DESC92C_RATE2M 0x01 -#define DESC92C_RATE5_5M 0x02 -#define DESC92C_RATE11M 0x03 - -/* OFDM Rates, TxHT = 0 */ -#define DESC92C_RATE6M 0x04 -#define DESC92C_RATE9M 0x05 -#define DESC92C_RATE12M 0x06 -#define DESC92C_RATE18M 0x07 -#define DESC92C_RATE24M 0x08 -#define DESC92C_RATE36M 0x09 -#define DESC92C_RATE48M 0x0a -#define DESC92C_RATE54M 0x0b - -/* MCS Rates, TxHT = 1 */ -#define DESC92C_RATEMCS0 0x0c -#define DESC92C_RATEMCS1 0x0d -#define DESC92C_RATEMCS2 0x0e -#define DESC92C_RATEMCS3 0x0f -#define DESC92C_RATEMCS4 0x10 -#define DESC92C_RATEMCS5 0x11 -#define DESC92C_RATEMCS6 0x12 -#define DESC92C_RATEMCS7 0x13 -#define DESC92C_RATEMCS8 0x14 -#define DESC92C_RATEMCS9 0x15 -#define DESC92C_RATEMCS10 0x16 -#define DESC92C_RATEMCS11 0x17 -#define DESC92C_RATEMCS12 0x18 -#define DESC92C_RATEMCS13 0x19 -#define DESC92C_RATEMCS14 0x1a -#define DESC92C_RATEMCS15 0x1b -#define DESC92C_RATEMCS15_SG 0x1c -#define DESC92C_RATEMCS32 0x20 - -/* structure and define */ - -struct phy_rx_agc_info { - #ifdef __LITTLE_ENDIAN - u8 gain:7, trsw:1; - #else - u8 trsw:1, gain:7; - #endif -}; - -struct phy_status_rpt { - struct phy_rx_agc_info path_agc[RF_PATH_MAX]; - u8 ch_corr[2]; - u8 cck_sig_qual_ofdm_pwdb_all; - u8 cck_agc_rpt_ofdm_cfosho_a; - u8 cck_rpt_b_ofdm_cfosho_b; - u8 rsvd_1;/* ch_corr_msb; */ - u8 noise_power_db_msb; - u8 path_cfotail[2]; - u8 pcts_mask[2]; - s8 stream_rxevm[2]; - u8 path_rxsnr[3]; - u8 noise_power_db_lsb; - u8 rsvd_2[3]; - u8 stream_csi[2]; - u8 stream_target_csi[2]; - s8 sig_evm; - u8 rsvd_3; - -#ifdef __LITTLE_ENDIAN - u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ - u8 sgi_en:1; - u8 rxsc:2; - u8 idle_long:1; - u8 r_ant_train_en:1; - u8 ant_sel_b:1; - u8 ant_sel:1; -#else /* _BIG_ENDIAN_ */ - u8 ant_sel:1; - u8 ant_sel_b:1; - u8 r_ant_train_en:1; - u8 idle_long:1; - u8 rxsc:2; - u8 sgi_en:1; - u8 antsel_rx_keep_2:1; /* ex_intf_flg:1; */ -#endif -}; - -void odm_phy_status_query(struct odm_dm_struct *dm_odm, - struct odm_phy_status_info *phy_info, - u8 *phy_status, - struct odm_per_pkt_info *pkt_info); - -#endif diff --git a/drivers/staging/rtl8188eu/include/odm_precomp.h b/drivers/staging/rtl8188eu/include/odm_precomp.h deleted file mode 100644 index eb2b8b613aad..000000000000 --- a/drivers/staging/rtl8188eu/include/odm_precomp.h +++ /dev/null @@ -1,63 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __ODM_PRECOMP_H__ -#define __ODM_PRECOMP_H__ - -#include "odm_types.h" - -#define TEST_FALG___ 1 - -/* 2 Config Flags and Structs - defined by each ODM Type */ - -#include -#include -#include -#include - -/* 2 OutSrc Header Files */ - -#include "odm.h" -#include "odm_hwconfig.h" -#include "phydm_regdefine11n.h" - -#include "hal8188e_rate_adaptive.h" /* for RA,Power training */ -#include "rtl8188e_hal.h" - -#include "phydm_reg.h" - -#include "odm_rtl8188e.h" - -void odm_DIGInit(struct odm_dm_struct *pDM_Odm); -void odm_RateAdaptiveMaskInit(struct odm_dm_struct *pDM_Odm); -void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm); -void odm_DynamicTxPowerInit(struct odm_dm_struct *pDM_Odm); -void odm_TXPowerTrackingInit(struct odm_dm_struct *pDM_Odm); -void ODM_EdcaTurboInit(struct odm_dm_struct *pDM_Odm); -void odm_SwAntDivInit_NIC(struct odm_dm_struct *pDM_Odm); -void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm); -void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm); -void odm_DIG(struct odm_dm_struct *pDM_Odm); -void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm); -void odm_RefreshRateAdaptiveMaskMP(struct odm_dm_struct *pDM_Odm); -void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm); -void odm_SwAntDivChkAntSwitch(struct odm_dm_struct *pDM_Odm, u8 Step); -void odm_EdcaTurboCheck(struct odm_dm_struct *pDM_Odm); -void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm); -void odm_RSSIMonitorCheck(struct odm_dm_struct *pDM_Odm); -void odm_RefreshRateAdaptiveMask(struct odm_dm_struct *pDM_Odm); -void odm_1R_CCA(struct odm_dm_struct *pDM_Odm); -void odm_RefreshRateAdaptiveMaskCE(struct odm_dm_struct *pDM_Odm); -void odm_RefreshRateAdaptiveMaskAPADSL(struct odm_dm_struct *pDM_Odm); -void odm_DynamicTxPowerNIC(struct odm_dm_struct *pDM_Odm); -void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm); -void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm); -void odm_SwAntDivChkAntSwitchCallback(void *FunctionContext); -void odm_InitHybridAntDiv(struct odm_dm_struct *pDM_Odm); -void odm_HwAntDiv(struct odm_dm_struct *pDM_Odm); - -#endif /* __ODM_PRECOMP_H__ */ diff --git a/drivers/staging/rtl8188eu/include/odm_rtl8188e.h b/drivers/staging/rtl8188eu/include/odm_rtl8188e.h deleted file mode 100644 index dbf13c48767d..000000000000 --- a/drivers/staging/rtl8188eu/include/odm_rtl8188e.h +++ /dev/null @@ -1,39 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __ODM_RTL8188E_H__ -#define __ODM_RTL8188E_H__ - -#define MAIN_ANT 0 -#define AUX_ANT 1 -#define MAIN_ANT_CG_TRX 1 -#define AUX_ANT_CG_TRX 0 -#define MAIN_ANT_CGCS_RX 0 -#define AUX_ANT_CGCS_RX 1 - -void ODM_DIG_LowerBound_88E(struct odm_dm_struct *pDM_Odm); - -void rtl88eu_dm_antenna_div_init(struct odm_dm_struct *dm_odm); - -void rtl88eu_dm_antenna_diversity(struct odm_dm_struct *dm_odm); - -void rtl88eu_dm_set_tx_ant_by_tx_info(struct odm_dm_struct *dm_odm, u8 *desc, - u8 mac_id); - -void rtl88eu_dm_update_rx_idle_ant(struct odm_dm_struct *dm_odm, u8 ant); - -void rtl88eu_dm_ant_sel_statistics(struct odm_dm_struct *dm_odm, u8 antsel_tr_mux, - u32 mac_id, u8 rx_pwdb_all); - -void odm_FastAntTraining(struct odm_dm_struct *pDM_Odm); - -void odm_FastAntTrainingCallback(struct odm_dm_struct *pDM_Odm); - -void odm_FastAntTrainingWorkItemCallback(struct odm_dm_struct *pDM_Odm); - -bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); - -#endif diff --git a/drivers/staging/rtl8188eu/include/odm_types.h b/drivers/staging/rtl8188eu/include/odm_types.h deleted file mode 100644 index 2b207f09b56b..000000000000 --- a/drivers/staging/rtl8188eu/include/odm_types.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __ODM_TYPES_H__ -#define __ODM_TYPES_H__ - -#define ODM_CE 0x04 /* BIT2 */ - -enum HAL_STATUS { - HAL_STATUS_SUCCESS, - HAL_STATUS_FAILURE, -}; - -#define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc + 8, 24, 1, __Value) -#define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc + 8, 25, 1, __Value) -#define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc + 28, 29, 1, __Value) - -#endif /* __ODM_TYPES_H__ */ diff --git a/drivers/staging/rtl8188eu/include/osdep_intf.h b/drivers/staging/rtl8188eu/include/osdep_intf.h deleted file mode 100644 index 5012b9176526..000000000000 --- a/drivers/staging/rtl8188eu/include/osdep_intf.h +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __OSDEP_INTF_H_ -#define __OSDEP_INTF_H_ - -#include -#include - -extern char *rtw_initmac; -extern int rtw_mc2u_disable; - -u8 rtw_init_drv_sw(struct adapter *padapter); -u8 rtw_free_drv_sw(struct adapter *padapter); -u8 rtw_reset_drv_sw(struct adapter *padapter); - -void rtw_stop_drv_threads(struct adapter *padapter); -void rtw_cancel_all_timer(struct adapter *padapter); - -int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); - -struct net_device *rtw_init_netdev(void); -u16 rtw_recv_select_queue(struct sk_buff *skb); - -int netdev_open(struct net_device *pnetdev); -int ips_netdrv_open(struct adapter *padapter); -void rtw_ips_dev_unload(struct adapter *padapter); -int rtw_ips_pwr_up(struct adapter *padapter); -void rtw_ips_pwr_down(struct adapter *padapter); - -#endif /* _OSDEP_INTF_H_ */ diff --git a/drivers/staging/rtl8188eu/include/osdep_service.h b/drivers/staging/rtl8188eu/include/osdep_service.h deleted file mode 100644 index efd0833e28c8..000000000000 --- a/drivers/staging/rtl8188eu/include/osdep_service.h +++ /dev/null @@ -1,81 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __OSDEP_SERVICE_H_ -#define __OSDEP_SERVICE_H_ - -#include - -#define _FAIL 0 -#define _SUCCESS 1 -#define RTW_RX_HANDLED 2 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include /* for struct tasklet_struct */ -#include -#include - -#include -#include - -struct __queue { - struct list_head queue; - spinlock_t lock; -}; - -static inline struct list_head *get_list_head(struct __queue *queue) -{ - return &queue->queue; -} - -static inline int rtw_netif_queue_stopped(struct net_device *pnetdev) -{ - return netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 0)) && - netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 1)) && - netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 2)) && - netif_tx_queue_stopped(netdev_get_tx_queue(pnetdev, 3)); -} - -u8 *_rtw_malloc(u32 sz); -#define rtw_malloc(sz) _rtw_malloc((sz)) - -void _rtw_init_queue(struct __queue *pqueue); - -#define FUNC_NDEV_FMT "%s(%s)" -#define FUNC_NDEV_ARG(ndev) __func__, ndev->name -#define FUNC_ADPT_FMT "%s(%s)" -#define FUNC_ADPT_ARG(adapter) __func__, adapter->pnetdev->name - -/* Macros for handling unaligned memory accesses */ - -#define RTW_GET_BE24(a) ((((u32)(a)[0]) << 16) | (((u32)(a)[1]) << 8) | \ - ((u32)(a)[2])) - -void rtw_buf_free(u8 **buf, u32 *buf_len); -void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); -#endif diff --git a/drivers/staging/rtl8188eu/include/phy.h b/drivers/staging/rtl8188eu/include/phy.h deleted file mode 100644 index 8ee13eb68a5a..000000000000 --- a/drivers/staging/rtl8188eu/include/phy.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#include - -#define IQK_DELAY_TIME_88E 10 -#define index_mapping_NUM_88E 15 -#define AVG_THERMAL_NUM_88E 4 - -bool phy_mac_config(struct adapter *adapt); -bool rtl88eu_phy_rf_config(struct adapter *adapt); -bool rtl88eu_phy_bb_config(struct adapter *adapt); - -u32 phy_query_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask); -void phy_set_bb_reg(struct adapter *adapt, u32 regaddr, u32 bitmask, u32 data); -u32 rtw_hal_read_rfreg(struct adapter *adapt, enum rf_radio_path rf_path, - u32 reg_addr, u32 bit_mask); -void phy_set_rf_reg(struct adapter *adapt, enum rf_radio_path rf_path, - u32 reg_addr, u32 bit_mask, u32 data); - -void phy_set_tx_power_level(struct adapter *adapt, u8 channel); - -void rtl88eu_dm_txpower_track_adjust(struct odm_dm_struct *dm_odm, - u8 type, u8 *dir, u32 *out_write); - -void rtl88eu_dm_txpower_tracking_callback_thermalmeter(struct adapter *adapt); -void rtl88eu_phy_iq_calibrate(struct adapter *adapter, bool recovery); -void rtl88eu_phy_lc_calibrate(struct adapter *adapter); diff --git a/drivers/staging/rtl8188eu/include/phydm_reg.h b/drivers/staging/rtl8188eu/include/phydm_reg.h deleted file mode 100644 index e3ae006487ba..000000000000 --- a/drivers/staging/rtl8188eu/include/phydm_reg.h +++ /dev/null @@ -1,22 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2016 Realtek Corporation. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ -#ifndef __HAL_ODM_REG_H__ -#define __HAL_ODM_REG_H__ - -#define ODM_EDCA_VO_PARAM 0x500 -#define ODM_EDCA_VI_PARAM 0x504 -#define ODM_EDCA_BE_PARAM 0x508 -#define ODM_EDCA_BK_PARAM 0x50C - -#endif diff --git a/drivers/staging/rtl8188eu/include/phydm_regdefine11n.h b/drivers/staging/rtl8188eu/include/phydm_regdefine11n.h deleted file mode 100644 index 565996828cab..000000000000 --- a/drivers/staging/rtl8188eu/include/phydm_regdefine11n.h +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2016 Realtek Corporation. - * - * Contact Information: - * wlanfae - * Realtek Corporation, No. 2, Innovation Road II, Hsinchu Science Park, - * Hsinchu 300, Taiwan. - * - * Larry Finger - * - *****************************************************************************/ - -#ifndef __ODM_REGDEFINE11N_H__ -#define __ODM_REGDEFINE11N_H__ - -#define ODM_REG_TX_ANT_CTRL_11N 0x80C -#define ODM_REG_RX_DEFAULT_A_11N 0x858 -#define ODM_REG_ANTSEL_CTRL_11N 0x860 -#define ODM_REG_RX_ANT_CTRL_11N 0x864 -#define ODM_REG_PIN_CTRL_11N 0x870 -#define ODM_REG_SC_CNT_11N 0x8C4 - -#define ODM_REG_ANT_MAPPING1_11N 0x914 - -#define ODM_REG_CCK_ANTDIV_PARA1_11N 0xA00 -#define ODM_REG_CCK_CCA_11N 0xA0A -#define ODM_REG_CCK_ANTDIV_PARA2_11N 0xA0C -#define ODM_REG_CCK_FA_RST_11N 0xA2C -#define ODM_REG_CCK_FA_MSB_11N 0xA58 -#define ODM_REG_CCK_FA_LSB_11N 0xA5C -#define ODM_REG_CCK_CCA_CNT_11N 0xA60 -#define ODM_REG_BB_PWR_SAV4_11N 0xA74 - -#define ODM_REG_LNA_SWITCH_11N 0xB2C - -#define ODM_REG_OFDM_FA_HOLDC_11N 0xC00 -#define ODM_REG_IGI_A_11N 0xC50 -#define ODM_REG_ANTDIV_PARA1_11N 0xCA4 -#define ODM_REG_OFDM_FA_TYPE1_11N 0xCF0 - -#define ODM_REG_OFDM_FA_RSTD_11N 0xD00 -#define ODM_REG_OFDM_FA_TYPE2_11N 0xDA0 -#define ODM_REG_OFDM_FA_TYPE3_11N 0xDA4 -#define ODM_REG_OFDM_FA_TYPE4_11N 0xDA8 - -#define ODM_REG_ANTSEL_PIN_11N 0x4C -#define ODM_REG_RESP_TX_11N 0x6D8 - -#define ODM_BIT_IGI_11N 0x0000007F - -#endif diff --git a/drivers/staging/rtl8188eu/include/pwrseq.h b/drivers/staging/rtl8188eu/include/pwrseq.h deleted file mode 100644 index 5a7b4206d240..000000000000 --- a/drivers/staging/rtl8188eu/include/pwrseq.h +++ /dev/null @@ -1,130 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __HAL8188EPWRSEQ_H__ -#define __HAL8188EPWRSEQ_H__ - -#include "pwrseqcmd.h" - -/* - * Check document WM-20110607-Paul-RTL8188E_Power_Architecture-R02.vsd - * There are 6 HW Power States: - * 0: POFF--Power Off - * 1: PDN--Power Down - * 2: CARDEMU--Card Emulation - * 3: ACT--Active Mode - * 4: LPS--Low Power State - * 5: SUS--Suspend - * - * PWR SEQ Version: rtl8188E_PwrSeq_V09.h - */ -#define RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS 10 -#define RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS 10 -#define RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS 10 -#define RTL8188E_TRANS_ACT_TO_LPS_STEPS 15 -#define RTL8188E_TRANS_END_STEPS 1 - -#define RTL8188E_TRANS_CARDEMU_TO_ACT \ - /* format - * { offset, cut_msk, cmd, msk, value - * }, - * comment here - */ \ - {0x0006, PWR_CMD_POLLING, BIT(1), BIT(1)}, \ - /* wait till 0x04[17] = 1 power ready*/ \ - {0x0002, PWR_CMD_WRITE, BIT(0) | BIT(1), 0}, \ - /* 0x02[1:0] = 0 reset BB*/ \ - {0x0026, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ - /*0x24[23] = 2b'01 schmit trigger */ \ - {0x0005, PWR_CMD_WRITE, BIT(7), 0}, \ - /* 0x04[15] = 0 disable HWPDN (control by DRV)*/ \ - {0x0005, PWR_CMD_WRITE, BIT(4) | BIT(3), 0}, \ - /*0x04[12:11] = 2b'00 disable WL suspend*/ \ - {0x0005, PWR_CMD_WRITE, BIT(0), BIT(0)}, \ - /*0x04[8] = 1 polling until return 0*/ \ - {0x0005, PWR_CMD_POLLING, BIT(0), 0}, \ - /*wait till 0x04[8] = 0*/ \ - {0x0023, PWR_CMD_WRITE, BIT(4), 0}, \ - /*LDO normal mode*/ - -#define RTL8188E_TRANS_ACT_TO_CARDEMU \ - /* format - * { offset, cut_msk, cmd, msk, value - * }, - * comments here - */ \ - {0x001F, PWR_CMD_WRITE, 0xFF, 0}, \ - /*0x1F[7:0] = 0 turn off RF*/ \ - {0x0023, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ - /*LDO Sleep mode*/ \ - {0x0005, PWR_CMD_WRITE, BIT(1), BIT(1)}, \ - /*0x04[9] = 1 turn off MAC by HW state machine*/ \ - {0x0005, PWR_CMD_POLLING, BIT(1), 0}, \ - /*wait till 0x04[9] = 0 polling until return 0 to disable*/ - -#define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0026, PWR_CMD_WRITE, BIT(7), BIT(7)}, \ - /*0x24[23] = 2b'01 schmit trigger */ \ - {0x0005, PWR_CMD_WRITE, BIT(3) | BIT(4), BIT(3)}, \ - /*0x04[12:11] = 2b'01 enable WL suspend*/ \ - {0x0007, PWR_CMD_WRITE, 0xFF, 0}, \ - /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */\ - {0x0041, PWR_CMD_WRITE, BIT(4), 0}, \ - /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ - {0xfe10, PWR_CMD_WRITE, BIT(4), BIT(4)}, \ - /*Set USB suspend enable local register 0xfe10[4]=1 */ - -/* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ -#define RTL8188E_TRANS_ACT_TO_LPS \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0x0522, PWR_CMD_WRITE, 0xFF, 0x7F},/*Tx Pause*/ \ - {0x05F8, PWR_CMD_POLLING, 0xFF, 0}, \ - /*Should be zero if no packet is transmitting*/ \ - {0x05F9, PWR_CMD_POLLING, 0xFF, 0}, \ - /*Should be zero if no packet is transmitting*/ \ - {0x05FA, PWR_CMD_POLLING, 0xFF, 0}, \ - /*Should be zero if no packet is transmitting*/ \ - {0x05FB, PWR_CMD_POLLING, 0xFF, 0}, \ - /*Should be zero if no packet is transmitting*/ \ - {0x0002, PWR_CMD_WRITE, BIT(0), 0}, \ - /*CCK and OFDM are disabled,and clock are gated*/ \ - {0x0002, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US}, \ - /*Delay 1us*/ \ - {0x0100, PWR_CMD_WRITE, 0xFF, 0x3F}, \ - /*Reset MAC TRX*/ \ - {0x0101, PWR_CMD_WRITE, BIT(1), 0}, \ - /*check if removed later*/\ - {0x0553, PWR_CMD_WRITE, BIT(5), BIT(5)}, \ - /*Respond TxOK to scheduler*/ - -#define RTL8188E_TRANS_END \ - /* format - * { offset, cut_msk, cmd, msk, - * value }, - * comments here - */ \ - {0xFFFF, PWR_CMD_END, 0, 0}, - -extern struct wl_pwr_cfg rtl8188E_power_on_flow - [RTL8188E_TRANS_CARDEMU_TO_ACT_STEPS + RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_card_disable_flow - [RTL8188E_TRANS_ACT_TO_CARDEMU_STEPS + - RTL8188E_TRANS_CARDEMU_TO_PDN_STEPS + - RTL8188E_TRANS_END_STEPS]; -extern struct wl_pwr_cfg rtl8188E_enter_lps_flow - [RTL8188E_TRANS_ACT_TO_LPS_STEPS + RTL8188E_TRANS_END_STEPS]; - -#endif /* __HAL8188EPWRSEQ_H__ */ diff --git a/drivers/staging/rtl8188eu/include/pwrseqcmd.h b/drivers/staging/rtl8188eu/include/pwrseqcmd.h deleted file mode 100644 index bbf4f302c9f4..000000000000 --- a/drivers/staging/rtl8188eu/include/pwrseqcmd.h +++ /dev/null @@ -1,37 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __HALPWRSEQCMD_H__ -#define __HALPWRSEQCMD_H__ - -#include - -/* The value of cmd: 4 bits */ -#define PWR_CMD_WRITE 0x01 -#define PWR_CMD_POLLING 0x02 -#define PWR_CMD_DELAY 0x03 -#define PWR_CMD_END 0x04 - -enum pwrseq_cmd_delat_unit { - PWRSEQ_DELAY_US, - PWRSEQ_DELAY_MS, -}; - -struct wl_pwr_cfg { - u16 offset; - u8 cmd:4; - u8 msk; - u8 value; -}; - -#define GET_PWR_CFG_OFFSET(__PWR_CMD) __PWR_CMD.offset -#define GET_PWR_CFG_CMD(__PWR_CMD) __PWR_CMD.cmd -#define GET_PWR_CFG_MASK(__PWR_CMD) __PWR_CMD.msk -#define GET_PWR_CFG_VALUE(__PWR_CMD) __PWR_CMD.value - -u8 rtl88eu_pwrseqcmdparsing(struct adapter *padapter, struct wl_pwr_cfg pwrcfgCmd[]); - -#endif diff --git a/drivers/staging/rtl8188eu/include/recv_osdep.h b/drivers/staging/rtl8188eu/include/recv_osdep.h deleted file mode 100644 index 614245d4b179..000000000000 --- a/drivers/staging/rtl8188eu/include/recv_osdep.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RECV_OSDEP_H_ -#define __RECV_OSDEP_H_ - -#include -#include - -int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter); -void _rtw_free_recv_priv(struct recv_priv *precvpriv); - -s32 rtw_recv_entry(struct recv_frame *precv_frame); -int rtw_recv_indicatepkt(struct adapter *adapter, - struct recv_frame *recv_frame); - -void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup); - -int rtw_os_recvbuf_resource_alloc(struct recv_buf *precvbuf); - -void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); - -#endif /* */ diff --git a/drivers/staging/rtl8188eu/include/rf.h b/drivers/staging/rtl8188eu/include/rf.h deleted file mode 100644 index ed3241c020ad..000000000000 --- a/drivers/staging/rtl8188eu/include/rf.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#define RF6052_MAX_TX_PWR 0x3F -#define RF6052_MAX_REG 0x3F - -void rtl88eu_phy_rf6052_set_bandwidth(struct adapter *adapt, - enum ht_channel_width bandwidth); -void rtl88eu_phy_rf6052_set_cck_txpower(struct adapter *adapt, - u8 *powerlevel); -void rtl88eu_phy_rf6052_set_ofdm_txpower(struct adapter *adapt, - u8 *powerlevel_ofdm, - u8 *powerlevel_bw20, - u8 *powerlevel_bw40, u8 channel); diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h b/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h deleted file mode 100644 index e588656f1de9..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_cmd.h +++ /dev/null @@ -1,70 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTL8188E_CMD_H__ -#define __RTL8188E_CMD_H__ - -enum RTL8188E_H2C_CMD_ID { - /* Class Common */ - H2C_COM_RSVD_PAGE = 0x00, - H2C_COM_MEDIA_STATUS_RPT = 0x01, - H2C_COM_SCAN = 0x02, - H2C_COM_KEEP_ALIVE = 0x03, - H2C_COM_DISCNT_DECISION = 0x04, - H2C_COM_INIT_OFFLOAD = 0x06, - H2C_COM_REMOTE_WAKE_CTL = 0x07, - H2C_COM_AP_OFFLOAD = 0x08, - H2C_COM_BCN_RSVD_PAGE = 0x09, - H2C_COM_PROB_RSP_RSVD_PAGE = 0x0A, - - /* Class PS */ - H2C_PS_PWR_MODE = 0x20, - H2C_PS_TUNE_PARA = 0x21, - H2C_PS_TUNE_PARA_2 = 0x22, - H2C_PS_LPS_PARA = 0x23, - H2C_PS_P2P_OFFLOAD = 0x24, - - /* Class DM */ - H2C_DM_MACID_CFG = 0x40, - H2C_DM_TXBF = 0x41, - - /* Class BT */ - H2C_BT_COEX_MASK = 0x60, - H2C_BT_COEX_GPIO_MODE = 0x61, - H2C_BT_DAC_SWING_VAL = 0x62, - H2C_BT_PSD_RST = 0x63, - - /* Class */ - H2C_RESET_TSF = 0xc0, -}; - -enum { - PWRS -}; - -struct setpwrmode_parm { - u8 Mode;/* 0:Active,1:LPS,2:WMMPS */ - u8 SmartPS_RLBM;/* LPS= 0:PS_Poll,1:PS_Poll,2:NullData,WMM= 0:PS_Poll,1:NullData */ - u8 AwakeInterval; /* unit: beacon interval */ - u8 bAllQueueUAPSD; - u8 PwrState;/* AllON(0x0c),RFON(0x04),RFOFF(0x00) */ -}; - -struct rsvdpage_loc { - u8 LocProbeRsp; - u8 LocPsPoll; - u8 LocNullData; - u8 LocQosNull; - u8 LocBTQosNull; -}; - -/* host message to firmware cmd */ -void rtl8188e_set_FwPwrMode_cmd(struct adapter *padapter, u8 Mode); -void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *padapter, u8 mstatus); - -void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt); - -#endif/* __RTL8188E_CMD_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h b/drivers/staging/rtl8188eu/include/rtl8188e_dm.h deleted file mode 100644 index 910b982ab775..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_dm.h +++ /dev/null @@ -1,40 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTL8188E_DM_H__ -#define __RTL8188E_DM_H__ -enum{ - UP_LINK, - DOWN_LINK, -}; - -struct dm_priv { - u8 DM_Type; - u8 DMFlag; - u8 InitDMFlag; - u32 InitODMFlag; - - /* Upper and Lower Signal threshold for Rate Adaptive*/ - int UndecoratedSmoothedPWDB; - int UndecoratedSmoothedCCK; - int EntryMinUndecoratedSmoothedPWDB; - int EntryMaxUndecoratedSmoothedPWDB; - int MinUndecoratedPWDBForDM; - int LastMinUndecoratedPWDBForDM; - - /* for High Power */ - u8 bDynamicTxPowerEnable; - u8 LastDTPLvl; - u8 DynamicTxHighPowerLvl;/* Tx Power Control for Near/Far Range */ - u8 PowerIndex_backup[6]; -}; - -void rtl8188e_InitHalDm(struct adapter *adapt); - -void AntDivCompare8188E(struct adapter *adapt, struct wlan_bssid_ex *dst, - struct wlan_bssid_ex *src); - -#endif diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h b/drivers/staging/rtl8188eu/include/rtl8188e_hal.h deleted file mode 100644 index 3e697a3321e1..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_hal.h +++ /dev/null @@ -1,319 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTL8188E_HAL_H__ -#define __RTL8188E_HAL_H__ - -/* include HAL Related header after HAL Related compiling flags */ -#include "rtl8188e_spec.h" -#include "hal8188e_phy_reg.h" -#include "hal8188e_phy_cfg.h" -#include "rtl8188e_dm.h" -#include "rtl8188e_recv.h" -#include "rtl8188e_xmit.h" -#include "rtl8188e_cmd.h" -#include "pwrseq.h" -#include "rtw_efuse.h" -#include "rtw_sreset.h" -#include "odm_precomp.h" - -/* RTL8188E Power Configuration CMDs for USB/SDIO interfaces */ -#define Rtl8188E_NIC_PWR_ON_FLOW rtl8188E_power_on_flow -#define Rtl8188E_NIC_DISABLE_FLOW rtl8188E_card_disable_flow -#define Rtl8188E_NIC_LPS_ENTER_FLOW rtl8188E_enter_lps_flow - -#define DRVINFO_SZ 4 /* unit is 8bytes */ -#define PageNum_128(_Len) (u32)(((_Len) >> 7) + ((_Len) & 0x7F ? 1 : 0)) - -/* download firmware related data structure */ -#define FW_8188E_SIZE 0x4000 /* 16384,16k */ -#define FW_8188E_START_ADDRESS 0x1000 -#define FW_8188E_END_ADDRESS 0x1FFF /* 0x5FFF */ - -#define MAX_PAGE_SIZE 4096 /* @ page : 4k bytes */ - -#define IS_FW_HEADER_EXIST(_pFwHdr) \ - ((le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x92C0 || \ - (le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x88C0 || \ - (le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x2300 || \ - (le16_to_cpu(_pFwHdr->signature) & 0xFFF0) == 0x88E0) - -#define DRIVER_EARLY_INT_TIME 0x05 -#define BCN_DMA_ATIME_INT_TIME 0x02 - -enum usb_rx_agg_mode { - USB_RX_AGG_DISABLE, - USB_RX_AGG_DMA, - USB_RX_AGG_USB, - USB_RX_AGG_MIX -}; - -#define MAX_RX_DMA_BUFFER_SIZE_88E \ - 0x2400 /* 9k for 88E nornal chip , MaxRxBuff=10k-max(TxReportSize(64*8), - * WOLPattern(16*24)) - */ - -#define MAX_TX_REPORT_BUFFER_SIZE 0x0400 /* 1k */ - -/* BK, BE, VI, VO, HCCA, MANAGEMENT, COMMAND, HIGH, BEACON. */ -#define MAX_TX_QUEUE 9 - -#define TX_SELE_HQ BIT(0) /* High Queue */ -#define TX_SELE_LQ BIT(1) /* Low Queue */ -#define TX_SELE_NQ BIT(2) /* Normal Queue */ - -/* Note: We will divide number of page equally for each queue other - * than public queue! - */ -/* 22k = 22528 bytes = 176 pages (@page = 128 bytes) */ -/* must reserved about 7 pages for LPS => 176-7 = 169 (0xA9) */ -/* 2*BCN / 1*ps-poll / 1*null-data /1*prob_rsp /1*QOS null-data /1*BT QOS - * null-data - */ - -#define TX_TOTAL_PAGE_NUMBER_88E 0xA9/* 169 (21632=> 21k) */ - -#define TX_PAGE_BOUNDARY_88E (TX_TOTAL_PAGE_NUMBER_88E + 1) - -/* Note: For Normal Chip Setting ,modify later */ -#define WMM_NORMAL_TX_TOTAL_PAGE_NUMBER \ - TX_TOTAL_PAGE_NUMBER_88E /* 0xA9 , 0xb0=>176=>22k */ -#define WMM_NORMAL_TX_PAGE_BOUNDARY_88E \ - (WMM_NORMAL_TX_TOTAL_PAGE_NUMBER + 1) /* 0xA9 */ - -/* Chip specific */ -#define CHIP_BONDING_IDENTIFIER(_value) (((_value) >> 22) & 0x3) -#define CHIP_BONDING_92C_1T2R 0x1 -#define CHIP_BONDING_88C_USB_MCARD 0x2 -#define CHIP_BONDING_88C_USB_HP 0x1 -#include "HalVerDef.h" -#include "hal_com.h" - -/* Channel Plan */ -enum ChannelPlan { - CHPL_FCC = 0, - CHPL_IC = 1, - CHPL_ETSI = 2, - CHPL_SPA = 3, - CHPL_FRANCE = 4, - CHPL_MKK = 5, - CHPL_MKK1 = 6, - CHPL_ISRAEL = 7, - CHPL_TELEC = 8, - CHPL_GLOBAL = 9, - CHPL_WORLD = 10, -}; - -struct txpowerinfo24g { - u8 IndexCCK_Base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; - u8 IndexBW40_Base[MAX_RF_PATH][MAX_CHNL_GROUP_24G]; - /* If only one tx, only BW20 and OFDM are used. */ - s8 CCK_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - s8 OFDM_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - s8 BW20_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - s8 BW40_Diff[MAX_RF_PATH][MAX_TX_COUNT]; -}; - -#define EFUSE_REAL_CONTENT_LEN 512 -#define EFUSE_MAX_SECTION 16 -#define EFUSE_IC_ID_OFFSET 506 /* For some inferior IC purpose*/ -#define AVAILABLE_EFUSE_ADDR(addr) (addr < EFUSE_REAL_CONTENT_LEN) -/* To prevent out of boundary programming case, */ -/* leave 1byte and program full section */ -/* 9bytes + 1byt + 5bytes and pre 1byte. */ -/* For worst case: */ -/* | 1byte|----8bytes----|1byte|--5bytes--| */ -/* | | Reserved(14bytes) | */ - -/* PG data exclude header, dummy 6 bytes from CP test and reserved 1byte. */ -#define EFUSE_OOB_PROTECT_BYTES 15 - -#define HWSET_MAX_SIZE_88E 512 - -#define EFUSE_REAL_CONTENT_LEN_88E 256 -#define EFUSE_MAP_LEN_88E 512 -#define EFUSE_MAP_LEN EFUSE_MAP_LEN_88E -#define EFUSE_MAX_SECTION_88E 64 -#define EFUSE_MAX_WORD_UNIT_88E 4 -#define EFUSE_IC_ID_OFFSET_88E 506 -#define AVAILABLE_EFUSE_ADDR_88E(addr) \ - (addr < EFUSE_REAL_CONTENT_LEN_88E) -/* To prevent out of boundary programming case, leave 1byte and program - * full section - */ -/* 9bytes + 1byt + 5bytes and pre 1byte. */ -/* For worst case: */ -/* | 2byte|----8bytes----|1byte|--7bytes--| 92D */ -/* PG data exclude header, dummy 7 bytes from CP test and reserved 1byte. */ -#define EFUSE_OOB_PROTECT_BYTES_88E 18 -#define EFUSE_PROTECT_BYTES_BANK_88E 16 - -/* EFUSE for BT definition */ -#define EFUSE_BT_REAL_CONTENT_LEN 1536 /* 512*3 */ -#define EFUSE_BT_MAP_LEN 1024 /* 1k bytes */ -#define EFUSE_BT_MAX_SECTION 128 /* 1024/8 */ - -#define EFUSE_PROTECT_BYTES_BANK 16 - -struct hal_data_8188e { - struct HAL_VERSION VersionID; - u16 CustomerID; - u16 FirmwareVersion; - u16 FirmwareVersionRev; - u16 FirmwareSubVersion; - u16 FirmwareSignature; - u8 PGMaxGroup; - /* current WIFI_PHY values */ - u32 ReceiveConfig; - enum wireless_mode CurrentWirelessMode; - enum ht_channel_width CurrentChannelBW; - u8 CurrentChannel; - u8 nCur40MhzPrimeSC;/* Control channel sub-carrier */ - - u16 BasicRateSet; - - u8 BoardType; - - /* EEPROM setting. */ - u16 EEPROMVID; - u16 EEPROMPID; - u16 EEPROMSVID; - u16 EEPROMSDID; - u8 EEPROMCustomerID; - u8 EEPROMSubCustomerID; - u8 EEPROMVersion; - u8 EEPROMRegulatory; - - u8 bTXPowerDataReadFromEEPORM; - u8 EEPROMThermalMeter; - - u8 Index24G_CCK_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; - u8 Index24G_BW40_Base[MAX_RF_PATH][CHANNEL_MAX_NUMBER]; - /* If only one tx, only BW20 and OFDM are used. */ - s8 CCK_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - s8 OFDM_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - s8 BW20_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - s8 BW40_24G_Diff[MAX_RF_PATH][MAX_TX_COUNT]; - - u8 TxPwrLevelCck[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - /* For HT 40MHZ pwr */ - u8 TxPwrLevelHT40_1S[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - /* For HT 40MHZ pwr */ - u8 TxPwrLevelHT40_2S[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - /* HT 20<->40 Pwr diff */ - u8 TxPwrHt20Diff[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - /* For HT<->legacy pwr diff */ - u8 TxPwrLegacyHtDiff[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - /* For power group */ - u8 PwrGroupHT20[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - u8 PwrGroupHT40[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; - - /* Read/write are allow for following hardware information variables */ - u8 framesync; - u8 pwrGroupCnt; - u32 MCSTxPowerLevelOriginalOffset[MAX_PG_GROUP][16]; - - u8 CrystalCap; - - u32 AcParam_BE; /* Original parameter for BE, use for EDCA turbo. */ - - struct bb_reg_def PHYRegDef[4]; /* Radio A/B/C/D */ - - u32 RfRegChnlVal[2]; - - /* RDG enable */ - bool bRDGEnable; - - /* for host message to fw */ - u8 LastHMEBoxNum; - - u8 RegFwHwTxQCtrl; - u8 RegReg542; - u8 RegCR_1; - - struct dm_priv dmpriv; - struct odm_dm_struct odmpriv; - struct sreset_priv srestpriv; - - u8 CurAntenna; - u8 AntDivCfg; - u8 TRxAntDivType; - - u8 bDumpRxPkt;/* for debug */ - u8 bDumpTxPkt;/* for debug */ - - /* Add for dual MAC 0--Mac0 1--Mac1 */ - u32 interfaceIndex; - - u8 OutEpQueueSel; - u8 OutEpNumber; - - u16 EfuseUsedBytes; - - /* Auto FSM to Turn On, include clock, isolation, power control - * for MAC only - */ - u8 bMacPwrCtrlOn; - - u32 UsbBulkOutSize; - - /* Interrupt relatd register information. */ - u32 IntArray[3];/* HISR0,HISR1,HSISR */ - u8 C2hArray[16]; - u8 UsbTxAggMode; - u8 UsbTxAggDescNum; - - enum usb_rx_agg_mode UsbRxAggMode; - u8 UsbRxAggBlockCount; /* USB Block count. Block size is - * 512-byte in high speed and 64-byte - * in full speed - */ - u8 UsbRxAggBlockTimeout; - u8 UsbRxAggPageCount; /* 8192C DMA page count */ - u8 UsbRxAggPageTimeout; -}; - -void Hal_GetChnlGroup88E(u8 chnl, u8 *group); - -/* rtl8188e_hal_init.c */ -void _8051Reset88E(struct adapter *padapter); -void rtl8188e_InitializeFirmwareVars(struct adapter *padapter); - -s32 InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy); - -/* EFuse */ -void Hal_EfuseParseIDCode88E(struct adapter *padapter, u8 *hwinfo); -void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *hwinfo, - bool AutoLoadFail); - -void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, - bool AutoLoadFail); -void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, - bool AutoLoadFail); -void Hal_EfuseParseCustomerID88E(struct adapter *padapter, u8 *hwinfo, - bool AutoLoadFail); -void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, - bool AutoLoadFail); -void Hal_ReadThermalMeter_88E(struct adapter *dapter, u8 *PROMContent, - bool AutoloadFail); -void Hal_EfuseParseXtal_8188E(struct adapter *pAdapter, u8 *hwinfo, - bool AutoLoadFail); -void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, - bool AutoLoadFail); -void Hal_ReadPowerSavingMode88E(struct adapter *pAdapter, u8 *hwinfo, - bool AutoLoadFail); - -/* register */ - -void rtl8188e_start_thread(struct adapter *padapter); -void rtl8188e_stop_thread(struct adapter *padapter); - -s32 iol_execute(struct adapter *padapter, u8 control); -void iol_mode_enable(struct adapter *padapter, u8 enable); -s32 rtl8188e_iol_efuse_patch(struct adapter *padapter); -void rtw_cancel_all_timer(struct adapter *padapter); - -#endif /* __RTL8188E_HAL_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h b/drivers/staging/rtl8188eu/include/rtl8188e_recv.h deleted file mode 100644 index fea1119c426e..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_recv.h +++ /dev/null @@ -1,53 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTL8188E_RECV_H__ -#define __RTL8188E_RECV_H__ - -#define TX_RPT1_PKT_LEN 8 - -#define RECV_BLK_SZ 512 -#define RECV_BLK_CNT 16 -#define RECV_BLK_TH RECV_BLK_CNT -#define RECV_BULK_IN_ADDR 0x80 -#define RECV_INT_IN_ADDR 0x81 - -#define NR_PREALLOC_RECV_SKB (8) - -#define NR_RECVBUFF (4) - -#define MAX_RECVBUF_SZ (15360) /* 15k < 16k */ - -struct phy_stat { - unsigned int phydw0; - unsigned int phydw1; - unsigned int phydw2; - unsigned int phydw3; - unsigned int phydw4; - unsigned int phydw5; - unsigned int phydw6; - unsigned int phydw7; -}; - -/* Rx smooth factor */ -#define Rx_Smooth_Factor (20) - -enum rx_packet_type { - NORMAL_RX,/* Normal rx packet */ - TX_REPORT1,/* CCX */ - TX_REPORT2,/* TX RPT */ - HIS_REPORT,/* USB HISR RPT */ -}; - -#define INTERRUPT_MSG_FORMAT_LEN 60 -void rtl8188eu_recv_tasklet(struct tasklet_struct *t); -void rtl8188e_process_phy_info(struct adapter *padapter, - struct recv_frame *prframe); -void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); -void update_recvframe_attrib_88e(struct recv_frame *fra, - struct recv_stat *stat); - -#endif diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h b/drivers/staging/rtl8188eu/include/rtl8188e_spec.h deleted file mode 100644 index c7be0a1d70b9..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_spec.h +++ /dev/null @@ -1,1116 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - *******************************************************************************/ -#ifndef __RTL8188E_SPEC_H__ -#define __RTL8188E_SPEC_H__ - -/* 8188E PKT_BUFF_ACCESS_CTRL value */ -#define TXPKT_BUF_SELECT 0x69 -#define DISABLE_TRXPKT_BUF_ACCESS 0x0 - -/* 0x0000h ~ 0x00FFh System Configuration */ -#define REG_SYS_ISO_CTRL 0x0000 -#define REG_SYS_FUNC_EN 0x0002 -#define REG_APS_FSMCO 0x0004 -#define REG_SYS_CLKR 0x0008 -#define REG_9346CR 0x000A -#define REG_EE_VPD 0x000C -#define REG_AFE_MISC 0x0010 -#define REG_SPS0_CTRL 0x0011 -#define REG_SPS_OCP_CFG 0x0018 -#define REG_RSV_CTRL 0x001C -#define REG_RF_CTRL 0x001F -#define REG_LDOA15_CTRL 0x0020 -#define REG_LDOV12D_CTRL 0x0021 -#define REG_LDOHCI12_CTRL 0x0022 -#define REG_LPLDO_CTRL 0x0023 -#define REG_AFE_XTAL_CTRL 0x0024 -#define REG_AFE_PLL_CTRL 0x0028 -#define REG_APE_PLL_CTRL_EXT 0x002c -#define REG_EFUSE_CTRL 0x0030 -#define REG_EFUSE_TEST 0x0034 -#define REG_GPIO_MUXCFG 0x0040 -#define REG_GPIO_IO_SEL 0x0042 -#define REG_MAC_PINMUX_CFG 0x0043 -#define REG_GPIO_PIN_CTRL 0x0044 -#define REG_GPIO_INTM 0x0048 -#define REG_LEDCFG0 0x004C -#define REG_LEDCFG1 0x004D -#define REG_LEDCFG2 0x004E -#define REG_LEDCFG3 0x004F -#define REG_FSIMR 0x0050 -#define REG_FSISR 0x0054 -#define REG_HSIMR 0x0058 -#define REG_HSISR 0x005c -#define REG_BB_PAD_CTRL 0x0064 -#define REG_MCUFWDL 0x0080 -#define REG_WOL_EVENT 0x0081 /* RTL8188E */ -#define REG_MCUTSTCFG 0x0084 -#define REG_HMEBOX_E0 0x0088 -#define REG_HMEBOX_E1 0x008A -#define REG_HMEBOX_E2 0x008C -#define REG_HMEBOX_E3 0x008E -#define REG_HMEBOX_EXT_0 0x01F0 -#define REG_HMEBOX_EXT_1 0x01F4 -#define REG_HMEBOX_EXT_2 0x01F8 -#define REG_HMEBOX_EXT_3 0x01FC -#define REG_HIMR_88E 0x00B0 -#define REG_HISR_88E 0x00B4 -#define REG_HIMRE_88E 0x00B8 -#define REG_HISRE_88E 0x00BC -#define REG_EFUSE_ACCESS 0x00CF /* Efuse access protection - * for RTL8723 - */ -#define REG_BIST_SCAN 0x00D0 -#define REG_BIST_RPT 0x00D4 -#define REG_BIST_ROM_RPT 0x00D8 -#define REG_USB_SIE_INTF 0x00E0 -#define REG_PCIE_MIO_INTF 0x00E4 -#define REG_PCIE_MIO_INTD 0x00E8 -#define REG_HPON_FSM 0x00EC -#define REG_SYS_CFG 0x00F0 -#define REG_GPIO_OUTSTS 0x00F4 /* For RTL8723 only. */ -#define REG_TYPE_ID 0x00FC - -#define REG_MAC_PHY_CTRL_NORMAL 0x00f8 - -/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ -#define REG_CR 0x0100 -#define REG_PBP 0x0104 -#define REG_PKT_BUFF_ACCESS_CTRL 0x0106 -#define REG_TRXDMA_CTRL 0x010C -#define REG_TRXFF_BNDY 0x0114 -#define REG_TRXFF_STATUS 0x0118 -#define REG_RXFF_PTR 0x011C -/* define REG_HIMR 0x0120 */ -/* define REG_HISR 0x0124 */ -#define REG_HIMRE 0x0128 -#define REG_HISRE 0x012C -#define REG_CPWM 0x012F -#define REG_FWIMR 0x0130 -#define REG_FTIMR 0x0138 -#define REG_FWISR 0x0134 -#define REG_PKTBUF_DBG_CTRL 0x0140 -#define REG_PKTBUF_DBG_ADDR (REG_PKTBUF_DBG_CTRL) -#define REG_RXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL + 2) -#define REG_TXPKTBUF_DBG (REG_PKTBUF_DBG_CTRL + 3) -#define REG_RXPKTBUF_CTRL (REG_PKTBUF_DBG_CTRL + 2) -#define REG_PKTBUF_DBG_DATA_L 0x0144 -#define REG_PKTBUF_DBG_DATA_H 0x0148 - -#define REG_TC0_CTRL 0x0150 -#define REG_TC1_CTRL 0x0154 -#define REG_TC2_CTRL 0x0158 -#define REG_TC3_CTRL 0x015C -#define REG_TC4_CTRL 0x0160 -#define REG_TCUNIT_BASE 0x0164 -#define REG_MBIST_START 0x0174 -#define REG_MBIST_DONE 0x0178 -#define REG_MBIST_FAIL 0x017C -#define REG_32K_CTRL 0x0194 /* RTL8188E */ -#define REG_C2HEVT_MSG_NORMAL 0x01A0 -#define REG_C2HEVT_CLEAR 0x01AF -#define REG_MCUTST_1 0x01c0 -#define REG_FMETHR 0x01C8 -#define REG_HMETFR 0x01CC -#define REG_HMEBOX_0 0x01D0 -#define REG_HMEBOX_1 0x01D4 -#define REG_HMEBOX_2 0x01D8 -#define REG_HMEBOX_3 0x01DC - -#define REG_LLT_INIT 0x01E0 - -/* 0x0200h ~ 0x027Fh TXDMA Configuration */ -#define REG_RQPN 0x0200 -#define REG_FIFOPAGE 0x0204 -#define REG_TDECTRL 0x0208 -#define REG_TXDMA_OFFSET_CHK 0x020C -#define REG_TXDMA_STATUS 0x0210 -#define REG_RQPN_NPQ 0x0214 - -/* 0x0280h ~ 0x02FFh RXDMA Configuration */ -#define REG_RXDMA_AGG_PG_TH 0x0280 -#define REG_RXPKT_NUM 0x0284 -#define REG_RXDMA_STATUS 0x0288 - -/* 0x0300h ~ 0x03FFh PCIe */ -#define REG_PCIE_CTRL_REG 0x0300 -#define REG_INT_MIG 0x0304 /* Interrupt Migration */ -#define REG_BCNQ_DESA 0x0308 /* TX Beacon Descr Address */ -#define REG_HQ_DESA 0x0310 /* TX High Queue Descr Addr */ -#define REG_MGQ_DESA 0x0318 /* TX Manage Queue Descr Addr*/ -#define REG_VOQ_DESA 0x0320 /* TX VO Queue Descr Addr */ -#define REG_VIQ_DESA 0x0328 /* TX VI Queue Descr Addr */ -#define REG_BEQ_DESA 0x0330 /* TX BE Queue Descr Addr */ -#define REG_BKQ_DESA 0x0338 /* TX BK Queue Descr Addr */ -#define REG_RX_DESA 0x0340 /* RX Queue Descr Addr */ -#define REG_MDIO 0x0354 /* MDIO for Access PCIE PHY */ -#define REG_DBG_SEL 0x0360 /* Debug Selection Register */ -#define REG_PCIE_HRPWM 0x0361 /* PCIe RPWM */ -#define REG_PCIE_HCPWM 0x0363 /* PCIe CPWM */ -#define REG_WATCH_DOG 0x0368 - -/* spec version 11 */ -/* 0x0400h ~ 0x047Fh Protocol Configuration */ -#define REG_VOQ_INFORMATION 0x0400 -#define REG_VIQ_INFORMATION 0x0404 -#define REG_BEQ_INFORMATION 0x0408 -#define REG_BKQ_INFORMATION 0x040C -#define REG_MGQ_INFORMATION 0x0410 -#define REG_HGQ_INFORMATION 0x0414 -#define REG_BCNQ_INFORMATION 0x0418 -#define REG_TXPKT_EMPTY 0x041A - -#define REG_CPU_MGQ_INFORMATION 0x041C -#define REG_FWHW_TXQ_CTRL 0x0420 -#define REG_HWSEQ_CTRL 0x0423 -#define REG_TXPKTBUF_BCNQ_BDNY 0x0424 -#define REG_TXPKTBUF_MGQ_BDNY 0x0425 -#define REG_LIFETIME_EN 0x0426 -#define REG_MULTI_BCNQ_OFFSET 0x0427 -#define REG_SPEC_SIFS 0x0428 -#define REG_RL 0x042A -#define REG_DARFRC 0x0430 -#define REG_RARFRC 0x0438 -#define REG_RRSR 0x0440 -#define REG_ARFR0 0x0444 -#define REG_ARFR1 0x0448 -#define REG_ARFR2 0x044C -#define REG_ARFR3 0x0450 -#define REG_AGGLEN_LMT 0x0458 -#define REG_AMPDU_MIN_SPACE 0x045C -#define REG_TXPKTBUF_WMAC_LBK_BF_HD 0x045D -#define REG_FAST_EDCA_CTRL 0x0460 -#define REG_RD_RESP_PKT_TH 0x0463 -#define REG_INIRTS_RATE_SEL 0x0480 -/* define REG_INIDATA_RATE_SEL 0x0484 */ -#define REG_POWER_STATUS 0x04A4 -#define REG_POWER_STAGE1 0x04B4 -#define REG_POWER_STAGE2 0x04B8 -#define REG_PKT_VO_VI_LIFE_TIME 0x04C0 -#define REG_PKT_BE_BK_LIFE_TIME 0x04C2 -#define REG_STBC_SETTING 0x04C4 -#define REG_PROT_MODE_CTRL 0x04C8 -#define REG_MAX_AGGR_NUM 0x04CA -#define REG_RTS_MAX_AGGR_NUM 0x04CB -#define REG_BAR_MODE_CTRL 0x04CC -#define REG_RA_TRY_RATE_AGG_LMT 0x04CF -#define REG_EARLY_MODE_CONTROL 0x4D0 -#define REG_NQOS_SEQ 0x04DC -#define REG_QOS_SEQ 0x04DE -#define REG_NEED_CPU_HANDLE 0x04E0 -#define REG_PKT_LOSE_RPT 0x04E1 -#define REG_PTCL_ERR_STATUS 0x04E2 -#define REG_TX_RPT_CTRL 0x04EC -#define REG_TX_RPT_TIME 0x04F0 /* 2 byte */ -#define REG_DUMMY 0x04FC - -/* 0x0500h ~ 0x05FFh EDCA Configuration */ -#define REG_EDCA_VO_PARAM 0x0500 -#define REG_EDCA_VI_PARAM 0x0504 -#define REG_EDCA_BE_PARAM 0x0508 -#define REG_EDCA_BK_PARAM 0x050C -#define REG_BCNTCFG 0x0510 -#define REG_PIFS 0x0512 -#define REG_RDG_PIFS 0x0513 -#define REG_SIFS_CTX 0x0514 -#define REG_SIFS_TRX 0x0516 -#define REG_TSFTR_SYN_OFFSET 0x0518 -#define REG_AGGR_BREAK_TIME 0x051A -#define REG_SLOT 0x051B -#define REG_TX_PTCL_CTRL 0x0520 -#define REG_TXPAUSE 0x0522 -#define REG_DIS_TXREQ_CLR 0x0523 -#define REG_RD_CTRL 0x0524 -/* Format for offset 540h-542h: - * [3:0]: TBTT prohibit setup in unit of 32us. The time for HW getting - * beacon content before TBTT. - * - * [7:4]: Reserved. - * [19:8]: TBTT prohibit hold in unit of 32us. The time for HW holding - * to send the beacon packet. - * - * [23:20]: Reserved - * Description: - * | - * |<--Setup--|--Hold------------>| - * --------------|---------------------- - * | - * TBTT - * Note: We cannot update beacon content to HW or send any AC packets during - * the time between Setup and Hold. - */ -#define REG_TBTT_PROHIBIT 0x0540 -#define REG_RD_NAV_NXT 0x0544 -#define REG_NAV_PROT_LEN 0x0546 -#define REG_BCN_CTRL 0x0550 -#define REG_BCN_CTRL_1 0x0551 -#define REG_MBID_NUM 0x0552 -#define REG_DUAL_TSF_RST 0x0553 -#define REG_BCN_INTERVAL 0x0554 -#define REG_DRVERLYINT 0x0558 -#define REG_BCNDMATIM 0x0559 -#define REG_ATIMWND 0x055A -#define REG_BCN_MAX_ERR 0x055D -#define REG_RXTSF_OFFSET_CCK 0x055E -#define REG_RXTSF_OFFSET_OFDM 0x055F -#define REG_TSFTR 0x0560 -#define REG_TSFTR1 0x0568 -#define REG_ATIMWND_1 0x0570 -#define REG_PSTIMER 0x0580 -#define REG_TIMER0 0x0584 -#define REG_TIMER1 0x0588 -#define REG_ACMHWCTRL 0x05C0 - -/* define REG_FW_TSF_SYNC_CNT 0x04A0 */ -#define REG_FW_RESET_TSF_CNT_1 0x05FC -#define REG_FW_RESET_TSF_CNT_0 0x05FD -#define REG_FW_BCN_DIS_CNT 0x05FE - -/* 0x0600h ~ 0x07FFh WMAC Configuration */ -#define REG_APSD_CTRL 0x0600 -#define REG_BWOPMODE 0x0603 -#define REG_TCR 0x0604 -#define REG_RCR 0x0608 -#define REG_RX_PKT_LIMIT 0x060C -#define REG_RX_DLK_TIME 0x060D -#define REG_RX_DRVINFO_SZ 0x060F - -#define REG_MACID 0x0610 -#define REG_BSSID 0x0618 -#define REG_MAR 0x0620 -#define REG_MBIDCAMCFG 0x0628 - -#define REG_USTIME_EDCA 0x0638 -#define REG_MAC_SPEC_SIFS 0x063A - -/* 20100719 Joseph: Hardware register definition change. (HW datasheet v54) */ -/* [15:8]SIFS_R2T_OFDM, [7:0]SIFS_R2T_CCK */ -#define REG_R2T_SIFS 0x063C -/* [15:8]SIFS_T2T_OFDM, [7:0]SIFS_T2T_CCK */ -#define REG_T2T_SIFS 0x063E -#define REG_ACKTO 0x0640 -#define REG_CTS2TO 0x0641 -#define REG_EIFS 0x0642 - -/* RXERR_RPT */ -#define RXERR_TYPE_OFDM_PPDU 0 -#define RXERR_TYPE_OFDM_false_ALARM 1 -#define RXERR_TYPE_OFDM_MPDU_OK 2 -#define RXERR_TYPE_OFDM_MPDU_FAIL 3 -#define RXERR_TYPE_CCK_PPDU 4 -#define RXERR_TYPE_CCK_false_ALARM 5 -#define RXERR_TYPE_CCK_MPDU_OK 6 -#define RXERR_TYPE_CCK_MPDU_FAIL 7 -#define RXERR_TYPE_HT_PPDU 8 -#define RXERR_TYPE_HT_false_ALARM 9 -#define RXERR_TYPE_HT_MPDU_TOTAL 10 -#define RXERR_TYPE_HT_MPDU_OK 11 -#define RXERR_TYPE_HT_MPDU_FAIL 12 -#define RXERR_TYPE_RX_FULL_DROP 15 - -#define RXERR_COUNTER_MASK 0xFFFFF -#define RXERR_RPT_RST BIT(27) -#define _RXERR_RPT_SEL(type) ((type) << 28) - -/* Note: - * The NAV upper value is very important to WiFi 11n 5.2.3 NAV test. - * The default value is always too small, but the WiFi TestPlan test - * by 25,000 microseconds of NAV through sending CTS in the air. - * We must update this value greater than 25,000 microseconds to pass - * the item. The offset of NAV_UPPER in 8192C Spec is incorrect, and - * the offset should be 0x0652. - */ -#define REG_NAV_UPPER 0x0652 /* unit of 128 */ - -/* WMA, BA, CCX */ -/* define REG_NAV_CTRL 0x0650 */ -#define REG_BACAMCMD 0x0654 -#define REG_BACAMCONTENT 0x0658 -#define REG_LBDLY 0x0660 -#define REG_FWDLY 0x0661 -#define REG_RXERR_RPT 0x0664 -#define REG_WMAC_TRXPTCL_CTL 0x0668 - -/* Security */ -#define REG_CAMCMD 0x0670 -#define REG_CAMWRITE 0x0674 -#define REG_CAMREAD 0x0678 -#define REG_CAMDBG 0x067C -#define REG_SECCFG 0x0680 - -/* Power */ -#define REG_WOW_CTRL 0x0690 -#define REG_PS_RX_INFO 0x0692 -#define REG_UAPSD_TID 0x0693 -#define REG_WKFMCAM_CMD 0x0698 -#define REG_WKFMCAM_NUM_88E 0x698 -#define REG_RXFLTMAP0 0x06A0 -#define REG_RXFLTMAP1 0x06A2 -#define REG_RXFLTMAP2 0x06A4 -#define REG_BCN_PSR_RPT 0x06A8 -#define REG_BT_COEX_TABLE 0x06C0 - -/* Hardware Port 2 */ -#define REG_MACID1 0x0700 -#define REG_BSSID1 0x0708 - -/* 0xFE00h ~ 0xFE55h USB Configuration */ -#define REG_USB_INFO 0xFE17 -#define REG_USB_SPECIAL_OPTION 0xFE55 -#define REG_USB_DMA_AGG_TO 0xFE5B -#define REG_USB_AGG_TO 0xFE5C -#define REG_USB_AGG_TH 0xFE5D - -/* For normal chip */ -#define REG_NORMAL_SIE_VID 0xFE60 /* 0xFE60~0xFE61 */ -#define REG_NORMAL_SIE_PID 0xFE62 /* 0xFE62~0xFE63 */ -#define REG_NORMAL_SIE_OPTIONAL 0xFE64 -#define REG_NORMAL_SIE_EP 0xFE65 /* 0xFE65~0xFE67 */ -#define REG_NORMAL_SIE_PHY 0xFE68 /* 0xFE68~0xFE6B */ -#define REG_NORMAL_SIE_OPTIONAL2 0xFE6C -#define REG_NORMAL_SIE_GPS_EP 0xFE6D /* 0xFE6D, for RTL8723 only. */ -#define REG_NORMAL_SIE_MAC_ADDR 0xFE70 /* 0xFE70~0xFE75 */ -#define REG_NORMAL_SIE_STRING 0xFE80 /* 0xFE80~0xFEDF */ - -/* TODO: use these definition when using REG_xxx naming rule. */ -/* NOTE: DO NOT Remove these definition. Use later. */ - -#define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ -#define EFUSE_TEST REG_EFUSE_TEST /* E-Fuse Test. */ -#define MSR (REG_CR + 2) /* Media Status reg */ -#define ISR REG_HISR_88E -/* Timing Sync Function Timer Register. */ -#define TSFR REG_TSFTR - -#define PBP REG_PBP - -/* Redifine MACID register, to compatible prior ICs. */ -/* MAC ID Register, Offset 0x0050-0x0053 */ -#define IDR0 REG_MACID -/* MAC ID Register, Offset 0x0054-0x0055 */ -#define IDR4 (REG_MACID + 4) - -/* 9. Security Control Registers (Offset: ) */ -/* IN 8190 Data Sheet is called CAMcmd */ -#define RWCAM REG_CAMCMD -/* Software write CAM input content */ -#define WCAMI REG_CAMWRITE -/* Software read/write CAM config */ -#define RCAMO REG_CAMREAD -#define CAMDBG REG_CAMDBG -/* Security Configuration Register */ -#define SECR REG_SECCFG - -/* Unused register */ -#define UnusedRegister 0x1BF -#define DCAM UnusedRegister -#define PSR UnusedRegister -#define BBAddr UnusedRegister -#define PhyDataR UnusedRegister - -/* Min Spacing related settings. */ -#define MAX_MSS_DENSITY_2T 0x13 -#define MAX_MSS_DENSITY_1T 0x0A - -/* EEPROM enable when set 1 */ -#define CmdEEPROM_En BIT(5) -/* System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346 */ -#define CmdEERPOMSEL BIT(4) -#define Cmd9346CR_9356SEL BIT(4) - -/* 8192C GPIO MUX Configuration Register (offset 0x40, 4 byte) */ -#define GPIOSEL_GPIO 0 -#define GPIOSEL_ENBT BIT(5) - -/* 8192C GPIO PIN Control Register (offset 0x44, 4 byte) */ -/* GPIO pins input value */ -#define GPIO_IN REG_GPIO_PIN_CTRL -/* GPIO pins output value */ -#define GPIO_OUT (REG_GPIO_PIN_CTRL + 1) -/* GPIO pins output enable when a bit is set to "1"; otherwise, - * input is configured. - */ -#define GPIO_IO_SEL (REG_GPIO_PIN_CTRL + 2) -#define GPIO_MOD (REG_GPIO_PIN_CTRL + 3) - -/* 88EU (MSR) Media Status Register (Offset 0x4C, 8 bits) */ -#define USB_INTR_CONTENT_C2H_OFFSET 0 -#define USB_INTR_CONTENT_CPWM1_OFFSET 16 -#define USB_INTR_CONTENT_CPWM2_OFFSET 20 -#define USB_INTR_CONTENT_HISR_OFFSET 48 -#define USB_INTR_CONTENT_HISRE_OFFSET 52 - -/* 88E Driver Initialization Offload REG_FDHM0(Offset 0x88, 8 bits) */ -/* IOL config for REG_FDHM0(Reg0x88) */ -#define CMD_INIT_LLT BIT(0) -#define CMD_READ_EFUSE_MAP BIT(1) -#define CMD_EFUSE_PATCH BIT(2) -#define CMD_IOCONFIG BIT(3) -#define CMD_INIT_LLT_ERR BIT(4) -#define CMD_READ_EFUSE_MAP_ERR BIT(5) -#define CMD_EFUSE_PATCH_ERR BIT(6) -#define CMD_IOCONFIG_ERR BIT(7) - -/* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ -#define BW_OPMODE_20MHZ BIT(2) -#define BW_OPMODE_5G BIT(1) - -/* 8192C CAM Config Setting (offset 0x250, 1 byte) */ -#define CAM_VALID BIT(15) -#define CAM_NOTVALID 0x0000 -#define CAM_USEDK BIT(5) - -#define CAM_CONTENT_COUNT 8 - -#define CAM_NONE 0x0 -#define CAM_WEP40 0x01 -#define CAM_TKIP 0x02 -#define CAM_AES 0x04 -#define CAM_WEP104 0x05 -#define CAM_SMS4 0x6 - -#define TOTAL_CAM_ENTRY 32 -#define HALF_CAM_ENTRY 16 - -#define CAM_CONFIG_USEDK true -#define CAM_CONFIG_NO_USEDK false - -#define CAM_WRITE BIT(16) -#define CAM_READ 0x00000000 -#define CAM_POLLINIG BIT(31) - -#define SCR_UseDK 0x01 -#define SCR_TxSecEnable 0x02 -#define SCR_RxSecEnable 0x04 - -/* 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F) */ -/* 8188 IMR/ISR bits */ -#define IMR_DISABLED_88E 0x0 -/* IMR DW0(0x0060-0063) Bit 0-31 */ -#define IMR_TXCCK_88E BIT(30) /* TXRPT interrupt when CCX bit of the packet is set */ -#define IMR_PSTIMEOUT_88E BIT(29) /* Power Save Time Out Interrupt */ -#define IMR_GTINT4_88E BIT(28) /* When GTIMER4 expires, this bit is set to 1 */ -#define IMR_GTINT3_88E BIT(27) /* When GTIMER3 expires, this bit is set to 1 */ -#define IMR_TBDER_88E BIT(26) /* Transmit Beacon0 Error */ -#define IMR_TBDOK_88E BIT(25) /* Transmit Beacon0 OK */ -#define IMR_TSF_BIT32_TOGGLE_88E BIT(24) /* TSF Timer BIT32 toggle indication interrupt */ -#define IMR_BCNDMAINT0_88E BIT(20) /* Beacon DMA Interrupt 0 */ -#define IMR_BCNDERR0_88E BIT(16) /* Beacon Queue DMA Error 0 */ -#define IMR_HSISR_IND_ON_INT_88E BIT(15) /* HSISR Indicator (HSIMR & HSISR is true, this bit is set to 1) */ -#define IMR_BCNDMAINT_E_88E BIT(14) /* Beacon DMA Interrupt Extension for Win7 */ -#define IMR_ATIMEND_88E BIT(12) /* CTWidnow End or ATIM Window End */ -#define IMR_HISR1_IND_INT_88E BIT(11) /* HISR1 Indicator (HISR1 & HIMR1 is true, this bit is set to 1) */ -#define IMR_C2HCMD_88E BIT(10) /* CPU to Host Command INT Status, Write 1 clear */ -#define IMR_CPWM2_88E BIT(9) /* CPU power Mode exchange INT Status, Write 1 clear */ -#define IMR_CPWM_88E BIT(8) /* CPU power Mode exchange INT Status, Write 1 clear */ -#define IMR_HIGHDOK_88E BIT(7) /* High Queue DMA OK */ -#define IMR_MGNTDOK_88E BIT(6) /* Management Queue DMA OK */ -#define IMR_BKDOK_88E BIT(5) /* AC_BK DMA OK */ -#define IMR_BEDOK_88E BIT(4) /* AC_BE DMA OK */ -#define IMR_VIDOK_88E BIT(3) /* AC_VI DMA OK */ -#define IMR_VODOK_88E BIT(2) /* AC_VO DMA OK */ -#define IMR_RDU_88E BIT(1) /* Rx Descriptor Unavailable */ -#define IMR_ROK_88E BIT(0) /* Receive DMA OK */ - -/* IMR DW1(0x00B4-00B7) Bit 0-31 */ -#define IMR_BCNDMAINT7_88E BIT(27) /* Beacon DMA Interrupt 7 */ -#define IMR_BCNDMAINT6_88E BIT(26) /* Beacon DMA Interrupt 6 */ -#define IMR_BCNDMAINT5_88E BIT(25) /* Beacon DMA Interrupt 5 */ -#define IMR_BCNDMAINT4_88E BIT(24) /* Beacon DMA Interrupt 4 */ -#define IMR_BCNDMAINT3_88E BIT(23) /* Beacon DMA Interrupt 3 */ -#define IMR_BCNDMAINT2_88E BIT(22) /* Beacon DMA Interrupt 2 */ -#define IMR_BCNDMAINT1_88E BIT(21) /* Beacon DMA Interrupt 1 */ -#define IMR_BCNDERR7_88E BIT(20) /* Beacon DMA Error Int 7 */ -#define IMR_BCNDERR6_88E BIT(19) /* Beacon DMA Error Int 6 */ -#define IMR_BCNDERR5_88E BIT(18) /* Beacon DMA Error Int 5 */ -#define IMR_BCNDERR4_88E BIT(17) /* Beacon DMA Error Int 4 */ -#define IMR_BCNDERR3_88E BIT(16) /* Beacon DMA Error Int 3 */ -#define IMR_BCNDERR2_88E BIT(15) /* Beacon DMA Error Int 2 */ -#define IMR_BCNDERR1_88E BIT(14) /* Beacon DMA Error Int 1 */ -#define IMR_ATIMEND_E_88E BIT(13) /* ATIM Window End Ext for Win7 */ -#define IMR_TXERR_88E BIT(11) /* Tx Err Flag Int Status, write 1 clear. */ -#define IMR_RXERR_88E BIT(10) /* Rx Err Flag INT Status, Write 1 clear */ -#define IMR_TXFOVW_88E BIT(9) /* Transmit FIFO Overflow */ -#define IMR_RXFOVW_88E BIT(8) /* Receive FIFO Overflow */ - -#define HAL_NIC_UNPLUG_ISR 0xFFFFFFFF /* The value when the NIC is unplugged for PCI. */ - -/* 8192C EFUSE */ -#define HWSET_MAX_SIZE 256 -#define HWSET_MAX_SIZE_88E 512 - -/*=================================================================== -===================================================================== -Here the register defines are for 92C. When the define is as same with 92C, -we will use the 92C's define for the consistency -So the following defines for 92C is not entire!!!!!! -===================================================================== -=====================================================================*/ -/* - * Based on Datasheet V33---090401 - * Register Summary - * Current IOREG MAP - * 0x0000h ~ 0x00FFh System Configuration (256 Bytes) - * 0x0100h ~ 0x01FFh MACTOP General Configuration (256 Bytes) - * 0x0200h ~ 0x027Fh TXDMA Configuration (128 Bytes) - * 0x0280h ~ 0x02FFh RXDMA Configuration (128 Bytes) - * 0x0300h ~ 0x03FFh PCIE EMAC Reserved Region (256 Bytes) - * 0x0400h ~ 0x04FFh Protocol Configuration (256 Bytes) - * 0x0500h ~ 0x05FFh EDCA Configuration (256 Bytes) - * 0x0600h ~ 0x07FFh WMAC Configuration (512 Bytes) - * 0x2000h ~ 0x3FFFh 8051 FW Download Region (8196 Bytes) - */ - -/* 8192C (RCR) Receive Configuration Register(Offset 0x608, 32 bits) */ -#define RCR_APPFCS BIT(31) /* WMAC append FCS after payload */ -#define RCR_APP_MIC BIT(30) -#define RCR_APP_PHYSTS BIT(28) -#define RCR_APP_ICV BIT(29) -#define RCR_APP_PHYST_RXFF BIT(28) -#define RCR_APP_BA_SSN BIT(27) /* Accept BA SSN */ -#define RCR_ENMBID BIT(24) /* Enable Multiple BssId. */ -#define RCR_LSIGEN BIT(23) -#define RCR_MFBEN BIT(22) -#define RCR_HTC_LOC_CTRL BIT(14) /* MFC<--HTC=1 MFC-->HTC=0 */ -#define RCR_AMF BIT(13) /* Accept management type frame */ -#define RCR_ACF BIT(12) /* Accept control type frame */ -#define RCR_ADF BIT(11) /* Accept data type frame */ -#define RCR_AICV BIT(9) /* Accept ICV error packet */ -#define RCR_ACRC32 BIT(8) /* Accept CRC32 error packet */ -#define RCR_CBSSID_BCN BIT(7) /* Accept BSSID match packet - * (Rx beacon, probe rsp) - */ -#define RCR_CBSSID_DATA BIT(6) /* Accept BSSID match (Data)*/ -#define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match */ -#define RCR_APWRMGT BIT(5) /* Accept power management pkt*/ -#define RCR_ADD3 BIT(4) /* Accept address 3 match pkt */ -#define RCR_AB BIT(3) /* Accept broadcast packet */ -#define RCR_AM BIT(2) /* Accept multicast packet */ -#define RCR_APM BIT(1) /* Accept physical match pkt */ -#define RCR_AAP BIT(0) /* Accept all unicast packet */ -#define RCR_MXDMA_OFFSET 8 -#define RCR_FIFO_OFFSET 13 - -/* 0xFE00h ~ 0xFE55h USB Configuration */ -#define REG_USB_HRPWM 0xFE58 - -/* 8192C Register Bit and Content definition */ -/* 0x0000h ~ 0x00FFh System Configuration */ - -/* 2 SYS_ISO_CTRL */ -#define ISO_MD2PP BIT(0) -#define ISO_UA2USB BIT(1) -#define ISO_UD2CORE BIT(2) -#define ISO_PA2PCIE BIT(3) -#define ISO_PD2CORE BIT(4) -#define ISO_IP2MAC BIT(5) -#define ISO_DIOP BIT(6) -#define ISO_DIOE BIT(7) -#define ISO_EB2CORE BIT(8) -#define ISO_DIOR BIT(9) -#define PWC_EV12V BIT(15) - -/* 2 SYS_FUNC_EN */ -#define FEN_BBRSTB BIT(0) -#define FEN_BB_GLB_RSTn BIT(1) -#define FEN_USBA BIT(2) -#define FEN_UPLL BIT(3) -#define FEN_USBD BIT(4) -#define FEN_DIO_PCIE BIT(5) -#define FEN_PCIEA BIT(6) -#define FEN_PPLL BIT(7) -#define FEN_PCIED BIT(8) -#define FEN_DIOE BIT(9) -#define FEN_CPUEN BIT(10) -#define FEN_DCORE BIT(11) -#define FEN_ELDR BIT(12) -#define FEN_DIO_RF BIT(13) -#define FEN_HWPDN BIT(14) -#define FEN_MREGEN BIT(15) - -/* 2 APS_FSMCO */ -#define PFM_LDALL BIT(0) -#define PFM_ALDN BIT(1) -#define PFM_LDKP BIT(2) -#define PFM_WOWL BIT(3) -#define EnPDN BIT(4) -#define PDN_PL BIT(5) -#define APFM_ONMAC BIT(8) -#define APFM_OFF BIT(9) -#define APFM_RSM BIT(10) -#define AFSM_HSUS BIT(11) -#define AFSM_PCIE BIT(12) -#define APDM_MAC BIT(13) -#define APDM_HOST BIT(14) -#define APDM_HPDN BIT(15) -#define RDY_MACON BIT(16) -#define SUS_HOST BIT(17) -#define ROP_ALD BIT(20) -#define ROP_PWR BIT(21) -#define ROP_SPS BIT(22) -#define SOP_MRST BIT(25) -#define SOP_FUSE BIT(26) -#define SOP_ABG BIT(27) -#define SOP_AMB BIT(28) -#define SOP_RCK BIT(29) -#define SOP_A8M BIT(30) -#define XOP_BTCK BIT(31) - -/* 2 SYS_CLKR */ -#define ANAD16V_EN BIT(0) -#define ANA8M BIT(1) -#define MACSLP BIT(4) -#define LOADER_CLK_EN BIT(5) - -/* 2 9346CR */ - -#define BOOT_FROM_EEPROM BIT(4) -#define EEPROM_EN BIT(5) - -/* 2 SPS0_CTRL */ - -/* 2 SPS_OCP_CFG */ - -/* 2 RF_CTRL */ -#define RF_EN BIT(0) -#define RF_RSTB BIT(1) -#define RF_SDMRSTB BIT(2) - -/* 2 LDOV12D_CTRL */ -#define LDV12_EN BIT(0) -#define LDV12_SDBY BIT(1) -#define LPLDO_HSM BIT(2) -#define LPLDO_LSM_DIS BIT(3) -#define _LDV12_VADJ(x) (((x) & 0xF) << 4) - -/* 2EFUSE_CTRL */ -#define ALD_EN BIT(18) -#define EF_PD BIT(19) -#define EF_FLAG BIT(31) - -/* 2 EFUSE_TEST (For RTL8723 partially) */ -#define EF_TRPT BIT(7) -/* 00: Wifi Efuse, 01: BT Efuse0, 10: BT Efuse1, 11: BT Efuse2 */ -#define EF_CELL_SEL (BIT(8) | BIT(9)) -#define LDOE25_EN BIT(31) -#define EFUSE_SEL(x) (((x) & 0x3) << 8) -#define EFUSE_SEL_MASK 0x300 -#define EFUSE_WIFI_SEL_0 0x0 -#define EFUSE_BT_SEL_0 0x1 -#define EFUSE_BT_SEL_1 0x2 -#define EFUSE_BT_SEL_2 0x3 - -#define EFUSE_ACCESS_ON 0x69 /* For RTL8723 only. */ -#define EFUSE_ACCESS_OFF 0x00 /* For RTL8723 only. */ - -/* 2 8051FWDL */ -/* 2 MCUFWDL */ -#define MCUFWDL_EN BIT(0) -#define MCUFWDL_RDY BIT(1) -#define FWDL_CHKSUM_RPT BIT(2) -#define MACINI_RDY BIT(3) -#define BBINI_RDY BIT(4) -#define RFINI_RDY BIT(5) -#define WINTINI_RDY BIT(6) -#define RAM_DL_SEL BIT(7) /* 1:RAM, 0:ROM */ -#define ROM_DLEN BIT(19) -#define CPRST BIT(23) - -/* 2 REG_SYS_CFG */ -#define XCLK_VLD BIT(0) -#define ACLK_VLD BIT(1) -#define UCLK_VLD BIT(2) -#define PCLK_VLD BIT(3) -#define PCIRSTB BIT(4) -#define V15_VLD BIT(5) -#define SW_OFFLOAD_EN BIT(7) -#define SIC_IDLE BIT(8) -#define BD_MAC2 BIT(9) -#define BD_MAC1 BIT(10) -#define IC_MACPHY_MODE BIT(11) -#define CHIP_VER (BIT(12) | BIT(13) | BIT(14) | BIT(15)) -#define BT_FUNC BIT(16) -#define VENDOR_ID BIT(19) -#define PAD_HWPD_IDN BIT(22) -#define TRP_VAUX_EN BIT(23) /* RTL ID */ -#define TRP_BT_EN BIT(24) -#define BD_PKG_SEL BIT(25) -#define BD_HCI_SEL BIT(26) -#define TYPE_ID BIT(27) - -#define CHIP_VER_RTL_MASK 0xF000 /* Bit 12 ~ 15 */ -#define CHIP_VER_RTL_SHIFT 12 - -/* 2REG_GPIO_OUTSTS (For RTL8723 only) */ -#define EFS_HCI_SEL (BIT(0) | BIT(1)) -#define PAD_HCI_SEL (BIT(2) | BIT(3)) -#define HCI_SEL (BIT(4) | BIT(5)) -#define PKG_SEL_HCI BIT(6) -#define FEN_GPS BIT(7) -#define FEN_BT BIT(8) -#define FEN_WL BIT(9) -#define FEN_PCI BIT(10) -#define FEN_USB BIT(11) -#define BTRF_HWPDN_N BIT(12) -#define WLRF_HWPDN_N BIT(13) -#define PDN_BT_N BIT(14) -#define PDN_GPS_N BIT(15) -#define BT_CTL_HWPDN BIT(16) -#define GPS_CTL_HWPDN BIT(17) -#define PPHY_SUSB BIT(20) -#define UPHY_SUSB BIT(21) -#define PCI_SUSEN BIT(22) -#define USB_SUSEN BIT(23) -#define RF_RL_ID (BIT(31) | BIT(30) | BIT(29) | BIT(28)) - -/* 2SYS_CFG */ -#define RTL_ID BIT(23) /* TestChip ID, 1:Test(RLE); 0:MP(RL) */ - -/* 0x0100h ~ 0x01FFh MACTOP General Configuration */ - -/* 2 Function Enable Registers */ -/* 2 CR */ - -#define HCI_TXDMA_EN BIT(0) -#define HCI_RXDMA_EN BIT(1) -#define TXDMA_EN BIT(2) -#define RXDMA_EN BIT(3) -#define PROTOCOL_EN BIT(4) -#define SCHEDULE_EN BIT(5) -#define MACTXEN BIT(6) -#define MACRXEN BIT(7) -#define ENSWBCN BIT(8) -#define ENSEC BIT(9) -#define CALTMR_EN BIT(10) /* 32k CAL TMR enable */ - -/* Network type */ -#define _NETTYPE(x) (((x) & 0x3) << 16) -#define MASK_NETTYPE 0x30000 -#define NT_NO_LINK 0x0 -#define NT_LINK_AD_HOC 0x1 -#define NT_LINK_AP 0x2 -#define NT_AS_AP 0x3 - -/* 2 PBP - Page Size Register */ -#define GET_RX_PAGE_SIZE(value) ((value) & 0xF) -#define GET_TX_PAGE_SIZE(value) (((value) & 0xF0) >> 4) -#define _PSRX_MASK 0xF -#define _PSTX_MASK 0xF0 -#define _PSRX(x) (x) -#define _PSTX(x) ((x) << 4) - -#define PBP_128 0x1 - -/* 2 TX/RXDMA */ -#define RXDMA_ARBBW_EN BIT(0) -#define RXSHFT_EN BIT(1) -#define RXDMA_AGG_EN BIT(2) -#define QS_VO_QUEUE BIT(8) -#define QS_VI_QUEUE BIT(9) -#define QS_BE_QUEUE BIT(10) -#define QS_BK_QUEUE BIT(11) -#define QS_MANAGER_QUEUE BIT(12) -#define QS_HIGH_QUEUE BIT(13) - -#define HQSEL_VOQ BIT(0) -#define HQSEL_VIQ BIT(1) -#define HQSEL_BEQ BIT(2) -#define HQSEL_BKQ BIT(3) -#define HQSEL_MGTQ BIT(4) -#define HQSEL_HIQ BIT(5) - -/* For normal driver, 0x10C */ -#define _TXDMA_HIQ_MAP(x) (((x) & 0x3) << 14) -#define _TXDMA_MGQ_MAP(x) (((x) & 0x3) << 12) -#define _TXDMA_BKQ_MAP(x) (((x) & 0x3) << 10) -#define _TXDMA_BEQ_MAP(x) (((x) & 0x3) << 8) -#define _TXDMA_VIQ_MAP(x) (((x) & 0x3) << 6) -#define _TXDMA_VOQ_MAP(x) (((x) & 0x3) << 4) - -#define QUEUE_LOW 1 -#define QUEUE_NORMAL 2 -#define QUEUE_HIGH 3 - -/* 2 TRXFF_BNDY */ - -/* 2 LLT_INIT */ -#define _LLT_NO_ACTIVE 0x0 -#define _LLT_WRITE_ACCESS 0x1 -#define _LLT_READ_ACCESS 0x2 - -#define _LLT_INIT_DATA(x) ((x) & 0xFF) -#define _LLT_INIT_ADDR(x) (((x) & 0xFF) << 8) -#define _LLT_OP(x) (((x) & 0x3) << 30) -#define _LLT_OP_VALUE(x) (((x) >> 30) & 0x3) - -/* 0x0200h ~ 0x027Fh TXDMA Configuration */ -/* 2RQPN */ -#define _HPQ(x) ((x) & 0xFF) -#define _LPQ(x) (((x) & 0xFF) << 8) -#define _PUBQ(x) (((x) & 0xFF) << 16) -/* NOTE: in RQPN_NPQ register */ -#define _NPQ(x) ((x) & 0xFF) - -#define HPQ_PUBLIC_DIS BIT(24) -#define LPQ_PUBLIC_DIS BIT(25) -#define LD_RQPN BIT(31) - -/* 2TDECTRL */ -#define BCN_VALID BIT(16) -#define BCN_HEAD(x) (((x) & 0xFF) << 8) -#define BCN_HEAD_MASK 0xFF00 - -/* 2 TDECTL */ -#define BLK_DESC_NUM_SHIFT 4 -#define BLK_DESC_NUM_MASK 0xF - -/* 2 TXDMA_OFFSET_CHK */ -#define DROP_DATA_EN BIT(9) - -/* 0x0280h ~ 0x028Bh RX DMA Configuration */ - -/* REG_RXDMA_CONTROL, 0x0286h */ - -/* 2 REG_RXPKT_NUM, 0x0284 */ -#define RXPKT_RELEASE_POLL BIT(16) -#define RXDMA_IDLE BIT(17) -#define RW_RELEASE_EN BIT(18) - -/* 0x0400h ~ 0x047Fh Protocol Configuration */ -/* 2 FWHW_TXQ_CTRL */ -#define EN_AMPDU_RTY_NEW BIT(7) - -/* 2 SPEC SIFS */ -#define _SPEC_SIFS_CCK(x) ((x) & 0xFF) -#define _SPEC_SIFS_OFDM(x) (((x) & 0xFF) << 8) - -/* 2 RL */ -#define RETRY_LIMIT_SHORT_SHIFT 8 -#define RETRY_LIMIT_LONG_SHIFT 0 - -/* 0x0500h ~ 0x05FFh EDCA Configuration */ - -/* 2 EDCA setting */ -#define AC_PARAM_TXOP_LIMIT_OFFSET 16 -#define AC_PARAM_ECW_MAX_OFFSET 12 -#define AC_PARAM_ECW_MIN_OFFSET 8 -#define AC_PARAM_AIFS_OFFSET 0 - -#define _LRL(x) ((x) & 0x3F) -#define _SRL(x) (((x) & 0x3F) << 8) - -/* 2 BCN_CTRL */ -#define EN_MBSSID BIT(1) -#define EN_TXBCN_RPT BIT(2) -#define EN_BCN_FUNCTION BIT(3) -#define DIS_TSF_UPDATE BIT(3) - -/* The same function but different bit field. */ -#define DIS_TSF_UDT0_NORMAL_CHIP BIT(4) -#define DIS_TSF_UDT0_TEST_CHIP BIT(5) -#define STOP_BCNQ BIT(6) - -/* 2 ACMHWCTRL */ -#define AcmHw_HwEn BIT(0) -#define AcmHw_BeqEn BIT(1) -#define AcmHw_ViqEn BIT(2) -#define AcmHw_VoqEn BIT(3) -#define AcmHw_BeqStatus BIT(4) -#define AcmHw_ViqStatus BIT(5) -#define AcmHw_VoqStatus BIT(6) - -/* 0x0600h ~ 0x07FFh WMAC Configuration */ -/* 2APSD_CTRL */ -#define APSDOFF BIT(6) -#define APSDOFF_STATUS BIT(7) - -#define RATE_BITMAP_ALL 0xFFFFF - -/* Only use CCK 1M rate for ACK */ -#define RATE_RRSR_CCK_ONLY_1M 0xFFFF1 - -/* 2 TCR */ -#define TSFRST BIT(0) -#define DIS_GCLK BIT(1) -#define PAD_SEL BIT(2) -#define PWR_ST BIT(6) -#define PWRBIT_OW_EN BIT(7) -#define ACRC BIT(8) -#define CFENDFORM BIT(9) -#define ICV BIT(10) - -/* 2 RCR */ -#define AAP BIT(0) -#define APM BIT(1) -#define AM BIT(2) -#define AB BIT(3) -#define ADD3 BIT(4) -#define APWRMGT BIT(5) -#define CBSSID BIT(6) -#define CBSSID_DATA BIT(6) -#define CBSSID_BCN BIT(7) -#define ACRC32 BIT(8) -#define AICV BIT(9) -#define ADF BIT(11) -#define ACF BIT(12) -#define AMF BIT(13) -#define HTC_LOC_CTRL BIT(14) -#define UC_DATA_EN BIT(16) -#define BM_DATA_EN BIT(17) -#define MFBEN BIT(22) -#define LSIGEN BIT(23) -#define EnMBID BIT(24) -#define APP_BASSN BIT(27) -#define APP_PHYSTS BIT(28) -#define APP_ICV BIT(29) -#define APP_MIC BIT(30) -#define APP_FCS BIT(31) - -/* 2 SECCFG */ -#define SCR_TxUseDK BIT(0) /* Force Tx Use Default Key */ -#define SCR_RxUseDK BIT(1) /* Force Rx Use Default Key */ -#define SCR_TxEncEnable BIT(2) /* Enable Tx Encryption */ -#define SCR_RxDecEnable BIT(3) /* Enable Rx Decryption */ -#define SCR_SKByA2 BIT(4) /* Search kEY BY A2 */ -#define SCR_NoSKMC BIT(5) /* No Key Search Multicast */ -#define SCR_TXBCUSEDK BIT(6) /* Force Tx Bcast pkt Use Default Key */ -#define SCR_RXBCUSEDK BIT(7) /* Force Rx Bcast pkt Use Default Key */ - -/* 0xFE00h ~ 0xFE55h USB Configuration */ - -/* 2 USB Information (0xFE17) */ -#define USB_IS_HIGH_SPEED 0 -#define USB_IS_FULL_SPEED 1 -#define USB_SPEED_MASK BIT(5) - -#define USB_NORMAL_SIE_EP_MASK 0xF -#define USB_NORMAL_SIE_EP_SHIFT 4 - -/* 2 Special Option */ -#define USB_AGG_EN BIT(3) - -/* 0; Use interrupt endpoint to upload interrupt pkt */ -/* 1; Use bulk endpoint to upload interrupt pkt, */ -#define INT_BULK_SEL BIT(4) - -/* 2REG_C2HEVT_CLEAR */ -/* Set by driver and notify FW that the driver has read - * the C2H command message - */ -#define C2H_EVT_HOST_CLOSE 0x00 -/* Set by FW indicating that FW had set the C2H command - * message and it's not yet read by driver. - */ -#define C2H_EVT_FW_CLOSE 0xFF - -/* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ -/* Enable GPIO[9] as WiFi HW PDn source */ -#define WL_HWPDN_EN BIT(0) -/* WiFi HW PDn polarity control */ -#define WL_HWPDN_SL BIT(1) -/* WiFi function enable */ -#define WL_FUNC_EN BIT(2) -/* Enable GPIO[9] as WiFi RF HW PDn source */ -#define WL_HWROF_EN BIT(3) -/* Enable GPIO[11] as BT HW PDn source */ -#define BT_HWPDN_EN BIT(16) -/* BT HW PDn polarity control */ -#define BT_HWPDN_SL BIT(17) -/* BT function enable */ -#define BT_FUNC_EN BIT(18) -/* Enable GPIO[11] as BT/GPS RF HW PDn source */ -#define BT_HWROF_EN BIT(19) -/* Enable GPIO[10] as GPS HW PDn source */ -#define GPS_HWPDN_EN BIT(20) -/* GPS HW PDn polarity control */ -#define GPS_HWPDN_SL BIT(21) -/* GPS function enable */ -#define GPS_FUNC_EN BIT(22) - -/* General definitions */ -#define LAST_ENTRY_OF_TX_PKT_BUFFER 176 /* 22k 22528 bytes */ - -#define POLLING_LLT_THRESHOLD 20 -#define POLLING_READY_TIMEOUT_COUNT 1000 -/* GPIO BIT */ -#define HAL_8192C_HW_GPIO_WPS_BIT BIT(2) - -/* 8192C EEPROM/EFUSE share register definition. */ - -/* EEPROM/Efuse PG Offset for 88EE/88EU/88ES */ -#define EEPROM_TX_PWR_INX_88E 0x10 - -#define EEPROM_ChannelPlan_88E 0xB8 -#define EEPROM_XTAL_88E 0xB9 -#define EEPROM_THERMAL_METER_88E 0xBA -#define EEPROM_IQK_LCK_88E 0xBB - -#define EEPROM_RF_BOARD_OPTION_88E 0xC1 -#define EEPROM_RF_FEATURE_OPTION_88E 0xC2 -#define EEPROM_RF_BT_SETTING_88E 0xC3 -#define EEPROM_VERSION_88E 0xC4 -#define EEPROM_CUSTOMERID_88E 0xC5 -#define EEPROM_RF_ANTENNA_OPT_88E 0xC9 - -/* RTL88EU */ -#define EEPROM_MAC_ADDR_88EU 0xD7 -#define EEPROM_VID_88EU 0xD0 -#define EEPROM_PID_88EU 0xD2 -#define EEPROM_USB_OPTIONAL_FUNCTION0 0xD4 - -/* EEPROM/Efuse Value Type */ -#define EETYPE_TX_PWR 0x0 - -#define EEPROM_Default_CrystalCap_88E 0x20 -#define EEPROM_Default_ThermalMeter_88E 0x18 - -/* New EFUSE default value */ -#define EEPROM_DEFAULT_24G_INDEX 0x2D -#define EEPROM_DEFAULT_24G_HT20_DIFF 0X02 -#define EEPROM_DEFAULT_24G_OFDM_DIFF 0X04 - -#define EEPROM_DEFAULT_5G_INDEX 0X2A -#define EEPROM_DEFAULT_5G_HT20_DIFF 0X00 -#define EEPROM_DEFAULT_5G_OFDM_DIFF 0X04 - -#define EEPROM_DEFAULT_DIFF 0XFE -#define EEPROM_DEFAULT_CHANNEL_PLAN 0x7F -#define EEPROM_DEFAULT_BOARD_OPTION 0x00 -#define EEPROM_DEFAULT_FEATURE_OPTION 0x00 -#define EEPROM_DEFAULT_BT_OPTION 0x10 - -/* For debug */ -#define EEPROM_Default_PID 0x1234 -#define EEPROM_Default_VID 0x5678 -#define EEPROM_Default_CustomerID 0xAB -#define EEPROM_Default_CustomerID_8188E 0x00 -#define EEPROM_Default_SubCustomerID 0xCD -#define EEPROM_Default_Version 0 - -#define EEPROM_CHANNEL_PLAN_FCC 0x0 -#define EEPROM_CHANNEL_PLAN_IC 0x1 -#define EEPROM_CHANNEL_PLAN_ETSI 0x2 -#define EEPROM_CHANNEL_PLAN_SPA 0x3 -#define EEPROM_CHANNEL_PLAN_FRANCE 0x4 -#define EEPROM_CHANNEL_PLAN_MKK 0x5 -#define EEPROM_CHANNEL_PLAN_MKK1 0x6 -#define EEPROM_CHANNEL_PLAN_ISRAEL 0x7 -#define EEPROM_CHANNEL_PLAN_TELEC 0x8 -#define EEPROM_CHANNEL_PLAN_GLOBAL_DOMA 0x9 -#define EEPROM_CHANNEL_PLAN_WORLD_WIDE_13 0xA -#define EEPROM_CHANNEL_PLAN_NCC 0xB -#define EEPROM_USB_OPTIONAL1 0xE -#define EEPROM_CHANNEL_PLAN_BY_HW_MASK 0x80 - -#define EEPROM_CID_DEFAULT 0x0 -#define EEPROM_CID_TOSHIBA 0x4 -#define EEPROM_CID_CCX 0x10 /* CCX test. */ -#define EEPROM_CID_QMI 0x0D -#define EEPROM_CID_WHQL 0xFE -#define RTL_EEPROM_ID 0x8129 - -#endif /* __RTL8188E_SPEC_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h b/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h deleted file mode 100644 index 72a2bb812c9a..000000000000 --- a/drivers/staging/rtl8188eu/include/rtl8188e_xmit.h +++ /dev/null @@ -1,157 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTL8188E_XMIT_H__ -#define __RTL8188E_XMIT_H__ - -#define MAX_TX_AGG_PACKET_NUMBER 0xFF -/* */ -/* Queue Select Value in TxDesc */ -/* */ -#define QSLT_BK 0x2/* 0x01 */ -#define QSLT_BE 0x0 -#define QSLT_VI 0x5/* 0x4 */ -#define QSLT_VO 0x7/* 0x6 */ -#define QSLT_BEACON 0x10 -#define QSLT_HIGH 0x11 -#define QSLT_MGNT 0x12 -#define QSLT_CMD 0x13 - -/* For 88e early mode */ -#define SET_EARLYMODE_PKTNUM(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 0, 3, __Value) -#define SET_EARLYMODE_LEN0(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 4, 12, __Value) -#define SET_EARLYMODE_LEN1(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 16, 12, __Value) -#define SET_EARLYMODE_LEN2_1(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 28, 4, __Value) -#define SET_EARLYMODE_LEN2_2(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr + 4, 0, 8, __Value) -#define SET_EARLYMODE_LEN3(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr + 4, 8, 12, __Value) -#define SET_EARLYMODE_LEN4(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr + 4, 20, 12, __Value) - -/* */ -/* defined for TX DESC Operation */ -/* */ - -#define MAX_TID (15) - -/* OFFSET 0 */ -#define OFFSET_SZ 0 -#define OFFSET_SHT 16 -#define BMC BIT(24) -#define LSG BIT(26) -#define FSG BIT(27) -#define OWN BIT(31) - -/* OFFSET 4 */ -#define PKT_OFFSET_SZ 0 -#define QSEL_SHT 8 -#define RATE_ID_SHT 16 -#define NAVUSEHDR BIT(20) -#define SEC_TYPE_SHT 22 -#define PKT_OFFSET_SHT 26 - -/* OFFSET 8 */ -#define AGG_EN BIT(12) -#define AGG_BK BIT(16) -#define AMPDU_DENSITY_SHT 20 -#define ANTSEL_A BIT(24) -#define ANTSEL_B BIT(25) -#define TX_ANT_CCK_SHT 26 -#define TX_ANTL_SHT 28 -#define TX_ANT_HT_SHT 30 - -/* OFFSET 12 */ -#define SEQ_SHT 16 -#define EN_HWSEQ BIT(31) - -/* OFFSET 16 */ -#define QOS BIT(6) -#define HW_SSN BIT(7) -#define USERATE BIT(8) -#define DISDATAFB BIT(10) -#define CTS_2_SELF BIT(11) -#define RTS_EN BIT(12) -#define HW_RTS_EN BIT(13) -#define DATA_SHORT BIT(24) -#define PWR_STATUS_SHT 15 -#define DATA_SC_SHT 20 -#define DATA_BW BIT(25) - -/* OFFSET 20 */ -#define RTY_LMT_EN BIT(17) - -enum TXDESC_SC { - SC_DONT_CARE = 0x00, - SC_UPPER = 0x01, - SC_LOWER = 0x02, - SC_DUPLICATE = 0x03 -}; - -/* OFFSET 20 */ -#define SGI BIT(6) -#define USB_TXAGG_NUM_SHT 24 - -#define txdesc_set_ccx_sw_88e(txdesc, value) \ - do { \ - ((struct txdesc_88e *)(txdesc))->sw1 = (((value) >> 8) & 0x0f); \ - ((struct txdesc_88e *)(txdesc))->sw0 = ((value) & 0xff); \ - } while (0) - -struct txrpt_ccx_88e { - /* offset 0 */ - u8 tag1:1; - u8 pkt_num:3; - u8 txdma_underflow:1; - u8 int_bt:1; - u8 int_tri:1; - u8 int_ccx:1; - - /* offset 1 */ - u8 mac_id:6; - u8 pkt_ok:1; - u8 bmc:1; - - /* offset 2 */ - u8 retry_cnt:6; - u8 lifetime_over:1; - u8 retry_over:1; - - /* offset 3 */ - u8 ccx_qtime0; - u8 ccx_qtime1; - - /* offset 5 */ - u8 final_data_rate; - - /* offset 6 */ - u8 sw1:4; - u8 qsel:4; - - /* offset 7 */ - u8 sw0; -}; - -#define txrpt_ccx_sw_88e(txrpt_ccx) ((txrpt_ccx)->sw0 + ((txrpt_ccx)->sw1 << 8)) -#define txrpt_ccx_qtime_88e(txrpt_ccx) \ - ((txrpt_ccx)->ccx_qtime0 + ((txrpt_ccx)->ccx_qtime1 << 8)) - -void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, - u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); -s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); -s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); -#define hal_xmit_handler rtl8188eu_xmit_buf_handler -void rtl8188eu_xmit_tasklet(struct tasklet_struct *t); -bool rtl8188eu_xmitframe_complete(struct adapter *padapter, - struct xmit_priv *pxmitpriv); - -void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); - -#endif /* __RTL8188E_XMIT_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_android.h b/drivers/staging/rtl8188eu/include/rtw_android.h deleted file mode 100644 index 2c26993b8205..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_android.h +++ /dev/null @@ -1,50 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#ifndef __RTW_ANDROID_H__ -#define __RTW_ANDROID_H__ - -#include -#include - -enum ANDROID_WIFI_CMD { - ANDROID_WIFI_CMD_START, - ANDROID_WIFI_CMD_STOP, - ANDROID_WIFI_CMD_SCAN_ACTIVE, - ANDROID_WIFI_CMD_SCAN_PASSIVE, - ANDROID_WIFI_CMD_RSSI, - ANDROID_WIFI_CMD_LINKSPEED, - ANDROID_WIFI_CMD_RXFILTER_START, - ANDROID_WIFI_CMD_RXFILTER_STOP, - ANDROID_WIFI_CMD_RXFILTER_ADD, - ANDROID_WIFI_CMD_RXFILTER_REMOVE, - ANDROID_WIFI_CMD_BTCOEXSCAN_START, - ANDROID_WIFI_CMD_BTCOEXSCAN_STOP, - ANDROID_WIFI_CMD_BTCOEXMODE, - ANDROID_WIFI_CMD_SETSUSPENDOPT, - ANDROID_WIFI_CMD_P2P_DEV_ADDR, - ANDROID_WIFI_CMD_SETFWPATH, - ANDROID_WIFI_CMD_SETBAND, - ANDROID_WIFI_CMD_GETBAND, - ANDROID_WIFI_CMD_COUNTRY, - ANDROID_WIFI_CMD_P2P_SET_NOA, - ANDROID_WIFI_CMD_P2P_GET_NOA, - ANDROID_WIFI_CMD_P2P_SET_PS, - ANDROID_WIFI_CMD_SET_AP_WPS_P2P_IE, - ANDROID_WIFI_CMD_MACADDR, - ANDROID_WIFI_CMD_BLOCK, - ANDROID_WIFI_CMD_WFD_ENABLE, - ANDROID_WIFI_CMD_WFD_DISABLE, - ANDROID_WIFI_CMD_WFD_SET_TCPPORT, - ANDROID_WIFI_CMD_WFD_SET_MAX_TPUT, - ANDROID_WIFI_CMD_WFD_SET_DEVTYPE, - ANDROID_WIFI_CMD_MAX -}; - -int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd); - -#endif /* __RTW_ANDROID_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ap.h b/drivers/staging/rtl8188eu/include/rtw_ap.h deleted file mode 100644 index 7a4203bce473..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_ap.h +++ /dev/null @@ -1,45 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_AP_H_ -#define __RTW_AP_H_ - -#include -#include - -#ifdef CONFIG_88EU_AP_MODE - -/* external function */ -void rtw_indicate_sta_assoc_event(struct adapter *padapter, - struct sta_info *psta); -void rtw_indicate_sta_disassoc_event(struct adapter *padapter, - struct sta_info *psta); -void init_mlme_ap_info(struct adapter *padapter); -void free_mlme_ap_info(struct adapter *padapter); -void update_beacon(struct adapter *padapter, u8 ie_id, - u8 *oui, u8 tx); -void add_RATid(struct adapter *padapter, struct sta_info *psta, - u8 rssi_level); -void expire_timeout_chk(struct adapter *padapter); -void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta); -int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len); -void rtw_set_macaddr_acl(struct adapter *padapter, int mode); -int rtw_acl_add_sta(struct adapter *padapter, u8 *addr); -int rtw_acl_remove_sta(struct adapter *padapter, u8 *addr); - -void associated_clients_update(struct adapter *padapter, u8 updated); -void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta); -u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta); -void sta_info_update(struct adapter *padapter, struct sta_info *psta); -void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta); -u8 ap_free_sta(struct adapter *padapter, struct sta_info *psta, - bool active, u16 reason); -int rtw_sta_flush(struct adapter *padapter); -void start_ap_mode(struct adapter *padapter); -void stop_ap_mode(struct adapter *padapter); -#endif /* end of CONFIG_88EU_AP_MODE */ - -#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_cmd.h b/drivers/staging/rtl8188eu/include/rtw_cmd.h deleted file mode 100644 index 4e9cb93e4b8f..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_cmd.h +++ /dev/null @@ -1,361 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_CMD_H_ -#define __RTW_CMD_H_ - -#include -#include -#include - -#include -#include /* */ - -#define MAX_CMDSZ 1024 -#define MAX_RSPSZ 512 - -#define CMDBUFF_ALIGN_SZ 512 - -struct cmd_obj { - struct adapter *padapter; - u16 cmdcode; - u8 res; - u8 *parmbuf; - u32 cmdsz; - u8 *rsp; - u32 rspsz; - struct list_head list; -}; - -struct cmd_priv { - struct completion cmd_queue_comp; - struct __queue cmd_queue; -}; - -#define init_h2fwcmd_w_parm_no_rsp(pcmd, pparm, code) \ -do {\ - INIT_LIST_HEAD(&pcmd->list);\ - pcmd->cmdcode = code;\ - pcmd->parmbuf = (u8 *)(pparm);\ - pcmd->cmdsz = sizeof(*pparm);\ - pcmd->rsp = NULL;\ - pcmd->rspsz = 0;\ -} while (0) - -u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *obj); -struct cmd_obj *rtw_dequeue_cmd(struct __queue *queue); -void rtw_free_cmd_obj(struct cmd_obj *pcmd); - -int rtw_cmd_thread(void *context); - -void rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); - -enum rtw_drvextra_cmd_id { - NONE_WK_CID, - DYNAMIC_CHK_WK_CID, - DM_CTRL_WK_CID, - PBC_POLLING_WK_CID, - POWER_SAVING_CTRL_WK_CID,/* IPS,AUTOSuspend */ - LPS_CTRL_WK_CID, - ANT_SELECT_WK_CID, - P2P_PS_WK_CID, - P2P_PROTO_WK_CID, - CHECK_HIQ_WK_CID,/* for softap mode, check hi queue if empty */ - INTEl_WIDI_WK_CID, - C2H_WK_CID, - RTP_TIMER_CFG_WK_CID, - MAX_WK_CID -}; - -enum LPS_CTRL_TYPE { - LPS_CTRL_SCAN = 0, - LPS_CTRL_JOINBSS = 1, - LPS_CTRL_CONNECT = 2, - LPS_CTRL_DISCONNECT = 3, - LPS_CTRL_SPECIAL_PACKET = 4, - LPS_CTRL_LEAVE = 5, -}; - -enum RFINTFS { - SWSI, - HWSI, - HWPI, -}; - -/* - * Caller Mode: Infra, Ad-HoC(C) - * - * Notes: To disconnect the current associated BSS - * - * Command Mode - * - */ -struct disconnect_parm { - u32 deauth_timeout_ms; -}; - -struct setopmode_parm { - u8 mode; - u8 rsvd[3]; -}; - -/* - * Caller Mode: AP, Ad-HoC, Infra - * - * Notes: To ask RTL8711 performing site-survey - * - * Command-Event Mode - * - */ - -#define RTW_SSID_SCAN_AMOUNT 9 /* for WEXT_CSCAN_AMOUNT 9 */ -#define RTW_CHANNEL_SCAN_AMOUNT (14 + 37) -struct sitesurvey_parm { - int scan_mode; /* active: 1, passive: 0 */ - u8 ssid_num; - u8 ch_num; - struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; - struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; -}; - -/* - * Caller Mode: Any - * - * Notes: To set the auth type of RTL8711. open/shared/802.1x - * - * Command Mode - * - */ -struct setauth_parm { - u8 mode; /* 0: legacy open, 1: legacy shared 2: 802.1x */ - u8 _1x; /* 0: PSK, 1: TLS */ - u8 rsvd[2]; -}; - -/* - * Caller Mode: Infra - * - * a. algorithm: wep40, wep104, tkip & aes - * b. keytype: grp key/unicast key - * c. key contents - * - * when shared key ==> keyid is the camid - * when 802.1x ==> keyid [0:1] ==> grp key - * when 802.1x ==> keyid > 2 ==> unicast key - * - */ -struct setkey_parm { - u8 algorithm; /* could be none, wep40, TKIP, CCMP, wep104 */ - u8 keyid; - u8 grpkey; /* 1: this is the grpkey for 802.1x. - * 0: this is the unicast key for 802.1x - */ - u8 set_tx; /* 1: main tx key for wep. 0: other key. */ - u8 key[16]; /* this could be 40 or 104 */ -}; - -/* - * When in AP or Ad-Hoc mode, this is used to - * allocate an sw/hw entry for a newly associated sta. - * - * Command - * - * when shared key ==> algorithm/keyid - * - */ -struct set_stakey_parm { - u8 addr[ETH_ALEN]; - u8 algorithm; - u8 id;/* currently for erasing cam entry if - * algorithm == _NO_PRIVACY_ - */ - u8 key[16]; -}; - -struct set_stakey_rsp { - u8 addr[ETH_ALEN]; - u8 keyid; - u8 rsvd; -}; - -/* - * Caller Ad-Hoc/AP - * - * Command -Rsp(AID == CAMID) mode - * - * This is to force fw to add an sta_data entry per driver's request. - * - * FW will write an cam entry associated with it. - * - */ -struct set_assocsta_parm { - u8 addr[ETH_ALEN]; -}; - -struct set_assocsta_rsp { - u8 cam_id; - u8 rsvd[3]; -}; - -/* - * Notes: This command is used for H2C/C2H loopback testing - * - * mac[0] == 0 - * ==> CMD mode, return H2C_SUCCESS. - * The following condition must be true under CMD mode - * mac[1] == mac[4], mac[2] == mac[3], mac[0]=mac[5]= 0; - * s0 == 0x1234, s1 == 0xabcd, w0 == 0x78563412, w1 == 0x5aa5def7; - * s2 == (b1 << 8 | b0); - * - * mac[0] == 1 - * ==> CMD_RSP mode, return H2C_SUCCESS_RSP - * - * The rsp layout shall be: - * rsp: parm: - * mac[0] = mac[5]; - * mac[1] = mac[4]; - * mac[2] = mac[3]; - * mac[3] = mac[2]; - * mac[4] = mac[1]; - * mac[5] = mac[0]; - * s0 = s1; - * s1 = swap16(s0); - * w0 = swap32(w1); - * b0 = b1 - * s2 = s0 + s1 - * b1 = b0 - * w1 = w0 - * - * mac[0] == 2 - * ==> CMD_EVENT mode, return H2C_SUCCESS - * The event layout shall be: - * event: parm: - * mac[0] = mac[5]; - * mac[1] = mac[4]; - * mac[2] = event's seq no, starting from 1 to parm's marc[3] - * mac[2] = event's seq no, starting from 1 to parm's marc[3] - * mac[2] = event's seq no, starting from 1 to parm's marc[3] - * mac[3] = mac[2]; - * mac[4] = mac[1]; - * mac[5] = mac[0]; - * s0 = swap16(s0) - event.mac[2]; - * s1 = s1 + event.mac[2]; - * w0 = swap32(w0); - * b0 = b1 - * s2 = s0 + event.mac[2] - * b1 = b0 - * w1 = swap32(w1) - event.mac[2]; - * - * parm->mac[3] is the total event counts that host requested. - * event will be the same with the cmd's param. - */ - -/* CMD param Format for driver extra cmd handler */ -struct drvextra_cmd_parm { - int ec_id; /* extra cmd id */ - int type_size; /* Can use this field as the type id or command size */ - unsigned char *pbuf; -}; - -struct addBaReq_parm { - unsigned int tid; - u8 addr[ETH_ALEN]; -}; - -/*H2C Handler index: 46 */ -struct set_ch_parm { - u8 ch; - u8 bw; - u8 ch_offset; -}; - -/*H2C Handler index: 59 */ -struct SetChannelPlan_param { - u8 channel_plan; -}; - -/* - * - * Result: - * 0x00: success - * 0x01: success, and check Response. - * 0x02: cmd ignored due to duplicated sequcne number - * 0x03: cmd dropped due to invalid cmd code - * 0x04: reserved. - * - */ - -#define H2C_SUCCESS 0x00 -#define H2C_SUCCESS_RSP 0x01 -#define H2C_DROPPED 0x03 -#define H2C_PARAMETERS_ERROR 0x04 -#define H2C_REJECTED 0x05 - -u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, - int ssid_num, struct rtw_ieee80211_channel *ch, - int ch_num); -u8 rtw_createbss_cmd(struct adapter *padapter); -u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key); -u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, - u8 enqueue); -u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork); -u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, - bool enqueue); -u8 rtw_setopmode_cmd(struct adapter *padapter, - enum ndis_802_11_network_infra networktype); -u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr); - -u8 rtw_dynamic_chk_wk_cmd(struct adapter *adapter); - -u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue); -u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 minRptTime); - -u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue); -u8 rtw_ps_cmd(struct adapter *padapter); - -#ifdef CONFIG_88EU_AP_MODE -u8 rtw_chk_hi_queue_cmd(struct adapter *padapter); -#endif - -u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue); -u8 rtw_drvextra_cmd_hdl(struct adapter *padapter, unsigned char *pbuf); - -void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); -void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); -void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd); -void rtw_createbss_cmd_callback(struct adapter *adapt, struct cmd_obj *pcmd); -void rtw_readtssi_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); - -void rtw_setstaKey_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); -void rtw_setassocsta_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cm); -void rtw_getrttbl_cmdrsp_callback(struct adapter *adapt, struct cmd_obj *cmd); - -struct _cmd_callback { - u32 cmd_code; - void (*callback)(struct adapter *padapter, struct cmd_obj *cmd); -}; - -enum rtw_h2c_cmd { - _JoinBss_CMD_, - _DisConnect_CMD_, - _CreateBss_CMD_, - _SetOpMode_CMD_, - _SiteSurvey_CMD_, - _SetAuth_CMD_, - _SetKey_CMD_, - _SetStaKey_CMD_, - _SetAssocSta_CMD_, - _AddBAReq_CMD_, - _SetChannel_CMD_, - _TX_Beacon_CMD_, - _Set_MLME_EVT_CMD_, - _Set_Drv_Extra_CMD_, - _SetChannelPlan_CMD_, - - MAX_H2CCMD -}; - -#endif /* _CMD_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_eeprom.h b/drivers/staging/rtl8188eu/include/rtw_eeprom.h deleted file mode 100644 index 10525493129b..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_eeprom.h +++ /dev/null @@ -1,114 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_EEPROM_H__ -#define __RTW_EEPROM_H__ - -#include -#include - -#define RTL8712_EEPROM_ID 0x8712 - -#define HWSET_MAX_SIZE_512 512 -#define EEPROM_MAX_SIZE HWSET_MAX_SIZE_512 - -#define CLOCK_RATE 50 /* 100us */ - -/* EEPROM opcodes */ -#define EEPROM_READ_OPCODE 06 -#define EEPROM_WRITE_OPCODE 05 -#define EEPROM_ERASE_OPCODE 07 -#define EEPROM_EWEN_OPCODE 19 /* Erase/write enable */ -#define EEPROM_EWDS_OPCODE 16 /* Erase/write disable */ - -/* Country codes */ -#define USA 0x555320 -#define EUROPE 0x1 /* temp, should be provided later */ -#define JAPAN 0x2 /* temp, should be provided later */ - -#define EEPROM_CID_DEFAULT 0x0 -#define EEPROM_CID_ALPHA 0x1 -#define EEPROM_CID_Senao 0x3 -#define EEPROM_CID_NetCore 0x5 -#define EEPROM_CID_CAMEO 0X8 -#define EEPROM_CID_SITECOM 0x9 -#define EEPROM_CID_COREGA 0xB -#define EEPROM_CID_EDIMAX_BELK 0xC -#define EEPROM_CID_SERCOMM_BELK 0xE -#define EEPROM_CID_CAMEO1 0xF -#define EEPROM_CID_WNC_COREGA 0x12 -#define EEPROM_CID_CLEVO 0x13 -#define EEPROM_CID_WHQL 0xFE - -/* Customer ID, note that: */ -/* This variable is initiailzed through EEPROM or registry, */ -/* however, its definition may be different with that in EEPROM for */ -/* EEPROM size consideration. So, we have to perform proper translation - * between them. - */ -/* Besides, CustomerID of registry has precedence of that of EEPROM. */ -/* defined below. 060703, by rcnjko. */ -enum RT_CUSTOMER_ID { - RT_CID_DEFAULT = 0, - RT_CID_8187_ALPHA0 = 1, - RT_CID_8187_SERCOMM_PS = 2, - RT_CID_8187_HW_LED = 3, - RT_CID_8187_NETGEAR = 4, - RT_CID_WHQL = 5, - RT_CID_819x_CAMEO = 6, - RT_CID_819x_RUNTOP = 7, - RT_CID_819x_Senao = 8, - RT_CID_TOSHIBA = 9, /* Merge by Jacken, 2008/01/31. */ - RT_CID_819x_Netcore = 10, - RT_CID_Nettronix = 11, - RT_CID_DLINK = 12, - RT_CID_PRONET = 13, - RT_CID_COREGA = 14, - RT_CID_CHINA_MOBILE = 15, - RT_CID_819x_ALPHA = 16, - RT_CID_819x_Sitecom = 17, - RT_CID_CCX = 18, /* It's set under CCX logo test and isn't demanded - * for CCX functions, but for test behavior like retry - * limit and tx report. By Bruce, 2009-02-17. - */ - RT_CID_819x_Lenovo = 19, - RT_CID_819x_QMI = 20, - RT_CID_819x_Edimax_Belkin = 21, - RT_CID_819x_Sercomm_Belkin = 22, - RT_CID_819x_CAMEO1 = 23, - RT_CID_819x_MSI = 24, - RT_CID_819x_Acer = 25, - RT_CID_819x_AzWave_ASUS = 26, - RT_CID_819x_AzWave = 27, /* For AzWave in PCIe,i - * The ID is AzWave use and not only Asus - */ - RT_CID_819x_HP = 28, - RT_CID_819x_WNC_COREGA = 29, - RT_CID_819x_Arcadyan_Belkin = 30, - RT_CID_819x_SAMSUNG = 31, - RT_CID_819x_CLEVO = 32, - RT_CID_819x_DELL = 33, - RT_CID_819x_PRONETS = 34, - RT_CID_819x_Edimax_ASUS = 35, - RT_CID_819x_CAMEO_NETGEAR = 36, - RT_CID_PLANEX = 37, - RT_CID_CC_C = 38, - RT_CID_819x_Xavi = 39, - RT_CID_819x_FUNAI_TV = 40, - RT_CID_819x_ALPHA_WD = 41, -}; - -struct eeprom_priv { - u8 bautoload_fail_flag; - u8 bloadfile_fail_flag; - u8 bloadmac_fail_flag; - u8 mac_addr[6]; /* PermanentAddress */ - u16 channel_plan; - u8 EepromOrEfuse; - u8 efuse_eeprom_data[HWSET_MAX_SIZE_512]; -}; - -#endif /* __RTL871X_EEPROM_H__ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_efuse.h b/drivers/staging/rtl8188eu/include/rtw_efuse.h deleted file mode 100644 index bb5e2b5d4bf1..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_efuse.h +++ /dev/null @@ -1,67 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_EFUSE_H__ -#define __RTW_EFUSE_H__ - -#include - -#define EFUSE_ERROE_HANDLE 1 - -#define PG_STATE_HEADER 0x01 -#define PG_STATE_WORD_0 0x02 -#define PG_STATE_WORD_1 0x04 -#define PG_STATE_WORD_2 0x08 -#define PG_STATE_WORD_3 0x10 -#define PG_STATE_DATA 0x20 - -#define PG_SWBYTE_H 0x01 -#define PG_SWBYTE_L 0x02 - -#define PGPKT_DATA_SIZE 8 - -/* E-Fuse */ -#define EFUSE_MAP_SIZE 512 -#define EFUSE_MAX_SIZE 256 -/* end of E-Fuse */ - -#define EFUSE_MAX_MAP_LEN 512 -#define EFUSE_MAX_HW_SIZE 512 -#define EFUSE_MAX_SECTION_BASE 16 - -#define EXT_HEADER(header) ((header & 0x1F) == 0x0F) -#define ALL_WORDS_DISABLED(wde) ((wde & 0x0F) == 0x0F) -#define GET_HDR_OFFSET_2_0(header) ((header & 0xE0) >> 5) - -#define EFUSE_REPEAT_THRESHOLD_ 3 - -/* The following is for BT Efuse definition */ -#define EFUSE_BT_MAX_MAP_LEN 1024 -#define EFUSE_MAX_BANK 4 -#define EFUSE_MAX_BT_BANK (EFUSE_MAX_BANK - 1) -/*--------------------------Define Parameters-------------------------------*/ -#define EFUSE_MAX_WORD_UNIT 4 - -/*------------------------------Define structure----------------------------*/ -struct pgpkt { - u8 offset; - u8 word_en; - u8 data[8]; - u8 word_cnts; -}; - -u8 Efuse_CalculateWordCnts(u8 word_en); -u8 efuse_OneByteRead(struct adapter *adapter, u16 addr, u8 *data); -u8 efuse_OneByteWrite(struct adapter *adapter, u16 addr, u8 data); - -int Efuse_PgPacketRead(struct adapter *adapt, u8 offset, u8 *data); -bool Efuse_PgPacketWrite(struct adapter *adapter, u8 offset, u8 word, u8 *data); -void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata); -u8 Efuse_WordEnableDataWrite(struct adapter *adapter, u16 efuse_addr, - u8 word_en, u8 *data); - -void EFUSE_ShadowMapUpdate(struct adapter *adapter); -#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_event.h b/drivers/staging/rtl8188eu/include/rtw_event.h deleted file mode 100644 index bfe774e876d1..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_event.h +++ /dev/null @@ -1,81 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_EVENT_H_ -#define _RTW_EVENT_H_ - -#include - -#include -#include -#include - -/* - * Used to report a bss has been scanned - */ -struct survey_event { - struct wlan_bssid_ex bss; -}; - -/* - * Used to report that the requested site survey has been done. - * - * bss_cnt indicates the number of bss that has been reported. - * - * - */ -struct surveydone_event { - unsigned int bss_cnt; - -}; - -/* - * Used to report the link result of joinning the given bss - * - * - * join_res: - * -1: authentication fail - * -2: association fail - * > 0: TID - * - */ -struct joinbss_event { - struct wlan_network network; -}; - -/* - * Used to report a given STA has joinned the created BSS. - * It is used in AP/Ad-HoC(M) mode. - */ - -struct stassoc_event { - unsigned char macaddr[6]; - unsigned char rsvd[2]; - int cam_id; -}; - -struct stadel_event { - unsigned char macaddr[6]; - unsigned char rsvd[2]; /* for reason */ - int mac_id; -}; - -struct fwevent { - u32 parmsize; - void (*event_callback)(struct adapter *dev, u8 *pbuf); -}; - -#define C2HEVENT_SZ 32 - -#define NETWORK_QUEUE_SZ 4 - -struct network_queue { - int head; - int tail; - struct wlan_bssid_ex networks[NETWORK_QUEUE_SZ]; -}; - -#endif /* _WLANEVENT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ht.h b/drivers/staging/rtl8188eu/include/rtw_ht.h deleted file mode 100644 index 192fa50c07be..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_ht.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_HT_H_ -#define _RTW_HT_H_ - -#include - -struct ht_priv { - u32 ht_option; - u32 ampdu_enable;/* for enable Tx A-MPDU */ - u8 bwmode;/* */ - u8 ch_offset;/* PRIME_CHNL_OFFSET */ - u8 sgi;/* short GI */ - - /* for processing Tx A-MPDU */ - u8 agg_enable_bitmap; - u8 candidate_tid_bitmap; - - struct ieee80211_ht_cap ht_cap; -}; - -#endif /* _RTL871X_HT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl.h b/drivers/staging/rtl8188eu/include/rtw_ioctl.h deleted file mode 100644 index f681f9ebeafe..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl.h +++ /dev/null @@ -1,85 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_IOCTL_H_ -#define _RTW_IOCTL_H_ - -#include -#include - -#ifndef OID_802_11_CAPABILITY - #define OID_802_11_CAPABILITY 0x0d010122 -#endif - -#ifndef OID_802_11_PMKID - #define OID_802_11_PMKID 0x0d010123 -#endif - -/* For DDK-defined OIDs */ -#define OID_NDIS_SEG1 0x00010100 -#define OID_NDIS_SEG2 0x00010200 -#define OID_NDIS_SEG3 0x00020100 -#define OID_NDIS_SEG4 0x01010100 -#define OID_NDIS_SEG5 0x01020100 -#define OID_NDIS_SEG6 0x01020200 -#define OID_NDIS_SEG7 0xFD010100 -#define OID_NDIS_SEG8 0x0D010100 -#define OID_NDIS_SEG9 0x0D010200 -#define OID_NDIS_SEG10 0x0D020200 - -#define SZ_OID_NDIS_SEG1 23 -#define SZ_OID_NDIS_SEG2 3 -#define SZ_OID_NDIS_SEG3 6 -#define SZ_OID_NDIS_SEG4 6 -#define SZ_OID_NDIS_SEG5 4 -#define SZ_OID_NDIS_SEG6 8 -#define SZ_OID_NDIS_SEG7 7 -#define SZ_OID_NDIS_SEG8 36 -#define SZ_OID_NDIS_SEG9 24 -#define SZ_OID_NDIS_SEG10 19 - -/* For Realtek-defined OIDs */ -#define OID_MP_SEG1 0xFF871100 -#define OID_MP_SEG2 0xFF818000 - -#define OID_MP_SEG3 0xFF818700 -#define OID_MP_SEG4 0xFF011100 - -enum oid_type { - QUERY_OID, - SET_OID -}; - -struct oid_par_priv { - void *adapter_context; - NDIS_OID oid; - void *information_buf; - u32 information_buf_len; - u32 *bytes_rw; - u32 *bytes_needed; - enum oid_type type_of_oid; - u32 dbg; -}; - -#if defined(_RTW_MP_IOCTL_C_) -static int oid_null_function(struct oid_par_priv *poid_par_priv) -{ - return NDIS_STATUS_SUCCESS; -} -#endif - -extern struct iw_handler_def rtw_handlers_def; - -int drv_query_info(struct net_device *miniportadaptercontext, NDIS_OID oid, - void *informationbuffer, u32 informationbufferlength, - u32 *byteswritten, u32 *bytesneeded); - -int drv_set_info(struct net_device *MiniportAdapterContext, - NDIS_OID oid, void *informationbuffer, - u32 informationbufferlength, u32 *bytesread, - u32 *bytesneeded); - -#endif /* #ifndef __INC_CEINFO_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h b/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h deleted file mode 100644 index 7078f8252fa0..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_ioctl_set.h +++ /dev/null @@ -1,28 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_IOCTL_SET_H_ -#define __RTW_IOCTL_SET_H_ - -#include - -typedef u8 NDIS_802_11_PMKID_VALUE[16]; - -u8 rtw_set_802_11_authentication_mode(struct adapter *adapt, - enum ndis_802_11_auth_mode authmode); -u8 rtw_set_802_11_bssid(struct adapter *adapter, u8 *bssid); -u8 rtw_set_802_11_add_wep(struct adapter *adapter, struct ndis_802_11_wep *wep); -u8 rtw_set_802_11_disassociate(struct adapter *adapter); -u8 rtw_set_802_11_bssid_list_scan(struct adapter *adapter, - struct ndis_802_11_ssid *pssid, - int ssid_max_num); -u8 rtw_set_802_11_infrastructure_mode(struct adapter *adapter, - enum ndis_802_11_network_infra type); -u8 rtw_set_802_11_ssid(struct adapter *adapt, struct ndis_802_11_ssid *ssid); -u16 rtw_get_cur_max_rate(struct adapter *adapter); -int rtw_set_country(struct adapter *adapter, const char *country_code); - -#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_iol.h b/drivers/staging/rtl8188eu/include/rtw_iol.h deleted file mode 100644 index d713782d5cdc..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_iol.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_IOL_H_ -#define __RTW_IOL_H_ - -#include - -bool rtw_iol_applied(struct adapter *adapter); - -#endif /* __RTW_IOL_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_led.h b/drivers/staging/rtl8188eu/include/rtw_led.h deleted file mode 100644 index 5f65c3e1e46f..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_led.h +++ /dev/null @@ -1,98 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_LED_H_ -#define __RTW_LED_H_ - -#include -#include - -#define LED_BLINK_NO_LINK_INTERVAL_ALPHA 1000 -#define LED_BLINK_LINK_INTERVAL_ALPHA 500 /* 500 */ -#define LED_BLINK_SCAN_INTERVAL_ALPHA 180 /* 150 */ -#define LED_BLINK_FASTER_INTERVAL_ALPHA 50 -#define LED_BLINK_WPS_SUCCESS_INTERVAL_ALPHA 5000 - -enum LED_CTL_MODE { - LED_CTL_POWER_ON, - LED_CTL_LINK, - LED_CTL_NO_LINK, - LED_CTL_TX, - LED_CTL_RX, - LED_CTL_SITE_SURVEY, - LED_CTL_POWER_OFF, - LED_CTL_START_TO_LINK, - LED_CTL_START_WPS, - LED_CTL_STOP_WPS, - LED_CTL_START_WPS_BOTTON, - LED_CTL_STOP_WPS_FAIL -}; - -enum LED_STATE_871x { - LED_UNKNOWN, - RTW_LED_ON, - RTW_LED_OFF, - LED_BLINK_NORMAL, - LED_BLINK_SLOWLY, - LED_BLINK_POWER_ON, - LED_BLINK_SCAN, - LED_BLINK_TXRX, - LED_BLINK_WPS, - LED_BLINK_WPS_STOP -}; - -struct LED_871x { - struct adapter *padapter; - - enum LED_STATE_871x CurrLedState; /* Current LED state. */ - enum LED_STATE_871x BlinkingLedState; /* Next state for blinking, - * either RTW_LED_ON or RTW_LED_OFF are. - */ - - u8 led_on; /* true if LED is ON, false if LED is OFF. */ - - u8 bLedBlinkInProgress; /* true if it is blinking, false o.w.. */ - - u8 bLedWPSBlinkInProgress; - - u32 BlinkTimes; /* Number of times to toggle led state for blinking. */ - - struct timer_list BlinkTimer; /* Timer object for led blinking. */ - - /* ALPHA, added by chiyoko, 20090106 */ - u8 bLedNoLinkBlinkInProgress; - u8 bLedLinkBlinkInProgress; - u8 bLedScanBlinkInProgress; - struct work_struct BlinkWorkItem; /* Workitem used by BlinkTimer to - * manipulate H/W to blink LED. - */ -}; - -#define IS_LED_WPS_BLINKING(_LED_871x) \ - (((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS || \ - ((struct LED_871x *)_LED_871x)->CurrLedState == LED_BLINK_WPS_STOP || \ - ((struct LED_871x *)_LED_871x)->bLedWPSBlinkInProgress) - -void led_control_8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction); - -struct led_priv { - struct LED_871x sw_led; -}; - -void BlinkWorkItemCallback(struct work_struct *work); - -void ResetLedStatus(struct LED_871x *pLed); - -void InitLed871x(struct adapter *padapter, struct LED_871x *pLed); - -void DeInitLed871x(struct LED_871x *pLed); - -/* hal... */ -void blink_handler(struct LED_871x *pLed); -void sw_led_on(struct adapter *padapter, struct LED_871x *pLed); -void sw_led_off(struct adapter *padapter, struct LED_871x *pLed); - -#endif /* __RTW_LED_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme.h b/drivers/staging/rtl8188eu/include/rtw_mlme.h deleted file mode 100644 index 2f02316906d0..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_mlme.h +++ /dev/null @@ -1,355 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_MLME_H_ -#define __RTW_MLME_H_ - -#include -#include -#include -#include - -#define MAX_BSS_CNT 128 -#define MAX_JOIN_TIMEOUT 6500 - -/* Increase the scanning timeout because of increasing the SURVEY_TO value. */ - -#define SCANNING_TIMEOUT 8000 - -#define SCAN_INTERVAL (30) /* unit:2sec, 30*2=60sec */ - -#define SCANQUEUE_LIFETIME 20 /* unit:sec */ - -#define WIFI_NULL_STATE 0x00000000 - -#define WIFI_ASOC_STATE 0x00000001 /* Under Linked state */ -#define WIFI_REASOC_STATE 0x00000002 -#define WIFI_SLEEP_STATE 0x00000004 -#define WIFI_STATION_STATE 0x00000008 - -#define WIFI_AP_STATE 0x00000010 -#define WIFI_ADHOC_STATE 0x00000020 -#define WIFI_ADHOC_MASTER_STATE 0x00000040 -#define WIFI_UNDER_LINKING 0x00000080 - -#define WIFI_UNDER_WPS 0x00000100 -#define WIFI_STA_ALIVE_CHK_STATE 0x00000400 -#define WIFI_SITE_MONITOR 0x00000800 /* to indicate the station is under site surveying */ - -#define _FW_UNDER_LINKING WIFI_UNDER_LINKING -#define _FW_LINKED WIFI_ASOC_STATE -#define _FW_UNDER_SURVEY WIFI_SITE_MONITOR - -enum dot11AuthAlgrthmNum { - dot11AuthAlgrthm_Open = 0, /* open system */ - dot11AuthAlgrthm_Shared, - dot11AuthAlgrthm_8021X, - dot11AuthAlgrthm_Auto, - dot11AuthAlgrthm_WAPI, - dot11AuthAlgrthm_MaxNum -}; - -/* Scan type including active and passive scan. */ -enum rt_scan_type { - SCAN_PASSIVE, - SCAN_ACTIVE, - SCAN_MIX, -}; - -enum SCAN_RESULT_TYPE { - SCAN_RESULT_P2P_ONLY = 0, /* Will return all the P2P devices. */ - SCAN_RESULT_ALL = 1, /* Will return all the scanned device, - * include AP. - */ - SCAN_RESULT_WFD_TYPE = 2 /* Will just return the correct WFD - * device. - */ - /* If this device is Miracast sink - * device, it will just return all the - * Miracast source devices. - */ -}; - -/* - * there are several "locks" in mlme_priv, - * since mlme_priv is a shared resource between many threads, - * like ISR/Call-Back functions, the OID handlers, and even timer functions. - * - * Each _queue has its own locks, already. - * Other items are protected by mlme_priv.lock. - * - * To avoid possible dead lock, any thread trying to modifiying mlme_priv - * SHALL not lock up more than one lock at a time! - */ - -#define traffic_threshold 10 -#define traffic_scan_period 500 - -struct rt_link_detect { - u32 NumTxOkInPeriod; - u32 NumRxOkInPeriod; - u32 NumRxUnicastOkInPeriod; - bool bBusyTraffic; - bool bTxBusyTraffic; - bool bRxBusyTraffic; - bool bHigherBusyTraffic; /* For interrupt migration purpose. */ - bool bHigherBusyRxTraffic; /* We may disable Tx interrupt according - * to Rx traffic. - */ - bool bHigherBusyTxTraffic; /* We may disable Tx interrupt according - * to Tx traffic. - */ -}; - -struct mlme_priv { - spinlock_t lock; - int fw_state; /* shall we protect this variable? maybe not necessarily... */ - u8 bScanInProcess; - u8 to_join; /* flag */ - u8 to_roaming; /* roaming trying times */ - - struct list_head *pscanned; - struct __queue free_bss_pool; - struct __queue scanned_queue; - u8 *free_bss_buf; - - struct ndis_802_11_ssid assoc_ssid; - u8 assoc_bssid[6]; - - struct wlan_network cur_network; - - u32 scan_interval; - - struct timer_list assoc_timer; - - uint assoc_by_bssid; - - struct timer_list scan_to_timer; /* driver itself handles scan_timeout status. */ - - struct qos_priv qospriv; - - /* Number of non-HT AP/stations */ - int num_sta_no_ht; - - /* Number of HT AP/stations 20 MHz */ - /* int num_sta_ht_20mhz; */ - - int num_FortyMHzIntolerant; - struct ht_priv htpriv; - struct rt_link_detect LinkDetectInfo; - struct timer_list dynamic_chk_timer; /* dynamic/periodic check timer */ - - u8 key_mask; /* use for ips to set wep key after ips_leave */ - u8 acm_mask; /* for wmm acm mask */ - u8 ChannelPlan; - enum rt_scan_type scan_mode; /* active: 1, passive: 0 */ - - /* u8 probereq_wpsie[MAX_WPS_IE_LEN];added in probe req */ - /* int probereq_wpsie_len; */ - u8 *wps_probe_req_ie; - u32 wps_probe_req_ie_len; - - u8 *assoc_req; - u32 assoc_req_len; - u8 *assoc_rsp; - u32 assoc_rsp_len; - -#if defined(CONFIG_88EU_AP_MODE) - /* Number of associated Non-ERP stations (i.e., stations using 802.11b - * in 802.11g BSS) - */ - int num_sta_non_erp; - - /* Number of associated stations that do not support Short Slot Time */ - int num_sta_no_short_slot_time; - - /* Number of associated stations that do not support Short Preamble */ - int num_sta_no_short_preamble; - - int olbc; /* Overlapping Legacy BSS Condition */ - - /* Number of HT assoc sta that do not support greenfield */ - int num_sta_ht_no_gf; - - /* Number of associated non-HT stations */ - /* int num_sta_no_ht; */ - - /* Number of HT associated stations 20 MHz */ - int num_sta_ht_20mhz; - - /* Overlapping BSS information */ - int olbc_ht; - - u16 ht_op_mode; - - u8 *wps_beacon_ie; - /* u8 *wps_probe_req_ie; */ - u8 *wps_probe_resp_ie; - u8 *wps_assoc_resp_ie; - - u32 wps_beacon_ie_len; - u32 wps_probe_resp_ie_len; - u32 wps_assoc_resp_ie_len; - - spinlock_t bcn_update_lock; - u8 update_bcn; -#endif /* if defined (CONFIG_88EU_AP_MODE) */ -}; - -#ifdef CONFIG_88EU_AP_MODE - -struct hostapd_priv { - struct adapter *padapter; -}; - -int hostapd_mode_init(struct adapter *padapter); -void hostapd_mode_unload(struct adapter *padapter); -#endif - -extern const u8 WPA_TKIP_CIPHER[4]; -extern const u8 RSN_TKIP_CIPHER[4]; -extern u8 REALTEK_96B_IE[]; -extern const u8 MCS_rate_1R[16]; - -void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf); -void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf); -void indicate_wx_scan_complete_event(struct adapter *padapter); -void rtw_indicate_wx_assoc_event(struct adapter *padapter); -void rtw_indicate_wx_disassoc_event(struct adapter *padapter); -int event_thread(void *context); -void rtw_free_network_queue(struct adapter *adapter, u8 isfreeall); -int rtw_init_mlme_priv(struct adapter *adapter); -void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv); -int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv); -int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, - int keyid, u8 set_tx); -int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv); - -static inline u8 *get_bssid(struct mlme_priv *pmlmepriv) -{ /* if sta_mode:pmlmepriv->cur_network.network.MacAddress=> bssid */ - /* if adhoc_mode:pmlmepriv->cur_network.network.MacAddress=> ibss mac address */ - return pmlmepriv->cur_network.network.MacAddress; -} - -static inline int check_fwstate(struct mlme_priv *pmlmepriv, int state) -{ - if (pmlmepriv->fw_state & state) - return true; - - return false; -} - -static inline int get_fwstate(struct mlme_priv *pmlmepriv) -{ - return pmlmepriv->fw_state; -} - -/* - * No Limit on the calling context, - * therefore set it to be the critical section... - * - * ### NOTE:#### (!!!!) - * MUST TAKE CARE THAT BEFORE CALLING THIS FUNC, YOU SHOULD HAVE LOCKED pmlmepriv->lock - */ -static inline void set_fwstate(struct mlme_priv *pmlmepriv, int state) -{ - pmlmepriv->fw_state |= state; - /* FOR HW integration */ - if (state == _FW_UNDER_SURVEY) - pmlmepriv->bScanInProcess = true; -} - -static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) -{ - pmlmepriv->fw_state &= ~state; - /* FOR HW integration */ - if (state == _FW_UNDER_SURVEY) - pmlmepriv->bScanInProcess = false; -} - -/* - * No Limit on the calling context, - * therefore set it to be the critical section... - */ -static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state) -{ - spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, state)) - pmlmepriv->fw_state ^= state; - spin_unlock_bh(&pmlmepriv->lock); -} - -static inline void clr_fwstate_ex(struct mlme_priv *pmlmepriv, int state) -{ - spin_lock_bh(&pmlmepriv->lock); - _clr_fwstate_(pmlmepriv, state); - spin_unlock_bh(&pmlmepriv->lock); -} - -u16 rtw_get_capability(struct wlan_bssid_ex *bss); -void rtw_update_scanned_network(struct adapter *adapter, - struct wlan_bssid_ex *target); -void rtw_disconnect_hdl_under_linked(struct adapter *adapter, - struct sta_info *psta, u8 free_assoc); -void rtw_generate_random_ibss(u8 *pibss); -struct wlan_network *rtw_find_network(struct __queue *scanned_queue, u8 *addr); -struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue); - -void rtw_free_assoc_resources(struct adapter *adapter); -void rtw_free_assoc_resources_locked(struct adapter *adapter); -void rtw_indicate_disconnect(struct adapter *adapter); -void rtw_indicate_connect(struct adapter *adapter); -void rtw_indicate_scan_done(struct adapter *padapter, bool aborted); - -int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, - uint in_len); -int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, - uint in_len, uint initial_out_len); -void rtw_init_registrypriv_dev_network(struct adapter *adapter); - -void rtw_update_registrypriv_dev_network(struct adapter *adapter); - -void rtw_get_encrypt_decrypt_from_registrypriv(struct adapter *adapter); - -void _rtw_join_timeout_handler(struct timer_list *t); -void rtw_scan_timeout_handler(struct timer_list *t); - -void rtw_dynamic_check_timer_handlder(struct timer_list *t); -#define rtw_is_scan_deny(adapter) false -#define rtw_clear_scan_deny(adapter) do {} while (0) -#define rtw_set_scan_deny_timer_hdl(adapter) do {} while (0) -#define rtw_set_scan_deny(adapter, ms) do {} while (0) - -void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv); - -struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv); - -int rtw_if_up(struct adapter *padapter); - -u8 *rtw_get_capability_from_ie(u8 *ie); -u8 *rtw_get_beacon_interval_from_ie(u8 *ie); - -void rtw_joinbss_reset(struct adapter *padapter); - -unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, - u8 *out_ie, uint in_len, uint *pout_len); -void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len); -void rtw_issue_addbareq_cmd(struct adapter *padapter, - struct xmit_frame *pxmitframe); - -int rtw_is_same_ibss(struct adapter *adapter, struct wlan_network *pnetwork); -int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst); - -void rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); -void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network); - -void rtw_stassoc_hw_rpt(struct adapter *adapter, struct sta_info *psta); - -#endif /* __RTL871X_MLME_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h b/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h deleted file mode 100644 index c4fcfa986726..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_mlme_ext.h +++ /dev/null @@ -1,680 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_MLME_EXT_H_ -#define __RTW_MLME_EXT_H_ - -#include -#include -#include - -/* Commented by Albert 20101105 */ -/* Increase the SURVEY_TO value from 100 to 150 ( 100ms to 150ms ) */ -/* The Realtek 8188CE SoftAP will spend around 100ms to send the probe response after receiving the probe request. */ -/* So, this driver tried to extend the dwell time for each scanning channel. */ -/* This will increase the chance to receive the probe response from SoftAP. */ - -#define SURVEY_TO (100) -#define REAUTH_TO (300) /* 50) */ -#define REASSOC_TO (300) /* 50) */ -/* define DISCONNECT_TO (3000) */ -#define ADDBA_TO (2000) - -#define LINKED_TO (1) /* unit:2 sec, 1x2=2 sec */ - -#define REAUTH_LIMIT (4) -#define REASSOC_LIMIT (4) -#define READDBA_LIMIT (2) - -#define ROAMING_LIMIT 8 - -#define DYNAMIC_FUNC_DISABLE (0x0) - -/* ====== ODM_ABILITY_E ======== */ -/* BB ODM section BIT 0-15 */ -#define DYNAMIC_BB_DIG BIT(0) -#define DYNAMIC_BB_RA_MASK BIT(1) -#define DYNAMIC_BB_DYNAMIC_TXPWR BIT(2) -#define DYNAMIC_BB_BB_FA_CNT BIT(3) - -#define DYNAMIC_BB_RSSI_MONITOR BIT(4) -#define DYNAMIC_BB_CCK_PD BIT(5) -#define DYNAMIC_BB_ANT_DIV BIT(6) -#define DYNAMIC_BB_PWR_SAVE BIT(7) -#define DYNAMIC_BB_PWR_TRA BIT(8) -#define DYNAMIC_BB_RATE_ADAPTIVE BIT(9) -#define DYNAMIC_BB_PATH_DIV BIT(10) -#define DYNAMIC_BB_PSD BIT(11) - -/* MAC DM section BIT 16-23 */ -#define DYNAMIC_MAC_EDCA_TURBO BIT(16) -#define DYNAMIC_MAC_EARLY_MODE BIT(17) - -/* RF ODM section BIT 24-31 */ -#define DYNAMIC_RF_TX_PWR_TRACK BIT(24) -#define DYNAMIC_RF_RX_GAIN_TRACK BIT(25) -#define DYNAMIC_RF_CALIBRATION BIT(26) - -#define DYNAMIC_ALL_FUNC_ENABLE 0xFFFFFFF - -#define _HW_STATE_NOLINK_ 0x00 -#define _HW_STATE_ADHOC_ 0x01 -#define _HW_STATE_STATION_ 0x02 -#define _HW_STATE_AP_ 0x03 - -#define _1M_RATE_ 0 -#define _2M_RATE_ 1 -#define _5M_RATE_ 2 -#define _11M_RATE_ 3 -#define _6M_RATE_ 4 -#define _9M_RATE_ 5 -#define _12M_RATE_ 6 -#define _18M_RATE_ 7 -#define _24M_RATE_ 8 -#define _36M_RATE_ 9 -#define _48M_RATE_ 10 -#define _54M_RATE_ 11 - -extern const u8 RTW_WPA_OUI[]; -extern const u8 WPS_OUI[]; - -/* Channel Plan Type. */ -/* Note: */ -/* We just add new channel plan when the new channel plan is different - * from any of the following channel plan. - */ -/* If you just want to customize the actions(scan period or join actions) - * about one of the channel plan, - */ -/* customize them in struct rt_channel_info in the RT_CHANNEL_LIST. */ -enum RT_CHANNEL_DOMAIN { - /* old channel plan mapping ===== */ - RT_CHANNEL_DOMAIN_FCC = 0x00, - RT_CHANNEL_DOMAIN_IC = 0x01, - RT_CHANNEL_DOMAIN_ETSI = 0x02, - RT_CHANNEL_DOMAIN_SPAIN = 0x03, - RT_CHANNEL_DOMAIN_FRANCE = 0x04, - RT_CHANNEL_DOMAIN_MKK = 0x05, - RT_CHANNEL_DOMAIN_MKK1 = 0x06, - RT_CHANNEL_DOMAIN_ISRAEL = 0x07, - RT_CHANNEL_DOMAIN_TELEC = 0x08, - RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN = 0x09, - RT_CHANNEL_DOMAIN_WORLD_WIDE_13 = 0x0A, - RT_CHANNEL_DOMAIN_TAIWAN = 0x0B, - RT_CHANNEL_DOMAIN_CHINA = 0x0C, - RT_CHANNEL_DOMAIN_SINGAPORE_INDIA_MEXICO = 0x0D, - RT_CHANNEL_DOMAIN_KOREA = 0x0E, - RT_CHANNEL_DOMAIN_TURKEY = 0x0F, - RT_CHANNEL_DOMAIN_JAPAN = 0x10, - RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11, - RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12, - RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13, - RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14, - - /* new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */ - RT_CHANNEL_DOMAIN_WORLD_NULL = 0x20, - RT_CHANNEL_DOMAIN_ETSI1_NULL = 0x21, - RT_CHANNEL_DOMAIN_FCC1_NULL = 0x22, - RT_CHANNEL_DOMAIN_MKK1_NULL = 0x23, - RT_CHANNEL_DOMAIN_ETSI2_NULL = 0x24, - RT_CHANNEL_DOMAIN_FCC1_FCC1 = 0x25, - RT_CHANNEL_DOMAIN_WORLD_ETSI1 = 0x26, - RT_CHANNEL_DOMAIN_MKK1_MKK1 = 0x27, - RT_CHANNEL_DOMAIN_WORLD_KCC1 = 0x28, - RT_CHANNEL_DOMAIN_WORLD_FCC2 = 0x29, - RT_CHANNEL_DOMAIN_WORLD_FCC3 = 0x30, - RT_CHANNEL_DOMAIN_WORLD_FCC4 = 0x31, - RT_CHANNEL_DOMAIN_WORLD_FCC5 = 0x32, - RT_CHANNEL_DOMAIN_WORLD_FCC6 = 0x33, - RT_CHANNEL_DOMAIN_FCC1_FCC7 = 0x34, - RT_CHANNEL_DOMAIN_WORLD_ETSI2 = 0x35, - RT_CHANNEL_DOMAIN_WORLD_ETSI3 = 0x36, - RT_CHANNEL_DOMAIN_MKK1_MKK2 = 0x37, - RT_CHANNEL_DOMAIN_MKK1_MKK3 = 0x38, - RT_CHANNEL_DOMAIN_FCC1_NCC1 = 0x39, - RT_CHANNEL_DOMAIN_FCC1_NCC2 = 0x40, - RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G = 0x41, - /* Add new channel plan above this line=============== */ - RT_CHANNEL_DOMAIN_MAX, - RT_CHANNEL_DOMAIN_REALTEK_DEFINE = 0x7F, -}; - -enum RT_CHANNEL_DOMAIN_2G { - RT_CHANNEL_DOMAIN_2G_WORLD = 0x00, /* Worldwide 13 */ - RT_CHANNEL_DOMAIN_2G_ETSI1 = 0x01, /* Europe */ - RT_CHANNEL_DOMAIN_2G_FCC1 = 0x02, /* US */ - RT_CHANNEL_DOMAIN_2G_MKK1 = 0x03, /* Japan */ - RT_CHANNEL_DOMAIN_2G_ETSI2 = 0x04, /* France */ - RT_CHANNEL_DOMAIN_2G_NULL = 0x05, - /* Add new channel plan above this line=============== */ - RT_CHANNEL_DOMAIN_2G_MAX, -}; - -#define rtw_is_channel_plan_valid(chplan) \ - (chplan < RT_CHANNEL_DOMAIN_MAX || \ - chplan == RT_CHANNEL_DOMAIN_REALTEK_DEFINE) - -struct rt_channel_plan { - unsigned char Channel[MAX_CHANNEL_NUM]; - unsigned char Len; -}; - -struct rt_channel_plan_2g { - unsigned char Channel[MAX_CHANNEL_NUM_2G]; - unsigned char Len; -}; - -struct rt_channel_plan_map { - unsigned char Index2G; -}; - -enum Associated_AP { - atherosAP = 0, - broadcomAP = 1, - ciscoAP = 2, - marvellAP = 3, - ralinkAP = 4, - realtekAP = 5, - airgocapAP = 6, - unknownAP = 7, - maxAP, -}; - -enum HT_IOT_PEER { - HT_IOT_PEER_UNKNOWN = 0, - HT_IOT_PEER_REALTEK = 1, - HT_IOT_PEER_REALTEK_92SE = 2, - HT_IOT_PEER_BROADCOM = 3, - HT_IOT_PEER_RALINK = 4, - HT_IOT_PEER_ATHEROS = 5, - HT_IOT_PEER_CISCO = 6, - HT_IOT_PEER_MERU = 7, - HT_IOT_PEER_MARVELL = 8, - HT_IOT_PEER_REALTEK_SOFTAP = 9,/* peer is RealTek SOFT_AP */ - HT_IOT_PEER_SELF_SOFTAP = 10, /* Self is SoftAP */ - HT_IOT_PEER_AIRGO = 11, - HT_IOT_PEER_INTEL = 12, - HT_IOT_PEER_RTK_APCLIENT = 13, - HT_IOT_PEER_REALTEK_81XX = 14, - HT_IOT_PEER_REALTEK_WOW = 15, - HT_IOT_PEER_TENDA = 16, - HT_IOT_PEER_MAX = 17 -}; - -enum SCAN_STATE { - SCAN_DISABLE = 0, - SCAN_START = 1, - SCAN_TXNULL = 2, - SCAN_PROCESS = 3, - SCAN_COMPLETE = 4, - SCAN_STATE_MAX, -}; - -struct mlme_handler { - unsigned int num; - const char *str; - unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); -}; - -struct action_handler { - unsigned int num; - const char *str; - unsigned int (*func)(struct adapter *adapt, struct recv_frame *frame); -}; - -struct ss_res { - int state; - int bss_cnt; - int channel_idx; - int scan_mode; - u8 ssid_num; - u8 ch_num; - struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; - struct rtw_ieee80211_channel ch[RTW_CHANNEL_SCAN_AMOUNT]; -}; - -/* define AP_MODE 0x0C */ -/* define STATION_MODE 0x08 */ -/* define AD_HOC_MODE 0x04 */ -/* define NO_LINK_MODE 0x00 */ - -#define WIFI_FW_NULL_STATE _HW_STATE_NOLINK_ -#define WIFI_FW_STATION_STATE _HW_STATE_STATION_ -#define WIFI_FW_AP_STATE _HW_STATE_AP_ -#define WIFI_FW_ADHOC_STATE _HW_STATE_ADHOC_ - -#define WIFI_FW_AUTH_NULL 0x00000100 -#define WIFI_FW_AUTH_STATE 0x00000200 -#define WIFI_FW_AUTH_SUCCESS 0x00000400 - -#define WIFI_FW_ASSOC_STATE 0x00002000 -#define WIFI_FW_ASSOC_SUCCESS 0x00004000 - -#define WIFI_FW_LINKING_STATE (WIFI_FW_AUTH_NULL | \ - WIFI_FW_AUTH_STATE | \ - WIFI_FW_AUTH_SUCCESS | \ - WIFI_FW_ASSOC_STATE) - -struct FW_Sta_Info { - struct sta_info *psta; - u32 status; - u32 rx_pkt; - u32 retry; - unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; -}; - -/* - * Usage: - * When one iface acted as AP mode and the other iface is STA mode and scanning, - * it should switch back to AP's operating channel periodically. - * Parameters info: - * When the driver scanned RTW_SCAN_NUM_OF_CH channels, it would switch back to - * AP's operating channel for - * RTW_STAY_AP_CH_MILLISECOND * SURVEY_TO milliseconds. - * Example: - * For chip supports 2.4G + 5GHz and AP mode is operating in channel 1, - * RTW_SCAN_NUM_OF_CH is 8, RTW_STAY_AP_CH_MS is 3 and SURVEY_TO is 100. - * When it's STA mode gets set_scan command, - * it would - * 1. Doing the scan on channel 1.2.3.4.5.6.7.8 - * 2. Back to channel 1 for 300 milliseconds - * 3. Go through doing site survey on channel 9.10.11.36.40.44.48.52 - * 4. Back to channel 1 for 300 milliseconds - * 5. ... and so on, till survey done. - */ - -struct mlme_ext_info { - u32 state; - u32 reauth_count; - u32 reassoc_count; - u32 link_count; - u32 auth_seq; - u32 auth_algo; /* 802.11 auth, could be open, shared, auto */ - u32 authModeToggle; - u32 enc_algo;/* encrypt algorithm; */ - u32 key_index; /* this is only valid for legacy wep, - * 0~3 for key id. - */ - u32 iv; - u8 chg_txt[128]; - u16 aid; - u16 bcn_interval; - u16 capability; - u8 assoc_AP_vendor; - u8 slotTime; - u8 preamble_mode; - u8 WMM_enable; - u8 ERP_enable; - u8 ERP_IE; - u8 HT_enable; - u8 HT_caps_enable; - u8 HT_info_enable; - u8 HT_protection; - u8 turboMode_cts2self; - u8 turboMode_rtsen; - u8 SM_PS; - u8 agg_enable_bitmap; - u8 ADDBA_retry_count; - u8 candidate_tid_bitmap; - u8 dialogToken; - /* Accept ADDBA Request */ - bool accept_addba_req; - u8 bwmode_updated; - u8 hidden_ssid_mode; - - struct ADDBA_request ADDBA_req; - struct WMM_para_element WMM_param; - struct ieee80211_ht_cap HT_caps; - struct HT_info_element HT_info; - struct wlan_bssid_ex network;/* join network or bss_network, - * if in ap mode, it is the same - * as cur_network.network - */ - struct FW_Sta_Info FW_sta_info[NUM_STA]; -}; - -/* The channel information about this channel including joining, - * scanning, and power constraints. - */ -struct rt_channel_info { - u8 ChannelNum; /* The channel number. */ - enum rt_scan_type ScanType; /* Scan type such as passive - * or active scan. - */ - u32 rx_count; -}; - -int rtw_ch_set_search_ch(struct rt_channel_info *ch_set, const u32 ch); - -/* P2P_MAX_REG_CLASSES - Maximum number of regulatory classes */ -#define P2P_MAX_REG_CLASSES 10 - -/* P2P_MAX_REG_CLASS_CHANNELS - Maximum number of chan per regulatory class */ -#define P2P_MAX_REG_CLASS_CHANNELS 20 - -/* struct p2p_channels - List of supported channels */ -struct p2p_channels { - /* struct p2p_reg_class - Supported regulatory class */ - struct p2p_reg_class { - /* reg_class - Regulatory class (IEEE 802.11-2007, Annex J) */ - u8 reg_class; - - /* channel - Supported channels */ - u8 channel[P2P_MAX_REG_CLASS_CHANNELS]; - - /* channels - Number of channel entries in use */ - size_t channels; - } reg_class[P2P_MAX_REG_CLASSES]; - - /* reg_classes - Number of reg_class entries in use */ - size_t reg_classes; -}; - -struct p2p_oper_class_map { - enum hw_mode {IEEE80211G} mode; - u8 op_class; - u8 min_chan; - u8 max_chan; - u8 inc; - enum {BW20, BW40PLUS, BW40MINUS} bw; -}; - -struct mlme_ext_priv { - u8 mlmeext_init; - atomic_t event_seq; - u16 mgnt_seq; - - unsigned char cur_channel; - unsigned char cur_bwmode; - unsigned char cur_ch_offset;/* PRIME_CHNL_OFFSET */ - unsigned char cur_wireless_mode; /* NETWORK_TYPE */ - - unsigned char oper_channel; /* saved chan info when call - * set_channel_bw - */ - unsigned char oper_bwmode; - unsigned char oper_ch_offset;/* PRIME_CHNL_OFFSET */ - - unsigned char max_chan_nums; - struct rt_channel_info channel_set[MAX_CHANNEL_NUM]; - struct p2p_channels channel_list; - unsigned char basicrate[NumRates]; - unsigned char datarate[NumRates]; - - struct ss_res sitesurvey_res; - struct mlme_ext_info mlmext_info;/* for sta/adhoc mode, including - * current scan/connecting/connected - * related info. For ap mode, - * network includes ap's cap_info - */ - struct timer_list survey_timer; - struct timer_list link_timer; - u16 chan_scan_time; - - u8 scan_abort; - u8 tx_rate; /* TXRATE when USERATE is set. */ - - u32 retry; /* retry for issue probereq */ - - u64 TSFValue; - -#ifdef CONFIG_88EU_AP_MODE - unsigned char bstart_bss; -#endif - u8 update_channel_plan_by_ap_done; - /* recv_decache check for Action_public frame */ - u8 action_public_dialog_token; - u16 action_public_rxseq; - u8 active_keep_alive_check; -}; - -int init_mlme_ext_priv(struct adapter *adapter); -int init_hw_mlme_ext(struct adapter *padapter); -void free_mlme_ext_priv(struct mlme_ext_priv *pmlmeext); -void init_mlme_ext_timer(struct adapter *padapter); -void init_addba_retry_timer(struct adapter *adapt, struct sta_info *sta); -struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv); - -unsigned char networktype_to_raid(unsigned char network_type); -u8 judge_network_type(struct adapter *padapter, unsigned char *rate); -void get_rate_set(struct adapter *padapter, unsigned char *pbssrate, int *len); -void UpdateBrateTbl(struct adapter *padapter, u8 *mBratesOS); -void UpdateBrateTblForSoftAP(u8 *bssrateset, u32 bssratelen); - -void Save_DM_Func_Flag(struct adapter *padapter); -void Restore_DM_Func_Flag(struct adapter *padapter); -void Switch_DM_Func(struct adapter *padapter, u32 mode, u8 enable); - -void Set_MSR(struct adapter *padapter, u8 type); - -u8 rtw_get_oper_ch(struct adapter *adapter); -void rtw_set_oper_ch(struct adapter *adapter, u8 ch); -void rtw_set_oper_bw(struct adapter *adapter, u8 bw); -void rtw_set_oper_choffset(struct adapter *adapter, u8 offset); - -void set_channel_bwmode(struct adapter *padapter, unsigned char channel, - unsigned char channel_offset, unsigned short bwmode); -void SelectChannel(struct adapter *padapter, unsigned char channel); -void SetBWMode(struct adapter *padapter, unsigned short bwmode, - unsigned char channel_offset); - -unsigned int decide_wait_for_beacon_timeout(unsigned int bcn_interval); - -void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key); -void clear_cam_entry(struct adapter *padapter, u8 entry); - -void invalidate_cam_all(struct adapter *padapter); - -int allocate_fw_sta_entry(struct adapter *padapter); -void flush_all_cam_entry(struct adapter *padapter); - -void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, - struct adapter *adapter, bool update_ie); - -u16 get_beacon_interval(struct wlan_bssid_ex *bss); - -int is_client_associated_to_ap(struct adapter *padapter); -int is_client_associated_to_ibss(struct adapter *padapter); -int is_IBSS_empty(struct adapter *padapter); - -unsigned char check_assoc_AP(u8 *pframe, uint len); - -int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); -void WMMOnAssocRsp(struct adapter *padapter); - -void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); -void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); -void HTOnAssocRsp(struct adapter *padapter); - -void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE); -void VCS_update(struct adapter *padapter, struct sta_info *psta); - -void update_beacon_info(struct adapter *padapter, u8 *pframe, uint len, - struct sta_info *psta); -int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len); -void update_IOT_info(struct adapter *padapter); -void update_capinfo(struct adapter *adapter, u16 updatecap); -void update_wireless_mode(struct adapter *padapter); -void update_tx_basic_rate(struct adapter *padapter, u8 modulation); -void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id); -int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, - uint var_ie_len, int cam_idx); - -/* for sta/adhoc mode */ -void update_sta_info(struct adapter *padapter, struct sta_info *psta); -unsigned int update_basic_rate(unsigned char *ptn, unsigned int ptn_sz); -unsigned int update_supported_rate(unsigned char *ptn, unsigned int ptn_sz); -unsigned int update_MSC_rate(struct ieee80211_ht_cap *pHT_caps); -void Update_RA_Entry(struct adapter *padapter, u32 mac_id); -void set_sta_rate(struct adapter *padapter, struct sta_info *psta); - -unsigned char get_highest_rate_idx(u32 mask); -int support_short_GI(struct adapter *padapter, struct ieee80211_ht_cap *caps); -unsigned int is_ap_in_tkip(struct adapter *padapter); - -void report_join_res(struct adapter *padapter, int res); -void report_survey_event(struct adapter *padapter, - struct recv_frame *precv_frame); -void report_surveydone_event(struct adapter *padapter); -void report_del_sta_event(struct adapter *padapter, - unsigned char *addr, unsigned short reason); -void report_add_sta_event(struct adapter *padapter, unsigned char *addr, - int cam_idx); - -u8 set_tx_beacon_cmd(struct adapter *padapter); -unsigned int setup_beacon_frame(struct adapter *padapter, - unsigned char *beacon_frame); -void update_mgnt_tx_rate(struct adapter *padapter, u8 rate); -void update_mgntframe_attrib(struct adapter *padapter, - struct pkt_attrib *pattrib); - -int issue_nulldata(struct adapter *padapter, unsigned char *da, - unsigned int power_mode, int try_cnt, int wait_ms); -int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, - u16 tid, int try_cnt, int wait_ms); -int issue_deauth(struct adapter *padapter, unsigned char *da, - unsigned short reason); -unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr); -unsigned int send_beacon(struct adapter *padapter); - -void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res); -void mlmeext_sta_del_event_callback(struct adapter *padapter); -void mlmeext_sta_add_event_callback(struct adapter *padapter, - struct sta_info *psta); - -void linked_status_chk(struct adapter *padapter); - -void survey_timer_hdl(struct timer_list *t); -void link_timer_hdl(struct timer_list *t); -void addba_timer_hdl(struct timer_list *t); - -#define set_survey_timer(mlmeext, ms) \ - mod_timer(&mlmeext->survey_timer, jiffies + \ - msecs_to_jiffies(ms)) - -#define set_link_timer(mlmeext, ms) \ - mod_timer(&mlmeext->link_timer, jiffies + \ - msecs_to_jiffies(ms)) - -void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr); - -void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len); -void correct_TSF(struct adapter *padapter, struct mlme_ext_priv *pmlmeext); - -struct cmd_hdl { - uint parmsize; - u8 (*h2cfuns)(struct adapter *padapter, u8 *pbuf); -}; - -u8 read_macreg_hdl(struct adapter *padapter, u8 *pbuf); -u8 write_macreg_hdl(struct adapter *padapter, u8 *pbuf); -u8 read_bbreg_hdl(struct adapter *padapter, u8 *pbuf); -u8 write_bbreg_hdl(struct adapter *padapter, u8 *pbuf); -u8 read_rfreg_hdl(struct adapter *padapter, u8 *pbuf); -u8 write_rfreg_hdl(struct adapter *padapter, u8 *pbuf); -u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf); -u8 disconnect_hdl(struct adapter *padapter, u8 *pbuf); -u8 createbss_hdl(struct adapter *padapter, u8 *pbuf); -u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf); -u8 sitesurvey_cmd_hdl(struct adapter *padapter, u8 *pbuf); -u8 setauth_hdl(struct adapter *padapter, u8 *pbuf); -u8 setkey_hdl(struct adapter *padapter, u8 *pbuf); -u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf); -u8 set_assocsta_hdl(struct adapter *padapter, u8 *pbuf); -u8 del_assocsta_hdl(struct adapter *padapter, u8 *pbuf); -u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf); - -u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf); -u8 h2c_msg_hdl(struct adapter *padapter, unsigned char *pbuf); -u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf); -u8 set_ch_hdl(struct adapter *padapter, u8 *pbuf); -u8 set_chplan_hdl(struct adapter *padapter, unsigned char *pbuf); -u8 led_blink_hdl(struct adapter *padapter, unsigned char *pbuf); -/* Handling DFS channel switch announcement ie. */ -u8 set_csa_hdl(struct adapter *padapter, unsigned char *pbuf); -u8 tdls_hdl(struct adapter *padapter, unsigned char *pbuf); - -struct C2HEvent_Header { -#ifdef __LITTLE_ENDIAN - unsigned int len:16; - unsigned int ID:8; - unsigned int seq:8; -#elif defined(__BIG_ENDIAN) - unsigned int seq:8; - unsigned int ID:8; - unsigned int len:16; -#endif - unsigned int rsvd; -}; - -void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_fwdbg_event_callback(struct adapter *adapter, u8 *pbuf); - -enum rtw_c2h_event { - _Read_MACREG_EVT_ = 0, /*0*/ - _Read_BBREG_EVT_, - _Read_RFREG_EVT_, - _Read_EEPROM_EVT_, - _Read_EFUSE_EVT_, - _Read_CAM_EVT_, /*5*/ - _Get_BasicRate_EVT_, - _Get_DataRate_EVT_, - _Survey_EVT_, /*8*/ - _SurveyDone_EVT_, /*9*/ - - _JoinBss_EVT_, /*10*/ - _AddSTA_EVT_, - _DelSTA_EVT_, - _AtimDone_EVT_, - _TX_Report_EVT_, - _CCX_Report_EVT_, /*15*/ - _DTM_Report_EVT_, - _TX_Rate_Statistics_EVT_, - _C2HLBK_EVT_, - _FWDBG_EVT_, - _C2HFEEDBACK_EVT_, /*20*/ - _ADDBA_EVT_, - _C2HBCN_EVT_, - _ReportPwrState_EVT_, /* filen: only for PCIE, USB */ - _CloseRF_EVT_, /* filen: only for PCIE, - * work around ASPM - */ - MAX_C2HEVT -}; - -#ifdef _RTW_MLME_EXT_C_ - -static struct fwevent wlanevents[] = { - {0, rtw_dummy_event_callback}, /*0*/ - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, &rtw_survey_event_callback}, /*8*/ - {sizeof(struct surveydone_event), &rtw_surveydone_event_callback},/*9*/ - {0, &rtw_joinbss_event_callback}, /*10*/ - {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, - {sizeof(struct stadel_event), &rtw_stadel_event_callback}, - {0, NULL}, - {0, rtw_dummy_event_callback}, - {0, NULL}, /*15*/ - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, rtw_fwdbg_event_callback}, - {0, NULL}, /*20*/ - {0, NULL}, - {0, NULL}, - {0, NULL}, - {0, NULL}, -}; - -#endif/* _RTL_MLME_EXT_C_ */ - -#endif /* __RTW_MLME_EXT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h b/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h deleted file mode 100644 index 78febd3605c7..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_pwrctrl.h +++ /dev/null @@ -1,244 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_PWRCTRL_H_ -#define __RTW_PWRCTRL_H_ - -#include -#include - -#define FW_PWR0 0 -#define FW_PWR1 1 -#define FW_PWR2 2 -#define FW_PWR3 3 -#define HW_PWR0 7 -#define HW_PWR1 6 -#define HW_PWR2 2 -#define HW_PWR3 0 -#define HW_PWR4 8 - -#define FW_PWRMSK 0x7 - -#define XMIT_ALIVE BIT(0) -#define RECV_ALIVE BIT(1) -#define CMD_ALIVE BIT(2) -#define EVT_ALIVE BIT(3) - -enum power_mgnt { - PS_MODE_ACTIVE = 0, - PS_MODE_MIN, - PS_MODE_MAX, - PS_MODE_DTIM, - PS_MODE_VOIP, - PS_MODE_UAPSD_WMM, - PS_MODE_UAPSD, - PS_MODE_IBSS, - PS_MODE_WWLAN, - PM_Radio_Off, - PM_Card_Disable, - PS_MODE_NUM -}; - -/* - * BIT[2:0] = HW state - * BIT[3] = Protocol PS state, 0: register active state, - * 1: register sleep state - * BIT[4] = sub-state - */ - -#define PS_DPS BIT(0) -#define PS_LCLK (PS_DPS) -#define PS_RF_OFF BIT(1) -#define PS_ALL_ON BIT(2) -#define PS_ST_ACTIVE BIT(3) - -#define PS_ISR_ENABLE BIT(4) -#define PS_IMR_ENABLE BIT(5) -#define PS_ACK BIT(6) -#define PS_TOGGLE BIT(7) - -#define PS_STATE_MASK (0x0F) -#define PS_STATE_HW_MASK (0x07) -#define PS_SEQ_MASK (0xc0) - -#define PS_STATE(x) (PS_STATE_MASK & (x)) -#define PS_STATE_HW(x) (PS_STATE_HW_MASK & (x)) -#define PS_SEQ(x) (PS_SEQ_MASK & (x)) - -#define PS_STATE_S0 (PS_DPS) -#define PS_STATE_S1 (PS_LCLK) -#define PS_STATE_S2 (PS_RF_OFF) -#define PS_STATE_S3 (PS_ALL_ON) -#define PS_STATE_S4 ((PS_ST_ACTIVE) | (PS_ALL_ON)) - -#define PS_IS_RF_ON(x) ((x) & (PS_ALL_ON)) -#define PS_IS_ACTIVE(x) ((x) & (PS_ST_ACTIVE)) -#define CLR_PS_STATE(x) ((x) = ((x) & (0xF0))) - -struct reportpwrstate_parm { - unsigned char mode; - unsigned char state; /* the CPWM value */ - unsigned short rsvd; -}; - -#define LPS_DELAY_TIME 1 * HZ /* 1 sec */ - -#define EXE_PWR_NONE 0x01 -#define EXE_PWR_IPS 0x02 -#define EXE_PWR_LPS 0x04 - -/* RF state. */ -enum rt_rf_power_state { - rf_on, /* RF is on after RFSleep or RFOff */ - rf_sleep, /* 802.11 Power Save mode */ - rf_off, /* HW/SW Radio OFF or Inactive Power Save */ - /* Add the new RF state above this line===== */ - rf_max -}; - -/* RF Off Level for IPS or HW/SW radio off */ -#define RT_RF_OFF_LEVL_ASPM BIT(0) /* PCI ASPM */ -#define RT_RF_OFF_LEVL_CLK_REQ BIT(1) /* PCI clock request */ -#define RT_RF_OFF_LEVL_PCI_D3 BIT(2) /* PCI D3 mode */ -#define RT_RF_OFF_LEVL_HALT_NIC BIT(3) /* NIC halt, re-init hw param*/ -#define RT_RF_OFF_LEVL_FREE_FW BIT(4) /* FW free, re-download the FW*/ -#define RT_RF_OFF_LEVL_FW_32K BIT(5) /* FW in 32k */ -#define RT_RF_PS_LEVEL_ALWAYS_ASPM BIT(6) /* Always enable ASPM and Clock - * Req in initialization. - */ -#define RT_RF_LPS_DISALBE_2R BIT(30) /* When LPS is on, disable 2R - * if no packet is RX or TX. - */ -#define RT_RF_LPS_LEVEL_ASPM BIT(31) /* LPS with ASPM */ - -#define RT_IN_PS_LEVEL(ppsc, _PS_FLAG) \ - ((ppsc->cur_ps_level & _PS_FLAG) ? true : false) -#define RT_CLEAR_PS_LEVEL(ppsc, _PS_FLAG) \ - (ppsc->cur_ps_level &= (~(_PS_FLAG))) -#define RT_SET_PS_LEVEL(ppsc, _PS_FLAG) \ - (ppsc->cur_ps_level |= _PS_FLAG) - -enum _PS_BBRegBackup_ { - PSBBREG_RF0 = 0, - PSBBREG_RF1, - PSBBREG_RF2, - PSBBREG_AFE0, - PSBBREG_TOTALCNT -}; - -enum { /* for ips_mode */ - IPS_NONE = 0, - IPS_NORMAL, - IPS_LEVEL_2, -}; - -struct pwrctrl_priv { - struct mutex mutex_lock; - volatile u8 rpwm; /* requested power state for fw */ - volatile u8 cpwm; /* fw current power state. updated when - * 1. read from HCPWM 2. driver lowers power level - */ - volatile u8 tog; /* toggling */ - volatile u8 cpwm_tog; /* toggling */ - - u8 pwr_mode; - u8 smart_ps; - u8 bcn_ant_mode; - - u32 alives; - struct work_struct cpwm_event; - u8 bpower_saving; - - u8 b_hw_radio_off; - u8 reg_rfoff; - u8 reg_pdnmode; /* powerdown mode */ - u32 rfoff_reason; - - /* RF OFF Level */ - u32 cur_ps_level; - u32 reg_rfps_level; - uint ips_enter_cnts; - uint ips_leave_cnts; - - u8 ips_mode; - u8 ips_mode_req; /* used to accept the mode setting request, - * will update to ipsmode later - */ - uint bips_processing; - unsigned long ips_deny_time; /* will deny IPS when system time less than this */ - u8 ps_processing; /* temp used to mark whether in rtw_ps_processor */ - - bool bLeisurePs; - u8 LpsIdleCount; - u8 power_mgnt; - u32 DelayLPSLastTimeStamp; - u8 btcoex_rfon; - s32 pnp_current_pwr_state; - u8 pnp_bstop_trx; - - u8 bInternalAutoSuspend; - u8 bInSuspend; - u8 bSupportRemoteWakeup; - struct timer_list pwr_state_check_timer; - int pwr_state_check_interval; - u8 pwr_state_check_cnts; - - int ps_flag; - - enum rt_rf_power_state rf_pwrstate;/* cur power state */ - enum rt_rf_power_state change_rfpwrstate; - - u8 wepkeymask; - u8 bHWPowerdown;/* if support hw power down */ - u8 bHWPwrPindetect; - u8 bkeepfwalive; - u8 brfoffbyhw; - unsigned long PS_BBRegBackup[PSBBREG_TOTALCNT]; -}; - -#define rtw_get_ips_mode_req(pwrctrlpriv) \ - (pwrctrlpriv)->ips_mode_req - -#define rtw_ips_mode_req(pwrctrlpriv, ips_mode) \ - ((pwrctrlpriv)->ips_mode_req = (ips_mode)) - -#define RTW_PWR_STATE_CHK_INTERVAL 2000 - -#define _rtw_set_pwr_state_check_timer(pwrctrlpriv, ms) \ - mod_timer(&pwrctrlpriv->pwr_state_check_timer, \ - jiffies + msecs_to_jiffies(ms)) - -#define rtw_set_pwr_state_check_timer(pwrctrl) \ - _rtw_set_pwr_state_check_timer((pwrctrl), \ - (pwrctrl)->pwr_state_check_interval) - -void rtw_init_pwrctrl_priv(struct adapter *adapter); - -void rtw_set_ps_mode(struct adapter *adapter, u8 ps_mode, u8 smart_ps, - u8 bcn_ant_mode); -void rtw_set_rpwm(struct adapter *adapter, u8 val8); -void LeaveAllPowerSaveMode(struct adapter *adapter); -void ips_enter(struct adapter *padapter); -int ips_leave(struct adapter *padapter); - -void rtw_ps_processor(struct adapter *padapter); - -enum rt_rf_power_state RfOnOffDetect(struct adapter *iadapter); - -s32 LPS_RF_ON_check(struct adapter *adapter, u32 delay_ms); -void LPS_Enter(struct adapter *adapter); -void LPS_Leave(struct adapter *adapter); - -int _rtw_pwr_wakeup(struct adapter *adapter, u32 ips_defer_ms, - const char *caller); -#define rtw_pwr_wakeup(adapter) \ - _rtw_pwr_wakeup(adapter, RTW_PWR_STATE_CHK_INTERVAL, __func__) -#define rtw_pwr_wakeup_ex(adapter, ips_deffer_ms) \ - _rtw_pwr_wakeup(adapter, ips_deffer_ms, __func__) -int rtw_pm_set_ips(struct adapter *adapter, u8 mode); -int rtw_pm_set_lps(struct adapter *adapter, u8 mode); - -#endif /* __RTL871X_PWRCTRL_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h deleted file mode 100644 index 8c906b666b62..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_recv.h +++ /dev/null @@ -1,262 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_RECV_H_ -#define _RTW_RECV_H_ - -#include -#include - -#define NR_RECVFRAME 256 - -#define RXFRAME_ALIGN 8 -#define RXFRAME_ALIGN_SZ (1 << RXFRAME_ALIGN) - -#define MAX_RXFRAME_CNT 512 -#define MAX_RX_NUMBLKS (32) -#define RECVFRAME_HDR_ALIGN 128 - -#define SNAP_SIZE sizeof(struct ieee80211_snap_hdr) - -#define MAX_SUBFRAME_COUNT 64 - -/* for Rx reordering buffer control */ -struct recv_reorder_ctrl { - struct adapter *padapter; - bool enable; - u16 indicate_seq;/* wstart_b, init_value=0xffff */ - u16 wend_b; - u8 wsize_b; - struct __queue pending_recvframe_queue; - struct timer_list reordering_ctrl_timer; -}; - -struct stainfo_rxcache { - u16 tid_rxseq[16]; -/* - * unsigned short tid0_rxseq; - * unsigned short tid1_rxseq; - * unsigned short tid2_rxseq; - * unsigned short tid3_rxseq; - * unsigned short tid4_rxseq; - * unsigned short tid5_rxseq; - * unsigned short tid6_rxseq; - * unsigned short tid7_rxseq; - * unsigned short tid8_rxseq; - * unsigned short tid9_rxseq; - * unsigned short tid10_rxseq; - * unsigned short tid11_rxseq; - * unsigned short tid12_rxseq; - * unsigned short tid13_rxseq; - * unsigned short tid14_rxseq; - * unsigned short tid15_rxseq; - */ -}; - -struct signal_stat { - u8 update_req; /* used to indicate */ - u8 avg_val; /* avg of valid elements */ - u32 total_num; /* num of valid elements */ - u32 total_val; /* sum of valid elements */ -}; - -#define MAX_PATH_NUM_92CS 3 - -struct phy_info { - u8 RxPWDBAll; - u8 SignalQuality; /* in 0-100 index. */ - u8 RxMIMOSignalQuality[MAX_PATH_NUM_92CS]; /* EVM */ - u8 RxMIMOSignalStrength[MAX_PATH_NUM_92CS];/* in 0~100 index */ - s8 RxPower; /* in dBm Translate from PWdB */ -/* Real power in dBm for this packet, no beautification and aggregation. - * Keep this raw info to be used for the other procedures. - */ - s8 recvpower; - u8 BTRxRSSIPercentage; - u8 SignalStrength; /* in 0-100 index. */ - u8 RxPwr[MAX_PATH_NUM_92CS];/* per-path's pwdb */ - u8 RxSNR[MAX_PATH_NUM_92CS];/* per-path's SNR */ -}; - -struct rx_pkt_attrib { - u16 pkt_len; - u8 physt; - u8 drvinfo_sz; - u8 shift_sz; - u8 hdrlen; /* the WLAN Header Len */ - u8 to_fr_ds; - u8 amsdu; - u8 qos; - u8 priority; - u8 pw_save; - u8 mdata; - u16 seq_num; - u8 frag_num; - u8 mfrag; - u8 order; - u8 privacy; /* in frame_ctrl field */ - u8 bdecrypted; - u8 encrypt; /* when 0 indicate no encrypt. when non-zero, - * indicate the encrypt algorithm - */ - u8 iv_len; - u8 icv_len; - u8 crc_err; - u8 icv_err; - - u16 eth_type; - - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; - u8 ta[ETH_ALEN]; - u8 ra[ETH_ALEN]; - u8 bssid[ETH_ALEN]; - - u8 ack_policy; - - u8 key_index; - - u8 mcs_rate; - u8 rxht; - u8 sgi; - u8 pkt_rpt_type; - u32 MacIDValidEntry[2]; /* 64 bits present 64 entry. */ - - struct phy_info phy_info; -}; - -/* These definition is used for Rx packet reordering. */ -#define SN_LESS(a, b) (((a - b) & 0x800) != 0) -#define SN_EQUAL(a, b) (a == b) -#define REORDER_WAIT_TIME (50) /* (ms) */ - -#define RXDESC_SIZE 24 -#define RXDESC_OFFSET RXDESC_SIZE - -struct recv_stat { - __le32 rxdw0; - __le32 rxdw1; - __le32 rxdw2; - __le32 rxdw3; - __le32 rxdw4; - __le32 rxdw5; -}; - -/* - * accesser of recv_priv: rtw_recv_entry(dispatch / passive level); - * recv_thread(passive) ; returnpkt(dispatch) - * ; halt(passive) ; - * - * using enter_critical section to protect - */ -struct recv_priv { - struct __queue free_recv_queue; - struct __queue recv_pending_queue; - struct __queue uc_swdec_pending_queue; - void *pallocated_frame_buf; - struct adapter *adapter; - u32 bIsAnyNonBEPkts; - u64 rx_bytes; - u64 rx_pkts; - u64 rx_drop; - u64 last_rx_bytes; - - struct tasklet_struct irq_prepare_beacon_tasklet; - struct tasklet_struct recv_tasklet; - struct sk_buff_head free_recv_skb_queue; - struct sk_buff_head rx_skb_queue; - struct recv_buf *precv_buf; /* 4 alignment */ - struct __queue free_recv_buf_queue; - /* For display the phy information */ - s8 rssi; - s8 rxpwdb; - u8 signal_strength; - u8 signal_qual; - u8 noise; - s8 RxRssi[2]; - - struct timer_list signal_stat_timer; - u32 signal_stat_sampling_interval; - struct signal_stat signal_qual_data; - struct signal_stat signal_strength_data; -}; - -#define rtw_set_signal_stat_timer(recvpriv) \ - mod_timer(&(recvpriv)->signal_stat_timer, jiffies + \ - msecs_to_jiffies((recvpriv)->signal_stat_sampling_interval)) - -struct sta_recv_priv { - spinlock_t lock; - int option; - struct __queue defrag_q; /* keeping the fragment frame until defrag */ - struct stainfo_rxcache rxcache; -}; - -struct recv_buf { - struct adapter *adapter; - struct urb *purb; - struct sk_buff *pskb; - u8 reuse; -}; - -/* - * head -----> - * - * data -----> - * - * payload - * - * tail -----> - * - * - * end -----> - * - * len = (unsigned int )(tail - data); - * - */ -struct recv_frame { - struct list_head list; - struct sk_buff *pkt; - struct adapter *adapter; - struct rx_pkt_attrib attrib; - struct sta_info *psta; - /* for A-MPDU Rx reordering buffer control */ - struct recv_reorder_ctrl *preorder_ctrl; -}; - -struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue); -struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue); -void rtw_init_recvframe(struct recv_frame *precvframe, - struct recv_priv *precvpriv); -void rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv_queue); -#define rtw_dequeue_recvframe(queue) rtw_alloc_recvframe(queue) -int _rtw_enqueue_recvframe(struct recv_frame *precvframe, - struct __queue *queue); -int rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue); -void rtw_free_recvframe_queue(struct __queue *pframequeue, - struct __queue *pfree_recv_queue); -u32 rtw_free_uc_swdec_pending_queue(struct adapter *adapter); - -void rtw_reordering_ctrl_timeout_handler(struct timer_list *t); - -static inline s32 translate_percentage_to_dbm(u32 sig_stren_index) -{ - s32 power; /* in dBm. */ - - /* Translate to dBm (x=0.5y-95). */ - power = (s32)((sig_stren_index + 1) >> 1); - power -= 95; - - return power; -} - -struct sta_info; - -void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv); - -void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame); - -#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_rf.h b/drivers/staging/rtl8188eu/include/rtw_rf.h deleted file mode 100644 index aabacb41bdde..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_rf.h +++ /dev/null @@ -1,117 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_RF_H_ -#define __RTW_RF_H_ - -#include - -#define OFDM_PHY 1 -#define MIXED_PHY 2 -#define CCK_PHY 3 - -#define NumRates (13) - -/* slot time for 11g */ -#define SHORT_SLOT_TIME 9 -#define NON_SHORT_SLOT_TIME 20 - -/* We now define the following channels as the max channels in each - * channel plan. - */ -/* 2G, total 14 chnls */ -/* {1,2,3,4,5,6,7,8,9,10,11,12,13,14} */ -#define MAX_CHANNEL_NUM_2G 14 -#define MAX_CHANNEL_NUM 14 /* 2.4 GHz only */ - -/* Country codes */ -#define USA 0x555320 -#define EUROPE 0x1 /* temp, should be provided later */ -#define JAPAN 0x2 /* temp, should be provided later */ - -struct regulatory_class { - u32 starting_freq; /* MHz, */ - u8 channel_set[MAX_CHANNEL_NUM]; - u8 channel_cck_power[MAX_CHANNEL_NUM]; /* dbm */ - u8 channel_ofdm_power[MAX_CHANNEL_NUM]; /* dbm */ - u8 txpower_limit; /* dbm */ - u8 channel_spacing; /* MHz */ - u8 modem; -}; - -enum capability { - cESS = 0x0001, - cIBSS = 0x0002, - cPollable = 0x0004, - cPollReq = 0x0008, - cPrivacy = 0x0010, - cShortPreamble = 0x0020, - cPBCC = 0x0040, - cChannelAgility = 0x0080, - cSpectrumMgnt = 0x0100, - cQos = 0x0200, /* For HCCA, use with CF-Pollable - * and CF-PollReq - */ - cShortSlotTime = 0x0400, - cAPSD = 0x0800, - cRM = 0x1000, /* RRM (Radio Request Measurement) */ - cDSSS_OFDM = 0x2000, - cDelayedBA = 0x4000, - cImmediateBA = 0x8000, -}; - -enum _REG_PREAMBLE_MODE { - PREAMBLE_LONG = 1, - PREAMBLE_AUTO = 2, - PREAMBLE_SHORT = 3, -}; - -enum rf90_radio_path { - RF90_PATH_A = 0, /* Radio Path A */ - RF90_PATH_B = 1, /* Radio Path B */ - RF90_PATH_C = 2, /* Radio Path C */ - RF90_PATH_D = 3 /* Radio Path D */ -}; - -/* Bandwidth Offset */ -#define HAL_PRIME_CHNL_OFFSET_DONT_CARE 0 -#define HAL_PRIME_CHNL_OFFSET_LOWER 1 -#define HAL_PRIME_CHNL_OFFSET_UPPER 2 - -/* Represent Channel Width in HT Capabilities */ -/* */ -enum ht_channel_width { - HT_CHANNEL_WIDTH_20 = 0, - HT_CHANNEL_WIDTH_40 = 1, - HT_CHANNEL_WIDTH_80 = 2, - HT_CHANNEL_WIDTH_160 = 3, - HT_CHANNEL_WIDTH_10 = 4, -}; - -/* */ -/* Represent Extension Channel Offset in HT Capabilities */ -/* This is available only in 40Mhz mode. */ -/* */ -enum ht_extchnl_offset { - HT_EXTCHNL_OFFSET_NO_EXT = 0, - HT_EXTCHNL_OFFSET_UPPER = 1, - HT_EXTCHNL_OFFSET_NO_DEF = 2, - HT_EXTCHNL_OFFSET_LOWER = 3, -}; - -/* 2007/11/15 MH Define different RF type. */ -enum rt_rf_type_def { - RF_1T2R = 0, - RF_2T4R = 1, - RF_2T2R = 2, - RF_1T1R = 3, - RF_2T2R_GREEN = 4, - RF_819X_MAX_TYPE = 5, -}; - -u32 rtw_ch2freq(u32 ch); - -#endif /* _RTL8711_RF_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_security.h b/drivers/staging/rtl8188eu/include/rtw_security.h deleted file mode 100644 index fbb72c570239..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_security.h +++ /dev/null @@ -1,241 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __RTW_SECURITY_H_ -#define __RTW_SECURITY_H_ - -#include -#include - -#define _NO_PRIVACY_ 0x0 -#define _WEP40_ 0x1 -#define _TKIP_ 0x2 -#define _TKIP_WTMIC_ 0x3 -#define _AES_ 0x4 -#define _WEP104_ 0x5 -#define _WEP_WPA_MIXED_ 0x07 /* WEP + WPA */ -#define _SMS4_ 0x06 - -#define is_wep_enc(alg) (((alg) == _WEP40_) || ((alg) == _WEP104_)) - -#define SHA256_MAC_LEN 32 -#define AES_BLOCK_SIZE 16 -#define AES_PRIV_SIZE (4 * 44) - -enum { - ENCRYP_PROTOCOL_OPENSYS, /* open system */ - ENCRYP_PROTOCOL_WEP, /* WEP */ - ENCRYP_PROTOCOL_WPA, /* WPA */ - ENCRYP_PROTOCOL_WPA2, /* WPA2 */ - ENCRYP_PROTOCOL_WAPI, /* WAPI: Not support in this version */ - ENCRYP_PROTOCOL_MAX -}; - -#ifndef Ndis802_11AuthModeWPA2 -#define Ndis802_11AuthModeWPA2 (Ndis802_11AuthModeWPANone + 1) -#endif - -#ifndef Ndis802_11AuthModeWPA2PSK -#define Ndis802_11AuthModeWPA2PSK (Ndis802_11AuthModeWPANone + 2) -#endif - -union pn48 { - u64 val; - -#ifdef __LITTLE_ENDIAN - struct { - u8 TSC0; - u8 TSC1; - u8 TSC2; - u8 TSC3; - u8 TSC4; - u8 TSC5; - u8 TSC6; - u8 TSC7; - } _byte_; - -#elif defined(__BIG_ENDIAN) - - struct { - u8 TSC7; - u8 TSC6; - u8 TSC5; - u8 TSC4; - u8 TSC3; - u8 TSC2; - u8 TSC1; - u8 TSC0; - } _byte_; -#endif -}; - -union Keytype { - u8 skey[16]; - u32 lkey[4]; -}; - -struct rt_pmkid_list { - u8 used; - u8 bssid[ETH_ALEN]; - u8 PMKID[16]; - u8 SsidBuf[33]; - u8 *ssid_octet; - u16 ssid_length; -}; - -struct security_priv { - u32 dot11AuthAlgrthm; /* 802.11 auth, could be open, - * shared, 8021x and authswitch - */ - u32 dot11PrivacyAlgrthm; /* This specify the privacy for - * shared auth. algorithm. - */ - /* WEP */ - u32 dot11PrivacyKeyIndex; /* this is only valid for legendary - * wep, 0~3 for key id.(tx key index) - */ - union Keytype dot11DefKey[4]; /* this is only valid for def. key */ - u32 dot11DefKeylen[4]; - u32 dot118021XGrpPrivacy; /* This specify the privacy algthm. - * used for Grp key - */ - u32 dot118021XGrpKeyid; /* key id used for Grp Key - * ( tx key index) - */ - union Keytype dot118021XGrpKey[4]; /* 802.1x Group Key, - * for inx0 and inx1 - */ - union Keytype dot118021XGrptxmickey[4]; - union Keytype dot118021XGrprxmickey[4]; - union pn48 dot11Grptxpn; /* PN48 used for Grp Key xmit.*/ - union pn48 dot11Grprxpn; /* PN48 used for Grp Key recv.*/ -#ifdef CONFIG_88EU_AP_MODE - /* extend security capabilities for AP_MODE */ - unsigned int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */ - unsigned int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */ - unsigned int wpa_group_cipher; - unsigned int wpa2_group_cipher; - unsigned int wpa_pairwise_cipher; - unsigned int wpa2_pairwise_cipher; -#endif - u8 wps_ie[MAX_WPS_IE_LEN];/* added in assoc req */ - int wps_ie_len; - u8 binstallGrpkey; - u8 busetkipkey; - u8 bcheck_grpkey; - u8 bgrpkey_handshake; - s32 hw_decrypted;/* if the rx packets is hw_decrypted==false,i - * it means the hw has not been ready. - */ - - /* keeps the auth_type & enc_status from upper layer - * ioctl(wpa_supplicant or wzc) - */ - u32 ndisauthtype; /* NDIS_802_11_AUTHENTICATION_MODE */ - u32 ndisencryptstatus; /* NDIS_802_11_ENCRYPTION_STATUS */ - struct wlan_bssid_ex sec_bss; /* for joinbss (h2c buffer) usage */ - struct ndis_802_11_wep ndiswep; - u8 assoc_info[600]; - u8 szofcapability[256]; /* for wpa2 usage */ - u8 oidassociation[512]; /* for wpa/wpa2 usage */ - u8 authenticator_ie[256]; /* store ap security information element */ - u8 supplicant_ie[256]; /* store sta security information element */ - - /* for tkip countermeasure */ - u32 last_mic_err_time; - u8 btkip_countermeasure; - u8 btkip_wait_report; - u32 btkip_countermeasure_time; - - /* */ - /* For WPA2 Pre-Authentication. */ - /* */ - struct rt_pmkid_list PMKIDList[NUM_PMKID_CACHE]; - u8 PMKIDIndex; - u8 bWepDefaultKeyIdxSet; -}; - -#define GET_ENCRY_ALGO(psecuritypriv, psta, encry_algo, bmcst) \ -do { \ - switch (psecuritypriv->dot11AuthAlgrthm) { \ - case dot11AuthAlgrthm_Open: \ - case dot11AuthAlgrthm_Shared: \ - case dot11AuthAlgrthm_Auto: \ - encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm; \ - break; \ - case dot11AuthAlgrthm_8021X: \ - if (bmcst) \ - encry_algo = (u8)psecuritypriv->dot118021XGrpPrivacy;\ - else \ - encry_algo = (u8)psta->dot118021XPrivacy; \ - break; \ - case dot11AuthAlgrthm_WAPI: \ - encry_algo = (u8)psecuritypriv->dot11PrivacyAlgrthm; \ - break; \ - } \ -} while (0) - -#define SET_ICE_IV_LEN(iv_len, icv_len, encrypt) \ -do { \ - switch (encrypt) { \ - case _WEP40_: \ - case _WEP104_: \ - iv_len = 4; \ - icv_len = 4; \ - break; \ - case _TKIP_: \ - iv_len = 8; \ - icv_len = 4; \ - break; \ - case _AES_: \ - iv_len = 8; \ - icv_len = 8; \ - break; \ - case _SMS4_: \ - iv_len = 18; \ - icv_len = 16; \ - break; \ - default: \ - iv_len = 0; \ - icv_len = 0; \ - break; \ - } \ -} while (0) - -#define GET_TKIP_PN(iv, dot11txpn) \ -do { \ - dot11txpn._byte_.TSC0 = iv[2]; \ - dot11txpn._byte_.TSC1 = iv[0]; \ - dot11txpn._byte_.TSC2 = iv[4]; \ - dot11txpn._byte_.TSC3 = iv[5]; \ - dot11txpn._byte_.TSC4 = iv[6]; \ - dot11txpn._byte_.TSC5 = iv[7]; \ -} while (0) - -#define ROL32(A, n) (((A) << (n)) | (((A) >> (32 - (n))) & ((1UL << (n)) - 1))) -#define ROR32(A, n) ROL32((A), 32 - (n)) - -struct mic_data { - u32 K0, K1; /* Key */ - u32 L, R; /* Current state */ - u32 M; /* Message accumulator (single word) */ - u32 nBytesInM; /* # bytes in M */ -}; - -void rtw_secmicsetkey(struct mic_data *pmicdata, u8 *key); -void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b); -void rtw_secmicappend(struct mic_data *pmicdata, u8 *src, u32 nBytes); -void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst); -void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, - u8 *Miccode, u8 priority); -u32 rtw_aes_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); -u32 rtw_tkip_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); -void rtw_wep_encrypt(struct adapter *padapter, struct xmit_frame *pxmitframe); -u32 rtw_aes_decrypt(struct adapter *padapter, struct recv_frame *precvframe); -u32 rtw_tkip_decrypt(struct adapter *padapter, struct recv_frame *precvframe); -int rtw_wep_decrypt(struct adapter *padapter, struct recv_frame *precvframe); - -#endif /* __RTL871X_SECURITY_H_ */ diff --git a/drivers/staging/rtl8188eu/include/rtw_sreset.h b/drivers/staging/rtl8188eu/include/rtw_sreset.h deleted file mode 100644 index ea3c0d93bf0b..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_sreset.h +++ /dev/null @@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_SRESET_C_ -#define _RTW_SRESET_C_ - -#include -#include - -struct sreset_priv { - u8 wifi_error_status; -}; - -#include - -#define WIFI_STATUS_SUCCESS 0 -#define USB_VEN_REQ_CMD_FAIL BIT(0) -#define USB_READ_PORT_FAIL BIT(1) -#define USB_WRITE_PORT_FAIL BIT(2) -#define WIFI_MAC_TXDMA_ERROR BIT(3) -#define WIFI_TX_HANG BIT(4) -#define WIFI_RX_HANG BIT(5) -#define WIFI_IF_NOT_EXIST BIT(6) - -void sreset_set_wifi_error_status(struct adapter *padapter, u32 status); - -#endif diff --git a/drivers/staging/rtl8188eu/include/rtw_xmit.h b/drivers/staging/rtl8188eu/include/rtw_xmit.h deleted file mode 100644 index 456fd52717f3..000000000000 --- a/drivers/staging/rtl8188eu/include/rtw_xmit.h +++ /dev/null @@ -1,352 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _RTW_XMIT_H_ -#define _RTW_XMIT_H_ - -#include -#include - -#define MAX_XMITBUF_SZ (20480) /* 20k */ -#define NR_XMITBUFF (4) - -#define XMITBUF_ALIGN_SZ 4 - -/* xmit extension buff defination */ -#define MAX_XMIT_EXTBUF_SZ (1536) -#define NR_XMIT_EXTBUFF (32) - -#define MAX_NUMBLKS (1) - -#define XMIT_VO_QUEUE (0) -#define XMIT_VI_QUEUE (1) -#define XMIT_BE_QUEUE (2) -#define XMIT_BK_QUEUE (3) - -#define VO_QUEUE_INX 0 -#define VI_QUEUE_INX 1 -#define BE_QUEUE_INX 2 -#define BK_QUEUE_INX 3 -#define BCN_QUEUE_INX 4 -#define MGT_QUEUE_INX 5 -#define HIGH_QUEUE_INX 6 -#define TXCMD_QUEUE_INX 7 - -#define HW_QUEUE_ENTRY 8 - -#define WEP_IV(pattrib_iv, dot11txpn, keyidx)\ -do {\ - pattrib_iv[0] = dot11txpn._byte_.TSC0;\ - pattrib_iv[1] = dot11txpn._byte_.TSC1;\ - pattrib_iv[2] = dot11txpn._byte_.TSC2;\ - pattrib_iv[3] = ((keyidx & 0x3) << 6);\ - dot11txpn.val = (dot11txpn.val == 0xffffff) ? 0 : (dot11txpn.val + 1);\ -} while (0) - -#define TKIP_IV(pattrib_iv, dot11txpn, keyidx)\ -do {\ - pattrib_iv[0] = dot11txpn._byte_.TSC1;\ - pattrib_iv[1] = (dot11txpn._byte_.TSC1 | 0x20) & 0x7f;\ - pattrib_iv[2] = dot11txpn._byte_.TSC0;\ - pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6);\ - pattrib_iv[4] = dot11txpn._byte_.TSC2;\ - pattrib_iv[5] = dot11txpn._byte_.TSC3;\ - pattrib_iv[6] = dot11txpn._byte_.TSC4;\ - pattrib_iv[7] = dot11txpn._byte_.TSC5;\ - dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val + 1);\ -} while (0) - -#define AES_IV(pattrib_iv, dot11txpn, keyidx)\ -do { \ - pattrib_iv[0] = dot11txpn._byte_.TSC0; \ - pattrib_iv[1] = dot11txpn._byte_.TSC1; \ - pattrib_iv[2] = 0; \ - pattrib_iv[3] = BIT(5) | ((keyidx & 0x3) << 6); \ - pattrib_iv[4] = dot11txpn._byte_.TSC2; \ - pattrib_iv[5] = dot11txpn._byte_.TSC3; \ - pattrib_iv[6] = dot11txpn._byte_.TSC4; \ - pattrib_iv[7] = dot11txpn._byte_.TSC5; \ - dot11txpn.val = dot11txpn.val == 0xffffffffffffULL ? 0 : (dot11txpn.val + 1);\ -} while (0) - -#define HWXMIT_ENTRY 4 - -#define TXDESC_SIZE 32 - -#define PACKET_OFFSET_SZ (8) -#define TXDESC_OFFSET (TXDESC_SIZE + PACKET_OFFSET_SZ) - -struct tx_desc { - /* DWORD 0 */ - __le32 txdw0; - __le32 txdw1; - __le32 txdw2; - __le32 txdw3; - __le32 txdw4; - __le32 txdw5; - __le32 txdw6; - __le32 txdw7; -}; - -struct hw_xmit { - struct __queue *sta_queue; - int accnt; -}; - -/* reduce size */ -struct pkt_attrib { - u8 type; - u8 subtype; - u8 bswenc; - u8 dhcp_pkt; - u16 ether_type; - u16 seqnum; - u16 hdrlen; /* the WLAN Header Len */ - u32 pktlen; /* the original 802.3 pkt raw_data len (not include - * ether_hdr data) - */ - u32 last_txcmdsz; - u8 nr_frags; - u8 encrypt; /* when 0 indicate no encrypt. when non-zero, - * indicate the encrypt algorithm - */ - u8 iv_len; - u8 icv_len; - u8 iv[18]; - u8 icv[16]; - u8 priority; - u8 ack_policy; - u8 mac_id; - u8 vcs_mode; /* virtual carrier sense method */ - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; - u8 ta[ETH_ALEN]; - u8 ra[ETH_ALEN]; - u8 key_idx; - u8 qos_en; - u8 ht_en; - u8 raid;/* rate adpative id */ - u8 bwmode; - u8 ch_offset;/* PRIME_CHNL_OFFSET */ - u8 sgi;/* short GI */ - u8 ampdu_en;/* tx ampdu enable */ - u8 mdata;/* more data bit */ - u8 pctrl;/* per packet txdesc control enable */ - u8 triggered;/* for ap mode handling Power Saving sta */ - u8 qsel; - u8 eosp; - u8 rate; - u8 intel_proxim; - u8 retry_ctrl; - struct sta_info *psta; -}; - -#define WLANHDR_OFFSET 64 - -#define NULL_FRAMETAG (0x0) -#define DATA_FRAMETAG 0x01 -#define L2_FRAMETAG 0x02 -#define MGNT_FRAMETAG 0x03 -#define AMSDU_FRAMETAG 0x04 - -#define EII_FRAMETAG 0x05 -#define IEEE8023_FRAMETAG 0x06 - -#define MP_FRAMETAG 0x07 - -#define TXAGG_FRAMETAG 0x08 - -struct submit_ctx { - u32 submit_time; /* */ - u32 timeout_ms; /* <0: not synchronous, 0: wait forever, >0: up to ms waiting */ - int status; /* status for operation */ - struct completion done; -}; - -enum { - RTW_SCTX_SUBMITTED = -1, - RTW_SCTX_DONE_SUCCESS = 0, - RTW_SCTX_DONE_UNKNOWN, - RTW_SCTX_DONE_TIMEOUT, - RTW_SCTX_DONE_BUF_ALLOC, - RTW_SCTX_DONE_BUF_FREE, - RTW_SCTX_DONE_WRITE_PORT_ERR, - RTW_SCTX_DONE_TX_DESC_NA, - RTW_SCTX_DONE_TX_DENY, - RTW_SCTX_DONE_CCX_PKT_FAIL, - RTW_SCTX_DONE_DRV_STOP, - RTW_SCTX_DONE_DEV_REMOVE, -}; - -void rtw_sctx_init(struct submit_ctx *sctx, int timeout_ms); -int rtw_sctx_wait(struct submit_ctx *sctx); -void rtw_sctx_done_err(struct submit_ctx **sctx, int status); - -struct xmit_buf { - struct list_head list; - struct adapter *padapter; - u8 *pallocated_buf; - u8 *pbuf; - void *priv_data; - u16 ext_tag; /* 0: Normal xmitbuf, 1: extension xmitbuf. */ - u16 flags; - u32 len; - struct submit_ctx *sctx; - struct urb *pxmit_urb[8]; -}; - -struct xmit_frame { - struct list_head list; - struct pkt_attrib attrib; - struct sk_buff *pkt; - int frame_tag; - struct adapter *padapter; - u8 *buf_addr; - struct xmit_buf *pxmitbuf; - - u8 agg_num; - s8 pkt_offset; - u8 ack_report; -}; - -struct tx_servq { - struct list_head tx_pending; - struct __queue sta_pending; - int qcnt; -}; - -struct sta_xmit_priv { - spinlock_t lock; - int option; - int apsd_setting; /* When bit mask is on, the associated edca - * queue supports APSD. - */ - struct tx_servq be_q; /* priority == 0,3 */ - struct tx_servq bk_q; /* priority == 1,2 */ - struct tx_servq vi_q; /* priority == 4,5 */ - struct tx_servq vo_q; /* priority == 6,7 */ - struct list_head legacy_dz; - struct list_head apsd; - u16 txseq_tid[16]; -}; - -struct hw_txqueue { - volatile int head; - volatile int tail; - volatile int free_sz; /* in units of 64 bytes */ - volatile int free_cmdsz; - volatile int txsz[8]; - uint ff_hwaddr; - uint cmd_hwaddr; - int ac_tag; -}; - -struct xmit_priv { - spinlock_t lock; - struct __queue be_pending; - struct __queue bk_pending; - struct __queue vi_pending; - struct __queue vo_pending; - struct __queue bm_pending; - u8 *pallocated_frame_buf; - u8 *pxmit_frame_buf; - uint free_xmitframe_cnt; - struct __queue free_xmit_queue; - uint frag_len; - struct adapter *adapter; - u8 vcs_setting; - u8 vcs; - u8 vcs_type; - u64 tx_bytes; - u64 tx_pkts; - u64 tx_drop; - u64 last_tx_bytes; - u64 last_tx_pkts; - struct hw_xmit *hwxmits; - u8 hwxmit_entry; - u8 wmm_para_seq[4];/* sequence for wmm ac parameter strength - * from large to small. it's value is 0->vo, - * 1->vi, 2->be, 3->bk. - */ - u8 txirp_cnt;/* */ - struct tasklet_struct xmit_tasklet; - /* per AC pending irp */ - int beq_cnt; - int bkq_cnt; - int viq_cnt; - int voq_cnt; - struct __queue free_xmitbuf_queue; - struct __queue pending_xmitbuf_queue; - u8 *pallocated_xmitbuf; - u8 *pxmitbuf; - uint free_xmitbuf_cnt; - struct __queue free_xmit_extbuf_queue; - u8 *pallocated_xmit_extbuf; - u8 *pxmit_extbuf; - uint free_xmit_extbuf_cnt; - u16 nqos_ssn; - int ack_tx; - struct mutex ack_tx_mutex; - struct submit_ctx ack_tx_ops; -}; - -struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv); -s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, - struct xmit_buf *pxmitbuf); -struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv); -s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, - struct xmit_buf *pxmitbuf); -void rtw_count_tx_stats(struct adapter *padapter, - struct xmit_frame *pxmitframe, int sz); -void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len); -s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, - struct pkt_attrib *pattrib); -s32 rtw_put_snap(u8 *data, u16 h_proto); - -struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv); -s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, - struct xmit_frame *pxmitframe); -void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, - struct __queue *pframequeue); -struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, - struct sta_info *psta, int up, u8 *ac); -s32 rtw_xmitframe_enqueue(struct adapter *padapter, - struct xmit_frame *pxmitframe); -struct xmit_frame *rtw_dequeue_xframe(struct xmit_priv *pxmitpriv, - struct hw_xmit *phwxmit_i, int entry); - -s32 rtw_xmit_classifier(struct adapter *padapter, - struct xmit_frame *pxmitframe); -s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, - struct xmit_frame *pxmitframe); -s32 _rtw_init_hw_txqueue(struct hw_txqueue *phw_txqueue, u8 ac_tag); -void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv); -s32 rtw_txframes_pending(struct adapter *padapter); -s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, - struct pkt_attrib *pattrib); -void rtw_init_hwxmits(struct hw_xmit *phwxmit, int entry); -s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter); -void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv); -s32 rtw_alloc_hwxmits(struct adapter *padapter); -void rtw_free_hwxmits(struct adapter *padapter); -s32 rtw_xmit(struct adapter *padapter, struct sk_buff **pkt); - -#if defined(CONFIG_88EU_AP_MODE) -int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_frame *pxmitframe); -void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta); -void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta); -void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *psta); -#endif - -u8 qos_acm(u8 acm_mask, u8 priority); -u32 rtw_get_ff_hwaddr(struct xmit_frame *pxmitframe); -int rtw_ack_tx_wait(struct xmit_priv *pxmitpriv, u32 timeout_ms); -void rtw_ack_tx_done(struct xmit_priv *pxmitpriv, int status); - -/* include after declaring struct xmit_buf, in order to avoid warning */ -#include - -#endif /* _RTL871X_XMIT_H_ */ diff --git a/drivers/staging/rtl8188eu/include/sta_info.h b/drivers/staging/rtl8188eu/include/sta_info.h deleted file mode 100644 index 6165adafc451..000000000000 --- a/drivers/staging/rtl8188eu/include/sta_info.h +++ /dev/null @@ -1,359 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __STA_INFO_H_ -#define __STA_INFO_H_ - -#include -#include -#include - -#define IBSS_START_MAC_ID 2 -#define NUM_STA 32 -#define NUM_ACL 16 - -/* if mode ==0, then the sta is allowed once the addr is hit. */ -/* if mode ==1, then the sta is rejected once the addr is non-hit. */ -struct rtw_wlan_acl_node { - struct list_head list; - u8 addr[ETH_ALEN]; - u8 valid; -}; - -/* mode=0, disable */ -/* mode=1, accept unless in deny list */ -/* mode=2, deny unless in accept list */ -struct wlan_acl_pool { - int mode; - int num; - struct rtw_wlan_acl_node aclnode[NUM_ACL]; - struct __queue acl_node_q; -}; - -struct rssi_sta { - s32 UndecoratedSmoothedPWDB; - s32 UndecoratedSmoothedCCK; - s32 UndecoratedSmoothedOFDM; - u64 PacketMap; - u8 ValidBit; -}; - -struct stainfo_stats { - u64 rx_mgnt_pkts; - u64 rx_beacon_pkts; - u64 rx_probereq_pkts; - u64 rx_probersp_pkts; - u64 rx_probersp_bm_pkts; - u64 rx_probersp_uo_pkts; - u64 rx_ctrl_pkts; - u64 rx_data_pkts; - - u64 last_rx_mgnt_pkts; - u64 last_rx_beacon_pkts; - u64 last_rx_probereq_pkts; - u64 last_rx_probersp_pkts; - u64 last_rx_probersp_bm_pkts; - u64 last_rx_probersp_uo_pkts; - u64 last_rx_ctrl_pkts; - u64 last_rx_data_pkts; - u64 rx_bytes; - u64 rx_drops; - u64 tx_pkts; - u64 tx_bytes; - u64 tx_drops; -}; - -struct sta_info { - spinlock_t lock; - struct list_head list; /* free_sta_queue */ - struct list_head hash_list; /* sta_hash */ - - struct sta_xmit_priv sta_xmitpriv; - struct sta_recv_priv sta_recvpriv; - - struct __queue sleep_q; - unsigned int sleepq_len; - - uint state; - uint aid; - uint mac_id; - uint qos_option; - u8 hwaddr[ETH_ALEN]; - - uint ieee8021x_blocked; /* 0: allowed, 1:blocked */ - uint dot118021XPrivacy; /* aes, tkip... */ - union Keytype dot11tkiptxmickey; - union Keytype dot11tkiprxmickey; - union Keytype dot118021x_UncstKey; - union pn48 dot11txpn; /* PN48 used for Unicast xmit. */ - union pn48 dot11rxpn; /* PN48 used for Unicast recv. */ - u8 bssrateset[16]; - u32 bssratelen; - s32 rssi; - s32 signal_quality; - - u8 cts2self; - u8 rtsen; - - u8 raid; - u8 init_rate; - u8 wireless_mode; /* NETWORK_TYPE */ - struct stainfo_stats sta_stats; - - /* for A-MPDU TX, ADDBA timeout check */ - struct timer_list addba_retry_timer; - - /* for A-MPDU Rx reordering buffer control */ - struct recv_reorder_ctrl recvreorder_ctrl[16]; - - /* for A-MPDU Tx */ - /* unsigned char ampdu_txen_bitmap; */ - u16 BA_starting_seqctrl[16]; - - struct ht_priv htpriv; - - /* Notes: */ - /* STA_Mode: */ - /* curr_network(mlme_priv/security_priv/qos/ht) + - * sta_info: (STA & AP) CAP/INFO - */ - /* scan_q: AP CAP/INFO */ - - /* AP_Mode: */ - /* curr_network(mlme_priv/security_priv/qos/ht) : AP CAP/INFO */ - /* sta_info: (AP & STA) CAP/INFO */ - - struct list_head asoc_list; -#ifdef CONFIG_88EU_AP_MODE - struct list_head auth_list; - - unsigned int expire_to; - unsigned int auth_seq; - unsigned int authalg; - unsigned char chg_txt[128]; - - u16 capability; - int flags; - - int dot8021xalg;/* 0:disable, 1:psk, 2:802.1x */ - int wpa_psk;/* 0:disable, bit(0): WPA, bit(1):WPA2 */ - int wpa_group_cipher; - int wpa2_group_cipher; - int wpa_pairwise_cipher; - int wpa2_pairwise_cipher; - - u8 bpairwise_key_installed; - - u8 wpa_ie[32]; - - u8 nonerp_set; - u8 no_short_slot_time_set; - u8 no_short_preamble_set; - u8 no_ht_gf_set; - u8 no_ht_set; - u8 ht_20mhz_set; - - unsigned int tx_ra_bitmap; - u8 qos_info; - - u8 max_sp_len; - u8 uapsd_bk;/* BIT(0): Delivery enabled, BIT(1): Trigger enabled */ - u8 uapsd_be; - u8 uapsd_vi; - u8 uapsd_vo; - - u8 has_legacy_ac; - unsigned int sleepq_ac_len; -#endif /* CONFIG_88EU_AP_MODE */ - - u8 under_exist_checking; - u8 keep_alive_trycnt; - - /* for DM */ - struct rssi_sta rssi_stat; - - /* ================ODM Relative Info======================= */ - /* Please be careful, don't declare too much structure here. - * It will cost memory * STA support num. - */ - /* 2011/10/20 MH Add for ODM STA info. */ - /* Driver Write */ - u8 bValid; /* record the sta status link or not? */ - u8 IOTPeer; /* Enum value. HT_IOT_PEER_E */ - u8 rssi_level; /* for Refresh RA mask */ - /* ODM Write */ - /* 1 PHY_STATUS_INFO */ - u8 RSSI_Path[4]; /* */ - u8 RSSI_Ave; - u8 RXEVM[4]; - u8 RXSNR[4]; - - /* ================ODM Relative Info======================= */ - /* */ - - /* To store the sequence number of received management frame */ - u16 RxMgmtFrameSeqNum; -}; - -#define sta_rx_pkts(sta) \ - (sta->sta_stats.rx_mgnt_pkts \ - + sta->sta_stats.rx_ctrl_pkts \ - + sta->sta_stats.rx_data_pkts) - -#define sta_last_rx_pkts(sta) \ - (sta->sta_stats.last_rx_mgnt_pkts \ - + sta->sta_stats.last_rx_ctrl_pkts \ - + sta->sta_stats.last_rx_data_pkts) - -#define sta_rx_data_pkts(sta) \ - (sta->sta_stats.rx_data_pkts) - -#define sta_last_rx_data_pkts(sta) \ - (sta->sta_stats.last_rx_data_pkts) - -#define sta_rx_mgnt_pkts(sta) \ - (sta->sta_stats.rx_mgnt_pkts) - -#define sta_last_rx_mgnt_pkts(sta) \ - (sta->sta_stats.last_rx_mgnt_pkts) - -#define sta_rx_beacon_pkts(sta) \ - (sta->sta_stats.rx_beacon_pkts) - -#define sta_last_rx_beacon_pkts(sta) \ - (sta->sta_stats.last_rx_beacon_pkts) - -#define sta_rx_probereq_pkts(sta) \ - (sta->sta_stats.rx_probereq_pkts) - -#define sta_last_rx_probereq_pkts(sta) \ - (sta->sta_stats.last_rx_probereq_pkts) - -#define sta_rx_probersp_pkts(sta) \ - (sta->sta_stats.rx_probersp_pkts) - -#define sta_last_rx_probersp_pkts(sta) \ - (sta->sta_stats.last_rx_probersp_pkts) - -#define sta_rx_probersp_bm_pkts(sta) \ - (sta->sta_stats.rx_probersp_bm_pkts) - -#define sta_last_rx_probersp_bm_pkts(sta) \ - (sta->sta_stats.last_rx_probersp_bm_pkts) - -#define sta_rx_probersp_uo_pkts(sta) \ - (sta->sta_stats.rx_probersp_uo_pkts) - -#define sta_last_rx_probersp_uo_pkts(sta) \ - (sta->sta_stats.last_rx_probersp_uo_pkts) - -#define sta_update_last_rx_pkts(sta) \ -do { \ - sta->sta_stats.last_rx_mgnt_pkts = sta->sta_stats.rx_mgnt_pkts; \ - sta->sta_stats.last_rx_beacon_pkts = sta->sta_stats.rx_beacon_pkts; \ - sta->sta_stats.last_rx_probereq_pkts = sta->sta_stats.rx_probereq_pkts; \ - sta->sta_stats.last_rx_probersp_pkts = sta->sta_stats.rx_probersp_pkts; \ - sta->sta_stats.last_rx_probersp_bm_pkts = sta->sta_stats.rx_probersp_bm_pkts; \ - sta->sta_stats.last_rx_probersp_uo_pkts = sta->sta_stats.rx_probersp_uo_pkts; \ - sta->sta_stats.last_rx_ctrl_pkts = sta->sta_stats.rx_ctrl_pkts; \ - sta->sta_stats.last_rx_data_pkts = sta->sta_stats.rx_data_pkts; \ -} while (0) - -#define STA_RX_PKTS_ARG(sta) \ - sta->sta_stats.rx_mgnt_pkts \ - , sta->sta_stats.rx_ctrl_pkts \ - , sta->sta_stats.rx_data_pkts - -#define STA_LAST_RX_PKTS_ARG(sta) \ - sta->sta_stats.last_rx_mgnt_pkts \ - , sta->sta_stats.last_rx_ctrl_pkts \ - , sta->sta_stats.last_rx_data_pkts - -#define STA_RX_PKTS_DIFF_ARG(sta) \ - sta->sta_stats.rx_mgnt_pkts - sta->sta_stats.last_rx_mgnt_pkts \ - , sta->sta_stats.rx_ctrl_pkts - sta->sta_stats.last_rx_ctrl_pkts \ - , sta->sta_stats.rx_data_pkts - sta->sta_stats.last_rx_data_pkts - -#define STA_PKTS_FMT "(m:%llu, c:%llu, d:%llu)" - -struct sta_priv { - u8 *pallocated_stainfo_buf; - u8 *pstainfo_buf; - struct __queue free_sta_queue; - - spinlock_t sta_hash_lock; - struct list_head sta_hash[NUM_STA]; - int asoc_sta_count; - struct __queue sleep_q; - struct __queue wakeup_q; - - struct adapter *padapter; - - spinlock_t asoc_list_lock; - struct list_head asoc_list; - -#ifdef CONFIG_88EU_AP_MODE - struct list_head auth_list; - spinlock_t auth_list_lock; - u8 asoc_list_cnt; - u8 auth_list_cnt; - - unsigned int auth_to; /* sec, time to expire in authenticating. */ - unsigned int assoc_to; /* sec, time to expire before associating. */ - unsigned int expire_to; /* sec , time to expire after associated. */ - - /* pointers to STA info; based on allocated AID or NULL if AID free - * AID is in the range 1-2007, so sta_aid[0] corresponders to AID 1 - * and so on - */ - struct sta_info *sta_aid[NUM_STA]; - - u16 sta_dz_bitmap;/* only support 15 stations, station aid bitmap - * for sleeping sta. - */ - u16 tim_bitmap; /* only support 15 stations, aid=0~15 mapping - * bit0~bit15 - */ - - u16 max_num_sta; - - struct wlan_acl_pool acl_list; -#endif - -}; - -static inline u32 wifi_mac_hash(u8 *mac) -{ - u32 x; - - x = mac[0]; - x = (x << 2) ^ mac[1]; - x = (x << 2) ^ mac[2]; - x = (x << 2) ^ mac[3]; - x = (x << 2) ^ mac[4]; - x = (x << 2) ^ mac[5]; - - x ^= x >> 8; - x = x & (NUM_STA - 1); - return x; -} - -u32 _rtw_init_sta_priv(struct sta_priv *pstapriv); -u32 _rtw_free_sta_priv(struct sta_priv *pstapriv); - -#define stainfo_offset_valid(offset) (offset < NUM_STA && offset >= 0) -int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta); -struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int off); - -struct sta_info *rtw_alloc_stainfo(struct sta_priv *stapriv, u8 *hwaddr); -u32 rtw_free_stainfo(struct adapter *adapt, struct sta_info *psta); -void rtw_free_all_stainfo(struct adapter *adapt); -struct sta_info *rtw_get_stainfo(struct sta_priv *stapriv, u8 *hwaddr); -u32 rtw_init_bcmc_stainfo(struct adapter *adapt); -struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter); -bool rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr); - -#endif /* _STA_INFO_H_ */ diff --git a/drivers/staging/rtl8188eu/include/usb_ops_linux.h b/drivers/staging/rtl8188eu/include/usb_ops_linux.h deleted file mode 100644 index 19c6e76d747e..000000000000 --- a/drivers/staging/rtl8188eu/include/usb_ops_linux.h +++ /dev/null @@ -1,26 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __USB_OPS_LINUX_H__ -#define __USB_OPS_LINUX_H__ - -#define USB_HIGH_SPEED_BULK_SIZE 512 -#define USB_FULL_SPEED_BULK_SIZE 64 - -u8 usb_read8(struct adapter *adapter, u32 addr); -u16 usb_read16(struct adapter *adapter, u32 addr); -u32 usb_read32(struct adapter *adapter, u32 addr); - -u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf); - -int usb_write8(struct adapter *adapter, u32 addr, u8 val); -int usb_write16(struct adapter *adapter, u32 addr, u16 val); -int usb_write32(struct adapter *adapter, u32 addr, u32 val); - -u32 usb_write_port(struct adapter *adapter, u32 addr, u32 cnt, struct xmit_buf *pmem); -void usb_write_port_cancel(struct adapter *adapter); - -#endif diff --git a/drivers/staging/rtl8188eu/include/wifi.h b/drivers/staging/rtl8188eu/include/wifi.h deleted file mode 100644 index 716fec036e54..000000000000 --- a/drivers/staging/rtl8188eu/include/wifi.h +++ /dev/null @@ -1,355 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef _WIFI_H_ -#define _WIFI_H_ - -#define WLAN_HDR_A3_LEN 24 -#define WLAN_HDR_A3_QOS_LEN 26 - -#define P80211CAPTURE_VERSION 0x80211001 - -/* This value is tested by WiFi 11n Test Plan 5.2.3. */ -/* This test verifies the WLAN NIC can update the NAV through sending - * the CTS with large duration. - */ -#define WiFiNavUpperUs 30000 /* 30 ms */ - -enum WIFI_FRAME_TYPE { - WIFI_MGT_TYPE = (0), - WIFI_CTRL_TYPE = (BIT(2)), - WIFI_DATA_TYPE = (BIT(3)), - WIFI_QOS_DATA_TYPE = (BIT(7) | BIT(3)), /* QoS Data */ -}; - -#define SetToDs(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_TODS) - -#define GetToDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_TODS)) != 0) - -#define ClearToDs(pbuf) \ - *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_TODS)) - -#define SetFrDs(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_FROMDS) - -#define GetFrDs(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_FROMDS)) != 0) - -#define ClearFrDs(pbuf) \ - *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_FROMDS)) - -#define get_tofr_ds(pframe) ((GetToDs(pframe) << 1) | GetFrDs(pframe)) - -#define SetMFrag(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREFRAGS) - -#define GetMFrag(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) != 0) - -#define ClearMFrag(pbuf) \ - *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREFRAGS)) - -#define SetRetry(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_RETRY) - -#define GetRetry(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_RETRY)) != 0) - -#define ClearRetry(pbuf) \ - *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_RETRY)) - -#define SetPwrMgt(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PM) - -#define GetPwrMgt(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_PM)) != 0) - -#define ClearPwrMgt(pbuf) \ - *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_PM)) - -#define SetMData(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_MOREDATA) - -#define GetMData(pbuf) (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_MOREDATA)) != 0) - -#define ClearMData(pbuf) \ - *(__le16 *)(pbuf) &= (~cpu_to_le16(IEEE80211_FCTL_MOREDATA)) - -#define SetPrivacy(pbuf) \ - *(__le16 *)(pbuf) |= cpu_to_le16(IEEE80211_FCTL_PROTECTED) - -#define GetPrivacy(pbuf) \ - (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_PROTECTED)) != 0) - -#define GetOrder(pbuf) \ - (((*(__le16 *)(pbuf)) & cpu_to_le16(IEEE80211_FCTL_ORDER)) != 0) - -#define GetFrameType(pbuf) \ - (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(3) | BIT(2))) - -#define GetFrameSubType(pbuf) (le16_to_cpu(*(__le16 *)(pbuf)) & (BIT(7) |\ - BIT(6) | BIT(5) | BIT(4) | BIT(3) | BIT(2))) - -#define SetFrameSubType(pbuf, type) \ - do { \ - *(__le16 *)(pbuf) &= cpu_to_le16(~(BIT(7) | BIT(6) | \ - BIT(5) | BIT(4) | BIT(3) | BIT(2))); \ - *(__le16 *)(pbuf) |= cpu_to_le16(type); \ - } while (0) - -#define GetSequence(pbuf) \ - (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) >> 4) - -#define GetFragNum(pbuf) \ - (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 22)) & 0x0f) - -#define SetSeqNum(pbuf, num) \ - do { \ - *(__le16 *)((size_t)(pbuf) + 22) = \ - ((*(__le16 *)((size_t)(pbuf) + 22)) & cpu_to_le16((unsigned short)0x000f)) | \ - cpu_to_le16((unsigned short)(0xfff0 & (num << 4))); \ - } while (0) - -#define SetDuration(pbuf, dur) \ - *(__le16 *)((size_t)(pbuf) + 2) = cpu_to_le16(0xffff & (dur)) - -#define SetPriority(pbuf, tid) \ - *(__le16 *)(pbuf) |= cpu_to_le16(tid & 0xf) - -#define GetPriority(pbuf) ((le16_to_cpu(*(__le16 *)(pbuf))) & 0xf) - -#define SetEOSP(pbuf, eosp) \ - *(__le16 *)(pbuf) |= cpu_to_le16((eosp & 1) << 4) - -#define SetAckpolicy(pbuf, ack) \ - *(__le16 *)(pbuf) |= cpu_to_le16((ack & 3) << 5) - -#define GetAckpolicy(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 5) & 0x3) - -#define GetAMsdu(pbuf) (((le16_to_cpu(*(__le16 *)pbuf)) >> 7) & 0x1) - -#define GetAid(pbuf) (le16_to_cpu(*(__le16 *)((size_t)(pbuf) + 2)) & 0x3fff) - -#define GetAddr1Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 4)) - -#define GetAddr2Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 10)) - -#define GetAddr3Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 16)) - -static inline unsigned char *get_hdr_bssid(unsigned char *pframe) -{ - unsigned char *sa; - unsigned int to_fr_ds = (GetToDs(pframe) << 1) | GetFrDs(pframe); - - switch (to_fr_ds) { - case 0x00: /* ToDs=0, FromDs=0 */ - sa = GetAddr3Ptr(pframe); - break; - case 0x01: /* ToDs=0, FromDs=1 */ - sa = GetAddr2Ptr(pframe); - break; - case 0x02: /* ToDs=1, FromDs=0 */ - sa = GetAddr1Ptr(pframe); - break; - case 0x03: /* ToDs=1, FromDs=1 */ - sa = GetAddr1Ptr(pframe); - break; - default: - sa = NULL; /* */ - break; - } - return sa; -} - -/*----------------------------------------------------------------------------- - Below is for the security related definition -------------------------------------------------------------------------------*/ -#define _ASOCREQ_IE_OFFSET_ 4 /* excluding wlan_hdr */ -#define _ASOCRSP_IE_OFFSET_ 6 -#define _REASOCREQ_IE_OFFSET_ 10 -#define _REASOCRSP_IE_OFFSET_ 6 -#define _PROBEREQ_IE_OFFSET_ 0 -#define _PROBERSP_IE_OFFSET_ 12 -#define _AUTH_IE_OFFSET_ 6 -#define _DEAUTH_IE_OFFSET_ 0 -#define _BEACON_IE_OFFSET_ 12 -#define _PUBLIC_ACTION_IE_OFFSET_ 8 - -#define _FIXED_IE_LENGTH_ _BEACON_IE_OFFSET_ - -/* --------------------------------------------------------------------------- - Below is the fixed elements... ------------------------------------------------------------------------------*/ -#define _AUTH_ALGM_NUM_ 2 -#define _AUTH_SEQ_NUM_ 2 -#define _BEACON_ITERVAL_ 2 -#define _CAPABILITY_ 2 -#define _CURRENT_APADDR_ 6 -#define _LISTEN_INTERVAL_ 2 -#define _RSON_CODE_ 2 -#define _ASOC_ID_ 2 -#define _STATUS_CODE_ 2 -#define _TIMESTAMP_ 8 - -#define AUTH_ODD_TO 0 -#define AUTH_EVEN_TO 1 - -/*----------------------------------------------------------------------------- - Below is the definition for 802.11i / 802.1x -------------------------------------------------------------------------------*/ -#define _IEEE8021X_MGT_ 1 /* WPA */ -#define _IEEE8021X_PSK_ 2 /* WPA with pre-shared key */ - -/* - * #define _NO_PRIVACY_ 0 - * #define _WEP_40_PRIVACY_ 1 - * #define _TKIP_PRIVACY_ 2 - * #define _WRAP_PRIVACY_ 3 - * #define _CCMP_PRIVACY_ 4 - * #define _WEP_104_PRIVACY_ 5 - * #define _WEP_WPA_MIXED_PRIVACY_ 6 WEP + WPA - */ - -/*----------------------------------------------------------------------------- - Below is the definition for WMM -------------------------------------------------------------------------------*/ -#define _WMM_IE_Length_ 7 /* for WMM STA */ - -/*----------------------------------------------------------------------------- - Below is the definition for 802.11n -------------------------------------------------------------------------------*/ - -/** - * struct rtw_ieee80211_ht_cap - HT additional information - * - * This structure refers to "HT information element" as - * described in 802.11n draft section 7.3.2.53 - */ -struct ieee80211_ht_addt_info { - unsigned char control_chan; - unsigned char ht_param; - unsigned short operation_mode; - unsigned short stbc_param; - unsigned char basic_set[16]; -} __packed; - -struct HT_info_element { - unsigned char primary_channel; - unsigned char infos[5]; - unsigned char MCS_rate[16]; -} __packed; - -struct AC_param { - unsigned char ACI_AIFSN; - unsigned char CW; - __le16 TXOP_limit; -} __packed; - -struct WMM_para_element { - unsigned char QoS_info; - unsigned char reserved; - struct AC_param ac_param[4]; -} __packed; - -struct ADDBA_request { - unsigned char dialog_token; - __le16 BA_para_set; - unsigned short BA_timeout_value; - unsigned short BA_starting_seqctrl; -} __packed; - -enum ht_cap_ampdu_factor { - MAX_AMPDU_FACTOR_8K = 0, - MAX_AMPDU_FACTOR_16K = 1, - MAX_AMPDU_FACTOR_32K = 2, - MAX_AMPDU_FACTOR_64K = 3, -}; - -#define OP_MODE_PURE 0 -#define OP_MODE_MAY_BE_LEGACY_STAS 1 -#define OP_MODE_20MHZ_HT_STA_ASSOCED 2 -#define OP_MODE_MIXED 3 - -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_OFF_MASK ((u8)BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_ABOVE ((u8)BIT(0)) -#define HT_INFO_HT_PARAM_SECONDARY_CHNL_BELOW ((u8)BIT(0) | BIT(1)) -#define HT_INFO_HT_PARAM_REC_TRANS_CHNL_WIDTH ((u8)BIT(2)) -#define HT_INFO_HT_PARAM_RIFS_MODE ((u8)BIT(3)) -#define HT_INFO_HT_PARAM_CTRL_ACCESS_ONLY ((u8)BIT(4)) -#define HT_INFO_HT_PARAM_SRV_INTERVAL_GRANULARITY ((u8)BIT(5)) - -#define HT_INFO_OPERATION_MODE_OP_MODE_MASK \ - ((u16)(0x0001 | 0x0002)) -#define HT_INFO_OPERATION_MODE_OP_MODE_OFFSET 0 -#define HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT ((u8)BIT(2)) -#define HT_INFO_OPERATION_MODE_TRANSMIT_BURST_LIMIT ((u8)BIT(3)) -#define HT_INFO_OPERATION_MODE_NON_HT_STA_PRESENT ((u8)BIT(4)) - -/* ===============WPS Section=============== */ -/* For WPSv1.0 */ -#define WPSOUI 0x0050f204 -/* WPS attribute ID */ -#define WPS_ATTR_VER1 0x104A -#define WPS_ATTR_SIMPLE_CONF_STATE 0x1044 -#define WPS_ATTR_RESP_TYPE 0x103B -#define WPS_ATTR_UUID_E 0x1047 -#define WPS_ATTR_MANUFACTURER 0x1021 -#define WPS_ATTR_MODEL_NAME 0x1023 -#define WPS_ATTR_MODEL_NUMBER 0x1024 -#define WPS_ATTR_SERIAL_NUMBER 0x1042 -#define WPS_ATTR_PRIMARY_DEV_TYPE 0x1054 -#define WPS_ATTR_SEC_DEV_TYPE_LIST 0x1055 -#define WPS_ATTR_DEVICE_NAME 0x1011 -#define WPS_ATTR_CONF_METHOD 0x1008 -#define WPS_ATTR_RF_BANDS 0x103C -#define WPS_ATTR_DEVICE_PWID 0x1012 -#define WPS_ATTR_REQUEST_TYPE 0x103A -#define WPS_ATTR_ASSOCIATION_STATE 0x1002 -#define WPS_ATTR_CONFIG_ERROR 0x1009 -#define WPS_ATTR_VENDOR_EXT 0x1049 -#define WPS_ATTR_SELECTED_REGISTRAR 0x1041 - -/* Value of WPS Request Type Attribute */ -#define WPS_REQ_TYPE_ENROLLEE_INFO_ONLY 0x00 -#define WPS_REQ_TYPE_ENROLLEE_OPEN_8021X 0x01 -#define WPS_REQ_TYPE_REGISTRAR 0x02 -#define WPS_REQ_TYPE_WLAN_MANAGER_REGISTRAR 0x03 - -/* Value of WPS Response Type Attribute */ -#define WPS_RESPONSE_TYPE_INFO_ONLY 0x00 -#define WPS_RESPONSE_TYPE_8021X 0x01 -#define WPS_RESPONSE_TYPE_REGISTRAR 0x02 -#define WPS_RESPONSE_TYPE_AP 0x03 - -/* Value of WPS WiFi Simple Configuration State Attribute */ -#define WPS_WSC_STATE_NOT_CONFIG 0x01 -#define WPS_WSC_STATE_CONFIG 0x02 - -/* Value of WPS Version Attribute */ -#define WPS_VERSION_1 0x10 - -/* Value of WPS Configuration Method Attribute */ -#define WPS_CONFIG_METHOD_FLASH 0x0001 -#define WPS_CONFIG_METHOD_ETHERNET 0x0002 -#define WPS_CONFIG_METHOD_LABEL 0x0004 -#define WPS_CONFIG_METHOD_DISPLAY 0x0008 -#define WPS_CONFIG_METHOD_E_NFC 0x0010 -#define WPS_CONFIG_METHOD_I_NFC 0x0020 -#define WPS_CONFIG_METHOD_NFC 0x0040 -#define WPS_CONFIG_METHOD_PBC 0x0080 -#define WPS_CONFIG_METHOD_KEYPAD 0x0100 -#define WPS_CONFIG_METHOD_VPBC 0x0280 -#define WPS_CONFIG_METHOD_PPBC 0x0480 -#define WPS_CONFIG_METHOD_VDISPLAY 0x2008 -#define WPS_CONFIG_METHOD_PDISPLAY 0x4008 - -/* Value of WPS RF Bands Attribute */ -#define WPS_RF_BANDS_2_4_GHZ 0x01 -#define WPS_RF_BANDS_5_GHZ 0x02 - -#define IP_MCAST_MAC(mac) \ - ((mac[0] == 0x01) && (mac[1] == 0x00) && (mac[2] == 0x5e)) -#define ICMPV6_MCAST_MAC(mac) \ - ((mac[0] == 0x33) && (mac[1] == 0x33) && (mac[2] != 0xff)) - -#endif /* _WIFI_H_ */ diff --git a/drivers/staging/rtl8188eu/include/wlan_bssdef.h b/drivers/staging/rtl8188eu/include/wlan_bssdef.h deleted file mode 100644 index 350bbf9057b8..000000000000 --- a/drivers/staging/rtl8188eu/include/wlan_bssdef.h +++ /dev/null @@ -1,240 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __WLAN_BSSDEF_H__ -#define __WLAN_BSSDEF_H__ - -#define MAX_IE_SZ 768 - -#define NDIS_802_11_LENGTH_SSID 32 -#define NDIS_802_11_LENGTH_RATES 8 -#define NDIS_802_11_LENGTH_RATES_EX 16 - -#define NDIS_802_11_RSSI long /* in dBm */ - -struct ndis_802_11_ssid { - u32 ssid_length; - u8 ssid[32]; -}; - -enum NDIS_802_11_NETWORK_TYPE { - Ndis802_11FH, - Ndis802_11DS, - Ndis802_11OFDM5, - Ndis802_11OFDM24, - Ndis802_11NetworkTypeMax /* dummy upper bound */ -}; - -struct ndis_802_11_config_fh { - u32 Length; /* Length of structure */ - u32 HopPattern; /* As defined by 802.11, MSB set */ - u32 HopSet; /* to one if non-802.11 */ - u32 DwellTime; /* units are Kusec */ -}; - -/* - * FW will only save the channel number in DSConfig. - * ODI Handler will convert the channel number to freq. number. - */ -struct ndis_802_11_config { - u32 Length; /* Length of structure */ - u32 BeaconPeriod; /* units are Kusec */ - u32 ATIMWindow; /* units are Kusec */ - u32 DSConfig; /* Frequency, units are kHz */ - struct ndis_802_11_config_fh FHConfig; -}; - -enum ndis_802_11_network_infra { - Ndis802_11IBSS, - Ndis802_11Infrastructure, - Ndis802_11AutoUnknown, - Ndis802_11InfrastructureMax, /* dummy upper bound */ - Ndis802_11APMode -}; - -struct ndis_802_11_fixed_ie { - u8 Timestamp[8]; - u16 BeaconInterval; - u16 Capabilities; -}; - -struct ndis_802_11_var_ie { - u8 ElementID; - u8 Length; - u8 data[]; -}; - -/* - * Length is the 4 bytes multiples of the sume of - * [ETH_ALEN] + 2 + sizeof (struct ndis_802_11_ssid) + sizeof (u32) - * + sizeof (NDIS_802_11_RSSI) + sizeof (enum NDIS_802_11_NETWORK_TYPE) - * + sizeof (struct ndis_802_11_config) - * + NDIS_802_11_LENGTH_RATES_EX + ie_length - * - * Except the ie_length, all other fields are fixed length. - * Therefore, we can define a macro to represent the partial sum. - */ - -enum ndis_802_11_auth_mode { - Ndis802_11AuthModeOpen, - Ndis802_11AuthModeShared, - Ndis802_11AuthModeAutoSwitch, - Ndis802_11AuthModeWPA, - Ndis802_11AuthModeWPAPSK, - Ndis802_11AuthModeWPANone, - Ndis802_11AuthModeWAPI, - Ndis802_11AuthModeMax /* Not a real mode, upper bound */ -}; - -enum ndis_802_11_wep_status { - Ndis802_11WEPEnabled, - Ndis802_11Encryption1Enabled = Ndis802_11WEPEnabled, - Ndis802_11WEPDisabled, - Ndis802_11EncryptionDisabled = Ndis802_11WEPDisabled, - Ndis802_11WEPKeyAbsent, - Ndis802_11Encryption1KeyAbsent = Ndis802_11WEPKeyAbsent, - Ndis802_11WEPNotSupported, - Ndis802_11EncryptionNotSupported = Ndis802_11WEPNotSupported, - Ndis802_11Encryption2Enabled, - Ndis802_11Encryption2KeyAbsent, - Ndis802_11Encryption3Enabled, - Ndis802_11Encryption3KeyAbsent, - Ndis802_11_EncryptionWAPI -}; - -#define NDIS_802_11_AI_REQFI_CAPABILITIES 1 -#define NDIS_802_11_AI_REQFI_LISTENINTERVAL 2 -#define NDIS_802_11_AI_REQFI_CURRENTAPADDRESS 4 - -#define NDIS_802_11_AI_RESFI_CAPABILITIES 1 -#define NDIS_802_11_AI_RESFI_STATUSCODE 2 -#define NDIS_802_11_AI_RESFI_ASSOCIATIONID 4 - -enum ndis_802_11_reload_def { - Ndis802_11ReloadWEPKeys -}; - -struct ndis_802_11_wep { - u32 Length; /* Length of this structure */ - u32 KeyIndex; /* 0 is the per-client key, - * 1-N are the global keys - */ - u32 KeyLength; /* length of key in bytes */ - u8 KeyMaterial[16];/* variable len depending on above field */ -}; - -enum ndis_802_11_status_type { - Ndis802_11StatusType_Authentication, - Ndis802_11StatusType_MediaStreamMode, - Ndis802_11StatusType_PMKID_CandidateList, - Ndis802_11StatusTypeMax /* not a real type, defined as - * an upper bound - */ -}; - -/* mask for authentication/integrity fields */ -#define NDIS_802_11_AUTH_REQUEST_AUTH_FIELDS 0x0f -#define NDIS_802_11_AUTH_REQUEST_REAUTH 0x01 -#define NDIS_802_11_AUTH_REQUEST_KEYUPDATE 0x02 -#define NDIS_802_11_AUTH_REQUEST_PAIRWISE_ERROR 0x06 -#define NDIS_802_11_AUTH_REQUEST_GROUP_ERROR 0x0E - -/* MIC check time, 60 seconds. */ -#define MIC_CHECK_TIME 60000000 - -#ifndef Ndis802_11APMode -#define Ndis802_11APMode (Ndis802_11InfrastructureMax + 1) -#endif - -struct wlan_phy_info { - u8 SignalStrength;/* in percentage) */ - u8 SignalQuality;/* in percentage) */ - u8 Optimum_antenna; /* for Antenna diversity */ - u8 Reserved_0; -}; - -struct wlan_bcn_info { - /* these infor get from rtw_get_encrypt_info when - * * translate scan to UI - */ - u8 encryp_protocol;/* ENCRYP_PROTOCOL_E: OPEN/WEP/WPA/WPA2/WAPI */ - int group_cipher; /* WPA/WPA2 group cipher */ - int pairwise_cipher;/* WPA/WPA2/WEP pairwise cipher */ - int is_8021x; - - /* bwmode 20/40 and ch_offset UP/LOW */ - unsigned short ht_cap_info; - unsigned char ht_info_infos_0; -}; - -/* temporally add #pragma pack for structure alignment issue of - * struct wlan_bssid_ex and get_struct wlan_bssid_ex_sz() - */ -struct wlan_bssid_ex { - u32 Length; - unsigned char MacAddress[ETH_ALEN]; - u8 Reserved[2];/* 0]: IS beacon frame */ - struct ndis_802_11_ssid ssid; - u32 Privacy; - NDIS_802_11_RSSI Rssi;/* in dBM,raw data ,get from PHY) */ - enum NDIS_802_11_NETWORK_TYPE NetworkTypeInUse; - struct ndis_802_11_config Configuration; - enum ndis_802_11_network_infra InfrastructureMode; - unsigned char SupportedRates[NDIS_802_11_LENGTH_RATES_EX]; - struct wlan_phy_info PhyInfo; - u32 ie_length; - u8 ies[MAX_IE_SZ]; /* timestamp, beacon interval, and - * capability information) - */ -} __packed; - -static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) -{ - return sizeof(struct wlan_bssid_ex) - MAX_IE_SZ + bss->ie_length; -} - -struct wlan_network { - struct list_head list; - int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */ - int fixed; /* set fixed when not to be removed - * in site-surveying - */ - unsigned long last_scanned; /* timestamp for the network */ - int aid; /* will only be valid when a BSS is joinned. */ - int join_res; - struct wlan_bssid_ex network; /* must be the last item */ - struct wlan_bcn_info BcnInfo; -}; - -enum VRTL_CARRIER_SENSE { - DISABLE_VCS, - ENABLE_VCS, - AUTO_VCS -}; - -enum VCS_TYPE { - NONE_VCS, - RTS_CTS, - CTS_TO_SELF -}; - -#define PWR_CAM 0 -#define PWR_MINPS 1 -#define PWR_MAXPS 2 -#define PWR_UAPSD 3 -#define PWR_VOIP 4 - -enum UAPSD_MAX_SP { - NO_LIMIT, - TWO_MSDU, - FOUR_MSDU, - SIX_MSDU -}; - -#define NUM_PRE_AUTH_KEY 16 -#define NUM_PMKID_CACHE NUM_PRE_AUTH_KEY - -#endif /* ifndef WLAN_BSSDEF_H_ */ diff --git a/drivers/staging/rtl8188eu/include/xmit_osdep.h b/drivers/staging/rtl8188eu/include/xmit_osdep.h deleted file mode 100644 index 5fd8ca51f156..000000000000 --- a/drivers/staging/rtl8188eu/include/xmit_osdep.h +++ /dev/null @@ -1,32 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __XMIT_OSDEP_H_ -#define __XMIT_OSDEP_H_ - -#include -#include - -#define NR_XMITFRAME 256 - -struct xmit_priv; -struct pkt_attrib; -struct sta_xmit_priv; -struct xmit_frame; -struct xmit_buf; - -int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev); - -void rtw_os_xmit_schedule(struct adapter *padapter); - -int rtw_os_xmit_resource_alloc(struct xmit_buf *pxmitbuf, u32 alloc_sz); -void rtw_os_xmit_resource_free(struct xmit_buf *pxmitbuf); - -void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt); -void rtw_os_xmit_complete(struct adapter *padapter, - struct xmit_frame *pxframe); - -#endif /* __XMIT_OSDEP_H_ */ diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c deleted file mode 100644 index fddc8dd6632f..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c +++ /dev/null @@ -1,2699 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _IOCTL_LINUX_C_ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "osdep_intf.h" - -#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) - -#define SCAN_ITEM_SIZE 768 -#define MAX_CUSTOM_LEN 64 -#define RATE_COUNT 4 - -/* combo scan */ -#define WEXT_CSCAN_AMOUNT 9 -#define WEXT_CSCAN_BUF_LEN 360 -#define WEXT_CSCAN_HEADER "CSCAN S\x01\x00\x00S\x00" -#define WEXT_CSCAN_HEADER_SIZE 12 -#define WEXT_CSCAN_SSID_SECTION 'S' -#define WEXT_CSCAN_CHANNEL_SECTION 'C' -#define WEXT_CSCAN_NPROBE_SECTION 'N' -#define WEXT_CSCAN_ACTV_DWELL_SECTION 'A' -#define WEXT_CSCAN_PASV_DWELL_SECTION 'P' -#define WEXT_CSCAN_HOME_DWELL_SECTION 'H' -#define WEXT_CSCAN_TYPE_SECTION 'T' - -static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, - 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, - 48000000, 54000000}; - -void indicate_wx_scan_complete_event(struct adapter *padapter) -{ - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(union iwreq_data)); - wireless_send_event(padapter->pnetdev, SIOCGIWSCAN, &wrqu, NULL); -} - -void rtw_indicate_wx_assoc_event(struct adapter *padapter) -{ - union iwreq_data wrqu; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - memset(&wrqu, 0, sizeof(union iwreq_data)); - - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.MacAddress, ETH_ALEN); - - wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); -} - -void rtw_indicate_wx_disassoc_event(struct adapter *padapter) -{ - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(union iwreq_data)); - - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - eth_zero_addr(wrqu.ap_addr.sa_data); - - wireless_send_event(padapter->pnetdev, SIOCGIWAP, &wrqu, NULL); -} - -static char *translate_scan(struct adapter *padapter, - struct iw_request_info *info, - struct wlan_network *pnetwork, - char *start, char *stop) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct iw_event iwe; - u16 cap; - __le16 le_tmp; - u32 ht_ielen = 0; - char custom[MAX_CUSTOM_LEN]; - char *p; - u16 max_rate = 0, rate, ht_cap = false; - u32 i = 0; - u8 bw_40MHz = 0, short_GI = 0; - u16 mcs_rate = 0; - u8 ss, sq; - - /* AP MAC address */ - iwe.cmd = SIOCGIWAP; - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - - memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.MacAddress, ETH_ALEN); - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); - - /* Add the ESSID */ - iwe.cmd = SIOCGIWESSID; - iwe.u.data.flags = 1; - iwe.u.data.length = min_t(u16, pnetwork->network.ssid.ssid_length, 32); - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); - - /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pnetwork->network.ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length - 12); - - if (p && ht_ielen > 0) { - struct ieee80211_ht_cap *pht_capie; - - ht_cap = true; - - pht_capie = (struct ieee80211_ht_cap *)(p + 2); - memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); - bw_40MHz = !!(le16_to_cpu(pht_capie->cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH_20_40); - short_GI = !!(le16_to_cpu(pht_capie->cap_info) & - (IEEE80211_HT_CAP_SGI_20 | - IEEE80211_HT_CAP_SGI_40)); - } - - /* Add the protocol name */ - iwe.cmd = SIOCGIWNAME; - if ((rtw_is_cckratesonly_included((u8 *)&pnetwork->network.SupportedRates))) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((rtw_is_cckrates_included((u8 *)&pnetwork->network.SupportedRates))) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); - } else { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); - } - - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); - - /* Add mode */ - iwe.cmd = SIOCGIWMODE; - memcpy(&le_tmp, rtw_get_capability_from_ie(pnetwork->network.ies), 2); - - cap = le16_to_cpu(le_tmp); - - if (!WLAN_CAPABILITY_IS_STA_BSS(cap)) { - if (cap & WLAN_CAPABILITY_ESS) - iwe.u.mode = IW_MODE_MASTER; - else - iwe.u.mode = IW_MODE_ADHOC; - - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); - } - - if (pnetwork->network.Configuration.DSConfig < 1) - pnetwork->network.Configuration.DSConfig = 1; - - /* Add frequency/channel */ - iwe.cmd = SIOCGIWFREQ; - iwe.u.freq.m = rtw_ch2freq(pnetwork->network.Configuration.DSConfig) * 100000; - iwe.u.freq.e = 1; - iwe.u.freq.i = pnetwork->network.Configuration.DSConfig; - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); - - /* Add encryption capability */ - iwe.cmd = SIOCGIWENCODE; - if (cap & WLAN_CAPABILITY_PRIVACY) - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - else - iwe.u.data.flags = IW_ENCODE_DISABLED; - iwe.u.data.length = 0; - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); - - /*Add basic and extended rates */ - max_rate = 0; - p = custom; - p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - while (pnetwork->network.SupportedRates[i] != 0) { - rate = pnetwork->network.SupportedRates[i] & 0x7F; - if (rate > max_rate) - max_rate = rate; - p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), - "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); - i++; - } - - if (ht_cap) { - if (mcs_rate & 0x8000)/* MCS15 */ - max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); - else if (mcs_rate & 0x0080)/* MCS7 */ - ; - else/* default MCS7 */ - max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); - - max_rate *= 2; /* Mbps/2; */ - } - - iwe.cmd = SIOCGIWRATE; - iwe.u.bitrate.fixed = 0; - iwe.u.bitrate.disabled = 0; - iwe.u.bitrate.value = max_rate * 500000; - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); - - /* parsing WPA/WPA2 IE */ - { - u8 *buf; - u8 *wpa_ie, *rsn_ie; - u16 wpa_len = 0, rsn_len = 0; - u8 *p; - - buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC); - if (!buf) - return start; - - wpa_ie = kzalloc(255, GFP_ATOMIC); - if (!wpa_ie) - return start; - - rsn_ie = kzalloc(255, GFP_ATOMIC); - if (!rsn_ie) - return start; - - rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len); - - if (wpa_len > 0) { - p = buf; - p += sprintf(p, "wpa_ie="); - for (i = 0; i < wpa_len; i++) - p += sprintf(p, "%02x", wpa_ie[i]); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = wpa_len; - start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); - } - if (rsn_len > 0) { - p = buf; - p += sprintf(p, "rsn_ie="); - for (i = 0; i < rsn_len; i++) - p += sprintf(p, "%02x", rsn_ie[i]); - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = rsn_len; - start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); - } - kfree(buf); - kfree(wpa_ie); - kfree(rsn_ie); - } - - {/* parsing WPS IE */ - uint cnt = 0, total_ielen; - u8 *wpsie_ptr = NULL; - uint wps_ielen = 0; - u8 *ie_ptr = pnetwork->network.ies + _FIXED_IE_LENGTH_; - - total_ielen = pnetwork->network.ie_length - _FIXED_IE_LENGTH_; - - while (cnt < total_ielen) { - if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) { - wpsie_ptr = &ie_ptr[cnt]; - iwe.cmd = IWEVGENIE; - iwe.u.data.length = (u16)wps_ielen; - start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); - } - cnt += ie_ptr[cnt + 1] + 2; /* goto next */ - } - } - - /* Add quality statistics */ - iwe.cmd = IWEVQUAL; - iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; - - if (check_fwstate(pmlmepriv, _FW_LINKED) && - is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { - ss = padapter->recvpriv.signal_strength; - sq = padapter->recvpriv.signal_qual; - } else { - ss = pnetwork->network.PhyInfo.SignalStrength; - sq = pnetwork->network.PhyInfo.SignalQuality; - } - - iwe.u.qual.level = (u8)ss; - iwe.u.qual.qual = (u8)sq; /* signal quality */ - iwe.u.qual.noise = 0; /* noise level */ - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); - return start; -} - -static int wpa_set_auth_algs(struct net_device *dev, u32 value) -{ - struct adapter *padapter = netdev_priv(dev); - int ret = 0; - - if ((value & AUTH_ALG_SHARED_KEY) && (value & AUTH_ALG_OPEN_SYSTEM)) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeAutoSwitch; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Auto; - } else if (value & AUTH_ALG_SHARED_KEY) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeShared; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; - } else if (value & AUTH_ALG_OPEN_SYSTEM) { - if (padapter->securitypriv.ndisauthtype < Ndis802_11AuthModeWPAPSK) { - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - } - } else { - ret = -EINVAL; - } - return ret; -} - -static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) -{ - int ret = 0; - u32 wep_key_idx, wep_key_len, wep_total_len; - struct ndis_802_11_wep *pwep = NULL; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - - param->u.crypt.err = 0; - param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - - if (param_len < (u32)((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { - ret = -EINVAL; - goto exit; - } - - if (is_broadcast_ether_addr(param->sta_addr)) { - if (param->u.crypt.idx >= WEP_KEYS) { - ret = -EINVAL; - goto exit; - } - } else { - ret = -EINVAL; - goto exit; - } - - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; - - wep_key_idx = param->u.crypt.idx; - wep_key_len = param->u.crypt.key_len; - - if (wep_key_idx > WEP_KEYS) - return -EINVAL; - - if (wep_key_len > 0) { - wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = wep_key_len + offsetof(struct ndis_802_11_wep, KeyMaterial); - pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); - if (!pwep) - goto exit; - memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; - if (wep_key_len == 13) { - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; - } - } else { - ret = -EINVAL; - goto exit; - } - pwep->KeyIndex = wep_key_idx; - pwep->KeyIndex |= 0x80000000; - memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); - if (param->u.crypt.set_tx) { - if (rtw_set_802_11_add_wep(padapter, pwep) == (u8)_FAIL) - ret = -EOPNOTSUPP; - } else { - if (wep_key_idx >= WEP_KEYS) { - ret = -EOPNOTSUPP; - goto exit; - } - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; - rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); - } - goto exit; - } - - if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { /* 802_1x */ - struct sta_info *psta, *pbcmc_sta; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* sta mode */ - psta = rtw_get_stainfo(pstapriv, get_bssid(pmlmepriv)); - if (!psta) { - ; - } else { - if (strcmp(param->u.crypt.alg, "none") != 0) - psta->ieee8021x_blocked = false; - - if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || - (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) - psta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; - - if (param->u.crypt.set_tx == 1) { /* pairwise key */ - memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - - if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */ - memcpy(psta->dot11tkiptxmickey.skey, ¶m->u.crypt.key[16], 8); - memcpy(psta->dot11tkiprxmickey.skey, ¶m->u.crypt.key[24], 8); - padapter->securitypriv.busetkipkey = false; - } - - rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); - } else { /* group key */ - memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); - memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); - padapter->securitypriv.binstallGrpkey = true; - - padapter->securitypriv.dot118021XGrpKeyid = param->u.crypt.idx; - - rtw_set_key(padapter, &padapter->securitypriv, param->u.crypt.idx, 1); - } - } - pbcmc_sta = rtw_get_bcmc_stainfo(padapter); - if (!pbcmc_sta) { - ; - } else { - /* Jeff: don't disable ieee8021x_blocked while clearing key */ - if (strcmp(param->u.crypt.alg, "none") != 0) - pbcmc_sta->ieee8021x_blocked = false; - - if ((padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption2Enabled) || - (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption3Enabled)) - pbcmc_sta->dot118021XPrivacy = padapter->securitypriv.dot11PrivacyAlgrthm; - } - } - } - -exit: - - kfree(pwep); - return ret; -} - -static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ielen) -{ - u8 *buf = NULL; - int group_cipher = 0, pairwise_cipher = 0; - int ret = 0; - - if ((ielen > MAX_WPA_IE_LEN) || (!pie)) { - _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); - if (!pie) - return ret; - else - return -EINVAL; - } - - if (ielen) { - buf = kmemdup(pie, ielen, GFP_KERNEL); - if (!buf) { - ret = -ENOMEM; - goto exit; - } - - if (ielen < RSN_HEADER_LEN) { - ret = -1; - goto exit; - } - - if (rtw_parse_wpa_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; - memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); - } - - if (rtw_parse_wpa2_ie(buf, ielen, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; - memcpy(padapter->securitypriv.supplicant_ie, &buf[0], ielen); - } - - switch (group_cipher) { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot118021XGrpPrivacy = _TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot118021XGrpPrivacy = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot118021XGrpPrivacy = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - } - - switch (pairwise_cipher) { - case WPA_CIPHER_NONE: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - break; - case WPA_CIPHER_WEP40: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - case WPA_CIPHER_TKIP: - padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - } - - _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); - {/* set wps_ie */ - u16 cnt = 0; - u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - while (cnt < ielen) { - eid = buf[cnt]; - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&buf[cnt + 2], wps_oui, 4))) { - padapter->securitypriv.wps_ie_len = min(buf[cnt + 1] + 2, MAX_WPA_IE_LEN << 2); - - memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); - - set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); - cnt += buf[cnt + 1] + 2; - break; - } - cnt += buf[cnt + 1] + 2; /* goto next */ - } - } - } -exit: - kfree(buf); - return ret; -} - -typedef unsigned char NDIS_802_11_RATES_EX[NDIS_802_11_LENGTH_RATES_EX]; - -static int rtw_wx_get_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - u32 ht_ielen = 0; - char *p; - u8 ht_cap = false; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - NDIS_802_11_RATES_EX *prates = NULL; - - if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { - /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->ie_length - 12); - if (p && ht_ielen > 0) - ht_cap = true; - - prates = &pcur_bss->SupportedRates; - - if (rtw_is_cckratesonly_included((u8 *)prates)) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if (rtw_is_cckrates_included((u8 *)prates)) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); - } else { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); - } - } else { - snprintf(wrqu->name, IFNAMSIZ, "unassociated"); - } - return 0; -} - -static int rtw_wx_get_freq(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->Configuration.DSConfig-1] * 100000; */ - wrqu->freq.m = rtw_ch2freq(pcur_bss->Configuration.DSConfig) * 100000; - wrqu->freq.e = 1; - wrqu->freq.i = pcur_bss->Configuration.DSConfig; - } else { - wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; - wrqu->freq.e = 1; - wrqu->freq.i = padapter->mlmeextpriv.cur_channel; - } - - return 0; -} - -static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct adapter *padapter = netdev_priv(dev); - enum ndis_802_11_network_infra networkType; - int ret = 0; - - if (!rtw_pwr_wakeup(padapter)) { - ret = -EPERM; - goto exit; - } - - if (!padapter->hw_init_completed) { - ret = -EPERM; - goto exit; - } - - switch (wrqu->mode) { - case IW_MODE_AUTO: - networkType = Ndis802_11AutoUnknown; - break; - case IW_MODE_ADHOC: - networkType = Ndis802_11IBSS; - break; - case IW_MODE_MASTER: - networkType = Ndis802_11APMode; - break; - case IW_MODE_INFRA: - networkType = Ndis802_11Infrastructure; - break; - default: - ret = -EINVAL; - goto exit; - } - if (!rtw_set_802_11_infrastructure_mode(padapter, networkType)) { - ret = -EPERM; - goto exit; - } - rtw_setopmode_cmd(padapter, networkType); -exit: - return ret; -} - -static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - wrqu->mode = IW_MODE_INFRA; - else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) - wrqu->mode = IW_MODE_ADHOC; - else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) - wrqu->mode = IW_MODE_MASTER; - else - wrqu->mode = IW_MODE_AUTO; - - return 0; -} - -static int rtw_wx_set_pmkid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - u8 j, blInserted = false; - int ret = false; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct iw_pmksa *pPMK = (struct iw_pmksa *)extra; - u8 strZeroMacAddress[ETH_ALEN] = {0x00}; - u8 strIssueBssid[ETH_ALEN] = {0x00}; - - memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); - if (pPMK->cmd == IW_PMKSA_ADD) { - if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN)) - return ret; - ret = true; - blInserted = false; - - /* overwrite PMKID */ - for (j = 0; j < NUM_PMKID_CACHE; j++) { - if (!memcmp(psecuritypriv->PMKIDList[j].bssid, strIssueBssid, ETH_ALEN)) { - /* BSSID is matched, the same AP => rewrite with new PMKID. */ - memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); - psecuritypriv->PMKIDList[j].used = true; - psecuritypriv->PMKIDIndex = j + 1; - blInserted = true; - break; - } - } - - if (!blInserted) { - /* Find a new entry */ - memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bssid, strIssueBssid, ETH_ALEN); - memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); - - psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].used = true; - psecuritypriv->PMKIDIndex++; - if (psecuritypriv->PMKIDIndex == 16) - psecuritypriv->PMKIDIndex = 0; - } - } else if (pPMK->cmd == IW_PMKSA_REMOVE) { - ret = true; - for (j = 0; j < NUM_PMKID_CACHE; j++) { - if (!memcmp(psecuritypriv->PMKIDList[j].bssid, strIssueBssid, ETH_ALEN)) { - /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ - eth_zero_addr(psecuritypriv->PMKIDList[j].bssid); - psecuritypriv->PMKIDList[j].used = false; - break; - } - } - } else if (pPMK->cmd == IW_PMKSA_FLUSH) { - memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - psecuritypriv->PMKIDIndex = 0; - ret = true; - } - return ret; -} - -static int rtw_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wrqu->sens.value = 0; - wrqu->sens.fixed = 0; /* no auto select */ - wrqu->sens.disabled = 1; - return 0; -} - -static int rtw_wx_get_range(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_range *range = (struct iw_range *)extra; - struct adapter *padapter = netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - u16 val; - int i; - - wrqu->data.length = sizeof(*range); - memset(range, 0, sizeof(*range)); - - /* Let's try to keep this struct in the same order as in - * linux/include/wireless.h - */ - - /* TODO: See what values we can set, and remove the ones we can't - * set, or fill them with some default data. - */ - - /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; - - /* signal level threshold range */ - - /* percent values between 0 and 100. */ - range->max_qual.qual = 100; - range->max_qual.level = 100; - range->max_qual.noise = 100; - range->max_qual.updated = 7; /* Updated all three */ - - range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ - /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ - range->avg_qual.level = 178; /* -78 dBm */ - range->avg_qual.noise = 0; - range->avg_qual.updated = 7; /* Updated all three */ - - range->num_bitrates = RATE_COUNT; - - for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) - range->bitrate[i] = rtw_rates[i]; - - range->min_frag = MIN_FRAG_THRESHOLD; - range->max_frag = MAX_FRAG_THRESHOLD; - - range->pm_capa = 0; - - range->we_version_compiled = WIRELESS_EXT; - range->we_version_source = 16; - - for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { - /* Include only legal frequencies for some countries */ - if (pmlmeext->channel_set[i].ChannelNum != 0) { - range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; - range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; - range->freq[val].e = 1; - val++; - } - - if (val == IW_MAX_FREQUENCIES) - break; - } - - range->num_channels = val; - range->num_frequency = val; - -/* The following code will proivde the security capability to network manager. */ -/* If the driver doesn't provide this capability to network manager, */ -/* the WPA/WPA2 routers can't be chosen in the network manager. */ - - range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | - IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; - - range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | - IW_SCAN_CAPA_BSSID | IW_SCAN_CAPA_CHANNEL | - IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; - return 0; -} - -/* set bssid flow */ -/* s1. rtw_set_802_11_infrastructure_mode() */ -/* s2. rtw_set_802_11_authentication_mode() */ -/* s3. set_802_11_encryption_mode() */ -/* s4. rtw_set_802_11_bssid() */ -static int rtw_wx_set_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, char *extra) -{ - uint ret = 0; - struct adapter *padapter = netdev_priv(dev); - struct sockaddr *temp = (struct sockaddr *)awrq; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct list_head *phead; - u8 *dst_bssid, *src_bssid; - struct __queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - enum ndis_802_11_auth_mode authmode; - - if (!rtw_pwr_wakeup(padapter)) { - ret = -1; - goto exit; - } - - if (!padapter->bup) { - ret = -1; - goto exit; - } - - if (temp->sa_family != ARPHRD_ETHER) { - ret = -EINVAL; - goto exit; - } - - authmode = padapter->securitypriv.ndisauthtype; - spin_lock_bh(&queue->lock); - phead = get_list_head(queue); - list_for_each(pmlmepriv->pscanned, phead) { - pnetwork = list_entry(pmlmepriv->pscanned, - struct wlan_network, list); - - dst_bssid = pnetwork->network.MacAddress; - - src_bssid = temp->sa_data; - - if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { - if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { - ret = -1; - spin_unlock_bh(&queue->lock); - goto exit; - } - - break; - } - } - spin_unlock_bh(&queue->lock); - - rtw_set_802_11_authentication_mode(padapter, authmode); - if (!rtw_set_802_11_bssid(padapter, temp->sa_data)) { - ret = -1; - goto exit; - } - -exit: - - return ret; -} - -static int rtw_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - - wrqu->ap_addr.sa_family = ARPHRD_ETHER; - - eth_zero_addr(wrqu->ap_addr.sa_data); - - if (check_fwstate(pmlmepriv, _FW_LINKED) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || - check_fwstate(pmlmepriv, WIFI_AP_STATE)) - memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); - else - eth_zero_addr(wrqu->ap_addr.sa_data); - return 0; -} - -static int rtw_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = netdev_priv(dev); - struct iw_mlme *mlme = (struct iw_mlme *)extra; - - if (!mlme) - return -1; - - switch (mlme->cmd) { - case IW_MLME_DEAUTH: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - case IW_MLME_DISASSOC: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - default: - return -EOPNOTSUPP; - } - return ret; -} - -static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - u8 _status = false; - int ret = 0; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; - - if (!rtw_pwr_wakeup(padapter)) { - ret = -1; - goto exit; - } - - if (padapter->bDriverStopped) { - ret = -1; - goto exit; - } - - if (!padapter->bup) { - ret = -1; - goto exit; - } - - if (!padapter->hw_init_completed) { - ret = -1; - goto exit; - } - - /* When Busy Traffic, driver do not site survey. So driver return success. */ - /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ - /* modify by thomas 2011-02-22. */ - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { - indicate_wx_scan_complete_event(padapter); - goto exit; - } - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) { - indicate_wx_scan_complete_event(padapter); - goto exit; - } - -/* For the DMP WiFi Display project, the driver won't to scan because */ -/* the pmlmepriv->scan_interval is always equal to 3. */ -/* So, the wpa_supplicant won't find out the WPS SoftAP. */ - - memset(ssid, 0, sizeof(struct ndis_802_11_ssid) * RTW_SSID_SCAN_AMOUNT); - - if (wrqu->data.length == sizeof(struct iw_scan_req)) { - struct iw_scan_req *req = (struct iw_scan_req *)extra; - - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { - int len = min_t(int, req->essid_len, - IW_ESSID_MAX_SIZE); - - memcpy(ssid[0].ssid, req->essid, len); - ssid[0].ssid_length = len; - - spin_lock_bh(&pmlmepriv->lock); - - _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); - - spin_unlock_bh(&pmlmepriv->lock); - } - } else { - if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && - !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { - int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; - char *pos = extra + WEXT_CSCAN_HEADER_SIZE; - char section; - char sec_len; - int ssid_index = 0; - - while (len >= 1) { - section = *(pos++); - len -= 1; - - switch (section) { - case WEXT_CSCAN_SSID_SECTION: - if (len < 1) { - len = 0; - break; - } - sec_len = *(pos++); len -= 1; - if (sec_len > 0 && - sec_len <= len && - sec_len <= 32) { - ssid[ssid_index].ssid_length = sec_len; - memcpy(ssid[ssid_index].ssid, pos, sec_len); - ssid_index++; - } - pos += sec_len; - len -= sec_len; - break; - case WEXT_CSCAN_TYPE_SECTION: - case WEXT_CSCAN_CHANNEL_SECTION: - pos += 1; - len -= 1; - break; - case WEXT_CSCAN_PASV_DWELL_SECTION: - case WEXT_CSCAN_HOME_DWELL_SECTION: - case WEXT_CSCAN_ACTV_DWELL_SECTION: - pos += 2; - len -= 2; - break; - default: - len = 0; /* stop parsing */ - } - } - - /* it has still some scan parameter to parse, we only do this now... */ - _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); - } else { - _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); - } - } - - if (!_status) - ret = -1; - -exit: - - return ret; -} - -static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - struct list_head *plist, *phead; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct __queue *queue = &pmlmepriv->scanned_queue; - struct wlan_network *pnetwork = NULL; - char *ev = extra; - char *stop = ev + wrqu->data.length; - u32 ret = 0; - u32 cnt = 0; - u32 wait_for_surveydone; - int wait_status; - - if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { - ret = -EINVAL; - goto exit; - } - - wait_for_surveydone = 100; - - wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; - - while (check_fwstate(pmlmepriv, wait_status)) { - msleep(30); - cnt++; - if (cnt > wait_for_surveydone) - break; - } - - spin_lock_bh(&pmlmepriv->scanned_queue.lock); - - phead = get_list_head(queue); - list_for_each(plist, phead) { - if ((stop - ev) < SCAN_ITEM_SIZE) { - ret = -E2BIG; - break; - } - - pnetwork = list_entry(plist, struct wlan_network, list); - - /* report network only if the current channel set contains the channel to which this network belongs */ - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.Configuration.DSConfig) >= 0) - ev = translate_scan(padapter, a, pnetwork, ev, stop); - } - - spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - - wrqu->data.length = ev - extra; - wrqu->data.flags = 0; - -exit: - return ret; -} - -/* set ssid flow */ -/* s1. rtw_set_802_11_infrastructure_mode() */ -/* s2. set_802_11_authenticaion_mode() */ -/* s3. set_802_11_encryption_mode() */ -/* s4. rtw_set_802_11_ssid() */ -static int rtw_wx_set_essid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct __queue *queue = &pmlmepriv->scanned_queue; - struct list_head *phead; - struct wlan_network *pnetwork = NULL; - enum ndis_802_11_auth_mode authmode; - struct ndis_802_11_ssid ndis_ssid; - u8 *dst_ssid, *src_ssid; - - uint ret = 0, len; - - if (!rtw_pwr_wakeup(padapter)) { - ret = -1; - goto exit; - } - - if (!padapter->bup) { - ret = -1; - goto exit; - } - - if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { - ret = -E2BIG; - goto exit; - } - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - ret = -1; - goto exit; - } - - authmode = padapter->securitypriv.ndisauthtype; - if (wrqu->essid.flags && wrqu->essid.length) { - len = min_t(uint, wrqu->essid.length, IW_ESSID_MAX_SIZE); - - memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); - ndis_ssid.ssid_length = len; - memcpy(ndis_ssid.ssid, extra, len); - src_ssid = ndis_ssid.ssid; - - spin_lock_bh(&queue->lock); - phead = get_list_head(queue); - list_for_each(pmlmepriv->pscanned, phead) { - pnetwork = list_entry(pmlmepriv->pscanned, - struct wlan_network, list); - - dst_ssid = pnetwork->network.ssid.ssid; - - if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.ssid_length)) && - (pnetwork->network.ssid.ssid_length == ndis_ssid.ssid_length)) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) - continue; - } - - if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.InfrastructureMode)) { - ret = -1; - spin_unlock_bh(&queue->lock); - goto exit; - } - - break; - } - } - spin_unlock_bh(&queue->lock); - rtw_set_802_11_authentication_mode(padapter, authmode); - if (!rtw_set_802_11_ssid(padapter, &ndis_ssid)) { - ret = -1; - goto exit; - } - } - -exit: - return ret; -} - -static int rtw_wx_get_essid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - u32 len; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - - if ((check_fwstate(pmlmepriv, _FW_LINKED)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { - len = pcur_bss->ssid.ssid_length; - memcpy(extra, pcur_bss->ssid.ssid, len); - } else { - len = 0; - *extra = 0; - } - wrqu->essid.length = len; - wrqu->essid.flags = 1; - - return 0; -} - -static int rtw_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - u16 max_rate = 0; - - max_rate = rtw_get_cur_max_rate(netdev_priv(dev)); - - if (max_rate == 0) - return -EPERM; - - wrqu->bitrate.fixed = 0; /* no auto select */ - wrqu->bitrate.value = max_rate * 100000; - - return 0; -} - -static int rtw_wx_set_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - - if (wrqu->rts.disabled) { - padapter->registrypriv.rts_thresh = 2347; - } else { - if (wrqu->rts.value < 0 || - wrqu->rts.value > 2347) - return -EINVAL; - - padapter->registrypriv.rts_thresh = wrqu->rts.value; - } - - return 0; -} - -static int rtw_wx_get_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - - wrqu->rts.value = padapter->registrypriv.rts_thresh; - wrqu->rts.fixed = 0; /* no auto select */ - /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ - - return 0; -} - -static int rtw_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - - if (wrqu->frag.disabled) { - padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; - } else { - if (wrqu->frag.value < MIN_FRAG_THRESHOLD || - wrqu->frag.value > MAX_FRAG_THRESHOLD) - return -EINVAL; - - padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; - } - - return 0; -} - -static int rtw_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - - wrqu->frag.value = padapter->xmitpriv.frag_len; - wrqu->frag.fixed = 0; /* no auto select */ - - return 0; -} - -static int rtw_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wrqu->retry.value = 7; - wrqu->retry.fixed = 0; /* no auto select */ - wrqu->retry.disabled = 1; - - return 0; -} - -static int rtw_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *keybuf) -{ - u32 key, ret = 0; - u32 keyindex_provided; - struct ndis_802_11_wep wep; - enum ndis_802_11_auth_mode authmode; - - struct iw_point *erq = &wrqu->encoding; - struct adapter *padapter = netdev_priv(dev); - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - - memset(&wep, 0, sizeof(struct ndis_802_11_wep)); - - key = erq->flags & IW_ENCODE_INDEX; - - if (erq->flags & IW_ENCODE_DISABLED) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype = authmode; - - goto exit; - } - - if (key) { - if (key > WEP_KEYS) - return -EINVAL; - key--; - keyindex_provided = 1; - } else { - keyindex_provided = 0; - key = padapter->securitypriv.dot11PrivacyKeyIndex; - } - - /* set authentication mode */ - if (erq->flags & IW_ENCODE_OPEN) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype = authmode; - } else if (erq->flags & IW_ENCODE_RESTRICTED) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; - authmode = Ndis802_11AuthModeShared; - padapter->securitypriv.ndisauthtype = authmode; - } else { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype = authmode; - } - - wep.KeyIndex = key; - if (erq->length > 0) { - wep.KeyLength = erq->length <= 5 ? 5 : 13; - - wep.Length = wep.KeyLength + offsetof(struct ndis_802_11_wep, KeyMaterial); - } else { - wep.KeyLength = 0; - - if (keyindex_provided == 1) { - /* set key_id only, no given KeyMaterial(erq->length == 0). */ - padapter->securitypriv.dot11PrivacyKeyIndex = key; - - switch (padapter->securitypriv.dot11DefKeylen[key]) { - case 5: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - break; - case 13: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - break; - default: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - break; - } - - goto exit; - } - } - - wep.KeyIndex |= 0x80000000; - - memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); - - if (!rtw_set_802_11_add_wep(padapter, &wep)) { - if (rf_on == pwrpriv->rf_pwrstate) - ret = -EOPNOTSUPP; - goto exit; - } - -exit: - return ret; -} - -static int rtw_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *keybuf) -{ - uint key; - struct adapter *padapter = netdev_priv(dev); - struct iw_point *erq = &wrqu->encoding; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (!check_fwstate(pmlmepriv, _FW_LINKED)) { - if (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - return 0; - } - } - - key = erq->flags & IW_ENCODE_INDEX; - - if (key) { - if (key > WEP_KEYS) - return -EINVAL; - key--; - } else { - key = padapter->securitypriv.dot11PrivacyKeyIndex; - } - - erq->flags = key + 1; - - switch (padapter->securitypriv.ndisencryptstatus) { - case Ndis802_11EncryptionNotSupported: - case Ndis802_11EncryptionDisabled: - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - break; - case Ndis802_11Encryption1Enabled: - erq->length = padapter->securitypriv.dot11DefKeylen[key]; - if (erq->length) { - memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); - - erq->flags |= IW_ENCODE_ENABLED; - - if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) - erq->flags |= IW_ENCODE_OPEN; - else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) - erq->flags |= IW_ENCODE_RESTRICTED; - } else { - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - } - break; - case Ndis802_11Encryption2Enabled: - case Ndis802_11Encryption3Enabled: - erq->length = 16; - erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY); - break; - default: - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - break; - } - - return 0; -} - -static int rtw_wx_get_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - wrqu->power.value = 0; - wrqu->power.fixed = 0; /* no auto select */ - wrqu->power.disabled = 1; - - return 0; -} - -static int rtw_wx_set_gen_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - - return rtw_set_wpa_ie(padapter, extra, wrqu->data.length); -} - -static int rtw_wx_set_auth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = netdev_priv(dev); - struct iw_param *param = (struct iw_param *)&wrqu->param; - int ret = 0; - - switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: - break; - case IW_AUTH_CIPHER_PAIRWISE: - - break; - case IW_AUTH_CIPHER_GROUP: - - break; - case IW_AUTH_KEY_MGMT: - /* - * ??? does not use these parameters - */ - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - if (param->value) { - /* wpa_supplicant is enabling the tkip countermeasure. */ - padapter->securitypriv.btkip_countermeasure = true; - } else { - /* wpa_supplicant is disabling the tkip countermeasure. */ - padapter->securitypriv.btkip_countermeasure = false; - } - break; - case IW_AUTH_DROP_UNENCRYPTED: - /* HACK: - * - * wpa_supplicant calls set_wpa_enabled when the driver - * is loaded and unloaded, regardless of if WPA is being - * used. No other calls are made which can be used to - * determine if encryption will be used or not prior to - * association being expected. If encryption is not being - * used, drop_unencrypted is set to false, else true -- we - * can use this to determine if the CAP_PRIVACY_ON bit should - * be set. - */ - - if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) - break;/* it means init value, or using wep, ndisencryptstatus = Ndis802_11Encryption1Enabled, */ - /* then it needn't reset it; */ - - if (param->value) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; - } - - break; - case IW_AUTH_80211_AUTH_ALG: - /* It's the starting point of a link layer connection using wpa_supplicant */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { - LeaveAllPowerSaveMode(padapter); - rtw_disassoc_cmd(padapter, 500, false); - rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter); - } - ret = wpa_set_auth_algs(dev, (u32)param->value); - break; - case IW_AUTH_WPA_ENABLED: - break; - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - break; - case IW_AUTH_PRIVACY_INVOKED: - break; - default: - return -EOPNOTSUPP; - } - - return ret; -} - -static int rtw_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - char *alg_name; - u32 param_len; - struct ieee_param *param = NULL; - struct iw_point *pencoding = &wrqu->encoding; - struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; - int ret = 0; - - param_len = sizeof(struct ieee_param) + pext->key_len; - param = (struct ieee_param *)rtw_malloc(param_len); - if (!param) - return -1; - - memset(param, 0, param_len); - - param->cmd = IEEE_CMD_SET_ENCRYPTION; - eth_broadcast_addr(param->sta_addr); - - switch (pext->alg) { - case IW_ENCODE_ALG_NONE: - /* todo: remove key */ - /* remove = 1; */ - alg_name = "none"; - break; - case IW_ENCODE_ALG_WEP: - alg_name = "WEP"; - break; - case IW_ENCODE_ALG_TKIP: - alg_name = "TKIP"; - break; - case IW_ENCODE_ALG_CCMP: - alg_name = "CCMP"; - break; - default: - ret = -1; - goto exit; - } - - strscpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); - - if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) - param->u.crypt.set_tx = 1; - - /* cliW: WEP does not have group key - * just not checking GROUP key setting - */ - if ((pext->alg != IW_ENCODE_ALG_WEP) && - (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) - param->u.crypt.set_tx = 0; - - param->u.crypt.idx = (pencoding->flags & 0x00FF) - 1; - - if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) - memcpy(param->u.crypt.seq, pext->rx_seq, 8); - - if (pext->key_len) { - param->u.crypt.key_len = pext->key_len; - memcpy(param->u.crypt.key, pext + 1, pext->key_len); - } - - ret = wpa_set_encryption(dev, param, param_len); - -exit: - kfree(param); - return ret; -} - -static int rtw_wx_get_nick(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - if (extra) { - wrqu->data.length = 14; - wrqu->data.flags = 1; - memcpy(extra, "", 14); - } - - /* dump debug info here */ - return 0; -} - -static int wpa_set_param(struct net_device *dev, u8 name, u32 value) -{ - uint ret = 0; - struct adapter *padapter = netdev_priv(dev); - - switch (name) { - case IEEE_PARAM_WPA_ENABLED: - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ - switch (value & 0xff) { - case 1: /* WPA */ - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case 2: /* WPA2 */ - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */ - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - } - break; - case IEEE_PARAM_TKIP_COUNTERMEASURES: - break; - case IEEE_PARAM_DROP_UNENCRYPTED: { - /* HACK: - * - * wpa_supplicant calls set_wpa_enabled when the driver - * is loaded and unloaded, regardless of if WPA is being - * used. No other calls are made which can be used to - * determine if encryption will be used or not prior to - * association being expected. If encryption is not being - * used, drop_unencrypted is set to false, else true -- we - * can use this to determine if the CAP_PRIVACY_ON bit should - * be set. - */ - - break; - } - case IEEE_PARAM_PRIVACY_INVOKED: - break; - - case IEEE_PARAM_AUTH_ALGS: - ret = wpa_set_auth_algs(dev, value); - break; - case IEEE_PARAM_IEEE_802_1X: - break; - case IEEE_PARAM_WPAX_SELECT: - break; - default: - ret = -EOPNOTSUPP; - break; - } - return ret; -} - -static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) -{ - int ret = 0; - struct adapter *padapter = netdev_priv(dev); - - switch (command) { - case IEEE_MLME_STA_DEAUTH: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - case IEEE_MLME_STA_DISASSOC: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - default: - ret = -EOPNOTSUPP; - break; - } - - return ret; -} - -static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) -{ - struct ieee_param *param; - uint ret = 0; - - if (!p->pointer || p->length != sizeof(struct ieee_param)) - return -EINVAL; - - param = memdup_user(p->pointer, p->length); - if (IS_ERR(param)) - return PTR_ERR(param); - - switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: - ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value); - break; - - case IEEE_CMD_SET_WPA_IE: - ret = rtw_set_wpa_ie(netdev_priv(dev), - (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); - break; - - case IEEE_CMD_SET_ENCRYPTION: - ret = wpa_set_encryption(dev, param, p->length); - break; - - case IEEE_CMD_MLME: - ret = wpa_mlme(dev, param->u.mlme.command, param->u.mlme.reason_code); - break; - - default: - ret = -EOPNOTSUPP; - break; - } - - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - - kfree(param); - return ret; -} - -#ifdef CONFIG_88EU_AP_MODE -static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) -{ - struct cmd_obj *ph2c; - struct set_stakey_parm *psetstakey_para; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); - if (!psetstakey_para) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - - psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; - - memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); - - memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); - - res = rtw_enqueue_cmd(pcmdpriv, ph2c); - -exit: - - return res; -} - -static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) -{ - u8 keylen; - struct cmd_obj *pcmd; - struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - int res = _SUCCESS; - - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd) { - res = _FAIL; - goto exit; - } - psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); - if (!psetkeyparm) { - kfree(pcmd); - res = _FAIL; - goto exit; - } - - psetkeyparm->keyid = (u8)keyid; - - psetkeyparm->algorithm = alg; - - psetkeyparm->set_tx = 1; - - switch (alg) { - case _WEP40_: - keylen = 5; - break; - case _WEP104_: - keylen = 13; - break; - case _TKIP_: - case _TKIP_WTMIC_: - case _AES_: - default: - keylen = 16; - } - - memcpy(&psetkeyparm->key[0], key, keylen); - - pcmd->cmdcode = _SetKey_CMD_; - pcmd->parmbuf = (u8 *)psetkeyparm; - pcmd->cmdsz = (sizeof(struct setkey_parm)); - pcmd->rsp = NULL; - pcmd->rspsz = 0; - - INIT_LIST_HEAD(&pcmd->list); - - res = rtw_enqueue_cmd(pcmdpriv, pcmd); - -exit: - - return res; -} - -static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid) -{ - u8 alg; - - switch (keylen) { - case 5: - alg = _WEP40_; - break; - case 13: - alg = _WEP104_; - break; - default: - alg = _NO_PRIVACY_; - } - - return set_group_key(padapter, key, alg, keyid); -} - -static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) -{ - int ret = 0; - u32 wep_key_idx, wep_key_len, wep_total_len; - struct ndis_802_11_wep *pwep = NULL; - struct sta_info *psta = NULL, *pbcmc_sta = NULL; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sta_priv *pstapriv = &padapter->stapriv; - - param->u.crypt.err = 0; - param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) { - ret = -EINVAL; - goto exit; - } - if (is_broadcast_ether_addr(param->sta_addr)) { - if (param->u.crypt.idx >= WEP_KEYS) { - ret = -EINVAL; - goto exit; - } - } else { - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (!psta) - goto exit; - } - - if (strcmp(param->u.crypt.alg, "none") == 0 && (!psta)) - /* todo:clear default encryption keys */ - goto exit; - - if (strcmp(param->u.crypt.alg, "WEP") == 0 && (!psta)) { - wep_key_idx = param->u.crypt.idx; - wep_key_len = param->u.crypt.key_len; - if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) { - ret = -EINVAL; - goto exit; - } - - if (wep_key_len > 0) { - wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = wep_key_len + offsetof(struct ndis_802_11_wep, KeyMaterial); - pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); - if (!pwep) - goto exit; - - memset(pwep, 0, wep_total_len); - - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; - } - - pwep->KeyIndex = wep_key_idx; - - memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); - - if (param->u.crypt.set_tx) { - psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - - if (pwep->KeyLength == 13) { - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } - - psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; - - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); - - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; - - set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); - } else { - /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ - /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ - - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); - - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; - - set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); - } - - goto exit; - } - - if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ - if (param->u.crypt.set_tx == 1) { - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (param->u.crypt.key_len == 13) - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - psecuritypriv->dot118021XGrpPrivacy = _TKIP_; - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - /* set mic key */ - memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); - memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); - - psecuritypriv->busetkipkey = true; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - psecuritypriv->dot118021XGrpPrivacy = _AES_; - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - } else { - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; - } - psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - psecuritypriv->binstallGrpkey = true; - psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ - set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); - pbcmc_sta = rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta) { - pbcmc_sta->ieee8021x_blocked = false; - pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ - } - } - goto exit; - } - - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */ - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - if (param->u.crypt.set_tx == 1) { - memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - psta->dot118021XPrivacy = _WEP40_; - if (param->u.crypt.key_len == 13) - psta->dot118021XPrivacy = _WEP104_; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - psta->dot118021XPrivacy = _TKIP_; - - /* set mic key */ - memcpy(psta->dot11tkiptxmickey.skey, ¶m->u.crypt.key[16], 8); - memcpy(psta->dot11tkiprxmickey.skey, ¶m->u.crypt.key[24], 8); - - psecuritypriv->busetkipkey = true; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - psta->dot118021XPrivacy = _AES_; - } else { - psta->dot118021XPrivacy = _NO_PRIVACY_; - } - - set_pairwise_key(padapter, psta); - - psta->ieee8021x_blocked = false; - } else { /* group key??? */ - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (param->u.crypt.key_len == 13) - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - psecuritypriv->dot118021XGrpPrivacy = _TKIP_; - - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - - /* set mic key */ - memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); - memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); - - psecuritypriv->busetkipkey = true; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - psecuritypriv->dot118021XGrpPrivacy = _AES_; - - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, min_t(u16, param->u.crypt.key_len, 16)); - } else { - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; - } - - psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - - psecuritypriv->binstallGrpkey = true; - - psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ - - set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); - - pbcmc_sta = rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta) { - pbcmc_sta->ieee8021x_blocked = false; - pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ - } - } - } - } - -exit: - - kfree(pwep); - - return ret; -} - -static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - unsigned char *pbuf = param->u.bcn_ie.buf; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); - - if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) - pstapriv->max_num_sta = NUM_STA; - - if (rtw_check_beacon_data(padapter, pbuf, len - 12 - 2) == _SUCCESS) /* 12 = param header, 2:no packed */ - ret = 0; - else - ret = -EINVAL; - - return ret; -} - -static int rtw_hostapd_sta_flush(struct net_device *dev) -{ - struct adapter *padapter = netdev_priv(dev); - - flush_all_cam_entry(padapter); /* clear CAM */ - - return rtw_sta_flush(padapter); -} - -static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!check_fwstate(pmlmepriv, (_FW_LINKED | WIFI_AP_STATE))) - return -EINVAL; - - if (is_broadcast_ether_addr(param->sta_addr)) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) { - int flags = param->u.add_sta.flags; - - psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */ - - memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); - - /* check wmm cap. */ - if (WLAN_STA_WME & flags) - psta->qos_option = 1; - else - psta->qos_option = 0; - - if (pmlmepriv->qospriv.qos_option == 0) - psta->qos_option = 0; - - /* chec 802.11n ht cap. */ - if (WLAN_STA_HT & flags) { - psta->htpriv.ht_option = true; - psta->qos_option = 1; - memcpy(&psta->htpriv.ht_cap, ¶m->u.add_sta.ht_cap, - sizeof(struct ieee80211_ht_cap)); - } else { - psta->htpriv.ht_option = false; - } - - if (!pmlmepriv->htpriv.ht_option) - psta->htpriv.ht_option = false; - - update_sta_info_apmode(padapter, psta); - } else { - ret = -ENOMEM; - } - - return ret; -} - -static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) -{ - struct sta_info *psta = NULL; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - int updated = 0; - - if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE)) - return -EINVAL; - - if (is_broadcast_ether_addr(param->sta_addr)) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) { - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&psta->asoc_list)) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - associated_clients_update(padapter, updated); - psta = NULL; - } - - return 0; -} - -static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; - struct sta_data *psta_data = (struct sta_data *)param_ex->data; - - if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE)) - return -EINVAL; - - if (is_broadcast_ether_addr(param_ex->sta_addr)) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); - if (psta) { - psta_data->aid = (u16)psta->aid; - psta_data->capability = psta->capability; - psta_data->flags = psta->flags; - -/* - nonerp_set : BIT(0) - no_short_slot_time_set : BIT(1) - no_short_preamble_set : BIT(2) - no_ht_gf_set : BIT(3) - no_ht_set : BIT(4) - ht_20mhz_set : BIT(5) -*/ - - psta_data->sta_set = ((psta->nonerp_set) | - (psta->no_short_slot_time_set << 1) | - (psta->no_short_preamble_set << 2) | - (psta->no_ht_gf_set << 3) | - (psta->no_ht_set << 4) | - (psta->ht_20mhz_set << 5)); - psta_data->tx_supp_rates_len = psta->bssratelen; - memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); - memcpy(&psta_data->ht_cap, - &psta->htpriv.ht_cap, sizeof(struct ieee80211_ht_cap)); - psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; - psta_data->rx_bytes = psta->sta_stats.rx_bytes; - psta_data->rx_drops = psta->sta_stats.rx_drops; - psta_data->tx_pkts = psta->sta_stats.tx_pkts; - psta_data->tx_bytes = psta->sta_stats.tx_bytes; - psta_data->tx_drops = psta->sta_stats.tx_drops; - } else { - ret = -1; - } - - return ret; -} - -static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!check_fwstate(pmlmepriv, _FW_LINKED | WIFI_AP_STATE)) - return -EINVAL; - - if (is_broadcast_ether_addr(param->sta_addr)) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) { - if (psta->wpa_ie[0] == WLAN_EID_RSN || - psta->wpa_ie[0] == WLAN_EID_VENDOR_SPECIFIC) { - int wpa_ie_len; - int copy_len; - - wpa_ie_len = psta->wpa_ie[1]; - copy_len = min_t(int, wpa_ie_len + 2, sizeof(psta->wpa_ie)); - param->u.wpa_ie.len = copy_len; - memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); - } - } else { - ret = -1; - } - - return ret; -} - -static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) -{ - unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - int ie_len; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - ie_len = len - 12 - 2; /* 12 = param header, 2:no packed */ - - kfree(pmlmepriv->wps_beacon_ie); - pmlmepriv->wps_beacon_ie = NULL; - - if (ie_len > 0) { - pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); - pmlmepriv->wps_beacon_ie_len = ie_len; - if (!pmlmepriv->wps_beacon_ie) - return -EINVAL; - - memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); - - update_beacon(padapter, WLAN_EID_VENDOR_SPECIFIC, wps_oui, true); - - pmlmeext->bstart_bss = true; - } - - return 0; -} - -static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int ie_len; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - ie_len = len - 12 - 2; /* 12 = param header, 2:no packed */ - - kfree(pmlmepriv->wps_probe_resp_ie); - pmlmepriv->wps_probe_resp_ie = NULL; - - if (ie_len > 0) { - pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); - pmlmepriv->wps_probe_resp_ie_len = ie_len; - if (!pmlmepriv->wps_probe_resp_ie) - return -EINVAL; - memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); - } - - return 0; -} - -static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int ie_len; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - ie_len = len - 12 - 2; /* 12 = param header, 2:no packed */ - - kfree(pmlmepriv->wps_assoc_resp_ie); - pmlmepriv->wps_assoc_resp_ie = NULL; - - if (ie_len > 0) { - pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); - pmlmepriv->wps_assoc_resp_ie_len = ie_len; - if (!pmlmepriv->wps_assoc_resp_ie) - return -EINVAL; - - memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); - } - - return 0; -} - -static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - u8 value; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - value = param->u.wpa_param.value; - - /* use the same definition of hostapd's ignore_broadcast_ssid */ - if (value != 1 && value != 2) - value = 0; - pmlmeinfo->hidden_ssid_mode = value; - return 0; -} - -static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - if (is_broadcast_ether_addr(param->sta_addr)) - return -EINVAL; - - return rtw_acl_remove_sta(padapter, param->sta_addr); -} - -static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - if (is_broadcast_ether_addr(param->sta_addr)) - return -EINVAL; - - return rtw_acl_add_sta(padapter, param->sta_addr); -} - -static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) - return -EINVAL; - - rtw_set_macaddr_acl(padapter, param->u.mlme.command); - - return 0; -} - -static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) -{ - struct ieee_param *param; - int ret = 0; - struct adapter *padapter = netdev_priv(dev); - - /* - * this function is expect to call in master mode, which allows no power saving - * so, we just check hw_init_completed - */ - - if (!padapter->hw_init_completed) - return -EPERM; - - if (!p->pointer || p->length != sizeof(struct ieee_param)) - return -EINVAL; - - param = memdup_user(p->pointer, p->length); - if (IS_ERR(param)) - return PTR_ERR(param); - - switch (param->cmd) { - case RTL871X_HOSTAPD_FLUSH: - ret = rtw_hostapd_sta_flush(dev); - break; - case RTL871X_HOSTAPD_ADD_STA: - ret = rtw_add_sta(dev, param); - break; - case RTL871X_HOSTAPD_REMOVE_STA: - ret = rtw_del_sta(dev, param); - break; - case RTL871X_HOSTAPD_SET_BEACON: - ret = rtw_set_beacon(dev, param, p->length); - break; - case RTL871X_SET_ENCRYPTION: - ret = rtw_set_encryption(dev, param, p->length); - break; - case RTL871X_HOSTAPD_GET_WPAIE_STA: - ret = rtw_get_sta_wpaie(dev, param); - break; - case RTL871X_HOSTAPD_SET_WPS_BEACON: - ret = rtw_set_wps_beacon(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: - ret = rtw_set_wps_probe_resp(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: - ret = rtw_set_wps_assoc_resp(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_HIDDEN_SSID: - ret = rtw_set_hidden_ssid(dev, param, p->length); - break; - case RTL871X_HOSTAPD_GET_INFO_STA: - ret = rtw_ioctl_get_sta_data(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_MACADDR_ACL: - ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); - break; - case RTL871X_HOSTAPD_ACL_ADD_STA: - ret = rtw_ioctl_acl_add_sta(dev, param, p->length); - break; - case RTL871X_HOSTAPD_ACL_REMOVE_STA: - ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); - break; - default: - ret = -EOPNOTSUPP; - break; - } - - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - kfree(param); - return ret; -} -#endif - -#include -static int rtw_wx_set_priv(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, char *extra) -{ - int ret = 0; - int len = 0; - char *ext; - struct adapter *padapter = netdev_priv(dev); - struct iw_point *dwrq = (struct iw_point *)awrq; - - if (dwrq->length == 0) - return -EFAULT; - - len = dwrq->length; - ext = vmalloc(len); - if (!ext) - return -ENOMEM; - - if (copy_from_user(ext, dwrq->pointer, len)) { - vfree(ext); - return -EFAULT; - } - - /* added for wps2.0 @20110524 */ - if (dwrq->flags == 0x8766 && len > 8) { - u32 cp_sz; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 *probereq_wpsie = ext; - int probereq_wpsie_len = len; - u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - if ((probereq_wpsie[0] == WLAN_EID_VENDOR_SPECIFIC) && - (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { - cp_sz = min(probereq_wpsie_len, MAX_WPS_IE_LEN); - - pmlmepriv->wps_probe_req_ie_len = 0; - kfree(pmlmepriv->wps_probe_req_ie); - pmlmepriv->wps_probe_req_ie = NULL; - - pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); - if (!pmlmepriv->wps_probe_req_ie) { - pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); - ret = -EINVAL; - goto FREE_EXT; - } - memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); - pmlmepriv->wps_probe_req_ie_len = cp_sz; - } - goto FREE_EXT; - } - - if (len >= WEXT_CSCAN_HEADER_SIZE && - !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { - ret = rtw_wx_set_scan(dev, info, awrq, ext); - goto FREE_EXT; - } - -FREE_EXT: - - vfree(ext); - - return ret; -} - -static iw_handler rtw_handlers[] = { - IW_HANDLER(SIOCGIWNAME, rtw_wx_get_name), - IW_HANDLER(SIOCGIWFREQ, rtw_wx_get_freq), - IW_HANDLER(SIOCSIWMODE, rtw_wx_set_mode), - IW_HANDLER(SIOCGIWMODE, rtw_wx_get_mode), - IW_HANDLER(SIOCGIWSENS, rtw_wx_get_sens), - IW_HANDLER(SIOCGIWRANGE, rtw_wx_get_range), - IW_HANDLER(SIOCSIWPRIV, rtw_wx_set_priv), - IW_HANDLER(SIOCSIWAP, rtw_wx_set_wap), - IW_HANDLER(SIOCGIWAP, rtw_wx_get_wap), - IW_HANDLER(SIOCSIWMLME, rtw_wx_set_mlme), - IW_HANDLER(SIOCSIWSCAN, rtw_wx_set_scan), - IW_HANDLER(SIOCGIWSCAN, rtw_wx_get_scan), - IW_HANDLER(SIOCSIWESSID, rtw_wx_set_essid), - IW_HANDLER(SIOCGIWESSID, rtw_wx_get_essid), - IW_HANDLER(SIOCGIWNICKN, rtw_wx_get_nick), - IW_HANDLER(SIOCGIWRATE, rtw_wx_get_rate), - IW_HANDLER(SIOCSIWRTS, rtw_wx_set_rts), - IW_HANDLER(SIOCGIWRTS, rtw_wx_get_rts), - IW_HANDLER(SIOCSIWFRAG, rtw_wx_set_frag), - IW_HANDLER(SIOCGIWFRAG, rtw_wx_get_frag), - IW_HANDLER(SIOCGIWRETRY, rtw_wx_get_retry), - IW_HANDLER(SIOCSIWENCODE, rtw_wx_set_enc), - IW_HANDLER(SIOCGIWENCODE, rtw_wx_get_enc), - IW_HANDLER(SIOCGIWPOWER, rtw_wx_get_power), - IW_HANDLER(SIOCSIWGENIE, rtw_wx_set_gen_ie), - IW_HANDLER(SIOCSIWAUTH, rtw_wx_set_auth), - IW_HANDLER(SIOCSIWENCODEEXT, rtw_wx_set_enc_ext), - IW_HANDLER(SIOCSIWPMKSA, rtw_wx_set_pmkid), -}; - -static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) -{ - struct adapter *padapter = netdev_priv(dev); - struct iw_statistics *piwstats = &padapter->iwstats; - - if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { - piwstats->qual.qual = 0; - piwstats->qual.level = 0; - piwstats->qual.noise = 0; - } else { - piwstats->qual.level = padapter->recvpriv.signal_strength; - piwstats->qual.qual = padapter->recvpriv.signal_qual; - piwstats->qual.noise = padapter->recvpriv.noise; - } - piwstats->qual.updated = IW_QUAL_ALL_UPDATED;/* IW_QUAL_DBM; */ - return piwstats; -} - -struct iw_handler_def rtw_handlers_def = { - .standard = rtw_handlers, - .num_standard = ARRAY_SIZE(rtw_handlers), - .get_wireless_stats = rtw_get_wireless_stats, -}; - -int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct iwreq *wrq = (struct iwreq *)rq; - int ret = 0; - - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = wpa_supplicant_ioctl(dev, &wrq->u.data); - break; -#ifdef CONFIG_88EU_AP_MODE - case RTL_IOCTL_HOSTAPD: - ret = rtw_hostapd_ioctl(dev, &wrq->u.data); - break; -#endif /* CONFIG_88EU_AP_MODE */ - case (SIOCDEVPRIVATE + 1): - ret = rtw_android_priv_cmd(dev, rq, cmd); - break; - default: - ret = -EOPNOTSUPP; - break; - } - return ret; -} diff --git a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c b/drivers/staging/rtl8188eu/os_dep/mlme_linux.c deleted file mode 100644 index f12d8a707376..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/mlme_linux.c +++ /dev/null @@ -1,167 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#define _MLME_OSDEP_C_ - -#include -#include -#include - -void rtw_init_mlme_timer(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - timer_setup(&pmlmepriv->assoc_timer, _rtw_join_timeout_handler, 0); - timer_setup(&pmlmepriv->scan_to_timer, rtw_scan_timeout_handler, 0); - timer_setup(&pmlmepriv->dynamic_chk_timer, - rtw_dynamic_check_timer_handlder, 0); -} - -void rtw_os_indicate_connect(struct adapter *adapter) -{ - rtw_indicate_wx_assoc_event(adapter); - netif_carrier_on(adapter->pnetdev); -} - -static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE]; - -void rtw_reset_securitypriv(struct adapter *adapter) -{ - u8 backup_index; - u8 backup_counter; - u32 backup_time; - struct security_priv *psec_priv = &adapter->securitypriv; - - if (psec_priv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { - /* 802.1x - * We have to backup the PMK information for WiFi PMK Caching - * test item. Backup the btkip_countermeasure information. When - * the countermeasure is trigger, the driver have to disconnect - * with AP for 60 seconds. - */ - memcpy(backup_pmkid, psec_priv->PMKIDList, - sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - backup_index = psec_priv->PMKIDIndex; - backup_counter = psec_priv->btkip_countermeasure; - backup_time = psec_priv->btkip_countermeasure_time; - - memset(psec_priv, 0, sizeof(*psec_priv)); - - /* Restore the PMK information to securitypriv structure - * for the following connection. - */ - memcpy(psec_priv->PMKIDList, backup_pmkid, - sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - psec_priv->PMKIDIndex = backup_index; - psec_priv->btkip_countermeasure = backup_counter; - psec_priv->btkip_countermeasure_time = backup_time; - psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; - psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; - } else { - /* reset values in securitypriv */ - psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_; - psec_priv->dot11PrivacyKeyIndex = 0; - psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_; - psec_priv->dot118021XGrpKeyid = 1; - psec_priv->ndisauthtype = Ndis802_11AuthModeOpen; - psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled; - } -} - -void rtw_os_indicate_disconnect(struct adapter *adapter) -{ - /* Do it first for tx broadcast pkt after disconnection issue! */ - netif_carrier_off(adapter->pnetdev); - rtw_indicate_wx_disassoc_event(adapter); - rtw_reset_securitypriv(adapter); -} - -void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) -{ - uint len; - u8 *buff, *p, i; - union iwreq_data wrqu; - - buff = NULL; - if (authmode == WLAN_EID_VENDOR_SPECIFIC) { - buff = rtw_malloc(IW_CUSTOM_MAX); - if (!buff) - return; - memset(buff, 0, IW_CUSTOM_MAX); - p = buff; - p += sprintf(p, "ASSOCINFO(ReqIEs ="); - len = sec_ie[1] + 2; - len = min_t(uint, len, IW_CUSTOM_MAX); - for (i = 0; i < len; i++) - p += sprintf(p, "%02x", sec_ie[i]); - p += sprintf(p, ")"); - memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = min_t(__u16, p - buff, IW_CUSTOM_MAX); - wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); - kfree(buff); - } -} - -void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta) -{ - timer_setup(&psta->addba_retry_timer, addba_timer_hdl, 0); -} - -void init_mlme_ext_timer(struct adapter *padapter) -{ - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - timer_setup(&pmlmeext->survey_timer, survey_timer_hdl, 0); - timer_setup(&pmlmeext->link_timer, link_timer_hdl, 0); -} - -#ifdef CONFIG_88EU_AP_MODE - -void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta) -{ - union iwreq_data wrqu; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!psta) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL); -} - -void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta) -{ - union iwreq_data wrqu; - struct sta_priv *pstapriv = &padapter->stapriv; - - if (!psta) - return; - - if (psta->aid > NUM_STA) - return; - - if (pstapriv->sta_aid[psta->aid - 1] != psta) - return; - - wrqu.addr.sa_family = ARPHRD_ETHER; - - memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN); - - wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL); -} - -#endif diff --git a/drivers/staging/rtl8188eu/os_dep/mon.c b/drivers/staging/rtl8188eu/os_dep/mon.c deleted file mode 100644 index 6370a3d8881b..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/mon.c +++ /dev/null @@ -1,183 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/* - * RTL8188EU monitor interface - * - * Copyright (C) 2015 Jakub Sitnicki - */ - -#include -#include -#include - -#include -#include -#include -#include - -/* - * unprotect_frame() - unset Protected flag and strip off IV and ICV/MIC - */ -static void unprotect_frame(struct sk_buff *skb, int iv_len, int icv_len) -{ - struct ieee80211_hdr *hdr; - int hdr_len; - - hdr = (struct ieee80211_hdr *)skb->data; - hdr_len = ieee80211_hdrlen(hdr->frame_control); - - if (skb->len < hdr_len + iv_len + icv_len) - return; - if (!ieee80211_has_protected(hdr->frame_control)) - return; - - hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_PROTECTED); - - memmove(skb->data + iv_len, skb->data, hdr_len); - skb_pull(skb, iv_len); - skb_trim(skb, skb->len - icv_len); -} - -static void mon_recv_decrypted(struct net_device *dev, const u8 *data, - int data_len, int iv_len, int icv_len) -{ - struct sk_buff *skb; - - skb = netdev_alloc_skb(dev, data_len); - if (!skb) - return; - skb_put_data(skb, data, data_len); - - /* - * Frame data is not encrypted. Strip off protection so - * userspace doesn't think that it is. - */ - unprotect_frame(skb, iv_len, icv_len); - - skb->ip_summed = CHECKSUM_UNNECESSARY; - skb->protocol = eth_type_trans(skb, dev); - netif_rx(skb); -} - -static void mon_recv_encrypted(struct net_device *dev, const u8 *data, - int data_len) -{ - if (net_ratelimit()) - netdev_info(dev, "Encrypted packets are not supported"); -} - -/* - * rtl88eu_mon_recv_hook() - forward received frame to the monitor interface - * - * Assumes that the frame contains an IV and an ICV/MIC, and that - * encrypt field in frame->attrib have been set accordingly. - */ -void rtl88eu_mon_recv_hook(struct net_device *dev, struct recv_frame *frame) -{ - struct rx_pkt_attrib *attr; - int iv_len, icv_len; - int data_len; - u8 *data; - - if (!dev || !frame) - return; - if (!netif_running(dev)) - return; - - attr = &frame->attrib; - data = frame->pkt->data; - data_len = frame->pkt->len; - - /* Broadcast and multicast frames don't have attr->{iv,icv}_len set */ - SET_ICE_IV_LEN(iv_len, icv_len, attr->encrypt); - - if (attr->bdecrypted) - mon_recv_decrypted(dev, data, data_len, iv_len, icv_len); - else - mon_recv_encrypted(dev, data, data_len); -} - -/* - * rtl88eu_mon_xmit_hook() - forward trasmitted frame to the monitor interface - * - * Assumes that: - * - frame header contains an IV and frame->attrib.iv_len is set accordingly, - * - data is not encrypted and ICV/MIC has not been appended yet. - */ -void rtl88eu_mon_xmit_hook(struct net_device *dev, struct xmit_frame *frame, - uint frag_len) -{ - struct pkt_attrib *attr; - u8 *data; - int i, offset; - - if (!dev || !frame) - return; - if (!netif_running(dev)) - return; - - attr = &frame->attrib; - - offset = TXDESC_SIZE + frame->pkt_offset * PACKET_OFFSET_SZ; - data = frame->buf_addr + offset; - - for (i = 0; i < attr->nr_frags - 1; i++) { - mon_recv_decrypted(dev, data, frag_len, attr->iv_len, 0); - data += frag_len; - data = (u8 *)round_up((size_t)data, 4); - } - /* Last fragment has different length */ - mon_recv_decrypted(dev, data, attr->last_txcmdsz, attr->iv_len, 0); -} - -static netdev_tx_t mon_xmit(struct sk_buff *skb, struct net_device *dev) -{ - dev_kfree_skb(skb); - return NETDEV_TX_OK; -} - -static const struct net_device_ops mon_netdev_ops = { - .ndo_start_xmit = mon_xmit, - .ndo_set_mac_address = eth_mac_addr, - .ndo_validate_addr = eth_validate_addr, -}; - -static void mon_setup(struct net_device *dev) -{ - dev->netdev_ops = &mon_netdev_ops; - dev->needs_free_netdev = true; - ether_setup(dev); - dev->priv_flags |= IFF_NO_QUEUE; - dev->type = ARPHRD_IEEE80211; - /* - * Use a locally administered address (IEEE 802) - * XXX: Copied from mac80211_hwsim driver. Revisit. - */ - eth_zero_addr(dev->dev_addr); - dev->dev_addr[0] = 0x12; -} - -struct net_device *rtl88eu_mon_init(void) -{ - struct net_device *dev; - int err; - - dev = alloc_netdev(0, "mon%d", NET_NAME_UNKNOWN, mon_setup); - if (!dev) - return NULL; - - err = register_netdev(dev); - if (err < 0) { - free_netdev(dev); - return NULL; - } - - return dev; -} - -void rtl88eu_mon_deinit(struct net_device *dev) -{ - if (!dev) - return; - - unregister_netdev(dev); -} diff --git a/drivers/staging/rtl8188eu/os_dep/os_intfs.c b/drivers/staging/rtl8188eu/os_dep/os_intfs.c deleted file mode 100644 index 423c382e3d20..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/os_intfs.c +++ /dev/null @@ -1,657 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _OS_INTFS_C_ - -#include -#include -#include -#include -#include -#include -#include -#include - -MODULE_LICENSE("GPL"); -MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); -MODULE_AUTHOR("Realtek Semiconductor Corp."); -MODULE_VERSION("v4.1.4_6773.20130222"); -MODULE_FIRMWARE("rtlwifi/rtl8188eufw.bin"); - -#define RTW_NOTCH_FILTER 0 /* 0:Disable, 1:Enable, */ - -/* module param defaults */ -/* Ndis802_11Infrastructure; infra, ad-hoc, auto */ -static int rtw_channel = 1;/* ad-hoc support requirement */ -static int rtw_wireless_mode = WIRELESS_11BG_24N; -static int rtw_vrtl_carrier_sense = AUTO_VCS; -static int rtw_vcs_type = RTS_CTS;/* */ -static int rtw_rts_thresh = 2347;/* */ -static int rtw_frag_thresh = 2346;/* */ -static int rtw_preamble = PREAMBLE_LONG;/* long, short, auto */ -static int rtw_power_mgnt = 1; -static int rtw_ips_mode = IPS_NORMAL; - -static int rtw_smart_ps = 2; - -module_param(rtw_ips_mode, int, 0644); -MODULE_PARM_DESC(rtw_ips_mode, "The default IPS mode"); - -static int rtw_debug = 1; - -static int rtw_acm_method;/* 0:By SW 1:By HW. */ - -static int rtw_wmm_enable = 1;/* default is set to enable the wmm. */ -static int rtw_uapsd_enable; - -static int rtw_ht_enable = 1; -/* 0 :disable, bit(0): enable 2.4g, bit(1): enable 5g */ -static int rtw_cbw40_enable = 3; -static int rtw_ampdu_enable = 1;/* for enable tx_ampdu */ - -/* 0: disable - * bit(0):enable 2.4g - * bit(1):enable 5g - * default is set to enable 2.4GHZ for IOT issue with bufflao's AP at 5GHZ - */ -static int rtw_rx_stbc = 1; -static int rtw_ampdu_amsdu;/* 0: disabled, 1:enabled, 2:auto */ - -static int rtw_wifi_spec; -static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; - -static int rtw_antdiv_cfg = 2; /* 0:OFF , 1:ON, 2:decide by Efuse config */ - -/* 0: decide by efuse - * 1: for 88EE, 1Tx and 1RxCG are diversity (2 Ant with SPDT) - * 2: for 88EE, 1Tx and 2Rx are diversity (2 Ant, Tx and RxCG are both on aux - * port, RxCS is on main port) - * 3: for 88EE, 1Tx and 1RxCG are fixed (1Ant, Tx and RxCG are both on aux port) - */ -static int rtw_antdiv_type; - -static int rtw_enusbss;/* 0:disable, 1:enable */ - -static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */ - -int rtw_mc2u_disable; - -static int rtw_80211d; - -static char *ifname = "wlan%d"; -module_param(ifname, charp, 0644); -MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); - -static char *if2name = "wlan%d"; -module_param(if2name, charp, 0644); -MODULE_PARM_DESC(if2name, "The default name to allocate for second interface"); - -/* temp mac address if users want to use instead of the mac address in Efuse */ -char *rtw_initmac; - -module_param(rtw_initmac, charp, 0644); -module_param(rtw_channel_plan, int, 0644); -module_param(rtw_channel, int, 0644); -module_param(rtw_wmm_enable, int, 0644); -module_param(rtw_vrtl_carrier_sense, int, 0644); -module_param(rtw_vcs_type, int, 0644); -module_param(rtw_ht_enable, int, 0644); -module_param(rtw_cbw40_enable, int, 0644); -module_param(rtw_ampdu_enable, int, 0644); -module_param(rtw_rx_stbc, int, 0644); -module_param(rtw_ampdu_amsdu, int, 0644); -module_param(rtw_power_mgnt, int, 0644); -module_param(rtw_smart_ps, int, 0644); -module_param(rtw_wifi_spec, int, 0644); -module_param(rtw_antdiv_cfg, int, 0644); -module_param(rtw_antdiv_type, int, 0644); -module_param(rtw_enusbss, int, 0644); -module_param(rtw_hwpdn_mode, int, 0644); - -static uint rtw_max_roaming_times = 2; -module_param(rtw_max_roaming_times, uint, 0644); -MODULE_PARM_DESC(rtw_max_roaming_times, "The max roaming times to try"); - -static int rtw_fw_iol = 1;/* 0:Disable, 1:enable, 2:by usb speed */ -module_param(rtw_fw_iol, int, 0644); -MODULE_PARM_DESC(rtw_fw_iol, "FW IOL"); - -module_param(rtw_mc2u_disable, int, 0644); - -module_param(rtw_80211d, int, 0644); -MODULE_PARM_DESC(rtw_80211d, "Enable 802.11d mechanism"); - -static uint rtw_notch_filter = RTW_NOTCH_FILTER; -module_param(rtw_notch_filter, uint, 0644); -MODULE_PARM_DESC(rtw_notch_filter, "0:Disable, 1:Enable, 2:Enable only for P2P"); -module_param_named(debug, rtw_debug, int, 0444); -MODULE_PARM_DESC(debug, "Set debug level (1-9) (default 1)"); - -static bool rtw_monitor_enable; -module_param_named(monitor_enable, rtw_monitor_enable, bool, 0444); -MODULE_PARM_DESC(monitor_enable, "Enable monitor interface (default: false)"); - -static int netdev_close(struct net_device *pnetdev); - -static void loadparam(struct adapter *padapter) -{ - struct registry_priv *registry_par = &padapter->registrypriv; - - memcpy(registry_par->ssid.ssid, "ANY", 3); - registry_par->ssid.ssid_length = 3; - - registry_par->channel = (u8)rtw_channel; - registry_par->wireless_mode = (u8)rtw_wireless_mode; - registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense; - registry_par->vcs_type = (u8)rtw_vcs_type; - registry_par->rts_thresh = (u16)rtw_rts_thresh; - registry_par->frag_thresh = (u16)rtw_frag_thresh; - registry_par->preamble = (u8)rtw_preamble; - registry_par->smart_ps = (u8)rtw_smart_ps; - registry_par->power_mgnt = (u8)rtw_power_mgnt; - registry_par->ips_mode = (u8)rtw_ips_mode; - registry_par->mp_mode = 0; - registry_par->acm_method = (u8)rtw_acm_method; - - /* UAPSD */ - registry_par->wmm_enable = (u8)rtw_wmm_enable; - registry_par->uapsd_enable = (u8)rtw_uapsd_enable; - - registry_par->ht_enable = (u8)rtw_ht_enable; - registry_par->cbw40_enable = (u8)rtw_cbw40_enable; - registry_par->ampdu_enable = (u8)rtw_ampdu_enable; - registry_par->rx_stbc = (u8)rtw_rx_stbc; - registry_par->ampdu_amsdu = (u8)rtw_ampdu_amsdu; - registry_par->wifi_spec = (u8)rtw_wifi_spec; - registry_par->channel_plan = (u8)rtw_channel_plan; - registry_par->accept_addba_req = true; - registry_par->antdiv_cfg = (u8)rtw_antdiv_cfg; - registry_par->antdiv_type = (u8)rtw_antdiv_type; - registry_par->hwpdn_mode = (u8)rtw_hwpdn_mode; - - registry_par->max_roaming_times = (u8)rtw_max_roaming_times; - - registry_par->fw_iol = rtw_fw_iol; - - registry_par->enable80211d = (u8)rtw_80211d; - snprintf(registry_par->ifname, 16, "%s", ifname); - snprintf(registry_par->if2name, 16, "%s", if2name); - registry_par->notch_filter = (u8)rtw_notch_filter; - registry_par->monitor_enable = rtw_monitor_enable; -} - -static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) -{ - struct adapter *padapter = netdev_priv(pnetdev); - struct sockaddr *addr = p; - - if (!padapter->bup) - memcpy(padapter->eeprompriv.mac_addr, addr->sa_data, ETH_ALEN); - - return 0; -} - -static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) -{ - struct adapter *padapter = netdev_priv(pnetdev); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct recv_priv *precvpriv = &padapter->recvpriv; - - padapter->stats.tx_packets = pxmitpriv->tx_pkts; - padapter->stats.rx_packets = precvpriv->rx_pkts; - padapter->stats.tx_dropped = pxmitpriv->tx_drop; - padapter->stats.rx_dropped = precvpriv->rx_drop; - padapter->stats.tx_bytes = pxmitpriv->tx_bytes; - padapter->stats.rx_bytes = precvpriv->rx_bytes; - return &padapter->stats; -} - -/* - * AC to queue mapping - * - * AC_VO -> queue 0 - * AC_VI -> queue 1 - * AC_BE -> queue 2 - * AC_BK -> queue 3 - */ -static const u16 rtw_1d_to_queue[8] = { 2, 3, 3, 2, 1, 1, 0, 0 }; - -/* Given a data frame determine the 802.1p/1d tag to use. */ -static unsigned int rtw_classify8021d(struct sk_buff *skb) -{ - unsigned int dscp; - - /* skb->priority values from 256->263 are magic values to - * directly indicate a specific 802.1d priority. This is used - * to allow 802.1d priority to be passed directly in from VLAN - * tags, etc. - */ - if (skb->priority >= 256 && skb->priority <= 263) - return skb->priority - 256; - - switch (skb->protocol) { - case htons(ETH_P_IP): - dscp = ip_hdr(skb)->tos & 0xfc; - break; - default: - return 0; - } - - return dscp >> 5; -} - -static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, - struct net_device *sb_dev) -{ - struct adapter *padapter = netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - skb->priority = rtw_classify8021d(skb); - - if (pmlmepriv->acm_mask != 0) - skb->priority = qos_acm(pmlmepriv->acm_mask, skb->priority); - - return rtw_1d_to_queue[skb->priority]; -} - -u16 rtw_recv_select_queue(struct sk_buff *skb) -{ - struct iphdr *piphdr; - unsigned int dscp; - __be16 eth_type; - u32 priority; - u8 *pdata = skb->data; - - memcpy(ð_type, pdata + (ETH_ALEN << 1), 2); - - switch (eth_type) { - case htons(ETH_P_IP): - piphdr = (struct iphdr *)(pdata + ETH_HLEN); - dscp = piphdr->tos & 0xfc; - priority = dscp >> 5; - break; - default: - priority = 0; - } - - return rtw_1d_to_queue[priority]; -} - -static const struct net_device_ops rtw_netdev_ops = { - .ndo_open = netdev_open, - .ndo_stop = netdev_close, - .ndo_start_xmit = rtw_xmit_entry, - .ndo_select_queue = rtw_select_queue, - .ndo_set_mac_address = rtw_net_set_mac_address, - .ndo_get_stats = rtw_net_get_stats, - .ndo_do_ioctl = rtw_ioctl, -}; - -static const struct device_type wlan_type = { - .name = "wlan", -}; - -struct net_device *rtw_init_netdev(void) -{ - struct adapter *padapter; - struct net_device *pnetdev; - - pnetdev = alloc_etherdev_mq(sizeof(struct adapter), 4); - if (!pnetdev) - return NULL; - - pnetdev->dev.type = &wlan_type; - padapter = netdev_priv(pnetdev); - padapter->pnetdev = pnetdev; - pnetdev->netdev_ops = &rtw_netdev_ops; - pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */ - pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; - - loadparam(padapter); - padapter->cmdThread = NULL; - - return pnetdev; -} - -static int rtw_start_drv_threads(struct adapter *padapter) -{ - int err = 0; - - padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); - if (IS_ERR(padapter->cmdThread)) { - err = PTR_ERR(padapter->cmdThread); - padapter->cmdThread = NULL; - } - - return err; -} - -void rtw_stop_drv_threads(struct adapter *padapter) -{ - if (!padapter->cmdThread) - return; - - complete(&padapter->cmdpriv.cmd_queue_comp); - kthread_stop(padapter->cmdThread); -} - -static u8 rtw_init_default_value(struct adapter *padapter) -{ - struct registry_priv *pregistrypriv = &padapter->registrypriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - - /* xmit_priv */ - pxmitpriv->vcs_setting = pregistrypriv->vrtl_carrier_sense; - pxmitpriv->vcs = pregistrypriv->vcs_type; - pxmitpriv->vcs_type = pregistrypriv->vcs_type; - pxmitpriv->frag_len = pregistrypriv->frag_thresh; - - /* mlme_priv */ - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ - pmlmepriv->scan_mode = SCAN_ACTIVE; - - /* ht_priv */ - pmlmepriv->htpriv.ampdu_enable = false;/* set to disabled */ - - /* security_priv */ - psecuritypriv->binstallGrpkey = _FAIL; - psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; - psecuritypriv->dot11PrivacyKeyIndex = 0; - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; - psecuritypriv->dot118021XGrpKeyid = 1; - psecuritypriv->ndisauthtype = Ndis802_11AuthModeOpen; - psecuritypriv->ndisencryptstatus = Ndis802_11WEPDisabled; - - /* registry_priv */ - rtw_init_registrypriv_dev_network(padapter); - rtw_update_registrypriv_dev_network(padapter); - - /* hal_priv */ - rtw_hal_def_value_init(padapter); - - /* misc. */ - padapter->bReadPortCancel = false; - padapter->bWritePortCancel = false; - return _SUCCESS; -} - -u8 rtw_reset_drv_sw(struct adapter *padapter) -{ - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - - /* hal_priv */ - rtw_hal_def_value_init(padapter); - padapter->bReadPortCancel = false; - padapter->bWritePortCancel = false; - pmlmepriv->scan_interval = SCAN_INTERVAL;/* 30*2 sec = 60sec */ - - padapter->xmitpriv.tx_pkts = 0; - padapter->recvpriv.rx_pkts = 0; - - pmlmepriv->LinkDetectInfo.bBusyTraffic = false; - - _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING); - rtw_hal_sreset_init(padapter); - pwrctrlpriv->pwr_state_check_cnts = 0; - - /* mlmeextpriv */ - padapter->mlmeextpriv.sitesurvey_res.state = SCAN_DISABLE; - - rtw_set_signal_stat_timer(&padapter->recvpriv); - - return _SUCCESS; -} - -u8 rtw_init_drv_sw(struct adapter *padapter) -{ - u8 ret8 = _SUCCESS; - - rtw_init_cmd_priv(&padapter->cmdpriv); - - if (rtw_init_mlme_priv(padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } - - if (init_mlme_ext_priv(padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } - - if (_rtw_init_xmit_priv(&padapter->xmitpriv, padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } - - if (_rtw_init_recv_priv(&padapter->recvpriv, padapter) == _FAIL) { - ret8 = _FAIL; - goto exit; - } - - if (_rtw_init_sta_priv(&padapter->stapriv) == _FAIL) { - ret8 = _FAIL; - goto exit; - } - - padapter->stapriv.padapter = padapter; - - rtw_init_bcmc_stainfo(padapter); - - rtw_init_pwrctrl_priv(padapter); - - ret8 = rtw_init_default_value(padapter); - - rtw_hal_dm_init(padapter); - rtw_hal_sw_led_init(padapter); - - rtw_hal_sreset_init(padapter); - -exit: - return ret8; -} - -void rtw_cancel_all_timer(struct adapter *padapter) -{ - del_timer_sync(&padapter->mlmepriv.assoc_timer); - - del_timer_sync(&padapter->mlmepriv.scan_to_timer); - - del_timer_sync(&padapter->mlmepriv.dynamic_chk_timer); - - /* cancel sw led timer */ - rtw_hal_sw_led_deinit(padapter); - - del_timer_sync(&padapter->pwrctrlpriv.pwr_state_check_timer); - - del_timer_sync(&padapter->recvpriv.signal_stat_timer); -} - -u8 rtw_free_drv_sw(struct adapter *padapter) -{ - free_mlme_ext_priv(&padapter->mlmeextpriv); - - rtw_free_mlme_priv(&padapter->mlmepriv); - _rtw_free_xmit_priv(&padapter->xmitpriv); - - /* will free bcmc_stainfo here */ - _rtw_free_sta_priv(&padapter->stapriv); - - _rtw_free_recv_priv(&padapter->recvpriv); - - rtw_hal_free_data(padapter); - - mutex_destroy(&padapter->hw_init_mutex); - - return _SUCCESS; -} - -static int _netdev_open(struct net_device *pnetdev) -{ - uint status; - int err; - struct adapter *padapter = netdev_priv(pnetdev); - struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - - if (pwrctrlpriv->ps_flag) { - padapter->net_closed = false; - goto netdev_open_normal_process; - } - - if (!padapter->bup) { - padapter->bDriverStopped = false; - padapter->bSurpriseRemoved = false; - - status = rtw_hal_init(padapter); - if (status == _FAIL) - goto netdev_open_error; - - pr_info("MAC Address = %pM\n", pnetdev->dev_addr); - - err = rtw_start_drv_threads(padapter); - if (err) { - pr_info("Initialize driver software resource Failed!\n"); - goto netdev_open_error; - } - - if (init_hw_mlme_ext(padapter) == _FAIL) { - pr_info("can't init mlme_ext_priv\n"); - goto netdev_open_error; - } - rtw_hal_inirp_init(padapter); - - led_control_8188eu(padapter, LED_CTL_NO_LINK); - - padapter->bup = true; - } - padapter->net_closed = false; - - mod_timer(&padapter->mlmepriv.dynamic_chk_timer, - jiffies + msecs_to_jiffies(2000)); - - padapter->pwrctrlpriv.bips_processing = false; - rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); - - if (!rtw_netif_queue_stopped(pnetdev)) - netif_tx_start_all_queues(pnetdev); - else - netif_tx_wake_all_queues(pnetdev); - -netdev_open_normal_process: - return 0; - -netdev_open_error: - padapter->bup = false; - netif_carrier_off(pnetdev); - netif_tx_stop_all_queues(pnetdev); - return -1; -} - -int netdev_open(struct net_device *pnetdev) -{ - int ret; - struct adapter *padapter = netdev_priv(pnetdev); - - if (mutex_lock_interruptible(&padapter->hw_init_mutex)) - return -ERESTARTSYS; - ret = _netdev_open(pnetdev); - mutex_unlock(&padapter->hw_init_mutex); - return ret; -} - -int ips_netdrv_open(struct adapter *padapter) -{ - int status = _SUCCESS; - - padapter->net_closed = false; - - padapter->bDriverStopped = false; - padapter->bSurpriseRemoved = false; - - status = rtw_hal_init(padapter); - if (status == _FAIL) - goto netdev_open_error; - - rtw_hal_inirp_init(padapter); - - rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); - mod_timer(&padapter->mlmepriv.dynamic_chk_timer, - jiffies + msecs_to_jiffies(5000)); - - return _SUCCESS; - -netdev_open_error: - return _FAIL; -} - -int rtw_ips_pwr_up(struct adapter *padapter) -{ - int result; - - rtw_reset_drv_sw(padapter); - - result = ips_netdrv_open(padapter); - - led_control_8188eu(padapter, LED_CTL_NO_LINK); - - return result; -} - -void rtw_ips_pwr_down(struct adapter *padapter) -{ - padapter->net_closed = true; - - led_control_8188eu(padapter, LED_CTL_POWER_OFF); - - rtw_ips_dev_unload(padapter); -} - -void rtw_ips_dev_unload(struct adapter *padapter) -{ - rtw_hal_set_hwreg(padapter, HW_VAR_FIFO_CLEARN_UP, NULL); - - usb_intf_stop(padapter); - - /* s5. */ - if (!padapter->bSurpriseRemoved) - rtw_hal_deinit(padapter); -} - -static int netdev_close(struct net_device *pnetdev) -{ - struct adapter *padapter = netdev_priv(pnetdev); - - if (padapter->pwrctrlpriv.bInternalAutoSuspend) { - if (padapter->pwrctrlpriv.rf_pwrstate == rf_off) - padapter->pwrctrlpriv.ps_flag = true; - } - padapter->net_closed = true; - - if (padapter->pwrctrlpriv.rf_pwrstate == rf_on) { - /* s1. */ - if (pnetdev) { - if (!rtw_netif_queue_stopped(pnetdev)) - netif_tx_stop_all_queues(pnetdev); - } - - /* s2. */ - LeaveAllPowerSaveMode(padapter); - rtw_disassoc_cmd(padapter, 500, false); - /* s2-2. indicate disconnect to os */ - rtw_indicate_disconnect(padapter); - /* s2-3. */ - rtw_free_assoc_resources(padapter); - /* s2-4. */ - rtw_free_network_queue(padapter, true); - /* Close LED */ - led_control_8188eu(padapter, LED_CTL_POWER_OFF); - } - - return 0; -} diff --git a/drivers/staging/rtl8188eu/os_dep/osdep_service.c b/drivers/staging/rtl8188eu/os_dep/osdep_service.c deleted file mode 100644 index 57453df0ced8..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/osdep_service.c +++ /dev/null @@ -1,63 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _OSDEP_SERVICE_C_ - -#include -#include -#include -#include -#include -#include - -u8 *_rtw_malloc(u32 sz) -{ - return kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); -} - -void _rtw_init_queue(struct __queue *pqueue) -{ - INIT_LIST_HEAD(&pqueue->queue); - spin_lock_init(&pqueue->lock); -} - -void rtw_buf_free(u8 **buf, u32 *buf_len) -{ - *buf_len = 0; - kfree(*buf); - *buf = NULL; -} - -void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) -{ - u32 dup_len = 0; - u8 *ori = NULL; - u8 *dup = NULL; - - if (!buf || !buf_len) - return; - - if (!src || !src_len) - goto keep_ori; - - /* duplicate src */ - dup = rtw_malloc(src_len); - if (dup) { - dup_len = src_len; - memcpy(dup, src, dup_len); - } - -keep_ori: - ori = *buf; - - /* replace buf with dup */ - *buf_len = 0; - *buf = dup; - *buf_len = dup_len; - - /* free ori */ - kfree(ori); -} diff --git a/drivers/staging/rtl8188eu/os_dep/recv_linux.c b/drivers/staging/rtl8188eu/os_dep/recv_linux.c deleted file mode 100644 index 3460619ae08f..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/recv_linux.c +++ /dev/null @@ -1,138 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#include -#include - -#include -#include - -#include -#include - -/* alloc os related resource in struct recv_buf */ -int rtw_os_recvbuf_resource_alloc(struct recv_buf *precvbuf) -{ - precvbuf->pskb = NULL; - precvbuf->reuse = false; - precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL); - if (!precvbuf->purb) - return _FAIL; - return _SUCCESS; -} - -void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) -{ - union iwreq_data wrqu; - struct iw_michaelmicfailure ev; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - u32 cur_time = 0; - - if (psecuritypriv->last_mic_err_time == 0) { - psecuritypriv->last_mic_err_time = jiffies; - } else { - cur_time = jiffies; - - if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) { - psecuritypriv->btkip_countermeasure = true; - psecuritypriv->last_mic_err_time = 0; - psecuritypriv->btkip_countermeasure_time = cur_time; - } else { - psecuritypriv->last_mic_err_time = jiffies; - } - } - - memset(&ev, 0x00, sizeof(ev)); - if (bgroup) - ev.flags |= IW_MICFAILURE_GROUP; - else - ev.flags |= IW_MICFAILURE_PAIRWISE; - - ev.src_addr.sa_family = ARPHRD_ETHER; - memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN); - memset(&wrqu, 0x00, sizeof(wrqu)); - wrqu.data.length = sizeof(ev); - wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, - &wrqu, (char *)&ev); -} - -int rtw_recv_indicatepkt(struct adapter *padapter, - struct recv_frame *precv_frame) -{ - struct recv_priv *precvpriv; - struct __queue *pfree_recv_queue; - struct sk_buff *skb; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - precvpriv = &padapter->recvpriv; - pfree_recv_queue = &precvpriv->free_recv_queue; - - skb = precv_frame->pkt; - if (!skb) - goto _recv_indicatepkt_drop; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - struct sk_buff *pskb2 = NULL; - struct sta_info *psta = NULL; - struct sta_priv *pstapriv = &padapter->stapriv; - struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - bool mcast = is_multicast_ether_addr(pattrib->dst); - - if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), - ETH_ALEN)) { - if (mcast) { - psta = rtw_get_bcmc_stainfo(padapter); - pskb2 = skb_clone(skb, GFP_ATOMIC); - } else { - psta = rtw_get_stainfo(pstapriv, pattrib->dst); - } - - if (psta) { - struct net_device *pnetdev; - - pnetdev = (struct net_device *)padapter->pnetdev; - skb->dev = pnetdev; - skb_set_queue_mapping(skb, rtw_recv_select_queue(skb)); - - rtw_xmit_entry(skb, pnetdev); - - if (mcast) - skb = pskb2; - else - goto _recv_indicatepkt_end; - } - } - } - - skb->ip_summed = CHECKSUM_NONE; - skb->dev = padapter->pnetdev; - skb->protocol = eth_type_trans(skb, padapter->pnetdev); - - netif_rx(skb); - -_recv_indicatepkt_end: - - /* pointers to NULL before rtw_free_recvframe() */ - precv_frame->pkt = NULL; - - rtw_free_recvframe(precv_frame, pfree_recv_queue); - - return _SUCCESS; - -_recv_indicatepkt_drop: - - /* enqueue back to free_recv_queue */ - rtw_free_recvframe(precv_frame, pfree_recv_queue); - - return _FAIL; -} - -void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) -{ - timer_setup(&preorder_ctrl->reordering_ctrl_timer, - rtw_reordering_ctrl_timeout_handler, 0); -} diff --git a/drivers/staging/rtl8188eu/os_dep/rtw_android.c b/drivers/staging/rtl8188eu/os_dep/rtw_android.c deleted file mode 100644 index 3c5446999686..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/rtw_android.c +++ /dev/null @@ -1,223 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include -#include - -#include -#include -#include - -static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = { - "START", - "STOP", - "SCAN-ACTIVE", - "SCAN-PASSIVE", - "RSSI", - "LINKSPEED", - "RXFILTER-START", - "RXFILTER-STOP", - "RXFILTER-ADD", - "RXFILTER-REMOVE", - "BTCOEXSCAN-START", - "BTCOEXSCAN-STOP", - "BTCOEXMODE", - "SETSUSPENDOPT", - "P2P_DEV_ADDR", - "SETFWPATH", - "SETBAND", - "GETBAND", - "COUNTRY", - "P2P_SET_NOA", - "P2P_GET_NOA", - "P2P_SET_PS", - "SET_AP_WPS_P2P_IE", - "MACADDR", - "BLOCK", - "WFD-ENABLE", - "WFD-DISABLE", - "WFD-SET-TCPPORT", - "WFD-SET-MAXTPUT", - "WFD-SET-DEVTYPE", -}; - -struct android_wifi_priv_cmd { - const char __user *buf; - int used_len; - int total_len; -}; - -static int rtw_android_cmdstr_to_num(char *cmdstr) -{ - int cmd_num; - - for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) - if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], - strlen(android_wifi_cmd_str[cmd_num]))) - break; - return cmd_num; -} - -static int rtw_android_get_rssi(struct net_device *net, char *command, - int total_len) -{ - struct adapter *padapter = netdev_priv(net); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct wlan_network *pcur_network = &pmlmepriv->cur_network; - int bytes_written = 0; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - bytes_written += snprintf(&command[bytes_written], total_len, - "%s rssi %d", - pcur_network->network.ssid.ssid, - padapter->recvpriv.rssi); - } - return bytes_written; -} - -static int rtw_android_get_link_speed(struct net_device *net, char *command, - int total_len) -{ - struct adapter *padapter = netdev_priv(net); - u16 link_speed; - - link_speed = rtw_get_cur_max_rate(padapter) / 10; - return snprintf(command, total_len, "LinkSpeed %d", - link_speed); -} - -static int rtw_android_get_macaddr(struct net_device *net, char *command, - int total_len) -{ - return snprintf(command, total_len, "Macaddr = %pM", - net->dev_addr); -} - -static int android_set_cntry(struct net_device *net, char *command, - int total_len) -{ - struct adapter *adapter = netdev_priv(net); - char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1; - int ret; - - ret = rtw_set_country(adapter, country_code); - return (ret == _SUCCESS) ? 0 : -1; -} - -static int android_get_p2p_addr(struct net_device *net, char *command, - int total_len) -{ - /* We use the same address as our HW MAC address */ - memcpy(command, net->dev_addr, ETH_ALEN); - return ETH_ALEN; -} - -int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) -{ - int ret = 0; - char *command; - int cmd_num; - int bytes_written = 0; - struct android_wifi_priv_cmd priv_cmd; - - if (!ifr->ifr_data) - return -EINVAL; - if (copy_from_user(&priv_cmd, ifr->ifr_data, sizeof(priv_cmd))) - return -EFAULT; - if (priv_cmd.total_len < 1) - return -EINVAL; - command = memdup_user(priv_cmd.buf, priv_cmd.total_len); - if (IS_ERR(command)) - return PTR_ERR(command); - command[priv_cmd.total_len - 1] = 0; - cmd_num = rtw_android_cmdstr_to_num(command); - switch (cmd_num) { - case ANDROID_WIFI_CMD_START: - goto response; - case ANDROID_WIFI_CMD_SETFWPATH: - goto response; - } - switch (cmd_num) { - case ANDROID_WIFI_CMD_STOP: - break; - case ANDROID_WIFI_CMD_SCAN_ACTIVE: - break; - case ANDROID_WIFI_CMD_SCAN_PASSIVE: - break; - case ANDROID_WIFI_CMD_RSSI: - bytes_written = rtw_android_get_rssi(net, command, - priv_cmd.total_len); - break; - case ANDROID_WIFI_CMD_LINKSPEED: - bytes_written = rtw_android_get_link_speed(net, command, - priv_cmd.total_len); - break; - case ANDROID_WIFI_CMD_MACADDR: - bytes_written = rtw_android_get_macaddr(net, command, - priv_cmd.total_len); - break; - case ANDROID_WIFI_CMD_BLOCK: - break; - case ANDROID_WIFI_CMD_RXFILTER_START: - break; - case ANDROID_WIFI_CMD_RXFILTER_STOP: - break; - case ANDROID_WIFI_CMD_RXFILTER_ADD: - break; - case ANDROID_WIFI_CMD_RXFILTER_REMOVE: - break; - case ANDROID_WIFI_CMD_BTCOEXSCAN_START: - /* TBD: BTCOEXSCAN-START */ - break; - case ANDROID_WIFI_CMD_BTCOEXSCAN_STOP: - /* TBD: BTCOEXSCAN-STOP */ - break; - case ANDROID_WIFI_CMD_BTCOEXMODE: - break; - case ANDROID_WIFI_CMD_SETSUSPENDOPT: - break; - case ANDROID_WIFI_CMD_SETBAND: - break; - case ANDROID_WIFI_CMD_GETBAND: - break; - case ANDROID_WIFI_CMD_COUNTRY: - bytes_written = android_set_cntry(net, command, - priv_cmd.total_len); - break; - case ANDROID_WIFI_CMD_P2P_DEV_ADDR: - bytes_written = android_get_p2p_addr(net, command, - priv_cmd.total_len); - break; - case ANDROID_WIFI_CMD_P2P_SET_NOA: - break; - case ANDROID_WIFI_CMD_P2P_GET_NOA: - break; - case ANDROID_WIFI_CMD_P2P_SET_PS: - break; - default: - snprintf(command, 3, "OK"); - bytes_written = strlen("OK"); - } - -response: - if (bytes_written >= 0) { - if ((bytes_written == 0) && (priv_cmd.total_len > 0)) - command[0] = '\0'; - if (bytes_written >= priv_cmd.total_len) - bytes_written = priv_cmd.total_len; - else - bytes_written++; - priv_cmd.used_len = bytes_written; - if (copy_to_user((char __user *)priv_cmd.buf, command, - bytes_written)) - ret = -EFAULT; - } else { - ret = bytes_written; - } - kfree(command); - return ret; -} diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c deleted file mode 100644 index 1bf7b2c35c34..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c +++ /dev/null @@ -1,479 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#define pr_fmt(fmt) "R8188EU: " fmt -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include "rtl8188e_hal.h" - -#define USB_VENDER_ID_REALTEK 0x0bda - -/* DID_USB_v916_20130116 */ -static const struct usb_device_id rtw_usb_id_tbl[] = { - /*=== Realtek demoboard ===*/ - {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x8179)}, /* 8188EUS */ - {USB_DEVICE(USB_VENDER_ID_REALTEK, 0x0179)}, /* 8188ETV */ - /*=== Customer ID ===*/ - /****** 8188EUS ********/ - {USB_DEVICE(0x056e, 0x4008)}, /* Elecom WDC-150SU2M */ - {USB_DEVICE(0x07b8, 0x8179)}, /* Abocom - Abocom */ - {USB_DEVICE(0x0B05, 0x18F0)}, /* ASUS USB-N10 Nano B1 */ - {USB_DEVICE(0x2001, 0x330F)}, /* DLink DWA-125 REV D1 */ - {USB_DEVICE(0x2001, 0x3310)}, /* Dlink DWA-123 REV D1 */ - {USB_DEVICE(0x2001, 0x3311)}, /* DLink GO-USB-N150 REV B1 */ - {USB_DEVICE(0x2001, 0x331B)}, /* D-Link DWA-121 rev B1 */ - {USB_DEVICE(0x2357, 0x010c)}, /* TP-Link TL-WN722N v2 */ - {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */ - {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */ - {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ - {USB_DEVICE(0x7392, 0xb811)}, /* Edimax EW-7811UN V2 */ - {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */ - {} /* Terminating entry */ -}; - -MODULE_DEVICE_TABLE(usb, rtw_usb_id_tbl); - -static int usb_dvobj_init(struct usb_interface *usb_intf) -{ - int i; - struct dvobj_priv *pdvobjpriv; - struct usb_host_config *phost_conf; - struct usb_config_descriptor *pconf_desc; - struct usb_host_interface *phost_iface; - struct usb_interface_descriptor *piface_desc; - struct usb_endpoint_descriptor *pendp_desc; - struct usb_device *pusbd; - - pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL); - if (!pdvobjpriv) - return -ENOMEM; - - pdvobjpriv->pusbintf = usb_intf; - pusbd = interface_to_usbdev(usb_intf); - pdvobjpriv->pusbdev = pusbd; - usb_set_intfdata(usb_intf, pdvobjpriv); - - pdvobjpriv->RtNumInPipes = 0; - pdvobjpriv->RtNumOutPipes = 0; - - phost_conf = pusbd->actconfig; - pconf_desc = &phost_conf->desc; - - phost_iface = usb_intf->cur_altsetting; - piface_desc = &phost_iface->desc; - - pdvobjpriv->NumInterfaces = pconf_desc->bNumInterfaces; - pdvobjpriv->InterfaceNumber = piface_desc->bInterfaceNumber; - - for (i = 0; i < piface_desc->bNumEndpoints; i++) { - int ep_num; - - pendp_desc = &phost_iface->endpoint[i].desc; - - ep_num = usb_endpoint_num(pendp_desc); - - if (usb_endpoint_is_bulk_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_int_in(pendp_desc)) { - pdvobjpriv->RtInPipe[pdvobjpriv->RtNumInPipes] = ep_num; - pdvobjpriv->RtNumInPipes++; - } else if (usb_endpoint_is_bulk_out(pendp_desc)) { - pdvobjpriv->RtOutPipe[pdvobjpriv->RtNumOutPipes] = - ep_num; - pdvobjpriv->RtNumOutPipes++; - } - } - - if (pusbd->speed == USB_SPEED_HIGH) - pdvobjpriv->ishighspeed = true; - else - pdvobjpriv->ishighspeed = false; - - mutex_init(&pdvobjpriv->usb_vendor_req_mutex); - usb_get_dev(pusbd); - - return 0; -} - -static void usb_dvobj_deinit(struct usb_interface *usb_intf) -{ - struct dvobj_priv *dvobj = usb_get_intfdata(usb_intf); - - usb_set_intfdata(usb_intf, NULL); - if (dvobj) { - /* Modify condition for 92DU DMDP 2010.11.18, by Thomas */ - if ((dvobj->NumInterfaces != 2 && - dvobj->NumInterfaces != 3) || - (dvobj->InterfaceNumber == 1)) { - if (interface_to_usbdev(usb_intf)->state != - USB_STATE_NOTATTACHED) { - /* If we didn't unplug usb dongle and - * remove/insert module, driver fails - * on sitesurvey for the first time when - * device is up . Reset usb port for sitesurvey - * fail issue. - */ - pr_debug("usb attached..., try to reset usb device\n"); - usb_reset_device(interface_to_usbdev(usb_intf)); - } - } - - mutex_destroy(&dvobj->usb_vendor_req_mutex); - kfree(dvobj); - } - - usb_put_dev(interface_to_usbdev(usb_intf)); -} - -void usb_intf_stop(struct adapter *padapter) -{ - /* cancel in irp */ - rtw_hal_inirp_deinit(padapter); - - /* cancel out irp */ - usb_write_port_cancel(padapter); - - /* todo:cancel other irps */ -} - -static void rtw_dev_unload(struct adapter *padapter) -{ - if (padapter->bup) { - padapter->bDriverStopped = true; - if (padapter->xmitpriv.ack_tx) - rtw_ack_tx_done(&padapter->xmitpriv, RTW_SCTX_DONE_DRV_STOP); - /* s3. */ - usb_intf_stop(padapter); - /* s4. */ - if (!padapter->pwrctrlpriv.bInternalAutoSuspend) - rtw_stop_drv_threads(padapter); - - /* s5. */ - if (!padapter->bSurpriseRemoved) { - rtw_hal_deinit(padapter); - padapter->bSurpriseRemoved = true; - } - - padapter->bup = false; - } -} - -static int rtw_suspend(struct usb_interface *pusb_intf, pm_message_t message) -{ - struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); - struct adapter *padapter = dvobj->if1; - struct net_device *pnetdev = padapter->pnetdev; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - unsigned long start_time = jiffies; - - pr_debug("==> %s (%s:%d)\n", __func__, current->comm, current->pid); - - if ((!padapter->bup) || (padapter->bDriverStopped) || - (padapter->bSurpriseRemoved)) { - pr_debug("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", - padapter->bup, padapter->bDriverStopped, - padapter->bSurpriseRemoved); - goto exit; - } - - pwrpriv->bInSuspend = true; - rtw_cancel_all_timer(padapter); - LeaveAllPowerSaveMode(padapter); - - mutex_lock(&pwrpriv->mutex_lock); - /* s1. */ - if (pnetdev) { - netif_carrier_off(pnetdev); - netif_tx_stop_all_queues(pnetdev); - } - - /* s2. */ - rtw_disassoc_cmd(padapter, 0, false); - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && - check_fwstate(pmlmepriv, _FW_LINKED)) { - pr_debug("%s:%d %s(%pM), length:%d assoc_ssid.length:%d\n", - __func__, __LINE__, - pmlmepriv->cur_network.network.ssid.ssid, - pmlmepriv->cur_network.network.MacAddress, - pmlmepriv->cur_network.network.ssid.ssid_length, - pmlmepriv->assoc_ssid.ssid_length); - - pmlmepriv->to_roaming = 1; - } - /* s2-2. indicate disconnect to os */ - rtw_indicate_disconnect(padapter); - /* s2-3. */ - rtw_free_assoc_resources(padapter); - /* s2-4. */ - rtw_free_network_queue(padapter, true); - - rtw_dev_unload(padapter); - mutex_unlock(&pwrpriv->mutex_lock); - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) - rtw_indicate_scan_done(padapter, 1); - - if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) - rtw_indicate_disconnect(padapter); - -exit: - pr_debug("<=== %s .............. in %dms\n", __func__, - jiffies_to_msecs(jiffies - start_time)); - - return 0; -} - -static int rtw_resume_process(struct adapter *padapter) -{ - struct net_device *pnetdev; - struct pwrctrl_priv *pwrpriv = NULL; - int ret = -1; - unsigned long start_time = jiffies; - - pr_debug("==> %s (%s:%d)\n", __func__, current->comm, current->pid); - - if (padapter) { - pnetdev = padapter->pnetdev; - pwrpriv = &padapter->pwrctrlpriv; - } else { - goto exit; - } - - mutex_lock(&pwrpriv->mutex_lock); - rtw_reset_drv_sw(padapter); - pwrpriv->bkeepfwalive = false; - - pr_debug("bkeepfwalive(%x)\n", pwrpriv->bkeepfwalive); - if (netdev_open(pnetdev) != 0) { - mutex_unlock(&pwrpriv->mutex_lock); - goto exit; - } - - netif_device_attach(pnetdev); - netif_carrier_on(pnetdev); - - mutex_unlock(&pwrpriv->mutex_lock); - - rtw_roaming(padapter, NULL); - - ret = 0; -exit: - if (pwrpriv) - pwrpriv->bInSuspend = false; - pr_debug("<=== %s return %d.............. in %dms\n", __func__, - ret, jiffies_to_msecs(jiffies - start_time)); - - return ret; -} - -static int rtw_resume(struct usb_interface *pusb_intf) -{ - struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); - struct adapter *padapter = dvobj->if1; - - return rtw_resume_process(padapter); -} - -/* - * drv_init() - a device potentially for us - * - * notes: drv_init() is called when the bus driver has located - * a card for us to support. - * We accept the new device by returning 0. - */ - -static int rtw_usb_if1_init(struct usb_interface *pusb_intf) -{ - struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); - struct adapter *padapter; - struct net_device *pnetdev; - struct net_device *pmondev; - int err = 0; - - pnetdev = rtw_init_netdev(); - if (!pnetdev) - return -ENOMEM; - SET_NETDEV_DEV(pnetdev, dvobj_to_dev(dvobj)); - - padapter = netdev_priv(pnetdev); - padapter->dvobj = dvobj; - dvobj->if1 = padapter; - - padapter->bDriverStopped = true; - mutex_init(&padapter->hw_init_mutex); - - if (padapter->registrypriv.monitor_enable) { - pmondev = rtl88eu_mon_init(); - if (!pmondev) - netdev_warn(pnetdev, "Failed to initialize monitor interface"); - padapter->pmondev = pmondev; - } - - padapter->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL); - if (!padapter->HalData) { - err = -ENOMEM; - goto free_adapter; - } - - /* step read_chip_version */ - rtw_hal_read_chip_version(padapter); - - /* step usb endpoint mapping */ - rtw_hal_chip_configure(padapter); - - /* step read efuse/eeprom data and get mac_addr */ - rtw_hal_read_chip_info(padapter); - - /* step 5. */ - if (rtw_init_drv_sw(padapter) == _FAIL) { - err = -ENOMEM; - goto free_hal_data; - } - -#ifdef CONFIG_PM - if (padapter->pwrctrlpriv.bSupportRemoteWakeup) { - dvobj->pusbdev->do_remote_wakeup = 1; - pusb_intf->needs_remote_wakeup = 1; - device_init_wakeup(&pusb_intf->dev, 1); - pr_debug("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n", - device_may_wakeup(&pusb_intf->dev)); - } -#endif - - /* 2012-07-11 Move here to prevent the 8723AS-VAU BT auto suspend influence */ - if (usb_autopm_get_interface(pusb_intf) < 0) - pr_debug("can't get autopm:\n"); - - /* alloc dev name after read efuse. */ - err = dev_alloc_name(pnetdev, padapter->registrypriv.ifname); - if (err < 0) - goto free_hal_data; - - netif_carrier_off(pnetdev); - - rtw_macaddr_cfg(padapter->eeprompriv.mac_addr); - memcpy(pnetdev->dev_addr, padapter->eeprompriv.mac_addr, ETH_ALEN); - pr_debug("MAC Address from pnetdev->dev_addr = %pM\n", - pnetdev->dev_addr); - - /* step 6. Tell the network stack we exist */ - err = register_netdev(pnetdev); - if (err) - goto free_hal_data; - - pr_debug("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n" - , padapter->bDriverStopped - , padapter->bSurpriseRemoved - , padapter->bup - , padapter->hw_init_completed - ); - - return 0; - -free_hal_data: - kfree(padapter->HalData); -free_adapter: - free_netdev(pnetdev); - return err; -} - -static void rtw_usb_if1_deinit(struct adapter *if1) -{ - struct net_device *pnetdev = if1->pnetdev; - struct mlme_priv *pmlmepriv = &if1->mlmepriv; - - if (check_fwstate(pmlmepriv, _FW_LINKED)) - rtw_disassoc_cmd(if1, 0, false); - -#ifdef CONFIG_88EU_AP_MODE - free_mlme_ap_info(if1); -#endif - - if (pnetdev) - unregister_netdev(pnetdev); /* will call netdev_close() */ - - rtl88eu_mon_deinit(if1->pmondev); - rtw_cancel_all_timer(if1); - - rtw_dev_unload(if1); - pr_debug("+r871xu_dev_remove, hw_init_completed=%d\n", - if1->hw_init_completed); - rtw_free_drv_sw(if1); - if (pnetdev) - free_netdev(pnetdev); -} - -static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) -{ - int err; - - err = usb_dvobj_init(pusb_intf); - if (err) { - pr_debug("usb_dvobj_init failed\n"); - return err; - } - - err = rtw_usb_if1_init(pusb_intf); - if (err) { - pr_debug("rtw_usb_if1_init failed\n"); - usb_dvobj_deinit(pusb_intf); - return err; - } - - return 0; -} - -/* - * dev_remove() - our device is being removed - * - * rmmod module & unplug(SurpriseRemoved) will call r871xu_dev_remove() => how to recognize both - */ -static void rtw_dev_remove(struct usb_interface *pusb_intf) -{ - struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); - struct adapter *padapter = dvobj->if1; - - if (!pusb_intf->unregistering) - padapter->bSurpriseRemoved = true; - - rtw_pm_set_ips(padapter, IPS_NONE); - rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - - LeaveAllPowerSaveMode(padapter); - - rtw_usb_if1_deinit(padapter); - - usb_dvobj_deinit(pusb_intf); - - pr_debug("-r871xu_dev_remove, done\n"); -} - -static struct usb_driver rtl8188e_usb_drv = { - .name = "r8188eu", - .probe = rtw_drv_init, - .disconnect = rtw_dev_remove, - .id_table = rtw_usb_id_tbl, - .suspend = rtw_suspend, - .resume = rtw_resume, - .reset_resume = rtw_resume, -}; - -module_usb_driver(rtl8188e_usb_drv) diff --git a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c b/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c deleted file mode 100644 index 0ceb05f3884f..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/usb_ops_linux.c +++ /dev/null @@ -1,644 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _USB_OPS_LINUX_C_ - -#include -#include -#include - -#define RTW_USB_CONTROL_MSG_TIMEOUT 500 /* ms */ - -#define MAX_USBCTRL_VENDORREQ_TIMES 10 - -#define ALIGNMENT_UNIT 16 -#define MAX_VENDOR_REQ_CMD_SIZE 254 -#define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) - -#define REALTEK_USB_VENQT_READ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) -#define REALTEK_USB_VENQT_WRITE (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) - -#define REALTEK_USB_VENQT_CMD_REQ 0x05 -#define REALTEK_USB_VENQT_CMD_IDX 0x00 - -static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) -{ - struct hal_data_8188e *haldata = adapt->HalData; - - if (pkt_len != INTERRUPT_MSG_FORMAT_LEN) - return; - - /* HISR */ - memcpy(&haldata->IntArray[0], &pbuf[USB_INTR_CONTENT_HISR_OFFSET], 4); - memcpy(&haldata->IntArray[1], &pbuf[USB_INTR_CONTENT_HISRE_OFFSET], 4); - - /* C2H Event */ - if (pbuf[0] != 0) - memcpy(&haldata->C2hArray[0], - &pbuf[USB_INTR_CONTENT_C2H_OFFSET], 16); -} - -static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) -{ - u8 *pbuf; - u8 shift_sz = 0; - u16 pkt_cnt; - u32 pkt_offset, skb_len, alloc_sz; - s32 transfer_len; - struct recv_stat *prxstat; - struct phy_stat *pphy_status = NULL; - struct sk_buff *pkt_copy = NULL; - struct recv_frame *precvframe = NULL; - struct rx_pkt_attrib *pattrib = NULL; - struct hal_data_8188e *haldata = adapt->HalData; - struct recv_priv *precvpriv = &adapt->recvpriv; - struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; - - transfer_len = (s32)pskb->len; - pbuf = pskb->data; - - prxstat = (struct recv_stat *)pbuf; - pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; - - do { - prxstat = (struct recv_stat *)pbuf; - - precvframe = rtw_alloc_recvframe(pfree_recv_queue); - if (!precvframe) - goto _exit_recvbuf2recvframe; - - INIT_LIST_HEAD(&precvframe->list); - - update_recvframe_attrib_88e(precvframe, prxstat); - - pattrib = &precvframe->attrib; - - if ((pattrib->crc_err) || (pattrib->icv_err)) { - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - - if ((pattrib->physt) && (pattrib->pkt_rpt_type == NORMAL_RX)) - pphy_status = (struct phy_stat *)(pbuf + RXDESC_OFFSET); - - pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; - - if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - - /* Modified by Albert 20101213 */ - /* For 8 bytes IP header alignment. */ - if (pattrib->qos) /* Qos data, wireless lan header length is 26 */ - shift_sz = 6; - else - shift_sz = 0; - - skb_len = pattrib->pkt_len; - - /* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */ - /* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */ - if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) { - if (skb_len <= 1650) - alloc_sz = 1664; - else - alloc_sz = skb_len + 14; - } else { - alloc_sz = skb_len; - /* 6 is for IP header 8 bytes alignment in QoS packet case. */ - /* 8 is for skb->data 4 bytes alignment. */ - alloc_sz += 14; - } - - pkt_copy = netdev_alloc_skb(adapt->pnetdev, alloc_sz); - if (pkt_copy) { - pkt_copy->dev = adapt->pnetdev; - precvframe->pkt = pkt_copy; - skb_reserve(pkt_copy, 8 - ((size_t)(pkt_copy->data) & 7));/* force pkt_copy->data at 8-byte alignment address */ - skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */ - skb_put_data(pkt_copy, (pbuf + pattrib->drvinfo_sz + RXDESC_SIZE), skb_len); - } else { - rtw_free_recvframe(precvframe, pfree_recv_queue); - goto _exit_recvbuf2recvframe; - } - - switch (haldata->UsbRxAggMode) { - case USB_RX_AGG_DMA: - case USB_RX_AGG_MIX: - pkt_offset = (u16)round_up(pkt_offset, 128); - break; - case USB_RX_AGG_USB: - pkt_offset = (u16)round_up(pkt_offset, 4); - break; - case USB_RX_AGG_DISABLE: - default: - break; - } - if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ - if (pattrib->physt) - update_recvframe_phyinfo_88e(precvframe, pphy_status); - rtw_recv_entry(precvframe); - } else if (pattrib->pkt_rpt_type == TX_REPORT1) { - /* CCX-TXRPT ack for xmit mgmt frames. */ - handle_txrpt_ccx_88e(adapt, precvframe->pkt->data); - rtw_free_recvframe(precvframe, pfree_recv_queue); - } else if (pattrib->pkt_rpt_type == TX_REPORT2) { - ODM_RA_TxRPT2Handle_8188E(&haldata->odmpriv, - precvframe->pkt->data, - pattrib->pkt_len, - pattrib->MacIDValidEntry[0], - pattrib->MacIDValidEntry[1]); - rtw_free_recvframe(precvframe, pfree_recv_queue); - } else if (pattrib->pkt_rpt_type == HIS_REPORT) { - interrupt_handler_8188eu(adapt, pattrib->pkt_len, precvframe->pkt->data); - rtw_free_recvframe(precvframe, pfree_recv_queue); - } - pkt_cnt--; - transfer_len -= pkt_offset; - pbuf += pkt_offset; - precvframe = NULL; - pkt_copy = NULL; - - if (transfer_len > 0 && pkt_cnt == 0) - pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; - - } while ((transfer_len > 0) && (pkt_cnt > 0)); - -_exit_recvbuf2recvframe: - - return _SUCCESS; -} - -static unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr) -{ - unsigned int pipe = 0, ep_num = 0; - struct usb_device *pusbd = pdvobj->pusbdev; - - if (addr == RECV_BULK_IN_ADDR) { - pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]); - } else if (addr == RECV_INT_IN_ADDR) { - pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]); - } else if (addr < HW_QUEUE_ENTRY) { - ep_num = pdvobj->Queue2Pipe[addr]; - pipe = usb_sndbulkpipe(pusbd, ep_num); - } - - return pipe; -} - -static int -usbctrl_vendorreq(struct adapter *adapt, u16 value, void *pdata, u16 len, u8 reqtype) -{ - struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); - struct usb_device *udev = dvobjpriv->pusbdev; - unsigned int pipe; - int status = 0; - u8 *pIo_buf; - int vendorreq_times = 0; - - if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { - status = -EPERM; - goto exit; - } - - if (len > MAX_VENDOR_REQ_CMD_SIZE) { - status = -EINVAL; - goto exit; - } - - if (mutex_lock_interruptible(&dvobjpriv->usb_vendor_req_mutex)) { - status = -ERESTARTSYS; - goto exit; - } - - /* Acquire IO memory for vendorreq */ - pIo_buf = kmalloc(MAX_USB_IO_CTL_SIZE, GFP_ATOMIC); - - if (!pIo_buf) { - status = -ENOMEM; - goto release_mutex; - } - - if (reqtype == REALTEK_USB_VENQT_READ) { - pipe = usb_rcvctrlpipe(udev, 0); - } else if (reqtype == REALTEK_USB_VENQT_WRITE) { - pipe = usb_sndctrlpipe(udev, 0); - } else { - status = -EINVAL; - goto free_buf; - } - - while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { - if (reqtype == REALTEK_USB_VENQT_READ) - memset(pIo_buf, 0, len); - else - memcpy(pIo_buf, pdata, len); - - status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, - reqtype, value, REALTEK_USB_VENQT_CMD_IDX, - pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); - - if (status == len) { /* Success this control transfer. */ - if (reqtype == REALTEK_USB_VENQT_READ) - memcpy(pdata, pIo_buf, len); - } else { /* error cases */ - if (status < 0) { - if (status == -ESHUTDOWN || status == -ENODEV) - adapt->bSurpriseRemoved = true; - else - adapt->HalData->srestpriv.wifi_error_status = USB_VEN_REQ_CMD_FAIL; - } else { /* status != len && status >= 0 */ - if (status > 0) { - if (reqtype == REALTEK_USB_VENQT_READ) { - /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ - memcpy(pdata, pIo_buf, len); - } - } - } - } - - /* firmware download is checksummed, don't retry */ - if ((value >= FW_8188E_START_ADDRESS && value <= FW_8188E_END_ADDRESS) || status == len) - break; - } - -free_buf: - kfree(pIo_buf); -release_mutex: - mutex_unlock(&dvobjpriv->usb_vendor_req_mutex); -exit: - return status; -} - -u8 usb_read8(struct adapter *adapter, u32 addr) -{ - u16 wvalue = (u16)(addr & 0xffff); - u8 data; - - usbctrl_vendorreq(adapter, wvalue, &data, 1, REALTEK_USB_VENQT_READ); - - return data; -} - -u16 usb_read16(struct adapter *adapter, u32 addr) -{ - u16 wvalue = (u16)(addr & 0xffff); - __le32 data; - - usbctrl_vendorreq(adapter, wvalue, &data, 2, REALTEK_USB_VENQT_READ); - - return (u16)(le32_to_cpu(data) & 0xffff); -} - -u32 usb_read32(struct adapter *adapter, u32 addr) -{ - u16 wvalue = (u16)(addr & 0xffff); - __le32 data; - - usbctrl_vendorreq(adapter, wvalue, &data, 4, REALTEK_USB_VENQT_READ); - - return le32_to_cpu(data); -} - -static void usb_read_port_complete(struct urb *purb) -{ - struct recv_buf *precvbuf = (struct recv_buf *)purb->context; - struct adapter *adapt = (struct adapter *)precvbuf->adapter; - struct recv_priv *precvpriv = &adapt->recvpriv; - - if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { - precvbuf->reuse = true; - return; - } - - if (purb->status == 0) { /* SUCCESS */ - if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { - precvbuf->reuse = true; - usb_read_port(adapt, RECV_BULK_IN_ADDR, precvbuf); - } else { - skb_put(precvbuf->pskb, purb->actual_length); - skb_queue_tail(&precvpriv->rx_skb_queue, precvbuf->pskb); - - if (skb_queue_len(&precvpriv->rx_skb_queue) <= 1) - tasklet_schedule(&precvpriv->recv_tasklet); - - precvbuf->pskb = NULL; - precvbuf->reuse = false; - usb_read_port(adapt, RECV_BULK_IN_ADDR, precvbuf); - } - } else { - skb_put(precvbuf->pskb, purb->actual_length); - precvbuf->pskb = NULL; - - switch (purb->status) { - case -EINVAL: - case -EPIPE: - case -ENODEV: - case -ESHUTDOWN: - adapt->bSurpriseRemoved = true; - fallthrough; - case -ENOENT: - adapt->bDriverStopped = true; - break; - case -EPROTO: - case -EOVERFLOW: - adapt->HalData->srestpriv.wifi_error_status = USB_READ_PORT_FAIL; - precvbuf->reuse = true; - usb_read_port(adapt, RECV_BULK_IN_ADDR, precvbuf); - break; - case -EINPROGRESS: - break; - default: - break; - } - } -} - -u32 usb_read_port(struct adapter *adapter, u32 addr, struct recv_buf *precvbuf) -{ - struct urb *purb = NULL; - struct dvobj_priv *pdvobj = adapter_to_dvobj(adapter); - struct recv_priv *precvpriv = &adapter->recvpriv; - struct usb_device *pusbd = pdvobj->pusbdev; - int err; - unsigned int pipe; - - if (adapter->bDriverStopped || adapter->bSurpriseRemoved || - adapter->pwrctrlpriv.pnp_bstop_trx) { - return _FAIL; - } - - if (!precvbuf) - return _FAIL; - - if (!precvbuf->reuse || !precvbuf->pskb) { - precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); - if (precvbuf->pskb) - precvbuf->reuse = true; - } - - /* re-assign for linux based on skb */ - if (!precvbuf->reuse || !precvbuf->pskb) { - precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ); - if (!precvbuf->pskb) - return _FAIL; - } else { /* reuse skb */ - precvbuf->reuse = false; - } - - purb = precvbuf->purb; - - /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl(pdvobj, addr); - - usb_fill_bulk_urb(purb, pusbd, pipe, - precvbuf->pskb->data, - MAX_RECVBUF_SZ, - usb_read_port_complete, - precvbuf);/* context is precvbuf */ - - err = usb_submit_urb(purb, GFP_ATOMIC); - if (err) - return _FAIL; - - return _SUCCESS; -} - -void rtw_hal_inirp_deinit(struct adapter *padapter) -{ - int i; - struct recv_buf *precvbuf; - - precvbuf = padapter->recvpriv.precv_buf; - - padapter->bReadPortCancel = true; - - for (i = 0; i < NR_RECVBUFF; i++) { - precvbuf->reuse = true; - if (precvbuf->purb) - usb_kill_urb(precvbuf->purb); - precvbuf++; - } -} - -int usb_write8(struct adapter *adapter, u32 addr, u8 val) -{ - u16 wvalue = (u16)(addr & 0xffff); - u8 data = val; - - return usbctrl_vendorreq(adapter, wvalue, &data, 1, REALTEK_USB_VENQT_WRITE); -} - -int usb_write16(struct adapter *adapter, u32 addr, u16 val) -{ - u16 wvalue = (u16)(addr & 0xffff); - __le32 data = cpu_to_le32(val & 0xffff); - - return usbctrl_vendorreq(adapter, wvalue, &data, 2, REALTEK_USB_VENQT_WRITE); -} - -int usb_write32(struct adapter *adapter, u32 addr, u32 val) -{ - u16 wvalue = (u16)(addr & 0xffff); - __le32 data = cpu_to_le32(val); - - return usbctrl_vendorreq(adapter, wvalue, &data, 4, REALTEK_USB_VENQT_WRITE); -} - -static void usb_write_port_complete(struct urb *purb) -{ - struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context; - struct adapter *padapter = pxmitbuf->padapter; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - switch (pxmitbuf->flags) { - case VO_QUEUE_INX: - pxmitpriv->voq_cnt--; - break; - case VI_QUEUE_INX: - pxmitpriv->viq_cnt--; - break; - case BE_QUEUE_INX: - pxmitpriv->beq_cnt--; - break; - case BK_QUEUE_INX: - pxmitpriv->bkq_cnt--; - break; - case HIGH_QUEUE_INX: -#ifdef CONFIG_88EU_AP_MODE - rtw_chk_hi_queue_cmd(padapter); -#endif - break; - default: - break; - } - - if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->bWritePortCancel) - goto check_completion; - - if (purb->status) { - if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { - sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); - } else if (purb->status == -EINPROGRESS) { - goto check_completion; - } else if (purb->status == -ENOENT) { - goto check_completion; - } else if (purb->status == -ECONNRESET) { - goto check_completion; - } else if (purb->status == -ESHUTDOWN) { - padapter->bDriverStopped = true; - goto check_completion; - } else { - padapter->bSurpriseRemoved = true; - goto check_completion; - } - } - -check_completion: - rtw_sctx_done_err(&pxmitbuf->sctx, - purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR : - RTW_SCTX_DONE_SUCCESS); - - rtw_free_xmitbuf(pxmitpriv, pxmitbuf); - - tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); -} - -u32 usb_write_port(struct adapter *padapter, u32 addr, u32 cnt, struct xmit_buf *xmitbuf) -{ - unsigned long irqL; - unsigned int pipe; - int status; - u32 ret = _FAIL; - struct urb *purb = NULL; - struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct xmit_frame *pxmitframe = (struct xmit_frame *)xmitbuf->priv_data; - struct usb_device *pusbd = pdvobj->pusbdev; - - if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || - (padapter->pwrctrlpriv.pnp_bstop_trx)) { - rtw_sctx_done_err(&xmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); - goto exit; - } - - spin_lock_irqsave(&pxmitpriv->lock, irqL); - - switch (addr) { - case VO_QUEUE_INX: - pxmitpriv->voq_cnt++; - xmitbuf->flags = VO_QUEUE_INX; - break; - case VI_QUEUE_INX: - pxmitpriv->viq_cnt++; - xmitbuf->flags = VI_QUEUE_INX; - break; - case BE_QUEUE_INX: - pxmitpriv->beq_cnt++; - xmitbuf->flags = BE_QUEUE_INX; - break; - case BK_QUEUE_INX: - pxmitpriv->bkq_cnt++; - xmitbuf->flags = BK_QUEUE_INX; - break; - case HIGH_QUEUE_INX: - xmitbuf->flags = HIGH_QUEUE_INX; - break; - default: - xmitbuf->flags = MGT_QUEUE_INX; - break; - } - - spin_unlock_irqrestore(&pxmitpriv->lock, irqL); - - purb = xmitbuf->pxmit_urb[0]; - - /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl(pdvobj, addr); - - usb_fill_bulk_urb(purb, pusbd, pipe, - pxmitframe->buf_addr, /* xmitbuf->pbuf */ - cnt, - usb_write_port_complete, - xmitbuf);/* context is xmitbuf */ - - status = usb_submit_urb(purb, GFP_ATOMIC); - if (status) { - rtw_sctx_done_err(&xmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); - if (status == -ENODEV) - padapter->bDriverStopped = true; - - goto exit; - } - - ret = _SUCCESS; - -exit: - if (ret != _SUCCESS) - rtw_free_xmitbuf(pxmitpriv, xmitbuf); - return ret; -} - -void usb_write_port_cancel(struct adapter *padapter) -{ - int i, j; - struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf; - - padapter->bWritePortCancel = true; - - for (i = 0; i < NR_XMITBUFF; i++) { - for (j = 0; j < 8; j++) { - if (pxmitbuf->pxmit_urb[j]) - usb_kill_urb(pxmitbuf->pxmit_urb[j]); - } - pxmitbuf++; - } - - pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf; - for (i = 0; i < NR_XMIT_EXTBUFF; i++) { - for (j = 0; j < 8; j++) { - if (pxmitbuf->pxmit_urb[j]) - usb_kill_urb(pxmitbuf->pxmit_urb[j]); - } - pxmitbuf++; - } -} - -void rtl8188eu_recv_tasklet(struct tasklet_struct *t) -{ - struct sk_buff *pskb; - struct adapter *adapt = from_tasklet(adapt, t, recvpriv.recv_tasklet); - struct recv_priv *precvpriv = &adapt->recvpriv; - - while (NULL != (pskb = skb_dequeue(&precvpriv->rx_skb_queue))) { - if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved)) { - dev_kfree_skb_any(pskb); - break; - } - recvbuf2recvframe(adapt, pskb); - skb_reset_tail_pointer(pskb); - pskb->len = 0; - skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); - } -} - -void rtl8188eu_xmit_tasklet(struct tasklet_struct *t) -{ - struct adapter *adapt = from_tasklet(adapt, t, xmitpriv.xmit_tasklet); - struct xmit_priv *pxmitpriv = &adapt->xmitpriv; - - if (check_fwstate(&adapt->mlmepriv, _FW_UNDER_SURVEY)) - return; - - while (1) { - if ((adapt->bDriverStopped) || (adapt->bSurpriseRemoved) || (adapt->bWritePortCancel)) - break; - - if (!rtl8188eu_xmitframe_complete(adapt, pxmitpriv)) - break; - } -} diff --git a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c b/drivers/staging/rtl8188eu/os_dep/xmit_linux.c deleted file mode 100644 index 1b5776ae8eba..000000000000 --- a/drivers/staging/rtl8188eu/os_dep/xmit_linux.c +++ /dev/null @@ -1,189 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#define _XMIT_OSDEP_C_ - -#include -#include - -#include -#include -#include -#include - -int rtw_os_xmit_resource_alloc(struct xmit_buf *pxmitbuf, u32 alloc_sz) -{ - int i; - - pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL); - if (!pxmitbuf->pallocated_buf) - return _FAIL; - - pxmitbuf->pbuf = PTR_ALIGN(pxmitbuf->pallocated_buf, XMITBUF_ALIGN_SZ); - - for (i = 0; i < 8; i++) { - pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL); - if (!pxmitbuf->pxmit_urb[i]) - return _FAIL; - } - return _SUCCESS; -} - -void rtw_os_xmit_resource_free(struct xmit_buf *pxmitbuf) -{ - int i; - - for (i = 0; i < 8; i++) - usb_free_urb(pxmitbuf->pxmit_urb[i]); - - kfree(pxmitbuf->pallocated_buf); -} - -#define WMM_XMIT_THRESHOLD (NR_XMITFRAME * 2 / 5) - -void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) -{ - u16 queue; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - - queue = skb_get_queue_mapping(pkt); - if (padapter->registrypriv.wifi_spec) { - if (__netif_subqueue_stopped(padapter->pnetdev, queue) && - (pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD)) - netif_wake_subqueue(padapter->pnetdev, queue); - } else { - if (__netif_subqueue_stopped(padapter->pnetdev, queue)) - netif_wake_subqueue(padapter->pnetdev, queue); - } - - dev_kfree_skb_any(pkt); -} - -void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe) -{ - if (pxframe->pkt) - rtw_os_pkt_complete(padapter, pxframe->pkt); - pxframe->pkt = NULL; -} - -void rtw_os_xmit_schedule(struct adapter *padapter) -{ - struct xmit_priv *pxmitpriv; - - if (!padapter) - return; - - pxmitpriv = &padapter->xmitpriv; - - spin_lock_bh(&pxmitpriv->lock); - - if (rtw_txframes_pending(padapter)) - tasklet_hi_schedule(&pxmitpriv->xmit_tasklet); - - spin_unlock_bh(&pxmitpriv->lock); -} - -static void rtw_check_xmit_resource(struct adapter *padapter, - struct sk_buff *pkt) -{ - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - u16 queue; - - queue = skb_get_queue_mapping(pkt); - if (padapter->registrypriv.wifi_spec) { - /* No free space for Tx, tx_worker is too slow */ - if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) - netif_stop_subqueue(padapter->pnetdev, queue); - } else { - if (pxmitpriv->free_xmitframe_cnt <= 4) { - if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue))) - netif_stop_subqueue(padapter->pnetdev, queue); - } - } -} - -static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb) -{ - struct sta_priv *pstapriv = &padapter->stapriv; - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct list_head *phead, *plist; - struct sk_buff *newskb; - struct sta_info *psta = NULL; - s32 res; - - spin_lock_bh(&pstapriv->asoc_list_lock); - phead = &pstapriv->asoc_list; - /* free sta asoc_queue */ - list_for_each(plist, phead) { - psta = list_entry(plist, struct sta_info, asoc_list); - - /* avoid come from STA1 and send back STA1 */ - if (!memcmp(psta->hwaddr, &skb->data[6], 6)) - continue; - - newskb = skb_copy(skb, GFP_ATOMIC); - - if (newskb) { - memcpy(newskb->data, psta->hwaddr, 6); - res = rtw_xmit(padapter, &newskb); - if (res < 0) { - pxmitpriv->tx_drop++; - dev_kfree_skb_any(newskb); - } else { - pxmitpriv->tx_pkts++; - } - } else { - pxmitpriv->tx_drop++; - - spin_unlock_bh(&pstapriv->asoc_list_lock); - - /* Caller shall tx this multicast frame - * via normal way. - */ - return false; - } - } - - spin_unlock_bh(&pstapriv->asoc_list_lock); - dev_kfree_skb_any(skb); - return true; -} - -int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) -{ - struct adapter *padapter = netdev_priv(pnetdev); - struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - s32 res = 0; - - if (!rtw_if_up(padapter)) - goto drop_packet; - - rtw_check_xmit_resource(padapter, pkt); - - if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) && - (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) && - (padapter->registrypriv.wifi_spec == 0)) { - if (pxmitpriv->free_xmitframe_cnt > NR_XMITFRAME / 4) { - res = rtw_mlcst2unicst(padapter, pkt); - if (res) - goto exit; - } - } - - res = rtw_xmit(padapter, &pkt); - if (res < 0) - goto drop_packet; - - pxmitpriv->tx_pkts++; - goto exit; - -drop_packet: - pxmitpriv->tx_drop++; - dev_kfree_skb_any(pkt); -exit: - return NETDEV_TX_OK; -} -- cgit v1.2.3 From c66cd19e2b0c47a042ba219e446e2efefdea82de Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 00:56:48 +0100 Subject: staging: r8188eu: remove RT_PRINT_DATA macro Remove RT_PRINT_DATA definition from include/rtw_debug.h, and its two calling statements in hal/hal_com.c, as this code was not written with best practices in mind and is safer to simply remove. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210731235648.67642-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/hal_com.c | 7 ------- drivers/staging/r8188eu/include/rtw_debug.h | 18 ------------------ 2 files changed, 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index 66a2f3d6d9e7..91d5182f9bb1 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -339,18 +339,11 @@ s32 c2h_evt_read(struct adapter *adapter, u8 *buf) *buf = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL); *(buf+1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); - RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, "c2h_evt_read(): ", - &c2h_evt, sizeof(c2h_evt)); - /* Read the content */ for (i = 0; i < c2h_evt->plen; i++) c2h_evt->payload[i] = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + sizeof(*c2h_evt) + i); - RT_PRINT_DATA(_module_hal_init_c_, _drv_info_, - "c2h_evt_read(): Command Content:\n", - c2h_evt->payload, c2h_evt->plen); - ret = _SUCCESS; clear_evt: diff --git a/drivers/staging/r8188eu/include/rtw_debug.h b/drivers/staging/r8188eu/include/rtw_debug.h index 56af0751f70e..83c71275c47b 100644 --- a/drivers/staging/r8188eu/include/rtw_debug.h +++ b/drivers/staging/r8188eu/include/rtw_debug.h @@ -81,24 +81,6 @@ extern u32 GlobalDebugLevel; } \ } while (0) -#define RT_PRINT_DATA(_comp, _level, _titlestring, _hexdata, _hexdatalen)\ - do { \ - if (_level <= GlobalDebugLevel) { \ - int __i; \ - u8 *ptr = (u8 *)_hexdata; \ - pr_info("%s", DRIVER_PREFIX); \ - pr_info(_titlestring); \ - for (__i = 0; __i < (int)_hexdatalen; __i++ ) { \ - pr_info("%02X%s", ptr[__i], \ - (((__i + 1) % 4) == 0) ? \ - " " : " "); \ - if (((__i + 1) % 16) == 0) \ - printk("\n"); \ - } \ - printk("\n"); \ - } \ - } while (0) - int proc_get_drv_version(char *page, char **start, off_t offset, int count, int *eof, void *data); -- cgit v1.2.3 From 11e14fc3e49481b6322bbd976bb7dd2f0d7ef3d2 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 2 Aug 2021 16:30:39 +0200 Subject: Revert "staging: r8188eu: remove rtw_buf_free() function" This reverts commit c7e88ecbe328e2bcd892d84c4b26eff86cb776ef as it's broken because somehow I forgot how pointers work... Reported-by: Larry Finger Cc: "Fabio M. De Francesco" Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 8 ++------ drivers/staging/r8188eu/core/rtw_mlme_ext.c | 11 +++-------- drivers/staging/r8188eu/include/osdep_service.h | 1 + drivers/staging/r8188eu/os_dep/osdep_service.c | 7 +++++++ 4 files changed, 13 insertions(+), 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index d692f1477cc8..a6d62074289f 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -102,12 +102,8 @@ static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) { - kfree(&pmlmepriv->assoc_req); - pmlmepriv->assoc_req = NULL; - pmlmepriv->assoc_req_len = 0; - kfree(&pmlmepriv->assoc_rsp); - pmlmepriv->assoc_rsp = NULL; - pmlmepriv->assoc_rsp_len = 0; + rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 1160b7caffdd..78f66664bf9c 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -1522,9 +1522,7 @@ report_assoc_result: if (res > 0) { rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); } else { - kfree(&pmlmepriv->assoc_rsp); - pmlmepriv->assoc_rsp = NULL; - pmlmepriv->assoc_rsp_len = 0; + rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); } report_join_res(padapter, res); @@ -5551,11 +5549,8 @@ void issue_assocreq(struct adapter *padapter) exit: if (ret == _SUCCESS) rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); - else { - kfree(&pmlmepriv->assoc_req); - pmlmepriv->assoc_req = NULL; - pmlmepriv->assoc_req_len = 0; - } + else + rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); return; } diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 05cbc9b0dadd..ac0bd5cd0f82 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -440,6 +440,7 @@ u64 rtw_division64(u64 x, u64 y); (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ (((u64) (a)[1]) << 8) | ((u64) (a)[0])) +void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); struct rtw_cbuf { diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 99ddc535e5ea..71d4fa25db86 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -388,6 +388,13 @@ u64 rtw_division64(u64 x, u64 y) return x; } +void rtw_buf_free(u8 **buf, u32 *buf_len) +{ + *buf_len = 0; + kfree(*buf); + *buf = NULL; +} + void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) { u32 ori_len = 0, dup_len = 0; -- cgit v1.2.3 From 725a3f1c4d56b73d2d4089c1dc78d29554f8daba Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 1 Aug 2021 10:46:13 +0200 Subject: staging: r8188eu: clean up comparsions to NULL in hal directory Clean up comparsions to NULL in the hal directory reported by checkpatch. x == NULL -> !x x != NULL -> x Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210801084614.4328-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 2 +- drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 4 ++-- drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c | 2 +- drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 2 +- drivers/staging/r8188eu/hal/hal_com.c | 2 +- drivers/staging/r8188eu/hal/hal_intf.c | 4 ++-- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 4 ++-- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 10 +++++----- drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 8 ++++---- drivers/staging/r8188eu/hal/usb_halinit.c | 4 ++-- drivers/staging/r8188eu/hal/usb_ops_linux.c | 12 ++++++------ 13 files changed, 29 insertions(+), 29 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index d41bfbe8ec9c..fcfcb0d104d2 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -486,7 +486,7 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) struct odm_ra_info *pRaInfo = &dm_odm->RAInfo[macid]; u8 WirelessMode = 0xFF; /* invalid value */ u8 max_rate_idx = 0x13; /* MCS7 */ - if (dm_odm->pWirelessMode != NULL) + if (dm_odm->pWirelessMode) WirelessMode = *(dm_odm->pWirelessMode); if (WirelessMode != 0xFF) { diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c index f90827577059..2fbac01dd969 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -195,7 +195,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) if (biol) { pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); - if (pxmit_frame == NULL) { + if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); return HAL_STATUS_FAILURE; } @@ -474,7 +474,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) if (biol) { pxmit_frame = rtw_IOL_accquire_xmit_frame(adapter); - if (pxmit_frame == NULL) { + if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); return HAL_STATUS_FAILURE; } diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c index 06ef2c04cebf..56b5d7c0bb9c 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c @@ -153,7 +153,7 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) if (biol) { pxmit_frame = rtw_IOL_accquire_xmit_frame(adapt); - if (pxmit_frame == NULL) { + if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); return HAL_STATUS_FAILURE; } diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c index 7659b0953100..fa51023cd48e 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -163,7 +163,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) if (biol) { pxmit_frame = rtw_IOL_accquire_xmit_frame(Adapter); - if (pxmit_frame == NULL) { + if (!pxmit_frame) { pr_info("rtw_IOL_accquire_xmit_frame failed\n"); return HAL_STATUS_FAILURE; } diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index 91d5182f9bb1..c3c76a37e52f 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -322,7 +322,7 @@ s32 c2h_evt_read(struct adapter *adapter, u8 *buf) int i; u8 trigger; - if (buf == NULL) + if (!buf) goto exit; trigger = rtw_read8(adapter, REG_C2HEVT_CLEAR); diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 1d813b6c3678..5c4e19b1e60f 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -224,14 +224,14 @@ s32 rtw_hal_mgnt_xmit(struct adapter *adapt, struct xmit_frame *pmgntframe) s32 rtw_hal_init_xmit_priv(struct adapter *adapt) { - if (adapt->HalFunc.init_xmit_priv != NULL) + if (adapt->HalFunc.init_xmit_priv) return adapt->HalFunc.init_xmit_priv(adapt); return _FAIL; } void rtw_hal_free_xmit_priv(struct adapter *adapt) { - if (adapt->HalFunc.free_xmit_priv != NULL) + if (adapt->HalFunc.free_xmit_priv) adapt->HalFunc.free_xmit_priv(adapt); } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 4bd471873531..a6bb4ecadc49 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -490,7 +490,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) DBG_88E("%s\n", __func__); ReservedPagePacket = (u8 *)rtw_zmalloc(1000); - if (ReservedPagePacket == NULL) { + if (!ReservedPagePacket) { DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__); return; } @@ -559,7 +559,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) TotalPacketLen = BufIndex + QosNullLength; pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 1a7a62dd8504..cf19ffb1bed5 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -77,13 +77,13 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) u8 u1temp = 0; efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); - if (efuseTbl == NULL) { + if (!efuseTbl) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); goto exit; } eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); - if (eFuseWord == NULL) { + if (!eFuseWord) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); goto exit; } @@ -811,13 +811,13 @@ static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, } efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); - if (efuseTbl == NULL) { + if (!efuseTbl) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); goto exit; } eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); - if (eFuseWord == NULL) { + if (!eFuseWord) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); goto exit; } @@ -1240,7 +1240,7 @@ static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 * EFUSE_GetEfuseDefinition(pAdapter, EFUSE_WIFI, TYPE_EFUSE_MAX_SECTION, (void *)&max_section, bPseudoTest); - if (data == NULL) + if (!data) return false; if (offset > max_section) return false; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c index 20f7f449b106..8a668e96b764 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -28,7 +28,7 @@ static void process_link_qual(struct adapter *padapter, struct recv_frame *prfra struct rx_pkt_attrib *pattrib; struct signal_stat *signal_stat; - if (prframe == NULL || padapter == NULL) + if (!prframe || !padapter) return; pattrib = &prframe->attrib; diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 2e3f624d0f22..d4dd0b7376ad 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -45,7 +45,7 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) _rtw_init_queue(&precvpriv->free_recv_buf_queue); precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); - if (precvpriv->pallocated_recv_buf == NULL) { + if (!precvpriv->pallocated_recv_buf) { res = _FAIL; RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); goto exit; diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index e44a01af7f5c..47890fb5fd8a 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -444,9 +444,9 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp RT_TRACE(_module_rtl8192c_xmit_c_, _drv_info_, ("+xmitframe_complete\n")); /* check xmitbuffer is ok */ - if (pxmitbuf == NULL) { + if (!pxmitbuf) { pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (pxmitbuf == NULL) + if (!pxmitbuf) return false; } @@ -455,7 +455,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp rtw_free_xmitframe(pxmitpriv, pxmitframe); pxmitframe = rtw_dequeue_xframe(pxmitpriv, pxmitpriv->hwxmits, pxmitpriv->hwxmit_entry); - if (pxmitframe == NULL) { + if (!pxmitframe) { /* no more xmit frame, release xmit buffer */ rtw_free_xmitbuf(pxmitpriv, pxmitbuf); return false; @@ -638,7 +638,7 @@ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) goto enqueue; pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (pxmitbuf == NULL) + if (!pxmitbuf) goto enqueue; spin_unlock_bh(&pxmitpriv->lock); diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index d985894c0f30..788ebb378879 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -2117,7 +2117,7 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l if (mac_id >= NUM_STA) /* CAM_SIZE */ return; psta = pmlmeinfo->FW_sta_info[mac_id].psta; - if (psta == NULL) + if (!psta) return; switch (mac_id) { case 0:/* for infra mode */ @@ -2253,7 +2253,7 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt) struct hal_ops *halfunc = &adapt->HalFunc; adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); - if (adapt->HalData == NULL) + if (!adapt->HalData) DBG_88E("cant not alloc memory for HAL DATA\n"); adapt->hal_data_sz = sizeof(struct hal_data_8188e); diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 577090db84be..a2df752e5aac 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -38,7 +38,7 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u /* Acquire IO memory for vendorreq */ pIo_buf = dvobjpriv->usb_vendor_req_buf; - if (pIo_buf == NULL) { + if (!pIo_buf) { DBG_88E("[%s] pIo_buf == NULL\n", __func__); status = -ENOMEM; goto release_mutex; @@ -318,7 +318,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) prxstat = (struct recv_stat *)pbuf; precvframe = rtw_alloc_recvframe(pfree_recv_queue); - if (precvframe == NULL) { + if (!precvframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); goto _exit_recvbuf2recvframe; @@ -587,18 +587,18 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) return _FAIL; } - if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); - if (NULL != precvbuf->pskb) + if (precvbuf->pskb) precvbuf->reuse = true; } rtl8188eu_init_recvbuf(adapter, precvbuf); /* re-assign for linux based on skb */ - if ((!precvbuf->reuse) || (precvbuf->pskb == NULL)) { + if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); - if (precvbuf->pskb == NULL) { + if (!precvbuf->pskb) { RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); return _FAIL; -- cgit v1.2.3 From 552838fdcaef2c37442b3072fccc2e9ccc631c57 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 1 Aug 2021 10:46:14 +0200 Subject: staging: r8188eu: clean up comparsions to NULL in core directory Clean up comparsions to NULL in the core directory reported by checkpatch. x == NULL -> !x x != NULL -> x Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210801084614.4328-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 22 ++-- drivers/staging/r8188eu/core/rtw_br_ext.c | 28 ++--- drivers/staging/r8188eu/core/rtw_cmd.c | 158 +++++++++++++-------------- drivers/staging/r8188eu/core/rtw_efuse.c | 4 +- drivers/staging/r8188eu/core/rtw_ieee80211.c | 10 +- drivers/staging/r8188eu/core/rtw_io.c | 2 +- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 10 +- drivers/staging/r8188eu/core/rtw_iol.c | 4 +- drivers/staging/r8188eu/core/rtw_mlme.c | 44 ++++---- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 134 +++++++++++------------ drivers/staging/r8188eu/core/rtw_mp.c | 12 +- drivers/staging/r8188eu/core/rtw_p2p.c | 16 +-- drivers/staging/r8188eu/core/rtw_recv.c | 44 ++++---- drivers/staging/r8188eu/core/rtw_security.c | 14 +-- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 8 +- drivers/staging/r8188eu/core/rtw_wlan_util.c | 10 +- drivers/staging/r8188eu/core/rtw_xmit.c | 40 +++---- 17 files changed, 280 insertions(+), 280 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 0bb545135206..d7b1a071928c 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -67,7 +67,7 @@ static void update_BCNTIM(struct adapter *padapter) tim_bitmap_le = cpu_to_le16(pstapriv->tim_bitmap); p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); - if (p != NULL && tim_ielen > 0) { + if (p && tim_ielen > 0) { tim_ielen += 2; premainder_ie = p+tim_ielen; tim_ie_offset = (int)(p - pie); @@ -83,7 +83,7 @@ static void update_BCNTIM(struct adapter *padapter) /* get supported rates len */ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); - if (p != NULL) + if (p) offset += tmp_len+2; /* DS Parameter Set IE, len = 3 */ @@ -164,7 +164,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 i += (pIE->Length + 2); } - if (p != NULL && ielen > 0) { + if (p && ielen > 0) { ielen += 2; premainder_ie = p+ielen; @@ -211,7 +211,7 @@ void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, pnetwork->IELength - _FIXED_IE_LENGTH_); - if (p != NULL && ielen > 0) { + if (p && ielen > 0) { ielen += 2; premainder_ie = p+ielen; @@ -909,14 +909,14 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) memset(supportRate, 0, NDIS_802_11_LENGTH_RATES_EX); /* get supported rates */ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); - if (p != NULL) { + if (p) { memcpy(supportRate, p+2, ie_len); supportRateNum = ie_len; } /* get ext_supported rates */ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); - if (p != NULL) { + if (p) { memcpy(supportRate+supportRateNum, p+2, ie_len); supportRateNum += ie_len; } @@ -978,7 +978,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) } break; } - if ((p == NULL) || (ie_len == 0)) + if (!p || ie_len == 0) break; } @@ -1002,7 +1002,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) break; } - if ((p == NULL) || (ie_len == 0)) + if (!p || ie_len == 0) break; } } @@ -1089,7 +1089,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) psta = rtw_get_stainfo(&padapter->stapriv, pbss_network->MacAddress); if (!psta) { psta = rtw_alloc_stainfo(&padapter->stapriv, pbss_network->MacAddress); - if (psta == NULL) + if (!psta) return _FAIL; } @@ -1292,7 +1292,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); - if (pwps_ie == NULL || wps_ielen == 0) + if (!pwps_ie || wps_ielen == 0) return; wps_offset = (uint)(pwps_ie-ie); @@ -1308,7 +1308,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) } pwps_ie_src = pmlmepriv->wps_beacon_ie; - if (pwps_ie_src == NULL) + if (!pwps_ie_src) return; wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 8f434768dd15..89fce9a5f783 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -336,7 +336,7 @@ static inline void __network_hash_link(struct adapter *priv, { /* Caller must spin_lock already! */ ent->next_hash = priv->nethash[hash]; - if (ent->next_hash != NULL) + if (ent->next_hash) ent->next_hash->pprev_hash = &ent->next_hash; priv->nethash[hash] = ent; ent->pprev_hash = &priv->nethash[hash]; @@ -346,7 +346,7 @@ static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) { /* Caller must spin_lock already! */ *(ent->pprev_hash) = ent->next_hash; - if (ent->next_hash != NULL) + if (ent->next_hash) ent->next_hash->pprev_hash = ent->pprev_hash; ent->next_hash = NULL; ent->pprev_hash = NULL; @@ -360,7 +360,7 @@ static int __nat25_db_network_lookup_and_replace(struct adapter *priv, spin_lock_bh(&priv->br_ext_lock); db = priv->nethash[__nat25_network_hash(networkAddr)]; - while (db != NULL) { + while (db) { if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { if (!__nat25_has_expired(priv, db)) { /* replace the destination mac address */ @@ -411,7 +411,7 @@ static void __nat25_db_network_insert(struct adapter *priv, spin_lock_bh(&priv->br_ext_lock); hash = __nat25_network_hash(networkAddr); db = priv->nethash[hash]; - while (db != NULL) { + while (db) { if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { memcpy(db->macAddr, macAddr, ETH_ALEN); db->ageing_timer = jiffies; @@ -421,7 +421,7 @@ static void __nat25_db_network_insert(struct adapter *priv, db = db->next_hash; } db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); - if (db == NULL) { + if (!db) { spin_unlock_bh(&priv->br_ext_lock); return; } @@ -452,7 +452,7 @@ void nat25_db_cleanup(struct adapter *priv) for (i = 0; i < NAT25_HASH_SIZE; i++) { struct nat25_network_db_entry *f; f = priv->nethash[i]; - while (f != NULL) { + while (f) { struct nat25_network_db_entry *g; g = f->next_hash; @@ -479,7 +479,7 @@ void nat25_db_expire(struct adapter *priv) struct nat25_network_db_entry *f; f = priv->nethash[i]; - while (f != NULL) { + while (f) { struct nat25_network_db_entry *g; g = f->next_hash; @@ -506,7 +506,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) unsigned char networkAddr[MAX_NETWORK_ADDR_LEN]; unsigned int tmp; - if (skb == NULL) + if (!skb) return -1; if ((method <= NAT25_MIN) || (method >= NAT25_MAX)) @@ -675,7 +675,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) } /* IPX */ - if (ipx != NULL) { + if (ipx) { switch (method) { case NAT25_CHECK: if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) @@ -732,7 +732,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) default: return -1; } - } else if (ea != NULL) { + } else if (ea) { /* Sanity check fields. */ if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); @@ -775,7 +775,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) default: return -1; } - } else if (ddp != NULL) { + } else if (ddp) { switch (method) { case NAT25_CHECK: return -1; @@ -900,7 +900,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) int offset = 0; ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); - if (ptr == NULL) { + if (!ptr) { DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n"); return -1; } @@ -1132,7 +1132,7 @@ struct dhcpMessage { void dhcp_flag_bcast(struct adapter *priv, struct sk_buff *skb) { - if (skb == NULL) + if (!skb) return; if (!priv->ethBrExtInfo.dhcp_bcst_disable) { @@ -1182,7 +1182,7 @@ void *scdb_findEntry(struct adapter *priv, unsigned char *macAddr, __nat25_generate_ipv4_network_addr(networkAddr, (unsigned int *)ipAddr); hash = __nat25_network_hash(networkAddr); db = priv->nethash[hash]; - while (db != NULL) { + while (db) { if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { return (void *)db; } diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 4e17972ee66e..c432cc6e1b4d 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -33,7 +33,7 @@ int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) pcmdpriv->cmd_allocated_buf = kzalloc(MAX_CMDSZ + CMDBUFF_ALIGN_SZ, GFP_KERNEL); - if (pcmdpriv->cmd_allocated_buf == NULL) { + if (!pcmdpriv->cmd_allocated_buf) { res = _FAIL; goto exit; } @@ -42,7 +42,7 @@ int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL); - if (pcmdpriv->rsp_allocated_buf == NULL) { + if (!pcmdpriv->rsp_allocated_buf) { res = _FAIL; goto exit; } @@ -85,7 +85,7 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); - if (c2h != NULL && c2h != (void *)pevtpriv) + if (c2h && c2h != (void *)pevtpriv) kfree(c2h); } RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-rtw_free_evt_priv\n")); @@ -121,7 +121,7 @@ int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) { unsigned long flags; - if (obj == NULL) + if (!obj) goto exit; spin_lock_irqsave(&queue->lock, flags); @@ -207,7 +207,7 @@ u32 rtw_enqueue_cmd(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) int res = _FAIL; struct adapter *padapter = pcmdpriv->padapter; - if (cmd_obj == NULL) + if (!cmd_obj) goto exit; cmd_obj->padapter = padapter; @@ -253,7 +253,7 @@ void rtw_free_cmd_obj(struct cmd_obj *pcmd) kfree(pcmd->parmbuf); } - if (pcmd->rsp != NULL) { + if (pcmd->rsp) { if (pcmd->rspsz != 0) { /* free rsp in cmd_obj */ kfree(pcmd->rsp); @@ -337,7 +337,7 @@ post_process: /* call callback function for post-processed */ if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; - if (pcmd_callback == NULL) { + if (!pcmd_callback) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); rtw_free_cmd_obj(pcmd); } else { @@ -358,7 +358,7 @@ post_process: /* free all cmd_obj resources */ do { pcmd = rtw_dequeue_cmd(pcmdpriv); - if (pcmd == NULL) + if (!pcmd) break; /* DBG_88E("%s: leaving... drop cmdcode:%u\n", __func__, pcmd->cmdcode); */ @@ -380,13 +380,13 @@ u8 rtw_setstandby_cmd(struct adapter *padapter, uint action) u8 ret = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { ret = _FAIL; goto exit; } psetusbsuspend = kzalloc(sizeof(struct usb_suspend_parm), GFP_ATOMIC); - if (psetusbsuspend == NULL) { + if (!psetusbsuspend) { kfree(ph2c); ret = _FAIL; goto exit; @@ -426,11 +426,11 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, } ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) + if (!ph2c) return _FAIL; psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); - if (psurveyPara == NULL) { + if (!psurveyPara) { kfree(ph2c); return _FAIL; } @@ -499,13 +499,13 @@ u8 rtw_setdatarate_cmd(struct adapter *padapter, u8 *rateset) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pbsetdataratepara = kzalloc(sizeof(struct setdatarate_parm), GFP_ATOMIC); - if (pbsetdataratepara == NULL) { + if (!pbsetdataratepara) { kfree(ph2c); res = _FAIL; goto exit; @@ -528,13 +528,13 @@ u8 rtw_setbasicrate_cmd(struct adapter *padapter, u8 *rateset) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pssetbasicratepara = kzalloc(sizeof(struct setbasicrate_parm), GFP_ATOMIC); - if (pssetbasicratepara == NULL) { + if (!pssetbasicratepara) { kfree(ph2c); res = _FAIL; goto exit; @@ -565,13 +565,13 @@ u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } psetphypara = kzalloc(sizeof(struct setphy_parm), GFP_ATOMIC); - if (psetphypara == NULL) { + if (!psetphypara) { kfree(ph2c); res = _FAIL; goto exit; @@ -598,13 +598,13 @@ u8 rtw_setbbreg_cmd(struct adapter *padapter, u8 offset, u8 val) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pwritebbparm = kzalloc(sizeof(struct writeBB_parm), GFP_ATOMIC); - if (pwritebbparm == NULL) { + if (!pwritebbparm) { kfree(ph2c); res = _FAIL; goto exit; @@ -629,13 +629,13 @@ u8 rtw_getbbreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } prdbbparm = kzalloc(sizeof(struct readBB_parm), GFP_ATOMIC); - if (prdbbparm == NULL) { + if (!prdbbparm) { kfree(ph2c); return _FAIL; } @@ -663,13 +663,13 @@ u8 rtw_setrfreg_cmd(struct adapter *padapter, u8 offset, u32 val) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pwriterfparm = kzalloc(sizeof(struct writeRF_parm), GFP_ATOMIC); - if (pwriterfparm == NULL) { + if (!pwriterfparm) { kfree(ph2c); res = _FAIL; goto exit; @@ -694,13 +694,13 @@ u8 rtw_getrfreg_cmd(struct adapter *padapter, u8 offset, u8 *pval) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } prdrfparm = kzalloc(sizeof(struct readRF_parm), GFP_ATOMIC); - if (prdrfparm == NULL) { + if (!prdrfparm) { kfree(ph2c); res = _FAIL; goto exit; @@ -762,7 +762,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter) RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; goto exit; } @@ -787,7 +787,7 @@ u8 rtw_createbss_cmd_ex(struct adapter *padapter, unsigned char *pbss, unsigned u8 res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; goto exit; } @@ -831,7 +831,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) } pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); goto exit; @@ -856,8 +856,8 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) } psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; - if (psecnetwork == NULL) { - if (pcmd != NULL) + if (!psecnetwork) { + if (pcmd) kfree(pcmd); res = _FAIL; @@ -954,7 +954,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu /* prepare cmd parameter */ param = kzalloc(sizeof(*param), GFP_ATOMIC); - if (param == NULL) { + if (!param) { res = _FAIL; goto exit; } @@ -963,7 +963,7 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ cmdobj = kzalloc(sizeof(*cmdobj), GFP_ATOMIC); - if (cmdobj == NULL) { + if (!cmdobj) { res = _FAIL; kfree(param); goto exit; @@ -991,13 +991,13 @@ u8 rtw_setopmode_cmd(struct adapter *padapter, enum ndis_802_11_network_infra n u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { + if (!ph2c) { res = false; goto exit; } psetop = kzalloc(sizeof(struct setopmode_parm), GFP_KERNEL); - if (psetop == NULL) { + if (!psetop) { kfree(ph2c); res = false; goto exit; @@ -1026,20 +1026,20 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); - if (psetstakey_para == NULL) { + if (!psetstakey_para) { kfree(ph2c); res = _FAIL; goto exit; } psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_KERNEL); - if (psetstakey_rsp == NULL) { + if (!psetstakey_rsp) { kfree(ph2c); kfree(psetstakey_para); res = _FAIL; @@ -1085,14 +1085,14 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) clear_cam_entry(padapter, entry); } else { ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_ATOMIC); - if (psetstakey_para == NULL) { + if (!psetstakey_para) { kfree(ph2c); res = _FAIL; goto exit; @@ -1100,7 +1100,7 @@ u8 rtw_clearstakey_cmd(struct adapter *padapter, u8 *psta, u8 entry, u8 enqueue) psetstakey_rsp = kzalloc(sizeof(struct set_stakey_rsp), GFP_ATOMIC); - if (psetstakey_rsp == NULL) { + if (!psetstakey_rsp) { kfree(ph2c); kfree(psetstakey_para); res = _FAIL; @@ -1132,13 +1132,13 @@ u8 rtw_setrttbl_cmd(struct adapter *padapter, struct setratable_parm *prate_tab u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } psetrttblparm = kzalloc(sizeof(struct setratable_parm), GFP_KERNEL); - if (psetrttblparm == NULL) { + if (!psetrttblparm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1162,13 +1162,13 @@ u8 rtw_getrttbl_cmd(struct adapter *padapter, struct getratable_rsp *pval) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pgetrttblparm = kzalloc(sizeof(struct getratable_parm), GFP_KERNEL); - if (pgetrttblparm == NULL) { + if (!pgetrttblparm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1201,20 +1201,20 @@ u8 rtw_setassocsta_cmd(struct adapter *padapter, u8 *mac_addr) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } psetassocsta_para = kzalloc(sizeof(struct set_assocsta_parm), GFP_ATOMIC); - if (psetassocsta_para == NULL) { + if (!psetassocsta_para) { kfree(ph2c); res = _FAIL; goto exit; } psetassocsta_rsp = kzalloc(sizeof(struct set_assocsta_rsp), GFP_ATOMIC); - if (psetassocsta_rsp == NULL) { + if (!psetassocsta_rsp) { kfree(ph2c); kfree(psetassocsta_para); return _FAIL; @@ -1241,13 +1241,13 @@ u8 rtw_addbareq_cmd(struct adapter *padapter, u8 tid, u8 *addr) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } paddbareq_parm = kzalloc(sizeof(struct addBaReq_parm), GFP_ATOMIC); - if (paddbareq_parm == NULL) { + if (!paddbareq_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1276,13 +1276,13 @@ u8 rtw_dynamic_chk_wk_cmd(struct adapter *padapter) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1316,7 +1316,7 @@ u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enque /* prepare cmd parameter */ set_ch_parm = kzalloc(sizeof(*set_ch_parm), GFP_ATOMIC); - if (set_ch_parm == NULL) { + if (!set_ch_parm) { res = _FAIL; goto exit; } @@ -1327,7 +1327,7 @@ u8 rtw_set_ch_cmd(struct adapter *padapter, u8 ch, u8 bw, u8 ch_offset, u8 enque if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (pcmdobj == NULL) { + if (!pcmdobj) { kfree(set_ch_parm); res = _FAIL; goto exit; @@ -1371,7 +1371,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) /* prepare cmd parameter */ setChannelPlan_param = kzalloc(sizeof(struct SetChannelPlan_param), GFP_KERNEL); - if (setChannelPlan_param == NULL) { + if (!setChannelPlan_param) { res = _FAIL; goto exit; } @@ -1380,7 +1380,7 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) if (enqueue) { /* need enqueue, prepare cmd_obj and enqueue */ pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (pcmdobj == NULL) { + if (!pcmdobj) { kfree(setChannelPlan_param); res = _FAIL; goto exit; @@ -1416,13 +1416,13 @@ u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (pcmdobj == NULL) { + if (!pcmdobj) { res = _FAIL; goto exit; } ledBlink_param = kzalloc(sizeof(struct LedBlink_param), GFP_ATOMIC); - if (ledBlink_param == NULL) { + if (!ledBlink_param) { kfree(pcmdobj); res = _FAIL; goto exit; @@ -1449,14 +1449,14 @@ u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_csa_cmd\n")); pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (pcmdobj == NULL) { + if (!pcmdobj) { res = _FAIL; goto exit; } setChannelSwitch_param = kzalloc(sizeof(struct SetChannelSwitch_param), GFP_ATOMIC); - if (setChannelSwitch_param == NULL) { + if (!setChannelSwitch_param) { kfree(pcmdobj); res = _FAIL; goto exit; @@ -1614,14 +1614,14 @@ u8 rtw_lps_ctrl_wk_cmd(struct adapter *padapter, u8 lps_ctrl_type, u8 enqueue) if (enqueue) { ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1657,14 +1657,14 @@ u8 rtw_rpt_timer_cfg_cmd(struct adapter *padapter, u16 min_time) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1699,14 +1699,14 @@ u8 rtw_antenna_select_cmd(struct adapter *padapter, u8 antenna, u8 enqueue) if (enqueue) { ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1744,13 +1744,13 @@ u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType) return res; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1779,13 +1779,13 @@ u8 rtw_ps_cmd(struct adapter *padapter) u8 res = _SUCCESS; ppscmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ppscmd == NULL) { + if (!ppscmd) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ppscmd); res = _FAIL; goto exit; @@ -1852,13 +1852,13 @@ u8 rtw_chk_hi_queue_cmd(struct adapter *padapter) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -1884,13 +1884,13 @@ u8 rtw_c2h_wk_cmd(struct adapter *padapter, u8 *c2h_evt) u8 res = _SUCCESS; ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; @@ -2103,7 +2103,7 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); if (!psta) { psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); goto createbss_cmd_fail ; } @@ -2114,9 +2114,9 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) pwlan = _rtw_alloc_network(pmlmepriv); spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); - if (pwlan == NULL) { + if (!pwlan) { pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); - if (pwlan == NULL) { + if (!pwlan) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n")); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); goto createbss_cmd_fail; @@ -2151,7 +2151,7 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); goto exit; } @@ -2168,7 +2168,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj * struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); goto exit; } diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index e84540a7d2c5..9e9085aab952 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -534,7 +534,7 @@ u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) return _FAIL; map = rtw_zmalloc(mapLen); - if (map == NULL) + if (!map) return _FAIL; ret = rtw_efuse_map_read(padapter, 0, mapLen, map); @@ -626,7 +626,7 @@ u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data return _FAIL; map = rtw_zmalloc(mapLen); - if (map == NULL) + if (!map) return _FAIL; ret = rtw_BT_efuse_map_read(padapter, 0, mapLen, map); diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index f5ea93e2fff9..2c626dda3e5d 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -705,7 +705,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) u8 match = false; u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if (ie_ptr == NULL) + if (!ie_ptr) return match; eid = ie_ptr[0]; @@ -1075,7 +1075,7 @@ u8 key_2char2num(u8 hch, u8 lch) void rtw_macaddr_cfg(u8 *mac_addr) { u8 mac[ETH_ALEN]; - if (mac_addr == NULL) + if (!mac_addr) return; if (rtw_initmac) { /* Users specify the mac address */ @@ -1183,7 +1183,7 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) u8 *p2p_ie_ptr; u8 eid, p2p_oui[4] = {0x50, 0x6F, 0x9A, 0x09}; - if (p2p_ielen != NULL) + if (p2p_ielen) *p2p_ielen = 0; while (cnt < in_len) { @@ -1195,9 +1195,9 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) if ((eid == _VENDOR_SPECIFIC_IE_) && !memcmp(&in_ie[cnt+2], p2p_oui, 4)) { p2p_ie_ptr = in_ie + cnt; - if (p2p_ie != NULL) + if (p2p_ie) memcpy(p2p_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - if (p2p_ielen != NULL) + if (p2p_ielen) *p2p_ielen = in_ie[cnt + 1] + 2; return p2p_ie_ptr; } else { diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index 2c8e7707c9fa..85d1f7deda23 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -294,7 +294,7 @@ int rtw_init_io_priv(struct adapter *padapter, void (*set_intf_ops)(struct _io_o struct io_priv *piopriv = &padapter->iopriv; struct intf_hdl *pintf = &piopriv->intf; - if (set_intf_ops == NULL) + if (!set_intf_ops) return _FAIL; piopriv->padapter = padapter; diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 778da7c86995..3e2add5409cc 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -435,7 +435,7 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); - if (padapter == NULL) { + if (!padapter) { res = false; goto exit; } @@ -568,7 +568,7 @@ u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) { u8 ret = _SUCCESS; - if (keyindex >= 0x80000000 || padapter == NULL) { + if (keyindex >= 0x80000000 || !padapter) { ret = false; goto exit; } else { @@ -622,7 +622,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) pbssid = get_bssid(&padapter->mlmepriv); stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - if ((stainfo != NULL) && (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X)) { + if (stainfo && padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY:(stainfo!=NULL)&&(Adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)\n")); encryptionalgo = stainfo->dot118021XPrivacy; @@ -641,7 +641,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11AuthAlgrthm==%d)!\n", padapter->securitypriv.dot11AuthAlgrthm)); - if ((stainfo != NULL)) + if (stainfo) RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_add_key: (stainfo->dot118021XPrivacy==%d)!\n", stainfo->dot118021XPrivacy)); @@ -898,7 +898,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) pbssid = get_bssid(&padapter->mlmepriv); stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - if (stainfo != NULL) { + if (stainfo) { memset(&stainfo->dot118021x_UncstKey, 0, 16);/* clear keybuffer */ memcpy(&stainfo->dot118021x_UncstKey, key->KeyMaterial, 16); diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index 0382ff524657..0e5ce12d4b57 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -11,13 +11,13 @@ struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) struct xmit_priv *pxmitpriv = &(adapter->xmitpriv); xmit_frame = rtw_alloc_xmitframe(pxmitpriv); - if (xmit_frame == NULL) { + if (!xmit_frame) { DBG_88E("%s rtw_alloc_xmitframe return null\n", __func__); goto exit; } xmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (xmitbuf == NULL) { + if (!xmitbuf) { DBG_88E("%s rtw_alloc_xmitbuf return null\n", __func__); rtw_free_xmitframe(pxmitpriv, xmit_frame); xmit_frame = NULL; diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index a6d62074289f..298849214b97 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -58,7 +58,7 @@ int _rtw_init_mlme_priv (struct adapter *padapter) pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); - if (pbuf == NULL) { + if (!pbuf) { res = _FAIL; goto exit; } @@ -139,7 +139,7 @@ void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) int _rtw_enqueue_network(struct __queue *queue, struct wlan_network *pnetwork) { - if (pnetwork == NULL) + if (!pnetwork) goto exit; spin_lock_bh(&queue->lock); @@ -211,7 +211,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor u32 lifetime = SCANQUEUE_LIFETIME; struct __queue *free_queue = &(pmlmepriv->free_bss_pool); - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed) @@ -236,7 +236,7 @@ void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network * { struct __queue *free_queue = &(pmlmepriv->free_bss_pool); - if (pnetwork == NULL) + if (!pnetwork) return; if (pnetwork->fixed) return; @@ -466,7 +466,7 @@ struct wlan_network *rtw_get_oldest_wlan_network(struct __queue *scanned_queue) pwlan = container_of(plist, struct wlan_network, list); if (!pwlan->fixed) { - if (oldest == NULL || time_after(oldest->last_scanned, pwlan->last_scanned)) + if (!oldest || time_after(oldest->last_scanned, pwlan->last_scanned)) oldest = pwlan; } @@ -584,7 +584,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ - if (pnetwork == NULL) { + if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); goto exit; } @@ -659,7 +659,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen) != NULL) + if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -1035,7 +1035,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str struct sta_priv *pstapriv = &padapter->stapriv; psta = rtw_get_stainfo(pstapriv, pnetwork->network.MacAddress); - if (psta == NULL) + if (!psta) psta = rtw_alloc_stainfo(pstapriv, pnetwork->network.MacAddress); if (psta) { /* update ptarget_sta */ @@ -1227,7 +1227,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); - if (ptarget_sta == NULL) { + if (!ptarget_sta) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; @@ -1297,7 +1297,7 @@ static u8 search_max_mac_id(struct adapter *padapter) #if defined (CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1] != NULL) + if (pstapriv->sta_aid[aid-1]) break; } mac_id = aid + 1; @@ -1319,7 +1319,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, u16 media_status_rpt; u8 macid; - if (psta == NULL) + if (!psta) return; macid = search_max_mac_id(adapter); @@ -1351,13 +1351,13 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) #endif /* for AD-HOC mode */ psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta != NULL) { + if (psta) { /* the sta have been in sta_info_queue => do nothing */ RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ } psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); return; } @@ -1653,7 +1653,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (*candidate == NULL || (*candidate)->network.Rssi < competitor->network.Rssi) { + if (!*candidate || (*candidate)->network.Rssi < competitor->network.Rssi) { *candidate = competitor; updated = true; } @@ -1694,7 +1694,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) pmlmepriv->pscanned = phead->next; while (phead != pmlmepriv->pscanned) { pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); - if (pnetwork == NULL) { + if (!pnetwork) { RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork==NULL)\n", __func__)); ret = _FAIL; goto exit; @@ -1702,7 +1702,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) pmlmepriv->pscanned = pmlmepriv->pscanned->next; rtw_check_join_candidate(pmlmepriv, &candidate, pnetwork); } - if (candidate == NULL) { + if (!candidate) { DBG_88E("%s: return _FAIL(candidate==NULL)\n", __func__); ret = _FAIL; goto exit; @@ -1747,13 +1747,13 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) int res = _SUCCESS; pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; /* try again */ goto exit; } psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); - if (psetauthparm == NULL) { + if (!psetauthparm) { kfree(pcmd); res = _FAIL; goto exit; @@ -1785,12 +1785,12 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in int res = _SUCCESS; pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd == NULL) { + if (!pcmd) { res = _FAIL; /* try again */ goto exit; } psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); - if (psetkeyparm == NULL) { + if (!psetkeyparm) { kfree(pcmd); res = _FAIL; goto exit; @@ -2272,7 +2272,7 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr else psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - if (psta == NULL) + if (!psta) return; phtpriv = &psta->htpriv; @@ -2304,7 +2304,7 @@ void _rtw_roaming(struct adapter *padapter, struct wlan_network *tgt_network) struct wlan_network *pnetwork; - if (tgt_network != NULL) + if (tgt_network) pnetwork = tgt_network; else pnetwork = &pmlmepriv->cur_network; diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 78f66664bf9c..c42bdbd09464 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -289,7 +289,7 @@ static void init_channel_list(struct adapter *padapter, struct rt_channel_info * ((BW40MINUS == o->bw) || (BW40PLUS == o->bw))) continue; - if (reg == NULL) { + if (!reg) { reg = &channel_list->reg_class[cla]; cla++; reg->reg_class = o->op_class; @@ -442,7 +442,7 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) } ptable += index; - if (psta != NULL) { + if (psta) { if (GetRetry(pframe)) { if (precv_frame->attrib.seq_num == psta->RxMgmtFrameSeqNum) { /* drop the duplicate management frame */ @@ -570,7 +570,7 @@ _continue: len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_); /* check (wildcard) SSID */ - if (p != NULL) { + if (p) { if (is_valid_p2p_probereq) goto _issue_probersp; @@ -685,7 +685,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta != NULL) { + if (psta) { ret = rtw_check_bcn_info(padapter, pframe, len); if (!ret) { DBG_88E_LEVEL(_drv_info_, "ap has changed, disconnect now\n "); @@ -700,7 +700,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) } } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if (psta != NULL) { + if (psta) { /* update WMM, ERP in the beacon */ /* todo: the timer is used instead of the number of the beacon received */ if ((sta_rx_pkts(psta) & 0xf) == 0) @@ -781,11 +781,11 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) } pstat = rtw_get_stainfo(pstapriv, sa); - if (pstat == NULL) { + if (!pstat) { /* allocate a new one */ DBG_88E("going to alloc stainfo for sa=%pM\n", sa); pstat = rtw_alloc_stainfo(pstapriv, sa); - if (pstat == NULL) { + if (!pstat) { DBG_88E(" Exceed the upper limit of supported clients...\n"); status = _STATS_UNABLE_HANDLE_STA_; goto auth_fail; @@ -850,7 +850,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + 4 + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&ie_len, len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_ - 4); - if ((p == NULL) || (ie_len <= 0)) { + if (!p || ie_len <= 0) { DBG_88E("auth rejected because challenge failure!(1)\n"); status = _STATS_CHALLENGE_FAIL_; goto auth_fail; @@ -947,7 +947,7 @@ unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fra p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _AUTH_IE_OFFSET_, _CHLGETXT_IE_, (int *)&len, pkt_len - WLAN_HDR_A3_LEN - _AUTH_IE_OFFSET_); - if (p == NULL) + if (!p) goto authclnt_fail; memcpy((void *)(pmlmeinfo->chg_txt), (void *)(p + 2), len); @@ -1065,7 +1065,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* checking SSID */ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SSID_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p == NULL) + if (!p) status = _STATS_FAILURE_; if (ie_len == 0) { /* broadcast ssid, however it is not allowed in assocreq */ @@ -1084,7 +1084,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* check if the supported rate is ok */ p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p == NULL) { + if (!p) { DBG_88E("Rx a sta assoc-req which supported rate is empty!\n"); /* use our own rate set as statoin used */ /* memcpy(supportRate, AP_BSSRATE, AP_BSSRATE_LEN); */ @@ -1098,7 +1098,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p != NULL) { + if (p) { if (supportRateNum <= sizeof(supportRate)) { memcpy(supportRate+supportRateNum, p+2, ie_len); supportRateNum += ie_len; @@ -1173,7 +1173,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame goto OnAssocReqFail; pstat->flags &= ~(WLAN_STA_WPS | WLAN_STA_MAYBE_WPS); - if (wpa_ie == NULL) { + if (!wpa_ie) { if (elems.wps_ie) { DBG_88E("STA included WPS IE in " "(Re)Association Request - assume WPS is " @@ -1243,7 +1243,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame p = pframe + WLAN_HDR_A3_LEN + ie_offset; ie_len = 0; for (;;) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); - if (p != NULL) { + if (p) { if (!memcmp(p+2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; @@ -1357,7 +1357,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame DBG_88E(" old AID %d\n", pstat->aid); } else { for (pstat->aid = 1; pstat->aid <= NUM_STA; pstat->aid++) - if (pstapriv->sta_aid[pstat->aid - 1] == NULL) + if (!pstapriv->sta_aid[pstat->aid - 1]) break; /* if (pstat->aid > NUM_STA) { */ @@ -1751,7 +1751,7 @@ unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_fr addr = GetAddr2Ptr(pframe); psta = rtw_get_stainfo(pstapriv, addr); - if (psta == NULL) + if (!psta) return _SUCCESS; frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); @@ -1837,7 +1837,7 @@ void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) struct wifidirect_info *pwdinfo = &(padapter->wdinfo); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; DBG_88E("[%s] In\n", __func__); @@ -2175,7 +2175,7 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame struct wifidirect_info *pwdinfo = &(padapter->wdinfo); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; DBG_88E("[%s] In, result=%d\n", __func__, result); @@ -2534,7 +2534,7 @@ static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) struct wifidirect_info *pwdinfo = &(padapter->wdinfo); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; DBG_88E("[%s] In\n", __func__); @@ -2698,7 +2698,7 @@ void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) struct wifidirect_info *pwdinfo = &(padapter->wdinfo); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -2946,7 +2946,7 @@ void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialo struct wifidirect_info *pwdinfo = &(padapter->wdinfo); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -3139,7 +3139,7 @@ void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidle struct wifidirect_info *pwdinfo = &(padapter->wdinfo); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; DBG_88E("[%s] In\n", __func__); @@ -3252,7 +3252,7 @@ void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) u32 wpsielen = 0, p2pielen = 0; pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -3500,7 +3500,7 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -3569,7 +3569,7 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) /* Value: */ wpsie[wpsielen++] = WPS_VERSION_1; /* Version 1.0 */ - if (pmlmepriv->wps_probe_req_ie == NULL) { + if (!pmlmepriv->wps_probe_req_ie) { /* UUID-E */ /* Type: */ *(__be16 *)(wpsie + wpsielen) = cpu_to_be16(WPS_ATTR_UUID_E); @@ -3747,7 +3747,7 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); - if (pmlmepriv->wps_probe_req_ie != NULL) { + if (pmlmepriv->wps_probe_req_ie) { /* WPS IE */ memcpy(pframe, pmlmepriv->wps_probe_req_ie, pmlmepriv->wps_probe_req_ie_len); pattrib->pktlen += pmlmepriv->wps_probe_req_ie_len; @@ -4280,13 +4280,13 @@ struct xmit_frame *alloc_mgtxmitframe(struct xmit_priv *pxmitpriv) struct xmit_buf *pxmitbuf; pmgntframe = rtw_alloc_xmitframe(pxmitpriv); - if (pmgntframe == NULL) { + if (!pmgntframe) { DBG_88E("%s, alloc xmitframe fail\n", __func__); return NULL; } pxmitbuf = rtw_alloc_xmitbuf_ext(pxmitpriv); - if (pxmitbuf == NULL) { + if (!pxmitbuf) { DBG_88E("%s, alloc xmitbuf fail\n", __func__); rtw_free_xmitframe(pxmitpriv, pmgntframe); return NULL; @@ -4448,7 +4448,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) #endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) { + if (!pmgntframe) { DBG_88E("%s, alloc mgnt frame fail\n", __func__); return; } @@ -4677,7 +4677,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p #endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) { + if (!pmgntframe) { DBG_88E("%s, alloc mgnt frame fail\n", __func__); return; } @@ -4716,7 +4716,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); /* inerset & update wps_probe_resp_ie */ - if ((pmlmepriv->wps_probe_resp_ie != NULL) && pwps_ie && (wps_ielen > 0)) { + if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) { uint wps_offset, remainder_ielen; u8 *premainder_ie; @@ -4834,7 +4834,7 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -4970,7 +4970,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -5109,7 +5109,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i DBG_88E("%s\n", __func__); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -5191,7 +5191,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i break; } - if ((pbuf == NULL) || (ie_len == 0)) + if (!pbuf || ie_len == 0) break; } } @@ -5247,7 +5247,7 @@ void issue_assocreq(struct adapter *padapter) #endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -5341,13 +5341,13 @@ void issue_assocreq(struct adapter *padapter) /* RSN */ p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); - if (p != NULL) + if (p) pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, (p + 2), &(pattrib->pktlen)); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option) { p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_CAPABILITY_IE_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); - if ((p != NULL) && (!(is_ap_in_tkip(padapter)))) { + if (p && !is_ap_in_tkip(padapter)) { memcpy(&(pmlmeinfo->HT_caps), (p + 2), sizeof(struct HT_caps_element)); /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ @@ -5576,7 +5576,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned pmlmeinfo = &(pmlmeext->mlmext_info); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -5635,7 +5635,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* da == NULL, assum it's null data for sta to ap*/ - if (da == NULL) + if (!da) da = get_my_bssid(&(pmlmeinfo->network)); do { @@ -5686,7 +5686,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 DBG_88E("%s\n", __func__); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -5758,7 +5758,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); /* da == NULL, assum it's null data for sta to ap*/ - if (da == NULL) + if (!da) da = get_my_bssid(&(pmlmeinfo->network)); do { @@ -5816,7 +5816,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s #endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) goto exit; /* update attribute */ @@ -5917,7 +5917,7 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u FUNC_NDEV_ARG(padapter->pnetdev), ra, new_ch, ch_offset); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -5987,7 +5987,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch DBG_88E("%s, category=%d, action=%d, status=%d\n", __func__, category, action, status); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -6034,7 +6034,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); psta = rtw_get_stainfo(pstapriv, raddr); - if (psta != NULL) { + if (psta) { start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; DBG_88E("BA_starting_seqctrl=%d for TID=%d\n", start_seq, status & 0x07); @@ -6126,7 +6126,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) action = ACT_PUBLIC_BSSCOEXIST; pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -6186,7 +6186,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pbss_network = (struct wlan_bssid_ex *)&pnetwork->network; p = rtw_get_ie(pbss_network->IEs + _FIXED_IE_LENGTH_, _HT_CAPABILITY_IE_, &len, pbss_network->IELength - _FIXED_IE_LENGTH_); - if ((p == NULL) || (len == 0)) { /* non-HT */ + if (!p || len == 0) { /* non-HT */ if ((pbss_network->Configuration.DSConfig <= 0) || (pbss_network->Configuration.DSConfig > 14)) continue; @@ -6240,7 +6240,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) return _SUCCESS; psta = rtw_get_stainfo(pstapriv, addr); - if (psta == NULL) + if (!psta) return _SUCCESS; if (initiator == 0) { /* recipient */ @@ -6526,7 +6526,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st /* checking SSID */ p = rtw_get_ie(bssid->IEs + ie_offset, _SSID_IE_, &len, bssid->IELength - ie_offset); - if (p == NULL) { + if (!p) { DBG_88E("marc: cannot find SSID for survey event\n"); return _FAIL; } @@ -6547,7 +6547,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st /* checking rate info... */ i = 0; p = rtw_get_ie(bssid->IEs + ie_offset, _SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); - if (p != NULL) { + if (p) { if (len > NDIS_802_11_LENGTH_RATES_EX) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; @@ -6557,7 +6557,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st } p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); - if (p != NULL) { + if (p) { if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; @@ -6986,12 +6986,12 @@ void report_survey_event(struct adapter *padapter, struct recv_frame *precv_fram pcmdpriv = &padapter->cmdpriv; pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); pevtcmd = (u8 *)rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -7038,12 +7038,12 @@ void report_surveydone_event(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); pevtcmd = (u8 *)rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -7084,12 +7084,12 @@ void report_join_res(struct adapter *padapter, int res) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); pevtcmd = (u8 *)rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -7135,12 +7135,12 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); pevtcmd = (u8 *)rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -7189,12 +7189,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (pcmd_obj == NULL) + if (!pcmd_obj) return; cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); pevtcmd = (u8 *)rtw_zmalloc(cmdsz); - if (pevtcmd == NULL) { + if (!pevtcmd) { kfree(pcmd_obj); return; } @@ -7479,7 +7479,7 @@ void linked_status_chk(struct adapter *padapter) rx_chk_limit = 4; psta = rtw_get_stainfo(pstapriv, pmlmeinfo->network.MacAddress); - if (psta != NULL) { + if (psta) { bool is_p2p_enable = false; #ifdef CONFIG_88EU_P2P is_p2p_enable = !rtw_p2p_chk_state(&padapter->wdinfo, P2P_STATE_NONE); @@ -7612,11 +7612,11 @@ void survey_timer_hdl(struct adapter *padapter) } ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) + if (!ph2c) goto exit_survey_timer_hdl; psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); - if (psurveyPara == NULL) { + if (!psurveyPara) { kfree(ph2c); goto exit_survey_timer_hdl; } @@ -8189,13 +8189,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) int len_diff = 0; ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); - if (ptxBeacon_parm == NULL) { + if (!ptxBeacon_parm) { kfree(ph2c); res = _FAIL; goto exit; diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 1b4e9bbc394b..1065e9e8a015 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -382,7 +382,7 @@ s32 mp_start_test(struct adapter *padapter) rtw_free_stainfo(padapter, psta); psta = rtw_alloc_stainfo(&padapter->stapriv, bssid.MacAddress); - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_mp_, _drv_err_, ("mp_start_test: Can't alloc sta_info!\n")); pmlmepriv->fw_state = pmppriv->prev_fw_state; res = _FAIL; @@ -547,11 +547,11 @@ static struct xmit_frame *alloc_mp_xmitframe(struct xmit_priv *pxmitpriv) struct xmit_buf *pxmitbuf; pmpframe = rtw_alloc_xmitframe(pxmitpriv); - if (pmpframe == NULL) + if (!pmpframe) return NULL; pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); - if (pxmitbuf == NULL) { + if (!pxmitbuf) { rtw_free_xmitframe(pxmitpriv, pmpframe); return NULL; } @@ -585,7 +585,7 @@ static int mp_xmit_packet_thread(void *context) /* DBG_88E("%s:pkTx Start\n", __func__); */ while (1) { pxmitframe = alloc_mp_xmitframe(pxmitpriv); - if (pxmitframe == NULL) { + if (!pxmitframe) { if (pmptx->stop || padapter->bSurpriseRemoved || padapter->bDriverStopped) { @@ -670,7 +670,7 @@ void SetPacketTx(struct adapter *padapter) pmp_priv->tx.write_size = pkt_size; pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ; pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size); - if (pmp_priv->tx.pallocated_buf == NULL) { + if (!pmp_priv->tx.pallocated_buf) { DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size); return; } @@ -938,7 +938,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + if (!pxmitpriv->pallocated_xmit_extbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 30823bfdd1b5..ce30161535c1 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -128,7 +128,7 @@ static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) DBG_88E("[%s]\n", __func__); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -187,7 +187,7 @@ static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 s DBG_88E("[%s]\n", __func__); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -257,7 +257,7 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -336,7 +336,7 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 DBG_88E("[%s]\n", __func__); pmgntframe = alloc_mgtxmitframe(pxmitpriv); - if (pmgntframe == NULL) + if (!pmgntframe) return; /* update attribute */ @@ -792,13 +792,13 @@ u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen); if (p2pie) { - if ((p != NULL) && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) { + if (p && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) { /* todo: */ /* Check Requested Device Type attributes in WSC IE. */ /* Check Device ID attribute in P2P IE */ ret = true; - } else if ((p != NULL) && (ssid_len == 0)) { + } else if (p && ssid_len == 0) { ret = true; } } else { @@ -1700,13 +1700,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) if (enqueue) { ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); - if (ph2c == NULL) { + if (!ph2c) { res = _FAIL; goto exit; } pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); - if (pdrvextra_cmd_parm == NULL) { + if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; goto exit; diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 610cc699caf9..37cf22569c59 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -60,7 +60,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); - if (precvpriv->pallocated_frame_buf == NULL) { + if (!precvpriv->pallocated_frame_buf) { res = _FAIL; goto exit; } @@ -141,7 +141,7 @@ struct recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) list_del_init(&hdr->list); padapter = hdr->adapter; - if (padapter != NULL) { + if (padapter) { precvpriv = &padapter->recvpriv; if (pfree_recv_queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt--; @@ -194,7 +194,7 @@ int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv list_add_tail(&(precvframe->list), get_list_head(pfree_recv_queue)); - if (padapter != NULL) { + if (padapter) { if (pfree_recv_queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt++; } @@ -212,7 +212,7 @@ int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) list_del_init(&(precvframe->list)); list_add_tail(&(precvframe->list), get_list_head(queue)); - if (padapter != NULL) { + if (padapter) { if (queue == &precvpriv->free_recv_queue) precvpriv->free_recvframe_cnt++; } @@ -347,7 +347,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); /* calculate mic code */ - if (stainfo != NULL) { + if (stainfo) { if (IS_MCAST(prxattrib->ra)) { mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; @@ -541,7 +541,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p adapter->securitypriv.dot11AuthAlgrthm)); if (auth_alg == 2) { - if ((psta != NULL) && (psta->ieee8021x_blocked)) { + if (psta && psta->ieee8021x_blocked) { /* blocked */ /* only accept EAPOL frame */ RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==1\n")); @@ -805,7 +805,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, else *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n")); if (adapter->registrypriv.mp_mode == 1) { if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) @@ -874,7 +874,7 @@ static int ap2sta_data_frame ( else *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n")); ret = _FAIL; goto exit; @@ -901,7 +901,7 @@ static int ap2sta_data_frame ( memcpy(pattrib->bssid, mybssid, ETH_ALEN); *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under MP_MODE ; drop pkt\n")); ret = _FAIL; goto exit; @@ -913,7 +913,7 @@ static int ap2sta_data_frame ( } else { if (!memcmp(myhwaddr, pattrib->dst, ETH_ALEN) && (!bmcast)) { *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ - if (*psta == NULL) { + if (!*psta) { DBG_88E("issue_deauth to the ap =%pM for the reason(7)\n", (pattrib->bssid)); issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); @@ -947,7 +947,7 @@ static int sta2ap_data_frame(struct adapter *adapter, } *psta = rtw_get_stainfo(pstapriv, pattrib->src); - if (*psta == NULL) { + if (!*psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); @@ -1011,7 +1011,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, aid = GetAid(pframe); psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); - if ((psta == NULL) || (psta->aid != aid)) + if (!psta || psta->aid != aid) return _FAIL; /* for rx pkt statistics */ @@ -1119,7 +1119,7 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+validate_recv_mgnt_frame\n")); precv_frame = recvframe_chk_defrag(padapter, precv_frame); - if (precv_frame == NULL) { + if (!precv_frame) { RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); return _SUCCESS; } @@ -1164,7 +1164,7 @@ static int validate_recv_data_frame(struct adapter *adapter, psa = get_sa(ptr); pbssid = get_hdr_bssid(ptr); - if (pbssid == NULL) { + if (!pbssid) { ret = _FAIL; goto exit; } @@ -1207,7 +1207,7 @@ static int validate_recv_data_frame(struct adapter *adapter, goto exit; } - if (psta == NULL) { + if (!psta) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" after to_fr_ds_chk; psta==NULL\n")); ret = _FAIL; goto exit; @@ -1547,7 +1547,7 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr psta_addr = pfhdr->attrib.ta; psta = rtw_get_stainfo(pstapriv, psta_addr); - if (psta == NULL) { + if (!psta) { u8 type = GetFrameType(pfhdr->rx_data); if (type != WIFI_DATA_TYPE) { psta = rtw_get_bcmc_stainfo(padapter); @@ -1565,7 +1565,7 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr if (ismfrag == 1) { /* 0~(n-1) fragment frame */ /* enqueue to defraf_g */ - if (pdefrag_q != NULL) { + if (pdefrag_q) { if (fragnum == 0) { /* the first fragment */ if (!list_empty(&pdefrag_q->queue)) { @@ -1594,7 +1594,7 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr if ((ismfrag == 0) && (fragnum != 0)) { /* the last fragment frame */ /* enqueue the last fragment */ - if (pdefrag_q != NULL) { + if (pdefrag_q) { phead = get_list_head(pdefrag_q); list_add_tail(&pfhdr->list, phead); @@ -1611,7 +1611,7 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr } } - if ((prtnframe != NULL) && (prtnframe->attrib.privacy)) { + if (prtnframe && prtnframe->attrib.privacy) { /* after defrag we must check tkip mic code */ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); @@ -2054,20 +2054,20 @@ static int recv_func_posthandle(struct adapter *padapter, struct recv_frame *prf rtw_led_control(padapter, LED_CTL_RX); prframe = decryptor(padapter, prframe); - if (prframe == NULL) { + if (!prframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decryptor: drop pkt\n")); ret = _FAIL; goto _recv_data_drop; } prframe = recvframe_chk_defrag(padapter, prframe); - if (prframe == NULL) { + if (!prframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chk_defrag: drop pkt\n")); goto _recv_data_drop; } prframe = portctrl(padapter, prframe); - if (prframe == NULL) { + if (!prframe) { RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n")); ret = _FAIL; goto _recv_data_drop; diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 2c1b9a6dcdf2..66c730a5d754 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -95,7 +95,7 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) struct security_priv *psecuritypriv = &padapter->securitypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + if (!((struct xmit_frame *)pxmitframe)->buf_addr) return; hw_hdr_offset = TXDESC_SIZE + @@ -542,7 +542,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u32 res = _SUCCESS; - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + if (!((struct xmit_frame *)pxmitframe)->buf_addr) return _FAIL; hw_hdr_offset = TXDESC_SIZE + @@ -555,7 +555,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) else stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - if (stainfo != NULL) { + if (stainfo) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo!= NULL!!!\n")); if (IS_MCAST(pattrib->ra)) @@ -631,7 +631,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) /* 4 start to decrypt recvframe */ if (prxattrib->encrypt == _TKIP_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - if (stainfo != NULL) { + if (stainfo) { if (IS_MCAST(prxattrib->ra)) { if (!psecuritypriv->binstallGrpkey) { res = _FAIL; @@ -1202,7 +1202,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) /* uint offset = 0; */ u32 res = _SUCCESS; - if (((struct xmit_frame *)pxmitframe)->buf_addr == NULL) + if (!((struct xmit_frame *)pxmitframe)->buf_addr) return _FAIL; hw_hdr_offset = TXDESC_SIZE + @@ -1217,7 +1217,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) else stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - if (stainfo != NULL) { + if (stainfo) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo!= NULL!!!\n")); if (IS_MCAST(pattrib->ra)) @@ -1456,7 +1456,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) /* 4 start to encrypt each fragment */ if ((prxattrib->encrypt == _AES_)) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); - if (stainfo != NULL) { + if (stainfo) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); if (IS_MCAST(prxattrib->ra)) { diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index feaf39fddf7c..93cd1db1ba2a 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -153,7 +153,7 @@ void rtw_mfree_stainfo(struct sta_info *psta); void rtw_mfree_stainfo(struct sta_info *psta) { - if (&psta->lock != NULL) + if (&psta->lock) _rtw_spinlock_free(&psta->lock); _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); @@ -333,7 +333,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct sta_priv *pstapriv = &padapter->stapriv; - if (psta == NULL) + if (!psta) goto exit; pfree_sta_queue = &pstapriv->free_sta_queue; @@ -488,7 +488,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) u8 *addr; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - if (hwaddr == NULL) + if (!hwaddr) return NULL; if (IS_MCAST(hwaddr)) @@ -528,7 +528,7 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) psta = rtw_alloc_stainfo(pstapriv, bcast_addr); - if (psta == NULL) { + if (!psta) { res = _FAIL; RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); goto exit; diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 15edccef9f1d..db133ffad8f9 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -740,7 +740,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (pIE == NULL) + if (!pIE) return; if (!phtpriv->ht_option) @@ -787,7 +787,7 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; - if (pIE == NULL) + if (!pIE) return; if (!phtpriv->ht_option) @@ -986,7 +986,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) /* checking SSID */ p = rtw_get_ie(bssid->IEs + _FIXED_IE_LENGTH_, _SSID_IE_, &len, bssid->IELength - _FIXED_IE_LENGTH_); - if (p == NULL) { + if (!p) { DBG_88E("%s marc: cannot find SSID for survey event\n", __func__); hidden_ssid = true; } else { @@ -1590,7 +1590,7 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); - if (pIE == NULL) + if (!pIE) return _FAIL; memcpy(pmlmeinfo->FW_sta_info[cam_idx].SupportedRates, pIE->data, ie_len); @@ -1657,7 +1657,7 @@ int rtw_handle_dualmac(struct adapter *adapter, bool init) int status = _SUCCESS; if (init) { - if (pbuddy_padapter == NULL) { + if (!pbuddy_padapter) { pbuddy_padapter = adapter; DBG_88E("%s(): pbuddy_padapter == NULL, Set pbuddy_padapter\n", __func__); } else { diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 4a5393184737..3b61eb651ee4 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -74,7 +74,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); - if (pxmitpriv->pallocated_frame_buf == NULL) { + if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); res = _FAIL; @@ -112,7 +112,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmitbuf == NULL) { + if (!pxmitpriv->pallocated_xmitbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); res = _FAIL; goto exit; @@ -154,7 +154,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - if (pxmitpriv->pallocated_xmit_extbuf == NULL) { + if (!pxmitpriv->pallocated_xmit_extbuf) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; @@ -238,7 +238,7 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) rtw_mfree_xmit_priv_lock(pxmitpriv); - if (pxmitpriv->pxmit_frame_buf == NULL) + if (!pxmitpriv->pxmit_frame_buf) return; for (i = 0; i < NR_XMITFRAME; i++) { @@ -509,7 +509,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p psta = rtw_get_bcmc_stainfo(padapter); } else { psta = rtw_get_stainfo(pstapriv, pattrib->ra); - if (psta == NULL) { /* if we cannot get psta => drrp the pkt */ + if (!psta) { /* if we cannot get psta => drrp the pkt */ RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra: %pM\n", (pattrib->ra))); res = _FAIL; goto exit; @@ -656,7 +656,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ /* encode mic code */ - if (stainfo != NULL) { + if (stainfo) { u8 null_key[16] = {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0}; @@ -992,10 +992,10 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); - if (psta == NULL) + if (!psta) return _FAIL; - if (pxmitframe->buf_addr == NULL) { + if (!pxmitframe->buf_addr) { DBG_88E("==> %s buf_addr == NULL\n", __func__); return _FAIL; } @@ -1033,7 +1033,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct /* adding icv, if necessary... */ if (pattrib->iv_len) { - if (psta != NULL) { + if (psta) { switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: @@ -1177,7 +1177,7 @@ void rtw_update_protection(struct adapter *padapter, u8 *ie, uint ie_len) case AUTO_VCS: default: perp = rtw_get_ie(ie, _ERPINFO_IE_, &erp_len, ie_len); - if (perp == NULL) { + if (!perp) { pxmitpriv->vcs = NONE_VCS; } else { protection = (*(perp + 2)) & BIT(1); @@ -1236,7 +1236,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) list_del_init(&(pxmitbuf->list)); } - if (pxmitbuf != NULL) { + if (pxmitbuf) { pxmitpriv->free_xmit_extbuf_cnt--; pxmitbuf->priv_data = NULL; @@ -1258,7 +1258,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) struct __queue *pfree_queue = &pxmitpriv->free_xmit_extbuf_queue; unsigned long flags; - if (pxmitbuf == NULL) + if (!pxmitbuf) return _FAIL; spin_lock_irqsave(&pfree_queue->lock, flags); @@ -1296,7 +1296,7 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) list_del_init(&(pxmitbuf->list)); } - if (pxmitbuf != NULL) { + if (pxmitbuf) { pxmitpriv->free_xmitbuf_cnt--; pxmitbuf->priv_data = NULL; if (pxmitbuf->sctx) { @@ -1314,7 +1314,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) struct __queue *pfree_xmitbuf_queue = &pxmitpriv->free_xmitbuf_queue; unsigned long flags; - if (pxmitbuf == NULL) + if (!pxmitbuf) return _FAIL; if (pxmitbuf->sctx) { @@ -1377,7 +1377,7 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf list_del_init(&(pxframe->list)); } - if (pxframe != NULL) { /* default value setting */ + if (pxframe) { /* default value setting */ pxmitpriv->free_xmitframe_cnt--; RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); @@ -1408,7 +1408,7 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram struct adapter *padapter = pxmitpriv->adapter; struct sk_buff *pndis_pkt = NULL; - if (pxmitframe == NULL) { + if (!pxmitframe) { RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); goto exit; } @@ -1598,7 +1598,7 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) psta = rtw_get_stainfo(pstapriv, pattrib->ra); } - if (psta == NULL) { + if (!psta) { res = _FAIL; DBG_88E("rtw_xmit_classifier: psta == NULL\n"); RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmit_classifier: psta == NULL\n")); @@ -1727,7 +1727,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) } newskb = skb_copy(skb, GFP_ATOMIC); - if (newskb == NULL) { + if (!newskb) { DEBUG_ERR("TX DROP: skb_copy fail!\n"); return -1; } @@ -1847,7 +1847,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) s32 res; pxmitframe = rtw_alloc_xmitframe(pxmitpriv); - if (pxmitframe == NULL) { + if (!pxmitframe) { RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); DBG_88E("DBG_TX_DROP_FRAME %s no more pxmitframe\n", __func__); return -1; @@ -1912,7 +1912,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra else psta = rtw_get_stainfo(pstapriv, pattrib->ra); - if (psta == NULL) + if (!psta) return ret; if (pattrib->triggered == 1) { -- cgit v1.2.3 From 167fc30e8e5185a411f0115302f4ef467517ffb8 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sun, 1 Aug 2021 15:46:29 +0200 Subject: staging: rtl8723bs: remove unused macros remove unused macros detected by -Wunused-macros gcc option. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/20210801134629.23433-1-fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 1 - drivers/staging/rtl8723bs/core/rtw_debug.c | 1 - drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 1 - drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 1 - drivers/staging/rtl8723bs/core/rtw_rf.c | 1 - drivers/staging/rtl8723bs/core/rtw_security.c | 5 ----- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 3 --- drivers/staging/rtl8723bs/hal/HalPhyRf.c | 15 ------------- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 27 ----------------------- drivers/staging/rtl8723bs/hal/hal_btcoex.c | 3 --- drivers/staging/rtl8723bs/hal/hal_com.c | 1 - drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 1 - drivers/staging/rtl8723bs/hal/hal_sdio.c | 1 - drivers/staging/rtl8723bs/hal/odm.c | 4 ---- drivers/staging/rtl8723bs/hal/odm_DIG.c | 2 -- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 2 -- drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 2 -- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 3 --- drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c | 10 --------- drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c | 1 - drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 3 --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 1 - drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c | 1 - 26 files changed, 93 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index b7e1d7817595..69a55482e8a0 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTW_AP_C_ #include #include diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c index 576b039f741c..76ad1122f89f 100644 --- a/drivers/staging/rtl8723bs/core/rtw_debug.c +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTW_DEBUG_C_ #include #include diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index b7ad4a11a7b7..795eafb7d6ff 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _IEEE80211_C #include #include diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 8914ef3d33c8..0152491455a2 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTW_IOCTL_SET_C_ #include #include diff --git a/drivers/staging/rtl8723bs/core/rtw_rf.c b/drivers/staging/rtl8723bs/core/rtw_rf.c index a5095a4ef690..96eb8ca38003 100644 --- a/drivers/staging/rtl8723bs/core/rtw_rf.c +++ b/drivers/staging/rtl8723bs/core/rtw_rf.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTW_RF_C_ #include #include diff --git a/drivers/staging/rtl8723bs/core/rtw_security.c b/drivers/staging/rtl8723bs/core/rtw_security.c index 8b507f6a447e..b050bf62e3b9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_security.c +++ b/drivers/staging/rtl8723bs/core/rtw_security.c @@ -268,11 +268,6 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod /* fixed algorithm "parameters" */ #define PHASE1_LOOP_CNT 8 /* this needs to be "big enough" */ -#define TA_SIZE 6 /* 48-bit transmitter address */ -#define TK_SIZE 16 /* 128-bit temporal key */ -#define P1K_SIZE 10 /* 80-bit Phase1 key */ -#define RC4_KEY_SIZE 16 /* 128-bit RC4KEY (104 bits unknown) */ - /* 2-unsigned char by 2-unsigned char subset of the full AES S-box table */ static const unsigned short Sbox1[2][256] = { /* Sbox for hash (can be in ROM) */ diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 865a82d5cedb..170536986476 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTW_WLAN_UTIL_C_ #include #include @@ -25,8 +24,6 @@ static unsigned char AIRGOCAP_OUI[] = {0x00, 0x0a, 0xf5}; static unsigned char RSN_TKIP_CIPHER[4] = {0x00, 0x0f, 0xac, 0x02}; static unsigned char WPA_TKIP_CIPHER[4] = {0x00, 0x50, 0xf2, 0x02}; -#define R2T_PHY_DELAY (0) - /* define WAIT_FOR_BCN_TO_MIN (3000) */ #define WAIT_FOR_BCN_TO_MIN (6000) #define WAIT_FOR_BCN_TO_MAX (20000) diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf.c b/drivers/staging/rtl8723bs/hal/HalPhyRf.c index 365e1195b5e5..9c6d3bf2f2ea 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf.c @@ -8,21 +8,6 @@ /* include "Mp_Precomp.h" */ #include "odm_precomp.h" - -#define CALCULATE_SWINGTALBE_OFFSET(_offset, _direction, _size, _deltaThermal) \ - do {\ - for (_offset = 0; _offset < _size; _offset++) {\ - if (_deltaThermal < thermalThreshold[_direction][_offset]) {\ - if (_offset != 0)\ - _offset--;\ - break;\ - } \ - } \ - if (_offset >= _size)\ - _offset = _size-1;\ - } while (0) - - void ConfigureTxpowerTrack(struct dm_odm_t *pDM_Odm, struct txpwrtrack_cfg *pConfig) { ConfigureTxpowerTrack_8723B(pConfig); diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index 8121b8eb45b6..c696569ae5cf 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -9,17 +9,10 @@ #include #include "odm_precomp.h" - - -/*---------------------------Define Local Constant---------------------------*/ -/* 2010/04/25 MH Define the max tx power tracking tx agc power. */ -#define ODM_TXPWRTRACK_MAX_IDX8723B 6 - /* MACRO definition for pRFCalibrateInfo->TxIQC_8723B[0] */ #define PATH_S0 1 /* RF_PATH_B */ #define IDX_0xC94 0 #define IDX_0xC80 1 -#define IDX_0xC4C 2 #define IDX_0xC14 0 #define IDX_0xCA0 1 #define KEY 0 @@ -27,12 +20,7 @@ /* MACRO definition for pRFCalibrateInfo->TxIQC_8723B[1] */ #define PATH_S1 0 /* RF_PATH_A */ -#define IDX_0xC9C 0 -#define IDX_0xC88 1 #define IDX_0xC4C 2 -#define IDX_0xC1C 0 -#define IDX_0xC78 1 - /*---------------------------Define Local Constant---------------------------*/ @@ -373,7 +361,6 @@ void ConfigureTxpowerTrack_8723B(struct txpwrtrack_cfg *pConfig) /* 1 7. IQK */ #define MAX_TOLERANCE 5 -#define IQK_DELAY_TIME 1 /* ms */ /* bit0 = 1 => Tx OK, bit1 = 1 => Rx OK */ static u8 phy_PathA_IQK_8723B( @@ -1583,20 +1570,6 @@ static void phy_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm, bool is2T) rtw_write8(pDM_Odm->Adapter, REG_TXPAUSE, 0x00); } -/* Analog Pre-distortion calibration */ -#define APK_BB_REG_NUM 8 -#define APK_CURVE_REG_NUM 4 -#define PATH_NUM 2 - -#define DP_BB_REG_NUM 7 -#define DP_RF_REG_NUM 1 -#define DP_RETRY_LIMIT 10 -#define DP_PATH_NUM 2 -#define DP_DPK_NUM 3 -#define DP_DPK_VALUE_NUM 2 - - - /* IQK version:V2.5 20140123 */ /* IQK is controlled by Is2ant, RF path */ void PHY_IQCalibrate_8723B( diff --git a/drivers/staging/rtl8723bs/hal/hal_btcoex.c b/drivers/staging/rtl8723bs/hal/hal_btcoex.c index 6e165d808bbd..f4b3e8b28712 100644 --- a/drivers/staging/rtl8723bs/hal/hal_btcoex.c +++ b/drivers/staging/rtl8723bs/hal/hal_btcoex.c @@ -4,7 +4,6 @@ * Copyright(c) 2013 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define __HAL_BTCOEX_C__ #include #include @@ -17,8 +16,6 @@ struct btc_coexist GLBtCoexist; static u8 GLBtcWiFiInScanState; static u8 GLBtcWiFiInIQKState; -#define BT_Operation(Adapter) false - /* */ /* Debug related function */ /* */ diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 0df2b9b61cf8..fbe6b64aa1fb 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _HAL_COM_C_ #include #include diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index bb7941aee0c4..4fb2884fce38 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _HAL_COM_PHYCFG_C_ #include #include diff --git a/drivers/staging/rtl8723bs/hal/hal_sdio.c b/drivers/staging/rtl8723bs/hal/hal_sdio.c index 2d61b09ebce6..9de62a0f5d35 100644 --- a/drivers/staging/rtl8723bs/hal/hal_sdio.c +++ b/drivers/staging/rtl8723bs/hal/hal_sdio.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _HAL_SDIO_C_ #include #include diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c index 68dfb77772b2..45fdd51b784e 100644 --- a/drivers/staging/rtl8723bs/hal/odm.c +++ b/drivers/staging/rtl8723bs/hal/odm.c @@ -281,10 +281,6 @@ u32 TxScalingTable_Jaguar[TXSCALE_TABLE_SIZE] = { /* Remove Edca by Yu Chen */ - -#define RxDefaultAnt1 0x65a9 -#define RxDefaultAnt2 0x569a - static void odm_CommonInfoSelfInit(struct dm_odm_t *pDM_Odm) { pDM_Odm->bCckHighPower = (bool) PHY_QueryBBReg(pDM_Odm->Adapter, ODM_REG(CCK_RPT_FORMAT, pDM_Odm), ODM_BIT(CCK_RPT_FORMAT, pDM_Odm)); diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index ef5b48bb01b2..fb932e0618e2 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -7,8 +7,6 @@ #include "odm_precomp.h" -#define ADAPTIVITY_VERSION "5.0" - void odm_NHMCounterStatisticsInit(void *pDM_VOID) { struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID; diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 32f7eb952ca8..859451810c48 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -9,8 +9,6 @@ #define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig_MP_##ic##txt(pDM_Odm)) #define READ_AND_CONFIG READ_AND_CONFIG_MP -#define GET_VERSION_MP(ic, txt) (ODM_GetVersion_MP_##ic##txt()) -#define GET_VERSION(ic, txt) (pDM_Odm->bIsMPChip?GET_VERSION_MP(ic, txt):GET_VERSION_TC(ic, txt)) static u8 odm_QueryRxPwrPercentage(s8 AntPower) { diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c index 853fe758c4a9..a59ae622f05e 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_cmd.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTL8723B_CMD_C_ #include #include diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index 5840a5241fde..54e2a68a0824 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -7,8 +7,6 @@ /* Description: */ /* This file is for 92CE/92CU dynamic mechanism only */ -#define _RTL8723B_DM_C_ - #include #include #include diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index d9a2d3e6a56f..713ee0179dda 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2013 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _HAL_INIT_C_ #include #include @@ -598,14 +597,12 @@ static void Hal_GetEfuseDefinition( } #define VOLTAGE_V25 0x03 -#define LDOE25_SHIFT 28 /* */ /* The following is for compile ok */ /* That should be merged with the original in the future */ /* */ #define EFUSE_ACCESS_ON_8723 0x69 /* For RTL8723 only. */ -#define EFUSE_ACCESS_OFF_8723 0x00 /* For RTL8723 only. */ #define REG_EFUSE_ACCESS_8723 0x00CF /* Efuse access protection for RTL8723 */ /* */ diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c index 6e524034f388..ca6b548171b4 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c @@ -4,21 +4,11 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTL8723B_PHYCFG_C_ #include #include #include - -/*---------------------------Define Local Constant---------------------------*/ -/* Channel switch:The size of command tables for switch channel*/ -#define MAX_PRECMD_CNT 16 -#define MAX_RFDEPENDCMD_CNT 16 -#define MAX_POSTCMD_CNT 16 - -#define MAX_DOZE_WAITING_TIMES_9x 64 - /** * phy_CalculateBitShift - Get shifted position of the BitMask. * @BitMask: Bitmask. diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c index f2f02a69f0af..717faebf8aca 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rxdesc.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTL8723B_REDESC_C_ #include diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index ad803ffc0696..6dc5cd959b75 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTL8723BS_RECV_C_ #include #include diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c index a05d43b716ee..156d6aba18ca 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_xmit.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _RTL8723BS_XMIT_C_ #include #include diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 12b8e1773a84..62eb64e447a4 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _IOCTL_CFG80211_C_ #include #include @@ -71,8 +70,6 @@ static struct ieee80211_rate rtw_rates[] = { RATETAB_ENT(540, 0x800, 0), }; -#define rtw_a_rates (rtw_rates + 4) -#define RTW_A_RATES_NUM 8 #define rtw_g_rates (rtw_rates + 0) #define RTW_G_RATES_NUM 12 diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 19c5c7e8f403..e2ab34463182 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * ******************************************************************************/ -#define _IOCTL_LINUX_C_ #include #include diff --git a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c index bed930760656..0a0b04088e66 100644 --- a/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/sdio_ops_linux.c @@ -4,7 +4,6 @@ * Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved. * *******************************************************************************/ -#define _SDIO_OPS_LINUX_C_ #include #include -- cgit v1.2.3 From b0c70266e418600ac332c9a1ddaa3c53b394b6cc Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 20:04:24 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_pwrctrl.c Remove RT_TRACE macro calls from core/rtw_pwrctrl.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210801190437.82017-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index d67eeb045002..fa0d8bef11ca 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -219,37 +219,22 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) pslv = PS_STATE_S3; } - if ((pwrpriv->rpwm == pslv)) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: Already set rpwm[0x%02X], new=0x%02X!\n", __func__, pwrpriv->rpwm, pslv)); + if ((pwrpriv->rpwm == pslv)) return; - } if ((padapter->bSurpriseRemoved) || (!padapter->hw_init_completed)) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: SurpriseRemoved(%d) hw_init_completed(%d)\n", - __func__, padapter->bSurpriseRemoved, padapter->hw_init_completed)); - pwrpriv->cpwm = PS_STATE_S4; return; } if (padapter->bDriverStopped) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: change power state(0x%02X) when DriverStopped\n", __func__, pslv)); - - if (pslv < PS_STATE_S2) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, - ("%s: Reject to enter PS_STATE(0x%02X) lower than S2 when DriverStopped!!\n", __func__, pslv)); + if (pslv < PS_STATE_S2) return; - } } rpwm = pslv | pwrpriv->tog; - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, - ("rtw_set_rpwm: rpwm=0x%02x cpwm=0x%02x\n", rpwm, pwrpriv->cpwm)); pwrpriv->rpwm = pslv; @@ -294,14 +279,8 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a struct wifidirect_info *pwdinfo = &(padapter->wdinfo); #endif /* CONFIG_88EU_P2P */ - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_notice_, - ("%s: PowerMode=%d Smart_PS=%d\n", - __func__, ps_mode, smart_ps)); - - if (ps_mode > PM_Card_Disable) { - RT_TRACE(_module_rtl871x_pwrctrl_c_, _drv_err_, ("ps_mode:%d error\n", ps_mode)); + if (ps_mode > PM_Card_Disable) return; - } if (pwrpriv->pwr_mode == ps_mode) { if (PS_MODE_ACTIVE == ps_mode) -- cgit v1.2.3 From 821e507947fe3a7e6159ab6cf9b5e7da3c529b9e Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 20:04:25 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_wlan_util.c Remove RT_TRACE macro calls from core/rtw_wlan_util.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210801190437.82017-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_wlan_util.c | 25 +++---------------------- 1 file changed, 3 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index db133ffad8f9..8603a297b929 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -1001,11 +1001,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) bssid->Ssid.Ssid[0] = '\0'; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s bssid.Ssid.Ssid:%s bssid.Ssid.SsidLength:%d " - "cur_network->network.Ssid.Ssid:%s len:%d\n", __func__, bssid->Ssid.Ssid, - bssid->Ssid.SsidLength, cur_network->network.Ssid.Ssid, - cur_network->network.Ssid.SsidLength)); - if (memcmp(bssid->Ssid.Ssid, cur_network->network.Ssid.Ssid, 32) || bssid->Ssid.SsidLength != cur_network->network.Ssid.SsidLength) { if (bssid->Ssid.Ssid[0] != '\0' && bssid->Ssid.SsidLength != 0) { /* not hidden ssid */ @@ -1022,9 +1017,6 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) else bssid->Privacy = 0; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s(): cur_network->network.Privacy is %d, bssid.Privacy is %d\n", - __func__, cur_network->network.Privacy, bssid->Privacy)); if (cur_network->network.Privacy != bssid->Privacy) { DBG_88E("%s(), privacy is not match return FAIL\n", __func__); goto _mismatch; @@ -1049,25 +1041,14 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, group_cipher is %d, is_8021x is %d\n", __func__, - pairwise_cipher, group_cipher, is_8021x)); - } + rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x); } else { pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); - if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("%s pnetwork->pairwise_cipher: %d, pnetwork->group_cipher is %d, is_802x is %d\n", - __func__, pairwise_cipher, group_cipher, is_8021x)); - } - } + if (pbuf && (wpa_ielen > 0)) + rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x); } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("%s cur_network->group_cipher is %d: %d\n", __func__, cur_network->BcnInfo.group_cipher, group_cipher)); if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { DBG_88E("%s pairwise_cipher(%x:%x) or group_cipher(%x:%x) is not match , return FAIL\n", __func__, pairwise_cipher, cur_network->BcnInfo.pairwise_cipher, -- cgit v1.2.3 From 0399a1e24bbd1b78bf3e73ee46f25c2647ae8927 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 20:04:26 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_ieee80211.c Remove RT_TRACE macro calls from core/rtw_ieee80211.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210801190437.82017-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ieee80211.c | 67 +++------------------------- 1 file changed, 6 insertions(+), 61 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index 2c626dda3e5d..e54926e1f569 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -531,7 +531,6 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis pos += WPA_SELECTOR_LEN; left -= WPA_SELECTOR_LEN; } else if (left > 0) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); return _FAIL; } @@ -541,11 +540,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis pos += 2; left -= 2; - if (count == 0 || left < count * WPA_SELECTOR_LEN) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " - "count %u left %u", __func__, count, left)); + if (count == 0 || left < count * WPA_SELECTOR_LEN) return _FAIL; - } for (i = 0; i < count; i++) { *pairwise_cipher |= rtw_get_wpa_cipher_suite(pos); @@ -554,17 +550,14 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis left -= WPA_SELECTOR_LEN; } } else if (left == 1) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); return _FAIL; } if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s : there has 802.1x auth\n", __func__)); + if (!memcmp(pos, SUITE_1X, 4)) *is_8021x = 1; - } } } @@ -598,7 +591,6 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi left -= RSN_SELECTOR_LEN; } else if (left > 0) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie length mismatch, %u too much", __func__, left)); return _FAIL; } @@ -608,11 +600,8 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi pos += 2; left -= 2; - if (count == 0 || left < count * RSN_SELECTOR_LEN) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie count botch (pairwise), " - "count %u left %u", __func__, count, left)); + if (count == 0 || left < count * RSN_SELECTOR_LEN) return _FAIL; - } for (i = 0; i < count; i++) { *pairwise_cipher |= rtw_get_wpa2_cipher_suite(pos); @@ -622,18 +611,14 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi } } else if (left == 1) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s: ie too short (for key mgmt)", __func__)); - return _FAIL; } if (is_8021x) { if (left >= 6) { pos += 2; - if (!memcmp(pos, SUITE_1X, 4)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s (): there has 802.1x auth\n", __func__)); + if (!memcmp(pos, SUITE_1X, 4)) *is_8021x = 1; - } } } return ret; @@ -655,40 +640,16 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, authmode = in_ie[cnt]; if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\n rtw_get_wpa_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", - sec_idx, in_ie[cnt+1]+2)); - - if (wpa_ie) { + if (wpa_ie) memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2); - for (i = 0; i < (in_ie[cnt+1]+2); i += 8) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", - wpa_ie[i], wpa_ie[i+1], wpa_ie[i+2], wpa_ie[i+3], wpa_ie[i+4], - wpa_ie[i+5], wpa_ie[i+6], wpa_ie[i+7])); - } - } - *wpa_len = in_ie[cnt+1]+2; cnt += in_ie[cnt+1]+2; /* get next */ } else { if (authmode == _WPA2_IE_ID_) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\n get_rsn_ie: sec_idx =%d in_ie[cnt+1]+2 =%d\n", - sec_idx, in_ie[cnt+1]+2)); - - if (rsn_ie) { + if (rsn_ie) memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt+1]+2); - for (i = 0; i < (in_ie[cnt+1]+2); i += 8) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\n %2x,%2x,%2x,%2x,%2x,%2x,%2x,%2x\n", - rsn_ie[i], rsn_ie[i+1], rsn_ie[i+2], rsn_ie[i+3], rsn_ie[i+4], - rsn_ie[i+5], rsn_ie[i+6], rsn_ie[i+7])); - } - } - *rsn_len = in_ie[cnt+1]+2; cnt += in_ie[cnt+1]+2; /* get next */ } else { @@ -1403,28 +1364,20 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); if (pbuf && (wpa_ielen > 0)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_cipher_info: wpa_ielen: %d", wpa_ielen)); if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d, is_8021x is %d", - __func__, pnetwork->BcnInfo.pairwise_cipher, pnetwork->BcnInfo.is_8021x)); ret = _SUCCESS; } } else { pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); if (pbuf && (wpa_ielen > 0)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE\n")); if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("get RSN IE OK!!!\n")); pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("%s: pnetwork->pairwise_cipher: %d," - "pnetwork->group_cipher is %d, is_8021x is %d", __func__, pnetwork->BcnInfo.pairwise_cipher, - pnetwork->BcnInfo.group_cipher, pnetwork->BcnInfo.is_8021x)); ret = _SUCCESS; } } @@ -1453,10 +1406,6 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_OPENSYS; } rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, NULL, &rsn_len, NULL, &wpa_len); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: ssid =%s\n", pnetwork->network.Ssid.Ssid)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); if (rsn_len > 0) { pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WPA2; @@ -1466,10 +1415,6 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) if (bencrypt) pnetwork->BcnInfo.encryp_protocol = ENCRYP_PROTOCOL_WEP; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", - pnetwork->BcnInfo.encryp_protocol)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_get_bcn_info: pnetwork->encryp_protocol is %x\n", - pnetwork->BcnInfo.encryp_protocol)); rtw_get_cipher_info(pnetwork); /* get bwmode and ch_offset */ -- cgit v1.2.3 From 9bc84d0a4578a835620dfec7cc61de9d9ad085a1 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 20:04:27 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_io.c Remove RT_TRACE macro calls from core/rtw_io.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210801190437.82017-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_io.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index 85d1f7deda23..2a47329d90e8 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -182,12 +182,8 @@ void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) struct intf_hdl *pintfhdl = &(pio_priv->intf); - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { - RT_TRACE(_module_rtl871x_io_c_, _drv_info_, - ("rtw_read_mem:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - adapter->bDriverStopped, adapter->bSurpriseRemoved)); + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) return; - } _read_mem = pintfhdl->io_ops._read_mem; _read_mem(pintfhdl, addr, cnt, pmem); @@ -216,12 +212,8 @@ void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) - if (adapter->bDriverStopped || adapter->bSurpriseRemoved) { - RT_TRACE(_module_rtl871x_io_c_, _drv_info_, - ("rtw_read_port:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - adapter->bDriverStopped, adapter->bSurpriseRemoved)); + if (adapter->bDriverStopped || adapter->bSurpriseRemoved) return; - } _read_port = pintfhdl->io_ops._read_port; -- cgit v1.2.3 From 6a4bcaf1e8397337d496ab3481febd4c1f467ffc Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 20:04:35 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_led.c Remove RT_TRACE macro calls from core/rtw_led.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210801190437.82017-14-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_led.c | 82 +++++----------------------------- 1 file changed, 12 insertions(+), 70 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 70e989d11e44..22d4df9c92a5 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -89,13 +89,10 @@ static void SwLedBlink(struct LED_871x *pLed) u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { + if (pLed->BlinkingLedState == RTW_LED_ON) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { + else SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } /* Determine if we shall change LED state again. */ pLed->BlinkTimes--; @@ -170,13 +167,10 @@ static void SwLedBlink1(struct LED_871x *pLed) u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { + if (pLed->BlinkingLedState == RTW_LED_ON) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { + else SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff(padapter, pLed); @@ -212,7 +206,6 @@ static void SwLedBlink1(struct LED_871x *pLed) else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; @@ -221,7 +214,6 @@ static void SwLedBlink1(struct LED_871x *pLed) else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedScanBlinkInProgress = false; } else { @@ -245,7 +237,6 @@ static void SwLedBlink1(struct LED_871x *pLed) else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; @@ -254,7 +245,6 @@ static void SwLedBlink1(struct LED_871x *pLed) else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->BlinkTimes = 0; pLed->bLedBlinkInProgress = false; @@ -287,7 +277,6 @@ static void SwLedBlink1(struct LED_871x *pLed) else pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); pLed->bLedWPSBlinkInProgress = false; } else { @@ -307,13 +296,10 @@ static void SwLedBlink2(struct LED_871x *pLed) u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { + if (pLed->BlinkingLedState == RTW_LED_ON) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { + else SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } switch (pLed->CurrLedState) { case LED_BLINK_SCAN: @@ -327,13 +313,10 @@ static void SwLedBlink2(struct LED_871x *pLed) pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); - } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop scan blink CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedScanBlinkInProgress = false; } else { @@ -359,12 +342,10 @@ static void SwLedBlink2(struct LED_871x *pLed) pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("stop CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedBlinkInProgress = false; } else { @@ -393,11 +374,9 @@ static void SwLedBlink3(struct LED_871x *pLed) /* Change LED according to BlinkingLedState specified. */ if (pLed->BlinkingLedState == RTW_LED_ON) { SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); } else { if (pLed->CurrLedState != LED_BLINK_WPS_STOP) SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); } switch (pLed->CurrLedState) { @@ -413,13 +392,11 @@ static void SwLedBlink3(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_ON; if (!pLed->bLedOn) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedOn) SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedScanBlinkInProgress = false; } else { @@ -446,14 +423,12 @@ static void SwLedBlink3(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_ON; if (!pLed->bLedOn) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedOn) SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedBlinkInProgress = false; } else { @@ -490,7 +465,6 @@ static void SwLedBlink3(struct LED_871x *pLed) pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } pLed->bLedWPSBlinkInProgress = false; } @@ -508,13 +482,10 @@ static void SwLedBlink4(struct LED_871x *pLed) u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { + if (pLed->BlinkingLedState == RTW_LED_ON) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { + else SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } if (!pLed1->bLedWPSBlinkInProgress && pLed1->BlinkingLedState == LED_UNKNOWN) { pLed1->BlinkingLedState = RTW_LED_OFF; @@ -639,7 +610,6 @@ static void SwLedBlink4(struct LED_871x *pLed) default: break; } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink4 CurrLedState %d\n", pLed->CurrLedState)); } static void SwLedBlink5(struct LED_871x *pLed) @@ -648,13 +618,10 @@ static void SwLedBlink5(struct LED_871x *pLed) u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { + if (pLed->BlinkingLedState == RTW_LED_ON) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { + else SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } switch (pLed->CurrLedState) { case LED_BLINK_SCAN: @@ -723,8 +690,6 @@ static void SwLedBlink5(struct LED_871x *pLed) default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("SwLedBlink5 CurrLedState %d\n", pLed->CurrLedState)); } static void SwLedBlink6(struct LED_871x *pLed) @@ -732,15 +697,10 @@ static void SwLedBlink6(struct LED_871x *pLed) struct adapter *padapter = pLed->padapter; /* Change LED according to BlinkingLedState specified. */ - if (pLed->BlinkingLedState == RTW_LED_ON) { + if (pLed->BlinkingLedState == RTW_LED_ON) SwLedOn(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn on\n", pLed->BlinkTimes)); - } else { + else SwLedOff(padapter, pLed); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Blinktimes (%d): turn off\n", pLed->BlinkTimes)); - } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("<==== blink6\n")); } /* ALPHA, added by chiyoko, 20090106 */ @@ -946,8 +906,6 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ @@ -1031,7 +989,6 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; _set_timer(&(pLed->BlinkTimer), 0); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } break; case LED_CTL_STOP_WPS_FAIL: @@ -1042,7 +999,6 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; _set_timer(&(pLed->BlinkTimer), 0); - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } break; case LED_CTL_START_TO_LINK: @@ -1074,8 +1030,6 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("CurrLedState %d\n", pLed->CurrLedState)); } /* COREGA, added by chiyoko, 20090316 */ @@ -1212,8 +1166,6 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct default: break; } - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("CurrLedState %d\n", pLed->CurrLedState)); } /* Edimax-Belkin, added by chiyoko, 20090413 */ @@ -1478,8 +1430,6 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } /* Sercomm-Belkin, added by chiyoko, 20090415 */ @@ -1547,8 +1497,6 @@ SwLedControlMode5( default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("Led %d\n", pLed->CurrLedState)); } /* WNC-Corega, added by chiyoko, 20090902 */ @@ -1576,8 +1524,6 @@ SwLedControlMode6( default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, ("ledcontrol 6 Led %d\n", pLed0->CurrLedState)); } /* */ @@ -1669,8 +1615,4 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) default: break; } - - RT_TRACE(_module_rtl8712_led_c_, _drv_info_, - ("LedStrategy:%d, LedAction %d\n", - ledpriv->LedStrategy, LedAction)); } -- cgit v1.2.3 From c8ec10db41e5f95237d10d00d2a41037a370a265 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sun, 1 Aug 2021 20:04:36 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_mp_ioctl.c Remove RT_TRACE macro calls from core/rtw_mp_ioctl.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210801190437.82017-15-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 176 ++-------------------------- 1 file changed, 8 insertions(+), 168 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index b6145c7b5893..f465acfa20b8 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -22,7 +22,6 @@ int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv) } else if (poid_par_priv->type_of_oid == QUERY_OID) { *(u8 *)poid_par_priv->information_buf = Adapter->registrypriv.wireless_mode; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_info_, ("-query Wireless Mode=%d\n", Adapter->registrypriv.wireless_mode)); } else { status = NDIS_STATUS_NOT_ACCEPTED; } @@ -38,8 +37,6 @@ int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_bb_reg_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -54,10 +51,6 @@ int rtl8188eu_oid_rt_pro_write_bb_reg_hdl(struct oid_par_priv *poid_par_priv) value = pbbreg->value; - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_write_bb_reg_hdl: offset=0x%03X value=0x%08X\n", - offset, value)); - _irqlevel_changed_(&oldirql, LOWER); write_bbreg(Adapter, offset, 0xFFFFFFFF, value); _irqlevel_changed_(&oldirql, RAISE); @@ -73,8 +66,6 @@ int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_bb_reg_hdl\n")); - if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -94,10 +85,6 @@ int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv) pbbreg->value = value; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_notice_, - ("-rtl8188eu_oid_rt_pro_read_bb_reg_hdl: offset=0x%03X value:0x%08X\n", - offset, value)); - return status; } /* */ @@ -110,8 +97,6 @@ int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_write_rf_reg_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -131,10 +116,6 @@ int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv) offset = (u8)pbbreg->offset; value = pbbreg->value; - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_write_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", - path, offset, value)); - _irqlevel_changed_(&oldirql, LOWER); write_rfreg(Adapter, path, offset, value); _irqlevel_changed_(&oldirql, RAISE); @@ -151,8 +132,6 @@ int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); int status = NDIS_STATUS_SUCCESS; - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_read_rf_reg_hdl\n")); - if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -177,10 +156,6 @@ int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_notice_, - ("-rtl8188eu_oid_rt_pro_read_rf_reg_hdl: path=%d offset=0x%02X value=0x%05X\n", - path, offset, value)); - return status; } /* rtl8188eu_oid_rtl_seg_81_87_00 section end**************** */ @@ -194,9 +169,6 @@ int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_set_data_rate_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -204,8 +176,6 @@ int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv) return NDIS_STATUS_INVALID_LENGTH; ratevalue = *((u32 *)poid_par_priv->information_buf);/* 4 */ - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_set_data_rate_hdl: data rate idx=%d\n", ratevalue)); if (ratevalue >= MPT_RATE_LAST) return NDIS_STATUS_INVALID_DATA; @@ -224,8 +194,6 @@ int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_start_test_hdl\n")); - if (Adapter->registrypriv.mp_mode == 0) return NDIS_STATUS_NOT_ACCEPTED; @@ -247,8 +215,6 @@ int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv) exit: _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_pro_start_test_hdl: mp_mode=%d\n", Adapter->mppriv.mode)); - return status; } /* */ @@ -257,8 +223,6 @@ int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+Set OID_RT_PRO_STOP_TEST\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -266,8 +230,6 @@ int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv) mp_stop_test(Adapter); _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_notice_, ("-Set OID_RT_PRO_STOP_TEST\n")); - return status; } /* */ @@ -277,8 +239,6 @@ int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_p int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl\n")); - if (poid_par_priv->information_buf_len != sizeof(u32)) return NDIS_STATUS_INVALID_LENGTH; @@ -291,7 +251,6 @@ int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_p return NDIS_STATUS_NOT_ACCEPTED; Channel = *((u32 *)poid_par_priv->information_buf); - RT_TRACE(_module_mp_, _drv_notice_, ("rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl: Channel=%d\n", Channel)); if (Channel > 14) return NDIS_STATUS_NOT_ACCEPTED; Adapter->mppriv.channel = Channel; @@ -310,9 +269,6 @@ int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_info_, - ("+rtl8188eu_oid_rt_set_bandwidth_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -331,10 +287,6 @@ int rtl8188eu_oid_rt_set_bandwidth_hdl(struct oid_par_priv *poid_par_priv) SetBandwidth(padapter); _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_notice_, - ("-rtl8188eu_oid_rt_set_bandwidth_hdl: bandwidth=%d channel_offset=%d\n", - bandwidth, channel_offset)); - return status; } /* */ @@ -344,8 +296,6 @@ int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_antenna_bb_hdl\n")); - if (poid_par_priv->information_buf_len != sizeof(u32)) return NDIS_STATUS_INVALID_LENGTH; @@ -354,9 +304,6 @@ int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) Adapter->mppriv.antenna_tx = (u16)((antenna & 0xFFFF0000) >> 16); Adapter->mppriv.antenna_rx = (u16)(antenna & 0x0000FFFF); - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_set_antenna_bb_hdl: tx_ant=0x%04x rx_ant=0x%04x\n", - Adapter->mppriv.antenna_tx, Adapter->mppriv.antenna_rx)); _irqlevel_changed_(&oldirql, LOWER); SetAntenna(Adapter); @@ -375,8 +322,6 @@ int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_ int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_set_tx_power_control_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -389,10 +334,6 @@ int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_ Adapter->mppriv.txpoweridx = (u8)tx_pwr_idx; - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_set_tx_power_control_hdl: idx=0x%2x\n", - Adapter->mppriv.txpoweridx)); - _irqlevel_changed_(&oldirql, LOWER); SetTxPower(Adapter); _irqlevel_changed_(&oldirql, RAISE); @@ -432,11 +373,9 @@ int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_ status = NDIS_STATUS_NOT_ACCEPTED; return status; } - RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl.\n")); if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_pktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_alert_, ("recv_ok:%d\n", Adapter->mppriv.rx_pktcount)); } else { status = NDIS_STATUS_INVALID_LENGTH; } @@ -453,11 +392,9 @@ int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *po status = NDIS_STATUS_NOT_ACCEPTED; return status; } - RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl.\n")); if (poid_par_priv->information_buf_len == sizeof(u32)) { *(u32 *)poid_par_priv->information_buf = Adapter->mppriv.rx_crcerrpktcount; *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_alert_, ("recv_err:%d\n", Adapter->mppriv.rx_crcerrpktcount)); } else { status = NDIS_STATUS_INVALID_LENGTH; } @@ -476,7 +413,6 @@ int rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl(struct oid_par_priv *poid_par_ return status; } - RT_TRACE(_module_mp_, _drv_alert_, ("===> rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl.\n")); Adapter->mppriv.tx_pktcount = 0; return status; @@ -524,8 +460,6 @@ int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_pa int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl\n")); - if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -538,8 +472,6 @@ int rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl(struct oid_par_priv *poid_pa *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_notice_, ("-rtl8188eu_oid_rt_get_phy_rx_packet_received_hdl: recv_ok=%d\n", *(u32 *)poid_par_priv->information_buf)); - return status; } /* */ @@ -548,8 +480,6 @@ int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl\n")); - if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -562,10 +492,6 @@ int rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl(struct oid_par_priv *poid *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_get_phy_rx_packet_crc32_error_hdl: recv_err =%d\n", - *(u32 *)poid_par_priv->information_buf)); - return status; } /* rtl8188eu_oid_rtl_seg_81_80_20 section end **************** */ @@ -575,8 +501,6 @@ int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_pri int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_continuous_tx_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -606,8 +530,6 @@ int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -637,8 +559,6 @@ int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poi int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -668,8 +588,6 @@ int rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl(struct oid_par_priv *poid_par_pr int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_alert_, ("+rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -715,9 +633,6 @@ int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_info_, - ("+rtl8188eu_oid_rt_pro_read_register_hdl\n")); - if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -742,9 +657,6 @@ int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) RegRWStruct->value = rtw_read32(Adapter, offset); break; } - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_read_register_hdl: offset:0x%04X value:0x%X\n", - offset, RegRWStruct->value)); _irqlevel_changed_(&oldirql, RAISE); @@ -760,9 +672,6 @@ int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) int status = NDIS_STATUS_SUCCESS; struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_info_, - ("+rtl8188eu_oid_rt_pro_write_register_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -801,10 +710,6 @@ int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_pro_write_register_hdl: offset=0x%08X width=%d value=0x%X\n", - offset, width, value)); - return status; } /* */ @@ -876,8 +781,6 @@ int rtl8188eu_oid_rt_pro_set_data_rate_ex_hdl(struct oid_par_priv *poid_par_priv int status = NDIS_STATUS_SUCCESS; - RT_TRACE(_module_mp_, _drv_notice_, ("+OID_RT_PRO_SET_DATA_RATE_EX\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -897,8 +800,6 @@ int rtl8188eu_oid_rt_get_thermal_meter_hdl(struct oid_par_priv *poid_par_priv) u8 thermal = 0; struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_get_thermal_meter_hdl\n")); - if (poid_par_priv->type_of_oid != QUERY_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -933,8 +834,6 @@ int rtl8188eu_oid_rt_pro_set_power_tracking_hdl(struct oid_par_priv *poid_par_pr u8 enable; enable = *(u8 *)poid_par_priv->information_buf; - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_set_power_tracking_hdl: enable =%d\n", enable)); SetPowerTracking(Adapter, enable); } else { @@ -1015,24 +914,16 @@ int rtl8188eu_oid_rt_pro_read_efuse_hdl(struct oid_par_priv *poid_par_priv) cnts = pefuse->cnts; data = pefuse->data; - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_read_efuse_hd: buf_len=%d addr=%d cnts=%d\n", - poid_par_priv->information_buf_len, addr, cnts)); - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) { - RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: parameter error!\n")); + if ((addr + cnts) > max_available_size) return NDIS_STATUS_NOT_ACCEPTED; - } _irqlevel_changed_(&oldirql, LOWER); - if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) { - RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_read_efuse_hdl: rtw_efuse_access FAIL!\n")); + if (rtw_efuse_access(Adapter, false, addr, cnts, data) == _FAIL) status = NDIS_STATUS_FAILURE; - } else { + else *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - } _irqlevel_changed_(&oldirql, RAISE); return status; @@ -1054,16 +945,10 @@ int rtl8188eu_oid_rt_pro_write_efuse_hdl(struct oid_par_priv *poid_par_priv) cnts = pefuse->cnts; data = pefuse->data; - RT_TRACE(_module_mp_, _drv_notice_, - ("+rtl8188eu_oid_rt_pro_write_efuse_hdl: buf_len=%d addr=0x%04x cnts=%d\n", - poid_par_priv->information_buf_len, addr, cnts)); - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr + cnts) > max_available_size) { - RT_TRACE(_module_mp_, _drv_err_, ("!rtl8188eu_oid_rt_pro_write_efuse_hdl: parameter error")); + if ((addr + cnts) > max_available_size) return NDIS_STATUS_NOT_ACCEPTED; - } _irqlevel_changed_(&oldirql, LOWER); if (rtw_efuse_access(Adapter, true, addr, cnts, data) == _FAIL) @@ -1089,10 +974,6 @@ int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) _irqlevel_changed_(&oldirql, LOWER); if (poid_par_priv->type_of_oid == QUERY_OID) { - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Read offset=0x%x\n",\ - ppgpkt->offset)); - Efuse_PowerSwitch(Adapter, false, true); if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false) == true) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; @@ -1100,10 +981,6 @@ int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) status = NDIS_STATUS_FAILURE; Efuse_PowerSwitch(Adapter, false, false); } else { - RT_TRACE(_module_mp_, _drv_notice_, - ("rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: Write offset=0x%x word_en=0x%x\n",\ - ppgpkt->offset, ppgpkt->word_en)); - Efuse_PowerSwitch(Adapter, true, true); if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false) == true) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; @@ -1114,9 +991,6 @@ int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl: status=0x%08X\n", status)); - return status; } /* */ @@ -1160,10 +1034,6 @@ int rtl8188eu_oid_rt_get_efuse_max_size_hdl(struct oid_par_priv *poid_par_priv) *(u32 *)poid_par_priv->information_buf = efuse_GetMaxSize(Adapter); *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_get_efuse_max_size_hdl: size=%d status=0x%08X\n", - *(int *)poid_par_priv->information_buf, status)); - return status; } /* */ @@ -1171,15 +1041,11 @@ int rtl8188eu_oid_rt_pro_efuse_hdl(struct oid_par_priv *poid_par_priv) { int status; - RT_TRACE(_module_mp_, _drv_info_, ("+rtl8188eu_oid_rt_pro_efuse_hdl\n")); - if (poid_par_priv->type_of_oid == QUERY_OID) status = rtl8188eu_oid_rt_pro_read_efuse_hdl(poid_par_priv); else status = rtl8188eu_oid_rt_pro_write_efuse_hdl(poid_par_priv); - RT_TRACE(_module_mp_, _drv_info_, ("-rtl8188eu_oid_rt_pro_efuse_hdl: status=0x%08X\n", status)); - return status; } /* */ @@ -1190,8 +1056,6 @@ int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) struct adapter *Adapter = (struct adapter *)(poid_par_priv->adapter_context); u16 maplen = 0; - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_pro_efuse_map_hdl\n")); - EFUSE_GetEfuseDefinition(Adapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&maplen, false); *poid_par_priv->bytes_rw = 0; @@ -1204,35 +1068,20 @@ int rtl8188eu_oid_rt_pro_efuse_map_hdl(struct oid_par_priv *poid_par_priv) _irqlevel_changed_(&oldirql, LOWER); if (poid_par_priv->type_of_oid == QUERY_OID) { - RT_TRACE(_module_mp_, _drv_info_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ\n")); - - if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) { + if (rtw_efuse_map_read(Adapter, 0, maplen, data) == _SUCCESS) *poid_par_priv->bytes_rw = maplen; - } else { - RT_TRACE(_module_mp_, _drv_err_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: READ fail\n")); + else status = NDIS_STATUS_FAILURE; - } } else { /* SET_OID */ - RT_TRACE(_module_mp_, _drv_info_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE\n")); - - if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) { + if (rtw_efuse_map_write(Adapter, 0, maplen, data) == _SUCCESS) *poid_par_priv->bytes_rw = maplen; - } else { - RT_TRACE(_module_mp_, _drv_err_, - ("rtl8188eu_oid_rt_pro_efuse_map_hdl: WRITE fail\n")); + else status = NDIS_STATUS_FAILURE; - } } _irqlevel_changed_(&oldirql, RAISE); - RT_TRACE(_module_mp_, _drv_info_, - ("-rtl8188eu_oid_rt_pro_efuse_map_hdl: status=0x%08X\n", status)); - return status; } @@ -1247,8 +1096,6 @@ int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) u8 rx_pkt_type; int status = NDIS_STATUS_SUCCESS; - RT_TRACE(_module_mp_, _drv_notice_, ("+rtl8188eu_oid_rt_set_rx_packet_type_hdl\n")); - if (poid_par_priv->type_of_oid != SET_OID) return NDIS_STATUS_NOT_ACCEPTED; @@ -1257,8 +1104,6 @@ int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */ - RT_TRACE(_module_mp_, _drv_info_, ("rx_pkt_type: %x\n", rx_pkt_type)); - return status; } @@ -1279,8 +1124,6 @@ int rtl8188eu_mp_ioctl_xmit_packet_hdl(struct oid_par_priv *poid_par_priv) struct mp_priv *pmp_priv; struct pkt_attrib *pattrib; - RT_TRACE(_module_mp_, _drv_notice_, ("+%s\n", __func__)); - pparm = (struct mp_xmit_parm *)poid_par_priv->information_buf; padapter = (struct adapter *)poid_par_priv->adapter_context; pmp_priv = &padapter->mppriv; @@ -1317,9 +1160,6 @@ int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv) return status; } - RT_TRACE(_module_mp_, _drv_info_, - ("\n ===> Setrtl8188eu_oid_rt_set_power_down_hdl.\n")); - _irqlevel_changed_(&oldirql, LOWER); /* CALL the power_down function */ -- cgit v1.2.3 From 3d0d19b174a28d98962fc271953f7e6d526b69e4 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Thu, 5 Aug 2021 12:43:38 +0200 Subject: Revert "staging: r8188eu: Fix different base types in assignments and parameters" This reverts commit 56febcc2595e2bf2546c5bb4c35740ce883771a2. It's not correct and instead of fixing it up, let's just revert it for now. Reported-by: Dan Carpenter Cc: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210802203020.9679-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 46 +++++++------------------------ 1 file changed, 10 insertions(+), 36 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 89fce9a5f783..27c8ec3b7d62 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -71,7 +71,7 @@ static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *t struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; - data_len = be16_to_cpu(tag->tag_len) + TAG_HDR_LEN; + data_len = tag->tag_len + TAG_HDR_LEN; if (skb_tailroom(skb) < data_len) { _DEBUG_ERR("skb_tailroom() failed in add SID tag!\n"); return -1; @@ -134,68 +134,42 @@ static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr } static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - __be32 *ipxNetAddr, unsigned char *ipxNodeAddr) + unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) { - union { - unsigned int f0; - unsigned char f1[IPX_NODE_LEN]; - } addr; - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_IPX; - addr.f0 = be32_to_cpu(*ipxNetAddr); - memcpy(networkAddr+1, addr.f1, 4); + memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); memcpy(networkAddr+5, ipxNodeAddr, 6); } static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - __be32 *ipxNetAddr, __be16 *ipxSocketAddr) + unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) { - union { - unsigned int f0; - unsigned char f1[4]; - } addr; - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_IPX; - addr.f0 = be32_to_cpu(*ipxNetAddr); - memcpy(networkAddr+1, addr.f1, 4); - addr.f0 ^= addr.f0; - addr.f0 = be16_to_cpu(*ipxSocketAddr); - memcpy(networkAddr+5, addr.f1, 2); + memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); } static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, - __be16 *network, unsigned char *node) + unsigned short *network, unsigned char *node) { - union { - unsigned short f0; - unsigned char f1[2]; - } addr; - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_APPLE; - addr.f0 = be16_to_cpu(*network); - memcpy(networkAddr+1, addr.f1, 2); + memcpy(networkAddr+1, (unsigned char *)network, 2); networkAddr[3] = *node; } static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, - unsigned char *ac_mac, __be16 *sid) + unsigned char *ac_mac, unsigned short *sid) { - union { - unsigned short f0; - unsigned char f1[2]; - } addr; - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_PPPOE; - addr.f0 = be16_to_cpu(*sid); - memcpy(networkAddr+1, addr.f1, 2); + memcpy(networkAddr+1, (unsigned char *)sid, 2); memcpy(networkAddr+3, (unsigned char *)ac_mac, 6); } -- cgit v1.2.3 From b398ff88aa362e6fb348b2f39f2bf1b9a1f42d1e Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 1 Aug 2021 23:03:53 +0200 Subject: staging: r8188eu: remove return from void functions Remove return from void functions to clear checkpatch warnings. WARNING: void function return statements are not generally useful Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210801210354.25218-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 7 ------- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 30 ---------------------------- drivers/staging/r8188eu/core/rtw_p2p.c | 2 -- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 1 - drivers/staging/r8188eu/core/rtw_security.c | 2 -- drivers/staging/r8188eu/core/rtw_wlan_util.c | 4 ---- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 1 - drivers/staging/r8188eu/hal/rtl8188e_dm.c | 1 - drivers/staging/r8188eu/hal/rtl8188e_mp.c | 2 -- drivers/staging/r8188eu/os_dep/usb_intf.c | 2 -- 10 files changed, 52 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 298849214b97..007b9d510168 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -326,8 +326,6 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ - - return; } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -698,10 +696,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * /* TODO: Perry: For Power Management */ void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); - - return; } void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) @@ -748,8 +743,6 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) exit: spin_unlock_bh(&pmlmepriv->lock); - - return; } void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index c42bdbd09464..72b0774ffa83 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -2147,8 +2147,6 @@ void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame_body, uint len, u8 result) @@ -2512,7 +2510,6 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - return; } static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) @@ -2675,7 +2672,6 @@ static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, (unsigned char *)p2pie, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - return; } void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) @@ -2923,8 +2919,6 @@ void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialogToken, u8 status_code) @@ -3115,8 +3109,6 @@ void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialo pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidlen, u8 *pdev_raddr) @@ -3212,8 +3204,6 @@ void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidle pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profileinfo) @@ -3478,8 +3468,6 @@ void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) @@ -4811,8 +4799,6 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u8 *da, int wait_ack) @@ -5082,8 +5068,6 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short rtw_wep_encrypt(padapter, (u8 *)pmgntframe); DBG_88E("%s\n", __func__); dump_mgntframe(padapter, pmgntframe); - - return; } void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_info *pstat, int pkt_type) @@ -5551,8 +5535,6 @@ exit: rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); else rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); - - return; } /* when wait_ack is ture, this function shoule be called at process context */ @@ -6468,7 +6450,6 @@ void site_survey(struct adapter *padapter) issue_action_BSSCoexistPacket(padapter); } } - return; } /* collect bss info from Beacon and Probe request/response frames. */ @@ -7023,8 +7004,6 @@ void report_survey_event(struct adapter *padapter, struct recv_frame *precv_fram rtw_enqueue_cmd(pcmdpriv, pcmd_obj); pmlmeext->sitesurvey_res.bss_cnt++; - - return; } void report_surveydone_event(struct adapter *padapter) @@ -7068,8 +7047,6 @@ void report_surveydone_event(struct adapter *padapter) DBG_88E("survey done event(%x)\n", psurveydone_evt->bss_cnt); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_join_res(struct adapter *padapter, int res) @@ -7118,8 +7095,6 @@ void report_join_res(struct adapter *padapter, int res) rtw_joinbss_event_prehandle(padapter, (u8 *)&pjoinbss_evt->network); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) @@ -7174,8 +7149,6 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi DBG_88E("report_del_sta_event: delete STA, mac_id =%d\n", mac_id); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int cam_idx) @@ -7220,8 +7193,6 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int DBG_88E("report_add_sta_event: add STA\n"); rtw_enqueue_cmd(pcmdpriv, pcmd_obj); - - return; } /**************************************************************************** @@ -7662,7 +7633,6 @@ void link_timer_hdl(struct adapter *padapter) issue_assocreq(padapter); set_link_timer(pmlmeext, REASSOC_TO); } - return; } void addba_timer_hdl(struct sta_info *psta) diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index ce30161535c1..c19360ea09a4 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -312,8 +312,6 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, pattrib->last_txcmdsz = pattrib->pktlen; dump_mgntframe(padapter, pmgntframe); - - return; } static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 status, u8 dialogToken) diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index fa0d8bef11ca..2c029f85d63d 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -189,7 +189,6 @@ void rtw_ps_processor(struct adapter *padapter) exit: rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); pwrpriv->ps_processing = false; - return; } static void pwr_state_check_handler(struct timer_list *t) diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 66c730a5d754..df8107a0f5f2 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -180,8 +180,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) &crc, &payload[length-4])); } } - - return; } /* 3 ===== TKIP related ===== */ diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 8603a297b929..c4e2726f3a19 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -648,8 +648,6 @@ void WMMOnAssocRsp(struct adapter *padapter) pxmitpriv->wmm_para_seq[i] = inx[i]; DBG_88E("wmm_para_seq(%d): %d\n", i, pxmitpriv->wmm_para_seq[i]); } - - return; } static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) @@ -777,7 +775,6 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) else pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= MCS_rate_2R[i]; } - return; } void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) @@ -798,7 +795,6 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) pmlmeinfo->HT_info_enable = 1; memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); - return; } void HTOnAssocRsp(struct adapter *padapter) diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 62219a908097..03fe29e16f1d 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -345,5 +345,4 @@ bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) { - return; } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index 0e264c39d636..b5f42127a751 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -182,7 +182,6 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) skip_dm: /* Check GPIO to determine current RF on/off and Pbc status. */ /* Check Hardware Radio ON/OFF or not */ - return; } void rtl8188e_init_dm_priv(struct adapter *Adapter) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index 510906cc6007..a7893aa469ac 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -67,8 +67,6 @@ void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter) pmp->MptCtx.backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0); PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD); PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD); - - return; } /*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/ diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index bc7f4bd7ce0b..ffa2f150f937 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -808,8 +808,6 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); DBG_88E("-r871xu_dev_remove, done\n"); - - return; } static int __init rtw_drv_entry(void) -- cgit v1.2.3 From d37b3b54f133f282683e59145ee2a906719dee2f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 1 Aug 2021 23:03:54 +0200 Subject: staging: r8188eu: remove empty function odm_DynamicPrimaryCCA() Function odm_DynamicPrimaryCCA() does nothing, remove it. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210801210354.25218-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm.c | 1 - drivers/staging/r8188eu/hal/odm_RTL8188E.c | 4 ---- drivers/staging/r8188eu/include/odm_RTL8188E.h | 2 -- 3 files changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 0bc836311036..08ec1e18b3f0 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -211,7 +211,6 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) odm_RefreshRateAdaptiveMask(pDM_Odm); odm_DynamicBBPowerSaving(pDM_Odm); - odm_DynamicPrimaryCCA(pDM_Odm); if ((pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) || (pDM_Odm->AntDivType == CGCS_RX_HW_ANTDIV) || (pDM_Odm->AntDivType == CG_TRX_SMART_ANTDIV)) diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 03fe29e16f1d..792284eac01f 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -342,7 +342,3 @@ bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) return PrimaryCCA->DupRTS_flag; } - -void odm_DynamicPrimaryCCA(struct odm_dm_struct *dm_odm) -{ -} diff --git a/drivers/staging/r8188eu/include/odm_RTL8188E.h b/drivers/staging/r8188eu/include/odm_RTL8188E.h index d6718186f2d6..776a8a6dab68 100644 --- a/drivers/staging/r8188eu/include/odm_RTL8188E.h +++ b/drivers/staging/r8188eu/include/odm_RTL8188E.h @@ -35,6 +35,4 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *pDM_Odm); bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); -void odm_DynamicPrimaryCCA(struct odm_dm_struct *pDM_Odm); - #endif -- cgit v1.2.3 From fd03e7f784a19235bd8114da9de40708fa35279f Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Mon, 2 Aug 2021 03:00:56 +0200 Subject: staging: r8188eu: Remove set but unused variables Remove set but unused variables. Issues detected by sparse. Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210802010056.20543-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 4 ---- drivers/staging/r8188eu/os_dep/osdep_service.c | 3 +-- 2 files changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 007b9d510168..850dbb3f1cc7 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -748,7 +748,6 @@ exit: void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - struct mlme_ext_priv *pmlmeext; u8 timer_cancelled = 0; spin_lock_bh(&pmlmepriv->lock); @@ -843,9 +842,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0); rtw_os_xmit_schedule(adapter); - - pmlmeext = &adapter->mlmeextpriv; - } void rtw_dummy_event_callback(struct adapter *adapter, u8 *pbuf) diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 71d4fa25db86..3c88b36c19f8 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -397,7 +397,7 @@ void rtw_buf_free(u8 **buf, u32 *buf_len) void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) { - u32 ori_len = 0, dup_len = 0; + u32 dup_len = 0; u8 *ori = NULL; u8 *dup = NULL; @@ -416,7 +416,6 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) keep_ori: ori = *buf; - ori_len = *buf_len; /* replace buf with dup */ *buf_len = 0; -- cgit v1.2.3 From 85143bdc731b543b4a184f63cdf42f557fb66f77 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Mon, 2 Aug 2021 03:10:25 +0200 Subject: staging: r8188eu: include: Remove unused const definitions Remove unused const definitions. Issues detected by sparse. Remove the '#ifdef' and '#endif' preprocessor directives that surround them. Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210802011025.23887-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_mp_ioctl.h | 77 -------------------------- 1 file changed, 77 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h index e856fd0ad036..0376ddbf6011 100644 --- a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h @@ -135,83 +135,6 @@ int rtl8188eu_oid_rt_set_power_down_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_get_power_mode_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_trigger_gpio_hdl(struct oid_par_priv *poid_par_priv); -#ifdef _RTW_MP_IOCTL_C_ - -static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_00[] = { - {1, &oid_null_function}, /* 0x00 OID_RT_PRO_RESET_DUT */ - {1, &rtl8188eu_oid_rt_pro_set_data_rate_hdl}, /* 0x01 */ - {1, &rtl8188eu_oid_rt_pro_start_test_hdl}, /* 0x02 */ - {1, &rtl8188eu_oid_rt_pro_stop_test_hdl}, /* 0x03 */ - {1, &oid_null_function}, /* 0x04 OID_RT_PRO_SET_PREAMBLE */ - {1, &oid_null_function}, /* 0x05 OID_RT_PRO_SET_SCRAMBLER */ - {1, &oid_null_function}, /* 0x06 OID_RT_PRO_SET_FILTER_BB */ - {1, &oid_null_function},/* 0x07 OID_RT_PRO_SET_MANUAL_DIVERSITY_BB */ - {1, &rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl}, /* 0x08 */ - {1, &oid_null_function},/* 0x09 OID_RT_PRO_SET_SLEEP_MODE_DIRECT_CALL */ - {1, &oid_null_function},/* 0x0A OID_RT_PRO_SET_WAKE_MODE_DIRECT_CALL */ - {1, &rtl8188eu_oid_rt_pro_set_continuous_tx_hdl}, /* 0x0B OID_RT_PRO_SET_TX_CONTINUOUS_DIRECT_CALL */ - {1, &rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl},/* 0x0C OID_RT_PRO_SET_SINGLE_CARRIER_TX_CONTINUOUS */ - {1, &oid_null_function}, /* 0x0D OID_RT_PRO_SET_TX_ANTENNA_BB */ - {1, &rtl8188eu_oid_rt_pro_set_antenna_bb_hdl}, /* 0x0E */ - {1, &oid_null_function}, /* 0x0F OID_RT_PRO_SET_CR_SCRAMBLER */ - {1, &oid_null_function}, /* 0x10 OID_RT_PRO_SET_CR_NEW_FILTER */ - {1, &rtl8188eu_oid_rt_pro_set_tx_power_control_hdl},/* 0x11 OID_RT_PRO_SET_TX_POWER_CONTROL */ - {1, &oid_null_function}, /* 0x12 OID_RT_PRO_SET_CR_TX_CONFIG */ - {1, &oid_null_function}, /* 0x13 OID_RT_PRO_GET_TX_POWER_CONTROL */ - {1, &oid_null_function}, /* 0x14 OID_RT_PRO_GET_CR_SIGNAL_QUALITY */ - {1, &oid_null_function}, /* 0x15 OID_RT_PRO_SET_CR_SETPOINT */ - {1, &oid_null_function}, /* 0x16 OID_RT_PRO_SET_INTEGRATOR */ - {1, &oid_null_function}, /* 0x17 OID_RT_PRO_SET_SIGNAL_QUALITY */ - {1, &oid_null_function}, /* 0x18 OID_RT_PRO_GET_INTEGRATOR */ - {1, &oid_null_function}, /* 0x19 OID_RT_PRO_GET_SIGNAL_QUALITY */ - {1, &oid_null_function}, /* 0x1A OID_RT_PRO_QUERY_EEPROM_TYPE */ - {1, &oid_null_function}, /* 0x1B OID_RT_PRO_WRITE_MAC_ADDRESS */ - {1, &oid_null_function}, /* 0x1C OID_RT_PRO_READ_MAC_ADDRESS */ - {1, &oid_null_function}, /* 0x1D OID_RT_PRO_WRITE_CIS_DATA */ - {1, &oid_null_function}, /* 0x1E OID_RT_PRO_READ_CIS_DATA */ - {1, &oid_null_function} /* 0x1F OID_RT_PRO_WRITE_POWER_CONTROL */ -}; - -static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_20[] = { - {1, &oid_null_function}, /* 0x20 OID_RT_PRO_READ_POWER_CONTROL */ - {1, &oid_null_function}, /* 0x21 OID_RT_PRO_WRITE_EEPROM */ - {1, &oid_null_function}, /* 0x22 OID_RT_PRO_READ_EEPROM */ - {1, &rtl8188eu_oid_rt_pro_reset_tx_packet_sent_hdl}, /* 0x23 */ - {1, &rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl}, /* 0x24 */ - {1, &rtl8188eu_oid_rt_pro_reset_rx_packet_received_hdl}, /* 0x25 */ - {1, &rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl}, /* 0x26 */ - {1, &rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl}, /* 0x27 */ - {1, &oid_null_function}, /* 0x28 OID_RT_PRO_QUERY_CURRENT_ADDRESS */ - {1, &oid_null_function}, /* 0x29 OID_RT_PRO_QUERY_PERMANENT_ADDRESS */ - {1, &oid_null_function}, /* 0x2A OID_RT_PRO_SET_PHILIPS_RF_PARAMETERS */ - {1, &rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl},/* 0x2B OID_RT_PRO_SET_CARRIER_SUPPRESSION_TX */ - {1, &oid_null_function}, /* 0x2C OID_RT_PRO_RECEIVE_PACKET */ - {1, &oid_null_function}, /* 0x2D OID_RT_PRO_WRITE_EEPROM_BYTE */ - {1, &oid_null_function}, /* 0x2E OID_RT_PRO_READ_EEPROM_BYTE */ - {1, &rtl8188eu_oid_rt_pro_set_modulation_hdl} /* 0x2F */ -}; - -static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_40[] = { - {1, &oid_null_function}, /* 0x40 */ - {1, &oid_null_function}, /* 0x41 */ - {1, &oid_null_function}, /* 0x42 */ - {1, &rtl8188eu_oid_rt_pro_set_single_tone_tx_hdl}, /* 0x43 */ - {1, &oid_null_function}, /* 0x44 */ - {1, &oid_null_function} /* 0x45 */ -}; - -static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_80_80[] = { - {1, &oid_null_function}, /* 0x80 OID_RT_DRIVER_OPTION */ - {1, &oid_null_function}, /* 0x81 OID_RT_RF_OFF */ - {1, &oid_null_function} /* 0x82 OID_RT_AUTH_STATUS */ -}; - -static const struct oid_obj_priv rtl8188eu_oid_rtl_seg_81_85[] = { - {1, &rtl8188eu_oid_rt_wireless_mode_hdl} /* 0x00 OID_RT_WIRELESS_MODE */ -}; - -#endif /* _RTL871X_MP_IOCTL_C_ */ - struct rwreg_param { u32 offset; u32 width; -- cgit v1.2.3 From 8cc35e0d4d3f4d84744a50eb8d950b73414045c7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 2 Aug 2021 14:27:18 -0500 Subject: staging: r8188eu: Remove wrappers for atomic operations These wrappers were useful when this driver had the hooks for Windows, but are no longer needed. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210802192721.23110-4-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 14 +++---- drivers/staging/r8188eu/include/drv_types.h | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 14 ------- drivers/staging/r8188eu/include/rtw_cmd.h | 2 +- drivers/staging/r8188eu/include/rtw_mlme_ext.h | 2 +- drivers/staging/r8188eu/include/usb_ops.h | 4 +- drivers/staging/r8188eu/os_dep/osdep_service.c | 50 ------------------------- 8 files changed, 13 insertions(+), 77 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index c432cc6e1b4d..4ac76ca6e383 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -64,7 +64,7 @@ int _rtw_init_evt_priv(struct evt_priv *pevtpriv) int res = _SUCCESS; /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ - ATOMIC_SET(&pevtpriv->event_seq, 0); + atomic_set(&pevtpriv->event_seq, 0); pevtpriv->evt_done_cnt = 0; _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 72b0774ffa83..1ca356eecd1c 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -204,7 +204,7 @@ static void init_mlme_ext_priv_value(struct adapter *padapter) _12M_RATE_, _24M_RATE_, 0xff, }; - ATOMIC_SET(&pmlmeext->event_seq, 0); + atomic_set(&pmlmeext->event_seq, 0); pmlmeext->mgnt_seq = 0;/* reset to zero when disconnect at client mode */ pmlmeext->cur_channel = padapter->registrypriv.channel; @@ -6989,7 +6989,7 @@ void report_survey_event(struct adapter *padapter, struct recv_frame *precv_fram pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct survey_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_Survey); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); psurvey_evt = (struct survey_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); @@ -7039,7 +7039,7 @@ void report_surveydone_event(struct adapter *padapter) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct surveydone_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_SurveyDone); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); psurveydone_evt = (struct surveydone_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); psurveydone_evt->bss_cnt = pmlmeext->sitesurvey_res.bss_cnt; @@ -7083,7 +7083,7 @@ void report_join_res(struct adapter *padapter, int res) pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct joinbss_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_JoinBss); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); @@ -7132,7 +7132,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stadel_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_DelSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -7184,7 +7184,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int pc2h_evt_hdr = (struct C2HEvent_Header *)(pevtcmd); pc2h_evt_hdr->len = sizeof(struct stassoc_event); pc2h_evt_hdr->ID = GEN_EVT_CODE(_AddSTA); - pc2h_evt_hdr->seq = ATOMIC_INC_RETURN(&pmlmeext->event_seq); + pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); @@ -8214,7 +8214,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) goto _abort_event_; } - ATOMIC_INC(&pevt_priv->event_seq); + atomic_inc(&pevt_priv->event_seq); peventbuf += 2; diff --git a/drivers/staging/r8188eu/include/drv_types.h b/drivers/staging/r8188eu/include/drv_types.h index 8cefb5c288f3..04f4224c11de 100644 --- a/drivers/staging/r8188eu/include/drv_types.h +++ b/drivers/staging/r8188eu/include/drv_types.h @@ -178,7 +178,7 @@ struct dvobj_priv { struct usb_interface *pusbintf; struct usb_device *pusbdev; - ATOMIC_T continual_urb_error; + atomic_t continual_urb_error; u8 signal_strength; }; diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index ac0bd5cd0f82..bea7091e3a80 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -335,20 +335,6 @@ void rtw_suspend_lock_uninit(void); void rtw_lock_suspend(void); void rtw_unlock_suspend(void); -/* Atomic integer operations */ -#define ATOMIC_T atomic_t - -void ATOMIC_SET(ATOMIC_T *v, int i); -int ATOMIC_READ(ATOMIC_T *v); -void ATOMIC_ADD(ATOMIC_T *v, int i); -void ATOMIC_SUB(ATOMIC_T *v, int i); -void ATOMIC_INC(ATOMIC_T *v); -void ATOMIC_DEC(ATOMIC_T *v); -int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i); -int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i); -int ATOMIC_INC_RETURN(ATOMIC_T *v); -int ATOMIC_DEC_RETURN(ATOMIC_T *v); - struct rtw_netdev_priv_indicator { void *priv; u32 sizeof_priv; diff --git a/drivers/staging/r8188eu/include/rtw_cmd.h b/drivers/staging/r8188eu/include/rtw_cmd.h index 0f64b72bb5de..c14d9052b997 100644 --- a/drivers/staging/r8188eu/include/rtw_cmd.h +++ b/drivers/staging/r8188eu/include/rtw_cmd.h @@ -53,7 +53,7 @@ struct evt_priv { bool c2h_wk_alive; struct rtw_cbuf *c2h_queue; #define C2H_QUEUE_MAX_LEN 10 - ATOMIC_T event_seq; + atomic_t event_seq; u8 *evt_buf; /* shall be non-paged, and 4 bytes aligned */ u8 *evt_allocated_buf; u32 evt_done_cnt; diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index b9c76f04445c..88d4ec073723 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -382,7 +382,7 @@ struct p2p_oper_class_map { struct mlme_ext_priv { struct adapter *padapter; u8 mlmeext_init; - ATOMIC_T event_seq; + atomic_t event_seq; u16 mgnt_seq; unsigned char cur_channel; diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index 273bc2705558..5d290199e37c 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -38,7 +38,7 @@ static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj) { int ret = false; int value; - value = ATOMIC_INC_RETURN(&dvobj->continual_urb_error); + value = atomic_inc_return(&dvobj->continual_urb_error); if (value > MAX_CONTINUAL_URB_ERR) { DBG_88E("[dvobj:%p][ERROR] continual_urb_error:%d > %d\n", dvobj, value, MAX_CONTINUAL_URB_ERR); @@ -52,7 +52,7 @@ static inline int rtw_inc_and_chk_continual_urb_error(struct dvobj_priv *dvobj) */ static inline void rtw_reset_continual_urb_error(struct dvobj_priv *dvobj) { - ATOMIC_SET(&dvobj->continual_urb_error, 0); + atomic_set(&dvobj->continual_urb_error, 0); } #define USB_HIGH_SPEED_BULK_SIZE 512 diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 3c88b36c19f8..a75c681dd4af 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -207,56 +207,6 @@ inline void rtw_unlock_suspend(void) { } -inline void ATOMIC_SET(ATOMIC_T *v, int i) -{ - atomic_set(v, i); -} - -inline int ATOMIC_READ(ATOMIC_T *v) -{ - return atomic_read(v); -} - -inline void ATOMIC_ADD(ATOMIC_T *v, int i) -{ - atomic_add(i, v); -} - -inline void ATOMIC_SUB(ATOMIC_T *v, int i) -{ - atomic_sub(i, v); -} - -inline void ATOMIC_INC(ATOMIC_T *v) -{ - atomic_inc(v); -} - -inline void ATOMIC_DEC(ATOMIC_T *v) -{ - atomic_dec(v); -} - -inline int ATOMIC_ADD_RETURN(ATOMIC_T *v, int i) -{ - return atomic_add_return(i, v); -} - -inline int ATOMIC_SUB_RETURN(ATOMIC_T *v, int i) -{ - return atomic_sub_return(i, v); -} - -inline int ATOMIC_INC_RETURN(ATOMIC_T *v) -{ - return atomic_inc_return(v); -} - -inline int ATOMIC_DEC_RETURN(ATOMIC_T *v) -{ - return atomic_dec_return(v); -} - static const struct device_type wlan_type = { .name = "wlan", }; -- cgit v1.2.3 From 5b283ad4c8daeb8f1ddb2324ef0a146fe97bc900 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Mon, 2 Aug 2021 14:27:19 -0500 Subject: staging: r8188eu: Remove 4 empty routines from os_sep/service.c Routines rtw_suspend_lock_init(), rtw_suspend_lock_uninit(), rtw_lock_suspend(), and rtw_unlock_suspend() do not conti=ain any code. Simplify by removing them. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210802192721.23110-5-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 5 ----- drivers/staging/r8188eu/os_dep/osdep_service.c | 16 ---------------- drivers/staging/r8188eu/os_dep/rtw_android.c | 2 -- drivers/staging/r8188eu/os_dep/usb_intf.c | 4 ---- 4 files changed, 27 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index bea7091e3a80..376c9018c7e8 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -330,11 +330,6 @@ static inline u32 bitshift(u32 bitmask) /* limitation of path length */ #define PATH_LENGTH_MAX PATH_MAX -void rtw_suspend_lock_init(void); -void rtw_suspend_lock_uninit(void); -void rtw_lock_suspend(void); -void rtw_unlock_suspend(void); - struct rtw_netdev_priv_indicator { void *priv; u32 sizeof_priv; diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index a75c681dd4af..2e921460e99e 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -191,22 +191,6 @@ void rtw_yield_os(void) #define RTW_SUSPEND_LOCK_NAME "rtw_wifi" -inline void rtw_suspend_lock_init(void) -{ -} - -inline void rtw_suspend_lock_uninit(void) -{ -} - -inline void rtw_lock_suspend(void) -{ -} - -inline void rtw_unlock_suspend(void) -{ -} - static const struct device_type wlan_type = { .name = "wlan", }; diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index 2b9e719e2a51..b55c86131dc7 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -147,7 +147,6 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) int bytes_written = 0; struct android_wifi_priv_cmd priv_cmd; - rtw_lock_suspend(); if (!ifr->ifr_data) { ret = -EINVAL; goto exit; @@ -279,7 +278,6 @@ response: ret = bytes_written; } exit: - rtw_unlock_suspend(); kfree(command); return ret; } diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index ffa2f150f937..fffc2c0d9efb 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -816,8 +816,6 @@ static int __init rtw_drv_entry(void) DBG_88E(DRV_NAME " driver version=%s\n", DRIVERVERSION); - rtw_suspend_lock_init(); - _rtw_mutex_init(&usb_drv->hw_init_mutex); usb_drv->drv_registered = true; @@ -829,8 +827,6 @@ static void __exit rtw_drv_halt(void) RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n")); DBG_88E("+rtw_drv_halt\n"); - rtw_suspend_lock_uninit(); - usb_drv->drv_registered = false; usb_deregister(&usb_drv->usbdrv); -- cgit v1.2.3 From b90a6bf384cb0b31278e93ef54ef95682c234806 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 3 Aug 2021 08:52:20 -0500 Subject: staging: r8188eu: Remove rtw_division64() This wrapper is never used. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210803135223.12543-8-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 6 ------ 2 files changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 376c9018c7e8..ea7c503df7c1 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -354,7 +354,6 @@ void rtw_free_netdev(struct net_device *netdev); #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) u64 rtw_modular64(u64 x, u64 y); -u64 rtw_division64(u64 x, u64 y); /* Macros for handling unaligned memory accesses */ diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 2e921460e99e..a2b691fe94d7 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -316,12 +316,6 @@ u64 rtw_modular64(u64 x, u64 y) return do_div(x, y); } -u64 rtw_division64(u64 x, u64 y) -{ - do_div(x, y); - return x; -} - void rtw_buf_free(u8 **buf, u32 *buf_len) { *buf_len = 0; -- cgit v1.2.3 From e2530e0b7ded1bc15c1f778b85d3db9981181427 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 3 Aug 2021 08:52:21 -0500 Subject: staging: r8188eu: Remove wrapper around do_div Wrapper routine rtw_modular64() contains only a call to do_div() and is used once in the code. Remove the wrapper. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210803135223.12543-9-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_halinit.c | 3 ++- drivers/staging/r8188eu/include/osdep_service.h | 2 -- drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 3 files changed, 2 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 788ebb378879..919bcbd9f318 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -1453,7 +1453,8 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - tsf = pmlmeext->TSFValue - rtw_modular64(pmlmeext->TSFValue, (pmlmeinfo->bcn_interval*1024)) - 1024; /* us */ + tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, + pmlmeinfo->bcn_interval * 1024) - 1024; /* us */ if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) StopTxBeacon(Adapter); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index ea7c503df7c1..0be9885b184e 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -353,8 +353,6 @@ void rtw_free_netdev(struct net_device *netdev); #define rtw_signal_process(pid, sig) kill_pid(find_vpid((pid)),(sig), 1) -u64 rtw_modular64(u64 x, u64 y); - /* Macros for handling unaligned memory accesses */ #define RTW_GET_BE16(a) ((u16) (((a)[0] << 8) | (a)[1])) diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index a2b691fe94d7..250d499e4d4a 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -311,11 +311,6 @@ error: return -1; } -u64 rtw_modular64(u64 x, u64 y) -{ - return do_div(x, y); -} - void rtw_buf_free(u8 **buf, u32 *buf_len) { *buf_len = 0; -- cgit v1.2.3 From 496fd4e78afd7a1802cde83d6171040bd3924c17 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 3 Aug 2021 08:52:22 -0500 Subject: staging: r8188eu: Remove some unused and ugly macros This driver contains a number of macros that are intended to do endian conversion. The first step in getting rid of them is to delete the ones that are not used. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210803135223.12543-10-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 39 ------------------------- 1 file changed, 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 0be9885b184e..57c0f32586a4 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -370,15 +370,7 @@ void rtw_free_netdev(struct net_device *netdev); #define RTW_GET_BE24(a) ((((u32) (a)[0]) << 16) | (((u32) (a)[1]) << 8) | \ ((u32) (a)[2])) -#define RTW_PUT_BE24(a, val) \ - do { \ - (a)[0] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[2] = (u8) (((u32) (val)) & 0xff); \ - } while (0) -#define RTW_GET_BE32(a) ((((u32) (a)[0]) << 24) | (((u32) (a)[1]) << 16) | \ - (((u32) (a)[2]) << 8) | ((u32) (a)[3])) #define RTW_PUT_BE32(a, val) \ do { \ (a)[0] = (u8) ((((u32) (val)) >> 24) & 0xff); \ @@ -387,37 +379,6 @@ void rtw_free_netdev(struct net_device *netdev); (a)[3] = (u8) (((u32) (val)) & 0xff); \ } while (0) -#define RTW_GET_LE32(a) ((((u32) (a)[3]) << 24) | (((u32) (a)[2]) << 16) | \ - (((u32) (a)[1]) << 8) | ((u32) (a)[0])) -#define RTW_PUT_LE32(a, val) \ - do { \ - (a)[3] = (u8) ((((u32) (val)) >> 24) & 0xff); \ - (a)[2] = (u8) ((((u32) (val)) >> 16) & 0xff); \ - (a)[1] = (u8) ((((u32) (val)) >> 8) & 0xff); \ - (a)[0] = (u8) (((u32) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_BE64(a) ((((u64) (a)[0]) << 56) | (((u64) (a)[1]) << 48) | \ - (((u64) (a)[2]) << 40) | (((u64) (a)[3]) << 32) | \ - (((u64) (a)[4]) << 24) | (((u64) (a)[5]) << 16) | \ - (((u64) (a)[6]) << 8) | ((u64) (a)[7])) -#define RTW_PUT_BE64(a, val) \ - do { \ - (a)[0] = (u8) (((u64) (val)) >> 56); \ - (a)[1] = (u8) (((u64) (val)) >> 48); \ - (a)[2] = (u8) (((u64) (val)) >> 40); \ - (a)[3] = (u8) (((u64) (val)) >> 32); \ - (a)[4] = (u8) (((u64) (val)) >> 24); \ - (a)[5] = (u8) (((u64) (val)) >> 16); \ - (a)[6] = (u8) (((u64) (val)) >> 8); \ - (a)[7] = (u8) (((u64) (val)) & 0xff); \ - } while (0) - -#define RTW_GET_LE64(a) ((((u64) (a)[7]) << 56) | (((u64) (a)[6]) << 48) | \ - (((u64) (a)[5]) << 40) | (((u64) (a)[4]) << 32) | \ - (((u64) (a)[3]) << 24) | (((u64) (a)[2]) << 16) | \ - (((u64) (a)[1]) << 8) | ((u64) (a)[0])) - void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); -- cgit v1.2.3 From a9f392d4518214d1de5aa9457f9778dd1ba578a9 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 3 Aug 2021 08:52:23 -0500 Subject: staging: r8188eu: Remove some bit manipulation macros This driver defines a set of macros that get or set a bitfield in the RX and TX descriptors. Most of these have been replaced by the appropriate use of the system macros BIT() or GENMASK(). While reworking these routines, I also fixed camel case variables and missing spaces. Some comments were also converted to the drivers/net/wireless preferred format. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210803135223.12543-11-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 2 +- .../staging/r8188eu/include/Hal8188ERateAdaptive.h | 59 +++++++++------------- drivers/staging/r8188eu/include/basic_types.h | 45 ----------------- drivers/staging/r8188eu/include/odm_types.h | 12 ++--- drivers/staging/r8188eu/include/rtl8188e_xmit.h | 26 +++++----- 5 files changed, 42 insertions(+), 102 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index fcfcb0d104d2..5307b10c1bc3 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -626,7 +626,7 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 if (valid) { pRAInfo->RTY[0] = (u16)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer); pRAInfo->RTY[1] = (u16)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer); - pRAInfo->RTY[2] = (u16)GET_TX_REPORT_TYPE1_RERTY_2(pBuffer); + pRAInfo->RTY[2] = (u16)GET_TX_REPORT_TYPE1_RERTY_2((u8 *)pBuffer); pRAInfo->RTY[3] = (u16)GET_TX_REPORT_TYPE1_RERTY_3(pBuffer); pRAInfo->RTY[4] = (u16)GET_TX_REPORT_TYPE1_RERTY_4(pBuffer); pRAInfo->DROP = (u16)GET_TX_REPORT_TYPE1_DROP_0(pBuffer); diff --git a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h index ce4c96d4b84a..d5ced507a648 100644 --- a/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h +++ b/drivers/staging/r8188eu/include/Hal8188ERateAdaptive.h @@ -3,19 +3,11 @@ #ifndef __INC_RA_H #define __INC_RA_H -/*++ +/* Module Name: RateAdaptive.h + * Abstract: Prototype of RA and related data structure. + */ -Module Name: - RateAdaptive.h - -Abstract: - Prototype of RA and related data structure. - -Major Change History: - When Who What - ---------- --------------- ------------------------------- - 2011-08-12 Page Create. ---*/ +#include /* Rate adaptive define */ #define PERENTRY 23 @@ -23,31 +15,26 @@ Major Change History: #define RATESIZE 28 #define TX_RPT2_ITEM_SIZE 8 -/* */ /* TX report 2 format in Rx desc */ -/* */ -#define GET_TX_RPT2_DESC_PKT_LEN_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc, 0, 9) -#define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc+16, 0, 32) -#define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__pRxStatusDesc) \ - LE_BITS_TO_4BYTE(__pRxStatusDesc+20, 0, 32) - -#define GET_TX_REPORT_TYPE1_RERTY_0(__pAddr) \ - LE_BITS_TO_4BYTE(__pAddr, 0, 16) -#define GET_TX_REPORT_TYPE1_RERTY_1(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+2, 0, 8) -#define GET_TX_REPORT_TYPE1_RERTY_2(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+3, 0, 8) -#define GET_TX_REPORT_TYPE1_RERTY_3(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4, 0, 8) -#define GET_TX_REPORT_TYPE1_RERTY_4(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4+1, 0, 8) -#define GET_TX_REPORT_TYPE1_DROP_0(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4+2, 0, 8) -#define GET_TX_REPORT_TYPE1_DROP_1(__pAddr) \ - LE_BITS_TO_1BYTE(__pAddr+4+3, 0, 8) - +#define GET_TX_RPT2_DESC_PKT_LEN_88E(__rxstatusdesc) \ + le32_get_bits(*(__le32 *)__rxstatusdesc, GENMASK(8, 0)) +#define GET_TX_RPT2_DESC_MACID_VALID_1_88E(__rxstatusdesc) \ + le32_to_cpu((*(__le32 *)(__rxstatusdesc + 16)) +#define GET_TX_RPT2_DESC_MACID_VALID_2_88E(__rxstatusdesc) \ + le32_to_cpu((*(__le32 *)(__rxstatusdesc + 20)) + +#define GET_TX_REPORT_TYPE1_RERTY_0(__paddr) \ + le16_get_bits(*(__le16 *)__paddr, GENMASK(15, 0)) +#define GET_TX_REPORT_TYPE1_RERTY_1(__paddr) \ + LE_BITS_TO_1BYTE(__paddr + 2, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_2(__paddr) \ + LE_BITS_TO_1BYTE(__paddr + 3, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_3(__paddr) \ + LE_BITS_TO_1BYTE(__paddr + 4, 0, 8) +#define GET_TX_REPORT_TYPE1_RERTY_4(__paddr) \ + LE_BITS_TO_1BYTE(__paddr + 5, 0, 8) +#define GET_TX_REPORT_TYPE1_DROP_0(__paddr) \ + LE_BITS_TO_1BYTE(__paddr + 6, 0, 8) /* End rate adaptive define */ void ODM_RASupport_Init(struct odm_dm_struct *dm_odm); diff --git a/drivers/staging/r8188eu/include/basic_types.h b/drivers/staging/r8188eu/include/basic_types.h index 9c34e2dad6bb..d82b2171d584 100644 --- a/drivers/staging/r8188eu/include/basic_types.h +++ b/drivers/staging/r8188eu/include/basic_types.h @@ -117,51 +117,6 @@ value to host byte ordering.*/ BIT_LEN_MASK_8(__bitlen) \ ) -/* Description: - * Mask subfield (continuous bits in little-endian) of 4-byte value - * and return the result in 4-byte value in host byte ordering. - */ -#define LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - LE_P4BYTE_TO_HOST_4BYTE(__pstart) & \ - (~BIT_OFFSET_LEN_MASK_32(__bitoffset, __bitlen)) \ - ) -#define LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - LE_P2BYTE_TO_HOST_2BYTE(__pstart) & \ - (~BIT_OFFSET_LEN_MASK_16(__bitoffset, __bitlen)) \ - ) -#define LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) \ - ( \ - LE_P1BYTE_TO_HOST_1BYTE(__pstart) & \ - (~BIT_OFFSET_LEN_MASK_8(__bitoffset, __bitlen)) \ - ) - -/* Description: - * Set subfield of little-endian 4-byte value to specified value. - */ -#define SET_BITS_TO_LE_4BYTE(__pstart, __bitoffset, __bitlen, __val) \ - *((u32 *)(__pstart)) = \ - ( \ - LE_BITS_CLEARED_TO_4BYTE(__pstart, __bitoffset, __bitlen) | \ - ((((u32)__val) & BIT_LEN_MASK_32(__bitlen)) << (__bitoffset)) \ - ) - -#define SET_BITS_TO_LE_2BYTE(__pstart, __bitoffset, __bitlen, __val) \ - *((u16 *)(__pstart)) = \ - ( \ - LE_BITS_CLEARED_TO_2BYTE(__pstart, __bitoffset, __bitlen) | \ - ((((u16)__val) & BIT_LEN_MASK_16(__bitlen)) << (__bitoffset)) \ - ); - -#define SET_BITS_TO_LE_1BYTE(__pstart, __bitoffset, __bitlen, __val) \ - *((u8 *)(__pstart)) = EF1BYTE \ - ( \ - LE_BITS_CLEARED_TO_1BYTE(__pstart, __bitoffset, __bitlen) | \ - ((((u8)__val) & BIT_LEN_MASK_8(__bitlen)) << (__bitoffset)) \ - ) - -/* Get the N-bytes aligment offset from the current length */ #define N_BYTE_ALIGMENT(__value, __aligment) ((__aligment == 1) ? \ (__value) : (((__value + __aligment - 1) / __aligment) * __aligment)) diff --git a/drivers/staging/r8188eu/include/odm_types.h b/drivers/staging/r8188eu/include/odm_types.h index e2e5aa8e8054..53a2fee55e35 100644 --- a/drivers/staging/r8188eu/include/odm_types.h +++ b/drivers/staging/r8188eu/include/odm_types.h @@ -29,12 +29,12 @@ enum RT_SPINLOCK_TYPE { #define DEV_BUS_TYPE RT_USB_INTERFACE -#define SET_TX_DESC_ANTSEL_A_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 24, 1, __Value) -#define SET_TX_DESC_ANTSEL_B_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+8, 25, 1, __Value) -#define SET_TX_DESC_ANTSEL_C_88E(__pTxDesc, __Value) \ - SET_BITS_TO_LE_4BYTE(__pTxDesc+28, 29, 1, __Value) +#define SET_TX_DESC_ANTSEL_A_88E(__ptxdesc, __value) \ + le32p_replace_bits((__le32 *)(__ptxdesc + 8), __value, BIT(24)) +#define SET_TX_DESC_ANTSEL_B_88E(__ptxdesc, __value) \ + le32p_replace_bits((__le32 *)(__ptxdesc + 8), __value, BIT(25)) +#define SET_TX_DESC_ANTSEL_C_88E(__ptxdesc, __value) \ + le32p_replace_bits((__le32 *)(__ptxdesc + 28), __value, BIT(29)) /* define useless flag to avoid compile warning */ #define USE_WORKITEM 0 diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index e9b71de0d165..95fb1ca69d46 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -18,24 +18,22 @@ #define QSLT_CMD 0x13 /* For 88e early mode */ -#define SET_EARLYMODE_PKTNUM(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 0, 3, __Value) +#define SET_EARLYMODE_PKTNUM(__paddr, __value) \ + le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(2, 0)) #define SET_EARLYMODE_LEN0(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 4, 12, __Value) -#define SET_EARLYMODE_LEN1(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 16, 12, __Value) -#define SET_EARLYMODE_LEN2_1(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr, 28, 4, __Value) -#define SET_EARLYMODE_LEN2_2(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr+4, 0, 8, __Value) + le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(15, 4)) +#define SET_EARLYMODE_LEN1(__paddr, __value) \ + le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(27, 16)) +#define SET_EARLYMODE_LEN2_1(__pdr, __vValue) \ + le32p_replace_bits((__le32 *)__paddr, __value, GENMASK(31, 28)) +#define SET_EARLYMODE_LEN2_2(__paddr, __value) \ + le32p_replace_bits((__le32 *)(__paddr + 4), __value, GENMASK(7, 0)) #define SET_EARLYMODE_LEN3(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr+4, 8, 12, __Value) -#define SET_EARLYMODE_LEN4(__pAddr, __Value) \ - SET_BITS_TO_LE_4BYTE(__pAddr+4, 20, 12, __Value) + le32p_replace_bits((__le32 *)(__paddr + 4), __value, GENMASK(19, 8)) +#define SET_EARLYMODE_LEN4(__paAddr, __vValue) \ + le32p_replace_bits((__le32 *)(__paddr + 4), __value, GENMASK(31, 20)) -/* */ /* defined for TX DESC Operation */ -/* */ #define MAX_TID (15) -- cgit v1.2.3 From fc048dee3902e063bda1d744011fa14ea02a83f7 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:28 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/rtl8188eu_xmit.c Remove RT_TRACE macro calls from hal/rtl8188eu_xmit.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index 47890fb5fd8a..900ae24c504a 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -354,15 +354,11 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) rtw_issue_addbareq_cmd(adapt, pxmitframe); mem_addr = pxmitframe->buf_addr; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_dump_xframe()\n")); - for (t = 0; t < pattrib->nr_frags; t++) { if (inner_ret != _SUCCESS && ret == _SUCCESS) ret = _FAIL; if (t != (pattrib->nr_frags - 1)) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("pattrib->nr_frags=%d\n", pattrib->nr_frags)); - sz = pxmitpriv->frag_len; sz = sz - 4 - (psecuritypriv->sw_encrypt ? 0 : pattrib->icv_len); } else { @@ -385,8 +381,6 @@ static s32 rtw_dump_xframe(struct adapter *adapt, struct xmit_frame *pxmitframe) rtw_count_tx_stats(adapt, pxmitframe, sz); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_write_port, w_sz=%d\n", w_sz)); - mem_addr += w_sz; mem_addr = (u8 *)RND4(((size_t)(mem_addr))); @@ -441,8 +435,6 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp /* dump frame variable */ u32 ff_hwaddr; - RT_TRACE(_module_rtl8192c_xmit_c_, _drv_info_, ("+xmitframe_complete\n")); - /* check xmitbuffer is ok */ if (!pxmitbuf) { pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); @@ -659,7 +651,6 @@ enqueue: spin_unlock_bh(&pxmitpriv->lock); if (res != _SUCCESS) { - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("pre_xmitframe: enqueue xmitframe fail\n")); rtw_free_xmitframe(pxmitpriv, pxmitframe); /* Trick, make the statistics correct */ -- cgit v1.2.3 From 204270c147de065cafc818bd21405a1651b2bc7e Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:29 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/rtl8188eu_recv.c Remove RT_TRACE macro calls from hal/rtl8188eu_recv.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index d4dd0b7376ad..d0102b002fd2 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -47,7 +47,6 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); if (!precvpriv->pallocated_recv_buf) { res = _FAIL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("alloc recv_buf fail!\n")); goto exit; } memset(precvpriv->pallocated_recv_buf, 0, NR_RECVBUFF * sizeof(struct recv_buf) + 4); -- cgit v1.2.3 From 23f7f44a933805457a8748f6f2469d86ab6a6b3a Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:30 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/HalPwrSeqCmd.c Remove RT_TRACE macro calls from hal/HalPwrSeqCmd.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index e1059c5dd711..e092563a3577 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -39,27 +39,12 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, do { pwrcfgcmd = pwrseqcmd[aryidx]; - RT_TRACE(_module_hal_init_c_, _drv_info_, - ("HalPwrSeqCmdParsing: offset(%#x) cut_msk(%#x) fab_msk(%#x) interface_msk(%#x) base(%#x) cmd(%#x) msk(%#x) value(%#x)\n", - GET_PWR_CFG_OFFSET(pwrcfgcmd), - GET_PWR_CFG_CUT_MASK(pwrcfgcmd), - GET_PWR_CFG_FAB_MASK(pwrcfgcmd), - GET_PWR_CFG_INTF_MASK(pwrcfgcmd), - GET_PWR_CFG_BASE(pwrcfgcmd), - GET_PWR_CFG_CMD(pwrcfgcmd), - GET_PWR_CFG_MASK(pwrcfgcmd), - GET_PWR_CFG_VALUE(pwrcfgcmd))); - /* 2 Only Handle the command whose FAB, CUT, and Interface are matched */ if ((GET_PWR_CFG_FAB_MASK(pwrcfgcmd) & fab_vers) && (GET_PWR_CFG_CUT_MASK(pwrcfgcmd) & cut_vers) && (GET_PWR_CFG_INTF_MASK(pwrcfgcmd) & ifacetype)) { switch (GET_PWR_CFG_CMD(pwrcfgcmd)) { - case PWR_CMD_READ: - RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_READ\n")); - break; case PWR_CMD_WRITE: - RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_WRITE\n")); offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); /* Read the value from system register */ @@ -72,8 +57,6 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, rtw_write8(padapter, offset, value); break; case PWR_CMD_POLLING: - RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_POLLING\n")); - poll_bit = false; offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); do { @@ -92,7 +75,6 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, } while (!poll_bit); break; case PWR_CMD_DELAY: - RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_DELAY\n")); if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else @@ -100,11 +82,9 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, break; case PWR_CMD_END: /* When this command is parsed, end the process */ - RT_TRACE(_module_hal_init_c_, _drv_info_, ("HalPwrSeqCmdParsing: PWR_CMD_END\n")); return true; break; default: - RT_TRACE(_module_hal_init_c_, _drv_err_, ("HalPwrSeqCmdParsing: Unknown CMD!!\n")); break; } } -- cgit v1.2.3 From 7ca7bbdc1487331a420bb6bec497188de5346643 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:31 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/hal_intf.c Remove RT_TRACE macro calls from hal/hal_intf.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/hal_intf.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 5c4e19b1e60f..e07d430dc7ba 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -88,9 +88,6 @@ uint rtw_hal_init(struct adapter *adapt) DBG_88E("rtw_hal_init: hal__init fail\n"); } - RT_TRACE(_module_hal_init_c_, _drv_err_, - ("-rtl871x_hal_init:status=0x%x\n", status)); - return status; } -- cgit v1.2.3 From eabc1a26e1ca56e3341cd55354fa074853fc0d5d Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:32 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/rtl8188e_hal_init.c Remove RT_TRACE macro calls from hal/rtl8188e_hal_init.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index cf19ffb1bed5..433e960ec10b 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -409,12 +409,6 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) blockCount_p1 = buffSize / blockSize_p1; remainSize_p1 = buffSize % blockSize_p1; - if (blockCount_p1) { - RT_TRACE(_module_hal_init_c_, _drv_notice_, - ("_BlockWrite: [P1] buffSize(%d) blockSize_p1(%d) blockCount_p1(%d) remainSize_p1(%d)\n", - buffSize, blockSize_p1, blockCount_p1, remainSize_p1)); - } - for (i = 0; i < blockCount_p1; i++) { ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + i * blockSize_p1), blockSize_p1, (bufferPtr + i * blockSize_p1)); if (ret == _FAIL) @@ -428,12 +422,6 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) blockCount_p2 = remainSize_p1/blockSize_p2; remainSize_p2 = remainSize_p1%blockSize_p2; - if (blockCount_p2) { - RT_TRACE(_module_hal_init_c_, _drv_notice_, - ("_BlockWrite: [P2] buffSize_p2(%d) blockSize_p2(%d) blockCount_p2(%d) remainSize_p2(%d)\n", - (buffSize-offset), blockSize_p2, blockCount_p2, remainSize_p2)); - } - for (i = 0; i < blockCount_p2; i++) { ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + offset + i*blockSize_p2), blockSize_p2, (bufferPtr + offset + i*blockSize_p2)); @@ -448,10 +436,6 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) blockCount_p3 = remainSize_p2 / blockSize_p3; - RT_TRACE(_module_hal_init_c_, _drv_notice_, - ("_BlockWrite: [P3] buffSize_p3(%d) blockSize_p3(%d) blockCount_p3(%d)\n", - (buffSize-offset), blockSize_p3, blockCount_p3)); - for (i = 0; i < blockCount_p3; i++) { ret = rtw_write8(padapter, (FW_8188E_START_ADDRESS + offset + i), *(bufferPtr + offset + i)); @@ -502,7 +486,6 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) if (ret == _FAIL) goto exit; } - RT_TRACE(_module_hal_init_c_, _drv_info_, ("_WriteFW Done- for Normal chip.\n")); exit: return ret; } @@ -578,7 +561,6 @@ static int load_firmware(struct rt_firmware *pFirmware, struct device *device) } if (fw->size > FW_8188E_SIZE) { rtStatus = _FAIL; - RT_TRACE(_module_hal_init_c_, _drv_err_, ("Firmware size exceed 0x%X. Check it.\n", FW_8188E_SIZE)); goto Exit; } @@ -610,7 +592,6 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter) u32 FirmwareLen; static int log_version; - RT_TRACE(_module_hal_init_c_, _drv_info_, ("+%s\n", __func__)); if (!dvobj->firmware.szFwBuffer) rtStatus = load_firmware(&dvobj->firmware, device); if (rtStatus == _FAIL) { @@ -672,7 +653,6 @@ s32 rtl8188e_FirmwareDownload(struct adapter *padapter) DBG_88E("DL Firmware failed!\n"); goto Exit; } - RT_TRACE(_module_hal_init_c_, _drv_info_, ("Firmware is ready to run!\n")); Exit: return rtStatus; @@ -1896,7 +1876,6 @@ static s32 _LLTWrite(struct adapter *padapter, u32 address, u32 data) break; if (count > POLLING_LLT_THRESHOLD) { - RT_TRACE(_module_hal_init_c_, _drv_err_, ("Failed to polling write LLT done at address %d!\n", address)); status = _FAIL; break; } @@ -1955,7 +1934,6 @@ Hal_InitPGData88E(struct adapter *padapter) EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); } } else {/* autoload fail */ - RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, ("AutoLoad Fail reported from CR9346!!\n")); /* update to default value 0xFF */ if (!is_boot_from_eeprom(padapter)) EFUSE_ShadowMapUpdate(padapter, EFUSE_WIFI, false); @@ -2246,9 +2224,6 @@ void Hal_EfuseParseEEPROMVer88E(struct adapter *padapter, u8 *hwinfo, bool AutoL } else { pHalData->EEPROMVersion = 1; } - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, - ("Hal_EfuseParseEEPROMVer(), EEVer = %d\n", - pHalData->EEPROMVersion)); } void rtl8188e_EfuseParseChnlPlan(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -- cgit v1.2.3 From 392d406b5c1421c4195dc14d54d6ae0bd2707050 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:33 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/rtl8188e_mp.c Remove RT_TRACE macro calls from hal/rtl8188e_mp.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 43 +++---------------------------- 1 file changed, 4 insertions(+), 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index a7893aa469ac..3defe1a6904d 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -13,17 +13,11 @@ s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); - if (!netif_running(padapter->pnetdev)) { - RT_TRACE(_module_mp_, _drv_warning_, - ("SetPowerTracking! Fail: interface not opened!\n")); + if (!netif_running(padapter->pnetdev)) return _FAIL; - } - if (!check_fwstate(&padapter->mlmepriv, WIFI_MP_STATE)) { - RT_TRACE(_module_mp_, _drv_warning_, - ("SetPowerTracking! Fail: not in MP mode!\n")); + if (!check_fwstate(&padapter->mlmepriv, WIFI_MP_STATE)) return _FAIL; - } if (enable) pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; @@ -260,10 +254,6 @@ void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 *TxPower) write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, TxPower[RF_PATH_B]); tmpval = (TxPower[RF_PATH_B]<<16) | (TxPower[RF_PATH_B]<<8) | TxPower[RF_PATH_B]; write_bbreg(pAdapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); - - RT_TRACE(_module_mp_, _drv_notice_, - ("-SetCCKTxPower: A[0x%02x] B[0x%02x]\n", - TxPower[RF_PATH_A], TxPower[RF_PATH_B])); } void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 *TxPower) @@ -512,23 +502,17 @@ void Hal_SetAntenna(struct adapter *pAdapter) break; } } - - RT_TRACE(_module_mp_, _drv_notice_, ("-SwitchAntenna: finished\n")); } s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) { struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - if (!netif_running(pAdapter->pnetdev)) { - RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter! Fail: interface not opened!\n")); + if (!netif_running(pAdapter->pnetdev)) return _FAIL; - } - if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { - RT_TRACE(_module_mp_, _drv_warning_, ("SetThermalMeter: Fail! not in MP mode!\n")); + if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) return _FAIL; - } target_ther &= 0xff; if (target_ther < 0x07) @@ -566,7 +550,6 @@ void Hal_SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) pAdapter->mppriv.MptCtx.bSingleCarrier = bStart; if (bStart) { /* Start Single Carrier. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test start\n")); /* 1. if OFDM block on? */ if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ @@ -584,8 +567,6 @@ void Hal_SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); } else { /* Stop Single Carrier. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleCarrierTx: test stop\n")); - /* Turn off all test modes. */ write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); @@ -625,7 +606,6 @@ void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) pAdapter->mppriv.MptCtx.bSingleTone = bStart; if (bStart) { /* Start Single Tone. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test start\n")); /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ if (IS_HARDWARE_TYPE_8188E(pAdapter)) { reg58 = PHY_QueryRFReg(pAdapter, RF_PATH_A, LNA_Low_Gain_3, bRFRegOffsetMask); @@ -658,8 +638,6 @@ void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) } else { /* Stop Single Tone. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetSingleToneTx: test stop\n")); - /* <20120326, Kordan> To amplify the power of tone for Xtal calibration. (asked by Edlu) */ /* <20120326, Kordan> Only in single tone mode. (asked by Edlu) */ if (IS_HARDWARE_TYPE_8188E(pAdapter)) { @@ -693,7 +671,6 @@ void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) pAdapter->mppriv.MptCtx.bCarrierSuppression = bStart; if (bStart) { /* Start Carrier Suppression. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test start\n")); if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { /* 1. if CCK block on? */ if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) @@ -716,7 +693,6 @@ void Hal_SetCarrierSuppressionTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); } else { /* Stop Carrier Suppression. */ - RT_TRACE(_module_mp_, _drv_alert_, ("SetCarrierSuppressionTx: test stop\n")); if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) { write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ write_bbreg(pAdapter, rCCK0_System, bCCKScramble, 0x1); /* turn on scramble setting */ @@ -737,9 +713,6 @@ void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart) u32 cckrate; if (bStart) { - RT_TRACE(_module_mp_, _drv_alert_, - ("SetCCKContinuousTx: test start\n")); - /* 1. if CCK block on? */ if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn)) write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, bEnable);/* set CCK block on */ @@ -758,9 +731,6 @@ void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rFPGA0_XA_HSSIParameter1, bMaskDWord, 0x01000500); write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); } else { - RT_TRACE(_module_mp_, _drv_info_, - ("SetCCKContinuousTx: test stop\n")); - write_bbreg(pAdapter, rCCK0_System, bCCKBBMode, 0x0); /* normal mode */ write_bbreg(pAdapter, rCCK0_System, bCCKScramble, bEnable); /* turn on scramble setting */ @@ -780,7 +750,6 @@ void Hal_SetCCKContinuousTx(struct adapter *pAdapter, u8 bStart) void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) { if (bStart) { - RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test start\n")); /* 1. if OFDM block on? */ if (!read_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn)) write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, bEnable);/* set OFDM block on */ @@ -800,7 +769,6 @@ void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rFPGA0_XB_HSSIParameter1, bMaskDWord, 0x01000500); } else { - RT_TRACE(_module_mp_, _drv_info_, ("SetOFDMContinuousTx: test stop\n")); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); @@ -821,9 +789,6 @@ void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) void Hal_SetContinuousTx(struct adapter *pAdapter, u8 bStart) { - RT_TRACE(_module_mp_, _drv_info_, - ("SetContinuousTx: rate:%d\n", pAdapter->mppriv.rateidx)); - pAdapter->mppriv.MptCtx.bStartContTx = bStart; if (pAdapter->mppriv.rateidx <= MPT_RATE_11M) Hal_SetCCKContinuousTx(pAdapter, bStart); -- cgit v1.2.3 From 24b336db31946f1e6780017c664dee1b759b2674 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:34 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/usb_halinit.c Remove RT_TRACE macro calls from hal/usb_halinit.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-8-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_halinit.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 919bcbd9f318..2981c3075ae8 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -712,10 +712,8 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_PW_ON); status = rtl8188eu_InitPowerOn(Adapter); - if (status == _FAIL) { - RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init power on!\n")); + if (status == _FAIL) goto exit; - } /* Save target channel */ haldata->CurrentChannel = 6;/* default set to 6 */ @@ -757,7 +755,6 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) haldata->fw_ractrl = false; return status; } else { - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("Initializeadapt8192CSdio(): Download Firmware Success!!\n")); Adapter->bFWReady = true; haldata->fw_ractrl = false; } @@ -805,10 +802,8 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_LLTT); status = InitLLTTable(Adapter, txpktbuf_bndy); - if (status == _FAIL) { - RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("Failed to init LLT table\n")); + if (status == _FAIL) goto exit; - } HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC02); /* Get Rx PHY status in order to report RSSI and others. */ @@ -968,8 +963,6 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) u8 val8; struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("CardDisableRTL8188EU\n")); - /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ val8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT1)); @@ -1067,16 +1060,12 @@ static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) status = _SUCCESS; - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, - ("===> usb_inirp_init\n")); - precvpriv->ff_hwaddr = RECV_BULK_IN_ADDR; /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { - RT_TRACE(_module_hci_hal_init_c_, _drv_err_, ("usb_rx_init: usb_read_port error\n")); status = _FAIL; goto exit; } @@ -1086,20 +1075,13 @@ static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) } exit: - - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("<=== usb_inirp_init\n")); - return status; } static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) { - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n ===> usb_rx_deinit\n")); - rtw_read_port_cancel(Adapter); - RT_TRACE(_module_hci_hal_init_c_, _drv_info_, ("\n <=== usb_rx_deinit\n")); - return _SUCCESS; } @@ -1156,11 +1138,6 @@ static void Hal_EfuseParseMACAddr_8188EU(struct adapter *adapt, u8 *hwinfo, bool /* Read Permanent MAC address */ memcpy(eeprom->mac_addr, &hwinfo[EEPROM_MAC_ADDR_88EU], ETH_ALEN); } - RT_TRACE(_module_hci_hal_init_c_, _drv_notice_, - ("Hal_EfuseParseMACAddr_8188EU: Permanent Address = %02x-%02x-%02x-%02x-%02x-%02x\n", - eeprom->mac_addr[0], eeprom->mac_addr[1], - eeprom->mac_addr[2], eeprom->mac_addr[3], - eeprom->mac_addr[4], eeprom->mac_addr[5])); } static void Hal_CustomizeByCustomerID_8188EU(struct adapter *adapt) -- cgit v1.2.3 From 52c3c004727baca39800df0153d8c782ae66a8ac Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 4 Aug 2021 00:05:35 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from hal/usb_ops_linux.c Remove RT_TRACE macro calls from hal/usb_ops_linux.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210803230535.74254-9-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 38 +++-------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index a2df752e5aac..650dba9bd38c 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -22,7 +22,6 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u int vendorreq_times = 0; if ((adapt->bSurpriseRemoved) || (adapt->pwrctrlpriv.pnp_bstop_trx)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usbctrl_vendorreq:(adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); status = -EPERM; goto exit; } @@ -311,15 +310,10 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; do { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("recvbuf2recvframe: rxdesc=offsset 0:0x%08x, 4:0x%08x, 8:0x%08x, C:0x%08x\n", - prxstat->rxdw0, prxstat->rxdw1, prxstat->rxdw2, prxstat->rxdw4)); - prxstat = (struct recv_stat *)pbuf; precvframe = rtw_alloc_recvframe(pfree_recv_queue); if (!precvframe) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvbuf2recvframe: precvframe==NULL\n")); DBG_88E("%s()-%d: rtw_alloc_recvframe() failed! RX Drop!\n", __func__, __LINE__); goto _exit_recvbuf2recvframe; } @@ -345,7 +339,6 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) pkt_offset = RXDESC_SIZE + pattrib->drvinfo_sz + pattrib->shift_sz + pattrib->pkt_len; if ((pattrib->pkt_len <= 0) || (pkt_offset > transfer_len)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recvbuf2recvframe: pkt_len<=0\n")); DBG_88E("%s()-%d: RX Warning!,pkt_len<=0 or pkt_offset> transfoer_len\n", __func__, __LINE__); rtw_free_recvframe(precvframe, pfree_recv_queue); goto _exit_recvbuf2recvframe; @@ -421,10 +414,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) if (pattrib->pkt_rpt_type == NORMAL_RX) { /* Normal rx packet */ if (pattrib->physt) update_recvframe_phyinfo_88e(precvframe, (struct phy_stat *)pphy_status); - if (rtw_recv_entry(precvframe) != _SUCCESS) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("recvbuf2recvframe: rtw_recv_entry(precvframe) != _SUCCESS\n")); - } + rtw_recv_entry(precvframe); } else { /* enqueue recvframe to txrtp queue */ if (pattrib->pkt_rpt_type == TX_REPORT1) { @@ -484,15 +474,9 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) struct adapter *adapt = (struct adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &adapt->recvpriv; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete!!!\n")); - precvpriv->rx_pending_cnt--; if (adapt->bSurpriseRemoved || adapt->bDriverStopped || adapt->bReadPortCancel) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", - adapt->bDriverStopped, adapt->bSurpriseRemoved)); - precvbuf->reuse = true; DBG_88E("%s() RX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bReadPortCancel(%d)\n", __func__, adapt->bDriverStopped, @@ -502,8 +486,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) if (purb->status == 0) { /* SUCCESS */ if ((purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); precvbuf->reuse = true; rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); DBG_88E("%s()-%d: RX Warning!\n", __func__, __LINE__); @@ -522,8 +504,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } } else { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete : purb->status(%d) != 0\n", purb->status)); - DBG_88E("###=> usb_read_port_complete => urb status(%d)\n", purb->status); skb_put(precvbuf->pskb, purb->actual_length); precvbuf->pskb = NULL; @@ -536,11 +516,9 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) case -EPIPE: case -ENODEV: case -ESHUTDOWN: - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bSurpriseRemoved=true\n")); __attribute__((__fallthrough__)); case -ENOENT: adapt->bDriverStopped = true; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete:bDriverStopped=true\n")); break; case -EPROTO: case -EOVERFLOW: @@ -575,17 +553,11 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) u32 ret = _SUCCESS; if (adapter->bDriverStopped || adapter->bSurpriseRemoved || - adapter->pwrctrlpriv.pnp_bstop_trx) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:(adapt->bDriverStopped ||adapt->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); + adapter->pwrctrlpriv.pnp_bstop_trx) return _FAIL; - } - if (!precvbuf) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_read_port:precvbuf==NULL\n")); + if (!precvbuf) return _FAIL; - } if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = skb_dequeue(&precvpriv->free_recv_skb_queue); @@ -599,7 +571,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) if (!precvbuf->reuse || !precvbuf->pskb) { precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); if (!precvbuf->pskb) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("init_recvbuf(): alloc_skb fail!\n")); DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); return _FAIL; } @@ -638,9 +609,6 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) err = usb_submit_urb(purb, GFP_ATOMIC); if ((err) && (err != (-EPERM))) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("cannot submit rx in-token(err=0x%.8x), URB_STATUS =0x%.8x", - err, purb->status)); DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", err, purb->status); ret = _FAIL; -- cgit v1.2.3 From 04e424519d320fb4e3486dd929b69a67d06a6b05 Mon Sep 17 00:00:00 2001 From: "Scott J. Crouch" Date: Wed, 4 Aug 2021 10:13:34 +1000 Subject: staging: rtl8723bs: Remove initialisation of globals to 0 This fixes the following checkpatch.pl errors: ERROR: do not initialise globals to {0,NULL} Signed-off-by: Scott J. Crouch Link: https://lore.kernel.org/r/20210804001335.16742-1-scottjcrouch@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 7359f0861cce..128c64e0f0ab 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -111,7 +111,7 @@ static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */ static int rtw_hw_wps_pbc; -int rtw_mc2u_disable = 0; +int rtw_mc2u_disable; static int rtw_80211d; @@ -122,7 +122,7 @@ static char *ifname = "wlan%d"; module_param(ifname, charp, 0644); MODULE_PARM_DESC(ifname, "The default name to allocate for first interface"); -char *rtw_initmac = NULL; /* temp mac address if users want to use instead of the mac address in Efuse */ +char *rtw_initmac; /* temp mac address if users want to use instead of the mac address in Efuse */ module_param(rtw_initmac, charp, 0644); module_param(rtw_channel_plan, int, 0644); -- cgit v1.2.3 From 96ac47d2418d32bb8a7aff5973bd5d3375775897 Mon Sep 17 00:00:00 2001 From: Bryan Brattlof Date: Wed, 4 Aug 2021 15:01:10 +0000 Subject: staging: rtl8723bs: remove unused BT structures remove static BT debugging structures no longer in use. Signed-off-by: Bryan Brattlof Link: https://lore.kernel.org/r/20210804144812.715695-1-hello@bryanbrattlof.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c | 6 ------ drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c | 6 ------ 2 files changed, 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c index 242c14959176..b3d7f50fac4c 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b1Ant.c @@ -13,12 +13,6 @@ static struct coex_dm_8723b_1ant *pCoexDm = &GLCoexDm8723b1Ant; static struct coex_sta_8723b_1ant GLCoexSta8723b1Ant; static struct coex_sta_8723b_1ant *pCoexSta = &GLCoexSta8723b1Ant; -static const char *const GLBtInfoSrc8723b1Ant[] = { - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - /* local function proto type if needed */ /* local function start with halbtc8723b1ant_ */ static u8 halbtc8723b1ant_BtRssiState( diff --git a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c index 3e36a7dc72a6..c1c7b5cc17a7 100644 --- a/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c +++ b/drivers/staging/rtl8723bs/hal/HalBtc8723b2Ant.c @@ -20,12 +20,6 @@ static struct coex_dm_8723b_2ant *pCoexDm = &GLCoexDm8723b2Ant; static struct coex_sta_8723b_2ant GLCoexSta8723b2Ant; static struct coex_sta_8723b_2ant *pCoexSta = &GLCoexSta8723b2Ant; -static const char *const GLBtInfoSrc8723b2Ant[] = { - "BT Info[wifi fw]", - "BT Info[bt rsp]", - "BT Info[bt auto report]", -}; - /* local function start with halbtc8723b2ant_ */ static u8 halbtc8723b2ant_BtRssiState( u8 levelNum, u8 rssiThresh, u8 rssiThresh1 -- cgit v1.2.3 From b888897014a9986726b7f8d69356097722834c04 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sun, 1 Aug 2021 10:51:53 +0200 Subject: staging/fbtft: Remove all strcpy() uses strcpy() performs no bounds checking on the destination buffer. This could result in linear overflows beyond the end of the buffer, leading to all kinds of misbehaviors. The safe replacement is strscpy() but in this case it is simpler to use the "%*ph" format specifier. Moreover, with the "0x%02X " in the sprintf followed by the strcat, the msg buffer (now removed) can print 128/5 values (25 hex values). So, the "%*ph" replacement won't cut output earlier than requested since this format specifier can print up to 64 bytes. Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210801085155.3170-2-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index 3723269890d5..e6286043bff7 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -992,8 +992,6 @@ out_free: int fbtft_init_display(struct fbtft_par *par) { int buf[64]; - char msg[128]; - char str[16]; int i = 0; int j; @@ -1036,17 +1034,14 @@ int fbtft_init_display(struct fbtft_par *par) switch (par->init_sequence[i]) { case -1: i++; + /* make debug message */ - strcpy(msg, ""); - j = i + 1; - while (par->init_sequence[j] >= 0) { - sprintf(str, "0x%02X ", par->init_sequence[j]); - strcat(msg, str); - j++; - } + for (j = 0; par->init_sequence[i + 1 + j] >= 0; j++); + fbtft_par_dbg(DEBUG_INIT_DISPLAY, par, - "init: write(0x%02X) %s\n", - par->init_sequence[i], msg); + "init: write(0x%02X) %*ph\n", + par->init_sequence[i], j, + &par->init_sequence[i + 1]); /* Write */ j = 0; -- cgit v1.2.3 From 31f0c349dd399ae03df5633abd73830b2429e7a1 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sun, 1 Aug 2021 10:51:54 +0200 Subject: staging/fbtft: Remove unnecessary variable initialization Remove the initialization of the variable "i" since it is written a few lines later. Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210801085155.3170-3-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index e6286043bff7..ed896049118c 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -992,7 +992,7 @@ out_free: int fbtft_init_display(struct fbtft_par *par) { int buf[64]; - int i = 0; + int i; int j; /* sanity check */ -- cgit v1.2.3 From f9d39971c0cc648625c841af16e7c96911603e63 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Sun, 1 Aug 2021 10:51:55 +0200 Subject: staging/fbtft: Fix braces coding style Add braces to the "for" loop. This way, the kernel coding style is followed. Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210801085155.3170-4-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/fbtft/fbtft-core.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/fbtft/fbtft-core.c b/drivers/staging/fbtft/fbtft-core.c index ed896049118c..ed992ca605eb 100644 --- a/drivers/staging/fbtft/fbtft-core.c +++ b/drivers/staging/fbtft/fbtft-core.c @@ -1003,9 +1003,11 @@ int fbtft_init_display(struct fbtft_par *par) } /* make sure stop marker exists */ - for (i = 0; i < FBTFT_MAX_INIT_SEQUENCE; i++) + for (i = 0; i < FBTFT_MAX_INIT_SEQUENCE; i++) { if (par->init_sequence[i] == -3) break; + } + if (i == FBTFT_MAX_INIT_SEQUENCE) { dev_err(par->info->device, "missing stop marker at end of init sequence\n"); -- cgit v1.2.3 From e1109da7bebbf1a0faca8a5e3453fe98035578fa Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Wed, 4 Aug 2021 16:32:18 +0200 Subject: staging: r8188eu: Fix cast between incompatible function type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix sparse warnings of casts between incompatible function types from ‘void (*)(void *)’ to ‘void (*)(long unsigned int)’ [-Wcast-function-type]. Suggested-by: Dan Carpenter Reviewed-by: Dan Carpenter Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210804143218.13665-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 2 +- drivers/staging/r8188eu/hal/usb_ops_linux.c | 4 ++-- drivers/staging/r8188eu/include/rtl8188e_recv.h | 2 +- drivers/staging/r8188eu/include/rtl8188e_xmit.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index d0102b002fd2..8535d3d1e3d8 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -38,7 +38,7 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) struct recv_buf *precvbuf; tasklet_init(&precvpriv->recv_tasklet, - (void(*)(unsigned long))rtl8188eu_recv_tasklet, + rtl8188eu_recv_tasklet, (unsigned long)padapter); /* init recv_buf */ diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index 900ae24c504a..e4aa0b3bc7b7 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -14,7 +14,7 @@ s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) struct xmit_priv *pxmitpriv = &adapt->xmitpriv; tasklet_init(&pxmitpriv->xmit_tasklet, - (void(*)(unsigned long))rtl8188eu_xmit_tasklet, + rtl8188eu_xmit_tasklet, (unsigned long)adapt); return _SUCCESS; } diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 650dba9bd38c..80d44aafd8ea 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -449,7 +449,7 @@ _exit_recvbuf2recvframe: return _SUCCESS; } -void rtl8188eu_recv_tasklet(void *priv) +void rtl8188eu_recv_tasklet(unsigned long priv) { struct sk_buff *pskb; struct adapter *adapt = (struct adapter *)priv; @@ -617,7 +617,7 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) return ret; } -void rtl8188eu_xmit_tasklet(void *priv) +void rtl8188eu_xmit_tasklet(unsigned long priv) { int ret = false; struct adapter *adapt = (struct adapter *)priv; diff --git a/drivers/staging/r8188eu/include/rtl8188e_recv.h b/drivers/staging/r8188eu/include/rtl8188e_recv.h index bc1d532592b9..a91daf84d6c3 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_recv.h +++ b/drivers/staging/r8188eu/include/rtl8188e_recv.h @@ -44,7 +44,7 @@ void rtl8188eu_init_recvbuf(struct adapter *padapter, struct recv_buf *buf); s32 rtl8188eu_init_recv_priv(struct adapter *padapter); void rtl8188eu_free_recv_priv(struct adapter * padapter); void rtl8188eu_recv_hdl(struct adapter * padapter, struct recv_buf *precvbuf); -void rtl8188eu_recv_tasklet(void *priv); +void rtl8188eu_recv_tasklet(unsigned long priv); void rtl8188e_query_rx_phy_status(struct recv_frame *fr, struct phy_stat *phy); void rtl8188e_process_phy_info(struct adapter * padapter, void *prframe); void update_recvframe_phyinfo_88e(struct recv_frame *fra, struct phy_stat *phy); diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index 95fb1ca69d46..ff8b73441c52 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -145,7 +145,7 @@ s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); #define hal_xmit_handler rtl8188eu_xmit_buf_handler -void rtl8188eu_xmit_tasklet(void *priv); +void rtl8188eu_xmit_tasklet(unsigned long priv); s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -- cgit v1.2.3 From d229f0fb10250173989d2086073ff702980ef48b Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Mon, 2 Aug 2021 02:55:17 +0200 Subject: staging: r8188eu: core: Remove rtw_mfree_all_stainfo() Remove rtw_mfree_all_stainfo() and the only line of code that calls it. This function simply takes a spinlock and iterates over a list with no purpose. That iteration has no side effects. Signed-off-by: Fabio M. De Francesco Acked-by: Larry Finger Acked-by: Dan Carpenter Link: https://lore.kernel.org/r/20210802005517.12815-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 22 ---------------------- 1 file changed, 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 93cd1db1ba2a..4f62ef3dd246 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -161,34 +161,12 @@ void rtw_mfree_stainfo(struct sta_info *psta) } -/* this function is used to free the memory of lock || sema for all stainfos */ -void rtw_mfree_all_stainfo(struct sta_priv *pstapriv); -void rtw_mfree_all_stainfo(struct sta_priv *pstapriv) -{ - struct list_head *plist, *phead; - struct sta_info *psta = NULL; - - spin_lock_bh(&pstapriv->sta_hash_lock); - - phead = get_list_head(&pstapriv->free_sta_queue); - plist = phead->next; - - while (phead != plist) { - psta = container_of(plist, struct sta_info, list); - plist = plist->next; - } - - spin_unlock_bh(&pstapriv->sta_hash_lock); -} - static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) { #ifdef CONFIG_88EU_AP_MODE struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; #endif - rtw_mfree_all_stainfo(pstapriv); /* be done before free sta_hash_lock */ - _rtw_spinlock_free(&pstapriv->free_sta_queue.lock); _rtw_spinlock_free(&pstapriv->sta_hash_lock); -- cgit v1.2.3 From a8f80c20b373bb46670643db81f043ba7da6a537 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 5 Aug 2021 14:06:09 +0200 Subject: staging: r8188eu: Remove unneeded comments in rtw_mp_ioctl.h After commit 85143bdc731b ("staging: r8188eu: include: Remove unused const definitions"), some comments are not anymore needed. Remove them too. In the while, remove also a line with a void comment. Suggested-by: Greg Kroah-Hartman Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210805120609.28588-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_mp_ioctl.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h index 0376ddbf6011..cf99f39a582e 100644 --- a/drivers/staging/r8188eu/include/rtw_mp_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_mp_ioctl.h @@ -11,7 +11,6 @@ #include "rtw_efuse.h" #include "rtw_mp.h" -/* */ struct cfg_dbg_msg_struct { u32 DebugLevel; u32 DebugComponent_H32; @@ -52,7 +51,6 @@ struct dr_variable_struct { #define _irqlevel_changed_(a, b) -/* rtl8188eu_oid_rtl_seg_81_80_00 */ int rtl8188eu_oid_rt_pro_set_data_rate_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_start_test_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_stop_test_hdl(struct oid_par_priv *poid_par_priv); @@ -60,7 +58,6 @@ int rtl8188eu_oid_rt_pro_set_channel_direct_call_hdl(struct oid_par_priv *poid_p int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_set_tx_power_control_hdl(struct oid_par_priv *poid_par_priv); -/* rtl8188eu_oid_rtl_seg_81_80_20 */ int rtl8188eu_oid_rt_pro_query_tx_packet_sent_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_query_rx_packet_received_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_query_rx_packet_crc32_error_hdl(struct oid_par_priv *par_priv); @@ -78,7 +75,6 @@ int rtl8188eu_oid_rt_pro_read_bb_reg_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_write_rf_reg_hdl(struct oid_par_priv *poid_par_priv); int rtl8188eu_oid_rt_pro_read_rf_reg_hdl(struct oid_par_priv *poid_par_priv); -/* rtl8188eu_oid_rtl_seg_81_85 */ int rtl8188eu_oid_rt_wireless_mode_hdl(struct oid_par_priv *poid_par_priv); /* rtl8188eu_oid_rtl_seg_87_11_00 */ -- cgit v1.2.3 From 066eea44c1ea430cabebffc383dcaa861fa9a2b9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 5 Aug 2021 16:09:41 +0200 Subject: staging: r8188eu: fix build error Remove unnecessary label to fix build error introduced with commit b398ff88aa36 ("staging: r8188eu: remove return from void functions") drivers/staging/r8188eu/hal/rtl8188e_dm.c:182:1: error: label at end of compound statement Reported-by: kernel test robot Signed-off-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210805140941.9130-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index b5f42127a751..7ac4257d7ebe 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -145,7 +145,7 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) hw_init_completed = Adapter->hw_init_completed; if (!hw_init_completed) - goto skip_dm; + return; fw_cur_in_ps = Adapter->pwrctrlpriv.bFwCurrentInPSMode; rtw_hal_get_hwreg(Adapter, HW_VAR_FWLPS_RF_ON, (u8 *)(&fw_ps_awake)); @@ -179,9 +179,6 @@ void rtl8188e_HalDmWatchDog(struct adapter *Adapter) ODM_CmnInfoUpdate(&hal_data->odmpriv, ODM_CMNINFO_LINK, bLinked); ODM_DMWatchdog(&hal_data->odmpriv); } -skip_dm: - /* Check GPIO to determine current RF on/off and Pbc status. */ - /* Check Hardware Radio ON/OFF or not */ } void rtl8188e_init_dm_priv(struct adapter *Adapter) -- cgit v1.2.3 From 66e9564aae0185eb7f36d946b0ba22b779a4e193 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 5 Aug 2021 15:11:08 +0200 Subject: staging: r8188eu: Fix incorrect types in arguments GCC + Sparse emit warnings of passing incorrect type in arguments of some functions because of different base types. Fix them by changing the types of the parameters of the above-mentioned functions. In the meantime, remove the unnecessary casts of those arguments which are then passed to memcpy() within those same functions. Reviewed-by: Dan Carpenter Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210805131108.19775-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 27c8ec3b7d62..e4110d5bc6f2 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -134,37 +134,37 @@ static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr } static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned char *ipxNodeAddr) + __be32 *ipxNetAddr, unsigned char *ipxNodeAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); + memcpy(networkAddr+1, ipxNetAddr, 4); memcpy(networkAddr+5, ipxNodeAddr, 6); } static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - unsigned int *ipxNetAddr, unsigned short *ipxSocketAddr) + __be32 *ipxNetAddr, __be16 *ipxSocketAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, (unsigned char *)ipxNetAddr, 4); - memcpy(networkAddr+5, (unsigned char *)ipxSocketAddr, 2); + memcpy(networkAddr+1, ipxNetAddr, 4); + memcpy(networkAddr+5, ipxSocketAddr, 2); } static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, - unsigned short *network, unsigned char *node) + __be16 *network, unsigned char *node) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); networkAddr[0] = NAT25_APPLE; - memcpy(networkAddr+1, (unsigned char *)network, 2); + memcpy(networkAddr+1, network, 2); networkAddr[3] = *node; } static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, - unsigned char *ac_mac, unsigned short *sid) + unsigned char *ac_mac, __be16 *sid) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); -- cgit v1.2.3 From 79f712ea994de30b3887a45e9ca42fd47b840b62 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 13:37:13 -0500 Subject: staging: r8188eu: Remove wrappers for kalloc() and kzalloc() These wrappers involve an in_interrupt() call, which is not frowned on in the kernel. These changes decrease the size of the driver by a trivial amount. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805183717.23007-2-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 8 +-- drivers/staging/r8188eu/core/rtw_br_ext.c | 2 +- drivers/staging/r8188eu/core/rtw_cmd.c | 11 +++-- drivers/staging/r8188eu/core/rtw_efuse.c | 4 +- drivers/staging/r8188eu/core/rtw_mlme.c | 8 +-- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 30 +++++------ drivers/staging/r8188eu/core/rtw_mp.c | 2 +- drivers/staging/r8188eu/core/rtw_p2p.c | 8 +-- drivers/staging/r8188eu/core/rtw_wlan_util.c | 2 +- drivers/staging/r8188eu/core/rtw_xmit.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 8 +-- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 3 +- drivers/staging/r8188eu/hal/usb_halinit.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 6 --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 66 +++++++++++-------------- drivers/staging/r8188eu/os_dep/mlme_linux.c | 3 +- drivers/staging/r8188eu/os_dep/osdep_service.c | 28 ++--------- drivers/staging/r8188eu/os_dep/usb_intf.c | 4 +- drivers/staging/r8188eu/os_dep/xmit_linux.c | 2 +- 20 files changed, 86 insertions(+), 115 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index d7b1a071928c..ad37f1f02ee2 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -98,7 +98,7 @@ static void update_BCNTIM(struct adapter *padapter) } if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); if (pbackup_remainder_ie && premainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } @@ -180,7 +180,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 } if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); if (pbackup_remainder_ie && premainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } @@ -224,7 +224,7 @@ void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, } if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); if (pbackup_remainder_ie && premainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } @@ -1302,7 +1302,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) remainder_ielen = ielen - wps_offset - wps_ielen; if (remainder_ielen > 0) { - pbackup_remainder_ie = rtw_malloc(remainder_ielen); + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); if (pbackup_remainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index e4110d5bc6f2..28f0452d6ccb 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -394,7 +394,7 @@ static void __nat25_db_network_insert(struct adapter *priv, } db = db->next_hash; } - db = (struct nat25_network_db_entry *) rtw_malloc(sizeof(*db)); + db = kmalloc(sizeof(*db), GFP_KERNEL); if (!db) { spin_unlock_bh(&priv->br_ext_lock); return; diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 4ac76ca6e383..d7d33e201f37 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -1947,10 +1947,13 @@ static void c2h_wk_callback(struct work_struct *work) if ((c2h_evt = (struct c2h_evt_hdr *)rtw_cbuf_pop(evtpriv->c2h_queue)) != NULL) { /* This C2H event is read, clear it */ c2h_evt_clear(adapter); - } else if ((c2h_evt = (struct c2h_evt_hdr *)rtw_malloc(16)) != NULL) { - /* This C2H event is not read, read & clear now */ - if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) - continue; + } else { + c2h_evt = kmalloc(16, GFP_KERNEL); + if (c2h_evt) { + /* This C2H event is not read, read & clear now */ + if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) + continue; + } } /* Special pointer to trigger c2h_evt_clear only */ diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index 9e9085aab952..3e53ec522519 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -533,7 +533,7 @@ u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) if ((addr + cnts) > mapLen) return _FAIL; - map = rtw_zmalloc(mapLen); + map = kzalloc(mapLen, GFP_KERNEL); if (!map) return _FAIL; @@ -625,7 +625,7 @@ u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data if ((addr + cnts) > mapLen) return _FAIL; - map = rtw_zmalloc(mapLen); + map = kzalloc(mapLen, GFP_KERNEL); if (!map) return _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 850dbb3f1cc7..549ebcccca57 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1735,13 +1735,13 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); int res = _SUCCESS; - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; /* try again */ goto exit; } - psetauthparm = (struct setauth_parm *)rtw_zmalloc(sizeof(struct setauth_parm)); + psetauthparm = kzalloc(sizeof(struct setauth_parm), GFP_KERNEL); if (!psetauthparm) { kfree(pcmd); res = _FAIL; @@ -1773,12 +1773,12 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); int res = _SUCCESS; - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; /* try again */ goto exit; } - psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); if (!psetkeyparm) { kfree(pcmd); res = _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 1ca356eecd1c..a8ed4e1a0278 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -662,7 +662,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) if (!memcmp(GetAddr3Ptr(pframe), get_my_bssid(&pmlmeinfo->network), ETH_ALEN)) { if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { /* we should update current network before auth, or some IE is wrong */ - pbss = (struct wlan_bssid_ex *)rtw_malloc(sizeof(struct wlan_bssid_ex)); + pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); if (pbss) { if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); @@ -6966,12 +6966,12 @@ void report_survey_event(struct adapter *padapter, struct recv_frame *precv_fram pmlmeext = &padapter->mlmeextpriv; pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmd_obj) return; cmdsz = (sizeof(struct survey_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); if (!pevtcmd) { kfree(pcmd_obj); return; @@ -7016,12 +7016,12 @@ void report_surveydone_event(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd_obj) return; cmdsz = (sizeof(struct surveydone_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_KERNEL); if (!pevtcmd) { kfree(pcmd_obj); return; @@ -7060,12 +7060,12 @@ void report_join_res(struct adapter *padapter, int res) struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmd_obj) return; cmdsz = (sizeof(struct joinbss_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_ATOMIC); if (!pevtcmd) { kfree(pcmd_obj); return; @@ -7109,12 +7109,12 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd_obj) return; cmdsz = (sizeof(struct stadel_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_KERNEL); if (!pevtcmd) { kfree(pcmd_obj); return; @@ -7161,12 +7161,12 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - pcmd_obj = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd_obj) return; cmdsz = (sizeof(struct stassoc_event) + sizeof(struct C2HEvent_Header)); - pevtcmd = (u8 *)rtw_zmalloc(cmdsz); + pevtcmd = kzalloc(cmdsz, GFP_KERNEL); if (!pevtcmd) { kfree(pcmd_obj); return; @@ -7582,11 +7582,11 @@ void survey_timer_hdl(struct adapter *padapter) pmlmeext->scan_abort = false;/* reset */ } - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) goto exit_survey_timer_hdl; - psurveyPara = (struct sitesurvey_parm *)rtw_zmalloc(sizeof(struct sitesurvey_parm)); + psurveyPara = kzalloc(sizeof(struct sitesurvey_parm), GFP_ATOMIC); if (!psurveyPara) { kfree(ph2c); goto exit_survey_timer_hdl; @@ -8158,13 +8158,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) u8 res = _SUCCESS; int len_diff = 0; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!ph2c) { res = _FAIL; goto exit; } - ptxBeacon_parm = (struct Tx_Beacon_param *)rtw_zmalloc(sizeof(struct Tx_Beacon_param)); + ptxBeacon_parm = kzalloc(sizeof(struct Tx_Beacon_param), GFP_KERNEL); if (!ptxBeacon_parm) { kfree(ph2c); res = _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 1065e9e8a015..36119602541a 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -669,7 +669,7 @@ void SetPacketTx(struct adapter *padapter) kfree(pmp_priv->tx.pallocated_buf); pmp_priv->tx.write_size = pkt_size; pmp_priv->tx.buf_size = pkt_size + XMITBUF_ALIGN_SZ; - pmp_priv->tx.pallocated_buf = rtw_zmalloc(pmp_priv->tx.buf_size); + pmp_priv->tx.pallocated_buf = kzalloc(pmp_priv->tx.buf_size, GFP_KERNEL); if (!pmp_priv->tx.pallocated_buf) { DBG_88E("%s: malloc(%d) fail!!\n", __func__, pmp_priv->tx.buf_size); return; diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index c19360ea09a4..b4497444a7af 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -34,7 +34,7 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) DBG_88E("%s\n", __func__); - pdata_attr = rtw_zmalloc(MAX_P2P_IE_LEN); + pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_KERNEL); pstart = pdata_attr; pcur = pdata_attr; @@ -855,7 +855,7 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l /* Check P2P Device Info ATTR */ if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_INFO, NULL, (uint *)&attr_contentlen)) { DBG_88E("[%s] Got P2P DEVICE INFO Attr!!\n", __func__); - pattr_content = rtw_zmalloc(attr_contentlen); + pattr_content = kzalloc(attr_contentlen, GFP_KERNEL); pbuf = pattr_content; if (pattr_content) { u8 num_of_secdev_type; @@ -1697,13 +1697,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) return res; if (enqueue) { - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!ph2c) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = (struct drvextra_cmd_parm *)rtw_zmalloc(sizeof(struct drvextra_cmd_parm)); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index c4e2726f3a19..5a9a824dcbfd 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -915,7 +915,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) return true; } - bssid = (struct wlan_bssid_ex *)rtw_zmalloc(sizeof(struct wlan_bssid_ex)); + bssid = kzalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); if (!bssid) return _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 3b61eb651ee4..3aab02a90697 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -1625,7 +1625,7 @@ void rtw_alloc_hwxmits(struct adapter *padapter) pxmitpriv->hwxmit_entry = HWXMIT_ENTRY; - pxmitpriv->hwxmits = (struct hw_xmit *)rtw_zmalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry); + pxmitpriv->hwxmits = kzalloc(sizeof(struct hw_xmit) * pxmitpriv->hwxmit_entry, GFP_KERNEL); hwxmits = pxmitpriv->hwxmits; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index a6bb4ecadc49..f33bf732eeaf 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -489,7 +489,7 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) struct rsvdpage_loc RsvdPageLoc; DBG_88E("%s\n", __func__); - ReservedPagePacket = (u8 *)rtw_zmalloc(1000); + ReservedPagePacket = kzalloc(1000, GFP_KERNEL); if (!ReservedPagePacket) { DBG_88E("%s: alloc ReservedPagePacket fail!\n", __func__); return; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 433e960ec10b..abbc8d22883b 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -76,13 +76,13 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) u16 efuse_utilized = 0; u8 u1temp = 0; - efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); if (!efuseTbl) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); goto exit; } - eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); if (!eFuseWord) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); goto exit; @@ -790,13 +790,13 @@ static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, goto exit; } - efuseTbl = (u8 *)rtw_zmalloc(EFUSE_MAP_LEN_88E); + efuseTbl = kzalloc(EFUSE_MAP_LEN_88E, GFP_KERNEL); if (!efuseTbl) { DBG_88E("%s: alloc efuseTbl fail!\n", __func__); goto exit; } - eFuseWord = (u16 **)rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); + eFuseWord = rtw_malloc2d(EFUSE_MAX_SECTION_88E, EFUSE_MAX_WORD_UNIT, sizeof(u16)); if (!eFuseWord) { DBG_88E("%s: alloc eFuseWord fail!\n", __func__); goto exit; diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 8535d3d1e3d8..3a169392d183 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -44,7 +44,8 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) /* init recv_buf */ _rtw_init_queue(&precvpriv->free_recv_buf_queue); - precvpriv->pallocated_recv_buf = rtw_zmalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4); + precvpriv->pallocated_recv_buf = kzalloc(NR_RECVBUFF * sizeof(struct recv_buf) + 4, + GFP_KERNEL); if (!precvpriv->pallocated_recv_buf) { res = _FAIL; goto exit; diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 2981c3075ae8..b214b7b1e9de 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -2230,7 +2230,7 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt) { struct hal_ops *halfunc = &adapt->HalFunc; - adapt->HalData = rtw_zmalloc(sizeof(struct hal_data_8188e)); + adapt->HalData = kzalloc(sizeof(struct hal_data_8188e), GFP_KERNEL); if (!adapt->HalData) DBG_88E("cant not alloc memory for HAL DATA\n"); adapt->hal_data_sz = sizeof(struct hal_data_8188e); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 57c0f32586a4..b64f8851796b 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -215,15 +215,9 @@ extern unsigned char RSN_TKIP_CIPHER[4]; u8 *_rtw_vmalloc(u32 sz); u8 *_rtw_zvmalloc(u32 sz); void _rtw_vmfree(u8 *pbuf, u32 sz); -u8 *_rtw_zmalloc(u32 sz); -u8 *_rtw_malloc(u32 sz); -void _rtw_mfree(u8 *pbuf, u32 sz); #define rtw_vmalloc(sz) _rtw_vmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) #define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) -#define rtw_malloc(sz) _rtw_malloc((sz)) -#define rtw_zmalloc(sz) _rtw_zmalloc((sz)) -#define rtw_mfree(pbuf, sz) _rtw_mfree((pbuf), (sz)) void *rtw_malloc2d(int h, int w, int size); diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 8ba2b81e32b8..5f4355cb03e7 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -522,7 +522,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + pwep = kmalloc(wep_total_len, GFP_KERNEL); if (!pwep) { RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); goto exit; @@ -642,7 +642,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } if (ielen) { - buf = rtw_zmalloc(ielen); + buf = kzalloc(ielen, GFP_KERNEL); if (!buf) { ret = -ENOMEM; goto exit; @@ -2109,11 +2109,9 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, int ret = 0; param_len = sizeof(struct ieee_param) + pext->key_len; - param = (struct ieee_param *)rtw_malloc(param_len); + param = kzalloc(param_len, GFP_KERNEL); if (!param) - return -1; - - memset(param, 0, param_len); + return -ENOMEM; param->cmd = IEEE_CMD_SET_ENCRYPTION; memset(param->sta_addr, 0xff, ETH_ALEN); @@ -2194,8 +2192,8 @@ static int rtw_wx_read32(struct net_device *dev, padapter = (struct adapter *)rtw_netdev_priv(dev); p = &wrqu->data; len = p->length; - ptmp = (u8 *)rtw_malloc(len); - if (NULL == ptmp) + ptmp = kmalloc(len, GFP_KERNEL); + if (!ptmp) return -ENOMEM; if (copy_from_user(ptmp, p->pointer, len)) { @@ -2464,7 +2462,7 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info pparmbuf = NULL; bset = (u8)(p->flags & 0xFFFF); len = p->length; - pparmbuf = (u8 *)rtw_malloc(len); + pparmbuf = kmalloc(len, GFP_KERNEL); if (!pparmbuf) { ret = -ENOMEM; goto _rtw_mp_ioctl_hdl_exit; @@ -4674,7 +4672,7 @@ static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) goto out; } - param = (struct ieee_param *)rtw_malloc(p->length); + param = kmalloc(p->length, GFP_KERNEL); if (!param) { ret = -ENOMEM; goto out; @@ -4728,13 +4726,13 @@ static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - ph2c = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!ph2c) { res = _FAIL; goto exit; } - psetstakey_para = (struct set_stakey_parm *)rtw_zmalloc(sizeof(struct set_stakey_parm)); + psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); if (!psetstakey_para) { kfree(ph2c); res = _FAIL; @@ -4766,12 +4764,12 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) DBG_88E("%s\n", __func__); - pcmd = (struct cmd_obj *)rtw_zmalloc(sizeof(struct cmd_obj)); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; goto exit; } - psetkeyparm = (struct setkey_parm *)rtw_zmalloc(sizeof(struct setkey_parm)); + psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); if (!psetkeyparm) { kfree(pcmd); res = _FAIL; @@ -4887,14 +4885,11 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = (struct ndis_802_11_wep *)rtw_malloc(wep_total_len); + pwep = kzalloc(wep_total_len, GFP_KERNEL); if (!pwep) { - DBG_88E(" r871x_set_encryption: pwep allocate fail !!!\n"); + ret = -ENOMEM; goto exit; } - - memset(pwep, 0, wep_total_len); - pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; } @@ -5315,7 +5310,7 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, } if (ie_len > 0) { - pmlmepriv->wps_beacon_ie = rtw_malloc(ie_len); + pmlmepriv->wps_beacon_ie = kmalloc(ie_len, GFP_KERNEL); pmlmepriv->wps_beacon_ie_len = ie_len; if (!pmlmepriv->wps_beacon_ie) { DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); @@ -5352,7 +5347,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par } if (ie_len > 0) { - pmlmepriv->wps_probe_resp_ie = rtw_malloc(ie_len); + pmlmepriv->wps_probe_resp_ie = kmalloc(ie_len, GFP_KERNEL); pmlmepriv->wps_probe_resp_ie_len = ie_len; if (!pmlmepriv->wps_probe_resp_ie) { DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); @@ -5384,11 +5379,11 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par } if (ie_len > 0) { - pmlmepriv->wps_assoc_resp_ie = rtw_malloc(ie_len); + pmlmepriv->wps_assoc_resp_ie = kmalloc(ie_len, GFP_KERNEL); pmlmepriv->wps_assoc_resp_ie_len = ie_len; if (!pmlmepriv->wps_assoc_resp_ie) { DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); - return -EINVAL; + return -ENOMEM; } memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); @@ -5491,7 +5486,7 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) goto out; } - param = (struct ieee_param *)rtw_malloc(p->length); + param = kmalloc(p->length, GFP_KERNEL); if (!param) { ret = -ENOMEM; goto out; @@ -5600,9 +5595,8 @@ static int rtw_wx_set_priv(struct net_device *dev, kfree(pmlmepriv->wps_probe_req_ie); pmlmepriv->wps_probe_req_ie = NULL; - pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); + pmlmepriv->wps_probe_req_ie = kmalloc(cp_sz, GFP_KERNEL); if (!pmlmepriv->wps_probe_req_ie) { - pr_info("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); ret = -EINVAL; goto FREE_EXT; } @@ -5674,12 +5668,12 @@ static int rtw_mp_efuse_get(struct net_device *dev, pEfuseHal = &haldata->EfuseHal; err = 0; - data = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); + data = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); if (!data) { err = -ENOMEM; goto exit; } - rawdata = _rtw_zmalloc(EFUSE_BT_MAX_MAP_LEN); + rawdata = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); if (!rawdata) { err = -ENOMEM; goto exit; @@ -5989,22 +5983,22 @@ static int rtw_mp_efuse_set(struct net_device *dev, haldata = GET_HAL_DATA(padapter); pEfuseHal = &haldata->EfuseHal; err = 0; - setdata = _rtw_zmalloc(1024); + setdata = kzalloc(1024, GFP_KERNEL); if (!setdata) { err = -ENOMEM; goto exit; } - ShadowMapBT = _rtw_malloc(EFUSE_BT_MAX_MAP_LEN); + ShadowMapBT = kmalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); if (!ShadowMapBT) { err = -ENOMEM; goto exit; } - ShadowMapWiFi = _rtw_malloc(EFUSE_MAP_SIZE); + ShadowMapWiFi = kmalloc(EFUSE_MAP_SIZE, GFP_KERNEL); if (!ShadowMapWiFi) { err = -ENOMEM; goto exit; } - setrawdata = _rtw_malloc(EFUSE_MAX_SIZE); + setrawdata = kmalloc(EFUSE_MAX_SIZE, GFP_KERNEL); if (!setrawdata) { err = -ENOMEM; goto exit; @@ -7486,7 +7480,7 @@ static int rtw_test( DBG_88E("+%s\n", __func__); len = wrqu->data.length; - pbuf = (u8 *)rtw_zmalloc(len); + pbuf = kzalloc(len, GFP_KERNEL); if (!pbuf) { DBG_88E("%s: no memory!\n", __func__); return -ENOMEM; @@ -7832,7 +7826,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ input_len = wdata.data.length; if (input_len == 0) return -EFAULT; - input = rtw_zmalloc(input_len); + input = kzalloc(input_len, GFP_KERNEL); if (NULL == input) return -ENOMEM; if (copy_from_user(input, wdata.data.pointer, input_len)) { @@ -7895,7 +7889,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ k = j; } - buffer = rtw_zmalloc(4096); + buffer = kzalloc(4096, GFP_KERNEL); if (NULL == buffer) { err = -ENOMEM; goto exit; @@ -8044,7 +8038,7 @@ static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_ else n = wdata.data.length; - output = rtw_zmalloc(4096); + output = kzalloc(4096, GFP_KERNEL); if (NULL == output) { err = -ENOMEM; goto exit; diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index 766b346afbb8..0855b218f7b1 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -119,10 +119,9 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) if (authmode == _WPA_IE_ID_) { RT_TRACE(_module_mlme_osdep_c_, _drv_info_, ("rtw_report_sec_ie, authmode=%d\n", authmode)); - buff = rtw_malloc(IW_CUSTOM_MAX); + buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); if (!buff) return; - memset(buff, 0, IW_CUSTOM_MAX); p = buff; p += sprintf(p, "ASSOCINFO(ReqIEs ="); len = sec_ie[1]+2; diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 250d499e4d4a..9cf9f272cccb 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -58,32 +58,13 @@ inline void _rtw_vmfree(u8 *pbuf, u32 sz) vfree(pbuf); } -u8 *_rtw_malloc(u32 sz) -{ - u8 *pbuf = NULL; - - pbuf = kmalloc(sz, in_interrupt() ? GFP_ATOMIC : GFP_KERNEL); - return pbuf; -} - -u8 *_rtw_zmalloc(u32 sz) -{ - u8 *pbuf = _rtw_malloc(sz); - - if (pbuf) - memset(pbuf, 0, sz); - return pbuf; -} - void *rtw_malloc2d(int h, int w, int size) { int j; - void **a = (void **)rtw_zmalloc(h*sizeof(void *) + h*w*size); - if (!a) { - pr_info("%s: alloc memory fail!\n", __func__); + void **a = kzalloc(h * sizeof(void *) + h * w * size, GFP_KERNEL); + if (!a) return NULL; - } for (j = 0; j < h; j++) a[j] = ((char *)(a+h)) + j*w*size; @@ -331,7 +312,7 @@ void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) goto keep_ori; /* duplicate src */ - dup = rtw_malloc(src_len); + dup = kmalloc(src_len, GFP_ATOMIC); if (dup) { dup_len = src_len; memcpy(dup, src, dup_len); @@ -423,8 +404,7 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size) { struct rtw_cbuf *cbuf; - cbuf = (struct rtw_cbuf *)rtw_malloc(sizeof(*cbuf) + - sizeof(void *)*size); + cbuf = kmalloc(sizeof(*cbuf) + sizeof(void *)*size, GFP_KERNEL); if (cbuf) { cbuf->write = 0; diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index fffc2c0d9efb..f3321a6653fc 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -118,7 +118,7 @@ static u8 rtw_init_intf_priv(struct dvobj_priv *dvobj) _rtw_mutex_init(&dvobj->usb_vendor_req_mutex); - dvobj->usb_alloc_vendor_req_buf = rtw_zmalloc(MAX_USB_IO_CTL_SIZE); + dvobj->usb_alloc_vendor_req_buf = kzalloc(MAX_USB_IO_CTL_SIZE, GFP_KERNEL); if (!dvobj->usb_alloc_vendor_req_buf) { DBG_88E("alloc usb_vendor_req_buf failed... /n"); rst = _FAIL; @@ -150,7 +150,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) struct usb_endpoint_descriptor *pendp_desc; struct usb_device *pusbd; - pdvobjpriv = (struct dvobj_priv *)rtw_zmalloc(sizeof(*pdvobjpriv)); + pdvobjpriv = kzalloc(sizeof(*pdvobjpriv), GFP_KERNEL); if (!pdvobjpriv) goto exit; diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 421328173984..df9bdbff91ac 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -76,7 +76,7 @@ int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitb { int i; - pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz); + pxmitbuf->pallocated_buf = kzalloc(alloc_sz, GFP_KERNEL); if (!pxmitbuf->pallocated_buf) return _FAIL; -- cgit v1.2.3 From 71f09c5ae9d2c2c1344987b104dc167ab1922b72 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 13:37:14 -0500 Subject: staging: r8188eu: Remove wrapper around vfree This call is so simple that there is no need, or use, for a wrapper. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805183717.23007-3-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 4 +--- drivers/staging/r8188eu/core/rtw_mp.c | 3 +-- drivers/staging/r8188eu/core/rtw_recv.c | 5 +---- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/r8188eu/core/rtw_xmit.c | 10 +++------- drivers/staging/r8188eu/hal/odm_interface.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 2 -- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 ++-- drivers/staging/r8188eu/os_dep/osdep_service.c | 7 +------ drivers/staging/r8188eu/os_dep/usb_intf.c | 2 +- 11 files changed, 13 insertions(+), 30 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 549ebcccca57..72570aede776 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -129,9 +129,7 @@ void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) if (pmlmepriv) { rtw_mfree_mlme_priv_lock (pmlmepriv); - if (pmlmepriv->free_bss_buf) { - rtw_vmfree(pmlmepriv->free_bss_buf, MAX_BSS_CNT * sizeof(struct wlan_network)); - } + vfree(pmlmepriv->free_bss_buf); } } diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 36119602541a..9ff0a19cc680 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -922,8 +922,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_xmit_extbuf) - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmit_extbuf); if (padapter->registrypriv.mp_mode == 0) { max_xmit_extbuf_size = 6000; diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 37cf22569c59..6f6caf727f3b 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -115,12 +115,9 @@ void _rtw_free_recv_priv (struct recv_priv *precvpriv) rtw_os_recv_resource_free(precvpriv); - if (precvpriv->pallocated_frame_buf) { - rtw_vmfree(precvpriv->pallocated_frame_buf, NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); - } + vfree(precvpriv->pallocated_frame_buf); rtw_hal_free_recv_priv(padapter); - } struct recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 4f62ef3dd246..2f1d1bfb6f73 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -211,7 +211,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) rtw_mfree_sta_priv_lock(pstapriv); if (pstapriv->pallocated_stainfo_buf) - rtw_vmfree(pstapriv->pallocated_stainfo_buf, sizeof(struct sta_info)*NUM_STA+4); + vfree(pstapriv->pallocated_stainfo_buf); } return _SUCCESS; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 3aab02a90697..05396cc2e82a 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -252,11 +252,9 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_frame_buf) - rtw_vmfree(pxmitpriv->pallocated_frame_buf, NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + vfree(pxmitpriv->pallocated_frame_buf); - if (pxmitpriv->pallocated_xmitbuf) - rtw_vmfree(pxmitpriv->pallocated_xmitbuf, NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + vfree(pxmitpriv->pallocated_xmitbuf); /* free xmit extension buff */ _rtw_spinlock_free(&pxmitpriv->free_xmit_extbuf_queue.lock); @@ -267,9 +265,7 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) pxmitbuf++; } - if (pxmitpriv->pallocated_xmit_extbuf) { - rtw_vmfree(pxmitpriv->pallocated_xmit_extbuf, num_xmit_extbuf * sizeof(struct xmit_buf) + 4); - } + vfree(pxmitpriv->pallocated_xmit_extbuf); rtw_free_hwxmits(padapter); diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index 507baf9fd913..38f6ae410e53 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -85,7 +85,7 @@ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) /* length could be ignored, used to detect memory leakage. */ void ODM_FreeMemory(struct odm_dm_struct *pDM_Odm, void *pPtr, u32 length) { - rtw_vmfree(pPtr, length); + vfree(pPtr); } s32 ODM_CompareMemory(struct odm_dm_struct *pDM_Odm, void *pBuf1, void *pBuf2, u32 length) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index abbc8d22883b..9b0d02a759a4 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -363,7 +363,7 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) } while (!rstatus && (loop++ < 10)); } rtw_IOL_cmd_buf_dump(Adapter, data_len, pbuf); - rtw_vmfree(pbuf, data_len+10); + vfree(pbuf); } DBG_88E("###### %s ######\n", __func__); } diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index b64f8851796b..1ff0980e6bfb 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -214,10 +214,8 @@ extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) u8 *_rtw_vmalloc(u32 sz); u8 *_rtw_zvmalloc(u32 sz); -void _rtw_vmfree(u8 *pbuf, u32 sz); #define rtw_vmalloc(sz) _rtw_vmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) -#define rtw_vmfree(pbuf, sz) _rtw_vmfree((pbuf), (sz)) void *rtw_malloc2d(int h, int w, int size); diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 5f4355cb03e7..11301e0f287a 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -5575,7 +5575,7 @@ static int rtw_wx_set_priv(struct net_device *dev, return -ENOMEM; if (copy_from_user(ext, dwrq->pointer, len)) { - rtw_vmfree(ext, len); + vfree(ext); return -EFAULT; } @@ -5614,7 +5614,7 @@ static int rtw_wx_set_priv(struct net_device *dev, FREE_EXT: - rtw_vmfree(ext, len); + vfree(ext); return ret; } diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 9cf9f272cccb..d3603e34eeb4 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -53,11 +53,6 @@ inline u8 *_rtw_zvmalloc(u32 sz) return pbuf; } -inline void _rtw_vmfree(u8 *pbuf, u32 sz) -{ - vfree(pbuf); -} - void *rtw_malloc2d(int h, int w, int size) { int j; @@ -230,7 +225,7 @@ void rtw_free_netdev(struct net_device *netdev) if (!pnpi->priv) goto RETURN; - rtw_vmfree(pnpi->priv, pnpi->sizeof_priv); + vfree(pnpi->priv); free_netdev(netdev); RETURN: diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index f3321a6653fc..b1184c36ddfc 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -702,7 +702,7 @@ free_adapter: if (pnetdev) rtw_free_netdev(pnetdev); else if (padapter) - rtw_vmfree((u8 *)padapter, sizeof(*padapter)); + vfree(padapter); padapter = NULL; } exit: -- cgit v1.2.3 From 1c10f2b95cc1b24166959c0694a0d812bf665a89 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 13:37:15 -0500 Subject: staging: r8188eu: Remove all calls to _rtw_spinlock_free() This routine is empty, thus all calls to it can be removed. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805183717.23007-4-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 3 --- drivers/staging/r8188eu/core/rtw_mlme.c | 3 --- drivers/staging/r8188eu/core/rtw_recv.c | 5 ----- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 28 ------------------------- drivers/staging/r8188eu/core/rtw_xmit.c | 14 ------------- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/os_intfs.c | 2 -- drivers/staging/r8188eu/os_dep/osdep_service.c | 4 ---- 8 files changed, 60 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index d7d33e201f37..720b534c29ad 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -96,15 +96,12 @@ void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) { if (pcmdpriv) { - _rtw_spinlock_free(&(pcmdpriv->cmd_queue.lock)); - if (pcmdpriv->cmd_allocated_buf) kfree(pcmdpriv->cmd_allocated_buf); if (pcmdpriv->rsp_allocated_buf) kfree(pcmdpriv->rsp_allocated_buf); } - } /* diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 72570aede776..4ffed8a35054 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -87,9 +87,6 @@ exit: static void rtw_mfree_mlme_priv_lock (struct mlme_priv *pmlmepriv) { - _rtw_spinlock_free(&pmlmepriv->lock); - _rtw_spinlock_free(&(pmlmepriv->free_bss_pool.lock)); - _rtw_spinlock_free(&(pmlmepriv->scanned_queue.lock)); } #if defined (CONFIG_88EU_AP_MODE) diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 6f6caf727f3b..47e19c506584 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -98,11 +98,6 @@ exit: static void rtw_mfree_recv_priv_lock(struct recv_priv *precvpriv) { - _rtw_spinlock_free(&precvpriv->lock); - _rtw_spinlock_free(&precvpriv->free_recv_queue.lock); - _rtw_spinlock_free(&precvpriv->recv_pending_queue.lock); - - _rtw_spinlock_free(&precvpriv->free_recv_buf_queue.lock); } void _rtw_free_recv_priv (struct recv_priv *precvpriv) diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 2f1d1bfb6f73..b7c39d5e316c 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -130,32 +130,16 @@ inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv); void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv) { - - _rtw_spinlock_free(&psta_xmitpriv->lock); - - _rtw_spinlock_free(&(psta_xmitpriv->be_q.sta_pending.lock)); - _rtw_spinlock_free(&(psta_xmitpriv->bk_q.sta_pending.lock)); - _rtw_spinlock_free(&(psta_xmitpriv->vi_q.sta_pending.lock)); - _rtw_spinlock_free(&(psta_xmitpriv->vo_q.sta_pending.lock)); - } static void _rtw_free_sta_recv_priv_lock(struct sta_recv_priv *psta_recvpriv) { - - _rtw_spinlock_free(&psta_recvpriv->lock); - - _rtw_spinlock_free(&(psta_recvpriv->defrag_q.lock)); - } void rtw_mfree_stainfo(struct sta_info *psta); void rtw_mfree_stainfo(struct sta_info *psta) { - if (&psta->lock) - _rtw_spinlock_free(&psta->lock); - _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); @@ -166,18 +150,6 @@ static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) #ifdef CONFIG_88EU_AP_MODE struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; #endif - - _rtw_spinlock_free(&pstapriv->free_sta_queue.lock); - - _rtw_spinlock_free(&pstapriv->sta_hash_lock); - _rtw_spinlock_free(&pstapriv->wakeup_q.lock); - _rtw_spinlock_free(&pstapriv->sleep_q.lock); - -#ifdef CONFIG_88EU_AP_MODE - _rtw_spinlock_free(&pstapriv->asoc_list_lock); - _rtw_spinlock_free(&pstapriv->auth_list_lock); - _rtw_spinlock_free(&pacl_list->acl_node_q.lock); -#endif } u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 05396cc2e82a..edd5746be556 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -212,17 +212,6 @@ exit: static void rtw_mfree_xmit_priv_lock (struct xmit_priv *pxmitpriv) { - _rtw_spinlock_free(&pxmitpriv->lock); - - _rtw_spinlock_free(&pxmitpriv->be_pending.lock); - _rtw_spinlock_free(&pxmitpriv->bk_pending.lock); - _rtw_spinlock_free(&pxmitpriv->vi_pending.lock); - _rtw_spinlock_free(&pxmitpriv->vo_pending.lock); - _rtw_spinlock_free(&pxmitpriv->bm_pending.lock); - - _rtw_spinlock_free(&pxmitpriv->free_xmit_queue.lock); - _rtw_spinlock_free(&pxmitpriv->free_xmitbuf_queue.lock); - _rtw_spinlock_free(&pxmitpriv->pending_xmitbuf_queue.lock); } void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) @@ -256,9 +245,6 @@ void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) vfree(pxmitpriv->pallocated_xmitbuf); - /* free xmit extension buff */ - _rtw_spinlock_free(&pxmitpriv->free_xmit_extbuf_queue.lock); - pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmit_extbuf; for (i = 0; i < num_xmit_extbuf; i++) { rtw_os_xmit_resource_free(padapter, pxmitbuf, (max_xmit_extbuf_size + XMITBUF_ALIGN_SZ)); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 1ff0980e6bfb..cb876b50d68c 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -222,7 +222,6 @@ void *rtw_malloc2d(int h, int w, int size); u32 _rtw_down_sema(struct semaphore *sema); void _rtw_mutex_init(struct mutex *pmutex); void _rtw_mutex_free(struct mutex *pmutex); -void _rtw_spinlock_free(spinlock_t *plock); void _rtw_init_queue(struct __queue *pqueue); diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 5f1ec883d6ed..935e35c82666 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -979,8 +979,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter) } #endif - _rtw_spinlock_free(&padapter->br_ext_lock); - free_mlme_ext_priv(&padapter->mlmeextpriv); rtw_free_cmd_priv(&padapter->cmdpriv); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index d3603e34eeb4..db6ee1dca48e 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -94,10 +94,6 @@ void _rtw_mutex_free(struct mutex *pmutex) mutex_destroy(pmutex); } -void _rtw_spinlock_free(spinlock_t *plock) -{ -} - void _rtw_init_queue(struct __queue *pqueue) { INIT_LIST_HEAD(&(pqueue->queue)); -- cgit v1.2.3 From 346d13128a86db4f64e7ffa01527693e0112fb81 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 13:37:16 -0500 Subject: staging: r8188eu: Remove more empty routines After removing some empty routines in os_dep/osdep_service.c, new routines become empty. These include rtw_mfree_stainfo(), _rtw_free_sta_xmit_priv_lock(), and rtw_mfree_recv_priv_lock. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805183717.23007-5-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 6 ------ drivers/staging/r8188eu/core/rtw_sta_mgt.c | 18 ------------------ 2 files changed, 24 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 47e19c506584..aef32f029537 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -96,18 +96,12 @@ exit: return res; } -static void rtw_mfree_recv_priv_lock(struct recv_priv *precvpriv) -{ -} - void _rtw_free_recv_priv (struct recv_priv *precvpriv) { struct adapter *padapter = precvpriv->adapter; rtw_free_uc_swdec_pending_queue(padapter); - rtw_mfree_recv_priv_lock(precvpriv); - rtw_os_recv_resource_free(precvpriv); vfree(precvpriv->pallocated_frame_buf); diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index b7c39d5e316c..fc963bee37be 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -127,24 +127,6 @@ inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); } -void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv); -void _rtw_free_sta_xmit_priv_lock(struct sta_xmit_priv *psta_xmitpriv) -{ -} - -static void _rtw_free_sta_recv_priv_lock(struct sta_recv_priv *psta_recvpriv) -{ -} - -void rtw_mfree_stainfo(struct sta_info *psta); -void rtw_mfree_stainfo(struct sta_info *psta) -{ - - _rtw_free_sta_xmit_priv_lock(&psta->sta_xmitpriv); - _rtw_free_sta_recv_priv_lock(&psta->sta_recvpriv); - -} - static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) { #ifdef CONFIG_88EU_AP_MODE -- cgit v1.2.3 From d48401b8609ff19db0f461759ac6b5210cd81288 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 13:37:17 -0500 Subject: staging: r8188eu: Remove rtw_buf_free() This routine is just a wrapper around kfree(). The wrapper also sets buffer length to 0, and the pointer to NULL. The length variable is in the struct to be freed, thus setting it to zero is meaningless. Setting the pointer to NULL is also not needed. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805183717.23007-6-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 9 ++++----- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 7 ------- 4 files changed, 6 insertions(+), 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 4ffed8a35054..e3d5a721d25c 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -99,8 +99,8 @@ static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) { - rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); + kfree(pmlmepriv->assoc_req); + kfree(pmlmepriv->assoc_rsp); rtw_free_mlme_ie_data(&pmlmepriv->wps_beacon_ie, &pmlmepriv->wps_beacon_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_req_ie, &pmlmepriv->wps_probe_req_ie_len); rtw_free_mlme_ie_data(&pmlmepriv->wps_probe_resp_ie, &pmlmepriv->wps_probe_resp_ie_len); diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index a8ed4e1a0278..470c338b44e1 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -1519,11 +1519,10 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame UpdateBrateTbl(padapter, pmlmeinfo->network.SupportedRates); report_assoc_result: - if (res > 0) { + if (res > 0) rtw_buf_update(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len, pframe, pkt_len); - } else { - rtw_buf_free(&pmlmepriv->assoc_rsp, &pmlmepriv->assoc_rsp_len); - } + else + kfree(pmlmepriv->assoc_rsp); report_join_res(padapter, res); @@ -5534,7 +5533,7 @@ exit: if (ret == _SUCCESS) rtw_buf_update(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len, (u8 *)pwlanhdr, pattrib->pktlen); else - rtw_buf_free(&pmlmepriv->assoc_req, &pmlmepriv->assoc_req_len); + kfree(pmlmepriv->assoc_req); } /* when wait_ack is ture, this function shoule be called at process context */ diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index cb876b50d68c..10f0203fd905 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -370,7 +370,6 @@ void rtw_free_netdev(struct net_device *netdev); (a)[3] = (u8) (((u32) (val)) & 0xff); \ } while (0) -void rtw_buf_free(u8 **buf, u32 *buf_len); void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len); struct rtw_cbuf { diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index db6ee1dca48e..232d3a337be4 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -283,13 +283,6 @@ error: return -1; } -void rtw_buf_free(u8 **buf, u32 *buf_len) -{ - *buf_len = 0; - kfree(*buf); - *buf = NULL; -} - void rtw_buf_update(u8 **buf, u32 *buf_len, u8 *src, u32 src_len) { u32 dup_len = 0; -- cgit v1.2.3 From 717d933d003c88668cbfab145d02c86ff3cf8756 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 5 Aug 2021 11:58:05 -0700 Subject: staging: r8188eu: Remove unnecessary parentheses Clang warns several times across the driver along the lines of: drivers/staging/r8188eu/core/rtw_pwrctrl.c:222:21: warning: equality comparison with extraneous parentheses [-Wparentheses-equality] if ((pwrpriv->rpwm == pslv)) { ~~~~~~~~~~~~~~^~~~~~~ drivers/staging/r8188eu/core/rtw_pwrctrl.c:222:21: note: remove extraneous parentheses around the comparison to silence this warning if ((pwrpriv->rpwm == pslv)) { ~ ^ ~ drivers/staging/r8188eu/core/rtw_pwrctrl.c:222:21: note: use '=' to turn this equality comparison into an assignment if ((pwrpriv->rpwm == pslv)) { ^~ = 1 warning generated. The compilers have agreed that single parentheses are used for equality and double parentheses are used for assignment within control flow statements such as if and while so remove them in these places to fix the warning. Reviewed-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210805185807.3296077-2-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 2 +- drivers/staging/r8188eu/core/rtw_security.c | 4 ++-- drivers/staging/r8188eu/core/rtw_wlan_util.c | 2 +- drivers/staging/r8188eu/hal/odm.c | 2 +- drivers/staging/r8188eu/hal/usb_halinit.c | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 2c029f85d63d..967c9623e7d1 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -218,7 +218,7 @@ void rtw_set_rpwm(struct adapter *padapter, u8 pslv) pslv = PS_STATE_S3; } - if ((pwrpriv->rpwm == pslv)) + if (pwrpriv->rpwm == pslv) return; if ((padapter->bSurpriseRemoved) || diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index df8107a0f5f2..08a5a1975d11 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -1209,7 +1209,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) pframe = ((struct xmit_frame *)pxmitframe)->buf_addr + hw_hdr_offset; /* 4 start to encrypt each fragment */ - if ((pattrib->encrypt == _AES_)) { + if (pattrib->encrypt == _AES_) { if (pattrib->psta) stainfo = pattrib->psta; else @@ -1452,7 +1452,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) pframe = (unsigned char *)((struct recv_frame *)precvframe)->rx_data; /* 4 start to encrypt each fragment */ - if ((prxattrib->encrypt == _AES_)) { + if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo) { RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 5a9a824dcbfd..21a3d0868214 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -1283,7 +1283,7 @@ int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps) if (!(pmlmeinfo->HT_enable)) return _FAIL; - if ((pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK)) + if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_RALINK) return _FAIL; bit_offset = (pmlmeext->cur_bwmode & HT_CHANNEL_WIDTH_40) ? 6 : 5; diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 08ec1e18b3f0..0deeb21c8006 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1630,7 +1630,7 @@ void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv); struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - if ((pregpriv->wifi_spec == 1))/* (pmlmeinfo->HT_enable == 0)) */ + if (pregpriv->wifi_spec == 1) goto dm_CheckEdcaTurbo_EXIT; if (pmlmeinfo->assoc_AP_vendor >= HT_IOT_PEER_MAX) diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index b214b7b1e9de..c2d9c0359e64 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -1277,7 +1277,7 @@ static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) StopTxBeacon(Adapter); rtw_write8(Adapter, REG_BCN_CTRL, 0x19);/* disable atim wnd */ - } else if ((mode == _HW_STATE_ADHOC_)) { + } else if (mode == _HW_STATE_ADHOC_) { ResumeTxBeacon(Adapter); rtw_write8(Adapter, REG_BCN_CTRL, 0x1a); } else if (mode == _HW_STATE_AP_) { -- cgit v1.2.3 From 760e7353a6e13e73a73b419cac766b4a718d711c Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 5 Aug 2021 11:58:06 -0700 Subject: staging: r8188eu: Remove self assignment in get_rx_power_val_by_reg() Clang warns: drivers/staging/r8188eu/hal/rtl8188e_rf6052.c:344:13: warning: explicitly assigning value of variable of type 'u32' (aka 'unsigned int') to itself [-Wself-assign] writeVal = writeVal; ~~~~~~~~ ^ ~~~~~~~~ 1 warning generated. Remove this branch as it is useless. Reviewed-by: Nick Desaulniers Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210805185807.3296077-3-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index 335b120ce603..77889dc05858 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -340,8 +340,6 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1) writeVal = writeVal - 0x06060606; - else if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT2) - writeVal = writeVal; *(pOutWriteVal+rf) = writeVal; } } -- cgit v1.2.3 From bf7396230f74bf4e9d0da4f703fc73b27a8f01df Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 5 Aug 2021 11:58:07 -0700 Subject: staging: r8188eu: Remove pointless NULL check in rtw_check_join_candidate() Clang warns: drivers/staging/r8188eu/core/rtw_mlme.c:1629:28: warning: address of array 'pmlmepriv->assoc_ssid.Ssid' will always evaluate to 'true' [-Wpointer-bool-conversion] if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { ~~~~~~~~~~~~~~~~~~~~~~^~~~ ~~ 1 warning generated. Ssid is an array not at the beginning of a struct so its address cannot be NULL so remove the check. Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210805185807.3296077-4-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index e3d5a721d25c..95b952871e67 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1622,7 +1622,7 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv } /* check ssid, if needed */ - if (pmlmepriv->assoc_ssid.Ssid && pmlmepriv->assoc_ssid.SsidLength) { + if (pmlmepriv->assoc_ssid.SsidLength) { if (competitor->network.Ssid.SsidLength != pmlmepriv->assoc_ssid.SsidLength || memcmp(competitor->network.Ssid.Ssid, pmlmepriv->assoc_ssid.Ssid, pmlmepriv->assoc_ssid.SsidLength)) goto exit; -- cgit v1.2.3 From 0e08f5b76a3c6636a78455a7aeaaa311890c7532 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:39 -0500 Subject: staging: r8188eu: Remove rtw_yield_os() This wrapper is just a call to yield(). Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805192644.15978-1-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 2 -- drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 4 files changed, 2 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 470c338b44e1..fe24f72a3cf1 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -6260,7 +6260,7 @@ unsigned int send_beacon(struct adapter *padapter) issue_beacon(padapter, 100); issue++; do { - rtw_yield_os(); + yield(); rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); poll++; } while ((poll%10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index f33bf732eeaf..be41e3700969 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -625,7 +625,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) SetFwRsvdPagePkt(adapt, false); DLBcnCount++; do { - rtw_yield_os(); + yield(); /* rtw_mdelay_os(10); */ /* check rsvd page download OK. */ rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 10f0203fd905..87315d1a5c72 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -240,8 +240,6 @@ u32 rtw_atoi(u8 *s); void rtw_mdelay_os(int ms); void rtw_udelay_os(int us); -void rtw_yield_os(void); - static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) { return del_timer_sync(ptimer); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 232d3a337be4..e0eddf44b5c7 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -156,11 +156,6 @@ void rtw_udelay_os(int us) udelay((unsigned long)us); } -void rtw_yield_os(void) -{ - yield(); -} - #define RTW_SUSPEND_LOCK_NAME "rtw_wifi" static const struct device_type wlan_type = { -- cgit v1.2.3 From d21edee5a4276b1c25bf0599846842396c892d5c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:40 -0500 Subject: staging: r8188eu: Remove wrapper routine rtw_msleep_os() The effect of this macro is to call msleep(). Remove the wrapper. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805192644.15978-2-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mlme.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 16 ++++++++-------- drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 6 +++--- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 4 ++-- drivers/staging/r8188eu/core/rtw_xmit.c | 4 ++-- drivers/staging/r8188eu/hal/odm_interface.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 6 +++--- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/ioctl_linux.c | 10 +++++----- drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 12 files changed, 29 insertions(+), 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 720b534c29ad..3462543ae143 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -81,7 +81,7 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) _cancel_workitem_sync(&pevtpriv->c2h_wk); while (pevtpriv->c2h_wk_alive) - rtw_msleep_os(10); + msleep(10); while (!rtw_cbuf_empty(pevtpriv->c2h_queue)) { void *c2h = rtw_cbuf_pop(pevtpriv->c2h_queue); @@ -1820,7 +1820,7 @@ static void rtw_chk_hi_queue_hdl(struct adapter *padapter) rtw_hal_get_hwreg(padapter, HW_VAR_CHK_HI_QUEUE_EMPTY, &val); while (!val) { - rtw_msleep_os(100); + msleep(100); cnt++; diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 95b952871e67..ea1e6d1cd2b7 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1001,7 +1001,7 @@ void rtw_scan_abort(struct adapter *adapter) if (adapter->bDriverStopped || adapter->bSurpriseRemoved) break; DBG_88E(FUNC_NDEV_FMT"fw_state=_FW_UNDER_SURVEY!\n", FUNC_NDEV_ARG(adapter->pnetdev)); - rtw_msleep_os(20); + msleep(20); } if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { if (!adapter->bDriverStopped && !adapter->bSurpriseRemoved) diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index fe24f72a3cf1..a9a4007ce063 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -3776,7 +3776,7 @@ int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, int wait break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -4913,7 +4913,7 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); @@ -5628,7 +5628,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -5751,7 +5751,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -5862,7 +5862,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int break; if (i < try_cnt && wait_ms > 0 && ret == _FAIL) - rtw_msleep_os(wait_ms); + msleep(wait_ms); } while ((i < try_cnt) && ((ret == _FAIL) || (wait_ms == 0))); if (ret != _FAIL) { @@ -6350,7 +6350,7 @@ void site_survey(struct adapter *padapter) if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { /* todo: to issue two probe req??? */ issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); - /* rtw_msleep_os(SURVEY_TO>>1); */ + /* msleep(SURVEY_TO>>1); */ issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); } } @@ -6358,7 +6358,7 @@ void site_survey(struct adapter *padapter) if (pmlmeext->sitesurvey_res.scan_mode == SCAN_ACTIVE) { /* todo: to issue two probe req??? */ issue_probereq(padapter, NULL, NULL); - /* rtw_msleep_os(SURVEY_TO>>1); */ + /* msleep(SURVEY_TO>>1); */ issue_probereq(padapter, NULL, NULL); } } @@ -8255,7 +8255,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { - rtw_msleep_os(10);/* 10ms, ATIM(HIQ) Windows */ + msleep(10);/* 10ms, ATIM(HIQ) Windows */ spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 9ff0a19cc680..76db563d3969 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -591,7 +591,7 @@ static int mp_xmit_packet_thread(void *context) padapter->bDriverStopped) { goto exit; } else { - rtw_msleep_os(1); + msleep(1); continue; } } @@ -895,7 +895,7 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data) i++; } - rtw_msleep_os(100); + msleep(100); return strlen(data)+1; } diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index f465acfa20b8..8fcc74598e5f 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -513,7 +513,7 @@ int rtl8188eu_oid_rt_pro_set_continuous_tx_hdl(struct oid_par_priv *poid_par_pri if (pmp_priv->tx.stop == 0) { pmp_priv->tx.stop = 1; DBG_88E("%s: pkt tx is running...\n", __func__); - rtw_msleep_os(5); + msleep(5); } pmp_priv->tx.stop = 0; pmp_priv->tx.count = 1; @@ -542,7 +542,7 @@ int rtl8188eu_oid_rt_pro_set_single_carrier_tx_hdl(struct oid_par_priv *poid_par if (pmp_priv->tx.stop == 0) { pmp_priv->tx.stop = 1; DBG_88E("%s: pkt tx is running...\n", __func__); - rtw_msleep_os(5); + msleep(5); } pmp_priv->tx.stop = 0; pmp_priv->tx.count = 1; @@ -571,7 +571,7 @@ int rtl8188eu_oid_rt_pro_set_carrier_suppression_tx_hdl(struct oid_par_priv *poi if (pmp_priv->tx.stop == 0) { pmp_priv->tx.stop = 1; DBG_88E("%s: pkt tx is running...\n", __func__); - rtw_msleep_os(5); + msleep(5); } pmp_priv->tx.stop = 0; pmp_priv->tx.count = 1; diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 967c9623e7d1..57cd10205d6c 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -507,7 +507,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal if (pwrpriv->ps_processing) { DBG_88E("%s wait ps_processing...\n", __func__); while (pwrpriv->ps_processing && rtw_get_passing_time_ms(start) <= 3000) - rtw_msleep_os(10); + msleep(10); if (pwrpriv->ps_processing) DBG_88E("%s wait ps_processing timeout\n", __func__); else @@ -519,7 +519,7 @@ int _rtw_pwr_wakeup(struct adapter *padapter, u32 ips_deffer_ms, const char *cal while (pwrpriv->bInSuspend && (rtw_get_passing_time_ms(start) <= 3000 || (rtw_get_passing_time_ms(start) <= 500))) - rtw_msleep_os(10); + msleep(10); if (pwrpriv->bInSuspend) DBG_88E("%s wait bInSuspend timeout\n", __func__); else diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index edd5746be556..036f1f9a5d0f 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -134,7 +134,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) /* Tx buf allocation may fail sometimes, so sleep and retry. */ res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) { - rtw_msleep_os(10); + msleep(10); res = rtw_os_xmit_resource_alloc(padapter, pxmitbuf, (MAX_XMITBUF_SZ + XMITBUF_ALIGN_SZ)); if (res == _FAIL) { goto exit; @@ -652,7 +652,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr rtw_secmicsetkey(&micdata, psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey); } else { if (!memcmp(&stainfo->dot11tkiptxmickey.skey[0], null_key, 16)) { - /* rtw_msleep_os(10); */ + /* msleep(10); */ return _FAIL; } /* start to calculate the mic code */ diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index 38f6ae410e53..d39556d4a347 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -147,7 +147,7 @@ void ODM_delay_us(u32 us) void ODM_sleep_ms(u32 ms) { - rtw_msleep_os(ms); + msleep(ms); } void ODM_sleep_us(u32 us) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index 3defe1a6904d..cc24684945ef 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -541,7 +541,7 @@ u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter) void Hal_GetThermalMeter(struct adapter *pAdapter, u8 *value) { Hal_TriggerRFThermalMeter(pAdapter); - rtw_msleep_os(1000); + msleep(1000); *value = Hal_ReadRFThermalMeter(pAdapter); } @@ -571,7 +571,7 @@ void Hal_SetSingleCarrierTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMContinueTx, bDisable); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); - rtw_msleep_os(10); + msleep(10); /* BB Reset */ write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); @@ -773,7 +773,7 @@ void Hal_SetOFDMContinuousTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleCarrier, bDisable); write_bbreg(pAdapter, rOFDM1_LSTF, bOFDMSingleTone, bDisable); /* Delay 10 ms */ - rtw_msleep_os(10); + msleep(10); /* BB Reset */ write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x0); write_bbreg(pAdapter, rPMAC_Reset, bBBResetB, 0x1); diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 87315d1a5c72..5b83f2efd94c 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -232,7 +232,6 @@ s32 rtw_get_time_interval_ms(u32 start, u32 end); void rtw_sleep_schedulable(int ms); -void rtw_msleep_os(int ms); void rtw_usleep_os(int us); u32 rtw_atoi(u8 *s); diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 11301e0f287a..34dce01e469c 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1431,7 +1431,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; while (check_fwstate(pmlmepriv, wait_status)) { - rtw_msleep_os(30); + msleep(30); cnt++; if (cnt > wait_for_surveydone) break; @@ -2566,7 +2566,7 @@ static int rtw_get_ap_info(struct net_device *dev, } while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { - rtw_msleep_os(30); + msleep(30); cnt++; if (cnt > 100) break; @@ -6957,7 +6957,7 @@ static int rtw_mp_ctx(struct net_device *dev, struct mp_priv *pmp_priv = &padapter->mppriv; if (pmp_priv->tx.stop == 0) { pmp_priv->tx.stop = 1; - rtw_msleep_os(5); + msleep(5); } pmp_priv->tx.stop = 0; pmp_priv->tx.count = 1; @@ -7172,7 +7172,7 @@ static int rtw_mp_reset_stats(struct net_device *dev, /* reset phy counter */ write_bbreg(padapter, 0xf14, BIT16, 0x1); - rtw_msleep_os(10); + msleep(10); write_bbreg(padapter, 0xf14, BIT16, 0x0); return 0; @@ -7449,7 +7449,7 @@ static int rtw_mp_get(struct net_device *dev, break; } - rtw_msleep_os(10); /* delay 5ms for sending pkt before exit adb shell operation */ + msleep(10); /* delay 5ms for sending pkt before exit adb shell operation */ return 0; } diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index e0eddf44b5c7..a29d10f281e9 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -133,11 +133,6 @@ void rtw_sleep_schedulable(int ms) return; } -void rtw_msleep_os(int ms) -{ - msleep((unsigned int)ms); -} - void rtw_usleep_os(int us) { if (1 < (us/1000)) -- cgit v1.2.3 From e72e1495c6f77b47598aab1a5df0413d4b883b7d Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:41 -0500 Subject: staging: r8188eu: Remove wrapper rtw_mdelay_os() This wrapper just calls mdelay(). Remove it. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805192644.15978-3-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- drivers/staging/r8188eu/hal/odm_interface.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 2 +- drivers/staging/r8188eu/hal/usb_halinit.c | 2 +- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 6 files changed, 5 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 76db563d3969..252d5c37d813 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -840,11 +840,11 @@ static u32 rtw_GetPSDData(struct adapter *pAdapter, u32 point) psd_val |= point; rtw_write32(pAdapter, 0x808, psd_val); - rtw_mdelay_os(1); + mdelay(1); psd_val |= 0x00400000; rtw_write32(pAdapter, 0x808, psd_val); - rtw_mdelay_os(1); + mdelay(1); psd_val = rtw_read32(pAdapter, 0x8B4); psd_val &= 0x0000FFFF; diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index d39556d4a347..a64eeb5ae2e2 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -137,7 +137,7 @@ void ODM_StallExecution(u32 usDelay) void ODM_delay_ms(u32 ms) { - rtw_mdelay_os(ms); + mdelay(ms); } void ODM_delay_us(u32 us) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index be41e3700969..712307bc674f 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -626,7 +626,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) DLBcnCount++; do { yield(); - /* rtw_mdelay_os(10); */ + /* mdelay(10); */ /* check rsvd page download OK. */ rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); poll++; diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index c2d9c0359e64..6ecadba17963 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -1846,7 +1846,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) /* RQPN Load 0 */ rtw_write16(Adapter, REG_RQPN_NPQ, 0x0); rtw_write32(Adapter, REG_RQPN, 0x80000000); - rtw_mdelay_os(10); + mdelay(10); } } break; diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 5b83f2efd94c..16d6df702788 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -236,7 +236,6 @@ void rtw_usleep_os(int us); u32 rtw_atoi(u8 *s); -void rtw_mdelay_os(int ms); void rtw_udelay_os(int us); static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index a29d10f281e9..99497bb11e0b 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -141,11 +141,6 @@ void rtw_usleep_os(int us) msleep((us/1000) + 1); } -void rtw_mdelay_os(int ms) -{ - mdelay((unsigned long)ms); -} - void rtw_udelay_os(int us) { udelay((unsigned long)us); -- cgit v1.2.3 From 49f2a554eb408b75773a42bc1132fe14f825abf7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:42 -0500 Subject: staging: r8188eu: Remove wrapper rtw_udelay_os() This wrapper is a simple call to udelay(). Remove it. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805192644.15978-4-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_efuse.c | 2 +- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 6 +++--- drivers/staging/r8188eu/hal/odm_interface.c | 4 ++-- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 6 +++--- drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 8 ++++---- drivers/staging/r8188eu/include/osdep_service.h | 2 -- drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 8 files changed, 14 insertions(+), 21 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index 3e53ec522519..6e790f529d61 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -186,7 +186,7 @@ ReadEFuseByte( /* This fix the problem that Efuse read error in high temperature condition. */ /* Designer says that there shall be some delay after ready bit is set, or the */ /* result will always stay on last data we read. */ - rtw_udelay_os(50); + udelay(50); value32 = rtw_read32(Adapter, EFUSE_CTRL); *pbuf = (u8)(value32 & 0xff); diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index e092563a3577..37bca779ee00 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -66,7 +66,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) poll_bit = true; else - rtw_udelay_os(10); + udelay(10); if (poll_count++ > max_poll_count) { DBG_88E("Fail to polling Offset[%#x]\n", offset); @@ -76,9 +76,9 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, break; case PWR_CMD_DELAY: if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) - rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else - rtw_udelay_os(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index a64eeb5ae2e2..239a9703bb34 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -132,7 +132,7 @@ void ODM_IsWorkItemScheduled(void *pRtWorkItem) /* ODM Timer relative API. */ void ODM_StallExecution(u32 usDelay) { - rtw_udelay_os(usDelay); + udelay(usDelay); } void ODM_delay_ms(u32 ms) @@ -142,7 +142,7 @@ void ODM_delay_ms(u32 ms) void ODM_delay_us(u32 us) { - rtw_udelay_os(us); + udelay(us); } void ODM_sleep_ms(u32 ms) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 9b0d02a759a4..732d42ab3e0d 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -533,7 +533,7 @@ static s32 _FWFreeToGo(struct adapter *padapter) DBG_88E("%s: Polling FW ready success!! REG_MCUFWDL:0x%08x\n", __func__, value32); return _SUCCESS; } - rtw_udelay_os(5); + udelay(5); } while (counter++ < POLLING_READY_TIMEOUT_COUNT); DBG_88E("%s: Polling FW ready fail!! REG_MCUFWDL:0x%08x\n", __func__, value32); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index 37f2342ddbaa..58d8e0113490 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -170,12 +170,12 @@ phy_RFSerialRead( tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong&(~bLSSIReadEdge)); - rtw_udelay_os(10);/* PlatformStallExecution(10); */ + udelay(10);/* PlatformStallExecution(10); */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2); - rtw_udelay_os(100);/* PlatformStallExecution(100); */ + udelay(100);/* PlatformStallExecution(100); */ - rtw_udelay_os(10);/* PlatformStallExecution(10); */ + udelay(10);/* PlatformStallExecution(10); */ if (eRFPath == RF_PATH_A) RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT8); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index 77889dc05858..6628ad1eb1bb 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -480,18 +480,18 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) } /*----Set RF_ENV enable----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ PHY_SetBBReg(Adapter, pPhyReg->rfintfo, bRFSI_RFENV, 0x1); - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ /* Set bit number of Address and Data for RF register */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireAddressLength, 0x0); /* Set 1 to 4 bits for 8255 */ - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, b3WireDataLength, 0x0); /* Set 0 to 12 bits for 8255 */ - rtw_udelay_os(1);/* PlatformStallExecution(1); */ + udelay(1);/* PlatformStallExecution(1); */ /*----Initialize RF fom connfiguration file----*/ switch (eRFPath) { diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 16d6df702788..eb993a030953 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -236,8 +236,6 @@ void rtw_usleep_os(int us); u32 rtw_atoi(u8 *s); -void rtw_udelay_os(int us); - static inline unsigned char _cancel_timer_ex(struct timer_list *ptimer) { return del_timer_sync(ptimer); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 99497bb11e0b..2192250f21d4 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -141,11 +141,6 @@ void rtw_usleep_os(int us) msleep((us/1000) + 1); } -void rtw_udelay_os(int us) -{ - udelay((unsigned long)us); -} - #define RTW_SUSPEND_LOCK_NAME "rtw_wifi" static const struct device_type wlan_type = { -- cgit v1.2.3 From 8b2403d0d355008cdcd1975072e12862977eeaa8 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:43 -0500 Subject: staging: r8188eu: Remove wrapper rtw_get_time_interval_ms() This one is never used. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805192644.15978-5-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 5 ----- 2 files changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index eb993a030953..1d1889539973 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -228,7 +228,6 @@ void _rtw_init_queue(struct __queue *pqueue); u32 rtw_systime_to_ms(u32 systime); u32 rtw_ms_to_systime(u32 ms); s32 rtw_get_passing_time_ms(u32 start); -s32 rtw_get_time_interval_ms(u32 start, u32 end); void rtw_sleep_schedulable(int ms); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 2192250f21d4..79f12b0d643e 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -116,11 +116,6 @@ inline s32 rtw_get_passing_time_ms(u32 start) return rtw_systime_to_ms(jiffies-start); } -inline s32 rtw_get_time_interval_ms(u32 start, u32 end) -{ - return rtw_systime_to_ms(end-start); -} - void rtw_sleep_schedulable(int ms) { u32 delta; -- cgit v1.2.3 From 4a956abc170acc8c096b86d6e7f2b02b024b25f7 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Thu, 5 Aug 2021 14:26:44 -0500 Subject: staging: r8188eu: Remove wrapper rtw_sleep_schedulable() This wrapper is never used. Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210805192644.15978-6-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 2 -- drivers/staging/r8188eu/os_dep/osdep_service.c | 12 ------------ 2 files changed, 14 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 1d1889539973..7e002009f9a0 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -229,8 +229,6 @@ u32 rtw_systime_to_ms(u32 systime); u32 rtw_ms_to_systime(u32 ms); s32 rtw_get_passing_time_ms(u32 start); -void rtw_sleep_schedulable(int ms); - void rtw_usleep_os(int us); u32 rtw_atoi(u8 *s); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 79f12b0d643e..9f097f2b3ddd 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -116,18 +116,6 @@ inline s32 rtw_get_passing_time_ms(u32 start) return rtw_systime_to_ms(jiffies-start); } -void rtw_sleep_schedulable(int ms) -{ - u32 delta; - - delta = (ms * HZ)/1000;/* ms) */ - if (delta == 0) - delta = 1;/* 1 ms */ - set_current_state(TASK_INTERRUPTIBLE); - if (schedule_timeout(delta) != 0) - return; -} - void rtw_usleep_os(int us) { if (1 < (us/1000)) -- cgit v1.2.3 From b72290ce7da235f458316978bf0d38fb10640e50 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:24 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_cmd.c Remove RT_TRACE macro calls from core/rtw_cmd.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 66 ++++------------------------------ 1 file changed, 7 insertions(+), 59 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 3462543ae143..c3a9051ca10c 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -76,9 +76,6 @@ int _rtw_init_evt_priv(struct evt_priv *pevtpriv) void rtw_free_evt_priv(struct evt_priv *pevtpriv) { - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+rtw_free_evt_priv\n")); - _cancel_workitem_sync(&pevtpriv->c2h_wk); while (pevtpriv->c2h_wk_alive) msleep(10); @@ -88,8 +85,6 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) if (c2h && c2h != (void *)pevtpriv) kfree(c2h); } - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("-rtw_free_evt_priv\n")); - } void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) @@ -170,10 +165,7 @@ u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) void rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) { - - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("rtw_free_cmd_priv\n")); _rtw_free_cmd_priv(pcmdpriv); - } static int rtw_cmd_filter(struct cmd_priv *pcmdpriv, struct cmd_obj *cmd_obj) @@ -279,8 +271,6 @@ int rtw_cmd_thread(void *context) pcmdpriv->cmdthd_running = true; up(&pcmdpriv->terminate_cmdthread_sema); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("start r871x rtw_cmd_thread !!!!\n")); - while (1) { if (_rtw_down_sema(&pcmdpriv->cmd_queue_sema) == _FAIL) break; @@ -334,15 +324,12 @@ post_process: /* call callback function for post-processed */ if (pcmd->cmdcode < ARRAY_SIZE(rtw_cmd_callback)) { pcmd_callback = rtw_cmd_callback[pcmd->cmdcode].callback; - if (!pcmd_callback) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("mlme_cmd_hdl(): pcmd_callback = 0x%p, cmdcode = 0x%x\n", pcmd_callback, pcmd->cmdcode)); + if (!pcmd_callback) rtw_free_cmd_obj(pcmd); - } else { + else /* todo: !!! fill rsp_buf to pcmd->rsp if (pcmd->rsp!= NULL) */ pcmd_callback(pcmd->padapter, pcmd);/* need conider that free cmd_obj in rtw_cmd_callback */ - } } else { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("%s: cmdcode = 0x%x callback not defined!\n", __func__, pcmd->cmdcode)); rtw_free_cmd_obj(pcmd); } @@ -434,8 +421,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, rtw_free_network_queue(padapter, false); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("%s: flush network queue\n", __func__)); - init_h2fwcmd_w_parm_no_rsp(ph2c, psurveyPara, GEN_CMD_CODE(_SiteSurvey)); /* psurveyPara->bsslimit = 48; */ @@ -576,8 +561,6 @@ u8 rtw_setphy_cmd(struct adapter *padapter, u8 modem, u8 ch) init_h2fwcmd_w_parm_no_rsp(ph2c, psetphypara, _SetPhy_CMD_); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("CH =%d, modem =%d", ch, modem)); - psetphypara->modem = modem; psetphypara->rfchannel = ch; @@ -747,17 +730,11 @@ u8 rtw_createbss_cmd(struct adapter *padapter) { struct cmd_obj *pcmd; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; u8 res = _SUCCESS; rtw_led_control(padapter, LED_CTL_START_TO_LINK); - if (pmlmepriv->assoc_ssid.SsidLength == 0) - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for Any SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - else - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, (" createbss for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); if (!pcmd) { res = _FAIL; @@ -821,16 +798,9 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) rtw_led_control(padapter, LED_CTL_START_TO_LINK); - if (pmlmepriv->assoc_ssid.SsidLength == 0) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_info_, ("+Join cmd: Any SSid\n")); - } else { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+Join cmd: SSid =[%s]\n", pmlmepriv->assoc_ssid.Ssid)); - } - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmd) { res = _FAIL; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd: memory allocate for cmd_obj fail!!!\n")); goto exit; } /* for IEs is fix buf size */ @@ -859,8 +829,6 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) res = _FAIL; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("rtw_joinbss_cmd :psecnetwork == NULL!!!\n")); - goto exit; } @@ -947,8 +915,6 @@ u8 rtw_disassoc_cmd(struct adapter *padapter, u32 deauth_timeout_ms, bool enqueu struct cmd_priv *cmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_disassoc_cmd\n")); - /* prepare cmd parameter */ param = kzalloc(sizeof(*param), GFP_ATOMIC); if (!param) { @@ -1357,8 +1323,6 @@ u8 rtw_set_chplan_cmd(struct adapter *padapter, u8 chplan, u8 enqueue) u8 res = _SUCCESS; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_chplan_cmd\n")); - /* check input parameter */ if (!rtw_is_channel_plan_valid(chplan)) { res = _FAIL; @@ -1410,8 +1374,6 @@ u8 rtw_led_blink_cmd(struct adapter *padapter, struct LED_871x *pLed) u8 res = _SUCCESS; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_led_blink_cmd\n")); - pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmdobj) { res = _FAIL; @@ -1443,8 +1405,6 @@ u8 rtw_set_csa_cmd(struct adapter *padapter, u8 new_ch_no) u8 res = _SUCCESS; - RT_TRACE(_module_rtl871x_cmd_c_, _drv_notice_, ("+rtw_set_csa_cmd\n")); - pcmdobj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmdobj) { res = _FAIL; @@ -2040,7 +2000,6 @@ void rtw_survey_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) _set_timer(&pmlmepriv->scan_to_timer, 1); } else if (pcmd->res != H2C_SUCCESS) { _set_timer(&pmlmepriv->scan_to_timer, 1); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: MgntActrtw_set_802_11_bssid_LIST_SCAN Fail ************\n\n.")); } /* free cmd */ @@ -2056,7 +2015,6 @@ void rtw_disassoc_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) set_fwstate(pmlmepriv, _FW_LINKED); spin_unlock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ***Error: disconnect_cmd_callback Fail ***\n.")); return; } else /* clear bridge database */ nat25_db_cleanup(padapter); @@ -2074,7 +2032,6 @@ void rtw_joinbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) /* need to make timeout handlerOS independent */ _set_timer(&pmlmepriv->assoc_timer, 1); } else if (pcmd->res != H2C_SUCCESS) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("********Error:rtw_select_and_join_from_scanned_queue Wait Sema Fail ************\n")); _set_timer(&pmlmepriv->assoc_timer, 1); } @@ -2090,10 +2047,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; struct wlan_network *tgt_network = &(pmlmepriv->cur_network); - if ((pcmd->res != H2C_SUCCESS)) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n ********Error: rtw_createbss_cmd_callback Fail ************\n\n.")); + if ((pcmd->res != H2C_SUCCESS)) _set_timer(&pmlmepriv->assoc_timer, 1); - } _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); @@ -2103,10 +2058,8 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) psta = rtw_get_stainfo(&padapter->stapriv, pnetwork->MacAddress); if (!psta) { psta = rtw_alloc_stainfo(&padapter->stapriv, pnetwork->MacAddress); - if (!psta) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nCan't alloc sta_info when createbss_cmd_callback\n")); - goto createbss_cmd_fail ; - } + if (!psta) + goto createbss_cmd_fail; } rtw_indicate_connect(padapter); @@ -2117,7 +2070,6 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) if (!pwlan) { pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); if (!pwlan) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\n Error: can't get pwlan in rtw_joinbss_event_callback\n")); spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); goto createbss_cmd_fail; } @@ -2151,10 +2103,8 @@ void rtw_setstaKey_cmdrsp_callback(struct adapter *padapter, struct cmd_obj *pc struct set_stakey_rsp *psetstakey_rsp = (struct set_stakey_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, psetstakey_rsp->addr); - if (!psta) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: rtw_setstaKey_cmdrsp_callback => can't get sta_info\n\n")); + if (!psta) goto exit; - } exit: rtw_free_cmd_obj(pcmd); @@ -2168,10 +2118,8 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj * struct set_assocsta_rsp *passocsta_rsp = (struct set_assocsta_rsp *)(pcmd->rsp); struct sta_info *psta = rtw_get_stainfo(pstapriv, passocsta_parm->addr); - if (!psta) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nERROR: setassocsta_cmdrsp_callbac => can't get sta_info\n\n")); + if (!psta) goto exit; - } psta->aid = passocsta_rsp->cam_id; psta->mac_id = passocsta_rsp->cam_id; -- cgit v1.2.3 From ef0661507147179afbab278e1364715fd905b7ab Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:25 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_ioctl_set.c Remove RT_TRACE macro calls from core/rtw_ioctl_set.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 218 +-------------------------- 1 file changed, 7 insertions(+), 211 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 3e2add5409cc..a7f966ad7082 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -26,7 +26,6 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) u8 ret = true; if (ssid->SsidLength > 32) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid length >32\n")); ret = false; goto exit; } @@ -34,7 +33,6 @@ u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) for (i = 0; i < ssid->SsidLength; i++) { /* wifi, printable ascii code must be supported */ if (!((ssid->Ssid[i] >= 0x20) && (ssid->Ssid[i] <= 0x7e))) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("ssid has nonprintabl ascii\n")); ret = false; break; } @@ -57,8 +55,6 @@ u8 rtw_do_join(struct adapter *padapter) phead = get_list_head(queue); plist = phead->next; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("\n rtw_do_join: phead = %p; plist = %p\n\n\n", phead, plist)); - pmlmepriv->cur_network.join_res = -2; set_fwstate(pmlmepriv, _FW_UNDER_LINKING); @@ -76,13 +72,10 @@ u8 rtw_do_join(struct adapter *padapter) if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || pmlmepriv->to_roaming > 0) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("rtw_do_join(): site survey if scanned_queue is empty\n.")); /* submit site_survey_cmd */ ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (_SUCCESS != ret) { + if (_SUCCESS != ret) pmlmepriv->to_join = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_do_join(): site survey return error\n.")); - } } else { pmlmepriv->to_join = false; ret = _FAIL; @@ -116,14 +109,10 @@ u8 rtw_do_join(struct adapter *padapter) rtw_generate_random_ibss(pibss); if (rtw_createbss_cmd(padapter) != _SUCCESS) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error =>do_goin: rtw_createbss_cmd status FAIL***\n ")); ret = false; goto exit; } pmlmepriv->to_join = false; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("***Error => rtw_select_and_join_from_scanned_queue FAIL under STA_Mode***\n ")); } else { /* can't associate ; reset under-linking */ _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); @@ -133,10 +122,8 @@ u8 rtw_do_join(struct adapter *padapter) if (!pmlmepriv->LinkDetectInfo.bBusyTraffic || pmlmepriv->to_roaming > 0) { ret = rtw_sitesurvey_cmd(padapter, &pmlmepriv->assoc_ssid, 1, NULL, 0); - if (_SUCCESS != ret) { + if (_SUCCESS != ret) pmlmepriv->to_join = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("do_join(): site survey return error\n.")); - } } else { ret = _FAIL; pmlmepriv->to_join = false; @@ -175,16 +162,10 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) goto release_mlme_lock; if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); - if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set BSSID not the same bssid\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_bssid =%pM\n", (bssid))); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("cur_bssid =%pM\n", (pmlmepriv->cur_network.network.MacAddress))); - rtw_disassoc_cmd(padapter, 0, true); if (check_fwstate(pmlmepriv, _FW_LINKED) == true) @@ -226,9 +207,6 @@ release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); exit: - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_bssid: status=%d\n", status)); - return status; } @@ -244,8 +222,6 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) ssid->Ssid, get_fwstate(pmlmepriv)); if (!padapter->hw_init_completed) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("set_ssid: hw_init_completed == false =>exit!!!\n")); status = _FAIL; goto exit; } @@ -260,16 +236,9 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) } if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("set_ssid: _FW_LINKED||WIFI_ADHOC_MASTER_STATE\n")); - if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Set SSID is the same ssid, fw_state = 0x%08x\n", - get_fwstate(pmlmepriv))); - if (!rtw_is_same_ibss(padapter, pnetwork)) { /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ rtw_disassoc_cmd(padapter, 0, true); @@ -290,10 +259,6 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_JOINBSS, 1); } } else { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("Set SSID not the same ssid\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_ssid =[%s] len = 0x%x\n", ssid->Ssid, (unsigned int)ssid->SsidLength)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("assoc_ssid =[%s] len = 0x%x\n", pmlmepriv->assoc_ssid.Ssid, (unsigned int)pmlmepriv->assoc_ssid.SsidLength)); - rtw_disassoc_cmd(padapter, 0, true); if (check_fwstate(pmlmepriv, _FW_LINKED) == true) @@ -335,9 +300,6 @@ release_mlme_lock: spin_unlock_bh(&pmlmepriv->lock); exit: - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("-rtw_set_802_11_ssid: status =%d\n", status)); - return status; } @@ -348,14 +310,9 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, struct wlan_network *cur_network = &pmlmepriv->cur_network; enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_notice_, - ("+rtw_set_802_11_infrastructure_mode: old =%d new =%d fw_state = 0x%08x\n", - *pold_state, networktype, get_fwstate(pmlmepriv))); - if (*pold_state != networktype) { spin_lock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, (" change mode!")); /* DBG_88E("change mode, old_mode =%d, new_mode =%d, fw_state = 0x%x\n", *pold_state, networktype, get_fwstate(pmlmepriv)); */ if (*pold_state == Ndis802_11APMode) { @@ -414,9 +371,6 @@ u8 rtw_set_802_11_disassociate(struct adapter *padapter) spin_lock_bh(&pmlmepriv->lock); if (check_fwstate(pmlmepriv, _FW_LINKED)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("MgntActrtw_set_802_11_disassociate: rtw_indicate_disconnect\n")); - rtw_disassoc_cmd(padapter, 0, true); rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); @@ -433,29 +387,19 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 res = true; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("+rtw_set_802_11_bssid_list_scan(), fw_state =%x\n", get_fwstate(pmlmepriv))); - if (!padapter) { res = false; goto exit; } if (!padapter->hw_init_completed) { res = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n === rtw_set_802_11_bssid_list_scan:hw_init_completed == false ===\n")); goto exit; } if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || (pmlmepriv->LinkDetectInfo.bBusyTraffic)) { /* Scan or linking is in progress, do nothing. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("rtw_set_802_11_bssid_list_scan fail since fw_state = %x\n", get_fwstate(pmlmepriv))); res = true; - - if (check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)) == true) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###_FW_UNDER_SURVEY|_FW_UNDER_LINKING\n\n")); - } else { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n###pmlmepriv->sitesurveyctrl.traffic_busy == true\n\n")); - } } else { if (rtw_is_scan_deny(padapter)) { DBG_88E(FUNC_ADPT_FMT": scan deny\n", FUNC_ADPT_ARG(padapter)); @@ -480,14 +424,8 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 int res; u8 ret; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("set_802_11_auth.mode(): mode =%x\n", authmode)); - psecuritypriv->ndisauthtype = authmode; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_authentication_mode:psecuritypriv->ndisauthtype=%d", - psecuritypriv->ndisauthtype)); - if (psecuritypriv->ndisauthtype > 3) psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; @@ -510,7 +448,6 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) keyid = wep->KeyIndex & 0x3fffffff; if (keyid >= 4) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MgntActrtw_set_802_11_add_wep:keyid>4 =>fail\n")); ret = false; goto exit; } @@ -518,20 +455,14 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) switch (wep->KeyLength) { case 5: psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 5\n")); break; case 13: psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength = 13\n")); break; default: psecuritypriv->dot11PrivacyAlgrthm = _NO_PRIVACY_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, ("MgntActrtw_set_802_11_add_wep:wep->KeyLength!= 5 or 13\n")); break; } - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep:befor memcpy, wep->KeyLength = 0x%x wep->KeyIndex = 0x%x keyid =%x\n", - wep->KeyLength, wep->KeyIndex, keyid)); memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); @@ -539,22 +470,6 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) psecuritypriv->dot11PrivacyKeyIndex = keyid; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_wep:security key material : %x %x %x %x %x %x %x %x %x %x %x %x %x\n", - psecuritypriv->dot11DefKey[keyid].skey[0], - psecuritypriv->dot11DefKey[keyid].skey[1], - psecuritypriv->dot11DefKey[keyid].skey[2], - psecuritypriv->dot11DefKey[keyid].skey[3], - psecuritypriv->dot11DefKey[keyid].skey[4], - psecuritypriv->dot11DefKey[keyid].skey[5], - psecuritypriv->dot11DefKey[keyid].skey[6], - psecuritypriv->dot11DefKey[keyid].skey[7], - psecuritypriv->dot11DefKey[keyid].skey[8], - psecuritypriv->dot11DefKey[keyid].skey[9], - psecuritypriv->dot11DefKey[keyid].skey[10], - psecuritypriv->dot11DefKey[keyid].skey[11], - psecuritypriv->dot11DefKey[keyid].skey[12])); - res = rtw_set_key(padapter, psecuritypriv, keyid, 1); if (res == _FAIL) @@ -601,15 +516,6 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) if (((key->KeyIndex & 0x80000000) == 0) && ((key->KeyIndex & 0x40000000) > 0)) { /* It is invalid to clear bit 31 and set bit 30. If the miniport driver encounters this combination, */ /* it must fail the request and return NDIS_STATUS_INVALID_DATA. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_key: ((key->KeyIndex & 0x80000000)==0)[=%d]", - (int)(key->KeyIndex & 0x80000000) == 0)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_key:((key->KeyIndex & 0x40000000)>0)[=%d]", - (int)(key->KeyIndex & 0x40000000) > 0)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_info_, - ("rtw_set_802_11_add_key: key->KeyIndex=%d\n", - (int)key->KeyIndex)); ret = _FAIL; goto exit; } @@ -617,54 +523,30 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) if (key->KeyIndex & 0x40000000) { /* Pairwise key */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Pairwise key +++++\n")); - pbssid = get_bssid(&padapter->mlmepriv); stainfo = rtw_get_stainfo(&padapter->stapriv, pbssid); - if (stainfo && padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("OID_802_11_ADD_KEY:(stainfo!=NULL)&&(Adapter->securitypriv.dot11AuthAlgrthm==dot11AuthAlgrthm_8021X)\n")); + if (stainfo && padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) encryptionalgo = stainfo->dot118021XPrivacy; - } else { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: stainfo == NULL)||(Adapter->securitypriv.dot11AuthAlgrthm!= dot11AuthAlgrthm_8021X)\n")); + else encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; - } - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (encryptionalgo==%d)!\n", - encryptionalgo)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11PrivacyAlgrthm==%d)!\n", - padapter->securitypriv.dot11PrivacyAlgrthm)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (Adapter->securitypriv.dot11AuthAlgrthm==%d)!\n", - padapter->securitypriv.dot11AuthAlgrthm)); - - if (stainfo) - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("rtw_set_802_11_add_key: (stainfo->dot118021XPrivacy==%d)!\n", - stainfo->dot118021XPrivacy)); if (key->KeyIndex & 0x000000FF) { /* The key index is specified in the lower 8 bits by values of zero to 255. */ /* The key index should be set to zero for a Pairwise key, and the driver should fail with */ /* NDIS_STATUS_INVALID_DATA if the lower 8 bits is not zero */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, (" key->KeyIndex & 0x000000FF.\n")); ret = _FAIL; goto exit; } /* check BSSID */ if (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == true) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("MacAddr_isBcst(key->BSSID)\n")); ret = false; goto exit; } /* Check key length for TKIP. */ if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("TKIP KeyLength:0x%x != 32\n", key->KeyLength)); ret = _FAIL; goto exit; } @@ -683,95 +565,52 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) /* Check key length for WEP. For NDTEST, 2005.01.27, by rcnjko. */ if ((encryptionalgo == _WEP40_ || encryptionalgo == _WEP104_) && (key->KeyLength != 5 && key->KeyLength != 13)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("WEP KeyLength:0x%x != 5 or 13\n", key->KeyLength)); ret = _FAIL; goto exit; } bgroup = false; - - /* Check the pairwise key. Added by Annie, 2005-07-06. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Pairwise Key set]\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - } else { /* Group key - KeyIndex(BIT30 == 0) */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ Group key +++++\n")); - /* when add wep key through add key and didn't assigned encryption type before */ if ((padapter->securitypriv.ndisauthtype <= 3) && (padapter->securitypriv.dot118021XGrpPrivacy == 0)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("keylen =%d(Adapter->securitypriv.dot11PrivacyAlgrthm=%x )padapter->securitypriv.dot118021XGrpPrivacy(%x)\n", - key->KeyLength, padapter->securitypriv.dot11PrivacyAlgrthm, - padapter->securitypriv.dot118021XGrpPrivacy)); switch (key->KeyLength) { case 5: padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", - padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); break; case 13: padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", - padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); break; default: padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("Adapter->securitypriv.dot11PrivacyAlgrthm=%x key->KeyLength=%u\n", - padapter->securitypriv.dot11PrivacyAlgrthm, key->KeyLength)); break; } encryptionalgo = padapter->securitypriv.dot11PrivacyAlgrthm; - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - (" Adapter->securitypriv.dot11PrivacyAlgrthm=%x\n", - padapter->securitypriv.dot11PrivacyAlgrthm)); - } else { encryptionalgo = padapter->securitypriv.dot118021XGrpPrivacy; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("(Adapter->securitypriv.dot11PrivacyAlgrthm=%x)encryptionalgo(%x)=padapter->securitypriv.dot118021XGrpPrivacy(%x)keylen=%d\n", - padapter->securitypriv.dot11PrivacyAlgrthm, encryptionalgo, - padapter->securitypriv.dot118021XGrpPrivacy, key->KeyLength)); } if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) == true) && (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == false)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - (" IBSS but BSSID is not Broadcast Address.\n")); ret = _FAIL; goto exit; } /* Check key length for TKIP */ if ((encryptionalgo == _TKIP_) && (key->KeyLength != 32)) { - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - (" TKIP GTK KeyLength:%u != 32\n", key->KeyLength)); ret = _FAIL; goto exit; } else if (encryptionalgo == _AES_ && (key->KeyLength != 16 && key->KeyLength != 32)) { /* Check key length for AES */ /* For NDTEST, we allow keylen = 32 in this case. 2005.01.27, by rcnjko. */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("<=== SetInfo, OID_802_11_ADD_KEY: AES GTK KeyLength:%u != 16 or 32\n", - key->KeyLength)); ret = _FAIL; goto exit; } /* Change the key length for EAPPkt9x.vxd. Added by Annie, 2005-11-03. */ - if ((encryptionalgo == _AES_) && (key->KeyLength == 32)) { + if ((encryptionalgo == _AES_) && (key->KeyLength == 32)) key->KeyLength = 16; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("AES key length changed: %u\n", key->KeyLength)); - } if (key->KeyIndex & 0x8000000) {/* error ??? 0x8000_0000 */ bgrouptkey = true; @@ -781,12 +620,6 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) (check_fwstate(&padapter->mlmepriv, _FW_LINKED))) bgrouptkey = true; bgroup = true; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("[Group Key set]\n")); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")) ; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key index: 0x%8x(0x%8x)\n", key->KeyIndex, (key->KeyIndex&0x3))); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("key Length: %d\n", key->KeyLength)) ; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("------------------------------------------\n")); } /* If WEP encryption algorithm, just call rtw_set_802_11_add_wep(). */ @@ -796,15 +629,11 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) u32 len = FIELD_OFFSET(struct ndis_802_11_key, KeyMaterial) + key->KeyLength; struct ndis_802_11_wep *wep = &padapter->securitypriv.ndiswep; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ WEP key +++++\n")); - wep->Length = len; keyindex = key->KeyIndex&0x7fffffff; wep->KeyIndex = keyindex ; wep->KeyLength = key->KeyLength; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY:Before memcpy\n")); - memcpy(wep->KeyMaterial, key->KeyMaterial, key->KeyLength); memcpy(&(padapter->securitypriv.dot11DefKey[keyindex].skey[0]), key->KeyMaterial, key->KeyLength); @@ -816,7 +645,6 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) } if (key->KeyIndex & 0x20000000) { /* SetRSC */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("OID_802_11_ADD_KEY: +++++ SetRSC+++++\n")); if (bgroup) { unsigned long long keysrc = key->KeyRSC & 0x00FFFFFFFFFFFFULL; memcpy(&padapter->securitypriv.dot11Grprxpn, &keysrc, 8); @@ -844,34 +672,9 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) if ((key->KeyIndex & 0x10000000)) { memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); } else { memcpy(&padapter->securitypriv.dot118021XGrptxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 24, 8); memcpy(&padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)], key->KeyMaterial + 16, 8); - - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("\n rtw_set_802_11_add_key:rx mic :0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[0], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[1], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[2], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[3], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[4], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[5], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex) & 0x03)].skey[6], - padapter->securitypriv.dot118021XGrprxmickey[(u8)((key->KeyIndex-1) & 0x03)].skey[7])); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, - ("\n rtw_set_802_11_add_key:set Group mic key!!!!!!!!\n")); } /* set group key by index */ @@ -883,8 +686,6 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) padapter->securitypriv.bcheck_grpkey = false; - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("reset group key")); - res = rtw_set_key(padapter, &padapter->securitypriv, key->KeyIndex, 1); if (res == _FAIL) @@ -908,8 +709,6 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) /* _set_timer(&padapter->securitypriv.tkip_timer, 50); */ - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n========== _set_timer\n")); - /* if TKIP, save the Receive/Transmit MIC key in KeyMaterial[128-255] */ if ((key->KeyIndex & 0x10000000)) { memcpy(&stainfo->dot11tkiptxmickey, key->KeyMaterial + 16, 8); @@ -922,13 +721,10 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) } /* Set key to CAM through H2C command */ - if (bgrouptkey) { /* never go to here */ + if (bgrouptkey) /* never go to here */ res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, false); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(group)\n")); - } else { + else res = rtw_setstakey_cmd(padapter, (unsigned char *)stainfo, true); - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("\n rtw_set_802_11_add_key:rtw_setstakey_cmd(unicast)\n")); - } if (!res) ret = _FAIL; } -- cgit v1.2.3 From 2965d4b44b3e39632c6235aa8981631aa976415e Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:26 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_mlme.c Remove RT_TRACE macro calls from core/rtw_mlme.c, so that ultimately the macro definition itself can eventually be removed. Also remove the (now) empty functions rtw_atimdone_event_callback and rtw_cpwm_event_callback, as well as their declarations and struct inclusions in the relevant header files. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 130 +++---------------------- drivers/staging/r8188eu/include/rtw_mlme.h | 2 - drivers/staging/r8188eu/include/rtw_mlme_ext.h | 4 +- 3 files changed, 14 insertions(+), 122 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index ea1e6d1cd2b7..4768d3ef350e 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -185,7 +185,6 @@ struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *f list_del_init(&pnetwork->list); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("_rtw_alloc_network: ptr=%p\n", plist)); pnetwork->network_type = 0; pnetwork->fixed = false; pnetwork->last_scanned = jiffies; @@ -299,14 +298,10 @@ int rtw_if_up(struct adapter *padapter) int res; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("rtw_if_up:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - padapter->bDriverStopped, padapter->bSurpriseRemoved)); + (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) res = false; - } else { + else res = true; - } return res; } @@ -358,10 +353,7 @@ int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) { - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_mlme_priv\n")); _rtw_free_mlme_priv (pmlmepriv); - } static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) @@ -577,10 +569,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t pnetwork = rtw_alloc_network(pmlmepriv); /* will update scan_time */ - if (!pnetwork) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n\nsomething wrong here\n\n\n")); + if (!pnetwork) goto exit; - } bssid_ex_sz = get_wlan_bssid_ex_sz(target); target->Length = bssid_ex_sz; @@ -688,12 +678,6 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * return bselected; } -/* TODO: Perry: For Power Management */ -void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf) -{ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("receive atimdone_evet\n")); -} - void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) { u32 len; @@ -702,13 +686,9 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) pnetwork = (struct wlan_bssid_ex *)pbuf; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_survey_event_callback, ssid=%s\n", pnetwork->Ssid.Ssid)); - len = get_wlan_bssid_ex_sz(pnetwork); - if (len > (sizeof(struct wlan_bssid_ex))) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n****rtw_survey_event_callback: return a wrong bss ***\n")); + if (len > (sizeof(struct wlan_bssid_ex))) return; - } spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ @@ -753,14 +733,10 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->wps_probe_req_ie = NULL; } - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_surveydone_event_callback: fw_state:%x\n\n", get_fwstate(pmlmepriv))); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { timer_cancelled = 1; _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("nic status=%x, survey done event comes too late!\n", get_fwstate(pmlmepriv))); } spin_unlock_bh(&pmlmepriv->lock); @@ -784,8 +760,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("switching to adhoc master\n")); - memset(&pdev_network->Ssid, 0, sizeof(struct ndis_802_11_ssid)); memcpy(&pdev_network->Ssid, &pmlmepriv->assoc_ssid, sizeof(struct ndis_802_11_ssid)); @@ -794,8 +768,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; - if (rtw_createbss_cmd(adapter) != _SUCCESS) - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error=>rtw_createbss_cmd status FAIL\n")); + rtw_createbss_cmd(adapter); pmlmepriv->to_join = false; } } @@ -853,7 +826,6 @@ static void free_scanqueue(struct mlme_priv *pmlmepriv) struct __queue *scan_queue = &pmlmepriv->scanned_queue; struct list_head *plist, *phead, *ptemp; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+free_scanqueue\n")); spin_lock_bh(&scan_queue->lock); spin_lock_bh(&free_queue->lock); @@ -882,11 +854,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) struct sta_priv *pstapriv = &adapter->stapriv; struct wlan_network *tgt_network = &pmlmepriv->cur_network; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_free_assoc_resources\n")); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("tgt_network->network.MacAddress=%pM ssid=%s\n", - tgt_network->network.MacAddress, tgt_network->network.Ssid.Ssid)); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_AP_STATE)) { struct sta_info *psta; @@ -916,8 +883,6 @@ void rtw_free_assoc_resources(struct adapter *adapter, int lock_scanned_queue) pwlan = rtw_find_network(&pmlmepriv->scanned_queue, tgt_network->network.MacAddress); if (pwlan) pwlan->fixed = false; - else - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_free_assoc_resources:pwlan==NULL\n\n")); if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) && (adapter->stapriv.asoc_sta_count == 1))) rtw_free_network_nolock(pmlmepriv, pwlan); @@ -935,8 +900,6 @@ void rtw_indicate_connect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_connect\n")); - pmlmepriv->to_join = false; if (!check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { @@ -950,9 +913,6 @@ void rtw_indicate_connect(struct adapter *padapter) pmlmepriv->to_roaming = 0; rtw_set_scan_deny(padapter, 3000); - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("-rtw_indicate_connect: fw_state=0x%08x\n", get_fwstate(pmlmepriv))); - } /* @@ -962,8 +922,6 @@ void rtw_indicate_disconnect(struct adapter *padapter) { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_indicate_disconnect\n")); - _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING | WIFI_UNDER_WPS); if (pmlmepriv->to_roaming > 0) @@ -1085,10 +1043,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net DBG_88E("%s\n", __func__); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("\nfw_state:%x, BSSID:%pM\n", - get_fwstate(pmlmepriv), pnetwork->network.MacAddress)); - /* why not use ptarget_wlan?? */ memcpy(&cur_network->network, &pnetwork->network, pnetwork->network.Length); /* some IEs in pnetwork is wrong, so we should use ptarget_wlan IEs */ @@ -1117,7 +1071,6 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net break; default: pmlmepriv->fw_state = WIFI_NULL_STATE; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Invalid network_mode\n")); break; } @@ -1145,27 +1098,16 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; unsigned int the_same_macaddr = false; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("joinbss event call back received with res=%d\n", pnetwork->join_res)); - rtw_get_encrypt_decrypt_from_registrypriv(adapter); - if (pmlmepriv->assoc_ssid.SsidLength == 0) - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ joinbss event call back for Any SSid\n")); - else - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("@@@@@ rtw_joinbss_event_callback for SSid:%s\n", pmlmepriv->assoc_ssid.Ssid)); - the_same_macaddr = !memcmp(pnetwork->network.MacAddress, cur_network->network.MacAddress, ETH_ALEN); pnetwork->network.Length = get_wlan_bssid_ex_sz(&pnetwork->network); - if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("\n\n ***joinbss_evt_callback return a wrong bss ***\n\n")); + if (pnetwork->network.Length > sizeof(struct wlan_bssid_ex)) return; - } spin_lock_bh(&pmlmepriv->lock); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("\nrtw_joinbss_event_callback!! spin_lock_init\n")); - if (pnetwork->join_res > 0) { spin_lock_bh(&pmlmepriv->scanned_queue.lock); if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { @@ -1203,7 +1145,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (ptarget_wlan) { rtw_joinbss_update_network(adapter, ptarget_wlan, pnetwork); } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't find ptarget_wlan when joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } @@ -1212,7 +1153,6 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); if (!ptarget_sta) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't update stainfo when joinbss_event callback\n")); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } @@ -1222,18 +1162,11 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { pmlmepriv->cur_network_scanned = ptarget_wlan; rtw_indicate_connect(adapter); - } else { - /* adhoc mode will rtw_indicate_connect when rtw_stassoc_event_callback */ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("adhoc mode, fw_state:%x", get_fwstate(pmlmepriv))); } /* s5. Cancle assoc_timer */ _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("Cancle assoc_timer\n")); - } else { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("rtw_joinbss_event_callback err: fw_state:%x", get_fwstate(pmlmepriv))); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto ignore_joinbss_callback; } @@ -1244,10 +1177,8 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) rtw_reset_securitypriv(adapter); _set_timer(&pmlmepriv->assoc_timer, 1); - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("fail! clear _FW_UNDER_LINKING ^^^fw_state=%x\n", get_fwstate(pmlmepriv))); + if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - } } else { /* if join_res < 0 (join fails), then try again */ _set_timer(&pmlmepriv->assoc_timer, 1); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); @@ -1335,16 +1266,12 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) #endif /* for AD-HOC mode */ psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (psta) { + if (psta) /* the sta have been in sta_info_queue => do nothing */ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Error: rtw_stassoc_event_callback: sta has been in sta_hash_queue\n")); return; /* between drv has received this event before and fw have not yet to set key to CAM_ENTRY) */ - } psta = rtw_alloc_stainfo(&adapter->stapriv, pstassoc->macaddr); - if (!psta) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Can't alloc sta_info when rtw_stassoc_event_callback\n")); + if (!psta) return; - } /* to do: init sta_info variable */ psta->qos_option = 0; psta->mac_id = (uint)pstassoc->cam_id; @@ -1466,21 +1393,13 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) _clr_fwstate_(pmlmepriv, WIFI_ADHOC_STATE); } - if (rtw_createbss_cmd(adapter) != _SUCCESS) - RT_TRACE(_module_rtl871x_ioctl_set_c_, _drv_err_, ("***Error=>stadel_event_callback: rtw_createbss_cmd status FAIL***\n ")); + rtw_createbss_cmd(adapter); } } spin_unlock_bh(&pmlmepriv->lock); } -void rtw_cpwm_event_callback(struct adapter *padapter, u8 *pbuf) -{ - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("+rtw_cpwm_event_callback !!!\n")); - -} - /* * _rtw_join_timeout_handler - Timeout/faliure handler for CMD JoinBss * @adapter: pointer to struct adapter structure @@ -1679,7 +1598,6 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) while (phead != pmlmepriv->pscanned) { pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); if (!pnetwork) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("%s return _FAIL:(pnetwork==NULL)\n", __func__)); ret = _FAIL; goto exit; } @@ -1750,9 +1668,6 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) pcmd->rsp = NULL; pcmd->rspsz = 0; INIT_LIST_HEAD(&pcmd->list); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("after enqueue set_auth_cmd, auth_mode=%x\n", - psecuritypriv->dot11AuthAlgrthm)); res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: @@ -1782,25 +1697,15 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in memset(psetkeyparm, 0, sizeof(struct setkey_parm)); - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) { + if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) psetkeyparm->algorithm = (unsigned char)psecuritypriv->dot118021XGrpPrivacy; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key: psetkeyparm->algorithm=(unsigned char)psecuritypriv->dot118021XGrpPrivacy=%d\n", - psetkeyparm->algorithm)); - } else { + else psetkeyparm->algorithm = (u8)psecuritypriv->dot11PrivacyAlgrthm; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key: psetkeyparm->algorithm=(u8)psecuritypriv->dot11PrivacyAlgrthm=%d\n", - psetkeyparm->algorithm)); - } psetkeyparm->keyid = (u8)keyid;/* 0~3 */ psetkeyparm->set_tx = set_tx; pmlmepriv->key_mask |= BIT(psetkeyparm->keyid); DBG_88E("==> rtw_set_key algorithm(%x), keyid(%x), key_mask(%x)\n", psetkeyparm->algorithm, psetkeyparm->keyid, pmlmepriv->key_mask); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key: psetkeyparm->algorithm=%d psetkeyparm->keyid=(u8)keyid=%d\n", - psetkeyparm->algorithm, keyid)); switch (psetkeyparm->algorithm) { case _WEP40_: @@ -1822,9 +1727,6 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in psetkeyparm->grpkey = 1; break; default: - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, - ("\n rtw_set_key:psecuritypriv->dot11PrivacyAlgrthm=%x (must be 1 or 2 or 4 or 5)\n", - psecuritypriv->dot11PrivacyAlgrthm)); res = _FAIL; goto exit; } @@ -1938,11 +1840,6 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct security_priv *psecuritypriv = &adapter->securitypriv; uint ndisauthmode = psecuritypriv->ndisauthtype; - uint ndissecuritytype = psecuritypriv->ndisencryptstatus; - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("+rtw_restruct_sec_ie: ndisauthmode=%d ndissecuritytype=%d\n", - ndisauthmode, ndissecuritytype)); /* copy fixed ie only */ memcpy(out_ie, in_ie, 12); @@ -2035,9 +1932,6 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) } pdev_network->Configuration.DSConfig = (pregistrypriv->channel); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("pregistrypriv->channel=%d, pdev_network->Configuration.DSConfig=0x%x\n", - pregistrypriv->channel, pdev_network->Configuration.DSConfig)); if (cur_network->network.InfrastructureMode == Ndis802_11IBSS) pdev_network->Configuration.ATIMWindow = (0); diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index 8c54da73f1a7..11a2e176ccf7 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -453,8 +453,6 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf); void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf); void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf); void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf); -void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf); void indicate_wx_scan_complete_event(struct adapter *padapter); void rtw_indicate_wx_assoc_event(struct adapter *padapter); void rtw_indicate_wx_disassoc_event(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index 88d4ec073723..3b6e3ae92c9f 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -839,7 +839,7 @@ static struct fwevent wlanevents[] = { {0, &rtw_joinbss_event_callback}, /*10*/ {sizeof(struct stassoc_event), &rtw_stassoc_event_callback}, {sizeof(struct stadel_event), &rtw_stadel_event_callback}, - {0, &rtw_atimdone_event_callback}, + {0, NULL}, {0, rtw_dummy_event_callback}, {0, NULL}, /*15*/ {0, NULL}, @@ -849,7 +849,7 @@ static struct fwevent wlanevents[] = { {0, NULL}, /*20*/ {0, NULL}, {0, NULL}, - {0, &rtw_cpwm_event_callback}, + {0, NULL}, {0, NULL}, }; -- cgit v1.2.3 From a0adc4cc74d98ef8aa12d19bf1c8e2890d326d2b Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:27 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_mlme_ext.c Remove RT_TRACE macro calls from core/rtw_mlme_ext.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 39 ++++------------------------- 1 file changed, 5 insertions(+), 34 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index a9a4007ce063..40f7ef78a733 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -418,14 +418,8 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) u8 *pframe = precv_frame->rx_data; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(pframe)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, - ("+mgt_dispatcher: type(0x%x) subtype(0x%x)\n", - GetFrameType(pframe), GetFrameSubType(pframe))); - - if (GetFrameType(pframe) != WIFI_MGT_TYPE) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("mgt_dispatcher: type(0x%x) error!\n", GetFrameType(pframe))); + if (GetFrameType(pframe) != WIFI_MGT_TYPE) return; - } /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && @@ -436,10 +430,8 @@ void mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame) index = GetFrameSubType(pframe) >> 4; - if (index > 13) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("Currently we do not support reserved sub-fr-type=%d\n", index)); + if (index > 13) return; - } ptable += index; if (psta) { @@ -3743,8 +3735,6 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) pattrib->last_txcmdsz = pattrib->pktlen; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); - if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); } else { @@ -4816,8 +4806,6 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps int bssrate_len = 0; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+issue_probereq\n")); - pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) goto exit; @@ -4878,9 +4866,6 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps pattrib->last_txcmdsz = pattrib->pktlen; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("issuing probe_req, tx_len=%d\n", pattrib->last_txcmdsz)); - if (wait_ack) { ret = dump_mgntframe_and_wait_ack(padapter, pmgntframe); } else { @@ -6644,8 +6629,6 @@ void start_create_ibss(struct adapter *padapter) /* issue beacon */ if (send_beacon(padapter) == _FAIL) { - RT_TRACE(_module_rtl871x_mlme_c_, _drv_err_, ("issuing beacon frame fail....\n")); - report_join_res(padapter, -1); pmlmeinfo->state = WIFI_FW_NULL_STATE; } else { @@ -6822,8 +6805,6 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid memset(country, 0, 4); memcpy(country, p, 3); p += 3; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: 802.11d country =%s\n", __func__, country)); i = 0; while ((ie - p) >= 3) { @@ -6929,12 +6910,8 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid i = 0; while ((i < MAX_CHANNEL_NUM) && (chplan_new[i].ChannelNum != 0)) { if (chplan_new[i].ChannelNum == channel) { - if (chplan_new[i].ScanType == SCAN_PASSIVE) { + if (chplan_new[i].ScanType == SCAN_PASSIVE) chplan_new[i].ScanType = SCAN_ACTIVE; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, - ("%s: change channel %d scan type from passive to active\n", - __func__, channel)); - } break; } i++; @@ -8199,19 +8176,13 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) evt_code = (u8)((*peventbuf>>16)&0xff); /* checking if event code is valid */ - if (evt_code >= MAX_C2HEVT) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, ("\nEvent Code(%d) mismatch!\n", evt_code)); + if (evt_code >= MAX_C2HEVT) goto _abort_event_; - } /* checking if event size match the event parm size */ if ((wlanevents[evt_code].parmsize != 0) && - (wlanevents[evt_code].parmsize != evt_sz)) { - RT_TRACE(_module_rtl871x_cmd_c_, _drv_err_, - ("\nEvent(%d) Parm Size mismatch (%d vs %d)!\n", - evt_code, wlanevents[evt_code].parmsize, evt_sz)); + (wlanevents[evt_code].parmsize != evt_sz)) goto _abort_event_; - } atomic_inc(&pevt_priv->event_seq); -- cgit v1.2.3 From fea8d09f804f324d0095d5b3d7938589008e47a7 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:28 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_mp.c Remove RT_TRACE macro calls from core/rtw_mp.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 252d5c37d813..def0c250a4ac 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -383,7 +383,6 @@ s32 mp_start_test(struct adapter *padapter) psta = rtw_alloc_stainfo(&padapter->stapriv, bssid.MacAddress); if (!psta) { - RT_TRACE(_module_mp_, _drv_err_, ("mp_start_test: Can't alloc sta_info!\n")); pmlmepriv->fw_state = pmppriv->prev_fw_state; res = _FAIL; goto end_of_mp_start_test; @@ -864,15 +863,11 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data) u32 i, psd_pts = 0, psd_start = 0, psd_stop = 0; u32 psd_data = 0; - if (!netif_running(pAdapter->pnetdev)) { - RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! interface not opened!\n")); + if (!netif_running(pAdapter->pnetdev)) return 0; - } - if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) { - RT_TRACE(_module_mp_, _drv_warning_, ("mp_query_psd: Fail! not in MP mode!\n")); + if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) return 0; - } if (strlen(data) == 0) { /* default value */ psd_pts = 128; @@ -938,7 +933,6 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmit_extbuf) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; } @@ -972,8 +966,6 @@ exit: void Hal_ProSetCrystalCap (struct adapter *pAdapter, u32 CrystalCapVal) { - struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); - CrystalCapVal = CrystalCapVal & 0x3F; // write 0x24[16:11] = 0x24[22:17] = CrystalCap -- cgit v1.2.3 From de30da13709b8f1aa4b9da5135119a3f37a7e0de Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:29 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_security.c Remove RT_TRACE macro calls from core/rtw_security.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_security.c | 44 +---------------------------- 1 file changed, 1 insertion(+), 43 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 08a5a1975d11..6cacf7d01626 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -139,10 +139,6 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) { /* exclude ICV */ - union { - __le32 f0; - u8 f1[4]; - } crc; struct arc4context mycontext; int length; u32 keylength; @@ -167,18 +163,6 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) /* decrypt payload include icv */ arcfour_init(&mycontext, wepkey, 3+keylength); arcfour_encrypt(&mycontext, payload, payload, length); - - /* calculate icv and compare the icv */ - crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - - if (crc.f1[3] != payload[length-1] || - crc.f1[2] != payload[length-2] || - crc.f1[1] != payload[length-3] || - crc.f1[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, - ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", - &crc, &payload[length-4])); - } } } @@ -554,8 +538,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); if (stainfo) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo!= NULL!!!\n")); - if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else @@ -574,9 +556,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; - RT_TRACE(_module_rtl871x_security_c_, _drv_info_, - ("pattrib->iv_len=%x, pattrib->icv_len=%x\n", - pattrib->iv_len, pattrib->icv_len)); crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, rc4key, 16); @@ -595,7 +574,6 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) } } } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_encrypt: stainfo==NULL!!!\n")); res = _FAIL; } } @@ -638,7 +616,6 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) } prwskey = psecuritypriv->dot118021XGrpKey[prxattrib->key_index].skey; } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo!= NULL!!!\n")); prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } @@ -664,14 +641,9 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) if (crc.f1[3] != payload[length-1] || crc.f1[2] != payload[length-2] || crc.f1[1] != payload[length-3] || - crc.f1[0] != payload[length-4]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, - ("rtw_wep_decrypt:icv error crc (%4ph)!=payload (%4ph)\n", - &crc, &payload[length-4])); + crc.f1[0] != payload[length-4]) res = _FAIL; - } } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_tkip_decrypt: stainfo==NULL!!!\n")); res = _FAIL; } } @@ -1216,8 +1188,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); if (stainfo) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo!= NULL!!!\n")); - if (IS_MCAST(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else @@ -1236,7 +1206,6 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) } } } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); res = _FAIL; } } @@ -1428,9 +1397,6 @@ static int aes_decipher(u8 *key, uint hdrlen, /* compare the mic */ for (i = 0; i < 8; i++) { if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, - ("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", - i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i])); DBG_88E("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); res = _FAIL; @@ -1455,8 +1421,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo) { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_decrypt: stainfo!= NULL!!!\n")); - if (IS_MCAST(prxattrib->ra)) { /* in concurrent we should use sw descrypt in group key, so we remove this message */ if (!psecuritypriv->binstallGrpkey) { @@ -1477,7 +1441,6 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); } else { - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("rtw_aes_encrypt: stainfo==NULL!!!\n")); res = _FAIL; } } @@ -1689,10 +1652,5 @@ void rtw_use_tkipkey_handler(void *FunctionContext) { struct adapter *padapter = (struct adapter *)FunctionContext; - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler ^^^\n")); - padapter->securitypriv.busetkipkey = true; - - RT_TRACE(_module_rtl871x_security_c_, _drv_err_, ("^^^rtw_use_tkipkey_handler padapter->securitypriv.busetkipkey=%d^^^\n", padapter->securitypriv.busetkipkey)); - } -- cgit v1.2.3 From 5833ca54050768a328ca01c1ef29a4aa6d45ec4a Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:30 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_sta_mgt.c Remove RT_TRACE macro calls from core/rtw_sta_mgt.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-8-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index fc963bee37be..3e8e85756f25 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -195,9 +195,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) _rtw_init_stainfo(psta); memcpy(psta->hwaddr, hwaddr, ETH_ALEN); index = wifi_mac_hash(hwaddr); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, ("rtw_alloc_stainfo: index=%x", index)); if (index >= NUM_STA) { - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("ERROR => rtw_alloc_stainfo: index >= NUM_STA")); psta = NULL; goto exit; } @@ -219,10 +217,6 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) for (i = 0; i < 16; i++) memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i], &wRxSeqInitialValue, 2); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_, - ("alloc number_%d stainfo with hwaddr = %pM\n", - pstapriv->asoc_sta_count, hwaddr)); - init_addba_retry_timer(pstapriv->padapter, psta); /* for A-MPDU Rx reordering buffer control */ @@ -296,7 +290,6 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) spin_unlock_bh(&pxmitpriv->lock); list_del_init(&psta->hash_list); - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("\n free number_%d stainfo with hwaddr=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", pstapriv->asoc_sta_count, psta->hwaddr[0], psta->hwaddr[1], psta->hwaddr[2], psta->hwaddr[3], psta->hwaddr[4], psta->hwaddr[5])); pstapriv->asoc_sta_count--; /* re-init sta_info; 20061114 */ @@ -462,7 +455,6 @@ u32 rtw_init_bcmc_stainfo(struct adapter *padapter) if (!psta) { res = _FAIL; - RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_, ("rtw_alloc_stainfo fail")); goto exit; } -- cgit v1.2.3 From 9bb2e9b1f5b17b79d95a4ad1007292cda839c5b4 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:31 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_xmit.c Remove RT_TRACE macro calls from core/rtw_xmit.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-9-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 83 ++------------------------------- 1 file changed, 4 insertions(+), 79 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 036f1f9a5d0f..0a755d7b8f19 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -76,7 +76,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_frame fail!\n")); res = _FAIL; goto exit; } @@ -113,7 +112,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmitbuf) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_buf fail!\n")); res = _FAIL; goto exit; } @@ -155,7 +153,6 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmit_extbuf) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("alloc xmit_extbuf fail!\n")); res = _FAIL; goto exit; } @@ -467,7 +464,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p ((tmp[21] == 67) && (tmp[23] == 68))) { /* 68 : UDP BOOTP client */ /* 67 : UDP BOOTP server */ - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====================== update_attrib: get DHCP Packet\n")); /* Use low rate to send DHCP packet. */ pattrib->dhcp_pkt = 1; } @@ -492,7 +488,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p } else { psta = rtw_get_stainfo(pstapriv, pattrib->ra); if (!psta) { /* if we cannot get psta => drrp the pkt */ - RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra: %pM\n", (pattrib->ra))); res = _FAIL; goto exit; } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) { @@ -507,7 +502,6 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p pattrib->psta = psta; } else { /* if we cannot get psta => drop the pkt */ - RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("\nupdate_attrib => get sta_info fail, ra:%pM\n", (pattrib->ra))); res = _FAIL; goto exit; } @@ -533,12 +527,9 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p } if (psta->ieee8021x_blocked) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\n psta->ieee8021x_blocked == true\n")); - pattrib->encrypt = 0; if ((pattrib->ether_type != 0x888e) && !check_fwstate(pmlmepriv, WIFI_MP_STATE)) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("\npsta->ieee8021x_blocked == true, pattrib->ether_type(%.4x) != 0x888e\n", pattrib->ether_type)); res = _FAIL; goto exit; } @@ -574,15 +565,11 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p pattrib->icv_len = 4; if (padapter->securitypriv.busetkipkey == _FAIL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("\npadapter->securitypriv.busetkipkey(%d) == _FAIL drop packet\n", - padapter->securitypriv.busetkipkey)); res = _FAIL; goto exit; } break; case _AES_: - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("pattrib->encrypt=%d (_AES_)\n", pattrib->encrypt)); pattrib->iv_len = 8; pattrib->icv_len = 8; break; @@ -592,20 +579,11 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p break; } - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - ("update_attrib: encrypt=%d securitypriv.sw_encrypt=%d\n", - pattrib->encrypt, padapter->securitypriv.sw_encrypt)); - if (pattrib->encrypt && - (padapter->securitypriv.sw_encrypt || !psecuritypriv->hw_decrypted)) { + (padapter->securitypriv.sw_encrypt || !psecuritypriv->hw_decrypted)) pattrib->bswenc = true; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("update_attrib: encrypt=%d securitypriv.hw_decrypted=%d bswenc = true\n", - pattrib->encrypt, padapter->securitypriv.sw_encrypt)); - } else { + else pattrib->bswenc = false; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("update_attrib: bswenc = false\n")); - } rtw_set_tx_chksum_offload(pkt, pattrib); @@ -682,17 +660,8 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { payload = (u8 *)RND4((size_t)(payload)); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("=== curfragnum=%d, pframe = 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x,!!!\n", - curfragnum, *payload, *(payload+1), - *(payload+2), *(payload+3), - *(payload+4), *(payload+5), - *(payload+6), *(payload+7))); payload = payload+pattrib->hdrlen+pattrib->iv_len; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("curfragnum=%d pattrib->hdrlen=%d pattrib->iv_len=%d", - curfragnum, pattrib->hdrlen, pattrib->iv_len)); if ((curfragnum+1) == pattrib->nr_frags) { length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); rtw_secmicappend(&micdata, payload, length); @@ -701,32 +670,16 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); rtw_secmicappend(&micdata, payload, length); payload = payload+length+pattrib->icv_len; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("curfragnum=%d length=%d pattrib->icv_len=%d", curfragnum, length, pattrib->icv_len)); } } rtw_secgetmic(&micdata, &(mic[0])); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: before add mic code!!!\n")); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: pattrib->last_txcmdsz=%d!!!\n", pattrib->last_txcmdsz)); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: mic[0]=0x%.2x , mic[1]=0x%.2x , mic[2]= 0x%.2x, mic[3]=0x%.2x\n\ - mic[4]= 0x%.2x , mic[5]= 0x%.2x , mic[6]= 0x%.2x , mic[7]= 0x%.2x !!!!\n", - mic[0], mic[1], mic[2], mic[3], mic[4], mic[5], mic[6], mic[7])); /* add mic code and add the mic code length in last_txcmdsz */ memcpy(payload, &(mic[0]), 8); pattrib->last_txcmdsz += 8; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("\n ======== last pkt ========\n")); payload = payload-pattrib->last_txcmdsz+8; - for (curfragnum = 0; curfragnum < pattrib->last_txcmdsz; curfragnum = curfragnum+8) - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, - (" %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x, %.2x ", - *(payload+curfragnum), *(payload+curfragnum+1), - *(payload+curfragnum+2), *(payload+curfragnum+3), - *(payload+curfragnum+4), *(payload+curfragnum+5), - *(payload+curfragnum+6), *(payload+curfragnum+7))); - } else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic: rtw_get_stainfo==NULL!!!\n")); - } + } } return _SUCCESS; @@ -737,7 +690,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi struct pkt_attrib *pattrib = &pxmitframe->attrib; if (pattrib->bswenc) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_alert_, ("### xmitframe_swencrypt\n")); switch (pattrib->encrypt) { case _WEP40_: case _WEP104_: @@ -752,8 +704,6 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi default: break; } - } else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, ("### xmitframe_hwencrypt\n")); } return _SUCCESS; @@ -818,7 +768,6 @@ s32 rtw_make_wlanhdr (struct adapter *padapter, u8 *hdr, struct pkt_attrib *patt if (psta->qos_option) qos_option = true; } else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("fw_state:%x is not allowed to xmit frame\n", get_fwstate(pmlmepriv))); res = _FAIL; goto exit; } @@ -989,7 +938,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct mem_start = pbuf_start + hw_hdr_offset; if (rtw_make_wlanhdr(padapter, mem_start, pattrib) == _FAIL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n")); DBG_88E("rtw_xmitframe_coalesce: rtw_make_wlanhdr fail; drop pkt\n"); res = _FAIL; goto exit; @@ -1038,10 +986,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct memcpy(pframe, pattrib->iv, pattrib->iv_len); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_notice_, - ("rtw_xmitframe_coalesce: keyid=%d pattrib->iv[3]=%.2x pframe=%.2x %.2x %.2x %.2x\n", - padapter->securitypriv.dot11PrivacyKeyIndex, pattrib->iv[3], *pframe, *(pframe+1), *(pframe+2), *(pframe+3))); - pframe += pattrib->iv_len; mpdu_len -= pattrib->iv_len; @@ -1082,8 +1026,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct ClearMFrag(mem_start); break; - } else { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("%s: There're still something in packet!\n", __func__)); } addr = (size_t)(pframe); @@ -1093,7 +1035,6 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct } if (xmitframe_addmic(padapter, pxmitframe) == _FAIL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n")); DBG_88E("xmitframe_addmic(padapter, pxmitframe) == _FAIL\n"); res = _FAIL; goto exit; @@ -1347,7 +1288,6 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf spin_lock_bh(&pfree_xmit_queue->lock); if (list_empty(&pfree_xmit_queue->queue)) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe:%d\n", pxmitpriv->free_xmitframe_cnt)); pxframe = NULL; } else { phead = get_list_head(pfree_xmit_queue); @@ -1362,8 +1302,6 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf if (pxframe) { /* default value setting */ pxmitpriv->free_xmitframe_cnt--; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_alloc_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); - pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; @@ -1390,10 +1328,8 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram struct adapter *padapter = pxmitpriv->adapter; struct sk_buff *pndis_pkt = NULL; - if (!pxmitframe) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("====== rtw_free_xmitframe():pxmitframe == NULL!!!!!!!!!!\n")); + if (!pxmitframe) goto exit; - } spin_lock_bh(&pfree_xmit_queue->lock); @@ -1407,7 +1343,6 @@ s32 rtw_free_xmitframe(struct xmit_priv *pxmitpriv, struct xmit_frame *pxmitfram list_add_tail(&pxmitframe->list, get_list_head(pfree_xmit_queue)); pxmitpriv->free_xmitframe_cnt++; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_debug_, ("rtw_free_xmitframe():free_xmitframe_cnt=%d\n", pxmitpriv->free_xmitframe_cnt)); spin_unlock_bh(&pfree_xmit_queue->lock); @@ -1443,8 +1378,6 @@ void rtw_free_xmitframe_queue(struct xmit_priv *pxmitpriv, struct __queue *pfram s32 rtw_xmitframe_enqueue(struct adapter *padapter, struct xmit_frame *pxmitframe) { if (rtw_xmit_classifier(padapter, pxmitframe) == _FAIL) { - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, - ("rtw_xmitframe_enqueue: drop xmit pkt for classifier fail\n")); /* pxmitframe->pkt = NULL; */ return _FAIL; } @@ -1534,26 +1467,22 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * case 2: ptxservq = &(psta->sta_xmitpriv.bk_q); *(ac) = 3; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BK\n")); break; case 4: case 5: ptxservq = &(psta->sta_xmitpriv.vi_q); *(ac) = 1; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VI\n")); break; case 6: case 7: ptxservq = &(psta->sta_xmitpriv.vo_q); *(ac) = 0; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : VO\n")); break; case 0: case 3: default: ptxservq = &(psta->sta_xmitpriv.be_q); *(ac) = 2; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("rtw_get_sta_pending : BE\n")); break; } @@ -1583,7 +1512,6 @@ s32 rtw_xmit_classifier(struct adapter *padapter, struct xmit_frame *pxmitframe) if (!psta) { res = _FAIL; DBG_88E("rtw_xmit_classifier: psta == NULL\n"); - RT_TRACE(_module_rtl871x_xmit_c_, _drv_err_, ("rtw_xmit_classifier: psta == NULL\n")); goto exit; } @@ -1807,7 +1735,6 @@ static void do_queue_select(struct adapter *padapter, struct pkt_attrib *pattrib u8 qsel; qsel = pattrib->priority; - RT_TRACE(_module_rtl871x_xmit_c_, _drv_info_, ("### do_queue_select priority=%d , qsel = %d\n", pattrib->priority, qsel)); pattrib->qsel = qsel; } @@ -1830,7 +1757,6 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) pxmitframe = rtw_alloc_xmitframe(pxmitpriv); if (!pxmitframe) { - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: no more pxmitframe\n")); DBG_88E("DBG_TX_DROP_FRAME %s no more pxmitframe\n", __func__); return -1; } @@ -1850,7 +1776,6 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) res = update_attrib(padapter, *ppkt, &pxmitframe->attrib); if (res == _FAIL) { - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit: update attrib fail\n")); rtw_free_xmitframe(pxmitpriv, pxmitframe); return -1; } -- cgit v1.2.3 From 5ea6417afa721c65690f64285aa9b779a6a9eb6a Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:32 +0100 Subject: staging: r8188eu: remove RT_TRACE calls from core/rtw_recv.c Remove RT_TRACE macro calls from core/rtw_recv.c, so that ultimately the macro definition itself can eventually be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-10-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 161 +++----------------------------- 1 file changed, 11 insertions(+), 150 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index aef32f029537..46fb8c289652 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -328,33 +328,24 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); if (prxattrib->encrypt == _TKIP_) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:prxattrib->encrypt==_TKIP_\n")); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic:da=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5])); - /* calculate mic code */ if (stainfo) { if (IS_MCAST(prxattrib->ra)) { mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n recvframe_chkmic: bcmc key\n")); - if (!psecuritypriv) { res = _FAIL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n")); DBG_88E("\n recvframe_chkmic:didn't install group key!!!!!!!!!!\n"); goto exit; } } else { mickey = &stainfo->dot11tkiprxmickey.skey[0]; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n recvframe_chkmic: unicast key\n")); } datalen = precvframe->len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ pframe = precvframe->rx_data; payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n prxattrib->iv_len=%d prxattrib->icv_len=%d\n", prxattrib->iv_len, prxattrib->icv_len)); rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], (unsigned char)prxattrib->priority); /* care the length of the data */ @@ -363,44 +354,11 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr bmic_err = false; for (i = 0; i < 8; i++) { - if (miccode[i] != *(pframemic+i)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("recvframe_chkmic:miccode[%d](%02x)!=*(pframemic+%d)(%02x) ", - i, miccode[i], i, *(pframemic+i))); + if (miccode[i] != *(pframemic+i)) bmic_err = true; - } } if (bmic_err) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("\n *(pframemic-8)-*(pframemic-1)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - *(pframemic-8), *(pframemic-7), *(pframemic-6), - *(pframemic-5), *(pframemic-4), *(pframemic-3), - *(pframemic-2), *(pframemic-1))); - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("\n *(pframemic-16)-*(pframemic-9)=0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x\n", - *(pframemic-16), *(pframemic-15), *(pframemic-14), - *(pframemic-13), *(pframemic-12), *(pframemic-11), - *(pframemic-10), *(pframemic-9))); - { - uint i; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ======demp packet (len=%d)======\n", precvframe->len)); - for (i = 0; i < precvframe->len; i = i+8) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x:0x%02x", - *(precvframe->rx_data+i), *(precvframe->rx_data+i+1), - *(precvframe->rx_data+i+2), *(precvframe->rx_data+i+3), - *(precvframe->rx_data+i+4), *(precvframe->rx_data+i+5), - *(precvframe->rx_data+i+6), *(precvframe->rx_data+i+7))); - } - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n ====== demp packet end [len=%d]======\n", precvframe->len)); - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("\n hrdlen=%d,\n", prxattrib->hdrlen)); - } - - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, - ("ra=0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x psecuritypriv->binstallGrpkey=%d ", - prxattrib->ra[0], prxattrib->ra[1], prxattrib->ra[2], - prxattrib->ra[3], prxattrib->ra[4], prxattrib->ra[5], psecuritypriv->binstallGrpkey)); - /* double check key_index for some timing issue , */ /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index)) @@ -408,22 +366,16 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr if ((prxattrib->bdecrypted) && (brpt_micerror)) { rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted)); DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); } else { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" mic error :prxattrib->bdecrypted=%d ", prxattrib->bdecrypted)); DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); } res = _FAIL; } else { /* mic checked ok */ - if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST(prxattrib->ra))) { + if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST(prxattrib->ra))) psecuritypriv->bcheck_grpkey = true; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("psecuritypriv->bcheck_grpkey = true")); - } } - } else { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic: rtw_get_stainfo==NULL!!!\n")); } recvframe_pull_tail(precvframe, 8); @@ -442,8 +394,6 @@ static struct recv_frame *decryptor(struct adapter *padapter, struct recv_frame struct recv_frame *return_packet = precv_frame; u32 res = _SUCCESS; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("prxstat->decrypted=%x prxattrib->encrypt=0x%03x\n", prxattrib->bdecrypted, prxattrib->encrypt)); - if (prxattrib->encrypt > 0) { u8 *iv = precv_frame->rx_data+prxattrib->hdrlen; prxattrib->key_index = (((iv[3])>>6)&0x3); @@ -522,16 +472,11 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p prtnframe = NULL; psta = rtw_get_stainfo(pstapriv, psta_addr); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("########portctrl:adapter->securitypriv.dot11AuthAlgrthm=%d\n", - adapter->securitypriv.dot11AuthAlgrthm)); if (auth_alg == 2) { if (psta && psta->ieee8021x_blocked) { /* blocked */ /* only accept EAPOL frame */ - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==1\n")); - prtnframe = precv_frame; /* get ether_type */ @@ -549,22 +494,11 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p } else { /* allowed */ /* check decryption status, and decrypt the frame if needed */ - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:psta->ieee8021x_blocked==0\n")); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:precv_frame->hdr.attrib.privacy=%x\n", precv_frame->attrib.privacy)); - - if (pattrib->bdecrypted == 0) - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("portctrl:prxstat->decrypted=%x\n", pattrib->bdecrypted)); - prtnframe = precv_frame; /* check is the EAPOL frame or not (Rekey) */ - if (ether_type == eapol_type) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("########portctrl:ether_type==0x888e\n")); + if (ether_type == eapol_type) /* check Rekey */ - prtnframe = precv_frame; - } else { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("########portctrl:ether_type=0x%04x\n", ether_type)); - } } } else { prtnframe = precv_frame; @@ -580,18 +514,12 @@ static int recv_decache(struct recv_frame *precv_frame, u8 bretry, struct stainf u16 seq_ctrl = ((precv_frame->attrib.seq_num&0xffff) << 4) | (precv_frame->attrib.frag_num & 0xf); - if (tid > 15) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, (tid>15)! seq_ctrl=0x%x, tid=0x%x\n", seq_ctrl, tid)); - + if (tid > 15) return _FAIL; - } if (1) {/* if (bretry) */ - if (seq_ctrl == prxcache->tid_rxseq[tid]) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_decache, seq_ctrl=0x%x, tid=0x%x, tid_rxseq=0x%x\n", seq_ctrl, tid, prxcache->tid_rxseq[tid])); - + if (seq_ctrl == prxcache->tid_rxseq[tid]) return _FAIL; - } } prxcache->tid_rxseq[tid] = seq_ctrl; @@ -732,7 +660,6 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); ret = _FAIL; goto exit; } @@ -753,7 +680,6 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, } else if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* For Station mode, sa and bssid should always be BSSID, and DA is my mac-address */ if (memcmp(pattrib->bssid, pattrib->src, ETH_ALEN)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("bssid!=TA under STATION_MODE; drop pkt\n")); ret = _FAIL; goto exit; } @@ -792,7 +718,6 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, *psta = rtw_get_stainfo(pstapriv, sta_addr); /* get ap_info */ if (!*psta) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under sta2sta_data_frame ; drop pkt\n")); if (adapter->registrypriv.mp_mode == 1) { if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) adapter->mppriv.rx_pktloss++; @@ -825,15 +750,12 @@ static int ap2sta_data_frame ( check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" SA==myself\n")); ret = _FAIL; goto exit; } /* da should be for me */ if ((memcmp(myhwaddr, pattrib->dst, ETH_ALEN)) && (!bmcast)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - (" ap2sta_data_frame: compare DA fail; DA=%pM\n", (pattrib->dst))); ret = _FAIL; goto exit; } @@ -842,10 +764,6 @@ static int ap2sta_data_frame ( if (!memcmp(pattrib->bssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || !memcmp(mybssid, "\x0\x0\x0\x0\x0\x0", ETH_ALEN) || (memcmp(pattrib->bssid, mybssid, ETH_ALEN))) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - (" ap2sta_data_frame: compare BSSID fail ; BSSID=%pM\n", (pattrib->bssid))); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("mybssid=%pM\n", (mybssid))); - if (!bmcast) { DBG_88E("issue_deauth to the nonassociated ap=%pM for the reason(7)\n", (pattrib->bssid)); issue_deauth(adapter, pattrib->bssid, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); @@ -861,7 +779,6 @@ static int ap2sta_data_frame ( *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get ap_info */ if (!*psta) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("ap2sta: can't get psta under STATION_MODE ; drop pkt\n")); ret = _FAIL; goto exit; } @@ -888,7 +805,6 @@ static int ap2sta_data_frame ( *psta = rtw_get_stainfo(pstapriv, pattrib->bssid); /* get sta_info */ if (!*psta) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under MP_MODE ; drop pkt\n")); ret = _FAIL; goto exit; } @@ -934,7 +850,6 @@ static int sta2ap_data_frame(struct adapter *adapter, *psta = rtw_get_stainfo(pstapriv, pattrib->src); if (!*psta) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("can't get psta under AP_MODE; drop pkt\n")); DBG_88E("issue_deauth to sta=%pM for the reason(7)\n", (pattrib->src)); issue_deauth(adapter, pattrib->src, WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA); @@ -1102,13 +1017,9 @@ static int validate_recv_mgnt_frame(struct adapter *padapter, { struct sta_info *psta; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("+validate_recv_mgnt_frame\n")); - precv_frame = recvframe_chk_defrag(padapter, precv_frame); - if (!precv_frame) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("%s: fragment packet\n", __func__)); + if (!precv_frame) return _SUCCESS; - } /* for rx pkt statistics */ psta = rtw_get_stainfo(&padapter->stapriv, GetAddr2Ptr(precv_frame->rx_data)); @@ -1180,7 +1091,6 @@ static int validate_recv_data_frame(struct adapter *adapter, memcpy(pattrib->ra, GetAddr1Ptr(ptr), ETH_ALEN); memcpy(pattrib->ta, GetAddr2Ptr(ptr), ETH_ALEN); ret = _FAIL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" case 3\n")); break; default: ret = _FAIL; @@ -1194,7 +1104,6 @@ static int validate_recv_data_frame(struct adapter *adapter, } if (!psta) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, (" after to_fr_ds_chk; psta==NULL\n")); ret = _FAIL; goto exit; } @@ -1226,19 +1135,13 @@ static int validate_recv_data_frame(struct adapter *adapter, /* decache, drop duplicate recv packets */ if (recv_decache(precv_frame, bretry, &psta->sta_recvpriv.rxcache) == _FAIL) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decache : drop pkt\n")); ret = _FAIL; goto exit; } if (pattrib->privacy) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("validate_recv_data_frame:pattrib->privacy=%x\n", pattrib->privacy)); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n ^^^^^^^^^^^IS_MCAST(pattrib->ra(0x%02x))=%d^^^^^^^^^^^^^^^6\n", pattrib->ra[0], IS_MCAST(pattrib->ra))); - GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, IS_MCAST(pattrib->ra)); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("\n pattrib->encrypt=%d\n", pattrib->encrypt)); - SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); } else { pattrib->encrypt = 0; @@ -1274,7 +1177,6 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv /* add version chk */ if (ver != 0) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! (ver!=0)\n")); retval = _FAIL; goto exit; } @@ -1326,15 +1228,11 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv } switch (type) { case WIFI_MGT_TYPE: /* mgnt */ - retval = validate_recv_mgnt_frame(adapter, precv_frame); - if (retval == _FAIL) - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_mgnt_frame fail\n")); + validate_recv_mgnt_frame(adapter, precv_frame); retval = _FAIL; /* only data frame return _SUCCESS */ break; case WIFI_CTRL_TYPE: /* ctrl */ - retval = validate_recv_ctrl_frame(adapter, precv_frame); - if (retval == _FAIL) - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_ctrl_frame fail\n")); + validate_recv_ctrl_frame(adapter, precv_frame); retval = _FAIL; /* only data frame return _SUCCESS */ break; case WIFI_DATA_TYPE: /* data */ @@ -1347,7 +1245,6 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv } break; default: - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("validate_recv_data_frame fail! type= 0x%x\n", type)); retval = _FAIL; break; } @@ -1395,9 +1292,6 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); len = precvframe->len - rmv_len; - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, - ("\n===pattrib->hdrlen: %x, pattrib->iv_len:%x===\n\n", pattrib->hdrlen, pattrib->iv_len)); - memcpy(&be_tmp, ptr+rmv_len, 2); eth_type = ntohs(be_tmp); /* pattrib->ether_type */ pattrib->eth_type = eth_type; @@ -1503,8 +1397,6 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter, struct __que /* free the defrag_q queue and return the prframe */ rtw_free_recvframe_queue(defrag_q, pfree_recv_queue); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Performance defrag!!!!!\n")); - return prframe; } @@ -1565,15 +1457,12 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr phead = get_list_head(pdefrag_q); list_add_tail(&pfhdr->list, phead); - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("Enqueuq: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); - prtnframe = NULL; } else { /* can't find this ta's defrag_queue, so free this recv_frame */ if (precv_frame && pfree_recv_queue) rtw_free_recvframe(precv_frame, pfree_recv_queue); prtnframe = NULL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q==NULL: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); } } @@ -1585,7 +1474,6 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr list_add_tail(&pfhdr->list, phead); /* call recvframe_defrag to defrag */ - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("defrag: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); precv_frame = recvframe_defrag(padapter, pdefrag_q); prtnframe = precv_frame; } else { @@ -1593,14 +1481,12 @@ struct recv_frame *recvframe_chk_defrag(struct adapter *padapter, struct recv_fr if (precv_frame && pfree_recv_queue) rtw_free_recvframe(precv_frame, pfree_recv_queue); prtnframe = NULL; - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("Free because pdefrag_q==NULL: ismfrag=%d, fragnum=%d\n", ismfrag, fragnum)); } } if (prtnframe && prtnframe->attrib.privacy) { /* after defrag we must check tkip mic code */ if (recvframe_chkmic(padapter, prtnframe) == _FAIL) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chkmic(padapter, prtnframe)==_FAIL\n")); if (precv_frame && pfree_recv_queue) rtw_free_recvframe(prtnframe, pfree_recv_queue); prtnframe = NULL; @@ -1817,9 +1703,6 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor pattrib = &prframe->attrib; if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, - ("recv_indicatepkts_in_order: indicate=%d seq=%d amsdu=%d\n", - preorder_ctrl->indicate_seq, pattrib->seq_num, pattrib->amsdu)); plist = plist->next; list_del_init(&(prframe->list)); @@ -1864,9 +1747,6 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame if (pattrib->qos != 1) { if (!padapter->bDriverStopped && !padapter->bSurpriseRemoved) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, - ("@@@@ recv_indicatepkt_reorder -recv_func recv_indicatepkt\n")); - rtw_recv_indicatepkt(padapter, prframe); return _SUCCESS; } @@ -1894,10 +1774,6 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame spin_lock_bh(&ppending_recvframe_queue->lock); - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, - ("recv_indicatepkt_reorder: indicate=%d seq=%d\n", - preorder_ctrl->indicate_seq, pattrib->seq_num)); - /* s2. check if winstart_b(indicate_seq) needs to been updated */ if (!check_indicate_seq(preorder_ctrl, pattrib->seq_num)) goto _err_exit; @@ -1974,20 +1850,14 @@ static int process_recv_indicatepkts(struct adapter *padapter, struct recv_frame } } else { /* B/G mode */ retval = wlanhdr_to_ethhdr (prframe); - if (retval != _SUCCESS) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n")); + if (retval != _SUCCESS) return retval; - } if ((!padapter->bDriverStopped) && (!padapter->bSurpriseRemoved)) { /* indicate this recv_frame */ - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func recv_indicatepkt\n")); rtw_recv_indicatepkt(padapter, prframe); } else { - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("@@@@ process_recv_indicatepkts- recv_func free_indicatepkt\n")); - - RT_TRACE(_module_rtl871x_recv_c_, _drv_notice_, ("recv_func:bDriverStopped(%d) OR bSurpriseRemoved(%d)", padapter->bDriverStopped, padapter->bSurpriseRemoved)); retval = _FAIL; return retval; } @@ -2010,7 +1880,6 @@ static int recv_func_prehandle(struct adapter *padapter, struct recv_frame *rfra padapter->mppriv.rx_pktcount++; if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_alert_, ("MP - Not in loopback mode , drop pkt\n")); ret = _FAIL; rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ goto exit; @@ -2020,7 +1889,6 @@ static int recv_func_prehandle(struct adapter *padapter, struct recv_frame *rfra /* check the frame crtl field and decache */ ret = validate_recv_frame(padapter, rframe); if (ret != _SUCCESS) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("recv_func: validate_recv_frame fail! drop pkt\n")); rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ goto exit; } @@ -2041,20 +1909,16 @@ static int recv_func_posthandle(struct adapter *padapter, struct recv_frame *prf prframe = decryptor(padapter, prframe); if (!prframe) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("decryptor: drop pkt\n")); ret = _FAIL; goto _recv_data_drop; } prframe = recvframe_chk_defrag(padapter, prframe); - if (!prframe) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recvframe_chk_defrag: drop pkt\n")); + if (!prframe) goto _recv_data_drop; - } prframe = portctrl(padapter, prframe); if (!prframe) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("portctrl: drop pkt\n")); ret = _FAIL; goto _recv_data_drop; } @@ -2063,7 +1927,6 @@ static int recv_func_posthandle(struct adapter *padapter, struct recv_frame *prf ret = process_recv_indicatepkts(padapter, prframe); if (ret != _SUCCESS) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("recv_func: process_recv_indicatepkts fail!\n")); rtw_free_recvframe(orig_prframe, pfree_recv_queue);/* free this recv_frame */ goto _recv_data_drop; } @@ -2135,10 +1998,8 @@ s32 rtw_recv_entry(struct recv_frame *precvframe) precvpriv = &padapter->recvpriv; ret = recv_func(padapter, precvframe); - if (ret == _FAIL) { - RT_TRACE(_module_rtl871x_recv_c_, _drv_info_, ("rtw_recv_entry: recv_func return fail!!!\n")); + if (ret == _FAIL) goto _recv_entry_drop; - } precvpriv->rx_pkts++; -- cgit v1.2.3 From fe4bbfb44a222059ae2625b89ab5007cca130b8b Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:33 +0100 Subject: staging: r8188eu: fix unused variable warnings in core/rtw_ieee80211.c Remove an unused variable and a set but unused variable within core/rtw_ieee80211.c to fix a kernel test robot warning. Reported-by: kernel test robot Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-11-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ieee80211.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index e54926e1f569..ff77e686721c 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -626,7 +626,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, u16 *wpa_len) { - u8 authmode, sec_idx, i; + u8 authmode; u8 wpa_oui[4] = {0x0, 0x50, 0xf2, 0x01}; uint cnt; @@ -634,8 +634,6 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, cnt = (_TIMESTAMP_ + _BEACON_ITERVAL_ + _CAPABILITY_); - sec_idx = 0; - while (cnt < in_len) { authmode = in_ie[cnt]; -- cgit v1.2.3 From d28a4c009bfbbdd26fa196b7b8af1d879470211b Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Fri, 6 Aug 2021 01:40:34 +0100 Subject: staging: r8188eu: remove two set but unused variables in core/rtw_mp_ioctl.c Remove two set but unused variables in core/rtw_mp_ioctl.c to fix a kernel test robot warning. Reported-by: kernel test robot Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210806004034.82233-12-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index 8fcc74598e5f..fed94d66aee0 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -668,7 +668,7 @@ int rtl8188eu_oid_rt_pro_read_register_hdl(struct oid_par_priv *poid_par_priv) int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) { struct mp_rw_reg *RegRWStruct; - u32 offset, width, value; + u32 offset, value; int status = NDIS_STATUS_SUCCESS; struct adapter *padapter = (struct adapter *)(poid_par_priv->adapter_context); @@ -677,7 +677,6 @@ int rtl8188eu_oid_rt_pro_write_register_hdl(struct oid_par_priv *poid_par_priv) RegRWStruct = (struct mp_rw_reg *)poid_par_priv->information_buf; offset = RegRWStruct->offset; - width = RegRWStruct->width; value = RegRWStruct->value; if (offset > 0xFFF) @@ -1093,7 +1092,6 @@ int rtl8188eu_oid_rt_set_crystal_cap_hdl(struct oid_par_priv *poid_par_priv) int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) { - u8 rx_pkt_type; int status = NDIS_STATUS_SUCCESS; if (poid_par_priv->type_of_oid != SET_OID) @@ -1102,8 +1100,6 @@ int rtl8188eu_oid_rt_set_rx_packet_type_hdl(struct oid_par_priv *poid_par_priv) if (poid_par_priv->information_buf_len < sizeof(u8)) return NDIS_STATUS_INVALID_LENGTH; - rx_pkt_type = *((u8 *)poid_par_priv->information_buf);/* 4 */ - return status; } -- cgit v1.2.3 From 282bd08229761af5c7d529befe38f56c20f77c54 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 5 Aug 2021 22:50:10 +0200 Subject: staging: r8188eu: replace custom macros with is_broadcast_ether_addr Replace usage of custom macros with is_broadcast_ether_addr. All buffers are properly aligned. Remove the now unsued macros MacAddr_isBcst and IS_MAC_ADDRESS_BROADCAST. Signed-off-by: Michael Straube Acked-by: Larry Finger Link: https://lore.kernel.org/r/20210805205010.31192-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 11 ++--------- drivers/staging/r8188eu/core/rtw_recv.c | 2 +- drivers/staging/r8188eu/include/wifi.h | 7 ------- 3 files changed, 3 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index a7f966ad7082..1a4227729e0d 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -13,13 +13,6 @@ extern void indicate_wx_scan_complete_event(struct adapter *padapter); -#define IS_MAC_ADDRESS_BROADCAST(addr) \ -(\ - ((addr[0] == 0xff) && (addr[1] == 0xff) && \ - (addr[2] == 0xff) && (addr[3] == 0xff) && \ - (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ -) - u8 rtw_validate_ssid(struct ndis_802_11_ssid *ssid) { u8 i; @@ -540,7 +533,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) } /* check BSSID */ - if (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == true) { + if (is_broadcast_ether_addr(key->BSSID)) { ret = false; goto exit; } @@ -592,7 +585,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) encryptionalgo = padapter->securitypriv.dot118021XGrpPrivacy; } - if ((check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) == true) && (IS_MAC_ADDRESS_BROADCAST(key->BSSID) == false)) { + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE) && !is_broadcast_ether_addr(key->BSSID)) { ret = _FAIL; goto exit; } diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 46fb8c289652..3f5a7282c857 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -622,7 +622,7 @@ static void count_rx_stats(struct adapter *padapter, struct recv_frame *prframe, padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - if ((!MacAddr_isBcst(pattrib->dst)) && (!IS_MCAST(pattrib->dst))) + if (!is_broadcast_ether_addr(pattrib->dst) && !IS_MCAST(pattrib->dst)) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; if (sta) diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h index 2c56d1d70d03..65fc677bf4eb 100644 --- a/drivers/staging/r8188eu/include/wifi.h +++ b/drivers/staging/r8188eu/include/wifi.h @@ -368,13 +368,6 @@ enum WIFI_REG_DOMAIN { #define GetAddr4Ptr(pbuf) ((unsigned char *)((size_t)(pbuf) + 24)) -#define MacAddr_isBcst(addr) \ - ( \ - ((addr[0] == 0xff) && (addr[1] == 0xff) && \ - (addr[2] == 0xff) && (addr[3] == 0xff) && \ - (addr[4] == 0xff) && (addr[5] == 0xff)) ? true : false \ -) - static inline int IS_MCAST(unsigned char *da) { if ((*da) & 0x01) -- cgit v1.2.3 From bb13dc2b3d8a7c6157ecaf680c435e7b2fbe4613 Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Mon, 2 Aug 2021 23:12:10 +0530 Subject: staging: vchiq: Set $CONFIG_BCM2835_VCHIQ to imply $CONFIG_VCHIQ_CDEV Before $CONFIG_VCHIQ_CDEV was defined, the vchiq cdev used to be created unconditionally when CONFIG_BCM2835_VCHIQ=y. When an earlier commit introduced the new config, its default behavior was set to disabled, which might surprise some unsuspecting users. Hence, modify CONFIG_BCM2835_VCHIQ to imply CONFIG_VCHIQ_CDEV Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/da53207b24bc37f166b05c6835087becdc6b5b4d.1627925241.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig index 63caa6818d37..ad44b80f13ca 100644 --- a/drivers/staging/vc04_services/Kconfig +++ b/drivers/staging/vc04_services/Kconfig @@ -13,6 +13,7 @@ if BCM_VIDEOCORE config BCM2835_VCHIQ tristate "BCM2835 VCHIQ" + imply VCHIQ_CDEV help Kernel to VideoCore communication interface for the BCM2835 family of products. -- cgit v1.2.3 From 69c92a749b89a7654084d0afd774018008a8de49 Mon Sep 17 00:00:00 2001 From: Ojaswin Mujoo Date: Mon, 2 Aug 2021 23:12:11 +0530 Subject: staging: vchiq: Add details to Kconfig help texts Add some details to the Kconfig definitions of $CONFIG_VCHIQ_CDEV and $CONFIG_BCM2835_VCHIQ to help make the motive behind the configs a bit more clear. Reviewed-by: Stefan Wahren Signed-off-by: Ojaswin Mujoo Link: https://lore.kernel.org/r/ab88d3222088aca29a319147b50a9d1e9f0f8b81.1627925241.git.ojaswin98@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vc04_services/Kconfig | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vc04_services/Kconfig b/drivers/staging/vc04_services/Kconfig index ad44b80f13ca..cb7c82403dbf 100644 --- a/drivers/staging/vc04_services/Kconfig +++ b/drivers/staging/vc04_services/Kconfig @@ -15,18 +15,27 @@ config BCM2835_VCHIQ tristate "BCM2835 VCHIQ" imply VCHIQ_CDEV help - Kernel to VideoCore communication interface for the - BCM2835 family of products. - Defaults to Y when the Broadcom Videocore services - are included in the build, N otherwise. + Broadcom BCM2835 and similar SoCs have a VPU called VideoCore. This config + enables the VCHIQ driver, which implements a messaging interface between + the kernel and the firmware running on VideoCore. Other drivers use this + interface to communicate to the VPU. More specifically, the VCHIQ driver is + used by audio/video and camera drivers as well as for implementing MMAL + API, which is in turn used by several multimedia services on the BCM2835 + family of SoCs. + Defaults to Y when the Broadcom Videocore services are included in + the build, N otherwise. if BCM2835_VCHIQ config VCHIQ_CDEV bool "VCHIQ Character Driver" help - Enable the creation of VCHIQ character driver to help - communicate with the Videocore platform. + Enable the creation of VCHIQ character driver. The cdev exposes ioctls used + by userspace libraries and testing tools to interact with VideoCore, via + the VCHIQ core driver (Check BCM2835_VCHIQ for more info). + This can be set to 'N' if the VideoCore communication is not needed by + userspace but only by other kernel modules (like bcm2835-audio). If not + sure, set this to 'Y'. endif -- cgit v1.2.3 From ada0e6dbbb098350e0cb7fd32672ba4fd98500fc Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Fri, 6 Aug 2021 13:11:06 -0700 Subject: staging: rtl8192e: Avoid field-overflowing memcpy() In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields. Split the 3 addr memcpy() into 3 memcpy() calls so the compiler doesn't think an overflowing memcpy() happens against the addr1 field (the neighbors are intended to be copied as well). rtllib_read_qos_param_element() copies a struct rtllib_info_element into a struct rtllib_qos_information_element, but is actually wanting to copy into the larger struct rtllib_qos_parameter_info (the contents of ac_params_record[] is later examined). Refactor the routine to perform centralized checks, and copy the entire contents directly (since the id and len members match the elementID and length members): struct rtllib_info_element { u8 id; u8 len; u8 data[]; } __packed; struct rtllib_qos_information_element { u8 elementID; u8 length; u8 qui[QOS_OUI_LEN]; u8 qui_type; u8 qui_subtype; u8 version; u8 ac_info; } __packed; struct rtllib_qos_parameter_info { struct rtllib_qos_information_element info_element; u8 reserved; struct rtllib_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; } __packed; Cc: Darshan D V Cc: Aditya Srivastava Cc: devel@driverdev.osuosl.org Cc: Larry Finger Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210806201106.2871169-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtllib_crypt_ccmp.c | 4 +- drivers/staging/rtl8192e/rtllib_rx.c | 57 +++++++++------------------- 2 files changed, 20 insertions(+), 41 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c index b60e2a109ce4..ed968c01c7ff 100644 --- a/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c +++ b/drivers/staging/rtl8192e/rtllib_crypt_ccmp.c @@ -133,7 +133,9 @@ static int ccmp_init_iv_and_aad(struct rtllib_hdr_4addr *hdr, pos = (u8 *) hdr; aad[0] = pos[0] & 0x8f; aad[1] = pos[1] & 0xc7; - memcpy(aad + 2, hdr->addr1, 3 * ETH_ALEN); + memcpy(&aad[2], &hdr->addr1, ETH_ALEN); + memcpy(&aad[8], &hdr->addr2, ETH_ALEN); + memcpy(&aad[14], &hdr->addr3, ETH_ALEN); pos = (u8 *) &hdr->seq_ctl; aad[20] = pos[0] & 0x0f; aad[21] = 0; /* all bits masked */ diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c index c2209c033838..e3d0a361d370 100644 --- a/drivers/staging/rtl8192e/rtllib_rx.c +++ b/drivers/staging/rtl8192e/rtllib_rx.c @@ -1556,6 +1556,8 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element *info_element, int sub_type) { + if (info_element->elementID != QOS_ELEMENT_ID) + return -1; if (info_element->qui_subtype != sub_type) return -1; if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) @@ -1570,57 +1572,32 @@ static int rtllib_verify_qos_info(struct rtllib_qos_information_element /* Parse a QoS parameter element */ -static int rtllib_read_qos_param_element(struct rtllib_qos_parameter_info - *element_param, - struct rtllib_info_element - *info_element) +static int rtllib_read_qos_param_element( + struct rtllib_qos_parameter_info *element_param, + struct rtllib_info_element *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_parameter_info) - 2; + size_t size = sizeof(*element_param); - if ((info_element == NULL) || (element_param == NULL)) + if (!element_param || !info_element || info_element->len != size - 2) return -1; - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; + memcpy(element_param, info_element, size); + return rtllib_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); } /* Parse a QoS information element */ -static int rtllib_read_qos_info_element(struct rtllib_qos_information_element - *element_info, - struct rtllib_info_element - *info_element) +static int rtllib_read_qos_info_element( + struct rtllib_qos_information_element *element_info, + struct rtllib_info_element *info_element) { - int ret = 0; - u16 size = sizeof(struct rtllib_qos_information_element) - 2; + size_t size = sizeof(*element_info); - if (element_info == NULL) + if (!element_info || !info_element || info_element->len != size - 2) return -1; - if (info_element == NULL) - return -1; - - if ((info_element->id == QOS_ELEMENT_ID) && - (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = rtllib_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; + memcpy(element_info, info_element, size); + return rtllib_verify_qos_info(element_info, QOS_OUI_INFO_SUB_TYPE); } -- cgit v1.2.3 From 1b3c6cccda3f012ffab8287f1d6151492055340e Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Fri, 6 Aug 2021 13:12:07 -0700 Subject: staging: rtl8192u: Avoid field-overflowing memcpy() In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields. Split the 3 addr memcpy() into 3 memcpy() calls so the compiler doesn't think an overflowing memcpy() happens against the addr1 field (the neighbors are intended to be copied as well). ieee80211_read_qos_param_element() copies a struct ieee80211_info_element into a struct ieee80211_qos_information_element, but is actually wanting to copy into the larger struct ieee80211_qos_parameter_info (the contents of ac_params_record[] is later examined). Refactor the routine to perform centralized checks, and copy the entire contents directly (since the id and len members match the elementID and length members): struct ieee80211_info_element { u8 id; u8 len; u8 data[]; } __packed; struct ieee80211_qos_information_element { u8 elementID; u8 length; u8 qui[QOS_OUI_LEN]; u8 qui_type; u8 qui_subtype; u8 version; u8 ac_info; } __packed; struct ieee80211_qos_parameter_info { struct ieee80211_qos_information_element info_element; u8 reserved; struct ieee80211_qos_ac_parameter ac_params_record[QOS_QUEUE_NUM]; } __packed; Additionally replace old-style zero-element arrays with flexible arrays. Cc: Greg Kroah-Hartman Cc: Pascal Terjan Cc: Christophe JAILLET Cc: devel@driverdev.osuosl.org Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210806201208.2871467-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/ieee80211/ieee80211.h | 4 +- .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 4 +- drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | 49 +++++++--------------- 3 files changed, 19 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 7903c777a417..15207dc1f5c5 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -303,7 +303,7 @@ struct ieee_param { struct { u32 len; u8 reserved[32]; - u8 data[0]; + u8 data[]; } wpa_ie; struct{ int command; @@ -316,7 +316,7 @@ struct ieee_param { u8 idx; u8 seq[8]; /* sequence counter (set: RX, get: TX) */ u16 key_len; - u8 key[0]; + u8 key[]; } crypt; } u; }; diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c index c241cf484023..ccff385cf1f8 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c @@ -141,7 +141,9 @@ static int ccmp_init_iv_and_aad(struct rtl_80211_hdr_4addr *hdr, pos = (u8 *)hdr; aad[0] = pos[0] & 0x8f; aad[1] = pos[1] & 0xc7; - memcpy(aad + 2, hdr->addr1, 3 * ETH_ALEN); + memcpy(&aad[2], &hdr->addr1, ETH_ALEN); + memcpy(&aad[8], &hdr->addr2, ETH_ALEN); + memcpy(&aad[14], &hdr->addr3, ETH_ALEN); pos = (u8 *)&hdr->seq_ctl; aad[20] = pos[0] & 0x0f; aad[21] = 0; /* all bits masked */ diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index b0e01ee65f7f..b58e75932ecd 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -1310,7 +1310,8 @@ static u8 qos_oui[QOS_OUI_LEN] = { 0x00, 0x50, 0xF2 }; static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element *info_element, int sub_type) { - + if (info_element->elementID != QOS_ELEMENT_ID) + return -1; if (info_element->qui_subtype != sub_type) return -1; if (memcmp(info_element->qui, qos_oui, QOS_OUI_LEN)) @@ -1327,27 +1328,18 @@ static int ieee80211_verify_qos_info(struct ieee80211_qos_information_element /* * Parse a QoS parameter element */ -static int ieee80211_read_qos_param_element(struct ieee80211_qos_parameter_info - *element_param, struct ieee80211_info_element - *info_element) +static int ieee80211_read_qos_param_element( + struct ieee80211_qos_parameter_info *element_param, + struct ieee80211_info_element *info_element) { - int ret = 0; - u16 size = sizeof(struct ieee80211_qos_parameter_info) - 2; + size_t size = sizeof(*element_param); - if (!info_element || !element_param) + if (!element_param || !info_element || info_element->len != size - 2) return -1; - if (info_element->id == QOS_ELEMENT_ID && info_element->len == size) { - memcpy(element_param->info_element.qui, info_element->data, - info_element->len); - element_param->info_element.elementID = info_element->id; - element_param->info_element.length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = ieee80211_verify_qos_info(&element_param->info_element, - QOS_OUI_PARAM_SUB_TYPE); - return ret; + memcpy(element_param, info_element, size); + return ieee80211_verify_qos_info(&element_param->info_element, + QOS_OUI_PARAM_SUB_TYPE); } /* @@ -1357,26 +1349,13 @@ static int ieee80211_read_qos_info_element( struct ieee80211_qos_information_element *element_info, struct ieee80211_info_element *info_element) { - int ret = 0; - u16 size = sizeof(struct ieee80211_qos_information_element) - 2; + size_t size = sizeof(*element_info); - if (!element_info) + if (!element_info || !info_element || info_element->len != size - 2) return -1; - if (!info_element) - return -1; - - if ((info_element->id == QOS_ELEMENT_ID) && (info_element->len == size)) { - memcpy(element_info->qui, info_element->data, - info_element->len); - element_info->elementID = info_element->id; - element_info->length = info_element->len; - } else - ret = -1; - if (ret == 0) - ret = ieee80211_verify_qos_info(element_info, - QOS_OUI_INFO_SUB_TYPE); - return ret; + memcpy(element_info, info_element, size); + return ieee80211_verify_qos_info(element_info, QOS_OUI_INFO_SUB_TYPE); } -- cgit v1.2.3 From 859c57f606c78cb8b33cabbd22ad1d4ff9f80e4e Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Fri, 6 Aug 2021 13:14:22 -0700 Subject: staging: rtl8723bs: Avoid field-overflowing memcpy() In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields. Adjust memcpy() destination to be the named structure itself, rather than the first member, allowing memcpy() to correctly reason about the size. "objdump -d" shows no object code changes. Cc: Ross Schmidt Cc: Joe Perches Cc: devel@driverdev.osuosl.org Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210806201422.2871679-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_mlme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index 5ed13bf765d2..e0cee51224ff 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2389,7 +2389,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ } /* fill default supported_mcs_set */ - memcpy(ht_capie.mcs.rx_mask, pmlmeext->default_supported_mcs_set, 16); + memcpy(&ht_capie.mcs, pmlmeext->default_supported_mcs_set, 16); /* update default supported_mcs_set */ rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); -- cgit v1.2.3 From dfac77baa2837a9a4ac66015234854ebccb85bf1 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Fri, 6 Aug 2021 16:32:35 -0500 Subject: staging: r8188eu: Fix potential memory leak or NULL dereference In routine c2h_wk_callback(() following a kmalloc() call, the error recovery is flawed. If the kmalloc() returns a pointer that is not NULL, and the following c2h_evt_read() fails, the code will leak that buffer. If the kmalloc() fails, a NULL dereference will occur in the following code. Reported-by: Dan Carpenter Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210806213235.22349-1-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index c3a9051ca10c..238ae79f4141 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -1908,8 +1908,12 @@ static void c2h_wk_callback(struct work_struct *work) c2h_evt = kmalloc(16, GFP_KERNEL); if (c2h_evt) { /* This C2H event is not read, read & clear now */ - if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) + if (c2h_evt_read(adapter, (u8 *)c2h_evt) != _SUCCESS) { + kfree(c2h_evt); continue; + } + } else { + return; } } -- cgit v1.2.3 From 0d6dc43772a6a5101ae43548a2716e5b5b249543 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:53 +0200 Subject: staging: rtl8723bs: remove code related to unsupported MCS index values remove code related to MCS index from 8 to 31 for rtl8723bs works only with index from 0 to 7 and index 32. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/1d5c8ca570a9f1880864f37099d625f96ea4a1d1.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com.c | 144 ----------- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 275 +-------------------- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 5 +- drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h | 2 - drivers/staging/rtl8723bs/hal/odm_reg.h | 4 - drivers/staging/rtl8723bs/include/hal_com.h | 35 +-- drivers/staging/rtl8723bs/include/hal_com_phycfg.h | 3 - drivers/staging/rtl8723bs/include/hal_com_reg.h | 19 -- drivers/staging/rtl8723bs/include/ieee80211.h | 24 -- drivers/staging/rtl8723bs/include/rtl8723b_xmit.h | 8 - 10 files changed, 8 insertions(+), 511 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index fbe6b64aa1fb..7dd49c8538e4 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -222,78 +222,6 @@ u8 MRateToHwRate(u8 rate) case MGN_MCS7: ret = DESC_RATEMCS7; break; - case MGN_MCS8: - ret = DESC_RATEMCS8; - break; - case MGN_MCS9: - ret = DESC_RATEMCS9; - break; - case MGN_MCS10: - ret = DESC_RATEMCS10; - break; - case MGN_MCS11: - ret = DESC_RATEMCS11; - break; - case MGN_MCS12: - ret = DESC_RATEMCS12; - break; - case MGN_MCS13: - ret = DESC_RATEMCS13; - break; - case MGN_MCS14: - ret = DESC_RATEMCS14; - break; - case MGN_MCS15: - ret = DESC_RATEMCS15; - break; - case MGN_MCS16: - ret = DESC_RATEMCS16; - break; - case MGN_MCS17: - ret = DESC_RATEMCS17; - break; - case MGN_MCS18: - ret = DESC_RATEMCS18; - break; - case MGN_MCS19: - ret = DESC_RATEMCS19; - break; - case MGN_MCS20: - ret = DESC_RATEMCS20; - break; - case MGN_MCS21: - ret = DESC_RATEMCS21; - break; - case MGN_MCS22: - ret = DESC_RATEMCS22; - break; - case MGN_MCS23: - ret = DESC_RATEMCS23; - break; - case MGN_MCS24: - ret = DESC_RATEMCS24; - break; - case MGN_MCS25: - ret = DESC_RATEMCS25; - break; - case MGN_MCS26: - ret = DESC_RATEMCS26; - break; - case MGN_MCS27: - ret = DESC_RATEMCS27; - break; - case MGN_MCS28: - ret = DESC_RATEMCS28; - break; - case MGN_MCS29: - ret = DESC_RATEMCS29; - break; - case MGN_MCS30: - ret = DESC_RATEMCS30; - break; - case MGN_MCS31: - ret = DESC_RATEMCS31; - break; default: break; } @@ -366,78 +294,6 @@ u8 HwRateToMRate(u8 rate) case DESC_RATEMCS7: ret_rate = MGN_MCS7; break; - case DESC_RATEMCS8: - ret_rate = MGN_MCS8; - break; - case DESC_RATEMCS9: - ret_rate = MGN_MCS9; - break; - case DESC_RATEMCS10: - ret_rate = MGN_MCS10; - break; - case DESC_RATEMCS11: - ret_rate = MGN_MCS11; - break; - case DESC_RATEMCS12: - ret_rate = MGN_MCS12; - break; - case DESC_RATEMCS13: - ret_rate = MGN_MCS13; - break; - case DESC_RATEMCS14: - ret_rate = MGN_MCS14; - break; - case DESC_RATEMCS15: - ret_rate = MGN_MCS15; - break; - case DESC_RATEMCS16: - ret_rate = MGN_MCS16; - break; - case DESC_RATEMCS17: - ret_rate = MGN_MCS17; - break; - case DESC_RATEMCS18: - ret_rate = MGN_MCS18; - break; - case DESC_RATEMCS19: - ret_rate = MGN_MCS19; - break; - case DESC_RATEMCS20: - ret_rate = MGN_MCS20; - break; - case DESC_RATEMCS21: - ret_rate = MGN_MCS21; - break; - case DESC_RATEMCS22: - ret_rate = MGN_MCS22; - break; - case DESC_RATEMCS23: - ret_rate = MGN_MCS23; - break; - case DESC_RATEMCS24: - ret_rate = MGN_MCS24; - break; - case DESC_RATEMCS25: - ret_rate = MGN_MCS25; - break; - case DESC_RATEMCS26: - ret_rate = MGN_MCS26; - break; - case DESC_RATEMCS27: - ret_rate = MGN_MCS27; - break; - case DESC_RATEMCS28: - ret_rate = MGN_MCS28; - break; - case DESC_RATEMCS29: - ret_rate = MGN_MCS29; - break; - case DESC_RATEMCS30: - ret_rate = MGN_MCS30; - break; - case DESC_RATEMCS31: - ret_rate = MGN_MCS31; - break; default: break; } diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 4fb2884fce38..03c174aab08d 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -29,15 +29,6 @@ u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, case HT_MCS0_MCS7: value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2]; break; - case HT_MCS8_MCS15: - value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3]; - break; - case HT_MCS16_MCS23: - value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4]; - break; - case HT_MCS24_MCS31: - value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5]; - break; default: break; } @@ -69,15 +60,6 @@ phy_SetTxPowerByRateBase( case HT_MCS0_MCS7: pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2] = Value; break; - case HT_MCS8_MCS15: - pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][3] = Value; - break; - case HT_MCS16_MCS23: - pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][4] = Value; - break; - case HT_MCS24_MCS31: - pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][5] = Value; - break; default: break; } @@ -99,13 +81,6 @@ struct adapter *padapter base = PHY_GetTxPowerByRate(padapter, path, RF_1TX, MGN_MCS7); phy_SetTxPowerByRateBase(padapter, path, HT_MCS0_MCS7, RF_1TX, base); - - base = PHY_GetTxPowerByRate(padapter, path, RF_2TX, MGN_MCS15); - phy_SetTxPowerByRateBase(padapter, path, HT_MCS8_MCS15, RF_2TX, base); - - base = PHY_GetTxPowerByRate(padapter, path, RF_3TX, MGN_MCS23); - phy_SetTxPowerByRateBase(padapter, path, HT_MCS16_MCS23, RF_3TX, base); - } } @@ -266,33 +241,6 @@ PHY_GetRateValuesOfTxPowerByRate( *RateNum = 4; break; - case rTxAGC_A_Mcs11_Mcs08: - case rTxAGC_B_Mcs11_Mcs08: - RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8); - RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9); - RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10); - RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11); - for (i = 0; i < 4; ++i) { - PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + - ((Value >> (i * 8)) & 0xF)); - } - *RateNum = 4; - break; - - case rTxAGC_A_Mcs15_Mcs12: - case rTxAGC_B_Mcs15_Mcs12: - RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12); - RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13); - RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14); - RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15); - for (i = 0; i < 4; ++i) { - PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + - ((Value >> (i * 8)) & 0xF)); - } - *RateNum = 4; - - break; - case rTxAGC_B_CCK1_55_Mcs32: RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_1M); RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_2M); @@ -379,66 +327,6 @@ PHY_GetRateValuesOfTxPowerByRate( *RateNum = 4; break; - case 0xC34: - case 0xE34: - case 0x1834: - case 0x1a34: - RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS8); - RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS9); - RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS10); - RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS11); - for (i = 0; i < 4; ++i) { - PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + - ((Value >> (i * 8)) & 0xF)); - } - *RateNum = 4; - break; - - case 0xC38: - case 0xE38: - case 0x1838: - case 0x1a38: - RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS12); - RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS13); - RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS14); - RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS15); - for (i = 0; i < 4; ++i) { - PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + - ((Value >> (i * 8)) & 0xF)); - } - *RateNum = 4; - break; - - case 0xCD8: - case 0xED8: - case 0x18D8: - case 0x1aD8: - RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS16); - RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS17); - RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS18); - RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS19); - for (i = 0; i < 4; ++i) { - PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + - ((Value >> (i * 8)) & 0xF)); - } - *RateNum = 4; - break; - - case 0xCDC: - case 0xEDC: - case 0x18DC: - case 0x1aDC: - RateIndex[0] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS20); - RateIndex[1] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS21); - RateIndex[2] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS22); - RateIndex[3] = PHY_GetRateIndexOfTxPowerByRate(MGN_MCS23); - for (i = 0; i < 4; ++i) { - PwrByRateVal[i] = (s8) ((((Value >> (i * 8 + 4)) & 0xF)) * 10 + - ((Value >> (i * 8)) & 0xF)); - } - *RateNum = 4; - break; - default: break; } @@ -530,13 +418,6 @@ struct adapter *padapter u8 mcs0_7Rates[8] = { MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7 }; - u8 mcs8_15Rates[8] = { - MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15 - }; - u8 mcs16_23Rates[8] = { - MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23 - }; - for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path) { for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) { /* CCK */ @@ -560,19 +441,6 @@ struct adapter *padapter PHY_SetTxPowerByRate(padapter, path, txNum, mcs0_7Rates[i], value - base); } - /* HT MCS8~15 */ - base = PHY_GetTxPowerByRate(padapter, path, txNum, MGN_MCS15); - for (i = 0; i < sizeof(mcs8_15Rates); ++i) { - value = PHY_GetTxPowerByRate(padapter, path, txNum, mcs8_15Rates[i]); - PHY_SetTxPowerByRate(padapter, path, txNum, mcs8_15Rates[i], value - base); - } - - /* HT MCS16~23 */ - base = PHY_GetTxPowerByRate(padapter, path, txNum, MGN_MCS23); - for (i = 0; i < sizeof(mcs16_23Rates); ++i) { - value = PHY_GetTxPowerByRate(padapter, path, txNum, mcs16_23Rates[i]); - PHY_SetTxPowerByRate(padapter, path, txNum, mcs16_23Rates[i], value - base); - } } } } @@ -614,27 +482,6 @@ void PHY_SetTxPowerIndexByRateSection( Channel, htRates1T, ARRAY_SIZE(htRates1T)); - } else if (RateSection == HT_MCS8_MCS15) { - u8 htRates2T[] = {MGN_MCS8, MGN_MCS9, MGN_MCS10, MGN_MCS11, MGN_MCS12, MGN_MCS13, MGN_MCS14, MGN_MCS15}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, - pHalData->CurrentChannelBW, - Channel, htRates2T, - ARRAY_SIZE(htRates2T)); - - } else if (RateSection == HT_MCS16_MCS23) { - u8 htRates3T[] = {MGN_MCS16, MGN_MCS17, MGN_MCS18, MGN_MCS19, MGN_MCS20, MGN_MCS21, MGN_MCS22, MGN_MCS23}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, - pHalData->CurrentChannelBW, - Channel, htRates3T, - ARRAY_SIZE(htRates3T)); - - } else if (RateSection == HT_MCS24_MCS31) { - u8 htRates4T[] = {MGN_MCS24, MGN_MCS25, MGN_MCS26, MGN_MCS27, MGN_MCS28, MGN_MCS29, MGN_MCS30, MGN_MCS31}; - PHY_SetTxPowerIndexByRateArray(padapter, RFPath, - pHalData->CurrentChannelBW, - Channel, htRates4T, - ARRAY_SIZE(htRates4T)); - } } @@ -663,25 +510,11 @@ u8 PHY_GetTxPowerIndexBase( txPower += pHalData->OFDM_24G_Diff[RFPath][TX_1S]; if (BandWidth == CHANNEL_WIDTH_20) { /* BW20-1S, BW20-2S */ - if (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) + if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7) txPower += pHalData->BW20_24G_Diff[RFPath][TX_1S]; - if (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) - txPower += pHalData->BW20_24G_Diff[RFPath][TX_2S]; - if (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) - txPower += pHalData->BW20_24G_Diff[RFPath][TX_3S]; - if (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) - txPower += pHalData->BW20_24G_Diff[RFPath][TX_4S]; - } else if (BandWidth == CHANNEL_WIDTH_40) { /* BW40-1S, BW40-2S */ - if (MGN_MCS0 <= Rate && Rate <= MGN_MCS31) + if (MGN_MCS0 <= Rate && Rate <= MGN_MCS7) txPower += pHalData->BW40_24G_Diff[RFPath][TX_1S]; - if (MGN_MCS8 <= Rate && Rate <= MGN_MCS31) - txPower += pHalData->BW40_24G_Diff[RFPath][TX_2S]; - if (MGN_MCS16 <= Rate && Rate <= MGN_MCS31) - txPower += pHalData->BW40_24G_Diff[RFPath][TX_3S]; - if (MGN_MCS24 <= Rate && Rate <= MGN_MCS31) - txPower += pHalData->BW40_24G_Diff[RFPath][TX_4S]; - } return txPower; @@ -768,78 +601,6 @@ u8 PHY_GetRateIndexOfTxPowerByRate(u8 Rate) case MGN_MCS7: index = 19; break; - case MGN_MCS8: - index = 20; - break; - case MGN_MCS9: - index = 21; - break; - case MGN_MCS10: - index = 22; - break; - case MGN_MCS11: - index = 23; - break; - case MGN_MCS12: - index = 24; - break; - case MGN_MCS13: - index = 25; - break; - case MGN_MCS14: - index = 26; - break; - case MGN_MCS15: - index = 27; - break; - case MGN_MCS16: - index = 28; - break; - case MGN_MCS17: - index = 29; - break; - case MGN_MCS18: - index = 30; - break; - case MGN_MCS19: - index = 31; - break; - case MGN_MCS20: - index = 32; - break; - case MGN_MCS21: - index = 33; - break; - case MGN_MCS22: - index = 34; - break; - case MGN_MCS23: - index = 35; - break; - case MGN_MCS24: - index = 36; - break; - case MGN_MCS25: - index = 37; - break; - case MGN_MCS26: - index = 38; - break; - case MGN_MCS27: - index = 39; - break; - case MGN_MCS28: - index = 40; - break; - case MGN_MCS29: - index = 41; - break; - case MGN_MCS30: - index = 42; - break; - case MGN_MCS31: - index = 43; - break; default: break; } @@ -896,19 +657,10 @@ void PHY_SetTxPowerByRate( void PHY_SetTxPowerLevelByPath(struct adapter *Adapter, u8 channel, u8 path) { - struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - - /* if (pMgntInfo->RegNByteAccess == 0) */ - { - PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, CCK); + PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, CCK); - PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, OFDM); - PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS0_MCS7); - - if (pHalData->NumTotalRFPath >= 2) - PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS8_MCS15); - - } + PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, OFDM); + PHY_SetTxPowerIndexByRateSection(Adapter, path, channel, HT_MCS0_MCS7); } void PHY_SetTxPowerIndexByRateArray( @@ -970,15 +722,6 @@ static s16 get_rate_sctn_idx(const u8 rate) case MGN_MCS0: case MGN_MCS1: case MGN_MCS2: case MGN_MCS3: case MGN_MCS4: case MGN_MCS5: case MGN_MCS6: case MGN_MCS7: return 2; - case MGN_MCS8: case MGN_MCS9: case MGN_MCS10: case MGN_MCS11: - case MGN_MCS12: case MGN_MCS13: case MGN_MCS14: case MGN_MCS15: - return 3; - case MGN_MCS16: case MGN_MCS17: case MGN_MCS18: case MGN_MCS19: - case MGN_MCS20: case MGN_MCS21: case MGN_MCS22: case MGN_MCS23: - return 4; - case MGN_MCS24: case MGN_MCS25: case MGN_MCS26: case MGN_MCS27: - case MGN_MCS28: case MGN_MCS29: case MGN_MCS30: case MGN_MCS31: - return 5; default: return -1; } @@ -1070,13 +813,7 @@ void PHY_ConvertTxPowerLimitToPowerIndex(struct adapter *Adapter) for (rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) { if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { - if (rateSection == 5) /* HT 4T */ - BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_4TX, HT_MCS24_MCS31); - else if (rateSection == 4) /* HT 3T */ - BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_3TX, HT_MCS16_MCS23); - else if (rateSection == 3) /* HT 2T */ - BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_2TX, HT_MCS8_MCS15); - else if (rateSection == 2) /* HT 1T */ + if (rateSection == 2) /* HT 1T */ BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_1TX, HT_MCS0_MCS7); else if (rateSection == 1) /* OFDM */ BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_1TX, OFDM); diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 859451810c48..17a5850183ad 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -186,10 +186,7 @@ static void odm_RxPhyStatus92CSeries_Parsing( /* */ /* (3)EVM of HT rate */ /* */ - if (pPktinfo->data_rate >= DESC_RATEMCS8 && pPktinfo->data_rate <= DESC_RATEMCS15) - Max_spatial_stream = 2; /* both spatial stream make sense */ - else - Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ + Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ for (i = 0; i < Max_spatial_stream; i++) { /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ diff --git a/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h b/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h index 1c6c08000e27..3c71938899e0 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h +++ b/drivers/staging/rtl8723bs/hal/odm_RegDefine11N.h @@ -111,8 +111,6 @@ #define ODM_REG_TXAGC_A_1_MCS32_11N 0xE08 #define ODM_REG_TXAGC_A_MCS0_3_11N 0xE10 #define ODM_REG_TXAGC_A_MCS4_7_11N 0xE14 -#define ODM_REG_TXAGC_A_MCS8_11_11N 0xE18 -#define ODM_REG_TXAGC_A_MCS12_15_11N 0xE1C #define ODM_REG_FPGA0_IQK_11N 0xE28 #define ODM_REG_TXIQK_TONE_A_11N 0xE30 #define ODM_REG_RXIQK_TONE_A_11N 0xE34 diff --git a/drivers/staging/rtl8723bs/hal/odm_reg.h b/drivers/staging/rtl8723bs/hal/odm_reg.h index 1ec6ffd69dbe..a3b1f673774c 100644 --- a/drivers/staging/rtl8723bs/hal/odm_reg.h +++ b/drivers/staging/rtl8723bs/hal/odm_reg.h @@ -32,10 +32,8 @@ #define ODM_TXAGC_B_MCS32_5 0x838 #define ODM_TXAGC_B_MCS0_MCS3 0x83c #define ODM_TXAGC_B_MCS4_MCS7 0x848 -#define ODM_TXAGC_B_MCS8_MCS11 0x84c #define ODM_ANALOG_REGISTER 0x85c #define ODM_RF_INTERFACE_OUTPUT 0x860 -#define ODM_TXAGC_B_MCS12_MCS15 0x868 #define ODM_TXAGC_B_11_A_2_11 0x86c #define ODM_AD_DA_LSB_MASK 0x874 #define ODM_ENABLE_3_WIRE 0x88c @@ -71,8 +69,6 @@ #define ODM_TXAGC_A_1_MCS32 0xe08 #define ODM_TXAGC_A_MCS0_MCS3 0xe10 #define ODM_TXAGC_A_MCS4_MCS7 0xe14 -#define ODM_TXAGC_A_MCS8_MCS11 0xe18 -#define ODM_TXAGC_A_MCS12_MCS15 0xe1c /* RF REG */ #define ODM_GAIN_SETTING 0x00 diff --git a/drivers/staging/rtl8723bs/include/hal_com.h b/drivers/staging/rtl8723bs/include/hal_com.h index 1bc332261b2a..7be0ea20bca4 100644 --- a/drivers/staging/rtl8723bs/include/hal_com.h +++ b/drivers/staging/rtl8723bs/include/hal_com.h @@ -45,30 +45,6 @@ #define DESC_RATEMCS5 0x11 #define DESC_RATEMCS6 0x12 #define DESC_RATEMCS7 0x13 -#define DESC_RATEMCS8 0x14 -#define DESC_RATEMCS9 0x15 -#define DESC_RATEMCS10 0x16 -#define DESC_RATEMCS11 0x17 -#define DESC_RATEMCS12 0x18 -#define DESC_RATEMCS13 0x19 -#define DESC_RATEMCS14 0x1a -#define DESC_RATEMCS15 0x1b -#define DESC_RATEMCS16 0x1C -#define DESC_RATEMCS17 0x1D -#define DESC_RATEMCS18 0x1E -#define DESC_RATEMCS19 0x1F -#define DESC_RATEMCS20 0x20 -#define DESC_RATEMCS21 0x21 -#define DESC_RATEMCS22 0x22 -#define DESC_RATEMCS23 0x23 -#define DESC_RATEMCS24 0x24 -#define DESC_RATEMCS25 0x25 -#define DESC_RATEMCS26 0x26 -#define DESC_RATEMCS27 0x27 -#define DESC_RATEMCS28 0x28 -#define DESC_RATEMCS29 0x29 -#define DESC_RATEMCS30 0x2A -#define DESC_RATEMCS31 0x2B #define HDATA_RATE(rate)\ (rate == DESC_RATE1M) ? "CCK_1M" : \ @@ -90,16 +66,7 @@ (rate == DESC_RATEMCS4) ? "MCS4" : \ (rate == DESC_RATEMCS5) ? "MCS5" : \ (rate == DESC_RATEMCS6) ? "MCS6" : \ -(rate == DESC_RATEMCS7) ? "MCS7" : \ -(rate == DESC_RATEMCS8) ? "MCS8" : \ -(rate == DESC_RATEMCS9) ? "MCS9" : \ -(rate == DESC_RATEMCS10) ? "MCS10" : \ -(rate == DESC_RATEMCS11) ? "MCS11" : \ -(rate == DESC_RATEMCS12) ? "MCS12" : \ -(rate == DESC_RATEMCS13) ? "MCS13" : \ -(rate == DESC_RATEMCS14) ? "MCS14" : \ -(rate == DESC_RATEMCS15) ? "MCS15" : "UNKNOWN" - +(rate == DESC_RATEMCS7) ? "MCS7" : "UNKNOWN" enum{ UP_LINK, diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h index c966d0e3e5ae..637089fed93d 100644 --- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h +++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h @@ -16,9 +16,6 @@ enum rate_section { CCK = 0, OFDM, HT_MCS0_MCS7, - HT_MCS8_MCS15, - HT_MCS16_MCS23, - HT_MCS24_MCS31, }; enum { diff --git a/drivers/staging/rtl8723bs/include/hal_com_reg.h b/drivers/staging/rtl8723bs/include/hal_com_reg.h index b2f179b48019..8213dcf48b34 100644 --- a/drivers/staging/rtl8723bs/include/hal_com_reg.h +++ b/drivers/staging/rtl8723bs/include/hal_com_reg.h @@ -662,15 +662,6 @@ Default: 00b. #define RATR_MCS5 0x00020000 #define RATR_MCS6 0x00040000 #define RATR_MCS7 0x00080000 -/* MCS 2 Spatial Stream */ -#define RATR_MCS8 0x00100000 -#define RATR_MCS9 0x00200000 -#define RATR_MCS10 0x00400000 -#define RATR_MCS11 0x00800000 -#define RATR_MCS12 0x01000000 -#define RATR_MCS13 0x02000000 -#define RATR_MCS14 0x04000000 -#define RATR_MCS15 0x08000000 /* CCK */ #define RATE_1M BIT(0) @@ -695,16 +686,6 @@ Default: 00b. #define RATE_MCS5 BIT(17) #define RATE_MCS6 BIT(18) #define RATE_MCS7 BIT(19) -/* MCS 2 Spatial Stream */ -#define RATE_MCS8 BIT(20) -#define RATE_MCS9 BIT(21) -#define RATE_MCS10 BIT(22) -#define RATE_MCS11 BIT(23) -#define RATE_MCS12 BIT(24) -#define RATE_MCS13 BIT(25) -#define RATE_MCS14 BIT(26) -#define RATE_MCS15 BIT(27) - /* ALL CCK Rate */ #define RATE_BITMAP_ALL 0xFFFFF diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index b3a9bcce4c44..89851fa36830 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -389,30 +389,6 @@ enum { MGN_MCS5, MGN_MCS6, MGN_MCS7, - MGN_MCS8, - MGN_MCS9, - MGN_MCS10, - MGN_MCS11, - MGN_MCS12, - MGN_MCS13, - MGN_MCS14, - MGN_MCS15, - MGN_MCS16, - MGN_MCS17, - MGN_MCS18, - MGN_MCS19, - MGN_MCS20, - MGN_MCS21, - MGN_MCS22, - MGN_MCS23, - MGN_MCS24, - MGN_MCS25, - MGN_MCS26, - MGN_MCS27, - MGN_MCS28, - MGN_MCS29, - MGN_MCS30, - MGN_MCS31, MGN_UNKNOWN }; diff --git a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h index 9dd329a5208a..ad2542d0cabe 100644 --- a/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h +++ b/drivers/staging/rtl8723bs/include/rtl8723b_xmit.h @@ -394,14 +394,6 @@ struct txdesc_8723b { #define DESC8723B_RATEMCS5 0x11 #define DESC8723B_RATEMCS6 0x12 #define DESC8723B_RATEMCS7 0x13 -#define DESC8723B_RATEMCS8 0x14 -#define DESC8723B_RATEMCS9 0x15 -#define DESC8723B_RATEMCS10 0x16 -#define DESC8723B_RATEMCS11 0x17 -#define DESC8723B_RATEMCS12 0x18 -#define DESC8723B_RATEMCS13 0x19 -#define DESC8723B_RATEMCS14 0x1a -#define DESC8723B_RATEMCS15 0x1b #define RX_HAL_IS_CCK_RATE_8723B(pDesc)\ (GET_RX_STATUS_DESC_RX_RATE_8723B(pDesc) == DESC8723B_RATE1M ||\ -- cgit v1.2.3 From 7942bdd45549770e4b223cb95c055fad0a9796cf Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:54 +0200 Subject: staging: rtl8723bs: remove unneeded loop remove unneeded loop over multiple spatial streams as phy only works on 1 spatial stream. Removed commented code, removed condition always satisfied, beautified comments. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/45f2ed02b8e5bb25057da6e7dc3e7c8713a1a2c0.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 43 +++++++++++++--------------- 1 file changed, 20 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 17a5850183ad..af4d5ab1b382 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -78,7 +78,7 @@ static void odm_RxPhyStatus92CSeries_Parsing( struct odm_packet_info *pPktinfo ) { - u8 i, Max_spatial_stream; + u8 i; s8 rx_pwr[4], rx_pwr_all = 0; u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; u8 RSSI, total_rssi = 0; @@ -182,30 +182,27 @@ static void odm_RxPhyStatus92CSeries_Parsing( pPhyInfo->rx_power = rx_pwr_all; pPhyInfo->recv_signal_power = rx_pwr_all; - {/* pMgntInfo->CustomerID != RT_CID_819x_Lenovo */ - /* */ - /* (3)EVM of HT rate */ - /* */ - Max_spatial_stream = 1; /* only spatial stream 1 makes sense */ - - for (i = 0; i < Max_spatial_stream; i++) { - /* Do not use shift operation like "rx_evmX >>= 1" because the compilor of free build environment */ - /* fill most significant bit to "zero" when doing shifting operation which may change a negative */ - /* value to positive one, then the dbm value (which is supposed to be negative) is not correct anymore. */ - EVM = odm_EVMdbToPercentage((pPhyStaRpt->stream_rxevm[i])); /* dbm */ - - /* if (pPktinfo->bPacketMatchBSSID) */ - { - if (i == ODM_RF_PATH_A) /* Fill value in RFD, Get the first spatial stream only */ - pPhyInfo->signal_quality = (u8)(EVM & 0xff); - - pPhyInfo->rx_mimo_signal_quality[i] = (u8)(EVM & 0xff); - } - } - } + /* + * (3)EVM of HT rate + * + * Only spatial stream 1 makes sense + * + * Do not use shift operation like "rx_evmX >>= 1" + * because the compiler of free build environment + * fill most significant bit to "zero" when doing + * shifting operation which may change a negative + * value to positive one, then the dbm value (which + * is supposed to be negative) is not correct + * anymore. + */ + EVM = odm_EVMdbToPercentage(pPhyStaRpt->stream_rxevm[0]); /* dbm */ + + /* Fill value in RFD, Get the first spatial stream only */ + pPhyInfo->signal_quality = (u8)(EVM & 0xff); + + pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = (u8)(EVM & 0xff); ODM_ParsingCFO(pDM_Odm, pPktinfo, pPhyStaRpt->path_cfotail); - } /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ -- cgit v1.2.3 From caa976ebf922f8ff68f32037430b9c7d9c9beba5 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:55 +0200 Subject: staging: rtl8723bs: do some code cleaning in modified function do some code cleaning after changes of previous commit. Fixed comments, camel case names, variable naming conventions; kept function names without chip series numbers (this is just code for 8723), fixed indentations, blank lines and other minor stuff. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/2bddef34cebdf35666d8abec4462c1a8d30c8c60.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_CfoTracking.c | 26 +-- drivers/staging/rtl8723bs/hal/odm_CfoTracking.h | 2 +- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 229 ++++++++++++------------ drivers/staging/rtl8723bs/hal/odm_HWConfig.h | 2 +- drivers/staging/rtl8723bs/hal/odm_RTL8723B.c | 12 +- drivers/staging/rtl8723bs/hal/odm_RTL8723B.h | 2 +- 6 files changed, 139 insertions(+), 134 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c index 0f6b9d661e39..a99d567468b2 100644 --- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c +++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c @@ -188,26 +188,28 @@ void ODM_CfoTracking(void *pDM_VOID) } } -void ODM_ParsingCFO(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail) +void odm_parsing_cfo(void *dm_void, void *pkt_info_void, s8 *cfotail) { - struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID; - struct odm_packet_info *pPktinfo = pPktinfo_VOID; - struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack; + struct dm_odm_t *dm_odm = (struct dm_odm_t *)dm_void; + struct odm_packet_info *pkt_info = pkt_info_void; + struct cfo_tracking *cfo_track = &dm_odm->DM_CfoTrack; u8 i; - if (!(pDM_Odm->SupportAbility & ODM_BB_CFO_TRACKING)) + if (!(dm_odm->SupportAbility & ODM_BB_CFO_TRACKING)) return; - if (pPktinfo->station_id != 0) { - /* 3 Update CFO report for path-A & path-B */ - /* Only paht-A and path-B have CFO tail and short CFO */ + if (pkt_info->station_id != 0) { + /* + * 3 Update CFO report for path-A & path-B + * Only paht-A and path-B have CFO tail and short CFO + */ for (i = ODM_RF_PATH_A; i <= ODM_RF_PATH_B; i++) - pCfoTrack->CFO_tail[i] = (int)pcfotail[i]; + cfo_track->CFO_tail[i] = (int)cfotail[i]; /* 3 Update packet counter */ - if (pCfoTrack->packetCount == 0xffffffff) - pCfoTrack->packetCount = 0; + if (cfo_track->packetCount == 0xffffffff) + cfo_track->packetCount = 0; else - pCfoTrack->packetCount++; + cfo_track->packetCount++; } } diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h index bb00d8c893bd..8fa6d9ec5880 100644 --- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h +++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.h @@ -34,6 +34,6 @@ void ODM_CfoTrackingInit(void *pDM_VOID); void ODM_CfoTracking(void *pDM_VOID); -void ODM_ParsingCFO(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail); +void odm_parsing_cfo(void *pDM_VOID, void *pPktinfo_VOID, s8 *pcfotail); #endif diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index af4d5ab1b382..6d7b34fd595e 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -10,51 +10,51 @@ #define READ_AND_CONFIG_MP(ic, txt) (ODM_ReadAndConfig_MP_##ic##txt(pDM_Odm)) #define READ_AND_CONFIG READ_AND_CONFIG_MP -static u8 odm_QueryRxPwrPercentage(s8 AntPower) +static u8 odm_query_rx_pwr_percentage(s8 ant_power) { - if ((AntPower <= -100) || (AntPower >= 20)) + if ((ant_power <= -100) || (ant_power >= 20)) return 0; - else if (AntPower >= 0) + else if (ant_power >= 0) return 100; else - return 100 + AntPower; + return 100 + ant_power; } -s32 odm_SignalScaleMapping(struct dm_odm_t *pDM_Odm, s32 CurrSig) +s32 odm_signal_scale_mapping(struct dm_odm_t *dm_odm, s32 curr_sig) { - s32 RetSig = 0; - - if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO) { - if (CurrSig >= 51 && CurrSig <= 100) - RetSig = 100; - else if (CurrSig >= 41 && CurrSig <= 50) - RetSig = 80 + ((CurrSig - 40)*2); - else if (CurrSig >= 31 && CurrSig <= 40) - RetSig = 66 + (CurrSig - 30); - else if (CurrSig >= 21 && CurrSig <= 30) - RetSig = 54 + (CurrSig - 20); - else if (CurrSig >= 10 && CurrSig <= 20) - RetSig = 42 + (((CurrSig - 10) * 2) / 3); - else if (CurrSig >= 5 && CurrSig <= 9) - RetSig = 22 + (((CurrSig - 5) * 3) / 2); - else if (CurrSig >= 1 && CurrSig <= 4) - RetSig = 6 + (((CurrSig - 1) * 3) / 2); + s32 ret_sig = 0; + + if (dm_odm->SupportInterface == ODM_ITRF_SDIO) { + if (curr_sig >= 51 && curr_sig <= 100) + ret_sig = 100; + else if (curr_sig >= 41 && curr_sig <= 50) + ret_sig = 80 + ((curr_sig - 40)*2); + else if (curr_sig >= 31 && curr_sig <= 40) + ret_sig = 66 + (curr_sig - 30); + else if (curr_sig >= 21 && curr_sig <= 30) + ret_sig = 54 + (curr_sig - 20); + else if (curr_sig >= 10 && curr_sig <= 20) + ret_sig = 42 + (((curr_sig - 10) * 2) / 3); + else if (curr_sig >= 5 && curr_sig <= 9) + ret_sig = 22 + (((curr_sig - 5) * 3) / 2); + else if (curr_sig >= 1 && curr_sig <= 4) + ret_sig = 6 + (((curr_sig - 1) * 3) / 2); else - RetSig = CurrSig; + ret_sig = curr_sig; } - return RetSig; + return ret_sig; } -static u8 odm_EVMdbToPercentage(s8 Value) +static u8 odm_evm_db_to_percentage(s8 value) { /* */ /* -33dB~0dB to 0%~99% */ /* */ s8 ret_val; - ret_val = Value; + ret_val = value; ret_val /= 2; if (ret_val >= 0) @@ -71,116 +71,116 @@ static u8 odm_EVMdbToPercentage(s8 Value) return ret_val; } -static void odm_RxPhyStatus92CSeries_Parsing( - struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_packet_info *pPktinfo -) +static void odm_rx_phy_status_parsing(struct dm_odm_t *dm_odm, + struct odm_phy_info *phy_info, + u8 *phy_status, + struct odm_packet_info *pkt_info) { u8 i; s8 rx_pwr[4], rx_pwr_all = 0; - u8 EVM, PWDB_ALL = 0, PWDB_ALL_BT; - u8 RSSI, total_rssi = 0; - bool isCCKrate = false; + u8 evm, pwdb_all = 0, pwdb_all_bt; + u8 rssi, total_rssi = 0; + bool is_cck_rate = false; u8 rf_rx_num = 0; - u8 LNA_idx, VGA_idx; - struct phy_status_rpt_8192cd_t *pPhyStaRpt = (struct phy_status_rpt_8192cd_t *)pPhyStatus; + u8 lna_idx, vga_idx; + struct phy_status_rpt_8192cd_t *phy_sta_rpt = (struct phy_status_rpt_8192cd_t *)phy_status; - isCCKrate = pPktinfo->data_rate <= DESC_RATE11M; - pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1; - pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1; + is_cck_rate = pkt_info->data_rate <= DESC_RATE11M; + phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1; + phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1; - if (isCCKrate) { + if (is_cck_rate) { u8 cck_agc_rpt; - pDM_Odm->PhyDbgInfo.NumQryPhyStatusCCK++; - /* */ - /* (1)Hardware does not provide RSSI for CCK */ - /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ - /* */ - - cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a; - - /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ - /* The RSSI formula should be modified according to the gain table */ - LNA_idx = ((cck_agc_rpt & 0xE0)>>5); - VGA_idx = (cck_agc_rpt & 0x1F); - rx_pwr_all = odm_CCKRSSI_8723B(LNA_idx, VGA_idx); - PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); - if (PWDB_ALL > 100) - PWDB_ALL = 100; - - pPhyInfo->rx_pwd_ba11 = PWDB_ALL; - pPhyInfo->bt_rx_rssi_percentage = PWDB_ALL; - pPhyInfo->recv_signal_power = rx_pwr_all; - /* */ + dm_odm->PhyDbgInfo.NumQryPhyStatusCCK++; + + /* + * (1)Hardware does not provide RSSI for CCK/ + * (2)PWDB, Average PWDB calculated by + * hardware (for rate adaptive) + */ + + cck_agc_rpt = phy_sta_rpt->cck_agc_rpt_ofdm_cfosho_a; + + /* + * 2011.11.28 LukeLee: 88E use different LNA & VGA gain table + * The RSSI formula should be modified according to the gain table + */ + lna_idx = ((cck_agc_rpt & 0xE0)>>5); + vga_idx = (cck_agc_rpt & 0x1F); + rx_pwr_all = odm_cck_rssi(lna_idx, vga_idx); + pwdb_all = odm_query_rx_pwr_percentage(rx_pwr_all); + if (pwdb_all > 100) + pwdb_all = 100; + + phy_info->rx_pwd_ba11 = pwdb_all; + phy_info->bt_rx_rssi_percentage = pwdb_all; + phy_info->recv_signal_power = rx_pwr_all; + /* (3) Get Signal Quality (EVM) */ - /* */ + /* if (pPktinfo->bPacketMatchBSSID) */ { - u8 SQ, SQ_rpt; + u8 sq, sq_rpt; - if (pPhyInfo->rx_pwd_ba11 > 40 && !pDM_Odm->bInHctTest) - SQ = 100; + if (phy_info->rx_pwd_ba11 > 40 && !dm_odm->bInHctTest) + sq = 100; else { - SQ_rpt = pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all; + sq_rpt = phy_sta_rpt->cck_sig_qual_ofdm_pwdb_all; - if (SQ_rpt > 64) - SQ = 0; - else if (SQ_rpt < 20) - SQ = 100; + if (sq_rpt > 64) + sq = 0; + else if (sq_rpt < 20) + sq = 100; else - SQ = ((64-SQ_rpt) * 100) / 44; + sq = ((64-sq_rpt) * 100) / 44; } - pPhyInfo->signal_quality = SQ; - pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = SQ; - pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1; + phy_info->signal_quality = sq; + phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = sq; + phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1; } } else { /* is OFDM rate */ - pDM_Odm->PhyDbgInfo.NumQryPhyStatusOFDM++; + dm_odm->PhyDbgInfo.NumQryPhyStatusOFDM++; - /* */ - /* (1)Get RSSI for HT rate */ - /* */ + /* + * (1)Get RSSI for HT rate + */ for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) { /* 2008/01/30 MH we will judge RF RX path now. */ - if (pDM_Odm->RFPathRxEnable & BIT(i)) + if (dm_odm->RFPathRxEnable & BIT(i)) rf_rx_num++; /* else */ /* continue; */ - rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain&0x3F)*2) - 110; - + rx_pwr[i] = ((phy_sta_rpt->path_agc[i].gain & 0x3F) * 2) - 110; - pPhyInfo->rx_pwr[i] = rx_pwr[i]; + phy_info->rx_pwr[i] = rx_pwr[i]; /* Translate DBM to percentage. */ - RSSI = odm_QueryRxPwrPercentage(rx_pwr[i]); - total_rssi += RSSI; + rssi = odm_query_rx_pwr_percentage(rx_pwr[i]); + total_rssi += rssi; - pPhyInfo->rx_mimo_signal_strength[i] = (u8) RSSI; + phy_info->rx_mimo_signal_strength[i] = (u8)rssi; /* Get Rx snr value in DB */ - pPhyInfo->rx_snr[i] = pDM_Odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + phy_info->rx_snr[i] = dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(phy_sta_rpt->path_rxsnr[i]/2); } + /* + * (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) + */ + rx_pwr_all = ((phy_sta_rpt->cck_sig_qual_ofdm_pwdb_all >> 1) & 0x7f) - 110; - /* */ - /* (2)PWDB, Average PWDB calculated by hardware (for rate adaptive) */ - /* */ - rx_pwr_all = (((pPhyStaRpt->cck_sig_qual_ofdm_pwdb_all) >> 1)&0x7f)-110; - - PWDB_ALL_BT = PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); + pwdb_all_bt = pwdb_all = odm_query_rx_pwr_percentage(rx_pwr_all); - pPhyInfo->rx_pwd_ba11 = PWDB_ALL; - pPhyInfo->bt_rx_rssi_percentage = PWDB_ALL_BT; - pPhyInfo->rx_power = rx_pwr_all; - pPhyInfo->recv_signal_power = rx_pwr_all; + phy_info->rx_pwd_ba11 = pwdb_all; + phy_info->bt_rx_rssi_percentage = pwdb_all_bt; + phy_info->rx_power = rx_pwr_all; + phy_info->recv_signal_power = rx_pwr_all; /* * (3)EVM of HT rate @@ -195,23 +195,26 @@ static void odm_RxPhyStatus92CSeries_Parsing( * is supposed to be negative) is not correct * anymore. */ - EVM = odm_EVMdbToPercentage(pPhyStaRpt->stream_rxevm[0]); /* dbm */ + evm = odm_evm_db_to_percentage(phy_sta_rpt->stream_rxevm[0]); /* dbm */ /* Fill value in RFD, Get the first spatial stream only */ - pPhyInfo->signal_quality = (u8)(EVM & 0xff); + phy_info->signal_quality = (u8)(evm & 0xff); - pPhyInfo->rx_mimo_signal_quality[ODM_RF_PATH_A] = (u8)(EVM & 0xff); + phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = (u8)(evm & 0xff); - ODM_ParsingCFO(pDM_Odm, pPktinfo, pPhyStaRpt->path_cfotail); + odm_parsing_cfo(dm_odm, pkt_info, phy_sta_rpt->path_cfotail); } - /* UI BSS List signal strength(in percentage), make it good looking, from 0~100. */ - /* It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). */ - if (isCCKrate) { - pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, PWDB_ALL));/* PWDB_ALL; */ + /* + * UI BSS List signal strength(in percentage), make it good + * looking, from 0~100. + * It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). + */ + if (is_cck_rate) { + phy_info->signal_strength = (u8)(odm_signal_scale_mapping(dm_odm, pwdb_all)); } else { if (rf_rx_num != 0) { - pPhyInfo->signal_strength = (u8)(odm_SignalScaleMapping(pDM_Odm, total_rssi /= rf_rx_num)); + phy_info->signal_strength = (u8)(odm_signal_scale_mapping(dm_odm, total_rssi /= rf_rx_num)); } } } @@ -364,17 +367,17 @@ static void odm_Process_RSSIForDM( /* Endianness before calling this API */ /* */ static void ODM_PhyStatusQuery_92CSeries( - struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_packet_info *pPktinfo + struct dm_odm_t *dm_odm, + struct odm_phy_info *phy_info, + u8 *phy_status, + struct odm_packet_info *pkt_info ) { - odm_RxPhyStatus92CSeries_Parsing(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); + odm_rx_phy_status_parsing(dm_odm, phy_info, phy_status, pkt_info); - if (!pDM_Odm->RSSI_test) - odm_Process_RSSIForDM(pDM_Odm, pPhyInfo, pPktinfo); + if (!dm_odm->RSSI_test) + odm_Process_RSSIForDM(dm_odm, phy_info, pkt_info); } void ODM_PhyStatusQuery( diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h index 574f9cfe8190..c0dbf5cc8ed4 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h @@ -102,6 +102,6 @@ enum hal_status ODM_ConfigFWWithHeaderFile( u32 *pSize ); -s32 odm_SignalScaleMapping(struct dm_odm_t *pDM_Odm, s32 CurrSig); +s32 odm_signal_scale_mapping(struct dm_odm_t *pDM_Odm, s32 CurrSig); #endif diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c index 54518ea1be6b..325f2a7ae337 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c +++ b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c @@ -7,25 +7,25 @@ #include "odm_precomp.h" -s8 odm_CCKRSSI_8723B(u8 LNA_idx, u8 VGA_idx) +s8 odm_cck_rssi(u8 lna_idx, u8 vga_idx) { s8 rx_pwr_all = 0x00; - switch (LNA_idx) { + switch (lna_idx) { /* 46 53 73 95 201301231630 */ /* 46 53 77 99 201301241630 */ case 6: - rx_pwr_all = -34 - (2 * VGA_idx); + rx_pwr_all = -34 - (2 * vga_idx); break; case 4: - rx_pwr_all = -14 - (2 * VGA_idx); + rx_pwr_all = -14 - (2 * vga_idx); break; case 1: - rx_pwr_all = 6 - (2 * VGA_idx); + rx_pwr_all = 6 - (2 * vga_idx); break; case 0: - rx_pwr_all = 16 - (2 * VGA_idx); + rx_pwr_all = 16 - (2 * vga_idx); break; default: /* rx_pwr_all = -53+(2*(31-VGA_idx)); */ diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h index 96ef1cc41a96..752f180ebd46 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h +++ b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h @@ -9,6 +9,6 @@ #define DM_DIG_MIN_NIC_8723 0x1C -s8 odm_CCKRSSI_8723B(u8 LNA_idx, u8 VGA_idx); +s8 odm_cck_rssi(u8 LNA_idx, u8 VGA_idx); #endif -- cgit v1.2.3 From 4db87ba2b69c695831ce833b3f1f5d5991fb7e7f Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:56 +0200 Subject: staging: rtl8723bs: move function to file hal/odm_HWConfig.c move function odm_cck_rssi() to hal/odm_HWConfig.c. As it is used only in this file turn it to static. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/c2bb14c3d32d3a654df95288751f0bc8cd6566b0.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 27 +++++++++++++++++++++++++++ drivers/staging/rtl8723bs/hal/odm_RTL8723B.c | 28 ---------------------------- drivers/staging/rtl8723bs/hal/odm_RTL8723B.h | 2 -- 3 files changed, 27 insertions(+), 30 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 6d7b34fd595e..2d4d8d57ceeb 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -71,6 +71,33 @@ static u8 odm_evm_db_to_percentage(s8 value) return ret_val; } +static s8 odm_cck_rssi(u8 lna_idx, u8 vga_idx) +{ + s8 rx_pwr_all = 0x00; + + switch (lna_idx) { + /* 46 53 73 95 201301231630 */ + /* 46 53 77 99 201301241630 */ + + case 6: + rx_pwr_all = -34 - (2 * vga_idx); + break; + case 4: + rx_pwr_all = -14 - (2 * vga_idx); + break; + case 1: + rx_pwr_all = 6 - (2 * vga_idx); + break; + case 0: + rx_pwr_all = 16 - (2 * vga_idx); + break; + default: + /* rx_pwr_all = -53+(2*(31-VGA_idx)); */ + break; + } + return rx_pwr_all; +} + static void odm_rx_phy_status_parsing(struct dm_odm_t *dm_odm, struct odm_phy_info *phy_info, u8 *phy_status, diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c index 325f2a7ae337..66bda505c01e 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c +++ b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c @@ -6,31 +6,3 @@ ******************************************************************************/ #include "odm_precomp.h" - -s8 odm_cck_rssi(u8 lna_idx, u8 vga_idx) -{ - s8 rx_pwr_all = 0x00; - - switch (lna_idx) { - /* 46 53 73 95 201301231630 */ - /* 46 53 77 99 201301241630 */ - - case 6: - rx_pwr_all = -34 - (2 * vga_idx); - break; - case 4: - rx_pwr_all = -14 - (2 * vga_idx); - break; - case 1: - rx_pwr_all = 6 - (2 * vga_idx); - break; - case 0: - rx_pwr_all = 16 - (2 * vga_idx); - break; - default: - /* rx_pwr_all = -53+(2*(31-VGA_idx)); */ - break; - - } - return rx_pwr_all; -} diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h index 752f180ebd46..12b3ca90a43d 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h +++ b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h @@ -9,6 +9,4 @@ #define DM_DIG_MIN_NIC_8723 0x1C -s8 odm_cck_rssi(u8 LNA_idx, u8 VGA_idx); - #endif -- cgit v1.2.3 From 56f0c0df5e7216100990d8a3896e6cb52e0effe6 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:57 +0200 Subject: staging: rtl8723bs: remove empty files remove empty files after function move, hal/odm_RTL8723B.h has only an unused macro declaration. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/92cba6beb56150635ab4c7985d733c93fba7fe83.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/Makefile | 1 - drivers/staging/rtl8723bs/hal/odm_RTL8723B.c | 8 -------- drivers/staging/rtl8723bs/hal/odm_RTL8723B.h | 12 ------------ drivers/staging/rtl8723bs/hal/odm_precomp.h | 1 - 4 files changed, 22 deletions(-) delete mode 100644 drivers/staging/rtl8723bs/hal/odm_RTL8723B.c delete mode 100644 drivers/staging/rtl8723bs/hal/odm_RTL8723B.h (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/Makefile b/drivers/staging/rtl8723bs/Makefile index fe45200ff53c..159ca1b9016b 100644 --- a/drivers/staging/rtl8723bs/Makefile +++ b/drivers/staging/rtl8723bs/Makefile @@ -35,7 +35,6 @@ r8723bs-y = \ hal/odm_HWConfig.o \ hal/odm_NoiseMonitor.o \ hal/odm_RegConfig8723B.o \ - hal/odm_RTL8723B.o \ hal/rtl8723b_cmd.o \ hal/rtl8723b_dm.o \ hal/rtl8723b_hal_init.o \ diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c deleted file mode 100644 index 66bda505c01e..000000000000 --- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.c +++ /dev/null @@ -1,8 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ - -#include "odm_precomp.h" diff --git a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h b/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h deleted file mode 100644 index 12b3ca90a43d..000000000000 --- a/drivers/staging/rtl8723bs/hal/odm_RTL8723B.h +++ /dev/null @@ -1,12 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -#ifndef __ODM_RTL8723B_H__ -#define __ODM_RTL8723B_H__ - -#define DM_DIG_MIN_NIC_8723 0x1C - -#endif diff --git a/drivers/staging/rtl8723bs/hal/odm_precomp.h b/drivers/staging/rtl8723bs/hal/odm_precomp.h index 5041c9535e9a..edce506022a5 100644 --- a/drivers/staging/rtl8723bs/hal/odm_precomp.h +++ b/drivers/staging/rtl8723bs/hal/odm_precomp.h @@ -43,7 +43,6 @@ #include "HalHWImg8723B_RF.h" #include "HalHWImg8723B_BB.h" #include "Hal8723BReg.h" -#include "odm_RTL8723B.h" #include "odm_RegConfig8723B.h" #endif /* __ODM_PRECOMP_H__ */ -- cgit v1.2.3 From c328eee4ff9d2dc6056b6068b787dc72f7a83934 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:58 +0200 Subject: staging: rtl8723bs: remove wrapping static function remove unneeded wrapping static function in hal/odm_HWConif.c Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/786fc4d72db2a4b5e22c95e0e1437cfb734e1218.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 2d4d8d57ceeb..5e6186040484 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -393,7 +393,7 @@ static void odm_Process_RSSIForDM( /* */ /* Endianness before calling this API */ /* */ -static void ODM_PhyStatusQuery_92CSeries( +void ODM_PhyStatusQuery( struct dm_odm_t *dm_odm, struct odm_phy_info *phy_info, u8 *phy_status, @@ -407,17 +407,6 @@ static void ODM_PhyStatusQuery_92CSeries( odm_Process_RSSIForDM(dm_odm, phy_info, pkt_info); } -void ODM_PhyStatusQuery( - struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_packet_info *pPktinfo -) -{ - - ODM_PhyStatusQuery_92CSeries(pDM_Odm, pPhyInfo, pPhyStatus, pPktinfo); -} - /* */ /* If you want to add a new IC, Please follow below template and generate a new one. */ /* */ -- cgit v1.2.3 From 3bd25c9557a8a16e777eb8513b013125785d7d88 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:47:59 +0200 Subject: staging: rtl8723bs: beautify function ODM_PhyStatusQuery() beautify function ODM_PhyStatusQuery(). Fix camel case name, put more than one argument per line, fix camel case in arugment names. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/5e17b5ece9dbeb526f7a9aff147bf8767d39395c.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 8 ++------ drivers/staging/rtl8723bs/hal/odm_HWConfig.h | 8 ++------ drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c | 2 +- 3 files changed, 5 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 5e6186040484..16d479dbd069 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -393,12 +393,8 @@ static void odm_Process_RSSIForDM( /* */ /* Endianness before calling this API */ /* */ -void ODM_PhyStatusQuery( - struct dm_odm_t *dm_odm, - struct odm_phy_info *phy_info, - u8 *phy_status, - struct odm_packet_info *pkt_info -) +void odm_phy_status_query(struct dm_odm_t *dm_odm, struct odm_phy_info *phy_info, + u8 *phy_status, struct odm_packet_info *pkt_info) { odm_rx_phy_status_parsing(dm_odm, phy_info, phy_status, pkt_info); diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h index c0dbf5cc8ed4..b2eae7d993fa 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h @@ -76,12 +76,8 @@ struct phy_status_rpt_8192cd_t { #endif }; -void ODM_PhyStatusQuery( - struct dm_odm_t *pDM_Odm, - struct odm_phy_info *pPhyInfo, - u8 *pPhyStatus, - struct odm_packet_info *pPktinfo -); +void odm_phy_status_query(struct dm_odm_t *dm_odm, struct odm_phy_info *phy_info, + u8 *phy_status, struct odm_packet_info *pkt_info); enum hal_status ODM_ConfigRFWithTxPwrTrackHeaderFile(struct dm_odm_t *pDM_Odm); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c index 6dc5cd959b75..418016930728 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723bs_recv.c @@ -129,7 +129,7 @@ static void update_recvframe_phyinfo(union recv_frame *precvframe, /* rtl8723b_query_rx_phy_status(precvframe, pphy_status); */ /* spin_lock_bh(&p_hal_data->odm_stainfo_lock); */ - ODM_PhyStatusQuery(&p_hal_data->odmpriv, p_phy_info, + odm_phy_status_query(&p_hal_data->odmpriv, p_phy_info, (u8 *)pphy_status, &(pkt_info)); if (psta) psta->rssi = pattrib->phy_info.RecvSignalPower; -- cgit v1.2.3 From e3678dc1ea40425b7218c20e2fe7b00a72f23a41 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:00 +0200 Subject: staging: rtl8723bs: fix right side of condition TxNum value is compared against ODM_RF_PATH_D, which is inconsistent. Compare it against RF_MAX_TX_NUM, as in other places in the same file. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/147631fe6f4f5de84cc54a62ba71d739b92697be.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 03c174aab08d..a47a0a1cae22 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -350,7 +350,7 @@ static void PHY_StoreTxPowerByRateNew( if (RfPath > ODM_RF_PATH_D) return; - if (TxNum > ODM_RF_PATH_D) + if (TxNum > RF_MAX_TX_NUM) return; for (i = 0; i < rateNum; ++i) { -- cgit v1.2.3 From 61b919fe3df685a3fa310c44d5ce608f08d679b5 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:01 +0200 Subject: staging: rtl8723bs: clean driver from unused RF paths rtl8723bs support only two rf paths (A and B), remove all the others (C, D, BC, ...) as they are unused. Keep just one enum selecting rf path, remove unused macro indicating max rf path number, add an item in rf_path enum for this pourpose. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/23060c85ab9aa468c9c021378f0dc8a8f887a578.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalPhyRf.c | 52 +++---- drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c | 164 ++++++++++----------- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 22 +-- drivers/staging/rtl8723bs/hal/odm.c | 4 +- drivers/staging/rtl8723bs/hal/odm.h | 20 --- drivers/staging/rtl8723bs/hal/odm_CfoTracking.c | 2 +- drivers/staging/rtl8723bs/hal/odm_HWConfig.c | 36 ++--- drivers/staging/rtl8723bs/hal/odm_HWConfig.h | 2 +- drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c | 18 +-- drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c | 4 +- drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h | 2 +- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 12 +- drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c | 42 +++--- drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c | 16 +- drivers/staging/rtl8723bs/include/hal_phy.h | 3 +- 15 files changed, 185 insertions(+), 214 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf.c b/drivers/staging/rtl8723bs/hal/HalPhyRf.c index 9c6d3bf2f2ea..7bef05a9a063 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf.c @@ -30,7 +30,7 @@ void ODM_ClearTxPowerTrackingState(struct dm_odm_t *pDM_Odm) pDM_Odm->BbSwingIdxCck = pDM_Odm->DefaultCckIndex; pDM_Odm->RFCalibrateInfo.CCK_index = 0; - for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) { + for (p = RF_PATH_A; p < MAX_RF_PATH; ++p) { pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex; pDM_Odm->BbSwingIdxOfdm[p] = pDM_Odm->DefaultOfdmIndex; pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex; @@ -93,7 +93,7 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter) pDM_Odm->RFCalibrateInfo.TXPowerTrackingCallbackCnt++; pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = true; - ThermalValue = (u8)PHY_QueryRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, c.ThermalRegAddr, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ + ThermalValue = (u8)PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH_A, c.ThermalRegAddr, 0xfc00); /* 0x42: RF Reg[15:10] 88E */ if ( !pDM_Odm->RFCalibrateInfo.TxPowerTrackControl || pHalData->EEPROMThermalMeter == 0 || @@ -154,49 +154,49 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter) /* 4 7.1 The Final Power Index = BaseIndex + PowerIndexOffset */ if (ThermalValue > pHalData->EEPROMThermalMeter) { - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_A] = - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A]; - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_A] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A]; + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A] = deltaSwingTableIdx_TUP_A[delta]; /* Record delta swing for mix mode power tracking */ - pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = + pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_A] = deltaSwingTableIdx_TUP_A[delta]; if (c.RfPathCount > 1) { - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_B] = - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B]; - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_B] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B]; + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B] = deltaSwingTableIdx_TUP_B[delta]; /* Record delta swing for mix mode power tracking */ - pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = + pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_B] = deltaSwingTableIdx_TUP_B[delta]; } } else { - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_A] = - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A]; - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_A] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_A] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A]; + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_A] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; /* Record delta swing for mix mode power tracking */ - pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_A] = + pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_A] = -1 * deltaSwingTableIdx_TDOWN_A[delta]; if (c.RfPathCount > 1) { - pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[ODM_RF_PATH_B] = - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B]; - pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[ODM_RF_PATH_B] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[RF_PATH_B] = + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B]; + pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[RF_PATH_B] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; /* Record delta swing for mix mode power tracking */ - pDM_Odm->Absolute_OFDMSwingIdx[ODM_RF_PATH_B] = + pDM_Odm->Absolute_OFDMSwingIdx[RF_PATH_B] = -1 * deltaSwingTableIdx_TDOWN_B[delta]; } } - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) { + for (p = RF_PATH_A; p < c.RfPathCount; p++) { if ( pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] == pDM_Odm->RFCalibrateInfo.DeltaPowerIndexLast[p] @@ -230,17 +230,17 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter) /* else if (pDM_Odm->RFCalibrateInfo.CCK_index < 0) */ /* pDM_Odm->RFCalibrateInfo.CCK_index = 0; */ } else { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) + for (p = RF_PATH_A; p < c.RfPathCount; p++) pDM_Odm->RFCalibrateInfo.PowerIndexOffset[p] = 0; } /* Print Swing base & current */ - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) { + for (p = RF_PATH_A; p < c.RfPathCount; p++) { } if ( - (pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_A] != 0 || - pDM_Odm->RFCalibrateInfo.PowerIndexOffset[ODM_RF_PATH_B] != 0) && + (pDM_Odm->RFCalibrateInfo.PowerIndexOffset[RF_PATH_A] != 0 || + pDM_Odm->RFCalibrateInfo.PowerIndexOffset[RF_PATH_B] != 0) && pDM_Odm->RFCalibrateInfo.TxPowerTrackControl ) { /* 4 7.2 Configure the Swing Table to adjust Tx Power. */ @@ -253,16 +253,16 @@ void ODM_TXPowerTrackingCallback_ThermalMeter(struct adapter *Adapter) /* 2012/04/25 MH Add for tx power tracking to set tx power in tx agc for 88E. */ if (ThermalValue > pHalData->EEPROMThermalMeter) { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) + for (p = RF_PATH_A; p < c.RfPathCount; p++) (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, 0); } else { - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) + for (p = RF_PATH_A; p < c.RfPathCount; p++) (*c.ODM_TxPwrTrackSetPwr)(pDM_Odm, MIX_MODE, p, Indexforchannel); } /* Record last time Power Tracking result as base. */ pDM_Odm->BbSwingIdxCckBase = pDM_Odm->BbSwingIdxCck; - for (p = ODM_RF_PATH_A; p < c.RfPathCount; p++) + for (p = RF_PATH_A; p < c.RfPathCount; p++) pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->BbSwingIdxOfdm[p]; /* Record last Power Tracking Thermal Value */ diff --git a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c index c696569ae5cf..a52748f7b56e 100644 --- a/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c +++ b/drivers/staging/rtl8723bs/hal/HalPhyRf_8723B.c @@ -67,9 +67,9 @@ static void setIqkMatrix_8723B( IqkResult_Y = IqkResult_Y | 0xFFFFFC00; ele_C = ((IqkResult_Y * ele_D)>>8)&0x000003FF; - /* if (RFPath == ODM_RF_PATH_A) */ + /* if (RFPath == RF_PATH_A) */ switch (RFPath) { - case ODM_RF_PATH_A: + case RF_PATH_A: /* write new elements A, C, D to regC80 and regC94, * element B is always 0 */ @@ -82,7 +82,7 @@ static void setIqkMatrix_8723B( value32 = ((IqkResult_X * ele_D)>>7)&0x01; PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT24, value32); break; - case ODM_RF_PATH_B: + case RF_PATH_B: /* write new elements A, C, D to regC88 and regC9C, * element B is always 0 */ @@ -101,13 +101,13 @@ static void setIqkMatrix_8723B( } } else { switch (RFPath) { - case ODM_RF_PATH_A: + case RF_PATH_A: PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XATxIQImbalance, bMaskDWord, OFDMSwingTable_New[OFDM_index]); PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XCTxAFE, bMaskH4Bits, 0x00); PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT24, 0x00); break; - case ODM_RF_PATH_B: + case RF_PATH_B: PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable_New[OFDM_index]); PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); PHY_SetBBReg(pDM_Odm->Adapter, rOFDM0_ECCAThreshold, BIT28, 0x00); @@ -380,13 +380,13 @@ static u8 phy_PathA_IQK_8723B( PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); /* enable path A PA in TXIQK mode */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0003f); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xc7f87); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0003f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xc7f87); /* disable path B PA in TXIQK mode */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xed, bRFRegOffsetMask, 0x00020); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x43, bRFRegOffsetMask, 0x40ec1); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xed, bRFRegOffsetMask, 0x00020); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x43, bRFRegOffsetMask, 0x40ec1); */ /* 1 Tx IQK */ /* IQK setting */ @@ -480,12 +480,12 @@ static u8 phy_PathA_RxIQK8723B( PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); /* 1 Get TXIMR setting */ /* modify RXIQK mode table */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); /* LNA2 off, PA on for Dcut */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7fb7); -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x0); */ + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7fb7); +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x0); */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x808000); /* IQK setting */ @@ -564,16 +564,16 @@ static u8 phy_PathA_RxIQK8723B( /* modify RXIQK mode table */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); /* LAN2 on, PA off for Dcut */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7d77); -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x0); */ + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7d77); +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x0); */ /* PA, PAD setting */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xdf, bRFRegOffsetMask, 0xf80); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x55, bRFRegOffsetMask, 0x4021f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0xf80); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x55, bRFRegOffsetMask, 0x4021f); /* IQK setting */ @@ -631,7 +631,7 @@ static u8 phy_PathA_RxIQK8723B( /* PA/PAD controlled by 0x0 */ /* leave IQK mode */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x780); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x780); /* Allen 20131125 */ tmp = (regEAC & 0x03FF0000)>>16; @@ -666,13 +666,13 @@ static u8 phy_PathB_IQK_8723B(struct adapter *padapter) PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); /* in TXIQK mode */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x20000); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0003f); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xc7f87); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x20000); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0003f); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xc7f87); */ /* enable path B PA in TXIQK mode */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xed, 0x20, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x43, bRFRegOffsetMask, 0x30fc1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xed, 0x20, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x43, bRFRegOffsetMask, 0x30fc1); @@ -700,7 +700,7 @@ static u8 phy_PathB_IQK_8723B(struct adapter *padapter) /* switch to path B */ PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000280); -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, bRFRegOffsetMask, 0xeffe0); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, bRFRegOffsetMask, 0xeffe0); */ /* GNT_BT = 0 */ PHY_SetBBReg(pDM_Odm->Adapter, 0x764, bMaskDWord, 0x00000800); @@ -760,13 +760,13 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB) /* switch to path B */ PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000280); /* modify RXIQK mode table */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7fb7); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7fb7); /* open PA S1 & SMIXER */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xed, 0x20, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x43, bRFRegOffsetMask, 0x30fcd); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xed, 0x20, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x43, bRFRegOffsetMask, 0x30fcd); /* IQK setting */ @@ -794,7 +794,7 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB) /* switch to path B */ PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000280); -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, bRFRegOffsetMask, 0xeffe0); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, bRFRegOffsetMask, 0xeffe0); */ /* GNT_BT = 0 */ PHY_SetBBReg(pDM_Odm->Adapter, 0x764, bMaskDWord, 0x00000800); @@ -844,19 +844,19 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB) /* modify RXIQK mode table */ /* 20121009, Kordan> RF Mode = 3 */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7d77); -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x0); */ + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7d77); +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x0); */ /* open PA S1 & close SMIXER */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xed, 0x20, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x43, bRFRegOffsetMask, 0x30ebd); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xed, 0x20, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x43, bRFRegOffsetMask, 0x30ebd); /* PA, PAD setting */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xdf, bRFRegOffsetMask, 0xf80); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0xf80); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x56, bRFRegOffsetMask, 0x51000); */ /* IQK setting */ PHY_SetBBReg(pDM_Odm->Adapter, rRx_IQK, bMaskDWord, 0x01004800); @@ -881,7 +881,7 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB) /* switch to path B */ PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, 0x00000280); -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, bRFRegOffsetMask, 0xeffe0); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, bRFRegOffsetMask, 0xeffe0); */ /* GNT_BT = 0 */ PHY_SetBBReg(pDM_Odm->Adapter, 0x764, bMaskDWord, 0x00000800); @@ -909,7 +909,7 @@ static u8 phy_PathB_RxIQK8723B(struct adapter *padapter, bool configPathB) /* PA/PAD controlled by 0x0 */ /* leave IQK mode */ /* PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, 0xffffff00, 0x00000000); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_B, 0xdf, bRFRegOffsetMask, 0x180); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_B, 0xdf, bRFRegOffsetMask, 0x180); */ @@ -1384,7 +1384,7 @@ static void phy_IQCalibrate_8723B( /* save RF path for 8723B */ /* Path_SEL_BB = PHY_QueryBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord); */ -/* Path_SEL_RF = PHY_QueryRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, 0xfffff); */ +/* Path_SEL_RF = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, 0xfffff); */ /* MAC settings */ _PHY_MACSettingCalibration8723B(padapter, IQK_MAC_REG, pDM_Odm->RFCalibrateInfo.IQK_MAC_backup); @@ -1406,12 +1406,12 @@ static void phy_IQCalibrate_8723B( /* RX IQ calibration setting for 8723B D cut large current issue when leaving IPS */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7fb7); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xed, 0x20, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x43, bRFRegOffsetMask, 0x60fbd); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x30000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xf7fb7); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xed, 0x20, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x43, bRFRegOffsetMask, 0x60fbd); /* path A TX IQK */ for (i = 0 ; i < retryCount ; i++) { @@ -1420,7 +1420,7 @@ static void phy_IQCalibrate_8723B( if (PathAOK == 0x01) { /* Path A Tx IQK Success */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); - pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_A] = PHY_QueryRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x8, bRFRegOffsetMask); + pDM_Odm->RFCalibrateInfo.TxLOK[RF_PATH_A] = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x8, bRFRegOffsetMask); result[t][0] = (PHY_QueryBBReg(pDM_Odm->Adapter, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; result[t][1] = (PHY_QueryBBReg(pDM_Odm->Adapter, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; @@ -1452,7 +1452,7 @@ static void phy_IQCalibrate_8723B( if (PathBOK == 0x01) { /* Path B Tx IQK Success */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_IQK, bMaskH3Bytes, 0x000000); - pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_B] = PHY_QueryRFReg(pDM_Odm->Adapter, ODM_RF_PATH_B, 0x8, bRFRegOffsetMask); + pDM_Odm->RFCalibrateInfo.TxLOK[RF_PATH_B] = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH_B, 0x8, bRFRegOffsetMask); result[t][4] = (PHY_QueryBBReg(pDM_Odm->Adapter, rTx_Power_Before_IQK_A, bMaskDWord)&0x3FF0000)>>16; result[t][5] = (PHY_QueryBBReg(pDM_Odm->Adapter, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; @@ -1489,7 +1489,7 @@ static void phy_IQCalibrate_8723B( /* Reload RF path */ /* PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, Path_SEL_BB); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, 0xfffff, Path_SEL_RF); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, 0xfffff, Path_SEL_RF); */ /* Allen initial gain 0xc50 */ /* Restore RX initial gain */ @@ -1526,46 +1526,46 @@ static void phy_LCCalibrate_8723B(struct dm_odm_t *pDM_Odm, bool is2T) if ((tmpReg&0x70) != 0) { /* 1. Read original RF mode */ /* Path-A */ - RF_Amode = PHY_QueryRFReg(padapter, ODM_RF_PATH_A, RF_AC, bMask12Bits); + RF_Amode = PHY_QueryRFReg(padapter, RF_PATH_A, RF_AC, bMask12Bits); /* Path-B */ if (is2T) - RF_Bmode = PHY_QueryRFReg(padapter, ODM_RF_PATH_B, RF_AC, bMask12Bits); + RF_Bmode = PHY_QueryRFReg(padapter, RF_PATH_B, RF_AC, bMask12Bits); /* 2. Set RF mode = standby mode */ /* Path-A */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); /* Path-B */ if (is2T) - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); } /* 3. Read RF reg18 */ - LC_Cal = PHY_QueryRFReg(padapter, ODM_RF_PATH_A, RF_CHNLBW, bMask12Bits); + LC_Cal = PHY_QueryRFReg(padapter, RF_PATH_A, RF_CHNLBW, bMask12Bits); /* 4. Set LC calibration begin bit15 */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFBE0); /* LDO ON */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFBE0); /* LDO ON */ + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); mdelay(100); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFFE0); /* LDO OFF */ + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xB0, bRFRegOffsetMask, 0xDFFE0); /* LDO OFF */ /* Channel 10 LC calibration issue for 8723bs with 26M xtal */ if (pDM_Odm->SupportInterface == ODM_ITRF_SDIO && pDM_Odm->PackageType >= 0x2) { - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal); } /* Restore original situation */ if ((tmpReg&0x70) != 0) { /* Deal with contisuous TX case */ /* Path-A */ rtw_write8(pDM_Odm->Adapter, 0xd03, tmpReg); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_AC, bMask12Bits, RF_Amode); /* Path-B */ if (is2T) - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_B, RF_AC, bMask12Bits, RF_Bmode); } else /* Deal with Packet TX case */ rtw_write8(pDM_Odm->Adapter, REG_TXPAUSE, 0x00); } @@ -1625,7 +1625,7 @@ void PHY_IQCalibrate_8723B( u8 path, bResult = SUCCESS; struct odm_rf_cal_t *pRFCalibrateInfo = &pDM_Odm->RFCalibrateInfo; - path = (PHY_QueryBBReg(pDM_Odm->Adapter, rS0S1_PathSwitch, bMaskByte0) == 0x00) ? ODM_RF_PATH_A : ODM_RF_PATH_B; + path = (PHY_QueryBBReg(pDM_Odm->Adapter, rS0S1_PathSwitch, bMaskByte0) == 0x00) ? RF_PATH_A : RF_PATH_B; /* Restore TX IQK */ for (i = 0; i < 3; ++i) { @@ -1649,11 +1649,11 @@ void PHY_IQCalibrate_8723B( PHY_SetBBReg(pDM_Odm->Adapter, offset, bMaskDWord, data); } - if (pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_A] == 0) { + if (pDM_Odm->RFCalibrateInfo.TxLOK[RF_PATH_A] == 0) { bResult = FAIL; } else { - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXM_IDAC, bRFRegOffsetMask, pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_A]); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_B, RF_TXM_IDAC, bRFRegOffsetMask, pDM_Odm->RFCalibrateInfo.TxLOK[ODM_RF_PATH_B]); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXM_IDAC, bRFRegOffsetMask, pDM_Odm->RFCalibrateInfo.TxLOK[RF_PATH_A]); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_B, RF_TXM_IDAC, bRFRegOffsetMask, pDM_Odm->RFCalibrateInfo.TxLOK[RF_PATH_B]); } if (bResult == SUCCESS) @@ -1669,7 +1669,7 @@ void PHY_IQCalibrate_8723B( GNT_BT_default = PHY_QueryBBReg(pDM_Odm->Adapter, 0x764, bMaskDWord); /* Save RF Path */ /* Path_SEL_BB = PHY_QueryBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord); */ -/* Path_SEL_RF = PHY_QueryRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, 0xfffff); */ +/* Path_SEL_RF = PHY_QueryRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, 0xfffff); */ /* set GNT_BT = 0, pause BT traffic */ /* PHY_SetBBReg(pDM_Odm->Adapter, 0x764, BIT12, 0x0); */ @@ -1770,15 +1770,15 @@ void PHY_IQCalibrate_8723B( PHY_SetBBReg(pDM_Odm->Adapter, 0x764, bMaskDWord, GNT_BT_default); /* Restore RF Path */ /* PHY_SetBBReg(pDM_Odm->Adapter, 0x948, bMaskDWord, Path_SEL_BB); */ -/* PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xb0, 0xfffff, Path_SEL_RF); */ +/* PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xb0, 0xfffff, Path_SEL_RF); */ /* Resotr RX mode table parameter */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xe6177); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0xed, 0x20, 0x1); - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, 0x43, bRFRegOffsetMask, 0x300bd); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_WE_LUT, 0x80000, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_RCK_OS, bRFRegOffsetMask, 0x18000); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G1, bRFRegOffsetMask, 0x0001f); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_TXPA_G2, bRFRegOffsetMask, 0xe6177); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0xed, 0x20, 0x1); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, 0x43, bRFRegOffsetMask, 0x300bd); /* set GNT_BT = HW control */ /* PHY_SetBBReg(pDM_Odm->Adapter, 0x764, BIT12, 0x0); */ diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index a47a0a1cae22..3e426c975828 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -16,7 +16,7 @@ u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); u8 value = 0; - if (RfPath > ODM_RF_PATH_D) + if (RfPath >= RF_PATH_MAX) return 0; switch (RateSection) { @@ -47,7 +47,7 @@ phy_SetTxPowerByRateBase( { struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); - if (RfPath > ODM_RF_PATH_D) + if (RfPath >= RF_PATH_MAX) return; switch (RateSection) { @@ -72,7 +72,7 @@ struct adapter *padapter { u8 path, base; - for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_B; ++path) { + for (path = RF_PATH_A; path <= RF_PATH_B; ++path) { base = PHY_GetTxPowerByRate(padapter, path, RF_1TX, MGN_11M); phy_SetTxPowerByRateBase(padapter, path, CCK, RF_1TX, base); @@ -347,7 +347,7 @@ static void PHY_StoreTxPowerByRateNew( PHY_GetRateValuesOfTxPowerByRate(padapter, RegAddr, BitMask, Data, rateIndex, PwrByRateVal, &rateNum); - if (RfPath > ODM_RF_PATH_D) + if (RfPath >= RF_PATH_MAX) return; if (TxNum > RF_MAX_TX_NUM) @@ -418,7 +418,7 @@ struct adapter *padapter u8 mcs0_7Rates[8] = { MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7 }; - for (path = ODM_RF_PATH_A; path <= ODM_RF_PATH_D; ++path) { + for (path = RF_PATH_A; path < RF_PATH_MAX; ++path) { for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) { /* CCK */ base = PHY_GetTxPowerByRate(padapter, path, txNum, MGN_11M); @@ -619,7 +619,7 @@ s8 PHY_GetTxPowerByRate( padapter->registrypriv.RegEnableTxPowerByRate == 0) return 0; - if (RFPath > ODM_RF_PATH_D) + if (RFPath >= RF_PATH_MAX) return value; if (TxNum >= RF_MAX_TX_NUM) @@ -643,7 +643,7 @@ void PHY_SetTxPowerByRate( struct hal_com_data *pHalData = GET_HAL_DATA(padapter); u8 rateIndex = PHY_GetRateIndexOfTxPowerByRate(Rate); - if (RFPath > ODM_RF_PATH_D) + if (RFPath >= RF_PATH_MAX) return; if (TxNum >= RF_MAX_TX_NUM) @@ -809,9 +809,9 @@ void PHY_ConvertTxPowerLimitToPowerIndex(struct adapter *Adapter) for (bw = 0; bw < MAX_2_4G_BANDWIDTH_NUM; ++bw) { for (channel = 0; channel < CHANNEL_MAX_NUMBER_2G; ++channel) { for (rateSection = 0; rateSection < MAX_RATE_SECTION_NUM; ++rateSection) { - tempPwrLmt = pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][ODM_RF_PATH_A]; + tempPwrLmt = pHalData->TxPwrLimit_2_4G[regulation][bw][rateSection][channel][RF_PATH_A]; - for (rfPath = ODM_RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) { + for (rfPath = RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) { if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { if (rateSection == 2) /* HT 1T */ BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_1TX, HT_MCS0_MCS7); @@ -904,10 +904,10 @@ void PHY_SetTxPowerLimit( if (channelIndex == -1) return; - prevPowerLimit = pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A]; + prevPowerLimit = pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][RF_PATH_A]; if (powerLimit < prevPowerLimit) - pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][ODM_RF_PATH_A] = powerLimit; + pHalData->TxPwrLimit_2_4G[regulation][bandwidth][rateSection][channelIndex][RF_PATH_A] = powerLimit; } void Hal_ChannelPlanToRegulation(struct adapter *Adapter, u16 ChannelPlan) diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c index 45fdd51b784e..fd5656398c3d 100644 --- a/drivers/staging/rtl8723bs/hal/odm.c +++ b/drivers/staging/rtl8723bs/hal/odm.c @@ -718,7 +718,7 @@ void odm_TXPowerTrackingInit(struct dm_odm_t *pDM_Odm) pDM_Odm->BbSwingIdxCckBase = pDM_Odm->DefaultCckIndex; pDM_Odm->RFCalibrateInfo.CCK_index = pDM_Odm->DefaultCckIndex; - for (p = ODM_RF_PATH_A; p < MAX_RF_PATH; ++p) { + for (p = RF_PATH_A; p < MAX_RF_PATH; ++p) { pDM_Odm->BbSwingIdxOfdmBase[p] = pDM_Odm->DefaultOfdmIndex; pDM_Odm->RFCalibrateInfo.OFDM_index[p] = pDM_Odm->DefaultOfdmIndex; pDM_Odm->RFCalibrateInfo.DeltaPowerIndex[p] = 0; @@ -736,7 +736,7 @@ void ODM_TXPowerTrackingCheck(struct dm_odm_t *pDM_Odm) return; if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ - PHY_SetRFReg(pDM_Odm->Adapter, ODM_RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03); + PHY_SetRFReg(pDM_Odm->Adapter, RF_PATH_A, RF_T_METER_NEW, (BIT17 | BIT16), 0x03); pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; return; diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h index abf6547518fb..c77fb6e341b2 100644 --- a/drivers/staging/rtl8723bs/hal/odm.h +++ b/drivers/staging/rtl8723bs/hal/odm.h @@ -998,26 +998,6 @@ struct dm_odm_t { /* DM_Out_Source_Dynamic_Mechanism_Structure */ #endif }; -#define ODM_RF_PATH_MAX 2 - -enum odm_rf_radio_path_e { - ODM_RF_PATH_A = 0, /* Radio Path A */ - ODM_RF_PATH_B = 1, /* Radio Path B */ - ODM_RF_PATH_C = 2, /* Radio Path C */ - ODM_RF_PATH_D = 3, /* Radio Path D */ - ODM_RF_PATH_AB, - ODM_RF_PATH_AC, - ODM_RF_PATH_AD, - ODM_RF_PATH_BC, - ODM_RF_PATH_BD, - ODM_RF_PATH_CD, - ODM_RF_PATH_ABC, - ODM_RF_PATH_ACD, - ODM_RF_PATH_BCD, - ODM_RF_PATH_ABCD, - /* ODM_RF_PATH_MAX, Max RF number 90 support */ -}; - enum odm_rf_content { odm_radioa_txt = 0x1000, odm_radiob_txt = 0x1001, diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c index a99d567468b2..1e084f01050e 100644 --- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c +++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c @@ -203,7 +203,7 @@ void odm_parsing_cfo(void *dm_void, void *pkt_info_void, s8 *cfotail) * 3 Update CFO report for path-A & path-B * Only paht-A and path-B have CFO tail and short CFO */ - for (i = ODM_RF_PATH_A; i <= ODM_RF_PATH_B; i++) + for (i = RF_PATH_A; i <= RF_PATH_B; i++) cfo_track->CFO_tail[i] = (int)cfotail[i]; /* 3 Update packet counter */ diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c index 16d479dbd069..994b8c578e7a 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.c +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.c @@ -113,8 +113,8 @@ static void odm_rx_phy_status_parsing(struct dm_odm_t *dm_odm, struct phy_status_rpt_8192cd_t *phy_sta_rpt = (struct phy_status_rpt_8192cd_t *)phy_status; is_cck_rate = pkt_info->data_rate <= DESC_RATE11M; - phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = -1; - phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1; + phy_info->rx_mimo_signal_quality[RF_PATH_A] = -1; + phy_info->rx_mimo_signal_quality[RF_PATH_B] = -1; if (is_cck_rate) { @@ -166,8 +166,8 @@ static void odm_rx_phy_status_parsing(struct dm_odm_t *dm_odm, } phy_info->signal_quality = sq; - phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = sq; - phy_info->rx_mimo_signal_quality[ODM_RF_PATH_B] = -1; + phy_info->rx_mimo_signal_quality[RF_PATH_A] = sq; + phy_info->rx_mimo_signal_quality[RF_PATH_B] = -1; } } else { /* is OFDM rate */ dm_odm->PhyDbgInfo.NumQryPhyStatusOFDM++; @@ -176,7 +176,7 @@ static void odm_rx_phy_status_parsing(struct dm_odm_t *dm_odm, * (1)Get RSSI for HT rate */ - for (i = ODM_RF_PATH_A; i < ODM_RF_PATH_MAX; i++) { + for (i = RF_PATH_A; i < RF_PATH_MAX; i++) { /* 2008/01/30 MH we will judge RF RX path now. */ if (dm_odm->RFPathRxEnable & BIT(i)) rf_rx_num++; @@ -227,7 +227,7 @@ static void odm_rx_phy_status_parsing(struct dm_odm_t *dm_odm, /* Fill value in RFD, Get the first spatial stream only */ phy_info->signal_quality = (u8)(evm & 0xff); - phy_info->rx_mimo_signal_quality[ODM_RF_PATH_A] = (u8)(evm & 0xff); + phy_info->rx_mimo_signal_quality[RF_PATH_A] = (u8)(evm & 0xff); odm_parsing_cfo(dm_odm, pkt_info, phy_sta_rpt->path_cfotail); } @@ -290,23 +290,23 @@ static void odm_Process_RSSIForDM( if (pPktinfo->to_self || pPktinfo->is_beacon) { if (!isCCKrate) { /* ofdm rate */ - if (pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B] == 0) { - RSSI_Ave = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A]; - pDM_Odm->RSSI_A = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A]; + if (pPhyInfo->rx_mimo_signal_strength[RF_PATH_B] == 0) { + RSSI_Ave = pPhyInfo->rx_mimo_signal_strength[RF_PATH_A]; + pDM_Odm->RSSI_A = pPhyInfo->rx_mimo_signal_strength[RF_PATH_A]; pDM_Odm->RSSI_B = 0; } else { - pDM_Odm->RSSI_A = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A]; - pDM_Odm->RSSI_B = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B]; + pDM_Odm->RSSI_A = pPhyInfo->rx_mimo_signal_strength[RF_PATH_A]; + pDM_Odm->RSSI_B = pPhyInfo->rx_mimo_signal_strength[RF_PATH_B]; if ( - pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A] > - pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B] + pPhyInfo->rx_mimo_signal_strength[RF_PATH_A] > + pPhyInfo->rx_mimo_signal_strength[RF_PATH_B] ) { - RSSI_max = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A]; - RSSI_min = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B]; + RSSI_max = pPhyInfo->rx_mimo_signal_strength[RF_PATH_A]; + RSSI_min = pPhyInfo->rx_mimo_signal_strength[RF_PATH_B]; } else { - RSSI_max = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_B]; - RSSI_min = pPhyInfo->rx_mimo_signal_strength[ODM_RF_PATH_A]; + RSSI_max = pPhyInfo->rx_mimo_signal_strength[RF_PATH_B]; + RSSI_min = pPhyInfo->rx_mimo_signal_strength[RF_PATH_A]; } if ((RSSI_max-RSSI_min) < 3) @@ -411,7 +411,7 @@ void odm_phy_status_query(struct dm_odm_t *dm_odm, struct odm_phy_info *phy_info enum hal_status ODM_ConfigRFWithHeaderFile( struct dm_odm_t *pDM_Odm, enum ODM_RF_Config_Type ConfigType, - enum odm_rf_radio_path_e eRFPath + enum rf_path eRFPath ) { if (ConfigType == CONFIG_RF_RADIO) diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h index b2eae7d993fa..2e10974ffef1 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h @@ -84,7 +84,7 @@ enum hal_status ODM_ConfigRFWithTxPwrTrackHeaderFile(struct dm_odm_t *pDM_Odm); enum hal_status ODM_ConfigRFWithHeaderFile( struct dm_odm_t *pDM_Odm, enum ODM_RF_Config_Type ConfigType, - enum odm_rf_radio_path_e eRFPath + enum rf_path eRFPath ); enum hal_status ODM_ConfigBBWithHeaderFile( diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c index ad169704f3e9..97acf75fc04e 100644 --- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c +++ b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c @@ -70,17 +70,17 @@ static s16 odm_InbandNoise_Monitor_NSeries( /* update idle time pwer report per 5us */ PHY_SetBBReg(pDM_Odm->Adapter, rFPGA0_TxGainStage, BIT25, 0); - noise_data.value[ODM_RF_PATH_A] = (u8)(tmp4b&0xff); - noise_data.value[ODM_RF_PATH_B] = (u8)((tmp4b&0xff00)>>8); + noise_data.value[RF_PATH_A] = (u8)(tmp4b&0xff); + noise_data.value[RF_PATH_B] = (u8)((tmp4b&0xff00)>>8); - for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) { + for (rf_path = RF_PATH_A; rf_path < max_rf_path; rf_path++) { noise_data.sval[rf_path] = (s8)noise_data.value[rf_path]; noise_data.sval[rf_path] /= 2; } /* mdelay(10); */ /* msleep(10); */ - for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) { + for (rf_path = RF_PATH_A; rf_path < max_rf_path; rf_path++) { if ((noise_data.valid_cnt[rf_path] < ValidCnt) && (noise_data.sval[rf_path] < Valid_Max && noise_data.sval[rf_path] >= Valid_Min)) { noise_data.valid_cnt[rf_path]++; noise_data.sum[rf_path] += noise_data.sval[rf_path]; @@ -94,7 +94,7 @@ static s16 odm_InbandNoise_Monitor_NSeries( /* printk("####### valid_done:%d #############\n", valid_done); */ if ((valid_done == max_rf_path) || (jiffies_to_msecs(jiffies - start) > max_time)) { - for (rf_path = ODM_RF_PATH_A; rf_path < max_rf_path; rf_path++) { + for (rf_path = RF_PATH_A; rf_path < max_rf_path; rf_path++) { /* printk("%s PATH_%d - sum = %d, valid_cnt = %d\n", __func__, rf_path, noise_data.sum[rf_path], noise_data.valid_cnt[rf_path]); */ if (noise_data.valid_cnt[rf_path]) noise_data.sum[rf_path] /= noise_data.valid_cnt[rf_path]; @@ -106,14 +106,14 @@ static s16 odm_InbandNoise_Monitor_NSeries( } reg_c50 = (s32)PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XAAGCCore1, bMaskByte0); reg_c50 &= ~BIT7; - pDM_Odm->noise_level.noise[ODM_RF_PATH_A] = -110 + reg_c50 + noise_data.sum[ODM_RF_PATH_A]; - pDM_Odm->noise_level.noise_all += pDM_Odm->noise_level.noise[ODM_RF_PATH_A]; + pDM_Odm->noise_level.noise[RF_PATH_A] = -110 + reg_c50 + noise_data.sum[RF_PATH_A]; + pDM_Odm->noise_level.noise_all += pDM_Odm->noise_level.noise[RF_PATH_A]; if (max_rf_path == 2) { reg_c58 = (s32)PHY_QueryBBReg(pDM_Odm->Adapter, rOFDM0_XBAGCCore1, bMaskByte0); reg_c58 &= ~BIT7; - pDM_Odm->noise_level.noise[ODM_RF_PATH_B] = -110 + reg_c58 + noise_data.sum[ODM_RF_PATH_B]; - pDM_Odm->noise_level.noise_all += pDM_Odm->noise_level.noise[ODM_RF_PATH_B]; + pDM_Odm->noise_level.noise[RF_PATH_B] = -110 + reg_c58 + noise_data.sum[RF_PATH_B]; + pDM_Odm->noise_level.noise_all += pDM_Odm->noise_level.noise[RF_PATH_B]; } pDM_Odm->noise_level.noise_all /= max_rf_path; diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c index a29bd9375023..0f71b1adea40 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c +++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c @@ -11,7 +11,7 @@ void odm_ConfigRFReg_8723B( struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data, - enum odm_rf_radio_path_e RF_PATH, + enum rf_path RF_PATH, u32 RegAddr ) { @@ -93,7 +93,7 @@ void odm_ConfigRF_RadioA_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data) pDM_Odm, Addr, Data, - ODM_RF_PATH_A, + RF_PATH_A, Addr|maskforPhySet ); } diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h index bdd6fde49fc6..b8d4c2aa6d4d 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h +++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h @@ -10,7 +10,7 @@ void odm_ConfigRFReg_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, u32 Data, - enum odm_rf_radio_path_e RF_PATH, + enum rf_path RF_PATH, u32 RegAddr ); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 713ee0179dda..ce4f81828a65 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -2280,21 +2280,21 @@ void Hal_EfuseParseBTCoexistInfo_8723B( tempval = hwinfo[EEPROM_RF_BT_SETTING_8723B]; if (tempval != 0xFF) { pHalData->EEPROMBluetoothAntNum = tempval & BIT(0); - /* EFUSE_0xC3[6] == 0, S1(Main)-ODM_RF_PATH_A; */ - /* EFUSE_0xC3[6] == 1, S0(Aux)-ODM_RF_PATH_B */ - pHalData->ant_path = (tempval & BIT(6))?ODM_RF_PATH_B:ODM_RF_PATH_A; + /* EFUSE_0xC3[6] == 0, S1(Main)-RF_PATH_A; */ + /* EFUSE_0xC3[6] == 1, S0(Aux)-RF_PATH_B */ + pHalData->ant_path = (tempval & BIT(6))? RF_PATH_B : RF_PATH_A; } else { pHalData->EEPROMBluetoothAntNum = Ant_x1; if (pHalData->PackageType == PACKAGE_QFN68) - pHalData->ant_path = ODM_RF_PATH_B; + pHalData->ant_path = RF_PATH_B; else - pHalData->ant_path = ODM_RF_PATH_A; + pHalData->ant_path = RF_PATH_A; } } else { pHalData->EEPROMBluetoothCoexist = false; pHalData->EEPROMBluetoothType = BT_RTL8723B; pHalData->EEPROMBluetoothAntNum = Ant_x1; - pHalData->ant_path = ODM_RF_PATH_A; + pHalData->ant_path = RF_PATH_A; } if (padapter->registrypriv.ant_num > 0) { diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c index ca6b548171b4..4b362320ce31 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c @@ -308,28 +308,28 @@ static void phy_InitBBRFRegisterDefinition(struct adapter *Adapter) struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); /* RF Interface Sowrtware Control */ - pHalData->PHYRegDef[ODM_RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 LSBs if read 32-bit from 0x870 */ - pHalData->PHYRegDef[ODM_RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) */ + pHalData->PHYRegDef[RF_PATH_A].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 LSBs if read 32-bit from 0x870 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfs = rFPGA0_XAB_RFInterfaceSW; /* 16 MSBs if read 32-bit from 0x870 (16-bit for 0x872) */ /* RF Interface Output (and Enable) */ - pHalData->PHYRegDef[ODM_RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x860 */ - pHalData->PHYRegDef[ODM_RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x864 */ + pHalData->PHYRegDef[RF_PATH_A].rfintfo = rFPGA0_XA_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x860 */ + pHalData->PHYRegDef[RF_PATH_B].rfintfo = rFPGA0_XB_RFInterfaceOE; /* 16 LSBs if read 32-bit from 0x864 */ /* RF Interface (Output and) Enable */ - pHalData->PHYRegDef[ODM_RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */ - pHalData->PHYRegDef[ODM_RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) */ + pHalData->PHYRegDef[RF_PATH_A].rfintfe = rFPGA0_XA_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x860 (16-bit for 0x862) */ + pHalData->PHYRegDef[RF_PATH_B].rfintfe = rFPGA0_XB_RFInterfaceOE; /* 16 MSBs if read 32-bit from 0x864 (16-bit for 0x866) */ - pHalData->PHYRegDef[ODM_RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; /* LSSI Parameter */ - pHalData->PHYRegDef[ODM_RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; + pHalData->PHYRegDef[RF_PATH_A].rf3wireOffset = rFPGA0_XA_LSSIParameter; /* LSSI Parameter */ + pHalData->PHYRegDef[RF_PATH_B].rf3wireOffset = rFPGA0_XB_LSSIParameter; - pHalData->PHYRegDef[ODM_RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; /* wire control parameter2 */ - pHalData->PHYRegDef[ODM_RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; /* wire control parameter2 */ + pHalData->PHYRegDef[RF_PATH_A].rfHSSIPara2 = rFPGA0_XA_HSSIParameter2; /* wire control parameter2 */ + pHalData->PHYRegDef[RF_PATH_B].rfHSSIPara2 = rFPGA0_XB_HSSIParameter2; /* wire control parameter2 */ /* Tranceiver Readback LSSI/HSPI mode */ - pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; - pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; - pHalData->PHYRegDef[ODM_RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; - pHalData->PHYRegDef[ODM_RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; + pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBack = rFPGA0_XA_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBack = rFPGA0_XB_LSSIReadBack; + pHalData->PHYRegDef[RF_PATH_A].rfLSSIReadBackPi = TransceiverA_HSPI_Readback; + pHalData->PHYRegDef[RF_PATH_B].rfLSSIReadBackPi = TransceiverB_HSPI_Readback; } @@ -399,7 +399,7 @@ int PHY_BBConfig8723B(struct adapter *Adapter) msleep(1); - PHY_SetRFReg(Adapter, ODM_RF_PATH_A, 0x1, 0xfffff, 0x780); + PHY_SetRFReg(Adapter, RF_PATH_A, 0x1, 0xfffff, 0x780); rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_PPLL|FEN_PCIEA|FEN_DIO_PCIE|FEN_BB_GLB_RSTn|FEN_BBRSTB); @@ -453,7 +453,7 @@ void PHY_SetTxPowerIndex( u8 Rate ) { - if (RFPath == ODM_RF_PATH_A || RFPath == ODM_RF_PATH_B) { + if (RFPath == RF_PATH_A || RFPath == RF_PATH_B) { switch (Rate) { case MGN_1M: PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, PowerIndex); @@ -538,7 +538,7 @@ u8 PHY_GetTxPowerIndex( s8 txPower = 0, powerDiffByRate = 0, limit = 0; txPower = (s8) PHY_GetTxPowerIndexBase(padapter, RFPath, Rate, BandWidth, Channel); - powerDiffByRate = PHY_GetTxPowerByRate(padapter, ODM_RF_PATH_A, RF_1TX, Rate); + powerDiffByRate = PHY_GetTxPowerByRate(padapter, RF_PATH_A, RF_1TX, Rate); limit = phy_get_tx_pwr_lmt( padapter, @@ -565,10 +565,10 @@ void PHY_SetTxPowerLevel8723B(struct adapter *Adapter, u8 Channel) struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; struct fat_t *pDM_FatTable = &pDM_Odm->DM_FatTable; - u8 RFPath = ODM_RF_PATH_A; + u8 RFPath = RF_PATH_A; if (pHalData->AntDivCfg) {/* antenna diversity Enable */ - RFPath = ((pDM_FatTable->RxIdleAnt == MAIN_ANT) ? ODM_RF_PATH_A : ODM_RF_PATH_B); + RFPath = ((pDM_FatTable->RxIdleAnt == MAIN_ANT) ? RF_PATH_A : RF_PATH_B); } else { /* antenna diversity disable */ RFPath = pHalData->ant_path; } @@ -672,8 +672,8 @@ static void phy_SwChnl8723B(struct adapter *padapter) if (pHalData->rf_chip == RF_PSEUDO_11N) return; pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff00) | channelToSW); - PHY_SetRFReg(padapter, ODM_RF_PATH_A, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]); - PHY_SetRFReg(padapter, ODM_RF_PATH_B, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(padapter, RF_PATH_A, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(padapter, RF_PATH_B, RF_CHNLBW, 0x3FF, pHalData->RfRegChnlVal[0]); } static void phy_SwChnlAndSetBwMode8723B(struct adapter *Adapter) diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c index 38228b46b1ee..51865f81b1fe 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c @@ -63,14 +63,14 @@ void PHY_RF6052SetBandwidth8723B( switch (Bandwidth) { case CHANNEL_WIDTH_20: pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10 | BIT11); - PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); - PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); break; case CHANNEL_WIDTH_40: pHalData->RfRegChnlVal[0] = ((pHalData->RfRegChnlVal[0] & 0xfffff3ff) | BIT10); - PHY_SetRFReg(Adapter, ODM_RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); - PHY_SetRFReg(Adapter, ODM_RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); + PHY_SetRFReg(Adapter, RF_PATH_B, RF_CHNLBW, bRFRegOffsetMask, pHalData->RfRegChnlVal[0]); break; default: @@ -97,11 +97,9 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) /*----Store original RFENV control type----*/ switch (eRFPath) { case RF_PATH_A: - case RF_PATH_C: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV); break; case RF_PATH_B: - case RF_PATH_D: u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16); break; } @@ -128,19 +126,14 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) ODM_ConfigRFWithHeaderFile(&pHalData->odmpriv, CONFIG_RF_RADIO, eRFPath); break; - case RF_PATH_C: - case RF_PATH_D: - break; } /*----Restore RFENV control type----*/ switch (eRFPath) { case RF_PATH_A: - case RF_PATH_C: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV, u4RegValue); break; case RF_PATH_B: - case RF_PATH_D: PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue); break; } @@ -163,7 +156,6 @@ int PHY_RF6052_Config8723B(struct adapter *Adapter) /* */ /* Initialize general global value */ /* */ - /* TODO: Extend RF_PATH_C and RF_PATH_D in the future */ if (pHalData->rf_type == RF_1T1R) pHalData->NumTotalRFPath = 1; else diff --git a/drivers/staging/rtl8723bs/include/hal_phy.h b/drivers/staging/rtl8723bs/include/hal_phy.h index 861aa71cd179..3d71a4f41592 100644 --- a/drivers/staging/rtl8723bs/include/hal_phy.h +++ b/drivers/staging/rtl8723bs/include/hal_phy.h @@ -30,8 +30,7 @@ enum { enum rf_path { RF_PATH_A = 0, RF_PATH_B, - RF_PATH_C, - RF_PATH_D + RF_PATH_MAX }; #define TX_1S 0 -- cgit v1.2.3 From b2f29c8a6baee889fd6d6aa93ca224fed576ed43 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:02 +0200 Subject: staging: rtl8723bs: remove unused macros remove unused macros in hal/odm_HWConfig.h Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/00575e78b23e36edb3a7e404e26a3c5e84394f3d.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm_HWConfig.h | 17 ----------------- 1 file changed, 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h index 2e10974ffef1..0c3697c38e64 100644 --- a/drivers/staging/rtl8723bs/hal/odm_HWConfig.h +++ b/drivers/staging/rtl8723bs/hal/odm_HWConfig.h @@ -9,23 +9,6 @@ #ifndef __HALHWOUTSRC_H__ #define __HALHWOUTSRC_H__ - -/*--------------------------Define -------------------------------------------*/ -/* define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = Array[i]; v2 = Array[i+1]; } while (0) */ -#define AGC_DIFF_CONFIG_MP(ic, band) (ODM_ReadAndConfig_MP_##ic##_AGC_TAB_DIFF(pDM_Odm, Array_MP_##ic##_AGC_TAB_DIFF_##band, \ - sizeof(Array_MP_##ic##_AGC_TAB_DIFF_##band)/sizeof(u32))) -#define AGC_DIFF_CONFIG_TC(ic, band) (ODM_ReadAndConfig_TC_##ic##_AGC_TAB_DIFF(pDM_Odm, Array_TC_##ic##_AGC_TAB_DIFF_##band, \ - sizeof(Array_TC_##ic##_AGC_TAB_DIFF_##band)/sizeof(u32))) - -#define AGC_DIFF_CONFIG(ic, band)\ - do {\ - if (pDM_Odm->bIsMPChip)\ - AGC_DIFF_CONFIG_MP(ic, band);\ - else\ - AGC_DIFF_CONFIG_TC(ic, band);\ - } while (0) - - /* */ /* structure and define */ /* */ -- cgit v1.2.3 From cddb75f307da56e5079059815dc7558ec6b709e5 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:03 +0200 Subject: staging: rtl8723bs: remove unused struct member remove unused bIsMPChip struct member and all code storing it. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/ad7831868683a99598cd00a3aacc45f76ba234e8.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm.c | 4 ---- drivers/staging/rtl8723bs/hal/odm.h | 2 -- drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 1 - 3 files changed, 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c index fd5656398c3d..f87dd84434f7 100644 --- a/drivers/staging/rtl8723bs/hal/odm.c +++ b/drivers/staging/rtl8723bs/hal/odm.c @@ -856,10 +856,6 @@ void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 V pDM_Odm->SupportInterface = (u8)Value; break; - case ODM_CMNINFO_MP_TEST_CHIP: - pDM_Odm->bIsMPChip = (u8)Value; - break; - case ODM_CMNINFO_IC_TYPE: pDM_Odm->SupportICType = Value; break; diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h index c77fb6e341b2..814f4d54a96d 100644 --- a/drivers/staging/rtl8723bs/hal/odm.h +++ b/drivers/staging/rtl8723bs/hal/odm.h @@ -282,7 +282,6 @@ enum odm_cmninfo_e { ODM_CMNINFO_PLATFORM = 0, ODM_CMNINFO_ABILITY, /* ODM_ABILITY_E */ ODM_CMNINFO_INTERFACE, /* ODM_INTERFACE_E */ - ODM_CMNINFO_MP_TEST_CHIP, ODM_CMNINFO_IC_TYPE, /* ODM_IC_TYPE_E */ ODM_CMNINFO_CUT_VER, /* ODM_CUT_VERSION_E */ ODM_CMNINFO_FAB_VER, /* ODM_FAB_E */ @@ -802,7 +801,6 @@ struct dm_odm_t { /* DM_Out_Source_Dynamic_Mechanism_Structure */ bool bsta_state; u8 RSSI_Min; u8 InterfaceIndex; /* Add for 92D dual MAC: 0--Mac0 1--Mac1 */ - bool bIsMPChip; bool bOneEntryOnly; /* Common info for BTDM */ bool bBtEnabled; /* BT is disabled */ diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index 54e2a68a0824..c1caeaf44943 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -44,7 +44,6 @@ static void Init_ODM_ComInfo_8723b(struct adapter *Adapter) ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_FAB_VER, fab_ver); ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_CUT_VER, cut_ver); - ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_MP_TEST_CHIP, IS_NORMAL_CHIP(pHalData->VersionID)); ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_PATCH_ID, pHalData->CustomerID); /* ODM_CMNINFO_BINHCT_TEST only for MP Team */ -- cgit v1.2.3 From 9df030033e05c9106ca9cefff021998bdb19a9db Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:04 +0200 Subject: staging: rtl8723bs: remove rf type branching (first patch) remove rf type branching, for the baseband works only on 1T1R rf type, so just keep code branches related to 1T1R. Remove RFType from hal_version struct, and all related code. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/72ce98106bb172fce0f43315bc4dbbb7065afef5.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com.c | 10 +--------- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 8 +------- drivers/staging/rtl8723bs/include/HalVerDef.h | 18 ------------------ 3 files changed, 2 insertions(+), 34 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 7dd49c8538e4..65987e3076a3 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -70,15 +70,7 @@ void dump_chip_info(struct hal_version ChipVersion) cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "UNKNOWN_CUT(%d)_", ChipVersion.CUTVersion); - if (IS_1T1R(ChipVersion)) - cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "1T1R_"); - else if (IS_1T2R(ChipVersion)) - cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "1T2R_"); - else if (IS_2T2R(ChipVersion)) - cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "2T2R_"); - else - cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, - "UNKNOWN_RFTYPE(%d)_", ChipVersion.RFType); + cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "1T1R_"); cnt += scnprintf(buf + cnt, sizeof(buf) - cnt, "RomVer(%d)\n", ChipVersion.ROMVer); } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index ce4f81828a65..5da8e21bb02f 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -1640,7 +1640,6 @@ static struct hal_version ReadChipVersion8723B(struct adapter *padapter) value32 = rtw_read32(padapter, REG_SYS_CFG); ChipVersion.ICType = CHIP_8723B; ChipVersion.ChipType = ((value32 & RTL_ID) ? TEST_CHIP : NORMAL_CHIP); - ChipVersion.RFType = RF_TYPE_1T1R; ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ @@ -1661,12 +1660,7 @@ static struct hal_version ReadChipVersion8723B(struct adapter *padapter) dump_chip_info(ChipVersion); #endif pHalData->VersionID = ChipVersion; - if (IS_1T2R(ChipVersion)) - pHalData->rf_type = RF_1T2R; - else if (IS_2T2R(ChipVersion)) - pHalData->rf_type = RF_2T2R; - else - pHalData->rf_type = RF_1T1R; + pHalData->rf_type = RF_1T1R; return ChipVersion; } diff --git a/drivers/staging/rtl8723bs/include/HalVerDef.h b/drivers/staging/rtl8723bs/include/HalVerDef.h index bab226f77b24..8f654a49fb9d 100644 --- a/drivers/staging/rtl8723bs/include/HalVerDef.h +++ b/drivers/staging/rtl8723bs/include/HalVerDef.h @@ -50,23 +50,11 @@ enum hal_vendor_e { /* tag_HAL_Manufacturer_Version_Definition */ CHIP_VENDOR_SMIC = 2, }; -enum hal_rf_type_e { /* tag_HAL_RF_Type_Definition */ - RF_TYPE_1T1R = 0, - RF_TYPE_1T2R = 1, - RF_TYPE_2T2R = 2, - RF_TYPE_2T3R = 3, - RF_TYPE_2T4R = 4, - RF_TYPE_3T3R = 5, - RF_TYPE_3T4R = 6, - RF_TYPE_4T4R = 7, -}; - struct hal_version { /* tag_HAL_VERSION */ enum hal_ic_type_e ICType; enum hal_chip_type_e ChipType; enum hal_cut_version_e CUTVersion; enum hal_vendor_e VendorType; - enum hal_rf_type_e RFType; u8 ROMVer; }; @@ -76,7 +64,6 @@ struct hal_version { /* tag_HAL_VERSION */ /* Get element */ #define GET_CVID_IC_TYPE(version) ((enum hal_ic_type_e)((version).ICType)) #define GET_CVID_CHIP_TYPE(version) ((enum hal_chip_type_e)((version).ChipType)) -#define GET_CVID_RF_TYPE(version) ((enum hal_rf_type_e)((version).RFType)) #define GET_CVID_MANUFACTUER(version) ((enum hal_vendor_e)((version).VendorType)) #define GET_CVID_CUT_VERSION(version) ((enum hal_cut_version_e)((version).CUTVersion)) #define GET_CVID_ROM_VERSION(version) (((version).ROMVer) & ROM_VERSION_MASK) @@ -105,9 +92,4 @@ struct hal_version { /* tag_HAL_VERSION */ #define IS_CHIP_VENDOR_UMC(version) ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_UMC) ? true : false) #define IS_CHIP_VENDOR_SMIC(version) ((GET_CVID_MANUFACTUER(version) == CHIP_VENDOR_SMIC) ? true : false) -/* hal_rf_type_e */ -#define IS_1T1R(version) ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T1R) ? true : false) -#define IS_1T2R(version) ((GET_CVID_RF_TYPE(version) == RF_TYPE_1T2R) ? true : false) -#define IS_2T2R(version) ((GET_CVID_RF_TYPE(version) == RF_TYPE_2T2R) ? true : false) - #endif -- cgit v1.2.3 From 9d535e9286c8c04f845030e8d888009753cc9269 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:05 +0200 Subject: staging: rtl8723bs: remove rf type branching (second patch) remove RFType field in dm_odm_t struct, keep unconditioned all code branches related to 1T1R path, delete the others. Remove unused variable to silence gcc warning. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/fd41fbfba16df2b93a7593c1f853a874255e945c.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/odm.c | 44 ++++++------------------ drivers/staging/rtl8723bs/hal/odm.h | 3 -- drivers/staging/rtl8723bs/hal/odm_CfoTracking.c | 8 ++--- drivers/staging/rtl8723bs/hal/odm_DIG.c | 3 +- drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c | 5 +-- drivers/staging/rtl8723bs/hal/rtl8723b_dm.c | 9 ----- 6 files changed, 14 insertions(+), 58 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/odm.c b/drivers/staging/rtl8723bs/hal/odm.c index f87dd84434f7..31f65d817899 100644 --- a/drivers/staging/rtl8723bs/hal/odm.c +++ b/drivers/staging/rtl8723bs/hal/odm.c @@ -391,36 +391,20 @@ u32 ODM_Get_Rate_Bitmap( case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): case (ODM_WM_B|ODM_WM_N24G): case (ODM_WM_G|ODM_WM_N24G): - if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) { - if (rssi_level == DM_RATR_STA_HIGH) - rate_bitmap = 0x000f0000; - else if (rssi_level == DM_RATR_STA_MIDDLE) - rate_bitmap = 0x000ff000; - else { - if (*(pDM_Odm->pBandWidth) == ODM_BW40M) - rate_bitmap = 0x000ff015; - else - rate_bitmap = 0x000ff005; - } - } else { - if (rssi_level == DM_RATR_STA_HIGH) - rate_bitmap = 0x0f8f0000; - else if (rssi_level == DM_RATR_STA_MIDDLE) - rate_bitmap = 0x0f8ff000; - else { - if (*(pDM_Odm->pBandWidth) == ODM_BW40M) - rate_bitmap = 0x0f8ff015; - else - rate_bitmap = 0x0f8ff005; - } + if (rssi_level == DM_RATR_STA_HIGH) + rate_bitmap = 0x000f0000; + else if (rssi_level == DM_RATR_STA_MIDDLE) + rate_bitmap = 0x000ff000; + else { + if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + rate_bitmap = 0x000ff015; + else + rate_bitmap = 0x000ff005; } break; default: - if (pDM_Odm->RFType == RF_1T2R) - rate_bitmap = 0x000fffff; - else - rate_bitmap = 0x0fffffff; + rate_bitmap = 0x0fffffff; break; } @@ -844,10 +828,6 @@ void ODM_CmnInfoInit(struct dm_odm_t *pDM_Odm, enum odm_cmninfo_e CmnInfo, u32 V pDM_Odm->SupportAbility = (u32)Value; break; - case ODM_CMNINFO_RF_TYPE: - pDM_Odm->RFType = (u8)Value; - break; - case ODM_CMNINFO_PLATFORM: pDM_Odm->SupportPlatform = (u8)Value; break; @@ -1094,10 +1074,6 @@ void ODM_CmnInfoUpdate(struct dm_odm_t *pDM_Odm, u32 CmnInfo, u64 Value) pDM_Odm->SupportAbility = (u32)Value; break; - case ODM_CMNINFO_RF_TYPE: - pDM_Odm->RFType = (u8)Value; - break; - case ODM_CMNINFO_WIFI_DIRECT: pDM_Odm->bWIFI_Direct = (bool)Value; break; diff --git a/drivers/staging/rtl8723bs/hal/odm.h b/drivers/staging/rtl8723bs/hal/odm.h index 814f4d54a96d..19cfc2915458 100644 --- a/drivers/staging/rtl8723bs/hal/odm.h +++ b/drivers/staging/rtl8723bs/hal/odm.h @@ -285,7 +285,6 @@ enum odm_cmninfo_e { ODM_CMNINFO_IC_TYPE, /* ODM_IC_TYPE_E */ ODM_CMNINFO_CUT_VER, /* ODM_CUT_VERSION_E */ ODM_CMNINFO_FAB_VER, /* ODM_FAB_E */ - ODM_CMNINFO_RF_TYPE, /* ODM_RF_PATH_E or ODM_RF_TYPE_E? */ ODM_CMNINFO_RFE_TYPE, ODM_CMNINFO_PACKAGE_TYPE, ODM_CMNINFO_EXT_LNA, /* true */ @@ -422,7 +421,6 @@ enum { /* tag_ODM_Fab_Version_Definition */ ODM_UMC = 1, }; -/* ODM_CMNINFO_RF_TYPE */ /* */ /* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ /* */ @@ -719,7 +717,6 @@ struct dm_odm_t { /* DM_Out_Source_Dynamic_Mechanism_Structure */ /* Fab Version TSMC/UMC = 0/1 */ u8 FabVersion; /* RF Type 4T4R/3T3R/2T2R/1T2R/1T1R/... */ - u8 RFType; u8 RFEType; /* Board Type Normal/HighPower/MiniCard/SLIM/Combo/... = 0/1/2/3/4/... */ u8 BoardType; diff --git a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c index 1e084f01050e..928c58be6c9b 100644 --- a/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c +++ b/drivers/staging/rtl8723bs/hal/odm_CfoTracking.c @@ -94,7 +94,7 @@ void ODM_CfoTracking(void *pDM_VOID) { struct dm_odm_t *pDM_Odm = (struct dm_odm_t *)pDM_VOID; struct cfo_tracking *pCfoTrack = &pDM_Odm->DM_CfoTrack; - int CFO_kHz_A, CFO_kHz_B, CFO_ave = 0; + int CFO_kHz_A, CFO_ave = 0; int CFO_ave_diff; int CrystalCap = (int)pCfoTrack->CrystalCap; u8 Adjust_Xtal = 1; @@ -117,12 +117,8 @@ void ODM_CfoTracking(void *pDM_VOID) /* 4 1.2 Calculate CFO */ CFO_kHz_A = (int)(pCfoTrack->CFO_tail[0] * 3125) / 1280; - CFO_kHz_B = (int)(pCfoTrack->CFO_tail[1] * 3125) / 1280; - if (pDM_Odm->RFType < ODM_2T2R) - CFO_ave = CFO_kHz_A; - else - CFO_ave = (int)(CFO_kHz_A + CFO_kHz_B) >> 1; + CFO_ave = CFO_kHz_A; /* 4 1.3 Avoid abnormal large CFO */ CFO_ave_diff = diff --git a/drivers/staging/rtl8723bs/hal/odm_DIG.c b/drivers/staging/rtl8723bs/hal/odm_DIG.c index fb932e0618e2..beda7b8a7c6a 100644 --- a/drivers/staging/rtl8723bs/hal/odm_DIG.c +++ b/drivers/staging/rtl8723bs/hal/odm_DIG.c @@ -302,8 +302,7 @@ void ODM_Write_DIG(void *pDM_VOID, u8 CurrentIGI) /* 1 Set IGI value */ PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->RFType > ODM_1T1R) - PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); + PHY_SetBBReg(pDM_Odm->Adapter, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); pDM_DigTable->CurIGValue = CurrentIGI; } diff --git a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c index 97acf75fc04e..392cc8a398f5 100644 --- a/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c +++ b/drivers/staging/rtl8723bs/hal/odm_NoiseMonitor.c @@ -33,10 +33,7 @@ static s16 odm_InbandNoise_Monitor_NSeries( pDM_Odm->noise_level.noise_all = 0; - if ((pDM_Odm->RFType == ODM_1T2R) || (pDM_Odm->RFType == ODM_2T2R)) - max_rf_path = 2; - else - max_rf_path = 1; + max_rf_path = 1; memset(&noise_data, 0, sizeof(struct noise_level)); diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c index c1caeaf44943..2028791988e7 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_dm.c @@ -49,15 +49,6 @@ static void Init_ODM_ComInfo_8723b(struct adapter *Adapter) /* ODM_CMNINFO_BINHCT_TEST only for MP Team */ ODM_CmnInfoInit(pDM_Odm, ODM_CMNINFO_BWIFI_TEST, Adapter->registrypriv.wifi_spec); - - if (pHalData->rf_type == RF_1T1R) { - ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_1T1R); - } else if (pHalData->rf_type == RF_2T2R) { - ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_2T2R); - } else if (pHalData->rf_type == RF_1T2R) { - ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_RF_TYPE, ODM_1T2R); - } - pdmpriv->InitODMFlag = ODM_RF_CALIBRATION|ODM_RF_TX_PWR_TRACK; ODM_CmnInfoUpdate(pDM_Odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); -- cgit v1.2.3 From f75b87a61880ba518c1e712fe033de62b7b9527d Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:06 +0200 Subject: staging: rtl8723bs: remove rf type branching (third patch) remove rf_type struct member, keep all 1T1R code unconditionally, remove the other *T*R branches. Removed dead code related to MCS indexes above 7. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/e626790eb8bd7d96f939e1bbb47b899bf12dab0d.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com.c | 3 --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 17 ----------------- drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 1 - drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c | 5 +---- drivers/staging/rtl8723bs/hal/sdio_halinit.c | 2 -- drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h | 4 ---- drivers/staging/rtl8723bs/include/hal_data.h | 1 - 7 files changed, 1 insertion(+), 32 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 65987e3076a3..8964303a619f 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -670,9 +670,6 @@ void GetHwReg(struct adapter *adapter, u8 variable, u8 *val) case HW_VAR_DM_FLAG: *((u32 *)val) = odm->SupportAbility; break; - case HW_VAR_RF_TYPE: - *((u8 *)val) = hal_data->rf_type; - break; default: netdev_dbg(adapter->pnetdev, FUNC_ADPT_FMT " variable(%d) not defined!\n", diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 3e426c975828..4a249d20c661 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -116,12 +116,6 @@ u8 PHY_GetRateSectionIndexOfTxPowerByRate( case rTxAGC_A_Mcs07_Mcs04: index = 3; break; - case rTxAGC_A_Mcs11_Mcs08: - index = 4; - break; - case rTxAGC_A_Mcs15_Mcs12: - index = 5; - break; case rTxAGC_B_Rate18_06: index = 8; break; @@ -137,12 +131,6 @@ u8 PHY_GetRateSectionIndexOfTxPowerByRate( case rTxAGC_B_Mcs07_Mcs04: index = 11; break; - case rTxAGC_B_Mcs11_Mcs08: - index = 12; - break; - case rTxAGC_B_Mcs15_Mcs12: - index = 13; - break; default: break; } @@ -395,11 +383,6 @@ void PHY_StoreTxPowerByRate( PHY_StoreTxPowerByRateNew(padapter, RfPath, TxNum, RegAddr, BitMask, Data); else if (pDM_Odm->PhyRegPgVersion == 0) { PHY_StoreTxPowerByRateOld(padapter, RegAddr, BitMask, Data); - - if (RegAddr == rTxAGC_A_Mcs15_Mcs12 && pHalData->rf_type == RF_1T1R) - pHalData->pwrGroupCnt++; - else if (RegAddr == rTxAGC_B_Mcs15_Mcs12 && pHalData->rf_type != RF_1T1R) - pHalData->pwrGroupCnt++; } } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c index 5da8e21bb02f..cce3e7e80953 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c @@ -1660,7 +1660,6 @@ static struct hal_version ReadChipVersion8723B(struct adapter *padapter) dump_chip_info(ChipVersion); #endif pHalData->VersionID = ChipVersion; - pHalData->rf_type = RF_1T1R; return ChipVersion; } diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c index 51865f81b1fe..ffb35e1ace62 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_rf6052.c @@ -156,10 +156,7 @@ int PHY_RF6052_Config8723B(struct adapter *Adapter) /* */ /* Initialize general global value */ /* */ - if (pHalData->rf_type == RF_1T1R) - pHalData->NumTotalRFPath = 1; - else - pHalData->NumTotalRFPath = 2; + pHalData->NumTotalRFPath = 1; /* */ /* Config BB and RF */ diff --git a/drivers/staging/rtl8723bs/hal/sdio_halinit.c b/drivers/staging/rtl8723bs/hal/sdio_halinit.c index a07a6dacec42..c9cd6578f7f8 100644 --- a/drivers/staging/rtl8723bs/hal/sdio_halinit.c +++ b/drivers/staging/rtl8723bs/hal/sdio_halinit.c @@ -556,8 +556,6 @@ static void _InitRFType(struct adapter *padapter) struct hal_com_data *pHalData = GET_HAL_DATA(padapter); pHalData->rf_chip = RF_6052; - - pHalData->rf_type = RF_1T1R; } static void _RfPowerSave(struct adapter *padapter) diff --git a/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h b/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h index aad962548278..586a3dabc5ca 100644 --- a/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h +++ b/drivers/staging/rtl8723bs/include/Hal8192CPhyReg.h @@ -109,7 +109,6 @@ #define rTxAGC_B_Mcs03_Mcs00 0x83c #define rTxAGC_B_Mcs07_Mcs04 0x848 -#define rTxAGC_B_Mcs11_Mcs08 0x84c #define rFPGA0_XA_LSSIParameter 0x840 #define rFPGA0_XB_LSSIParameter 0x844 @@ -123,7 +122,6 @@ #define rFPGA0_XA_RFInterfaceOE 0x860 /* RF Channel switch */ #define rFPGA0_XB_RFInterfaceOE 0x864 -#define rTxAGC_B_Mcs15_Mcs12 0x868 #define rTxAGC_B_CCK11_A_CCK2_11 0x86c #define rFPGA0_XAB_RFInterfaceSW 0x870 /* RF Interface Software Control */ @@ -303,8 +301,6 @@ #define rTxAGC_A_CCK1_Mcs32 0xe08 #define rTxAGC_A_Mcs03_Mcs00 0xe10 #define rTxAGC_A_Mcs07_Mcs04 0xe14 -#define rTxAGC_A_Mcs11_Mcs08 0xe18 -#define rTxAGC_A_Mcs15_Mcs12 0xe1c #define rFPGA0_IQK 0xe28 #define rTx_IQK_Tone_A 0xe30 diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h index 3298fa8eb682..f0b26e44f9b9 100644 --- a/drivers/staging/rtl8723bs/include/hal_data.h +++ b/drivers/staging/rtl8723bs/include/hal_data.h @@ -189,7 +189,6 @@ struct hal_com_data { /* rf_ctrl */ u8 rf_chip; - u8 rf_type; u8 PackageType; u8 NumTotalRFPath; -- cgit v1.2.3 From 24e65aac94578765c8796511e769c08219d52ed9 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:07 +0200 Subject: staging: rtl8723bs: remove rf type branching (fourth patch) remove all function calls to rtw_get_hw_reg made to read HW_VAR_RF_TYPE and get value of rt_type, which is always 1T1R. Clean up code on removal sites, keeping 1T1R code unconditionally. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/8ca2f788c42d81b9cb4dbc46e23c7549dc27d081.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ap.c | 8 +-- drivers/staging/rtl8723bs/core/rtw_debug.c | 18 ++---- drivers/staging/rtl8723bs/core/rtw_ieee80211.c | 73 ++++++----------------- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 6 +- drivers/staging/rtl8723bs/core/rtw_mlme.c | 36 ++--------- drivers/staging/rtl8723bs/core/rtw_wlan_util.c | 38 ++---------- drivers/staging/rtl8723bs/hal/hal_com.c | 8 +-- drivers/staging/rtl8723bs/include/ieee80211.h | 2 +- drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c | 23 ++----- 9 files changed, 44 insertions(+), 168 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ap.c b/drivers/staging/rtl8723bs/core/rtw_ap.c index 69a55482e8a0..6064dd6a76b4 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ap.c +++ b/drivers/staging/rtl8723bs/core/rtw_ap.c @@ -1034,7 +1034,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->ie_length - _BEACON_IE_OFFSET_) ); if (p && ie_len > 0) { - u8 rf_type = 0; u8 max_rx_ampdu_factor = 0; struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p + 2); @@ -1080,11 +1079,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) IEEE80211_HT_CAP_AMPDU_FACTOR & max_rx_ampdu_factor ); /* set Max Rx AMPDU size to 64K */ - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - if (rf_type == RF_1T1R) { - pht_cap->mcs.rx_mask[0] = 0xff; - pht_cap->mcs.rx_mask[1] = 0x0; - } + pht_cap->mcs.rx_mask[0] = 0xff; + pht_cap->mcs.rx_mask[1] = 0x0; memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); } diff --git a/drivers/staging/rtl8723bs/core/rtw_debug.c b/drivers/staging/rtl8723bs/core/rtw_debug.c index 76ad1122f89f..5354fdd11c9b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_debug.c +++ b/drivers/staging/rtl8723bs/core/rtw_debug.c @@ -58,21 +58,11 @@ static void dump_4_rf_regs(struct adapter *adapter, int path, int offset) void rf_reg_dump(struct adapter *adapter) { - int i, path; - u8 rf_type = 0; - u8 path_nums = 0; - - rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - if ((RF_1T2R == rf_type) || (RF_1T1R == rf_type)) - path_nums = 1; - else - path_nums = 2; + int i, path = 0; netdev_dbg(adapter->pnetdev, "======= RF REG =======\n"); - for (path = 0; path < path_nums; path++) { - netdev_dbg(adapter->pnetdev, "RF_Path(%x)\n", path); - for (i = 0; i < 0x100; i++) - dump_4_rf_regs(adapter, path, i); - } + netdev_dbg(adapter->pnetdev, "RF_Path(%x)\n", path); + for (i = 0; i < 0x100; i++) + dump_4_rf_regs(adapter, path, i); } diff --git a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c index 795eafb7d6ff..b449be537376 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ieee80211.c +++ b/drivers/staging/rtl8723bs/core/rtw_ieee80211.c @@ -1106,64 +1106,27 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork) } /* show MCS rate, unit: 100Kbps */ -u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate) +u16 rtw_mcs_rate(u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate) { u16 max_rate = 0; - if (rf_type == RF_1T1R) { - if (MCS_rate[0] & BIT(7)) - max_rate = (bw_40MHz) ? ((short_GI)?1500:1350):((short_GI)?722:650); - else if (MCS_rate[0] & BIT(6)) - max_rate = (bw_40MHz) ? ((short_GI)?1350:1215):((short_GI)?650:585); - else if (MCS_rate[0] & BIT(5)) - max_rate = (bw_40MHz) ? ((short_GI)?1200:1080):((short_GI)?578:520); - else if (MCS_rate[0] & BIT(4)) - max_rate = (bw_40MHz) ? ((short_GI)?900:810):((short_GI)?433:390); - else if (MCS_rate[0] & BIT(3)) - max_rate = (bw_40MHz) ? ((short_GI)?600:540):((short_GI)?289:260); - else if (MCS_rate[0] & BIT(2)) - max_rate = (bw_40MHz) ? ((short_GI)?450:405):((short_GI)?217:195); - else if (MCS_rate[0] & BIT(1)) - max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); - else if (MCS_rate[0] & BIT(0)) - max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); - } else { - if (MCS_rate[1]) { - if (MCS_rate[1] & BIT(7)) - max_rate = (bw_40MHz) ? ((short_GI)?3000:2700):((short_GI)?1444:1300); - else if (MCS_rate[1] & BIT(6)) - max_rate = (bw_40MHz) ? ((short_GI)?2700:2430):((short_GI)?1300:1170); - else if (MCS_rate[1] & BIT(5)) - max_rate = (bw_40MHz) ? ((short_GI)?2400:2160):((short_GI)?1156:1040); - else if (MCS_rate[1] & BIT(4)) - max_rate = (bw_40MHz) ? ((short_GI)?1800:1620):((short_GI)?867:780); - else if (MCS_rate[1] & BIT(3)) - max_rate = (bw_40MHz) ? ((short_GI)?1200:1080):((short_GI)?578:520); - else if (MCS_rate[1] & BIT(2)) - max_rate = (bw_40MHz) ? ((short_GI)?900:810):((short_GI)?433:390); - else if (MCS_rate[1] & BIT(1)) - max_rate = (bw_40MHz) ? ((short_GI)?600:540):((short_GI)?289:260); - else if (MCS_rate[1] & BIT(0)) - max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); - } else { - if (MCS_rate[0] & BIT(7)) - max_rate = (bw_40MHz) ? ((short_GI)?1500:1350):((short_GI)?722:650); - else if (MCS_rate[0] & BIT(6)) - max_rate = (bw_40MHz) ? ((short_GI)?1350:1215):((short_GI)?650:585); - else if (MCS_rate[0] & BIT(5)) - max_rate = (bw_40MHz) ? ((short_GI)?1200:1080):((short_GI)?578:520); - else if (MCS_rate[0] & BIT(4)) - max_rate = (bw_40MHz) ? ((short_GI)?900:810):((short_GI)?433:390); - else if (MCS_rate[0] & BIT(3)) - max_rate = (bw_40MHz) ? ((short_GI)?600:540):((short_GI)?289:260); - else if (MCS_rate[0] & BIT(2)) - max_rate = (bw_40MHz) ? ((short_GI)?450:405):((short_GI)?217:195); - else if (MCS_rate[0] & BIT(1)) - max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); - else if (MCS_rate[0] & BIT(0)) - max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); - } - } + if (MCS_rate[0] & BIT(7)) + max_rate = (bw_40MHz) ? ((short_GI)?1500:1350):((short_GI)?722:650); + else if (MCS_rate[0] & BIT(6)) + max_rate = (bw_40MHz) ? ((short_GI)?1350:1215):((short_GI)?650:585); + else if (MCS_rate[0] & BIT(5)) + max_rate = (bw_40MHz) ? ((short_GI)?1200:1080):((short_GI)?578:520); + else if (MCS_rate[0] & BIT(4)) + max_rate = (bw_40MHz) ? ((short_GI)?900:810):((short_GI)?433:390); + else if (MCS_rate[0] & BIT(3)) + max_rate = (bw_40MHz) ? ((short_GI)?600:540):((short_GI)?289:260); + else if (MCS_rate[0] & BIT(2)) + max_rate = (bw_40MHz) ? ((short_GI)?450:405):((short_GI)?217:195); + else if (MCS_rate[0] & BIT(1)) + max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); + else if (MCS_rate[0] & BIT(0)) + max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); + return max_rate; } diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 0152491455a2..5f25cbf83723 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -541,7 +541,6 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; struct sta_info *psta = NULL; u8 short_GI = 0; - u8 rf_type = 0; if ((check_fwstate(pmlmepriv, _FW_LINKED) != true) && (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != true)) @@ -554,10 +553,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) short_GI = query_ra_short_GI(psta); if (is_supported_ht(psta->wireless_mode)) { - rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - - max_rate = rtw_mcs_rate(rf_type, - ((psta->bw_mode == CHANNEL_WIDTH_40)?1:0), + max_rate = rtw_mcs_rate(psta->bw_mode == CHANNEL_WIDTH_40 ? 1 : 0, short_GI, psta->htpriv.ht_cap.mcs.rx_mask); } else { diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index e0cee51224ff..ab6a24d70cc9 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c @@ -2313,7 +2313,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ enum ieee80211_max_ampdu_length_exp max_rx_ampdu_factor; unsigned char *p; struct ieee80211_ht_cap ht_capie; - u8 cbw40_enable = 0, stbc_rx_enable = 0, rf_type = 0, operation_bw = 0; + u8 cbw40_enable = 0, stbc_rx_enable = 0, operation_bw = 0; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -2392,25 +2392,10 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ memcpy(&ht_capie.mcs, pmlmeext->default_supported_mcs_set, 16); /* update default supported_mcs_set */ - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); + if (stbc_rx_enable) + ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_1R);/* RX STBC One spatial stream */ - switch (rf_type) { - case RF_1T1R: - if (stbc_rx_enable) - ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_1R);/* RX STBC One spatial stream */ - - set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_1R); - break; - - case RF_2T2R: - case RF_1T2R: - default: - if (stbc_rx_enable) - ht_capie.cap_info |= cpu_to_le16(IEEE80211_HT_CAP_RX_STBC_2R);/* RX STBC two spatial stream */ - - set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_2R); - break; - } + set_mcs_rate_by_mask(ht_capie.mcs.rx_mask, MCS_RATE_1R); { u32 rx_packet_offset, max_recvbuf_sz; @@ -2510,24 +2495,13 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len, u8 channe (le16_to_cpu(pmlmeinfo->HT_caps.u.HT_cap_element.HT_caps_info) & BIT(1)) && (pmlmeinfo->HT_info.infos[0] & BIT(2))) { int i; - u8 rf_type; - - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); /* update the MCS set */ for (i = 0; i < 16; i++) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= pmlmeext->default_supported_mcs_set[i]; /* update the MCS rates */ - switch (rf_type) { - case RF_1T1R: - case RF_1T2R: - set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); - break; - case RF_2T2R: - default: - set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); - } + set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); /* switch to the 40M Hz mode according to the AP */ /* pmlmeext->cur_bwmode = CHANNEL_WIDTH_40; */ diff --git a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c index 170536986476..18ba846c0b7b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_wlan_util.c +++ b/drivers/staging/rtl8723bs/core/rtw_wlan_util.c @@ -46,16 +46,7 @@ static u8 rtw_basic_rate_ofdm[3] = { u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta) { - u8 raid, cur_rf_type, rf_type = RF_1T1R; - - rtw_hal_get_hwreg(adapter, HW_VAR_RF_TYPE, (u8 *)(&cur_rf_type)); - - if (cur_rf_type == RF_1T1R) { - rf_type = RF_1T1R; - } else if (is_supported_ht(psta->wireless_mode)) { - if (psta->ra_mask & 0xfff00000) - rf_type = RF_2T2R; - } + u8 raid; switch (psta->wireless_mode) { case WIRELESS_11B: @@ -69,23 +60,14 @@ u8 networktype_to_raid_ex(struct adapter *adapter, struct sta_info *psta) break; case WIRELESS_11_24N: case WIRELESS_11G_24N: - if (rf_type == RF_2T2R) - raid = RATEID_IDX_GN_N2SS; - else - raid = RATEID_IDX_GN_N1SS; + raid = RATEID_IDX_GN_N1SS; break; case WIRELESS_11B_24N: case WIRELESS_11BG_24N: if (psta->bw_mode == CHANNEL_WIDTH_20) { - if (rf_type == RF_2T2R) - raid = RATEID_IDX_BGN_20M_2SS_BN; - else - raid = RATEID_IDX_BGN_20M_1SS_BN; + raid = RATEID_IDX_BGN_20M_1SS_BN; } else { - if (rf_type == RF_2T2R) - raid = RATEID_IDX_BGN_40M_2SS; - else - raid = RATEID_IDX_BGN_40M_1SS; + raid = RATEID_IDX_BGN_40M_1SS; } break; default: @@ -982,7 +964,6 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_80211_var_ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) { unsigned int i; - u8 rf_type; u8 max_AMPDU_len, min_MPDU_spacing; u8 cur_ldpc_cap = 0, cur_stbc_cap = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; @@ -1018,22 +999,13 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_80211_var_ie *pIE) pmlmeinfo->HT_caps.u.HT_cap_element.AMPDU_para = max_AMPDU_len | min_MPDU_spacing; } } - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); /* update the MCS set */ for (i = 0; i < 16; i++) pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate[i] &= pmlmeext->default_supported_mcs_set[i]; /* update the MCS rates */ - switch (rf_type) { - case RF_1T1R: - case RF_1T2R: - set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); - break; - case RF_2T2R: - default: - set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_2R); - } + set_mcs_rate_by_mask(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_RATE_1R); if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* Config STBC setting */ diff --git a/drivers/staging/rtl8723bs/hal/hal_com.c b/drivers/staging/rtl8723bs/hal/hal_com.c index 8964303a619f..909b37bcc897 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com.c +++ b/drivers/staging/rtl8723bs/hal/hal_com.c @@ -545,7 +545,7 @@ u8 rtw_get_mgntframe_raid(struct adapter *adapter, unsigned char network_type) void rtw_hal_update_sta_rate_mask(struct adapter *padapter, struct sta_info *psta) { - u8 i, rf_type, limit; + u8 i, limit; u32 tx_ra_bitmap; if (!psta) @@ -561,11 +561,7 @@ void rtw_hal_update_sta_rate_mask(struct adapter *padapter, struct sta_info *pst /* n mode ra_bitmap */ if (psta->htpriv.ht_option) { - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - if (rf_type == RF_2T2R) - limit = 16; /* 2R */ - else - limit = 8; /* 1R */ + limit = 8; /* 1R */ for (i = 0; i < limit; i++) { if (psta->htpriv.ht_cap.mcs.rx_mask[i/8] & BIT(i%8)) diff --git a/drivers/staging/rtl8723bs/include/ieee80211.h b/drivers/staging/rtl8723bs/include/ieee80211.h index 89851fa36830..d6236f5b069d 100644 --- a/drivers/staging/rtl8723bs/include/ieee80211.h +++ b/drivers/staging/rtl8723bs/include/ieee80211.h @@ -779,7 +779,7 @@ void rtw_get_bcn_info(struct wlan_network *pnetwork); void rtw_macaddr_cfg(struct device *dev, u8 *mac_addr); -u16 rtw_mcs_rate(u8 rf_type, u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate); +u16 rtw_mcs_rate(u8 bw_40MHz, u8 short_GI, unsigned char *MCS_rate); int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *action); const char *action_public_str(u8 action); diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c index 62eb64e447a4..499ac3a77512 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c @@ -2755,7 +2755,7 @@ exit: return ret; } -static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum nl80211_band band, u8 rf_type) +static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum nl80211_band band) { #define MAX_BIT_RATE_40MHZ_MCS15 300 /* Mbps */ @@ -2788,34 +2788,23 @@ static void rtw_cfg80211_init_ht_capab(struct ieee80211_sta_ht_cap *ht_cap, enum *if BW_40 rx_mask[4]= 0x01; *highest supported RX rate */ - if (rf_type == RF_1T1R) { - ht_cap->mcs.rx_mask[0] = 0xFF; - ht_cap->mcs.rx_mask[1] = 0x00; - ht_cap->mcs.rx_mask[4] = 0x01; + ht_cap->mcs.rx_mask[0] = 0xFF; + ht_cap->mcs.rx_mask[1] = 0x00; + ht_cap->mcs.rx_mask[4] = 0x01; - ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7); - } else if ((rf_type == RF_1T2R) || (rf_type == RF_2T2R)) { - ht_cap->mcs.rx_mask[0] = 0xFF; - ht_cap->mcs.rx_mask[1] = 0xFF; - ht_cap->mcs.rx_mask[4] = 0x01; - - ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS15); - } + ht_cap->mcs.rx_highest = cpu_to_le16(MAX_BIT_RATE_40MHZ_MCS7); } void rtw_cfg80211_init_wiphy(struct adapter *padapter) { - u8 rf_type; struct ieee80211_supported_band *bands; struct wireless_dev *pwdev = padapter->rtw_wdev; struct wiphy *wiphy = pwdev->wiphy; - rtw_hal_get_hwreg(padapter, HW_VAR_RF_TYPE, (u8 *)(&rf_type)); - { bands = wiphy->bands[NL80211_BAND_2GHZ]; if (bands) - rtw_cfg80211_init_ht_capab(&bands->ht_cap, NL80211_BAND_2GHZ, rf_type); + rtw_cfg80211_init_ht_capab(&bands->ht_cap, NL80211_BAND_2GHZ); } /* copy mac_addr to wiphy */ -- cgit v1.2.3 From 05d7d4ba4bcc0bbadf6f5ecfb27612d8c6994bea Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:08 +0200 Subject: staging: rtl8723bs: remove unused rtw_rf_config module param remove unused rtw_rf_config module param and struct field used to store the param value. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/a83eaa9b2350d3d16f5b1dddc40870e0f0a6df06.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/drv_types.h | 1 - drivers/staging/rtl8723bs/os_dep/os_intfs.c | 4 ---- 2 files changed, 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index d49009c75d2e..580028d28c42 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -132,7 +132,6 @@ struct registry_priv { u8 lowrate_two_xmit; - u8 rf_config; u8 low_power; u8 wifi_spec;/* !turbo_mode */ diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 128c64e0f0ab..7728eabdfe48 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -89,8 +89,6 @@ static int rtw_beamform_cap = 0x2; static int rtw_lowrate_two_xmit = 1;/* Use 2 path Tx to transmit MCS0~7 and legacy mode */ -/* int rf_config = RF_1T2R; 1T2R */ -static int rtw_rf_config = RF_MAX_TYPE; /* auto */ static int rtw_low_power; static int rtw_wifi_spec; static int rtw_channel_plan = RT_CHANNEL_DOMAIN_MAX; @@ -144,7 +142,6 @@ module_param(rtw_ampdu_amsdu, int, 0644); module_param(rtw_lowrate_two_xmit, int, 0644); -module_param(rtw_rf_config, int, 0644); module_param(rtw_power_mgnt, int, 0644); module_param(rtw_smart_ps, int, 0644); module_param(rtw_low_power, int, 0644); @@ -249,7 +246,6 @@ static void loadparam(struct adapter *padapter, struct net_device *pnetdev) registry_par->beamform_cap = (u8)rtw_beamform_cap; registry_par->lowrate_two_xmit = (u8)rtw_lowrate_two_xmit; - registry_par->rf_config = (u8)rtw_rf_config; registry_par->low_power = (u8)rtw_low_power; -- cgit v1.2.3 From 1b09e3886a983b3ba2a092b12a8d85028332b939 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:09 +0200 Subject: staging: rtl8723bs: remove unused macro in include/hal_data.h remove unused macro in include/hal_data.h Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/13b4f41247d1b8bc10f0576d82e4dc9a285d88e1.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/hal_data.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h index f0b26e44f9b9..2bd7a7151db1 100644 --- a/drivers/staging/rtl8723bs/include/hal_data.h +++ b/drivers/staging/rtl8723bs/include/hal_data.h @@ -404,6 +404,5 @@ struct hal_com_data { #define GET_HAL_DATA(__padapter) ((struct hal_com_data *)((__padapter)->HalData)) #define GET_HAL_RFPATH_NUM(__padapter) (((struct hal_com_data *)((__padapter)->HalData))->NumTotalRFPath) #define RT_GetInterfaceSelection(_Adapter) (GET_HAL_DATA(_Adapter)->InterfaceSel) -#define GET_RF_TYPE(__padapter) (GET_HAL_DATA(__padapter)->rf_type) #endif /* __HAL_DATA_H__ */ -- cgit v1.2.3 From da4c99c261bca220f364fc630e8987a60d605e8d Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:10 +0200 Subject: staging: rtl8723bs: remove RF_*TX enum remove RF_*TX enum, its only used value is RF_1TX. So remove it and remove all indexes and loop over these enum items. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/3acc624742a933d90e83a83babb4eecb193cf869.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c | 17 ++- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 120 ++++++++------------- drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c | 3 +- drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h | 9 +- drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c | 2 +- drivers/staging/rtl8723bs/include/hal_com_phycfg.h | 17 +-- drivers/staging/rtl8723bs/include/hal_data.h | 8 +- 7 files changed, 64 insertions(+), 112 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c index 3de8dcb5ed7c..dd0f74b0cf0d 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_BB.c @@ -543,12 +543,12 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG(struct dm_odm_t *pDM_Odm) ******************************************************************************/ static u32 Array_MP_8723B_PHY_REG_PG[] = { - 0, 0, 0x00000e08, 0x0000ff00, 0x00003800, - 0, 0, 0x0000086c, 0xffffff00, 0x32343600, - 0, 0, 0x00000e00, 0xffffffff, 0x40424444, - 0, 0, 0x00000e04, 0xffffffff, 0x28323638, - 0, 0, 0x00000e10, 0xffffffff, 0x38404244, - 0, 0, 0x00000e14, 0xffffffff, 0x26303436 + 0, 0x00000e08, 0x0000ff00, 0x00003800, + 0, 0x0000086c, 0xffffff00, 0x32343600, + 0, 0x00000e00, 0xffffffff, 0x40424444, + 0, 0x00000e04, 0xffffffff, 0x28323638, + 0, 0x00000e10, 0xffffffff, 0x38404244, + 0, 0x00000e14, 0xffffffff, 0x26303436 }; void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(struct dm_odm_t *pDM_Odm) @@ -559,13 +559,12 @@ void ODM_ReadAndConfig_MP_8723B_PHY_REG_PG(struct dm_odm_t *pDM_Odm) pDM_Odm->PhyRegPgVersion = 1; pDM_Odm->PhyRegPgValueType = PHY_REG_PG_EXACT_VALUE; - for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_PHY_REG_PG); i += 5) { + for (i = 0; i < ARRAY_SIZE(Array_MP_8723B_PHY_REG_PG); i += 4) { u32 v1 = Array[i]; u32 v2 = Array[i+1]; u32 v3 = Array[i+2]; u32 v4 = Array[i+3]; - u32 v5 = Array[i+4]; - odm_ConfigBB_PHY_REG_PG_8723B(pDM_Odm, v1, v2, v3, v4, v5); + odm_ConfigBB_PHY_REG_PG_8723B(pDM_Odm, v1, v2, v3, v4); } } diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 4a249d20c661..272a9ec7a2d3 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -11,7 +11,7 @@ #include u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, - u8 TxNum, enum rate_section RateSection) + enum rate_section RateSection) { struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); u8 value = 0; @@ -21,13 +21,13 @@ u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, switch (RateSection) { case CCK: - value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0]; + value = pHalData->TxPwrByRateBase2_4G[RfPath][0]; break; case OFDM: - value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1]; + value = pHalData->TxPwrByRateBase2_4G[RfPath][1]; break; case HT_MCS0_MCS7: - value = pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2]; + value = pHalData->TxPwrByRateBase2_4G[RfPath][2]; break; default: break; @@ -37,13 +37,8 @@ u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, } static void -phy_SetTxPowerByRateBase( - struct adapter *Adapter, - u8 RfPath, - enum rate_section RateSection, - u8 TxNum, - u8 Value -) +phy_SetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, + enum rate_section RateSection, u8 Value) { struct hal_com_data *pHalData = GET_HAL_DATA(Adapter); @@ -52,13 +47,13 @@ phy_SetTxPowerByRateBase( switch (RateSection) { case CCK: - pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][0] = Value; + pHalData->TxPwrByRateBase2_4G[RfPath][0] = Value; break; case OFDM: - pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][1] = Value; + pHalData->TxPwrByRateBase2_4G[RfPath][1] = Value; break; case HT_MCS0_MCS7: - pHalData->TxPwrByRateBase2_4G[RfPath][TxNum][2] = Value; + pHalData->TxPwrByRateBase2_4G[RfPath][2] = Value; break; default: break; @@ -73,14 +68,14 @@ struct adapter *padapter u8 path, base; for (path = RF_PATH_A; path <= RF_PATH_B; ++path) { - base = PHY_GetTxPowerByRate(padapter, path, RF_1TX, MGN_11M); - phy_SetTxPowerByRateBase(padapter, path, CCK, RF_1TX, base); + base = PHY_GetTxPowerByRate(padapter, path, MGN_11M); + phy_SetTxPowerByRateBase(padapter, path, CCK, base); - base = PHY_GetTxPowerByRate(padapter, path, RF_1TX, MGN_54M); - phy_SetTxPowerByRateBase(padapter, path, OFDM, RF_1TX, base); + base = PHY_GetTxPowerByRate(padapter, path, MGN_54M); + phy_SetTxPowerByRateBase(padapter, path, OFDM, base); - base = PHY_GetTxPowerByRate(padapter, path, RF_1TX, MGN_MCS7); - phy_SetTxPowerByRateBase(padapter, path, HT_MCS0_MCS7, RF_1TX, base); + base = PHY_GetTxPowerByRate(padapter, path, MGN_MCS7); + phy_SetTxPowerByRateBase(padapter, path, HT_MCS0_MCS7, base); } } @@ -320,14 +315,8 @@ PHY_GetRateValuesOfTxPowerByRate( } } -static void PHY_StoreTxPowerByRateNew( - struct adapter *padapter, - u32 RfPath, - u32 TxNum, - u32 RegAddr, - u32 BitMask, - u32 Data -) +static void PHY_StoreTxPowerByRateNew(struct adapter *padapter, u32 RfPath, + u32 RegAddr, u32 BitMask, u32 Data) { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); u8 i = 0, rateIndex[4] = {0}, rateNum = 0; @@ -338,11 +327,8 @@ static void PHY_StoreTxPowerByRateNew( if (RfPath >= RF_PATH_MAX) return; - if (TxNum > RF_MAX_TX_NUM) - return; - for (i = 0; i < rateNum; ++i) { - pHalData->TxPwrByRateOffset[RfPath][TxNum][rateIndex[i]] = PwrByRateVal[i]; + pHalData->TxPwrByRateOffset[RfPath][rateIndex[i]] = PwrByRateVal[i]; } } @@ -359,18 +345,16 @@ static void PHY_StoreTxPowerByRateOld( void PHY_InitTxPowerByRate(struct adapter *padapter) { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); - u8 rfPath, TxNum, rate; + u8 rfPath, rate; for (rfPath = 0; rfPath < TX_PWR_BY_RATE_NUM_RF; ++rfPath) - for (TxNum = 0; TxNum < TX_PWR_BY_RATE_NUM_RF; ++TxNum) - for (rate = 0; rate < TX_PWR_BY_RATE_NUM_RATE; ++rate) - pHalData->TxPwrByRateOffset[rfPath][TxNum][rate] = 0; + for (rate = 0; rate < TX_PWR_BY_RATE_NUM_RATE; ++rate) + pHalData->TxPwrByRateOffset[rfPath][rate] = 0; } void PHY_StoreTxPowerByRate( struct adapter *padapter, u32 RfPath, - u32 TxNum, u32 RegAddr, u32 BitMask, u32 Data @@ -380,7 +364,7 @@ void PHY_StoreTxPowerByRate( struct dm_odm_t *pDM_Odm = &pHalData->odmpriv; if (pDM_Odm->PhyRegPgVersion > 0) - PHY_StoreTxPowerByRateNew(padapter, RfPath, TxNum, RegAddr, BitMask, Data); + PHY_StoreTxPowerByRateNew(padapter, RfPath, RegAddr, BitMask, Data); else if (pDM_Odm->PhyRegPgVersion == 0) { PHY_StoreTxPowerByRateOld(padapter, RegAddr, BitMask, Data); } @@ -391,7 +375,7 @@ phy_ConvertTxPowerByRateInDbmToRelativeValues( struct adapter *padapter ) { - u8 base = 0, i = 0, value = 0, path = 0, txNum = 0; + u8 base = 0, i = 0, value = 0, path = 0; u8 cckRates[4] = { MGN_1M, MGN_2M, MGN_5_5M, MGN_11M }; @@ -402,28 +386,25 @@ struct adapter *padapter MGN_MCS0, MGN_MCS1, MGN_MCS2, MGN_MCS3, MGN_MCS4, MGN_MCS5, MGN_MCS6, MGN_MCS7 }; for (path = RF_PATH_A; path < RF_PATH_MAX; ++path) { - for (txNum = RF_1TX; txNum < RF_MAX_TX_NUM; ++txNum) { - /* CCK */ - base = PHY_GetTxPowerByRate(padapter, path, txNum, MGN_11M); - for (i = 0; i < ARRAY_SIZE(cckRates); ++i) { - value = PHY_GetTxPowerByRate(padapter, path, txNum, cckRates[i]); - PHY_SetTxPowerByRate(padapter, path, txNum, cckRates[i], value - base); - } - - /* OFDM */ - base = PHY_GetTxPowerByRate(padapter, path, txNum, MGN_54M); - for (i = 0; i < sizeof(ofdmRates); ++i) { - value = PHY_GetTxPowerByRate(padapter, path, txNum, ofdmRates[i]); - PHY_SetTxPowerByRate(padapter, path, txNum, ofdmRates[i], value - base); - } + /* CCK */ + base = PHY_GetTxPowerByRate(padapter, path, MGN_11M); + for (i = 0; i < ARRAY_SIZE(cckRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, path, cckRates[i]); + PHY_SetTxPowerByRate(padapter, path, cckRates[i], value - base); + } - /* HT MCS0~7 */ - base = PHY_GetTxPowerByRate(padapter, path, txNum, MGN_MCS7); - for (i = 0; i < sizeof(mcs0_7Rates); ++i) { - value = PHY_GetTxPowerByRate(padapter, path, txNum, mcs0_7Rates[i]); - PHY_SetTxPowerByRate(padapter, path, txNum, mcs0_7Rates[i], value - base); - } + /* OFDM */ + base = PHY_GetTxPowerByRate(padapter, path, MGN_54M); + for (i = 0; i < sizeof(ofdmRates); ++i) { + value = PHY_GetTxPowerByRate(padapter, path, ofdmRates[i]); + PHY_SetTxPowerByRate(padapter, path, ofdmRates[i], value - base); + } + /* HT MCS0~7 */ + base = PHY_GetTxPowerByRate(padapter, path, MGN_MCS7); + for (i = 0; i < sizeof(mcs0_7Rates); ++i) { + value = PHY_GetTxPowerByRate(padapter, path, mcs0_7Rates[i]); + PHY_SetTxPowerByRate(padapter, path, mcs0_7Rates[i], value - base); } } } @@ -590,9 +571,7 @@ u8 PHY_GetRateIndexOfTxPowerByRate(u8 Rate) return index; } -s8 PHY_GetTxPowerByRate( - struct adapter *padapter, u8 RFPath, u8 TxNum, u8 Rate -) +s8 PHY_GetTxPowerByRate(struct adapter *padapter, u8 RFPath, u8 Rate) { struct hal_com_data *pHalData = GET_HAL_DATA(padapter); s8 value = 0; @@ -605,20 +584,16 @@ s8 PHY_GetTxPowerByRate( if (RFPath >= RF_PATH_MAX) return value; - if (TxNum >= RF_MAX_TX_NUM) - return value; - if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) return value; - return pHalData->TxPwrByRateOffset[RFPath][TxNum][rateIndex]; + return pHalData->TxPwrByRateOffset[RFPath][rateIndex]; } void PHY_SetTxPowerByRate( struct adapter *padapter, u8 RFPath, - u8 TxNum, u8 Rate, s8 Value ) @@ -629,13 +604,10 @@ void PHY_SetTxPowerByRate( if (RFPath >= RF_PATH_MAX) return; - if (TxNum >= RF_MAX_TX_NUM) - return; - if (rateIndex >= TX_PWR_BY_RATE_NUM_RATE) return; - pHalData->TxPwrByRateOffset[RFPath][TxNum][rateIndex] = Value; + pHalData->TxPwrByRateOffset[RFPath][rateIndex] = Value; } void PHY_SetTxPowerLevelByPath(struct adapter *Adapter, u8 channel, u8 path) @@ -797,11 +769,11 @@ void PHY_ConvertTxPowerLimitToPowerIndex(struct adapter *Adapter) for (rfPath = RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) { if (pHalData->odmpriv.PhyRegPgValueType == PHY_REG_PG_EXACT_VALUE) { if (rateSection == 2) /* HT 1T */ - BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_1TX, HT_MCS0_MCS7); + BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, HT_MCS0_MCS7); else if (rateSection == 1) /* OFDM */ - BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_1TX, OFDM); + BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, OFDM); else if (rateSection == 0) /* CCK */ - BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, RF_1TX, CCK); + BW40PwrBasedBm2_4G = PHY_GetTxPowerByRateBase(Adapter, rfPath, CCK); } else BW40PwrBasedBm2_4G = Adapter->registrypriv.RegPowerBase * 2; diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c index 0f71b1adea40..1df42069bd5c 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c +++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.c @@ -118,7 +118,6 @@ void odm_ConfigBB_AGC_8723B( void odm_ConfigBB_PHY_REG_PG_8723B( struct dm_odm_t *pDM_Odm, u32 RfPath, - u32 TxNum, u32 Addr, u32 Bitmask, u32 Data @@ -127,7 +126,7 @@ void odm_ConfigBB_PHY_REG_PG_8723B( if (Addr == 0xfe || Addr == 0xffe) msleep(50); else { - PHY_StoreTxPowerByRate(pDM_Odm->Adapter, RfPath, TxNum, Addr, Bitmask, Data); + PHY_StoreTxPowerByRate(pDM_Odm->Adapter, RfPath, Addr, Bitmask, Data); } } diff --git a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h index b8d4c2aa6d4d..fba7053ee3e1 100644 --- a/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h +++ b/drivers/staging/rtl8723bs/hal/odm_RegConfig8723B.h @@ -24,13 +24,8 @@ void odm_ConfigBB_AGC_8723B(struct dm_odm_t *pDM_Odm, u32 Data ); -void odm_ConfigBB_PHY_REG_PG_8723B(struct dm_odm_t *pDM_Odm, - u32 RfPath, - u32 TxNum, - u32 Addr, - u32 Bitmask, - u32 Data -); +void odm_ConfigBB_PHY_REG_PG_8723B(struct dm_odm_t *pDM_Odm, u32 RfPath, u32 Addr, + u32 Bitmask, u32 Data); void odm_ConfigBB_PHY_8723B(struct dm_odm_t *pDM_Odm, u32 Addr, diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c index 4b362320ce31..a3bff27af523 100644 --- a/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/rtl8723b_phycfg.c @@ -538,7 +538,7 @@ u8 PHY_GetTxPowerIndex( s8 txPower = 0, powerDiffByRate = 0, limit = 0; txPower = (s8) PHY_GetTxPowerIndexBase(padapter, RFPath, Rate, BandWidth, Channel); - powerDiffByRate = PHY_GetTxPowerByRate(padapter, RF_PATH_A, RF_1TX, Rate); + powerDiffByRate = PHY_GetTxPowerByRate(padapter, RF_PATH_A, Rate); limit = phy_get_tx_pwr_lmt( padapter, diff --git a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h index 637089fed93d..cb7c7ed74146 100644 --- a/drivers/staging/rtl8723bs/include/hal_com_phycfg.h +++ b/drivers/staging/rtl8723bs/include/hal_com_phycfg.h @@ -18,15 +18,6 @@ enum rate_section { HT_MCS0_MCS7, }; -enum { - RF_1TX = 0, - RF_2TX, - RF_3TX, - RF_4TX, - RF_MAX_TX_NUM, - RF_TX_NUM_NONIMPLEMENT, -}; - #define MAX_POWER_INDEX 0x3F enum { @@ -63,7 +54,7 @@ struct bb_register_def { }; -u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, u8 TxNum, +u8 PHY_GetTxPowerByRateBase(struct adapter *Adapter, u8 RfPath, enum rate_section RateSection); u8 PHY_GetRateSectionIndexOfTxPowerByRate(struct adapter *padapter, u32 RegAddr, @@ -78,9 +69,9 @@ u8 PHY_GetRateIndexOfTxPowerByRate(u8 Rate); void PHY_SetTxPowerIndexByRateSection(struct adapter *padapter, u8 RFPath, u8 Channel, u8 RateSection); -s8 PHY_GetTxPowerByRate(struct adapter *padapter, u8 RFPath, u8 TxNum, u8 RateIndex); +s8 PHY_GetTxPowerByRate(struct adapter *padapter, u8 RFPath, u8 RateIndex); -void PHY_SetTxPowerByRate(struct adapter *padapter, u8 RFPath, u8 TxNum, u8 Rate, +void PHY_SetTxPowerByRate(struct adapter *padapter, u8 RFPath, u8 Rate, s8 Value); void PHY_SetTxPowerLevelByPath(struct adapter *Adapter, u8 channel, u8 path); @@ -91,7 +82,7 @@ void PHY_SetTxPowerIndexByRateArray(struct adapter *padapter, u8 RFPath, void PHY_InitTxPowerByRate(struct adapter *padapter); -void PHY_StoreTxPowerByRate(struct adapter *padapter, u32 RfPath, u32 TxNum, +void PHY_StoreTxPowerByRate(struct adapter *padapter, u32 RfPath, u32 RegAddr, u32 BitMask, u32 Data); void PHY_TxPowerByRateConfiguration(struct adapter *padapter); diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h index 2bd7a7151db1..7bbf81ce3045 100644 --- a/drivers/staging/rtl8723bs/include/hal_data.h +++ b/drivers/staging/rtl8723bs/include/hal_data.h @@ -241,9 +241,7 @@ struct hal_com_data { /* CCK = 0 OFDM = 1/2 HT-MCS 0-15 =3/4/56 VHT =7/8/9/10/11 */ u8 TxPwrByRateTable; u8 TxPwrByRateBand; - s8 TxPwrByRateOffset[TX_PWR_BY_RATE_NUM_RF] - [TX_PWR_BY_RATE_NUM_RF] - [TX_PWR_BY_RATE_NUM_RATE]; + s8 TxPwrByRateOffset[TX_PWR_BY_RATE_NUM_RF][TX_PWR_BY_RATE_NUM_RATE]; /* */ /* 2 Power Limit Table */ @@ -261,9 +259,7 @@ struct hal_com_data { [MAX_RF_PATH_NUM]; /* Store the original power by rate value of the base of each rate section of rf path A & B */ - u8 TxPwrByRateBase2_4G[TX_PWR_BY_RATE_NUM_RF] - [TX_PWR_BY_RATE_NUM_RF] - [MAX_BASE_NUM_IN_PHY_REG_PG_2_4G]; + u8 TxPwrByRateBase2_4G[TX_PWR_BY_RATE_NUM_RF][MAX_BASE_NUM_IN_PHY_REG_PG_2_4G]; /* For power group */ u8 PwrGroupHT20[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER]; -- cgit v1.2.3 From c4c7c7182ea4dc15d4fe53b5e9611c1fd35e1c57 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:11 +0200 Subject: staging: rtl8723bs: use MAX_RF_PATH_NUM as ceiling to rf path index use MAX_RF_PATH_NUM as ceiling to rf path index. Only 2 rf paths are used, not 4. Remove also TX_POWER_BY_RATE_NUM_RF left unused. Use RF_PATH_A as loop starting point instead of hardcoded 0, as in other places. Related comments modified accordingly. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/88da23cef57131b39a63b2757b91f959553dd65d.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 2 +- drivers/staging/rtl8723bs/include/hal_data.h | 12 +++++------- drivers/staging/rtl8723bs/include/hal_pg.h | 8 +++----- 3 files changed, 9 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 272a9ec7a2d3..14f34e38a327 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -347,7 +347,7 @@ void PHY_InitTxPowerByRate(struct adapter *padapter) struct hal_com_data *pHalData = GET_HAL_DATA(padapter); u8 rfPath, rate; - for (rfPath = 0; rfPath < TX_PWR_BY_RATE_NUM_RF; ++rfPath) + for (rfPath = RF_PATH_A; rfPath < MAX_RF_PATH_NUM; ++rfPath) for (rate = 0; rate < TX_PWR_BY_RATE_NUM_RATE; ++rate) pHalData->TxPwrByRateOffset[rfPath][rate] = 0; } diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h index 7bbf81ce3045..db9d7587c20e 100644 --- a/drivers/staging/rtl8723bs/include/hal_data.h +++ b/drivers/staging/rtl8723bs/include/hal_data.h @@ -234,14 +234,12 @@ struct hal_com_data { u8 TxPwrInPercentage; u8 TxPwrCalibrateRate; - /* TX power by rate table at most 4RF path. */ - /* The register is */ - /* VHT TX power by rate off setArray = */ - /* RF: at most 4*4 = ABCD = 0/1/2/3 */ - /* CCK = 0 OFDM = 1/2 HT-MCS 0-15 =3/4/56 VHT =7/8/9/10/11 */ + /* TX power by rate table */ + /* RF: at most 2 = AB = 0/1 */ + /* CCK = 0 OFDM = 1 HT-MCS 0-7 = 2 */ u8 TxPwrByRateTable; u8 TxPwrByRateBand; - s8 TxPwrByRateOffset[TX_PWR_BY_RATE_NUM_RF][TX_PWR_BY_RATE_NUM_RATE]; + s8 TxPwrByRateOffset[MAX_RF_PATH_NUM][TX_PWR_BY_RATE_NUM_RATE]; /* */ /* 2 Power Limit Table */ @@ -259,7 +257,7 @@ struct hal_com_data { [MAX_RF_PATH_NUM]; /* Store the original power by rate value of the base of each rate section of rf path A & B */ - u8 TxPwrByRateBase2_4G[TX_PWR_BY_RATE_NUM_RF][MAX_BASE_NUM_IN_PHY_REG_PG_2_4G]; + u8 TxPwrByRateBase2_4G[MAX_RF_PATH_NUM][MAX_BASE_NUM_IN_PHY_REG_PG_2_4G]; /* For power group */ u8 PwrGroupHT20[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER]; diff --git a/drivers/staging/rtl8723bs/include/hal_pg.h b/drivers/staging/rtl8723bs/include/hal_pg.h index 2d8ccc9ddebb..7cb9c441fc01 100644 --- a/drivers/staging/rtl8723bs/include/hal_pg.h +++ b/drivers/staging/rtl8723bs/include/hal_pg.h @@ -14,11 +14,9 @@ */ #define MAX_TX_COUNT 4 -/* For VHT series TX power by rate table. */ -/* VHT TX power by rate off setArray = */ -/* RF: at most 4*4 = ABCD = 0/1/2/3 */ -/* CCK = 0 OFDM = 1/2 HT-MCS 0-15 =3/4/56 VHT =7/8/9/10/11 */ -#define TX_PWR_BY_RATE_NUM_RF 4 +/* TX power by rate table. */ +/* RF: = AB = 0/1 */ +/* CCK = 0 OFDM = 1 HT-MCS 0-7 = 2 */ #define TX_PWR_BY_RATE_NUM_RATE 84 #define MAX_RF_PATH_NUM 2 #define MAX_CHNL_GROUP_24G 6 -- cgit v1.2.3 From 854a3b21ddd95157f444a60cf73950851fcd05dd Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:12 +0200 Subject: staging: rtl8723bs: fix tx power tables size fix sizes of tx power tables to the real used values (i.e. 2 bandwidth, 3 rate sections). Delete MAX_BASE_NUM_IN_PHY_REG_PG_2_4 macro in this process, for it expands to a larger than needed rate section index value. Modify comments accordingly. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/5f52295a8b17f68ad80ffb7b6301da83bfc11a68.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c | 86 +----------------------- drivers/staging/rtl8723bs/hal/hal_com_phycfg.c | 10 --- drivers/staging/rtl8723bs/include/hal_data.h | 8 +-- 3 files changed, 4 insertions(+), 100 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c index 00d429977ea9..efc68c17b126 100644 --- a/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c +++ b/drivers/staging/rtl8723bs/hal/HalHWImg8723B_RF.c @@ -494,48 +494,6 @@ static u8 *Array_MP_8723B_TXPWR_LMT[] = { "FCC", "20M", "HT", "1T", "14", "63", "ETSI", "20M", "HT", "1T", "14", "63", "MKK", "20M", "HT", "1T", "14", "63", - "FCC", "20M", "HT", "2T", "01", "30", - "ETSI", "20M", "HT", "2T", "01", "32", - "MKK", "20M", "HT", "2T", "01", "32", - "FCC", "20M", "HT", "2T", "02", "32", - "ETSI", "20M", "HT", "2T", "02", "32", - "MKK", "20M", "HT", "2T", "02", "32", - "FCC", "20M", "HT", "2T", "03", "32", - "ETSI", "20M", "HT", "2T", "03", "32", - "MKK", "20M", "HT", "2T", "03", "32", - "FCC", "20M", "HT", "2T", "04", "32", - "ETSI", "20M", "HT", "2T", "04", "32", - "MKK", "20M", "HT", "2T", "04", "32", - "FCC", "20M", "HT", "2T", "05", "32", - "ETSI", "20M", "HT", "2T", "05", "32", - "MKK", "20M", "HT", "2T", "05", "32", - "FCC", "20M", "HT", "2T", "06", "32", - "ETSI", "20M", "HT", "2T", "06", "32", - "MKK", "20M", "HT", "2T", "06", "32", - "FCC", "20M", "HT", "2T", "07", "32", - "ETSI", "20M", "HT", "2T", "07", "32", - "MKK", "20M", "HT", "2T", "07", "32", - "FCC", "20M", "HT", "2T", "08", "32", - "ETSI", "20M", "HT", "2T", "08", "32", - "MKK", "20M", "HT", "2T", "08", "32", - "FCC", "20M", "HT", "2T", "09", "32", - "ETSI", "20M", "HT", "2T", "09", "32", - "MKK", "20M", "HT", "2T", "09", "32", - "FCC", "20M", "HT", "2T", "10", "32", - "ETSI", "20M", "HT", "2T", "10", "32", - "MKK", "20M", "HT", "2T", "10", "32", - "FCC", "20M", "HT", "2T", "11", "30", - "ETSI", "20M", "HT", "2T", "11", "32", - "MKK", "20M", "HT", "2T", "11", "32", - "FCC", "20M", "HT", "2T", "12", "63", - "ETSI", "20M", "HT", "2T", "12", "32", - "MKK", "20M", "HT", "2T", "12", "32", - "FCC", "20M", "HT", "2T", "13", "63", - "ETSI", "20M", "HT", "2T", "13", "32", - "MKK", "20M", "HT", "2T", "13", "32", - "FCC", "20M", "HT", "2T", "14", "63", - "ETSI", "20M", "HT", "2T", "14", "63", - "MKK", "20M", "HT", "2T", "14", "63", "FCC", "40M", "HT", "1T", "01", "63", "ETSI", "40M", "HT", "1T", "01", "63", "MKK", "40M", "HT", "1T", "01", "63", @@ -577,49 +535,7 @@ static u8 *Array_MP_8723B_TXPWR_LMT[] = { "MKK", "40M", "HT", "1T", "13", "32", "FCC", "40M", "HT", "1T", "14", "63", "ETSI", "40M", "HT", "1T", "14", "63", - "MKK", "40M", "HT", "1T", "14", "63", - "FCC", "40M", "HT", "2T", "01", "63", - "ETSI", "40M", "HT", "2T", "01", "63", - "MKK", "40M", "HT", "2T", "01", "63", - "FCC", "40M", "HT", "2T", "02", "63", - "ETSI", "40M", "HT", "2T", "02", "63", - "MKK", "40M", "HT", "2T", "02", "63", - "FCC", "40M", "HT", "2T", "03", "30", - "ETSI", "40M", "HT", "2T", "03", "30", - "MKK", "40M", "HT", "2T", "03", "30", - "FCC", "40M", "HT", "2T", "04", "32", - "ETSI", "40M", "HT", "2T", "04", "30", - "MKK", "40M", "HT", "2T", "04", "30", - "FCC", "40M", "HT", "2T", "05", "32", - "ETSI", "40M", "HT", "2T", "05", "30", - "MKK", "40M", "HT", "2T", "05", "30", - "FCC", "40M", "HT", "2T", "06", "32", - "ETSI", "40M", "HT", "2T", "06", "30", - "MKK", "40M", "HT", "2T", "06", "30", - "FCC", "40M", "HT", "2T", "07", "32", - "ETSI", "40M", "HT", "2T", "07", "30", - "MKK", "40M", "HT", "2T", "07", "30", - "FCC", "40M", "HT", "2T", "08", "32", - "ETSI", "40M", "HT", "2T", "08", "30", - "MKK", "40M", "HT", "2T", "08", "30", - "FCC", "40M", "HT", "2T", "09", "32", - "ETSI", "40M", "HT", "2T", "09", "30", - "MKK", "40M", "HT", "2T", "09", "30", - "FCC", "40M", "HT", "2T", "10", "32", - "ETSI", "40M", "HT", "2T", "10", "30", - "MKK", "40M", "HT", "2T", "10", "30", - "FCC", "40M", "HT", "2T", "11", "30", - "ETSI", "40M", "HT", "2T", "11", "30", - "MKK", "40M", "HT", "2T", "11", "30", - "FCC", "40M", "HT", "2T", "12", "63", - "ETSI", "40M", "HT", "2T", "12", "32", - "MKK", "40M", "HT", "2T", "12", "32", - "FCC", "40M", "HT", "2T", "13", "63", - "ETSI", "40M", "HT", "2T", "13", "32", - "MKK", "40M", "HT", "2T", "13", "32", - "FCC", "40M", "HT", "2T", "14", "63", - "ETSI", "40M", "HT", "2T", "14", "63", - "MKK", "40M", "HT", "2T", "14", "63" + "MKK", "40M", "HT", "1T", "14", "63" }; void ODM_ReadAndConfig_MP_8723B_TXPWR_LMT(struct dm_odm_t *pDM_Odm) diff --git a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c index 14f34e38a327..3e814a15e893 100644 --- a/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c +++ b/drivers/staging/rtl8723bs/hal/hal_com_phycfg.c @@ -836,12 +836,6 @@ void PHY_SetTxPowerLimit( rateSection = 1; else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("1T"), 2)) rateSection = 2; - else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("2T"), 2)) - rateSection = 3; - else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("3T"), 2)) - rateSection = 4; - else if (eqNByte(RateSection, (u8 *)("HT"), 2) && eqNByte(RfPath, (u8 *)("4T"), 2)) - rateSection = 5; else return; @@ -849,10 +843,6 @@ void PHY_SetTxPowerLimit( bandwidth = 0; else if (eqNByte(Bandwidth, (u8 *)("40M"), 3)) bandwidth = 1; - else if (eqNByte(Bandwidth, (u8 *)("80M"), 3)) - bandwidth = 2; - else if (eqNByte(Bandwidth, (u8 *)("160M"), 4)) - bandwidth = 3; channelIndex = phy_GetChannelIndexOfTxPowerLimit(channel); diff --git a/drivers/staging/rtl8723bs/include/hal_data.h b/drivers/staging/rtl8723bs/include/hal_data.h index db9d7587c20e..b87c90f693ec 100644 --- a/drivers/staging/rtl8723bs/include/hal_data.h +++ b/drivers/staging/rtl8723bs/include/hal_data.h @@ -52,10 +52,8 @@ enum rt_ampdu_burst { /* Tx Power Limit Table Size */ #define MAX_REGULATION_NUM 4 -#define MAX_2_4G_BANDWIDTH_NUM 4 -#define MAX_RATE_SECTION_NUM 10 - -#define MAX_BASE_NUM_IN_PHY_REG_PG_2_4G 10 /* CCK:1, OFDM:1, HT:4, VHT:4 */ +#define MAX_2_4G_BANDWIDTH_NUM 2 +#define MAX_RATE_SECTION_NUM 3 /* CCK:1, OFDM:1, HT:1 */ /* duplicate code, will move to ODM ######### */ /* define IQK_MAC_REG_NUM 4 */ @@ -257,7 +255,7 @@ struct hal_com_data { [MAX_RF_PATH_NUM]; /* Store the original power by rate value of the base of each rate section of rf path A & B */ - u8 TxPwrByRateBase2_4G[MAX_RF_PATH_NUM][MAX_BASE_NUM_IN_PHY_REG_PG_2_4G]; + u8 TxPwrByRateBase2_4G[MAX_RF_PATH_NUM][MAX_RATE_SECTION_NUM]; /* For power group */ u8 PwrGroupHT20[RF_PATH_MAX_92C_88E][CHANNEL_MAX_NUMBER]; -- cgit v1.2.3 From 96bee36bdf88f10420b27c47702a348dda12b80f Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Sat, 7 Aug 2021 11:48:13 +0200 Subject: staging: rtl8723bs: remove unused RF_*T*R enum remove unused RF_*T*R enum, for rtl8723bs is only capable of 1T1R rf path so selection is not needed. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/2f2f185a80fbec71af4a165180ed0156d194c96e.1628329348.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/include/rtw_rf.h | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/include/rtw_rf.h b/drivers/staging/rtl8723bs/include/rtw_rf.h index 6c25707f4ec8..718275ee4500 100644 --- a/drivers/staging/rtl8723bs/include/rtw_rf.h +++ b/drivers/staging/rtl8723bs/include/rtw_rf.h @@ -97,16 +97,6 @@ enum { HT_DATA_SC_20_LOWER_OF_40MHZ = 2, }; -/* 2007/11/15 MH Define different RF type. */ -enum { - RF_1T2R = 0, - RF_2T4R = 1, - RF_2T2R = 2, - RF_1T1R = 3, - RF_2T2R_GREEN = 4, - RF_MAX_TYPE = 5, -}; - u32 rtw_ch2freq(u32 ch); #endif /* _RTL8711_RF_H_ */ -- cgit v1.2.3 From 4f4991098dd0bd224954d864d807143b2ad78984 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:25 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from usb_intf.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 51 +++---------------------------- 1 file changed, 4 insertions(+), 47 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index b1184c36ddfc..cdd9734adf94 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -200,11 +200,8 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) DBG_88E("NON USB_SPEED_HIGH\n"); } - if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, - ("\n Can't INIT rtw_init_intf_priv\n")); + if (rtw_init_intf_priv(pdvobjpriv) == _FAIL) goto free_dvobj; - } /* 3 misc */ sema_init(&(pdvobjpriv->usb_suspend_sema), 0); @@ -262,25 +259,11 @@ static void chip_by_usb_id(struct adapter *padapter, static void usb_intf_start(struct adapter *padapter) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_start\n")); - rtw_hal_inirp_init(padapter); - - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_start\n")); } static void usb_intf_stop(struct adapter *padapter) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+usb_intf_stop\n")); - - /* disabel_hw_interrupt */ - if (!padapter->bSurpriseRemoved) { - /* device still exists, so driver can do i/o operation */ - /* TODO: */ - RT_TRACE(_module_hci_intfs_c_, _drv_err_, - ("SurpriseRemoved == false\n")); - } - /* cancel in irp */ rtw_hal_inirp_deinit(padapter); @@ -288,14 +271,10 @@ static void usb_intf_stop(struct adapter *padapter) rtw_write_port_cancel(padapter); /* todo:cancel other irps */ - - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-usb_intf_stop\n")); } static void rtw_dev_unload(struct adapter *padapter) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_dev_unload\n")); - if (padapter->bup) { DBG_88E("===> rtw_dev_unload\n"); padapter->bDriverStopped = true; @@ -315,14 +294,9 @@ static void rtw_dev_unload(struct adapter *padapter) } padapter->bup = false; - } else { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, - ("r871x_dev_unload():padapter->bup == false\n")); } DBG_88E("<=== rtw_dev_unload\n"); - - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-rtw_dev_unload\n")); } static void process_spec_devid(const struct usb_device_id *pdid) @@ -643,11 +617,8 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, rtw_hal_read_chip_info(padapter); /* step 5. */ - if (rtw_init_drv_sw(padapter) == _FAIL) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, - ("Initialize driver software resource Failed!\n")); + if (rtw_init_drv_sw(padapter) == _FAIL) goto free_hal_data; - } #ifdef CONFIG_PM if (padapter->pwrctrlpriv.bSupportRemoteWakeup) { @@ -677,10 +648,8 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, pnetdev->dev_addr); /* step 6. Tell the network stack we exist */ - if (register_netdev(pnetdev) != 0) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("register_netdev() failed\n")); + if (register_netdev(pnetdev) != 0) goto free_hal_data; - } DBG_88E("bDriverStopped:%d, bSurpriseRemoved:%d, bup:%d, hw_init_completed:%d\n" , padapter->bDriverStopped @@ -745,18 +714,13 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device int status; struct dvobj_priv *dvobj; - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_init\n")); - /* step 0. */ process_spec_devid(pdid); /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); - if (!dvobj) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, - ("initialize device object priv Failed!\n")); + if (!dvobj) goto exit; - } if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid); if (!if1) { @@ -769,8 +733,6 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device rtw_signal_process(ui_pid[1], SIGUSR2); } - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-871x_drv - drv_init, success!\n")); - status = _SUCCESS; if (status != _SUCCESS && if1) @@ -792,7 +754,6 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) struct adapter *padapter = dvobj->if1; DBG_88E("+rtw_dev_remove\n"); - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+dev_remove()\n")); if (usb_drv->drv_registered) padapter->bSurpriseRemoved = true; @@ -806,14 +767,11 @@ static void rtw_dev_remove(struct usb_interface *pusb_intf) usb_dvobj_deinit(pusb_intf); - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("-dev_remove()\n")); DBG_88E("-r871xu_dev_remove, done\n"); } static int __init rtw_drv_entry(void) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_entry\n")); - DBG_88E(DRV_NAME " driver version=%s\n", DRIVERVERSION); _rtw_mutex_init(&usb_drv->hw_init_mutex); @@ -824,7 +782,6 @@ static int __init rtw_drv_entry(void) static void __exit rtw_drv_halt(void) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("+rtw_drv_halt\n")); DBG_88E("+rtw_drv_halt\n"); usb_drv->drv_registered = false; -- cgit v1.2.3 From 7912bb6a4ec8fb1915c80c9c21c52e461162a04d Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:26 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from usb_ops_linux.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-3-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_ops_linux.c | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c index dd4bd14b76c2..62dd4a131534 100644 --- a/drivers/staging/r8188eu/os_dep/usb_ops_linux.c +++ b/drivers/staging/r8188eu/os_dep/usb_ops_linux.c @@ -89,9 +89,6 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) if (padapter->bSurpriseRemoved || padapter->bDriverStopped || padapter->bWritePortCancel) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)", - padapter->bDriverStopped, padapter->bSurpriseRemoved)); DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n", __func__, padapter->bDriverStopped, padapter->bSurpriseRemoved, padapter->bReadPortCancel, @@ -101,12 +98,10 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) } if (purb->status) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete : purb->status(%d) != 0\n", purb->status)); DBG_88E("###=> urb_write_port_complete status(%d)\n", purb->status); if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) { sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL); } else if (purb->status == -EINPROGRESS) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: EINPROGESS\n")); goto check_completion; } else if (purb->status == -ENOENT) { DBG_88E("%s: -ENOENT\n", __func__); @@ -115,14 +110,11 @@ static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs) DBG_88E("%s: -ECONNRESET\n", __func__); goto check_completion; } else if (purb->status == -ESHUTDOWN) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: ESHUTDOWN\n")); padapter->bDriverStopped = true; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bDriverStopped = true\n")); goto check_completion; } else { padapter->bSurpriseRemoved = true; DBG_88E("bSurpriseRemoved = true\n"); - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bSurpriseRemoved = true\n")); goto check_completion; } @@ -156,12 +148,8 @@ u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data; struct usb_device *pusbd = pdvobj->pusbdev; - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n")); - if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) || (padapter->pwrctrlpriv.pnp_bstop_trx)) { - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, - ("usb_write_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n")); rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY); goto exit; } @@ -214,7 +202,6 @@ u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) } else { rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR); DBG_88E("usb_write_port, status =%d\n", status); - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port(): usb_submit_urb, status =%x\n", status)); switch (status) { case -ENODEV: @@ -230,8 +217,6 @@ u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem) /* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */ - RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port\n")); - exit: if (ret != _SUCCESS) rtw_free_xmitbuf(pxmitpriv, pxmitbuf); -- cgit v1.2.3 From 71931a7fa85859a76c8ac6ab8efe09ade729df46 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:27 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from ioctl_linux.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-4-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 78 ++-------------------------- 1 file changed, 3 insertions(+), 75 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 34dce01e469c..3d26d50abd7e 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -355,8 +355,6 @@ static char *translate_scan(struct adapter *padapter, goto exit; } rtw_get_sec_ie(pnetwork->network.IEs, pnetwork->network.IELength, rsn_ie, &rsn_len, wpa_ie, &wpa_len); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: ssid =%s\n", pnetwork->network.Ssid.Ssid)); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan: wpa_len =%d rsn_len =%d\n", wpa_len, rsn_len)); if (wpa_len > 0) { p = buf; @@ -501,7 +499,6 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, } if (strcmp(param->u.crypt.alg, "WEP") == 0) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("wpa_set_encryption, crypt.alg = WEP\n")); DBG_88E("wpa_set_encryption, crypt.alg = WEP\n"); padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; @@ -511,22 +508,18 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, wep_key_idx = param->u.crypt.idx; wep_key_len = param->u.crypt.key_len; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(1)wep_key_idx =%d\n", wep_key_idx)); DBG_88E("(1)wep_key_idx =%d\n", wep_key_idx); if (wep_key_idx > WEP_KEYS) return -EINVAL; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("(2)wep_key_idx =%d\n", wep_key_idx)); - if (wep_key_len > 0) { wep_key_len = wep_key_len <= 5 ? 5 : 13; wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); pwep = kmalloc(wep_total_len, GFP_KERNEL); - if (!pwep) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, (" wpa_set_encryption: pwep allocate fail !!!\n")); + if (!pwep) goto exit; - } + memset(pwep, 0, wep_total_len); pwep->KeyLength = wep_key_len; pwep->Length = wep_total_len; @@ -659,7 +652,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } if (ielen < RSN_HEADER_LEN) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("Ie len too short %d\n", ielen)); ret = -1; goto exit; } @@ -750,9 +742,6 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } } - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_set_wpa_ie: pairwise_cipher = 0x%08x padapter->securitypriv.ndisencryptstatus =%d padapter->securitypriv.ndisauthtype =%d\n", - pairwise_cipher, padapter->securitypriv.ndisencryptstatus, padapter->securitypriv.ndisauthtype)); exit: kfree(buf); return ret; @@ -772,10 +761,6 @@ static int rtw_wx_get_name(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; NDIS_802_11_RATES_EX *prates = NULL; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("cmd_code =%x\n", info->cmd)); - - - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); @@ -820,12 +805,6 @@ static int rtw_wx_set_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { - - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_notice_, ("+rtw_wx_set_freq\n")); - - - return 0; } @@ -889,7 +868,6 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, break; default: ret = -EINVAL; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("\n Mode: %s is not supported\n", iw_operation_mode[wrqu->mode])); goto exit; } if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { @@ -908,10 +886,6 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_get_mode\n")); - - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) wrqu->mode = IW_MODE_INFRA; else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || @@ -1015,10 +989,6 @@ static int rtw_wx_get_range(struct net_device *dev, u16 val; int i; - - - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_range. cmd_code =%x\n", info->cmd)); - wrqu->data.length = sizeof(*range); memset(range, 0, sizeof(*range)); @@ -1192,10 +1162,6 @@ static int rtw_wx_get_wap(struct net_device *dev, memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_wap\n")); - - - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) @@ -1252,7 +1218,6 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, #ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &(padapter->wdinfo); #endif /* CONFIG_88EU_P2P */ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_set_scan\n")); if (padapter->registrypriv.mp_mode == 1) { if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) { @@ -1404,10 +1369,6 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, #ifdef CONFIG_88EU_P2P struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_scan\n")); - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, (" Start of Query SIOCGIWSCAN .\n")); - - if (padapter->pwrctrlpriv.brfoffbyhw && padapter->bDriverStopped) { ret = -EINVAL; @@ -1487,10 +1448,6 @@ static int rtw_wx_set_essid(struct net_device *dev, uint ret = 0, len; - - - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("+rtw_wx_set_essid: fw_state = 0x%08x\n", get_fwstate(pmlmepriv))); if (_FAIL == rtw_pwr_wakeup(padapter)) { ret = -1; goto exit; @@ -1524,7 +1481,6 @@ static int rtw_wx_set_essid(struct net_device *dev, memcpy(ndis_ssid.Ssid, extra, len); src_ssid = ndis_ssid.Ssid; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("rtw_wx_set_essid: ssid =[%s]\n", src_ssid)); spin_lock_bh(&queue->lock); phead = get_list_head(queue); pmlmepriv->pscanned = phead->next; @@ -1536,14 +1492,8 @@ static int rtw_wx_set_essid(struct net_device *dev, dst_ssid = pnetwork->network.Ssid.Ssid; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_wx_set_essid: dst_ssid =%s\n", - pnetwork->network.Ssid.Ssid)); - if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_wx_set_essid: find match, set infra mode\n")); if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) @@ -1560,8 +1510,6 @@ static int rtw_wx_set_essid(struct net_device *dev, } } spin_unlock_bh(&queue->lock); - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("set ssid: set_802_11_auth. mode =%d\n", authmode)); rtw_set_802_11_authentication_mode(padapter, authmode); if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { ret = -1; @@ -1587,10 +1535,6 @@ static int rtw_wx_get_essid(struct net_device *dev, struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("rtw_wx_get_essid\n")); - - - if ((check_fwstate(pmlmepriv, _FW_LINKED)) || (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) { len = pcur_bss->Ssid.SsidLength; @@ -1618,9 +1562,6 @@ static int rtw_wx_set_rate(struct net_device *dev, u32 ratevalue = 0; u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, (" rtw_wx_set_rate\n")); - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("target_rate = %d, fixed = %d\n", target_rate, fixed)); - if (target_rate == -1) { ratevalue = 11; goto set_rate; @@ -1679,14 +1620,10 @@ set_rate: } else { datarates[i] = 0xff; } - - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, ("datarate_inx =%d\n", datarates[i])); } - if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("rtw_wx_set_rate Fail!!!\n")); + if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) ret = -1; - } return ret; } @@ -2474,12 +2411,8 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info } poidparam = (struct mp_ioctl_param *)pparmbuf; - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("rtw_mp_ioctl_hdl: subcode [%d], len[%d], buffer_len[%d]\r\n", - poidparam->subcode, poidparam->len, len)); if (poidparam->subcode >= MAX_MP_IOCTL_SUBCODE) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, ("no matching drvext subcodes\r\n")); ret = -EINVAL; goto _rtw_mp_ioctl_hdl_exit; } @@ -2488,9 +2421,6 @@ static int rtw_mp_ioctl_hdl(struct net_device *dev, struct iw_request_info *info phandler = mp_ioctl_hdl + poidparam->subcode; if ((phandler->paramsize != 0) && (poidparam->len < phandler->paramsize)) { - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_err_, - ("no matching drvext param size %d vs %d\r\n", - poidparam->len, phandler->paramsize)); ret = -EINVAL; goto _rtw_mp_ioctl_hdl_exit; } @@ -4603,8 +4533,6 @@ static int wpa_set_param(struct net_device *dev, u8 name, u32 value) padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; break; } - RT_TRACE(_module_rtl871x_ioctl_os_c, _drv_info_, - ("wpa_set_param:padapter->securitypriv.ndisauthtype =%d\n", padapter->securitypriv.ndisauthtype)); break; case IEEE_PARAM_TKIP_COUNTERMEASURES: break; -- cgit v1.2.3 From ca3515d268e150744a04e1fa555ee91ef650ee2d Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:28 +0200 Subject: staging: r8188eu: remove empty function With the RT_TRACE print removed, the rtw_wx_set_freq function is now empty. This function should be removed. At the moment, the setfreq ioctl returns success to the caller although the frequency wasn't set. It makes more sense to inform callers that this driver does not support setfreq. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-5-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 3d26d50abd7e..404744c90518 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -801,13 +801,6 @@ static int rtw_wx_get_name(struct net_device *dev, return 0; } -static int rtw_wx_set_freq(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - static int rtw_wx_get_freq(struct net_device *dev, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) @@ -7437,7 +7430,7 @@ static iw_handler rtw_handlers[] = { rtw_wx_get_name, /* SIOCGIWNAME */ dummy, /* SIOCSIWNWID */ dummy, /* SIOCGIWNWID */ - rtw_wx_set_freq, /* SIOCSIWFREQ */ + NULL, /* SIOCSIWFREQ */ rtw_wx_get_freq, /* SIOCGIWFREQ */ rtw_wx_set_mode, /* SIOCSIWMODE */ rtw_wx_get_mode, /* SIOCGIWMODE */ -- cgit v1.2.3 From 34f231c525751d43a85a726049b52b34e4f98814 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:29 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from mlme_linux.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-6-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/mlme_linux.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index 0855b218f7b1..259628cbf020 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -113,12 +113,8 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) u8 *buff, *p, i; union iwreq_data wrqu; - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("+rtw_report_sec_ie, authmode=%d\n", authmode)); buff = NULL; if (authmode == _WPA_IE_ID_) { - RT_TRACE(_module_mlme_osdep_c_, _drv_info_, - ("rtw_report_sec_ie, authmode=%d\n", authmode)); buff = kzalloc(IW_CUSTOM_MAX, GFP_KERNEL); if (!buff) return; -- cgit v1.2.3 From 3fbb0047d12851e0aa0b81371b07711d9347aa9e Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:30 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from os_intfs.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Handle errors from dev_alloc_name in one place instead of showing a debug print. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-7-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/os_intfs.c | 49 +++++-------------------------- 1 file changed, 7 insertions(+), 42 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 935e35c82666..c98dbedd10f7 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -697,8 +697,11 @@ static const struct net_device_ops rtw_netdev_ops = { int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) { - if (dev_alloc_name(pnetdev, ifname) < 0) - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("dev_alloc_name, fail!\n")); + int err; + + err = dev_alloc_name(pnetdev, ifname); + if (err < 0) + return err; netif_carrier_off(pnetdev); return 0; @@ -719,8 +722,6 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) struct adapter *padapter; struct net_device *pnetdev; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+init_net_dev\n")); - if (old_padapter) pnetdev = rtw_alloc_etherdev_with_old_priv(sizeof(struct adapter), (void *)old_padapter); else @@ -747,8 +748,6 @@ u32 rtw_start_drv_threads(struct adapter *padapter) { u32 _status = _SUCCESS; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_start_drv_threads\n")); - padapter->cmdThread = kthread_run(rtw_cmd_thread, padapter, "RTW_CMD_THREAD"); if (IS_ERR(padapter->cmdThread)) _status = _FAIL; @@ -761,8 +760,6 @@ u32 rtw_start_drv_threads(struct adapter *padapter) void rtw_stop_drv_threads(struct adapter *padapter) { - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_stop_drv_threads\n")); - /* Below is to termindate rtw_cmd_thread & event_thread... */ up(&padapter->cmdpriv.cmd_queue_sema); if (padapter->cmdThread) @@ -858,10 +855,7 @@ u8 rtw_init_drv_sw(struct adapter *padapter) u8 ret8 = _SUCCESS; unsigned long flags; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_init_drv_sw\n")); - if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init cmd_priv\n")); ret8 = _FAIL; goto exit; } @@ -869,13 +863,11 @@ u8 rtw_init_drv_sw(struct adapter *padapter) padapter->cmdpriv.padapter = padapter; if ((rtw_init_evt_priv(&padapter->evtpriv)) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init evt_priv\n")); ret8 = _FAIL; goto exit; } if (rtw_init_mlme_priv(padapter) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_priv\n")); ret8 = _FAIL; goto exit; } @@ -887,7 +879,6 @@ u8 rtw_init_drv_sw(struct adapter *padapter) #endif /* CONFIG_88EU_P2P */ if (init_mlme_ext_priv(padapter) == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("\n Can't init mlme_ext_priv\n")); ret8 = _FAIL; goto exit; } @@ -929,29 +920,19 @@ u8 rtw_init_drv_sw(struct adapter *padapter) spin_lock_init(&padapter->br_ext_lock); exit: - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_init_drv_sw\n")); - - - return ret8; } void rtw_cancel_all_timer(struct adapter *padapter) { - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+rtw_cancel_all_timer\n")); - _cancel_timer_ex(&padapter->mlmepriv.assoc_timer); - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel association timer complete!\n")); _cancel_timer_ex(&padapter->mlmepriv.scan_to_timer); - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel scan_to_timer!\n")); _cancel_timer_ex(&padapter->mlmepriv.dynamic_chk_timer); - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel dynamic_chk_timer!\n")); /* cancel sw led timer */ rtw_hal_sw_led_deinit(padapter); - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("rtw_cancel_all_timer:cancel DeInitSwLeds!\n")); _cancel_timer_ex(&padapter->pwrctrlpriv.pwr_state_check_timer); @@ -962,8 +943,6 @@ void rtw_cancel_all_timer(struct adapter *padapter) u8 rtw_free_drv_sw(struct adapter *padapter) { - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("==>rtw_free_drv_sw")); - /* we can call rtw_p2p_enable here, but: */ /* 1. rtw_p2p_enable may have IO operation */ /* 2. rtw_p2p_enable is bundled with wext interface */ @@ -996,8 +975,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter) rtw_hal_free_data(padapter); - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("<== rtw_free_drv_sw\n")); - /* free the old_pnetdev */ if (padapter->rereg_nd_name_priv.old_pnetdev) { free_netdev(padapter->rereg_nd_name_priv.old_pnetdev); @@ -1008,8 +985,6 @@ u8 rtw_free_drv_sw(struct adapter *padapter) if (padapter->pbuddy_adapter) padapter->pbuddy_adapter->pbuddy_adapter = NULL; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-rtw_free_drv_sw\n")); - return _SUCCESS; } @@ -1048,7 +1023,6 @@ int _netdev_open(struct net_device *pnetdev) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - dev_open\n")); DBG_88E("+88eu_drv - drv_open, bup =%d\n", padapter->bup); if (pwrctrlpriv->ps_flag) { @@ -1062,10 +1036,8 @@ int _netdev_open(struct net_device *pnetdev) padapter->bCardDisableWOHSM = false; status = rtw_hal_init(padapter); - if (status == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("rtl88eu_hal_init(): Can't init h/w!\n")); + if (status == _FAIL) goto netdev_open_error; - } pr_info("MAC Address = %pM\n", pnetdev->dev_addr); @@ -1102,7 +1074,6 @@ int _netdev_open(struct net_device *pnetdev) netdev_br_init(pnetdev); netdev_open_normal_process: - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - dev_open\n")); DBG_88E("-88eu_drv - drv_open, bup =%d\n", padapter->bup); return 0; @@ -1110,7 +1081,6 @@ netdev_open_error: padapter->bup = false; netif_carrier_off(pnetdev); rtw_netif_stop_queue(pnetdev); - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("-88eu_drv - dev_open, fail!\n")); DBG_88E("-88eu_drv - drv_open fail, bup =%d\n", padapter->bup); return -1; } @@ -1137,10 +1107,8 @@ static int ips_netdrv_open(struct adapter *padapter) padapter->bCardDisableWOHSM = false; status = rtw_hal_init(padapter); - if (status == _FAIL) { - RT_TRACE(_module_os_intfs_c_, _drv_err_, ("ips_netdrv_open(): Can't init h/w!\n")); + if (status == _FAIL) goto netdev_open_error; - } if (padapter->intf_start) padapter->intf_start(padapter); @@ -1216,8 +1184,6 @@ int netdev_close(struct net_device *pnetdev) struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); struct dvobj_priv *dvobj = adapter_to_dvobj(padapter); - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("+88eu_drv - drv_close\n")); - if (padapter->pwrctrlpriv.bInternalAutoSuspend) { if (padapter->pwrctrlpriv.rf_pwrstate == rf_off) padapter->pwrctrlpriv.ps_flag = true; @@ -1256,7 +1222,6 @@ int netdev_close(struct net_device *pnetdev) kfree(dvobj->firmware.szFwBuffer); dvobj->firmware.szFwBuffer = NULL; - RT_TRACE(_module_os_intfs_c_, _drv_info_, ("-88eu_drv - drv_close\n")); DBG_88E("-88eu_drv - drv_close, bup =%d\n", padapter->bup); return 0; } -- cgit v1.2.3 From bd285cab08d9cba3aca9ad3a6c45bc6c627ae79a Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:31 +0200 Subject: staging: r8188eu: remove an RT_TRACE print from osdep_service.c We should use the standard mechanism for debug prints. Remove a print that uses a driver-specific macro. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-8-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/osdep_service.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 9f097f2b3ddd..36bb3813c677 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -235,11 +235,9 @@ int rtw_change_ifname(struct adapter *padapter, const char *ifname) ret = register_netdev(pnetdev); else ret = register_netdevice(pnetdev); - if (ret != 0) { - RT_TRACE(_module_hci_intfs_c_, _drv_err_, - ("register_netdev() failed\n")); + if (ret != 0) goto error; - } + rtw_proc_init_one(pnetdev); return 0; error: -- cgit v1.2.3 From 8be55d7a3043a6eb2b2217d6e13b46b170277ee8 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:32 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from recv_linux.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-9-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/recv_linux.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 1fd3f1bf1fe5..8dfabdb02494 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -118,21 +118,8 @@ int rtw_recv_indicatepkt(struct adapter *padapter, pfree_recv_queue = &(precvpriv->free_recv_queue); skb = precv_frame->pkt; - if (!skb) { - RT_TRACE(_module_recv_osdep_c_, _drv_err_, - ("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n")); + if (!skb) goto _recv_indicatepkt_drop; - } - - RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("rtw_recv_indicatepkt():skb != NULL !!!\n")); - RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("rtw_recv_indicatepkt():precv_frame->rx_head =%p precv_frame->hdr.rx_data =%p\n", - precv_frame->rx_head, precv_frame->rx_data)); - RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("precv_frame->hdr.rx_tail =%p precv_frame->rx_end =%p precv_frame->hdr.len =%d\n", - precv_frame->rx_tail, precv_frame->rx_end, - precv_frame->len)); skb->data = precv_frame->rx_data; @@ -140,11 +127,6 @@ int rtw_recv_indicatepkt(struct adapter *padapter, skb->len = precv_frame->len; - RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n", - skb->head, skb->data, skb_tail_pointer(skb), - skb_end_pointer(skb), skb->len)); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { struct sk_buff *pskb2 = NULL; struct sta_info *psta = NULL; @@ -195,9 +177,6 @@ _recv_indicatepkt_end: rtw_free_recvframe(precv_frame, pfree_recv_queue); - RT_TRACE(_module_recv_osdep_c_, _drv_info_, - ("\n rtw_recv_indicatepkt :after netif_rx!!!!\n")); - return _SUCCESS; _recv_indicatepkt_drop: -- cgit v1.2.3 From a8357683dbfea39573b3d854fbc56b636ba1ad3a Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:33 +0200 Subject: staging: r8188eu: remove RT_TRACE prints from xmit_linux.c We should use the standard mechanism for debug prints. Remove the prints that use driver-specific macros. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-10-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/xmit_linux.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index df9bdbff91ac..3a1b9d8988f2 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -227,12 +227,8 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; - RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n")); - - if (rtw_if_up(padapter) == false) { - RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit_entry: rtw_if_up fail\n")); + if (rtw_if_up(padapter) == false) goto drop_packet; - } rtw_check_xmit_resource(padapter, pkt); @@ -251,13 +247,11 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) goto drop_packet; pxmitpriv->tx_pkts++; - RT_TRACE(_module_xmit_osdep_c_, _drv_info_, ("rtw_xmit_entry: tx_pkts=%d\n", (u32)pxmitpriv->tx_pkts)); goto exit; drop_packet: pxmitpriv->tx_drop++; dev_kfree_skb_any(pkt); - RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop=%d\n", (u32)pxmitpriv->tx_drop)); exit: -- cgit v1.2.3 From da2aa1ecad1c9fcbe8fb2c16d91dbe99d264667c Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:34 +0200 Subject: staging: r8188eu: use IW_HANDLER to declare wext handlers Use the IW_HANDLER macro to declare the handler functions for wext ioctls. We don't have to skip unused ioctl numbers manually. The same modification was applied to the deprecated rtl8188eu driver in commit af249fce390f ("staging: rtl8188eu: use IW_HANDLER to declare wext handlers"). Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-11-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 96 ++++++++++++---------------- 1 file changed, 40 insertions(+), 56 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 404744c90518..3da5adc64404 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -7426,62 +7426,46 @@ static int rtw_test( } static iw_handler rtw_handlers[] = { - NULL, /* SIOCSIWCOMMIT */ - rtw_wx_get_name, /* SIOCGIWNAME */ - dummy, /* SIOCSIWNWID */ - dummy, /* SIOCGIWNWID */ - NULL, /* SIOCSIWFREQ */ - rtw_wx_get_freq, /* SIOCGIWFREQ */ - rtw_wx_set_mode, /* SIOCSIWMODE */ - rtw_wx_get_mode, /* SIOCGIWMODE */ - dummy, /* SIOCSIWSENS */ - rtw_wx_get_sens, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - rtw_wx_get_range, /* SIOCGIWRANGE */ - rtw_wx_set_priv, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - dummy, /* SIOCSIWSPY */ - dummy, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - rtw_wx_set_wap, /* SIOCSIWAP */ - rtw_wx_get_wap, /* SIOCGIWAP */ - rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */ - dummy, /* SIOCGIWAPLIST -- depricated */ - rtw_wx_set_scan, /* SIOCSIWSCAN */ - rtw_wx_get_scan, /* SIOCGIWSCAN */ - rtw_wx_set_essid, /* SIOCSIWESSID */ - rtw_wx_get_essid, /* SIOCGIWESSID */ - dummy, /* SIOCSIWNICKN */ - rtw_wx_get_nick, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - rtw_wx_set_rate, /* SIOCSIWRATE */ - rtw_wx_get_rate, /* SIOCGIWRATE */ - rtw_wx_set_rts, /* SIOCSIWRTS */ - rtw_wx_get_rts, /* SIOCGIWRTS */ - rtw_wx_set_frag, /* SIOCSIWFRAG */ - rtw_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ - dummy, /* SIOCSIWRETRY */ - rtw_wx_get_retry, /* SIOCGIWRETRY */ - rtw_wx_set_enc, /* SIOCSIWENCODE */ - rtw_wx_get_enc, /* SIOCGIWENCODE */ - dummy, /* SIOCSIWPOWER */ - rtw_wx_get_power, /* SIOCGIWPOWER */ - NULL, /*---hole---*/ - NULL, /*---hole---*/ - rtw_wx_set_gen_ie, /* SIOCSIWGENIE */ - NULL, /* SIOCGWGENIE */ - rtw_wx_set_auth, /* SIOCSIWAUTH */ - NULL, /* SIOCGIWAUTH */ - rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ - NULL, /* SIOCGIWENCODEEXT */ - rtw_wx_set_pmkid, /* SIOCSIWPMKSA */ - NULL, /*---hole---*/ + IW_HANDLER(SIOCGIWNAME, rtw_wx_get_name), + IW_HANDLER(SIOCSIWNWID, dummy), + IW_HANDLER(SIOCGIWNWID, dummy), + IW_HANDLER(SIOCGIWFREQ, rtw_wx_get_freq), + IW_HANDLER(SIOCSIWMODE, rtw_wx_set_mode), + IW_HANDLER(SIOCGIWMODE, rtw_wx_get_mode), + IW_HANDLER(SIOCSIWSENS, dummy), + IW_HANDLER(SIOCGIWSENS, rtw_wx_get_sens), + IW_HANDLER(SIOCGIWRANGE, rtw_wx_get_range), + IW_HANDLER(SIOCSIWPRIV, rtw_wx_set_priv), + IW_HANDLER(SIOCSIWSPY, dummy), + IW_HANDLER(SIOCGIWSPY, dummy), + IW_HANDLER(SIOCSIWAP, rtw_wx_set_wap), + IW_HANDLER(SIOCGIWAP, rtw_wx_get_wap), + IW_HANDLER(SIOCSIWMLME, rtw_wx_set_mlme), + IW_HANDLER(SIOCGIWAPLIST, dummy), + IW_HANDLER(SIOCSIWSCAN, rtw_wx_set_scan), + IW_HANDLER(SIOCGIWSCAN, rtw_wx_get_scan), + IW_HANDLER(SIOCSIWESSID, rtw_wx_set_essid), + IW_HANDLER(SIOCGIWESSID, rtw_wx_get_essid), + IW_HANDLER(SIOCSIWNICKN, dummy), + IW_HANDLER(SIOCGIWNICKN, rtw_wx_get_nick), + IW_HANDLER(SIOCSIWRATE, rtw_wx_set_rate), + IW_HANDLER(SIOCGIWRATE, rtw_wx_get_rate), + IW_HANDLER(SIOCSIWRTS, rtw_wx_set_rts), + IW_HANDLER(SIOCGIWRTS, rtw_wx_get_rts), + IW_HANDLER(SIOCSIWFRAG, rtw_wx_set_frag), + IW_HANDLER(SIOCGIWFRAG, rtw_wx_get_frag), + IW_HANDLER(SIOCSIWTXPOW, dummy), + IW_HANDLER(SIOCGIWTXPOW, dummy), + IW_HANDLER(SIOCSIWRETRY, dummy), + IW_HANDLER(SIOCGIWRETRY, rtw_wx_get_retry), + IW_HANDLER(SIOCSIWENCODE, rtw_wx_set_enc), + IW_HANDLER(SIOCGIWENCODE, rtw_wx_get_enc), + IW_HANDLER(SIOCSIWPOWER, dummy), + IW_HANDLER(SIOCGIWPOWER, rtw_wx_get_power), + IW_HANDLER(SIOCSIWGENIE, rtw_wx_set_gen_ie), + IW_HANDLER(SIOCSIWAUTH, rtw_wx_set_auth), + IW_HANDLER(SIOCSIWENCODEEXT, rtw_wx_set_enc_ext), + IW_HANDLER(SIOCSIWPMKSA, rtw_wx_set_pmkid), }; static const struct iw_priv_args rtw_private_args[] = { -- cgit v1.2.3 From ac338b17bbf798f9baf2604f65c54c32c063f10c Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:35 +0200 Subject: staging: r8188eu: remove unused DEBUG_OID macro The DEBUG_OID macro is not used and can be removed. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-12-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_ioctl.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_ioctl.h b/drivers/staging/r8188eu/include/rtw_ioctl.h index 8c03c16bb998..7ebc52f008a0 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl.h @@ -45,12 +45,6 @@ #define OID_MP_SEG3 0xFF818700 #define OID_MP_SEG4 0xFF011100 -#define DEBUG_OID(dbg, str) \ - if ((!dbg)) { \ - RT_TRACE(_module_rtl871x_ioctl_c_, _drv_info_, \ - ("%s(%d): %s", __func__, __line__, str)); \ - } - enum oid_type { QUERY_OID, SET_OID -- cgit v1.2.3 From 2abc0000d2970bb631dd39a151b46ba334526130 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 7 Aug 2021 17:36:36 +0200 Subject: staging: r8188eu: remove the RT_TRACE macro We've deleted all RT_TRACE calls. The macro itself can now be removed as well. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210807153636.11712-13-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_debug.h | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_debug.h b/drivers/staging/r8188eu/include/rtw_debug.h index 83c71275c47b..3c3bf2a4f30e 100644 --- a/drivers/staging/r8188eu/include/rtw_debug.h +++ b/drivers/staging/r8188eu/include/rtw_debug.h @@ -72,15 +72,6 @@ extern u32 GlobalDebugLevel; pr_info(DRIVER_PREFIX __VA_ARGS__); \ } while (0) -#define RT_TRACE(_comp, _level, fmt) \ - do { \ - if (_level <= GlobalDebugLevel) { \ - pr_info("%s [0x%08x,%d]", DRIVER_PREFIX, \ - (unsigned int)_comp, _level); \ - pr_info fmt; \ - } \ - } while (0) - int proc_get_drv_version(char *page, char **start, off_t offset, int count, int *eof, void *data); -- cgit v1.2.3 From 3bb8fa376b8a21ccaf25bf64cc70a6a54cf343f8 Mon Sep 17 00:00:00 2001 From: Saurav Girepunje Date: Sat, 7 Aug 2021 15:52:31 +0530 Subject: staging: rtl8192e: rtl8192e: rtl_core: remove unused global variable Remove unused global variable channels from rtl_core.c Signed-off-by: Saurav Girepunje Link: https://lore.kernel.org/r/20210807102232.6674-4-saurav.girepunje@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index e85d9c2cdc96..dffae61b517b 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -23,7 +23,6 @@ #include "rtl_pm.h" int hwwep = 1; -static int channels = 0x3fff; static char *ifname = "wlan%d"; @@ -2642,8 +2641,6 @@ MODULE_FIRMWARE(RTL8192E_DATA_IMG_FW); module_param(ifname, charp, 0644); module_param(hwwep, int, 0644); -module_param(channels, int, 0644); MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default"); MODULE_PARM_DESC(hwwep, " Try to use hardware WEP support(default use hw. set 0 to use software security)"); -MODULE_PARM_DESC(channels, " Channel bitmask for specific locales. NYI"); -- cgit v1.2.3 From 7929cc52986cc4d580ab7a74029037b3aa9f4583 Mon Sep 17 00:00:00 2001 From: Saurav Girepunje Date: Sat, 7 Aug 2021 15:52:32 +0530 Subject: staging: rtl8723bs: os_dep: remove unused variable Remove below unused static variable from os_intfs.c rtw_enusbss rtw_hwpdn_mode rtw_hwpwrp_detect Signed-off-by: Saurav Girepunje Link: https://lore.kernel.org/r/20210807102232.6674-5-saurav.girepunje@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 8 -------- 1 file changed, 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index 7728eabdfe48..d772a044185d 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -101,11 +101,6 @@ static int rtw_antdiv_cfg = 1; /* 0:OFF , 1:ON, 2:decide by Efuse config */ static int rtw_antdiv_type; /* 0:decide by efuse 1: for 88EE, 1Tx and 1RxCG are diversity.(2 Ant with SPDT), 2: for 88EE, 1Tx and 2Rx are diversity.(2 Ant, Tx and RxCG are both on aux port, RxCS is on main port), 3: for 88EE, 1Tx and 1RxCG are fixed.(1Ant, Tx and RxCG are both on aux port) */ -static int rtw_enusbss;/* 0:disable, 1:enable */ - -static int rtw_hwpdn_mode = 2;/* 0:disable, 1:enable, 2: by EFUSE config */ - -static int rtw_hwpwrp_detect; /* HW power ping detect 0:disable , 1:enable */ static int rtw_hw_wps_pbc; @@ -150,9 +145,6 @@ module_param(rtw_wifi_spec, int, 0644); module_param(rtw_antdiv_cfg, int, 0644); module_param(rtw_antdiv_type, int, 0644); -module_param(rtw_enusbss, int, 0644); -module_param(rtw_hwpdn_mode, int, 0644); -module_param(rtw_hwpwrp_detect, int, 0644); module_param(rtw_hw_wps_pbc, int, 0644); -- cgit v1.2.3 From 76cdbbc582b682d9b139769c38dbad3fa6beeebf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:51 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in os_dep dir Remove unnecessary parentheses in the os_dep directory reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 162 ++++++++++++------------- drivers/staging/r8188eu/os_dep/os_intfs.c | 4 +- drivers/staging/r8188eu/os_dep/osdep_service.c | 4 +- drivers/staging/r8188eu/os_dep/recv_linux.c | 4 +- drivers/staging/r8188eu/os_dep/rtw_android.c | 2 +- drivers/staging/r8188eu/os_dep/usb_intf.c | 2 +- 6 files changed, 89 insertions(+), 89 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 3da5adc64404..a0ea9b43054b 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -168,7 +168,7 @@ static char *translate_scan(struct adapter *padapter, struct wlan_network *pnetwork, char *start, char *stop) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct iw_event iwe; u16 cap; __le16 le_tmp; @@ -544,7 +544,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ret = -EOPNOTSUPP; goto exit; } - memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); } @@ -571,8 +571,8 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); if (strcmp(param->u.crypt.alg, "TKIP") == 0) { /* set mic key */ - memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); - memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); + memcpy(psta->dot11tkiptxmickey.skey, ¶m->u.crypt.key[16], 8); + memcpy(psta->dot11tkiprxmickey.skey, ¶m->u.crypt.key[24], 8); padapter->securitypriv.busetkipkey = false; } @@ -581,8 +581,8 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, rtw_setstakey_cmd(padapter, (unsigned char *)psta, true); } else { /* group key */ memcpy(padapter->securitypriv.dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); - memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + memcpy(padapter->securitypriv.dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); + memcpy(padapter->securitypriv.dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); padapter->securitypriv.binstallGrpkey = true; DBG_88E(" ~~~~set sta key:groupkey\n"); @@ -757,7 +757,7 @@ static int rtw_wx_get_name(struct net_device *dev, u32 ht_ielen = 0; char *p; u8 ht_cap = false; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; NDIS_802_11_RATES_EX *prates = NULL; @@ -806,7 +806,7 @@ static int rtw_wx_get_freq(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; if (check_fwstate(pmlmepriv, _FW_LINKED)) { @@ -877,7 +877,7 @@ static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) wrqu->mode = IW_MODE_INFRA; @@ -1078,10 +1078,10 @@ static int rtw_wx_set_wap(struct net_device *dev, uint ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct sockaddr *temp = (struct sockaddr *)awrq; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *phead; u8 *dst_bssid, *src_bssid; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; enum ndis_802_11_auth_mode authmode; @@ -1148,7 +1148,7 @@ static int rtw_wx_get_wap(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; wrqu->ap_addr.sa_family = ARPHRD_ETHER; @@ -1209,7 +1209,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ if (padapter->registrypriv.mp_mode == 1) { @@ -1350,8 +1350,8 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, { struct list_head *plist, *phead; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; char *ev = extra; char *stop = ev + wrqu->data.length; @@ -1525,7 +1525,7 @@ static int rtw_wx_get_essid(struct net_device *dev, { u32 len, ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; if ((check_fwstate(pmlmepriv, _FW_LINKED)) || @@ -1745,7 +1745,7 @@ static int rtw_wx_set_enc(struct net_device *dev, struct ndis_802_11_wep wep; enum ndis_802_11_auth_mode authmode; - struct iw_point *erq = &(wrqu->encoding); + struct iw_point *erq = &wrqu->encoding; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; DBG_88E("+rtw_wx_set_enc, flags = 0x%x\n", erq->flags); @@ -1860,8 +1860,8 @@ static int rtw_wx_get_enc(struct net_device *dev, { uint key, ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *erq = &(wrqu->encoding); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct iw_point *erq = &wrqu->encoding; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -1949,7 +1949,7 @@ static int rtw_wx_set_auth(struct net_device *dev, union iwreq_data *wrqu, char *extra) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_param *param = (struct iw_param *)&(wrqu->param); + struct iw_param *param = (struct iw_param *)&wrqu->param; int ret = 0; switch (param->flags & IW_AUTH_INDEX) { @@ -2477,8 +2477,8 @@ static int rtw_get_ap_info(struct net_device *dev, char data[32]; struct wlan_network *pnetwork = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; struct iw_point *pdata = &wrqu->data; DBG_88E("+rtw_get_aplist_info\n"); @@ -2622,7 +2622,7 @@ static int rtw_wext_p2p_enable(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; enum P2P_ROLE init_role = P2P_ROLE_DISABLE; @@ -2672,7 +2672,7 @@ static int rtw_p2p_set_go_nego_ssid(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] ssid = %s, len = %zu\n", __func__, extra, strlen(extra)); memcpy(pwdinfo->nego_ssid, extra, strlen(extra)); @@ -2687,7 +2687,7 @@ static int rtw_p2p_set_intent(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 intent = pwdinfo->intent; switch (wrqu->data.length) { @@ -2712,7 +2712,7 @@ static int rtw_p2p_set_listen_ch(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 listen_ch = pwdinfo->listen_channel; /* Listen channel number */ switch (wrqu->data.length) { @@ -2745,7 +2745,7 @@ static int rtw_p2p_set_op_ch(struct net_device *dev, int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 op_ch = pwdinfo->operating_channel; /* Operating channel number */ switch (wrqu->data.length) { @@ -2773,7 +2773,7 @@ static int rtw_p2p_profilefound(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; /* Comment by Albert 2010/10/13 */ /* Input data format: */ @@ -2820,7 +2820,7 @@ static int rtw_p2p_setDN(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] %s %d\n", __func__, extra, wrqu->data.length - 1); memset(pwdinfo->device_name, 0x00, WPS_MAX_DEVICE_NAME_LEN); @@ -2836,7 +2836,7 @@ static int rtw_p2p_get_status(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; if (padapter->bShowGetP2PState) DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), @@ -2863,7 +2863,7 @@ static int rtw_p2p_get_req_cm(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; sprintf(extra, "\n\nCM =%s\n", pwdinfo->rx_prov_disc_info.strconfig_method_desc_of_prov_disc_req); wrqu->data.length = strlen(extra); @@ -2876,7 +2876,7 @@ static int rtw_p2p_get_role(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] Role = %d, Status = %d, peer addr = %.2X:%.2X:%.2X:%.2X:%.2X:%.2X\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), pwdinfo->p2p_peer_interface_addr[0], pwdinfo->p2p_peer_interface_addr[1], pwdinfo->p2p_peer_interface_addr[2], @@ -2893,7 +2893,7 @@ static int rtw_p2p_get_peer_ifaddr(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), @@ -2911,7 +2911,7 @@ static int rtw_p2p_get_peer_devaddr(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), @@ -2929,7 +2929,7 @@ static int rtw_p2p_get_peer_devaddr_by_invitation(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] Role = %d, Status = %d, peer addr = %pM\n", __func__, rtw_p2p_role(pwdinfo), rtw_p2p_state(pwdinfo), @@ -2947,7 +2947,7 @@ static int rtw_p2p_get_groupid(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; sprintf(extra, "\n%.2X:%.2X:%.2X:%.2X:%.2X:%.2X %s", pwdinfo->groupid_info.go_device_addr[0], pwdinfo->groupid_info.go_device_addr[1], @@ -2965,7 +2965,7 @@ static int rtw_p2p_get_op_ch(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] Op_ch = %02x\n", __func__, pwdinfo->operating_channel); @@ -2985,7 +2985,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; u8 blnMatch = 0; u16 attr_content = 0; @@ -3053,7 +3053,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; u8 blnMatch = 0; u8 *p2pie; @@ -3136,7 +3136,7 @@ static int rtw_p2p_get_device_type(struct net_device *dev, u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; u8 blnMatch = 0; u8 dev_type[8] = {0x00}; @@ -3212,7 +3212,7 @@ static int rtw_p2p_get_device_name(struct net_device *dev, u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; u8 blnMatch = 0; u8 dev_name[WPS_MAX_DEVICE_NAME_LEN] = {0x00}; @@ -3278,7 +3278,7 @@ static int rtw_p2p_get_invitation_procedure(struct net_device *dev, u8 peerMACStr[17] = {0x00}; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; u8 blnMatch = 0; u8 *p2pie; @@ -3349,12 +3349,12 @@ static int rtw_p2p_connect(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 peerMAC[ETH_ALEN] = {0x00}; int jj, kk; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; uint uintPeerChannel = 0; @@ -3428,11 +3428,11 @@ static int rtw_p2p_invite_req(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; int jj, kk; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; uint uintPeerChannel = 0; u8 attr_content[50] = {0x00}; @@ -3537,7 +3537,7 @@ static int rtw_p2p_set_persistent(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; /* The input data is 0 or 1 */ /* 0: disable persistent group functionality */ @@ -3566,12 +3566,12 @@ static int rtw_p2p_prov_disc(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 peerMAC[ETH_ALEN] = {0x00}; int jj, kk; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct list_head *plist, *phead; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; uint uintPeerChannel = 0; u8 attr_content[100] = {0x00}; @@ -3698,7 +3698,7 @@ static int rtw_p2p_got_wpsinfo(struct net_device *dev, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("[%s] data = %s\n", __func__, extra); /* Added by Albert 20110328 */ @@ -4000,11 +4000,11 @@ static int rtw_dbg_port(struct net_device *dev, u32 *pdata, val32; struct sta_info *psta; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct sta_priv *pstapriv = &padapter->stapriv; pdata = (u32 *)&wrqu->data; @@ -4311,7 +4311,7 @@ static int rtw_dbg_port(struct net_device *dev, spin_lock_bh(&pstapriv->sta_hash_lock); for (i = 0; i < NUM_STA; i++) { - phead = &(pstapriv->sta_hash[i]); + phead = &pstapriv->sta_hash[i]; plist = phead->next; while (phead != plist) { @@ -4680,7 +4680,7 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) u8 keylen; struct cmd_obj *pcmd; struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; int res = _SUCCESS; DBG_88E("%s\n", __func__); @@ -4719,7 +4719,7 @@ static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) keylen = 16; } - memcpy(&(psetkeyparm->key[0]), key, keylen); + memcpy(&psetkeyparm->key[0], key, keylen); pcmd->cmdcode = _SetKey_CMD_; pcmd->parmbuf = (u8 *)psetkeyparm; @@ -4762,7 +4762,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, struct sta_info *psta = NULL, *pbcmc_sta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; struct sta_priv *pstapriv = &padapter->stapriv; DBG_88E("%s\n", __func__); @@ -4833,7 +4833,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; - memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; @@ -4844,7 +4844,7 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ - memcpy(&(psecuritypriv->dot11DefKey[wep_key_idx].skey[0]), pwep->KeyMaterial, pwep->KeyLength); + memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; @@ -4871,8 +4871,8 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); /* set mic key */ - memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); - memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); + memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); psecuritypriv->busetkipkey = true; } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { @@ -4914,8 +4914,8 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, psta->dot118021XPrivacy = _TKIP_; /* set mic key */ - memcpy(psta->dot11tkiptxmickey.skey, &(param->u.crypt.key[16]), 8); - memcpy(psta->dot11tkiprxmickey.skey, &(param->u.crypt.key[24]), 8); + memcpy(psta->dot11tkiptxmickey.skey, ¶m->u.crypt.key[16], 8); + memcpy(psta->dot11tkiprxmickey.skey, ¶m->u.crypt.key[24], 8); psecuritypriv->busetkipkey = true; } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { @@ -4945,8 +4945,8 @@ static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); /* set mic key */ - memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[16]), 8); - memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, &(param->u.crypt.key[24]), 8); + memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); + memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); psecuritypriv->busetkipkey = true; } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { @@ -4986,7 +4986,7 @@ static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; unsigned char *pbuf = param->u.bcn_ie.buf; @@ -5027,7 +5027,7 @@ static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); @@ -5082,7 +5082,7 @@ static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; int updated = 0; @@ -5119,7 +5119,7 @@ static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *par int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; struct sta_data *psta_data = (struct sta_data *)param_ex->data; @@ -5176,7 +5176,7 @@ static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) int ret = 0; struct sta_info *psta = NULL; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); @@ -5214,8 +5214,8 @@ static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int ret = 0; unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int ie_len; DBG_88E("%s, len =%d\n", __func__, len); @@ -5252,7 +5252,7 @@ static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *par { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int ie_len; DBG_88E("%s, len =%d\n", __func__, len); @@ -5284,7 +5284,7 @@ static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *par { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int ie_len; DBG_88E("%s, len =%d\n", __func__, len); @@ -5317,9 +5317,9 @@ static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 value; @@ -5342,7 +5342,7 @@ static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *p { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; @@ -5359,7 +5359,7 @@ static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *para { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; @@ -5376,7 +5376,7 @@ static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param * { int ret = 0; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) return -EINVAL; @@ -5503,7 +5503,7 @@ static int rtw_wx_set_priv(struct net_device *dev, /* added for wps2.0 @20110524 */ if (dwrq->flags == 0x8766 && len > 8) { u32 cp_sz; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 *probereq_wpsie = ext; int probereq_wpsie_len = len; u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index c98dbedd10f7..7c76c15809e4 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -591,8 +591,8 @@ static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) static struct net_device_stats *rtw_net_get_stats(struct net_device *pnetdev) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev); - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct recv_priv *precvpriv = &(padapter->recvpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct recv_priv *precvpriv = &padapter->recvpriv; padapter->stats.tx_packets = pxmitpriv->tx_pkts;/* pxmitpriv->tx_pkts++; */ padapter->stats.rx_packets = precvpriv->rx_pkts;/* precvpriv->rx_pkts++; */ diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 36bb3813c677..910da0f0004a 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -96,8 +96,8 @@ void _rtw_mutex_free(struct mutex *pmutex) void _rtw_init_queue(struct __queue *pqueue) { - INIT_LIST_HEAD(&(pqueue->queue)); - spin_lock_init(&(pqueue->lock)); + INIT_LIST_HEAD(&pqueue->queue); + spin_lock_init(&pqueue->lock); } inline u32 rtw_systime_to_ms(u32 systime) diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 8dfabdb02494..e0fbc5751391 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -114,8 +114,8 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sk_buff *skb; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - precvpriv = &(padapter->recvpriv); - pfree_recv_queue = &(precvpriv->free_recv_queue); + precvpriv = &padapter->recvpriv; + pfree_recv_queue = &precvpriv->free_recv_queue; skb = precv_frame->pkt; if (!skb) diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index b55c86131dc7..d666feb87a7a 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -78,7 +78,7 @@ static int rtw_android_get_rssi(struct net_device *net, char *command, int total_len) { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *pcur_network = &pmlmepriv->cur_network; int bytes_written = 0; diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index cdd9734adf94..8f1e33d2fff7 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -204,7 +204,7 @@ static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) goto free_dvobj; /* 3 misc */ - sema_init(&(pdvobjpriv->usb_suspend_sema), 0); + sema_init(&pdvobjpriv->usb_suspend_sema, 0); rtw_reset_continual_urb_error(pdvobjpriv); usb_get_dev(pusbd); -- cgit v1.2.3 From 6839ff57baa4a600f78a63efa8bb9cfd78aa65ba Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:52 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in hal dir Remove unnecessary parentheses in the hal directory reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 8 ++-- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 16 +++---- drivers/staging/r8188eu/hal/hal_intf.c | 2 +- drivers/staging/r8188eu/hal/odm.c | 44 ++++++++--------- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 10 ++-- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 56 +++++++++++----------- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 30 ++++++------ drivers/staging/r8188eu/hal/rtl8188e_mp.c | 8 ++-- drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_led.c | 12 ++--- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 10 ++-- drivers/staging/r8188eu/hal/usb_halinit.c | 32 ++++++------- drivers/staging/r8188eu/hal/usb_ops_linux.c | 6 +-- 13 files changed, 118 insertions(+), 118 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index 5307b10c1bc3..57839f8629ac 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -487,7 +487,7 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) u8 WirelessMode = 0xFF; /* invalid value */ u8 max_rate_idx = 0x13; /* MCS7 */ if (dm_odm->pWirelessMode) - WirelessMode = *(dm_odm->pWirelessMode); + WirelessMode = *dm_odm->pWirelessMode; if (WirelessMode != 0xFF) { if (WirelessMode & ODM_WM_N24G) @@ -580,7 +580,7 @@ void ODM_RA_UpdateRateInfo_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rate if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return; - pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo = &dm_odm->RAInfo[macid]; pRaInfo->RateID = RateID; pRaInfo->RateMask = RateMask; pRaInfo->SGIEnable = SGIEnable; @@ -594,7 +594,7 @@ void ODM_RA_SetRSSI_8188E(struct odm_dm_struct *dm_odm, u8 macid, u8 Rssi) if ((NULL == dm_odm) || (macid >= ASSOCIATE_ENTRY_NUM)) return; - pRaInfo = &(dm_odm->RAInfo[macid]); + pRaInfo = &dm_odm->RAInfo[macid]; pRaInfo->RssiStaRA = Rssi; } @@ -622,7 +622,7 @@ void ODM_RA_TxRPT2Handle_8188E(struct odm_dm_struct *dm_odm, u8 *TxRPT_Buf, u16 else valid = (1 << MacId) & macid_entry0; - pRAInfo = &(dm_odm->RAInfo[MacId]); + pRAInfo = &dm_odm->RAInfo[MacId]; if (valid) { pRAInfo->RTY[0] = (u16)GET_TX_REPORT_TYPE1_RERTY_0(pBuffer); pRAInfo->RTY[1] = (u16)GET_TX_REPORT_TYPE1_RERTY_1(pBuffer); diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index 166adaac371a..68e7c31cc720 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -86,7 +86,7 @@ void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, static void odm_TxPwrTrackSetPwr88E(struct odm_dm_struct *dm_odm) { if (dm_odm->BbSwingFlagOfdm || dm_odm->BbSwingFlagCck) { - PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *(dm_odm->pChannel)); + PHY_SetTxPowerLevel8188E(dm_odm->Adapter, *dm_odm->pChannel); dm_odm->BbSwingFlagOfdm = false; dm_odm->BbSwingFlagCck = false; } @@ -318,7 +318,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][4]; Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][5]; - if ((X != 0) && (*(dm_odm->pBandType) == ODM_BAND_2_4G)) { + if ((X != 0) && (*dm_odm->pBandType == ODM_BAND_2_4G)) { if ((X & 0x00000200) != 0) /* consider minus */ X = X | 0xFFFFFC00; ele_A = ((X * ele_D)>>8)&0x000003FF; @@ -883,7 +883,7 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, }; u32 retryCount = 9; - if (*(dm_odm->mp_mode) == 1) + if (*dm_odm->mp_mode == 1) retryCount = 9; else retryCount = 2; @@ -1086,7 +1086,7 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) { struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + struct mpt_context *pMptCtx = &adapt->mppriv.MptCtx; s32 result[4][8]; /* last is final result */ u8 i, final_candidate, Indexforchannel; bool pathaok, pathbok; @@ -1108,7 +1108,7 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) if (!(dm_odm->SupportAbility & ODM_RF_CALIBRATION)) return; - if (*(dm_odm->mp_mode) == 1) { + if (*dm_odm->mp_mode == 1) { singletone = pMptCtx->bSingleTone; carrier_sup = pMptCtx->bCarrierSuppression; } @@ -1219,9 +1219,9 @@ void PHY_LCCalibrate_8188E(struct adapter *adapt) u32 timeout = 2000, timecount = 0; struct hal_data_8188e *pHalData = GET_HAL_DATA(adapt); struct odm_dm_struct *dm_odm = &pHalData->odmpriv; - struct mpt_context *pMptCtx = &(adapt->mppriv.MptCtx); + struct mpt_context *pMptCtx = &adapt->mppriv.MptCtx; - if (*(dm_odm->mp_mode) == 1) { + if (*dm_odm->mp_mode == 1) { singletone = pMptCtx->bSingleTone; carrier_sup = pMptCtx->bCarrierSuppression; } @@ -1231,7 +1231,7 @@ void PHY_LCCalibrate_8188E(struct adapter *adapt) if (singletone || carrier_sup) return; - while (*(dm_odm->pbScanInProcess) && timecount < timeout) { + while (*dm_odm->pbScanInProcess && timecount < timeout) { ODM_delay_ms(50); timecount += 50; } diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index e07d430dc7ba..87c3bd58b63b 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -248,7 +248,7 @@ void rtw_hal_free_recv_priv(struct adapter *adapt) void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) { - struct mlme_priv *pmlmepriv = &(adapt->mlmepriv); + struct mlme_priv *pmlmepriv = &adapt->mlmepriv; if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { #ifdef CONFIG_88EU_AP_MODE diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 0deeb21c8006..99b61a6c3a7a 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -205,7 +205,7 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) odm_DIG(pDM_Odm); odm_CCKPacketDetectionThresh(pDM_Odm); - if (*(pDM_Odm->pbPowerSaving)) + if (*pDM_Odm->pbPowerSaving) return; odm_RefreshRateAdaptiveMask(pDM_Odm); @@ -440,13 +440,13 @@ void odm_CommonInfoSelfUpdate(struct odm_dm_struct *pDM_Odm) u8 i; struct sta_info *pEntry; - if (*(pDM_Odm->pBandWidth) == ODM_BW40M) { - if (*(pDM_Odm->pSecChOffset) == 1) - pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) - 2; - else if (*(pDM_Odm->pSecChOffset) == 2) - pDM_Odm->ControlChannel = *(pDM_Odm->pChannel) + 2; + if (*pDM_Odm->pBandWidth == ODM_BW40M) { + if (*pDM_Odm->pSecChOffset == 1) + pDM_Odm->ControlChannel = *pDM_Odm->pChannel - 2; + else if (*pDM_Odm->pSecChOffset == 2) + pDM_Odm->ControlChannel = *pDM_Odm->pChannel + 2; } else { - pDM_Odm->ControlChannel = *(pDM_Odm->pChannel); + pDM_Odm->ControlChannel = *pDM_Odm->pChannel; } for (i = 0; i < ODM_ASSOCIATE_ENTRY_NUM; i++) { @@ -485,7 +485,7 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) if (pDM_Odm->SupportICType != ODM_RTL8188E) ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); } else if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { - switch (*(pDM_Odm->pOnePathCCA)) { + switch (*pDM_Odm->pOnePathCCA) { case ODM_CCA_2R: ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); if (pDM_Odm->SupportICType != ODM_RTL8188E) @@ -602,7 +602,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) return; - if (*(pDM_Odm->pbScanInProcess)) + if (*pDM_Odm->pbScanInProcess) return; /* add by Neil Chen to avoid PSD is processing */ @@ -610,8 +610,8 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) return; if (pDM_Odm->SupportICType == ODM_RTL8192D) { - if (*(pDM_Odm->pMacPhyMode) == ODM_DMSP) { - if (*(pDM_Odm->pbMasterOfDMSP)) { + if (*pDM_Odm->pMacPhyMode == ODM_DMSP) { + if (*pDM_Odm->pbMasterOfDMSP) { DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); @@ -621,7 +621,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); } } else { - if (*(pDM_Odm->pBandType) == ODM_BAND_5G) { + if (*pDM_Odm->pBandType == ODM_BAND_5G) { DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); @@ -791,7 +791,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) { u32 ret_value; - struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); + struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; if (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT)) return; @@ -884,7 +884,7 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) { u8 CurCCK_CCAThres; - struct false_alarm_stats *FalseAlmCnt = &(pDM_Odm->FalseAlmCnt); + struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD|ODM_BB_FA_CNT))) return; @@ -1116,7 +1116,7 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u } else if (rssi_level == DM_RATR_STA_MIDDLE) { rate_bitmap = 0x000ff000; } else { - if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + if (*pDM_Odm->pBandWidth == ODM_BW40M) rate_bitmap = 0x000ff015; else rate_bitmap = 0x000ff005; @@ -1127,7 +1127,7 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u } else if (rssi_level == DM_RATR_STA_MIDDLE) { rate_bitmap = 0x0f8ff000; } else { - if (*(pDM_Odm->pBandWidth) == ODM_BW40M) + if (*pDM_Odm->pBandWidth == ODM_BW40M) rate_bitmap = 0x0f8ff015; else rate_bitmap = 0x0f8ff005; @@ -1402,7 +1402,7 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) /* Report every sta's RSSI to FW */ } else { ODM_RA_SetRSSI_8188E( - &(pHalData->odmpriv), (PWDB_rssi[i]&0xFF), (u8)((PWDB_rssi[i]>>16) & 0xFF)); + &pHalData->odmpriv, (PWDB_rssi[i]&0xFF), (u8)((PWDB_rssi[i]>>16) & 0xFF)); } } } @@ -1456,7 +1456,7 @@ void odm_TXPowerTrackingThermalMeterInit(struct odm_dm_struct *pDM_Odm) pDM_Odm->RFCalibrateInfo.bTXPowerTracking = true; pDM_Odm->RFCalibrateInfo.TXPowercount = 0; pDM_Odm->RFCalibrateInfo.bTXPowerTrackingInit = false; - if (*(pDM_Odm->mp_mode) != 1) + if (*pDM_Odm->mp_mode != 1) pDM_Odm->RFCalibrateInfo.TxPowerTrackControl = true; MSG_88E("pDM_Odm TxPowerTrackControl = %d\n", pDM_Odm->RFCalibrateInfo.TxPowerTrackControl); @@ -1624,11 +1624,11 @@ void odm_EdcaTurboCheckCE(struct odm_dm_struct *pDM_Odm) u64 cur_rx_bytes = 0; u8 bbtchange = false; struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - struct xmit_priv *pxmitpriv = &(Adapter->xmitpriv); - struct recv_priv *precvpriv = &(Adapter->recvpriv); + struct xmit_priv *pxmitpriv = &Adapter->xmitpriv; + struct recv_priv *precvpriv = &Adapter->recvpriv; struct registry_priv *pregpriv = &Adapter->registrypriv; - struct mlme_ext_priv *pmlmeext = &(Adapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pregpriv->wifi_spec == 1) goto dm_CheckEdcaTurbo_EXIT; diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 792284eac01f..02e44403fd31 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -16,7 +16,7 @@ static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) { u32 value32; - if (*(dm_odm->mp_mode) == 1) { + if (*dm_odm->mp_mode == 1) { dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* 1:CG, 0:CS */ @@ -44,7 +44,7 @@ static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) { u32 value32; - if (*(dm_odm->mp_mode) == 1) { + if (*dm_odm->mp_mode == 1) { dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, 0); /* Default RX (0/1) */ @@ -83,7 +83,7 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) struct fast_ant_train *dm_fat_tbl = &dm_odm->DM_FatTable; u32 AntCombination = 2; - if (*(dm_odm->mp_mode) == 1) + if (*dm_odm->mp_mode == 1) return; for (i = 0; i < 6; i++) { @@ -327,7 +327,7 @@ void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) { - struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); + struct dyn_primary_cca *PrimaryCCA = &dm_odm->DM_PriCCA; PrimaryCCA->DupRTS_flag = 0; PrimaryCCA->intf_flag = 0; @@ -338,7 +338,7 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) { - struct dyn_primary_cca *PrimaryCCA = &(dm_odm->DM_PriCCA); + struct dyn_primary_cca *PrimaryCCA = &dm_odm->DM_PriCCA; return PrimaryCCA->DupRTS_flag; } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 712307bc674f..02eda8fae25c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -181,7 +181,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi DBG_88E("%s=> mac_id:%d, raid:%d, ra_bitmap=0x%x, shortGIrate=0x%02x\n", __func__, macid, raid, bitmap, shortGIrate); - ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), macid, raid, bitmap, shortGIrate); + ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, macid, raid, bitmap, shortGIrate); } void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) @@ -247,18 +247,18 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; u32 rate_len, pktlen; - struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); @@ -300,7 +300,7 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pktlen); + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; @@ -330,14 +330,14 @@ _ConstructBeacon: static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength) { struct rtw_ieee80211_hdr *pwlanhdr; - struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; __le16 *fctrl; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; /* Frame control. */ - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; SetPwrMgt(fctrl); SetFrameSubType(pframe, WIFI_PSPOLL); @@ -346,10 +346,10 @@ static void ConstructPSPoll(struct adapter *adapt, u8 *pframe, u32 *pLength) SetDuration(pframe, (pmlmeinfo->aid | 0xc000)); /* BSSID. */ - memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); /* TA. */ - memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN); *pLength = 16; } @@ -367,8 +367,8 @@ static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe, u32 pktlen; struct mlme_priv *pmlmepriv = &adapt->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; - struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; @@ -380,21 +380,21 @@ static void ConstructNullFunctionData(struct adapter *adapt, u8 *pframe, switch (cur_network->network.InfrastructureMode) { case Ndis802_11Infrastructure: SetToDs(fctrl); - memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, StaAddr, ETH_ALEN); break; case Ndis802_11APMode: SetFrDs(fctrl); memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(adapt->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&adapt->eeprompriv), ETH_ALEN); break; case Ndis802_11IBSS: default: memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(adapt->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&adapt->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); break; } @@ -425,16 +425,16 @@ static void ConstructProbeRsp(struct adapter *adapt, u8 *pframe, u32 *pLength, u __le16 *fctrl; u8 *mac, *bssid; u32 pktlen; - struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - mac = myid(&(adapt->eeprompriv)); + mac = myid(&adapt->eeprompriv); bssid = cur_network->MacAddress; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, StaAddr, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN); @@ -582,8 +582,8 @@ exit: void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) { struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; bool bSendBeacon = false; bool bcn_valid = false; u8 DLBcnCount = 0; @@ -678,7 +678,7 @@ void rtl8188e_set_p2p_ps_offload_cmd(struct adapter *adapt, u8 p2p_ps_state) { #ifdef CONFIG_88EU_P2P struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - struct wifidirect_info *pwdinfo = &(adapt->wdinfo); + struct wifidirect_info *pwdinfo = &adapt->wdinfo; struct P2P_PS_Offload_t *p2p_ps_offload = &haldata->p2p_ps_offload; u8 i; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index 7ac4257d7ebe..fab385774400 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -30,7 +30,7 @@ static void Init_ODM_ComInfo_88E(struct adapter *Adapter) { struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &hal_data->dmpriv; - struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; u8 cut_ver, fab_ver; /* Init Value */ @@ -79,7 +79,7 @@ static void Update_ODM_ComInfo_88E(struct adapter *Adapter) struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &Adapter->pwrctrlpriv; struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); - struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; struct dm_priv *pdmpriv = &hal_data->dmpriv; int i; @@ -103,17 +103,17 @@ static void Update_ODM_ComInfo_88E(struct adapter *Adapter) ODM_CmnInfoUpdate(dm_odm, ODM_CMNINFO_ABILITY, pdmpriv->InitODMFlag); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_TX_UNI, &(Adapter->xmitpriv.tx_bytes)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_RX_UNI, &(Adapter->recvpriv.rx_bytes)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_WM_MODE, &(pmlmeext->cur_wireless_mode)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_CHNL_OFFSET, &(hal_data->nCur40MhzPrimeSC)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_MODE, &(Adapter->securitypriv.dot11PrivacyAlgrthm)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_BW, &(hal_data->CurrentChannelBW)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_CHNL, &(hal_data->CurrentChannel)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_NET_CLOSED, &(Adapter->net_closed)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_MP_MODE, &(Adapter->registrypriv.mp_mode)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SCAN, &(pmlmepriv->bScanInProcess)); - ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_POWER_SAVING, &(pwrctrlpriv->bpower_saving)); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_TX_UNI, &Adapter->xmitpriv.tx_bytes); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_RX_UNI, &Adapter->recvpriv.rx_bytes); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_WM_MODE, &pmlmeext->cur_wireless_mode); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_CHNL_OFFSET, &hal_data->nCur40MhzPrimeSC); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SEC_MODE, &Adapter->securitypriv.dot11PrivacyAlgrthm); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_BW, &hal_data->CurrentChannelBW); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_CHNL, &hal_data->CurrentChannel); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_NET_CLOSED, &Adapter->net_closed); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_MP_MODE, &Adapter->registrypriv.mp_mode); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_SCAN, &pmlmepriv->bScanInProcess); + ODM_CmnInfoHook(dm_odm, ODM_CMNINFO_POWER_SAVING, &pwrctrlpriv->bpower_saving); ODM_CmnInfoInit(dm_odm, ODM_CMNINFO_RF_ANTENNA_TYPE, hal_data->TRxAntDivType); for (i = 0; i < NUM_STA; i++) @@ -124,7 +124,7 @@ void rtl8188e_InitHalDm(struct adapter *Adapter) { struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &hal_data->dmpriv; - struct odm_dm_struct *dm_odm = &(hal_data->odmpriv); + struct odm_dm_struct *dm_odm = &hal_data->odmpriv; dm_InitGPIOSetting(Adapter); pdmpriv->DM_Type = DM_Type_ByDriver; @@ -216,7 +216,7 @@ u8 AntDivBeforeLink8188E(struct adapter *Adapter) struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); struct odm_dm_struct *dm_odm = &hal_data->odmpriv; struct sw_ant_switch *dm_swat_tbl = &dm_odm->DM_SWAT_Table; - struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; /* Condition that does not need to use antenna diversity. */ if (hal_data->AntDivCfg == 0) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index cc24684945ef..f6d4029eae22 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -11,7 +11,7 @@ s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + struct odm_dm_struct *pDM_Odm = &pHalData->odmpriv; if (!netif_running(padapter->pnetdev)) return _FAIL; @@ -30,7 +30,7 @@ s32 Hal_SetPowerTracking(struct adapter *padapter, u8 enable) void Hal_GetPowerTracking(struct adapter *padapter, u8 *enable) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + struct odm_dm_struct *pDM_Odm = &pHalData->odmpriv; *enable = pDM_Odm->RFCalibrateInfo.TxPowerTrackControl; } @@ -135,7 +135,7 @@ void Hal_MPT_CCKTxPowerAdjustbyIndex(struct adapter *pAdapter, bool beven) { struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); struct mpt_context *pMptCtx = &pAdapter->mppriv.MptCtx; - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + struct odm_dm_struct *pDM_Odm = &pHalData->odmpriv; s32 TempCCk; u8 CCK_index, CCK_index_old = 0; u8 Action = 0; /* 0: no action, 1: even->odd, 2:odd->even */ @@ -209,7 +209,7 @@ void Hal_SetChannel(struct adapter *pAdapter) { struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); struct mp_priv *pmp = &pAdapter->mppriv; - struct odm_dm_struct *pDM_Odm = &(pHalData->odmpriv); + struct odm_dm_struct *pDM_Odm = &pHalData->odmpriv; u8 eRFPath; u8 channel = pmp->channel; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index 6628ad1eb1bb..60fa7e4f5f2c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -186,7 +186,7 @@ i * Currently, we cannot fully disable driver dynamic } } for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { - ptr = (u8 *)(&(TxAGC[idx1])); + ptr = (u8 *)(&TxAGC[idx1]); for (idx2 = 0; idx2 < 4; idx2++) { if (*ptr > RF6052_MAX_TX_PWR) *ptr = RF6052_MAX_TX_PWR; diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_led.c b/drivers/staging/r8188eu/hal/rtl8188eu_led.c index 51fd30b25a5f..2c573e86d3f8 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_led.c @@ -74,21 +74,21 @@ exit: /* Initialize all LED_871x objects. */ void rtl8188eu_InitSwLeds(struct adapter *padapter) { - struct led_priv *pledpriv = &(padapter->ledpriv); + struct led_priv *pledpriv = &padapter->ledpriv; pledpriv->LedControlHandler = LedControl8188eu; - InitLed871x(padapter, &(pledpriv->SwLed0), LED_PIN_LED0); + InitLed871x(padapter, &pledpriv->SwLed0, LED_PIN_LED0); - InitLed871x(padapter, &(pledpriv->SwLed1), LED_PIN_LED1); + InitLed871x(padapter, &pledpriv->SwLed1, LED_PIN_LED1); } /* Description: */ /* DeInitialize all LED_819xUsb objects. */ void rtl8188eu_DeInitSwLeds(struct adapter *padapter) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; - DeInitLed871x(&(ledpriv->SwLed0)); - DeInitLed871x(&(ledpriv->SwLed1)); + DeInitLed871x(&ledpriv->SwLed0); + DeInitLed871x(&ledpriv->SwLed1); } diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index e4aa0b3bc7b7..a38e10b16233 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -170,7 +170,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); struct tx_desc *ptxdesc = (struct tx_desc *)pmem; struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bmcst = IS_MCAST(pattrib->ra); if (adapt->registrypriv.mp_mode == 0) { @@ -489,23 +489,23 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp switch (pfirstframe->attrib.priority) { case 1: case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); + ptxservq = &psta->sta_xmitpriv.bk_q; phwxmit = pxmitpriv->hwxmits + 3; break; case 4: case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); + ptxservq = &psta->sta_xmitpriv.vi_q; phwxmit = pxmitpriv->hwxmits + 1; break; case 6: case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); + ptxservq = &psta->sta_xmitpriv.vo_q; phwxmit = pxmitpriv->hwxmits; break; case 0: case 3: default: - ptxservq = &(psta->sta_xmitpriv.be_q); + ptxservq = &psta->sta_xmitpriv.be_q; phwxmit = pxmitpriv->hwxmits + 2; break; } diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 6ecadba17963..2bce4334ba68 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -409,7 +409,7 @@ static void _InitBeaconMaxError(struct adapter *Adapter, bool InfraMode) static void _InitHWLed(struct adapter *Adapter) { - struct led_priv *pledpriv = &(Adapter->ledpriv); + struct led_priv *pledpriv = &Adapter->ledpriv; if (pledpriv->LedStrategy != HW_LED) return; @@ -1053,7 +1053,7 @@ static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) struct recv_buf *precvbuf; uint status; struct intf_hdl *pintfhdl = &Adapter->iopriv.intf; - struct recv_priv *precvpriv = &(Adapter->recvpriv); + struct recv_priv *precvpriv = &Adapter->recvpriv; u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); _read_port = pintfhdl->io_ops._read_port; @@ -1092,7 +1092,7 @@ static unsigned int rtl8188eu_inirp_deinit(struct adapter *Adapter) /* */ static void _ReadLEDSetting(struct adapter *Adapter, u8 *PROMContent, bool AutoloadFail) { - struct led_priv *pledpriv = &(Adapter->ledpriv); + struct led_priv *pledpriv = &Adapter->ledpriv; struct hal_data_8188e *haldata = GET_HAL_DATA(Adapter); pledpriv->bRegUseLed = true; @@ -1428,7 +1428,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { u64 tsf; struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024; /* us */ @@ -1486,7 +1486,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); } else { /* sitesurvey done */ struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if ((is_client_associated_to_ap(Adapter)) || ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) { @@ -1556,7 +1556,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { u8 u1bAIFS, aSifsTime; struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; rtw_write8(Adapter, REG_SLOT, val[0]); @@ -1980,19 +1980,19 @@ GetHalDefVar8188EUsb( case HAL_DEF_RA_DECISION_RATE: { u8 MacID = *((u8 *)pValue); - *((u8 *)pValue) = ODM_RA_GetDecisionRate_8188E(&(haldata->odmpriv), MacID); + *((u8 *)pValue) = ODM_RA_GetDecisionRate_8188E(&haldata->odmpriv, MacID); } break; case HAL_DEF_RA_SGI: { u8 MacID = *((u8 *)pValue); - *((u8 *)pValue) = ODM_RA_GetShortGI_8188E(&(haldata->odmpriv), MacID); + *((u8 *)pValue) = ODM_RA_GetShortGI_8188E(&haldata->odmpriv, MacID); } break; case HAL_DEF_PT_PWR_STATUS: { u8 MacID = *((u8 *)pValue); - *((u8 *)pValue) = ODM_RA_GetHwPwrStatus_8188E(&(haldata->odmpriv), MacID); + *((u8 *)pValue) = ODM_RA_GetHwPwrStatus_8188E(&haldata->odmpriv, MacID); } break; case HW_VAR_MAX_RX_AMPDU_FACTOR: @@ -2089,8 +2089,8 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l struct sta_info *psta; struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (mac_id >= NUM_STA) /* CAM_SIZE */ return; @@ -2103,8 +2103,8 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l networkType = judge_network_type(adapt, cur_network->SupportedRates, supportRateNum) & 0xf; raid = networktype_to_raid(networkType); mask = update_supported_rate(cur_network->SupportedRates, supportRateNum); - mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&(pmlmeinfo->HT_caps)) : 0; - if (support_short_GI(adapt, &(pmlmeinfo->HT_caps))) + mask |= (pmlmeinfo->HT_enable) ? update_MSC_rate(&pmlmeinfo->HT_caps) : 0; + if (support_short_GI(adapt, &pmlmeinfo->HT_caps)) shortGIrate = true; break; case 1:/* for broadcast/multicast */ @@ -2150,7 +2150,7 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l /* to do ,for 8188E-SMIC */ rtl8188e_set_raid_cmd(adapt, mask); } else { - ODM_RA_UpdateRateInfo_8188E(&(haldata->odmpriv), + ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, mac_id, raid, mask, @@ -2165,8 +2165,8 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l static void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) { u32 value32; - struct mlme_ext_priv *pmlmeext = &(adapt->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u32 bcn_ctrl_reg = REG_BCN_CTRL; /* reset TSF, enable update TSF, correcting TSF On Beacon */ diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 80d44aafd8ea..012846ea8263 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -279,12 +279,12 @@ static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbu } /* HISR */ - memcpy(&(haldata->IntArray[0]), &(pbuf[USB_INTR_CONTENT_HISR_OFFSET]), 4); - memcpy(&(haldata->IntArray[1]), &(pbuf[USB_INTR_CONTENT_HISRE_OFFSET]), 4); + memcpy(&haldata->IntArray[0], &pbuf[USB_INTR_CONTENT_HISR_OFFSET], 4); + memcpy(&haldata->IntArray[1], &pbuf[USB_INTR_CONTENT_HISRE_OFFSET], 4); /* C2H Event */ if (pbuf[0] != 0) - memcpy(&(haldata->C2hArray[0]), &(pbuf[USB_INTR_CONTENT_C2H_OFFSET]), 16); + memcpy(&haldata->C2hArray[0], &pbuf[USB_INTR_CONTENT_C2H_OFFSET], 16); } static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) -- cgit v1.2.3 From 3b522a11b504767ab245173da74b39395ff1ad0d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:53 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_mlme_ext.c Remove unnecessary parentheses in core/rtw_mlme_ext.c. Most of them reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 586 ++++++++++++++-------------- 1 file changed, 293 insertions(+), 293 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 40f7ef78a733..967c7574215a 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -193,7 +193,7 @@ int init_hw_mlme_ext(struct adapter *padapter) static void init_mlme_ext_priv_value(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; unsigned char mixed_datarate[NumRates] = { _1M_RATE_, _2M_RATE_, _5M_RATE_, _11M_RATE_, _6M_RATE_, _9M_RATE_, _12M_RATE_, _18M_RATE_, _24M_RATE_, _36M_RATE_, @@ -354,8 +354,8 @@ int init_mlme_ext_priv(struct adapter *padapter) int res = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pmlmeext->padapter = padapter; @@ -508,14 +508,14 @@ unsigned int OnProbeReq(struct adapter *padapter, struct recv_frame *precv_frame unsigned char *p; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur = &pmlmeinfo->network; u8 *pframe = precv_frame->rx_data; uint len = precv_frame->len; u8 is_valid_p2p_probereq = false; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 wifi_test_chk_rate = 1; if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE) && @@ -638,7 +638,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) int cam_idx; struct sta_info *psta; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->rx_data; @@ -657,8 +657,8 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) pbss = kmalloc(sizeof(struct wlan_bssid_ex), GFP_ATOMIC); if (pbss) { if (collect_bss_info(padapter, precv_frame, pbss) == _SUCCESS) { - update_network(&(pmlmepriv->cur_network.network), pbss, padapter, true); - rtw_get_bcn_info(&(pmlmepriv->cur_network)); + update_network(&pmlmepriv->cur_network.network, pbss, padapter, true); + rtw_get_bcn_info(&pmlmepriv->cur_network); } kfree(pbss); } @@ -736,7 +736,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; uint len = precv_frame->len; @@ -902,14 +902,14 @@ unsigned int OnAuthClient(struct adapter *padapter, struct recv_frame *precv_fra unsigned char *p; unsigned int go2asoc = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; uint pkt_len = precv_frame->len; DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & WIFI_FW_AUTH_STATE)) @@ -987,13 +987,13 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; u8 *pframe = precv_frame->rx_data; uint pkt_len = precv_frame->len; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 p2p_status_code = P2P_STATUS_SUCCESS; u8 *p2pie; u32 p2pielen = 0; @@ -1440,7 +1440,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame struct ndis_802_11_var_ie *pIE; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); */ u8 *pframe = precv_frame->rx_data; uint pkt_len = precv_frame->len; @@ -1448,7 +1448,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame DBG_88E("%s\n", __func__); /* check A1 matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), get_da(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), get_da(pframe), ETH_ALEN)) return _SUCCESS; if (!(pmlmeinfo->state & (WIFI_FW_AUTH_SUCCESS | WIFI_FW_ASSOC_STATE))) @@ -1526,10 +1526,10 @@ unsigned int OnDeAuth(struct adapter *padapter, struct recv_frame *precv_frame) unsigned short reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ /* check A3 */ @@ -1606,10 +1606,10 @@ unsigned int OnDisassoc(struct adapter *padapter, struct recv_frame *precv_frame u16 reason; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ /* check A3 */ @@ -1726,11 +1726,11 @@ unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_fr unsigned char category, action; unsigned short tid, status, reason_code = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 *pframe = precv_frame->rx_data; struct sta_priv *pstapriv = &padapter->stapriv; /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ return _SUCCESS; DBG_88E("%s\n", __func__); @@ -1755,8 +1755,8 @@ unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_fr DBG_88E("%s, action=%d\n", __func__, action); switch (action) { case RTW_WLAN_ACTION_ADDBA_REQ: /* ADDBA request */ - memcpy(&(pmlmeinfo->ADDBA_req), &(frame_body[2]), sizeof(struct ADDBA_request)); - process_addba_req(padapter, (u8 *)&(pmlmeinfo->ADDBA_req), addr); + memcpy(&pmlmeinfo->ADDBA_req, &frame_body[2], sizeof(struct ADDBA_request)); + process_addba_req(padapter, (u8 *)&pmlmeinfo->ADDBA_req, addr); if (pmlmeinfo->bAcceptAddbaReq) issue_action_BA(padapter, addr, RTW_WLAN_ACTION_ADDBA_RESP, 0); @@ -1823,9 +1823,9 @@ void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wifidirect_info *pwdinfo = &padapter->wdinfo; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -1841,12 +1841,12 @@ void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -1855,12 +1855,12 @@ void issue_p2p_GO_request(struct adapter *padapter, u8 *raddr) pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); pwdinfo->negotiation_dialog_token = 1; /* Initialize the dialog value */ - pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &pattrib->pktlen); /* WPS Section */ wpsielen = 0; @@ -2159,9 +2159,9 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wifidirect_info *pwdinfo = &padapter->wdinfo; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -2177,12 +2177,12 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -2191,12 +2191,12 @@ static void issue_p2p_GO_response(struct adapter *padapter, u8 *raddr, u8 *frame pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); pwdinfo->negotiation_dialog_token = frame_body[7]; /* The Dialog Token of provisioning discovery request frame. */ - pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &pattrib->pktlen); /* Commented by Albert 20110328 */ /* Try to get the device password ID from the WPS IE of group negotiation request frame */ @@ -2517,9 +2517,9 @@ static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wifidirect_info *pwdinfo = &padapter->wdinfo; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -2535,12 +2535,12 @@ static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -2549,11 +2549,11 @@ static void issue_p2p_GO_confirm(struct adapter *padapter, u8 *raddr, u8 result) pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(pwdinfo->negotiation_dialog_token), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &pwdinfo->negotiation_dialog_token, &pattrib->pktlen); /* P2P IE Section. */ @@ -2680,9 +2680,9 @@ void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wifidirect_info *pwdinfo = &padapter->wdinfo; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -2697,11 +2697,11 @@ void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -2711,11 +2711,11 @@ void issue_p2p_invitation_request(struct adapter *padapter, u8 *raddr) pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); /* P2P IE Section. */ @@ -2926,9 +2926,9 @@ void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialo unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wifidirect_info *pwdinfo = &padapter->wdinfo; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -2943,11 +2943,11 @@ void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialo pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, raddr, ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -2957,11 +2957,11 @@ void issue_p2p_invitation_response(struct adapter *padapter, u8 *raddr, u8 dialo pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); /* P2P IE Section. */ @@ -3117,9 +3117,9 @@ void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidle unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct wifidirect_info *pwdinfo = &padapter->wdinfo; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -3135,11 +3135,11 @@ void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidle pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, pdev_raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, pdev_raddr, ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -3149,11 +3149,11 @@ void issue_p2p_provision_request(struct adapter *padapter, u8 *pssid, u8 ussidle pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); p2pielen = build_prov_disc_request_p2p_ie(pwdinfo, pframe, pssid, ussidlen, pdev_raddr); @@ -3224,11 +3224,11 @@ void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned char *mac; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u16 beacon_interval = 100; u16 capInfo = 0; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 wpsie[255] = { 0x00 }; u32 wpsielen = 0, p2pielen = 0; @@ -3245,9 +3245,9 @@ void issue_probersp_p2p(struct adapter *padapter, unsigned char *da) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - mac = myid(&(padapter->eeprompriv)); + mac = myid(&padapter->eeprompriv); - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, da, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN); @@ -3470,13 +3470,13 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned char *mac; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 wpsie[255] = { 0x00 }, p2pie[255] = { 0x00 }; u16 wpsielen = 0, p2pielen = 0; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -3491,9 +3491,9 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - mac = myid(&(padapter->eeprompriv)); + mac = myid(&padapter->eeprompriv); - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; if (da) { @@ -3520,9 +3520,9 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) - pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &pattrib->pktlen); else - pframe = rtw_set_ie(pframe, _SSID_IE_, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, P2P_WILDCARD_SSID_LEN, pwdinfo->p2p_wildcard_ssid, &pattrib->pktlen); /* Use the OFDM rate in the P2P probe request frame. (6(B), 9(B), 12(B), 24(B), 36, 48, 54) */ pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pwdinfo->support_rate, &pattrib->pktlen); @@ -3793,7 +3793,7 @@ exit: static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) { struct adapter *adapter = recv_frame->adapter; - struct mlme_ext_priv *mlmeext = &(adapter->mlmeextpriv); + struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; u8 *frame = recv_frame->rx_data; u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | (recv_frame->attrib.frag_num & 0xf); @@ -3832,7 +3832,7 @@ static unsigned int on_action_public_p2p(struct recv_frame *precv_frame) uint len = precv_frame->len; u8 *p2p_ie; u32 p2p_ielen; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 result = P2P_STATUS_SUCCESS; u8 empty_addr[ETH_ALEN] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; #endif /* CONFIG_88EU_P2P */ @@ -4151,7 +4151,7 @@ unsigned int on_action_public(struct adapter *padapter, struct recv_frame *precv u8 category, action; /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN)) + if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), ETH_ALEN)) goto exit; category = frame_body[0]; @@ -4189,12 +4189,12 @@ unsigned int OnAction_p2p(struct adapter *padapter, struct recv_frame *precv_fra u8 category, OUI_Subtype; u8 *pframe = precv_frame->rx_data; uint len = precv_frame->len; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; DBG_88E("%s\n", __func__); /* check RA matches or not */ - if (memcmp(myid(&(padapter->eeprompriv)), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ + if (memcmp(myid(&padapter->eeprompriv), GetAddr1Ptr(pframe), ETH_ALEN))/* for if1, sta/ap mode */ return _SUCCESS; frame_body = (unsigned char *)(pframe + sizeof(struct rtw_ieee80211_hdr_3addr)); @@ -4283,7 +4283,7 @@ Following are some TX fuctions for WiFi MLME void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; pmlmeext->tx_rate = rate; DBG_88E("%s(): rate = %x\n", __func__, rate); @@ -4291,7 +4291,7 @@ void update_mgnt_tx_rate(struct adapter *padapter, u8 rate) void update_mgntframe_attrib(struct adapter *padapter, struct pkt_attrib *pattrib) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; memset((u8 *)(pattrib), 0, sizeof(struct pkt_attrib)); @@ -4414,14 +4414,14 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned int rate_len; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); @@ -4443,11 +4443,11 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, bc_addr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); memcpy(pwlanhdr->addr3, get_my_bssid(cur_network), ETH_ALEN); SetSeqNum(pwlanhdr, 0/*pmlmeext->mgnt_seq*/); @@ -4592,7 +4592,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); { u8 erpinfo = 0; @@ -4639,18 +4639,18 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned char *mac, *bssid; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; #if defined (CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; #endif /* if defined (CONFIG_88EU_AP_MODE) */ - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; unsigned int rate_len; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ pmgntframe = alloc_mgtxmitframe(pxmitpriv); @@ -4668,10 +4668,10 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - mac = myid(&(padapter->eeprompriv)); + mac = myid(&padapter->eeprompriv); bssid = cur_network->MacAddress; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, da, ETH_ALEN); memcpy(pwlanhdr->addr2, mac, ETH_ALEN); @@ -4755,7 +4755,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, ((rate_len > 8) ? 8 : rate_len), cur_network->SupportedRates, &pattrib->pktlen); /* DS parameter set */ - pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&(cur_network->Configuration.DSConfig), &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; @@ -4800,9 +4800,9 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps __le16 *fctrl; unsigned char *mac; unsigned char bssrate[NumRates]; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int bssrate_len = 0; u8 bc_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; @@ -4819,9 +4819,9 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - mac = myid(&(padapter->eeprompriv)); + mac = myid(&padapter->eeprompriv); - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; if (da) { @@ -4844,17 +4844,17 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); if (pssid) - pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &pattrib->pktlen); else - pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, 0, NULL, &pattrib->pktlen); get_rate_set(padapter, bssrate, &bssrate_len); if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen); } /* add wps_ie for wps2.0 */ @@ -4935,9 +4935,9 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short __le16 le_val16; #endif int use_shared_key = 0; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -4952,7 +4952,7 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -4966,8 +4966,8 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short #ifdef CONFIG_88EU_AP_MODE memcpy(pwlanhdr->addr1, psta->hwaddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); /* setting auth algo number */ val16 = (u16)psta->authalg; @@ -4982,21 +4982,21 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short le_val16 = 0; } - pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_val16, &pattrib->pktlen); /* setting auth seq number */ val16 = (u16)psta->auth_seq; le_val16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_val16, &pattrib->pktlen); /* setting status code... */ val16 = status; le_val16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_val16, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_val16, &pattrib->pktlen); /* added challenging text... */ if ((psta->auth_seq == 2) && (psta->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, psta->chg_txt, &pattrib->pktlen); #endif } else { __le32 le_tmp32; @@ -5014,26 +5014,26 @@ void issue_auth(struct adapter *padapter, struct sta_info *psta, unsigned short if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { val32 = ((pmlmeinfo->iv++) | (pmlmeinfo->key_index << 30)); le_tmp32 = cpu_to_le32(val32); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&le_tmp32, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&le_tmp32, &pattrib->pktlen); pattrib->iv_len = 4; } le_tmp16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _AUTH_ALGM_NUM_, (unsigned char *)&le_tmp16, &pattrib->pktlen); /* setting auth seq number */ val16 = pmlmeinfo->auth_seq; le_tmp16 = cpu_to_le16(val16); - pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _AUTH_SEQ_NUM_, (unsigned char *)&le_tmp16, &pattrib->pktlen); /* setting status code... */ le_tmp16 = cpu_to_le16(status); - pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_tmp16, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&le_tmp16, &pattrib->pktlen); /* then checking to see if sending challenging text... */ if ((pmlmeinfo->auth_seq == 3) && (pmlmeinfo->state & WIFI_FW_AUTH_STATE) && (use_shared_key == 1)) { - pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _CHLGETXT_IE_, 128, pmlmeinfo->chg_txt, &pattrib->pktlen); SetPrivacy(fctrl); @@ -5063,15 +5063,15 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i unsigned char *pbuf, *pframe; unsigned short val; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; u8 *ie = pnetwork->IEs; __le16 lestatus, leval; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ DBG_88E("%s\n", __func__); @@ -5089,12 +5089,12 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy((void *)GetAddr1Ptr(pwlanhdr), pstat->hwaddr, ETH_ALEN); - memcpy((void *)GetAddr2Ptr(pwlanhdr), myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy((void *)GetAddr3Ptr(pwlanhdr), get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy((void *)GetAddr2Ptr(pwlanhdr), myid(&padapter->eeprompriv), ETH_ALEN); + memcpy((void *)GetAddr3Ptr(pwlanhdr), get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -5110,19 +5110,19 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* capability */ val = *(unsigned short *)rtw_get_capability_from_ie(ie); - pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_, (unsigned char *)&val, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _CAPABILITY_, (unsigned char *)&val, &pattrib->pktlen); lestatus = cpu_to_le16(status); - pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&lestatus, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _STATUS_CODE_, (unsigned char *)&lestatus, &pattrib->pktlen); leval = cpu_to_le16(pstat->aid | BIT(14) | BIT(15)); - pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, (unsigned char *)&leval, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _ASOC_ID_, (unsigned char *)&leval, &pattrib->pktlen); if (pstat->bssratelen <= 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (pstat->bssratelen-8), pstat->bssrateset+8, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, pstat->bssratelen-8, pstat->bssrateset+8, &pattrib->pktlen); } if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { @@ -5165,7 +5165,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); /* add WPS IE ie for wps 2.0 */ if (pmlmepriv->wps_assoc_resp_ie && pmlmepriv->wps_assoc_resp_ie_len > 0) { @@ -5203,13 +5203,13 @@ void issue_assocreq(struct adapter *padapter) unsigned char rf_type, bssrate[NumRates], sta_bssrate[NumRates]; struct ndis_802_11_var_ie *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int bssrate_len = 0, sta_bssrate_len = 0; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 p2pie[255] = { 0x00 }; u16 p2pielen = 0; #endif /* CONFIG_88EU_P2P */ @@ -5226,11 +5226,11 @@ void issue_assocreq(struct adapter *padapter) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -5254,7 +5254,7 @@ void issue_assocreq(struct adapter *padapter) pattrib->pktlen += 2; /* SSID */ - pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SSID_IE_, pmlmeinfo->network.Ssid.SsidLength, pmlmeinfo->network.Ssid.Ssid, &pattrib->pktlen); /* supported rate & extended supported rate */ @@ -5301,22 +5301,22 @@ void issue_assocreq(struct adapter *padapter) } if (bssrate_len > 8) { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &(pattrib->pktlen)); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, (bssrate_len - 8), (bssrate + 8), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, bssrate, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, bssrate_len - 8, bssrate + 8, &pattrib->pktlen); } else { - pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, bssrate_len, bssrate, &pattrib->pktlen); } /* RSN */ p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _RSN_IE_2_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); if (p) - pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, (p + 2), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _RSN_IE_2_, ie_len, p + 2, &pattrib->pktlen); /* HT caps */ if (padapter->mlmepriv.htpriv.ht_option) { p = rtw_get_ie((pmlmeinfo->network.IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_CAPABILITY_IE_, &ie_len, (pmlmeinfo->network.IELength - sizeof(struct ndis_802_11_fixed_ie))); if (p && !is_ap_in_tkip(padapter)) { - memcpy(&(pmlmeinfo->HT_caps), (p + 2), sizeof(struct HT_caps_element)); + memcpy(&pmlmeinfo->HT_caps, p + 2, sizeof(struct HT_caps_element)); /* to disable 40M Hz support while gd_bw_40MHz_en = 0 */ if (pregpriv->cbw40_enable == 0) @@ -5346,7 +5346,7 @@ void issue_assocreq(struct adapter *padapter) memcpy(pmlmeinfo->HT_caps.u.HT_cap_element.MCS_rate, MCS_rate_2R, 16); break; } - pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&(pmlmeinfo->HT_caps)), &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _HT_CAPABILITY_IE_, ie_len, (u8 *)(&pmlmeinfo->HT_caps), &pattrib->pktlen); } } @@ -5366,7 +5366,7 @@ void issue_assocreq(struct adapter *padapter) if (!memcmp(pIE->data, WPS_OUI, 4)) pIE->Length = 14; } - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, pIE->Length, pIE->data, &pattrib->pktlen); } break; default: @@ -5376,7 +5376,7 @@ void issue_assocreq(struct adapter *padapter) } if (pmlmeinfo->assoc_AP_vendor == HT_IOT_PEER_REALTEK) - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, 6, REALTEK_96B_IE, &pattrib->pktlen); #ifdef CONFIG_88EU_P2P @@ -5537,9 +5537,9 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned if (!padapter) goto exit; - pxmitpriv = &(padapter->xmitpriv); - pmlmeext = &(padapter->mlmeextpriv); - pmlmeinfo = &(pmlmeext->mlmext_info); + pxmitpriv = &padapter->xmitpriv; + pmlmeext = &padapter->mlmeextpriv; + pmlmeinfo = &pmlmeext->mlmext_info; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -5555,7 +5555,7 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) @@ -5567,8 +5567,8 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned SetPwrMgt(fctrl); memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -5597,12 +5597,12 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow int ret; int i = 0; u32 start = jiffies; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* da == NULL, assum it's null data for sta to ap*/ if (!da) - da = get_my_bssid(&(pmlmeinfo->network)); + da = get_my_bssid(&pmlmeinfo->network); do { ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false); @@ -5645,9 +5645,9 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; unsigned short *qc; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_88E("%s\n", __func__); @@ -5670,7 +5670,7 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) @@ -5690,8 +5690,8 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 SetAckpolicy(qc, pattrib->ack_policy); memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -5720,12 +5720,12 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int int ret; int i = 0; u32 start = jiffies; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* da == NULL, assum it's null data for sta to ap*/ if (!da) - da = get_my_bssid(&(pmlmeinfo->network)); + da = get_my_bssid(&pmlmeinfo->network); do { ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false); @@ -5765,13 +5765,13 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int ret = _FAIL; __le16 le_tmp; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ #ifdef CONFIG_88EU_P2P @@ -5795,12 +5795,12 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, da, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -5810,7 +5810,7 @@ static int _issue_deauth(struct adapter *padapter, unsigned char *da, unsigned s pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); le_tmp = cpu_to_le16(reason); - pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_, (unsigned char *)&le_tmp, &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, _RSON_CODE_, (unsigned char *)&le_tmp, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; @@ -5876,8 +5876,8 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; DBG_88E(FUNC_NDEV_FMT" ra =%pM, ch:%u, offset:%u\n", FUNC_NDEV_ARG(padapter->pnetdev), ra, new_ch, ch_offset); @@ -5895,11 +5895,11 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, ra, ETH_ALEN); /* RA */ - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); /* TA */ + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); /* TA */ memcpy(pwlanhdr->addr3, ra, ETH_ALEN); /* DA = RA */ SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); @@ -5915,12 +5915,12 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u category = RTW_WLAN_CATEGORY_SPECTRUM_MGMT; action = RTW_WLAN_ACTION_SPCT_CHL_SWITCH; - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); } - pframe = rtw_set_ie_ch_switch (pframe, &(pattrib->pktlen), 0, new_ch, 0); - pframe = rtw_set_ie_secondary_ch_offset(pframe, &(pattrib->pktlen), + pframe = rtw_set_ie_ch_switch (pframe, &pattrib->pktlen, 0, new_ch, 0); + pframe = rtw_set_ie_secondary_ch_offset(pframe, &pattrib->pktlen, hal_ch_offset_to_secondary_ch_offset(ch_offset)); pattrib->last_txcmdsz = pattrib->pktlen; @@ -5943,9 +5943,9 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch u8 *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -5965,13 +5965,13 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; /* memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); */ memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -5980,8 +5980,8 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &(category), &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &(action), &pattrib->pktlen); if (category == 3) { switch (action) { @@ -5989,15 +5989,15 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch do { pmlmeinfo->dialogToken++; } while (pmlmeinfo->dialogToken == 0); - pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->dialogToken, &pattrib->pktlen); BA_para_set = (0x1002 | ((status & 0xf) << 2)); /* immediate ack & 64 buffer size */ le_tmp = cpu_to_le16(BA_para_set); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); BA_timeout_value = 5000;/* 5ms */ le_tmp = cpu_to_le16(BA_timeout_value); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); psta = rtw_get_stainfo(pstapriv, raddr); if (psta) { @@ -6010,11 +6010,11 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch BA_starting_seqctrl = start_seq << 4; } le_tmp = cpu_to_le16(BA_starting_seqctrl); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); break; case 1: /* ADDBA rsp */ - pframe = rtw_set_fixed_ie(pframe, 1, &(pmlmeinfo->ADDBA_req.dialog_token), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&status), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &pmlmeinfo->ADDBA_req.dialog_token, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&status, &pattrib->pktlen); BA_para_set = le16_to_cpu(pmlmeinfo->ADDBA_req.BA_para_set) & 0x3f; rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); switch (max_rx_ampdu_factor) { @@ -6041,17 +6041,17 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch BA_para_set = BA_para_set | BIT(0); le_tmp = cpu_to_le16(BA_para_set); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(pmlmeinfo->ADDBA_req.BA_timeout_value)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&pmlmeinfo->ADDBA_req.BA_timeout_value, &pattrib->pktlen); break; case 2:/* DELBA */ BA_para_set = (status & 0x1F) << 3; le_tmp = cpu_to_le16(BA_para_set); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); reason_code = 37;/* Requested from peer STA as it does not want to use the mechanism */ le_tmp = cpu_to_le16(reason_code); - pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)(&(le_tmp)), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 2, (unsigned char *)&le_tmp, &pattrib->pktlen); break; default: break; @@ -6073,11 +6073,11 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; struct wlan_network *pnetwork = NULL; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct __queue *queue = &pmlmepriv->scanned_queue; u8 InfoContent[16] = {0}; u8 ICS[8][15]; if ((pmlmepriv->num_FortyMHzIntolerant == 0) || (pmlmepriv->num_sta_no_ht == 0)) @@ -6104,12 +6104,12 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - memcpy(pwlanhdr->addr1, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, get_my_bssid(&(pmlmeinfo->network)), ETH_ALEN); + memcpy(pwlanhdr->addr1, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, get_my_bssid(&pmlmeinfo->network), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -6118,8 +6118,8 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); /* */ if (pmlmepriv->num_FortyMHzIntolerant > 0) { @@ -6127,7 +6127,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) iedata |= BIT(2);/* 20 MHz BSS Width Request */ - pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, EID_BSSCoexistence, 1, &iedata, &pattrib->pktlen); } /* */ @@ -6182,7 +6182,7 @@ static void issue_action_BSSCoexistPacket(struct adapter *padapter) } } - pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, EID_BSSIntolerantChlReport, k, InfoContent, &pattrib->pktlen); } } } @@ -6198,7 +6198,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) struct sta_info *psta = NULL; /* struct recv_reorder_ctrl *preorder_ctrl; */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u16 tid; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) @@ -6276,11 +6276,11 @@ void site_survey(struct adapter *padapter) unsigned char survey_channel = 0, val8; enum rt_scan_type ScanType = SCAN_PASSIVE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u32 initialgain = 0; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; if ((pwdinfo->rx_invitereq_info.scan_op_ch_only) || (pwdinfo->p2p_info.scan_op_ch_only)) { if (pwdinfo->rx_invitereq_info.scan_op_ch_only) { @@ -6334,9 +6334,9 @@ void site_survey(struct adapter *padapter) for (i = 0; i < RTW_SSID_SCAN_AMOUNT; i++) { if (pmlmeext->sitesurvey_res.ssid[i].SsidLength) { /* todo: to issue two probe req??? */ - issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); /* msleep(SURVEY_TO>>1); */ - issue_probereq(padapter, &(pmlmeext->sitesurvey_res.ssid[i]), NULL); + issue_probereq(padapter, &pmlmeext->sitesurvey_res.ssid[i], NULL); } } @@ -6448,7 +6448,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st u8 ie_offset; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; __le32 le32_tmp; len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); @@ -6602,8 +6602,8 @@ void start_create_ibss(struct adapter *padapter) u8 val8; u8 join_type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; pmlmeinfo->bcn_interval = get_beacon_interval(pnetwork); @@ -6653,8 +6653,8 @@ void start_clnt_join(struct adapter *padapter) unsigned short caps; u8 val8; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); int beacon_timeout; pmlmeext->cur_channel = (u8)pnetwork->Configuration.DSConfig; @@ -6706,7 +6706,7 @@ void start_clnt_join(struct adapter *padapter) void start_clnt_auth(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; _cancel_timer_ex(&pmlmeext->link_timer); @@ -6724,7 +6724,7 @@ void start_clnt_auth(struct adapter *padapter) /* issue deauth before issuing auth to deal with the situation */ /* Commented by Albert 2012/07/21 */ /* For the Win8 P2P connection, it will be hard to have a successful connection if this Wi-Fi doesn't connect to it. */ - issue_deauth(padapter, (&(pmlmeinfo->network))->MacAddress, WLAN_REASON_DEAUTH_LEAVING); + issue_deauth(padapter, (&pmlmeinfo->network)->MacAddress, WLAN_REASON_DEAUTH_LEAVING); DBG_88E_LEVEL(_drv_info_, "start auth\n"); issue_auth(padapter, NULL, 0); @@ -6735,7 +6735,7 @@ void start_clnt_auth(struct adapter *padapter) void start_clnt_assoc(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; _cancel_timer_ex(&pmlmeext->link_timer); @@ -6750,7 +6750,7 @@ void start_clnt_assoc(struct adapter *padapter) unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr, unsigned short reason) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* check A3 */ if (!(!memcmp(MacAddr, get_my_bssid(&pmlmeinfo->network), ETH_ALEN))) @@ -7033,7 +7033,7 @@ void report_join_res(struct adapter *padapter, int res) struct joinbss_event *pjoinbss_evt; struct C2HEvent_Header *pc2h_evt_hdr; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; pcmd_obj = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); @@ -7062,7 +7062,7 @@ void report_join_res(struct adapter *padapter, int res) pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pjoinbss_evt = (struct joinbss_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - memcpy((unsigned char *)(&(pjoinbss_evt->network.network)), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + memcpy((unsigned char *)(&pjoinbss_evt->network.network), &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); pjoinbss_evt->network.join_res = res; pjoinbss_evt->network.aid = res; @@ -7111,7 +7111,7 @@ void report_del_sta_event(struct adapter *padapter, unsigned char *MacAddr, unsi pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); pdel_sta_evt = (struct stadel_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - memcpy((unsigned char *)(&(pdel_sta_evt->macaddr)), MacAddr, ETH_ALEN); + memcpy((unsigned char *)(&pdel_sta_evt->macaddr), MacAddr, ETH_ALEN); memcpy((unsigned char *)(pdel_sta_evt->rsvd), (unsigned char *)(&reason), 2); psta = rtw_get_stainfo(&padapter->stapriv, MacAddr); @@ -7163,7 +7163,7 @@ void report_add_sta_event(struct adapter *padapter, unsigned char *MacAddr, int pc2h_evt_hdr->seq = atomic_inc_return(&pmlmeext->event_seq); padd_sta_evt = (struct stassoc_event *)(pevtcmd + sizeof(struct C2HEvent_Header)); - memcpy((unsigned char *)(&(padd_sta_evt->macaddr)), MacAddr, ETH_ALEN); + memcpy((unsigned char *)(&padd_sta_evt->macaddr), MacAddr, ETH_ALEN); padd_sta_evt->cam_id = cam_idx; DBG_88E("report_add_sta_event: add STA\n"); @@ -7180,9 +7180,9 @@ Following are the event callback functions /* for sta/adhoc mode */ void update_sta_info(struct adapter *padapter, struct sta_info *psta) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; /* ERP */ VCS_update(padapter, psta); @@ -7193,7 +7193,7 @@ void update_sta_info(struct adapter *padapter, struct sta_info *psta) psta->htpriv.ampdu_enable = pmlmepriv->htpriv.ampdu_enable; - if (support_short_GI(padapter, &(pmlmeinfo->HT_caps))) + if (support_short_GI(padapter, &pmlmeinfo->HT_caps)) psta->htpriv.sgi = true; psta->qos_option = true; @@ -7222,8 +7222,8 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) { struct sta_info *psta, *psta_bmc; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; u8 join_type; u16 media_status; @@ -7300,8 +7300,8 @@ exit_mlmeext_joinbss_event_callback: void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *psta) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 join_type; DBG_88E("%s\n", __func__); @@ -7338,7 +7338,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p void mlmeext_sta_del_event_callback(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (is_client_associated_to_ap(padapter) || is_IBSS_empty(padapter)) { rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); @@ -7374,7 +7374,7 @@ void _linked_rx_signal_strehgth_display(struct adapter *padapter); void _linked_rx_signal_strehgth_display(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 mac_id; int UndecoratedSmoothedPWDB; if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) @@ -7408,9 +7408,9 @@ void linked_status_chk(struct adapter *padapter) { u32 i; struct sta_info *psta; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_priv *pstapriv = &padapter->stapriv; if (padapter->bRxRSSIDisplay) @@ -7529,7 +7529,7 @@ void survey_timer_hdl(struct adapter *padapter) struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* issue rtw_sitesurvey_cmd */ @@ -7579,7 +7579,7 @@ exit_survey_timer_hdl: void link_timer_hdl(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeinfo->state & WIFI_FW_AUTH_NULL) { DBG_88E("link_timer_hdl:no beacon while connecting\n"); @@ -7635,7 +7635,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) { u8 type; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct setopmode_parm *psetop = (struct setopmode_parm *)pbuf; if (psetop->mode == Ndis802_11APMode) { @@ -7660,8 +7660,8 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) u8 createbss_hdl(struct adapter *padapter, u8 *pbuf) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; /* u32 initialgain; */ @@ -7723,8 +7723,8 @@ u8 join_cmd_hdl(struct adapter *padapter, u8 *pbuf) struct ndis_802_11_var_ie *pIE; struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); struct joinbss_parm *pparm = (struct joinbss_parm *)pbuf; u32 i; @@ -7834,8 +7834,8 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) { struct disconnect_parm *param = (struct disconnect_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&pmlmeinfo->network); u8 val8; if (is_client_associated_to_ap(padapter)) @@ -8002,7 +8002,7 @@ u8 setauth_hdl(struct adapter *padapter, unsigned char *pbuf) { struct setauth_parm *pparm = (struct setauth_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pparm->mode < 4) pmlmeinfo->auth_algo = pparm->mode; @@ -8014,7 +8014,7 @@ u8 setkey_hdl(struct adapter *padapter, u8 *pbuf) unsigned short ctrl; struct setkey_parm *pparm = (struct setkey_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; unsigned char null_sta[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; /* main tx key for wep. */ @@ -8036,7 +8036,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) u16 ctrl = 0; u8 cam_id;/* cam_entry */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct set_stakey_parm *pparm = (struct set_stakey_parm *)pbuf; /* cam_entry: */ @@ -8107,7 +8107,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) { struct addBaReq_parm *pparm = (struct addBaReq_parm *)pbuf; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct sta_info *psta = rtw_get_stainfo(&padapter->stapriv, pparm->addr); @@ -8128,9 +8128,9 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) { struct cmd_obj *ph2c; struct Tx_Beacon_param *ptxBeacon_parm; - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 res = _SUCCESS; int len_diff = 0; @@ -8147,7 +8147,7 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) goto exit; } - memcpy(&(ptxBeacon_parm->network), &(pmlmeinfo->network), sizeof(struct wlan_bssid_ex)); + memcpy(&ptxBeacon_parm->network, &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, @@ -8169,7 +8169,7 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) u16 evt_sz; uint *peventbuf; void (*event_callback)(struct adapter *dev, u8 *pbuf); - struct evt_priv *pevt_priv = &(padapter->evtpriv); + struct evt_priv *pevt_priv = &padapter->evtpriv; peventbuf = (uint *)pbuf; evt_sz = (u16)(*peventbuf&0xffff); -- cgit v1.2.3 From b79f4e84500e4985587232b3ac5ab386e2884f63 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:54 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_ap.c Remove unnecessary parentheses in core/rtw_ap.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 80 +++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index ad37f1f02ee2..d7548619061e 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -12,7 +12,7 @@ void init_mlme_ap_info(struct adapter *padapter) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; @@ -28,9 +28,9 @@ void free_mlme_ap_info(struct adapter *padapter) { struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pmlmepriv->update_bcn = false; pmlmeext->bstart_bss = false; @@ -52,9 +52,9 @@ void free_mlme_ap_info(struct adapter *padapter) static void update_BCNTIM(struct adapter *padapter) { struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; unsigned char *pie = pnetwork_mlmeext->IEs; /* update TIM IE */ @@ -426,7 +426,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) unsigned char limit; unsigned int tx_ra_bitmap = 0; struct ht_priv *psta_ht = NULL; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; if (psta) @@ -518,7 +518,7 @@ void update_bmc_sta(struct adapter *padapter) unsigned char network_type, raid; int i, supportRateNum = 0; unsigned int tx_ra_bitmap = 0; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pcur_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; struct sta_info *psta = rtw_get_bcmc_stainfo(padapter); @@ -600,9 +600,9 @@ void update_bmc_sta(struct adapter *padapter) void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; struct ht_priv *phtpriv_sta = &psta->htpriv; u16 sta_cap_info; @@ -670,7 +670,7 @@ static void update_hw_ht_param(struct adapter *padapter) unsigned char max_AMPDU_len; unsigned char min_MPDU_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_88E("%s\n", __func__); @@ -703,15 +703,15 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) u32 acparm; int ie_len; struct registry_priv *pregpriv = &padapter->registrypriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct security_priv *psecuritypriv = &padapter->securitypriv; struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork_mlmeext = &(pmlmeinfo->network); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork_mlmeext = &pmlmeinfo->network; struct HT_info_element *pht_info = NULL; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ bcn_interval = (u16)pnetwork->Configuration.BeaconPeriod; @@ -846,7 +846,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) u8 WMM_PARA_IE[] = {0x00, 0x50, 0xf2, 0x02, 0x01, 0x01}; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct security_priv *psecuritypriv = &padapter->securitypriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pbss_network = (struct wlan_bssid_ex *)&pmlmepriv->cur_network.network; u8 *ie = pbss_network->IEs; @@ -880,7 +880,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pbss_network->Rssi = 0; - memcpy(pbss_network->MacAddress, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pbss_network->MacAddress, myid(&padapter->eeprompriv), ETH_ALEN); /* beacon interval */ p = rtw_get_beacon_interval_from_ie(ie);/* 8: TimeStamp, 2: Beacon Interval 2:Capability */ @@ -1219,10 +1219,10 @@ static void update_bcn_fixed_ie(struct adapter *padapter) static void update_bcn_erpinfo_ie(struct adapter *padapter) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; unsigned char *p, *ie = pnetwork->IEs; u32 len = 0; @@ -1281,10 +1281,10 @@ static void update_bcn_wps_ie(struct adapter *padapter) u8 *pwps_ie = NULL, *pwps_ie_src; u8 *premainder_ie, *pbackup_remainder_ie = NULL; uint wps_ielen = 0, wps_offset, remainder_ielen; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = &(pmlmeinfo->network); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *pnetwork = &pmlmeinfo->network; unsigned char *ie = pnetwork->IEs; u32 ielen = pnetwork->IELength; @@ -1355,8 +1355,8 @@ void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx) if (!padapter) return; - pmlmepriv = &(padapter->mlmepriv); - pmlmeext = &(padapter->mlmeextpriv); + pmlmepriv = &padapter->mlmepriv; + pmlmeext = &padapter->mlmeextpriv; if (!pmlmeext->bstart_bss) return; @@ -1413,7 +1413,7 @@ static int rtw_ht_operation_update(struct adapter *padapter) { u16 cur_op_mode, new_op_mode; int op_mode_changes = 0; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv_ap = &pmlmepriv->htpriv; if (pmlmepriv->htpriv.ht_option) @@ -1506,8 +1506,8 @@ void associated_clients_update(struct adapter *padapter, u8 updated) void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) { u8 beacon_updated = false; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (!(psta->flags & WLAN_STA_SHORT_PREAMBLE)) { if (!psta->no_short_preamble_set) { @@ -1641,8 +1641,8 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) u8 bss_cap_update_on_sta_leave(struct adapter *padapter, struct sta_info *psta) { u8 beacon_updated = false; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; if (!psta) return beacon_updated; @@ -1750,7 +1750,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) @@ -1785,7 +1785,7 @@ int rtw_sta_flush(struct adapter *padapter) struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); @@ -1821,7 +1821,7 @@ int rtw_sta_flush(struct adapter *padapter) void sta_info_update(struct adapter *padapter, struct sta_info *psta) { int flags = psta->flags; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; /* update wmm cap. */ if (WLAN_STA_WME&flags) @@ -1858,7 +1858,7 @@ void ap_sta_info_defer_update(struct adapter *padapter, struct sta_info *psta) void start_ap_mode(struct adapter *padapter) { int i; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; @@ -1894,7 +1894,7 @@ void start_ap_mode(struct adapter *padapter) pmlmepriv->p2p_probe_resp_ie = NULL; /* for ACL */ - INIT_LIST_HEAD(&(pacl_list->acl_node_q.queue)); + INIT_LIST_HEAD(&pacl_list->acl_node_q.queue); pacl_list->num = 0; pacl_list->mode = 0; for (i = 0; i < NUM_ACL; i++) { @@ -1909,7 +1909,7 @@ void stop_ap_mode(struct adapter *padapter) struct rtw_wlan_acl_node *paclnode; struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; struct __queue *pacl_node_q = &pacl_list->acl_node_q; -- cgit v1.2.3 From b5f7cd5fdfff005728e32a57e0b5817b8675f67d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:55 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_wlan_util.c Remove unnecessary parentheses in core/rtw_wlan_util.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-6-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_wlan_util.c | 70 ++++++++++++++-------------- 1 file changed, 35 insertions(+), 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 21a3d0868214..e897920b7af1 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -107,7 +107,7 @@ u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen { u8 network_type = 0; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeext->cur_channel > 14) { if (pmlmeinfo->HT_enable) @@ -411,7 +411,7 @@ int is_client_associated_to_ap(struct adapter *padapter) return _FAIL; pmlmeext = &padapter->mlmeextpriv; - pmlmeinfo = &(pmlmeext->mlmext_info); + pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) return true; @@ -422,7 +422,7 @@ int is_client_associated_to_ap(struct adapter *padapter) int is_client_associated_to_ibss(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) return true; @@ -434,7 +434,7 @@ int is_IBSS_empty(struct adapter *padapter) { unsigned int i; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (i = IBSS_START_MAC_ID; i < NUM_STA; i++) { if (pmlmeinfo->FW_sta_info[i].status == 1) @@ -505,7 +505,7 @@ int allocate_fw_sta_entry(struct adapter *padapter) { unsigned int mac_id; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; for (mac_id = IBSS_START_MAC_ID; mac_id < NUM_STA; mac_id++) { if (pmlmeinfo->FW_sta_info[mac_id].status == 0) { @@ -521,7 +521,7 @@ int allocate_fw_sta_entry(struct adapter *padapter) void flush_all_cam_entry(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; rtw_hal_set_hwreg(padapter, HW_VAR_CAM_INVALID_ALL, NULL); @@ -531,9 +531,9 @@ void flush_all_cam_entry(struct adapter *padapter) int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { /* struct registry_priv *pregpriv = &padapter->registrypriv; */ - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmepriv->qospriv.qos_option == 0) { pmlmeinfo->WMM_enable = 0; @@ -541,7 +541,7 @@ int WMM_param_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) } pmlmeinfo->WMM_enable = 1; - memcpy(&(pmlmeinfo->WMM_param), (pIE->data + 6), sizeof(struct WMM_para_element)); + memcpy(&pmlmeinfo->WMM_param, pIE->data + 6, sizeof(struct WMM_para_element)); return true; } @@ -553,7 +553,7 @@ void WMMOnAssocRsp(struct adapter *padapter) u32 acParm, i; u32 edca[4], inx[4]; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct registry_priv *pregpriv = &padapter->registrypriv; @@ -655,9 +655,9 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var unsigned char new_bwmode; unsigned char new_ch_offset; struct HT_info_element *pHT_info; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -706,7 +706,7 @@ static void bwmode_update_check(struct adapter *padapter, struct ndis_802_11_var if (pmlmeinfo->bwmode_updated) { struct sta_info *psta; - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; struct sta_priv *pstapriv = &padapter->stapriv; /* set_channel_bwmode(padapter, pmlmeext->cur_channel, pmlmeext->cur_ch_offset, pmlmeext->cur_bwmode); */ @@ -734,7 +734,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) u8 rf_type; u8 max_AMPDU_len, min_MPDU_spacing; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -780,7 +780,7 @@ void HT_caps_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct ht_priv *phtpriv = &pmlmepriv->htpriv; @@ -794,7 +794,7 @@ void HT_info_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) return; pmlmeinfo->HT_info_enable = 1; - memcpy(&(pmlmeinfo->HT_info), pIE->data, pIE->Length); + memcpy(&pmlmeinfo->HT_info, pIE->data, pIE->Length); } void HTOnAssocRsp(struct adapter *padapter) @@ -803,7 +803,7 @@ void HTOnAssocRsp(struct adapter *padapter) unsigned char min_MPDU_spacing; /* struct registry_priv *pregpriv = &padapter->registrypriv; */ struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; DBG_88E("%s\n", __func__); @@ -831,20 +831,20 @@ void HTOnAssocRsp(struct adapter *padapter) void ERP_IE_handler(struct adapter *padapter, struct ndis_802_11_var_ie *pIE) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pIE->Length > 1) return; pmlmeinfo->ERP_enable = 1; - memcpy(&(pmlmeinfo->ERP_IE), pIE->data, pIE->Length); + memcpy(&pmlmeinfo->ERP_IE, pIE->data, pIE->Length); } void VCS_update(struct adapter *padapter, struct sta_info *psta) { struct registry_priv *pregpriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pregpriv->vrtl_carrier_sense) { /* 0:off 1:on 2:auto */ case 0: /* off */ @@ -883,7 +883,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) unsigned int len; unsigned char *p; unsigned short val16, subtype; - struct wlan_network *cur_network = &(Adapter->mlmepriv.cur_network); + struct wlan_network *cur_network = &Adapter->mlmepriv.cur_network; /* u8 wpa_ie[255], rsn_ie[255]; */ u16 wpa_len = 0, rsn_len = 0; u8 encryp_protocol = 0; @@ -1101,8 +1101,8 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) u32 i; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { @@ -1168,8 +1168,8 @@ unsigned int is_ap_in_wep(struct adapter *padapter) u32 i; struct ndis_802_11_var_ie *pIE; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; if (rtw_get_capability((struct wlan_bssid_ex *)cur_network) & WLAN_CAPABILITY_PRIVACY) { for (i = sizeof(struct ndis_802_11_fixed_ie); i < pmlmeinfo->network.IELength;) { @@ -1278,7 +1278,7 @@ int support_short_GI(struct adapter *padapter, struct HT_caps_element *pHT_caps) { unsigned char bit_offset; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!(pmlmeinfo->HT_enable)) return _FAIL; @@ -1429,7 +1429,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) void update_IOT_info(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; switch (pmlmeinfo->assoc_AP_vendor) { case HT_IOT_PEER_MARVELL: @@ -1458,7 +1458,7 @@ void update_IOT_info(struct adapter *padapter) void update_capinfo(struct adapter *Adapter, u16 updateCap) { struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; bool ShortPreamble; /* Check preamble mode, 2005.01.06, by rcnjko. */ @@ -1506,8 +1506,8 @@ void update_wireless_mode(struct adapter *padapter) int ratelen, network_type = 0; u32 SIFS_Timer; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *cur_network = &(pmlmeinfo->network); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct wlan_bssid_ex *cur_network = &pmlmeinfo->network; unsigned char *rate = cur_network->SupportedRates; ratelen = rtw_get_rateset_len(cur_network->SupportedRates); @@ -1547,8 +1547,8 @@ void update_wireless_mode(struct adapter *padapter) void update_bmc_sta_support_rate(struct adapter *padapter, u32 mac_id) { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeext->cur_wireless_mode & WIRELESS_11B) { /* Only B, B/G, and B/G/N AP could use CCK rate */ @@ -1563,8 +1563,8 @@ int update_sta_support_rate(struct adapter *padapter, u8 *pvar_ie, uint var_ie_l unsigned int ie_len; struct ndis_802_11_var_ie *pIE; int supportRateNum = 0; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; pIE = (struct ndis_802_11_var_ie *)rtw_get_ie(pvar_ie, _SUPPORTEDRATES_IE_, &ie_len, var_ie_len); if (!pIE) @@ -1589,7 +1589,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) struct sta_priv *pstapriv = &padapter->stapriv; struct ADDBA_request *preq = (struct ADDBA_request *)paddba_req; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; psta = rtw_get_stainfo(pstapriv, addr); -- cgit v1.2.3 From f6cf663a7258292098b19b6959f9ce87894f9c00 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:56 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_led.c Remove unnecessary parentheses in core/rtw_led.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-7-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_led.c | 354 ++++++++++++++++----------------- 1 file changed, 177 insertions(+), 177 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 22d4df9c92a5..671c7cbc7cc3 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -17,7 +17,7 @@ void BlinkTimerCallback(struct timer_list *t) if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; - _set_workitem(&(pLed->BlinkWorkItem)); + _set_workitem(&pLed->BlinkWorkItem); } /* */ @@ -62,7 +62,7 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_8 ResetLedStatus(pLed); timer_setup(&pLed->BlinkTimer, BlinkTimerCallback, 0); - _init_workitem(&(pLed->BlinkWorkItem), BlinkWorkItemCallback, pLed); + _init_workitem(&pLed->BlinkWorkItem, BlinkWorkItemCallback, pLed); } /* */ @@ -71,8 +71,8 @@ void InitLed871x(struct adapter *padapter, struct LED_871x *pLed, enum LED_PIN_8 /* */ void DeInitLed871x(struct LED_871x *pLed) { - _cancel_workitem_sync(&(pLed->BlinkWorkItem)); - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_workitem_sync(&pLed->BlinkWorkItem); + _cancel_timer_ex(&pLed->BlinkTimer); ResetLedStatus(pLed); } @@ -85,7 +85,7 @@ void DeInitLed871x(struct LED_871x *pLed) static void SwLedBlink(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ @@ -141,20 +141,20 @@ static void SwLedBlink(struct LED_871x *pLed) /* Schedule a timer to toggle LED state. */ switch (pLed->CurrLedState) { case LED_BLINK_NORMAL: - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); break; case LED_BLINK_SLOWLY: case LED_BLINK_StartToBlink: - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); break; case LED_BLINK_WPS: if (pLed->BlinkingLedState == RTW_LED_ON) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LONG_INTERVAL); else - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LONG_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LONG_INTERVAL); break; default: - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); break; } } @@ -163,7 +163,7 @@ static void SwLedBlink(struct LED_871x *pLed) static void SwLedBlink1(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ @@ -184,14 +184,14 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); break; case LED_BLINK_NORMAL: if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); break; case LED_BLINK_SCAN: pLed->BlinkTimes--; @@ -205,7 +205,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; @@ -213,7 +213,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } pLed->bLedScanBlinkInProgress = false; } else { @@ -221,7 +221,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_BLINK_TXRX: @@ -236,7 +236,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); } else if (!check_fwstate(pmlmepriv, _FW_LINKED)) { pLed->bLedNoLinkBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_SLOWLY; @@ -244,7 +244,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } pLed->BlinkTimes = 0; pLed->bLedBlinkInProgress = false; @@ -253,7 +253,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } break; case LED_BLINK_WPS: @@ -261,7 +261,7 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); break; case LED_BLINK_WPS_STOP: /* WPS success */ if (pLed->BlinkingLedState == RTW_LED_ON) @@ -276,12 +276,12 @@ static void SwLedBlink1(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); pLed->bLedWPSBlinkInProgress = false; } else { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); } break; default: @@ -292,7 +292,7 @@ static void SwLedBlink1(struct LED_871x *pLed) static void SwLedBlink2(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ @@ -327,7 +327,7 @@ static void SwLedBlink2(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } } break; @@ -356,7 +356,7 @@ static void SwLedBlink2(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } } break; @@ -368,7 +368,7 @@ static void SwLedBlink2(struct LED_871x *pLed) static void SwLedBlink3(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ @@ -407,7 +407,7 @@ static void SwLedBlink3(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } } break; @@ -439,7 +439,7 @@ static void SwLedBlink3(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } } break; @@ -448,12 +448,12 @@ static void SwLedBlink3(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); break; case LED_BLINK_WPS_STOP: /* WPS success */ if (pLed->BlinkingLedState == RTW_LED_ON) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); bStopBlinking = false; } else { bStopBlinking = true; @@ -477,8 +477,8 @@ static void SwLedBlink3(struct LED_871x *pLed) static void SwLedBlink4(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed1 = &(ledpriv->SwLed1); + struct led_priv *ledpriv = &padapter->ledpriv; + struct LED_871x *pLed1 = &ledpriv->SwLed1; u8 bStopBlinking = false; /* Change LED according to BlinkingLedState specified. */ @@ -499,15 +499,15 @@ static void SwLedBlink4(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); break; case LED_BLINK_StartToBlink: if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); } break; case LED_BLINK_SCAN: @@ -524,7 +524,7 @@ static void SwLedBlink4(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } pLed->bLedScanBlinkInProgress = false; } else { @@ -535,7 +535,7 @@ static void SwLedBlink4(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } } break; @@ -553,7 +553,7 @@ static void SwLedBlink4(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } pLed->bLedBlinkInProgress = false; } else { @@ -564,17 +564,17 @@ static void SwLedBlink4(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } } break; case LED_BLINK_WPS: if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); } break; case LED_BLINK_WPS_STOP: /* WPS authentication fail */ @@ -583,7 +583,7 @@ static void SwLedBlink4(struct LED_871x *pLed) else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); break; case LED_BLINK_WPS_STOP_OVERLAP: /* WPS session overlap */ pLed->BlinkTimes--; @@ -597,14 +597,14 @@ static void SwLedBlink4(struct LED_871x *pLed) if (bStopBlinking) { pLed->BlinkTimes = 10; pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); } else { if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); } break; default: @@ -639,7 +639,7 @@ static void SwLedBlink5(struct LED_871x *pLed) pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; if (!pLed->bLedOn) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } pLed->bLedScanBlinkInProgress = false; @@ -651,7 +651,7 @@ static void SwLedBlink5(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } } break; @@ -670,7 +670,7 @@ static void SwLedBlink5(struct LED_871x *pLed) pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; if (!pLed->bLedOn) - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } pLed->bLedBlinkInProgress = false; @@ -682,7 +682,7 @@ static void SwLedBlink5(struct LED_871x *pLed) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } } break; @@ -706,9 +706,9 @@ static void SwLedBlink6(struct LED_871x *pLed) /* ALPHA, added by chiyoko, 20090106 */ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed = &(ledpriv->SwLed0); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct led_priv *ledpriv = &padapter->ledpriv; + struct LED_871x *pLed = &ledpriv->SwLed0; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; switch (LedAction) { case LED_CTL_POWER_ON: @@ -718,11 +718,11 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -732,7 +732,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } break; case LED_CTL_LINK: @@ -740,11 +740,11 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedLinkBlinkInProgress = true; @@ -753,7 +753,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LINK_INTERVAL_ALPHA); } break; case LED_CTL_SITE_SURVEY: @@ -763,15 +763,15 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -781,7 +781,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_TX: @@ -790,11 +790,11 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } pLed->bLedBlinkInProgress = true; @@ -804,26 +804,26 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } break; case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: if (!pLed->bLedWPSBlinkInProgress) { if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -832,42 +832,42 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_STOP_WPS: if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); else pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_WPS_STOP; if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_STOP_WPS_FAIL: if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -876,29 +876,29 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); break; case LED_CTL_POWER_OFF: pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } SwLedOff(padapter, pLed); @@ -911,9 +911,9 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct /* Arcadyan/Sitecom , added by chiyoko, 20090216 */ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); + struct LED_871x *pLed = &ledpriv->SwLed0; switch (LedAction) { case LED_CTL_SITE_SURVEY: @@ -923,7 +923,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct return; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -933,7 +933,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_TX: @@ -948,37 +948,37 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } break; case LED_CTL_LINK: pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); break; case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: if (!pLed->bLedWPSBlinkInProgress) { if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_STOP_WPS: @@ -988,7 +988,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct } else { pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_STOP_WPS_FAIL: @@ -998,7 +998,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct } else { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_START_TO_LINK: @@ -1006,26 +1006,26 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct if (!IS_LED_BLINKING(pLed)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_POWER_OFF: pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); break; default: break; @@ -1035,9 +1035,9 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct /* COREGA, added by chiyoko, 20090316 */ static void SwLedControlMode3(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); + struct LED_871x *pLed = &ledpriv->SwLed0; switch (LedAction) { case LED_CTL_SITE_SURVEY: @@ -1047,7 +1047,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct return; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1057,7 +1057,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_TX: @@ -1072,7 +1072,7 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } break; case LED_CTL_LINK: @@ -1081,25 +1081,25 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); break; case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: if (!pLed->bLedWPSBlinkInProgress) { if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; @@ -1108,12 +1108,12 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_STOP_WPS: if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } else { pLed->bLedWPSBlinkInProgress = true; @@ -1122,46 +1122,46 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = LED_BLINK_WPS_STOP; if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_WPS_SUCESS_INTERVAL_ALPHA); } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_STOP_WPS_FAIL: if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); break; case LED_CTL_START_TO_LINK: case LED_CTL_NO_LINK: if (!IS_LED_BLINKING(pLed)) { pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } break; case LED_CTL_POWER_OFF: pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); break; default: break; @@ -1171,33 +1171,33 @@ static void SwLedControlMode2(struct adapter *padapter, enum LED_CTL_MODE LedAct /* Edimax-Belkin, added by chiyoko, 20090413 */ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); - struct LED_871x *pLed1 = &(ledpriv->SwLed1); + struct LED_871x *pLed = &ledpriv->SwLed0; + struct LED_871x *pLed1 = &ledpriv->SwLed1; switch (LedAction) { case LED_CTL_START_TO_LINK: if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); + _cancel_timer_ex(&pLed1->BlinkTimer); pLed1->BlinkingLedState = RTW_LED_OFF; pLed1->CurrLedState = RTW_LED_OFF; if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } if (!pLed->bLedStartToLinkBlinkInProgress) { if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } @@ -1205,10 +1205,10 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->CurrLedState = LED_BLINK_StartToBlink; if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); } } break; @@ -1218,13 +1218,13 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct if (LedAction == LED_CTL_LINK) { if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); + _cancel_timer_ex(&pLed1->BlinkTimer); pLed1->BlinkingLedState = RTW_LED_OFF; pLed1->CurrLedState = RTW_LED_OFF; if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } } @@ -1232,7 +1232,7 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } @@ -1242,7 +1242,7 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); } break; case LED_CTL_SITE_SURVEY: @@ -1252,11 +1252,11 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1266,7 +1266,7 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_TX: @@ -1275,7 +1275,7 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct if (pLed->CurrLedState == LED_BLINK_SCAN || IS_LED_WPS_BLINKING(pLed)) return; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } pLed->bLedBlinkInProgress = true; @@ -1285,49 +1285,49 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } break; case LED_CTL_START_WPS: /* wait until xinpin finish */ case LED_CTL_START_WPS_BOTTON: if (pLed1->bLedWPSBlinkInProgress) { pLed1->bLedWPSBlinkInProgress = false; - _cancel_timer_ex(&(pLed1->BlinkTimer)); + _cancel_timer_ex(&pLed1->BlinkTimer); pLed1->BlinkingLedState = RTW_LED_OFF; pLed1->CurrLedState = RTW_LED_OFF; if (pLed1->bLedOn) - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); } if (!pLed->bLedWPSBlinkInProgress) { if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } pLed->bLedWPSBlinkInProgress = true; pLed->CurrLedState = LED_BLINK_WPS; if (pLed->bLedOn) { pLed->BlinkingLedState = RTW_LED_OFF; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SLOWLY_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); } else { pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); } } break; case LED_CTL_STOP_WPS: /* WPS connect success */ if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } @@ -1337,12 +1337,12 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); break; case LED_CTL_STOP_WPS_FAIL: /* WPS authentication fail */ if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1351,11 +1351,11 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); /* LED1 settings */ if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed1->BlinkTimer)); + _cancel_timer_ex(&pLed1->BlinkTimer); else pLed1->bLedWPSBlinkInProgress = true; pLed1->CurrLedState = LED_BLINK_WPS_STOP; @@ -1363,11 +1363,11 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed1->BlinkingLedState = RTW_LED_OFF; else pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); break; case LED_CTL_STOP_WPS_FAIL_OVERLAP: /* WPS session overlap */ if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } pLed->bLedNoLinkBlinkInProgress = true; @@ -1376,11 +1376,11 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NO_LINK_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NO_LINK_INTERVAL_ALPHA); /* LED1 settings */ if (pLed1->bLedWPSBlinkInProgress) - _cancel_timer_ex(&(pLed1->BlinkTimer)); + _cancel_timer_ex(&pLed1->BlinkTimer); else pLed1->bLedWPSBlinkInProgress = true; pLed1->CurrLedState = LED_BLINK_WPS_STOP_OVERLAP; @@ -1389,38 +1389,38 @@ static void SwLedControlMode4(struct adapter *padapter, enum LED_CTL_MODE LedAct pLed1->BlinkingLedState = RTW_LED_OFF; else pLed1->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_NORMAL_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_NORMAL_INTERVAL); break; case LED_CTL_POWER_OFF: pLed->CurrLedState = RTW_LED_OFF; pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedNoLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedNoLinkBlinkInProgress = false; } if (pLed->bLedLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } if (pLed->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedWPSBlinkInProgress = false; } if (pLed->bLedScanBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedScanBlinkInProgress = false; } if (pLed->bLedStartToLinkBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedStartToLinkBlinkInProgress = false; } if (pLed1->bLedWPSBlinkInProgress) { - _cancel_timer_ex(&(pLed1->BlinkTimer)); + _cancel_timer_ex(&pLed1->BlinkTimer); pLed1->bLedWPSBlinkInProgress = false; } pLed1->BlinkingLedState = LED_UNKNOWN; @@ -1439,9 +1439,9 @@ SwLedControlMode5( enum LED_CTL_MODE LedAction ) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct LED_871x *pLed = &(ledpriv->SwLed0); + struct LED_871x *pLed = &ledpriv->SwLed0; switch (LedAction) { case LED_CTL_POWER_ON: @@ -1450,13 +1450,13 @@ SwLedControlMode5( pLed->CurrLedState = RTW_LED_ON; pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), 0); + _set_timer(&pLed->BlinkTimer, 0); break; case LED_CTL_SITE_SURVEY: if ((pmlmepriv->LinkDetectInfo.bBusyTraffic) && (check_fwstate(pmlmepriv, _FW_LINKED))) { } else if (!pLed->bLedScanBlinkInProgress) { if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } pLed->bLedScanBlinkInProgress = true; @@ -1466,7 +1466,7 @@ SwLedControlMode5( pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_SCAN_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_SCAN_INTERVAL_ALPHA); } break; case LED_CTL_TX: @@ -1481,7 +1481,7 @@ SwLedControlMode5( pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed->BlinkTimer), LED_BLINK_FASTER_INTERVAL_ALPHA); + _set_timer(&pLed->BlinkTimer, LED_BLINK_FASTER_INTERVAL_ALPHA); } break; case LED_CTL_POWER_OFF: @@ -1489,7 +1489,7 @@ SwLedControlMode5( pLed->BlinkingLedState = RTW_LED_OFF; if (pLed->bLedBlinkInProgress) { - _cancel_timer_ex(&(pLed->BlinkTimer)); + _cancel_timer_ex(&pLed->BlinkTimer); pLed->bLedBlinkInProgress = false; } SwLedOff(padapter, pLed); @@ -1506,17 +1506,17 @@ SwLedControlMode6( enum LED_CTL_MODE LedAction ) { - struct led_priv *ledpriv = &(padapter->ledpriv); - struct LED_871x *pLed0 = &(ledpriv->SwLed0); + struct led_priv *ledpriv = &padapter->ledpriv; + struct LED_871x *pLed0 = &ledpriv->SwLed0; switch (LedAction) { case LED_CTL_POWER_ON: case LED_CTL_LINK: case LED_CTL_NO_LINK: - _cancel_timer_ex(&(pLed0->BlinkTimer)); + _cancel_timer_ex(&pLed0->BlinkTimer); pLed0->CurrLedState = RTW_LED_ON; pLed0->BlinkingLedState = RTW_LED_ON; - _set_timer(&(pLed0->BlinkTimer), 0); + _set_timer(&pLed0->BlinkTimer, 0); break; case LED_CTL_POWER_OFF: SwLedOff(padapter, pLed0); @@ -1534,7 +1534,7 @@ SwLedControlMode6( void BlinkHandler(struct LED_871x *pLed) { struct adapter *padapter = pLed->padapter; - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped)) return; @@ -1568,7 +1568,7 @@ void BlinkHandler(struct LED_871x *pLed) void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) { - struct led_priv *ledpriv = &(padapter->ledpriv); + struct led_priv *ledpriv = &padapter->ledpriv; struct registry_priv *registry_par; if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || -- cgit v1.2.3 From 7bc4f399dc11501bc160d54f2b4943f3a87e1bb8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:57 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_p2p.c Remove unnecessary parentheses in core/rtw_p2p.c. Most of them reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-8-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_p2p.c | 78 +++++++++++++++++----------------- 1 file changed, 39 insertions(+), 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index b4497444a7af..9b3ea8a31508 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -118,8 +118,8 @@ static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; struct adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ __be32 p2poui = cpu_to_be32(P2POUI); u8 oui_subtype = P2P_GO_DISC_REQUEST; @@ -140,7 +140,7 @@ static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, da, ETH_ALEN); @@ -155,10 +155,10 @@ static void issue_group_disc_req(struct wifidirect_info *pwdinfo, u8 *da) pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); /* there is no IE in this P2P action frame */ @@ -175,8 +175,8 @@ static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 s struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; struct adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; unsigned char category = RTW_WLAN_CATEGORY_PUBLIC; u8 action = P2P_PUB_ACTION_ACTION; __be32 p2poui = cpu_to_be32(P2POUI); @@ -199,7 +199,7 @@ static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 s pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, da, ETH_ALEN); @@ -214,11 +214,11 @@ static void issue_p2p_devdisc_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 s pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); /* Build P2P public action frame header */ - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); /* Build P2P IE */ /* P2P OUI */ @@ -253,8 +253,8 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, unsigned char *pframe; struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; pmgntframe = alloc_mgtxmitframe(pxmitpriv); if (!pmgntframe) @@ -269,12 +269,12 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, raddr, ETH_ALEN); - memcpy(pwlanhdr->addr2, myid(&(padapter->eeprompriv)), ETH_ALEN); - memcpy(pwlanhdr->addr3, myid(&(padapter->eeprompriv)), ETH_ALEN); + memcpy(pwlanhdr->addr2, myid(&padapter->eeprompriv), ETH_ALEN); + memcpy(pwlanhdr->addr3, myid(&padapter->eeprompriv), ETH_ALEN); SetSeqNum(pwlanhdr, pmlmeext->mgnt_seq); pmlmeext->mgnt_seq++; @@ -283,11 +283,11 @@ static void issue_p2p_provision_resp(struct wifidirect_info *pwdinfo, u8 *raddr, pframe += sizeof(struct rtw_ieee80211_hdr_3addr); pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(action), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); wpsielen = 0; /* WPS OUI */ @@ -322,8 +322,8 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 struct rtw_ieee80211_hdr *pwlanhdr; __le16 *fctrl; struct adapter *padapter = pwdinfo->padapter; - struct xmit_priv *pxmitpriv = &(padapter->xmitpriv); - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); + struct xmit_priv *pxmitpriv = &padapter->xmitpriv; + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; unsigned char category = RTW_WLAN_CATEGORY_P2P;/* P2P action frame */ __be32 p2poui = cpu_to_be32(P2POUI); u8 oui_subtype = P2P_PRESENCE_RESPONSE; @@ -346,7 +346,7 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 pframe = (u8 *)(pmgntframe->buf_addr) + TXDESC_OFFSET; pwlanhdr = (struct rtw_ieee80211_hdr *)pframe; - fctrl = &(pwlanhdr->frame_ctl); + fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; memcpy(pwlanhdr->addr1, da, ETH_ALEN); @@ -361,10 +361,10 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); /* Build P2P action frame header */ - pframe = rtw_set_fixed_ie(pframe, 1, &(category), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&(p2poui), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(oui_subtype), &(pattrib->pktlen)); - pframe = rtw_set_fixed_ie(pframe, 1, &(dialogToken), &(pattrib->pktlen)); + pframe = rtw_set_fixed_ie(pframe, 1, &category, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 4, (unsigned char *)&p2poui, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &oui_subtype, &pattrib->pktlen); + pframe = rtw_set_fixed_ie(pframe, 1, &dialogToken, &pattrib->pktlen); /* Add P2P IE header */ /* P2P OUI */ @@ -385,7 +385,7 @@ static void issue_p2p_presence_resp(struct wifidirect_info *pwdinfo, u8 *da, u8 p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_NOA, 2, noa_attr_content); - pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &(pattrib->pktlen)); + pframe = rtw_set_ie(pframe, _VENDOR_SPECIFIC_IE_, p2pielen, p2pie, &pattrib->pktlen); pattrib->last_txcmdsz = pattrib->pktlen; @@ -1556,7 +1556,7 @@ void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) u8 noa_attr[MAX_P2P_IE_LEN] = { 0x00 };/* NoA length should be n*(13) + 2 */ u32 attr_contentlen = 0; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; u8 find_p2p = false, find_p2p_ps = false; u8 noa_offset, noa_num, noa_index; @@ -1636,7 +1636,7 @@ void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; /* Pre action for p2p state */ switch (p2p_ps_state) { @@ -1653,7 +1653,7 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) if (padapter->pwrctrlpriv.bFwCurrentInPSMode) { if (pwrpriv->smart_ps == 0) { pwrpriv->smart_ps = 2; - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&(padapter->pwrctrlpriv.pwr_mode))); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&padapter->pwrctrlpriv.pwr_mode)); } } break; @@ -1665,7 +1665,7 @@ void p2p_ps_wk_hdl(struct adapter *padapter, u8 p2p_ps_state) if (pwrpriv->smart_ps != 0) { pwrpriv->smart_ps = 0; DBG_88E("%s(): Enter CTW, change SmartPS\n", __func__); - rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&(padapter->pwrctrlpriv.pwr_mode))); + rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_PWRMODE, (u8 *)(&padapter->pwrctrlpriv.pwr_mode)); } } rtw_hal_set_hwreg(padapter, HW_VAR_H2C_FW_P2P_PS_OFFLOAD, (u8 *)(&p2p_ps_state)); @@ -1689,7 +1689,7 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; @@ -1938,7 +1938,7 @@ void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) { int ret = _SUCCESS; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; if (role == P2P_ROLE_DEVICE || role == P2P_ROLE_CLIENT || role == P2P_ROLE_GO) { /* leave IPS/Autosuspend */ -- cgit v1.2.3 From e293639ec5a9e95d54e140d0698987b213ec8815 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:58 +0200 Subject: staging: r8188eu: clean up comparsions to true/false Clean up some comparsions to true/false to clear chackpatch warnings. WARNING: Unnecessary parentheses - maybe == should be = ? Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-9-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mlme.c | 2 +- drivers/staging/r8188eu/core/rtw_xmit.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 1a4227729e0d..41c14a4cff1f 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -166,7 +166,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) rtw_free_assoc_resources(padapter, 1); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } @@ -231,7 +231,7 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false)) { + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (!rtw_is_same_ibss(padapter, pnetwork)) { /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ rtw_disassoc_cmd(padapter, 0, true); diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 4768d3ef350e..f28c30a6efb0 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -748,7 +748,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) rtw_set_signal_stat_timer(&adapter->recvpriv); if (pmlmepriv->to_join) { - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 0a755d7b8f19..018ee20553dd 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -740,7 +740,7 @@ s32 rtw_make_wlanhdr (struct adapter *padapter, u8 *hdr, struct pkt_attrib *patt SetFrameSubType(fctrl, pattrib->subtype); if (pattrib->subtype & WIFI_DATA_TYPE) { - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { /* to_ds = 1, fr_ds = 0; */ /* Data transfer to AP */ SetToDs(fctrl); -- cgit v1.2.3 From a8962b247ae37cd3e543cb465475fd7a627cccbc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:49:59 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_mlme.c Remove unnecessary parentheses in core/rtw_mlme.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-10-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 108 ++++++++++++++++---------------- 1 file changed, 54 insertions(+), 54 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index f28c30a6efb0..d688f2427b03 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -48,9 +48,9 @@ int _rtw_init_mlme_priv (struct adapter *padapter) pmlmepriv->cur_network.network.InfrastructureMode = Ndis802_11AutoUnknown; pmlmepriv->scan_mode = SCAN_ACTIVE;/* 1: active, 0: pasive. Maybe someday we should rename this varable to "active_mode" (Jeff) */ - spin_lock_init(&(pmlmepriv->lock)); - _rtw_init_queue(&(pmlmepriv->free_bss_pool)); - _rtw_init_queue(&(pmlmepriv->scanned_queue)); + spin_lock_init(&pmlmepriv->lock); + _rtw_init_queue(&pmlmepriv->free_bss_pool); + _rtw_init_queue(&pmlmepriv->scanned_queue); set_scanned_network_val(pmlmepriv, 0); @@ -67,9 +67,9 @@ int _rtw_init_mlme_priv (struct adapter *padapter) pnetwork = (struct wlan_network *)pbuf; for (i = 0; i < MAX_BSS_CNT; i++) { - INIT_LIST_HEAD(&(pnetwork->list)); + INIT_LIST_HEAD(&pnetwork->list); - list_add_tail(&(pnetwork->list), &(pmlmepriv->free_bss_pool.queue)); + list_add_tail(&pnetwork->list, &pmlmepriv->free_bss_pool.queue); pnetwork++; } @@ -159,7 +159,7 @@ struct wlan_network *_rtw_dequeue_network(struct __queue *queue) } else { pnetwork = container_of((&queue->queue)->next, struct wlan_network, list); - list_del_init(&(pnetwork->list)); + list_del_init(&pnetwork->list); } spin_unlock_bh(&queue->lock); @@ -179,7 +179,7 @@ struct wlan_network *_rtw_alloc_network(struct mlme_priv *pmlmepriv)/* _queue *f pnetwork = NULL; goto exit; } - plist = (&(free_queue->queue))->next; + plist = (&free_queue->queue)->next; pnetwork = container_of(plist, struct wlan_network, list); @@ -203,7 +203,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor { u32 curr_time, delta_time; u32 lifetime = SCANQUEUE_LIFETIME; - struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + struct __queue *free_queue = &pmlmepriv->free_bss_pool; if (!pnetwork) return; @@ -220,22 +220,22 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor return; } spin_lock_bh(&free_queue->lock); - list_del_init(&(pnetwork->list)); - list_add_tail(&(pnetwork->list), &(free_queue->queue)); + list_del_init(&pnetwork->list); + list_add_tail(&pnetwork->list, &free_queue->queue); pmlmepriv->num_of_scanned--; spin_unlock_bh(&free_queue->lock); } void _rtw_free_network_nolock(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwork) { - struct __queue *free_queue = &(pmlmepriv->free_bss_pool); + struct __queue *free_queue = &pmlmepriv->free_bss_pool; if (!pnetwork) return; if (pnetwork->fixed) return; - list_del_init(&(pnetwork->list)); - list_add_tail(&(pnetwork->list), get_list_head(free_queue)); + list_del_init(&pnetwork->list); + list_add_tail(&pnetwork->list, get_list_head(free_queue)); pmlmepriv->num_of_scanned--; } @@ -473,7 +473,7 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, rtw_hal_antdiv_rssi_compared(padapter, dst, src); /* this will update src.Rssi, need consider again */ /* The rule below is 1/5 for sample value, 4/5 for history value */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&(padapter->mlmepriv.cur_network.network), src)) { + if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) && is_same_network(&padapter->mlmepriv.cur_network.network, src)) { /* Take the recvpriv's value for the connected AP*/ ss_final = padapter->recvpriv.signal_strength; sq_final = padapter->recvpriv.signal_qual; @@ -507,11 +507,11 @@ void update_network(struct wlan_bssid_ex *dst, struct wlan_bssid_ex *src, static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex *pnetwork) { - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && - (is_same_network(&(pmlmepriv->cur_network.network), pnetwork))) { - update_network(&(pmlmepriv->cur_network.network), pnetwork, adapter, true); + (is_same_network(&pmlmepriv->cur_network.network, pnetwork))) { + update_network(&pmlmepriv->cur_network.network, pnetwork, adapter, true); rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), pmlmepriv->cur_network.network.IELength); } @@ -525,8 +525,8 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t { struct list_head *plist, *phead; u32 bssid_ex_sz; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; struct wlan_network *oldest = NULL; @@ -537,7 +537,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t while (phead != plist) { pnetwork = container_of(plist, struct wlan_network, list); - if (is_same_network(&(pnetwork->network), target)) + if (is_same_network(&pnetwork->network, target)) break; if ((oldest == ((struct wlan_network *)0)) || time_after(oldest->last_scanned, pnetwork->last_scanned)) @@ -547,12 +547,12 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t /* If we didn't find a match, then get a new network slot to initialize * with this beacon's information */ if (phead == plist) { - if (list_empty(&(pmlmepriv->free_bss_pool.queue))) { + if (list_empty(&pmlmepriv->free_bss_pool.queue)) { /* If there are no more slots, expire the oldest */ pnetwork = oldest; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); - memcpy(&(pnetwork->network), target, get_wlan_bssid_ex_sz(target)); + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &target->PhyInfo.Optimum_antenna); + memcpy(&pnetwork->network, target, get_wlan_bssid_ex_sz(target)); /* variable initialize */ pnetwork->fixed = false; pnetwork->last_scanned = jiffies; @@ -574,15 +574,15 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t bssid_ex_sz = get_wlan_bssid_ex_sz(target); target->Length = bssid_ex_sz; - rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &(target->PhyInfo.Optimum_antenna)); - memcpy(&(pnetwork->network), target, bssid_ex_sz); + rtw_hal_get_def_var(adapter, HAL_DEF_CURRENT_ANTENNA, &target->PhyInfo.Optimum_antenna); + memcpy(&pnetwork->network, target, bssid_ex_sz); pnetwork->last_scanned = jiffies; /* bss info not receiving from the right channel */ if (pnetwork->network.PhyInfo.SignalQuality == 101) pnetwork->network.PhyInfo.SignalQuality = 0; - list_add_tail(&(pnetwork->list), &(queue->queue)); + list_add_tail(&pnetwork->list, &queue->queue); } } else { /* we have an entry and we are going to update it. But this entry may @@ -600,7 +600,7 @@ void rtw_update_scanned_network(struct adapter *adapter, struct wlan_bssid_ex *t update_ie = true; else update_ie = false; - update_network(&(pnetwork->network), target, adapter, update_ie); + update_network(&pnetwork->network, target, adapter, update_ie); } exit: @@ -682,7 +682,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) { u32 len; struct wlan_bssid_ex *pnetwork; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; pnetwork = (struct wlan_bssid_ex *)pbuf; @@ -693,7 +693,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) /* update IBSS_network 's timestamp */ if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { - if (!memcmp(&(pmlmepriv->cur_network.network.MacAddress), pnetwork->MacAddress, ETH_ALEN)) { + if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; memcpy(pmlmepriv->cur_network.network.IEs, pnetwork->IEs, 8); @@ -704,7 +704,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto exit; } - spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); } } @@ -722,7 +722,7 @@ exit: void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) { - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 timer_cancelled = 0; spin_lock_bh(&pmlmepriv->lock); @@ -755,7 +755,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); } else { - struct wlan_bssid_ex *pdev_network = &(adapter->registrypriv.dev_network); + struct wlan_bssid_ex *pdev_network = &adapter->registrypriv.dev_network; u8 *pibss = adapter->registrypriv.dev_network.MacAddress; _clr_fwstate_(pmlmepriv, _FW_UNDER_SURVEY); @@ -949,8 +949,8 @@ inline void rtw_indicate_scan_done(struct adapter *padapter, bool aborted) void rtw_scan_abort(struct adapter *adapter) { u32 start; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); - struct mlme_ext_priv *pmlmeext = &(adapter->mlmeextpriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; + struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; start = jiffies; pmlmeext->scan_abort = true; @@ -1038,8 +1038,8 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str /* ptarget_wlan: found from scanned_queue */ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_network *ptarget_wlan, struct wlan_network *pnetwork) { - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct wlan_network *cur_network = &pmlmepriv->cur_network; DBG_88E("%s\n", __func__); @@ -1092,9 +1092,9 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) u8 timer_cancelled; struct sta_info *ptarget_sta = NULL, *pcur_sta = NULL; struct sta_priv *pstapriv = &adapter->stapriv; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct wlan_network *pnetwork = (struct wlan_network *)pbuf; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wlan_network *pcur_wlan = NULL, *ptarget_wlan = NULL; unsigned int the_same_macaddr = false; @@ -1203,11 +1203,11 @@ static u8 search_max_mac_id(struct adapter *padapter) u8 mac_id; #if defined (CONFIG_88EU_AP_MODE) u8 aid; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; #endif - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; #if defined (CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { @@ -1248,9 +1248,9 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) { struct sta_info *psta; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct stassoc_event *pstassoc = (struct stassoc_event *)pbuf; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wlan_network *ptarget_wlan = NULL; if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) @@ -1307,10 +1307,10 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) struct wlan_network *pwlan = NULL; struct wlan_bssid_ex *pdev_network = NULL; u8 *pibss = NULL; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct stadel_event *pstadel = (struct stadel_event *)pbuf; struct sta_priv *pstapriv = &adapter->stapriv; - struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + struct wlan_network *tgt_network = &pmlmepriv->cur_network; psta = rtw_get_stainfo(&adapter->stapriv, pstadel->macaddr); if (psta) @@ -1362,7 +1362,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) } if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - spin_lock_bh(&(pstapriv->sta_hash_lock)); + spin_lock_bh(&pstapriv->sta_hash_lock); rtw_free_stainfo(adapter, psta); spin_unlock_bh(&pstapriv->sta_hash_lock); @@ -1376,7 +1376,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) } spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* re-create ibss */ - pdev_network = &(adapter->registrypriv.dev_network); + pdev_network = &adapter->registrypriv.dev_network; pibss = adapter->registrypriv.dev_network.MacAddress; memcpy(pdev_network, &tgt_network->network, get_wlan_bssid_ex_sz(&tgt_network->network)); @@ -1586,7 +1586,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) int ret; struct list_head *phead; struct adapter *adapter; - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct __queue *queue = &pmlmepriv->scanned_queue; struct wlan_network *pnetwork = NULL; struct wlan_network *candidate = NULL; u8 supp_ant_div = false; @@ -1645,7 +1645,7 @@ int rtw_set_auth(struct adapter *adapter, struct security_priv *psecuritypriv) { struct cmd_obj *pcmd; struct setauth_parm *psetauthparm; - struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); + struct cmd_priv *pcmdpriv = &adapter->cmdpriv; int res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -1679,8 +1679,8 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in u8 keylen; struct cmd_obj *pcmd; struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv = &(adapter->cmdpriv); - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct cmd_priv *pcmdpriv = &adapter->cmdpriv; + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; int res = _SUCCESS; pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); @@ -1710,11 +1710,11 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in switch (psetkeyparm->algorithm) { case _WEP40_: keylen = 5; - memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + memcpy(&psetkeyparm->key[0], &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); break; case _WEP104_: keylen = 13; - memcpy(&(psetkeyparm->key[0]), &(psecuritypriv->dot11DefKey[keyid].skey[0]), keylen); + memcpy(&psetkeyparm->key[0], &psecuritypriv->dot11DefKey[keyid].skey[0], keylen); break; case _TKIP_: keylen = 16; @@ -2059,7 +2059,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) struct ht_priv *phtpriv = &pmlmepriv->htpriv; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (!phtpriv->ht_option) return; -- cgit v1.2.3 From f9f527d09a1e862b78bfea5785c46420ccfefdb1 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:00 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_xmit.c Remove unnecessary parentheses in core/rtw_xmit.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-11-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 54 ++++++++++++++++----------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 018ee20553dd..1b05f1643ebf 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -86,7 +86,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe = (struct xmit_frame *)pxmitpriv->pxmit_frame_buf; for (i = 0; i < NR_XMITFRAME; i++) { - INIT_LIST_HEAD(&(pxframe->list)); + INIT_LIST_HEAD(&pxframe->list); pxframe->padapter = padapter; pxframe->frame_tag = NULL_FRAMETAG; @@ -96,7 +96,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxframe->buf_addr = NULL; pxframe->pxmitbuf = NULL; - list_add_tail(&(pxframe->list), &(pxmitpriv->free_xmit_queue.queue)); + list_add_tail(&pxframe->list, &pxmitpriv->free_xmit_queue.queue); pxframe++; } @@ -141,7 +141,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitbuf->flags = XMIT_VO_QUEUE; - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmitbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmitbuf_queue.queue); pxmitbuf++; } @@ -174,7 +174,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) goto exit; } - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); pxmitbuf++; } @@ -188,7 +188,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) pxmitpriv->txirp_cnt = 1; - sema_init(&(pxmitpriv->tx_retevt), 0); + sema_init(&pxmitpriv->tx_retevt, 0); /* per AC pending irp */ pxmitpriv->beq_cnt = 0; @@ -260,8 +260,8 @@ static void update_attrib_vcs_info(struct adapter *padapter, struct xmit_frame * u32 sz; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct sta_info *psta = pattrib->psta; - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pattrib->nr_frags != 1) sz = padapter->xmitpriv.frag_len; @@ -672,10 +672,10 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr payload = payload+length+pattrib->icv_len; } } - rtw_secgetmic(&micdata, &(mic[0])); + rtw_secgetmic(&micdata, &mic[0]); /* add mic code and add the mic code length in last_txcmdsz */ - memcpy(payload, &(mic[0]), 8); + memcpy(payload, &mic[0], 8); pattrib->last_txcmdsz += 8; payload = payload-pattrib->last_txcmdsz+8; @@ -852,20 +852,20 @@ s32 rtw_txframes_sta_ac_pending(struct adapter *padapter, struct pkt_attrib *pat switch (priority) { case 1: case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); + ptxservq = &psta->sta_xmitpriv.bk_q; break; case 4: case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); + ptxservq = &psta->sta_xmitpriv.vi_q; break; case 6: case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); + ptxservq = &psta->sta_xmitpriv.vo_q; break; case 0: case 3: default: - ptxservq = &(psta->sta_xmitpriv.be_q); + ptxservq = &psta->sta_xmitpriv.be_q; break; } @@ -1156,7 +1156,7 @@ struct xmit_buf *rtw_alloc_xmitbuf_ext(struct xmit_priv *pxmitpriv) pxmitbuf = container_of(plist, struct xmit_buf, list); - list_del_init(&(pxmitbuf->list)); + list_del_init(&pxmitbuf->list); } if (pxmitbuf) { @@ -1188,7 +1188,7 @@ s32 rtw_free_xmitbuf_ext(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&(pxmitbuf->list), get_list_head(pfree_queue)); + list_add_tail(&pxmitbuf->list, get_list_head(pfree_queue)); pxmitpriv->free_xmit_extbuf_cnt++; spin_unlock_irqrestore(&pfree_queue->lock, flags); @@ -1216,7 +1216,7 @@ struct xmit_buf *rtw_alloc_xmitbuf(struct xmit_priv *pxmitpriv) pxmitbuf = container_of(plist, struct xmit_buf, list); - list_del_init(&(pxmitbuf->list)); + list_del_init(&pxmitbuf->list); } if (pxmitbuf) { @@ -1252,7 +1252,7 @@ s32 rtw_free_xmitbuf(struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf) list_del_init(&pxmitbuf->list); - list_add_tail(&(pxmitbuf->list), get_list_head(pfree_xmitbuf_queue)); + list_add_tail(&pxmitbuf->list, get_list_head(pfree_xmitbuf_queue)); pxmitpriv->free_xmitbuf_cnt++; spin_unlock_irqrestore(&pfree_xmitbuf_queue->lock, flags); @@ -1296,7 +1296,7 @@ struct xmit_frame *rtw_alloc_xmitframe(struct xmit_priv *pxmitpriv)/* _queue *pf pxframe = container_of(plist, struct xmit_frame, list); - list_del_init(&(pxframe->list)); + list_del_init(&pxframe->list); } if (pxframe) { /* default value setting */ @@ -1465,23 +1465,23 @@ struct tx_servq *rtw_get_sta_pending(struct adapter *padapter, struct sta_info * switch (up) { case 1: case 2: - ptxservq = &(psta->sta_xmitpriv.bk_q); + ptxservq = &psta->sta_xmitpriv.bk_q; *(ac) = 3; break; case 4: case 5: - ptxservq = &(psta->sta_xmitpriv.vi_q); + ptxservq = &psta->sta_xmitpriv.vi_q; *(ac) = 1; break; case 6: case 7: - ptxservq = &(psta->sta_xmitpriv.vo_q); + ptxservq = &psta->sta_xmitpriv.vo_q; *(ac) = 0; break; case 0: case 3: default: - ptxservq = &(psta->sta_xmitpriv.be_q); + ptxservq = &psta->sta_xmitpriv.be_q; *(ac) = 2; break; } @@ -1951,21 +1951,21 @@ void stop_sta_xmit(struct adapter *padapter, struct sta_info *psta) pstapriv->sta_dz_bitmap |= BIT(psta->aid); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vo_q.sta_pending); - list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&pstaxmitpriv->vo_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->vi_q.sta_pending); - list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&pstaxmitpriv->vi_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); dequeue_xmitframes_to_sleeping_queue(padapter, psta, &pstaxmitpriv->bk_q.sta_pending); - list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&pstaxmitpriv->bk_q.tx_pending); /* for BC/MC Frames */ pstaxmitpriv = &psta_bmc->sta_xmitpriv; dequeue_xmitframes_to_sleeping_queue(padapter, psta_bmc, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); spin_unlock_bh(&pxmitpriv->lock); } -- cgit v1.2.3 From e05b0ea4eb872f0563ef74cccd089be12c68cc29 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:01 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_sta_mgt.c Remove unnecessary parentheses in core/rtw_sta_mgt.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-12-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 3e8e85756f25..c9644a3ecc4e 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -81,7 +81,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) for (i = 0; i < NUM_STA; i++) { _rtw_init_stainfo(psta); - INIT_LIST_HEAD(&(pstapriv->sta_hash[i])); + INIT_LIST_HEAD(&pstapriv->sta_hash[i]); list_add_tail(&psta->list, get_list_head(&pstapriv->free_sta_queue)); @@ -145,7 +145,7 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) /* delete all reordering_ctrl_timer */ spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { - phead = &(pstapriv->sta_hash[index]); + phead = &pstapriv->sta_hash[index]; plist = phead->next; while (phead != plist) { @@ -190,7 +190,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) psta = NULL; } else { psta = container_of((&pfree_sta_queue->queue)->next, struct sta_info, list); - list_del_init(&(psta->list)); + list_del_init(&psta->list); spin_unlock_bh(&pfree_sta_queue->lock); _rtw_init_stainfo(psta); memcpy(psta->hwaddr, hwaddr, ETH_ALEN); @@ -199,7 +199,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) psta = NULL; goto exit; } - phash_list = &(pstapriv->sta_hash[index]); + phash_list = &pstapriv->sta_hash[index]; spin_lock_bh(&pstapriv->sta_hash_lock); @@ -273,19 +273,19 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vo_q.sta_pending); - list_del_init(&(pstaxmitpriv->vo_q.tx_pending)); + list_del_init(&pstaxmitpriv->vo_q.tx_pending); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->vi_q.sta_pending); - list_del_init(&(pstaxmitpriv->vi_q.tx_pending)); + list_del_init(&pstaxmitpriv->vi_q.tx_pending); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->bk_q.sta_pending); - list_del_init(&(pstaxmitpriv->bk_q.tx_pending)); + list_del_init(&pstaxmitpriv->bk_q.tx_pending); rtw_free_xmitframe_queue(pxmitpriv, &pstaxmitpriv->be_q.sta_pending); - list_del_init(&(pstaxmitpriv->be_q.tx_pending)); + list_del_init(&pstaxmitpriv->be_q.tx_pending); spin_unlock_bh(&pxmitpriv->lock); @@ -321,7 +321,7 @@ u32 rtw_free_stainfo(struct adapter *padapter, struct sta_info *psta) plist = plist->next; - list_del_init(&(prframe->list)); + list_del_init(&prframe->list); rtw_free_recvframe(prframe, pfree_recv_queue); } @@ -389,7 +389,7 @@ void rtw_free_all_stainfo(struct adapter *padapter) spin_lock_bh(&pstapriv->sta_hash_lock); for (index = 0; index < NUM_STA; index++) { - phead = &(pstapriv->sta_hash[index]); + phead = &pstapriv->sta_hash[index]; plist = phead->next; while (phead != plist) { @@ -425,7 +425,7 @@ struct sta_info *rtw_get_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) spin_lock_bh(&pstapriv->sta_hash_lock); - phead = &(pstapriv->sta_hash[index]); + phead = &pstapriv->sta_hash[index]; plist = phead->next; while (phead != plist) { -- cgit v1.2.3 From 79c35b74513b5bc1160fec845ec09091ebff9696 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:02 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_recv.c Remove unnecessary parentheses in core/rtw_recv.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-13-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 3f5a7282c857..08aea680312c 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -70,9 +70,9 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) precvframe = (struct recv_frame *)precvpriv->precv_frame_buf; for (i = 0; i < NR_RECVFRAME; i++) { - INIT_LIST_HEAD(&(precvframe->list)); + INIT_LIST_HEAD(&precvframe->list); - list_add_tail(&(precvframe->list), &(precvpriv->free_recv_queue.queue)); + list_add_tail(&precvframe->list, &precvpriv->free_recv_queue.queue); res = rtw_os_recv_resource_alloc(padapter, precvframe); @@ -174,11 +174,11 @@ int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv spin_lock_bh(&pfree_recv_queue->lock); - list_del_init(&(precvframe->list)); + list_del_init(&precvframe->list); precvframe->len = 0; - list_add_tail(&(precvframe->list), get_list_head(pfree_recv_queue)); + list_add_tail(&precvframe->list, get_list_head(pfree_recv_queue)); if (padapter) { if (pfree_recv_queue == &precvpriv->free_recv_queue) @@ -195,8 +195,8 @@ int _rtw_enqueue_recvframe(struct recv_frame *precvframe, struct __queue *queue) struct adapter *padapter = precvframe->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; - list_del_init(&(precvframe->list)); - list_add_tail(&(precvframe->list), get_list_head(queue)); + list_del_init(&precvframe->list); + list_add_tail(&precvframe->list, get_list_head(queue)); if (padapter) { if (queue == &precvpriv->free_recv_queue) @@ -323,7 +323,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr struct security_priv *psecuritypriv = &adapter->securitypriv; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; stainfo = rtw_get_stainfo(&adapter->stapriv, &prxattrib->ta[0]); @@ -1338,7 +1338,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter, struct __que plist = phead->next; pfhdr = container_of(plist, struct recv_frame, list); prframe = (struct recv_frame *)pfhdr; - list_del_init(&(prframe->list)); + list_del_init(&prframe->list); if (curfragnum != pfhdr->attrib.frag_num) { /* the first fragment number must be 0 */ @@ -1355,7 +1355,7 @@ static struct recv_frame *recvframe_defrag(struct adapter *adapter, struct __que plist = phead->next; pfhdr = container_of(plist, struct recv_frame, list); prframe = (struct recv_frame *)pfhdr; - list_del_init(&(prframe->list)); + list_del_init(&prframe->list); plist = plist->next; @@ -1506,7 +1506,7 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) unsigned char *data_ptr; struct sk_buff *sub_skb, *subframes[MAX_SUBFRAME_COUNT]; struct recv_priv *precvpriv = &padapter->recvpriv; - struct __queue *pfree_recv_queue = &(precvpriv->free_recv_queue); + struct __queue *pfree_recv_queue = &precvpriv->free_recv_queue; int ret = _SUCCESS; nr_subframes = 0; @@ -1668,9 +1668,9 @@ int enqueue_reorder_recvframe(struct recv_reorder_ctrl *preorder_ctrl, struct re break; } - list_del_init(&(prframe->list)); + list_del_init(&prframe->list); - list_add_tail(&(prframe->list), plist); + list_add_tail(&prframe->list, plist); return true; } @@ -1704,7 +1704,7 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor if (!SN_LESS(preorder_ctrl->indicate_seq, pattrib->seq_num)) { plist = plist->next; - list_del_init(&(prframe->list)); + list_del_init(&prframe->list); if (SN_EQUAL(preorder_ctrl->indicate_seq, pattrib->seq_num)) preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) & 0xFFF; -- cgit v1.2.3 From 9355adf7e52f8f7d9aa23a8e967a6c86d097a9df Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:03 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_pwrctrl.c Remove unnecessary parentheses in core/rtw_pwrctrl.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-14-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 57cd10205d6c..9a00a316674b 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -51,8 +51,8 @@ void ips_enter(struct adapter *padapter) int ips_leave(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct security_priv *psecuritypriv = &(padapter->securitypriv); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int result = _SUCCESS; int keyid; @@ -98,9 +98,9 @@ int ips_leave(struct adapter *padapter) static bool rtw_pwr_unassociated_idle(struct adapter *adapter) { struct adapter *buddy = adapter->pbuddy_adapter; - struct mlme_priv *pmlmepriv = &(adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &adapter->mlmepriv; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(adapter->wdinfo); + struct wifidirect_info *pwdinfo = &adapter->wdinfo; #endif bool ret = false; @@ -122,9 +122,9 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) /* consider buddy, if exist */ if (buddy) { - struct mlme_priv *b_pmlmepriv = &(buddy->mlmepriv); + struct mlme_priv *b_pmlmepriv = &buddy->mlmepriv; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *b_pwdinfo = &(buddy->wdinfo); + struct wifidirect_info *b_pwdinfo = &buddy->wdinfo; #endif if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || @@ -147,7 +147,7 @@ exit: void rtw_ps_processor(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; enum rt_rf_power_state rfpwrstate; pwrpriv->ps_processing = true; @@ -248,7 +248,7 @@ static u8 PS_RDY_CHECK(struct adapter *padapter) { u32 curr_time, delta_time; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; curr_time = jiffies; delta_time = curr_time - pwrpriv->DelayLPSLastTimeStamp; @@ -275,7 +275,7 @@ void rtw_set_ps_mode(struct adapter *padapter, u8 ps_mode, u8 smart_ps, u8 bcn_a { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; #ifdef CONFIG_88EU_P2P - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; #endif /* CONFIG_88EU_P2P */ if (ps_mode > PM_Card_Disable) @@ -412,7 +412,7 @@ void LPS_Leave(struct adapter *padapter) /* */ void LeaveAllPowerSaveMode(struct adapter *Adapter) { - struct mlme_priv *pmlmepriv = &(Adapter->mlmepriv); + struct mlme_priv *pmlmepriv = &Adapter->mlmepriv; u8 enqueue = 0; if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ -- cgit v1.2.3 From 4fdda47ee4356a717f8a7ca3540f557ad6c52969 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:04 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_io.c Remove unnecessary parentheses in core/rtw_io.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-15-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_io.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index 2a47329d90e8..b5cd9bbc1ce1 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -38,7 +38,7 @@ u8 _rtw_read8(struct adapter *adapter, u32 addr) { u8 r_val; struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; u8 (*_read8)(struct intf_hdl *pintfhdl, u32 addr); @@ -52,7 +52,7 @@ u16 _rtw_read16(struct adapter *adapter, u32 addr) { u16 r_val; struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; u16 (*_read16)(struct intf_hdl *pintfhdl, u32 addr); _read16 = pintfhdl->io_ops._read16; @@ -66,7 +66,7 @@ u32 _rtw_read32(struct adapter *adapter, u32 addr) { u32 r_val; struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; u32 (*_read32)(struct intf_hdl *pintfhdl, u32 addr); _read32 = pintfhdl->io_ops._read32; @@ -79,7 +79,7 @@ u32 _rtw_read32(struct adapter *adapter, u32 addr) int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; int (*_write8)(struct intf_hdl *pintfhdl, u32 addr, u8 val); int ret; @@ -94,7 +94,7 @@ int _rtw_write8(struct adapter *adapter, u32 addr, u8 val) int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; int (*_write16)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int ret; @@ -108,7 +108,7 @@ int _rtw_write16(struct adapter *adapter, u32 addr, u16 val) int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; int (*_write32)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int ret; @@ -123,7 +123,7 @@ int _rtw_write32(struct adapter *adapter, u32 addr, u32 val) int _rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = (struct intf_hdl *)(&(pio_priv->intf)); + struct intf_hdl *pintfhdl = (struct intf_hdl *)(&pio_priv->intf); int (*_writeN)(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata); int ret; @@ -137,7 +137,7 @@ int _rtw_writeN(struct adapter *adapter, u32 addr, u32 length, u8 *pdata) int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; int (*_write8_async)(struct intf_hdl *pintfhdl, u32 addr, u8 val); int ret; @@ -152,7 +152,7 @@ int _rtw_write8_async(struct adapter *adapter, u32 addr, u8 val) int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; int (*_write16_async)(struct intf_hdl *pintfhdl, u32 addr, u16 val); int ret; @@ -165,7 +165,7 @@ int _rtw_write16_async(struct adapter *adapter, u32 addr, u16 val) int _rtw_write32_async(struct adapter *adapter, u32 addr, u32 val) { struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; int (*_write32_async)(struct intf_hdl *pintfhdl, u32 addr, u32 val); int ret; @@ -179,7 +179,7 @@ void _rtw_read_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { void (*_read_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; if (adapter->bDriverStopped || adapter->bSurpriseRemoved) @@ -193,7 +193,7 @@ void _rtw_write_mem(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; @@ -208,7 +208,7 @@ void _rtw_read_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; @@ -226,7 +226,7 @@ void _rtw_read_port_cancel(struct adapter *adapter) { void (*_read_port_cancel)(struct intf_hdl *pintfhdl); struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; _read_port_cancel = pintfhdl->io_ops._read_port_cancel; @@ -238,7 +238,7 @@ u32 _rtw_write_port(struct adapter *adapter, u32 addr, u32 cnt, u8 *pmem) { u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; u32 ret = _SUCCESS; @@ -273,7 +273,7 @@ void _rtw_write_port_cancel(struct adapter *adapter) { void (*_write_port_cancel)(struct intf_hdl *pintfhdl); struct io_priv *pio_priv = &adapter->iopriv; - struct intf_hdl *pintfhdl = &(pio_priv->intf); + struct intf_hdl *pintfhdl = &pio_priv->intf; _write_port_cancel = pintfhdl->io_ops._write_port_cancel; -- cgit v1.2.3 From 6cd1603cc2853a4892c8a9f86a3b219166720029 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:05 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_ioctl_set.c Remove unnecessary parentheses in core/rtw_ioctl_set.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-16-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 41c14a4cff1f..35a4a9e222e6 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -40,8 +40,8 @@ u8 rtw_do_join(struct adapter *padapter) { struct list_head *plist, *phead; u8 *pibss = NULL; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + struct __queue *queue = &pmlmepriv->scanned_queue; u8 ret = _SUCCESS; spin_lock_bh(&pmlmepriv->scanned_queue.lock); @@ -88,7 +88,7 @@ u8 rtw_do_join(struct adapter *padapter) /* submit createbss_cmd to change to a ADHOC_MASTER */ /* pmlmepriv->lock has been acquired by caller... */ - struct wlan_bssid_ex *pdev_network = &(padapter->registrypriv.dev_network); + struct wlan_bssid_ex *pdev_network = &padapter->registrypriv.dev_network; pmlmepriv->fw_state = WIFI_ADHOC_MASTER_STATE; @@ -301,7 +301,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, { struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_network *cur_network = &pmlmepriv->cur_network; - enum ndis_802_11_network_infra *pold_state = &(cur_network->network.InfrastructureMode); + enum ndis_802_11_network_infra *pold_state = &cur_network->network.InfrastructureMode; if (*pold_state != networktype) { spin_lock_bh(&pmlmepriv->lock); @@ -435,7 +435,7 @@ u8 rtw_set_802_11_authentication_mode(struct adapter *padapter, enum ndis_802_11 u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) { int keyid, res; - struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; u8 ret = _SUCCESS; keyid = wep->KeyIndex & 0x3fffffff; @@ -457,7 +457,7 @@ u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep) break; } - memcpy(&(psecuritypriv->dot11DefKey[keyid].skey[0]), &(wep->KeyMaterial), wep->KeyLength); + memcpy(&psecuritypriv->dot11DefKey[keyid].skey[0], &wep->KeyMaterial, wep->KeyLength); psecuritypriv->dot11DefKeylen[keyid] = wep->KeyLength; @@ -481,7 +481,7 @@ u8 rtw_set_802_11_remove_wep(struct adapter *padapter, u32 keyindex) goto exit; } else { int res; - struct security_priv *psecuritypriv = &(padapter->securitypriv); + struct security_priv *psecuritypriv = &padapter->securitypriv; if (keyindex < 4) { memset(&psecuritypriv->dot11DefKey[keyindex], 0, 16); res = rtw_set_key(padapter, psecuritypriv, keyindex, 0); @@ -628,7 +628,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) wep->KeyLength = key->KeyLength; memcpy(wep->KeyMaterial, key->KeyMaterial, key->KeyLength); - memcpy(&(padapter->securitypriv.dot11DefKey[keyindex].skey[0]), key->KeyMaterial, key->KeyLength); + memcpy(&padapter->securitypriv.dot11DefKey[keyindex].skey[0], key->KeyMaterial, key->KeyLength); padapter->securitypriv.dot11DefKeylen[keyindex] = key->KeyLength; padapter->securitypriv.dot11PrivacyKeyIndex = keyindex; @@ -776,7 +776,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) u8 *p; u16 rate = 0, max_rate = 0; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; struct registry_priv *pregistrypriv = &adapter->registrypriv; struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; -- cgit v1.2.3 From a8165f872b18db09494c21e32922445e7e0975dc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:06 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_cmd.c Remove unnecessary parentheses in core/rtw_cmd.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-17-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 36 +++++++++++++++++----------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 238ae79f4141..a62dd3c986e5 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -20,11 +20,11 @@ int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) { int res = _SUCCESS; - sema_init(&(pcmdpriv->cmd_queue_sema), 0); + sema_init(&pcmdpriv->cmd_queue_sema, 0); /* sema_init(&(pcmdpriv->cmd_done_sema), 0); */ - sema_init(&(pcmdpriv->terminate_cmdthread_sema), 0); + sema_init(&pcmdpriv->terminate_cmdthread_sema, 0); - _rtw_init_queue(&(pcmdpriv->cmd_queue)); + _rtw_init_queue(&pcmdpriv->cmd_queue); /* allocate DMA-able/Non-Page memory for cmd_buf and rsp_buf */ @@ -133,10 +133,10 @@ struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) unsigned long flags; spin_lock_irqsave(&queue->lock, flags); - if (list_empty(&(queue->queue))) { + if (list_empty(&queue->queue)) { obj = NULL; } else { - obj = container_of((&(queue->queue))->next, struct cmd_obj, list); + obj = container_of((&queue->queue)->next, struct cmd_obj, list); rtw_list_delete(&obj->list); } @@ -262,7 +262,7 @@ int rtw_cmd_thread(void *context) u8 (*cmd_hdl)(struct adapter *padapter, u8 *pbuf); void (*pcmd_callback)(struct adapter *dev, struct cmd_obj *pcmd); struct adapter *padapter = (struct adapter *)context; - struct cmd_priv *pcmdpriv = &(padapter->cmdpriv); + struct cmd_priv *pcmdpriv = &padapter->cmdpriv; thread_enter("RTW_CMD_THREAD"); @@ -794,7 +794,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) struct ht_priv *phtpriv = &pmlmepriv->htpriv; enum ndis_802_11_network_infra ndis_network_mode = pnetwork->network.InfrastructureMode; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; rtw_led_control(padapter, LED_CTL_START_TO_LINK); @@ -1439,7 +1439,7 @@ static void traffic_status_watchdog(struct adapter *padapter) u8 bEnterPS; u8 bBusyTraffic = false, bTxBusyTraffic = false, bRxBusyTraffic = false; u8 bHigherBusyTraffic = false, bHigherBusyRxTraffic = false, bHigherBusyTxTraffic = false; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; /* */ /* Determine if our traffic is busy now */ @@ -1498,7 +1498,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) struct mlme_priv *pmlmepriv; padapter = (struct adapter *)pbuf; - pmlmepriv = &(padapter->mlmepriv); + pmlmepriv = &padapter->mlmepriv; #ifdef CONFIG_88EU_AP_MODE if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) @@ -1516,7 +1516,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 mstatus; if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || @@ -1693,7 +1693,7 @@ u8 p2p_protocol_wk_cmd(struct adapter *padapter, int intCmdType) { struct cmd_obj *ph2c; struct drvextra_cmd_parm *pdrvextra_cmd_parm; - struct wifidirect_info *pwdinfo = &(padapter->wdinfo); + struct wifidirect_info *pwdinfo = &padapter->wdinfo; struct cmd_priv *pcmdpriv = &padapter->cmdpriv; u8 res = _SUCCESS; @@ -2049,9 +2049,9 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) struct wlan_network *pwlan = NULL; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)pcmd->parmbuf; - struct wlan_network *tgt_network = &(pmlmepriv->cur_network); + struct wlan_network *tgt_network = &pmlmepriv->cur_network; - if ((pcmd->res != H2C_SUCCESS)) + if (pcmd->res != H2C_SUCCESS) _set_timer(&pmlmepriv->assoc_timer, 1); _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); @@ -2070,26 +2070,26 @@ void rtw_createbss_cmd_callback(struct adapter *padapter, struct cmd_obj *pcmd) } else { pwlan = _rtw_alloc_network(pmlmepriv); - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_lock_bh(&pmlmepriv->scanned_queue.lock); if (!pwlan) { pwlan = rtw_get_oldest_wlan_network(&pmlmepriv->scanned_queue); if (!pwlan) { - spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); goto createbss_cmd_fail; } pwlan->last_scanned = jiffies; } else { - list_add_tail(&(pwlan->list), &pmlmepriv->scanned_queue.queue); + list_add_tail(&pwlan->list, &pmlmepriv->scanned_queue.queue); } pnetwork->Length = get_wlan_bssid_ex_sz(pnetwork); - memcpy(&(pwlan->network), pnetwork, pnetwork->Length); + memcpy(&pwlan->network, pnetwork, pnetwork->Length); memcpy(&tgt_network->network, pnetwork, (get_wlan_bssid_ex_sz(pnetwork))); _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); - spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); + spin_unlock_bh(&pmlmepriv->scanned_queue.lock); /* we will set _FW_LINKED when there is one more sat to join us (rtw_stassoc_event_callback) */ } -- cgit v1.2.3 From 1c69b0a861d12bad2f76f15d799e5a58742a0763 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 9 Aug 2021 18:50:07 +0200 Subject: staging: r8188eu: remove remaining unnecessary parentheses in core dir Remove remaining unnecessary parentheses in core dir reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210809165007.23204-18-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 6 +++--- drivers/staging/r8188eu/core/rtw_debug.c | 14 +++++++------- drivers/staging/r8188eu/core/rtw_ieee80211.c | 4 ++-- drivers/staging/r8188eu/core/rtw_iol.c | 2 +- drivers/staging/r8188eu/core/rtw_mp.c | 10 +++++----- 5 files changed, 18 insertions(+), 18 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 28f0452d6ccb..e13f134a497b 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -319,7 +319,7 @@ static inline void __network_hash_link(struct adapter *priv, static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) { /* Caller must spin_lock already! */ - *(ent->pprev_hash) = ent->next_hash; + *ent->pprev_hash = ent->next_hash; if (ent->next_hash) ent->next_hash->pprev_hash = ent->pprev_hash; ent->next_hash = NULL; @@ -853,7 +853,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) } else { /* session phase */ DEBUG_INFO("NAT25: Insert PPPoE, insert session packet to %s\n", skb->dev->name); - __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &(ph->sid)); + __nat25_generate_pppoe_network_addr(networkAddr, skb->data, &ph->sid); __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); @@ -921,7 +921,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) } else { if (ph->sid != 0) { DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name); - __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &(ph->sid)); + __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &ph->sid); __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); __nat25_db_print(priv); } else { diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c index 30ef77842787..e7b088563738 100644 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -133,7 +133,7 @@ int proc_get_fwstate(char *page, char **start, { struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int len = 0; @@ -168,7 +168,7 @@ int proc_get_mlmext_state(char *page, char **start, struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; int len = 0; @@ -184,7 +184,7 @@ int proc_get_qos_option(char *page, char **start, { struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int len = 0; @@ -200,7 +200,7 @@ int proc_get_ht_option(char *page, char **start, { struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int len = 0; len += snprintf(page + len, count - len, "ht_option=%d\n", pmlmepriv->htpriv.ht_option); @@ -230,9 +230,9 @@ int proc_get_ap_info(char *page, char **start, struct sta_info *psta; struct net_device *dev = data; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct wlan_network *cur_network = &(pmlmepriv->cur_network); + struct wlan_network *cur_network = &pmlmepriv->cur_network; struct sta_priv *pstapriv = &padapter->stapriv; int len = 0; @@ -830,7 +830,7 @@ int proc_get_all_sta_info(char *page, char **start, spin_lock_bh(&pstapriv->sta_hash_lock); for (i = 0; i < NUM_STA; i++) { - phead = &(pstapriv->sta_hash[i]); + phead = &pstapriv->sta_hash[i]; plist = phead->next; while (phead != plist) { diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index ff77e686721c..55d2b8f90d91 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -414,11 +414,11 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) } /* DS parameter set */ - ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&(pdev_network->Configuration.DSConfig), &sz); + ie = rtw_set_ie(ie, _DSSET_IE_, 1, (u8 *)&pdev_network->Configuration.DSConfig, &sz); /* IBSS Parameter Set */ - ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&(pdev_network->Configuration.ATIMWindow), &sz); + ie = rtw_set_ie(ie, _IBSS_PARA_IE_, 2, (u8 *)&pdev_network->Configuration.ATIMWindow, &sz); if (rateLen > 8) ie = rtw_set_ie(ie, _EXT_SUPPORTEDRATES_IE_, (rateLen - 8), (pdev_network->SupportedRates + 8), &sz); diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index 0e5ce12d4b57..927b8c919fa7 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -8,7 +8,7 @@ struct xmit_frame *rtw_IOL_accquire_xmit_frame(struct adapter *adapter) struct xmit_frame *xmit_frame; struct xmit_buf *xmitbuf; struct pkt_attrib *pattrib; - struct xmit_priv *pxmitpriv = &(adapter->xmitpriv); + struct xmit_priv *pxmitpriv = &adapter->xmitpriv; xmit_frame = rtw_alloc_xmitframe(pxmitpriv); if (!xmit_frame) { diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index def0c250a4ac..7f7a7eddda4a 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -577,7 +577,7 @@ static int mp_xmit_packet_thread(void *context) pmp_priv = (struct mp_priv *)context; pmptx = &pmp_priv->tx; padapter = pmp_priv->papdater; - pxmitpriv = &(padapter->xmitpriv); + pxmitpriv = &padapter->xmitpriv; thread_enter("RTW_MP_THREAD"); @@ -596,7 +596,7 @@ static int mp_xmit_packet_thread(void *context) } memcpy((u8 *)(pxmitframe->buf_addr+TXDESC_OFFSET), pmptx->buf, pmptx->write_size); - memcpy(&(pxmitframe->attrib), &(pmptx->attrib), sizeof(struct pkt_attrib)); + memcpy(&pxmitframe->attrib, &pmptx->attrib, sizeof(struct pkt_attrib)); dump_mpframe(padapter, pxmitframe); @@ -625,7 +625,7 @@ exit: void fill_txdesc_for_mp(struct adapter *padapter, struct tx_desc *ptxdesc) { struct mp_priv *pmp_priv = &padapter->mppriv; - memcpy(ptxdesc, &(pmp_priv->tx.desc), TXDESC_SIZE); + memcpy(ptxdesc, &pmp_priv->tx.desc, TXDESC_SIZE); } void SetPacketTx(struct adapter *padapter) @@ -676,7 +676,7 @@ void SetPacketTx(struct adapter *padapter) pmp_priv->tx.buf = (u8 *)N_BYTE_ALIGMENT((size_t)(pmp_priv->tx.pallocated_buf), XMITBUF_ALIGN_SZ); ptr = pmp_priv->tx.buf; - desc = &(pmp_priv->tx.desc); + desc = &pmp_priv->tx.desc; memset(desc, 0, TXDESC_SIZE); pkt_start = ptr; pkt_end = pkt_start + pkt_size; @@ -954,7 +954,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) goto exit; } - list_add_tail(&pxmitbuf->list, &(pxmitpriv->free_xmit_extbuf_queue.queue)); + list_add_tail(&pxmitbuf->list, &pxmitpriv->free_xmit_extbuf_queue.queue); pxmitbuf++; } -- cgit v1.2.3 From ae7471cae00a432d1c9692452b1b9175a8f3c1b3 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Tue, 10 Aug 2021 08:45:04 +0100 Subject: staging: r8188eu: remove rtw_ioctl function Remove rtw_ioctl function from os_dep/ioctl_linux.c, its declaration in include/osdep_intf.h, and finally its inclusion as the value of the .ndo_do_ioctl member of struct net_device_ops rtw_netdev_ops in os_dep/os_intfs.c. The e-mail from Arnd Bergmann at: https://lore.kernel.org/linux-next/CAK8P3a0WRMNmBmBDerZ0nWPdFZKALnxrj-uUFBkTP-MOtv48vg@mail.gmail.com explains the justification for this approach. Essentially, changes from net-next make the existing function and its use of SIOCDEVPRIVATE ioctls unworkable without changes. Functions called from rtw_ioctl that are now no longer accessible will be cleaned up in further patches. Additionally, once these changes have made their way downstream to the staging branch, we can modify and reconnect rtw_android_priv_cmd via ndo_siocdevprivate in struct net_device_ops. Suggested-by: Arnd Bergmann Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810074504.957-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_intf.h | 2 -- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 28 ---------------------------- drivers/staging/r8188eu/os_dep/os_intfs.c | 1 - 3 files changed, 31 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_intf.h b/drivers/staging/r8188eu/include/osdep_intf.h index 1915c926faac..3ea60feee2db 100644 --- a/drivers/staging/r8188eu/include/osdep_intf.h +++ b/drivers/staging/r8188eu/include/osdep_intf.h @@ -48,8 +48,6 @@ u32 rtw_start_drv_threads(struct adapter *padapter); void rtw_stop_drv_threads (struct adapter *padapter); void rtw_cancel_all_timer(struct adapter *padapter); -int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd); - int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname); struct net_device *rtw_init_netdev(struct adapter *padapter); u16 rtw_recv_select_queue(struct sk_buff *skb); diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index a0ea9b43054b..4e21801cbfcf 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -8002,31 +8002,3 @@ exit: kfree(output); return err; } - -#include "../include/rtw_android.h" -int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) -{ - struct iwreq *wrq = (struct iwreq *)rq; - int ret = 0; - - switch (cmd) { - case RTL_IOCTL_WPA_SUPPLICANT: - ret = wpa_supplicant_ioctl(dev, &wrq->u.data); - break; -#ifdef CONFIG_88EU_AP_MODE - case RTL_IOCTL_HOSTAPD: - ret = rtw_hostapd_ioctl(dev, &wrq->u.data); - break; -#endif /* CONFIG_88EU_AP_MODE */ - case SIOCDEVPRIVATE: - ret = rtw_ioctl_wext_private(dev, &wrq->u); - break; - case (SIOCDEVPRIVATE+1): - ret = rtw_android_priv_cmd(dev, rq, cmd); - break; - default: - ret = -EOPNOTSUPP; - break; - } - return ret; -} diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 7c76c15809e4..38d3283dbac3 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -692,7 +692,6 @@ static const struct net_device_ops rtw_netdev_ops = { .ndo_select_queue = rtw_select_queue, .ndo_set_mac_address = rtw_net_set_mac_address, .ndo_get_stats = rtw_net_get_stats, - .ndo_do_ioctl = rtw_ioctl, }; int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) -- cgit v1.2.3 From ba4b1d7cdd2cb9f6ded814d8aa555068d7d00ea6 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:40 +0100 Subject: staging: r8188eu: remove unused functions from os_dep/ioctl_linux.c Remove unused functions that are now no longer called as a result of the removal of rtw_ioctl in a previous patch. This includes functions not directly called from rtw_ioctl, but anything in that specific call-chain. Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 1538 +++----------------------- 1 file changed, 127 insertions(+), 1411 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 4e21801cbfcf..1ccc5f8de1ee 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1539,7 +1539,6 @@ static int rtw_wx_get_essid(struct net_device *dev, wrqu->essid.length = len; wrqu->essid.flags = 1; -exit: return ret; } @@ -4508,1143 +4507,175 @@ static int rtw_dbg_port(struct net_device *dev, return ret; } -static int wpa_set_param(struct net_device *dev, u8 name, u32 value) -{ - uint ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - switch (name) { - case IEEE_PARAM_WPA_ENABLED: - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; /* 802.1x */ - switch ((value)&0xff) { - case 1: /* WPA */ - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPAPSK; /* WPA_PSK */ - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case 2: /* WPA2 */ - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeWPA2PSK; /* WPA2_PSK */ - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - } - break; - case IEEE_PARAM_TKIP_COUNTERMEASURES: - break; - case IEEE_PARAM_DROP_UNENCRYPTED: { - /* HACK: - * - * wpa_supplicant calls set_wpa_enabled when the driver - * is loaded and unloaded, regardless of if WPA is being - * used. No other calls are made which can be used to - * determine if encryption will be used or not prior to - * association being expected. If encryption is not being - * used, drop_unencrypted is set to false, else true -- we - * can use this to determine if the CAP_PRIVACY_ON bit should - * be set. - */ - - break; - } - case IEEE_PARAM_PRIVACY_INVOKED: - break; - - case IEEE_PARAM_AUTH_ALGS: - ret = wpa_set_auth_algs(dev, value); - break; - case IEEE_PARAM_IEEE_802_1X: - break; - case IEEE_PARAM_WPAX_SELECT: - break; - default: - ret = -EOPNOTSUPP; - break; - } - return ret; -} - -static int wpa_mlme(struct net_device *dev, u32 command, u32 reason) +static int rtw_wx_set_priv(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *awrq, + char *extra) { int ret = 0; + int len = 0; + char *ext; struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); + struct iw_point *dwrq = (struct iw_point *)awrq; - switch (command) { - case IEEE_MLME_STA_DEAUTH: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - case IEEE_MLME_STA_DISASSOC: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - default: - ret = -EOPNOTSUPP; - break; - } - - return ret; -} - -static int wpa_supplicant_ioctl(struct net_device *dev, struct iw_point *p) -{ - struct ieee_param *param; - uint ret = 0; - - if (p->length < sizeof(struct ieee_param) || !p->pointer) { - ret = -EINVAL; - goto out; - } + if (dwrq->length == 0) + return -EFAULT; - param = kmalloc(p->length, GFP_KERNEL); - if (!param) { - ret = -ENOMEM; - goto out; - } + len = dwrq->length; + ext = rtw_vmalloc(len); + if (!ext) + return -ENOMEM; - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - ret = -EFAULT; - goto out; + if (copy_from_user(ext, dwrq->pointer, len)) { + vfree(ext); + return -EFAULT; } - switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: - ret = wpa_set_param(dev, param->u.wpa_param.name, param->u.wpa_param.value); - break; - - case IEEE_CMD_SET_WPA_IE: - ret = rtw_set_wpa_ie((struct adapter *)rtw_netdev_priv(dev), - (char *)param->u.wpa_ie.data, (u16)param->u.wpa_ie.len); - break; + /* added for wps2.0 @20110524 */ + if (dwrq->flags == 0x8766 && len > 8) { + u32 cp_sz; + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + u8 *probereq_wpsie = ext; + int probereq_wpsie_len = len; + u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - case IEEE_CMD_SET_ENCRYPTION: - ret = wpa_set_encryption(dev, param, p->length); - break; + if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && + (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { + cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; - case IEEE_CMD_MLME: - ret = wpa_mlme(dev, param->u.mlme.command, param->u.mlme.reason_code); - break; + pmlmepriv->wps_probe_req_ie_len = 0; + kfree(pmlmepriv->wps_probe_req_ie); + pmlmepriv->wps_probe_req_ie = NULL; - default: - DBG_88E("Unknown WPA supplicant request: %d\n", param->cmd); - ret = -EOPNOTSUPP; - break; + pmlmepriv->wps_probe_req_ie = kmalloc(cp_sz, GFP_KERNEL); + if (!pmlmepriv->wps_probe_req_ie) { + ret = -EINVAL; + goto FREE_EXT; + } + memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); + pmlmepriv->wps_probe_req_ie_len = cp_sz; + } + goto FREE_EXT; } - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; + if (len >= WEXT_CSCAN_HEADER_SIZE && + !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { + ret = rtw_wx_set_scan(dev, info, awrq, ext); + goto FREE_EXT; + } - kfree(param); +FREE_EXT: -out: + vfree(ext); return ret; } -#ifdef CONFIG_88EU_AP_MODE -static u8 set_pairwise_key(struct adapter *padapter, struct sta_info *psta) +static int rtw_pm_set(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra) { - struct cmd_obj *ph2c; - struct set_stakey_parm *psetstakey_para; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - u8 res = _SUCCESS; - - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!ph2c) { - res = _FAIL; - goto exit; - } - - psetstakey_para = kzalloc(sizeof(struct set_stakey_parm), GFP_KERNEL); - if (!psetstakey_para) { - kfree(ph2c); - res = _FAIL; - goto exit; - } - - init_h2fwcmd_w_parm_no_rsp(ph2c, psetstakey_para, _SetStaKey_CMD_); - - psetstakey_para->algorithm = (u8)psta->dot118021XPrivacy; - - memcpy(psetstakey_para->addr, psta->hwaddr, ETH_ALEN); - - memcpy(psetstakey_para->key, &psta->dot118021x_UncstKey, 16); + int ret = 0; + unsigned mode = 0; + struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - res = rtw_enqueue_cmd(pcmdpriv, ph2c); + DBG_88E("[%s] extra = %s\n", __func__, extra); -exit: + if (!memcmp(extra, "lps =", 4)) { + sscanf(extra+4, "%u", &mode); + ret = rtw_pm_set_lps(padapter, mode); + } else if (!memcmp(extra, "ips =", 4)) { + sscanf(extra+4, "%u", &mode); + ret = rtw_pm_set_ips(padapter, mode); + } else { + ret = -EINVAL; + } - return res; + return ret; } -static int set_group_key(struct adapter *padapter, u8 *key, u8 alg, int keyid) +static int rtw_mp_efuse_get(struct net_device *dev, + struct iw_request_info *info, + union iwreq_data *wdata, char *extra) { - u8 keylen; - struct cmd_obj *pcmd; - struct setkey_parm *psetkeyparm; - struct cmd_priv *pcmdpriv = &padapter->cmdpriv; - int res = _SUCCESS; + struct adapter *padapter = rtw_netdev_priv(dev); + struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); + struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); + struct efuse_hal *pEfuseHal; + struct iw_point *wrqu; - DBG_88E("%s\n", __func__); + u8 *PROMContent = pEEPROM->efuse_eeprom_data; + u8 ips_mode = 0, lps_mode = 0; + struct pwrctrl_priv *pwrctrlpriv; + u8 *data = NULL; + u8 *rawdata = NULL; + char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; + u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; + u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; + int err; + u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ + + wrqu = (struct iw_point *)wdata; + pwrctrlpriv = &padapter->pwrctrlpriv; + pEfuseHal = &haldata->EfuseHal; - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); - if (!pcmd) { - res = _FAIL; + err = 0; + data = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); + if (!data) { + err = -ENOMEM; goto exit; } - psetkeyparm = kzalloc(sizeof(struct setkey_parm), GFP_KERNEL); - if (!psetkeyparm) { - kfree(pcmd); - res = _FAIL; + rawdata = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); + if (!rawdata) { + err = -ENOMEM; goto exit; } - memset(psetkeyparm, 0, sizeof(struct setkey_parm)); - - psetkeyparm->keyid = (u8)keyid; - - psetkeyparm->algorithm = alg; - - psetkeyparm->set_tx = 1; - - switch (alg) { - case _WEP40_: - keylen = 5; - break; - case _WEP104_: - keylen = 13; - break; - case _TKIP_: - case _TKIP_WTMIC_: - case _AES_: - default: - keylen = 16; + if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { + err = -EFAULT; + goto exit; } + lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ + rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - memcpy(&psetkeyparm->key[0], key, keylen); - - pcmd->cmdcode = _SetKey_CMD_; - pcmd->parmbuf = (u8 *)psetkeyparm; - pcmd->cmdsz = (sizeof(struct setkey_parm)); - pcmd->rsp = NULL; - pcmd->rspsz = 0; - - INIT_LIST_HEAD(&pcmd->list); - - res = rtw_enqueue_cmd(pcmdpriv, pcmd); - -exit: - - return res; -} + ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ + rtw_pm_set_ips(padapter, IPS_NONE); -static int set_wep_key(struct adapter *padapter, u8 *key, u8 keylen, int keyid) -{ - u8 alg; + pch = extra; + DBG_88E("%s: in =%s\n", __func__, extra); - switch (keylen) { - case 5: - alg = _WEP40_; - break; - case 13: - alg = _WEP104_; - break; - default: - alg = _NO_PRIVACY_; + i = 0; + /* mac 16 "00e04c871200" rmap, 00, 2 */ + while ((token = strsep(&pch, ",")) != NULL) { + if (i > 2) + break; + tmp[i] = token; + i++; } + padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ - return set_group_key(padapter, key, alg, keyid); -} + if (strcmp(tmp[0], "status") == 0) { + sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); -static int rtw_set_encryption(struct net_device *dev, struct ieee_param *param, u32 param_len) -{ - int ret = 0; - u32 wep_key_idx, wep_key_len, wep_total_len; - struct ndis_802_11_wep *pwep = NULL; - struct sta_info *psta = NULL, *pbcmc_sta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct sta_priv *pstapriv = &padapter->stapriv; + goto exit; + } else if (strcmp(tmp[0], "filemap") == 0) { + mapLen = EFUSE_MAP_SIZE; - DBG_88E("%s\n", __func__); - param->u.crypt.err = 0; - param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - if (param_len != sizeof(struct ieee_param) + param->u.crypt.key_len) { - ret = -EINVAL; - goto exit; - } - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) { - if (param->u.crypt.idx >= WEP_KEYS) { - ret = -EINVAL; - goto exit; - } - } else { - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (!psta) { - DBG_88E("rtw_set_encryption(), sta has already been removed or never been added\n"); - goto exit; + sprintf(extra, "\n"); + for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { + sprintf(extra + strlen(extra), "0x%02x\t", i); + for (j = 0; j < 8; j++) + sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); + sprintf(extra + strlen(extra), "\t"); + for (; j < 16; j++) + sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); + sprintf(extra + strlen(extra), "\n"); } - } - - if (strcmp(param->u.crypt.alg, "none") == 0 && !psta) { - /* todo:clear default encryption keys */ - - DBG_88E("clear default encryption keys, keyid =%d\n", param->u.crypt.idx); - goto exit; - } - if (strcmp(param->u.crypt.alg, "WEP") == 0 && !psta) { - DBG_88E("r871x_set_encryption, crypt.alg = WEP\n"); - wep_key_idx = param->u.crypt.idx; - wep_key_len = param->u.crypt.key_len; - DBG_88E("r871x_set_encryption, wep_key_idx=%d, len=%d\n", wep_key_idx, wep_key_len); - if ((wep_key_idx >= WEP_KEYS) || (wep_key_len <= 0)) { - ret = -EINVAL; - goto exit; - } - - if (wep_key_len > 0) { - wep_key_len = wep_key_len <= 5 ? 5 : 13; - wep_total_len = wep_key_len + FIELD_OFFSET(struct ndis_802_11_wep, KeyMaterial); - pwep = kzalloc(wep_total_len, GFP_KERNEL); - if (!pwep) { - ret = -ENOMEM; - goto exit; - } - pwep->KeyLength = wep_key_len; - pwep->Length = wep_total_len; - } - - pwep->KeyIndex = wep_key_idx; - - memcpy(pwep->KeyMaterial, param->u.crypt.key, pwep->KeyLength); - - if (param->u.crypt.set_tx) { - DBG_88E("wep, set_tx = 1\n"); - - psecuritypriv->ndisencryptstatus = Ndis802_11Encryption1Enabled; - psecuritypriv->dot11PrivacyAlgrthm = _WEP40_; - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - - if (pwep->KeyLength == 13) { - psecuritypriv->dot11PrivacyAlgrthm = _WEP104_; - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } - - psecuritypriv->dot11PrivacyKeyIndex = wep_key_idx; - - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); - - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; - - set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); - } else { - DBG_88E("wep, set_tx = 0\n"); - - /* don't update "psecuritypriv->dot11PrivacyAlgrthm" and */ - /* psecuritypriv->dot11PrivacyKeyIndex = keyid", but can rtw_set_key to cam */ - - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); - - psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; - - set_wep_key(padapter, pwep->KeyMaterial, pwep->KeyLength, wep_key_idx); - } - - goto exit; - } - - if (!psta && check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* group key */ - if (param->u.crypt.set_tx == 1) { - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - DBG_88E("%s, set group_key, WEP\n", __func__); - - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (param->u.crypt.key_len == 13) - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - DBG_88E("%s, set group_key, TKIP\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _TKIP_; - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - /* set mic key */ - memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); - memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); - - psecuritypriv->busetkipkey = true; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - DBG_88E("%s, set group_key, CCMP\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _AES_; - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - } else { - DBG_88E("%s, set group_key, none\n", __func__); - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; - } - psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - psecuritypriv->binstallGrpkey = true; - psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ - set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); - pbcmc_sta = rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta) { - pbcmc_sta->ieee8021x_blocked = false; - pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ - } - } - goto exit; - } - - if (psecuritypriv->dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && psta) { /* psk/802_1x */ - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - if (param->u.crypt.set_tx == 1) { - memcpy(psta->dot118021x_UncstKey.skey, param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - DBG_88E("%s, set pairwise key, WEP\n", __func__); - - psta->dot118021XPrivacy = _WEP40_; - if (param->u.crypt.key_len == 13) - psta->dot118021XPrivacy = _WEP104_; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - DBG_88E("%s, set pairwise key, TKIP\n", __func__); - - psta->dot118021XPrivacy = _TKIP_; - - /* set mic key */ - memcpy(psta->dot11tkiptxmickey.skey, ¶m->u.crypt.key[16], 8); - memcpy(psta->dot11tkiprxmickey.skey, ¶m->u.crypt.key[24], 8); - - psecuritypriv->busetkipkey = true; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - DBG_88E("%s, set pairwise key, CCMP\n", __func__); - - psta->dot118021XPrivacy = _AES_; - } else { - DBG_88E("%s, set pairwise key, none\n", __func__); - - psta->dot118021XPrivacy = _NO_PRIVACY_; - } - - set_pairwise_key(padapter, psta); - - psta->ieee8021x_blocked = false; - } else { /* group key??? */ - if (strcmp(param->u.crypt.alg, "WEP") == 0) { - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - psecuritypriv->dot118021XGrpPrivacy = _WEP40_; - if (param->u.crypt.key_len == 13) - psecuritypriv->dot118021XGrpPrivacy = _WEP104_; - } else if (strcmp(param->u.crypt.alg, "TKIP") == 0) { - psecuritypriv->dot118021XGrpPrivacy = _TKIP_; - - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - - /* set mic key */ - memcpy(psecuritypriv->dot118021XGrptxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[16], 8); - memcpy(psecuritypriv->dot118021XGrprxmickey[param->u.crypt.idx].skey, ¶m->u.crypt.key[24], 8); - - psecuritypriv->busetkipkey = true; - } else if (strcmp(param->u.crypt.alg, "CCMP") == 0) { - psecuritypriv->dot118021XGrpPrivacy = _AES_; - - memcpy(psecuritypriv->dot118021XGrpKey[param->u.crypt.idx].skey, - param->u.crypt.key, (param->u.crypt.key_len > 16 ? 16 : param->u.crypt.key_len)); - } else { - psecuritypriv->dot118021XGrpPrivacy = _NO_PRIVACY_; - } - - psecuritypriv->dot118021XGrpKeyid = param->u.crypt.idx; - - psecuritypriv->binstallGrpkey = true; - - psecuritypriv->dot11PrivacyAlgrthm = psecuritypriv->dot118021XGrpPrivacy;/* */ - - set_group_key(padapter, param->u.crypt.key, psecuritypriv->dot118021XGrpPrivacy, param->u.crypt.idx); - - pbcmc_sta = rtw_get_bcmc_stainfo(padapter); - if (pbcmc_sta) { - pbcmc_sta->ieee8021x_blocked = false; - pbcmc_sta->dot118021XPrivacy = psecuritypriv->dot118021XGrpPrivacy;/* rx will use bmc_sta's dot118021XPrivacy */ - } - } - } - } - -exit: - - kfree(pwep); - - return ret; -} - -static int rtw_set_beacon(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - unsigned char *pbuf = param->u.bcn_ie.buf; - - DBG_88E("%s, len =%d\n", __func__, len); - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - memcpy(&pstapriv->max_num_sta, param->u.bcn_ie.reserved, 2); - - if ((pstapriv->max_num_sta > NUM_STA) || (pstapriv->max_num_sta <= 0)) - pstapriv->max_num_sta = NUM_STA; - - if (rtw_check_beacon_data(padapter, pbuf, (len-12-2)) == _SUCCESS)/* 12 = param header, 2:no packed */ - ret = 0; - else - ret = -EINVAL; - - return ret; -} - -static int rtw_hostapd_sta_flush(struct net_device *dev) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - DBG_88E("%s\n", __func__); - - flush_all_cam_entry(padapter); /* clear CAM */ - - ret = rtw_sta_flush(padapter); - - return ret; -} - -static int rtw_add_sta(struct net_device *dev, struct ieee_param *param) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_88E("rtw_add_sta(aid =%d) =%pM\n", param->u.add_sta.aid, (param->sta_addr)); - - if (!check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE))) - return -EINVAL; - - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) { - int flags = param->u.add_sta.flags; - - psta->aid = param->u.add_sta.aid;/* aid = 1~2007 */ - - memcpy(psta->bssrateset, param->u.add_sta.tx_supp_rates, 16); - - /* check wmm cap. */ - if (WLAN_STA_WME&flags) - psta->qos_option = 1; - else - psta->qos_option = 0; - - if (pmlmepriv->qospriv.qos_option == 0) - psta->qos_option = 0; - - /* chec 802.11n ht cap. */ - if (WLAN_STA_HT&flags) { - psta->htpriv.ht_option = true; - psta->qos_option = 1; - memcpy((void *)&psta->htpriv.ht_cap, (void *)¶m->u.add_sta.ht_cap, sizeof(struct ieee80211_ht_cap)); - } else { - psta->htpriv.ht_option = false; - } - - if (pmlmepriv->htpriv.ht_option == false) - psta->htpriv.ht_option = false; - - update_sta_info_apmode(padapter, psta); - } else { - ret = -ENOMEM; - } - - return ret; -} - -static int rtw_del_sta(struct net_device *dev, struct ieee_param *param) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - int updated = 0; - - DBG_88E("rtw_del_sta =%pM\n", (param->sta_addr)); - - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - return -EINVAL; - - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) { - spin_lock_bh(&pstapriv->asoc_list_lock); - if (!list_empty(&psta->asoc_list)) { - list_del_init(&psta->asoc_list); - pstapriv->asoc_list_cnt--; - updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); - } - spin_unlock_bh(&pstapriv->asoc_list_lock); - associated_clients_update(padapter, updated); - psta = NULL; - } else { - DBG_88E("rtw_del_sta(), sta has already been removed or never been added\n"); - } - - return ret; -} - -static int rtw_ioctl_get_sta_data(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - struct ieee_param_ex *param_ex = (struct ieee_param_ex *)param; - struct sta_data *psta_data = (struct sta_data *)param_ex->data; - - DBG_88E("rtw_ioctl_get_sta_info, sta_addr: %pM\n", (param_ex->sta_addr)); - - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - return -EINVAL; - - if (param_ex->sta_addr[0] == 0xff && param_ex->sta_addr[1] == 0xff && - param_ex->sta_addr[2] == 0xff && param_ex->sta_addr[3] == 0xff && - param_ex->sta_addr[4] == 0xff && param_ex->sta_addr[5] == 0xff) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param_ex->sta_addr); - if (psta) { - psta_data->aid = (u16)psta->aid; - psta_data->capability = psta->capability; - psta_data->flags = psta->flags; - -/* - nonerp_set : BIT(0) - no_short_slot_time_set : BIT(1) - no_short_preamble_set : BIT(2) - no_ht_gf_set : BIT(3) - no_ht_set : BIT(4) - ht_20mhz_set : BIT(5) -*/ - - psta_data->sta_set = ((psta->nonerp_set) | - (psta->no_short_slot_time_set << 1) | - (psta->no_short_preamble_set << 2) | - (psta->no_ht_gf_set << 3) | - (psta->no_ht_set << 4) | - (psta->ht_20mhz_set << 5)); - psta_data->tx_supp_rates_len = psta->bssratelen; - memcpy(psta_data->tx_supp_rates, psta->bssrateset, psta->bssratelen); - memcpy(&psta_data->ht_cap, &psta->htpriv.ht_cap, sizeof(struct ieee80211_ht_cap)); - psta_data->rx_pkts = psta->sta_stats.rx_data_pkts; - psta_data->rx_bytes = psta->sta_stats.rx_bytes; - psta_data->rx_drops = psta->sta_stats.rx_drops; - psta_data->tx_pkts = psta->sta_stats.tx_pkts; - psta_data->tx_bytes = psta->sta_stats.tx_bytes; - psta_data->tx_drops = psta->sta_stats.tx_drops; - } else { - ret = -1; - } - - return ret; -} - -static int rtw_get_sta_wpaie(struct net_device *dev, struct ieee_param *param) -{ - int ret = 0; - struct sta_info *psta = NULL; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct sta_priv *pstapriv = &padapter->stapriv; - - DBG_88E("rtw_get_sta_wpaie, sta_addr: %pM\n", (param->sta_addr)); - - if (check_fwstate(pmlmepriv, (_FW_LINKED|WIFI_AP_STATE)) != true) - return -EINVAL; - - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - return -EINVAL; - - psta = rtw_get_stainfo(pstapriv, param->sta_addr); - if (psta) { - if ((psta->wpa_ie[0] == WLAN_EID_RSN) || (psta->wpa_ie[0] == WLAN_EID_GENERIC)) { - int wpa_ie_len; - int copy_len; - - wpa_ie_len = psta->wpa_ie[1]; - copy_len = ((wpa_ie_len+2) > sizeof(psta->wpa_ie)) ? (sizeof(psta->wpa_ie)) : (wpa_ie_len+2); - param->u.wpa_ie.len = copy_len; - memcpy(param->u.wpa_ie.reserved, psta->wpa_ie, copy_len); - } else { - DBG_88E("sta's wpa_ie is NONE\n"); - } - } else { - ret = -1; - } - - return ret; -} - -static int rtw_set_wps_beacon(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - unsigned char wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - int ie_len; - - DBG_88E("%s, len =%d\n", __func__, len); - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - ie_len = len-12-2;/* 12 = param header, 2:no packed */ - - if (pmlmepriv->wps_beacon_ie) { - kfree(pmlmepriv->wps_beacon_ie); - pmlmepriv->wps_beacon_ie = NULL; - } - - if (ie_len > 0) { - pmlmepriv->wps_beacon_ie = kmalloc(ie_len, GFP_KERNEL); - pmlmepriv->wps_beacon_ie_len = ie_len; - if (!pmlmepriv->wps_beacon_ie) { - DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); - return -EINVAL; - } - - memcpy(pmlmepriv->wps_beacon_ie, param->u.bcn_ie.buf, ie_len); - - update_beacon(padapter, _VENDOR_SPECIFIC_IE_, wps_oui, true); - - pmlmeext->bstart_bss = true; - } - - return ret; -} - -static int rtw_set_wps_probe_resp(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int ie_len; - - DBG_88E("%s, len =%d\n", __func__, len); - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - ie_len = len-12-2;/* 12 = param header, 2:no packed */ - - if (pmlmepriv->wps_probe_resp_ie) { - kfree(pmlmepriv->wps_probe_resp_ie); - pmlmepriv->wps_probe_resp_ie = NULL; - } - - if (ie_len > 0) { - pmlmepriv->wps_probe_resp_ie = kmalloc(ie_len, GFP_KERNEL); - pmlmepriv->wps_probe_resp_ie_len = ie_len; - if (!pmlmepriv->wps_probe_resp_ie) { - DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); - return -EINVAL; - } - memcpy(pmlmepriv->wps_probe_resp_ie, param->u.bcn_ie.buf, ie_len); - } - - return ret; -} - -static int rtw_set_wps_assoc_resp(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int ie_len; - - DBG_88E("%s, len =%d\n", __func__, len); - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - ie_len = len-12-2;/* 12 = param header, 2:no packed */ - - if (pmlmepriv->wps_assoc_resp_ie) { - kfree(pmlmepriv->wps_assoc_resp_ie); - pmlmepriv->wps_assoc_resp_ie = NULL; - } - - if (ie_len > 0) { - pmlmepriv->wps_assoc_resp_ie = kmalloc(ie_len, GFP_KERNEL); - pmlmepriv->wps_assoc_resp_ie_len = ie_len; - if (!pmlmepriv->wps_assoc_resp_ie) { - DBG_88E("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); - return -ENOMEM; - } - - memcpy(pmlmepriv->wps_assoc_resp_ie, param->u.bcn_ie.buf, ie_len); - } - - return ret; -} - -static int rtw_set_hidden_ssid(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - - u8 value; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - if (param->u.wpa_param.name != 0) /* dummy test... */ - DBG_88E("%s name(%u) != 0\n", __func__, param->u.wpa_param.name); - value = param->u.wpa_param.value; - - /* use the same definition of hostapd's ignore_broadcast_ssid */ - if (value != 1 && value != 2) - value = 0; - DBG_88E("%s value(%u)\n", __func__, value); - pmlmeinfo->hidden_ssid_mode = value; - return ret; -} - -static int rtw_ioctl_acl_remove_sta(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - return -EINVAL; - ret = rtw_acl_remove_sta(padapter, param->sta_addr); - return ret; -} - -static int rtw_ioctl_acl_add_sta(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - if (param->sta_addr[0] == 0xff && param->sta_addr[1] == 0xff && - param->sta_addr[2] == 0xff && param->sta_addr[3] == 0xff && - param->sta_addr[4] == 0xff && param->sta_addr[5] == 0xff) - return -EINVAL; - ret = rtw_acl_add_sta(padapter, param->sta_addr); - return ret; -} - -static int rtw_ioctl_set_macaddr_acl(struct net_device *dev, struct ieee_param *param, int len) -{ - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) != true) - return -EINVAL; - - rtw_set_macaddr_acl(padapter, param->u.mlme.command); - - return ret; -} - -static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) -{ - struct ieee_param *param; - int ret = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - /* - * this function is expect to call in master mode, which allows no power saving - * so, we just check hw_init_completed - */ - - if (!padapter->hw_init_completed) { - ret = -EPERM; - goto out; - } - - if (!p->pointer || p->length > (sizeof(struct ieee_param) + 100)) { - ret = -EINVAL; - goto out; - } - - param = kmalloc(p->length, GFP_KERNEL); - if (!param) { - ret = -ENOMEM; - goto out; - } - - if (copy_from_user(param, p->pointer, p->length)) { - kfree(param); - ret = -EFAULT; - goto out; - } - - switch (param->cmd) { - case RTL871X_HOSTAPD_FLUSH: - ret = rtw_hostapd_sta_flush(dev); - break; - case RTL871X_HOSTAPD_ADD_STA: - ret = rtw_add_sta(dev, param); - break; - case RTL871X_HOSTAPD_REMOVE_STA: - ret = rtw_del_sta(dev, param); - break; - case RTL871X_HOSTAPD_SET_BEACON: - ret = rtw_set_beacon(dev, param, p->length); - break; - case RTL871X_SET_ENCRYPTION: - ret = rtw_set_encryption(dev, param, p->length); - break; - case RTL871X_HOSTAPD_GET_WPAIE_STA: - ret = rtw_get_sta_wpaie(dev, param); - break; - case RTL871X_HOSTAPD_SET_WPS_BEACON: - ret = rtw_set_wps_beacon(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_WPS_PROBE_RESP: - ret = rtw_set_wps_probe_resp(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_WPS_ASSOC_RESP: - ret = rtw_set_wps_assoc_resp(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_HIDDEN_SSID: - ret = rtw_set_hidden_ssid(dev, param, p->length); - break; - case RTL871X_HOSTAPD_GET_INFO_STA: - ret = rtw_ioctl_get_sta_data(dev, param, p->length); - break; - case RTL871X_HOSTAPD_SET_MACADDR_ACL: - ret = rtw_ioctl_set_macaddr_acl(dev, param, p->length); - break; - case RTL871X_HOSTAPD_ACL_ADD_STA: - ret = rtw_ioctl_acl_add_sta(dev, param, p->length); - break; - case RTL871X_HOSTAPD_ACL_REMOVE_STA: - ret = rtw_ioctl_acl_remove_sta(dev, param, p->length); - break; - default: - pr_info("Unknown hostapd request: %d\n", param->cmd); - ret = -EOPNOTSUPP; - break; - } - - if (ret == 0 && copy_to_user(p->pointer, param, p->length)) - ret = -EFAULT; - kfree(param); -out: - return ret; -} -#endif - -static int rtw_wx_set_priv(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra) -{ - int ret = 0; - int len = 0; - char *ext; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - struct iw_point *dwrq = (struct iw_point *)awrq; - - if (dwrq->length == 0) - return -EFAULT; - - len = dwrq->length; - ext = rtw_vmalloc(len); - if (!ext) - return -ENOMEM; - - if (copy_from_user(ext, dwrq->pointer, len)) { - vfree(ext); - return -EFAULT; - } - - /* added for wps2.0 @20110524 */ - if (dwrq->flags == 0x8766 && len > 8) { - u32 cp_sz; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 *probereq_wpsie = ext; - int probereq_wpsie_len = len; - u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - if ((_VENDOR_SPECIFIC_IE_ == probereq_wpsie[0]) && - (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { - cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; - - pmlmepriv->wps_probe_req_ie_len = 0; - kfree(pmlmepriv->wps_probe_req_ie); - pmlmepriv->wps_probe_req_ie = NULL; - - pmlmepriv->wps_probe_req_ie = kmalloc(cp_sz, GFP_KERNEL); - if (!pmlmepriv->wps_probe_req_ie) { - ret = -EINVAL; - goto FREE_EXT; - } - memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); - pmlmepriv->wps_probe_req_ie_len = cp_sz; - } - goto FREE_EXT; - } - - if (len >= WEXT_CSCAN_HEADER_SIZE && - !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { - ret = rtw_wx_set_scan(dev, info, awrq, ext); - goto FREE_EXT; - } - -FREE_EXT: - - vfree(ext); - - return ret; -} - -static int rtw_pm_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - unsigned mode = 0; - struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); - - DBG_88E("[%s] extra = %s\n", __func__, extra); - - if (!memcmp(extra, "lps =", 4)) { - sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_lps(padapter, mode); - } else if (!memcmp(extra, "ips =", 4)) { - sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_ips(padapter, mode); - } else { - ret = -EINVAL; - } - - return ret; -} - -static int rtw_mp_efuse_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wdata, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(padapter); - struct hal_data_8188e *haldata = GET_HAL_DATA(padapter); - struct efuse_hal *pEfuseHal; - struct iw_point *wrqu; - - u8 *PROMContent = pEEPROM->efuse_eeprom_data; - u8 ips_mode = 0, lps_mode = 0; - struct pwrctrl_priv *pwrctrlpriv; - u8 *data = NULL; - u8 *rawdata = NULL; - char *pch, *ptmp, *token, *tmp[3] = {NULL, NULL, NULL}; - u16 i = 0, j = 0, mapLen = 0, addr = 0, cnts = 0; - u16 max_available_size = 0, raw_cursize = 0, raw_maxsize = 0; - int err; - u8 org_fw_iol = padapter->registrypriv.fw_iol;/* 0:Disable, 1:enable, 2:by usb speed */ - - wrqu = (struct iw_point *)wdata; - pwrctrlpriv = &padapter->pwrctrlpriv; - pEfuseHal = &haldata->EfuseHal; - - err = 0; - data = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); - if (!data) { - err = -ENOMEM; - goto exit; - } - rawdata = kzalloc(EFUSE_BT_MAX_MAP_LEN, GFP_KERNEL); - if (!rawdata) { - err = -ENOMEM; - goto exit; - } - - if (copy_from_user(extra, wrqu->pointer, wrqu->length)) { - err = -EFAULT; - goto exit; - } - lps_mode = pwrctrlpriv->power_mgnt;/* keep org value */ - rtw_pm_set_lps(padapter, PS_MODE_ACTIVE); - - ips_mode = pwrctrlpriv->ips_mode;/* keep org value */ - rtw_pm_set_ips(padapter, IPS_NONE); - - pch = extra; - DBG_88E("%s: in =%s\n", __func__, extra); - - i = 0; - /* mac 16 "00e04c871200" rmap, 00, 2 */ - while ((token = strsep(&pch, ",")) != NULL) { - if (i > 2) - break; - tmp[i] = token; - i++; - } - padapter->registrypriv.fw_iol = 0;/* 0:Disable, 1:enable, 2:by usb speed */ - - if (strcmp(tmp[0], "status") == 0) { - sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); - - goto exit; - } else if (strcmp(tmp[0], "filemap") == 0) { - mapLen = EFUSE_MAP_SIZE; - - sprintf(extra, "\n"); - for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { - sprintf(extra + strlen(extra), "0x%02x\t", i); - for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); - sprintf(extra + strlen(extra), "\t"); - for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); - sprintf(extra + strlen(extra), "\n"); - } - } else if (strcmp(tmp[0], "realmap") == 0) { - mapLen = EFUSE_MAP_SIZE; - if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { - DBG_88E("%s: read realmap Fail!!\n", __func__); - err = -EFAULT; + } else if (strcmp(tmp[0], "realmap") == 0) { + mapLen = EFUSE_MAP_SIZE; + if (rtw_efuse_map_read(padapter, 0, mapLen, pEfuseHal->fakeEfuseInitMap) == _FAIL) { + DBG_88E("%s: read realmap Fail!!\n", __func__); + err = -EFAULT; goto exit; } @@ -7687,318 +6718,3 @@ static const char iw_priv_type_size[] = { sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ 0, /* Not defined */ }; - -static int get_priv_size(__u16 args) -{ - int num = args & IW_PRIV_SIZE_MASK; - int type = (args & IW_PRIV_TYPE_MASK) >> 12; - - return num * iw_priv_type_size[type]; -} -/* copy from net/wireless/wext.c end */ - -static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) -{ - int err = 0; - u8 *input = NULL; - u32 input_len = 0; - const char delim[] = " "; - u8 *output = NULL; - u32 output_len = 0; - u32 count = 0; - u8 *buffer = NULL; - u32 buffer_len = 0; - char *ptr = NULL; - u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ - u32 cmdlen; - s32 len; - u8 *extra = NULL; - u32 extra_size = 0; - - s32 k; - const iw_handler *priv; /* Private ioctl */ - const struct iw_priv_args *priv_args; /* Private ioctl description */ - u32 num_priv_args; /* Number of descriptions */ - iw_handler handler; - int temp; - int subcmd = 0; /* sub-ioctl index */ - int offset = 0; /* Space for sub-ioctl index */ - - union iwreq_data wdata; - - memcpy(&wdata, wrq_data, sizeof(wdata)); - - input_len = wdata.data.length; - if (input_len == 0) - return -EFAULT; - input = kzalloc(input_len, GFP_KERNEL); - if (NULL == input) - return -ENOMEM; - if (copy_from_user(input, wdata.data.pointer, input_len)) { - err = -EFAULT; - goto exit; - } - ptr = input; - len = input_len; - - sscanf(ptr, "%16s", cmdname); - cmdlen = strlen(cmdname); - DBG_88E("%s: cmd =%s\n", __func__, cmdname); - - /* skip command string */ - if (cmdlen > 0) - cmdlen += 1; /* skip one space */ - ptr += cmdlen; - len -= cmdlen; - DBG_88E("%s: parameters =%s\n", __func__, ptr); - - priv = rtw_private_handler; - priv_args = rtw_private_args; - num_priv_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args); - - if (num_priv_args == 0) { - err = -EOPNOTSUPP; - goto exit; - } - - /* Search the correct ioctl */ - k = -1; - while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname)); - - /* If not found... */ - if (k == num_priv_args) { - err = -EOPNOTSUPP; - goto exit; - } - - /* Watch out for sub-ioctls ! */ - if (priv_args[k].cmd < SIOCDEVPRIVATE) { - int j = -1; - - /* Find the matching *real* ioctl */ - while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') || - (priv_args[j].set_args != priv_args[k].set_args) || - (priv_args[j].get_args != priv_args[k].get_args))); - - /* If not found... */ - if (j == num_priv_args) { - err = -EINVAL; - goto exit; - } - - /* Save sub-ioctl number */ - subcmd = priv_args[k].cmd; - /* Reserve one int (simplify alignment issues) */ - offset = sizeof(__u32); - /* Use real ioctl definition from now on */ - k = j; - } - - buffer = kzalloc(4096, GFP_KERNEL); - if (NULL == buffer) { - err = -ENOMEM; - goto exit; - } - - /* If we have to set some data */ - if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { - u8 *str; - - switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) - break; - sscanf(str, "%i", &temp); - buffer[count++] = (u8)temp; - } while (1); - buffer_len = count; - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - break; - case IW_PRIV_TYPE_INT: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) - break; - sscanf(str, "%i", &temp); - ((s32 *)buffer)[count++] = (s32)temp; - } while (1); - buffer_len = count * sizeof(s32); - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - break; - case IW_PRIV_TYPE_CHAR: - if (len > 0) { - /* Size of the string to fetch */ - wdata.data.length = len; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - /* Fetch string */ - memcpy(buffer, ptr, wdata.data.length); - } else { - wdata.data.length = 1; - buffer[0] = '\0'; - } - buffer_len = wdata.data.length; - break; - default: - DBG_88E("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; - } - - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { - DBG_88E("%s: The command %s needs exactly %d argument(s)...\n", - __func__, cmdname, priv_args[k].set_args & IW_PRIV_SIZE_MASK); - err = -EINVAL; - goto exit; - } - } else { - /* if args to set */ - wdata.data.length = 0L; - } - - /* Those two tests are important. They define how the driver - * will have to handle the data */ - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { - /* First case : all SET args fit within wrq */ - if (offset) - wdata.mode = subcmd; - memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); - } else { - if ((priv_args[k].set_args == 0) && - (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { - /* Second case : no SET args, GET args fit within wrq */ - if (offset) - wdata.mode = subcmd; - } else { - /* Third case : args won't fit in wrq, or variable number of args */ - if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { - err = -EFAULT; - goto exit; - } - wdata.data.flags = subcmd; - } - } - - kfree(input); - input = NULL; - - extra_size = 0; - if (IW_IS_SET(priv_args[k].cmd)) { - /* Size of set arguments */ - extra_size = get_priv_size(priv_args[k].set_args); - - /* Does it fits in iwr ? */ - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((extra_size + offset) <= IFNAMSIZ)) - extra_size = 0; - } else { - /* Size of get arguments */ - extra_size = get_priv_size(priv_args[k].get_args); - - /* Does it fits in iwr ? */ - if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (extra_size <= IFNAMSIZ)) - extra_size = 0; - } - - if (extra_size == 0) { - extra = (u8 *)&wdata; - kfree(buffer); - buffer = NULL; - } else { - extra = buffer; - } - - handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; - err = handler(dev, NULL, &wdata, extra); - - /* If we have to get some data */ - if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { - int j; - int n = 0; /* number of args */ - u8 str[20] = {0}; - - /* Check where is the returned data */ - if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) - n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; - else - n = wdata.data.length; - - output = kzalloc(4096, GFP_KERNEL); - if (NULL == output) { - err = -ENOMEM; - goto exit; - } - switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Display args */ - for (j = 0; j < n; j++) { - sprintf(str, "%d ", extra[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); - } - break; - case IW_PRIV_TYPE_INT: - /* Display args */ - for (j = 0; j < n; j++) { - sprintf(str, "%d ", ((__s32 *)extra)[j]); - len = strlen(str); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); - } - break; - case IW_PRIV_TYPE_CHAR: - /* Display args */ - memcpy(output, extra, n); - break; - default: - DBG_88E("%s: Not yet implemented...\n", __func__); - err = -1; - goto exit; - } - - output_len = strlen(output) + 1; - wrq_data->data.length = output_len; - if (copy_to_user(wrq_data->data.pointer, output, output_len)) { - err = -EFAULT; - goto exit; - } - } else { - /* if args to set */ - wrq_data->data.length = 0; - } - -exit: - kfree(input); - kfree(buffer); - kfree(output); - return err; -} -- cgit v1.2.3 From 085f11874b12cc7301ec252313e48fb8a30c980d Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:41 +0100 Subject: staging: r8188eu: remove unused oid_null_function function Remove unused oid_null_function function from include/rtw_ioctl.h Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_ioctl.h | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_ioctl.h b/drivers/staging/r8188eu/include/rtw_ioctl.h index 7ebc52f008a0..a36bd7313755 100644 --- a/drivers/staging/r8188eu/include/rtw_ioctl.h +++ b/drivers/staging/r8188eu/include/rtw_ioctl.h @@ -76,12 +76,6 @@ struct oid_obj_priv { int (*oidfuns)(struct oid_par_priv *poid_par_priv); }; -#if defined(_RTW_MP_IOCTL_C_) -static int oid_null_function(struct oid_par_priv *poid_par_priv) { - return NDIS_STATUS_SUCCESS; -} -#endif - extern struct iw_handler_def rtw_handlers_def; int drv_query_info(struct net_device *miniportadaptercontext, NDIS_OID oid, -- cgit v1.2.3 From d60489b69781104bca0017fcdb0ba39e7f26d3d4 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:42 +0100 Subject: staging: r8188eu: remove unused label from recv_indicatepkt_reorder Remove unused goto label from recv_indicatepkt_reorder function in core/rtw_recv.c Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 08aea680312c..f0a042467386 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -1801,8 +1801,6 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame _cancel_timer_ex(&preorder_ctrl->reordering_ctrl_timer); } -_success_exit: - return _SUCCESS; _err_exit: -- cgit v1.2.3 From aab87047305d2966a9ebfc60a2eb9dff480e6ca0 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:43 +0100 Subject: staging: r8188eu: remove rtw_mfree_sta_priv_lock function Remove rtw_mfree_sta_priv_lock function from rtw_sta_mgt.c, as it does nothing and contains an unused variable. Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index c9644a3ecc4e..a74d0741658a 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -127,13 +127,6 @@ inline struct sta_info *rtw_get_stainfo_by_offset(struct sta_priv *stapriv, int return (struct sta_info *)(stapriv->pstainfo_buf + offset * sizeof(struct sta_info)); } -static void rtw_mfree_sta_priv_lock(struct sta_priv *pstapriv) -{ -#ifdef CONFIG_88EU_AP_MODE - struct wlan_acl_pool *pacl_list = &pstapriv->acl_list; -#endif -} - u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) { struct list_head *phead, *plist; @@ -162,8 +155,6 @@ u32 _rtw_free_sta_priv(struct sta_priv *pstapriv) spin_unlock_bh(&pstapriv->sta_hash_lock); /*===============================*/ - rtw_mfree_sta_priv_lock(pstapriv); - if (pstapriv->pallocated_stainfo_buf) vfree(pstapriv->pallocated_stainfo_buf); } -- cgit v1.2.3 From fdd46ffbe4714f9bfd57cccb8033348d76ebcb89 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:44 +0100 Subject: staging: r8188eu: remove unused variable from rtl8188e_init_dm_priv Remove unused variable from the rtl8188e_init_dm_priv function in hal/rtl8188e_dm.c Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_dm.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_dm.c b/drivers/staging/r8188eu/hal/rtl8188e_dm.c index fab385774400..78552303c990 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_dm.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_dm.c @@ -185,7 +185,6 @@ void rtl8188e_init_dm_priv(struct adapter *Adapter) { struct hal_data_8188e *hal_data = GET_HAL_DATA(Adapter); struct dm_priv *pdmpriv = &hal_data->dmpriv; - struct odm_dm_struct *podmpriv = &hal_data->odmpriv; memset(pdmpriv, 0, sizeof(struct dm_priv)); Init_ODM_ComInfo_88E(Adapter); -- cgit v1.2.3 From 8268010e8f0e23ae31331bc250d420677df7a9e7 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:45 +0100 Subject: staging: r8188eu: remove unused variable from rtw_init_drv_sw Remove unused variable from rtw_init_drv_sw function in os_dep/os_intfs.c Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/os_intfs.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 38d3283dbac3..1eb53cf8bccb 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -852,7 +852,6 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) u8 rtw_init_drv_sw(struct adapter *padapter) { u8 ret8 = _SUCCESS; - unsigned long flags; if ((rtw_init_cmd_priv(&padapter->cmdpriv)) == _FAIL) { ret8 = _FAIL; -- cgit v1.2.3 From 6be20b17ff40d71ff08692eccd6cfff3f33f1e8f Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:46 +0100 Subject: staging: r8188eu: remove unused variable from rtw_init_recv_timer Remove unused variable from rtw_init_recv_timer function in os_dep/recv_linux.c Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-8-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/recv_linux.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index e0fbc5751391..74d76b2baebb 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -211,7 +211,5 @@ static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t) void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl) { - struct adapter *padapter = preorder_ctrl->padapter; - timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0); } -- cgit v1.2.3 From 987219ad34a67b6160e6f5247578596a1a887031 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 11 Aug 2021 00:50:47 +0100 Subject: staging: r8188eu: remove lines from Makefile that silence build warnings Remove the several lines from the Makefile that append EXTRA_CFLAGS options to silence build warnings about unused variables, unused functions and such like. This will enable cleanup of missed warnings, and easier spotting of future such problems. Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210810235047.177883-9-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Makefile | 9 --------- 1 file changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index 152d6325b4d9..7f6658f931d1 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -2,15 +2,6 @@ SHELL := /bin/bash EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS) EXTRA_CFLAGS += -O1 -EXTRA_CFLAGS += -Wno-unused-variable -EXTRA_CFLAGS += -Wno-unused-value -EXTRA_CFLAGS += -Wno-unused-label -EXTRA_CFLAGS += -Wno-unused-parameter -EXTRA_CFLAGS += -Wno-unused-function -EXTRA_CFLAGS += -Wno-unused - -EXTRA_CFLAGS += -Wno-uninitialized - ccflags-y += -D__CHECK_ENDIAN__ CONFIG_R8188EU = m -- cgit v1.2.3 From dcda94c9412a079df2e7b6b7e167342349db3a3f Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Tue, 10 Aug 2021 13:05:11 -0500 Subject: staging: r8188eu: Replace BITn with BIT(n) The driver uses BITn instead of BIT(n). All such usage is converted. Note that this patch does not address any warnings that checkpatch will find. These include missing space around operators and lines that are too long. These problems will be addressed in a separate patch. Acked-by: Phillip Potter Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210810180511.8986-1-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 40 +-- drivers/staging/r8188eu/hal/odm.c | 68 ++-- drivers/staging/r8188eu/hal/odm_HWConfig.c | 4 +- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 116 +++---- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 14 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 66 ++-- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 34 +- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 8 +- drivers/staging/r8188eu/hal/rtl8188eu_led.c | 10 +- drivers/staging/r8188eu/hal/usb_halinit.c | 48 +-- drivers/staging/r8188eu/include/Hal8188EPhyCfg.h | 14 +- drivers/staging/r8188eu/include/Hal8188EPwrSeq.h | 84 ++--- drivers/staging/r8188eu/include/hal_intf.h | 16 +- drivers/staging/r8188eu/include/odm.h | 106 +++--- drivers/staging/r8188eu/include/odm_reg.h | 2 +- drivers/staging/r8188eu/include/odm_types.h | 8 +- drivers/staging/r8188eu/include/osdep_service.h | 42 --- drivers/staging/r8188eu/include/rtl8188e_spec.h | 415 +++++++++++------------ drivers/staging/r8188eu/include/rtw_sreset.h | 14 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 4 +- 21 files changed, 518 insertions(+), 597 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 35a4a9e222e6..37e8b076be93 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -564,7 +564,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) bgroup = false; } else { - /* Group key - KeyIndex(BIT30 == 0) */ + /* Group key - KeyIndex(BIT(30) == 0) */ /* when add wep key through add key and didn't assigned encryption type before */ if ((padapter->securitypriv.ndisauthtype <= 3) && (padapter->securitypriv.dot118021XGrpPrivacy == 0)) { diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index 68e7c31cc720..643a4d348b2e 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -336,11 +336,11 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, value32); value32 = ((X * ele_D)>>7)&0x01; - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, value32); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(28), value32); } else { ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)OFDM_index[1]]); ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, 0x00); - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT28, 0x00); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(28), 0x00); } } } @@ -392,7 +392,7 @@ phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - if (!(regeac & BIT28) && + if (!(regeac & BIT(28)) && (((regE94 & 0x03FF0000)>>16) != 0x142) && (((regE9C & 0x03FF0000)>>16) != 0x42)) result |= 0x01; @@ -446,7 +446,7 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) regE94 = ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord); regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); - if (!(regeac & BIT28) && + if (!(regeac & BIT(28)) && (((regE94 & 0x03FF0000)>>16) != 0x142) && (((regE9C & 0x03FF0000)>>16) != 0x42)) result |= 0x01; @@ -495,7 +495,7 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) ODM_SetBBReg(dm_odm, rFPGA0_IQK, bMaskDWord, 0x00000000); ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); - if (!(regeac & BIT27) && /* if Tx is OK, check whether Rx is OK */ + if (!(regeac & BIT(27)) && /* if Tx is OK, check whether Rx is OK */ (((regEA4 & 0x03FF0000)>>16) != 0x132) && (((regeac & 0x03FF0000)>>16) != 0x36)) result |= 0x02; @@ -525,14 +525,14 @@ phy_PathB_IQK_8188E(struct adapter *adapt) regec4 = ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord); regecc = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord); - if (!(regeac & BIT31) && + if (!(regeac & BIT(31)) && (((regeb4 & 0x03FF0000)>>16) != 0x142) && (((regebc & 0x03FF0000)>>16) != 0x42)) result |= 0x01; else return result; - if (!(regeac & BIT30) && + if (!(regeac & BIT(30)) && (((regec4 & 0x03FF0000)>>16) != 0x132) && (((regecc & 0x03FF0000)>>16) != 0x36)) result |= 0x02; @@ -732,9 +732,9 @@ _PHY_MACSettingCalibration( ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT3))); + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT(3)))); } - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT5))); + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT(5)))); } void @@ -907,15 +907,15 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, } /* BB setting */ - ODM_SetBBReg(dm_odm, rFPGA0_RFMOD, BIT24, 0x00); + ODM_SetBBReg(dm_odm, rFPGA0_RFMOD, BIT(24), 0x00); ODM_SetBBReg(dm_odm, rOFDM0_TRxPathEnable, bMaskDWord, 0x03a05600); ODM_SetBBReg(dm_odm, rOFDM0_TRMuxPar, bMaskDWord, 0x000800e4); ODM_SetBBReg(dm_odm, rFPGA0_XCD_RFInterfaceSW, bMaskDWord, 0x22204000); - ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT10, 0x01); - ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT26, 0x01); - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT10, 0x00); - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT10, 0x00); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(10), 0x00); + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(10), 0x00); if (is2t) { ODM_SetBBReg(dm_odm, rFPGA0_XA_LSSIParameter, bMaskDWord, 0x00010000); @@ -1255,21 +1255,21 @@ static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2 if (!adapt->hw_init_completed) { u8 u1btmp; - u1btmp = ODM_Read1Byte(dm_odm, REG_LEDCFG2) | BIT7; + u1btmp = ODM_Read1Byte(dm_odm, REG_LEDCFG2) | BIT(7); ODM_Write1Byte(dm_odm, REG_LEDCFG2, u1btmp); - ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFParameter, BIT13, 0x01); + ODM_SetBBReg(dm_odm, rFPGA0_XAB_RFParameter, BIT(13), 0x01); } if (is2t) { /* 92C */ if (main) - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x1); /* 92C_Path_A */ + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(5)|BIT(6), 0x1); /* 92C_Path_A */ else - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT5|BIT6, 0x2); /* BT */ + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(5)|BIT(6), 0x2); /* BT */ } else { /* 88C */ if (main) - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x2); /* Main */ + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(8)|BIT(9), 0x2); /* Main */ else - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT8|BIT9, 0x1); /* Aux */ + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(8)|BIT(9), 0x1); /* Aux */ } } diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 99b61a6c3a7a..53198bf92c0f 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -426,7 +426,7 @@ void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value) void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) { - pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT9); + pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT(9)); pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); if (pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D)) pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV; @@ -798,8 +798,8 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { /* hold ofdm counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 1); /* hold page C counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 1); /* hold page D counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 1); /* hold page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */ ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); @@ -824,8 +824,8 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) } /* hold cck counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT12, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT14, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(12), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(14), 1); ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); FalseAlmCnt->Cnt_Cck_fail = ret_value; @@ -847,20 +847,20 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) if (pDM_Odm->SupportICType >= ODM_RTL8723A) { /* reset false alarm counter registers */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT31, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT27, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT(31), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTC_11N, BIT(31), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(27), 0); /* update ofdm counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT31, 0); /* update page C counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT31, 0); /* update page D counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_HOLDC_11N, BIT(31), 0); /* update page C counter */ + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 0); /* update page D counter */ /* reset CCK CCA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT13|BIT12, 2); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(13)|BIT(12), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(13)|BIT(12), 2); /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT15|BIT14, 2); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(15)|BIT(14), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(15)|BIT(14), 2); } } else { /* FOR ODM_IC_11AC_SERIES */ /* read OFDM FA counter */ @@ -869,11 +869,11 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) FalseAlmCnt->Cnt_all = FalseAlmCnt->Cnt_Ofdm_fail + FalseAlmCnt->Cnt_Cck_fail; /* reset OFDM FA coutner */ - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 1); - ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT17, 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT(17), 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RST_11AC, BIT(17), 0); /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT15, 1); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT(15), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11AC, BIT(15), 1); } } @@ -1000,7 +1000,7 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) } if (pDM_PSTable->initialize == 0) { pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14; - pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT3)>>3; + pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT(3))>>3; pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24; pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12; pDM_PSTable->initialize = 1; @@ -1031,23 +1031,23 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) /* 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode. */ /* Suggested by SD3 Yu-Nan. 2011.01.20. */ if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x1); /* Reg874[5]=1b'1 */ + ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x1); /* Reg874[5]=1b'1 */ ODM_SetBBReg(pDM_Odm, 0x874, 0x1C0000, 0x2); /* Reg874[20:18]=3'b010 */ - ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, 0); /* RegC70[3]=1'b0 */ + ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), 0); /* RegC70[3]=1'b0 */ ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, 0x63); /* Reg85C[31:24]=0x63 */ ODM_SetBBReg(pDM_Odm, 0x874, 0xC000, 0x2); /* Reg874[15:14]=2'b10 */ ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, 0x3); /* RegA75[7:4]=0x3 */ - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); /* Reg818[28]=1'b0 */ - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x1); /* Reg818[28]=1'b1 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); /* Reg818[28]=1'b0 */ + ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x1); /* Reg818[28]=1'b1 */ } else { ODM_SetBBReg(pDM_Odm, 0x874, 0x1CC000, pDM_PSTable->Reg874); - ODM_SetBBReg(pDM_Odm, 0xc70, BIT3, pDM_PSTable->RegC70); + ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), pDM_PSTable->RegC70); ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); - ODM_SetBBReg(pDM_Odm, 0x818, BIT28, 0x0); + ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); if (pDM_Odm->SupportICType == ODM_RTL8723A) - ODM_SetBBReg(pDM_Odm, 0x874, BIT5, 0x0); /* Reg874[5]=1b'0 */ + ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x0); /* Reg874[5]=1b'0 */ } pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; } @@ -1491,7 +1491,7 @@ void odm_TXPowerTrackingCheckCE(struct odm_dm_struct *pDM_Odm) return; if (!pDM_Odm->RFCalibrateInfo.TM_Trigger) { /* at least delay 1 sec */ - PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); + PHY_SetRFReg(Adapter, RF_PATH_A, RF_T_METER_88E, BIT(17) | BIT(16), 0x03); pDM_Odm->RFCalibrateInfo.TM_Trigger = 1; return; @@ -1700,10 +1700,10 @@ u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, u8 initial_gai ODM_SetBBReg(pDM_Odm, 0x808, 0x3FF, point); /* Start PSD calculation, Reg808[22]=0->1 */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 1); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(22), 1); /* Need to wait for HW PSD report */ ODM_StallExecution(30); - ODM_SetBBReg(pDM_Odm, 0x808, BIT22, 0); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(22), 0); /* Read PSD report, Reg8B4[15:0] */ psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF; @@ -1805,11 +1805,11 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) if (pDM_Odm->SupportICType == ODM_RTL8192C) { /* Which path in ADC/DAC is turnned on for PSD: both I/Q */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT10|BIT11, 0x3); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(10)|BIT(11), 0x3); /* Ageraged number: 8 */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT12|BIT13, 0x1); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(12)|BIT(13), 0x1); /* pts = 128; */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT14|BIT15, 0x0); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(14)|BIT(15), 0x0); } /* 1 Backup Current RF/BB Settings */ @@ -1831,7 +1831,7 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); /* Set PSD 128 pts */ - ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT14|BIT15, 0x0); /* 128 pts */ + ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT(14)|BIT(15), 0x0); /* 128 pts */ /* To SET CH1 to do */ ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); /* Channel 1 */ diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 5f29535590cd..343c647a1eaf 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -449,7 +449,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, } } - pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT0; + pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT(0); } else { RSSI_Ave = pPhyInfo->RxPWDBAll; @@ -478,7 +478,7 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, pEntry->rssi_stat.ValidBit++; for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) - OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT0; + OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT(0); if (pEntry->rssi_stat.ValidBit == 64) { Weighting = ((OFDM_pkt<<4) > 64) ? 64 : (OFDM_pkt<<4); diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 02e44403fd31..b6b95649f3af 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -18,24 +18,24 @@ static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) if (*dm_odm->mp_mode == 1) { dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* 1:CG, 0:CS */ + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT(7), 0); /* disable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); /* 1:CG, 0:CS */ return; } /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT(23)|BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ /* Pin Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 1); /* Regb2c[22]=1'b0 disable CS/CG switch */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT(9)|BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(22), 1); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); /* Regb2c[31]=1'b1 output at CG only */ /* OFDM Settings */ ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); /* CCK Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT(7), 1); /* Fix CCK PHY status report issue */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT(4), 1); /* CCK complete HW AntDiv within 64 samples */ ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, 0xFFFF, 0x0201); /* antenna mapping table */ } @@ -46,32 +46,32 @@ static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) if (*dm_odm->mp_mode == 1) { dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* disable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, 0); /* Default RX (0/1) */ + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT(7), 0); /* disable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5)|BIT(4)|BIT(3), 0); /* Default RX (0/1) */ return; } /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT(23)|BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ /* Pin Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ - ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT(9)|BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(22), 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); /* Regb2c[31]=1'b1 output at CG only */ /* OFDM Settings */ ODM_SetBBReg(dm_odm, ODM_REG_ANTDIV_PARA1_11N, bMaskDWord, 0x000000a0); /* CCK Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT7, 1); /* Fix CCK PHY status report issue */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT4, 1); /* CCK complete HW AntDiv within 64 samples */ + ODM_SetBBReg(dm_odm, ODM_REG_BB_PWR_SAV4_11N, BIT(7), 1); /* Fix CCK PHY status report issue */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA2_11N, BIT(4), 1); /* CCK complete HW AntDiv within 64 samples */ /* Tx Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 0); /* Reg80c[21]=1'b0 from TX Reg */ ODM_UpdateRxIdleAnt_88E(dm_odm, MAIN_ANT); /* antenna mapping table */ if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT(10)|BIT(9)|BIT(8), 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT(13)|BIT(12)|BIT(11), 2); /* Reg858[13:11]=3'b010 */ } else { /* MPchip */ ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, 0x0201); /* Reg914=3'b010, Reg915=3'b001 */ } @@ -97,40 +97,40 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, 0x4c, bMaskDWord); - ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32|(BIT23|BIT25)); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32|(BIT(23)|BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ value32 = ODM_GetMACReg(dm_odm, 0x7B4, bMaskDWord); - ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32|(BIT16|BIT17)); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ + ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32|(BIT(16)|BIT(17))); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ /* Match MAC ADDR */ ODM_SetMACReg(dm_odm, 0x7b4, 0xFFFF, 0); ODM_SetMACReg(dm_odm, 0x7b0, bMaskDWord, 0); - ODM_SetBBReg(dm_odm, 0x870, BIT9|BIT8, 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ - ODM_SetBBReg(dm_odm, 0x864, BIT10, 0); /* Reg864[10]=1'b0 antsel2 by HW */ - ODM_SetBBReg(dm_odm, 0xb2c, BIT22, 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ - ODM_SetBBReg(dm_odm, 0xb2c, BIT31, 1); /* Regb2c[31]=1'b1 output at CG only */ + ODM_SetBBReg(dm_odm, 0x870, BIT(9)|BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, 0x864, BIT(10), 0); /* Reg864[10]=1'b0 antsel2 by HW */ + ODM_SetBBReg(dm_odm, 0xb2c, BIT(22), 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ + ODM_SetBBReg(dm_odm, 0xb2c, BIT(31), 1); /* Regb2c[31]=1'b1 output at CG only */ ODM_SetBBReg(dm_odm, 0xca4, bMaskDWord, 0x000000a0); /* antenna mapping table */ if (AntCombination == 2) { if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 1); /* Reg858[10:8]=3'b001 */ - ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 2); /* Reg858[13:11]=3'b010 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(10)|BIT(9)|BIT(8), 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(13)|BIT(12)|BIT(11), 2); /* Reg858[13:11]=3'b010 */ } else { /* MPchip */ ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 1); ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 2); } } else if (AntCombination == 7) { if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, 0x858, BIT10|BIT9|BIT8, 0); /* Reg858[10:8]=3'b000 */ - ODM_SetBBReg(dm_odm, 0x858, BIT13|BIT12|BIT11, 1); /* Reg858[13:11]=3'b001 */ - ODM_SetBBReg(dm_odm, 0x878, BIT16, 0); - ODM_SetBBReg(dm_odm, 0x858, BIT15|BIT14, 2); /* Reg878[0],Reg858[14:15])=3'b010 */ - ODM_SetBBReg(dm_odm, 0x878, BIT19|BIT18|BIT17, 3);/* Reg878[3:1]=3b'011 */ - ODM_SetBBReg(dm_odm, 0x878, BIT22|BIT21|BIT20, 4);/* Reg878[6:4]=3b'100 */ - ODM_SetBBReg(dm_odm, 0x878, BIT25|BIT24|BIT23, 5);/* Reg878[9:7]=3b'101 */ - ODM_SetBBReg(dm_odm, 0x878, BIT28|BIT27|BIT26, 6);/* Reg878[12:10]=3b'110 */ - ODM_SetBBReg(dm_odm, 0x878, BIT31|BIT30|BIT29, 7);/* Reg878[15:13]=3b'111 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(10)|BIT(9)|BIT(8), 0); /* Reg858[10:8]=3'b000 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(13)|BIT(12)|BIT(11), 1); /* Reg858[13:11]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(16), 0); + ODM_SetBBReg(dm_odm, 0x858, BIT(15)|BIT(14), 2); /* Reg878[0],Reg858[14:15])=3'b010 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(19)|BIT(18)|BIT(17), 3);/* Reg878[3:1]=3b'011 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(22)|BIT(21)|BIT(20), 4);/* Reg878[6:4]=3b'100 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(25)|BIT(24)|BIT(23), 5);/* Reg878[9:7]=3b'101 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(28)|BIT(27)|BIT(26), 6);/* Reg878[12:10]=3b'110 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(31)|BIT(30)|BIT(29), 7);/* Reg878[15:13]=3b'111 */ } else { /* MPchip */ ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 0); ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 1); @@ -144,13 +144,13 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) } /* Default Ant Setting when no fast training */ - ODM_SetBBReg(dm_odm, 0x80c, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ - ODM_SetBBReg(dm_odm, 0x864, BIT5|BIT4|BIT3, 0); /* Default RX */ - ODM_SetBBReg(dm_odm, 0x864, BIT8|BIT7|BIT6, 1); /* Optional RX */ + ODM_SetBBReg(dm_odm, 0x80c, BIT(21), 1); /* Reg80c[21]=1'b1 from TX Info */ + ODM_SetBBReg(dm_odm, 0x864, BIT(5)|BIT(4)|BIT(3), 0); /* Default RX */ + ODM_SetBBReg(dm_odm, 0x864, BIT(8)|BIT(7)|BIT(6), 1); /* Optional RX */ /* Enter Traing state */ - ODM_SetBBReg(dm_odm, 0x864, BIT2|BIT1|BIT0, (AntCombination-1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ - ODM_SetBBReg(dm_odm, 0xc50, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, 0x864, BIT(2)|BIT(1)|BIT(0), (AntCombination-1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ + ODM_SetBBReg(dm_odm, 0xc50, BIT(7), 1); /* RegC50[7]=1'b1 enable HW AntDiv */ } void ODM_AntennaDiversityInit_88E(struct odm_dm_struct *dm_odm) @@ -181,13 +181,13 @@ void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) } if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ - ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT14|BIT13|BIT12, DefaultAnt); /* Default TX */ - ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT6|BIT7, DefaultAnt); /* Resp Tx */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5)|BIT(4)|BIT(3), DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(8)|BIT(7)|BIT(6), OptionalAnt); /* Optional RX */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT(14)|BIT(13)|BIT(12), DefaultAnt); /* Default TX */ + ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT(6)|BIT(7), DefaultAnt); /* Resp Tx */ } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT5|BIT4|BIT3, DefaultAnt); /* Default RX */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT8|BIT7|BIT6, OptionalAnt); /* Optional RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5)|BIT(4)|BIT(3), DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(8)|BIT(7)|BIT(6), OptionalAnt); /* Optional RX */ } } dm_fat_tbl->RxIdleAnt = Ant; @@ -204,9 +204,9 @@ static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId) TargetAnt = MAIN_ANT_CG_TRX; else TargetAnt = AUX_ANT_CG_TRX; - dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT0; - dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT1)>>1; - dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT2)>>2; + dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT(0); + dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT(1))>>1; + dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT(2))>>2; } void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId) @@ -300,20 +300,20 @@ void ODM_AntennaDiversity_88E(struct odm_dm_struct *dm_odm) return; if (!dm_odm->bLinked) { if (dm_fat_tbl->bBecomeLinked) { - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 0); /* RegC50[7]=1'b1 enable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 0); /* Enable CCK AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT(7), 0); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT(15), 0); /* Enable CCK AntDiv */ if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 0); /* Reg80c[21]=1'b0 from TX Reg */ + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 0); /* Reg80c[21]=1'b0 from TX Reg */ dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; } return; } else { if (!dm_fat_tbl->bBecomeLinked) { /* Because HW AntDiv is disabled before Link, we enable HW AntDiv after link */ - ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT7, 1); /* RegC50[7]=1'b1 enable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT15, 1); /* Enable CCK AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT(7), 1); /* RegC50[7]=1'b1 enable HW AntDiv */ + ODM_SetBBReg(dm_odm, ODM_REG_CCK_ANTDIV_PARA1_11N, BIT(15), 1); /* Enable CCK AntDiv */ if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT21, 1); /* Reg80c[21]=1'b1 from TX Info */ + ODM_SetBBReg(dm_odm, ODM_REG_TX_ANT_CTRL_11N, BIT(21), 1); /* Reg80c[21]=1'b1 from TX Info */ dm_fat_tbl->bBecomeLinked = dm_odm->bLinked; } } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 02eda8fae25c..6cbda9ab6e3f 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -598,7 +598,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ /* Set REG_CR bit 8. DMA beacon by SW. */ - haldata->RegCR_1 |= BIT0; + haldata->RegCR_1 |= BIT(0); rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); /* Disable Hw protection for a time which revserd for Hw sending beacon. */ @@ -607,14 +607,14 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(3))); rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(4)); - if (haldata->RegFwHwTxQCtrl&BIT6) { + if (haldata->RegFwHwTxQCtrl&BIT(6)) { DBG_88E("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n"); bSendBeacon = true; } /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT6))); - haldata->RegFwHwTxQCtrl &= (~BIT6); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT(6)))); + haldata->RegFwHwTxQCtrl &= (~BIT(6)); /* Clear beacon valid check bit. */ rtw_hal_set_hwreg(adapt, HW_VAR_BCN_VALID, NULL); @@ -656,8 +656,8 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* the beacon cannot be sent by HW. */ /* 2010.06.23. Added by tynli. */ if (bSendBeacon) { - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT6)); - haldata->RegFwHwTxQCtrl |= BIT6; + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT(6))); + haldata->RegFwHwTxQCtrl |= BIT(6); } /* Update RSVD page location H2C to Fw. */ @@ -668,7 +668,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */ /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ - haldata->RegCR_1 &= (~BIT0); + haldata->RegCR_1 &= (~BIT(0)); rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 732d42ab3e0d..588520d28097 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -351,7 +351,7 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) rtw_usleep_os(2); loop = 0; do { - rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL)&BIT24); + rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL)&BIT(24)); if (rstatus) { fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_L); memcpy(pbuf+(addr*8), &fifo_data, 4); @@ -495,8 +495,8 @@ void _8051Reset88E(struct adapter *padapter) u8 u1bTmp; u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT2)); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT2)); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT(2))); + rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT(2))); DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n"); } @@ -1077,7 +1077,7 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); - if (!(word_en&BIT0)) { + if (!(word_en&BIT(0))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[0], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[1], bPseudoTest); @@ -1085,9 +1085,9 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1], bPseudoTest); if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) - badworden &= (~BIT0); + badworden &= (~BIT(0)); } - if (!(word_en&BIT1)) { + if (!(word_en&BIT(1))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); @@ -1095,9 +1095,9 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[2], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) - badworden &= (~BIT1); + badworden &= (~BIT(1)); } - if (!(word_en&BIT2)) { + if (!(word_en&BIT(2))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[4], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[5], bPseudoTest); @@ -1105,9 +1105,9 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5], bPseudoTest); if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) - badworden &= (~BIT2); + badworden &= (~BIT(2)); } - if (!(word_en&BIT3)) { + if (!(word_en&BIT(3))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[6], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[7], bPseudoTest); @@ -1115,7 +1115,7 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7], bPseudoTest); if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) - badworden &= (~BIT3); + badworden &= (~BIT(3)); } return badworden; } @@ -1493,18 +1493,18 @@ static bool wordEnMatched(struct pgpkt *pTargetPkt, struct pgpkt *pCurPkt, u8 match_word_en = 0x0F; /* default all words are disabled */ /* check if the same words are enabled both target and current PG packet */ - if (((pTargetPkt->word_en & BIT0) == 0) && - ((pCurPkt->word_en & BIT0) == 0)) - match_word_en &= ~BIT0; /* enable word 0 */ - if (((pTargetPkt->word_en & BIT1) == 0) && - ((pCurPkt->word_en & BIT1) == 0)) - match_word_en &= ~BIT1; /* enable word 1 */ - if (((pTargetPkt->word_en & BIT2) == 0) && - ((pCurPkt->word_en & BIT2) == 0)) - match_word_en &= ~BIT2; /* enable word 2 */ - if (((pTargetPkt->word_en & BIT3) == 0) && - ((pCurPkt->word_en & BIT3) == 0)) - match_word_en &= ~BIT3; /* enable word 3 */ + if (((pTargetPkt->word_en & BIT(0)) == 0) && + ((pCurPkt->word_en & BIT(0)) == 0)) + match_word_en &= ~BIT(0); /* enable word 0 */ + if (((pTargetPkt->word_en & BIT(1)) == 0) && + ((pCurPkt->word_en & BIT(1)) == 0)) + match_word_en &= ~BIT(1); /* enable word 1 */ + if (((pTargetPkt->word_en & BIT(2)) == 0) && + ((pCurPkt->word_en & BIT(2)) == 0)) + match_word_en &= ~BIT(2); /* enable word 2 */ + if (((pTargetPkt->word_en & BIT(3)) == 0) && + ((pCurPkt->word_en & BIT(3)) == 0)) + match_word_en &= ~BIT(3); /* enable word 3 */ *pWden = match_word_en; @@ -1786,10 +1786,10 @@ static void hal_notch_filter_8188e(struct adapter *adapter, bool enable) { if (enable) { DBG_88E("Enable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT1); + rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT(1)); } else { DBG_88E("Disable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT1); + rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT(1)); } } void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) @@ -2008,7 +2008,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; } else { pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; - if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; } @@ -2016,7 +2016,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; } else { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); - if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; } pwrInfo24G->CCK_Diff[rfPath][TxCount] = 0; @@ -2026,7 +2026,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; - if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; } @@ -2034,7 +2034,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); - if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; } eeAddr++; @@ -2043,7 +2043,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; - if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; } @@ -2051,7 +2051,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); - if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT3) /* 4bit sign number to 8 bit sign number */ + if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; } eeAddr++; @@ -2121,13 +2121,13 @@ void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoL /* hw power down mode selection , 0:rf-off / 1:power down */ if (padapter->registrypriv.hwpdn_mode == 2) - padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT4); + padapter->pwrctrlpriv.bHWPowerdown = (hwinfo[EEPROM_RF_FEATURE_OPTION_88E] & BIT(4)); else padapter->pwrctrlpriv.bHWPowerdown = padapter->registrypriv.hwpdn_mode; /* decide hw if support remote wakeup function */ /* if hw supported, 8051 (SIE) will generate WeakUP signal(D+/D- toggle) when autoresume */ - padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT1) ? true : false; + padapter->pwrctrlpriv.bSupportRemoteWakeup = (hwinfo[EEPROM_USB_OPTIONAL_FUNCTION0] & BIT(1)) ? true : false; DBG_88E("%s...bHWPwrPindetect(%x)-bHWPowerdown(%x) , bSupportRemoteWakeup(%x)\n", __func__, padapter->pwrctrlpriv.bHWPwrPindetect, padapter->pwrctrlpriv.bHWPowerdown, padapter->pwrctrlpriv.bSupportRemoteWakeup); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index f6d4029eae22..b5fb3aedc000 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -400,11 +400,11 @@ void Hal_SetAntenna(struct adapter *pAdapter) /* We need to close RFB by SW control */ if (pHalData->rf_type == RF_2T2R) { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(26), 1); + PHY_SetBBReg(pAdapter, rFPGA0_XB_RFInterfaceOE, BIT(10), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT(1), 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT(17), 0); } break; case ANTENNA_B: @@ -425,11 +425,11 @@ void Hal_SetAntenna(struct adapter *pAdapter) /* 2008/10/31 MH From SD3 Willi's suggestion. We must read RF 1T table. */ /* 2009/01/08 MH From Sd3 Willis. We need to close RFA by SW control */ if (pHalData->rf_type == RF_2T2R || pHalData->rf_type == RF_1T2R) { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(10), 1); + PHY_SetBBReg(pAdapter, rFPGA0_XA_RFInterfaceOE, BIT(10), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT(1), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT(17), 1); } break; case ANTENNA_AB: /* For 8192S */ @@ -449,10 +449,10 @@ void Hal_SetAntenna(struct adapter *pAdapter) /* cosa r_ant_select_ofdm_val = 0x3321333; */ /* 2009/01/08 MH From Sd3 Willis. We need to enable RFA/B by SW control */ if (pHalData->rf_type == RF_2T2R) { - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT10, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT26, 0); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT1, 1); - PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT17, 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(10), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFInterfaceSW, BIT(26), 0); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT(1), 1); + PHY_SetBBReg(pAdapter, rFPGA0_XAB_RFParameter, BIT(17), 1); } break; default: @@ -527,7 +527,7 @@ s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) void Hal_TriggerRFThermalMeter(struct adapter *pAdapter) { - _write_rfreg(pAdapter, RF_PATH_A, RF_T_METER_88E, BIT17 | BIT16, 0x03); + _write_rfreg(pAdapter, RF_PATH_A, RF_T_METER_88E, BIT(17) | BIT(16), 0x03); } u8 Hal_ReadRFThermalMeter(struct adapter *pAdapter) @@ -617,7 +617,7 @@ void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) PHY_SetBBReg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x0); if (is92C) { - _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x01); + _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT(19), 0x01); rtw_usleep_os(100); if (rfPath == RF_PATH_A) write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x10000); /* PAD all on. */ @@ -648,7 +648,7 @@ void Hal_SetSingleToneTx(struct adapter *pAdapter, u8 bStart) write_bbreg(pAdapter, rFPGA0_RFMOD, bCCKEn, 0x1); write_bbreg(pAdapter, rFPGA0_RFMOD, bOFDMEn, 0x1); if (is92C) { - _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT19, 0x00); + _write_rfreg(pAdapter, RF_PATH_A, 0x21, BIT(19), 0x00); rtw_usleep_os(100); write_rfreg(pAdapter, RF_PATH_A, 0x00, 0x32d75); /* PAD all on. */ write_rfreg(pAdapter, RF_PATH_B, 0x00, 0x32d75); /* PAD all on. */ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index 58d8e0113490..f7b6402e1cd2 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -178,9 +178,9 @@ phy_RFSerialRead( udelay(10);/* PlatformStallExecution(10); */ if (eRFPath == RF_PATH_A) - RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT8); + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XA_HSSIParameter1, BIT(8)); else if (eRFPath == RF_PATH_B) - RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter1, BIT8); + RfPiEnable = (u8)PHY_QueryBBReg(Adapter, rFPGA0_XB_HSSIParameter1, BIT(8)); if (RfPiEnable) { /* Read from BBreg8b8, 12 bits for 8190, 20bits for T65 RF */ retValue = PHY_QueryBBReg(Adapter, pPhyReg->rfLSSIReadBackPi, bLSSIReadBackData); @@ -582,7 +582,7 @@ PHY_BBConfig8188E( /* Enable BB and RF */ RegVal = rtw_read16(Adapter, REG_SYS_FUNC_EN); - rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal|BIT13|BIT0|BIT1)); + rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal|BIT(13)|BIT(0)|BIT(1))); /* 20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */ @@ -1011,7 +1011,7 @@ _PHY_SetBWMode92C( /* Set Control channel to upper or lower. These settings are required only for 40MHz */ PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); - PHY_SetBBReg(Adapter, 0x818, (BIT26 | BIT27), + PHY_SetBBReg(Adapter, 0x818, (BIT(26) | BIT(27)), (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); break; default: diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_led.c b/drivers/staging/r8188eu/hal/rtl8188eu_led.c index 2c573e86d3f8..75ec97107add 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_led.c @@ -20,10 +20,10 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) LedCfg = rtw_read8(padapter, REG_LEDCFG2); switch (pLed->LedPin) { case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT5|BIT6); /* SW control led0 on. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT(5)|BIT(6)); /* SW control led0 on. */ break; case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT5); /* SW control led1 on. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT(5)); /* SW control led1 on. */ break; default: break; @@ -48,17 +48,17 @@ void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) if (pHalData->bLedOpenDrain) { /* Open-drain arrangement for controlling the LED) */ LedCfg &= 0x90; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT(3))); LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); LedCfg &= 0xFE; rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); } else { - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3|BIT5|BIT6)); + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT(3)|BIT(5)|BIT(6))); } break; case LED_PIN_LED1: LedCfg &= 0x0f; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT3)); + rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT(3))); break; default: break; diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 2bce4334ba68..9305d97fd54d 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -611,7 +611,7 @@ static void _InitBeaconParameters(struct adapter *Adapter) static void _BeaconFunctionEnable(struct adapter *Adapter, bool Enable, bool Linked) { - rtw_write8(Adapter, REG_BCN_CTRL, (BIT4 | BIT3 | BIT1)); + rtw_write8(Adapter, REG_BCN_CTRL, (BIT(4) | BIT(3) | BIT(1))); rtw_write8(Adapter, REG_RD_CTRL+1, 0x6F); } @@ -636,8 +636,8 @@ static void _InitAntenna_Selection(struct adapter *Adapter) return; DBG_88E("==> %s ....\n", __func__); - rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT23); - PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT13, 0x01); + rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT(23)); + PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT(13), 0x01); if (PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) haldata->CurAntenna = Antenna_A; @@ -668,13 +668,13 @@ enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) if (adapt->pwrctrlpriv.bHWPowerdown) { val8 = rtw_read8(adapt, REG_HSISR); - DBG_88E("pwrdown, 0x5c(BIT7)=%02x\n", val8); - rfpowerstate = (val8 & BIT7) ? rf_off : rf_on; + DBG_88E("pwrdown, 0x5c(BIT(7))=%02x\n", val8); + rfpowerstate = (val8 & BIT(7)) ? rf_off : rf_on; } else { /* rf on/off */ - rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT3)); + rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT(3))); val8 = rtw_read8(adapt, REG_GPIO_IO_SEL); DBG_88E("GPIO_IN=%02x\n", val8); - rfpowerstate = (val8 & BIT3) ? rf_on : rf_off; + rfpowerstate = (val8 & BIT(3)) ? rf_on : rf_off; } return rfpowerstate; } /* HalDetectPwrDownMode */ @@ -836,7 +836,7 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) /* Enable TX Report */ /* Enable Tx Report Timer */ value8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); - rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT1|BIT0)); + rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT(1)|BIT(0))); /* Set MAX RPT MACID */ rtw_write8(Adapter, REG_TX_RPT_CTRL+1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ /* Tx RPT Timer. Unit: 32us */ @@ -965,7 +965,7 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ val8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); - rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT1)); + rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT(1))); /* stop rx */ rtw_write8(Adapter, REG_CR, 0x0); @@ -989,16 +989,16 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) /* YJ,add,111212 */ /* Disable 32k */ val8 = rtw_read8(Adapter, REG_32K_CTRL); - rtw_write8(Adapter, REG_32K_CTRL, val8&(~BIT0)); + rtw_write8(Adapter, REG_32K_CTRL, val8&(~BIT(0))); /* Card disable power action flow */ HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_DISABLE_FLOW); /* Reset MCU IO Wrapper */ val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); - rtw_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT3))); + rtw_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT(3)))); val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); - rtw_write8(Adapter, REG_RSV_CTRL+1, val8|BIT3); + rtw_write8(Adapter, REG_RSV_CTRL+1, val8|BIT(3)); /* YJ,test add, 111207. For Power Consumption. */ val8 = rtw_read8(Adapter, GPIO_IN); @@ -1016,7 +1016,7 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) static void rtl8192cu_hw_power_down(struct adapter *adapt) { /* 2010/-8/09 MH For power down module, we need to enable register block contrl reg at 0x1c. */ - /* Then enable power down control bit of register 0x04 BIT4 and BIT15 as 1. */ + /* Then enable power down control bit of register 0x04 BIT(4) and BIT(15) as 1. */ /* Enable register area 0x0-0xc. */ rtw_write8(adapt, REG_RSV_CTRL, 0x0); @@ -1235,10 +1235,10 @@ static void ResumeTxBeacon(struct adapter *adapt) /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT6); - haldata->RegFwHwTxQCtrl |= BIT6; + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT(6)); + haldata->RegFwHwTxQCtrl |= BIT(6); rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); - haldata->RegReg542 |= BIT0; + haldata->RegReg542 |= BIT(0); rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); } @@ -1249,10 +1249,10 @@ static void StopTxBeacon(struct adapter *adapt) /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT6)); - haldata->RegFwHwTxQCtrl &= (~BIT6); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT(6))); + haldata->RegFwHwTxQCtrl &= (~BIT(6)); rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); - haldata->RegReg542 &= ~(BIT0); + haldata->RegReg542 &= ~(BIT(0)); rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ @@ -1303,7 +1303,7 @@ static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) /* reset TSF */ rtw_write8(Adapter, REG_DUAL_TSF_RST, BIT(0)); - /* BIT3 - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ + /* BIT(3) - If set 0, hw will clr bcnq when tx becon ok/fail or port 0 */ rtw_write8(Adapter, REG_MBID_NUM, rtw_read8(Adapter, REG_MBID_NUM) | BIT(3) | BIT(4)); /* enable BCN0 Function for if1 */ @@ -1867,8 +1867,8 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) rtl8188e_set_FwMediaStatus_cmd(Adapter, (*(__le16 *)val)); break; case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2, write 1 to clear, Clear by sw */ - rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT0); + /* BCN_VALID, BIT(16) of REG_TDECTRL = BIT(0) of REG_TDECTRL+2, write 1 to clear, Clear by sw */ + rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT(0)); break; default: break; @@ -1889,8 +1889,8 @@ static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) val[0] = rtw_read8(Adapter, REG_TXPAUSE); break; case HW_VAR_BCN_VALID: - /* BCN_VALID, BIT16 of REG_TDECTRL = BIT0 of REG_TDECTRL+2 */ - val[0] = (BIT0 & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; + /* BCN_VALID, BIT(16) of REG_TDECTRL = BIT(0) of REG_TDECTRL+2 */ + val[0] = (BIT(0) & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; break; case HW_VAR_DM_FLAG: val[0] = podmpriv->SupportAbility; diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h index 63b068fa9f4d..96888d66d28c 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h @@ -67,13 +67,13 @@ enum rf_radio_path { enum wireless_mode { WIRELESS_MODE_UNKNOWN = 0x00, - WIRELESS_MODE_A = BIT2, - WIRELESS_MODE_B = BIT0, - WIRELESS_MODE_G = BIT1, - WIRELESS_MODE_AUTO = BIT5, - WIRELESS_MODE_N_24G = BIT3, - WIRELESS_MODE_N_5G = BIT4, - WIRELESS_MODE_AC = BIT6 + WIRELESS_MODE_A = BIT(2), + WIRELESS_MODE_B = BIT(0), + WIRELESS_MODE_G = BIT(1), + WIRELESS_MODE_AUTO = BIT(5), + WIRELESS_MODE_N_24G = BIT(3), + WIRELESS_MODE_N_5G = BIT(4), + WIRELESS_MODE_AC = BIT(6) }; enum phy_rate_tx_offset_area { diff --git a/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h b/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h index 43f41e77a939..a73bd1a5d57b 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h +++ b/drivers/staging/r8188eu/include/Hal8188EPwrSeq.h @@ -42,70 +42,70 @@ #define RTL8188E_TRANS_CARDEMU_TO_ACT \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, BIT1},/* wait till 0x04[17] = 1 power ready*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0|BIT1, 0}, /* 0x02[1:0] = 0 reset BB*/ \ - {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, /*0x24[23] = 2b'01 schmit trigger */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0}, /* 0x04[15] = 0 disable HWPDN (control by DRV)*/\ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4|BIT3, 0}, /*0x04[12:11] = 2b'00 disable WL suspend*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, BIT0}, /*0x04[8] = 1 polling until return 0*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT0, 0}, /*wait till 0x04[8] = 0*/ \ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*LDO normal mode*/ \ - {0x0074, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*SDIO Driving*/ \ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), BIT(1)},/* wait till 0x04[17] = 1 power ready*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0)|BIT(1), 0}, /* 0x02[1:0] = 0 reset BB*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), BIT(7)}, /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0}, /* 0x04[15] = 0 disable HWPDN (control by DRV)*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4)|BIT(3), 0}, /*0x04[12:11] = 2b'00 disable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), BIT(0)}, /*0x04[8] = 1 polling until return 0*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(0), 0}, /*wait till 0x04[8] = 0*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*LDO normal mode*/ \ + {0x0074, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*SDIO Driving*/ \ #define RTL8188E_TRANS_ACT_TO_CARDEMU \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ {0x001F, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0},/*0x1F[7:0] = 0 turn off RF*/ \ - {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*LDO Sleep mode*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*0x04[9] = 1 turn off MAC by HW state machine*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT1, 0}, /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ + {0x0023, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*LDO Sleep mode*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)}, /*0x04[9] = 1 turn off MAC by HW state machine*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(1), 0}, /*wait till 0x04[9] = 0 polling until return 0 to disable*/ \ #define RTL8188E_TRANS_CARDEMU_TO_SUS \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01enable WL suspend*/ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3|BIT4}, /*0x04[12:11] = 2b'11enable WL suspend for PCIe*/ \ - {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, BIT7}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ - {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ - {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, /*0x04[12:11] = 2b'01enable WL suspend*/ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)|BIT(4)}, /*0x04[12:11] = 2b'11enable WL suspend for PCIe*/ \ + {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, BIT(7)}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), BIT(0)}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), 0}, /*wait power state to suspend*/ #define RTL8188E_TRANS_SUS_TO_CARDEMU \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), BIT(1)}, /*wait power state to suspend*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ #define RTL8188E_TRANS_CARDEMU_TO_CARDDIS \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ - {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7}, /*0x24[23] = 2b'01 schmit trigger */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, BIT3}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ + {0x0026, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), BIT(7)}, /*0x24[23] = 2b'01 schmit trigger */ \ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), BIT(3)}, /*0x04[12:11] = 2b'01 enable WL suspend*/ \ {0x0007, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /* 0x04[31:30] = 2b'10 enable enable bandgap mbias in suspend */ \ - {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ - {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, BIT4}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, BIT0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, 0}, /*wait power state to suspend*/ + {0x0041, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK|PWR_INTF_SDIO_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*Clear SIC_EN register 0x40[12] = 1'b0 */ \ + {0xfe10, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), BIT(4)}, /*Set USB suspend enable local register 0xfe10[4]=1 */ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), BIT(0)}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), 0}, /*wait power state to suspend*/ #define RTL8188E_TRANS_CARDDIS_TO_CARDEMU \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT0, 0}, /*Set SDIO suspend local register*/ \ - {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT1, BIT1}, /*wait power state to suspend*/\ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT3|BIT4, 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_WRITE, BIT(0), 0}, /*Set SDIO suspend local register*/ \ + {0x0086, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_SDIO_MSK, PWR_BASEADDR_SDIO, PWR_CMD_POLLING, BIT(1), BIT(1)}, /*wait power state to suspend*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(3)|BIT(4), 0}, /*0x04[12:11] = 2b'01enable WL suspend*/ #define RTL8188E_TRANS_CARDEMU_TO_PDN \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here*/ \ - {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/* 0x04[16] = 0*/\ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, BIT7},/* 0x04[15] = 1*/ + {0x0006, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},/* 0x04[16] = 0*/\ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), BIT(7)},/* 0x04[15] = 1*/ #define RTL8188E_TRANS_PDN_TO_CARDEMU \ /* format */ \ /* { offset, cut_msk, fab_msk|interface_msk, base|cmd, msk, value }, comments here */ \ - {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT7, 0},/* 0x04[15] = 0*/ + {0x0005, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(7), 0},/* 0x04[15] = 0*/ /* This is used by driver for LPSRadioOff Procedure, not for FW LPS Step */ #define RTL8188E_TRANS_ACT_TO_LPS \ @@ -116,11 +116,11 @@ {0x05F9, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ {0x05FA, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ {0x05FB, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, 0xFF, 0},/*Should be zero if no packet is transmitting*/ \ - {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT0, 0},/*CCK and OFDM are disabled,and clock are gated*/ \ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(0), 0},/*CCK and OFDM are disabled,and clock are gated*/ \ {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_US},/*Delay 1us*/ \ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x3F},/*Reset MAC TRX*/ \ - {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, 0},/*check if removed later*/ \ - {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT5, BIT5},/*Respond TxOK to scheduler*/ \ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), 0},/*check if removed later*/ \ + {0x0553, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(5), BIT(5)},/*Respond TxOK to scheduler*/ \ #define RTL8188E_TRANS_LPS_TO_ACT \ /* format */ \ @@ -129,12 +129,12 @@ {0xFE58, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*USB RPWM*/\ {0x0361, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_PCI_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0x84}, /*PCIe RPWM*/\ {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_DELAY, 0, PWRSEQ_DELAY_MS}, /*Delay*/\ - {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT4, 0}, /*. 0x08[4] = 0 switch TSF to 40M*/\ - {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT7, 0}, /*Polling 0x109[7]=0 TSF in 40M*/\ - {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT6|BIT7, 0}, /*. 0x29[7:6] = 2b'00 enable BB clock*/\ - {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1, BIT1}, /*. 0x101[1] = 1*/\ + {0x0008, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(4), 0}, /*. 0x08[4] = 0 switch TSF to 40M*/\ + {0x0109, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_POLLING, BIT(7), 0}, /*Polling 0x109[7]=0 TSF in 40M*/\ + {0x0029, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(6)|BIT(7), 0}, /*. 0x29[7:6] = 2b'00 enable BB clock*/\ + {0x0101, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1), BIT(1)}, /*. 0x101[1] = 1*/\ {0x0100, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0xFF}, /*. 0x100[7:0] = 0xFF enable WMAC TRX*/\ - {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT1|BIT0, BIT1|BIT0}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ + {0x0002, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, BIT(1)|BIT(0), BIT(1)|BIT(0)}, /*. 0x02[1:0] = 2b'11 enable BB macro*/\ {0x0522, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_ALL_MSK, PWR_BASEADDR_MAC, PWR_CMD_WRITE, 0xFF, 0}, /*. 0x522 = 0*/ #define RTL8188E_TRANS_END \ diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index 8f62cbe9ba37..37ddb9745350 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -9,10 +9,10 @@ #include "Hal8188EPhyCfg.h" enum RTL871X_HCI_TYPE { - RTW_PCIE = BIT0, - RTW_USB = BIT1, - RTW_SDIO = BIT2, - RTW_GSPI = BIT3, + RTW_PCIE = BIT(0), + RTW_USB = BIT(1), + RTW_SDIO = BIT(2), + RTW_GSPI = BIT(3), }; enum _CHIP_TYPE { @@ -264,10 +264,10 @@ enum rt_eeprom_type { }; #define RF_CHANGE_BY_INIT 0 -#define RF_CHANGE_BY_IPS BIT28 -#define RF_CHANGE_BY_PS BIT29 -#define RF_CHANGE_BY_HW BIT30 -#define RF_CHANGE_BY_SW BIT31 +#define RF_CHANGE_BY_IPS BIT(28) +#define RF_CHANGE_BY_PS BIT(29) +#define RF_CHANGE_BY_HW BIT(30) +#define RF_CHANGE_BY_SW BIT(31) enum hardware_type { HARDWARE_TYPE_RTL8180, diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index 2a6fd4072e00..a1f8c7fe595c 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -409,28 +409,28 @@ enum odm_common_info_def { enum odm_ability_def { /* BB ODM section BIT 0-15 */ - ODM_BB_DIG = BIT0, - ODM_BB_RA_MASK = BIT1, - ODM_BB_DYNAMIC_TXPWR = BIT2, - ODM_BB_FA_CNT = BIT3, - ODM_BB_RSSI_MONITOR = BIT4, - ODM_BB_CCK_PD = BIT5, - ODM_BB_ANT_DIV = BIT6, - ODM_BB_PWR_SAVE = BIT7, - ODM_BB_PWR_TRA = BIT8, - ODM_BB_RATE_ADAPTIVE = BIT9, - ODM_BB_PATH_DIV = BIT10, - ODM_BB_PSD = BIT11, - ODM_BB_RXHP = BIT12, + ODM_BB_DIG = BIT(0), + ODM_BB_RA_MASK = BIT(1), + ODM_BB_DYNAMIC_TXPWR = BIT(2), + ODM_BB_FA_CNT = BIT(3), + ODM_BB_RSSI_MONITOR = BIT(4), + ODM_BB_CCK_PD = BIT(5), + ODM_BB_ANT_DIV = BIT(6), + ODM_BB_PWR_SAVE = BIT(7), + ODM_BB_PWR_TRA = BIT(8), + ODM_BB_RATE_ADAPTIVE = BIT(9), + ODM_BB_PATH_DIV = BIT(10), + ODM_BB_PSD = BIT(11), + ODM_BB_RXHP = BIT(12), /* MAC DM section BIT 16-23 */ - ODM_MAC_EDCA_TURBO = BIT16, - ODM_MAC_EARLY_MODE = BIT17, + ODM_MAC_EDCA_TURBO = BIT(16), + ODM_MAC_EARLY_MODE = BIT(17), /* RF ODM section BIT 24-31 */ - ODM_RF_TX_PWR_TRACK = BIT24, - ODM_RF_RX_GAIN_TRACK = BIT25, - ODM_RF_CALIBRATION = BIT26, + ODM_RF_TX_PWR_TRACK = BIT(24), + ODM_RF_RX_GAIN_TRACK = BIT(25), + ODM_RF_CALIBRATION = BIT(26), }; /* ODM_CMNINFO_INTERFACE */ @@ -443,13 +443,13 @@ enum odm_interface_def { /* ODM_CMNINFO_IC_TYPE */ enum odm_ic_type { - ODM_RTL8192S = BIT0, - ODM_RTL8192C = BIT1, - ODM_RTL8192D = BIT2, - ODM_RTL8723A = BIT3, - ODM_RTL8188E = BIT4, - ODM_RTL8812 = BIT5, - ODM_RTL8821 = BIT6, + ODM_RTL8192S = BIT(0), + ODM_RTL8192C = BIT(1), + ODM_RTL8192D = BIT(2), + ODM_RTL8723A = BIT(3), + ODM_RTL8188E = BIT(4), + ODM_RTL8812 = BIT(5), + ODM_RTL8821 = BIT(6), }; #define ODM_IC_11N_SERIES \ @@ -475,16 +475,16 @@ enum odm_fab_Version { }; /* ODM_CMNINFO_RF_TYPE */ -/* For example 1T2R (A+AB = BIT0|BIT4|BIT5) */ +/* For example 1T2R (A+AB = BIT(0)|BIT(4)|BIT(5)) */ enum odm_rf_path { - ODM_RF_TX_A = BIT0, - ODM_RF_TX_B = BIT1, - ODM_RF_TX_C = BIT2, - ODM_RF_TX_D = BIT3, - ODM_RF_RX_A = BIT4, - ODM_RF_RX_B = BIT5, - ODM_RF_RX_C = BIT6, - ODM_RF_RX_D = BIT7, + ODM_RF_TX_A = BIT(0), + ODM_RF_TX_B = BIT(1), + ODM_RF_TX_C = BIT(2), + ODM_RF_TX_D = BIT(3), + ODM_RF_RX_A = BIT(4), + ODM_RF_RX_B = BIT(5), + ODM_RF_RX_C = BIT(6), + ODM_RF_RX_D = BIT(7), }; enum odm_rf_type { @@ -515,33 +515,33 @@ enum odm_bt_coexist { /* ODM_CMNINFO_OP_MODE */ enum odm_operation_mode { - ODM_NO_LINK = BIT0, - ODM_LINK = BIT1, - ODM_SCAN = BIT2, - ODM_POWERSAVE = BIT3, - ODM_AP_MODE = BIT4, - ODM_CLIENT_MODE = BIT5, - ODM_AD_HOC = BIT6, - ODM_WIFI_DIRECT = BIT7, - ODM_WIFI_DISPLAY = BIT8, + ODM_NO_LINK = BIT(0), + ODM_LINK = BIT(1), + ODM_SCAN = BIT(2), + ODM_POWERSAVE = BIT(3), + ODM_AP_MODE = BIT(4), + ODM_CLIENT_MODE = BIT(5), + ODM_AD_HOC = BIT(6), + ODM_WIFI_DIRECT = BIT(7), + ODM_WIFI_DISPLAY = BIT(8), }; /* ODM_CMNINFO_WM_MODE */ enum odm_wireless_mode { ODM_WM_UNKNOW = 0x0, - ODM_WM_B = BIT0, - ODM_WM_G = BIT1, - ODM_WM_A = BIT2, - ODM_WM_N24G = BIT3, - ODM_WM_N5G = BIT4, - ODM_WM_AUTO = BIT5, - ODM_WM_AC = BIT6, + ODM_WM_B = BIT(0), + ODM_WM_G = BIT(1), + ODM_WM_A = BIT(2), + ODM_WM_N24G = BIT(3), + ODM_WM_N5G = BIT(4), + ODM_WM_AUTO = BIT(5), + ODM_WM_AC = BIT(6), }; /* ODM_CMNINFO_BAND */ enum odm_band_type { - ODM_BAND_2_4G = BIT0, - ODM_BAND_5G = BIT1, + ODM_BAND_2_4G = BIT(0), + ODM_BAND_5G = BIT(1), }; /* ODM_CMNINFO_SEC_CHNL_OFFSET */ @@ -801,7 +801,7 @@ struct odm_dm_struct { u64 *pNumTxBytesUnicast; /* RX Unicast byte count */ u64 *pNumRxBytesUnicast; - /* Wireless mode B/G/A/N = BIT0/BIT1/BIT2/BIT3 */ + /* Wireless mode B/G/A/N = BIT(0)/BIT(1)/BIT(2)/BIT(3) */ u8 *pWirelessMode; /* ODM_WIRELESS_MODE_E */ /* Frequence band 2.4G/5G = 0/1 */ u8 *pBandType; diff --git a/drivers/staging/r8188eu/include/odm_reg.h b/drivers/staging/r8188eu/include/odm_reg.h index 81e633fcc0ac..78d7e904947c 100644 --- a/drivers/staging/r8188eu/include/odm_reg.h +++ b/drivers/staging/r8188eu/include/odm_reg.h @@ -84,6 +84,6 @@ /* Bitmap Definition */ /* */ -#define BIT_FA_RESET BIT0 +#define BIT_FA_RESET BIT(0) #endif diff --git a/drivers/staging/r8188eu/include/odm_types.h b/drivers/staging/r8188eu/include/odm_types.h index 53a2fee55e35..6f4a4bd37ec1 100644 --- a/drivers/staging/r8188eu/include/odm_types.h +++ b/drivers/staging/r8188eu/include/odm_types.h @@ -7,10 +7,10 @@ /* */ /* Define Different SW team support */ /* */ -#define ODM_AP 0x01 /* BIT0 */ -#define ODM_ADSL 0x02 /* BIT1 */ -#define ODM_CE 0x04 /* BIT2 */ -#define ODM_MP 0x08 /* BIT3 */ +#define ODM_AP 0x01 /* BIT(0) */ +#define ODM_ADSL 0x02 /* BIT(1) */ +#define ODM_CE 0x04 /* BIT(2) */ +#define ODM_MP 0x08 /* BIT(3) */ #define RT_PCI_INTERFACE 1 #define RT_USB_INTERFACE 2 diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 7e002009f9a0..6399f645cd40 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -143,48 +143,6 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev) netif_tx_stop_all_queues(pnetdev); } -#ifndef BIT - #define BIT(x) ( 1 << (x)) -#endif - -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 -#define BIT32 0x0100000000 -#define BIT33 0x0200000000 -#define BIT34 0x0400000000 -#define BIT35 0x0800000000 -#define BIT36 0x1000000000 - extern int RTW_STATUS_CODE(int error_code); /* flags used for rtw_update_mem_stat() */ diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h index 85e66d6ca2ba..5fdc6aac917c 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h @@ -4,43 +4,6 @@ #ifndef __RTL8188E_SPEC_H__ #define __RTL8188E_SPEC_H__ -#ifndef BIT -#define BIT(x) (1 << (x)) -#endif - -#define BIT0 0x00000001 -#define BIT1 0x00000002 -#define BIT2 0x00000004 -#define BIT3 0x00000008 -#define BIT4 0x00000010 -#define BIT5 0x00000020 -#define BIT6 0x00000040 -#define BIT7 0x00000080 -#define BIT8 0x00000100 -#define BIT9 0x00000200 -#define BIT10 0x00000400 -#define BIT11 0x00000800 -#define BIT12 0x00001000 -#define BIT13 0x00002000 -#define BIT14 0x00004000 -#define BIT15 0x00008000 -#define BIT16 0x00010000 -#define BIT17 0x00020000 -#define BIT18 0x00040000 -#define BIT19 0x00080000 -#define BIT20 0x00100000 -#define BIT21 0x00200000 -#define BIT22 0x00400000 -#define BIT23 0x00800000 -#define BIT24 0x01000000 -#define BIT25 0x02000000 -#define BIT26 0x04000000 -#define BIT27 0x08000000 -#define BIT28 0x10000000 -#define BIT29 0x20000000 -#define BIT30 0x40000000 -#define BIT31 0x80000000 - /* 8192C Regsiter offset definition */ #define HAL_PS_TIMER_INT_DELAY 50 /* 50 microseconds */ @@ -465,14 +428,14 @@ #define MAX_MSS_DENSITY_1T 0x0A /* EEPROM enable when set 1 */ -#define CmdEEPROM_En BIT5 +#define CmdEEPROM_En BIT(5) /* System EEPROM select, 0: boot from E-FUSE, 1: The EEPROM used is 9346 */ -#define CmdEERPOMSEL BIT4 -#define Cmd9346CR_9356SEL BIT4 +#define CmdEERPOMSEL BIT(4) +#define Cmd9346CR_9356SEL BIT(4) /* 8192C GPIO MUX Configuration Register (offset 0x40, 4 byte) */ #define GPIOSEL_GPIO 0 -#define GPIOSEL_ENBT BIT5 +#define GPIOSEL_ENBT BIT(5) /* 8192C GPIO PIN Control Register (offset 0x44, 4 byte) */ /* GPIO pins input value */ @@ -485,18 +448,18 @@ #define GPIO_MOD (REG_GPIO_PIN_CTRL+3) /* 8723/8188E Host System Interrupt Mask Register (offset 0x58, 32 byte) */ -#define HSIMR_GPIO12_0_INT_EN BIT0 -#define HSIMR_SPS_OCP_INT_EN BIT5 -#define HSIMR_RON_INT_EN BIT6 -#define HSIMR_PDN_INT_EN BIT7 -#define HSIMR_GPIO9_INT_EN BIT25 +#define HSIMR_GPIO12_0_INT_EN BIT(0) +#define HSIMR_SPS_OCP_INT_EN BIT(5) +#define HSIMR_RON_INT_EN BIT(6) +#define HSIMR_PDN_INT_EN BIT(7) +#define HSIMR_GPIO9_INT_EN BIT(25) /* 8723/8188E Host System Interrupt Status Register (offset 0x5C, 32 byte) */ -#define HSISR_GPIO12_0_INT BIT0 -#define HSISR_SPS_OCP_INT BIT5 -#define HSISR_RON_INT_EN BIT6 -#define HSISR_PDNINT BIT7 -#define HSISR_GPIO9_INT BIT25 +#define HSISR_GPIO12_0_INT BIT(0) +#define HSISR_SPS_OCP_INT BIT(5) +#define HSISR_RON_INT_EN BIT(6) +#define HSISR_PDNINT BIT(7) +#define HSISR_GPIO9_INT BIT(25) /* 8192C (MSR) Media Status Register (Offset 0x4C, 8 bits) */ /* @@ -521,51 +484,51 @@ Default: 00b. /* 88E Driver Initialization Offload REG_FDHM0(Offset 0x88, 8 bits) */ /* IOL config for REG_FDHM0(Reg0x88) */ -#define CMD_INIT_LLT BIT0 -#define CMD_READ_EFUSE_MAP BIT1 -#define CMD_EFUSE_PATCH BIT2 -#define CMD_IOCONFIG BIT3 -#define CMD_INIT_LLT_ERR BIT4 -#define CMD_READ_EFUSE_MAP_ERR BIT5 -#define CMD_EFUSE_PATCH_ERR BIT6 -#define CMD_IOCONFIG_ERR BIT7 +#define CMD_INIT_LLT BIT(0) +#define CMD_READ_EFUSE_MAP BIT(1) +#define CMD_EFUSE_PATCH BIT(2) +#define CMD_IOCONFIG BIT(3) +#define CMD_INIT_LLT_ERR BIT(4) +#define CMD_READ_EFUSE_MAP_ERR BIT(5) +#define CMD_EFUSE_PATCH_ERR BIT(6) +#define CMD_IOCONFIG_ERR BIT(7) /* 6. Adaptive Control Registers (Offset: 0x0160 - 0x01CF) */ /* 8192C Response Rate Set Register (offset 0x181, 24bits) */ -#define RRSR_1M BIT0 -#define RRSR_2M BIT1 -#define RRSR_5_5M BIT2 -#define RRSR_11M BIT3 -#define RRSR_6M BIT4 -#define RRSR_9M BIT5 -#define RRSR_12M BIT6 -#define RRSR_18M BIT7 -#define RRSR_24M BIT8 -#define RRSR_36M BIT9 -#define RRSR_48M BIT10 -#define RRSR_54M BIT11 -#define RRSR_MCS0 BIT12 -#define RRSR_MCS1 BIT13 -#define RRSR_MCS2 BIT14 -#define RRSR_MCS3 BIT15 -#define RRSR_MCS4 BIT16 -#define RRSR_MCS5 BIT17 -#define RRSR_MCS6 BIT18 -#define RRSR_MCS7 BIT19 +#define RRSR_1M BIT(0) +#define RRSR_2M BIT(1) +#define RRSR_5_5M BIT(2) +#define RRSR_11M BIT(3) +#define RRSR_6M BIT(4) +#define RRSR_9M BIT(5) +#define RRSR_12M BIT(6) +#define RRSR_18M BIT(7) +#define RRSR_24M BIT(8) +#define RRSR_36M BIT(9) +#define RRSR_48M BIT(10) +#define RRSR_54M BIT(11) +#define RRSR_MCS0 BIT(12) +#define RRSR_MCS1 BIT(13) +#define RRSR_MCS2 BIT(14) +#define RRSR_MCS3 BIT(15) +#define RRSR_MCS4 BIT(16) +#define RRSR_MCS5 BIT(17) +#define RRSR_MCS6 BIT(18) +#define RRSR_MCS7 BIT(19) /* 8192C Response Rate Set Register (offset 0x1BF, 8bits) */ /* WOL bit information */ -#define HAL92C_WOL_PTK_UPDATE_EVENT BIT0 -#define HAL92C_WOL_GTK_UPDATE_EVENT BIT1 +#define HAL92C_WOL_PTK_UPDATE_EVENT BIT(0) +#define HAL92C_WOL_GTK_UPDATE_EVENT BIT(1) /* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ -#define BW_OPMODE_20MHZ BIT2 -#define BW_OPMODE_5G BIT1 +#define BW_OPMODE_20MHZ BIT(2) +#define BW_OPMODE_5G BIT(1) /* 8192C CAM Config Setting (offset 0x250, 1 byte) */ -#define CAM_VALID BIT15 +#define CAM_VALID BIT(15) #define CAM_NOTVALID 0x0000 -#define CAM_USEDK BIT5 +#define CAM_USEDK BIT(5) #define CAM_CONTENT_COUNT 8 @@ -582,69 +545,69 @@ Default: 00b. #define CAM_CONFIG_USEDK true #define CAM_CONFIG_NO_USEDK false -#define CAM_WRITE BIT16 +#define CAM_WRITE BIT(16) #define CAM_READ 0x00000000 -#define CAM_POLLINIG BIT31 +#define CAM_POLLINIG BIT(31) #define SCR_UseDK 0x01 #define SCR_TxSecEnable 0x02 #define SCR_RxSecEnable 0x04 /* 10. Power Save Control Registers (Offset: 0x0260 - 0x02DF) */ -#define WOW_PMEN BIT0 /* Power management Enable. */ -#define WOW_WOMEN BIT1 /* WoW function on or off. */ -#define WOW_MAGIC BIT2 /* Magic packet */ -#define WOW_UWF BIT3 /* Unicast Wakeup frame. */ +#define WOW_PMEN BIT(0) /* Power management Enable. */ +#define WOW_WOMEN BIT(1) /* WoW function on or off. */ +#define WOW_MAGIC BIT(2) /* Magic packet */ +#define WOW_UWF BIT(3) /* Unicast Wakeup frame. */ /* 12. Host Interrupt Status Registers (Offset: 0x0300 - 0x030F) */ /* 8188 IMR/ISR bits */ #define IMR_DISABLED_88E 0x0 /* IMR DW0(0x0060-0063) Bit 0-31 */ -#define IMR_TXCCK_88E BIT30 /* TXRPT interrupt when CCX bit of the packet is set */ -#define IMR_PSTIMEOUT_88E BIT29 /* Power Save Time Out Interrupt */ -#define IMR_GTINT4_88E BIT28 /* When GTIMER4 expires, this bit is set to 1 */ -#define IMR_GTINT3_88E BIT27 /* When GTIMER3 expires, this bit is set to 1 */ -#define IMR_TBDER_88E BIT26 /* Transmit Beacon0 Error */ -#define IMR_TBDOK_88E BIT25 /* Transmit Beacon0 OK */ -#define IMR_TSF_BIT32_TOGGLE_88E BIT24 /* TSF Timer BIT32 toggle indication interrupt */ -#define IMR_BCNDMAINT0_88E BIT20 /* Beacon DMA Interrupt 0 */ -#define IMR_BCNDERR0_88E BIT16 /* Beacon Queue DMA Error 0 */ -#define IMR_HSISR_IND_ON_INT_88E BIT15 /* HSISR Indicator (HSIMR & HSISR is true, this bit is set to 1) */ -#define IMR_BCNDMAINT_E_88E BIT14 /* Beacon DMA Interrupt Extension for Win7 */ -#define IMR_ATIMEND_88E BIT12 /* CTWidnow End or ATIM Window End */ -#define IMR_HISR1_IND_INT_88E BIT11 /* HISR1 Indicator (HISR1 & HIMR1 is true, this bit is set to 1) */ -#define IMR_C2HCMD_88E BIT10 /* CPU to Host Command INT Status, Write 1 clear */ -#define IMR_CPWM2_88E BIT9 /* CPU power Mode exchange INT Status, Write 1 clear */ -#define IMR_CPWM_88E BIT8 /* CPU power Mode exchange INT Status, Write 1 clear */ -#define IMR_HIGHDOK_88E BIT7 /* High Queue DMA OK */ -#define IMR_MGNTDOK_88E BIT6 /* Management Queue DMA OK */ -#define IMR_BKDOK_88E BIT5 /* AC_BK DMA OK */ -#define IMR_BEDOK_88E BIT4 /* AC_BE DMA OK */ -#define IMR_VIDOK_88E BIT3 /* AC_VI DMA OK */ -#define IMR_VODOK_88E BIT2 /* AC_VO DMA OK */ -#define IMR_RDU_88E BIT1 /* Rx Descriptor Unavailable */ -#define IMR_ROK_88E BIT0 /* Receive DMA OK */ +#define IMR_TXCCK_88E BIT(30) /* TXRPT interrupt when CCX bit of the packet is set */ +#define IMR_PSTIMEOUT_88E BIT(29) /* Power Save Time Out Interrupt */ +#define IMR_GTINT4_88E BIT(28) /* When GTIMER4 expires, this bit is set to 1 */ +#define IMR_GTINT3_88E BIT(27) /* When GTIMER3 expires, this bit is set to 1 */ +#define IMR_TBDER_88E BIT(26) /* Transmit Beacon0 Error */ +#define IMR_TBDOK_88E BIT(25) /* Transmit Beacon0 OK */ +#define IMR_TSF_BIT32_TOGGLE_88E BIT(24) /* TSF Timer BIT32 toggle indication interrupt */ +#define IMR_BCNDMAINT0_88E BIT(20) /* Beacon DMA Interrupt 0 */ +#define IMR_BCNDERR0_88E BIT(16) /* Beacon Queue DMA Error 0 */ +#define IMR_HSISR_IND_ON_INT_88E BIT(15) /* HSISR Indicator (HSIMR & HSISR is true, this bit is set to 1) */ +#define IMR_BCNDMAINT_E_88E BIT(14) /* Beacon DMA Interrupt Extension for Win7 */ +#define IMR_ATIMEND_88E BIT(12) /* CTWidnow End or ATIM Window End */ +#define IMR_HISR1_IND_INT_88E BIT(11) /* HISR1 Indicator (HISR1 & HIMR1 is true, this bit is set to 1) */ +#define IMR_C2HCMD_88E BIT(10) /* CPU to Host Command INT Status, Write 1 clear */ +#define IMR_CPWM2_88E BIT(9) /* CPU power Mode exchange INT Status, Write 1 clear */ +#define IMR_CPWM_88E BIT(8) /* CPU power Mode exchange INT Status, Write 1 clear */ +#define IMR_HIGHDOK_88E BIT(7) /* High Queue DMA OK */ +#define IMR_MGNTDOK_88E BIT(6) /* Management Queue DMA OK */ +#define IMR_BKDOK_88E BIT(5) /* AC_BK DMA OK */ +#define IMR_BEDOK_88E BIT(4) /* AC_BE DMA OK */ +#define IMR_VIDOK_88E BIT(3) /* AC_VI DMA OK */ +#define IMR_VODOK_88E BIT(2) /* AC_VO DMA OK */ +#define IMR_RDU_88E BIT(1) /* Rx Descriptor Unavailable */ +#define IMR_ROK_88E BIT(0) /* Receive DMA OK */ /* IMR DW1(0x00B4-00B7) Bit 0-31 */ -#define IMR_BCNDMAINT7_88E BIT27 /* Beacon DMA Interrupt 7 */ -#define IMR_BCNDMAINT6_88E BIT26 /* Beacon DMA Interrupt 6 */ -#define IMR_BCNDMAINT5_88E BIT25 /* Beacon DMA Interrupt 5 */ -#define IMR_BCNDMAINT4_88E BIT24 /* Beacon DMA Interrupt 4 */ -#define IMR_BCNDMAINT3_88E BIT23 /* Beacon DMA Interrupt 3 */ -#define IMR_BCNDMAINT2_88E BIT22 /* Beacon DMA Interrupt 2 */ -#define IMR_BCNDMAINT1_88E BIT21 /* Beacon DMA Interrupt 1 */ -#define IMR_BCNDERR7_88E BIT20 /* Beacon DMA Error Int 7 */ -#define IMR_BCNDERR6_88E BIT19 /* Beacon DMA Error Int 6 */ -#define IMR_BCNDERR5_88E BIT18 /* Beacon DMA Error Int 5 */ -#define IMR_BCNDERR4_88E BIT17 /* Beacon DMA Error Int 4 */ -#define IMR_BCNDERR3_88E BIT16 /* Beacon DMA Error Int 3 */ -#define IMR_BCNDERR2_88E BIT15 /* Beacon DMA Error Int 2 */ -#define IMR_BCNDERR1_88E BIT14 /* Beacon DMA Error Int 1 */ -#define IMR_ATIMEND_E_88E BIT13 /* ATIM Window End Ext for Win7 */ -#define IMR_TXERR_88E BIT11 /* Tx Err Flag Int Status, write 1 clear. */ -#define IMR_RXERR_88E BIT10 /* Rx Err Flag INT Status, Write 1 clear */ -#define IMR_TXFOVW_88E BIT9 /* Transmit FIFO Overflow */ -#define IMR_RXFOVW_88E BIT8 /* Receive FIFO Overflow */ +#define IMR_BCNDMAINT7_88E BIT(27) /* Beacon DMA Interrupt 7 */ +#define IMR_BCNDMAINT6_88E BIT(26) /* Beacon DMA Interrupt 6 */ +#define IMR_BCNDMAINT5_88E BIT(25) /* Beacon DMA Interrupt 5 */ +#define IMR_BCNDMAINT4_88E BIT(24) /* Beacon DMA Interrupt 4 */ +#define IMR_BCNDMAINT3_88E BIT(23) /* Beacon DMA Interrupt 3 */ +#define IMR_BCNDMAINT2_88E BIT(22) /* Beacon DMA Interrupt 2 */ +#define IMR_BCNDMAINT1_88E BIT(21) /* Beacon DMA Interrupt 1 */ +#define IMR_BCNDERR7_88E BIT(20) /* Beacon DMA Error Int 7 */ +#define IMR_BCNDERR6_88E BIT(19) /* Beacon DMA Error Int 6 */ +#define IMR_BCNDERR5_88E BIT(18) /* Beacon DMA Error Int 5 */ +#define IMR_BCNDERR4_88E BIT(17) /* Beacon DMA Error Int 4 */ +#define IMR_BCNDERR3_88E BIT(16) /* Beacon DMA Error Int 3 */ +#define IMR_BCNDERR2_88E BIT(15) /* Beacon DMA Error Int 2 */ +#define IMR_BCNDERR1_88E BIT(14) /* Beacon DMA Error Int 1 */ +#define IMR_ATIMEND_E_88E BIT(13) /* ATIM Window End Ext for Win7 */ +#define IMR_TXERR_88E BIT(11) /* Tx Err Flag Int Status, write 1 clear. */ +#define IMR_RXERR_88E BIT(10) /* Rx Err Flag INT Status, Write 1 clear */ +#define IMR_TXFOVW_88E BIT(9) /* Transmit FIFO Overflow */ +#define IMR_RXFOVW_88E BIT(8) /* Receive FIFO Overflow */ #define HAL_NIC_UNPLUG_ISR 0xFFFFFFFF /* The value when the NIC is unplugged for PCI. */ @@ -680,40 +643,40 @@ Current IOREG MAP /* the correct arragement is VO - Bit0, VI - Bit1, BE - Bit2, * and BK - Bit3. */ /* 8723 and 88E may be not correct either in the earlier version. */ -#define StopBecon BIT6 -#define StopHigh BIT5 -#define StopMgt BIT4 -#define StopBK BIT3 -#define StopBE BIT2 -#define StopVI BIT1 -#define StopVO BIT0 +#define StopBecon BIT(6) +#define StopHigh BIT(5) +#define StopMgt BIT(4) +#define StopBK BIT(3) +#define StopBE BIT(2) +#define StopVI BIT(1) +#define StopVO BIT(0) /* 8192C (RCR) Receive Configuration Register(Offset 0x608, 32 bits) */ -#define RCR_APPFCS BIT31 /* WMAC append FCS after payload */ -#define RCR_APP_MIC BIT30 -#define RCR_APP_PHYSTS BIT28 -#define RCR_APP_ICV BIT29 -#define RCR_APP_PHYST_RXFF BIT28 -#define RCR_APP_BA_SSN BIT27 /* Accept BA SSN */ -#define RCR_ENMBID BIT24 /* Enable Multiple BssId. */ -#define RCR_LSIGEN BIT23 -#define RCR_MFBEN BIT22 -#define RCR_HTC_LOC_CTRL BIT14 /* MFC<--HTC=1 MFC-->HTC=0 */ -#define RCR_AMF BIT13 /* Accept management type frame */ -#define RCR_ACF BIT12 /* Accept control type frame */ -#define RCR_ADF BIT11 /* Accept data type frame */ -#define RCR_AICV BIT9 /* Accept ICV error packet */ -#define RCR_ACRC32 BIT8 /* Accept CRC32 error packet */ -#define RCR_CBSSID_BCN BIT7 /* Accept BSSID match packet +#define RCR_APPFCS BIT(31) /* WMAC append FCS after payload */ +#define RCR_APP_MIC BIT(30) +#define RCR_APP_PHYSTS BIT(28) +#define RCR_APP_ICV BIT(29) +#define RCR_APP_PHYST_RXFF BIT(28) +#define RCR_APP_BA_SSN BIT(27) /* Accept BA SSN */ +#define RCR_ENMBID BIT(24) /* Enable Multiple BssId. */ +#define RCR_LSIGEN BIT(23) +#define RCR_MFBEN BIT(22) +#define RCR_HTC_LOC_CTRL BIT(14) /* MFC<--HTC=1 MFC-->HTC=0 */ +#define RCR_AMF BIT(13) /* Accept management type frame */ +#define RCR_ACF BIT(12) /* Accept control type frame */ +#define RCR_ADF BIT(11) /* Accept data type frame */ +#define RCR_AICV BIT(9) /* Accept ICV error packet */ +#define RCR_ACRC32 BIT(8) /* Accept CRC32 error packet */ +#define RCR_CBSSID_BCN BIT(7) /* Accept BSSID match packet * (Rx beacon, probe rsp) */ -#define RCR_CBSSID_DATA BIT6 /* Accept BSSID match (Data)*/ +#define RCR_CBSSID_DATA BIT(6) /* Accept BSSID match (Data)*/ #define RCR_CBSSID RCR_CBSSID_DATA /* Accept BSSID match */ -#define RCR_APWRMGT BIT5 /* Accept power management pkt*/ -#define RCR_ADD3 BIT4 /* Accept address 3 match pkt */ -#define RCR_AB BIT3 /* Accept broadcast packet */ -#define RCR_AM BIT2 /* Accept multicast packet */ -#define RCR_APM BIT1 /* Accept physical match pkt */ -#define RCR_AAP BIT0 /* Accept all unicast packet */ +#define RCR_APWRMGT BIT(5) /* Accept power management pkt*/ +#define RCR_ADD3 BIT(4) /* Accept address 3 match pkt */ +#define RCR_AB BIT(3) /* Accept broadcast packet */ +#define RCR_AM BIT(2) /* Accept multicast packet */ +#define RCR_APM BIT(1) /* Accept physical match pkt */ +#define RCR_AAP BIT(0) /* Accept all unicast packet */ #define RCR_MXDMA_OFFSET 8 #define RCR_FIFO_OFFSET 13 @@ -1181,56 +1144,56 @@ Current IOREG MAP #define SDIO_HIMR_DISABLED 0 /* RTL8188E SDIO Host Interrupt Mask Register */ -#define SDIO_HIMR_RX_REQUEST_MSK BIT0 -#define SDIO_HIMR_AVAL_MSK BIT1 -#define SDIO_HIMR_TXERR_MSK BIT2 -#define SDIO_HIMR_RXERR_MSK BIT3 -#define SDIO_HIMR_TXFOVW_MSK BIT4 -#define SDIO_HIMR_RXFOVW_MSK BIT5 -#define SDIO_HIMR_TXBCNOK_MSK BIT6 -#define SDIO_HIMR_TXBCNERR_MSK BIT7 -#define SDIO_HIMR_BCNERLY_INT_MSK BIT16 -#define SDIO_HIMR_C2HCMD_MSK BIT17 -#define SDIO_HIMR_CPWM1_MSK BIT18 -#define SDIO_HIMR_CPWM2_MSK BIT19 -#define SDIO_HIMR_HSISR_IND_MSK BIT20 -#define SDIO_HIMR_GTINT3_IND_MSK BIT21 -#define SDIO_HIMR_GTINT4_IND_MSK BIT22 -#define SDIO_HIMR_PSTIMEOUT_MSK BIT23 -#define SDIO_HIMR_OCPINT_MSK BIT24 -#define SDIO_HIMR_ATIMEND_MSK BIT25 -#define SDIO_HIMR_ATIMEND_E_MSK BIT26 -#define SDIO_HIMR_CTWEND_MSK BIT27 +#define SDIO_HIMR_RX_REQUEST_MSK BIT(0) +#define SDIO_HIMR_AVAL_MSK BIT(1) +#define SDIO_HIMR_TXERR_MSK BIT(2) +#define SDIO_HIMR_RXERR_MSK BIT(3) +#define SDIO_HIMR_TXFOVW_MSK BIT(4) +#define SDIO_HIMR_RXFOVW_MSK BIT(5) +#define SDIO_HIMR_TXBCNOK_MSK BIT(6) +#define SDIO_HIMR_TXBCNERR_MSK BIT(7) +#define SDIO_HIMR_BCNERLY_INT_MSK BIT(16) +#define SDIO_HIMR_C2HCMD_MSK BIT(17) +#define SDIO_HIMR_CPWM1_MSK BIT(18) +#define SDIO_HIMR_CPWM2_MSK BIT(19) +#define SDIO_HIMR_HSISR_IND_MSK BIT(20) +#define SDIO_HIMR_GTINT3_IND_MSK BIT(21) +#define SDIO_HIMR_GTINT4_IND_MSK BIT(22) +#define SDIO_HIMR_PSTIMEOUT_MSK BIT(23) +#define SDIO_HIMR_OCPINT_MSK BIT(24) +#define SDIO_HIMR_ATIMEND_MSK BIT(25) +#define SDIO_HIMR_ATIMEND_E_MSK BIT(26) +#define SDIO_HIMR_CTWEND_MSK BIT(27) /* RTL8188E SDIO Specific */ -#define SDIO_HIMR_MCU_ERR_MSK BIT28 -#define SDIO_HIMR_TSF_BIT32_TOGGLE_MSK BIT29 +#define SDIO_HIMR_MCU_ERR_MSK BIT(28) +#define SDIO_HIMR_TSF_BIT32_TOGGLE_MSK BIT(29) /* SDIO Host Interrupt Service Routine */ -#define SDIO_HISR_RX_REQUEST BIT0 -#define SDIO_HISR_AVAL BIT1 -#define SDIO_HISR_TXERR BIT2 -#define SDIO_HISR_RXERR BIT3 -#define SDIO_HISR_TXFOVW BIT4 -#define SDIO_HISR_RXFOVW BIT5 -#define SDIO_HISR_TXBCNOK BIT6 -#define SDIO_HISR_TXBCNERR BIT7 -#define SDIO_HISR_BCNERLY_INT BIT16 -#define SDIO_HISR_C2HCMD BIT17 -#define SDIO_HISR_CPWM1 BIT18 -#define SDIO_HISR_CPWM2 BIT19 -#define SDIO_HISR_HSISR_IND BIT20 -#define SDIO_HISR_GTINT3_IND BIT21 -#define SDIO_HISR_GTINT4_IND BIT22 -#define SDIO_HISR_PSTIME BIT23 -#define SDIO_HISR_OCPINT BIT24 -#define SDIO_HISR_ATIMEND BIT25 -#define SDIO_HISR_ATIMEND_E BIT26 -#define SDIO_HISR_CTWEND BIT27 +#define SDIO_HISR_RX_REQUEST BIT(0) +#define SDIO_HISR_AVAL BIT(1) +#define SDIO_HISR_TXERR BIT(2) +#define SDIO_HISR_RXERR BIT(3) +#define SDIO_HISR_TXFOVW BIT(4) +#define SDIO_HISR_RXFOVW BIT(5) +#define SDIO_HISR_TXBCNOK BIT(6) +#define SDIO_HISR_TXBCNERR BIT(7) +#define SDIO_HISR_BCNERLY_INT BIT(16) +#define SDIO_HISR_C2HCMD BIT(17) +#define SDIO_HISR_CPWM1 BIT(18) +#define SDIO_HISR_CPWM2 BIT(19) +#define SDIO_HISR_HSISR_IND BIT(20) +#define SDIO_HISR_GTINT3_IND BIT(21) +#define SDIO_HISR_GTINT4_IND BIT(22) +#define SDIO_HISR_PSTIME BIT(23) +#define SDIO_HISR_OCPINT BIT(24) +#define SDIO_HISR_ATIMEND BIT(25) +#define SDIO_HISR_ATIMEND_E BIT(26) +#define SDIO_HISR_CTWEND BIT(27) /* RTL8188E SDIO Specific */ -#define SDIO_HISR_MCU_ERR BIT28 -#define SDIO_HISR_TSF_BIT32_TOGGLE BIT29 +#define SDIO_HISR_MCU_ERR BIT(28) +#define SDIO_HISR_TSF_BIT32_TOGGLE BIT(29) #define MASK_SDIO_HISR_CLEAR \ (SDIO_HISR_TXERR | SDIO_HISR_RXERR | SDIO_HISR_TXFOVW |\ @@ -1240,8 +1203,8 @@ Current IOREG MAP SDIO_HISR_PSTIMEOUT | SDIO_HISR_OCPINT) /* SDIO HCI Suspend Control Register */ -#define HCI_RESUME_PWR_RDY BIT1 -#define HCI_SUS_CTRL BIT0 +#define HCI_RESUME_PWR_RDY BIT(1) +#define HCI_SUS_CTRL BIT(0) /* SDIO Tx FIFO related */ /* The number of Tx FIFO free page */ @@ -1275,33 +1238,33 @@ Current IOREG MAP /* 2REG_MULTI_FUNC_CTRL(For RTL8723 Only) */ /* Enable GPIO[9] as WiFi HW PDn source */ -#define WL_HWPDN_EN BIT0 +#define WL_HWPDN_EN BIT(0) /* WiFi HW PDn polarity control */ -#define WL_HWPDN_SL BIT1 +#define WL_HWPDN_SL BIT(1) /* WiFi function enable */ -#define WL_FUNC_EN BIT2 +#define WL_FUNC_EN BIT(2) /* Enable GPIO[9] as WiFi RF HW PDn source */ -#define WL_HWROF_EN BIT3 +#define WL_HWROF_EN BIT(3) /* Enable GPIO[11] as BT HW PDn source */ -#define BT_HWPDN_EN BIT16 +#define BT_HWPDN_EN BIT(16) /* BT HW PDn polarity control */ -#define BT_HWPDN_SL BIT17 +#define BT_HWPDN_SL BIT(17) /* BT function enable */ -#define BT_FUNC_EN BIT18 +#define BT_FUNC_EN BIT(18) /* Enable GPIO[11] as BT/GPS RF HW PDn source */ -#define BT_HWROF_EN BIT19 +#define BT_HWROF_EN BIT(19) /* Enable GPIO[10] as GPS HW PDn source */ -#define GPS_HWPDN_EN BIT20 +#define GPS_HWPDN_EN BIT(20) /* GPS HW PDn polarity control */ -#define GPS_HWPDN_SL BIT21 +#define GPS_HWPDN_SL BIT(21) /* GPS function enable */ -#define GPS_FUNC_EN BIT22 +#define GPS_FUNC_EN BIT(22) /* 3 REG_LIFECTRL_CTRL */ -#define HAL92C_EN_PKT_LIFE_TIME_BK BIT3 -#define HAL92C_EN_PKT_LIFE_TIME_BE BIT2 -#define HAL92C_EN_PKT_LIFE_TIME_VI BIT1 -#define HAL92C_EN_PKT_LIFE_TIME_VO BIT0 +#define HAL92C_EN_PKT_LIFE_TIME_BK BIT(3) +#define HAL92C_EN_PKT_LIFE_TIME_BE BIT(2) +#define HAL92C_EN_PKT_LIFE_TIME_VI BIT(1) +#define HAL92C_EN_PKT_LIFE_TIME_VO BIT(0) #define HAL92C_MSDU_LIFE_TIME_UNIT 128 /* in us */ @@ -1311,7 +1274,7 @@ Current IOREG MAP #define POLLING_LLT_THRESHOLD 20 #define POLLING_READY_TIMEOUT_COUNT 1000 /* GPIO BIT */ -#define HAL_8192C_HW_GPIO_WPS_BIT BIT2 +#define HAL_8192C_HW_GPIO_WPS_BIT BIT(2) /* 8192C EEPROM/EFUSE share register definition. */ diff --git a/drivers/staging/r8188eu/include/rtw_sreset.h b/drivers/staging/r8188eu/include/rtw_sreset.h index 9ecd75258310..8fa7aa4abb3f 100644 --- a/drivers/staging/r8188eu/include/rtw_sreset.h +++ b/drivers/staging/r8188eu/include/rtw_sreset.h @@ -18,13 +18,13 @@ struct sreset_priv { #include "rtl8188e_hal.h" #define WIFI_STATUS_SUCCESS 0 -#define USB_VEN_REQ_CMD_FAIL BIT0 -#define USB_READ_PORT_FAIL BIT1 -#define USB_WRITE_PORT_FAIL BIT2 -#define WIFI_MAC_TXDMA_ERROR BIT3 -#define WIFI_TX_HANG BIT4 -#define WIFI_RX_HANG BIT5 -#define WIFI_IF_NOT_EXIST BIT6 +#define USB_VEN_REQ_CMD_FAIL BIT(0) +#define USB_READ_PORT_FAIL BIT(1) +#define USB_WRITE_PORT_FAIL BIT(2) +#define WIFI_MAC_TXDMA_ERROR BIT(3) +#define WIFI_TX_HANG BIT(4) +#define WIFI_RX_HANG BIT(5) +#define WIFI_IF_NOT_EXIST BIT(6) void sreset_init_value(struct adapter *padapter); void sreset_reset_value(struct adapter *padapter); diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 1ccc5f8de1ee..a3e6d761e748 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -6123,9 +6123,9 @@ static int rtw_mp_reset_stats(struct net_device *dev, pmp_priv->rx_crcerrpktcount = 0; /* reset phy counter */ - write_bbreg(padapter, 0xf14, BIT16, 0x1); + write_bbreg(padapter, 0xf14, BIT(16), 0x1); msleep(10); - write_bbreg(padapter, 0xf14, BIT16, 0x0); + write_bbreg(padapter, 0xf14, BIT(16), 0x0); return 0; } -- cgit v1.2.3 From e3027f25c6f756056a314b82c11971349cca7a62 Mon Sep 17 00:00:00 2001 From: Yang Yingliang Date: Tue, 10 Aug 2021 20:53:14 +0800 Subject: staging: r8188eu: Use GFP_ATOMIC under spin lock A spin lock is taken in __nat25_db_network_insert() and update_BCNTIM() is called under spin lock so we should use GFP_ATOMIC in both place. Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver") Reported-by: Hulk Robot Reviewed-by: Dan Carpenter Acked-by: Larry Finger Signed-off-by: Yang Yingliang Link: https://lore.kernel.org/r/20210810125314.2182112-1-yangyingliang@huawei.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 2 +- drivers/staging/r8188eu/core/rtw_br_ext.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index d7548619061e..3f23c1a25419 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -98,7 +98,7 @@ static void update_BCNTIM(struct adapter *padapter) } if (remainder_ielen > 0) { - pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC); if (pbackup_remainder_ie && premainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index e13f134a497b..63a4cabdd3a8 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -394,7 +394,7 @@ static void __nat25_db_network_insert(struct adapter *priv, } db = db->next_hash; } - db = kmalloc(sizeof(*db), GFP_KERNEL); + db = kmalloc(sizeof(*db), GFP_ATOMIC); if (!db) { spin_unlock_bh(&priv->br_ext_lock); return; -- cgit v1.2.3 From 3a330ece235e8d2647d7e9e287e226d77b7cae9f Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Tue, 10 Aug 2021 17:55:05 -0700 Subject: staging: r8188eu: os_dep: Hoist vmalloc.h include into osdep_service.h After commit 71f09c5ae9d2 ("staging: r8188eu: Remove wrapper around vfree"), the driver fails to build on Hexagon due to an implicit declaration in several different files: drivers/staging/r8188eu/core/rtw_mlme.c:129:3: error: implicit declaration of function 'vfree' [-Werror,-Wimplicit-function-declaration] vfree(pmlmepriv->free_bss_buf); ^ 1 error generated. Previously, vfree() was only called in osdep_service.c, which includes vmalloc.h for vmalloc() and vfree(). Now, the driver relies on vfree() getting implicitly included from another file. Hoist the vmalloc.h include from osdep_service.c to osdep_service.h so that the driver continues to build fine on all architectures. Fixes: 71f09c5ae9d2 ("staging: r8188eu: Remove wrapper around vfree") Acked-by: Larry Finger Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210811005505.3953122-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 + drivers/staging/r8188eu/os_dep/osdep_service.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 6399f645cd40..157ffe46c3d2 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -39,6 +39,7 @@ #include /* for struct tasklet_struct */ #include #include +#include #include #include diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 910da0f0004a..9ea4e1a7c45f 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -6,7 +6,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" #include "../include/recv_osdep.h" -#include "../include/linux/vmalloc.h" #include "../include/rtw_ioctl_set.h" /* -- cgit v1.2.3 From 25ee7e89d45debc195cc8cec2483e07bbccd1472 Mon Sep 17 00:00:00 2001 From: Tuo Li Date: Tue, 10 Aug 2021 20:11:35 -0700 Subject: staging: rtl8192e: rtl_core: Fix possible null-pointer dereference in _rtl92e_pci_disconnect() The variable dev is checked in: if (dev) This indicates that it can be NULL. If so, a null-pointer dereference will occur: priv = rtllib_priv(dev); However, the value of priv is not used in the remaining part of this function. Thus the else-branch can be removed to fix this posible null-pointer dereference. Reported-by: TOTE Robot Reviewed-by: Dan Carpenter Signed-off-by: Tuo Li Link: https://lore.kernel.org/r/20210811031135.4110-1-islituo@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c index dffae61b517b..a7dd1578b2c6 100644 --- a/drivers/staging/rtl8192e/rtl8192e/rtl_core.c +++ b/drivers/staging/rtl8192e/rtl8192e/rtl_core.c @@ -2556,8 +2556,6 @@ static void _rtl92e_pci_disconnect(struct pci_dev *pdev) release_mem_region(pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); } - } else { - priv = rtllib_priv(dev); } pci_disable_device(pdev); -- cgit v1.2.3 From 959aabedcd91ba659e17191f1d3da96ceb1c4147 Mon Sep 17 00:00:00 2001 From: Dee-Jay Anthony Logozzo Date: Wed, 11 Aug 2021 23:41:32 +1000 Subject: staging: gdm724x: Place macro argument within parentheses Place the macro arguments within parentheses to avoid precedence issues. This solves the following checkpatch.pl warnings CHECK: Macro argument 'len' may be better as '(len)' to avoid precedence issues +#define ND_NLMSG_S_LEN(len) (len + ND_IFINDEX_LEN) CHECK: Macro argument 'nlh' may be better as '(nlh)' to avoid precedence issues +#define ND_NLMSG_R_LEN(nlh) (nlh->nlmsg_len - ND_IFINDEX_LEN) Signed-off-by: Dee-Jay Anthony Logozzo Link: https://lore.kernel.org/r/20210811134132.5240-1-dj@djl.id.au Signed-off-by: Greg Kroah-Hartman --- drivers/staging/gdm724x/netlink_k.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/gdm724x/netlink_k.c b/drivers/staging/gdm724x/netlink_k.c index 7902e52a699b..8f39cc5617aa 100644 --- a/drivers/staging/gdm724x/netlink_k.c +++ b/drivers/staging/gdm724x/netlink_k.c @@ -19,8 +19,8 @@ static DEFINE_MUTEX(netlink_mutex); #define ND_NLMSG_SPACE(len) (NLMSG_SPACE(len) + ND_IFINDEX_LEN) #define ND_NLMSG_DATA(nlh) ((void *)((char *)NLMSG_DATA(nlh) + \ ND_IFINDEX_LEN)) -#define ND_NLMSG_S_LEN(len) (len + ND_IFINDEX_LEN) -#define ND_NLMSG_R_LEN(nlh) (nlh->nlmsg_len - ND_IFINDEX_LEN) +#define ND_NLMSG_S_LEN(len) ((len) + ND_IFINDEX_LEN) +#define ND_NLMSG_R_LEN(nlh) ((nlh)->nlmsg_len - ND_IFINDEX_LEN) #define ND_NLMSG_IFIDX(nlh) NLMSG_DATA(nlh) #define ND_MAX_MSG_LEN (1024 * 32) -- cgit v1.2.3 From b8a59fed6b1def89f0d14034998ddb757e767751 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 11 Aug 2021 22:14:46 +0200 Subject: staging: r8188eu: remove unused efuse hal components struct hal_data_8188e contains some components related to efuses which are not used for rl8188eu. Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210811201450.31366-1-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtl8188e_hal.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtl8188e_hal.h b/drivers/staging/r8188eu/include/rtl8188e_hal.h index ea879572d6e1..3939bf053de1 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_hal.h +++ b/drivers/staging/r8188eu/include/rtl8188e_hal.h @@ -263,9 +263,6 @@ struct hal_data_8188e { u8 bAPKThermalMeterIgnore; bool EepromOrEfuse; - /* 92C:256bytes, 88E:512bytes, we use union set (512bytes) */ - u8 EfuseMap[2][HWSET_MAX_SIZE_512]; - u8 EfuseUsedPercentage; struct efuse_hal EfuseHal; u8 Index24G_CCK_Base[RF_PATH_MAX][CHANNEL_MAX_NUMBER]; -- cgit v1.2.3 From 86d90d776e1cfe169457a64666e73abb6dfb1423 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 11 Aug 2021 22:14:47 +0200 Subject: staging: r8188eu: remove unused function parameters rtw_usb_if1_init and chip_by_usb_id do not need a struct usb_device_id parameter. Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210811201450.31366-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 8f1e33d2fff7..4bf89b78a74a 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -250,8 +250,7 @@ static void usb_dvobj_deinit(struct usb_interface *usb_intf) } -static void chip_by_usb_id(struct adapter *padapter, - const struct usb_device_id *pdid) +static void chip_by_usb_id(struct adapter *padapter) { padapter->chip_type = NULL_CHIP_TYPE; hal_set_hw_type(padapter); @@ -569,7 +568,7 @@ exit: */ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, - struct usb_interface *pusb_intf, const struct usb_device_id *pdid) + struct usb_interface *pusb_intf) { struct adapter *padapter = NULL; struct net_device *pnetdev = NULL; @@ -587,7 +586,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, /* step 1-1., decide the chip_type via vid/pid */ padapter->interface_type = RTW_USB; - chip_by_usb_id(padapter, pdid); + chip_by_usb_id(padapter); if (rtw_handle_dualmac(padapter, 1) != _SUCCESS) goto free_adapter; @@ -722,7 +721,7 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device if (!dvobj) goto exit; - if1 = rtw_usb_if1_init(dvobj, pusb_intf, pdid); + if1 = rtw_usb_if1_init(dvobj, pusb_intf); if (!if1) { DBG_88E("rtw_init_primarystruct adapter Failed!\n"); goto free_dvobj; -- cgit v1.2.3 From ef32cccc7f0656e8affa28b0ace7298c8144acb3 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 11 Aug 2021 22:14:48 +0200 Subject: staging: r8188eu: (trivial) remove a duplicate debug print Keep the one that shows the wakeup capability. Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210811201450.31366-3-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 4bf89b78a74a..6e4bf623f788 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -624,7 +624,6 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, dvobj->pusbdev->do_remote_wakeup = 1; pusb_intf->needs_remote_wakeup = 1; device_init_wakeup(&pusb_intf->dev, 1); - DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~~~~\n"); DBG_88E("\n padapter->pwrctrlpriv.bSupportRemoteWakeup~~~[%d]~~~\n", device_may_wakeup(&pusb_intf->dev)); } -- cgit v1.2.3 From a1c95234d6e6b2604abff9208e38db162b9a3e7b Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 11 Aug 2021 22:14:49 +0200 Subject: staging: r8188eu: use proper way to build a module It seems that for now, we can only build this driver as a module. Use the same mechanism as other drivers (such as rtl8723bs or the deprecated rtl8188eu) to enforce building as a module, i.e. depend on m in Kconfig instead of setting CONFIG_R8188EU = m in the Makefile. If we set CONFIG_R8188EU in the Makefile, this setting will not be visible in .config. Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210811201450.31366-4-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Kconfig | 1 + drivers/staging/r8188eu/Makefile | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Kconfig b/drivers/staging/r8188eu/Kconfig index 6323d63a4a1b..dc1719d3f2e4 100644 --- a/drivers/staging/r8188eu/Kconfig +++ b/drivers/staging/r8188eu/Kconfig @@ -2,6 +2,7 @@ config R8188EU tristate "Realtek RTL8188EU Wireless LAN NIC driver" depends on WLAN && USB && CFG80211 + depends on m select WIRELESS_EXT select WEXT_PRIV select LIB80211 diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index 7f6658f931d1..cca7a58c5f29 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -4,8 +4,6 @@ EXTRA_CFLAGS += -O1 ccflags-y += -D__CHECK_ENDIAN__ -CONFIG_R8188EU = m - CONFIG_USB_HCI = y CONFIG_BT_COEXIST = n -- cgit v1.2.3 From e7dd1a58ce708ae965c143ed6837b503d98cacfa Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 11 Aug 2021 22:14:50 +0200 Subject: staging: r8188eu: remove CONFIG_USB_HCI from Makefile We already depend on USB. There's no need to set CONFIG_USB_HCI in the Makefile. Some other Realtek drivers use #ifdef CONFIG_USB_HCI in their code, the r8188 driver doesn't. Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210811201450.31366-5-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/Makefile | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/Makefile b/drivers/staging/r8188eu/Makefile index cca7a58c5f29..6bd3a0590aa3 100644 --- a/drivers/staging/r8188eu/Makefile +++ b/drivers/staging/r8188eu/Makefile @@ -4,8 +4,6 @@ EXTRA_CFLAGS += -O1 ccflags-y += -D__CHECK_ENDIAN__ -CONFIG_USB_HCI = y - CONFIG_BT_COEXIST = n CONFIG_WOWLAN = n -- cgit v1.2.3 From 1fee0cc9398e511a4c38c3e6dc1d300c4bbef986 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 12 Aug 2021 02:25:17 +0200 Subject: staging: r8188eu: Remove all 5GHz network types Remove all 5Ghz network types. r8188eu works on 802.11bgn standards and on 2.4Ghz band. Acked-by: Larry Finger Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210812002519.23678-2-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 13 ++----------- drivers/staging/r8188eu/core/rtw_ieee80211.c | 19 +++---------------- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme.c | 10 ---------- drivers/staging/r8188eu/core/rtw_p2p.c | 2 +- drivers/staging/r8188eu/core/rtw_wlan_util.c | 15 ++------------- drivers/staging/r8188eu/hal/odm.c | 1 - drivers/staging/r8188eu/include/ieee80211.h | 23 ++--------------------- drivers/staging/r8188eu/include/wifi.h | 2 +- drivers/staging/r8188eu/include/wlan_bssdef.h | 2 +- 10 files changed, 13 insertions(+), 76 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 3f23c1a25419..bc4c6dbd5aa3 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -460,11 +460,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) } if (pcur_network->Configuration.DSConfig > 14) { - /* 5G band */ - if (tx_ra_bitmap & 0xffff000) - sta_band |= WIRELESS_11_5N | WIRELESS_11A; - else - sta_band |= WIRELESS_11A; + sta_band |= WIRELESS_INVALID; } else { if (tx_ra_bitmap & 0xffff000) sta_band |= WIRELESS_11_24N | WIRELESS_11G | WIRELESS_11B; @@ -547,9 +543,7 @@ void update_bmc_sta(struct adapter *padapter) } if (pcur_network->Configuration.DSConfig > 14) { - /* force to A mode. 5G doesn't support CCK rates */ - network_type = WIRELESS_11A; - tx_ra_bitmap = 0x150; /* 6, 12, 24 Mbps */ + network_type = WIRELESS_INVALID; } else { /* force to b mode */ network_type = WIRELESS_11B; @@ -1050,9 +1044,6 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) case WIRELESS_11BG_24N: pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; break; - case WIRELESS_11A: - pbss_network->NetworkTypeInUse = Ndis802_11OFDM5; - break; default: pbss_network->NetworkTypeInUse = Ndis802_11OFDM24; break; diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index 55d2b8f90d91..0c7231cefdda 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -98,10 +98,7 @@ uint rtw_is_cckratesonly_included(u8 *rate) int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) { if (channel > 14) { - if ((rtw_is_cckrates_included(rate)) == true) - return WIRELESS_INVALID; - else - return WIRELESS_11A; + return WIRELESS_INVALID; } else { /* could be pure B, pure G, or B/G */ if ((rtw_is_cckratesonly_included(rate)) == true) return WIRELESS_11B; @@ -328,9 +325,6 @@ void rtw_set_supported_rate(u8 *SupportedRates, uint mode) memcpy(SupportedRates, WIFI_CCKRATES, IEEE80211_CCK_RATE_LEN); break; case WIRELESS_11G: - case WIRELESS_11A: - case WIRELESS_11_5N: - case WIRELESS_11A_5N:/* Todo: no basic rate for ofdm ? */ memcpy(SupportedRates, WIFI_OFDMRATES, IEEE80211_NUM_OFDM_RATESLEN); break; case WIRELESS_11BG: @@ -393,16 +387,9 @@ int rtw_generate_ie(struct registry_priv *pregistrypriv) ie = rtw_set_ie(ie, _SSID_IE_, pdev_network->Ssid.SsidLength, pdev_network->Ssid.Ssid, &sz); /* supported rates */ - if (pregistrypriv->wireless_mode == WIRELESS_11ABGN) { - if (pdev_network->Configuration.DSConfig > 14) - wireless_mode = WIRELESS_11A_5N; - else - wireless_mode = WIRELESS_11BG_24N; - } else { - wireless_mode = pregistrypriv->wireless_mode; - } + wireless_mode = pregistrypriv->wireless_mode; - rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); + rtw_set_supported_rate(pdev_network->SupportedRates, wireless_mode); rateLen = rtw_get_rateset_len(pdev_network->SupportedRates); diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 37e8b076be93..8b2f5ace1d86 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -795,7 +795,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) (!check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE))) return 0; - if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N|WIRELESS_11_5N)) { + if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N)) { p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); if (p && ht_ielen > 0) { pht_capie = (struct ieee80211_ht_cap *)(p+2); diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index d688f2427b03..ae7fd24798c3 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1916,16 +1916,6 @@ void rtw_update_registrypriv_dev_network(struct adapter *adapter) case WIRELESS_11BG_24N: pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); break; - case WIRELESS_11A: - case WIRELESS_11A_5N: - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); - break; - case WIRELESS_11ABGN: - if (pregistrypriv->channel > 14) - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM5); - else - pdev_network->NetworkTypeInUse = (Ndis802_11OFDM24); - break; default: /* TODO */ break; diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 9b3ea8a31508..3c518a7cd64f 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1950,7 +1950,7 @@ int rtw_p2p_enable(struct adapter *padapter, enum P2P_ROLE role) /* Added by Albert 2011/03/22 */ /* In the P2P mode, the driver should not support the b mode. */ /* So, the Tx packet shouldn't use the CCK rate */ - update_tx_basic_rate(padapter, WIRELESS_11AGN); + update_tx_basic_rate(padapter, (WIRELESS_11G | WIRELESS_11_24N)); /* Enable P2P function */ init_wifidirect_info(padapter, role); diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index e897920b7af1..b9ef671bbc8a 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -78,7 +78,6 @@ unsigned char networktype_to_raid(unsigned char network_type) case WIRELESS_11B: raid = RATR_INX_WIRELESS_B; break; - case WIRELESS_11A: case WIRELESS_11G: raid = RATR_INX_WIRELESS_G; break; @@ -86,10 +85,8 @@ unsigned char networktype_to_raid(unsigned char network_type) raid = RATR_INX_WIRELESS_GB; break; case WIRELESS_11_24N: - case WIRELESS_11_5N: raid = RATR_INX_WIRELESS_N; break; - case WIRELESS_11A_5N: case WIRELESS_11G_24N: raid = RATR_INX_WIRELESS_NG; break; @@ -110,10 +107,7 @@ u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if (pmlmeext->cur_channel > 14) { - if (pmlmeinfo->HT_enable) - network_type = WIRELESS_11_5N; - - network_type |= WIRELESS_11A; + network_type |= WIRELESS_INVALID; } else { if (pmlmeinfo->HT_enable) network_type = WIRELESS_11_24N; @@ -1490,8 +1484,6 @@ void update_capinfo(struct adapter *Adapter, u16 updateCap) if (pmlmeinfo->slotTime != NON_SHORT_SLOT_TIME) pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; } - } else if (pmlmeext->cur_wireless_mode & (WIRELESS_11A | WIRELESS_11_5N)) { - pmlmeinfo->slotTime = SHORT_SLOT_TIME; } else { /* B Mode */ pmlmeinfo->slotTime = NON_SHORT_SLOT_TIME; @@ -1516,10 +1508,7 @@ void update_wireless_mode(struct adapter *padapter) pmlmeinfo->HT_enable = 1; if (pmlmeext->cur_channel > 14) { - if (pmlmeinfo->HT_enable) - network_type = WIRELESS_11_5N; - - network_type |= WIRELESS_11A; + network_type |= WIRELESS_INVALID; } else { if (pmlmeinfo->HT_enable) network_type = WIRELESS_11_24N; diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 53198bf92c0f..2fd20339460f 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1136,7 +1136,6 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u break; default: /* case WIRELESS_11_24N: */ - /* case WIRELESS_11_5N: */ if (pDM_Odm->RFType == RF_1T2R) rate_bitmap = 0x000fffff; else diff --git a/drivers/staging/r8188eu/include/ieee80211.h b/drivers/staging/r8188eu/include/ieee80211.h index 4dfa817175e7..bc5b030e9c40 100644 --- a/drivers/staging/r8188eu/include/ieee80211.h +++ b/drivers/staging/r8188eu/include/ieee80211.h @@ -145,53 +145,34 @@ enum NETWORK_TYPE { /* Sub-Element */ WIRELESS_11B = BIT(0), /* tx:cck only, rx:cck only, hw: cck */ WIRELESS_11G = BIT(1), /* tx:ofdm only, rx:ofdm & cck, hw:cck & ofdm*/ - WIRELESS_11A = BIT(2), /* tx:ofdm only, rx: ofdm only, hw:ofdm only */ WIRELESS_11_24N = BIT(3), /* tx:MCS only, rx:MCS & cck, hw:MCS & cck */ - WIRELESS_11_5N = BIT(4), /* tx:MCS only, rx:MCS & ofdm, hw:ofdm only */ - WIRELESS_AC = BIT(6), /* Combination */ /* tx: cck & ofdm, rx: cck & ofdm & MCS, hw: cck & ofdm */ WIRELESS_11BG = (WIRELESS_11B | WIRELESS_11G), /* tx: ofdm & MCS, rx: ofdm & cck & MCS, hw: cck & ofdm */ WIRELESS_11G_24N = (WIRELESS_11G | WIRELESS_11_24N), - /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ - WIRELESS_11A_5N = (WIRELESS_11A | WIRELESS_11_5N), /* tx: ofdm & cck & MCS, rx: ofdm & cck & MCS, hw: ofdm & cck */ WIRELESS_11BG_24N = (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N), - /* tx: ofdm & MCS, rx: ofdm & MCS, hw: ofdm only */ - WIRELESS_11AGN = (WIRELESS_11A | WIRELESS_11G | WIRELESS_11_24N | - WIRELESS_11_5N), - WIRELESS_11ABGN = (WIRELESS_11A | WIRELESS_11B | WIRELESS_11G | - WIRELESS_11_24N | WIRELESS_11_5N), }; #define SUPPORTED_24G_NETTYPE_MSK \ (WIRELESS_11B | WIRELESS_11G | WIRELESS_11_24N) -#define SUPPORTED_5G_NETTYPE_MSK \ - (WIRELESS_11A | WIRELESS_11_5N) #define IsSupported24G(NetType) \ ((NetType) & SUPPORTED_24G_NETTYPE_MSK ? true : false) -#define IsSupported5G(NetType) \ - ((NetType) & SUPPORTED_5G_NETTYPE_MSK ? true : false) #define IsEnableHWCCK(NetType) \ IsSupported24G(NetType) -#define IsEnableHWOFDM(NetType) \ - ((NetType) & (WIRELESS_11G | WIRELESS_11_24N | \ - SUPPORTED_5G_NETTYPE_MSK) ? true : false) #define IsSupportedRxCCK(NetType) IsEnableHWCCK(NetType) -#define IsSupportedRxOFDM(NetType) IsEnableHWOFDM(NetType) -#define IsSupportedRxMCS(NetType) IsEnableHWOFDM(NetType) #define IsSupportedTxCCK(NetType) \ ((NetType) & (WIRELESS_11B) ? true : false) #define IsSupportedTxOFDM(NetType) \ - ((NetType) & (WIRELESS_11G|WIRELESS_11A) ? true : false) + ((NetType) & (WIRELESS_11G) ? true : false) #define IsSupportedTxMCS(NetType) \ - ((NetType) & (WIRELESS_11_24N|WIRELESS_11_5N) ? true : false) + ((NetType) & (WIRELESS_11_24N) ? true : false) struct ieee_param { u32 cmd; diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h index 65fc677bf4eb..f4212c4f4ada 100644 --- a/drivers/staging/r8188eu/include/wifi.h +++ b/drivers/staging/r8188eu/include/wifi.h @@ -464,7 +464,7 @@ static inline int IsFrameTypeCtrl(unsigned char *pframe) #define _PRE_ALLOCMICHDR_ 6 #define _SIFSTIME_ \ - ((priv->pmib->dot11BssType.net_work_type & WIRELESS_11A) ? 16 : 10) + (priv->pmib->dot11BssType.net_work_type = 10) #define _ACKCTSLNG_ 14 /* 14 bytes long, including crclng */ #define _CRCLNG_ 4 diff --git a/drivers/staging/r8188eu/include/wlan_bssdef.h b/drivers/staging/r8188eu/include/wlan_bssdef.h index bada3e168c42..99ca097b8edd 100644 --- a/drivers/staging/r8188eu/include/wlan_bssdef.h +++ b/drivers/staging/r8188eu/include/wlan_bssdef.h @@ -254,7 +254,7 @@ static inline uint get_wlan_bssid_ex_sz(struct wlan_bssid_ex *bss) struct wlan_network { struct list_head list; - int network_type; /* refer to ieee80211.h for WIRELESS_11A/B/G */ + int network_type; /* refer to ieee80211.h for WIRELESS_11B/G */ int fixed; /* set fixed when not to be removed * in site-surveying */ unsigned long last_scanned; /* timestamp for the network */ -- cgit v1.2.3 From 9f68048346276aab4f37d5c6c57259dd61feb88c Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 12 Aug 2021 02:25:18 +0200 Subject: staging: r8188eu: Remove code related to unsupported channels Remove all code related to unsupported channel bandwidths. rtl8188eu* NICs work only on 20 and 40 Mhz channels. Acked-by: Larry Finger Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210812002519.23678-3-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/odm.h | 3 --- drivers/staging/r8188eu/include/rtw_rf.h | 3 --- 2 files changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index a1f8c7fe595c..4dadb22bcc89 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -567,9 +567,6 @@ enum odm_security { enum odm_bw { ODM_BW20M = 0, ODM_BW40M = 1, - ODM_BW80M = 2, - ODM_BW160M = 3, - ODM_BW10M = 4, }; /* ODM_CMNINFO_BOARD_TYPE */ diff --git a/drivers/staging/r8188eu/include/rtw_rf.h b/drivers/staging/r8188eu/include/rtw_rf.h index 0f790da7e0aa..48129da9c93f 100644 --- a/drivers/staging/r8188eu/include/rtw_rf.h +++ b/drivers/staging/r8188eu/include/rtw_rf.h @@ -97,9 +97,6 @@ enum rf90_radio_path { enum ht_channel_width { HT_CHANNEL_WIDTH_20 = 0, HT_CHANNEL_WIDTH_40 = 1, - HT_CHANNEL_WIDTH_80 = 2, - HT_CHANNEL_WIDTH_160 = 3, - HT_CHANNEL_WIDTH_10 = 4, }; /* */ -- cgit v1.2.3 From 221abd4d478ab52fd17de9287fa302ac0e06f7b3 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 12 Aug 2021 02:25:19 +0200 Subject: staging: r8188eu: Remove no more necessary definitions and code Remove no more necessary further 5GHz related code, along with no more used definitions of macro and variables. Acked-by: Larry Finger Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210812002519.23678-4-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_debug.c | 25 +----------------------- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 13 +++--------- drivers/staging/r8188eu/hal/odm.c | 19 +++--------------- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 3 --- drivers/staging/r8188eu/include/Hal8188EPhyCfg.h | 4 ---- drivers/staging/r8188eu/include/odm.h | 5 ----- drivers/staging/r8188eu/include/rtl8188e_spec.h | 5 ----- drivers/staging/r8188eu/include/rtw_mlme_ext.h | 1 - 9 files changed, 8 insertions(+), 69 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c index e7b088563738..771f62452498 100644 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -876,13 +876,11 @@ int proc_get_best_channel(char *page, char **start, struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; int len = 0; - u32 i, best_channel_24G = 1, best_channel_5G = 36, index_24G = 0, index_5G = 0; + u32 i, best_channel_24G = 1, index_24G = 0; for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { if (pmlmeext->channel_set[i].ChannelNum == 1) index_24G = i; - if (pmlmeext->channel_set[i].ChannelNum == 36) - index_5G = i; } for (i = 0; pmlmeext->channel_set[i].ChannelNum != 0; i++) { @@ -894,32 +892,11 @@ int proc_get_best_channel(char *page, char **start, } } - /* 5G */ - if (pmlmeext->channel_set[i].ChannelNum >= 36 && - pmlmeext->channel_set[i].ChannelNum < 140) { - /* Find primary channel */ - if (((pmlmeext->channel_set[i].ChannelNum - 36) % 8 == 0) && - (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) { - index_5G = i; - best_channel_5G = pmlmeext->channel_set[i].ChannelNum; - } - } - - if (pmlmeext->channel_set[i].ChannelNum >= 149 && - pmlmeext->channel_set[i].ChannelNum < 165) { - /* find primary channel */ - if (((pmlmeext->channel_set[i].ChannelNum - 149) % 8 == 0) && - (pmlmeext->channel_set[i].rx_count < pmlmeext->channel_set[index_5G].rx_count)) { - index_5G = i; - best_channel_5G = pmlmeext->channel_set[i].ChannelNum; - } - } /* debug */ len += snprintf(page + len, count - len, "The rx cnt of channel %3d = %d\n", pmlmeext->channel_set[i].ChannelNum, pmlmeext->channel_set[i].rx_count); } - len += snprintf(page + len, count - len, "best_channel_5G = %d\n", best_channel_5G); len += snprintf(page + len, count - len, "best_channel_24G = %d\n", best_channel_24G); *eof = 1; diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index 8b2f5ace1d86..edcac238076a 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -870,7 +870,7 @@ int rtw_set_channel_plan(struct adapter *adapter, u8 channel_plan) */ int rtw_set_country(struct adapter *adapter, const char *country_code) { - int channel_plan = RT_CHANNEL_DOMAIN_WORLD_WIDE_5G; + int channel_plan = RT_CHANNEL_DOMAIN_GLOBAL_DOAMIN_2G; DBG_88E("%s country_code:%s\n", __func__, country_code); diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 967c7574215a..17e7d33a80c4 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -104,7 +104,6 @@ static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { {0x01}, /* 0x10, RT_CHANNEL_DOMAIN_JAPAN */ {0x02}, /* 0x11, RT_CHANNEL_DOMAIN_FCC_NO_DFS */ {0x01}, /* 0x12, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS */ - {0x00}, /* 0x13, RT_CHANNEL_DOMAIN_WORLD_WIDE_5G */ {0x02}, /* 0x14, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS */ {0x00}, /* 0x15, RT_CHANNEL_DOMAIN_ETSI_NO_DFS */ {0x00}, /* 0x16, RT_CHANNEL_DOMAIN_KOREA_NO_DFS */ @@ -116,7 +115,6 @@ static struct rt_channel_plan_map RTW_ChannelPlanMap[RT_CHANNEL_DOMAIN_MAX] = { {0x00}, /* 0x1C, */ {0x00}, /* 0x1D, */ {0x00}, /* 0x1E, */ - {0x05}, /* 0x1F, RT_CHANNEL_DOMAIN_WORLD_WIDE_ONLY_5G */ /* 0x20 ~ 0x7F , New Define ===== */ {0x00}, /* 0x20, RT_CHANNEL_DOMAIN_WORLD_NULL */ {0x01}, /* 0x21, RT_CHANNEL_DOMAIN_ETSI1_NULL */ @@ -6813,11 +6811,7 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid p++; for (j = 0; j < noc; j++) { - if (fcn <= 14) - channel = fcn + j; /* 2.4 GHz */ - else - channel = fcn + j*4; /* 5 GHz */ - + channel = fcn + j; chplan_ap.Channel[i++] = channel; } } @@ -6834,11 +6828,10 @@ static void process_80211d(struct adapter *padapter, struct wlan_bssid_ex *bssid if (pregistrypriv->wireless_mode & WIRELESS_11G) { do { if ((i == MAX_CHANNEL_NUM) || - (chplan_sta[i].ChannelNum == 0) || - (chplan_sta[i].ChannelNum > 14)) + (chplan_sta[i].ChannelNum == 0)) break; - if ((j == chplan_ap.Len) || (chplan_ap.Channel[j] > 14)) + if (j == chplan_ap.Len) break; if (chplan_sta[i].ChannelNum == chplan_ap.Channel[j]) { diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 2fd20339460f..3c793852939d 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -621,15 +621,9 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); } } else { - if (*pDM_Odm->pBandType == ODM_BAND_5G) { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_0); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_0); - } else { - DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; - FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); - FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); - } + DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_1; + FirstConnect = (pDM_Odm->bLinked) && (!pDM_DigTable->bMediaConnect_1); + FirstDisConnect = (!pDM_Odm->bLinked) && (pDM_DigTable->bMediaConnect_1); } } else { DIG_Dynamic_MIN = pDM_DigTable->DIG_Dynamic_MIN_0; @@ -1094,12 +1088,6 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u else rate_bitmap = 0x0000000f; break; - case (ODM_WM_A|ODM_WM_G): - if (rssi_level == DM_RATR_STA_HIGH) - rate_bitmap = 0x00000f00; - else - rate_bitmap = 0x00000ff0; - break; case (ODM_WM_B|ODM_WM_G): if (rssi_level == DM_RATR_STA_HIGH) rate_bitmap = 0x00000f00; @@ -1109,7 +1097,6 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u rate_bitmap = 0x00000ff5; break; case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): - case (ODM_WM_A|ODM_WM_B|ODM_WM_G|ODM_WM_N24G): if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) { if (rssi_level == DM_RATR_STA_HIGH) { rate_bitmap = 0x000f0000; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index f7b6402e1cd2..02955b8c4005 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -1026,9 +1026,6 @@ _PHY_SetBWMode92C( case RF_8256: /* Please implement this function in Hal8190PciPhy8256.c */ break; - case RF_8258: - /* Please implement this function in Hal8190PciPhy8258.c */ - break; case RF_PSEUDO_11N: break; case RF_6052: diff --git a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h index 96888d66d28c..4370ec2fa981 100644 --- a/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h +++ b/drivers/staging/r8188eu/include/Hal8188EPhyCfg.h @@ -67,13 +67,10 @@ enum rf_radio_path { enum wireless_mode { WIRELESS_MODE_UNKNOWN = 0x00, - WIRELESS_MODE_A = BIT(2), WIRELESS_MODE_B = BIT(0), WIRELESS_MODE_G = BIT(1), WIRELESS_MODE_AUTO = BIT(5), WIRELESS_MODE_N_24G = BIT(3), - WIRELESS_MODE_N_5G = BIT(4), - WIRELESS_MODE_AC = BIT(6) }; enum phy_rate_tx_offset_area { @@ -91,7 +88,6 @@ enum RF_TYPE_8190P { RF_TYPE_MIN, /* 0 */ RF_8225 = 1, /* 1 11b/g RF for verification only */ RF_8256 = 2, /* 2 11b/g/n */ - RF_8258 = 3, /* 3 11a/b/g/n RF */ RF_6052 = 4, /* 4 11b/g/n RF */ /* TODO: We should remove this psudo PHY RF after we get new RF. */ RF_PSEUDO_11N = 5, /* 5, It is a temporality RF. */ diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index 4dadb22bcc89..19458e66603c 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -531,17 +531,13 @@ enum odm_wireless_mode { ODM_WM_UNKNOW = 0x0, ODM_WM_B = BIT(0), ODM_WM_G = BIT(1), - ODM_WM_A = BIT(2), ODM_WM_N24G = BIT(3), - ODM_WM_N5G = BIT(4), ODM_WM_AUTO = BIT(5), - ODM_WM_AC = BIT(6), }; /* ODM_CMNINFO_BAND */ enum odm_band_type { ODM_BAND_2_4G = BIT(0), - ODM_BAND_5G = BIT(1), }; /* ODM_CMNINFO_SEC_CHNL_OFFSET */ @@ -933,7 +929,6 @@ enum odm_bb_config_type { CONFIG_BB_PHY_REG, CONFIG_BB_AGC_TAB, CONFIG_BB_AGC_TAB_2G, - CONFIG_BB_AGC_TAB_5G, CONFIG_BB_PHY_REG_PG, }; diff --git a/drivers/staging/r8188eu/include/rtl8188e_spec.h b/drivers/staging/r8188eu/include/rtl8188e_spec.h index 5fdc6aac917c..1c96f7b81245 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_spec.h +++ b/drivers/staging/r8188eu/include/rtl8188e_spec.h @@ -523,7 +523,6 @@ Default: 00b. /* 8192C BW_OPMODE bits (Offset 0x203, 8bit) */ #define BW_OPMODE_20MHZ BIT(2) -#define BW_OPMODE_5G BIT(1) /* 8192C CAM Config Setting (offset 0x250, 1 byte) */ #define CAM_VALID BIT(15) @@ -1343,10 +1342,6 @@ Current IOREG MAP #define EEPROM_DEFAULT_24G_HT20_DIFF 0X02 #define EEPROM_DEFAULT_24G_OFDM_DIFF 0X04 -#define EEPROM_DEFAULT_5G_INDEX 0X2A -#define EEPROM_DEFAULT_5G_HT20_DIFF 0X00 -#define EEPROM_DEFAULT_5G_OFDM_DIFF 0X04 - #define EEPROM_DEFAULT_DIFF 0XFE #define EEPROM_DEFAULT_CHANNEL_PLAN 0x7F #define EEPROM_DEFAULT_BOARD_OPTION 0x00 diff --git a/drivers/staging/r8188eu/include/rtw_mlme_ext.h b/drivers/staging/r8188eu/include/rtw_mlme_ext.h index 3b6e3ae92c9f..d2f4d3ce7b90 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme_ext.h +++ b/drivers/staging/r8188eu/include/rtw_mlme_ext.h @@ -112,7 +112,6 @@ enum RT_CHANNEL_DOMAIN { RT_CHANNEL_DOMAIN_JAPAN = 0x10, RT_CHANNEL_DOMAIN_FCC_NO_DFS = 0x11, RT_CHANNEL_DOMAIN_JAPAN_NO_DFS = 0x12, - RT_CHANNEL_DOMAIN_WORLD_WIDE_5G = 0x13, RT_CHANNEL_DOMAIN_TAIWAN_NO_DFS = 0x14, /* new channel plan mapping, (2GDOMAIN_5GDOMAIN) ===== */ -- cgit v1.2.3 From 4d50f76395122d1a4e24bbba79986889e4b457ff Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 11 Aug 2021 20:52:30 -0500 Subject: staging: r8188eu: Fix Smatch warnings for core/*.c Smatch reports the following problems: drivers/staging/r8188eu/core/rtw_br_ext.c:655 nat25_db_handle() warn: if statement not indented drivers/staging/r8188eu/core/rtw_cmd.c:436 rtw_sitesurvey_cmd() warn: if statement not indented drivers/staging/r8188eu/core/rtw_cmd.c:450 rtw_sitesurvey_cmd() warn: if statement not indented drivers/staging/r8188eu/core/rtw_led.c:330 SwLedBlink2() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:359 SwLedBlink2() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:538 SwLedBlink4() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:567 SwLedBlink4() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:685 SwLedBlink5() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:771 SwLedControlMode1() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:819 SwLedControlMode1() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:845 SwLedControlMode1() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_led.c:1574 LedControl8188eu() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme.c:420 is_same_network() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme.c:986 rtw_joinbss_update_stainfo() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme.c:1162 rtw_joinbss_event_prehandle() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme.c:1858 rtw_restruct_sec_ie() error: uninitialized symbol 'authmode'. drivers/staging/r8188eu/core/rtw_mlme.c:1869 rtw_restruct_sec_ie() error: uninitialized symbol 'authmode'. drivers/staging/r8188eu/core/rtw_mlme_ext.c:401 _mgt_dispatcher() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme_ext.c:3210 is_matched_in_profilelist() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme_ext.c:4351 dump_mgntframe_and_wait() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme_ext.c:4374 dump_mgntframe_and_wait_ack() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mlme_ext.c:7378 _linked_rx_signal_strehgth_display() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mp.c:694 SetPacketTx() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_mp.c:900 _rtw_mp_xmit_priv() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_p2p.c:1130 process_p2p_group_negotation_req() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_recv.c:188 rtw_free_recvframe() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_recv.c:499 portctrl() error: uninitialized symbol 'ether_type'. drivers/staging/r8188eu/core/rtw_recv.c:507 portctrl() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_recv.c:722 sta2sta_data_frame() warn: if statement not indented drivers/staging/r8188eu/core/rtw_recv.c:1601 amsdu_to_msdu() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_security.c:283 rtw_seccalctkipmic() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_security.c:1116 aes_cipher() warn: for statement not indented drivers/staging/r8188eu/core/rtw_security.c:1213 rtw_aes_encrypt() warn: inconsistent indenting rivers/staging/r8188eu/core/rtw_sta_mgt.c:18 _rtw_init_stainfo() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_sta_mgt.c:475 rtw_get_bcmc_stainfo() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_wlan_util.c:65 cckratesonly_included() warn: if statement not indented drivers/staging/r8188eu/core/rtw_wlan_util.c:1150 should_forbid_n_rate() warn: if statement not indented drivers/staging/r8188eu/core/rtw_wlan_util.c:1401 check_assoc_AP() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_wlan_util.c:1403 check_assoc_AP() warn: inconsistent indenting drivers/staging/r8188eu/core/rtw_xmit.c:805 rtw_make_wlanhdr() warn: if statement not indented drivers/staging/r8188eu/core/rtw_xmit.c:1691 rtw_br_client_tx() warn: inconsistent indenting drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c:199 ODM_ReadAndConfig_RadioA_1T_8188E() warn: inconsistent indenting Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210812015232.23784-2-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 2 +- drivers/staging/r8188eu/core/rtw_cmd.c | 6 ------ drivers/staging/r8188eu/core/rtw_io.c | 2 +- drivers/staging/r8188eu/core/rtw_led.c | 20 ++++++++++---------- drivers/staging/r8188eu/core/rtw_mlme.c | 16 +++++++--------- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 16 +++++++++------- drivers/staging/r8188eu/core/rtw_mp.c | 6 +++--- drivers/staging/r8188eu/core/rtw_p2p.c | 4 ++-- drivers/staging/r8188eu/core/rtw_recv.c | 18 +++++++++--------- drivers/staging/r8188eu/core/rtw_security.c | 6 +++--- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 6 +++--- drivers/staging/r8188eu/core/rtw_wlan_util.c | 14 +++++++------- drivers/staging/r8188eu/core/rtw_xmit.c | 4 ++-- drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 2 +- 14 files changed, 58 insertions(+), 64 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 63a4cabdd3a8..22737cd0fe44 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -653,7 +653,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) switch (method) { case NAT25_CHECK: if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - DEBUG_INFO("NAT25: Check IPX skb_copy\n"); + DEBUG_INFO("NAT25: Check IPX skb_copy\n"); return 0; case NAT25_INSERT: DEBUG_INFO("NAT25: Insert IPX, Dest =%08x,%02x%02x%02x%02x%02x%02x,%04x Source =%08x,%02x%02x%02x%02x%02x%02x,%04x\n", diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index a62dd3c986e5..df83f4fb7fd0 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -433,9 +433,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, if (ssid[i].SsidLength) { memcpy(&psurveyPara->ssid[i], &ssid[i], sizeof(struct ndis_802_11_ssid)); psurveyPara->ssid_num++; - if (0) - DBG_88E(FUNC_ADPT_FMT" ssid:(%s, %d)\n", FUNC_ADPT_ARG(padapter), - psurveyPara->ssid[i].Ssid, psurveyPara->ssid[i].SsidLength); } } } @@ -447,9 +444,6 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, if (ch[i].hw_value && !(ch[i].flags & RTW_IEEE80211_CHAN_DISABLED)) { memcpy(&psurveyPara->ch[i], &ch[i], sizeof(struct rtw_ieee80211_channel)); psurveyPara->ch_num++; - if (0) - DBG_88E(FUNC_ADPT_FMT" ch:%u\n", FUNC_ADPT_ARG(padapter), - psurveyPara->ch[i].hw_value); } } } diff --git a/drivers/staging/r8188eu/core/rtw_io.c b/drivers/staging/r8188eu/core/rtw_io.c index b5cd9bbc1ce1..cde0205816b1 100644 --- a/drivers/staging/r8188eu/core/rtw_io.c +++ b/drivers/staging/r8188eu/core/rtw_io.c @@ -266,7 +266,7 @@ u32 _rtw_write_port_and_wait(struct adapter *adapter, u32 addr, u32 cnt, u8 *pme if (ret == _SUCCESS) ret = rtw_sctx_wait(&sctx); - return ret; + return ret; } void _rtw_write_port_cancel(struct adapter *adapter) diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 671c7cbc7cc3..306862aec53a 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -323,7 +323,7 @@ static void SwLedBlink2(struct LED_871x *pLed) if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff(padapter, pLed); } else { - if (pLed->bLedOn) + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; @@ -352,7 +352,7 @@ static void SwLedBlink2(struct LED_871x *pLed) if (padapter->pwrctrlpriv.rf_pwrstate != rf_on) { SwLedOff(padapter, pLed); } else { - if (pLed->bLedOn) + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; @@ -531,7 +531,7 @@ static void SwLedBlink4(struct LED_871x *pLed) if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { SwLedOff(padapter, pLed); } else { - if (pLed->bLedOn) + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; @@ -560,7 +560,7 @@ static void SwLedBlink4(struct LED_871x *pLed) if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { SwLedOff(padapter, pLed); } else { - if (pLed->bLedOn) + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; @@ -678,7 +678,7 @@ static void SwLedBlink5(struct LED_871x *pLed) if (padapter->pwrctrlpriv.rf_pwrstate != rf_on && padapter->pwrctrlpriv.rfoff_reason > RF_CHANGE_BY_PS) { SwLedOff(padapter, pLed); } else { - if (pLed->bLedOn) + if (pLed->bLedOn) pLed->BlinkingLedState = RTW_LED_OFF; else pLed->BlinkingLedState = RTW_LED_ON; @@ -768,7 +768,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct } if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&pLed->BlinkTimer); @@ -816,7 +816,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct } if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&pLed->BlinkTimer); @@ -842,7 +842,7 @@ static void SwLedControlMode1(struct adapter *padapter, enum LED_CTL_MODE LedAct } if (pLed->bLedLinkBlinkInProgress) { _cancel_timer_ex(&pLed->BlinkTimer); - pLed->bLedLinkBlinkInProgress = false; + pLed->bLedLinkBlinkInProgress = false; } if (pLed->bLedBlinkInProgress) { _cancel_timer_ex(&pLed->BlinkTimer); @@ -1571,8 +1571,8 @@ void LedControl8188eu(struct adapter *padapter, enum LED_CTL_MODE LedAction) struct led_priv *ledpriv = &padapter->ledpriv; struct registry_priv *registry_par; - if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || - (!padapter->hw_init_completed)) + if ((padapter->bSurpriseRemoved) || (padapter->bDriverStopped) || + (!padapter->hw_init_completed)) return; if (!ledpriv->bRegUseLed) diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index ae7fd24798c3..5088b555f55d 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -416,7 +416,7 @@ static int is_same_ess(struct wlan_bssid_ex *a, struct wlan_bssid_ex *b) int is_same_network(struct wlan_bssid_ex *src, struct wlan_bssid_ex *dst) { - u16 s_cap, d_cap; + u16 s_cap, d_cap; __le16 le_scap, le_dcap; memcpy((u8 *)&le_scap, rtw_get_capability_from_ie(src->IEs), 2); @@ -983,7 +983,7 @@ static struct sta_info *rtw_joinbss_update_stainfo(struct adapter *padapter, str if (psta) { /* update ptarget_sta */ DBG_88E("%s\n", __func__); psta->aid = pnetwork->join_res; - psta->mac_id = 0; + psta->mac_id = 0; /* sta mode */ rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); /* security related */ @@ -1159,10 +1159,10 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - pmlmepriv->cur_network_scanned = ptarget_wlan; - rtw_indicate_connect(adapter); - } + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + pmlmepriv->cur_network_scanned = ptarget_wlan; + rtw_indicate_connect(adapter); + } /* s5. Cancle assoc_timer */ _cancel_timer(&pmlmepriv->assoc_timer, &timer_cancelled); @@ -1738,7 +1738,6 @@ int rtw_set_key(struct adapter *adapter, struct security_priv *psecuritypriv, in INIT_LIST_HEAD(&pcmd->list); res = rtw_enqueue_cmd(pcmdpriv, pcmd); exit: - return res; } @@ -1833,10 +1832,9 @@ static int rtw_append_pmkid(struct adapter *Adapter, int iEntry, u8 *ie, uint ie int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_len) { - u8 authmode; + u8 authmode = 0; uint ielength; int iEntry; - struct mlme_priv *pmlmepriv = &adapter->mlmepriv; struct security_priv *psecuritypriv = &adapter->securitypriv; uint ndisauthmode = psecuritypriv->ndisauthtype; diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 17e7d33a80c4..61b239651e1a 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -396,8 +396,8 @@ static void _mgt_dispatcher(struct adapter *padapter, struct mlme_handler *ptabl u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; u8 *pframe = precv_frame->rx_data; - if (ptable->func) { - /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ + if (ptable->func) { + /* receive the frames that ra(a1) is my address or ra(a1) is bc address. */ if (memcmp(GetAddr1Ptr(pframe), myid(&padapter->eeprompriv), ETH_ALEN) && memcmp(GetAddr1Ptr(pframe), bc_addr, ETH_ALEN)) return; @@ -3203,8 +3203,9 @@ static u8 is_matched_in_profilelist(u8 *peermacaddr, struct profile_info *profil peermacaddr[0], peermacaddr[1], peermacaddr[2], peermacaddr[3], peermacaddr[4], peermacaddr[5]); for (i = 0; i < P2P_MAX_PERSISTENT_GROUP_NUM; i++, profileinfo++) { - DBG_88E("[%s] profileinfo_mac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, - profileinfo->peermac[0], profileinfo->peermac[1], profileinfo->peermac[2], profileinfo->peermac[3], profileinfo->peermac[4], profileinfo->peermac[5]); + DBG_88E("[%s] profileinfo_mac=%.2X %.2X %.2X %.2X %.2X %.2X\n", __func__, + profileinfo->peermac[0], profileinfo->peermac[1], profileinfo->peermac[2], + profileinfo->peermac[3], profileinfo->peermac[4], profileinfo->peermac[5]); if (!memcmp(peermacaddr, profileinfo->peermac, ETH_ALEN)) { match_result = 1; DBG_88E("[%s] Match!\n", __func__); @@ -4345,7 +4346,7 @@ s32 dump_mgntframe_and_wait(struct adapter *padapter, struct xmit_frame *pmgntfr if (ret == _SUCCESS) ret = rtw_sctx_wait(&sctx); - return ret; + return ret; } s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmgntframe) @@ -4368,7 +4369,7 @@ s32 dump_mgntframe_and_wait_ack(struct adapter *padapter, struct xmit_frame *pmg pxmitpriv->ack_tx = false; _exit_critical_mutex(&pxmitpriv->ack_tx_mutex, NULL); - return ret; + return ret; } static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) @@ -7367,9 +7368,10 @@ void _linked_rx_signal_strehgth_display(struct adapter *padapter); void _linked_rx_signal_strehgth_display(struct adapter *padapter) { struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; + struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 mac_id; int UndecoratedSmoothedPWDB; + if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) mac_id = 0; else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 7f7a7eddda4a..8de6af042156 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -691,7 +691,7 @@ void SetPacketTx(struct adapter *padapter) desc->txdw1 |= cpu_to_le32((0x01 << 26) & 0xff000000); /* offset 4 */ - desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x3F); /* CAM_ID(MAC_ID) */ + desc->txdw1 |= cpu_to_le32((pattrib->mac_id) & 0x3F); /* CAM_ID(MAC_ID) */ desc->txdw1 |= cpu_to_le32((pattrib->qsel << QSEL_SHT) & 0x00001F00); /* Queue Select, TID */ desc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000F0000); /* Rate Adaptive ID */ @@ -897,11 +897,11 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data) void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) { int i, res; - struct adapter *padapter = pxmitpriv->adapter; + struct adapter *padapter = pxmitpriv->adapter; struct xmit_buf *pxmitbuf = (struct xmit_buf *)pxmitpriv->pxmitbuf; - u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; + if (padapter->registrypriv.mp_mode == 0) { max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; num_xmit_extbuf = NR_XMIT_EXTBUFF; diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 3c518a7cd64f..3a05e194019c 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1127,7 +1127,7 @@ u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, rtw_p2p_set_state(pwdinfo, P2P_STATE_GONEGO_ING); - if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) { + if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GO_INTENT, &attr_content, &attr_contentlen)) { DBG_88E("[%s] GO Intent = %d, tie = %d\n", __func__, attr_content >> 1, attr_content & 0x01); pwdinfo->peer_intent = attr_content; /* include both intent and tie breaker values. */ @@ -1182,7 +1182,7 @@ u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, peer_operating_ch = operatingch_info[4]; if (rtw_p2p_is_channel_list_ok(peer_operating_ch, - ch_list_inclusioned, ch_num_inclusioned)) { + ch_list_inclusioned, ch_num_inclusioned)) { /** * Change our operating channel as peer's for compatibility. */ diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index f0a042467386..9b3637e49052 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -185,7 +185,7 @@ int rtw_free_recvframe(struct recv_frame *precvframe, struct __queue *pfree_recv precvpriv->free_recvframe_cnt++; } - spin_unlock_bh(&pfree_recv_queue->lock); + spin_unlock_bh(&pfree_recv_queue->lock); return _SUCCESS; } @@ -455,7 +455,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p struct sta_info *psta; struct sta_priv *pstapriv; struct recv_frame *prtnframe; - u16 ether_type; + u16 ether_type = 0; u16 eapol_type = 0x888e;/* for Funia BD's WPA issue */ struct rx_pkt_attrib *pattrib; __be16 be_tmp; @@ -504,7 +504,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p prtnframe = precv_frame; } - return prtnframe; + return prtnframe; } static int recv_decache(struct recv_frame *precv_frame, u8 bretry, struct stainfo_rxcache *prxcache) @@ -720,7 +720,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, if (!*psta) { if (adapter->registrypriv.mp_mode == 1) { if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) - adapter->mppriv.rx_pktloss++; + adapter->mppriv.rx_pktloss++; } ret = _FAIL; goto exit; @@ -1598,13 +1598,13 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) /* Indicate the packets to upper layer */ /* Insert NAT2.5 RX here! */ - sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); - sub_skb->dev = padapter->pnetdev; + sub_skb->protocol = eth_type_trans(sub_skb, padapter->pnetdev); + sub_skb->dev = padapter->pnetdev; - sub_skb->ip_summed = CHECKSUM_NONE; + sub_skb->ip_summed = CHECKSUM_NONE; - netif_rx(sub_skb); - } + netif_rx(sub_skb); + } exit: diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 6cacf7d01626..845301476e8b 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -279,7 +279,7 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ if (header[1]&1) { /* ToDS == 1 */ - rtw_secmicappend(&micdata, &header[16], 6); /* DA */ + rtw_secmicappend(&micdata, &header[16], 6); /* DA */ if (header[1]&2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &header[24], 6); else @@ -1114,7 +1114,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { @@ -1210,7 +1210,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) } } - return res; + return res; } static int aes_decipher(u8 *key, uint hdrlen, diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index a74d0741658a..b4568ec1c48a 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -15,7 +15,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) memset((u8 *)psta, 0, sizeof (struct sta_info)); - spin_lock_init(&psta->lock); + spin_lock_init(&psta->lock); INIT_LIST_HEAD(&psta->list); INIT_LIST_HEAD(&psta->hash_list); _rtw_init_queue(&psta->sleep_q); @@ -463,7 +463,7 @@ struct sta_info *rtw_get_bcmc_stainfo(struct adapter *padapter) struct sta_priv *pstapriv = &padapter->stapriv; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - psta = rtw_get_stainfo(pstapriv, bc_addr); + psta = rtw_get_stainfo(pstapriv, bc_addr); return psta; } @@ -500,7 +500,7 @@ u8 rtw_access_ctrl(struct adapter *padapter, u8 *mac_addr) else if (pacl_list->mode == 2)/* deny unless in accept list */ res = (match) ? true : false; else - res = true; + res = true; #endif diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index b9ef671bbc8a..cddacf023fa6 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -62,9 +62,9 @@ int cckratesonly_included(unsigned char *rate, int ratelen) int i; for (i = 0; i < ratelen; i++) { - if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && - (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) - return false; + if ((((rate[i]) & 0x7f) != 2) && (((rate[i]) & 0x7f) != 4) && + (((rate[i]) & 0x7f) != 11) && (((rate[i]) & 0x7f) != 22)) + return false; } return true; @@ -1142,8 +1142,8 @@ unsigned int should_forbid_n_rate(struct adapter *padapter) break; case _RSN_IE_2_: if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || - (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) - return false; + (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) + return false; default: break; } @@ -1391,10 +1391,10 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) DBG_88E("link to Airgo Cap\n"); return HT_IOT_PEER_AIRGO; } else if (!memcmp(pIE->data, EPIGRAM_OUI, 3)) { - epigram_vendor_flag = 1; + epigram_vendor_flag = 1; if (ralink_vendor_flag) { DBG_88E("link to Tenda W311R AP\n"); - return HT_IOT_PEER_TENDA; + return HT_IOT_PEER_TENDA; } else { DBG_88E("Capture EPIGRAM_OUI\n"); } diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 1b05f1643ebf..f941150e5f94 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -803,7 +803,7 @@ s32 rtw_make_wlanhdr (struct adapter *padapter, u8 *hdr, struct pkt_attrib *patt /* check if enable ampdu */ if (pattrib->ht_en && psta->htpriv.ampdu_enable) { if (psta->htpriv.agg_enable_bitmap & BIT(pattrib->priority)) - pattrib->ampdu_en = true; + pattrib->ampdu_en = true; } /* re-check if enable ampdu by BA_starting_seqctrl */ @@ -1688,7 +1688,7 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) if (memcmp(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { DEBUG_ERR("TX DROP: untransformed frame SA:%02X%02X%02X%02X%02X%02X!\n", skb->data[6], skb->data[7], skb->data[8], skb->data[9], skb->data[10], skb->data[11]); - return -1; + return -1; } return 0; } diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c index fa51023cd48e..c5895e0c798b 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -196,7 +196,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) } else { odm_ConfigRF_RadioA_8188E(pDM_Odm, v1, v2); } - continue; + continue; } else { /* This line is the start line of branch. */ if (!CheckCondition(Array[i], hex)) { /* Discard the following (offset, data) pairs. */ -- cgit v1.2.3 From 178cd80dc15c9f47a839e4a65242cfca5eca4c70 Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 11 Aug 2021 20:52:31 -0500 Subject: staging: r8188eu: Fix smatch problems in hal/*.c Smatch detects the folloring: drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c:199 ODM_ReadAndConfig_RadioA_1T_8188E() warn: inconsistent indenting drivers/staging/r8188eu/hal/HalPwrSeqCmd.c:65 HalPwrSeqCmdParsing() warn: inconsistent indenting drivers/staging/r8188eu/hal/odm.c:225 ODM_DMWatchdog() warn: inconsistent indenting drivers/staging/r8188eu/hal/odm.c:485 ODM_Write_DIG() warn: inconsistent indenting drivers/staging/r8188eu/hal/odm.c:485 ODM_Write_DIG() warn: if statement not indented drivers/staging/r8188eu/hal/odm.c:491 ODM_Write_DIG() warn: if statement not indented drivers/staging/r8188eu/hal/odm.c:493 ODM_Write_DIG() warn: inconsistent indenting drivers/staging/r8188eu/hal/odm.c:496 ODM_Write_DIG() warn: if statement not indented drivers/staging/r8188eu/hal/odm.c:498 ODM_Write_DIG() warn: inconsistent indenting drivers/staging/r8188eu/hal/odm.c:501 ODM_Write_DIG() warn: if statement not indented drivers/staging/r8188eu/hal/odm.c:551 odm_DIGbyRSSI_LPS() warn: inconsistent indenting drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c:360 odm_ARFBRefresh_8188E() warn: inconsistent indenting drivers/staging/r8188eu/hal/odm_HWConfig.c:268 odm_RxPhyStatus92CSeries_Parsing() warn: inconsistent indenting drivers/staging/r8188eu/hal/rtl8188e_hal_init.c:726 hal_EfusePowerSwitch_RTL8188E() warn: inconsistent indenting drivers/staging/r8188eu/hal/rtl8188e_mp.c:60 Hal_mpt_SwitchRfSetting() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:547 wpa_set_encryption() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1478 rtw_wx_set_essid() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1479 rtw_wx_set_essid() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1481 rtw_wx_set_essid() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1555 rtw_wx_set_rate() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:2596 rtw_wps_start() warn: variable dereferenced before check 'pdata' (see line 2590) drivers/staging/r8188eu/os_dep/ioctl_linux.c:2790 rtw_p2p_profilefound() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:4846 rtw_set_encryption() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:5628 rtw_mp_efuse_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7055 rtw_mp_thermal() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7251 rtw_mp_set() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7255 rtw_mp_set() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7310 rtw_mp_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7345 rtw_mp_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7349 rtw_mp_get() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:856 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:859 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:862 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:887 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:915 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:925 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_halinit.c:929 rtl8188eu_hal_init() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_ops_linux.c:263 usb_writeN() warn: inconsistent indenting drivers/staging/r8188eu/hal/usb_ops_linux.c:568 usb_read_port() warn: inconsistent indenting ` Signed-off-by: Larry Finger drivers/staging/r8188eu/hal/usb_halinit.c:1887:17: warning: mixing declarations and code drivers/staging/r8188eu/hal/usb_ops_linux.c:519:25: error: typename in expression Link: https://lore.kernel.org/r/20210812015232.23784-3-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 16 ++-- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 2 +- drivers/staging/r8188eu/hal/odm.c | 18 ++--- drivers/staging/r8188eu/hal/odm_HWConfig.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 8 +- drivers/staging/r8188eu/hal/usb_halinit.c | 18 ++--- drivers/staging/r8188eu/hal/usb_ops_linux.c | 87 +++++++++++----------- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 30 ++++---- 9 files changed, 90 insertions(+), 93 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index 57839f8629ac..1f1ce5f36f83 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -357,14 +357,14 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf } else { pRaInfo->LowestRate = 0; } - if (pRaInfo->HighestRate > 0x13) - pRaInfo->PTModeSS = 3; - else if (pRaInfo->HighestRate > 0x0b) - pRaInfo->PTModeSS = 2; - else if (pRaInfo->HighestRate > 0x03) - pRaInfo->PTModeSS = 1; - else - pRaInfo->PTModeSS = 0; + if (pRaInfo->HighestRate > 0x13) + pRaInfo->PTModeSS = 3; + else if (pRaInfo->HighestRate > 0x0b) + pRaInfo->PTModeSS = 2; + else if (pRaInfo->HighestRate > 0x03) + pRaInfo->PTModeSS = 1; + else + pRaInfo->PTModeSS = 0; if (pRaInfo->DecisionRate > pRaInfo->HighestRate) pRaInfo->DecisionRate = pRaInfo->HighestRate; diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index 37bca779ee00..15386d42b0da 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -60,7 +60,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, poll_bit = false; offset = GET_PWR_CFG_OFFSET(pwrcfgcmd); do { - value = rtw_read8(padapter, offset); + value = rtw_read8(padapter, offset); value &= GET_PWR_CFG_MASK(pwrcfgcmd); if (value == (GET_PWR_CFG_VALUE(pwrcfgcmd) & GET_PWR_CFG_MASK(pwrcfgcmd))) diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 3c793852939d..8a56b1a2516b 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -222,7 +222,7 @@ void ODM_DMWatchdog(struct odm_dm_struct *pDM_Odm) ; } else if (pDM_Odm->SupportICType & ODM_IC_11N_SERIES) { ODM_TXPowerTrackingCheck(pDM_Odm); - odm_EdcaTurboCheck(pDM_Odm); + odm_EdcaTurboCheck(pDM_Odm); odm_DynamicTxPower(pDM_Odm); } odm_dtc(pDM_Odm); @@ -482,26 +482,26 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) if (pDM_DigTable->CurIGValue != CurrentIGI) { if (pDM_Odm->SupportPlatform & (ODM_CE|ODM_MP)) { ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->SupportICType != ODM_RTL8188E) + if (pDM_Odm->SupportICType != ODM_RTL8188E) ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); } else if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { switch (*pDM_Odm->pOnePathCCA) { case ODM_CCA_2R: ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->SupportICType != ODM_RTL8188E) + if (pDM_Odm->SupportICType != ODM_RTL8188E) ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); break; case ODM_CCA_1R_A: ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - if (pDM_Odm->SupportICType != ODM_RTL8188E) + if (pDM_Odm->SupportICType != ODM_RTL8188E) ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); break; case ODM_CCA_1R_B: ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), getIGIForDiff(CurrentIGI)); - if (pDM_Odm->SupportICType != ODM_RTL8188E) + if (pDM_Odm->SupportICType != ODM_RTL8188E) ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - break; - } + break; + } } /* pDM_DigTable->PreIGValue = pDM_DigTable->CurIGValue; */ pDM_DigTable->CurIGValue = CurrentIGI; @@ -548,9 +548,9 @@ void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) RSSI_Lower = DM_DIG_MIN_NIC; /* Upper and Lower Bound checking */ - if (CurrentIGI > DM_DIG_MAX_NIC) + if (CurrentIGI > DM_DIG_MAX_NIC) CurrentIGI = DM_DIG_MAX_NIC; - else if (CurrentIGI < RSSI_Lower) + else if (CurrentIGI < RSSI_Lower) CurrentIGI = RSSI_Lower; ODM_Write_DIG(pDM_Odm, CurrentIGI);/* ODM_Write_DIG(pDM_Odm, pDM_DigTable->CurIGValue); */ diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 343c647a1eaf..530357b58d66 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -265,7 +265,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* (1)Get RSSI for HT rate */ - for (i = RF_PATH_A; i < RF_PATH_MAX; i++) { + for (i = RF_PATH_A; i < RF_PATH_MAX; i++) { /* 2008/01/30 MH we will judge RF RX path now. */ if (dm_odm->RFPathRxEnable & BIT(i)) rf_rx_num++; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 588520d28097..f0560c15387c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -723,7 +723,7 @@ hal_EfusePowerSwitch_RTL8188E( tmpV16 = rtw_read16(pAdapter, REG_SYS_ISO_CTRL); if (!(tmpV16 & PWC_EV12V)) { tmpV16 |= PWC_EV12V; - rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); + rtw_write16(pAdapter, REG_SYS_ISO_CTRL, tmpV16); } /* Reset: 0x0000h[28], default valid */ tmpV16 = rtw_read16(pAdapter, REG_SYS_FUNC_EN); diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index b5fb3aedc000..a26a5816a45f 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -57,10 +57,10 @@ void Hal_mpt_SwitchRfSetting(struct adapter *pAdapter) struct mp_priv *pmp = &pAdapter->mppriv; /* <20120525, Kordan> Dynamic mechanism for APK, asked by Dennis. */ - pmp->MptCtx.backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); - pmp->MptCtx.backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0); - PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD); - PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD); + pmp->MptCtx.backup0x52_RF_A = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0); + pmp->MptCtx.backup0x52_RF_B = (u8)PHY_QueryRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0); + PHY_SetRFReg(pAdapter, RF_PATH_A, RF_0x52, 0x000F0, 0xD); + PHY_SetRFReg(pAdapter, RF_PATH_B, RF_0x52, 0x000F0, 0xD); } /*---------------------------hal\rtl8192c\MPT_Phy.c---------------------------*/ diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 9305d97fd54d..8948c429afd7 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -853,13 +853,13 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) haldata->RfRegChnlVal[0] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)0, RF_CHNLBW, bRFRegOffsetMask); haldata->RfRegChnlVal[1] = PHY_QueryRFReg(Adapter, (enum rf_radio_path)1, RF_CHNLBW, bRFRegOffsetMask); -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_TURN_ON_BLOCK); _BBTurnOnBlock(Adapter); -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_SECURITY); invalidate_cam_all(Adapter); -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* 2010/12/17 MH We need to set TX power according to EFUSE content at first. */ PHY_SetTxPowerLevel8188E(Adapter, haldata->CurrentChannel); @@ -884,7 +884,7 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_MISC11); /* Nav limit , suggest by scott */ rtw_write8(Adapter, 0x652, 0x0); -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); rtl8188e_InitHalDm(Adapter); if (Adapter->registrypriv.mp_mode == 1) { @@ -912,7 +912,7 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_INIT_HAL_DM); /* enable tx DMA to drop the redundate data of packet */ rtw_write16(Adapter, REG_TXDMA_OFFSET_CHK, (rtw_read16(Adapter, REG_TXDMA_OFFSET_CHK) | DROP_DATA_EN)); -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); /* 2010/08/26 MH Merge from 8192CE. */ if (pwrctrlpriv->rf_pwrstate == rf_on) { if (haldata->odmpriv.RFCalibrateInfo.bIQKInitialized) { @@ -922,11 +922,11 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_IQK); haldata->odmpriv.RFCalibrateInfo.bIQKInitialized = true; } -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_PW_TRACK); ODM_TXPowerTrackingCheck(&haldata->odmpriv); -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); PHY_LCCalibrate_8188E(Adapter); } } @@ -939,7 +939,7 @@ HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_LCK); rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); exit: -HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); + HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); DBG_88E("%s in %dms\n", __func__, rtw_get_passing_time_ms(init_start_time)); @@ -1884,7 +1884,7 @@ static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) switch (variable) { case HW_VAR_BASIC_RATE: *((u16 *)(val)) = haldata->BasicRateSet; - __attribute__((__fallthrough__)); + fallthrough; case HW_VAR_TXPAUSE: val[0] = rtw_read8(Adapter, REG_TXPAUSE); break; diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 012846ea8263..8fcfe73cf5b3 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -260,12 +260,10 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata wvalue = (u16)(addr&0x0000ffff); len = length; - memcpy(buf, pdata, len); + memcpy(buf, pdata, len); ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); - - return ret; } @@ -516,7 +514,6 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) case -EPIPE: case -ENODEV: case -ESHUTDOWN: - __attribute__((__fallthrough__)); case -ENOENT: adapt->bDriverStopped = true; break; @@ -565,54 +562,54 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) precvbuf->reuse = true; } - rtl8188eu_init_recvbuf(adapter, precvbuf); - - /* re-assign for linux based on skb */ - if (!precvbuf->reuse || !precvbuf->pskb) { - precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); - if (!precvbuf->pskb) { - DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); - return _FAIL; - } - - tmpaddr = (size_t)precvbuf->pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); - skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); - - precvbuf->phead = precvbuf->pskb->head; - precvbuf->pdata = precvbuf->pskb->data; - precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); - precvbuf->pend = skb_end_pointer(precvbuf->pskb); - precvbuf->pbuf = precvbuf->pskb->data; - } else { /* reuse skb */ - precvbuf->phead = precvbuf->pskb->head; - precvbuf->pdata = precvbuf->pskb->data; - precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); - precvbuf->pend = skb_end_pointer(precvbuf->pskb); - precvbuf->pbuf = precvbuf->pskb->data; + rtl8188eu_init_recvbuf(adapter, precvbuf); - precvbuf->reuse = false; + /* re-assign for linux based on skb */ + if (!precvbuf->reuse || !precvbuf->pskb) { + precvbuf->pskb = netdev_alloc_skb(adapter->pnetdev, MAX_RECVBUF_SZ + RECVBUFF_ALIGN_SZ); + if (!precvbuf->pskb) { + DBG_88E("#### usb_read_port() alloc_skb fail!#####\n"); + return _FAIL; } - precvpriv->rx_pending_cnt++; + tmpaddr = (size_t)precvbuf->pskb->data; + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); + + precvbuf->phead = precvbuf->pskb->head; + precvbuf->pdata = precvbuf->pskb->data; + precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); + precvbuf->pend = skb_end_pointer(precvbuf->pskb); + precvbuf->pbuf = precvbuf->pskb->data; + } else { /* reuse skb */ + precvbuf->phead = precvbuf->pskb->head; + precvbuf->pdata = precvbuf->pskb->data; + precvbuf->ptail = skb_tail_pointer(precvbuf->pskb); + precvbuf->pend = skb_end_pointer(precvbuf->pskb); + precvbuf->pbuf = precvbuf->pskb->data; + + precvbuf->reuse = false; + } - purb = precvbuf->purb; + precvpriv->rx_pending_cnt++; - /* translate DMA FIFO addr to pipehandle */ - pipe = ffaddr2pipehdl(pdvobj, addr); + purb = precvbuf->purb; - usb_fill_bulk_urb(purb, pusbd, pipe, - precvbuf->pbuf, - MAX_RECVBUF_SZ, - usb_read_port_complete, - precvbuf);/* context is precvbuf */ + /* translate DMA FIFO addr to pipehandle */ + pipe = ffaddr2pipehdl(pdvobj, addr); - err = usb_submit_urb(purb, GFP_ATOMIC); - if ((err) && (err != (-EPERM))) { - DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", - err, purb->status); - ret = _FAIL; - } + usb_fill_bulk_urb(purb, pusbd, pipe, + precvbuf->pbuf, + MAX_RECVBUF_SZ, + usb_read_port_complete, + precvbuf);/* context is precvbuf */ + + err = usb_submit_urb(purb, GFP_ATOMIC); + if ((err) && (err != (-EPERM))) { + DBG_88E("cannot submit rx in-token(err = 0x%08x),urb_status = %d\n", + err, purb->status); + ret = _FAIL; + } return ret; } diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index a3e6d761e748..84486ba6193d 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -544,7 +544,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, ret = -EOPNOTSUPP; goto exit; } - memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); + memcpy(&psecuritypriv->dot11DefKey[wep_key_idx].skey[0], pwep->KeyMaterial, pwep->KeyLength); psecuritypriv->dot11DefKeylen[wep_key_idx] = pwep->KeyLength; rtw_set_key(padapter, psecuritypriv, wep_key_idx, 0); } @@ -6084,22 +6084,22 @@ static int rtw_mp_thermal(struct net_device *dev, if (copy_from_user(extra, wrqu->pointer, wrqu->length)) return -EFAULT; - bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ + bwrite = strncmp(extra, "write", 6); /* strncmp true is 0 */ - Hal_GetThermalMeter(padapter, &val); + Hal_GetThermalMeter(padapter, &val); - if (bwrite == 0) { - EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if (2 > max_available_size) { - DBG_88E("no available efuse!\n"); - return -EFAULT; - } - if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { - DBG_88E("rtw_efuse_map_write error\n"); - return -EFAULT; - } else { - sprintf(extra, " efuse write ok :%d", val); - } + if (bwrite == 0) { + EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); + if (2 > max_available_size) { + DBG_88E("no available efuse!\n"); + return -EFAULT; + } + if (rtw_efuse_map_write(padapter, addr, cnt, &val) == _FAIL) { + DBG_88E("rtw_efuse_map_write error\n"); + return -EFAULT; + } else { + sprintf(extra, " efuse write ok :%d", val); + } } else { sprintf(extra, "%d", val); } -- cgit v1.2.3 From 0d5e4bfe47eaf6080c812748a359f64be8073b3c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Wed, 11 Aug 2021 20:52:32 -0500 Subject: staging: r8188eu: Fix smatch warnings in os_dep/*.c Smatch shows the following: drivers/staging/r8188eu/os_dep/ioctl_linux.c:1478 rtw_wx_set_essid() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1479 rtw_wx_set_essid() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1481 rtw_wx_set_essid() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:1555 rtw_wx_set_rate() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:2596 rtw_wps_start() warn: variable dereferenced before check 'pdata' (see line 2590) drivers/staging/r8188eu/os_dep/ioctl_linux.c:2790 rtw_p2p_profilefound() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:4846 rtw_set_encryption() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:5628 rtw_mp_efuse_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7251 rtw_mp_set() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7255 rtw_mp_set() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7310 rtw_mp_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7345 rtw_mp_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/ioctl_linux.c:7349 rtw_mp_get() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/mlme_linux.c:106 rtw_os_indicate_disconnect() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/os_intfs.c:1118 ips_netdrv_open() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/osdep_service.c:37 rtw_atoi() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/recv_linux.c:65 rtw_os_recvbuf_resource_free() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/usb_intf.c:338 rtw_hw_suspend() warn: variable dereferenced before check 'padapter' (see line 327) drivers/staging/r8188eu/os_dep/usb_intf.c:381 rtw_hw_suspend() warn: inconsistent indenting drivers/staging/r8188eu/os_dep/usb_intf.c:394 rtw_hw_resume() warn: variable dereferenced before check 'padapter' (see line 391) drivers/staging/r8188eu/os_dep/usb_intf.c:506 rtw_resume() warn: inconsistent indenting Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210812015232.23784-4-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 26 +++--- drivers/staging/r8188eu/os_dep/mlme_linux.c | 3 +- drivers/staging/r8188eu/os_dep/os_intfs.c | 2 +- drivers/staging/r8188eu/os_dep/osdep_service.c | 2 +- drivers/staging/r8188eu/os_dep/recv_linux.c | 8 +- drivers/staging/r8188eu/os_dep/usb_intf.c | 117 ++++++++++++------------- 6 files changed, 77 insertions(+), 81 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 84486ba6193d..d059b738b348 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -1475,8 +1475,8 @@ static int rtw_wx_set_essid(struct net_device *dev, src_ssid = ndis_ssid.Ssid; spin_lock_bh(&queue->lock); - phead = get_list_head(queue); - pmlmepriv->pscanned = phead->next; + phead = get_list_head(queue); + pmlmepriv->pscanned = phead->next; while (phead != pmlmepriv->pscanned) { pnetwork = container_of(pmlmepriv->pscanned, struct wlan_network, list); @@ -1552,7 +1552,7 @@ static int rtw_wx_set_rate(struct net_device *dev, u32 target_rate = wrqu->bitrate.value; u32 fixed = wrqu->bitrate.fixed; u32 ratevalue = 0; - u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; + u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; if (target_rate == -1) { ratevalue = 11; @@ -2587,13 +2587,15 @@ static int rtw_wps_start(struct net_device *dev, struct iw_point *pdata = &wrqu->data; u32 u32wps_start = 0; + if (!pdata) + return -EINVAL; ret = copy_from_user((void *)&u32wps_start, pdata->pointer, 4); if (ret) { ret = -EINVAL; goto exit; } - if (padapter->bDriverStopped || !pdata) { + if (padapter->bDriverStopped) { ret = -EINVAL; goto exit; } @@ -2787,8 +2789,8 @@ static int rtw_p2p_profilefound(struct net_device *dev, DBG_88E("[%s] In value = %s, len = %d\n", __func__, extra, wrqu->data.length - 1); /* The upper application should pass the SSID to driver by using this rtw_p2p_profilefound function. */ - if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { - if (extra[0] == '0') { + if (!rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) { + if (extra[0] == '0') { /* Remove all the profile information of wifidirect_info structure. */ memset(&pwdinfo->profileinfo[0], 0x00, sizeof(struct profile_info) * P2P_MAX_PERSISTENT_GROUP_NUM); pwdinfo->profileindex = 0; @@ -4657,7 +4659,7 @@ static int rtw_mp_efuse_get(struct net_device *dev, if (strcmp(tmp[0], "status") == 0) { sprintf(extra, "Load File efuse =%s, Load File MAC =%s", (pEEPROM->bloadfile_fail_flag ? "FAIL" : "OK"), (pEEPROM->bloadmac_fail_flag ? "FAIL" : "OK")); - goto exit; + goto exit; } else if (strcmp(tmp[0], "filemap") == 0) { mapLen = EFUSE_MAP_SIZE; @@ -6280,11 +6282,11 @@ static int rtw_mp_set(struct net_device *dev, case MP_START: DBG_88E("set case mp_start\n"); rtw_mp_start(dev, info, wrqu, extra); - break; + break; case MP_STOP: DBG_88E("set case mp_stop\n"); rtw_mp_stop(dev, info, wrqu, extra); - break; + break; case MP_BANDWIDTH: DBG_88E("set case mp_bandwidth\n"); rtw_mp_bandwidth(dev, info, wrqu, extra); @@ -6339,7 +6341,7 @@ static int rtw_mp_get(struct net_device *dev, case READ_REG: DBG_88E("mp_get READ_REG\n"); rtw_mp_read_reg(dev, info, wrqu, extra); - break; + break; case READ_RF: DBG_88E("mp_get READ_RF\n"); rtw_mp_read_rf(dev, info, wrqu, extra); @@ -6374,11 +6376,11 @@ static int rtw_mp_get(struct net_device *dev, case EFUSE_GET: DBG_88E("efuse get EFUSE_GET\n"); rtw_mp_efuse_get(dev, info, wdata, extra); - break; + break; case MP_DUMP: DBG_88E("set case MP_DUMP\n"); rtw_mp_dump(dev, info, wrqu, extra); - break; + break; case MP_PSD: DBG_88E("set case MP_PSD\n"); rtw_mp_psd(dev, info, wrqu, extra); diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index 259628cbf020..be9166f2b524 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -103,8 +103,7 @@ void rtw_os_indicate_disconnect(struct adapter *adapter) netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */ rtw_indicate_wx_disassoc_event(adapter); - rtw_reset_securitypriv(adapter); - + rtw_reset_securitypriv(adapter); } void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 1eb53cf8bccb..cc7e54170948 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -1114,7 +1114,7 @@ static int ips_netdrv_open(struct adapter *padapter) rtw_set_pwr_state_check_timer(&padapter->pwrctrlpriv); _set_timer(&padapter->mlmepriv.dynamic_chk_timer, 5000); - return _SUCCESS; + return _SUCCESS; netdev_open_error: DBG_88E("-ips_netdrv_open - drv_open failure, bup =%d\n", padapter->bup); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 9ea4e1a7c45f..c8a15959cff3 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -33,7 +33,7 @@ u32 rtw_atoi(u8 *s) } if (flag == 1) num = num * -1; - return num; + return num; } inline u8 *_rtw_vmalloc(u32 sz) diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 74d76b2baebb..1fb01f135741 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -15,14 +15,14 @@ /* init os related resource in struct recv_priv */ int rtw_os_recv_resource_init(struct recv_priv *precvpriv, - struct adapter *padapter) + struct adapter *padapter) { return _SUCCESS; } /* alloc os related resource in struct recv_frame */ int rtw_os_recv_resource_alloc(struct adapter *padapter, - struct recv_frame *precvframe) + struct recv_frame *precvframe) { precvframe->pkt_newalloc = NULL; precvframe->pkt = NULL; @@ -36,7 +36,7 @@ void rtw_os_recv_resource_free(struct recv_priv *precvpriv) /* alloc os related resource in struct recv_buf */ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, - struct recv_buf *precvbuf) + struct recv_buf *precvbuf) { int res = _SUCCESS; @@ -61,7 +61,7 @@ int rtw_os_recvbuf_resource_alloc(struct adapter *padapter, int rtw_os_recvbuf_resource_free(struct adapter *padapter, struct recv_buf *precvbuf) { - usb_free_urb(precvbuf->purb); + usb_free_urb(precvbuf->purb); return _SUCCESS; } diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 6e4bf623f788..a462cb6f3005 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -326,6 +326,8 @@ int rtw_hw_suspend(struct adapter *padapter) struct net_device *pnetdev = padapter->pnetdev; + if (!padapter) + goto error_exit; if ((!padapter->bup) || (padapter->bDriverStopped) || (padapter->bSurpriseRemoved)) { DBG_88E("padapter->bup=%d bDriverStopped=%d bSurpriseRemoved = %d\n", @@ -334,50 +336,46 @@ int rtw_hw_suspend(struct adapter *padapter) goto error_exit; } - if (padapter) { /* system suspend */ - LeaveAllPowerSaveMode(padapter); + LeaveAllPowerSaveMode(padapter); - DBG_88E("==> rtw_hw_suspend\n"); - _enter_pwrlock(&pwrpriv->lock); - pwrpriv->bips_processing = true; - /* s1. */ - if (pnetdev) { - netif_carrier_off(pnetdev); - rtw_netif_stop_queue(pnetdev); - } + DBG_88E("==> rtw_hw_suspend\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + /* s1. */ + if (pnetdev) { + netif_carrier_off(pnetdev); + rtw_netif_stop_queue(pnetdev); + } - /* s2. */ - rtw_disassoc_cmd(padapter, 500, false); + /* s2. */ + rtw_disassoc_cmd(padapter, 500, false); - /* s2-2. indicate disconnect to os */ - { - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; + /* s2-2. indicate disconnect to os */ + { + struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED)) { - _clr_fwstate_(pmlmepriv, _FW_LINKED); + if (check_fwstate(pmlmepriv, _FW_LINKED)) { + _clr_fwstate_(pmlmepriv, _FW_LINKED); - rtw_led_control(padapter, LED_CTL_NO_LINK); + rtw_led_control(padapter, LED_CTL_NO_LINK); - rtw_os_indicate_disconnect(padapter); + rtw_os_indicate_disconnect(padapter); - /* donnot enqueue cmd */ - rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); - } + /* donnot enqueue cmd */ + rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_DISCONNECT, 0); } - /* s2-3. */ - rtw_free_assoc_resources(padapter, 1); + } + /* s2-3. */ + rtw_free_assoc_resources(padapter, 1); - /* s2-4. */ - rtw_free_network_queue(padapter, true); - rtw_ips_dev_unload(padapter); - pwrpriv->rf_pwrstate = rf_off; - pwrpriv->bips_processing = false; + /* s2-4. */ + rtw_free_network_queue(padapter, true); + rtw_ips_dev_unload(padapter); + pwrpriv->rf_pwrstate = rf_off; + pwrpriv->bips_processing = false; - _exit_pwrlock(&pwrpriv->lock); - } else { - goto error_exit; - } - return 0; + _exit_pwrlock(&pwrpriv->lock); + return 0; error_exit: DBG_88E("%s, failed\n", __func__); @@ -386,40 +384,37 @@ error_exit: int rtw_hw_resume(struct adapter *padapter) { - struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; + struct pwrctrl_priv *pwrpriv; struct net_device *pnetdev = padapter->pnetdev; + if (!padapter) + goto error_exit; + pwrpriv = &padapter->pwrctrlpriv; + DBG_88E("==> rtw_hw_resume\n"); + _enter_pwrlock(&pwrpriv->lock); + pwrpriv->bips_processing = true; + rtw_reset_drv_sw(padapter); - if (padapter) { /* system resume */ - DBG_88E("==> rtw_hw_resume\n"); - _enter_pwrlock(&pwrpriv->lock); - pwrpriv->bips_processing = true; - rtw_reset_drv_sw(padapter); - - if (pm_netdev_open(pnetdev, false) != 0) { - _exit_pwrlock(&pwrpriv->lock); - goto error_exit; - } - - netif_device_attach(pnetdev); - netif_carrier_on(pnetdev); + if (pm_netdev_open(pnetdev, false) != 0) { + _exit_pwrlock(&pwrpriv->lock); + goto error_exit; + } - if (!netif_queue_stopped(pnetdev)) - netif_start_queue(pnetdev); - else - netif_wake_queue(pnetdev); + netif_device_attach(pnetdev); + netif_carrier_on(pnetdev); - pwrpriv->bkeepfwalive = false; - pwrpriv->brfoffbyhw = false; + if (!netif_queue_stopped(pnetdev)) + netif_start_queue(pnetdev); + else + netif_wake_queue(pnetdev); - pwrpriv->rf_pwrstate = rf_on; - pwrpriv->bips_processing = false; + pwrpriv->bkeepfwalive = false; + pwrpriv->brfoffbyhw = false; - _exit_pwrlock(&pwrpriv->lock); - } else { - goto error_exit; - } + pwrpriv->rf_pwrstate = rf_on; + pwrpriv->bips_processing = false; + _exit_pwrlock(&pwrpriv->lock); return 0; error_exit: @@ -502,7 +497,7 @@ static int rtw_resume(struct usb_interface *pusb_intf) struct dvobj_priv *dvobj = usb_get_intfdata(pusb_intf); struct adapter *padapter = dvobj->if1; struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - int ret = 0; + int ret = 0; if (pwrpriv->bInternalAutoSuspend) ret = rtw_resume_process(padapter); -- cgit v1.2.3 From 0ea03f795df43643a932cd9ee809fdc7ecafa873 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 12 Aug 2021 09:57:10 +0300 Subject: staging: r8188eu: Fix a couple scheduling in atomic bugs These allocations are sometimes done while holding a spin_lock so they have to be atomic. The call tree looks like this: -> rtw_set_802_11_connect() <- takes a spin_lock -> rtw_do_join() -> rtw_sitesurvey_cmd() <-- does a GFP_ATOMIC allocation -> p2p_ps_wk_cmd() Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20210812065710.GA31863@kili Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_p2p.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 3a05e194019c..1c2c6193b7af 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -1697,13 +1697,13 @@ u8 p2p_ps_wk_cmd(struct adapter *padapter, u8 p2p_ps_state, u8 enqueue) return res; if (enqueue) { - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { res = _FAIL; goto exit; } - pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_KERNEL); + pdrvextra_cmd_parm = kzalloc(sizeof(struct drvextra_cmd_parm), GFP_ATOMIC); if (!pdrvextra_cmd_parm) { kfree(ph2c); res = _FAIL; -- cgit v1.2.3 From 626520f4ba27d92c8caaf2d1f70c4bca4ea3f9de Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 12 Aug 2021 09:58:52 +0300 Subject: staging: r8188eu: scheduling in atomic in rtw_createbss_cmd() A couple of the callers are holding spinlocks so this allocation has to be atomic. One spinlock is in rtw_set_802_11_connect() but the simpler spinlock to review is when this function is called from rtw_surveydone_event_callback(). Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver") Signed-off-by: Dan Carpenter Link: https://lore.kernel.org/r/20210812065852.GB31863@kili Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index df83f4fb7fd0..e95cb27516b0 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -729,7 +729,7 @@ u8 rtw_createbss_cmd(struct adapter *padapter) rtw_led_control(padapter, LED_CTL_START_TO_LINK); - pcmd = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + pcmd = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!pcmd) { res = _FAIL; goto exit; -- cgit v1.2.3 From 347c9e5201a3e2bb2c84bcb7a04a6ac6b6c3cc33 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 12 Aug 2021 15:20:57 +0200 Subject: staging: r8188eu: replace custom hwaddr_aton_i() with mac_pton() Replace custom hwaddr_aton_i() with mac_pton() in core/ioctl_linux.c and remove the now unused functions hwaddr_aton_i() and hex2num_i(). Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210812132057.22579-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 40 +--------------------------- 1 file changed, 1 insertion(+), 39 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index d059b738b348..38ee41f9d2ba 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -89,44 +89,6 @@ static const char * const iw_operation_mode[] = { "Secondary", "Monitor" }; -static int hex2num_i(char c) -{ - if (c >= '0' && c <= '9') - return c - '0'; - if (c >= 'a' && c <= 'f') - return c - 'a' + 10; - if (c >= 'A' && c <= 'F') - return c - 'A' + 10; - return -1; -} - -/** - * hwaddr_aton - Convert ASCII string to MAC address - * @txt: MAC address as a string (e.g., "00:11:22:33:44:55") - * @addr: Buffer for the MAC address (ETH_ALEN = 6 bytes) - * Returns: 0 on success, -1 on failure (e.g., string not a MAC address) - */ -static int hwaddr_aton_i(const char *txt, u8 *addr) -{ - int i; - - for (i = 0; i < 6; i++) { - int a, b; - - a = hex2num_i(*txt++); - if (a < 0) - return -1; - b = hex2num_i(*txt++); - if (b < 0) - return -1; - *addr++ = (a << 4) | b; - if (i < 5 && *txt++ != ':') - return -1; - } - - return 0; -} - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; @@ -2512,7 +2474,7 @@ static int rtw_get_ap_info(struct net_device *dev, while (phead != plist) { pnetwork = container_of(plist, struct wlan_network, list); - if (hwaddr_aton_i(data, bssid)) { + if (!mac_pton(data, bssid)) { DBG_88E("Invalid BSSID '%s'.\n", (u8 *)data); spin_unlock_bh(&pmlmepriv->scanned_queue.lock); return -EINVAL; -- cgit v1.2.3 From 32755b2434967e9d88ad626820c5506513c5c728 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 12 Aug 2021 13:40:25 -0700 Subject: staging: r8188eu: Remove unused static inline functions in rtw_recv.h After commit 987219ad34a6 ("staging: r8188eu: remove lines from Makefile that silence build warnings"), clang warns several times: In file included from drivers/staging/r8188eu/os_dep/../include/drv_types.h:22: drivers/staging/r8188eu/os_dep/../include/rtw_recv.h:395:9: warning: variable 'buf_desc' is uninitialized when used here [-Wuninitialized] return buf_desc; ^~~~~~~~ drivers/staging/r8188eu/os_dep/../include/rtw_recv.h:391:25: note: initialize the variable 'buf_desc' to silence this warning unsigned char *buf_desc; ^ = NULL drivers/staging/r8188eu/os_dep/../include/rtw_recv.h:412:52: warning: variable 'buf_star' is uninitialized when used here [-Wuninitialized] precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); ^~~~~~~~ drivers/staging/r8188eu/os_dep/../include/rtw_recv.h:410:14: note: initialize the variable 'buf_star' to silence this warning u8 *buf_star; ^ = NULL 2 warnings generated. The functions that these warnings come from are not used or are called from functions that are not used so just remove them to remove the warnings. Acked-by: Phillip Potter Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210812204027.338872-2-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_recv.h | 46 ------------------------------ 1 file changed, 46 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index 857269ae4209..81594e7aed51 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -386,52 +386,6 @@ static inline u8 *recvframe_pull_tail(struct recv_frame *precvframe, int sz) return precvframe->rx_tail; } -static inline unsigned char *get_rxbuf_desc(struct recv_frame *precvframe) -{ - unsigned char *buf_desc; - - if (precvframe == NULL) - return NULL; - return buf_desc; -} - -static inline struct recv_frame *rxmem_to_recvframe(u8 *rxmem) -{ - /* due to the design of 2048 bytes alignment of recv_frame, - * we can reference the struct recv_frame */ - /* from any given member of recv_frame. */ - /* rxmem indicates the any member/address in recv_frame */ - - return (struct recv_frame *)(((size_t)rxmem >> RXFRAME_ALIGN) << RXFRAME_ALIGN); -} - -static inline struct recv_frame *pkt_to_recvframe(struct sk_buff *pkt) -{ - u8 *buf_star; - struct recv_frame *precv_frame; - precv_frame = rxmem_to_recvframe((unsigned char *)buf_star); - - return precv_frame; -} - -static inline u8 *pkt_to_recvmem(struct sk_buff *pkt) -{ - /* return the rx_head */ - - struct recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->rx_head; -} - -static inline u8 *pkt_to_recvdata(struct sk_buff *pkt) -{ - /* return the rx_data */ - - struct recv_frame *precv_frame = pkt_to_recvframe(pkt); - - return precv_frame->rx_data; -} - static inline int get_recvframe_len(struct recv_frame *precvframe) { return precvframe->len; -- cgit v1.2.3 From 72a5e1d7496309e9734d20073a81a9bbffd8d79d Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 12 Aug 2021 13:40:26 -0700 Subject: staging: r8188eu: Remove uninitialized use of ether_type in portctrl() After commit 987219ad34a6 ("staging: r8188eu: remove lines from Makefile that silence build warnings"), clang warns: drivers/staging/r8188eu/core/rtw_recv.c:499:8: warning: variable 'ether_type' is uninitialized when used here [-Wuninitialized] if (ether_type == eapol_type) ^~~~~~~~~~ drivers/staging/r8188eu/core/rtw_recv.c:458:16: note: initialize the variable 'ether_type' to silence this warning u16 ether_type; ^ = 0 1 warning generated. This if statement sets the exact same assignment as above so just remove it. Acked-by: Phillip Potter Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210812204027.338872-3-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 9b3637e49052..8df38db9572c 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -495,10 +495,6 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p /* allowed */ /* check decryption status, and decrypt the frame if needed */ prtnframe = precv_frame; - /* check is the EAPOL frame or not (Rekey) */ - if (ether_type == eapol_type) - /* check Rekey */ - prtnframe = precv_frame; } } else { prtnframe = precv_frame; -- cgit v1.2.3 From 0bd35146642bdc56f1b87d75f047b1c92bd2bd39 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Thu, 12 Aug 2021 13:40:27 -0700 Subject: staging: r8188eu: Reorganize error handling in rtw_drv_init() After commit 987219ad34a6 ("staging: r8188eu: remove lines from Makefile that silence build warnings"), clang warns: drivers/staging/r8188eu/os_dep/usb_intf.c:726:6: warning: variable 'status' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (!if1) { ^~~~ drivers/staging/r8188eu/os_dep/usb_intf.c:741:6: note: uninitialized use occurs here if (status != _SUCCESS) ^~~~~~ drivers/staging/r8188eu/os_dep/usb_intf.c:726:2: note: remove the 'if' if its condition is always false if (!if1) { ^~~~~~~~~~~ drivers/staging/r8188eu/os_dep/usb_intf.c:714:12: note: initialize the variable 'status' to silence this warning int status; ^ = 0 1 warning generated. status is not initialized if the call to usb_dvobj_init() or rtw_usb_if1_init() fails. Looking at the error function as a whole, the error handling is odd compared to the rest of the kernel, which prefers to set error codes on goto paths, rather than a global "status" variable which determines the error code at the end of the function and function calls in the case of error. Rearrange the error handling of this function to bring it more inline with how the kernel does it in most cases, which helps readability. The call to rtw_usb_if1_deinit() is eliminated because it is not possible to ever hit it; if rtw_usb_if1_init() fails, the goto call jumps over the call to rtw_usb_if1_deinit() and in the success case, status is set to _SUCCESS. Acked-by: Phillip Potter Acked-by: Fabio M. De Francesco Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210812204027.338872-4-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index a462cb6f3005..667f41125a87 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -704,20 +704,23 @@ static void rtw_usb_if1_deinit(struct adapter *if1) static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device_id *pdid) { struct adapter *if1 = NULL; - int status; struct dvobj_priv *dvobj; + int ret; /* step 0. */ process_spec_devid(pdid); /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); - if (!dvobj) - goto exit; + if (!dvobj) { + ret = -ENODEV; + goto err; + } if1 = rtw_usb_if1_init(dvobj, pusb_intf); if (!if1) { DBG_88E("rtw_init_primarystruct adapter Failed!\n"); + ret = -ENODEV; goto free_dvobj; } @@ -726,15 +729,12 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device rtw_signal_process(ui_pid[1], SIGUSR2); } - status = _SUCCESS; + return 0; - if (status != _SUCCESS && if1) - rtw_usb_if1_deinit(if1); free_dvobj: - if (status != _SUCCESS) - usb_dvobj_deinit(pusb_intf); -exit: - return status == _SUCCESS ? 0 : -ENODEV; + usb_dvobj_deinit(pusb_intf); +err: + return ret; } /* -- cgit v1.2.3 From 6a78bb5c4f92d1a3a2fa5c6bad56c57b916c6a33 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 13 Aug 2021 09:31:06 +0200 Subject: staging: r8188eu: remove 5GHz code from Hal_GetChnlGroup88E() Remove 5GHz code from Hal_GetChnlGroup88E(). Acked-by: Phillip Potter Acked-by: Fabio M. De Francesco Acked-by: Martin Kaiser Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210813073109.25609-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 62 ++++++------------------- 1 file changed, 14 insertions(+), 48 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index f0560c15387c..634a0a022727 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -2062,54 +2062,20 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) { - u8 bIn24G = true; - - if (chnl <= 14) { - bIn24G = true; - - if (chnl < 3) /* Channel 1-2 */ - *pGroup = 0; - else if (chnl < 6) /* Channel 3-5 */ - *pGroup = 1; - else if (chnl < 9) /* Channel 6-8 */ - *pGroup = 2; - else if (chnl < 12) /* Channel 9-11 */ - *pGroup = 3; - else if (chnl < 14) /* Channel 12-13 */ - *pGroup = 4; - else if (chnl == 14) /* Channel 14 */ - *pGroup = 5; - } else { - bIn24G = false; - - if (chnl <= 40) - *pGroup = 0; - else if (chnl <= 48) - *pGroup = 1; - else if (chnl <= 56) - *pGroup = 2; - else if (chnl <= 64) - *pGroup = 3; - else if (chnl <= 104) - *pGroup = 4; - else if (chnl <= 112) - *pGroup = 5; - else if (chnl <= 120) - *pGroup = 5; - else if (chnl <= 128) - *pGroup = 6; - else if (chnl <= 136) - *pGroup = 7; - else if (chnl <= 144) - *pGroup = 8; - else if (chnl <= 153) - *pGroup = 9; - else if (chnl <= 161) - *pGroup = 10; - else if (chnl <= 177) - *pGroup = 11; - } - return bIn24G; + if (chnl < 3) /* Channel 1-2 */ + *pGroup = 0; + else if (chnl < 6) /* Channel 3-5 */ + *pGroup = 1; + else if (chnl < 9) /* Channel 6-8 */ + *pGroup = 2; + else if (chnl < 12) /* Channel 9-11 */ + *pGroup = 3; + else if (chnl < 14) /* Channel 12-13 */ + *pGroup = 4; + else if (chnl == 14) /* Channel 14 */ + *pGroup = 5; + + return true; } void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -- cgit v1.2.3 From 1cb5715d273e931e093804e0d81145c9edf15ace Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 13 Aug 2021 09:31:07 +0200 Subject: staging: r8188eu: convert return type of Hal_GetChnlGroup88E() to void After the removal of 5GHz code from Hal_GetChnlGroup88E() the function always returns true now. Convert the return type to void and change the only user Hal_ReadTxPowerInfo88E() accordingly. Acked-by: Phillip Potter Acked-by: Martin Kaiser Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210813073109.25609-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 30 +++++++++++-------------- 1 file changed, 13 insertions(+), 17 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 634a0a022727..d3345fa0eb60 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -2060,7 +2060,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, } } -static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) +static void Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) { if (chnl < 3) /* Channel 1-2 */ *pGroup = 0; @@ -2074,8 +2074,6 @@ static u8 Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) *pGroup = 4; else if (chnl == 14) /* Channel 14 */ *pGroup = 5; - - return true; } void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) @@ -2107,7 +2105,7 @@ void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool Auto struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); struct txpowerinfo24g pwrInfo24G; u8 rfPath, ch, group; - u8 bIn24G, TxCount; + u8 TxCount; Hal_ReadPowerValueFromPROM_8188E(&pwrInfo24G, PROMContent, AutoLoadFail); @@ -2116,19 +2114,17 @@ void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool Auto for (rfPath = 0; rfPath < pHalData->NumTotalRFPath; rfPath++) { for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { - bIn24G = Hal_GetChnlGroup88E(ch, &group); - if (bIn24G) { - pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; - if (ch == 14) - pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][4]; - else - pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; - } - if (bIn24G) { - DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch); - DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_CCK_Base[rfPath][ch]); - DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_BW40_Base[rfPath][ch]); - } + Hal_GetChnlGroup88E(ch, &group); + + pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; + if (ch == 14) + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][4]; + else + pHalData->Index24G_BW40_Base[rfPath][ch] = pwrInfo24G.IndexBW40_Base[rfPath][group]; + + DBG_88E("======= Path %d, Channel %d =======\n", rfPath, ch); + DBG_88E("Index24G_CCK_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_CCK_Base[rfPath][ch]); + DBG_88E("Index24G_BW40_Base[%d][%d] = 0x%x\n", rfPath, ch, pHalData->Index24G_BW40_Base[rfPath][ch]); } for (TxCount = 0; TxCount < MAX_TX_COUNT; TxCount++) { pHalData->CCK_24G_Diff[rfPath][TxCount] = pwrInfo24G.CCK_Diff[rfPath][TxCount]; -- cgit v1.2.3 From 16fe4b303e226739787ee206437bf42b4caf82fe Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 13 Aug 2021 09:31:08 +0200 Subject: staging: r8188eu: rename parameter of Hal_GetChnlGroup88E() Rename parameter of Hal_GetChnlGroup88E() to avoid camel case. pGroup -> group Acked-by: Phillip Potter Acked-by: Martin Kaiser Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210813073109.25609-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index d3345fa0eb60..07ba5f0eecc2 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -2060,20 +2060,20 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, } } -static void Hal_GetChnlGroup88E(u8 chnl, u8 *pGroup) +static void Hal_GetChnlGroup88E(u8 chnl, u8 *group) { if (chnl < 3) /* Channel 1-2 */ - *pGroup = 0; + *group = 0; else if (chnl < 6) /* Channel 3-5 */ - *pGroup = 1; + *group = 1; else if (chnl < 9) /* Channel 6-8 */ - *pGroup = 2; + *group = 2; else if (chnl < 12) /* Channel 9-11 */ - *pGroup = 3; + *group = 3; else if (chnl < 14) /* Channel 12-13 */ - *pGroup = 4; + *group = 4; else if (chnl == 14) /* Channel 14 */ - *pGroup = 5; + *group = 5; } void Hal_ReadPowerSavingMode88E(struct adapter *padapter, u8 *hwinfo, bool AutoLoadFail) -- cgit v1.2.3 From 40ba17da86cb9ed6ec1457bd05db77df94d09c96 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 13 Aug 2021 09:31:09 +0200 Subject: staging: r8188eu: rename Hal_GetChnlGroup88E() Rename Hal_GetChnlGroup88E() to avoid camel case. HalGetChnlGroup88E -> hal_get_chnl_group_88e Acked-by: Phillip Potter Acked-by: Martin Kaiser Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210813073109.25609-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 07ba5f0eecc2..24a82fc41872 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -2060,7 +2060,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, } } -static void Hal_GetChnlGroup88E(u8 chnl, u8 *group) +static void hal_get_chnl_group_88e(u8 chnl, u8 *group) { if (chnl < 3) /* Channel 1-2 */ *group = 0; @@ -2114,7 +2114,7 @@ void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool Auto for (rfPath = 0; rfPath < pHalData->NumTotalRFPath; rfPath++) { for (ch = 0; ch < CHANNEL_MAX_NUMBER; ch++) { - Hal_GetChnlGroup88E(ch, &group); + hal_get_chnl_group_88e(ch, &group); pHalData->Index24G_CCK_Base[rfPath][ch] = pwrInfo24G.IndexCCK_Base[rfPath][group]; if (ch == 14) -- cgit v1.2.3 From b38447035aedef5861732dcbf048a0c226073768 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 13 Aug 2021 18:08:12 +0200 Subject: staging: r8188eu: Remove variables and simplify PHY_SwChnl8188E() Remove "bResult" and "tmpchannel" and all tests and assignments that are related to them in the code of PHY_SwChnl8188E(). "bResult" was always true, therefore its test led to a null statement. "tmpchannel" was used only to restore "pHalData->CurrentChannel" to its previous value only if _PHY_SwChnl8192C() was not called; therefore assign "channel" to "pHalData->CurrentChannel" if and only if _PHY_SwChnl8192C() is to be executed (and get rid of that temporary storage). Acked-by: Phillip Potter Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210813160812.17603-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index 02955b8c4005..9af91ec92d36 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -1091,8 +1091,6 @@ void PHY_SwChnl8188E(struct adapter *Adapter, u8 channel) { /* Call after initialization */ struct hal_data_8188e *pHalData = GET_HAL_DATA(Adapter); - u8 tmpchannel = pHalData->CurrentChannel; - bool bResult = true; if (pHalData->rf_chip == RF_PSEUDO_11N) return; /* return immediately if it is peudo-phy */ @@ -1100,17 +1098,8 @@ void PHY_SwChnl8188E(struct adapter *Adapter, u8 channel) if (channel == 0) channel = 1; - pHalData->CurrentChannel = channel; - if ((!Adapter->bDriverStopped) && (!Adapter->bSurpriseRemoved)) { + pHalData->CurrentChannel = channel; _PHY_SwChnl8192C(Adapter, channel); - - if (bResult) - ; - else - pHalData->CurrentChannel = tmpchannel; - - } else { - pHalData->CurrentChannel = tmpchannel; } } -- cgit v1.2.3 From a4adfa836c5289df905af19edc9727fc275dc1a1 Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Fri, 13 Aug 2021 13:14:18 -0700 Subject: staging: r8188eu: Remove unnecessary ret variable in rtw_drv_init() ret is unnecessary as both error paths set the same error code so just return that directly. Suggested-by: Fabio M. De Francesco Reviewed-by: Fabio M. De Francesco Acked-by: Phillip Potter Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210813201418.4018631-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 667f41125a87..3e5f4b5eb0fc 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -705,22 +705,18 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device { struct adapter *if1 = NULL; struct dvobj_priv *dvobj; - int ret; /* step 0. */ process_spec_devid(pdid); /* Initialize dvobj_priv */ dvobj = usb_dvobj_init(pusb_intf); - if (!dvobj) { - ret = -ENODEV; + if (!dvobj) goto err; - } if1 = rtw_usb_if1_init(dvobj, pusb_intf); if (!if1) { DBG_88E("rtw_init_primarystruct adapter Failed!\n"); - ret = -ENODEV; goto free_dvobj; } @@ -734,7 +730,7 @@ static int rtw_drv_init(struct usb_interface *pusb_intf, const struct usb_device free_dvobj: usb_dvobj_deinit(pusb_intf); err: - return ret; + return -ENODEV; } /* -- cgit v1.2.3 From 11fc4822f9c08c80c55df2303a8b9c42566b74b8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Aug 2021 09:39:20 +0200 Subject: staging: r8188eu: remove ODM_GetRightChnlPlaceforIQK() Function ODM_GetRightChnlPlaceforIQK() returns always zero for channels <= 14. The driver is for chips that do not support 5 GHz, so remove the function and replace the usage of its return value with zero. Acked-by: Fabio M. De Francesco Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210814073920.3551-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 29 +++------------------------- 1 file changed, 3 insertions(+), 26 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index 643a4d348b2e..c92a76aebc11 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -1004,27 +1004,6 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, } } -#define ODM_TARGET_CHNL_NUM_2G_5G 59 -static u8 ODM_GetRightChnlPlaceforIQK(u8 chnl) -{ - u8 channel_all[ODM_TARGET_CHNL_NUM_2G_5G] = { - 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, - 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, - 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, - 124, 126, 128, 130, 132, 134, 136, 138, 140, 149, 151, 153, - 155, 157, 159, 161, 163, 165 - }; - u8 place = chnl; - - if (chnl > 14) { - for (place = 14; place < sizeof(channel_all); place++) { - if (channel_all[place] == chnl) - return place-13; - } - } - return 0; -} - static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) { u8 tmpreg; @@ -1088,7 +1067,7 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) struct odm_dm_struct *dm_odm = &pHalData->odmpriv; struct mpt_context *pMptCtx = &adapt->mppriv.MptCtx; s32 result[4][8]; /* last is final result */ - u8 i, final_candidate, Indexforchannel; + u8 i, final_candidate; bool pathaok, pathbok; s32 RegE94, RegE9C, RegEA4, RegEB4, RegEBC, RegEC4; bool is12simular, is13simular, is23simular; @@ -1200,14 +1179,12 @@ void PHY_IQCalibrate_8188E(struct adapter *adapt, bool recovery) pathb_fill_iqk(adapt, pathbok, result, final_candidate, (RegEC4 == 0)); } - Indexforchannel = ODM_GetRightChnlPlaceforIQK(pHalData->CurrentChannel); - /* To Fix BSOD when final_candidate is 0xff */ /* by sherry 20120321 */ if (final_candidate < 4) { for (i = 0; i < IQK_Matrix_REG_NUM; i++) - dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][i] = result[final_candidate][i]; - dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].bIQKDone = true; + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[0].Value[0][i] = result[final_candidate][i]; + dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[0].bIQKDone = true; } _PHY_SaveADDARegisters(adapt, IQK_BB_REG_92C, dm_odm->RFCalibrateInfo.IQK_BB_backup_recover, 9); -- cgit v1.2.3 From 7c715fbce5d300bb782e2b92afab371bc9b8c697 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Sat, 14 Aug 2021 18:08:04 +0200 Subject: staging: r8188eu: os_dep: Remove defined but not used variables Remove defined but not used const variables. Issues detected by GCC running with -Wunused-const-variable option enabled. Acked-by: Michael Straube Acked-by: Phillip Potter Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210814160804.11634-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 21 --------------------- 1 file changed, 21 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 38ee41f9d2ba..d9fdd83218dc 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -84,11 +84,6 @@ static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; -static const char * const iw_operation_mode[] = { - "Auto", "Ad-Hoc", "Managed", "Master", "Repeater", - "Secondary", "Monitor" -}; - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; @@ -6666,19 +6661,3 @@ struct iw_handler_def rtw_handlers_def = { .num_private_args = sizeof(rtw_private_args) / sizeof(struct iw_priv_args), .get_wireless_stats = rtw_get_wireless_stats, }; - -/* copy from net/wireless/wext.c start */ -/* ---------------------------------------------------------------- */ -/* - * Calculate size of private arguments - */ -static const char iw_priv_type_size[] = { - 0, /* IW_PRIV_TYPE_NONE */ - 1, /* IW_PRIV_TYPE_BYTE */ - 1, /* IW_PRIV_TYPE_CHAR */ - 0, /* Not defined */ - sizeof(__u32), /* IW_PRIV_TYPE_INT */ - sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ - sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ - 0, /* Not defined */ -}; -- cgit v1.2.3 From 099ec97ac92911abfb102bb5c68ed270fc12e0dd Mon Sep 17 00:00:00 2001 From: Nathan Chancellor Date: Sat, 14 Aug 2021 16:56:26 -0700 Subject: staging: rtl8192u: Fix bitwise vs logical operator in TranslateRxSignalStuff819xUsb() clang warns: drivers/staging/rtl8192u/r8192U_core.c:4268:20: warning: bitwise and of boolean expressions; did you mean logical and? [-Wbool-operation-and] bpacket_toself = bpacket_match_bssid & ^~~~~~~~~~~~~~~~~~~~~ && 1 warning generated. Replace the bitwise AND with a logical one to clear up the warning, as that is clearly what was intended. Fixes: 8fc8598e61f6 ("Staging: Added Realtek rtl8192u driver to staging") Signed-off-by: Nathan Chancellor Link: https://lore.kernel.org/r/20210814235625.1780033-1-nathan@kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r8192U_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index db26edeccea6..b6698656fc01 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c @@ -4265,7 +4265,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, bpacket_match_bssid = (type != IEEE80211_FTYPE_CTL) && (ether_addr_equal(priv->ieee80211->current_network.bssid, (fc & IEEE80211_FCTL_TODS) ? hdr->addr1 : (fc & IEEE80211_FCTL_FROMDS) ? hdr->addr2 : hdr->addr3)) && (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV); - bpacket_toself = bpacket_match_bssid & + bpacket_toself = bpacket_match_bssid && (ether_addr_equal(praddr, priv->ieee80211->dev->dev_addr)); if (WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BEACON) -- cgit v1.2.3 From 027ed956b526350d7098e31731fa81c5579c2e68 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 15 Aug 2021 12:24:06 +0200 Subject: staging: r8188eu: remove kernel version depended code paths Remove kernel version depended code paths from the driver. Reported by checkpatch. WARNING: LINUX_VERSION_CODE should be avoided, code should be for the version to which it is merged Acked-by: Martin Kaiser Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210815102406.3707-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 4 ---- drivers/staging/r8188eu/os_dep/os_intfs.c | 24 +----------------------- drivers/staging/r8188eu/os_dep/rtw_android.c | 9 --------- drivers/staging/r8188eu/os_dep/xmit_linux.c | 5 ----- 4 files changed, 1 insertion(+), 41 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 5088b555f55d..54d74b98ce47 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1499,11 +1499,7 @@ void rtw_dynamic_check_timer_handlder(struct adapter *adapter) rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) if (rcu_dereference(adapter->pnetdev->rx_handler_data) && -#else - if (rcu_dereference(adapter->pnetdev->br_port) && -#endif (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true)) { /* expire NAT2.5 entry */ nat25_db_expire(adapter); diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index cc7e54170948..f4bf4732578a 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -637,19 +637,7 @@ static unsigned int rtw_classify8021d(struct sk_buff *skb) return dscp >> 5; } -static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)) - ,struct net_device *sb_dev -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)) - ,struct net_device *sb_dev - ,select_queue_fallback_t fallback -#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 14, 0)) - ,void *unused - ,select_queue_fallback_t fallback -#elif (LINUX_VERSION_CODE == KERNEL_VERSION(3, 13, 0)) - , void *accel -#endif -) +static u16 rtw_select_queue(struct net_device *dev, struct sk_buff *skb, struct net_device *sb_dev) { struct adapter *padapter = rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -706,15 +694,9 @@ int rtw_init_netdev_name(struct net_device *pnetdev, const char *ifname) return 0; } -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,39) static const struct device_type wlan_type = { .name = "wlan", }; -#else -static struct device_type wlan_type = { - .name = "wlan", -}; -#endif struct net_device *rtw_init_netdev(struct adapter *old_padapter) { @@ -992,11 +974,7 @@ void netdev_br_init(struct net_device *netdev) rcu_read_lock(); -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36) if (rcu_dereference(adapter->pnetdev->rx_handler_data)) { -#else - if (rcu_dereference(adapter->pnetdev->br_port)) { -#endif struct net_device *br_netdev; struct net *devnet = NULL; diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index d666feb87a7a..bdd381606ba6 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -63,13 +63,8 @@ int rtw_android_cmdstr_to_num(char *cmdstr) { int cmd_num; for (cmd_num=0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0)) if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) -#else - if (0 == strnicmp(cmdstr, android_wifi_cmd_str[cmd_num], - strlen(android_wifi_cmd_str[cmd_num]))) -#endif break; return cmd_num; } @@ -162,11 +157,7 @@ int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd) ret = -ENOMEM; goto exit; } -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) if (!access_ok(priv_cmd.buf, priv_cmd.total_len)) { -#else - if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) { -#endif DBG_88E("%s: failed to access memory\n", __func__); ret = -EFAULT; goto exit; diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 3a1b9d8988f2..4f1ce346b3a5 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -108,7 +108,6 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) { -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)) u16 queue; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -121,10 +120,6 @@ void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) if (__netif_subqueue_stopped(padapter->pnetdev, queue)) netif_wake_subqueue(padapter->pnetdev, queue); } -#else - if (netif_queue_stopped(padapter->pnetdev)) - netif_wake_queue(padapter->pnetdev); -#endif dev_kfree_skb_any(pkt); } -- cgit v1.2.3 From f33ce7100b6b189362cf9d7a9d7e3333b6ba427a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 14 Aug 2021 18:55:18 +0200 Subject: staging: r8188eu: use common ieee80211 constants Many defined constants in wifi.h are unused and/or available from , some with slightly different names. Remove the constants from wifi.h and use the common ones. Rename where necessary. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210814165518.8672-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 12 +++---- drivers/staging/r8188eu/core/rtw_mlme.c | 8 ++--- drivers/staging/r8188eu/include/wifi.h | 50 ---------------------------- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 2 +- 4 files changed, 11 insertions(+), 61 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index bc4c6dbd5aa3..f1b519d20989 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -630,7 +630,7 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) phtpriv_sta->sgi = true; /* bwmode */ - if ((sta_cap_info & ap_cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) { + if ((sta_cap_info & ap_cap_info) & IEEE80211_HT_CAP_SUP_WIDTH_20_40) { phtpriv_sta->bwmode = pmlmeext->cur_bwmode; phtpriv_sta->ch_offset = pmlmeext->cur_ch_offset; } @@ -1015,12 +1015,12 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) if ((psecuritypriv->wpa_pairwise_cipher & WPA_CIPHER_CCMP) || (psecuritypriv->wpa2_pairwise_cipher & WPA_CIPHER_CCMP)) - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2)); else - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); /* set Max Rx AMPDU size to 64K */ - pht_cap->ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_FACTOR & 0x03); + pht_cap->ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_FACTOR & 0x03); if (rf_type == RF_1T1R) { pht_cap->mcs.rx_mask[0] = 0xff; @@ -1447,7 +1447,7 @@ static int rtw_ht_operation_update(struct adapter *padapter) (pmlmepriv->ht_op_mode & HT_INFO_OPERATION_MODE_NON_GF_DEVS_PRESENT)) new_op_mode = OP_MODE_MIXED; else if ((le16_to_cpu(phtpriv_ap->ht_cap.cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH) && + IEEE80211_HT_CAP_SUP_WIDTH_20_40) && pmlmepriv->num_sta_ht_20mhz) new_op_mode = OP_MODE_20MHZ_HT_STA_ASSOCED; else if (pmlmepriv->olbc_ht) @@ -1597,7 +1597,7 @@ void bss_cap_update_on_sta_join(struct adapter *padapter, struct sta_info *psta) pmlmepriv->num_sta_ht_no_gf); } - if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH) == 0) { + if ((ht_capab & IEEE80211_HT_CAP_SUP_WIDTH_20_40) == 0) { if (!psta->ht_20mhz_set) { psta->ht_20mhz_set = 1; pmlmepriv->num_sta_ht_20mhz++; diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 54d74b98ce47..d5ef5783f4ad 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -1997,7 +1997,7 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ memset(&ht_capie, 0, sizeof(struct ieee80211_ht_cap)); - ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH | + ht_capie.cap_info = cpu_to_le16(IEEE80211_HT_CAP_SUP_WIDTH_20_40 | IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40 | IEEE80211_HT_CAP_TX_STBC | @@ -2015,9 +2015,9 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ ht_capie.ampdu_params_info = (max_rx_ampdu_factor&0x03); if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) - ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&(0x07<<2)); + ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2)); else - ht_capie.ampdu_params_info |= (IEEE80211_HT_CAP_AMPDU_DENSITY&0x00); + ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); @@ -2068,7 +2068,7 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); if (p && len > 0) { pht_capie = (struct ieee80211_ht_cap *)(p+2); - max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_CAP_AMPDU_FACTOR); + max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ phtpriv->rx_ampdu_maxlen = max_ampdu_sz; } diff --git a/drivers/staging/r8188eu/include/wifi.h b/drivers/staging/r8188eu/include/wifi.h index f4212c4f4ada..0b3fd94cea18 100644 --- a/drivers/staging/r8188eu/include/wifi.h +++ b/drivers/staging/r8188eu/include/wifi.h @@ -597,10 +597,6 @@ struct rtw_ieee80211_bar { __le16 start_seq_num; } __packed; -/* 802.11 BAR control masks */ -#define IEEE80211_BAR_CTRL_ACK_POLICY_NORMAL 0x0000 -#define IEEE80211_BAR_CTRL_CBMTID_COMPRESSED_BA 0x0004 - /** * struct ieee80211_ht_cap - HT additional information * @@ -662,52 +658,6 @@ enum ht_cap_ampdu_factor { MAX_AMPDU_FACTOR_64K = 3, }; -/* 802.11n HT capabilities masks */ -#define IEEE80211_HT_CAP_SUP_WIDTH 0x0002 -#define IEEE80211_HT_CAP_SM_PS 0x000C -#define IEEE80211_HT_CAP_GRN_FLD 0x0010 -#define IEEE80211_HT_CAP_SGI_20 0x0020 -#define IEEE80211_HT_CAP_SGI_40 0x0040 -#define IEEE80211_HT_CAP_TX_STBC 0x0080 -#define IEEE80211_HT_CAP_RX_STBC 0x0300 -#define IEEE80211_HT_CAP_DELAY_BA 0x0400 -#define IEEE80211_HT_CAP_MAX_AMSDU 0x0800 -#define IEEE80211_HT_CAP_DSSSCCK40 0x1000 -/* 802.11n HT capability AMPDU settings */ -#define IEEE80211_HT_CAP_AMPDU_FACTOR 0x03 -#define IEEE80211_HT_CAP_AMPDU_DENSITY 0x1C -/* 802.11n HT capability MSC set */ -#define IEEE80211_SUPP_MCS_SET_UEQM 4 -#define IEEE80211_HT_CAP_MAX_STREAMS 4 -#define IEEE80211_SUPP_MCS_SET_LEN 10 -/* maximum streams the spec allows */ -#define IEEE80211_HT_CAP_MCS_TX_DEFINED 0x01 -#define IEEE80211_HT_CAP_MCS_TX_RX_DIFF 0x02 -#define IEEE80211_HT_CAP_MCS_TX_STREAMS 0x0C -#define IEEE80211_HT_CAP_MCS_TX_UEQM 0x10 -/* 802.11n HT IE masks */ -#define IEEE80211_HT_IE_CHA_SEC_OFFSET 0x03 -#define IEEE80211_HT_IE_CHA_SEC_NONE 0x00 -#define IEEE80211_HT_IE_CHA_SEC_ABOVE 0x01 -#define IEEE80211_HT_IE_CHA_SEC_BELOW 0x03 -#define IEEE80211_HT_IE_CHA_WIDTH 0x04 -#define IEEE80211_HT_IE_HT_PROTECTION 0x0003 -#define IEEE80211_HT_IE_NON_GF_STA_PRSNT 0x0004 -#define IEEE80211_HT_IE_NON_HT_STA_PRSNT 0x0010 - -/* block-ack parameters */ -#define IEEE80211_ADDBA_PARAM_POLICY_MASK 0x0002 -#define IEEE80211_ADDBA_PARAM_TID_MASK 0x003C -#define RTW_IEEE80211_ADDBA_PARAM_BUF_SIZE_MASK 0xFFC0 -#define IEEE80211_DELBA_PARAM_TID_MASK 0xF000 -#define IEEE80211_DELBA_PARAM_INITIATOR_MASK 0x0800 - -/* - * A-PMDU buffer sizes - * According to IEEE802.11n spec size varies from 8K to 64K (in powers of 2) - */ -#define IEEE80211_MIN_AMPDU_BUF 0x8 - /* Spatial Multiplexing Power Save Modes */ #define WLAN_HT_CAP_SM_PS_STATIC 0 #define WLAN_HT_CAP_SM_PS_DYNAMIC 1 diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index d9fdd83218dc..d40aaab48821 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -190,7 +190,7 @@ static char *translate_scan(struct adapter *padapter, pht_capie = (struct ieee80211_ht_cap *)(p+2); memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & - IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; + IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0; short_GI = (le16_to_cpu(pht_capie->cap_info) & (IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; } -- cgit v1.2.3 From cd40705f6b27313536836e4d3974873bf4e10247 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 16 Aug 2021 09:34:49 +0200 Subject: staging: r8188eu: remove inline markings from functions in rtw_br_ext.c The compiler is free to ignore, or follow, "inline" markings so they really have no use in .c files, so just remove them. This allows functions to properly show up as being unused when all callers to them are removed, otherwise gcc does not warn you about this. Acked-by: Phillip Potter Link: https://lore.kernel.org/r/20210816073450.668993-1-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 22737cd0fe44..fb2bb36f9e2c 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -49,7 +49,7 @@ -----------------------------------------------------------------*/ /* Find a tag in pppoe frame and return the pointer */ -static inline unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) +static unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsigned short type) { unsigned char *cur_ptr, *start_ptr; unsigned short tagLen, tagType; @@ -66,7 +66,7 @@ static inline unsigned char *__nat25_find_pppoe_tag(struct pppoe_hdr *ph, unsign return NULL; } -static inline int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) +static int __nat25_add_pppoe_tag(struct sk_buff *skb, struct pppoe_tag *tag) { struct pppoe_hdr *ph = (struct pppoe_hdr *)(skb->data + ETH_HLEN); int data_len; @@ -106,7 +106,7 @@ static int skb_pull_and_merge(struct sk_buff *skb, unsigned char *src, int len) return 0; } -static inline unsigned long __nat25_timeout(struct adapter *priv) +static unsigned long __nat25_timeout(struct adapter *priv) { unsigned long timeout; @@ -115,7 +115,7 @@ static inline unsigned long __nat25_timeout(struct adapter *priv) return timeout; } -static inline int __nat25_has_expired(struct adapter *priv, +static int __nat25_has_expired(struct adapter *priv, struct nat25_network_db_entry *fdb) { if (time_before_eq(fdb->ageing_timer, __nat25_timeout(priv))) @@ -124,7 +124,7 @@ static inline int __nat25_has_expired(struct adapter *priv, return 0; } -static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, +static void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, unsigned int *ipAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -133,7 +133,7 @@ static inline void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr memcpy(networkAddr+7, (unsigned char *)ipAddr, 4); } -static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, +static void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, __be32 *ipxNetAddr, unsigned char *ipxNodeAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -143,7 +143,7 @@ static inline void __nat25_generate_ipx_network_addr_with_node(unsigned char *ne memcpy(networkAddr+5, ipxNodeAddr, 6); } -static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, +static void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, __be32 *ipxNetAddr, __be16 *ipxSocketAddr) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -153,7 +153,7 @@ static inline void __nat25_generate_ipx_network_addr_with_socket(unsigned char * memcpy(networkAddr+5, ipxSocketAddr, 2); } -static inline void __nat25_generate_apple_network_addr(unsigned char *networkAddr, +static void __nat25_generate_apple_network_addr(unsigned char *networkAddr, __be16 *network, unsigned char *node) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -163,7 +163,7 @@ static inline void __nat25_generate_apple_network_addr(unsigned char *networkAdd networkAddr[3] = *node; } -static inline void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, +static void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, unsigned char *ac_mac, __be16 *sid) { memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); @@ -258,7 +258,7 @@ static int update_nd_link_layer_addr(unsigned char *data, int len, unsigned char return 0; } -static inline int __nat25_network_hash(unsigned char *networkAddr) +static int __nat25_network_hash(unsigned char *networkAddr) { if (networkAddr[0] == NAT25_IPV4) { unsigned long x; @@ -305,7 +305,7 @@ static inline int __nat25_network_hash(unsigned char *networkAddr) } } -static inline void __network_hash_link(struct adapter *priv, +static void __network_hash_link(struct adapter *priv, struct nat25_network_db_entry *ent, int hash) { /* Caller must spin_lock already! */ @@ -316,7 +316,7 @@ static inline void __network_hash_link(struct adapter *priv, ent->pprev_hash = &priv->nethash[hash]; } -static inline void __network_hash_unlink(struct nat25_network_db_entry *ent) +static void __network_hash_unlink(struct nat25_network_db_entry *ent) { /* Caller must spin_lock already! */ *ent->pprev_hash = ent->next_hash; -- cgit v1.2.3 From ff63261978ee1f00758f447d63276a6f180a81dc Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 16 Aug 2021 09:34:50 +0200 Subject: staging: r8188eu: remove ipx support from driver The ipx.h header files are being removed from the kernel, and support for them was long removed from the tree, so remove all references to it in the r8188eu driver as well, to allow it to continue to build properly in linux-next Reported-by: Stephen Rothwell Acked-by: Phillip Potter Link: https://lore.kernel.org/r/20210816073450.668993-2-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 228 ------------------------------ 1 file changed, 228 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index fb2bb36f9e2c..8be025992270 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -5,7 +5,6 @@ #include "../include/linux/if_arp.h" #include "../include/net/ip.h" -#include "../include/net/ipx.h" #include "../include/linux/atalk.h" #include "../include/linux/udp.h" #include "../include/linux/if_pppox.h" @@ -133,36 +132,6 @@ static void __nat25_generate_ipv4_network_addr(unsigned char *networkAddr, memcpy(networkAddr+7, (unsigned char *)ipAddr, 4); } -static void __nat25_generate_ipx_network_addr_with_node(unsigned char *networkAddr, - __be32 *ipxNetAddr, unsigned char *ipxNodeAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, ipxNetAddr, 4); - memcpy(networkAddr+5, ipxNodeAddr, 6); -} - -static void __nat25_generate_ipx_network_addr_with_socket(unsigned char *networkAddr, - __be32 *ipxNetAddr, __be16 *ipxSocketAddr) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_IPX; - memcpy(networkAddr+1, ipxNetAddr, 4); - memcpy(networkAddr+5, ipxSocketAddr, 2); -} - -static void __nat25_generate_apple_network_addr(unsigned char *networkAddr, - __be16 *network, unsigned char *node) -{ - memset(networkAddr, 0, MAX_NETWORK_ADDR_LEN); - - networkAddr[0] = NAT25_APPLE; - memcpy(networkAddr+1, network, 2); - networkAddr[3] = *node; -} - static void __nat25_generate_pppoe_network_addr(unsigned char *networkAddr, unsigned char *ac_mac, __be16 *sid) { @@ -584,203 +553,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) default: return -1; } - } else if ((protocol == ETH_P_IPX) || - (protocol <= ETH_FRAME_LEN)) { - /*---------------------------------------------------*/ - /* Handle IPX and Apple Talk frame */ - /*---------------------------------------------------*/ - unsigned char ipx_header[2] = {0xFF, 0xFF}; - struct ipxhdr *ipx = NULL; - struct elapaarp *ea = NULL; - struct ddpehdr *ddp = NULL; - unsigned char *framePtr = skb->data + ETH_HLEN; - - if (protocol == ETH_P_IPX) { - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet II)\n"); - ipx = (struct ipxhdr *)framePtr; - } else if (protocol <= ETH_FRAME_LEN) { - if (!memcmp(ipx_header, framePtr, 2)) { - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.3)\n"); - ipx = (struct ipxhdr *)framePtr; - } else { - unsigned char ipx_8022_type = 0xE0; - unsigned char snap_8022_type = 0xAA; - - if (*framePtr == snap_8022_type) { - unsigned char ipx_snap_id[5] = {0x0, 0x0, 0x0, 0x81, 0x37}; /* IPX SNAP ID */ - unsigned char aarp_snap_id[5] = {0x00, 0x00, 0x00, 0x80, 0xF3}; /* Apple Talk AARP SNAP ID */ - unsigned char ddp_snap_id[5] = {0x08, 0x00, 0x07, 0x80, 0x9B}; /* Apple Talk DDP SNAP ID */ - - framePtr += 3; /* eliminate the 802.2 header */ - - if (!memcmp(ipx_snap_id, framePtr, 5)) { - framePtr += 5; /* eliminate the SNAP header */ - - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet SNAP)\n"); - ipx = (struct ipxhdr *)framePtr; - } else if (!memcmp(aarp_snap_id, framePtr, 5)) { - framePtr += 5; /* eliminate the SNAP header */ - - ea = (struct elapaarp *)framePtr; - } else if (!memcmp(ddp_snap_id, framePtr, 5)) { - framePtr += 5; /* eliminate the SNAP header */ - - ddp = (struct ddpehdr *)framePtr; - } else { - DEBUG_WARN("NAT25: Protocol = Ethernet SNAP %02x%02x%02x%02x%02x\n", framePtr[0], - framePtr[1], framePtr[2], framePtr[3], framePtr[4]); - return -1; - } - } else if (*framePtr == ipx_8022_type) { - framePtr += 3; /* eliminate the 802.2 header */ - - if (!memcmp(ipx_header, framePtr, 2)) { - DEBUG_INFO("NAT25: Protocol = IPX (Ethernet 802.2)\n"); - ipx = (struct ipxhdr *)framePtr; - } else { - return -1; - } - } else { - return -1; - } - } - } else { - return -1; - } - - /* IPX */ - if (ipx) { - switch (method) { - case NAT25_CHECK: - if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) - DEBUG_INFO("NAT25: Check IPX skb_copy\n"); - return 0; - case NAT25_INSERT: - DEBUG_INFO("NAT25: Insert IPX, Dest =%08x,%02x%02x%02x%02x%02x%02x,%04x Source =%08x,%02x%02x%02x%02x%02x%02x,%04x\n", - ipx->ipx_dest.net, - ipx->ipx_dest.node[0], - ipx->ipx_dest.node[1], - ipx->ipx_dest.node[2], - ipx->ipx_dest.node[3], - ipx->ipx_dest.node[4], - ipx->ipx_dest.node[5], - ipx->ipx_dest.sock, - ipx->ipx_source.net, - ipx->ipx_source.node[0], - ipx->ipx_source.node[1], - ipx->ipx_source.node[2], - ipx->ipx_source.node[3], - ipx->ipx_source.node[4], - ipx->ipx_source.node[5], - ipx->ipx_source.sock); - - if (!memcmp(skb->data+ETH_ALEN, ipx->ipx_source.node, ETH_ALEN)) { - DEBUG_INFO("NAT25: Use IPX Net, and Socket as network addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_source.net, &ipx->ipx_source.sock); - - /* change IPX source node addr to wlan STA address */ - memcpy(ipx->ipx_source.node, GET_MY_HWADDR(priv), ETH_ALEN); - } else { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_source.net, ipx->ipx_source.node); - } - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - if (!memcmp(GET_MY_HWADDR(priv), ipx->ipx_dest.node, ETH_ALEN)) { - DEBUG_INFO("NAT25: Lookup IPX, Modify Destination IPX Node addr\n"); - - __nat25_generate_ipx_network_addr_with_socket(networkAddr, &ipx->ipx_dest.net, &ipx->ipx_dest.sock); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - /* replace IPX destination node addr with Lookup destination MAC addr */ - memcpy(ipx->ipx_dest.node, skb->data, ETH_ALEN); - } else { - __nat25_generate_ipx_network_addr_with_node(networkAddr, &ipx->ipx_dest.net, ipx->ipx_dest.node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - } - return 0; - default: - return -1; - } - } else if (ea) { - /* Sanity check fields. */ - if (ea->hw_len != ETH_ALEN || ea->pa_len != AARP_PA_ALEN) { - DEBUG_WARN("NAT25: Appletalk AARP Sanity check fail!\n"); - return -1; - } - - switch (method) { - case NAT25_CHECK: - return 0; - case NAT25_INSERT: - /* change to AARP source mac address to wlan STA address */ - memcpy(ea->hw_src, GET_MY_HWADDR(priv), ETH_ALEN); - - DEBUG_INFO("NAT25: Insert AARP, Source =%d,%d Destination =%d,%d\n", - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_src_net, &ea->pa_src_node); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup AARP, Source =%d,%d Destination =%d,%d\n", - ea->pa_src_net, - ea->pa_src_node, - ea->pa_dst_net, - ea->pa_dst_node); - - __nat25_generate_apple_network_addr(networkAddr, &ea->pa_dst_net, &ea->pa_dst_node); - - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - - /* change to AARP destination mac address to Lookup result */ - memcpy(ea->hw_dst, skb->data, ETH_ALEN); - return 0; - default: - return -1; - } - } else if (ddp) { - switch (method) { - case NAT25_CHECK: - return -1; - case NAT25_INSERT: - DEBUG_INFO("NAT25: Insert DDP, Source =%d,%d Destination =%d,%d\n", - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); - - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_snet, &ddp->deh_snode); - - __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); - - __nat25_db_print(priv); - return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup DDP, Source =%d,%d Destination =%d,%d\n", - ddp->deh_snet, - ddp->deh_snode, - ddp->deh_dnet, - ddp->deh_dnode); - __nat25_generate_apple_network_addr(networkAddr, &ddp->deh_dnet, &ddp->deh_dnode); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - return 0; - default: - return -1; - } - } - - return -1; } else if ((protocol == ETH_P_PPP_DISC) || (protocol == ETH_P_PPP_SES)) { /*---------------------------------------------------*/ -- cgit v1.2.3 From 9caf92ab573fd83c7455b65d4eefcefc1a9d2188 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Mon, 16 Aug 2021 18:06:15 +0200 Subject: staging: r8188eu: Remove unused nat25_handle_frame() Remove nat25_handle_frame() because it is not called by any other function of the driver. Acked-by: Michael Straube Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210816160617.11949-2-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 61 ---------------------------- drivers/staging/r8188eu/include/recv_osdep.h | 1 - 2 files changed, 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index 8be025992270..e8eea95a52e3 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -791,67 +791,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) return -1; } -int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb) -{ - if (!(skb->data[0] & 1)) { - int is_vlan_tag = 0, i, retval = 0; - unsigned short vlan_hdr = 0; - unsigned short protocol; - - protocol = be16_to_cpu(*((__be16 *)(skb->data + 2 * ETH_ALEN))); - if (protocol == ETH_P_8021Q) { - is_vlan_tag = 1; - vlan_hdr = *((unsigned short *)(skb->data+ETH_ALEN*2+2)); - for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data+ETH_ALEN*2+2-i*2)) = *((unsigned short *)(skb->data+ETH_ALEN*2-2-i*2)); - skb_pull(skb, 4); - } - - if (!priv->ethBrExtInfo.nat25_disable) { - spin_lock_bh(&priv->br_ext_lock); - /* - * This function look up the destination network address from - * the NAT2.5 database. Return value = -1 means that the - * corresponding network protocol is NOT support. - */ - if (!priv->ethBrExtInfo.nat25sc_disable && - (be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && - !memcmp(priv->scdb_ip, skb->data+ETH_HLEN+16, 4)) { - memcpy(skb->data, priv->scdb_mac, ETH_ALEN); - - spin_unlock_bh(&priv->br_ext_lock); - } else { - spin_unlock_bh(&priv->br_ext_lock); - - retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); - } - } else { - if (((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_IP) && - !memcmp(priv->br_ip, skb->data+ETH_HLEN+16, 4)) || - ((be16_to_cpu(*((__be16 *)(skb->data+ETH_ALEN*2))) == ETH_P_ARP) && - !memcmp(priv->br_ip, skb->data+ETH_HLEN+24, 4))) { - /* for traffic to upper TCP/IP */ - retval = nat25_db_handle(priv, skb, NAT25_LOOKUP); - } - } - - if (is_vlan_tag) { - skb_push(skb, 4); - for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); - *((__be16 *)(skb->data+ETH_ALEN*2)) = __constant_htons(ETH_P_8021Q); - *((unsigned short *)(skb->data+ETH_ALEN*2+2)) = vlan_hdr; - } - - if (retval == -1) { - /* DEBUG_ERR("NAT25: Lookup fail!\n"); */ - return -1; - } - } - - return 0; -} - #define SERVER_PORT 67 #define CLIENT_PORT 68 #define DHCP_MAGIC 0x63825363 diff --git a/drivers/staging/r8188eu/include/recv_osdep.h b/drivers/staging/r8188eu/include/recv_osdep.h index 7308f21c428f..72ddf515071e 100644 --- a/drivers/staging/r8188eu/include/recv_osdep.h +++ b/drivers/staging/r8188eu/include/recv_osdep.h @@ -30,7 +30,6 @@ int rtw_os_recvbuf_resource_free(struct adapter *adapt, struct recv_buf *buf); void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf); void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl); -int nat25_handle_frame(struct adapter *priv, struct sk_buff *skb); int _netdev_open(struct net_device *pnetdev); int netdev_open(struct net_device *pnetdev); int netdev_close(struct net_device *pnetdev); -- cgit v1.2.3 From 8694ef2d90b221cbe7ee67e1edc04414c05999ca Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:57:56 +0200 Subject: staging: r8188eu: add spaces around operators in core/rtw_ap.c Add missing spaces around operators in core/rtw_ap.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 88 +++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index f1b519d20989..8ef0586b753f 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -69,7 +69,7 @@ static void update_BCNTIM(struct adapter *padapter) p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, _TIM_IE_, &tim_ielen, pnetwork_mlmeext->IELength - _FIXED_IE_LENGTH_); if (p && tim_ielen > 0) { tim_ielen += 2; - premainder_ie = p+tim_ielen; + premainder_ie = p + tim_ielen; tim_ie_offset = (int)(p - pie); remainder_ielen = pnetwork_mlmeext->IELength - tim_ie_offset - tim_ielen; /* append TIM IE from dst_ie offset */ @@ -84,7 +84,7 @@ static void update_BCNTIM(struct adapter *padapter) /* get supported rates len */ p = rtw_get_ie(pie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &tmp_len, (pnetwork_mlmeext->IELength - _BEACON_IE_OFFSET_)); if (p) - offset += tmp_len+2; + offset += tmp_len + 2; /* DS Parameter Set IE, len = 3 */ offset += 3; @@ -104,7 +104,7 @@ static void update_BCNTIM(struct adapter *padapter) } *dst_ie++ = _TIM_IE_; - if ((pstapriv->tim_bitmap&0xff00) && (pstapriv->tim_bitmap&0x00fc)) + if ((pstapriv->tim_bitmap & 0xff00) && (pstapriv->tim_bitmap & 0x00fc)) tim_ielen = 5; else tim_ielen = 4; @@ -114,7 +114,7 @@ static void update_BCNTIM(struct adapter *padapter) *dst_ie++ = 0;/* DTIM count */ *dst_ie++ = 1;/* DTIM period */ - if (pstapriv->tim_bitmap&BIT(0))/* for bc/mc frames */ + if (pstapriv->tim_bitmap & BIT(0))/* for bc/mc frames */ *dst_ie++ = BIT(0);/* bitmap ctrl */ else *dst_ie++ = 0; @@ -167,7 +167,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 if (p && ielen > 0) { ielen += 2; - premainder_ie = p+ielen; + premainder_ie = p + ielen; ie_offset = (int)(p - pie); @@ -176,7 +176,7 @@ void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 if (bmatch) dst_ie = p; else - dst_ie = (p+ielen); + dst_ie = (p + ielen); } if (remainder_ielen > 0) { @@ -214,7 +214,7 @@ void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, if (p && ielen > 0) { ielen += 2; - premainder_ie = p+ielen; + premainder_ie = p + ielen; ie_offset = (int)(p - pie); @@ -355,8 +355,8 @@ void expire_timeout_chk(struct adapter *padapter) updated = ap_free_sta(padapter, psta, true, WLAN_REASON_DEAUTH_LEAVING); } else { /* TODO: Aging mechanism to digest frames in sleep_q to avoid running out of xmitframe */ - if (psta->sleepq_len > (NR_XMITFRAME/pstapriv->asoc_list_cnt) && - padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME/pstapriv->asoc_list_cnt/2)) { + if (psta->sleepq_len > (NR_XMITFRAME / pstapriv->asoc_list_cnt) && + padapter->xmitpriv.free_xmitframe_cnt < (NR_XMITFRAME / pstapriv->asoc_list_cnt / 2)) { DBG_88E("%s sta:%pM, sleepq_len:%u, free_xmitframe_cnt:%u, asoc_list_cnt:%u, clear sleep_q\n", __func__, (psta->hwaddr), psta->sleepq_len, padapter->xmitpriv.free_xmitframe_cnt, @@ -440,7 +440,7 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) /* b/g mode ra_bitmap */ for (i = 0; i < sizeof(psta->bssrateset); i++) { if (psta->bssrateset[i]) - tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f); } /* n mode ra_bitmap */ if (psta_ht->ht_option) { @@ -451,8 +451,8 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) limit = 8;/* 1R */ for (i = 0; i < limit; i++) { - if (psta_ht->ht_cap.mcs.rx_mask[i/8] & BIT(i%8)) - tx_ra_bitmap |= BIT(i+12); + if (psta_ht->ht_cap.mcs.rx_mask[i / 8] & BIT(i % 8)) + tx_ra_bitmap |= BIT(i + 12); } /* max short GI rate */ @@ -473,19 +473,19 @@ void add_RATid(struct adapter *padapter, struct sta_info *psta, u8 rssi_level) psta->wireless_mode = sta_band; raid = networktype_to_raid(sta_band); - init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f; if (psta->aid < NUM_STA) { u8 arg = 0; - arg = psta->mac_id&0x1f; + arg = psta->mac_id & 0x1f; arg |= BIT(7);/* support entry 2~31 */ if (shortGIrate) arg |= BIT(5); - tx_ra_bitmap |= ((raid<<28)&0xf0000000); + tx_ra_bitmap |= ((raid << 28) & 0xf0000000); DBG_88E("%s => mac_id:%d , raid:%d , bitmap = 0x%x, arg = 0x%x\n", __func__, psta->mac_id, raid, tx_ra_bitmap, arg); @@ -539,7 +539,7 @@ void update_bmc_sta(struct adapter *padapter) /* b/g mode ra_bitmap */ for (i = 0; i < supportRateNum; i++) { if (psta->bssrateset[i]) - tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i]&0x7f); + tx_ra_bitmap |= rtw_get_bit_value_from_ieee_value(psta->bssrateset[i] & 0x7f); } if (pcur_network->Configuration.DSConfig > 14) { @@ -551,7 +551,7 @@ void update_bmc_sta(struct adapter *padapter) } raid = networktype_to_raid(network_type); - init_rate = get_highest_rate_idx(tx_ra_bitmap&0x0fffffff)&0x3f; + init_rate = get_highest_rate_idx(tx_ra_bitmap & 0x0fffffff) & 0x3f; /* ap mode */ rtw_hal_set_odm_var(padapter, HAL_ODM_STA_INFO, psta, true); @@ -559,9 +559,9 @@ void update_bmc_sta(struct adapter *padapter) { u8 arg = 0; - arg = psta->mac_id&0x1f; + arg = psta->mac_id & 0x1f; arg |= BIT(7); - tx_ra_bitmap |= ((raid<<28)&0xf0000000); + tx_ra_bitmap |= ((raid << 28) & 0xf0000000); DBG_88E("update_bmc_sta, mask = 0x%x, arg = 0x%x\n", tx_ra_bitmap, arg); /* bitmap[0:27] = tx_rate_bitmap */ @@ -602,7 +602,7 @@ void update_sta_info_apmode(struct adapter *padapter, struct sta_info *psta) u16 sta_cap_info; u16 ap_cap_info; - psta->mac_id = psta->aid+1; + psta->mac_id = psta->aid + 1; DBG_88E("%s\n", __func__); /* ap mode */ @@ -716,7 +716,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) /* check if there is wps ie, */ /* if there is wpsie in beacon, the hostapd will update beacon twice when stating hostapd, */ /* and at first time the security ie (RSN/WPA IE) will not include in beacon. */ - if (!rtw_get_wps_ie(pnetwork->IEs+_FIXED_IE_LENGTH_, pnetwork->IELength-_FIXED_IE_LENGTH_, NULL, NULL)) + if (!rtw_get_wps_ie(pnetwork->IEs + _FIXED_IE_LENGTH_, pnetwork->IELength - _FIXED_IE_LENGTH_, NULL, NULL)) pmlmeext->bstart_bss = true; /* todo: update wmm, ht cap */ @@ -769,7 +769,7 @@ static void start_bss_network(struct adapter *padapter, u8 *pbuf) /* set channel, bwmode */ p = rtw_get_ie((pnetwork->IEs + sizeof(struct ndis_802_11_fixed_ie)), _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - sizeof(struct ndis_802_11_fixed_ie))); if (p && ie_len) { - pht_info = (struct HT_info_element *)(p+2); + pht_info = (struct HT_info_element *)(p + 2); if ((pregpriv->cbw40_enable) && (pht_info->infos[0] & BIT(2))) { /* switch to the 40M Hz mode */ @@ -904,14 +904,14 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) /* get supported rates */ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p) { - memcpy(supportRate, p+2, ie_len); + memcpy(supportRate, p + 2, ie_len); supportRateNum = ie_len; } /* get ext_supported rates */ p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->IELength - _BEACON_IE_OFFSET_); if (p) { - memcpy(supportRate+supportRateNum, p+2, ie_len); + memcpy(supportRate + supportRateNum, p + 2, ie_len); supportRateNum += ie_len; } @@ -939,7 +939,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) psecuritypriv->wpa2_pairwise_cipher = _NO_PRIVACY_; p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _RSN_IE_2_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { - if (rtw_parse_wpa2_ie(p, ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa2_ie(p, ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; psecuritypriv->dot8021xalg = 1;/* psk, todo:802.1x */ @@ -958,8 +958,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { p = rtw_get_ie(p, _SSN_IE_1_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && (!memcmp(p+2, OUI1, 4))) { - if (rtw_parse_wpa_ie(p, ie_len+2, &group_cipher, + if ((p) && (!memcmp(p + 2, OUI1, 4))) { + if (rtw_parse_wpa_ie(p, ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { psecuritypriv->dot11AuthAlgrthm = dot11AuthAlgrthm_8021X; @@ -983,10 +983,10 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) for (p = ie + _BEACON_IE_OFFSET_;; p += (ie_len + 2)) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, (pbss_network->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if ((p) && !memcmp(p+2, WMM_PARA_IE, 6)) { + if ((p) && !memcmp(p + 2, WMM_PARA_IE, 6)) { pmlmepriv->qospriv.qos_option = 1; - *(p+8) |= BIT(7);/* QoS Info, support U-APSD */ + *(p + 8) |= BIT(7);/* QoS Info, support U-APSD */ /* disable all ACM bits since the WMM admission control is not supported */ *(p + 10) &= ~BIT(4); /* BE */ @@ -1005,7 +1005,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) (pbss_network->IELength - _BEACON_IE_OFFSET_)); if (p && ie_len > 0) { u8 rf_type; - struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p+2); + struct ieee80211_ht_cap *pht_cap = (struct ieee80211_ht_cap *)(p + 2); pHT_caps_ie = p; ht_cap = true; @@ -1026,7 +1026,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) pht_cap->mcs.rx_mask[0] = 0xff; pht_cap->mcs.rx_mask[1] = 0x0; } - memcpy(&pmlmepriv->htpriv.ht_cap, p+2, ie_len); + memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); } /* parsing HT_INFO_IE */ @@ -1113,7 +1113,7 @@ int rtw_acl_add_sta(struct adapter *padapter, u8 *addr) DBG_88E("%s(acl_num =%d) =%pM\n", __func__, pacl_list->num, (addr)); - if ((NUM_ACL-1) < pacl_list->num) + if ((NUM_ACL - 1) < pacl_list->num) return -1; spin_lock_bh(&pacl_node_q->lock); @@ -1229,9 +1229,9 @@ static void update_bcn_erpinfo_ie(struct adapter *padapter) struct ndis_802_11_var_ie *pIE = (struct ndis_802_11_var_ie *)p; if (pmlmepriv->num_sta_non_erp == 1) - pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION; + pIE->data[0] |= RTW_ERP_INFO_NON_ERP_PRESENT | RTW_ERP_INFO_USE_PROTECTION; else - pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT|RTW_ERP_INFO_USE_PROTECTION); + pIE->data[0] &= ~(RTW_ERP_INFO_NON_ERP_PRESENT | RTW_ERP_INFO_USE_PROTECTION); if (pmlmepriv->num_sta_no_short_preamble > 0) pIE->data[0] |= RTW_ERP_INFO_BARKER_PREAMBLE_MODE; @@ -1281,12 +1281,12 @@ static void update_bcn_wps_ie(struct adapter *padapter) DBG_88E("%s\n", __func__); - pwps_ie = rtw_get_wps_ie(ie+_FIXED_IE_LENGTH_, ielen-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + pwps_ie = rtw_get_wps_ie(ie + _FIXED_IE_LENGTH_, ielen - _FIXED_IE_LENGTH_, NULL, &wps_ielen); if (!pwps_ie || wps_ielen == 0) return; - wps_offset = (uint)(pwps_ie-ie); + wps_offset = (uint)(pwps_ie - ie); premainder_ie = pwps_ie + wps_ielen; @@ -1303,15 +1303,15 @@ static void update_bcn_wps_ie(struct adapter *padapter) return; wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ - if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { - memcpy(pwps_ie, pwps_ie_src, wps_ielen+2); - pwps_ie += (wps_ielen+2); + if ((wps_offset + wps_ielen + 2 + remainder_ielen) <= MAX_IE_SZ) { + memcpy(pwps_ie, pwps_ie_src, wps_ielen + 2); + pwps_ie += (wps_ielen + 2); if (pbackup_remainder_ie) memcpy(pwps_ie, pbackup_remainder_ie, remainder_ielen); /* update IELength */ - pnetwork->IELength = wps_offset + (wps_ielen+2) + remainder_ielen; + pnetwork->IELength = wps_offset + (wps_ielen + 2) + remainder_ielen; } if (pbackup_remainder_ie) @@ -1744,7 +1744,7 @@ int rtw_ap_inform_ch_switch(struct adapter *padapter, u8 new_ch, u8 ch_offset) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u8 bc_addr[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return ret; DBG_88E(FUNC_NDEV_FMT" with ch:%u, offset:%u\n", @@ -1781,7 +1781,7 @@ int rtw_sta_flush(struct adapter *padapter) DBG_88E(FUNC_NDEV_FMT"\n", FUNC_NDEV_ARG(padapter->pnetdev)); - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return ret; spin_lock_bh(&pstapriv->asoc_list_lock); @@ -1815,7 +1815,7 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; /* update wmm cap. */ - if (WLAN_STA_WME&flags) + if (WLAN_STA_WME & flags) psta->qos_option = 1; else psta->qos_option = 0; @@ -1824,7 +1824,7 @@ void sta_info_update(struct adapter *padapter, struct sta_info *psta) psta->qos_option = 0; /* update 802.11n ht cap. */ - if (WLAN_STA_HT&flags) { + if (WLAN_STA_HT & flags) { psta->htpriv.ht_option = true; psta->qos_option = 1; } else { -- cgit v1.2.3 From f1249cfdb35854d1a29b825f53a73cde8ed2b2a2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:57:57 +0200 Subject: staging: r8188eu: rewrite subtraction in core/rtw_cmd.c Rewrite subtraction in core/rtw_cmd.c to clear missing spaces around operator reported by checkpatch. 256-1 -> 255 Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index e95cb27516b0..ff6c5fa71101 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -832,10 +832,10 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; - if ((psecnetwork->IELength-12) < (256-1)) { + if ((psecnetwork->IELength-12) < 255) { memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); } else { - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], (256-1)); + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], 255); } psecnetwork->IELength = 0; -- cgit v1.2.3 From 8ccacd41b6d6f7f06fa1a4f602c8fd3e6ad51237 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:57:58 +0200 Subject: staging: r8188eu: remove unnecessary parentheses in core/rtw_cmd.c Remove unnecessary parentheses in core/rtw_cmd.c. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index ff6c5fa71101..65ca4a2895f8 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -832,7 +832,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; - if ((psecnetwork->IELength-12) < 255) { + if (psecnetwork->IELength-12 < 255) { memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); } else { memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], 255); -- cgit v1.2.3 From 575da340cdb6aa9b4aa331d95c8a470ea976fe0f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:57:59 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_cmd.c Clean up spacing style issues in core/rtw_cmd.c reported by checkpatch. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 65ca4a2895f8..7c640c8148f6 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -16,7 +16,7 @@ Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. No irqsave is necessary. */ -int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) +int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { int res = _SUCCESS; @@ -38,7 +38,7 @@ int _rtw_init_cmd_priv (struct cmd_priv *pcmdpriv) goto exit; } - pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ-1)); + pcmdpriv->cmd_buf = pcmdpriv->cmd_allocated_buf + CMDBUFF_ALIGN_SZ - ((size_t)(pcmdpriv->cmd_allocated_buf) & (CMDBUFF_ALIGN_SZ - 1)); pcmdpriv->rsp_allocated_buf = kzalloc(MAX_RSPSZ + 4, GFP_KERNEL); @@ -69,7 +69,7 @@ int _rtw_init_evt_priv(struct evt_priv *pevtpriv) _init_workitem(&pevtpriv->c2h_wk, c2h_wk_callback, NULL); pevtpriv->c2h_wk_alive = false; - pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN+1); + pevtpriv->c2h_queue = rtw_cbuf_alloc(C2H_QUEUE_MAX_LEN + 1); return res; } @@ -87,7 +87,7 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) } } -void _rtw_free_cmd_priv (struct cmd_priv *pcmdpriv) +void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) { if (pcmdpriv) { @@ -149,12 +149,12 @@ u32 rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { u32 res; - res = _rtw_init_cmd_priv (pcmdpriv); + res = _rtw_init_cmd_priv(pcmdpriv); return res; } -u32 rtw_init_evt_priv (struct evt_priv *pevtpriv) +u32 rtw_init_evt_priv(struct evt_priv *pevtpriv) { int res; @@ -801,7 +801,7 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) t_len = sizeof(struct wlan_bssid_ex); /* for hidden ap to set fw_state here */ - if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) { switch (ndis_network_mode) { case Ndis802_11IBSS: set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); @@ -832,8 +832,8 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecuritypriv->authenticator_ie[0] = (unsigned char)psecnetwork->IELength; - if (psecnetwork->IELength-12 < 255) { - memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength-12); + if (psecnetwork->IELength - 12 < 255) { + memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], psecnetwork->IELength - 12); } else { memcpy(&psecuritypriv->authenticator_ie[1], &psecnetwork->IEs[12], 255); } @@ -1010,7 +1010,7 @@ u8 rtw_setstakey_cmd(struct adapter *padapter, u8 *psta, u8 unicast_key) memcpy(psetstakey_para->addr, sta->hwaddr, ETH_ALEN); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) - psetstakey_para->algorithm = (unsigned char) psecuritypriv->dot11PrivacyAlgrthm; + psetstakey_para->algorithm = (unsigned char)psecuritypriv->dot11PrivacyAlgrthm; else GET_ENCRY_ALGO(psecuritypriv, sta, psetstakey_para->algorithm, false); -- cgit v1.2.3 From 2d8f67a53a2a2b82a33ff71f0fa310a3dae9f3f1 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:00 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_efuse.c Clean up spacing style issues in core/rtw_efuse.c reported by checkpatch. CHECK: spaces preferred around that ... WARNING: space prohibited before semicolon Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-6-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_efuse.c | 96 ++++++++++++++++---------------- 1 file changed, 48 insertions(+), 48 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index 6e790f529d61..decccf7622f0 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -46,7 +46,7 @@ Efuse_Read1ByteFromFakeContent( if (fakeEfuseBank == 0) *Value = fakeEfuseContent[Offset]; else - *Value = fakeBTEfuseContent[fakeEfuseBank-1][Offset]; + *Value = fakeBTEfuseContent[fakeEfuseBank - 1][Offset]; return true; } @@ -61,7 +61,7 @@ Efuse_Write1ByteToFakeContent( if (fakeEfuseBank == 0) { fakeEfuseContent[Offset] = Value; } else { - fakeBTEfuseContent[fakeEfuseBank-1][Offset] = Value; + fakeBTEfuseContent[fakeEfuseBank - 1][Offset] = Value; } return true; } @@ -166,13 +166,13 @@ ReadEFuseByte( } /* Write Address */ - rtw_write8(Adapter, EFUSE_CTRL+1, (_offset & 0xff)); - readbyte = rtw_read8(Adapter, EFUSE_CTRL+2); - rtw_write8(Adapter, EFUSE_CTRL+2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); + rtw_write8(Adapter, EFUSE_CTRL + 1, (_offset & 0xff)); + readbyte = rtw_read8(Adapter, EFUSE_CTRL + 2); + rtw_write8(Adapter, EFUSE_CTRL + 2, ((_offset >> 8) & 0x03) | (readbyte & 0xfc)); /* Write bit 32 0 */ - readbyte = rtw_read8(Adapter, EFUSE_CTRL+3); - rtw_write8(Adapter, EFUSE_CTRL+3, (readbyte & 0x7f)); + readbyte = rtw_read8(Adapter, EFUSE_CTRL + 3); + rtw_write8(Adapter, EFUSE_CTRL + 3, (readbyte & 0x7f)); /* Check bit 32 read-ready */ retry = 0; @@ -250,21 +250,21 @@ u8 EFUSE_Read1Byte(struct adapter *Adapter, u16 Address) if (Address < contentLen) { /* E-fuse 512Byte */ /* Write E-fuse Register address bit0~7 */ temp = Address & 0xFF; - rtw_write8(Adapter, EFUSE_CTRL+1, temp); - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+2); + rtw_write8(Adapter, EFUSE_CTRL + 1, temp); + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 2); /* Write E-fuse Register address bit8~9 */ temp = ((Address >> 8) & 0x03) | (Bytetemp & 0xFC); - rtw_write8(Adapter, EFUSE_CTRL+2, temp); + rtw_write8(Adapter, EFUSE_CTRL + 2, temp); /* Write 0x30[31]= 0 */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 3); temp = Bytetemp & 0x7F; - rtw_write8(Adapter, EFUSE_CTRL+3, temp); + rtw_write8(Adapter, EFUSE_CTRL + 3, temp); /* Wait Write-ready (0x30[31]= 1) */ - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 3); while (!(Bytetemp & 0x80)) { - Bytetemp = rtw_read8(Adapter, EFUSE_CTRL+3); + Bytetemp = rtw_read8(Adapter, EFUSE_CTRL + 3); k++; if (k == 1000) { k = 0; @@ -291,13 +291,13 @@ u8 efuse_OneByteRead(struct adapter *pAdapter, u16 addr, u8 *data, bool pseudo) } /* -----------------e-fuse reg ctrl --------------------------------- */ /* address */ - rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr & 0xff)); - rtw_write8(pAdapter, EFUSE_CTRL+2, ((u8)((addr>>8) & 0x03)) | - (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC)); + rtw_write8(pAdapter, EFUSE_CTRL + 1, (u8)(addr & 0xff)); + rtw_write8(pAdapter, EFUSE_CTRL + 2, ((u8)((addr >> 8) & 0x03)) | + (rtw_read8(pAdapter, EFUSE_CTRL + 2) & 0xFC)); - rtw_write8(pAdapter, EFUSE_CTRL+3, 0x72);/* read cmd */ + rtw_write8(pAdapter, EFUSE_CTRL + 3, 0x72);/* read cmd */ - while (!(0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + while (!(0x80 & rtw_read8(pAdapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) { *data = rtw_read8(pAdapter, EFUSE_CTRL); @@ -322,15 +322,15 @@ u8 efuse_OneByteWrite(struct adapter *pAdapter, u16 addr, u8 data, bool pseudo) /* -----------------e-fuse reg ctrl --------------------------------- */ /* address */ - rtw_write8(pAdapter, EFUSE_CTRL+1, (u8)(addr&0xff)); - rtw_write8(pAdapter, EFUSE_CTRL+2, - (rtw_read8(pAdapter, EFUSE_CTRL+2) & 0xFC) | - (u8)((addr>>8) & 0x03)); + rtw_write8(pAdapter, EFUSE_CTRL + 1, (u8)(addr & 0xff)); + rtw_write8(pAdapter, EFUSE_CTRL + 2, + (rtw_read8(pAdapter, EFUSE_CTRL + 2) & 0xFC) | + (u8)((addr >> 8) & 0x03)); rtw_write8(pAdapter, EFUSE_CTRL, data);/* data */ - rtw_write8(pAdapter, EFUSE_CTRL+3, 0xF2);/* write cmd */ + rtw_write8(pAdapter, EFUSE_CTRL + 3, 0xF2);/* write cmd */ - while ((0x80 & rtw_read8(pAdapter, EFUSE_CTRL+3)) && (tmpidx < 100)) + while ((0x80 & rtw_read8(pAdapter, EFUSE_CTRL + 3)) && (tmpidx < 100)) tmpidx++; if (tmpidx < 100) @@ -387,19 +387,19 @@ static int Efuse_PgPacketWrite_BT(struct adapter *pAdapter, u8 offset, u8 word_e *---------------------------------------------------------------------------*/ void efuse_WordEnableDataRead(u8 word_en, u8 *sourdata, u8 *targetdata) { - if (!(word_en&BIT(0))) { + if (!(word_en & BIT(0))) { targetdata[0] = sourdata[0]; targetdata[1] = sourdata[1]; } - if (!(word_en&BIT(1))) { + if (!(word_en & BIT(1))) { targetdata[2] = sourdata[2]; targetdata[3] = sourdata[3]; } - if (!(word_en&BIT(2))) { + if (!(word_en & BIT(2))) { targetdata[4] = sourdata[4]; targetdata[5] = sourdata[5]; } - if (!(word_en&BIT(3))) { + if (!(word_en & BIT(3))) { targetdata[6] = sourdata[6]; targetdata[7] = sourdata[7]; } @@ -431,7 +431,7 @@ u8 rtw_efuse_access(struct adapter *padapter, u8 write, u16 start_addr, u16 cnts { int i = 0; u16 real_content_len = 0, max_available_size = 0; - u8 res = _FAIL ; + u8 res = _FAIL; u8 (*rw8)(struct adapter *, u16, u8*); EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_REAL_CONTENT_LEN, (void *)&real_content_len, false); @@ -551,9 +551,9 @@ u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) if (i & 0x1) { /* odd start */ - if (data[idx] != map[addr+idx]) { + if (data[idx] != map[addr + idx]) { word_en &= ~BIT(i >> 1); - newdata[i-1] = map[addr+idx-1]; + newdata[i - 1] = map[addr + idx - 1]; newdata[i] = data[idx]; } i++; @@ -564,19 +564,19 @@ u8 rtw_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data) if (cnts == idx) break; if ((cnts - idx) == 1) { - if (data[idx] != map[addr+idx]) { + if (data[idx] != map[addr + idx]) { word_en &= ~BIT(i >> 1); newdata[i] = data[idx]; - newdata[i+1] = map[addr+idx+1]; + newdata[i + 1] = map[addr + idx + 1]; } idx++; break; } else { - if ((data[idx] != map[addr+idx]) || - (data[idx+1] != map[addr+idx+1])) { + if ((data[idx] != map[addr + idx]) || + (data[idx + 1] != map[addr + idx + 1])) { word_en &= ~BIT(i >> 1); newdata[i] = data[idx]; - newdata[i+1] = data[idx + 1]; + newdata[i + 1] = data[idx + 1]; } idx += 2; } @@ -643,9 +643,9 @@ u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data if (i & 0x1) { /* odd start */ - if (data[idx] != map[addr+idx]) { + if (data[idx] != map[addr + idx]) { word_en &= ~BIT(i >> 1); - newdata[i-1] = map[addr+idx-1]; + newdata[i - 1] = map[addr + idx - 1]; newdata[i] = data[idx]; } i++; @@ -656,19 +656,19 @@ u8 rtw_BT_efuse_map_write(struct adapter *padapter, u16 addr, u16 cnts, u8 *data if (cnts == idx) break; if ((cnts - idx) == 1) { - if (data[idx] != map[addr+idx]) { + if (data[idx] != map[addr + idx]) { word_en &= ~BIT(i >> 1); newdata[i] = data[idx]; - newdata[i+1] = map[addr+idx+1]; + newdata[i + 1] = map[addr + idx + 1]; } idx++; break; } else { - if ((data[idx] != map[addr+idx]) || - (data[idx+1] != map[addr+idx+1])) { + if ((data[idx] != map[addr + idx]) || + (data[idx + 1] != map[addr + idx + 1])) { word_en &= ~BIT(i >> 1); newdata[i] = data[idx]; - newdata[i+1] = data[idx + 1]; + newdata[i + 1] = data[idx + 1]; } idx += 2; } @@ -747,7 +747,7 @@ efuse_ShadowRead2Byte( struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); *Value = pEEPROM->efuse_eeprom_data[Offset]; - *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; + *Value |= pEEPROM->efuse_eeprom_data[Offset + 1] << 8; } /* EFUSE_ShadowRead2Byte */ @@ -761,9 +761,9 @@ efuse_ShadowRead4Byte( struct eeprom_priv *pEEPROM = GET_EEPROM_EFUSE_PRIV(pAdapter); *Value = pEEPROM->efuse_eeprom_data[Offset]; - *Value |= pEEPROM->efuse_eeprom_data[Offset+1]<<8; - *Value |= pEEPROM->efuse_eeprom_data[Offset+2]<<16; - *Value |= pEEPROM->efuse_eeprom_data[Offset+3]<<24; + *Value |= pEEPROM->efuse_eeprom_data[Offset + 1] << 8; + *Value |= pEEPROM->efuse_eeprom_data[Offset + 2] << 16; + *Value |= pEEPROM->efuse_eeprom_data[Offset + 3] << 24; } /* efuse_ShadowRead4Byte */ -- cgit v1.2.3 From 4842e46f703c484598cf055ae4bc108fdf4b26d6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:01 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_ieee80211.c Clean up spacing style issues in core/rtw_ieee80211.c reported by checkpatch. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-7-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ieee80211.c | 124 +++++++++++++-------------- 1 file changed, 62 insertions(+), 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index 0c7231cefdda..add97664510c 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -140,7 +140,7 @@ u8 *rtw_set_ie return pbuf + len + 2; } -inline u8 *rtw_set_ie_ch_switch (u8 *buf, u32 *buf_len, u8 ch_switch_mode, +inline u8 *rtw_set_ie_ch_switch(u8 *buf, u32 *buf_len, u8 ch_switch_mode, u8 new_ch, u8 ch_switch_cnt) { u8 ie_data[3]; @@ -187,8 +187,8 @@ inline u8 *rtw_set_ie_mesh_ch_switch_parm(u8 *buf, u32 *buf_len, u8 ttl, ie_data[0] = ttl; ie_data[1] = flags; - *(u16 *)(ie_data+2) = cpu_to_le16(reason); - *(u16 *)(ie_data+4) = cpu_to_le16(precedence); + *(u16 *)(ie_data + 2) = cpu_to_le16(reason); + *(u16 *)(ie_data + 4) = cpu_to_le16(precedence); return rtw_set_ie(buf, 0x118, 6, ie_data, buf_len); } @@ -251,18 +251,18 @@ u8 *rtw_get_ie_ex(u8 *in_ie, uint in_len, u8 eid, u8 *oui, u8 oui_len, u8 *ie, u cnt = 0; while (cnt < in_len) { - if (eid == in_ie[cnt] && (!oui || !memcmp(&in_ie[cnt+2], oui, oui_len))) { + if (eid == in_ie[cnt] && (!oui || !memcmp(&in_ie[cnt + 2], oui, oui_len))) { target_ie = &in_ie[cnt]; if (ie) - memcpy(ie, &in_ie[cnt], in_ie[cnt+1]+2); + memcpy(ie, &in_ie[cnt], in_ie[cnt + 1] + 2); if (ielen) - *ielen = in_ie[cnt+1]+2; + *ielen = in_ie[cnt + 1] + 2; break; } else { - cnt += in_ie[cnt+1]+2; /* goto next */ + cnt += in_ie[cnt + 1] + 2; /* goto next */ } } return target_ie; @@ -427,7 +427,7 @@ unsigned char *rtw_get_wpa_ie(unsigned char *pie, int *wpa_ie_len, int limit) if (pbuf) { /* check if oui matches... */ - if (memcmp((pbuf + 2), wpa_oui_type, sizeof (wpa_oui_type))) + if (memcmp((pbuf + 2), wpa_oui_type, sizeof(wpa_oui_type))) goto check_next_ie; /* check version... */ @@ -503,8 +503,8 @@ int rtw_parse_wpa_ie(u8 *wpa_ie, int wpa_ie_len, int *group_cipher, int *pairwis return _FAIL; } - if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie+1) != (u8)(wpa_ie_len - 2)) || - (memcmp(wpa_ie+2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) + if ((*wpa_ie != _WPA_IE_ID_) || (*(wpa_ie + 1) != (u8)(wpa_ie_len - 2)) || + (memcmp(wpa_ie + 2, RTW_WPA_OUI_TYPE, WPA_SELECTOR_LEN))) return _FAIL; pos = wpa_ie; @@ -563,7 +563,7 @@ int rtw_parse_wpa2_ie(u8 *rsn_ie, int rsn_ie_len, int *group_cipher, int *pairwi return _FAIL; } - if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie+1) != (u8)(rsn_ie_len - 2))) + if ((*rsn_ie != _WPA2_IE_ID_) || (*(rsn_ie + 1) != (u8)(rsn_ie_len - 2))) return _FAIL; pos = rsn_ie; @@ -624,21 +624,21 @@ int rtw_get_sec_ie(u8 *in_ie, uint in_len, u8 *rsn_ie, u16 *rsn_len, u8 *wpa_ie, while (cnt < in_len) { authmode = in_ie[cnt]; - if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], &wpa_oui[0], 4))) { + if ((authmode == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], &wpa_oui[0], 4))) { if (wpa_ie) - memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt+1]+2); + memcpy(wpa_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - *wpa_len = in_ie[cnt+1]+2; - cnt += in_ie[cnt+1]+2; /* get next */ + *wpa_len = in_ie[cnt + 1] + 2; + cnt += in_ie[cnt + 1] + 2; /* get next */ } else { if (authmode == _WPA2_IE_ID_) { if (rsn_ie) - memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt+1]+2); + memcpy(rsn_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); - *rsn_len = in_ie[cnt+1]+2; - cnt += in_ie[cnt+1]+2; /* get next */ + *rsn_len = in_ie[cnt + 1] + 2; + cnt += in_ie[cnt + 1] + 2; /* get next */ } else { - cnt += in_ie[cnt+1]+2; /* get next */ + cnt += in_ie[cnt + 1] + 2; /* get next */ } } } @@ -657,7 +657,7 @@ u8 rtw_is_wps_ie(u8 *ie_ptr, uint *wps_ielen) eid = ie_ptr[0]; if ((eid == _WPA_IE_ID_) && (!memcmp(&ie_ptr[2], wps_oui, 4))) { - *wps_ielen = ie_ptr[1]+2; + *wps_ielen = ie_ptr[1] + 2; match = true; } return match; @@ -689,20 +689,20 @@ u8 *rtw_get_wps_ie(u8 *in_ie, uint in_len, u8 *wps_ie, uint *wps_ielen) while (cnt < in_len) { eid = in_ie[cnt]; - if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt+2], wps_oui, 4))) { + if ((eid == _WPA_IE_ID_) && (!memcmp(&in_ie[cnt + 2], wps_oui, 4))) { wpsie_ptr = &in_ie[cnt]; if (wps_ie) - memcpy(wps_ie, &in_ie[cnt], in_ie[cnt+1]+2); + memcpy(wps_ie, &in_ie[cnt], in_ie[cnt + 1] + 2); if (wps_ielen) - *wps_ielen = in_ie[cnt+1]+2; + *wps_ielen = in_ie[cnt + 1] + 2; - cnt += in_ie[cnt+1]+2; + cnt += in_ie[cnt + 1] + 2; break; } else { - cnt += in_ie[cnt+1]+2; /* goto next */ + cnt += in_ie[cnt + 1] + 2; /* goto next */ } } return wpsie_ptr; @@ -776,12 +776,12 @@ u8 *rtw_get_wps_attr_content(u8 *wps_ie, uint wps_ielen, u16 target_attr_id, u8 if (attr_ptr && attr_len) { if (buf_content) - memcpy(buf_content, attr_ptr+4, attr_len-4); + memcpy(buf_content, attr_ptr + 4, attr_len - 4); if (len_content) - *len_content = attr_len-4; + *len_content = attr_len - 4; - return attr_ptr+4; + return attr_ptr + 4; } return NULL; @@ -799,7 +799,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, if (elen < 4) { if (show_errors) { DBG_88E("short vendor specific information element ignored (len=%lu)\n", - (unsigned long) elen); + (unsigned long)elen); } return -1; } @@ -819,7 +819,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, case WME_OUI_TYPE: /* this is a Wi-Fi WME info. element */ if (elen < 5) { DBG_88E("short WME information element ignored (len=%lu)\n", - (unsigned long) elen); + (unsigned long)elen); return -1; } switch (pos[4]) { @@ -834,7 +834,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("unknown WME information element ignored (subtype=%d len=%lu)\n", - pos[4], (unsigned long) elen); + pos[4], (unsigned long)elen); return -1; } break; @@ -845,7 +845,7 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("Unknown Microsoft information element ignored (type=%d len=%lu)\n", - pos[3], (unsigned long) elen); + pos[3], (unsigned long)elen); return -1; } break; @@ -858,13 +858,13 @@ static int rtw_ieee802_11_parse_vendor_specific(u8 *pos, uint elen, break; default: DBG_88E("Unknown Broadcom information element ignored (type=%d len=%lu)\n", - pos[3], (unsigned long) elen); + pos[3], (unsigned long)elen); return -1; } break; default: DBG_88E("unknown vendor specific information element ignored (vendor OUI %02x:%02x:%02x len=%lu)\n", - pos[0], pos[1], pos[2], (unsigned long) elen); + pos[0], pos[1], pos[2], (unsigned long)elen); return -1; } return 0; @@ -898,7 +898,7 @@ enum parse_res rtw_ieee802_11_parse_elems(u8 *start, uint len, if (elen > left) { if (show_errors) { DBG_88E("IEEE 802.11 element parse failed (id=%d elen=%d left=%lu)\n", - id, elen, (unsigned long) left); + id, elen, (unsigned long)left); } return ParseFailed; } @@ -1057,9 +1057,9 @@ void dump_ies(u8 *buf, u32 buf_len) u8 *pos = (u8 *)buf; u8 id, len; - while (pos-buf <= buf_len) { + while (pos - buf <= buf_len) { id = *pos; - len = *(pos+1); + len = *(pos + 1); DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); #ifdef CONFIG_88EU_P2P @@ -1084,11 +1084,11 @@ void dump_wps_ie(u8 *ie, u32 ie_len) return; pos += 6; - while (pos-ie < ie_len) { + while (pos - ie < ie_len) { id = RTW_GET_BE16(pos); len = RTW_GET_BE16(pos + 2); DBG_88E("%s ID:0x%04x, LEN:%u\n", __func__, id, len); - pos += (4+len); + pos += (4 + len); } } @@ -1106,11 +1106,11 @@ void dump_p2p_ie(u8 *ie, u32 ie_len) return; pos += 6; - while (pos-ie < ie_len) { + while (pos - ie < ie_len) { id = *pos; - len = get_unaligned_le16(pos+1); + len = get_unaligned_le16(pos + 1); DBG_88E("%s ID:%u, LEN:%u\n", __func__, id, len); - pos += (3+len); + pos += (3 + len); } } @@ -1138,7 +1138,7 @@ u8 *rtw_get_p2p_ie(u8 *in_ie, int in_len, u8 *p2p_ie, uint *p2p_ielen) dump_stack(); return NULL; } - if ((eid == _VENDOR_SPECIFIC_IE_) && !memcmp(&in_ie[cnt+2], p2p_oui, 4)) { + if ((eid == _VENDOR_SPECIFIC_IE_) && !memcmp(&in_ie[cnt + 2], p2p_oui, 4)) { p2p_ie_ptr = in_ie + cnt; if (p2p_ie) @@ -1222,12 +1222,12 @@ u8 *rtw_get_p2p_attr_content(u8 *p2p_ie, uint p2p_ielen, u8 target_attr_id, u8 * if (attr_ptr && attr_len) { if (buf_content) - memcpy(buf_content, attr_ptr+3, attr_len-3); + memcpy(buf_content, attr_ptr + 3, attr_len - 3); if (len_content) - *len_content = attr_len-3; + *len_content = attr_len - 3; - return attr_ptr+3; + return attr_ptr + 3; } return NULL; @@ -1259,13 +1259,13 @@ static uint rtw_p2p_attr_remove(u8 *ie, uint ielen_ori, u8 attr_id) while (1) { target_attr = rtw_get_p2p_attr(ie, ielen, attr_id, NULL, &target_attr_len); if (target_attr && target_attr_len) { - u8 *next_attr = target_attr+target_attr_len; - uint remain_len = ielen-(next_attr-ie); + u8 *next_attr = target_attr + target_attr_len; + uint remain_len = ielen - (next_attr - ie); memset(target_attr, 0, target_attr_len); memcpy(target_attr, next_attr, remain_len); - memset(target_attr+remain_len, 0, target_attr_len); - *(ie+1) -= target_attr_len; + memset(target_attr + remain_len, 0, target_attr_len); + *(ie + 1) -= target_attr_len; ielen -= target_attr_len; } else { break; @@ -1279,17 +1279,17 @@ void rtw_wlan_bssid_ex_remove_p2p_attr(struct wlan_bssid_ex *bss_ex, u8 attr_id) u8 *p2p_ie; uint p2p_ielen, p2p_ielen_ori; - p2p_ie = rtw_get_p2p_ie(bss_ex->IEs+_FIXED_IE_LENGTH_, bss_ex->IELength-_FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori); + p2p_ie = rtw_get_p2p_ie(bss_ex->IEs + _FIXED_IE_LENGTH_, bss_ex->IELength - _FIXED_IE_LENGTH_, NULL, &p2p_ielen_ori); if (p2p_ie) { p2p_ielen = rtw_p2p_attr_remove(p2p_ie, p2p_ielen_ori, attr_id); if (p2p_ielen != p2p_ielen_ori) { - u8 *next_ie_ori = p2p_ie+p2p_ielen_ori; - u8 *next_ie = p2p_ie+p2p_ielen; - uint remain_len = bss_ex->IELength-(next_ie_ori-bss_ex->IEs); + u8 *next_ie_ori = p2p_ie + p2p_ielen_ori; + u8 *next_ie = p2p_ie + p2p_ielen; + uint remain_len = bss_ex->IELength - (next_ie_ori - bss_ex->IEs); memcpy(next_ie, next_ie_ori, remain_len); - memset(next_ie+remain_len, 0, p2p_ielen_ori-p2p_ielen); - bss_ex->IELength -= p2p_ielen_ori-p2p_ielen; + memset(next_ie + remain_len, 0, p2p_ielen_ori - p2p_ielen); + bss_ex->IELength -= p2p_ielen_ori - p2p_ielen; } } } @@ -1346,20 +1346,20 @@ static int rtw_get_cipher_info(struct wlan_network *pnetwork) unsigned char *pbuf; int group_cipher = 0, pairwise_cipher = 0, is8021x = 0; int ret = _FAIL; - pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + if (_SUCCESS == rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is8021x)) { pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; ret = _SUCCESS; } } else { - pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12); if (pbuf && (wpa_ielen > 0)) { - if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is8021x)) { + if (_SUCCESS == rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is8021x)) { pnetwork->BcnInfo.pairwise_cipher = pairwise_cipher; pnetwork->BcnInfo.group_cipher = group_cipher; pnetwork->BcnInfo.is_8021x = is8021x; @@ -1491,8 +1491,8 @@ int rtw_action_frame_parse(const u8 *frame, u32 frame_len, u8 *category, u8 *act fc = le16_to_cpu(((struct rtw_ieee80211_hdr_3addr *)frame)->frame_ctl); - if ((fc & (RTW_IEEE80211_FCTL_FTYPE|RTW_IEEE80211_FCTL_STYPE)) != - (RTW_IEEE80211_FTYPE_MGMT|RTW_IEEE80211_STYPE_ACTION)) + if ((fc & (RTW_IEEE80211_FCTL_FTYPE | RTW_IEEE80211_FCTL_STYPE)) != + (RTW_IEEE80211_FTYPE_MGMT | RTW_IEEE80211_STYPE_ACTION)) return false; c = frame_body[0]; -- cgit v1.2.3 From 35f1fa01c1c2e829f12e03d49c71f2c5625c6c0d Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:02 +0200 Subject: staging: r8188eu: simplify multiplication in core/rtw_ioctl_set.c Simplify multiplication in core/rtw_ioctl_set.c. to improve readability and clear a checkpatch issue. CHECK: spaces preferred around that '/' (ctx:VxV) Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-8-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index edcac238076a..bb6bc6508255 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -825,7 +825,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) i++; } - max_rate = max_rate*10/2; + max_rate *= 5; } return max_rate; -- cgit v1.2.3 From 292c8398d17537340aefe9b833be548286f8d839 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:03 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_ioctl_set.c Clean up spacing style issues in core/rtw_ioctl_set.c reported by checkpatch. CHECK: spaces preferred around that ... WARNING: space prohibited before semicolon Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-9-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index bb6bc6508255..edfea5ad8259 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -154,7 +154,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) goto release_mlme_lock; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ @@ -228,7 +228,7 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) goto release_mlme_lock; } - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { if ((pmlmepriv->assoc_ssid.SsidLength == ssid->SsidLength) && (!memcmp(&pmlmepriv->assoc_ssid.Ssid, ssid->Ssid, ssid->SsidLength))) { if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { @@ -389,7 +389,7 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s goto exit; } - if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) || + if ((check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) || (pmlmepriv->LinkDetectInfo.bBusyTraffic)) { /* Scan or linking is in progress, do nothing. */ res = true; @@ -623,8 +623,8 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) struct ndis_802_11_wep *wep = &padapter->securitypriv.ndiswep; wep->Length = len; - keyindex = key->KeyIndex&0x7fffffff; - wep->KeyIndex = keyindex ; + keyindex = key->KeyIndex & 0x7fffffff; + wep->KeyIndex = keyindex; wep->KeyLength = key->KeyLength; memcpy(wep->KeyMaterial, key->KeyMaterial, key->KeyLength); @@ -654,7 +654,7 @@ u8 rtw_set_802_11_add_key(struct adapter *padapter, struct ndis_802_11_key *key) if (bgrouptkey) padapter->securitypriv.dot118021XGrpKeyid = (u8)key->KeyIndex; - if ((key->KeyIndex&0x3) == 0) { + if ((key->KeyIndex & 0x3) == 0) { ret = _FAIL; goto exit; } @@ -796,9 +796,9 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) return 0; if (pmlmeext->cur_wireless_mode & (WIRELESS_11_24N)) { - p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength - 12); if (p && ht_ielen > 0) { - pht_capie = (struct ieee80211_ht_cap *)(p+2); + pht_capie = (struct ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); @@ -819,7 +819,7 @@ u16 rtw_get_cur_max_rate(struct adapter *adapter) } } else { while ((pcur_bss->SupportedRates[i] != 0) && (pcur_bss->SupportedRates[i] != 0xFF)) { - rate = pcur_bss->SupportedRates[i]&0x7F; + rate = pcur_bss->SupportedRates[i] & 0x7F; if (rate > max_rate) max_rate = rate; i++; -- cgit v1.2.3 From 174b79fcd0719e515e4dd3f57c33727998cbfc18 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:04 +0200 Subject: staging: r8188eu: add spaces around operators in core/rtw_iol.c Add missing spaces around operators in core/rtw_iol.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-10-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_iol.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_iol.c b/drivers/staging/r8188eu/core/rtw_iol.c index 927b8c919fa7..5c1b19679cad 100644 --- a/drivers/staging/r8188eu/core/rtw_iol.c +++ b/drivers/staging/r8188eu/core/rtw_iol.c @@ -46,7 +46,7 @@ int rtw_IOL_append_cmds(struct xmit_frame *xmit_frame, u8 *IOL_cmds, u32 cmd_len u32 ori_len; buf_offset = TXDESC_OFFSET; - ori_len = buf_offset+pattrib->pktlen; + ori_len = buf_offset + pattrib->pktlen; /* check if the io_buf can accommodate new cmds */ if (ori_len + cmd_len + 8 > MAX_XMITBUF_SZ) { @@ -128,7 +128,7 @@ int _rtw_IOL_append_WRF_cmd(struct xmit_frame *xmit_frame, u8 rf_path, u16 addr, { struct ioreg_cfg cmd = {8, IOREG_CMD_W_RF, 0x0, 0x0, 0x0}; - cmd.address = cpu_to_le16((rf_path<<8) | ((addr) & 0xFF)); + cmd.address = cpu_to_le16((rf_path << 8) | ((addr) & 0xFF)); cmd.data = cpu_to_le32(value); if (mask != 0x000FFFFF) { @@ -164,9 +164,9 @@ int rtw_IOL_append_END_cmd(struct xmit_frame *xmit_frame) u8 rtw_IOL_cmd_boundary_handle(struct xmit_frame *pxmit_frame) { u8 is_cmd_bndy = false; - if (((pxmit_frame->attrib.pktlen+32)%256) + 8 >= 256) { + if (((pxmit_frame->attrib.pktlen + 32) % 256) + 8 >= 256) { rtw_IOL_append_END_cmd(pxmit_frame); - pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen+32)/256)+1)*256); + pxmit_frame->attrib.pktlen = ((((pxmit_frame->attrib.pktlen + 32) / 256) + 1) * 256); pxmit_frame->attrib.last_txcmdsz = pxmit_frame->attrib.pktlen; is_cmd_bndy = true; @@ -181,9 +181,9 @@ void rtw_IOL_cmd_buf_dump(struct adapter *Adapter, int buf_len, u8 *pbuf) pr_info("###### %s ######\n", __func__); for (i = 0; i < buf_len; i++) { - printk("%02x-", *(pbuf+i)); + printk("%02x-", *(pbuf + i)); - if (j%32 == 0) + if (j % 32 == 0) printk("\n"); j++; } -- cgit v1.2.3 From c891e014b5796e84a6240e25ec51157d5dd9c8ff Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:05 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_mlme.c Clean up spacing style issues in core/rtw_mlme.c reported by checkpatch. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-11-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 80 ++++++++++++++++----------------- 1 file changed, 40 insertions(+), 40 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index d5ef5783f4ad..c0685965b436 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -31,7 +31,7 @@ u8 rtw_to_roaming(struct adapter *adapter) return adapter->mlmepriv.to_roaming; } -int _rtw_init_mlme_priv (struct adapter *padapter) +int _rtw_init_mlme_priv(struct adapter *padapter) { int i; u8 *pbuf; @@ -85,11 +85,11 @@ exit: return res; } -static void rtw_mfree_mlme_priv_lock (struct mlme_priv *pmlmepriv) +static void rtw_mfree_mlme_priv_lock(struct mlme_priv *pmlmepriv) { } -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) static void rtw_free_mlme_ie_data(u8 **ppie, u32 *plen) { kfree(*ppie); @@ -118,13 +118,13 @@ void rtw_free_mlme_priv_ie_data(struct mlme_priv *pmlmepriv) } #endif -void _rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +void _rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { rtw_free_mlme_priv_ie_data(pmlmepriv); if (pmlmepriv) { - rtw_mfree_mlme_priv_lock (pmlmepriv); + rtw_mfree_mlme_priv_lock(pmlmepriv); vfree(pmlmepriv->free_bss_buf); } @@ -215,7 +215,7 @@ void _rtw_free_network(struct mlme_priv *pmlmepriv, struct wlan_network *pnetwor (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) lifetime = 1; if (!isfreeall) { - delta_time = (curr_time - pnetwork->last_scanned)/HZ; + delta_time = (curr_time - pnetwork->last_scanned) / HZ; if (delta_time < lifetime)/* unit:sec */ return; } @@ -314,8 +314,8 @@ void rtw_generate_random_ibss(u8 *pibss) pibss[1] = 0x11; pibss[2] = 0x87; pibss[3] = (u8)(curtime & 0xff);/* p[0]; */ - pibss[4] = (u8)((curtime>>8) & 0xff);/* p[1]; */ - pibss[5] = (u8)((curtime>>16) & 0xff);/* p[2]; */ + pibss[4] = (u8)((curtime >> 8) & 0xff);/* p[1]; */ + pibss[5] = (u8)((curtime >> 16) & 0xff);/* p[2]; */ } u8 *rtw_get_capability_from_ie(u8 *ie) @@ -342,7 +342,7 @@ u8 *rtw_get_beacon_interval_from_ie(u8 *ie) return ie + 8; } -int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ +int rtw_init_mlme_priv(struct adapter *padapter)/* struct mlme_priv *pmlmepriv) */ { int res; @@ -351,9 +351,9 @@ int rtw_init_mlme_priv (struct adapter *padapter)/* struct mlme_priv *pmlmepriv) return res; } -void rtw_free_mlme_priv (struct mlme_priv *pmlmepriv) +void rtw_free_mlme_priv(struct mlme_priv *pmlmepriv) { - _rtw_free_mlme_priv (pmlmepriv); + _rtw_free_mlme_priv(pmlmepriv); } static struct wlan_network *rtw_alloc_network(struct mlme_priv *pmlmepriv) @@ -642,7 +642,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * privacy = pnetwork->network.Privacy; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - if (rtw_get_wps_ie(pnetwork->network.IEs+_FIXED_IE_LENGTH_, pnetwork->network.IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen)) + if (rtw_get_wps_ie(pnetwork->network.IEs + _FIXED_IE_LENGTH_, pnetwork->network.IELength - _FIXED_IE_LENGTH_, NULL, &wps_ielen)) return true; else return false; @@ -1061,8 +1061,8 @@ static void rtw_joinbss_update_network(struct adapter *padapter, struct wlan_net /* update fw_state will clr _FW_UNDER_LINKING here indirectly */ switch (pnetwork->network.InfrastructureMode) { case Ndis802_11Infrastructure: - if (pmlmepriv->fw_state&WIFI_UNDER_WPS) - pmlmepriv->fw_state = WIFI_STATION_STATE|WIFI_UNDER_WPS; + if (pmlmepriv->fw_state & WIFI_UNDER_WPS) + pmlmepriv->fw_state = WIFI_STATION_STATE | WIFI_UNDER_WPS; else pmlmepriv->fw_state = WIFI_STATION_STATE; break; @@ -1201,7 +1201,7 @@ void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf) static u8 search_max_mac_id(struct adapter *padapter) { u8 mac_id; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) u8 aid; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct sta_priv *pstapriv = &padapter->stapriv; @@ -1209,17 +1209,17 @@ static u8 search_max_mac_id(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { for (aid = (pstapriv->max_num_sta); aid > 0; aid--) { - if (pstapriv->sta_aid[aid-1]) + if (pstapriv->sta_aid[aid - 1]) break; } mac_id = aid + 1; } else #endif {/* adhoc id = 31~2 */ - for (mac_id = (NUM_STA-1); mac_id >= IBSS_START_MAC_ID; mac_id--) { + for (mac_id = (NUM_STA - 1); mac_id >= IBSS_START_MAC_ID; mac_id--) { if (pmlmeinfo->FW_sta_info[mac_id].status == 1) break; } @@ -1240,7 +1240,7 @@ void rtw_sta_media_status_rpt(struct adapter *adapter, struct sta_info *psta, macid = search_max_mac_id(adapter); rtw_hal_set_hwreg(adapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&macid); /* MACID|OPMODE:1 connect */ - media_status_rpt = (u16)((psta->mac_id<<8) | mstatus); + media_status_rpt = (u16)((psta->mac_id << 8) | mstatus); rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status_rpt); } @@ -1256,7 +1256,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) return; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { psta = rtw_get_stainfo(&adapter->stapriv, pstassoc->macaddr); if (psta) @@ -1322,7 +1322,7 @@ void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf) if (mac_id >= 0) { u16 media_status; - media_status = (mac_id<<8)|0; /* MACID|OPMODE:0 means disconnect */ + media_status = (mac_id << 8) | 0; /* MACID|OPMODE:0 means disconnect */ /* for STA, AP, ADHOC mode, report disconnect stauts to FW */ rtw_hal_set_hwreg(adapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } @@ -1500,7 +1500,7 @@ void rtw_dynamic_check_timer_handlder(struct adapter *adapter) rcu_read_lock(); if (rcu_dereference(adapter->pnetdev->rx_handler_data) && - (check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE) == true)) { + (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) == true)) { /* expire NAT2.5 entry */ nat25_db_expire(adapter); @@ -1747,7 +1747,7 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ while (i < in_len) { ielength = initial_out_len; - if (in_ie[i] == 0xDD && in_ie[i+2] == 0x00 && in_ie[i+3] == 0x50 && in_ie[i+4] == 0xF2 && in_ie[i+5] == 0x02 && i+5 < in_len) { + if (in_ie[i] == 0xDD && in_ie[i + 2] == 0x00 && in_ie[i + 3] == 0x50 && in_ie[i + 4] == 0xF2 && in_ie[i + 5] == 0x02 && i + 5 < in_len) { /* WMM element ID and OUI */ /* Append WMM IE to the last index of out_ie */ @@ -1760,7 +1760,7 @@ int rtw_restruct_wmm_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ out_ie[initial_out_len + 8] = 0x00; break; } - i += (in_ie[i+1]+2); /* to the next IE element */ + i += (in_ie[i + 1] + 2); /* to the next IE element */ } return ielength; } @@ -1846,13 +1846,13 @@ int rtw_restruct_sec_ie(struct adapter *adapter, u8 *in_ie, u8 *out_ie, uint in_ authmode = _WPA2_IE_ID_; if (check_fwstate(pmlmepriv, WIFI_UNDER_WPS)) { - memcpy(out_ie+ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); + memcpy(out_ie + ielength, psecuritypriv->wps_ie, psecuritypriv->wps_ie_len); ielength += psecuritypriv->wps_ie_len; } else if ((authmode == _WPA_IE_ID_) || (authmode == _WPA2_IE_ID_)) { /* copy RSN or SSN */ - memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1]+2); - ielength += psecuritypriv->supplicant_ie[1]+2; + memcpy(&out_ie[ielength], &psecuritypriv->supplicant_ie[0], psecuritypriv->supplicant_ie[1] + 2); + ielength += psecuritypriv->supplicant_ie[1] + 2; rtw_report_sec_ie(adapter, authmode, psecuritypriv->supplicant_ie); } @@ -1982,12 +1982,12 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ phtpriv->ht_option = false; - p = rtw_get_ie(in_ie+12, _HT_CAPABILITY_IE_, &ielen, in_len-12); + p = rtw_get_ie(in_ie + 12, _HT_CAPABILITY_IE_, &ielen, in_len - 12); if (p && ielen > 0) { if (pqospriv->qos_option == 0) { out_len = *pout_len; - rtw_set_ie(out_ie+out_len, _VENDOR_SPECIFIC_IE_, + rtw_set_ie(out_ie + out_len, _VENDOR_SPECIFIC_IE_, _WMM_IE_Length_, WMM_IE, pout_len); pqospriv->qos_option = 1; @@ -2012,22 +2012,22 @@ unsigned int rtw_restructure_ht_ie(struct adapter *padapter, u8 *in_ie, u8 *out_ */ rtw_hal_get_def_var(padapter, HW_VAR_MAX_RX_AMPDU_FACTOR, &max_rx_ampdu_factor); - ht_capie.ampdu_params_info = (max_rx_ampdu_factor&0x03); + ht_capie.ampdu_params_info = (max_rx_ampdu_factor & 0x03); if (padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & (0x07 << 2)); else ht_capie.ampdu_params_info |= (IEEE80211_HT_AMPDU_PARM_DENSITY & 0x00); - rtw_set_ie(out_ie+out_len, _HT_CAPABILITY_IE_, + rtw_set_ie(out_ie + out_len, _HT_CAPABILITY_IE_, sizeof(struct ieee80211_ht_cap), (unsigned char *)&ht_capie, pout_len); phtpriv->ht_option = true; - p = rtw_get_ie(in_ie+12, _HT_ADD_INFO_IE_, &ielen, in_len-12); + p = rtw_get_ie(in_ie + 12, _HT_ADD_INFO_IE_, &ielen, in_len - 12); if (p && (ielen == sizeof(struct ieee80211_ht_addt_info))) { out_len = *pout_len; - rtw_set_ie(out_ie+out_len, _HT_ADD_INFO_IE_, ielen, p+2, pout_len); + rtw_set_ie(out_ie + out_len, _HT_ADD_INFO_IE_, ielen, p + 2, pout_len); } } return phtpriv->ht_option; @@ -2065,15 +2065,15 @@ void rtw_update_ht_cap(struct adapter *padapter, u8 *pie, uint ie_len) /* check Max Rx A-MPDU Size */ len = 0; - p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); + p = rtw_get_ie(pie + sizeof(struct ndis_802_11_fixed_ie), _HT_CAPABILITY_IE_, &len, ie_len - sizeof(struct ndis_802_11_fixed_ie)); if (p && len > 0) { - pht_capie = (struct ieee80211_ht_cap *)(p+2); + pht_capie = (struct ieee80211_ht_cap *)(p + 2); max_ampdu_sz = (pht_capie->ampdu_params_info & IEEE80211_HT_AMPDU_PARM_FACTOR); - max_ampdu_sz = 1 << (max_ampdu_sz+3); /* max_ampdu_sz (kbytes); */ + max_ampdu_sz = 1 << (max_ampdu_sz + 3); /* max_ampdu_sz (kbytes); */ phtpriv->rx_ampdu_maxlen = max_ampdu_sz; } len = 0; - p = rtw_get_ie(pie+sizeof(struct ndis_802_11_fixed_ie), _HT_ADD_INFO_IE_, &len, ie_len-sizeof(struct ndis_802_11_fixed_ie)); + p = rtw_get_ie(pie + sizeof(struct ndis_802_11_fixed_ie), _HT_ADD_INFO_IE_, &len, ie_len - sizeof(struct ndis_802_11_fixed_ie)); /* update cur_bwmode & cur_ch_offset */ if ((pregistrypriv->cbw40_enable) && @@ -2140,13 +2140,13 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr phtpriv = &psta->htpriv; if ((phtpriv->ht_option) && (phtpriv->ampdu_enable)) { - issued = (phtpriv->agg_enable_bitmap>>priority)&0x1; - issued |= (phtpriv->candidate_tid_bitmap>>priority)&0x1; + issued = (phtpriv->agg_enable_bitmap >> priority) & 0x1; + issued |= (phtpriv->candidate_tid_bitmap >> priority) & 0x1; if (0 == issued) { DBG_88E("rtw_issue_addbareq_cmd, p=%d\n", priority); psta->htpriv.candidate_tid_bitmap |= BIT((u8)priority); - rtw_addbareq_cmd(padapter, (u8) priority, pattrib->ra); + rtw_addbareq_cmd(padapter, (u8)priority, pattrib->ra); } } } -- cgit v1.2.3 From 4257c1c3b0fcb573aba7055db32d00567aac0083 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:06 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_mlme_ext.c Clean up spacing style issues in core/rtw_mlme_ext.c reported by checkpatch. CHECK: spaces preferred around that ... WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-12-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 236 ++++++++++++++-------------- 1 file changed, 118 insertions(+), 118 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 61b239651e1a..f6ee72d5af09 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -553,7 +553,7 @@ _continue: return _SUCCESS; if (!check_fwstate(pmlmepriv, _FW_LINKED) && - !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_AP_STATE)) + !check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_AP_STATE)) return _SUCCESS; p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, _SSID_IE_, (int *)&ielen, @@ -564,7 +564,7 @@ _continue: if (is_valid_p2p_probereq) goto _issue_probersp; - if ((ielen != 0 && memcmp((void *)(p+2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || + if ((ielen != 0 && memcmp((void *)(p + 2), (void *)cur->Ssid.Ssid, cur->Ssid.SsidLength)) || (ielen == 0 && pmlmeinfo->hidden_ssid_mode)) return _SUCCESS; @@ -662,7 +662,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) } /* check the vendor of the assoc AP */ - pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe+sizeof(struct rtw_ieee80211_hdr_3addr), len-sizeof(struct rtw_ieee80211_hdr_3addr)); + pmlmeinfo->assoc_AP_vendor = check_assoc_AP(pframe + sizeof(struct rtw_ieee80211_hdr_3addr), len - sizeof(struct rtw_ieee80211_hdr_3addr)); /* update TSF Value */ update_TSF(pmlmeext, pframe, len); @@ -673,7 +673,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) return _SUCCESS; } - if (((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { + if (((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) && (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); if (psta) { ret = rtw_check_bcn_info(padapter, pframe, len); @@ -688,7 +688,7 @@ unsigned int OnBeacon(struct adapter *padapter, struct recv_frame *precv_frame) update_beacon_info(padapter, pframe, len, psta); process_p2p_ps_ie(padapter, (pframe + WLAN_HDR_A3_LEN), (len - WLAN_HDR_A3_LEN)); } - } else if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { psta = rtw_get_stainfo(pstapriv, GetAddr2Ptr(pframe)); if (psta) { /* update WMM, ERP in the beacon */ @@ -738,7 +738,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) u8 *pframe = precv_frame->rx_data; uint len = precv_frame->len; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; DBG_88E("+OnAuth\n"); @@ -808,7 +808,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) if ((pstat->auth_seq + 1) != seq) { DBG_88E("(1)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", - seq, pstat->auth_seq+1); + seq, pstat->auth_seq + 1); status = _STATS_OUT_OF_AUTH_SEQ_; goto auth_fail; } @@ -821,7 +821,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) pstat->authalg = algorithm; } else { DBG_88E("(2)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", - seq, pstat->auth_seq+1); + seq, pstat->auth_seq + 1); status = _STATS_OUT_OF_AUTH_SEQ_; goto auth_fail; } @@ -858,7 +858,7 @@ unsigned int OnAuth(struct adapter *padapter, struct recv_frame *precv_frame) } } else { DBG_88E("(3)auth rejected because out of seq [rx_seq=%d, exp_seq=%d]!\n", - seq, pstat->auth_seq+1); + seq, pstat->auth_seq + 1); status = _STATS_OUT_OF_AUTH_SEQ_; goto auth_fail; } @@ -997,7 +997,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame u32 p2pielen = 0; #endif /* CONFIG_88EU_P2P */ - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) return _FAIL; frame_type = GetFrameSubType(pframe); @@ -1062,7 +1062,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame status = _STATS_FAILURE_; } else { /* check if ssid match */ - if (memcmp((void *)(p+2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) + if (memcmp((void *)(p + 2), cur->Ssid.Ssid, cur->Ssid.SsidLength)) status = _STATS_FAILURE_; if (ie_len != cur->Ssid.SsidLength) @@ -1083,14 +1083,14 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame status = _STATS_FAILURE_; goto OnAssocReqFail; } else { - memcpy(supportRate, p+2, ie_len); + memcpy(supportRate, p + 2, ie_len); supportRateNum = ie_len; p = rtw_get_ie(pframe + WLAN_HDR_A3_LEN + ie_offset, _EXT_SUPPORTEDRATES_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p) { if (supportRateNum <= sizeof(supportRate)) { - memcpy(supportRate+supportRateNum, p+2, ie_len); + memcpy(supportRate + supportRateNum, p + 2, ie_len); supportRateNum += ie_len; } } @@ -1118,12 +1118,12 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame wpa_ie = elems.rsn_ie; wpa_ie_len = elems.rsn_ie_len; - if (rtw_parse_wpa2_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa2_ie(wpa_ie - 2, wpa_ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(1); - pstat->wpa2_group_cipher = group_cipher&psecuritypriv->wpa2_group_cipher; - pstat->wpa2_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa2_pairwise_cipher; + pstat->wpa2_group_cipher = group_cipher & psecuritypriv->wpa2_group_cipher; + pstat->wpa2_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa2_pairwise_cipher; if (!pstat->wpa2_group_cipher) status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; @@ -1139,12 +1139,12 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame wpa_ie = elems.wpa_ie; wpa_ie_len = elems.wpa_ie_len; - if (rtw_parse_wpa_ie(wpa_ie-2, wpa_ie_len+2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { + if (rtw_parse_wpa_ie(wpa_ie - 2, wpa_ie_len + 2, &group_cipher, &pairwise_cipher, NULL) == _SUCCESS) { pstat->dot8021xalg = 1;/* psk, todo:802.1x */ pstat->wpa_psk |= BIT(0); - pstat->wpa_group_cipher = group_cipher&psecuritypriv->wpa_group_cipher; - pstat->wpa_pairwise_cipher = pairwise_cipher&psecuritypriv->wpa_pairwise_cipher; + pstat->wpa_group_cipher = group_cipher & psecuritypriv->wpa_group_cipher; + pstat->wpa_pairwise_cipher = pairwise_cipher & psecuritypriv->wpa_pairwise_cipher; if (!pstat->wpa_group_cipher) status = WLAN_STATUS_GROUP_CIPHER_NOT_VALID; @@ -1181,7 +1181,7 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame /* AP support WPA/RSN, and sta is going to do WPS, but AP is not ready */ /* that the selected registrar of AP is _FLASE */ - if ((psecuritypriv->wpa_psk > 0) && (pstat->flags & (WLAN_STA_WPS|WLAN_STA_MAYBE_WPS))) { + if ((psecuritypriv->wpa_psk > 0) && (pstat->flags & (WLAN_STA_WPS | WLAN_STA_MAYBE_WPS))) { if (pmlmepriv->wps_beacon_ie) { u8 selected_registrar = 0; @@ -1215,10 +1215,10 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame pstat->flags |= WLAN_STA_WPS; copy_len = 0; } else { - copy_len = ((wpa_ie_len+2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)) : (wpa_ie_len+2); + copy_len = ((wpa_ie_len + 2) > sizeof(pstat->wpa_ie)) ? (sizeof(pstat->wpa_ie)) : (wpa_ie_len + 2); } if (copy_len > 0) - memcpy(pstat->wpa_ie, wpa_ie-2, copy_len); + memcpy(pstat->wpa_ie, wpa_ie - 2, copy_len); } /* check if there is WMM IE & support WWM-PS */ pstat->flags &= ~WLAN_STA_WME; @@ -1234,37 +1234,37 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame for (;;) { p = rtw_get_ie(p, _VENDOR_SPECIFIC_IE_, &ie_len, pkt_len - WLAN_HDR_A3_LEN - ie_offset); if (p) { - if (!memcmp(p+2, WMM_IE, 6)) { + if (!memcmp(p + 2, WMM_IE, 6)) { pstat->flags |= WLAN_STA_WME; pstat->qos_option = 1; - pstat->qos_info = *(p+8); + pstat->qos_info = *(p + 8); - pstat->max_sp_len = (pstat->qos_info>>5)&0x3; + pstat->max_sp_len = (pstat->qos_info >> 5) & 0x3; - if ((pstat->qos_info&0xf) != 0xf) + if ((pstat->qos_info & 0xf) != 0xf) pstat->has_legacy_ac = true; else pstat->has_legacy_ac = false; - if (pstat->qos_info&0xf) { - if (pstat->qos_info&BIT(0)) - pstat->uapsd_vo = BIT(0)|BIT(1); + if (pstat->qos_info & 0xf) { + if (pstat->qos_info & BIT(0)) + pstat->uapsd_vo = BIT(0) | BIT(1); else pstat->uapsd_vo = 0; - if (pstat->qos_info&BIT(1)) - pstat->uapsd_vi = BIT(0)|BIT(1); + if (pstat->qos_info & BIT(1)) + pstat->uapsd_vi = BIT(0) | BIT(1); else pstat->uapsd_vi = 0; - if (pstat->qos_info&BIT(2)) - pstat->uapsd_bk = BIT(0)|BIT(1); + if (pstat->qos_info & BIT(2)) + pstat->uapsd_bk = BIT(0) | BIT(1); else pstat->uapsd_bk = 0; - if (pstat->qos_info&BIT(3)) - pstat->uapsd_be = BIT(0)|BIT(1); + if (pstat->qos_info & BIT(3)) + pstat->uapsd_be = BIT(0) | BIT(1); else pstat->uapsd_be = 0; } @@ -1288,14 +1288,14 @@ unsigned int OnAssocReq(struct adapter *padapter, struct recv_frame *precv_frame } else { pstat->flags &= ~WLAN_STA_HT; } - if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags&WLAN_STA_HT)) { + if ((!pmlmepriv->htpriv.ht_option) && (pstat->flags & WLAN_STA_HT)) { status = _STATS_FAILURE_; goto OnAssocReqFail; } if ((pstat->flags & WLAN_STA_HT) && - ((pstat->wpa2_pairwise_cipher&WPA_CIPHER_TKIP) || - (pstat->wpa_pairwise_cipher&WPA_CIPHER_TKIP))) { + ((pstat->wpa2_pairwise_cipher & WPA_CIPHER_TKIP) || + (pstat->wpa_pairwise_cipher & WPA_CIPHER_TKIP))) { DBG_88E("HT: %pM tried to " "use TKIP with HT association\n", pstat->hwaddr); @@ -1473,7 +1473,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame pmlmeinfo->slotTime = (pmlmeinfo->capability & BIT(10)) ? 9 : 20; /* AID */ - pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4))&0x3fff); + pmlmeinfo->aid = (int)(le16_to_cpu(*(__le16 *)(pframe + WLAN_HDR_A3_LEN + 4)) & 0x3fff); res = pmlmeinfo->aid; /* following are moved to join event callback function */ @@ -1733,7 +1733,7 @@ unsigned int OnAction_back(struct adapter *padapter, struct recv_frame *precv_fr DBG_88E("%s\n", __func__); - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) return _SUCCESS; @@ -3515,8 +3515,8 @@ static int _issue_probereq_p2p(struct adapter *padapter, u8 *da, int wait_ack) pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_PROBEREQ); - pframe += sizeof (struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ)) pframe = rtw_set_ie(pframe, _SSID_IE_, pwdinfo->tx_prov_disc_info.ssid.SsidLength, pwdinfo->tx_prov_disc_info.ssid.Ssid, &pattrib->pktlen); @@ -3794,7 +3794,7 @@ static s32 rtw_action_public_decache(struct recv_frame *recv_frame, s32 token) struct adapter *adapter = recv_frame->adapter; struct mlme_ext_priv *mlmeext = &adapter->mlmeextpriv; u8 *frame = recv_frame->rx_data; - u16 seq_ctrl = ((recv_frame->attrib.seq_num&0xffff) << 4) | + u16 seq_ctrl = ((recv_frame->attrib.seq_num & 0xffff) << 4) | (recv_frame->attrib.frag_num & 0xf); if (GetRetry(frame)) { @@ -4237,7 +4237,7 @@ unsigned int OnAction(struct adapter *padapter, struct recv_frame *precv_frame) category = frame_body[0]; - for (i = 0; i < sizeof(OnAction_tbl)/sizeof(struct action_handler); i++) { + for (i = 0; i < sizeof(OnAction_tbl) / sizeof(struct action_handler); i++) { ptable = &OnAction_tbl[i]; if (category == ptable->num) ptable->func(padapter, precv_frame); @@ -4389,7 +4389,7 @@ static int update_hidden_ssid(u8 *ies, u32 ies_len, u8 hidden_ssid_mode) remain_len = ies_len - (next_ie - ies); ssid_ie[1] = 0; - memcpy(ssid_ie+2, next_ie, remain_len); + memcpy(ssid_ie + 2, next_ie, remain_len); len_diff -= ssid_len_ori; break; @@ -4428,7 +4428,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) DBG_88E("%s, alloc mgnt frame fail\n", __func__); return; } -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) spin_lock_bh(&pmlmepriv->bcn_update_lock); #endif /* if defined (CONFIG_88EU_AP_MODE) */ @@ -4454,14 +4454,14 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) SetFrameSubType(pframe, WIFI_BEACON); pframe += sizeof(struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { #ifdef CONFIG_88EU_P2P /* for P2P : Primary Device Type & Device Name */ u32 wpsielen = 0, insert_len = 0; u8 *wpsie = NULL; - wpsie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wpsielen); + wpsie = rtw_get_wps_ie(cur_network->IEs + _FIXED_IE_LENGTH_, cur_network->IELength - _FIXED_IE_LENGTH_, NULL, &wpsielen); if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO) && wpsie && wpsielen > 0) { uint wps_offset, remainder_ielen; @@ -4471,7 +4471,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) premainder_ie = wpsie + wpsielen; remainder_ielen = cur_network->IELength - wps_offset - wpsielen; pframe_wscie = pframe + wps_offset; - memcpy(pframe, cur_network->IEs, wps_offset+wpsielen); + memcpy(pframe, cur_network->IEs, wps_offset + wpsielen); pframe += (wps_offset + wpsielen); pattrib->pktlen += (wps_offset + wpsielen); @@ -4512,7 +4512,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) insert_len += pwdinfo->device_name_len; /* update wsc ie length */ - *(pframe_wscie+1) = (wpsielen-2) + insert_len; + *(pframe_wscie + 1) = (wpsielen - 2) + insert_len; /* pframe move to end */ pframe += insert_len; @@ -4528,20 +4528,20 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) int len_diff; memcpy(pframe, cur_network->IEs, cur_network->IELength); len_diff = update_hidden_ssid( - pframe+_BEACON_IE_OFFSET_ - , cur_network->IELength-_BEACON_IE_OFFSET_ + pframe + _BEACON_IE_OFFSET_ + , cur_network->IELength - _BEACON_IE_OFFSET_ , pmlmeinfo->hidden_ssid_mode ); - pframe += (cur_network->IELength+len_diff); - pattrib->pktlen += (cur_network->IELength+len_diff); + pframe += (cur_network->IELength + len_diff); + pattrib->pktlen += (cur_network->IELength + len_diff); } { u8 *wps_ie; uint wps_ielen; u8 sr = 0; - wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr+TXDESC_OFFSET+sizeof (struct rtw_ieee80211_hdr_3addr)+_BEACON_IE_OFFSET_, - pattrib->pktlen-sizeof (struct rtw_ieee80211_hdr_3addr)-_BEACON_IE_OFFSET_, NULL, &wps_ielen); + wps_ie = rtw_get_wps_ie(pmgntframe->buf_addr + TXDESC_OFFSET + sizeof(struct rtw_ieee80211_hdr_3addr) + _BEACON_IE_OFFSET_, + pattrib->pktlen - sizeof(struct rtw_ieee80211_hdr_3addr) - _BEACON_IE_OFFSET_, NULL, &wps_ielen); if (wps_ie && wps_ielen > 0) rtw_get_wps_attr_content(wps_ie, wps_ielen, WPS_ATTR_SELECTED_REGISTRAR, (u8 *)(&sr), NULL); if (sr != 0) @@ -4610,7 +4610,7 @@ void issue_beacon(struct adapter *padapter, int timeout_ms) /* todo:HT for adhoc */ _issue_bcn: -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) pmlmepriv->update_bcn = false; spin_unlock_bh(&pmlmepriv->bcn_update_lock); @@ -4639,7 +4639,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p __le16 *fctrl; unsigned char *mac, *bssid; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; -#if defined (CONFIG_88EU_AP_MODE) +#if defined(CONFIG_88EU_AP_MODE) u8 *pwps_ie; uint wps_ielen; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -4688,8 +4688,8 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p return; #if defined(CONFIG_88EU_AP_MODE) - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - pwps_ie = rtw_get_wps_ie(cur_network->IEs+_FIXED_IE_LENGTH_, cur_network->IELength-_FIXED_IE_LENGTH_, NULL, &wps_ielen); + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { + pwps_ie = rtw_get_wps_ie(cur_network->IEs + _FIXED_IE_LENGTH_, cur_network->IELength - _FIXED_IE_LENGTH_, NULL, &wps_ielen); /* inerset & update wps_probe_resp_ie */ if (pmlmepriv->wps_probe_resp_ie && pwps_ie && wps_ielen > 0) { @@ -4707,13 +4707,13 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p pattrib->pktlen += wps_offset; wps_ielen = (uint)pmlmepriv->wps_probe_resp_ie[1];/* to get ie data len */ - if ((wps_offset+wps_ielen+2) <= MAX_IE_SZ) { - memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen+2); - pframe += wps_ielen+2; - pattrib->pktlen += wps_ielen+2; + if ((wps_offset + wps_ielen + 2) <= MAX_IE_SZ) { + memcpy(pframe, pmlmepriv->wps_probe_resp_ie, wps_ielen + 2); + pframe += wps_ielen + 2; + pattrib->pktlen += wps_ielen + 2; } - if ((wps_offset+wps_ielen+2+remainder_ielen) <= MAX_IE_SZ) { + if ((wps_offset + wps_ielen + 2 + remainder_ielen) <= MAX_IE_SZ) { memcpy(pframe, premainder_ie, remainder_ielen); pframe += remainder_ielen; pattrib->pktlen += remainder_ielen; @@ -4756,7 +4756,7 @@ void issue_probersp(struct adapter *padapter, unsigned char *da, u8 is_valid_p2p /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pattrib->pktlen); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u8 erpinfo = 0; u32 ATIMWindow; /* IBSS Parameter Set... */ @@ -4839,8 +4839,8 @@ static int _issue_probereq(struct adapter *padapter, struct ndis_802_11_ssid *ps pmlmeext->mgnt_seq++; SetFrameSubType(pframe, WIFI_PROBEREQ); - pframe += sizeof (struct rtw_ieee80211_hdr_3addr); - pattrib->pktlen = sizeof (struct rtw_ieee80211_hdr_3addr); + pframe += sizeof(struct rtw_ieee80211_hdr_3addr); + pattrib->pktlen = sizeof(struct rtw_ieee80211_hdr_3addr); if (pssid) pframe = rtw_set_ie(pframe, _SSID_IE_, pssid->SsidLength, pssid->Ssid, &pattrib->pktlen); @@ -5121,7 +5121,7 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, pstat->bssratelen, pstat->bssrateset, &pattrib->pktlen); } else { pframe = rtw_set_ie(pframe, _SUPPORTEDRATES_IE_, 8, pstat->bssrateset, &pattrib->pktlen); - pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, pstat->bssratelen-8, pstat->bssrateset+8, &pattrib->pktlen); + pframe = rtw_set_ie(pframe, _EXT_SUPPORTEDRATES_IE_, pstat->bssratelen - 8, pstat->bssrateset + 8, &pattrib->pktlen); } if ((pstat->flags & WLAN_STA_HT) && (pmlmepriv->htpriv.ht_option)) { @@ -5130,17 +5130,17 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i /* FILL HT CAP INFO IE */ pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_CAPABILITY_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { - memcpy(pframe, pbuf, ie_len+2); - pframe += (ie_len+2); - pattrib->pktlen += (ie_len+2); + memcpy(pframe, pbuf, ie_len + 2); + pframe += (ie_len + 2); + pattrib->pktlen += (ie_len + 2); } /* FILL HT ADD INFO IE */ pbuf = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _HT_ADD_INFO_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_)); if (pbuf && ie_len > 0) { - memcpy(pframe, pbuf, ie_len+2); - pframe += (ie_len+2); - pattrib->pktlen += (ie_len+2); + memcpy(pframe, pbuf, ie_len + 2); + pframe += (ie_len + 2); + pattrib->pktlen += (ie_len + 2); } } @@ -5151,10 +5151,10 @@ void issue_asocrsp(struct adapter *padapter, unsigned short status, struct sta_i for (pbuf = ie + _BEACON_IE_OFFSET_;; pbuf += (ie_len + 2)) { pbuf = rtw_get_ie(pbuf, _VENDOR_SPECIFIC_IE_, &ie_len, (pnetwork->IELength - _BEACON_IE_OFFSET_ - (ie_len + 2))); - if (pbuf && !memcmp(pbuf+2, WMM_PARA_IE, 6)) { - memcpy(pframe, pbuf, ie_len+2); - pframe += (ie_len+2); - pattrib->pktlen += (ie_len+2); + if (pbuf && !memcmp(pbuf + 2, WMM_PARA_IE, 6)) { + memcpy(pframe, pbuf, ie_len + 2); + pframe += (ie_len + 2); + pattrib->pktlen += (ie_len + 2); break; } @@ -5276,8 +5276,8 @@ void issue_assocreq(struct adapter *padapter) /* Check if the AP's supported rates are also supported by STA. */ for (j = 0; j < sta_bssrate_len; j++) { /* Avoid the proprietary data rate (22Mbps) of Handlink WSG-4000 AP */ - if ((pmlmeinfo->network.SupportedRates[i]|IEEE80211_BASIC_RATE_MASK) - == (sta_bssrate[j]|IEEE80211_BASIC_RATE_MASK)) + if ((pmlmeinfo->network.SupportedRates[i] | IEEE80211_BASIC_RATE_MASK) + == (sta_bssrate[j] | IEEE80211_BASIC_RATE_MASK)) break; } @@ -5557,9 +5557,9 @@ static int _issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) SetFrDs(fctrl); - else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) SetToDs(fctrl); if (power_mode) @@ -5672,9 +5672,9 @@ static int _issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 fctrl = &pwlanhdr->frame_ctl; *(fctrl) = 0; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) SetFrDs(fctrl); - else if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + else if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) SetToDs(fctrl); if (pattrib->mdata) @@ -5868,7 +5868,7 @@ exit: return ret; } -void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) +void issue_action_spct_ch_switch(struct adapter *padapter, u8 *ra, u8 new_ch, u8 ch_offset) { struct xmit_frame *pmgntframe; struct pkt_attrib *pattrib; @@ -5918,7 +5918,7 @@ void issue_action_spct_ch_switch (struct adapter *padapter, u8 *ra, u8 new_ch, u pframe = rtw_set_fixed_ie(pframe, 1, &action, &pattrib->pktlen); } - pframe = rtw_set_ie_ch_switch (pframe, &pattrib->pktlen, 0, new_ch, 0); + pframe = rtw_set_ie_ch_switch(pframe, &pattrib->pktlen, 0, new_ch, 0); pframe = rtw_set_ie_secondary_ch_offset(pframe, &pattrib->pktlen, hal_ch_offset_to_secondary_ch_offset(ch_offset)); @@ -6000,7 +6000,7 @@ void issue_action_BA(struct adapter *padapter, unsigned char *raddr, unsigned ch psta = rtw_get_stainfo(pstapriv, raddr); if (psta) { - start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07]&0xfff) + 1; + start_seq = (psta->sta_xmitpriv.txseq_tid[status & 0x07] & 0xfff) + 1; DBG_88E("BA_starting_seqctrl=%d for TID=%d\n", start_seq, status & 0x07); @@ -6200,7 +6200,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; u16 tid; - if ((pmlmeinfo->state&0x03) != WIFI_FW_AP_STATE) + if ((pmlmeinfo->state & 0x03) != WIFI_FW_AP_STATE) if (!(pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS)) return _SUCCESS; @@ -6212,7 +6212,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) for (tid = 0; tid < MAXTID; tid++) { if (psta->recvreorder_ctrl[tid].enable) { DBG_88E("rx agg disable tid(%d)\n", tid); - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F)); psta->recvreorder_ctrl[tid].enable = false; psta->recvreorder_ctrl[tid].indicate_seq = 0xffff; } @@ -6221,7 +6221,7 @@ unsigned int send_delba(struct adapter *padapter, u8 initiator, u8 *addr) for (tid = 0; tid < MAXTID; tid++) { if (psta->htpriv.agg_enable_bitmap & BIT(tid)) { DBG_88E("tx agg disable tid(%d)\n", tid); - issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator)&0x1F)); + issue_action_BA(padapter, addr, RTW_WLAN_ACTION_DELBA, (((tid << 1) | initiator) & 0x1F)); psta->htpriv.agg_enable_bitmap &= ~BIT(tid); psta->htpriv.candidate_tid_bitmap &= ~BIT(tid); } @@ -6247,7 +6247,7 @@ unsigned int send_beacon(struct adapter *padapter) yield(); rtw_hal_get_hwreg(padapter, HW_VAR_BCN_VALID, (u8 *)(&bxmitok)); poll++; - } while ((poll%10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); + } while ((poll % 10) != 0 && !bxmitok && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); } while (!bxmitok && issue < 100 && !padapter->bSurpriseRemoved && !padapter->bDriverStopped); if (padapter->bSurpriseRemoved || padapter->bDriverStopped) @@ -6522,7 +6522,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st p = rtw_get_ie(bssid->IEs + ie_offset, _EXT_SUPPORTEDRATES_IE_, &len, bssid->IELength - ie_offset); if (p) { - if (len > (NDIS_802_11_LENGTH_RATES_EX-i)) { + if (len > (NDIS_802_11_LENGTH_RATES_EX - i)) { DBG_88E("%s()-%d: IE too long (%d) for survey event\n", __func__, __LINE__, len); return _FAIL; } @@ -6582,7 +6582,7 @@ u8 collect_bss_info(struct adapter *padapter, struct recv_frame *precv_frame, st struct HT_caps_element *pHT_caps; pHT_caps = (struct HT_caps_element *)(p + 2); - if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info)&BIT(14)) + if (le16_to_cpu(pHT_caps->u.HT_cap_element.HT_caps_info) & BIT(14)) pmlmepriv->num_FortyMHzIntolerant++; } else { pmlmepriv->num_sta_no_ht++; @@ -6612,7 +6612,7 @@ void start_create_ibss(struct adapter *padapter) /* udpate capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); - if (caps&cap_IBSS) {/* adhoc master */ + if (caps & cap_IBSS) {/* adhoc master */ val8 = 0xcf; rtw_hal_set_hwreg(padapter, HW_VAR_SEC_CFG, (u8 *)(&val8)); @@ -6665,7 +6665,7 @@ void start_clnt_join(struct adapter *padapter) /* udpate capability */ caps = rtw_get_capability((struct wlan_bssid_ex *)pnetwork); update_capinfo(padapter, caps); - if (caps&cap_ESS) { + if (caps & cap_ESS) { Set_MSR(padapter, WIFI_FW_STATION_STATE); val8 = (pmlmeinfo->auth_algo == dot11AuthAlgrthm_8021X) ? 0xcc : 0xcf; @@ -6680,10 +6680,10 @@ void start_clnt_join(struct adapter *padapter) beacon_timeout = decide_wait_for_beacon_timeout(pmlmeinfo->bcn_interval); set_link_timer(pmlmeext, beacon_timeout); _set_timer(&padapter->mlmepriv.assoc_timer, - (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO*REASSOC_LIMIT) + beacon_timeout); + (REAUTH_TO * REAUTH_LIMIT) + (REASSOC_TO * REASSOC_LIMIT) + beacon_timeout); pmlmeinfo->state = WIFI_FW_AUTH_NULL | WIFI_FW_STATION_STATE; - } else if (caps&cap_IBSS) { /* adhoc client */ + } else if (caps & cap_IBSS) { /* adhoc client */ Set_MSR(padapter, WIFI_FW_ADHOC_STATE); val8 = 0xcf; @@ -6757,7 +6757,7 @@ unsigned int receive_disconnect(struct adapter *padapter, unsigned char *MacAddr DBG_88E("%s\n", __func__); - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) { pmlmeinfo->state = WIFI_FW_NULL_STATE; report_del_sta_event(padapter, MacAddr, reason); @@ -7233,7 +7233,7 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) goto exit_mlmeext_joinbss_event_callback; } - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { /* for bc/mc */ psta_bmc = rtw_get_bcmc_stainfo(padapter); if (psta_bmc) { @@ -7274,14 +7274,14 @@ void mlmeext_joinbss_event_callback(struct adapter *padapter, int join_res) /* set per sta rate after updating HT cap. */ set_sta_rate(padapter, psta); rtw_hal_set_hwreg(padapter, HW_VAR_TX_RPT_MAX_MACID, (u8 *)&psta->mac_id); - media_status = (psta->mac_id<<8)|1; /* MACID|OPMODE: 1 means connect */ + media_status = (psta->mac_id << 8) | 1; /* MACID|OPMODE: 1 means connect */ rtw_hal_set_hwreg(padapter, HW_VAR_H2C_MEDIA_STATUS_RPT, (u8 *)&media_status); } join_type = 2; rtw_hal_set_hwreg(padapter, HW_VAR_MLME_JOIN, (u8 *)(&join_type)); - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) { /* correcting TSF */ correct_TSF(padapter, pmlmeext); } @@ -7300,7 +7300,7 @@ void mlmeext_sta_add_event_callback(struct adapter *padapter, struct sta_info *p DBG_88E("%s\n", __func__); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { if (pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) {/* adhoc master or sta_count>1 */ /* nothing to do */ } else { /* adhoc client */ @@ -7372,9 +7372,9 @@ void _linked_rx_signal_strehgth_display(struct adapter *padapter) u8 mac_id; int UndecoratedSmoothedPWDB; - if ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE) + if ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE) mac_id = 0; - else if ((pmlmeinfo->state&0x03) == _HW_STATE_AP_) + else if ((pmlmeinfo->state & 0x03) == _HW_STATE_AP_) mac_id = 2; rtw_hal_get_def_var(padapter, HW_DEF_RA_INFO_DUMP, &mac_id); @@ -7637,7 +7637,7 @@ u8 setopmode_hdl(struct adapter *padapter, u8 *pbuf) pmlmeinfo->state = WIFI_FW_AP_STATE; type = _HW_STATE_AP_; } else if (psetop->mode == Ndis802_11Infrastructure) { - pmlmeinfo->state &= ~(BIT(0)|BIT(1));/* clear state */ + pmlmeinfo->state &= ~(BIT(0) | BIT(1));/* clear state */ pmlmeinfo->state |= WIFI_FW_STATION_STATE;/* set to STATION_STATE */ type = _HW_STATE_STATION_; } else if (psetop->mode == Ndis802_11IBSS) { @@ -7834,7 +7834,7 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) u8 val8; if (is_client_associated_to_ap(padapter)) - issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms/100, 100); + issue_deauth_ex(padapter, pnetwork->MacAddress, WLAN_REASON_DEAUTH_LEAVING, param->deauth_timeout_ms / 100, 100); rtw_hal_set_hwreg(padapter, HW_VAR_MLME_DISCONNECT, NULL); rtw_hal_set_hwreg(padapter, HW_VAR_BSSID, null_addr); @@ -7842,7 +7842,7 @@ u8 disconnect_hdl(struct adapter *padapter, unsigned char *pbuf) /* restore to initial setting. */ update_tx_basic_rate(padapter, padapter->registrypriv.wireless_mode); - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { /* Stop BCN */ val8 = 0; rtw_hal_set_hwreg(padapter, HW_VAR_BCN_FUNC, (u8 *)(&val8)); @@ -7876,7 +7876,7 @@ static int rtw_scan_ch_decision(struct adapter *padapter, struct rtw_ieee80211_c struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; /* clear out first */ - memset(out, 0, sizeof(struct rtw_ieee80211_channel)*out_num); + memset(out, 0, sizeof(struct rtw_ieee80211_channel) * out_num); /* acquire channels from in */ j = 0; @@ -8051,7 +8051,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) DBG_88E_LEVEL(_drv_info_, "set pairwise key to hw: alg:%d(WEP40-1 WEP104-5 TKIP-2 AES-4) camid:%d\n", pparm->algorithm, cam_id); - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { struct sta_info *psta; struct sta_priv *pstapriv = &padapter->stapriv; @@ -8066,7 +8066,7 @@ u8 set_stakey_hdl(struct adapter *padapter, u8 *pbuf) DBG_88E("r871x_set_stakey_hdl(): enc_algorithm=%d\n", pparm->algorithm); - if ((psta->mac_id < 1) || (psta->mac_id > (NUM_STA-4))) { + if ((psta->mac_id < 1) || (psta->mac_id > (NUM_STA - 4))) { DBG_88E("r871x_set_stakey_hdl():set_stakey failed, mac_id(aid)=%d\n", psta->mac_id); return H2C_REJECTED; } @@ -8110,7 +8110,7 @@ u8 add_ba_hdl(struct adapter *padapter, unsigned char *pbuf) return H2C_SUCCESS; if (((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && (pmlmeinfo->HT_enable)) || - ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) { + ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) { issue_action_BA(padapter, pparm->addr, RTW_WLAN_ACTION_ADDBA_REQ, (u16)pparm->tid); _set_timer(&psta->addba_retry_timer, ADDBA_TO); } else { @@ -8144,8 +8144,8 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) memcpy(&ptxBeacon_parm->network, &pmlmeinfo->network, sizeof(struct wlan_bssid_ex)); - len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs+_BEACON_IE_OFFSET_, - ptxBeacon_parm->network.IELength-_BEACON_IE_OFFSET_, + len_diff = update_hidden_ssid(ptxBeacon_parm->network.IEs + _BEACON_IE_OFFSET_, + ptxBeacon_parm->network.IELength - _BEACON_IE_OFFSET_, pmlmeinfo->hidden_ssid_mode); ptxBeacon_parm->network.IELength += len_diff; @@ -8167,8 +8167,8 @@ u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf) struct evt_priv *pevt_priv = &padapter->evtpriv; peventbuf = (uint *)pbuf; - evt_sz = (u16)(*peventbuf&0xffff); - evt_code = (u8)((*peventbuf>>16)&0xff); + evt_sz = (u16)(*peventbuf & 0xffff); + evt_code = (u8)((*peventbuf >> 16) & 0xff); /* checking if event code is valid */ if (evt_code >= MAX_C2HEVT) @@ -8220,7 +8220,7 @@ u8 tx_beacon_hdl(struct adapter *padapter, unsigned char *pbuf) if (!psta_bmc) return H2C_SUCCESS; - if ((pstapriv->tim_bitmap&BIT(0)) && (psta_bmc->sleepq_len > 0)) { + if ((pstapriv->tim_bitmap & BIT(0)) && (psta_bmc->sleepq_len > 0)) { msleep(10);/* 10ms, ATIM(HIQ) Windows */ spin_lock_bh(&psta_bmc->sleep_q.lock); -- cgit v1.2.3 From 61249f2268b5e309bbfb9ed148efb134360fbc24 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:07 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_mp.c Clean up spacing style issues in core/rtw_mp.c reported by checkpatch. CHECK: spaces preferred around that ... WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-13-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 8de6af042156..8c044d3bb61a 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -595,7 +595,7 @@ static int mp_xmit_packet_thread(void *context) } } - memcpy((u8 *)(pxmitframe->buf_addr+TXDESC_OFFSET), pmptx->buf, pmptx->write_size); + memcpy((u8 *)(pxmitframe->buf_addr + TXDESC_OFFSET), pmptx->buf, pmptx->write_size); memcpy(&pxmitframe->attrib, &pmptx->attrib, sizeof(struct pkt_attrib)); dump_mpframe(padapter, pxmitframe); @@ -698,7 +698,7 @@ void SetPacketTx(struct adapter *padapter) /* offset 8 */ /* offset 12 */ - desc->txdw3 |= cpu_to_le32((pattrib->seqnum<<16)&0x0fff0000); + desc->txdw3 |= cpu_to_le32((pattrib->seqnum << 16) & 0x0fff0000); /* offset 16 */ desc->txdw4 |= cpu_to_le32(HW_SSN); @@ -882,7 +882,7 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data) i = psd_start; while (i < psd_stop) { if (i >= psd_pts) { - psd_data = rtw_GetPSDData(pAdapter, i-psd_pts); + psd_data = rtw_GetPSDData(pAdapter, i - psd_pts); } else { psd_data = rtw_GetPSDData(pAdapter, i); } @@ -891,7 +891,7 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data) } msleep(100); - return strlen(data)+1; + return strlen(data) + 1; } void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) @@ -964,7 +964,7 @@ exit: ; } -void Hal_ProSetCrystalCap (struct adapter *pAdapter, u32 CrystalCapVal) +void Hal_ProSetCrystalCap(struct adapter *pAdapter, u32 CrystalCapVal) { CrystalCapVal = CrystalCapVal & 0x3F; -- cgit v1.2.3 From 0296ded555ba48711ba04737fd3fb2971b67eaa6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:08 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_mp_ioctl.c Clean up spacing style issues in core/rtw_mp_ioctl.c reported by checkpatch. CHECK: spaces preferred around that '|' (ctx:VxV) WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-14-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index fed94d66aee0..36091eac0e0f 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -309,7 +309,7 @@ int rtl8188eu_oid_rt_pro_set_antenna_bb_hdl(struct oid_par_priv *poid_par_priv) SetAntenna(Adapter); _irqlevel_changed_(&oldirql, RAISE); } else { - antenna = (Adapter->mppriv.antenna_tx << 16)|Adapter->mppriv.antenna_rx; + antenna = (Adapter->mppriv.antenna_tx << 16) | Adapter->mppriv.antenna_rx; *(u32 *)poid_par_priv->information_buf = antenna; } @@ -734,7 +734,7 @@ int rtl8188eu_oid_rt_pro_read16_eeprom_hdl(struct oid_par_priv *poid_par_priv) } /* */ -int rtl8188eu_oid_rt_pro_write16_eeprom_hdl (struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_pro_write16_eeprom_hdl(struct oid_par_priv *poid_par_priv) { return 0; } @@ -754,7 +754,7 @@ int rtl8188eu_oid_rt_rd_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) return 0; } /* */ -int rtl8188eu_oid_rt_wr_attrib_mem_hdl (struct oid_par_priv *poid_par_priv) +int rtl8188eu_oid_rt_wr_attrib_mem_hdl(struct oid_par_priv *poid_par_priv) { return 0; } -- cgit v1.2.3 From 58bd6fc51411f5cfe2817318c5e6801c46b1243f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:09 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_p2p.c Clean up spacing style issues in core/rtw_p2p.c reported by checkpatch. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited before semicolon WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-15-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_p2p.c | 46 +++++++++++++++++----------------- 1 file changed, 23 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c index 1c2c6193b7af..e2b6cf2386e0 100644 --- a/drivers/staging/r8188eu/core/rtw_p2p.c +++ b/drivers/staging/r8188eu/core/rtw_p2p.c @@ -75,8 +75,8 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) *pcur = psta->num_of_secdev_type; pcur++; - memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type*8); - pcur += psta->num_of_secdev_type*8; + memcpy(pcur, psta->secdev_types_list, psta->num_of_secdev_type * 8); + pcur += psta->num_of_secdev_type * 8; if (psta->dev_name_len > 0) { /* u16*)(pcur) = cpu_to_be16(WPS_ATTR_DEVICE_NAME); */ @@ -91,9 +91,9 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf) pcur += psta->dev_name_len; } - tmplen = (u8)(pcur-pstart); + tmplen = (u8)(pcur - pstart); - *pstart = (tmplen-1); + *pstart = (tmplen - 1); attr_len += tmplen; @@ -419,10 +419,10 @@ u32 build_beacon_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pbuf) /* Be able to participate in additional P2P Groups and */ /* support the P2P Invitation Procedure */ /* Group Capability Bitmap, 1 byte */ - capability = P2P_DEVCAP_INVITATION_PROC|P2P_DEVCAP_CLIENT_DISCOVERABILITY; + capability = P2P_DEVCAP_INVITATION_PROC | P2P_DEVCAP_CLIENT_DISCOVERABILITY; capability |= ((P2P_GRPCAP_GO | P2P_GRPCAP_INTRABSS) << 8); if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_PROVISIONING_ING)) - capability |= (P2P_GRPCAP_GROUP_FORMATION<<8); + capability |= (P2P_GRPCAP_GROUP_FORMATION << 8); le_tmp = cpu_to_le16(capability); p2pielen += rtw_set_p2p_attr_content(&p2pie[p2pielen], P2P_ATTR_CAPABILITY, 2, (u8 *)&le_tmp); @@ -790,7 +790,7 @@ u32 process_probe_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l if (rtw_p2p_chk_role(pwdinfo, P2P_ROLE_DEVICE) || rtw_p2p_chk_role(pwdinfo, P2P_ROLE_GO)) { p2pie = rtw_get_p2p_ie(pframe + WLAN_HDR_A3_LEN + _PROBEREQ_IE_OFFSET_, len - WLAN_HDR_A3_LEN - _PROBEREQ_IE_OFFSET_, NULL, &p2pielen); if (p2pie) { - if (p && !memcmp((void *)(p+2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) { + if (p && !memcmp((void *)(p + 2), (void *)pwdinfo->p2p_wildcard_ssid, 7)) { /* todo: */ /* Check Requested Device Type attributes in WSC IE. */ /* Check Device ID attribute in P2P IE */ @@ -847,7 +847,7 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_CAPABILITY, (u8 *)&le_tmp, (uint *)&attr_contentlen)) { DBG_88E("[%s] Got P2P Capability Attr!!\n", __func__); cap_attr = le16_to_cpu(le_tmp); - psta->dev_cap = cap_attr&0xff; + psta->dev_cap = cap_attr & 0xff; } /* Check Extended Listen Timing ATTR */ @@ -886,28 +886,28 @@ u32 process_assoc_req_p2p_ie(struct wifidirect_info *pwdinfo, u8 *pframe, uint l psta->num_of_secdev_type = num_of_secdev_type; - len = (sizeof(psta->secdev_types_list) < (num_of_secdev_type*8)) ? - (sizeof(psta->secdev_types_list)) : (num_of_secdev_type*8); + len = (sizeof(psta->secdev_types_list) < (num_of_secdev_type * 8)) ? + (sizeof(psta->secdev_types_list)) : (num_of_secdev_type * 8); memcpy(psta->secdev_types_list, pattr_content, len); - pattr_content += (num_of_secdev_type*8); + pattr_content += (num_of_secdev_type * 8); } psta->dev_name_len = 0; if (WPS_ATTR_DEVICE_NAME == be16_to_cpu(*(__be16 *)pattr_content)) { - dev_name_len = be16_to_cpu(*(__be16 *)(pattr_content+2)); + dev_name_len = be16_to_cpu(*(__be16 *)(pattr_content + 2)); psta->dev_name_len = (sizeof(psta->dev_name) < dev_name_len) ? sizeof(psta->dev_name) : dev_name_len; - memcpy(psta->dev_name, pattr_content+4, psta->dev_name_len); + memcpy(psta->dev_name, pattr_content + 4, psta->dev_name_len); } kfree(pbuf); } } /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); } return status_code; @@ -936,7 +936,7 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_GROUP_ID, groupid, &attr_contentlen)) { if (!memcmp(pwdinfo->device_addr, groupid, ETH_ALEN) && - !memcmp(pwdinfo->p2p_group_ssid, groupid+ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { + !memcmp(pwdinfo->p2p_group_ssid, groupid + ETH_ALEN, pwdinfo->p2p_group_ssid_len)) { attr_contentlen = 0; if (rtw_get_p2p_attr_content(p2p_ie, p2p_ielen, P2P_ATTR_DEVICE_ID, dev_addr, &attr_contentlen)) { struct list_head *phead, *plist; @@ -951,7 +951,7 @@ u32 process_p2p_devdisc_req(struct wifidirect_info *pwdinfo, u8 *pframe, uint le plist = plist->next; - if (psta->is_p2p_device && (psta->dev_cap&P2P_DEVCAP_CLIENT_DISCOVERABILITY) && + if (psta->is_p2p_device && (psta->dev_cap & P2P_DEVCAP_CLIENT_DISCOVERABILITY) && !memcmp(psta->dev_addr, dev_addr, ETH_ALEN)) { /* issue GO Discoverability Request */ issue_group_disc_req(pwdinfo, psta->hwaddr); @@ -1038,7 +1038,7 @@ static u8 rtw_p2p_get_peer_ch_list(struct wifidirect_info *pwdinfo, u8 *ch_conte peer_ch_list[j] = *(ch_content + 1 + i); ch_content += (temp + 1); ch_cnt -= (temp + 1); - ch_no += temp ; + ch_no += temp; } return ch_no; @@ -1198,7 +1198,7 @@ u8 process_p2p_group_negotation_req(struct wifidirect_info *pwdinfo, u8 *pframe, } /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); } return result; } @@ -1360,7 +1360,7 @@ u8 process_p2p_group_negotation_resp(struct wifidirect_info *pwdinfo, u8 *pframe } /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); } } return result; @@ -1431,7 +1431,7 @@ u8 process_p2p_group_negotation_confirm(struct wifidirect_info *pwdinfo, u8 *pfr } /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); } return result; } @@ -1623,7 +1623,7 @@ void process_p2p_ps_ie(struct adapter *padapter, u8 *IEs, u32 IELength) } /* Get the next P2P IE */ - p2p_ie = rtw_get_p2p_ie(p2p_ie+p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); + p2p_ie = rtw_get_p2p_ie(p2p_ie + p2p_ielen, ies_len - (p2p_ie - ies + p2p_ielen), NULL, &p2p_ielen); } if (find_p2p) { @@ -1740,7 +1740,7 @@ static void reset_ch_sitesurvey_timer_process(struct timer_list *t) pwdinfo->rx_invitereq_info.scan_op_ch_only = 0; } -static void reset_ch_sitesurvey_timer_process2 (struct timer_list *t) +static void reset_ch_sitesurvey_timer_process2(struct timer_list *t) { struct adapter *adapter = from_timer(adapter, t, pwrctrlpriv.pwr_state_check_timer); struct wifidirect_info *pwdinfo = &adapter->wdinfo; @@ -1902,7 +1902,7 @@ void init_wifidirect_info(struct adapter *padapter, enum P2P_ROLE role) rtw_p2p_findphase_ex_set(pwdinfo, P2P_FINDPHASE_EX_NONE); - pwdinfo->listen_dwell = (u8) ((jiffies % 3) + 1); + pwdinfo->listen_dwell = (u8)((jiffies % 3) + 1); memset(&pwdinfo->tx_prov_disc_info, 0x00, sizeof(struct tx_provdisc_req_info)); pwdinfo->tx_prov_disc_info.wps_config_method_request = WPS_CM_NONE; -- cgit v1.2.3 From 63852ff22d8a6159de4e74b54ca74c1320140e7c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:10 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_pwrctrl.c Clean up spacing style issues in core/rtw_pwrctrl.c reported by checkpatch. CHECK: spaces preferred around that ... WARNING: space prohibited before semicolon Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-16-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 9a00a316674b..34e4c3339b56 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -108,11 +108,11 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) if (adapter->pwrctrlpriv.ips_deny_time >= jiffies) goto exit; - if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || - check_fwstate(pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + if (check_fwstate(pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) || + check_fwstate(pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) || check_fwstate(pmlmepriv, WIFI_UNDER_WPS) || check_fwstate(pmlmepriv, WIFI_AP_STATE) || - check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE) || #if defined(CONFIG_88EU_P2P) !rtw_p2p_chk_state(pwdinfo, P2P_STATE_NONE)) #else @@ -127,10 +127,10 @@ static bool rtw_pwr_unassociated_idle(struct adapter *adapter) struct wifidirect_info *b_pwdinfo = &buddy->wdinfo; #endif - if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE|WIFI_SITE_MONITOR) || - check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING|WIFI_UNDER_WPS) || + if (check_fwstate(b_pmlmepriv, WIFI_ASOC_STATE | WIFI_SITE_MONITOR) || + check_fwstate(b_pmlmepriv, WIFI_UNDER_LINKING | WIFI_UNDER_WPS) || check_fwstate(b_pmlmepriv, WIFI_AP_STATE) || - check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE|WIFI_ADHOC_STATE) || + check_fwstate(b_pmlmepriv, WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE) || #if defined(CONFIG_88EU_P2P) !rtw_p2p_chk_state(b_pwdinfo, P2P_STATE_NONE)) #else @@ -180,7 +180,7 @@ void rtw_ps_processor(struct adapter *padapter) if (!rtw_pwr_unassociated_idle(padapter)) goto exit; - if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts%4) == 0)) { + if ((pwrpriv->rf_pwrstate == rf_on) && ((pwrpriv->pwr_state_check_cnts % 4) == 0)) { DBG_88E("==>%s .fw_state(%x)\n", __func__, get_fwstate(pmlmepriv)); pwrpriv->change_rfpwrstate = rf_off; @@ -444,7 +444,7 @@ void rtw_init_pwrctrl_priv(struct adapter *padapter) pwrctrlpriv->LpsIdleCount = 0; if (padapter->registrypriv.mp_mode == 1) - pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE ; + pwrctrlpriv->power_mgnt = PS_MODE_ACTIVE; else pwrctrlpriv->power_mgnt = padapter->registrypriv.power_mgnt;/* PS_MODE_MIN; */ pwrctrlpriv->bLeisurePs = (PS_MODE_ACTIVE != pwrctrlpriv->power_mgnt) ? true : false; -- cgit v1.2.3 From 7527c5ea758cc5219bdf1844c669048653b6c9c8 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:11 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_recv.c Clean up spacing style issues in core/rtw_recv.c reported by checkpatch. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-17-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 112 ++++++++++++++++---------------- 1 file changed, 56 insertions(+), 56 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 8df38db9572c..c28e0204d18b 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -30,7 +30,7 @@ void rtw_signal_stat_timer_hdl(struct timer_list *); void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv) { - memset((u8 *)psta_recvpriv, 0, sizeof (struct sta_recv_priv)); + memset((u8 *)psta_recvpriv, 0, sizeof(struct sta_recv_priv)); spin_lock_init(&psta_recvpriv->lock); @@ -96,7 +96,7 @@ exit: return res; } -void _rtw_free_recv_priv (struct recv_priv *precvpriv) +void _rtw_free_recv_priv(struct recv_priv *precvpriv) { struct adapter *padapter = precvpriv->adapter; @@ -109,7 +109,7 @@ void _rtw_free_recv_priv (struct recv_priv *precvpriv) rtw_hal_free_recv_priv(padapter); } -struct recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +struct recv_frame *_rtw_alloc_recvframe(struct __queue *pfree_recv_queue) { struct recv_frame *hdr; struct list_head *plist, *phead; @@ -137,7 +137,7 @@ struct recv_frame *_rtw_alloc_recvframe (struct __queue *pfree_recv_queue) return (struct recv_frame *)hdr; } -struct recv_frame *rtw_alloc_recvframe (struct __queue *pfree_recv_queue) +struct recv_frame *rtw_alloc_recvframe(struct __queue *pfree_recv_queue) { struct recv_frame *precvframe; @@ -285,7 +285,7 @@ int rtw_enqueue_recvbuf(struct recv_buf *precvbuf, struct __queue *queue) return _SUCCESS; } -struct recv_buf *rtw_dequeue_recvbuf (struct __queue *queue) +struct recv_buf *rtw_dequeue_recvbuf(struct __queue *queue) { struct recv_buf *precvbuf; struct list_head *plist, *phead; @@ -342,19 +342,19 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr mickey = &stainfo->dot11tkiprxmickey.skey[0]; } - datalen = precvframe->len-prxattrib->hdrlen-prxattrib->iv_len-prxattrib->icv_len-8;/* icv_len included the mic code */ + datalen = precvframe->len - prxattrib->hdrlen - prxattrib->iv_len - prxattrib->icv_len - 8;/* icv_len included the mic code */ pframe = precvframe->rx_data; - payload = pframe+prxattrib->hdrlen+prxattrib->iv_len; + payload = pframe + prxattrib->hdrlen + prxattrib->iv_len; rtw_seccalctkipmic(mickey, pframe, payload, datalen, &miccode[0], (unsigned char)prxattrib->priority); /* care the length of the data */ - pframemic = payload+datalen; + pframemic = payload + datalen; bmic_err = false; for (i = 0; i < 8; i++) { - if (miccode[i] != *(pframemic+i)) + if (miccode[i] != *(pframemic + i)) bmic_err = true; } @@ -395,8 +395,8 @@ static struct recv_frame *decryptor(struct adapter *padapter, struct recv_frame u32 res = _SUCCESS; if (prxattrib->encrypt > 0) { - u8 *iv = precv_frame->rx_data+prxattrib->hdrlen; - prxattrib->key_index = (((iv[3])>>6)&0x3); + u8 *iv = precv_frame->rx_data + prxattrib->hdrlen; + prxattrib->key_index = (((iv[3]) >> 6) & 0x3); if (prxattrib->key_index > WEP_KEYS) { DBG_88E("prxattrib->key_index(%d)>WEP_KEYS\n", prxattrib->key_index); @@ -480,7 +480,7 @@ static struct recv_frame *portctrl(struct adapter *adapter, struct recv_frame *p prtnframe = precv_frame; /* get ether_type */ - ptr = ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; + ptr = ptr + pfhdr->attrib.hdrlen + pfhdr->attrib.iv_len + LLC_HEADER_SIZE; memcpy(&be_tmp, ptr, 2); ether_type = ntohs(be_tmp); @@ -507,7 +507,7 @@ static int recv_decache(struct recv_frame *precv_frame, u8 bretry, struct stainf { int tid = precv_frame->attrib.priority; - u16 seq_ctrl = ((precv_frame->attrib.seq_num&0xffff) << 4) | + u16 seq_ctrl = ((precv_frame->attrib.seq_num & 0xffff) << 4) | (precv_frame->attrib.frag_num & 0xf); if (tid > 15) @@ -565,29 +565,29 @@ static void process_wmmps_data(struct adapter *padapter, struct recv_frame *prec if (!psta->qos_option) return; - if (!(psta->qos_info&0xf)) + if (!(psta->qos_info & 0xf)) return; - if (psta->state&WIFI_SLEEP_STATE) { + if (psta->state & WIFI_SLEEP_STATE) { u8 wmmps_ac = 0; switch (pattrib->priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(1); + wmmps_ac = psta->uapsd_bk & BIT(1); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(1); + wmmps_ac = psta->uapsd_vi & BIT(1); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(1); + wmmps_ac = psta->uapsd_vo & BIT(1); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(1); + wmmps_ac = psta->uapsd_be & BIT(1); break; } @@ -727,7 +727,7 @@ exit: return ret; } -static int ap2sta_data_frame ( +static int ap2sta_data_frame( struct adapter *adapter, struct recv_frame *precv_frame, struct sta_info **psta) @@ -917,20 +917,20 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, switch (pattrib->priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(0); + wmmps_ac = psta->uapsd_bk & BIT(0); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(0); + wmmps_ac = psta->uapsd_vi & BIT(0); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(0); + wmmps_ac = psta->uapsd_vo & BIT(0); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(0); + wmmps_ac = psta->uapsd_be & BIT(0); break; } @@ -943,7 +943,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, psta->state ^= WIFI_STA_ALIVE_CHK_STATE; } - if ((psta->state&WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap&BIT(psta->aid))) { + if ((psta->state & WIFI_SLEEP_STATE) && (pstapriv->sta_dz_bitmap & BIT(psta->aid))) { struct list_head *xmitframe_plist, *xmitframe_phead; struct xmit_frame *pxmitframe = NULL; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; @@ -979,7 +979,7 @@ static int validate_recv_ctrl_frame(struct adapter *padapter, update_beacon(padapter, _TIM_IE_, NULL, false); } } else { - if (pstapriv->tim_bitmap&BIT(psta->aid)) { + if (pstapriv->tim_bitmap & BIT(psta->aid)) { if (psta->sleepq_len == 0) { DBG_88E("no buffered packets to xmit\n"); @@ -1162,7 +1162,7 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv u8 bDumpRxPkt; struct rx_pkt_attrib *pattrib = &precv_frame->attrib; u8 *ptr = precv_frame->rx_data; - u8 ver = (unsigned char) (*ptr)&0x3; + u8 ver = (unsigned char)(*ptr) & 0x3; struct mlme_ext_priv *pmlmeext = &adapter->mlmeextpriv; if (pmlmeext->sitesurvey_res.state == SCAN_PROCESS) { @@ -1197,18 +1197,18 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv int i; DBG_88E("#############################\n"); - for (i = 0; i < 64; i = i+8) - DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), - *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + for (i = 0; i < 64; i = i + 8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr + i), + *(ptr + i + 1), *(ptr + i + 2), *(ptr + i + 3), *(ptr + i + 4), *(ptr + i + 5), *(ptr + i + 6), *(ptr + i + 7)); DBG_88E("#############################\n"); } else if (bDumpRxPkt == 2) { if (type == WIFI_MGT_TYPE) { int i; DBG_88E("#############################\n"); - for (i = 0; i < 64; i = i+8) - DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), - *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + for (i = 0; i < 64; i = i + 8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr + i), + *(ptr + i + 1), *(ptr + i + 2), *(ptr + i + 3), *(ptr + i + 4), *(ptr + i + 5), *(ptr + i + 6), *(ptr + i + 7)); DBG_88E("#############################\n"); } } else if (bDumpRxPkt == 3) { @@ -1216,9 +1216,9 @@ static int validate_recv_frame(struct adapter *adapter, struct recv_frame *precv int i; DBG_88E("#############################\n"); - for (i = 0; i < 64; i = i+8) - DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr+i), - *(ptr+i+1), *(ptr+i+2), *(ptr+i+3), *(ptr+i+4), *(ptr+i+5), *(ptr+i+6), *(ptr+i+7)); + for (i = 0; i < 64; i = i + 8) + DBG_88E("%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X:\n", *(ptr + i), + *(ptr + i + 1), *(ptr + i + 2), *(ptr + i + 3), *(ptr + i + 4), *(ptr + i + 5), *(ptr + i + 6), *(ptr + i + 7)); DBG_88E("#############################\n"); } } @@ -1252,7 +1252,7 @@ exit: /* remove the wlanhdr and add the eth_hdr */ -static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) +static int wlanhdr_to_ethhdr(struct recv_frame *precvframe) { int rmv_len; u16 eth_type, len; @@ -1271,8 +1271,8 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) if (pattrib->encrypt) recvframe_pull_tail(precvframe, pattrib->icv_len); - psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len); - psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE; + psnap = (struct ieee80211_snap_hdr *)(ptr + pattrib->hdrlen + pattrib->iv_len); + psnap_type = ptr + pattrib->hdrlen + pattrib->iv_len + SNAP_SIZE; /* convert hdr + possible LLC headers into Ethernet header */ if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) && memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) && @@ -1288,30 +1288,30 @@ static int wlanhdr_to_ethhdr (struct recv_frame *precvframe) rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0); len = precvframe->len - rmv_len; - memcpy(&be_tmp, ptr+rmv_len, 2); + memcpy(&be_tmp, ptr + rmv_len, 2); eth_type = ntohs(be_tmp); /* pattrib->ether_type */ pattrib->eth_type = eth_type; if ((check_fwstate(pmlmepriv, WIFI_MP_STATE))) { ptr += rmv_len; *ptr = 0x87; - *(ptr+1) = 0x12; + *(ptr + 1) = 0x12; eth_type = 0x8712; /* append rx status for mp test packets */ - ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr)+2)-24); + ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + 2) - 24); memcpy(ptr, get_rxmem(precvframe), 24); ptr += 24; } else { - ptr = recvframe_pull(precvframe, (rmv_len-sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0))); + ptr = recvframe_pull(precvframe, (rmv_len - sizeof(struct ethhdr) + (bsnaphdr ? 2 : 0))); } memcpy(ptr, pattrib->dst, ETH_ALEN); - memcpy(ptr+ETH_ALEN, pattrib->src, ETH_ALEN); + memcpy(ptr + ETH_ALEN, pattrib->src, ETH_ALEN); if (!bsnaphdr) { be_tmp = htons(len); - memcpy(ptr+12, &be_tmp, 2); + memcpy(ptr + 12, &be_tmp, 2); } return ret; @@ -1558,7 +1558,7 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) pdata += nSubframe_Length; a_len -= nSubframe_Length; if (a_len != 0) { - padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4-1)); + padding_len = 4 - ((nSubframe_Length + ETH_HLEN) & (4 - 1)); if (padding_len == 4) { padding_len = 0; } @@ -1755,7 +1755,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame preorder_ctrl->indicate_seq = pattrib->seq_num; rtw_recv_indicatepkt(padapter, prframe); - preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096; + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) % 4096; return _SUCCESS; } } else if (pattrib->amsdu == 1) { /* temp filter -> means didn't support A-MSDUs in a A-MPDU */ @@ -1763,7 +1763,7 @@ static int recv_indicatepkt_reorder(struct adapter *padapter, struct recv_frame preorder_ctrl->indicate_seq = pattrib->seq_num; retval = amsdu_to_msdu(padapter, prframe); - preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1)%4096; + preorder_ctrl->indicate_seq = (preorder_ctrl->indicate_seq + 1) % 4096; return retval; } } @@ -1843,7 +1843,7 @@ static int process_recv_indicatepkts(struct adapter *padapter, struct recv_frame } } } else { /* B/G mode */ - retval = wlanhdr_to_ethhdr (prframe); + retval = wlanhdr_to_ethhdr(prframe); if (retval != _SUCCESS) return retval; @@ -1963,7 +1963,7 @@ static int recv_func(struct adapter *padapter, struct recv_frame *rframe) !psecuritypriv->busetkipkey) { rtw_enqueue_recvframe(rframe, &padapter->recvpriv.uc_swdec_pending_queue); DBG_88E("%s: no key, enqueue uc_swdec_pending_queue\n", __func__); - if (recvpriv->free_recvframe_cnt < NR_RECVFRAME/4) { + if (recvpriv->free_recvframe_cnt < NR_RECVFRAME / 4) { /* to prevent from recvframe starvation, * get recvframe from uc_swdec_pending_queue to * free_recvframe_cnt */ @@ -2036,19 +2036,19 @@ void rtw_signal_stat_timer_hdl(struct timer_list *t) /* update value of signal_strength, rssi, signal_qual */ if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == false) { - tmp_s = (avg_signal_strength+(_alpha-1)*recvpriv->signal_strength); + tmp_s = (avg_signal_strength + (_alpha - 1) * recvpriv->signal_strength); if (tmp_s % _alpha) - tmp_s = tmp_s/_alpha + 1; + tmp_s = tmp_s / _alpha + 1; else - tmp_s = tmp_s/_alpha; + tmp_s = tmp_s / _alpha; if (tmp_s > 100) tmp_s = 100; - tmp_q = (avg_signal_qual+(_alpha-1)*recvpriv->signal_qual); + tmp_q = (avg_signal_qual + (_alpha - 1) * recvpriv->signal_qual); if (tmp_q % _alpha) - tmp_q = tmp_q/_alpha + 1; + tmp_q = tmp_q / _alpha + 1; else - tmp_q = tmp_q/_alpha; + tmp_q = tmp_q / _alpha; if (tmp_q > 100) tmp_q = 100; -- cgit v1.2.3 From 88a924bf3f8e895a45a88b6a1178afc580c8f94c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:12 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_security.c Clean up spacing style issues in core/rtw_security.c reported by checkpatch. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited before semicolon Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-18-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_security.c | 188 ++++++++++++++-------------- 1 file changed, 94 insertions(+), 94 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index 845301476e8b..b9ab4b20ed8e 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -108,25 +108,25 @@ void rtw_wep_encrypt(struct adapter *padapter, u8 *pxmitframe) keylength = psecuritypriv->dot11DefKeylen[psecuritypriv->dot11PrivacyKeyIndex]; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; + iv = pframe + pattrib->hdrlen; memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[psecuritypriv->dot11PrivacyKeyIndex].skey[0], keylength); - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + payload = pframe + pattrib->iv_len + pattrib->hdrlen; - if ((curfragnum+1) == pattrib->nr_frags) { /* the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + if ((curfragnum + 1) == pattrib->nr_frags) { /* the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_init(&mycontext, wepkey, 3 + keylength); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); + arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_init(&mycontext, wepkey, 3 + keylength); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); + arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((size_t)(pframe)); @@ -151,17 +151,17 @@ void rtw_wep_decrypt(struct adapter *padapter, u8 *precvframe) /* start to decrypt recvframe */ if ((prxattrib->encrypt == _WEP40_) || (prxattrib->encrypt == _WEP104_)) { - iv = pframe+prxattrib->hdrlen; + iv = pframe + prxattrib->hdrlen; keyindex = prxattrib->key_index; keylength = psecuritypriv->dot11DefKeylen[keyindex]; memcpy(&wepkey[0], iv, 3); memcpy(&wepkey[3], &psecuritypriv->dot11DefKey[keyindex].skey[0], keylength); - length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len - prxattrib->hdrlen - prxattrib->iv_len; - payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; + payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; /* decrypt payload include icv */ - arcfour_init(&mycontext, wepkey, 3+keylength); + arcfour_init(&mycontext, wepkey, 3 + keylength); arcfour_encrypt(&mycontext, payload, payload, length); } } @@ -175,7 +175,7 @@ static u32 secmicgetuint32(u8 *p) u32 res = 0; for (i = 0; i < 4; i++) - res |= ((u32)(*p++)) << (8*i); + res |= ((u32)(*p++)) << (8 * i); return res; } @@ -186,7 +186,7 @@ static void secmicputuint32(u8 *p, u32 val) long i; for (i = 0; i < 4; i++) { - *p++ = (u8) (val & 0xff); + *p++ = (u8)(val & 0xff); val >>= 8; } @@ -218,7 +218,7 @@ void rtw_secmicappendbyte(struct mic_data *pmicdata, u8 b) { /* Append the byte to our word-sized buffer */ - pmicdata->M |= ((unsigned long)b) << (8*pmicdata->nBytesInM); + pmicdata->M |= ((unsigned long)b) << (8 * pmicdata->nBytesInM); pmicdata->nBytesInM++; /* Process the word if it is full. */ if (pmicdata->nBytesInM >= 4) { @@ -263,7 +263,7 @@ void rtw_secgetmic(struct mic_data *pmicdata, u8 *dst) rtw_secmicappendbyte(pmicdata, 0); /* The appendByte function has already computed the result. */ secmicputuint32(dst, pmicdata->L); - secmicputuint32(dst+4, pmicdata->R); + secmicputuint32(dst + 4, pmicdata->R); /* Reset to the empty message. */ secmicclear(pmicdata); @@ -278,15 +278,15 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod priority[0] = pri; /* Michael MIC pseudo header: DA, SA, 3 x 0, Priority */ - if (header[1]&1) { /* ToDS == 1 */ + if (header[1] & 1) { /* ToDS == 1 */ rtw_secmicappend(&micdata, &header[16], 6); /* DA */ - if (header[1]&2) /* From Ds == 1 */ + if (header[1] & 2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &header[24], 6); else rtw_secmicappend(&micdata, &header[10], 6); } else { /* ToDS == 0 */ rtw_secmicappend(&micdata, &header[4], 6); /* DA */ - if (header[1]&2) /* From Ds == 1 */ + if (header[1] & 2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &header[16], 6); else rtw_secmicappend(&micdata, &header[10], 6); @@ -308,7 +308,7 @@ void rtw_seccalctkipmic(u8 *key, u8 *header, u8 *data, u32 data_len, u8 *mic_cod #define Mk16(hi, lo) ((lo) ^ (((u16)(hi)) << 8)) /* select the Nth 16-bit word of the temporal key unsigned char array TK[] */ -#define TK16(N) Mk16(tk[2*(N)+1], tk[2*(N)]) +#define TK16(N) Mk16(tk[2 * (N) + 1], tk[2 * (N)]) /* S-box lookup: 16 bits --> 16 bits */ #define _S_(v16) (Sbox1[0][Lo8(v16)] ^ Sbox1[1][Hi8(v16)]) @@ -424,11 +424,11 @@ static void phase1(u16 *p1k, const u8 *tk, const u8 *ta, u32 iv32) /* Now compute an unbalanced Feistel cipher with 80-bit block */ /* size on the 80-bit block P1K[], using the 128-bit key TK[] */ for (i = 0; i < PHASE1_LOOP_CNT; i++) { /* Each add operation here is mod 2**16 */ - p1k[0] += _S_(p1k[4] ^ TK16((i&1)+0)); - p1k[1] += _S_(p1k[0] ^ TK16((i&1)+2)); - p1k[2] += _S_(p1k[1] ^ TK16((i&1)+4)); - p1k[3] += _S_(p1k[2] ^ TK16((i&1)+6)); - p1k[4] += _S_(p1k[3] ^ TK16((i&1)+0)); + p1k[0] += _S_(p1k[4] ^ TK16((i & 1) + 0)); + p1k[1] += _S_(p1k[0] ^ TK16((i & 1) + 2)); + p1k[2] += _S_(p1k[1] ^ TK16((i & 1) + 4)); + p1k[3] += _S_(p1k[2] ^ TK16((i & 1) + 6)); + p1k[4] += _S_(p1k[3] ^ TK16((i & 1) + 0)); p1k[4] += (unsigned short)i; /* avoid "slide attacks" */ } @@ -495,8 +495,8 @@ static void phase2(u8 *rc4key, const u8 *tk, const u16 *p1k, u16 iv16) /* Copy 96 bits of PPK[0..5] to RC4KEY[4..15] (little-endian) */ for (i = 0; i < 6; i++) { - rc4key[4+2*i] = Lo8(PPK[i]); - rc4key[5+2*i] = Hi8(PPK[i]); + rc4key[4 + 2 * i] = Lo8(PPK[i]); + rc4key[5 + 2 * i] = Hi8(PPK[i]); } } @@ -544,30 +544,30 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) prwskey = &stainfo->dot118021x_UncstKey.skey[0]; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - iv = pframe+pattrib->hdrlen; - payload = pframe+pattrib->iv_len+pattrib->hdrlen; + iv = pframe + pattrib->hdrlen; + payload = pframe + pattrib->iv_len + pattrib->hdrlen; GET_TKIP_PN(iv, dot11txpn); pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16); + pnh = (u32)(dot11txpn.val >> 16); phase1((u16 *)&ttkey[0], prwskey, &pattrib->ta[0], pnh); phase2(&rc4key[0], prwskey, (u16 *)&ttkey[0], pnl); - if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); + arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); arcfour_init(&mycontext, rc4key, 16); arcfour_encrypt(&mycontext, payload, payload, length); - arcfour_encrypt(&mycontext, payload+length, crc.f1, 4); + arcfour_encrypt(&mycontext, payload + length, crc.f1, 4); pframe += pxmitpriv->frag_len; pframe = (u8 *)RND4((size_t)(pframe)); @@ -619,14 +619,14 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } - iv = pframe+prxattrib->hdrlen; - payload = pframe+prxattrib->iv_len+prxattrib->hdrlen; - length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; + iv = pframe + prxattrib->hdrlen; + payload = pframe + prxattrib->iv_len + prxattrib->hdrlen; + length = ((struct recv_frame *)precvframe)->len - prxattrib->hdrlen - prxattrib->iv_len; GET_TKIP_PN(iv, dot11txpn); pnl = (u16)(dot11txpn.val); - pnh = (u32)(dot11txpn.val>>16); + pnh = (u32)(dot11txpn.val >> 16); phase1((u16 *)&ttkey[0], prwskey, &prxattrib->ta[0], pnh); phase2(&rc4key[0], prwskey, (unsigned short *)&ttkey[0], pnl); @@ -638,10 +638,10 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) crc.f0 = cpu_to_le32(~crc32_le(~0, payload, length)); - if (crc.f1[3] != payload[length-1] || - crc.f1[2] != payload[length-2] || - crc.f1[1] != payload[length-3] || - crc.f1[0] != payload[length-4]) + if (crc.f1[3] != payload[length - 1] || + crc.f1[2] != payload[length - 2] || + crc.f1[1] != payload[length - 3] || + crc.f1[0] != payload[length - 4]) res = _FAIL; } else { res = _FAIL; @@ -832,7 +832,7 @@ static void mix_column(u8 *in, u8 *out) for (i = 3; i > 0; i--) { /* logical shift left 1 bit */ andf7[i] = andf7[i] << 1; - if ((andf7[i-1] & 0x80) == 0x80) + if ((andf7[i - 1] & 0x80) == 0x80) andf7[i] = (andf7[i] | 0x01); } andf7[0] = andf7[0] << 1; @@ -906,8 +906,8 @@ static void construct_mic_iv(u8 *mic_iv, int qc_exists, int a4_exists, u8 *mpdu, mic_iv[i] = mpdu[i + 8]; /* mic_iv[2:7] = A2[0:5] = mpdu[10:15] */ for (i = 8; i < 14; i++) mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */ - mic_iv[14] = (unsigned char) (payload_length / 256); - mic_iv[15] = (unsigned char) (payload_length % 256); + mic_iv[14] = (unsigned char)(payload_length / 256); + mic_iv[15] = (unsigned char)(payload_length % 256); } @@ -962,7 +962,7 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int if (!qc_exists && a4_exists) { for (i = 0; i < 6; i++) - mic_header2[8+i] = mpdu[24+i]; /* A4 */ + mic_header2[8 + i] = mpdu[24 + i]; /* A4 */ } if (qc_exists && !a4_exists) { @@ -972,7 +972,7 @@ static void construct_mic_header2(u8 *mic_header2, u8 *mpdu, int a4_exists, int if (qc_exists && a4_exists) { for (i = 0; i < 6; i++) - mic_header2[8+i] = mpdu[24+i]; /* A4 */ + mic_header2[8 + i] = mpdu[24 + i]; /* A4 */ mic_header2[14] = mpdu[30] & 0x0f; mic_header2[15] = mpdu[31] & 0x00; @@ -1003,8 +1003,8 @@ static void construct_ctr_preload(u8 *ctr_preload, int a4_exists, int qc_exists, ctr_preload[i] = mpdu[i + 8]; /* ctr_preload[2:7] = A2[0:5] = mpdu[10:15] */ for (i = 8; i < 14; i++) ctr_preload[i] = pn_vector[13 - i]; /* ctr_preload[8:13] = PN[5:0] */ - ctr_preload[14] = (unsigned char) (c / 256); /* Ctr */ - ctr_preload[15] = (unsigned char) (c % 256); + ctr_preload[14] = (unsigned char)(c / 256); /* Ctr */ + ctr_preload[15] = (unsigned char)(c % 256); } @@ -1040,7 +1040,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); - frsubtype = frsubtype>>4; + frsubtype = frsubtype >> 4; memset((void *)mic_iv, 0, 16); memset((void *)mic_header1, 0, 16); @@ -1068,11 +1068,11 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) } pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; construct_mic_iv(mic_iv, qc_exists, a4_exists, pframe, plen, pn_vector); @@ -1114,11 +1114,11 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) /* Insert MIC into payload */ for (j = 0; j < 8; j++) - pframe[payload_index+j] = mic[j]; /* message[payload_index+j] = mic[j]; */ + pframe[payload_index + j] = mic[j]; /* message[payload_index+j] = mic[j]; */ payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i + 1); aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); for (j = 0; j < 16; j++) @@ -1127,12 +1127,12 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; + padded_buffer[j] = pframe[payload_index + j]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1144,7 +1144,7 @@ static int aes_cipher(u8 *key, uint hdrlen, u8 *pframe, uint plen) for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < 8; j++) - padded_buffer[j] = pframe[j+hdrlen+8+plen]; + padded_buffer[j] = pframe[j + hdrlen + 8 + plen]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); @@ -1193,12 +1193,12 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) else prwskey = &stainfo->dot118021x_UncstKey.skey[0]; for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { - if ((curfragnum+1) == pattrib->nr_frags) { /* 4 the last fragment */ - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len; + if ((curfragnum + 1) == pattrib->nr_frags) { /* 4 the last fragment */ + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-pattrib->icv_len ; + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - pattrib->icv_len; aes_cipher(prwskey, pattrib->hdrlen, pframe, length); pframe += pxmitpriv->frag_len; @@ -1236,7 +1236,7 @@ static int aes_decipher(u8 *key, uint hdrlen, uint frtype = GetFrameType(pframe); uint frsubtype = GetFrameSubType(pframe); - frsubtype = frsubtype>>4; + frsubtype = frsubtype >> 4; memset((void *)mic_iv, 0, 16); memset((void *)mic_header1, 0, 16); @@ -1248,16 +1248,16 @@ static int aes_decipher(u8 *key, uint hdrlen, /* start to decrypt the payload */ - num_blocks = (plen-8) / 16; /* plen including llc, payload_length and mic) */ + num_blocks = (plen - 8) / 16; /* plen including llc, payload_length and mic) */ - payload_remainder = (plen-8) % 16; + payload_remainder = (plen - 8) % 16; pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; if ((hdrlen == WLAN_HDR_A3_LEN) || (hdrlen == WLAN_HDR_A3_QOS_LEN)) a4_exists = 0; @@ -1283,7 +1283,7 @@ static int aes_decipher(u8 *key, uint hdrlen, payload_index = hdrlen + 8; /* 8 is for extiv */ for (i = 0; i < num_blocks; i++) { - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, i + 1); aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &pframe[payload_index], chain_buffer); @@ -1294,12 +1294,12 @@ static int aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, pframe, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = pframe[payload_index+j]; + padded_buffer[j] = pframe[payload_index + j]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1307,22 +1307,22 @@ static int aes_decipher(u8 *key, uint hdrlen, } /* start to calculate the mic */ - if ((hdrlen+plen+8) <= MAX_MSG_SIZE) - memcpy(message, pframe, (hdrlen + plen+8)); /* 8 is for ext iv len */ + if ((hdrlen + plen + 8) <= MAX_MSG_SIZE) + memcpy(message, pframe, (hdrlen + plen + 8)); /* 8 is for ext iv len */ pn_vector[0] = pframe[hdrlen]; - pn_vector[1] = pframe[hdrlen+1]; - pn_vector[2] = pframe[hdrlen+4]; - pn_vector[3] = pframe[hdrlen+5]; - pn_vector[4] = pframe[hdrlen+6]; - pn_vector[5] = pframe[hdrlen+7]; - construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen-8, pn_vector); + pn_vector[1] = pframe[hdrlen + 1]; + pn_vector[2] = pframe[hdrlen + 4]; + pn_vector[3] = pframe[hdrlen + 5]; + pn_vector[4] = pframe[hdrlen + 6]; + pn_vector[5] = pframe[hdrlen + 7]; + construct_mic_iv(mic_iv, qc_exists, a4_exists, message, plen - 8, pn_vector); construct_mic_header1(mic_header1, hdrlen, message); construct_mic_header2(mic_header2, message, a4_exists, qc_exists); - payload_remainder = (plen-8) % 16; - num_blocks = (plen-8) / 16; + payload_remainder = (plen - 8) % 16; + num_blocks = (plen - 8) / 16; /* Find start of payload */ payload_index = (hdrlen + 8); @@ -1356,11 +1356,11 @@ static int aes_decipher(u8 *key, uint hdrlen, /* Insert MIC into payload */ for (j = 0; j < 8; j++) - message[payload_index+j] = mic[j]; + message[payload_index + j] = mic[j]; payload_index = hdrlen + 8; for (i = 0; i < num_blocks; i++) { - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, i+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, i + 1); aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, &message[payload_index], chain_buffer); for (j = 0; j < 16; j++) @@ -1369,12 +1369,12 @@ static int aes_decipher(u8 *key, uint hdrlen, if (payload_remainder > 0) { /* If there is a short final block, then pad it,*/ /* encrypt it and copy the unpadded part back */ - construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, num_blocks+1); + construct_ctr_preload(ctr_preload, a4_exists, qc_exists, message, pn_vector, num_blocks + 1); for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < payload_remainder; j++) - padded_buffer[j] = message[payload_index+j]; + padded_buffer[j] = message[payload_index + j]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); for (j = 0; j < payload_remainder; j++) @@ -1387,7 +1387,7 @@ static int aes_decipher(u8 *key, uint hdrlen, for (j = 0; j < 16; j++) padded_buffer[j] = 0x00; for (j = 0; j < 8; j++) - padded_buffer[j] = message[j+hdrlen+8+plen-8]; + padded_buffer[j] = message[j + hdrlen + 8 + plen - 8]; aes128k128d(key, ctr_preload, aes_out); bitwise_xor(aes_out, padded_buffer, chain_buffer); @@ -1396,9 +1396,9 @@ static int aes_decipher(u8 *key, uint hdrlen, /* compare the mic */ for (i = 0; i < 8; i++) { - if (pframe[hdrlen+8+plen-8+i] != message[hdrlen+8+plen-8+i]) { + if (pframe[hdrlen + 8 + plen - 8 + i] != message[hdrlen + 8 + plen - 8 + i]) { DBG_88E("aes_decipher:mic check error mic[%d]: pframe(%x)!=message(%x)\n", - i, pframe[hdrlen+8+plen-8+i], message[hdrlen+8+plen-8+i]); + i, pframe[hdrlen + 8 + plen - 8 + i], message[hdrlen + 8 + plen - 8 + i]); res = _FAIL; } } @@ -1438,7 +1438,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) } else { prwskey = &stainfo->dot118021x_UncstKey.skey[0]; } - length = ((struct recv_frame *)precvframe)->len-prxattrib->hdrlen-prxattrib->iv_len; + length = ((struct recv_frame *)precvframe)->len - prxattrib->hdrlen - prxattrib->iv_len; res = aes_decipher(prwskey, prxattrib->hdrlen, pframe, length); } else { res = _FAIL; -- cgit v1.2.3 From 2dcdb9d1a6f670a04b0ca6492efb011254c7b44a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:13 +0200 Subject: staging: r8188eu: add spaces around operators in core/rtw_wlan_util.c Add missung spaces around operators in core/rtw_wlan_util.c reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-19-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_wlan_util.c | 60 ++++++++++++++-------------- 1 file changed, 30 insertions(+), 30 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index cddacf023fa6..96f03e84b7e5 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -29,20 +29,20 @@ unsigned char REALTEK_96B_IE[] = {0x00, 0xe0, 0x4c, 0x02, 0x01, 0x20}; #define WAIT_FOR_BCN_TO_MAX (20000) static u8 rtw_basic_rate_cck[4] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_ofdm[3] = { - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; static u8 rtw_basic_rate_mix[7] = { - IEEE80211_CCK_RATE_1MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_CCK_RATE_5MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_6MB|IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB|IEEE80211_BASIC_RATE_MASK, - IEEE80211_OFDM_RATE_24MB|IEEE80211_BASIC_RATE_MASK + IEEE80211_CCK_RATE_1MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_2MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_CCK_RATE_5MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_CCK_RATE_11MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_6MB | IEEE80211_BASIC_RATE_MASK, IEEE80211_OFDM_RATE_12MB | IEEE80211_BASIC_RATE_MASK, + IEEE80211_OFDM_RATE_24MB | IEEE80211_BASIC_RATE_MASK }; int cckrates_included(unsigned char *rate, int ratelen) @@ -407,7 +407,7 @@ int is_client_associated_to_ap(struct adapter *padapter) pmlmeext = &padapter->mlmeextpriv; pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_STATION_STATE)) + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_STATION_STATE)) return true; else return _FAIL; @@ -418,7 +418,7 @@ int is_client_associated_to_ibss(struct adapter *padapter) struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) + if ((pmlmeinfo->state & WIFI_FW_ASSOC_SUCCESS) && ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) return true; else return _FAIL; @@ -475,7 +475,7 @@ void write_cam(struct adapter *padapter, u8 entry, u16 ctrl, u8 *mac, u8 *key) break; default: i = (j - 2) << 2; - val = (key[i] | (key[i+1] << 8) | (key[i+2] << 16) | (key[i+3] << 24)); + val = (key[i] | (key[i + 1] << 8) | (key[i + 2] << 16) | (key[i + 3] << 24)); break; } @@ -613,7 +613,7 @@ void WMMOnAssocRsp(struct adapter *padapter) /* entry indx: 0->vo, 1->vi, 2->be, 3->bk. */ for (i = 0; i < 4; i++) { - for (j = i+1; j < 4; j++) { + for (j = i + 1; j < 4; j++) { /* compare CW and AIFS */ if ((edca[j] & 0xFFFF) < (edca[i] & 0xFFFF)) { change_inx = true; @@ -942,7 +942,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) ht_info_infos_0 = 0; } if (ht_cap_info != cur_network->BcnInfo.ht_cap_info || - ((ht_info_infos_0&0x03) != (cur_network->BcnInfo.ht_info_infos_0&0x03))) { + ((ht_info_infos_0 & 0x03) != (cur_network->BcnInfo.ht_info_infos_0 & 0x03))) { DBG_88E("%s bcn now: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, ht_cap_info, ht_info_infos_0); DBG_88E("%s bcn link: ht_cap_info:%x ht_info_infos_0:%x\n", __func__, @@ -1029,14 +1029,14 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) } if (encryp_protocol == ENCRYP_PROTOCOL_WPA || encryp_protocol == ENCRYP_PROTOCOL_WPA2) { - pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + pbuf = rtw_get_wpa_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength - 12); if (pbuf && (wpa_ielen > 0)) { - rtw_parse_wpa_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x); + rtw_parse_wpa_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x); } else { - pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength-12); + pbuf = rtw_get_wpa2_ie(&bssid->IEs[12], &wpa_ielen, bssid->IELength - 12); if (pbuf && (wpa_ielen > 0)) - rtw_parse_wpa2_ie(pbuf, wpa_ielen+2, &group_cipher, &pairwise_cipher, &is_8021x); + rtw_parse_wpa2_ie(pbuf, wpa_ielen + 2, &group_cipher, &pairwise_cipher, &is_8021x); } if (pairwise_cipher != cur_network->BcnInfo.pairwise_cipher || group_cipher != cur_network->BcnInfo.group_cipher) { @@ -1193,40 +1193,40 @@ int wifirate2_ratetbl_inx(unsigned char rate) rate = rate & 0x7f; switch (rate) { - case 54*2: + case 54 * 2: inx = 11; break; - case 48*2: + case 48 * 2: inx = 10; break; - case 36*2: + case 36 * 2: inx = 9; break; - case 24*2: + case 24 * 2: inx = 8; break; - case 18*2: + case 18 * 2: inx = 7; break; - case 12*2: + case 12 * 2: inx = 6; break; - case 9*2: + case 9 * 2: inx = 5; break; - case 6*2: + case 6 * 2: inx = 4; break; - case 11*2: + case 11 * 2: inx = 3; break; case 11: inx = 2; break; - case 2*2: + case 2 * 2: inx = 1; break; - case 1*2: + case 1 * 2: inx = 0; break; } @@ -1584,7 +1584,7 @@ void process_addba_req(struct adapter *padapter, u8 *paddba_req, u8 *addr) if (psta) { param = le16_to_cpu(preq->BA_para_set); - tid = (param>>2)&0x0f; + tid = (param >> 2) & 0x0f; preorder_ctrl = &psta->recvreorder_ctrl[tid]; preorder_ctrl->indicate_seq = 0xffff; preorder_ctrl->enable = (pmlmeinfo->bAcceptAddbaReq) ? true : false; @@ -1599,7 +1599,7 @@ void update_TSF(struct mlme_ext_priv *pmlmeext, u8 *pframe, uint len) pIE = pframe + sizeof(struct rtw_ieee80211_hdr_3addr); pbuf = (__le32 *)pIE; - pmlmeext->TSFValue = le32_to_cpu(*(pbuf+1)); + pmlmeext->TSFValue = le32_to_cpu(*(pbuf + 1)); pmlmeext->TSFValue = pmlmeext->TSFValue << 32; -- cgit v1.2.3 From 6b6fdf7341d5532e17ca152947ac3a9bdbdcf388 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:14 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_xmit.c Clean up spacing style issues in core/rtw_xmit.c reported by checkpatch. CHECK: spaces preferred around that ... WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-20-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 122 ++++++++++++++++---------------- 1 file changed, 61 insertions(+), 61 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index f941150e5f94..41723525074d 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -26,7 +26,7 @@ static void _init_txservq(struct tx_servq *ptxservq) void _rtw_init_sta_xmit_priv(struct sta_xmit_priv *psta_xmitpriv) { - memset((unsigned char *)psta_xmitpriv, 0, sizeof (struct sta_xmit_priv)); + memset((unsigned char *)psta_xmitpriv, 0, sizeof(struct sta_xmit_priv)); spin_lock_init(&psta_xmitpriv->lock); _init_txservq(&psta_xmitpriv->be_q); _init_txservq(&psta_xmitpriv->bk_q); @@ -207,11 +207,11 @@ exit: return res; } -static void rtw_mfree_xmit_priv_lock (struct xmit_priv *pxmitpriv) +static void rtw_mfree_xmit_priv_lock(struct xmit_priv *pxmitpriv) { } -void _rtw_free_xmit_priv (struct xmit_priv *pxmitpriv) +void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) { int i; struct adapter *padapter = pxmitpriv->adapter; @@ -514,7 +514,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p pattrib->subtype = WIFI_DATA_TYPE; pattrib->priority = 0; - if (check_fwstate(pmlmepriv, WIFI_AP_STATE|WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE | WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { if (psta->qos_option) set_qos(&pktfile, pattrib); } else { @@ -637,15 +637,15 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr rtw_secmicsetkey(&micdata, &stainfo->dot11tkiptxmickey.skey[0]); } - if (pframe[1]&1) { /* ToDS == 1 */ + if (pframe[1] & 1) { /* ToDS == 1 */ rtw_secmicappend(&micdata, &pframe[16], 6); /* DA */ - if (pframe[1]&2) /* From Ds == 1 */ + if (pframe[1] & 2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &pframe[24], 6); else rtw_secmicappend(&micdata, &pframe[10], 6); } else { /* ToDS == 0 */ rtw_secmicappend(&micdata, &pframe[4], 6); /* DA */ - if (pframe[1]&2) /* From Ds == 1 */ + if (pframe[1] & 2) /* From Ds == 1 */ rtw_secmicappend(&micdata, &pframe[16], 6); else rtw_secmicappend(&micdata, &pframe[10], 6); @@ -661,15 +661,15 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr for (curfragnum = 0; curfragnum < pattrib->nr_frags; curfragnum++) { payload = (u8 *)RND4((size_t)(payload)); - payload = payload+pattrib->hdrlen+pattrib->iv_len; - if ((curfragnum+1) == pattrib->nr_frags) { - length = pattrib->last_txcmdsz-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + payload = payload + pattrib->hdrlen + pattrib->iv_len; + if ((curfragnum + 1) == pattrib->nr_frags) { + length = pattrib->last_txcmdsz - pattrib->hdrlen - pattrib->iv_len - ((pattrib->bswenc) ? pattrib->icv_len : 0); rtw_secmicappend(&micdata, payload, length); - payload = payload+length; + payload = payload + length; } else { - length = pxmitpriv->frag_len-pattrib->hdrlen-pattrib->iv_len-((pattrib->bswenc) ? pattrib->icv_len : 0); + length = pxmitpriv->frag_len - pattrib->hdrlen - pattrib->iv_len - ((pattrib->bswenc) ? pattrib->icv_len : 0); rtw_secmicappend(&micdata, payload, length); - payload = payload+length+pattrib->icv_len; + payload = payload + length + pattrib->icv_len; } } rtw_secgetmic(&micdata, &mic[0]); @@ -678,7 +678,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr memcpy(payload, &mic[0], 8); pattrib->last_txcmdsz += 8; - payload = payload-pattrib->last_txcmdsz+8; + payload = payload - pattrib->last_txcmdsz + 8; } } @@ -709,7 +709,7 @@ static s32 xmitframe_swencrypt(struct adapter *padapter, struct xmit_frame *pxmi return _SUCCESS; } -s32 rtw_make_wlanhdr (struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) +s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattrib) { u16 *qc; @@ -816,11 +816,11 @@ s32 rtw_make_wlanhdr (struct adapter *padapter, u8 *hdr, struct pkt_attrib *patt if (SN_LESS(pattrib->seqnum, tx_seq)) { pattrib->ampdu_en = false;/* AGG BK */ } else if (SN_EQUAL(pattrib->seqnum, tx_seq)) { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq+1)&0xfff; + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (tx_seq + 1) & 0xfff; pattrib->ampdu_en = true;/* AGG EN */ } else { - psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum+1)&0xfff; + psta->BA_starting_seqctrl[pattrib->priority & 0x0f] = (pattrib->seqnum + 1) & 0xfff; pattrib->ampdu_en = true;/* AGG EN */ } } @@ -1125,7 +1125,7 @@ void rtw_count_tx_stats(struct adapter *padapter, struct xmit_frame *pxmitframe, struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if ((pxmitframe->frame_tag&0x0f) == DATA_FRAMETAG) { + if ((pxmitframe->frame_tag & 0x0f) == DATA_FRAMETAG) { pxmitpriv->tx_bytes += sz; pmlmepriv->LinkDetectInfo.NumTxOkInPeriod += pxmitframe->agg_num; @@ -1584,32 +1584,32 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) rcu_read_unlock(); spin_lock_bh(&padapter->br_ext_lock); if (!(skb->data[0] & 1) && br_port && - memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && - *((__be16 *)(skb->data+MACADDRLEN*2)) != __constant_htons(ETH_P_8021Q) && - *((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP) && - !memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN) && padapter->scdb_entry) { - memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + memcmp(skb->data + MACADDRLEN, padapter->br_mac, MACADDRLEN) && + *((__be16 *)(skb->data + MACADDRLEN * 2)) != __constant_htons(ETH_P_8021Q) && + *((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_IP) && + !memcmp(padapter->scdb_mac, skb->data + MACADDRLEN, MACADDRLEN) && padapter->scdb_entry) { + memcpy(skb->data + MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); padapter->scdb_entry->ageing_timer = jiffies; spin_unlock_bh(&padapter->br_ext_lock); } else { - if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_8021Q)) { + if (*((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_8021Q)) { is_vlan_tag = 1; - vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2)); + vlan_hdr = *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)); for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2)); + *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + MACADDRLEN * 2 - 2 - i * 2)); skb_pull(skb, 4); } - if (!memcmp(skb->data+MACADDRLEN, padapter->br_mac, MACADDRLEN) && - (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP))) - memcpy(padapter->br_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); + if (!memcmp(skb->data + MACADDRLEN, padapter->br_mac, MACADDRLEN) && + (*((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_IP))) + memcpy(padapter->br_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4); - if (*((__be16 *)(skb->data+MACADDRLEN*2)) == __constant_htons(ETH_P_IP)) { - if (memcmp(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN)) { + if (*((__be16 *)(skb->data + MACADDRLEN * 2)) == __constant_htons(ETH_P_IP)) { + if (memcmp(padapter->scdb_mac, skb->data + MACADDRLEN, MACADDRLEN)) { padapter->scdb_entry = (struct nat25_network_db_entry *)scdb_findEntry(padapter, - skb->data+MACADDRLEN, skb->data+WLAN_ETHHDR_LEN+12); + skb->data + MACADDRLEN, skb->data + WLAN_ETHHDR_LEN + 12); if (padapter->scdb_entry) { - memcpy(padapter->scdb_mac, skb->data+MACADDRLEN, MACADDRLEN); - memcpy(padapter->scdb_ip, skb->data+WLAN_ETHHDR_LEN+12, 4); + memcpy(padapter->scdb_mac, skb->data + MACADDRLEN, MACADDRLEN); + memcpy(padapter->scdb_ip, skb->data + WLAN_ETHHDR_LEN + 12, 4); padapter->scdb_entry->ageing_timer = jiffies; do_nat25 = 0; } @@ -1631,9 +1631,9 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) if (is_vlan_tag) { skb_push(skb, 4); for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); - *((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q); - *((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr; + *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); + *((__be16 *)(skb->data + MACADDRLEN * 2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)) = vlan_hdr; } newskb = skb_copy(skb, GFP_ATOMIC); @@ -1645,9 +1645,9 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) *pskb = skb = newskb; if (is_vlan_tag) { - vlan_hdr = *((unsigned short *)(skb->data+MACADDRLEN*2+2)); + vlan_hdr = *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)); for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data+MACADDRLEN*2+2-i*2)) = *((unsigned short *)(skb->data+MACADDRLEN*2-2-i*2)); + *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2 - i * 2)) = *((unsigned short *)(skb->data + MACADDRLEN * 2 - 2 - i * 2)); skb_pull(skb, 4); } } @@ -1671,21 +1671,21 @@ static int rtw_br_client_tx(struct adapter *padapter, struct sk_buff **pskb) } } - memcpy(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); + memcpy(skb->data + MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN); dhcp_flag_bcast(padapter, skb); if (is_vlan_tag) { skb_push(skb, 4); for (i = 0; i < 6; i++) - *((unsigned short *)(skb->data+i*2)) = *((unsigned short *)(skb->data+4+i*2)); - *((__be16 *)(skb->data+MACADDRLEN*2)) = __constant_htons(ETH_P_8021Q); - *((unsigned short *)(skb->data+MACADDRLEN*2+2)) = vlan_hdr; + *((unsigned short *)(skb->data + i * 2)) = *((unsigned short *)(skb->data + 4 + i * 2)); + *((__be16 *)(skb->data + MACADDRLEN * 2)) = __constant_htons(ETH_P_8021Q); + *((unsigned short *)(skb->data + MACADDRLEN * 2 + 2)) = vlan_hdr; } } /* check if SA is equal to our MAC */ - if (memcmp(skb->data+MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { + if (memcmp(skb->data + MACADDRLEN, GET_MY_HWADDR(padapter), MACADDRLEN)) { DEBUG_ERR("TX DROP: untransformed frame SA:%02X%02X%02X%02X%02X%02X!\n", skb->data[6], skb->data[7], skb->data[8], skb->data[9], skb->data[10], skb->data[11]); return -1; @@ -1765,7 +1765,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) br_port = rcu_dereference(padapter->pnetdev->rx_handler_data); rcu_read_unlock(); - if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE|WIFI_ADHOC_STATE)) { + if (br_port && check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) { res = rtw_br_client_tx(padapter, ppkt); if (res == -1) { rtw_free_xmitframe(pxmitpriv, pxmitframe); @@ -1853,10 +1853,10 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra spin_lock_bh(&psta->sleep_q.lock); - if (psta->state&WIFI_SLEEP_STATE) { + if (psta->state & WIFI_SLEEP_STATE) { u8 wmmps_ac = 0; - if (pstapriv->sta_dz_bitmap&BIT(psta->aid)) { + if (pstapriv->sta_dz_bitmap & BIT(psta->aid)) { list_del_init(&pxmitframe->list); list_add_tail(&pxmitframe->list, get_list_head(&psta->sleep_q)); @@ -1866,20 +1866,20 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra switch (pattrib->priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(0); + wmmps_ac = psta->uapsd_bk & BIT(0); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(0); + wmmps_ac = psta->uapsd_vi & BIT(0); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(0); + wmmps_ac = psta->uapsd_vo & BIT(0); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(0); + wmmps_ac = psta->uapsd_be & BIT(0); break; } @@ -1993,20 +1993,20 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) switch (pxmitframe->attrib.priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(1); + wmmps_ac = psta->uapsd_bk & BIT(1); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(1); + wmmps_ac = psta->uapsd_vi & BIT(1); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(1); + wmmps_ac = psta->uapsd_vo & BIT(1); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(1); + wmmps_ac = psta->uapsd_be & BIT(1); break; } @@ -2040,7 +2040,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) update_mask = BIT(0); - if (psta->state&WIFI_SLEEP_STATE) + if (psta->state & WIFI_SLEEP_STATE) psta->state ^= WIFI_SLEEP_STATE; if (psta->state & WIFI_STA_ALIVE_CHK_STATE) { @@ -2058,7 +2058,7 @@ void wakeup_sta_to_xmit(struct adapter *padapter, struct sta_info *psta) if (!psta_bmc) return; - if ((pstapriv->sta_dz_bitmap&0xfffe) == 0x0) { /* no any sta in ps mode */ + if ((pstapriv->sta_dz_bitmap & 0xfffe) == 0x0) { /* no any sta in ps mode */ spin_lock_bh(&psta_bmc->sleep_q.lock); xmitframe_phead = get_list_head(&psta_bmc->sleep_q); @@ -2119,20 +2119,20 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst switch (pxmitframe->attrib.priority) { case 1: case 2: - wmmps_ac = psta->uapsd_bk&BIT(1); + wmmps_ac = psta->uapsd_bk & BIT(1); break; case 4: case 5: - wmmps_ac = psta->uapsd_vi&BIT(1); + wmmps_ac = psta->uapsd_vi & BIT(1); break; case 6: case 7: - wmmps_ac = psta->uapsd_vo&BIT(1); + wmmps_ac = psta->uapsd_vo & BIT(1); break; case 0: case 3: default: - wmmps_ac = psta->uapsd_be&BIT(1); + wmmps_ac = psta->uapsd_be & BIT(1); break; } -- cgit v1.2.3 From 77cb924ec6913d3b46816dc964d83c9a775eaba0 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:15 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_debug.c Clean up spacing style issues in core/rtw_debug.c reported by checkpatch. CHECK: spaces preferred around that '%' (ctx:VxV) WARNING: space prohibited before semicolon Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-21-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_debug.c | 42 ++++++++++++++++---------------- 1 file changed, 21 insertions(+), 21 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_debug.c b/drivers/staging/r8188eu/core/rtw_debug.c index 771f62452498..2ee64cef73f7 100644 --- a/drivers/staging/r8188eu/core/rtw_debug.c +++ b/drivers/staging/r8188eu/core/rtw_debug.c @@ -309,10 +309,10 @@ int proc_get_mac_reg_dump1(char *page, char **start, len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); for (i = 0x0; i < 0x300; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x", i); len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -332,10 +332,10 @@ int proc_get_mac_reg_dump2(char *page, char **start, len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); memset(page, 0, count); for (i = 0x300; i < 0x600; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x", i); len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -355,10 +355,10 @@ int proc_get_mac_reg_dump3(char *page, char **start, len += snprintf(page + len, count - len, "\n======= MAC REG =======\n"); for (i = 0x600; i < 0x800; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x", i); len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -377,10 +377,10 @@ int proc_get_bb_reg_dump1(char *page, char **start, len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); for (i = 0x800; i < 0xB00; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x", i); len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } *eof = 1; @@ -398,10 +398,10 @@ int proc_get_bb_reg_dump2(char *page, char **start, len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); for (i = 0xB00; i < 0xE00; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x", i); len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } *eof = 1; @@ -419,10 +419,10 @@ int proc_get_bb_reg_dump3(char *page, char **start, len += snprintf(page + len, count - len, "\n======= BB REG =======\n"); for (i = 0xE00; i < 0x1000; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x", i); len += snprintf(page + len, count - len, " 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } *eof = 1; @@ -444,10 +444,10 @@ int proc_get_rf_reg_dump1(char *page, char **start, len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); for (i = 0; i < 0xC0; i++) { value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x ", i); len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } *eof = 1; @@ -469,10 +469,10 @@ int proc_get_rf_reg_dump2(char *page, char **start, len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); for (i = 0xC0; i < 0x100; i++) { value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x ", i); len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } *eof = 1; @@ -494,10 +494,10 @@ int proc_get_rf_reg_dump3(char *page, char **start, len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); for (i = 0; i < 0xC0; i++) { value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x ", i); len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } @@ -520,10 +520,10 @@ int proc_get_rf_reg_dump4(char *page, char **start, len += snprintf(page + len, count - len, "\nRF_Path(%x)\n", path); for (i = 0xC0; i < 0x100; i++) { value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) + if (j % 4 == 1) len += snprintf(page + len, count - len, "0x%02x ", i); len += snprintf(page + len, count - len, " 0x%08x ", value); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) len += snprintf(page + len, count - len, "\n"); } *eof = 1; @@ -801,7 +801,7 @@ int proc_set_rssi_disp(struct file *file, const char __user *buffer, if (enable) { DBG_88E("Turn On Rx RSSI Display Function\n"); - padapter->bRxRSSIDisplay = enable ; + padapter->bRxRSSIDisplay = enable; } else { DBG_88E("Turn Off Rx RSSI Display Function\n"); padapter->bRxRSSIDisplay = 0; -- cgit v1.2.3 From 3ec10b9d8ead9accdf7c46ade5ab0eca6ff9e2eb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:16 +0200 Subject: staging: r8188eu: add space around operator in core/rtw_sreset.c Add missing space around operator in core/rtw_sreset.c reported by checkpatch. CHECK: spaces preferred around that '|' (ctx:VxV) Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-22-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sreset.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sreset.c b/drivers/staging/r8188eu/core/rtw_sreset.c index 5084bc036424..8e1bc62e74e5 100644 --- a/drivers/staging/r8188eu/core/rtw_sreset.c +++ b/drivers/staging/r8188eu/core/rtw_sreset.c @@ -45,7 +45,7 @@ u8 sreset_get_wifi_status(struct adapter *padapter) if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) { DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->Wifi_Error_Status); - status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL|USB_WRITE_PORT_FAIL))); + status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL | USB_WRITE_PORT_FAIL))); } DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status); -- cgit v1.2.3 From 438bb20f00a738c38bf148e134efcfb394d73191 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 17:58:17 +0200 Subject: staging: r8188eu: clean up spacing style issues in core/rtw_sta_mgt.c Clean up spacing style issues in core/rtw_sta_mgt.c reported by checkpatch. WARNING: space prohibited between function name and open parenthesis '(' CHECK: spaces preferred around that '/' (ctx:VxV) WARNING: space prohibited before semicolon Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816155818.24005-23-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index b4568ec1c48a..9628d095a487 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -13,7 +13,7 @@ static void _rtw_init_stainfo(struct sta_info *psta) { - memset((u8 *)psta, 0, sizeof (struct sta_info)); + memset((u8 *)psta, 0, sizeof(struct sta_info)); spin_lock_init(&psta->lock); INIT_LIST_HEAD(&psta->list); @@ -111,7 +111,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) inline int rtw_stainfo_offset(struct sta_priv *stapriv, struct sta_info *sta) { - int offset = (((u8 *)sta) - stapriv->pstainfo_buf)/sizeof(struct sta_info); + int offset = (((u8 *)sta) - stapriv->pstainfo_buf) / sizeof(struct sta_info); if (!stainfo_offset_valid(offset)) DBG_88E("%s invalid offset(%d), out of range!!!", __func__, offset); @@ -196,7 +196,7 @@ struct sta_info *rtw_alloc_stainfo(struct sta_priv *pstapriv, u8 *hwaddr) list_add_tail(&psta->hash_list, phash_list); - pstapriv->asoc_sta_count++ ; + pstapriv->asoc_sta_count++; spin_unlock_bh(&pstapriv->sta_hash_lock); -- cgit v1.2.3 From 550b1cda158c8472984f1e7f86478f154c16a7d3 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 22:55:09 +0200 Subject: staging: r8188eu: clean up spacing style issues in hal dir, part 1 Clean up spacing style issues reported by checkpatch in the first 10 files in the hal directory. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816205511.20068-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c | 48 +++---- drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c | 22 ++-- drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c | 6 +- drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c | 6 +- drivers/staging/r8188eu/hal/HalPhyRf_8188e.c | 138 ++++++++++----------- drivers/staging/r8188eu/hal/HalPwrSeqCmd.c | 2 +- drivers/staging/r8188eu/hal/hal_com.c | 36 +++--- drivers/staging/r8188eu/hal/hal_intf.c | 4 +- drivers/staging/r8188eu/hal/odm.c | 114 ++++++++--------- 9 files changed, 188 insertions(+), 188 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c index 1f1ce5f36f83..d873672feb27 100644 --- a/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c +++ b/drivers/staging/r8188eu/hal/Hal8188ERateAdaptive.c @@ -16,7 +16,7 @@ Major Change History: /* Rate adaptive parameters */ -static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = { +static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE + 1] = { {5, 4, 3, 2, 0, 3}, /* 92 , idx = 0 */ {6, 5, 4, 3, 0, 4}, /* 86 , idx = 1 */ {6, 5, 4, 2, 0, 4}, /* 81 , idx = 2 */ @@ -42,7 +42,7 @@ static u8 RETRY_PENALTY[PERENTRY][RETRYSIZE+1] = { {49, 16, 16, 0, 0, 48} }; /* 3, idx = 0x16 */ -static u8 PT_PENALTY[RETRYSIZE+1] = {34, 31, 30, 24, 0, 32}; +static u8 PT_PENALTY[RETRYSIZE + 1] = {34, 31, 30, 24, 0, 32}; /* wilson modify */ static u8 RETRY_PENALTY_IDX[2][RATESIZE] = { @@ -132,7 +132,7 @@ static int odm_RateDown_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_info * pRaInfo->RateSGI = 0; } else if (RateID > LowestRate) { if (RateID > 0) { - for (i = RateID-1; i > LowestRate; i--) { + for (i = RateID - 1; i > LowestRate; i--) { if (pRaInfo->RAUseRate & BIT(i)) { RateID = i; goto RateDownFinish; @@ -183,7 +183,7 @@ static int odm_RateUp_8188E( odm_SetTxRPTTiming_8188E(dm_odm, pRaInfo, 0); if (RateID < HighestRate) { - for (i = RateID+1; i <= HighestRate; i++) { + for (i = RateID + 1; i <= HighestRate; i++) { if (pRaInfo->RAUseRate & BIT(i)) { RateID = i; goto RateUpfinish; @@ -198,7 +198,7 @@ static int odm_RateUp_8188E( RateID = HighestRate; } RateUpfinish: - if (pRaInfo->RAWaitingCounter == (4+PendingForRateUpFail[pRaInfo->RAPendingCounter])) + if (pRaInfo->RAWaitingCounter == (4 + PendingForRateUpFail[pRaInfo->RAPendingCounter])) pRaInfo->RAWaitingCounter = 0; else pRaInfo->RAWaitingCounter++; @@ -212,8 +212,8 @@ static void odm_ResetRaCounter_8188E(struct odm_ra_info *pRaInfo) u8 RateID; RateID = pRaInfo->DecisionRate; - pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; - pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID]+N_THRESHOLD_LOW[RateID])>>1; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[RateID] + N_THRESHOLD_LOW[RateID]) >> 1; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[RateID] + N_THRESHOLD_LOW[RateID]) >> 1; } static void odm_RateDecision_8188E(struct odm_dm_struct *dm_odm, @@ -295,41 +295,41 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf switch (pRaInfo->RateID) { case RATR_INX_WIRELESS_NGB: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff015; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff015; break; case RATR_INX_WIRELESS_NG: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff010; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff010; break; case RATR_INX_WIRELESS_NB: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff005; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff005; break; case RATR_INX_WIRELESS_N: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0f8ff000; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0f8ff000; break; case RATR_INX_WIRELESS_GB: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff5; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x00000ff5; break; case RATR_INX_WIRELESS_G: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x00000ff0; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x00000ff0; break; case RATR_INX_WIRELESS_B: - pRaInfo->RAUseRate = (pRaInfo->RateMask)&0x0000000d; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & 0x0000000d; break; case 12: MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR0); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg; break; case 13: MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR1); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg; break; case 14: MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR2); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg; break; case 15: MaskFromReg = ODM_Read4Byte(dm_odm, REG_ARFR3); - pRaInfo->RAUseRate = (pRaInfo->RateMask)&MaskFromReg; + pRaInfo->RAUseRate = (pRaInfo->RateMask) & MaskFromReg; break; default: pRaInfo->RAUseRate = (pRaInfo->RateMask); @@ -338,7 +338,7 @@ static int odm_ARFBRefresh_8188E(struct odm_dm_struct *dm_odm, struct odm_ra_inf /* Highest rate */ if (pRaInfo->RAUseRate) { for (i = RATESIZE; i >= 0; i--) { - if ((pRaInfo->RAUseRate)&BIT(i)) { + if ((pRaInfo->RAUseRate) & BIT(i)) { pRaInfo->HighestRate = i; break; } @@ -443,15 +443,15 @@ static void odm_PTDecision_8188E(struct odm_ra_info *pRaInfo) j = j >> 1; temp_stage = (pRaInfo->PTStage + 1) >> 1; if (temp_stage > j) - stage_id = temp_stage-j; + stage_id = temp_stage - j; else stage_id = 0; - pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor>>1) + (pRaInfo->PTSmoothFactor>>2) + stage_id*16+2; + pRaInfo->PTSmoothFactor = (pRaInfo->PTSmoothFactor >> 1) + (pRaInfo->PTSmoothFactor >> 2) + stage_id * 16 + 2; if (pRaInfo->PTSmoothFactor > 192) pRaInfo->PTSmoothFactor = 192; stage_id = pRaInfo->PTSmoothFactor >> 6; - temp_stage = stage_id*2; + temp_stage = stage_id * 2; if (temp_stage != 0) temp_stage -= 1; if (pRaInfo->DROP > 3) @@ -508,8 +508,8 @@ int ODM_RAInfo_Init(struct odm_dm_struct *dm_odm, u8 macid) pRaInfo->PreRssiStaRA = 0; pRaInfo->SGIEnable = 0; pRaInfo->RAUseRate = 0xffffffff; - pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; - pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13]+N_THRESHOLD_LOW[0x13])/2; + pRaInfo->NscDown = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2; + pRaInfo->NscUp = (N_THRESHOLD_HIGH[0x13] + N_THRESHOLD_LOW[0x13]) / 2; pRaInfo->RateSGI = 0; pRaInfo->Active = 1; /* Active is not used at present. by page, 110819 */ pRaInfo->RptTime = 0x927c; diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c index 2fbac01dd969..55aa20a30342 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c @@ -8,7 +8,7 @@ do { \ i += 2; \ v1 = array[i]; \ - v2 = array[i+1]; \ + v2 = array[i + 1]; \ } while (0) static bool CheckCondition(const u32 condition, const u32 hex) @@ -179,7 +179,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) u8 platform = dm_odm->SupportPlatform; u8 interfaceValue = dm_odm->SupportInterface; u8 board = dm_odm->BoardType; - u32 arraylen = sizeof(array_agc_tab_1t_8188e)/sizeof(u32); + u32 arraylen = sizeof(array_agc_tab_1t_8188e) / sizeof(u32); u32 *array = array_agc_tab_1t_8188e; bool biol = false; struct adapter *adapter = dm_odm->Adapter; @@ -203,7 +203,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) for (i = 0; i < arraylen; i += 2) { u32 v1 = array[i]; - u32 v2 = array[i+1]; + u32 v2 = array[i + 1]; /* This (offset, data) pair meets the condition. */ if (v1 < 0xCDCDCDCD) { @@ -459,7 +459,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) u8 platform = dm_odm->SupportPlatform; u8 interfaceValue = dm_odm->SupportInterface; u8 board = dm_odm->BoardType; - u32 arraylen = sizeof(array_phy_reg_1t_8188e)/sizeof(u32); + u32 arraylen = sizeof(array_phy_reg_1t_8188e) / sizeof(u32); u32 *array = array_phy_reg_1t_8188e; bool biol = false; struct adapter *adapter = dm_odm->Adapter; @@ -482,7 +482,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm) for (i = 0; i < arraylen; i += 2) { u32 v1 = array[i]; - u32 v2 = array[i+1]; + u32 v2 = array[i + 1]; /* This (offset, data) pair meets the condition. */ if (v1 < 0xCDCDCDCD) { @@ -676,8 +676,8 @@ void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm) for (i = 0; i < arraylen; i += 3) { u32 v1 = array[i]; - u32 v2 = array[i+1]; - u32 v3 = array[i+2]; + u32 v2 = array[i + 1]; + u32 v3 = array[i + 2]; /* this line is a line of pure_body */ if (v1 < 0xCDCDCDCD) { @@ -688,13 +688,13 @@ void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm) /* don't need the hw_body */ i += 2; /* skip the pair of expression */ v1 = array[i]; - v2 = array[i+1]; - v3 = array[i+2]; + v2 = array[i + 1]; + v3 = array[i + 2]; while (v2 != 0xDEAD) { i += 3; v1 = array[i]; - v2 = array[i+1]; - v3 = array[i+1]; + v2 = array[i + 1]; + v3 = array[i + 1]; } } } diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c index 56b5d7c0bb9c..0ff2609c26bb 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c @@ -129,14 +129,14 @@ static u32 array_MAC_REG_8188E[] = { enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) { - #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i+1]; } while (0) + #define READ_NEXT_PAIR(v1, v2, i) do { i += 2; v1 = array[i]; v2 = array[i + 1]; } while (0) u32 hex = 0; u32 i; u8 platform = dm_odm->SupportPlatform; u8 interface_val = dm_odm->SupportInterface; u8 board = dm_odm->BoardType; - u32 array_len = sizeof(array_MAC_REG_8188E)/sizeof(u32); + u32 array_len = sizeof(array_MAC_REG_8188E) / sizeof(u32); u32 *array = array_MAC_REG_8188E; bool biol = false; @@ -161,7 +161,7 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm) for (i = 0; i < array_len; i += 2) { u32 v1 = array[i]; - u32 v2 = array[i+1]; + u32 v2 = array[i + 1]; /* This (offset, data) pair meets the condition. */ if (v1 < 0xCDCDCDCD) { diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c index c5895e0c798b..55e4b4a877a4 100644 --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c @@ -140,14 +140,14 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) { #define READ_NEXT_PAIR(v1, v2, i) do \ { i += 2; v1 = Array[i]; \ - v2 = Array[i+1]; } while (0) + v2 = Array[i + 1]; } while (0) u32 hex = 0; u32 i = 0; u8 platform = pDM_Odm->SupportPlatform; u8 interfaceValue = pDM_Odm->SupportInterface; u8 board = pDM_Odm->BoardType; - u32 ArrayLen = sizeof(Array_RadioA_1T_8188E)/sizeof(u32); + u32 ArrayLen = sizeof(Array_RadioA_1T_8188E) / sizeof(u32); u32 *Array = Array_RadioA_1T_8188E; bool biol = false; struct adapter *Adapter = pDM_Odm->Adapter; @@ -171,7 +171,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm) for (i = 0; i < ArrayLen; i += 2) { u32 v1 = Array[i]; - u32 v2 = Array[i+1]; + u32 v2 = Array[i + 1]; /* This (offset, data) pair meets the condition. */ if (v1 < 0xCDCDCDCD) { diff --git a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c index c92a76aebc11..356885e27edd 100644 --- a/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c +++ b/drivers/staging/r8188eu/hal/HalPhyRf_8188e.c @@ -63,7 +63,7 @@ void ODM_TxPwrTrackAdjust88E(struct odm_dm_struct *dm_odm, u8 Type,/* 0 = OFDM, if (pwr_value >= ODM_TXPWRTRACK_MAX_IDX_88E && *pDirection == 1) pwr_value = ODM_TXPWRTRACK_MAX_IDX_88E; - *pOutWriteVal = pwr_value | (pwr_value<<8) | (pwr_value<<16) | (pwr_value<<24); + *pOutWriteVal = pwr_value | (pwr_value << 8) | (pwr_value << 16) | (pwr_value << 24); } /* ODM_TxPwrTrackAdjust88E */ /*----------------------------------------------------------------------------- @@ -147,9 +147,9 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( if (ThermalValue) { /* Query OFDM path A default setting */ - ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord)&bMaskOFDM_D; + ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XATxIQImbalance, bMaskDWord) & bMaskOFDM_D; for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ - if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { + if (ele_D == (OFDMSwingTable[i] & bMaskOFDM_D)) { OFDM_index_old[0] = (u8)i; dm_odm->BbSwingIdxOfdmBase = (u8)i; break; @@ -158,9 +158,9 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( /* Query OFDM path B default setting */ if (is2t) { - ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord)&bMaskOFDM_D; + ele_D = ODM_GetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord) & bMaskOFDM_D; for (i = 0; i < OFDM_TABLE_SIZE_92D; i++) { /* find the index */ - if (ele_D == (OFDMSwingTable[i]&bMaskOFDM_D)) { + if (ele_D == (OFDMSwingTable[i] & bMaskOFDM_D)) { OFDM_index_old[1] = (u8)i; break; } @@ -256,20 +256,20 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( } } if (offset >= index_mapping_NUM_88E) - offset = index_mapping_NUM_88E-1; + offset = index_mapping_NUM_88E - 1; for (i = 0; i < rf; i++) OFDM_index[i] = dm_odm->RFCalibrateInfo.OFDM_index[i] + OFDM_index_mapping[j][offset]; CCK_index = dm_odm->RFCalibrateInfo.CCK_index + OFDM_index_mapping[j][offset]; for (i = 0; i < rf; i++) { - if (OFDM_index[i] > OFDM_TABLE_SIZE_92D-1) - OFDM_index[i] = OFDM_TABLE_SIZE_92D-1; + if (OFDM_index[i] > OFDM_TABLE_SIZE_92D - 1) + OFDM_index[i] = OFDM_TABLE_SIZE_92D - 1; else if (OFDM_index[i] < OFDM_min_index) OFDM_index[i] = OFDM_min_index; } - if (CCK_index > CCK_TABLE_SIZE-1) - CCK_index = CCK_TABLE_SIZE-1; + if (CCK_index > CCK_TABLE_SIZE - 1) + CCK_index = CCK_TABLE_SIZE - 1; else if (CCK_index < 0) CCK_index = 0; @@ -279,7 +279,7 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( dm_odm->RFCalibrateInfo.bDoneTxpower = true; /* Adujst OFDM Ant_A according to IQK result */ - ele_D = (OFDMSwingTable[(u8)OFDM_index[0]] & 0xFFC00000)>>22; + ele_D = (OFDMSwingTable[(u8)OFDM_index[0]] & 0xFFC00000) >> 22; X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][0]; Y = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][1]; @@ -300,19 +300,19 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( if (X != 0) { if ((X & 0x00000200) != 0) X = X | 0xFFFFFC00; - ele_A = ((X * ele_D)>>8)&0x000003FF; + ele_A = ((X * ele_D) >> 8) & 0x000003FF; /* new element C = element D x Y */ if ((Y & 0x00000200) != 0) Y = Y | 0xFFFFFC00; - ele_C = ((Y * ele_D)>>8)&0x000003FF; + ele_C = ((Y * ele_D) >> 8) & 0x000003FF; /* 2012/04/23 MH According to Luke's suggestion, we can not write BB digital */ /* to increase TX power. Otherwise, EVM will be bad. */ } if (is2t) { - ele_D = (OFDMSwingTable[(u8)OFDM_index[1]] & 0xFFC00000)>>22; + ele_D = (OFDMSwingTable[(u8)OFDM_index[1]] & 0xFFC00000) >> 22; /* new element A = element D x X */ X = dm_odm->RFCalibrateInfo.IQKMatrixRegSetting[Indexforchannel].Value[0][4]; @@ -321,21 +321,21 @@ odm_TXPowerTrackingCallback_ThermalMeter_8188E( if ((X != 0) && (*dm_odm->pBandType == ODM_BAND_2_4G)) { if ((X & 0x00000200) != 0) /* consider minus */ X = X | 0xFFFFFC00; - ele_A = ((X * ele_D)>>8)&0x000003FF; + ele_A = ((X * ele_D) >> 8) & 0x000003FF; /* new element C = element D x Y */ if ((Y & 0x00000200) != 0) Y = Y | 0xFFFFFC00; - ele_C = ((Y * ele_D)>>8)&0x00003FF; + ele_C = ((Y * ele_D) >> 8) & 0x00003FF; /* wtite new elements A, C, D to regC88 and regC9C, element B is always 0 */ - value32 = (ele_D<<22) | ((ele_C&0x3F)<<16) | ele_A; + value32 = (ele_D << 22) | ((ele_C & 0x3F) << 16) | ele_A; ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, value32); - value32 = (ele_C&0x000003C0)>>6; + value32 = (ele_C & 0x000003C0) >> 6; ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, bMaskH4Bits, value32); - value32 = ((X * ele_D)>>7)&0x01; + value32 = ((X * ele_D) >> 7) & 0x01; ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(28), value32); } else { ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, bMaskDWord, OFDMSwingTable[(u8)OFDM_index[1]]); @@ -393,8 +393,8 @@ phy_PathA_IQK_8188E(struct adapter *adapt, bool configPathB) regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); if (!(regeac & BIT(28)) && - (((regE94 & 0x03FF0000)>>16) != 0x142) && - (((regE9C & 0x03FF0000)>>16) != 0x42)) + (((regE94 & 0x03FF0000) >> 16) != 0x142) && + (((regE9C & 0x03FF0000) >> 16) != 0x42)) result |= 0x01; return result; } @@ -447,13 +447,13 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) regE9C = ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord); if (!(regeac & BIT(28)) && - (((regE94 & 0x03FF0000)>>16) != 0x142) && - (((regE9C & 0x03FF0000)>>16) != 0x42)) + (((regE94 & 0x03FF0000) >> 16) != 0x142) && + (((regE9C & 0x03FF0000) >> 16) != 0x42)) result |= 0x01; else /* if Tx not OK, ignore Rx */ return result; - u4tmp = 0x80007C00 | (regE94&0x3FF0000) | ((regE9C&0x3FF0000) >> 16); + u4tmp = 0x80007C00 | (regE94 & 0x3FF0000) | ((regE9C & 0x3FF0000) >> 16); ODM_SetBBReg(dm_odm, rTx_IQK, bMaskDWord, u4tmp); /* 1 RX IQK */ @@ -496,8 +496,8 @@ phy_PathA_RxIQK(struct adapter *adapt, bool configPathB) ODM_SetRFReg(dm_odm, RF_PATH_A, 0xdf, bRFRegOffsetMask, 0x180); if (!(regeac & BIT(27)) && /* if Tx is OK, check whether Rx is OK */ - (((regEA4 & 0x03FF0000)>>16) != 0x132) && - (((regeac & 0x03FF0000)>>16) != 0x36)) + (((regEA4 & 0x03FF0000) >> 16) != 0x132) && + (((regeac & 0x03FF0000) >> 16) != 0x36)) result |= 0x02; return result; @@ -526,15 +526,15 @@ phy_PathB_IQK_8188E(struct adapter *adapt) regecc = ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord); if (!(regeac & BIT(31)) && - (((regeb4 & 0x03FF0000)>>16) != 0x142) && - (((regebc & 0x03FF0000)>>16) != 0x42)) + (((regeb4 & 0x03FF0000) >> 16) != 0x142) && + (((regebc & 0x03FF0000) >> 16) != 0x42)) result |= 0x01; else return result; if (!(regeac & BIT(30)) && - (((regec4 & 0x03FF0000)>>16) != 0x132) && - (((regecc & 0x03FF0000)>>16) != 0x36)) + (((regec4 & 0x03FF0000) >> 16) != 0x132) && + (((regecc & 0x03FF0000) >> 16) != 0x36)) result |= 0x02; return result; @@ -558,17 +558,17 @@ static void patha_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u TX0_A = (X * Oldval_0) >> 8; ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x3FF, TX0_A); - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0>>7) & 0x1)); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(31), ((X * Oldval_0 >> 7) & 0x1)); Y = result[final_candidate][1]; if ((Y & 0x00000200) != 0) Y = Y | 0xFFFFFC00; TX0_C = (Y * Oldval_0) >> 8; - ODM_SetBBReg(dm_odm, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C&0x3C0)>>6)); - ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C&0x3F)); + ODM_SetBBReg(dm_odm, rOFDM0_XCTxAFE, 0xF0000000, ((TX0_C & 0x3C0) >> 6)); + ODM_SetBBReg(dm_odm, rOFDM0_XATxIQImbalance, 0x003F0000, (TX0_C & 0x3F)); - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0>>7) & 0x1)); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(29), ((Y * Oldval_0 >> 7) & 0x1)); if (txonly) return; @@ -602,17 +602,17 @@ static void pathb_fill_iqk(struct adapter *adapt, bool iqkok, s32 result[][8], u TX1_A = (X * Oldval_1) >> 8; ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x3FF, TX1_A); - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1>>7) & 0x1)); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(27), ((X * Oldval_1 >> 7) & 0x1)); Y = result[final_candidate][5]; if ((Y & 0x00000200) != 0) Y = Y | 0xFFFFFC00; TX1_C = (Y * Oldval_1) >> 8; - ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C&0x3C0)>>6)); - ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C&0x3F)); + ODM_SetBBReg(dm_odm, rOFDM0_XDTxAFE, 0xF0000000, ((TX1_C & 0x3C0) >> 6)); + ODM_SetBBReg(dm_odm, rOFDM0_XBTxIQImbalance, 0x003F0000, (TX1_C & 0x3F)); - ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1>>7) & 0x1)); + ODM_SetBBReg(dm_odm, rOFDM0_ECCAThreshold, BIT(25), ((Y * Oldval_1 >> 7) & 0x1)); if (txonly) return; @@ -732,9 +732,9 @@ _PHY_MACSettingCalibration( ODM_Write1Byte(dm_odm, MACReg[i], 0x3F); for (i = 1; i < (IQK_MAC_REG_NUM - 1); i++) { - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT(3)))); + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i] & (~BIT(3)))); } - ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i]&(~BIT(5)))); + ODM_Write1Byte(dm_odm, MACReg[i], (u8)(MACBackup[i] & (~BIT(5)))); } void @@ -811,22 +811,22 @@ static bool phy_SimularityCompare_8188E( if (diff > MAX_TOLERANCE) { if ((i == 2 || i == 6) && !sim_bitmap) { - if (resulta[c1][i] + resulta[c1][i+1] == 0) - final_candidate[(i/4)] = c2; - else if (resulta[c2][i] + resulta[c2][i+1] == 0) - final_candidate[(i/4)] = c1; + if (resulta[c1][i] + resulta[c1][i + 1] == 0) + final_candidate[(i / 4)] = c2; + else if (resulta[c2][i] + resulta[c2][i + 1] == 0) + final_candidate[(i / 4)] = c1; else - sim_bitmap = sim_bitmap | (1<>16; - result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord)&0x3FF0000)>>16; + result[t][0] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_A, bMaskDWord) & 0x3FF0000) >> 16; + result[t][1] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_A, bMaskDWord) & 0x3FF0000) >> 16; break; } } @@ -949,8 +949,8 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, for (i = 0; i < retryCount; i++) { PathAOK = phy_PathA_RxIQK(adapt, is2t); if (PathAOK == 0x03) { - result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; - result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord)&0x3FF0000)>>16; + result[t][2] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_A_2, bMaskDWord) & 0x3FF0000) >> 16; + result[t][3] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_A_2, bMaskDWord) & 0x3FF0000) >> 16; break; } } @@ -964,14 +964,14 @@ static void phy_IQCalibrate_8188E(struct adapter *adapt, s32 result[][8], u8 t, for (i = 0; i < retryCount; i++) { PathBOK = phy_PathB_IQK_8188E(adapt); if (PathBOK == 0x03) { - result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][6] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; - result[t][7] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord)&0x3FF0000)>>16; + result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord) & 0x3FF0000) >> 16; + result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord) & 0x3FF0000) >> 16; + result[t][6] = (ODM_GetBBReg(dm_odm, rRx_Power_Before_IQK_B_2, bMaskDWord) & 0x3FF0000) >> 16; + result[t][7] = (ODM_GetBBReg(dm_odm, rRx_Power_After_IQK_B_2, bMaskDWord) & 0x3FF0000) >> 16; break; } else if (i == (retryCount - 1) && PathBOK == 0x01) { /* Tx IQK OK */ - result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord)&0x3FF0000)>>16; - result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord)&0x3FF0000)>>16; + result[t][4] = (ODM_GetBBReg(dm_odm, rTx_Power_Before_IQK_B, bMaskDWord) & 0x3FF0000) >> 16; + result[t][5] = (ODM_GetBBReg(dm_odm, rTx_Power_After_IQK_B, bMaskDWord) & 0x3FF0000) >> 16; } } } @@ -1014,12 +1014,12 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) /* Check continuous TX and Packet TX */ tmpreg = ODM_Read1Byte(dm_odm, 0xd03); - if ((tmpreg&0x70) != 0) /* Deal with contisuous TX case */ - ODM_Write1Byte(dm_odm, 0xd03, tmpreg&0x8F); /* disable all continuous TX */ + if ((tmpreg & 0x70) != 0) /* Deal with contisuous TX case */ + ODM_Write1Byte(dm_odm, 0xd03, tmpreg & 0x8F); /* disable all continuous TX */ else /* Deal with Packet TX case */ ODM_Write1Byte(dm_odm, REG_TXPAUSE, 0xFF); /* block all queues */ - if ((tmpreg&0x70) != 0) { + if ((tmpreg & 0x70) != 0) { /* 1. Read original RF mode */ /* Path-A */ RF_Amode = PHY_QueryRFReg(adapt, RF_PATH_A, RF_AC, bMask12Bits); @@ -1030,23 +1030,23 @@ static void phy_LCCalibrate_8188E(struct adapter *adapt, bool is2t) /* 2. Set RF mode = standby mode */ /* Path-A */ - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode&0x8FFFF)|0x10000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_AC, bMask12Bits, (RF_Amode & 0x8FFFF) | 0x10000); /* Path-B */ if (is2t) - ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode&0x8FFFF)|0x10000); + ODM_SetRFReg(dm_odm, RF_PATH_B, RF_AC, bMask12Bits, (RF_Bmode & 0x8FFFF) | 0x10000); } /* 3. Read RF reg18 */ LC_Cal = PHY_QueryRFReg(adapt, RF_PATH_A, RF_CHNLBW, bMask12Bits); /* 4. Set LC calibration begin bit15 */ - ODM_SetRFReg(dm_odm, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal|0x08000); + ODM_SetRFReg(dm_odm, RF_PATH_A, RF_CHNLBW, bMask12Bits, LC_Cal | 0x08000); ODM_sleep_ms(100); /* Restore original situation */ - if ((tmpreg&0x70) != 0) { + if ((tmpreg & 0x70) != 0) { /* Deal with continuous TX case */ /* Path-A */ ODM_Write1Byte(dm_odm, 0xd03, tmpreg); @@ -1239,14 +1239,14 @@ static void phy_setrfpathswitch_8188e(struct adapter *adapt, bool main, bool is2 if (is2t) { /* 92C */ if (main) - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(5)|BIT(6), 0x1); /* 92C_Path_A */ + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(5) | BIT(6), 0x1); /* 92C_Path_A */ else - ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(5)|BIT(6), 0x2); /* BT */ + ODM_SetBBReg(dm_odm, rFPGA0_XB_RFInterfaceOE, BIT(5) | BIT(6), 0x2); /* BT */ } else { /* 88C */ if (main) - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(8)|BIT(9), 0x2); /* Main */ + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(8) | BIT(9), 0x2); /* Main */ else - ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(8)|BIT(9), 0x1); /* Aux */ + ODM_SetBBReg(dm_odm, rFPGA0_XA_RFInterfaceOE, BIT(8) | BIT(9), 0x1); /* Aux */ } } diff --git a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c index 15386d42b0da..0fd11aca7ac7 100644 --- a/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c +++ b/drivers/staging/r8188eu/hal/HalPwrSeqCmd.c @@ -78,7 +78,7 @@ u8 HalPwrSeqCmdParsing(struct adapter *padapter, u8 cut_vers, u8 fab_vers, if (GET_PWR_CFG_VALUE(pwrcfgcmd) == PWRSEQ_DELAY_US) udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)); else - udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd)*1000); + udelay(GET_PWR_CFG_OFFSET(pwrcfgcmd) * 1000); break; case PWR_CMD_END: /* When this command is parsed, end the process */ diff --git a/drivers/staging/r8188eu/hal/hal_com.c b/drivers/staging/r8188eu/hal/hal_com.c index c3c76a37e52f..f09d4d49b159 100644 --- a/drivers/staging/r8188eu/hal/hal_com.c +++ b/drivers/staging/r8188eu/hal/hal_com.c @@ -16,46 +16,46 @@ void dump_chip_info(struct HAL_VERSION chip_vers) char buf[128]; if (IS_81XXC(chip_vers)) { - cnt += sprintf((buf+cnt), "Chip Version Info: %s_", + cnt += sprintf((buf + cnt), "Chip Version Info: %s_", IS_92C_SERIAL(chip_vers) ? "CHIP_8192C" : "CHIP_8188C"); } else if (IS_92D(chip_vers)) { - cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8192D_"); + cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8192D_"); } else if (IS_8723_SERIES(chip_vers)) { - cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8723A_"); + cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8723A_"); } else if (IS_8188E(chip_vers)) { - cnt += sprintf((buf+cnt), "Chip Version Info: CHIP_8188E_"); + cnt += sprintf((buf + cnt), "Chip Version Info: CHIP_8188E_"); } - cnt += sprintf((buf+cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ? + cnt += sprintf((buf + cnt), "%s_", IS_NORMAL_CHIP(chip_vers) ? "Normal_Chip" : "Test_Chip"); - cnt += sprintf((buf+cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ? + cnt += sprintf((buf + cnt), "%s_", IS_CHIP_VENDOR_TSMC(chip_vers) ? "TSMC" : "UMC"); if (IS_A_CUT(chip_vers)) - cnt += sprintf((buf+cnt), "A_CUT_"); + cnt += sprintf((buf + cnt), "A_CUT_"); else if (IS_B_CUT(chip_vers)) - cnt += sprintf((buf+cnt), "B_CUT_"); + cnt += sprintf((buf + cnt), "B_CUT_"); else if (IS_C_CUT(chip_vers)) - cnt += sprintf((buf+cnt), "C_CUT_"); + cnt += sprintf((buf + cnt), "C_CUT_"); else if (IS_D_CUT(chip_vers)) - cnt += sprintf((buf+cnt), "D_CUT_"); + cnt += sprintf((buf + cnt), "D_CUT_"); else if (IS_E_CUT(chip_vers)) - cnt += sprintf((buf+cnt), "E_CUT_"); + cnt += sprintf((buf + cnt), "E_CUT_"); else - cnt += sprintf((buf+cnt), "UNKNOWN_CUT(%d)_", + cnt += sprintf((buf + cnt), "UNKNOWN_CUT(%d)_", chip_vers.CUTVersion); if (IS_1T1R(chip_vers)) - cnt += sprintf((buf+cnt), "1T1R_"); + cnt += sprintf((buf + cnt), "1T1R_"); else if (IS_1T2R(chip_vers)) - cnt += sprintf((buf+cnt), "1T2R_"); + cnt += sprintf((buf + cnt), "1T2R_"); else if (IS_2T2R(chip_vers)) - cnt += sprintf((buf+cnt), "2T2R_"); + cnt += sprintf((buf + cnt), "2T2R_"); else - cnt += sprintf((buf+cnt), "UNKNOWN_RFTYPE(%d)_", + cnt += sprintf((buf + cnt), "UNKNOWN_RFTYPE(%d)_", chip_vers.RFType); - cnt += sprintf((buf+cnt), "RomVer(%d)\n", chip_vers.ROMVer); + cnt += sprintf((buf + cnt), "RomVer(%d)\n", chip_vers.ROMVer); pr_info("%s", buf); } @@ -337,7 +337,7 @@ s32 c2h_evt_read(struct adapter *adapter, u8 *buf) memset(c2h_evt, 0, 16); *buf = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL); - *(buf+1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); + *(buf + 1) = rtw_read8(adapter, REG_C2HEVT_MSG_NORMAL + 1); /* Read the content */ for (i = 0; i < c2h_evt->plen; i++) diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 87c3bd58b63b..3937b65db5cc 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -254,8 +254,8 @@ void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) #ifdef CONFIG_88EU_AP_MODE struct sta_info *psta = NULL; struct sta_priv *pstapriv = &adapt->stapriv; - if ((mac_id-1) > 0) - psta = pstapriv->sta_aid[(mac_id-1) - 1]; + if ((mac_id - 1) > 0) + psta = pstapriv->sta_aid[(mac_id - 1) - 1]; if (psta) add_RATid(adapt, psta, 0);/* todo: based on rssi_level*/ #endif diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index 8a56b1a2516b..babe37e4be8b 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -426,9 +426,9 @@ void ODM_CmnInfoUpdate(struct odm_dm_struct *pDM_Odm, u32 CmnInfo, u64 Value) void odm_CommonInfoSelfInit(struct odm_dm_struct *pDM_Odm) { - pDM_Odm->bCckHighPower = (bool) ODM_GetBBReg(pDM_Odm, 0x824, BIT(9)); - pDM_Odm->RFPathRxEnable = (u8) ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); - if (pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8192D)) + pDM_Odm->bCckHighPower = (bool)ODM_GetBBReg(pDM_Odm, 0x824, BIT(9)); + pDM_Odm->RFPathRxEnable = (u8)ODM_GetBBReg(pDM_Odm, 0xc04, 0x0F); + if (pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8192D)) pDM_Odm->AntDivType = CG_TRX_HW_ANTDIV; if (pDM_Odm->SupportICType & (ODM_RTL8723A)) pDM_Odm->AntDivType = CGCS_RX_SW_ANTDIV; @@ -480,11 +480,11 @@ void ODM_Write_DIG(struct odm_dm_struct *pDM_Odm, u8 CurrentIGI) struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; if (pDM_DigTable->CurIGValue != CurrentIGI) { - if (pDM_Odm->SupportPlatform & (ODM_CE|ODM_MP)) { + if (pDM_Odm->SupportPlatform & (ODM_CE | ODM_MP)) { ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); if (pDM_Odm->SupportICType != ODM_RTL8188E) ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_B, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); - } else if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + } else if (pDM_Odm->SupportPlatform & (ODM_AP | ODM_ADSL)) { switch (*pDM_Odm->pOnePathCCA) { case ODM_CCA_2R: ODM_SetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm), CurrentIGI); @@ -530,11 +530,11 @@ void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) if (bFwCurrentInPSMode) { /* Adjust by FA in LPS MODE */ if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH2_LPS) - CurrentIGI = CurrentIGI+2; + CurrentIGI = CurrentIGI + 2; else if (pFalseAlmCnt->Cnt_all > DM_DIG_FA_TH1_LPS) - CurrentIGI = CurrentIGI+1; + CurrentIGI = CurrentIGI + 1; else if (pFalseAlmCnt->Cnt_all < DM_DIG_FA_TH0_LPS) - CurrentIGI = CurrentIGI-1; + CurrentIGI = CurrentIGI - 1; } else { CurrentIGI = RSSI_Lower; } @@ -542,8 +542,8 @@ void odm_DIGbyRSSI_LPS(struct odm_dm_struct *pDM_Odm) /* Lower bound checking */ /* RSSI Lower bound check */ - if ((pDM_Odm->RSSI_Min-10) > DM_DIG_MIN_NIC) - RSSI_Lower = (pDM_Odm->RSSI_Min-10); + if ((pDM_Odm->RSSI_Min - 10) > DM_DIG_MIN_NIC) + RSSI_Lower = (pDM_Odm->RSSI_Min - 10); else RSSI_Lower = DM_DIG_MIN_NIC; @@ -560,7 +560,7 @@ void odm_DIGInit(struct odm_dm_struct *pDM_Odm) { struct rtw_dig *pDM_DigTable = &pDM_Odm->DM_DigTable; - pDM_DigTable->CurIGValue = (u8) ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)); + pDM_DigTable->CurIGValue = (u8)ODM_GetBBReg(pDM_Odm, ODM_REG(IGI_A, pDM_Odm), ODM_BIT(IGI, pDM_Odm)); pDM_DigTable->RssiLowThresh = DM_DIG_THRESH_LOW; pDM_DigTable->RssiHighThresh = DM_DIG_THRESH_HIGH; pDM_DigTable->FALowThresh = DM_false_ALARM_THRESH_LOW; @@ -599,7 +599,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) u8 dm_dig_max, dm_dig_min; u8 CurrentIGI = pDM_DigTable->CurIGValue; - if ((!(pDM_Odm->SupportAbility&ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility&ODM_BB_FA_CNT))) + if ((!(pDM_Odm->SupportAbility & ODM_BB_DIG)) || (!(pDM_Odm->SupportAbility & ODM_BB_FA_CNT))) return; if (*pDM_Odm->pbScanInProcess) @@ -632,9 +632,9 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } /* 1 Boundary Decision */ - if ((pDM_Odm->SupportICType & (ODM_RTL8192C|ODM_RTL8723A)) && + if ((pDM_Odm->SupportICType & (ODM_RTL8192C | ODM_RTL8723A)) && ((pDM_Odm->BoardType == ODM_BOARD_HIGHPWR) || pDM_Odm->ExtLNA)) { - if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + if (pDM_Odm->SupportPlatform & (ODM_AP | ODM_ADSL)) { dm_dig_max = DM_DIG_MAX_AP_HP; dm_dig_min = DM_DIG_MIN_AP_HP; } else { @@ -643,7 +643,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } DIG_MaxOfMin = DM_DIG_MAX_AP_HP; } else { - if (pDM_Odm->SupportPlatform & (ODM_AP|ODM_ADSL)) { + if (pDM_Odm->SupportPlatform & (ODM_AP | ODM_ADSL)) { dm_dig_max = DM_DIG_MAX_AP; dm_dig_min = DM_DIG_MIN_AP; DIG_MaxOfMin = dm_dig_max; @@ -685,7 +685,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) (pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) { /* 1 Lower Bound for 88E AntDiv */ if (pDM_Odm->AntDivType == CG_TRX_HW_ANTDIV) - DIG_Dynamic_MIN = (u8) pDM_DigTable->AntDiv_RSSI_max; + DIG_Dynamic_MIN = (u8)pDM_DigTable->AntDiv_RSSI_max; } else { DIG_Dynamic_MIN = dm_dig_min; } @@ -705,7 +705,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) } if (pDM_DigTable->LargeFAHit >= 3) { - if ((pDM_DigTable->ForbiddenIGI+1) > pDM_DigTable->rx_gain_range_max) + if ((pDM_DigTable->ForbiddenIGI + 1) > pDM_DigTable->rx_gain_range_max) pDM_DigTable->rx_gain_range_min = pDM_DigTable->rx_gain_range_max; else pDM_DigTable->rx_gain_range_min = (pDM_DigTable->ForbiddenIGI + 1); @@ -718,7 +718,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) pDM_DigTable->Recover_cnt--; } else { if (pDM_DigTable->LargeFAHit < 3) { - if ((pDM_DigTable->ForbiddenIGI-1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ + if ((pDM_DigTable->ForbiddenIGI - 1) < DIG_Dynamic_MIN) { /* DM_DIG_MIN) */ pDM_DigTable->ForbiddenIGI = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ pDM_DigTable->rx_gain_range_min = DIG_Dynamic_MIN; /* DM_DIG_MIN; */ } else { @@ -796,16 +796,16 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 1); /* hold page D counter */ ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE1_11N, bMaskDWord); - FalseAlmCnt->Cnt_Fast_Fsync = (ret_value&0xffff); - FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_Fast_Fsync = (ret_value & 0xffff); + FalseAlmCnt->Cnt_SB_Search_fail = ((ret_value & 0xffff0000) >> 16); ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE2_11N, bMaskDWord); - FalseAlmCnt->Cnt_OFDM_CCA = (ret_value&0xffff); - FalseAlmCnt->Cnt_Parity_Fail = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_OFDM_CCA = (ret_value & 0xffff); + FalseAlmCnt->Cnt_Parity_Fail = ((ret_value & 0xffff0000) >> 16); ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE3_11N, bMaskDWord); - FalseAlmCnt->Cnt_Rate_Illegal = (ret_value&0xffff); - FalseAlmCnt->Cnt_Crc8_fail = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_Rate_Illegal = (ret_value & 0xffff); + FalseAlmCnt->Cnt_Crc8_fail = ((ret_value & 0xffff0000) >> 16); ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_OFDM_FA_TYPE4_11N, bMaskDWord); - FalseAlmCnt->Cnt_Mcs_fail = (ret_value&0xffff); + FalseAlmCnt->Cnt_Mcs_fail = (ret_value & 0xffff); FalseAlmCnt->Cnt_Ofdm_fail = FalseAlmCnt->Cnt_Parity_Fail + FalseAlmCnt->Cnt_Rate_Illegal + FalseAlmCnt->Cnt_Crc8_fail + FalseAlmCnt->Cnt_Mcs_fail + @@ -813,8 +813,8 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) if (pDM_Odm->SupportICType == ODM_RTL8188E) { ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_SC_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_BW_LSC = (ret_value&0xffff); - FalseAlmCnt->Cnt_BW_USC = ((ret_value&0xffff0000)>>16); + FalseAlmCnt->Cnt_BW_LSC = (ret_value & 0xffff); + FalseAlmCnt->Cnt_BW_USC = ((ret_value & 0xffff0000) >> 16); } /* hold cck counter */ @@ -824,10 +824,10 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_LSB_11N, bMaskByte0); FalseAlmCnt->Cnt_Cck_fail = ret_value; ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_FA_MSB_11N, bMaskByte3); - FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff)<<8; + FalseAlmCnt->Cnt_Cck_fail += (ret_value & 0xff) << 8; ret_value = ODM_GetBBReg(pDM_Odm, ODM_REG_CCK_CCA_CNT_11N, bMaskDWord); - FalseAlmCnt->Cnt_CCK_CCA = ((ret_value&0xFF)<<8) | ((ret_value&0xFF00)>>8); + FalseAlmCnt->Cnt_CCK_CCA = ((ret_value & 0xFF) << 8) | ((ret_value & 0xFF00) >> 8); FalseAlmCnt->Cnt_all = (FalseAlmCnt->Cnt_Fast_Fsync + FalseAlmCnt->Cnt_SB_Search_fail + @@ -850,11 +850,11 @@ void odm_FalseAlarmCounterStatistics(struct odm_dm_struct *pDM_Odm) ODM_SetBBReg(pDM_Odm, ODM_REG_OFDM_FA_RSTD_11N, BIT(31), 0); /* update page D counter */ /* reset CCK CCA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(13)|BIT(12), 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(13)|BIT(12), 2); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(13) | BIT(12), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(13) | BIT(12), 2); /* reset CCK FA counter */ - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(15)|BIT(14), 0); - ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(15)|BIT(14), 2); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(15) | BIT(14), 0); + ODM_SetBBReg(pDM_Odm, ODM_REG_CCK_FA_RST_11N, BIT(15) | BIT(14), 2); } } else { /* FOR ODM_IC_11AC_SERIES */ /* read OFDM FA counter */ @@ -880,7 +880,7 @@ void odm_CCKPacketDetectionThresh(struct odm_dm_struct *pDM_Odm) u8 CurCCK_CCAThres; struct false_alarm_stats *FalseAlmCnt = &pDM_Odm->FalseAlmCnt; - if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD|ODM_BB_FA_CNT))) + if (!(pDM_Odm->SupportAbility & (ODM_BB_CCK_PD | ODM_BB_FA_CNT))) return; if (pDM_Odm->ExtLNA) return; @@ -935,7 +935,7 @@ void odm_DynamicBBPowerSaving(struct odm_dm_struct *pDM_Odm) return; if (!(pDM_Odm->SupportAbility & ODM_BB_PWR_SAVE)) return; - if (!(pDM_Odm->SupportPlatform & (ODM_MP|ODM_CE))) + if (!(pDM_Odm->SupportPlatform & (ODM_MP | ODM_CE))) return; /* 1 2.Power Saving for 92C */ @@ -993,10 +993,10 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) Rssi_Low_bound = 45; } if (pDM_PSTable->initialize == 0) { - pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord)&0x1CC000)>>14; - pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord)&BIT(3))>>3; - pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord)&0xFF000000)>>24; - pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord)&0xF000)>>12; + pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord) & 0x1CC000) >> 14; + pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord) & BIT(3)) >> 3; + pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord) & 0xFF000000) >> 24; + pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord) & 0xF000) >> 12; pDM_PSTable->initialize = 1; } @@ -1088,7 +1088,7 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u else rate_bitmap = 0x0000000f; break; - case (ODM_WM_B|ODM_WM_G): + case (ODM_WM_B | ODM_WM_G): if (rssi_level == DM_RATR_STA_HIGH) rate_bitmap = 0x00000f00; else if (rssi_level == DM_RATR_STA_MIDDLE) @@ -1096,7 +1096,7 @@ u32 ODM_Get_Rate_Bitmap(struct odm_dm_struct *pDM_Odm, u32 macid, u32 ra_mask, u else rate_bitmap = 0x00000ff5; break; - case (ODM_WM_B|ODM_WM_G|ODM_WM_N24G): + case (ODM_WM_B | ODM_WM_G | ODM_WM_N24G): if (pDM_Odm->RFType == ODM_1T2R || pDM_Odm->RFType == ODM_1T1R) { if (rssi_level == DM_RATR_STA_HIGH) { rate_bitmap = 0x000f0000; @@ -1378,7 +1378,7 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) if (psta->rssi_stat.UndecoratedSmoothedPWDB > tmpEntryMaxPWDB) tmpEntryMaxPWDB = psta->rssi_stat.UndecoratedSmoothedPWDB; if (psta->rssi_stat.UndecoratedSmoothedPWDB != (-1)) - PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB<<16)); + PWDB_rssi[sta_cnt++] = (psta->mac_id | (psta->rssi_stat.UndecoratedSmoothedPWDB << 16)); } } @@ -1388,7 +1388,7 @@ void odm_RSSIMonitorCheckCE(struct odm_dm_struct *pDM_Odm) /* Report every sta's RSSI to FW */ } else { ODM_RA_SetRSSI_8188E( - &pHalData->odmpriv, (PWDB_rssi[i]&0xFF), (u8)((PWDB_rssi[i]>>16) & 0xFF)); + &pHalData->odmpriv, (PWDB_rssi[i] & 0xFF), (u8)((PWDB_rssi[i] >> 16) & 0xFF)); } } } @@ -1693,7 +1693,7 @@ u32 GetPSDData(struct odm_dm_struct *pDM_Odm, unsigned int point, u8 initial_gai /* Read PSD report, Reg8B4[15:0] */ psd_report = ODM_GetBBReg(pDM_Odm, 0x8B4, bMaskDWord) & 0x0000FFFF; - psd_report = (u32) (ConvertTo_dB(psd_report))+(u32)(initial_gain_psd-0x1c); + psd_report = (u32)(ConvertTo_dB(psd_report)) + (u32)(initial_gain_psd - 0x1c); return psd_report; } @@ -1718,7 +1718,7 @@ u32 ConvertTo_dB(u32 Value) break; } - dB = i*12 + j + 1; + dB = i * 12 + j + 1; return dB; } @@ -1783,19 +1783,19 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) rSleep, rPMPD_ANAEN, rFPGA0_XCD_SwitchControl, rBlue_Tooth}; - if (!(pDM_Odm->SupportICType & (ODM_RTL8723A|ODM_RTL8192C))) + if (!(pDM_Odm->SupportICType & (ODM_RTL8723A | ODM_RTL8192C))) return bResult; - if (!(pDM_Odm->SupportAbility&ODM_BB_ANT_DIV)) + if (!(pDM_Odm->SupportAbility & ODM_BB_ANT_DIV)) return bResult; if (pDM_Odm->SupportICType == ODM_RTL8192C) { /* Which path in ADC/DAC is turnned on for PSD: both I/Q */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT(10)|BIT(11), 0x3); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(10) | BIT(11), 0x3); /* Ageraged number: 8 */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT(12)|BIT(13), 0x1); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(12) | BIT(13), 0x1); /* pts = 128; */ - ODM_SetBBReg(pDM_Odm, 0x808, BIT(14)|BIT(15), 0x0); + ODM_SetBBReg(pDM_Odm, 0x808, BIT(14) | BIT(15), 0x0); } /* 1 Backup Current RF/BB Settings */ @@ -1817,7 +1817,7 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) odm_PHY_SaveAFERegisters(pDM_Odm, AFE_REG_8723A, AFE_Backup, 16); /* Set PSD 128 pts */ - ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT(14)|BIT(15), 0x0); /* 128 pts */ + ODM_SetBBReg(pDM_Odm, rFPGA0_PSDFunction, BIT(14) | BIT(15), 0x0); /* 128 pts */ /* To SET CH1 to do */ ODM_SetRFReg(pDM_Odm, RF_PATH_A, ODM_CHANNEL, bRFRegOffsetMask, 0x01); /* Channel 1 */ @@ -1917,7 +1917,7 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) /* 2 Test Ant B based on Ant A is ON */ if (mode == ANTTESTB) { if (AntA_report >= 100) { - if (AntB_report > (AntA_report+1)) + if (AntB_report > (AntA_report + 1)) pDM_SWAT_Table->ANTB_ON = false; else pDM_SWAT_Table->ANTB_ON = true; @@ -1927,13 +1927,13 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) } } else if (mode == ANTTESTALL) { /* 2 Test Ant A and B based on DPDT Open */ - if ((AntO_report >= 100)&(AntO_report < 118)) { - if (AntA_report > (AntO_report+1)) + if ((AntO_report >= 100) & (AntO_report < 118)) { + if (AntA_report > (AntO_report + 1)) pDM_SWAT_Table->ANTA_ON = false; else pDM_SWAT_Table->ANTA_ON = true; - if (AntB_report > (AntO_report+2)) + if (AntB_report > (AntO_report + 2)) pDM_SWAT_Table->ANTB_ON = false; else pDM_SWAT_Table->ANTB_ON = true; @@ -1941,11 +1941,11 @@ bool ODM_SingleDualAntennaDetection(struct odm_dm_struct *pDM_Odm, u8 mode) } } else if (pDM_Odm->SupportICType == ODM_RTL8192C) { if (AntA_report >= 100) { - if (AntB_report > (AntA_report+2)) { + if (AntB_report > (AntA_report + 2)) { pDM_SWAT_Table->ANTA_ON = false; pDM_SWAT_Table->ANTB_ON = true; ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_B); - } else if (AntA_report > (AntB_report+2)) { + } else if (AntA_report > (AntB_report + 2)) { pDM_SWAT_Table->ANTA_ON = true; pDM_SWAT_Table->ANTB_ON = false; ODM_SetBBReg(pDM_Odm, rFPGA0_XA_RFInterfaceOE, 0x300, Antenna_A); -- cgit v1.2.3 From ea105f21c94fd3d40865ba6a4d1e61a310e86336 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 22:55:10 +0200 Subject: staging: r8188eu: clean up spacing style issues in hal dir, part 2 Clean up spacing style issues reported by checkpatch in the next 10 files in the hal directory. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited before semicolon WARNING: space prohibited between function name and open parenthesis '(' Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816205511.20068-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_HWConfig.c | 84 ++++---- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 70 +++---- drivers/staging/r8188eu/hal/odm_RegConfig8188E.c | 8 +- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 74 +++---- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 238 +++++++++++------------ drivers/staging/r8188eu/hal/rtl8188e_mp.c | 40 ++-- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 60 +++--- 7 files changed, 287 insertions(+), 287 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_HWConfig.c b/drivers/staging/r8188eu/hal/odm_HWConfig.c index 530357b58d66..ada22a526fee 100644 --- a/drivers/staging/r8188eu/hal/odm_HWConfig.c +++ b/drivers/staging/r8188eu/hal/odm_HWConfig.c @@ -15,7 +15,7 @@ static u8 odm_QueryRxPwrPercentage(s8 AntPower) else if (AntPower >= 0) return 100; else - return 100+AntPower; + return 100 + AntPower; } /* 2012/01/12 MH MOve some signal strength smooth method to MP HAL layer. */ @@ -39,7 +39,7 @@ static s32 odm_SignalScaleMapping_92CSeries(struct odm_dm_struct *dm_odm, s32 Cu if (CurrSig >= 51 && CurrSig <= 100) RetSig = 100; else if (CurrSig >= 41 && CurrSig <= 50) - RetSig = 80 + ((CurrSig - 40)*2); + RetSig = 80 + ((CurrSig - 40) * 2); else if (CurrSig >= 31 && CurrSig <= 40) RetSig = 66 + (CurrSig - 30); else if (CurrSig >= 21 && CurrSig <= 30) @@ -121,44 +121,44 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, cck_highpwr = dm_odm->bCckHighPower; - cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a ; + cck_agc_rpt = pPhyStaRpt->cck_agc_rpt_ofdm_cfosho_a; /* 2011.11.28 LukeLee: 88E use different LNA & VGA gain table */ /* The RSSI formula should be modified according to the gain table */ /* In 88E, cck_highpwr is always set to 1 */ - if (dm_odm->SupportICType & (ODM_RTL8188E|ODM_RTL8812)) { + if (dm_odm->SupportICType & (ODM_RTL8188E | ODM_RTL8812)) { LNA_idx = ((cck_agc_rpt & 0xE0) >> 5); VGA_idx = (cck_agc_rpt & 0x1F); switch (LNA_idx) { case 7: if (VGA_idx <= 27) - rx_pwr_all = -100 + 2*(27-VGA_idx); /* VGA_idx = 27~2 */ + rx_pwr_all = -100 + 2 * (27 - VGA_idx); /* VGA_idx = 27~2 */ else rx_pwr_all = -100; break; case 6: - rx_pwr_all = -48 + 2*(2-VGA_idx); /* VGA_idx = 2~0 */ + rx_pwr_all = -48 + 2 * (2 - VGA_idx); /* VGA_idx = 2~0 */ break; case 5: - rx_pwr_all = -42 + 2*(7-VGA_idx); /* VGA_idx = 7~5 */ + rx_pwr_all = -42 + 2 * (7 - VGA_idx); /* VGA_idx = 7~5 */ break; case 4: - rx_pwr_all = -36 + 2*(7-VGA_idx); /* VGA_idx = 7~4 */ + rx_pwr_all = -36 + 2 * (7 - VGA_idx); /* VGA_idx = 7~4 */ break; case 3: - rx_pwr_all = -24 + 2*(7-VGA_idx); /* VGA_idx = 7~0 */ + rx_pwr_all = -24 + 2 * (7 - VGA_idx); /* VGA_idx = 7~0 */ break; case 2: if (cck_highpwr) - rx_pwr_all = -12 + 2*(5-VGA_idx); /* VGA_idx = 5~0 */ + rx_pwr_all = -12 + 2 * (5 - VGA_idx); /* VGA_idx = 5~0 */ else - rx_pwr_all = -6 + 2*(5-VGA_idx); + rx_pwr_all = -6 + 2 * (5 - VGA_idx); break; case 1: - rx_pwr_all = 8-2*VGA_idx; + rx_pwr_all = 8 - 2 * VGA_idx; break; case 0: - rx_pwr_all = 14-2*VGA_idx; + rx_pwr_all = 14 - 2 * VGA_idx; break; default: break; @@ -167,7 +167,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, PWDB_ALL = odm_QueryRxPwrPercentage(rx_pwr_all); if (!cck_highpwr) { if (PWDB_ALL >= 80) - PWDB_ALL = ((PWDB_ALL-80)<<1)+((PWDB_ALL-80)>>1)+80; + PWDB_ALL = ((PWDB_ALL - 80) << 1) + ((PWDB_ALL - 80) >> 1) + 80; else if ((PWDB_ALL <= 78) && (PWDB_ALL >= 20)) PWDB_ALL += 3; if (PWDB_ALL > 100) @@ -175,7 +175,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, } } else { if (!cck_highpwr) { - report = (cck_agc_rpt & 0xc0)>>6; + report = (cck_agc_rpt & 0xc0) >> 6; switch (report) { /* 03312009 modified by cosa */ /* Modify the RF RNA gain value to -40, -20, -2, 14 by Jenyu's suggestion */ @@ -194,19 +194,19 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, break; } } else { - report = (cck_agc_rpt & 0x60)>>5; + report = (cck_agc_rpt & 0x60) >> 5; switch (report) { case 0x3: - rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f)<<1) ; + rx_pwr_all = -46 - ((cck_agc_rpt & 0x1f) << 1); break; case 0x2: - rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = -26 - ((cck_agc_rpt & 0x1f) << 1); break; case 0x1: - rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = -12 - ((cck_agc_rpt & 0x1f) << 1); break; case 0x0: - rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = 16 - ((cck_agc_rpt & 0x1f) << 1); break; } } @@ -215,13 +215,13 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, /* Modification for ext-LNA board */ if (dm_odm->BoardType == ODM_BOARD_HIGHPWR) { - if ((cck_agc_rpt>>7) == 0) { - PWDB_ALL = (PWDB_ALL > 94) ? 100 : (PWDB_ALL+6); + if ((cck_agc_rpt >> 7) == 0) { + PWDB_ALL = (PWDB_ALL > 94) ? 100 : (PWDB_ALL + 6); } else { if (PWDB_ALL > 38) PWDB_ALL -= 16; else - PWDB_ALL = (PWDB_ALL <= 16) ? (PWDB_ALL>>2) : (PWDB_ALL-12); + PWDB_ALL = (PWDB_ALL <= 16) ? (PWDB_ALL >> 2) : (PWDB_ALL - 12); } /* CCK modification */ @@ -254,7 +254,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, else if (SQ_rpt < 20) SQ = 100; else - SQ = ((64-SQ_rpt) * 100) / 44; + SQ = ((64 - SQ_rpt) * 100) / 44; } pPhyInfo->SignalQuality = SQ; pPhyInfo->RxMIMOSignalQuality[RF_PATH_A] = SQ; @@ -270,7 +270,7 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, if (dm_odm->RFPathRxEnable & BIT(i)) rf_rx_num++; - rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F)*2) - 110; + rx_pwr[i] = ((pPhyStaRpt->path_agc[i].gain & 0x3F) * 2) - 110; if (i == RF_PATH_A) adapt->signal_strength = rx_pwr[i]; @@ -294,8 +294,8 @@ static void odm_RxPhyStatus92CSeries_Parsing(struct odm_dm_struct *dm_odm, pPhyInfo->RxMIMOSignalStrength[i] = (u8)RSSI; /* Get Rx snr value in DB */ - pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); - dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i]/2); + pPhyInfo->RxSNR[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); + dm_odm->PhyDbgInfo.RxSNRdB[i] = (s32)(pPhyStaRpt->path_rxsnr[i] / 2); /* Record Signal Strength for next packet */ if (pPktinfo->bPacketMatchBSSID) { @@ -390,8 +390,8 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, if (dm_odm->AntDivType == CG_TRX_SMART_ANTDIV) { if (pDM_FatTable->FAT_State == FAT_TRAINING_STATE) { if (pPktinfo->bPacketToSelf) { - antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | - (pDM_FatTable->antsel_rx_keep_1<<1) | + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2 << 2) | + (pDM_FatTable->antsel_rx_keep_1 << 1) | pDM_FatTable->antsel_rx_keep_0; pDM_FatTable->antSumRSSI[antsel_tr_mux] += pPhyInfo->RxPWDBAll; pDM_FatTable->antRSSIcnt[antsel_tr_mux]++; @@ -399,8 +399,8 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, } } else if ((dm_odm->AntDivType == CG_TRX_HW_ANTDIV) || (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV)) { if (pPktinfo->bPacketToSelf || pPktinfo->bPacketBeacon) { - antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2<<2) | - (pDM_FatTable->antsel_rx_keep_1<<1) | pDM_FatTable->antsel_rx_keep_0; + antsel_tr_mux = (pDM_FatTable->antsel_rx_keep_2 << 2) | + (pDM_FatTable->antsel_rx_keep_1 << 1) | pDM_FatTable->antsel_rx_keep_0; ODM_AntselStatistics_88E(dm_odm, antsel_tr_mux, pPktinfo->StationID, pPhyInfo->RxPWDBAll); } } @@ -439,17 +439,17 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, } else { if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedOFDM) { UndecoratedSmoothedOFDM = - (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + + (((UndecoratedSmoothedOFDM) * (Rx_Smooth_Factor - 1)) + (RSSI_Ave)) / (Rx_Smooth_Factor); UndecoratedSmoothedOFDM = UndecoratedSmoothedOFDM + 1; } else { UndecoratedSmoothedOFDM = - (((UndecoratedSmoothedOFDM)*(Rx_Smooth_Factor-1)) + + (((UndecoratedSmoothedOFDM) * (Rx_Smooth_Factor - 1)) + (RSSI_Ave)) / (Rx_Smooth_Factor); } } - pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap<<1) | BIT(0); + pEntry->rssi_stat.PacketMap = (pEntry->rssi_stat.PacketMap << 1) | BIT(0); } else { RSSI_Ave = pPhyInfo->RxPWDBAll; @@ -460,16 +460,16 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, } else { if (pPhyInfo->RxPWDBAll > (u32)UndecoratedSmoothedCCK) { UndecoratedSmoothedCCK = - ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor-1)) + + ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor - 1)) + pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; UndecoratedSmoothedCCK = UndecoratedSmoothedCCK + 1; } else { UndecoratedSmoothedCCK = - ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor-1)) + + ((UndecoratedSmoothedCCK * (Rx_Smooth_Factor - 1)) + pPhyInfo->RxPWDBAll) / Rx_Smooth_Factor; } } - pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap<<1; + pEntry->rssi_stat.PacketMap = pEntry->rssi_stat.PacketMap << 1; } /* 2011.07.28 LukeLee: modified to prevent unstable CCK RSSI */ if (pEntry->rssi_stat.ValidBit >= 64) @@ -478,16 +478,16 @@ static void odm_Process_RSSIForDM(struct odm_dm_struct *dm_odm, pEntry->rssi_stat.ValidBit++; for (i = 0; i < pEntry->rssi_stat.ValidBit; i++) - OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap>>i)&BIT(0); + OFDM_pkt += (u8)(pEntry->rssi_stat.PacketMap >> i) & BIT(0); if (pEntry->rssi_stat.ValidBit == 64) { - Weighting = ((OFDM_pkt<<4) > 64) ? 64 : (OFDM_pkt<<4); - UndecoratedSmoothedPWDB = (Weighting*UndecoratedSmoothedOFDM+(64-Weighting)*UndecoratedSmoothedCCK)>>6; + Weighting = ((OFDM_pkt << 4) > 64) ? 64 : (OFDM_pkt << 4); + UndecoratedSmoothedPWDB = (Weighting * UndecoratedSmoothedOFDM + (64 - Weighting) * UndecoratedSmoothedCCK) >> 6; } else { if (pEntry->rssi_stat.ValidBit != 0) UndecoratedSmoothedPWDB = (OFDM_pkt * UndecoratedSmoothedOFDM + - (pEntry->rssi_stat.ValidBit-OFDM_pkt) * - UndecoratedSmoothedCCK)/pEntry->rssi_stat.ValidBit; + (pEntry->rssi_stat.ValidBit - OFDM_pkt) * + UndecoratedSmoothedCCK) / pEntry->rssi_stat.ValidBit; else UndecoratedSmoothedPWDB = 0; } diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index b6b95649f3af..10fe1ecc0342 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -8,7 +8,7 @@ void ODM_DIG_LowerBound_88E(struct odm_dm_struct *dm_odm) struct rtw_dig *pDM_DigTable = &dm_odm->DM_DigTable; if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) - pDM_DigTable->rx_gain_range_min = (u8) pDM_DigTable->AntDiv_RSSI_max; + pDM_DigTable->rx_gain_range_min = (u8)pDM_DigTable->AntDiv_RSSI_max; /* If only one Entry connected */ } @@ -25,9 +25,9 @@ static void odm_RX_HWAntDivInit(struct odm_dm_struct *dm_odm) /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT(23)|BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32 | (BIT(23) | BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ /* Pin Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT(9)|BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT(9) | BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0); /* Reg864[10]=1'b0 antsel2 by HW */ ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(22), 1); /* Regb2c[22]=1'b0 disable CS/CG switch */ ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); /* Regb2c[31]=1'b1 output at CG only */ @@ -47,15 +47,15 @@ static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) if (*dm_odm->mp_mode == 1) { dm_odm->AntDivType = CGCS_RX_SW_ANTDIV; ODM_SetBBReg(dm_odm, ODM_REG_IGI_A_11N, BIT(7), 0); /* disable HW AntDiv */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5)|BIT(4)|BIT(3), 0); /* Default RX (0/1) */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5) | BIT(4) | BIT(3), 0); /* Default RX (0/1) */ return; } /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord); - ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32|(BIT(23)|BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + ODM_SetMACReg(dm_odm, ODM_REG_ANTSEL_PIN_11N, bMaskDWord, value32 | (BIT(23) | BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ /* Pin Settings */ - ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT(9)|BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, ODM_REG_PIN_CTRL_11N, BIT(9) | BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(10), 0); /* Reg864[10]=1'b0 antsel2 by HW */ ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(22), 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ ODM_SetBBReg(dm_odm, ODM_REG_LNA_SWITCH_11N, BIT(31), 1); /* Regb2c[31]=1'b1 output at CG only */ @@ -70,8 +70,8 @@ static void odm_TRX_HWAntDivInit(struct odm_dm_struct *dm_odm) /* antenna mapping table */ if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT(10)|BIT(9)|BIT(8), 1); /* Reg858[10:8]=3'b001 */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT(13)|BIT(12)|BIT(11), 2); /* Reg858[13:11]=3'b010 */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT(10) | BIT(9) | BIT(8), 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_DEFUALT_A_11N, BIT(13) | BIT(12) | BIT(11), 2); /* Reg858[13:11]=3'b010 */ } else { /* MPchip */ ODM_SetBBReg(dm_odm, ODM_REG_ANT_MAPPING1_11N, bMaskDWord, 0x0201); /* Reg914=3'b010, Reg915=3'b001 */ } @@ -97,15 +97,15 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) /* MAC Setting */ value32 = ODM_GetMACReg(dm_odm, 0x4c, bMaskDWord); - ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32|(BIT(23)|BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ + ODM_SetMACReg(dm_odm, 0x4c, bMaskDWord, value32 | (BIT(23) | BIT(25))); /* Reg4C[25]=1, Reg4C[23]=1 for pin output */ value32 = ODM_GetMACReg(dm_odm, 0x7B4, bMaskDWord); - ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32|(BIT(16)|BIT(17))); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ + ODM_SetMACReg(dm_odm, 0x7b4, bMaskDWord, value32 | (BIT(16) | BIT(17))); /* Reg7B4[16]=1 enable antenna training, Reg7B4[17]=1 enable A2 match */ /* Match MAC ADDR */ ODM_SetMACReg(dm_odm, 0x7b4, 0xFFFF, 0); ODM_SetMACReg(dm_odm, 0x7b0, bMaskDWord, 0); - ODM_SetBBReg(dm_odm, 0x870, BIT(9)|BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ + ODM_SetBBReg(dm_odm, 0x870, BIT(9) | BIT(8), 0);/* Reg870[8]=1'b0, Reg870[9]=1'b0 antsel antselb by HW */ ODM_SetBBReg(dm_odm, 0x864, BIT(10), 0); /* Reg864[10]=1'b0 antsel2 by HW */ ODM_SetBBReg(dm_odm, 0xb2c, BIT(22), 0); /* Regb2c[22]=1'b0 disable CS/CG switch */ ODM_SetBBReg(dm_odm, 0xb2c, BIT(31), 1); /* Regb2c[31]=1'b1 output at CG only */ @@ -114,23 +114,23 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) /* antenna mapping table */ if (AntCombination == 2) { if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, 0x858, BIT(10)|BIT(9)|BIT(8), 1); /* Reg858[10:8]=3'b001 */ - ODM_SetBBReg(dm_odm, 0x858, BIT(13)|BIT(12)|BIT(11), 2); /* Reg858[13:11]=3'b010 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(10) | BIT(9) | BIT(8), 1); /* Reg858[10:8]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(13) | BIT(12) | BIT(11), 2); /* Reg858[13:11]=3'b010 */ } else { /* MPchip */ ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 1); ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 2); } } else if (AntCombination == 7) { if (!dm_odm->bIsMPChip) { /* testchip */ - ODM_SetBBReg(dm_odm, 0x858, BIT(10)|BIT(9)|BIT(8), 0); /* Reg858[10:8]=3'b000 */ - ODM_SetBBReg(dm_odm, 0x858, BIT(13)|BIT(12)|BIT(11), 1); /* Reg858[13:11]=3'b001 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(10) | BIT(9) | BIT(8), 0); /* Reg858[10:8]=3'b000 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(13) | BIT(12) | BIT(11), 1); /* Reg858[13:11]=3'b001 */ ODM_SetBBReg(dm_odm, 0x878, BIT(16), 0); - ODM_SetBBReg(dm_odm, 0x858, BIT(15)|BIT(14), 2); /* Reg878[0],Reg858[14:15])=3'b010 */ - ODM_SetBBReg(dm_odm, 0x878, BIT(19)|BIT(18)|BIT(17), 3);/* Reg878[3:1]=3b'011 */ - ODM_SetBBReg(dm_odm, 0x878, BIT(22)|BIT(21)|BIT(20), 4);/* Reg878[6:4]=3b'100 */ - ODM_SetBBReg(dm_odm, 0x878, BIT(25)|BIT(24)|BIT(23), 5);/* Reg878[9:7]=3b'101 */ - ODM_SetBBReg(dm_odm, 0x878, BIT(28)|BIT(27)|BIT(26), 6);/* Reg878[12:10]=3b'110 */ - ODM_SetBBReg(dm_odm, 0x878, BIT(31)|BIT(30)|BIT(29), 7);/* Reg878[15:13]=3b'111 */ + ODM_SetBBReg(dm_odm, 0x858, BIT(15) | BIT(14), 2); /* Reg878[0],Reg858[14:15])=3'b010 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(19) | BIT(18) | BIT(17), 3);/* Reg878[3:1]=3b'011 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(22) | BIT(21) | BIT(20), 4);/* Reg878[6:4]=3b'100 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(25) | BIT(24) | BIT(23), 5);/* Reg878[9:7]=3b'101 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(28) | BIT(27) | BIT(26), 6);/* Reg878[12:10]=3b'110 */ + ODM_SetBBReg(dm_odm, 0x878, BIT(31) | BIT(30) | BIT(29), 7);/* Reg878[15:13]=3b'111 */ } else { /* MPchip */ ODM_SetBBReg(dm_odm, 0x914, bMaskByte0, 0); ODM_SetBBReg(dm_odm, 0x914, bMaskByte1, 1); @@ -145,11 +145,11 @@ static void odm_FastAntTrainingInit(struct odm_dm_struct *dm_odm) /* Default Ant Setting when no fast training */ ODM_SetBBReg(dm_odm, 0x80c, BIT(21), 1); /* Reg80c[21]=1'b1 from TX Info */ - ODM_SetBBReg(dm_odm, 0x864, BIT(5)|BIT(4)|BIT(3), 0); /* Default RX */ - ODM_SetBBReg(dm_odm, 0x864, BIT(8)|BIT(7)|BIT(6), 1); /* Optional RX */ + ODM_SetBBReg(dm_odm, 0x864, BIT(5) | BIT(4) | BIT(3), 0); /* Default RX */ + ODM_SetBBReg(dm_odm, 0x864, BIT(8) | BIT(7) | BIT(6), 1); /* Optional RX */ /* Enter Traing state */ - ODM_SetBBReg(dm_odm, 0x864, BIT(2)|BIT(1)|BIT(0), (AntCombination-1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ + ODM_SetBBReg(dm_odm, 0x864, BIT(2) | BIT(1) | BIT(0), (AntCombination - 1)); /* Reg864[2:0]=3'd6 ant combination=reg864[2:0]+1 */ ODM_SetBBReg(dm_odm, 0xc50, BIT(7), 1); /* RegC50[7]=1'b1 enable HW AntDiv */ } @@ -181,13 +181,13 @@ void ODM_UpdateRxIdleAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant) } if (dm_odm->AntDivType == CG_TRX_HW_ANTDIV) { - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5)|BIT(4)|BIT(3), DefaultAnt); /* Default RX */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(8)|BIT(7)|BIT(6), OptionalAnt); /* Optional RX */ - ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT(14)|BIT(13)|BIT(12), DefaultAnt); /* Default TX */ - ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT(6)|BIT(7), DefaultAnt); /* Resp Tx */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5) | BIT(4) | BIT(3), DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(8) | BIT(7) | BIT(6), OptionalAnt); /* Optional RX */ + ODM_SetBBReg(dm_odm, ODM_REG_ANTSEL_CTRL_11N, BIT(14) | BIT(13) | BIT(12), DefaultAnt); /* Default TX */ + ODM_SetMACReg(dm_odm, ODM_REG_RESP_TX_11N, BIT(6) | BIT(7), DefaultAnt); /* Resp Tx */ } else if (dm_odm->AntDivType == CGCS_RX_HW_ANTDIV) { - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5)|BIT(4)|BIT(3), DefaultAnt); /* Default RX */ - ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(8)|BIT(7)|BIT(6), OptionalAnt); /* Optional RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(5) | BIT(4) | BIT(3), DefaultAnt); /* Default RX */ + ODM_SetBBReg(dm_odm, ODM_REG_RX_ANT_CTRL_11N, BIT(8) | BIT(7) | BIT(6), OptionalAnt); /* Optional RX */ } } dm_fat_tbl->RxIdleAnt = Ant; @@ -204,9 +204,9 @@ static void odm_UpdateTxAnt_88E(struct odm_dm_struct *dm_odm, u8 Ant, u32 MacId) TargetAnt = MAIN_ANT_CG_TRX; else TargetAnt = AUX_ANT_CG_TRX; - dm_fat_tbl->antsel_a[MacId] = TargetAnt&BIT(0); - dm_fat_tbl->antsel_b[MacId] = (TargetAnt&BIT(1))>>1; - dm_fat_tbl->antsel_c[MacId] = (TargetAnt&BIT(2))>>2; + dm_fat_tbl->antsel_a[MacId] = TargetAnt & BIT(0); + dm_fat_tbl->antsel_b[MacId] = (TargetAnt & BIT(1)) >> 1; + dm_fat_tbl->antsel_c[MacId] = (TargetAnt & BIT(2)) >> 2; } void ODM_SetTxAntByTxInfo_88E(struct odm_dm_struct *dm_odm, u8 *pDesc, u8 macId) @@ -255,8 +255,8 @@ static void odm_HWAntDiv(struct odm_dm_struct *dm_odm) pEntry = dm_odm->pODM_StaInfo[i]; if (IS_STA_VALID(pEntry)) { /* 2 Caculate RSSI per Antenna */ - Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i]/dm_fat_tbl->MainAnt_Cnt[i]) : 0; - Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i]/dm_fat_tbl->AuxAnt_Cnt[i]) : 0; + Main_RSSI = (dm_fat_tbl->MainAnt_Cnt[i] != 0) ? (dm_fat_tbl->MainAnt_Sum[i] / dm_fat_tbl->MainAnt_Cnt[i]) : 0; + Aux_RSSI = (dm_fat_tbl->AuxAnt_Cnt[i] != 0) ? (dm_fat_tbl->AuxAnt_Sum[i] / dm_fat_tbl->AuxAnt_Cnt[i]) : 0; TargetAnt = (Main_RSSI >= Aux_RSSI) ? MAIN_ANT : AUX_ANT; /* 2 Select MaxRSSI for DIG */ LocalMaxRSSI = (Main_RSSI > Aux_RSSI) ? Main_RSSI : Aux_RSSI; diff --git a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c index ec8158e37cb3..1bc3b49cd67f 100644 --- a/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RegConfig8188E.c @@ -29,17 +29,17 @@ void odm_ConfigRFReg_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, void odm_ConfigRF_RadioA_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) { u32 content = 0x1000; /* RF_Content: radioa_txt */ - u32 maskforPhySet = (u32)(content&0xE000); + u32 maskforPhySet = (u32)(content & 0xE000); - odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_A, Addr|maskforPhySet); + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_A, Addr | maskforPhySet); } void odm_ConfigRF_RadioB_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u32 Data) { u32 content = 0x1001; /* RF_Content: radiob_txt */ - u32 maskforPhySet = (u32)(content&0xE000); + u32 maskforPhySet = (u32)(content & 0xE000); - odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_B, Addr|maskforPhySet); + odm_ConfigRFReg_8188E(pDM_Odm, Addr, Data, RF_PATH_B, Addr | maskforPhySet); } void odm_ConfigMAC_8188E(struct odm_dm_struct *pDM_Odm, u32 Addr, u8 Data) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 6cbda9ab6e3f..6afdebd4f367 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -80,26 +80,26 @@ static s32 FillH2CCmd_88E(struct adapter *adapt, u8 ElementID, u32 CmdLen, u8 *p *(u8 *)(&h2c_cmd) = ElementID; if (CmdLen <= 3) { - memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, CmdLen); + memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, CmdLen); } else { - memcpy((u8 *)(&h2c_cmd)+1, pCmdBuffer, 3); - ext_cmd_len = CmdLen-3; - memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer+3, ext_cmd_len); + memcpy((u8 *)(&h2c_cmd) + 1, pCmdBuffer, 3); + ext_cmd_len = CmdLen - 3; + memcpy((u8 *)(&h2c_cmd_ex), pCmdBuffer + 3, ext_cmd_len); /* Write Ext command */ msgbox_ex_addr = REG_HMEBOX_EXT_0 + (h2c_box_num * RTL88E_EX_MESSAGE_BOX_SIZE); for (cmd_idx = 0; cmd_idx < ext_cmd_len; cmd_idx++) { - rtw_write8(adapt, msgbox_ex_addr+cmd_idx, *((u8 *)(&h2c_cmd_ex)+cmd_idx)); + rtw_write8(adapt, msgbox_ex_addr + cmd_idx, *((u8 *)(&h2c_cmd_ex) + cmd_idx)); } } /* Write command */ msgbox_addr = REG_HMEBOX_0 + (h2c_box_num * RTL88E_MESSAGE_BOX_SIZE); for (cmd_idx = 0; cmd_idx < RTL88E_MESSAGE_BOX_SIZE; cmd_idx++) { - rtw_write8(adapt, msgbox_addr+cmd_idx, *((u8 *)(&h2c_cmd)+cmd_idx)); + rtw_write8(adapt, msgbox_addr + cmd_idx, *((u8 *)(&h2c_cmd) + cmd_idx)); } bcmd_down = true; - haldata->LastHMEBoxNum = (h2c_box_num+1) % RTL88E_MAX_H2C_BOX_NUMS; + haldata->LastHMEBoxNum = (h2c_box_num + 1) % RTL88E_MAX_H2C_BOX_NUMS; } while ((!bcmd_down) && (retry_cnts--)); @@ -157,24 +157,24 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi u8 macid, init_rate, raid, shortGIrate = false; - macid = arg&0x1f; + macid = arg & 0x1f; - raid = (bitmap>>28) & 0x0f; + raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fffffff; if (rssi_level != DM_RATR_STA_INIT) bitmap = ODM_Get_Rate_Bitmap(&haldata->odmpriv, macid, bitmap, rssi_level); - bitmap |= ((raid<<28)&0xf0000000); + bitmap |= ((raid << 28) & 0xf0000000); - init_rate = get_highest_rate_idx(bitmap&0x0fffffff)&0x3f; + init_rate = get_highest_rate_idx(bitmap & 0x0fffffff) & 0x3f; - shortGIrate = (arg&BIT(5)) ? true : false; + shortGIrate = (arg & BIT(5)) ? true : false; if (shortGIrate) init_rate |= BIT(6); - raid = (bitmap>>28) & 0x0f; + raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fffffff; @@ -216,7 +216,7 @@ void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) break; } - H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps<<4)&0xf0) | (RLBM & 0x0f)); + H2CSetPwrMode.SmartPS_RLBM = (((pwrpriv->smart_ps << 4) & 0xf0) | (RLBM & 0x0f)); H2CSetPwrMode.AwakeInterval = 1; @@ -235,7 +235,7 @@ void rtl8188e_set_FwMediaStatus_cmd(struct adapter *adapt, __le16 mstatus_rpt) { u8 opmode, macid; u16 mst_rpt = le16_to_cpu(mstatus_rpt); - opmode = (u8) mst_rpt; + opmode = (u8)mst_rpt; macid = (u8)(mst_rpt >> 8); DBG_88E("### %s: MStatus=%x MACID=%d\n", __func__, opmode, macid); @@ -283,9 +283,9 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) pframe += 2; pktlen += 2; - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { pktlen += cur_network->IELength - sizeof(struct ndis_802_11_fixed_ie); - memcpy(pframe, cur_network->IEs+sizeof(struct ndis_802_11_fixed_ie), pktlen); + memcpy(pframe, cur_network->IEs + sizeof(struct ndis_802_11_fixed_ie), pktlen); goto _ConstructBeacon; } @@ -302,7 +302,7 @@ static void ConstructBeacon(struct adapter *adapt, u8 *pframe, u32 *pLength) /* DS parameter set */ pframe = rtw_set_ie(pframe, _DSSET_IE_, 1, (unsigned char *)&cur_network->Configuration.DSConfig, &pktlen); - if ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) { + if ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) { u32 ATIMWindow; /* IBSS Parameter Set... */ ATIMWindow = 0; @@ -516,43 +516,43 @@ static void SetFwRsvdPagePkt(struct adapter *adapt, bool bDLFinished) PageNum += PageNeed; haldata->FwRsvdPageStartOffset = PageNum; - BufIndex += PageNeed*128; + BufIndex += PageNeed * 128; /* 3 (2) ps-poll *1 page */ RsvdPageLoc.LocPsPoll = PageNum; ConstructPSPoll(adapt, &ReservedPagePacket[BufIndex], &PSPollLength); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], PSPollLength, true, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], PSPollLength, true, false); PageNeed = (u8)PageNum_128(TxDescLen + PSPollLength); PageNum += PageNeed; - BufIndex += PageNeed*128; + BufIndex += PageNeed * 128; /* 3 (3) null data * 1 page */ RsvdPageLoc.LocNullData = PageNum; ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &NullDataLength, get_my_bssid(&pmlmeinfo->network), false, 0, 0, false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], NullDataLength, false, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], NullDataLength, false, false); PageNeed = (u8)PageNum_128(TxDescLen + NullDataLength); PageNum += PageNeed; - BufIndex += PageNeed*128; + BufIndex += PageNeed * 128; /* 3 (4) probe response * 1page */ RsvdPageLoc.LocProbeRsp = PageNum; ConstructProbeRsp(adapt, &ReservedPagePacket[BufIndex], &ProbeRspLength, get_my_bssid(&pmlmeinfo->network), false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], ProbeRspLength, false, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], ProbeRspLength, false, false); PageNeed = (u8)PageNum_128(TxDescLen + ProbeRspLength); PageNum += PageNeed; - BufIndex += PageNeed*128; + BufIndex += PageNeed * 128; /* 3 (5) Qos null data */ RsvdPageLoc.LocQosNull = PageNum; ConstructNullFunctionData(adapt, &ReservedPagePacket[BufIndex], &QosNullLength, get_my_bssid(&pmlmeinfo->network), true, 0, 0, false); - rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex-TxDescLen], QosNullLength, false, false); + rtl8188e_fill_fake_txdesc(adapt, &ReservedPagePacket[BufIndex - TxDescLen], QosNullLength, false, false); PageNeed = (u8)PageNum_128(TxDescLen + QosNullLength); PageNum += PageNeed; @@ -594,26 +594,26 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) if (mstatus == 1) { /* We should set AID, correct TSF, HW seq enable before set JoinBssReport to Fw in 88/92C. */ /* Suggested by filen. Added by tynli. */ - rtw_write16(adapt, REG_BCN_PSR_RPT, (0xC000|pmlmeinfo->aid)); + rtw_write16(adapt, REG_BCN_PSR_RPT, (0xC000 | pmlmeinfo->aid)); /* Do not set TSF again here or vWiFi beacon DMA INT will not work. */ /* Set REG_CR bit 8. DMA beacon by SW. */ haldata->RegCR_1 |= BIT(0); - rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + rtw_write8(adapt, REG_CR + 1, haldata->RegCR_1); /* Disable Hw protection for a time which revserd for Hw sending beacon. */ /* Fix download reserved page packet fail that access collision with the protection time. */ /* 2010.05.11. Added by tynli. */ - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(3))); - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(4)); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL) & (~BIT(3))); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL) | BIT(4)); - if (haldata->RegFwHwTxQCtrl&BIT(6)) { + if (haldata->RegFwHwTxQCtrl & BIT(6)) { DBG_88E("HalDownloadRSVDPage(): There is an Adapter is sending beacon.\n"); bSendBeacon = true; } /* Set FWHW_TXQ_CTRL 0x422[6]=0 to tell Hw the packet is not a real beacon frame. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl&(~BIT(6)))); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl & (~BIT(6)))); haldata->RegFwHwTxQCtrl &= (~BIT(6)); /* Clear beacon valid check bit. */ @@ -630,7 +630,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* check rsvd page download OK. */ rtw_hal_get_hwreg(adapt, HW_VAR_BCN_VALID, (u8 *)(&bcn_valid)); poll++; - } while (!bcn_valid && (poll%10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); + } while (!bcn_valid && (poll % 10) != 0 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); } while (!bcn_valid && DLBcnCount <= 100 && !adapt->bSurpriseRemoved && !adapt->bDriverStopped); if (adapt->bSurpriseRemoved || adapt->bDriverStopped) @@ -647,8 +647,8 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* */ /* Enable Bcn */ - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)|BIT(3)); - rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL)&(~BIT(4))); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL) | BIT(3)); + rtw_write8(adapt, REG_BCN_CTRL, rtw_read8(adapt, REG_BCN_CTRL) & (~BIT(4))); /* To make sure that if there exists an adapter which would like to send beacon. */ /* If exists, the origianl value of 0x422[6] will be 1, we should check this to */ @@ -656,7 +656,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* the beacon cannot be sent by HW. */ /* 2010.06.23. Added by tynli. */ if (bSendBeacon) { - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl|BIT(6))); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl | BIT(6))); haldata->RegFwHwTxQCtrl |= BIT(6); } @@ -669,7 +669,7 @@ void rtl8188e_set_FwJoinBssReport_cmd(struct adapter *adapt, u8 mstatus) /* Do not enable HW DMA BCN or it will cause Pcie interface hang by timing issue. 2011.11.24. by tynli. */ /* Clear CR[8] or beacon packet will not be send to TxBuf anymore. */ haldata->RegCR_1 &= (~BIT(0)); - rtw_write8(adapt, REG_CR+1, haldata->RegCR_1); + rtw_write8(adapt, REG_CR + 1, haldata->RegCR_1); } } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 24a82fc41872..e27d8966498a 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -17,7 +17,7 @@ static void iol_mode_enable(struct adapter *padapter, u8 enable) if (enable) { /* Enable initial offload */ reg_0xf0 = rtw_read8(padapter, REG_SYS_CFG); - rtw_write8(padapter, REG_SYS_CFG, reg_0xf0|SW_OFFLOAD_EN); + rtw_write8(padapter, REG_SYS_CFG, reg_0xf0 | SW_OFFLOAD_EN); if (!padapter->bFWReady) { DBG_88E("bFWReady == false call reset 8051...\n"); @@ -37,9 +37,9 @@ static s32 iol_execute(struct adapter *padapter, u8 control) u8 reg_0x88 = 0; u32 start = 0, passing_time = 0; - control = control&0x0f; + control = control & 0x0f; reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); - rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88|control); + rtw_write8(padapter, REG_HMEBOX_E0, reg_0x88 | control); start = jiffies; while ((reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0)) & control && @@ -49,7 +49,7 @@ static s32 iol_execute(struct adapter *padapter, u8 control) reg_0x88 = rtw_read8(padapter, REG_HMEBOX_E0); status = (reg_0x88 & control) ? _FAIL : _SUCCESS; - if (reg_0x88 & control<<4) + if (reg_0x88 & control << 4) status = _FAIL; return status; } @@ -58,7 +58,7 @@ static s32 iol_InitLLTTable(struct adapter *padapter, u8 txpktbuf_bndy) { s32 rst = _SUCCESS; iol_mode_enable(padapter, 1); - rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); rst = iol_execute(padapter, CMD_INIT_LLT); iol_mode_enable(padapter, 0); return rst; @@ -97,7 +97,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) /* 1. Read the first byte to check if efuse is empty!!! */ /* */ /* */ - rtemp8 = *(phymap+eFuse_Addr); + rtemp8 = *(phymap + eFuse_Addr); if (rtemp8 != 0xFF) { efuse_utilized++; eFuse_Addr++; @@ -113,10 +113,10 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) /* Check PG header for section num. */ if ((rtemp8 & 0x1F) == 0x0F) { /* extended header */ u1temp = ((rtemp8 & 0xE0) >> 5); - rtemp8 = *(phymap+eFuse_Addr); + rtemp8 = *(phymap + eFuse_Addr); if ((rtemp8 & 0x0F) == 0x0F) { eFuse_Addr++; - rtemp8 = *(phymap+eFuse_Addr); + rtemp8 = *(phymap + eFuse_Addr); if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) eFuse_Addr++; @@ -136,13 +136,13 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) for (i = 0; i < EFUSE_MAX_WORD_UNIT; i++) { /* Check word enable condition in the section */ if (!(wren & 0x01)) { - rtemp8 = *(phymap+eFuse_Addr); + rtemp8 = *(phymap + eFuse_Addr); eFuse_Addr++; efuse_utilized++; eFuseWord[offset][i] = (rtemp8 & 0xff); if (eFuse_Addr >= EFUSE_REAL_CONTENT_LEN_88E) break; - rtemp8 = *(phymap+eFuse_Addr); + rtemp8 = *(phymap + eFuse_Addr); eFuse_Addr++; efuse_utilized++; eFuseWord[offset][i] |= (((u16)rtemp8 << 8) & 0xff00); @@ -154,7 +154,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) } } /* Read next PG header */ - rtemp8 = *(phymap+eFuse_Addr); + rtemp8 = *(phymap + eFuse_Addr); if (rtemp8 != 0xFF && (eFuse_Addr < EFUSE_REAL_CONTENT_LEN_88E)) { efuse_utilized++; @@ -167,8 +167,8 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) /* */ for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { - efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); - efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff); } } @@ -176,7 +176,7 @@ efuse_phymap_to_logical(u8 *phymap, u16 _offset, u16 _size_byte, u8 *pbuf) /* 4. Copy from Efuse map to output pointer memory!!! */ /* */ for (i = 0; i < _size_byte; i++) - pbuf[i] = efuseTbl[_offset+i]; + pbuf[i] = efuseTbl[_offset + i]; /* */ /* 5. Calculate Efuse utilization. */ @@ -205,16 +205,16 @@ static void efuse_read_phymap_from_txpktbuf( u8 *pos = content; if (bcnhead < 0) /* if not valid */ - bcnhead = rtw_read8(adapter, REG_TDECTRL+1); + bcnhead = rtw_read8(adapter, REG_TDECTRL + 1); DBG_88E("%s bcnhead:%d\n", __func__, bcnhead); rtw_write8(adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); - dbg_addr = bcnhead*128/8; /* 8-bytes addressing */ + dbg_addr = bcnhead * 128 / 8; /* 8-bytes addressing */ while (1) { - rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr+i); + rtw_write16(adapter, REG_PKTBUF_DBG_ADDR, dbg_addr + i); rtw_write8(adapter, REG_TXPKTBUF_DBG, 0); start = jiffies; @@ -237,26 +237,26 @@ static void efuse_read_phymap_from_txpktbuf( len = le32_to_cpu(lo32) & 0x0000ffff; - limit = (len-2 < limit) ? len-2 : limit; + limit = (len - 2 < limit) ? len - 2 : limit; DBG_88E("%s len:%u, lenc:%u\n", __func__, len, lenc); - memcpy(pos, ((u8 *)&lo32)+2, (limit >= count+2) ? 2 : limit-count); - count += (limit >= count+2) ? 2 : limit-count; - pos = content+count; + memcpy(pos, ((u8 *)&lo32) + 2, (limit >= count + 2) ? 2 : limit - count); + count += (limit >= count + 2) ? 2 : limit - count; + pos = content + count; } else { - memcpy(pos, ((u8 *)&lo32), (limit >= count+4) ? 4 : limit-count); - count += (limit >= count+4) ? 4 : limit-count; - pos = content+count; + memcpy(pos, ((u8 *)&lo32), (limit >= count + 4) ? 4 : limit - count); + count += (limit >= count + 4) ? 4 : limit - count; + pos = content + count; } - if (limit > count && len-2 > count) { - memcpy(pos, (u8 *)&hi32, (limit >= count+4) ? 4 : limit-count); - count += (limit >= count+4) ? 4 : limit-count; - pos = content+count; + if (limit > count && len - 2 > count) { + memcpy(pos, (u8 *)&hi32, (limit >= count + 4) ? 4 : limit - count); + count += (limit >= count + 4) ? 4 : limit - count; + pos = content + count; } - if (limit <= count || len-2 <= count) + if (limit <= count || len - 2 <= count) break; i++; } @@ -271,7 +271,7 @@ static s32 iol_read_efuse(struct adapter *padapter, u8 txpktbuf_bndy, u16 offset u8 physical_map[512]; u16 size = 512; - rtw_write8(padapter, REG_TDECTRL+1, txpktbuf_bndy); + rtw_write8(padapter, REG_TDECTRL + 1, txpktbuf_bndy); memset(physical_map, 0xFF, 512); rtw_write8(padapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); status = iol_execute(padapter, CMD_READ_EFUSE_MAP); @@ -301,7 +301,7 @@ static s32 iol_ioconfig(struct adapter *padapter, u8 iocfg_bndy) { s32 rst = _SUCCESS; - rtw_write8(padapter, REG_TDECTRL+1, iocfg_bndy); + rtw_write8(padapter, REG_TDECTRL + 1, iocfg_bndy); rst = iol_execute(padapter, CMD_IOCONFIG); return rst; } @@ -314,7 +314,7 @@ static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_fram if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) goto exit; - if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE+pattrib->last_txcmdsz)) { + if (rtw_usb_bulk_size_boundary(adapter, TXDESC_SIZE + pattrib->last_txcmdsz)) { if (rtw_IOL_append_END_cmd(xmit_frame) != _SUCCESS) goto exit; } @@ -324,7 +324,7 @@ static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_fram iol_mode_enable(adapter, 1); for (i = 0; i < bndy_cnt; i++) { u8 page_no = 0; - page_no = i*2; + page_no = i * 2; ret = iol_ioconfig(adapter, page_no); if (ret != _SUCCESS) break; @@ -332,7 +332,7 @@ static int rtl8188e_IOL_exec_cmds_sync(struct adapter *adapter, struct xmit_fram iol_mode_enable(adapter, 0); exit: /* restore BCN_HEAD */ - rtw_write8(adapter, REG_TDECTRL+1, 0); + rtw_write8(adapter, REG_TDECTRL + 1, 0); return ret; } @@ -340,8 +340,8 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) { u32 fifo_data, reg_140; u32 addr, rstatus, loop = 0; - u16 data_cnts = (data_len/8)+1; - u8 *pbuf = rtw_zvmalloc(data_len+10); + u16 data_cnts = (data_len / 8) + 1; + u8 *pbuf = rtw_zvmalloc(data_len + 10); DBG_88E("###### %s ######\n", __func__); rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); @@ -351,13 +351,13 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) rtw_usleep_os(2); loop = 0; do { - rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL)&BIT(24)); + rstatus = (reg_140 = rtw_read32(Adapter, REG_PKTBUF_DBG_CTRL) & BIT(24)); if (rstatus) { fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_L); - memcpy(pbuf+(addr*8), &fifo_data, 4); + memcpy(pbuf + (addr * 8), &fifo_data, 4); fifo_data = rtw_read32(Adapter, REG_PKTBUF_DBG_DATA_H); - memcpy(pbuf+(addr*8+4), &fifo_data, 4); + memcpy(pbuf + (addr * 8 + 4), &fifo_data, 4); } rtw_usleep_os(2); } while (!rstatus && (loop++ < 10)); @@ -378,15 +378,15 @@ static void _FWDownloadEnable(struct adapter *padapter, bool enable) rtw_write8(padapter, REG_MCUFWDL, tmp | 0x01); /* 8051 reset */ - tmp = rtw_read8(padapter, REG_MCUFWDL+2); - rtw_write8(padapter, REG_MCUFWDL+2, tmp&0xf7); + tmp = rtw_read8(padapter, REG_MCUFWDL + 2); + rtw_write8(padapter, REG_MCUFWDL + 2, tmp & 0xf7); } else { /* MCU firmware download disable. */ tmp = rtw_read8(padapter, REG_MCUFWDL); - rtw_write8(padapter, REG_MCUFWDL, tmp&0xfe); + rtw_write8(padapter, REG_MCUFWDL, tmp & 0xfe); /* Reserved for fw extension. */ - rtw_write8(padapter, REG_MCUFWDL+1, 0x00); + rtw_write8(padapter, REG_MCUFWDL + 1, 0x00); } } @@ -419,11 +419,11 @@ static int _BlockWrite(struct adapter *padapter, void *buffer, u32 buffSize) if (remainSize_p1) { offset = blockCount_p1 * blockSize_p1; - blockCount_p2 = remainSize_p1/blockSize_p2; - remainSize_p2 = remainSize_p1%blockSize_p2; + blockCount_p2 = remainSize_p1 / blockSize_p2; + remainSize_p2 = remainSize_p1 % blockSize_p2; for (i = 0; i < blockCount_p2; i++) { - ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + offset + i*blockSize_p2), blockSize_p2, (bufferPtr + offset + i*blockSize_p2)); + ret = rtw_writeN(padapter, (FW_8188E_START_ADDRESS + offset + i * blockSize_p2), blockSize_p2, (bufferPtr + offset + i * blockSize_p2)); if (ret == _FAIL) goto exit; @@ -453,8 +453,8 @@ static int _PageWrite(struct adapter *padapter, u32 page, void *buffer, u32 size u8 value8; u8 u8Page = (u8)(page & 0x07); - value8 = (rtw_read8(padapter, REG_MCUFWDL+2) & 0xF8) | u8Page; - rtw_write8(padapter, REG_MCUFWDL+2, value8); + value8 = (rtw_read8(padapter, REG_MCUFWDL + 2) & 0xF8) | u8Page; + rtw_write8(padapter, REG_MCUFWDL + 2, value8); return _BlockWrite(padapter, buffer, size); } @@ -473,7 +473,7 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) for (page = 0; page < pageNums; page++) { offset = page * MAX_PAGE_SIZE; - ret = _PageWrite(padapter, page, bufferPtr+offset, MAX_PAGE_SIZE); + ret = _PageWrite(padapter, page, bufferPtr + offset, MAX_PAGE_SIZE); if (ret == _FAIL) goto exit; @@ -481,7 +481,7 @@ static int _WriteFW(struct adapter *padapter, void *buffer, u32 size) if (remainSize) { offset = pageNums * MAX_PAGE_SIZE; page = pageNums; - ret = _PageWrite(padapter, page, bufferPtr+offset, remainSize); + ret = _PageWrite(padapter, page, bufferPtr + offset, remainSize); if (ret == _FAIL) goto exit; @@ -494,9 +494,9 @@ void _8051Reset88E(struct adapter *padapter) { u8 u1bTmp; - u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN+1); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp&(~BIT(2))); - rtw_write8(padapter, REG_SYS_FUNC_EN+1, u1bTmp|(BIT(2))); + u1bTmp = rtw_read8(padapter, REG_SYS_FUNC_EN + 1); + rtw_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp & (~BIT(2))); + rtw_write8(padapter, REG_SYS_FUNC_EN + 1, u1bTmp | (BIT(2))); DBG_88E("=====> _8051Reset88E(): 8051 reset success .\n"); } @@ -741,18 +741,18 @@ hal_EfusePowerSwitch_RTL8188E( if (bWrite) { /* Enable LDO 2.5V before read/write action */ - tempval = rtw_read8(pAdapter, EFUSE_TEST+3); + tempval = rtw_read8(pAdapter, EFUSE_TEST + 3); tempval &= 0x0F; tempval |= (VOLTAGE_V25 << 4); - rtw_write8(pAdapter, EFUSE_TEST+3, (tempval | 0x80)); + rtw_write8(pAdapter, EFUSE_TEST + 3, (tempval | 0x80)); } } else { rtw_write8(pAdapter, REG_EFUSE_ACCESS, EFUSE_ACCESS_OFF); if (bWrite) { /* Disable LDO 2.5V after read/write action */ - tempval = rtw_read8(pAdapter, EFUSE_TEST+3); - rtw_write8(pAdapter, EFUSE_TEST+3, (tempval & 0x7F)); + tempval = rtw_read8(pAdapter, EFUSE_TEST + 3); + rtw_write8(pAdapter, EFUSE_TEST + 3, (tempval & 0x7F)); } } } @@ -882,14 +882,14 @@ static void Hal_EfuseReadEFuse88E(struct adapter *Adapter, /* 3. Collect 16 sections and 4 word unit into Efuse map. */ for (i = 0; i < EFUSE_MAX_SECTION_88E; i++) { for (j = 0; j < EFUSE_MAX_WORD_UNIT; j++) { - efuseTbl[(i*8)+(j*2)] = (eFuseWord[i][j] & 0xff); - efuseTbl[(i*8)+((j*2)+1)] = ((eFuseWord[i][j] >> 8) & 0xff); + efuseTbl[(i * 8) + (j * 2)] = (eFuseWord[i][j] & 0xff); + efuseTbl[(i * 8) + ((j * 2) + 1)] = ((eFuseWord[i][j] >> 8) & 0xff); } } /* 4. Copy from Efuse map to output pointer memory!!! */ for (i = 0; i < _size_byte; i++) - pbuf[i] = efuseTbl[_offset+i]; + pbuf[i] = efuseTbl[_offset + i]; /* 5. Calculate Efuse utilization. */ rtw_hal_set_hwreg(Adapter, HW_VAR_EFUSE_BYTES, (u8 *)&eFuse_Addr); @@ -930,7 +930,7 @@ static void rtl8188e_ReadEFuse(struct adapter *Adapter, u8 efuseType, bool bPseudoTest) { if (bPseudoTest) - ReadEFuse_Pseudo (Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); + ReadEFuse_Pseudo(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); else ReadEFuseByIC(Adapter, efuseType, _offset, _size_byte, pbuf, bPseudoTest); } @@ -964,14 +964,14 @@ static void Hal_EFUSEGetEfuseDefinition88E(struct adapter *pAdapter, u8 efuseTyp { u16 *pu2Tmp; pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E - EFUSE_OOB_PROTECT_BYTES_88E); } break; case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: { u16 *pu2Tmp; pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E - EFUSE_OOB_PROTECT_BYTES_88E); } break; case TYPE_EFUSE_MAP_LEN: @@ -1026,14 +1026,14 @@ static void Hal_EFUSEGetEfuseDefinition_Pseudo88E(struct adapter *pAdapter, u8 e { u16 *pu2Tmp; pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E - EFUSE_OOB_PROTECT_BYTES_88E); } break; case TYPE_AVAILABLE_EFUSE_BYTES_TOTAL: { u16 *pu2Tmp; pu2Tmp = (u16 *)pOut; - *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E-EFUSE_OOB_PROTECT_BYTES_88E); + *pu2Tmp = (u16)(EFUSE_REAL_CONTENT_LEN_88E - EFUSE_OOB_PROTECT_BYTES_88E); } break; case TYPE_EFUSE_MAP_LEN: @@ -1077,43 +1077,43 @@ static u8 Hal_EfuseWordEnableDataWrite(struct adapter *pAdapter, u16 efuse_addr, memset((void *)tmpdata, 0xff, PGPKT_DATA_SIZE); - if (!(word_en&BIT(0))) { + if (!(word_en & BIT(0))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[0], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[1], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[0], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[1], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[1], bPseudoTest); if ((data[0] != tmpdata[0]) || (data[1] != tmpdata[1])) badworden &= (~BIT(0)); } - if (!(word_en&BIT(1))) { + if (!(word_en & BIT(1))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[2], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[3], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[2], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[3], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[3], bPseudoTest); if ((data[2] != tmpdata[2]) || (data[3] != tmpdata[3])) badworden &= (~BIT(1)); } - if (!(word_en&BIT(2))) { + if (!(word_en & BIT(2))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[4], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[5], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[4], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[5], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[5], bPseudoTest); if ((data[4] != tmpdata[4]) || (data[5] != tmpdata[5])) badworden &= (~BIT(2)); } - if (!(word_en&BIT(3))) { + if (!(word_en & BIT(3))) { tmpaddr = start_addr; efuse_OneByteWrite(pAdapter, start_addr++, data[6], bPseudoTest); efuse_OneByteWrite(pAdapter, start_addr++, data[7], bPseudoTest); efuse_OneByteRead(pAdapter, tmpaddr, &tmpdata[6], bPseudoTest); - efuse_OneByteRead(pAdapter, tmpaddr+1, &tmpdata[7], bPseudoTest); + efuse_OneByteRead(pAdapter, tmpaddr + 1, &tmpdata[7], bPseudoTest); if ((data[6] != tmpdata[6]) || (data[7] != tmpdata[7])) badworden &= (~BIT(3)); } @@ -1133,7 +1133,7 @@ static u8 rtl8188e_Efuse_WordEnableDataWrite(struct adapter *pAdapter, u16 efuse u8 ret = 0; if (bPseudoTest) - ret = Hal_EfuseWordEnableDataWrite_Pseudo (pAdapter, efuse_addr, word_en, data, bPseudoTest); + ret = Hal_EfuseWordEnableDataWrite_Pseudo(pAdapter, efuse_addr, word_en, data, bPseudoTest); else ret = Hal_EfuseWordEnableDataWrite(pAdapter, efuse_addr, word_en, data, bPseudoTest); return ret; @@ -1155,7 +1155,7 @@ static u16 hal_EfuseGetCurrentSize_8188e(struct adapter *pAdapter, bool bPseudoT efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest) && AVAILABLE_EFUSE_ADDR(efuse_addr)) { if (efuse_data != 0xFF) { - if ((efuse_data&0x1F) == 0x0F) { /* extended header */ + if ((efuse_data & 0x1F) == 0x0F) { /* extended header */ hoffset = efuse_data; efuse_addr++; efuse_OneByteRead(pAdapter, efuse_addr, &efuse_data, bPseudoTest); @@ -1167,12 +1167,12 @@ static u16 hal_EfuseGetCurrentSize_8188e(struct adapter *pAdapter, bool bPseudoT hworden = efuse_data & 0x0F; } } else { - hoffset = (efuse_data>>4) & 0x0F; + hoffset = (efuse_data >> 4) & 0x0F; hworden = efuse_data & 0x0F; } word_cnts = Efuse_CalculateWordCnts(hworden); /* read next header */ - efuse_addr = efuse_addr + (word_cnts*2)+1; + efuse_addr = efuse_addr + (word_cnts * 2) + 1; } else { bContinual = false; } @@ -1225,8 +1225,8 @@ static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 * if (offset > max_section) return false; - memset((void *)data, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); - memset((void *)tmpdata, 0xff, sizeof(u8)*PGPKT_DATA_SIZE); + memset((void *)data, 0xff, sizeof(u8) * PGPKT_DATA_SIZE); + memset((void *)tmpdata, 0xff, sizeof(u8) * PGPKT_DATA_SIZE); /* Efuse has been pre-programmed dummy 5Bytes at the end of Efuse by CP. */ /* Skip dummy parts to prevent unexpected data read from Efuse. */ @@ -1248,15 +1248,15 @@ static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 * continue; } } else { - hoffset = (efuse_data>>4) & 0x0F; + hoffset = (efuse_data >> 4) & 0x0F; hworden = efuse_data & 0x0F; } word_cnts = Efuse_CalculateWordCnts(hworden); bDataEmpty = true; if (hoffset == offset) { - for (tmpidx = 0; tmpidx < word_cnts*2; tmpidx++) { - if (efuse_OneByteRead(pAdapter, efuse_addr+1+tmpidx, &efuse_data, bPseudoTest)) { + for (tmpidx = 0; tmpidx < word_cnts * 2; tmpidx++) { + if (efuse_OneByteRead(pAdapter, efuse_addr + 1 + tmpidx, &efuse_data, bPseudoTest)) { tmpdata[tmpidx] = efuse_data; if (efuse_data != 0xff) bDataEmpty = false; @@ -1265,11 +1265,11 @@ static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 * if (bDataEmpty == false) { ReadState = PG_STATE_DATA; } else {/* read next header */ - efuse_addr = efuse_addr + (word_cnts*2)+1; + efuse_addr = efuse_addr + (word_cnts * 2) + 1; ReadState = PG_STATE_HEADER; } } else {/* read next header */ - efuse_addr = efuse_addr + (word_cnts*2)+1; + efuse_addr = efuse_addr + (word_cnts * 2) + 1; ReadState = PG_STATE_HEADER; } } else { @@ -1278,7 +1278,7 @@ static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 * } else if (ReadState & PG_STATE_DATA) { /* Data section Read ------------- */ efuse_WordEnableDataRead(hworden, tmpdata, data); - efuse_addr = efuse_addr + (word_cnts*2)+1; + efuse_addr = efuse_addr + (word_cnts * 2) + 1; ReadState = PG_STATE_HEADER; } @@ -1312,7 +1312,7 @@ static int rtl8188e_Efuse_PgPacketRead(struct adapter *pAdapter, u8 offset, u8 * int ret; if (bPseudoTest) - ret = Hal_EfusePgPacketRead_Pseudo (pAdapter, offset, data, bPseudoTest); + ret = Hal_EfusePgPacketRead_Pseudo(pAdapter, offset, data, bPseudoTest); else ret = Hal_EfusePgPacketRead(pAdapter, offset, data, bPseudoTest); return ret; @@ -1328,7 +1328,7 @@ static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, st if (Efuse_PgPacketRead(pAdapter, pFixPkt->offset, originaldata, bPseudoTest)) { /* check if data exist */ - badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pFixPkt->word_en, originaldata, bPseudoTest); + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr + 1, pFixPkt->word_en, originaldata, bPseudoTest); if (badworden != 0xf) { /* write fail */ PgWriteSuccess = Efuse_PgPacketWrite(pAdapter, pFixPkt->offset, badworden, originaldata, bPseudoTest); @@ -1338,10 +1338,10 @@ static bool hal_EfuseFixHeaderProcess(struct adapter *pAdapter, u8 efuseType, st else efuse_addr = Efuse_GetCurrentSize(pAdapter, efuseType, bPseudoTest); } else { - efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + efuse_addr = efuse_addr + (pFixPkt->word_cnts * 2) + 1; } } else { - efuse_addr = efuse_addr + (pFixPkt->word_cnts*2) + 1; + efuse_addr = efuse_addr + (pFixPkt->word_cnts * 2) + 1; } *pAddr = efuse_addr; return true; @@ -1437,7 +1437,7 @@ static bool hal_EfusePgPacketWrite1ByteHeader(struct adapter *pAdapter, u8 efuse bRet = true; } else { struct pgpkt fixPkt; - fixPkt.offset = (tmp_header>>4) & 0x0F; + fixPkt.offset = (tmp_header >> 4) & 0x0F; fixPkt.word_en = tmp_header & 0x0F; fixPkt.word_cnts = Efuse_CalculateWordCnts(fixPkt.word_en); if (!hal_EfuseFixHeaderProcess(pAdapter, efuseType, &fixPkt, &efuse_addr, bPseudoTest)) @@ -1455,7 +1455,7 @@ static bool hal_EfusePgPacketWriteData(struct adapter *pAdapter, u8 efuseType, u u32 PgWriteSuccess = 0; badworden = 0x0f; - badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr+1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); + badworden = Efuse_WordEnableDataWrite(pAdapter, efuse_addr + 1, pTargetPkt->word_en, pTargetPkt->data, bPseudoTest); if (badworden == 0x0F) { /* write ok */ return true; @@ -1519,8 +1519,8 @@ static bool hal_EfuseCheckIfDatafollowed(struct adapter *pAdapter, u8 word_cnts, bool bRet = false; u8 i, efuse_data; - for (i = 0; i < (word_cnts*2); i++) { - if (efuse_OneByteRead(pAdapter, (startAddr+i), &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) + for (i = 0; i < (word_cnts * 2); i++) { + if (efuse_OneByteRead(pAdapter, (startAddr + i), &efuse_data, bPseudoTest) && (efuse_data != 0xFF)) bRet = true; } return bRet; @@ -1539,16 +1539,16 @@ static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u if (efuseType == EFUSE_WIFI) { if (bPseudoTest) { - startAddr = (u16)(fakeEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + startAddr = (u16)(fakeEfuseUsedBytes % EFUSE_REAL_CONTENT_LEN); } else { rtw_hal_get_hwreg(pAdapter, HW_VAR_EFUSE_BYTES, (u8 *)&startAddr); startAddr %= EFUSE_REAL_CONTENT_LEN; } } else { if (bPseudoTest) - startAddr = (u16)(fakeBTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + startAddr = (u16)(fakeBTEfuseUsedBytes % EFUSE_REAL_CONTENT_LEN); else - startAddr = (u16)(BTEfuseUsedBytes%EFUSE_REAL_CONTENT_LEN); + startAddr = (u16)(BTEfuseUsedBytes % EFUSE_REAL_CONTENT_LEN); } while (1) { @@ -1571,7 +1571,7 @@ static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u } } else { cur_header = efuse_data; - curPkt.offset = (cur_header>>4) & 0x0F; + curPkt.offset = (cur_header >> 4) & 0x0F; curPkt.word_en = cur_header & 0x0F; } @@ -1579,10 +1579,10 @@ static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u /* if same header is found but no data followed */ /* write some part of data followed by the header. */ if ((curPkt.offset == pTargetPkt->offset) && - (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr+1, bPseudoTest)) && + (!hal_EfuseCheckIfDatafollowed(pAdapter, curPkt.word_cnts, startAddr + 1, bPseudoTest)) && wordEnMatched(pTargetPkt, &curPkt, &matched_wden)) { /* Here to write partial data */ - badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr+1, matched_wden, pTargetPkt->data, bPseudoTest); + badworden = Efuse_WordEnableDataWrite(pAdapter, startAddr + 1, matched_wden, pTargetPkt->data, bPseudoTest); if (badworden != 0x0F) { u32 PgWriteSuccess = 0; /* if write fail on some words, write these bad words again */ @@ -1596,13 +1596,13 @@ static bool hal_EfusePartialWriteCheck(struct adapter *pAdapter, u8 efuseType, u } /* partial write ok, update the target packet for later use */ for (i = 0; i < 4; i++) { - if ((matched_wden & (0x1<word_en |= (0x1<word_en |= (0x1 << i); /* disable the word */ } pTargetPkt->word_cnts = Efuse_CalculateWordCnts(pTargetPkt->word_en); } /* read from next header */ - startAddr = startAddr + (curPkt.word_cnts*2) + 1; + startAddr = startAddr + (curPkt.word_cnts * 2) + 1; } else { /* not used header, 0xff */ *pAddr = startAddr; @@ -1632,7 +1632,7 @@ hal_EfusePgCheckAvailableAddr( static void hal_EfuseConstructPGPkt(u8 offset, u8 word_en, u8 *pData, struct pgpkt *pTargetPkt) { - memset((void *)pTargetPkt->data, 0xFF, sizeof(u8)*8); + memset((void *)pTargetPkt->data, 0xFF, sizeof(u8) * 8); pTargetPkt->offset = offset; pTargetPkt->word_en = word_en; efuse_WordEnableDataRead(word_en, pData, pTargetPkt->data); @@ -1683,7 +1683,7 @@ static int rtl8188e_Efuse_PgPacketWrite(struct adapter *pAdapter, u8 offset, u8 int ret; if (bPseudoTest) - ret = Hal_EfusePgPacketWrite_Pseudo (pAdapter, offset, word_en, data, bPseudoTest); + ret = Hal_EfusePgPacketWrite_Pseudo(pAdapter, offset, word_en, data, bPseudoTest); else ret = Hal_EfusePgPacketWrite(pAdapter, offset, word_en, data, bPseudoTest); return ret; @@ -1703,7 +1703,7 @@ static struct HAL_VERSION ReadChipVersion8188E(struct adapter *padapter) ChipVersion.RFType = RF_TYPE_1T1R; ChipVersion.VendorType = ((value32 & VENDOR_ID) ? CHIP_VENDOR_UMC : CHIP_VENDOR_TSMC); - ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK)>>CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ + ChipVersion.CUTVersion = (value32 & CHIP_VER_RTL_MASK) >> CHIP_VER_RTL_SHIFT; /* IC version (CUT) */ /* For regulator mode. by tynli. 2011.01.14 */ pHalData->RegulatorMode = ((value32 & TRP_BT_EN) ? RT_LDO_REGULATOR : RT_SWITCHING_REGULATOR); @@ -1786,10 +1786,10 @@ static void hal_notch_filter_8188e(struct adapter *adapter, bool enable) { if (enable) { DBG_88E("Enable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) | BIT(1)); + rtw_write8(adapter, rOFDM0_RxDSP + 1, rtw_read8(adapter, rOFDM0_RxDSP + 1) | BIT(1)); } else { DBG_88E("Disable notch filter\n"); - rtw_write8(adapter, rOFDM0_RxDSP+1, rtw_read8(adapter, rOFDM0_RxDSP+1) & ~BIT(1)); + rtw_write8(adapter, rOFDM0_RxDSP + 1, rtw_read8(adapter, rOFDM0_RxDSP + 1) & ~BIT(1)); } } void rtl8188e_set_hal_ops(struct hal_ops *pHalFunc) @@ -1996,7 +1996,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (pwrInfo24G->IndexCCK_Base[rfPath][group] == 0xFF) pwrInfo24G->IndexCCK_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; } - for (group = 0; group < MAX_CHNL_GROUP_24G-1; group++) { + for (group = 0; group < MAX_CHNL_GROUP_24G - 1; group++) { pwrInfo24G->IndexBW40_Base[rfPath][group] = PROMContent[eeAddr++]; if (pwrInfo24G->IndexBW40_Base[rfPath][group] == 0xFF) pwrInfo24G->IndexBW40_Base[rfPath][group] = EEPROM_DEFAULT_24G_INDEX; @@ -2007,7 +2007,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_HT20_DIFF; } else { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4; if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; } @@ -2015,7 +2015,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_24G_OFDM_DIFF; } else { - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f); if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; } @@ -2025,7 +2025,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->BW40_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { - pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + pwrInfo24G->BW40_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4; if (pwrInfo24G->BW40_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW40_Diff[rfPath][TxCount] |= 0xF0; } @@ -2033,7 +2033,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->BW20_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { - pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + pwrInfo24G->BW20_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f); if (pwrInfo24G->BW20_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->BW20_Diff[rfPath][TxCount] |= 0xF0; } @@ -2042,7 +2042,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->OFDM_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { - pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0xf0)>>4; + pwrInfo24G->OFDM_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0xf0) >> 4; if (pwrInfo24G->OFDM_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->OFDM_Diff[rfPath][TxCount] |= 0xF0; } @@ -2050,7 +2050,7 @@ static void Hal_ReadPowerValueFromPROM_8188E(struct txpowerinfo24g *pwrInfo24G, if (PROMContent[eeAddr] == 0xFF) { pwrInfo24G->CCK_Diff[rfPath][TxCount] = EEPROM_DEFAULT_DIFF; } else { - pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr]&0x0f); + pwrInfo24G->CCK_Diff[rfPath][TxCount] = (PROMContent[eeAddr] & 0x0f); if (pwrInfo24G->CCK_Diff[rfPath][TxCount] & BIT(3)) /* 4bit sign number to 8 bit sign number */ pwrInfo24G->CCK_Diff[rfPath][TxCount] |= 0xF0; } @@ -2141,9 +2141,9 @@ void Hal_ReadTxPowerInfo88E(struct adapter *padapter, u8 *PROMContent, bool Auto /* 2010/10/19 MH Add Regulator recognize for CU. */ if (!AutoLoadFail) { - pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x7); /* bit0~2 */ + pHalData->EEPROMRegulatory = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x7); /* bit0~2 */ if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) - pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION&0x7); /* bit0~2 */ + pHalData->EEPROMRegulatory = (EEPROM_DEFAULT_BOARD_OPTION & 0x7); /* bit0~2 */ } else { pHalData->EEPROMRegulatory = 0; } @@ -2169,7 +2169,7 @@ void Hal_EfuseParseBoardType88E(struct adapter *pAdapter, u8 *hwinfo, bool AutoL struct hal_data_8188e *pHalData = GET_HAL_DATA(pAdapter); if (!AutoLoadFail) - pHalData->BoardType = ((hwinfo[EEPROM_RF_BOARD_OPTION_88E]&0xE0)>>5); + pHalData->BoardType = ((hwinfo[EEPROM_RF_BOARD_OPTION_88E] & 0xE0) >> 5); else pHalData->BoardType = 0; DBG_88E("Board Type: 0x%2x\n", pHalData->BoardType); @@ -2220,9 +2220,9 @@ void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool if (!AutoLoadFail) { /* Antenna Diversity setting. */ if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ - pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E]&0x18)>>3; + pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x18) >> 3; if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) - pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION&0x18)>>3;; + pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION & 0x18) >> 3;; } else { pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index a26a5816a45f..7d412b10e6c3 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -78,8 +78,8 @@ void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14) /* Readback the current bb cck swing value and compare with the table to */ /* get the current swing index */ for (i = 0; i < CCK_TABLE_SIZE; i++) { - if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch1_Ch13[i][0]) && - (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch1_Ch13[i][1])) { + if (((CurrCCKSwingVal & 0xff) == (u32)CCKSwingTable_Ch1_Ch13[i][0]) && + (((CurrCCKSwingVal & 0xff00) >> 8) == (u32)CCKSwingTable_Ch1_Ch13[i][1])) { CCKSwingIndex = i; break; } @@ -87,23 +87,23 @@ void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14) /* Write 0xa22 0xa23 */ TempVal = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][0] + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][1]<<8); + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][1] << 8); /* Write 0xa24 ~ 0xa27 */ TempVal2 = 0; TempVal2 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][2] + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][3]<<8) + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][4]<<16)+ - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][5]<<24); + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][3] << 8) + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][4] << 16) + + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][5] << 24); /* Write 0xa28 0xa29 */ TempVal3 = 0; TempVal3 = CCKSwingTable_Ch1_Ch13[CCKSwingIndex][6] + - (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][7]<<8); + (CCKSwingTable_Ch1_Ch13[CCKSwingIndex][7] << 8); } else { for (i = 0; i < CCK_TABLE_SIZE; i++) { - if (((CurrCCKSwingVal&0xff) == (u32)CCKSwingTable_Ch14[i][0]) && - (((CurrCCKSwingVal&0xff00)>>8) == (u32)CCKSwingTable_Ch14[i][1])) { + if (((CurrCCKSwingVal & 0xff) == (u32)CCKSwingTable_Ch14[i][0]) && + (((CurrCCKSwingVal & 0xff00) >> 8) == (u32)CCKSwingTable_Ch14[i][1])) { CCKSwingIndex = i; break; } @@ -111,19 +111,19 @@ void Hal_MPT_CCKTxPowerAdjust(struct adapter *Adapter, bool bInCH14) /* Write 0xa22 0xa23 */ TempVal = CCKSwingTable_Ch14[CCKSwingIndex][0] + - (CCKSwingTable_Ch14[CCKSwingIndex][1]<<8); + (CCKSwingTable_Ch14[CCKSwingIndex][1] << 8); /* Write 0xa24 ~ 0xa27 */ TempVal2 = 0; TempVal2 = CCKSwingTable_Ch14[CCKSwingIndex][2] + - (CCKSwingTable_Ch14[CCKSwingIndex][3]<<8) + - (CCKSwingTable_Ch14[CCKSwingIndex][4]<<16)+ - (CCKSwingTable_Ch14[CCKSwingIndex][5]<<24); + (CCKSwingTable_Ch14[CCKSwingIndex][3] << 8) + + (CCKSwingTable_Ch14[CCKSwingIndex][4] << 16) + + (CCKSwingTable_Ch14[CCKSwingIndex][5] << 24); /* Write 0xa28 0xa29 */ TempVal3 = 0; TempVal3 = CCKSwingTable_Ch14[CCKSwingIndex][6] + - (CCKSwingTable_Ch14[CCKSwingIndex][7]<<8); + (CCKSwingTable_Ch14[CCKSwingIndex][7] << 8); } write_bbreg(Adapter, rCCK0_TxFilter1, bMaskHWord, TempVal); @@ -247,12 +247,12 @@ void Hal_SetCCKTxPower(struct adapter *pAdapter, u8 *TxPower) /* rf-A cck tx power */ write_bbreg(pAdapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, TxPower[RF_PATH_A]); - tmpval = (TxPower[RF_PATH_A]<<16) | (TxPower[RF_PATH_A]<<8) | TxPower[RF_PATH_A]; + tmpval = (TxPower[RF_PATH_A] << 16) | (TxPower[RF_PATH_A] << 8) | TxPower[RF_PATH_A]; write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); /* rf-B cck tx power */ write_bbreg(pAdapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, TxPower[RF_PATH_B]); - tmpval = (TxPower[RF_PATH_B]<<16) | (TxPower[RF_PATH_B]<<8) | TxPower[RF_PATH_B]; + tmpval = (TxPower[RF_PATH_B] << 16) | (TxPower[RF_PATH_B] << 8) | TxPower[RF_PATH_B]; write_bbreg(pAdapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); } @@ -263,7 +263,7 @@ void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 *TxPower) /* HT Tx-rf(A) */ tmpval = TxPower[RF_PATH_A]; - TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; + TxAGC = (tmpval << 24) | (tmpval << 16) | (tmpval << 8) | tmpval; write_bbreg(pAdapter, rTxAGC_A_Rate18_06, bMaskDWord, TxAGC); write_bbreg(pAdapter, rTxAGC_A_Rate54_24, bMaskDWord, TxAGC); @@ -274,7 +274,7 @@ void Hal_SetOFDMTxPower(struct adapter *pAdapter, u8 *TxPower) /* HT Tx-rf(B) */ tmpval = TxPower[RF_PATH_B]; - TxAGC = (tmpval<<24) | (tmpval<<16) | (tmpval<<8) | tmpval; + TxAGC = (tmpval << 24) | (tmpval << 16) | (tmpval << 8) | tmpval; write_bbreg(pAdapter, rTxAGC_B_Rate18_06, bMaskDWord, TxAGC); write_bbreg(pAdapter, rTxAGC_B_Rate54_24, bMaskDWord, TxAGC); @@ -312,7 +312,7 @@ void Hal_SetAntennaPathPower(struct adapter *pAdapter) case RF_6052: Hal_SetCCKTxPower(pAdapter, TxPowerLevel); if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ - Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); + Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath] % 2 == 0); Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); break; default: @@ -351,7 +351,7 @@ void Hal_SetTxPower(struct adapter *pAdapter) case RF_6052: Hal_SetCCKTxPower(pAdapter, TxPowerLevel); if (pAdapter->mppriv.rateidx < MPT_RATE_6M) /* CCK rate */ - Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath]%2 == 0); + Hal_MPT_CCKTxPowerAdjustbyIndex(pAdapter, TxPowerLevel[rfPath] % 2 == 0); Hal_SetOFDMTxPower(pAdapter, TxPowerLevel); break; default: diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c index 9af91ec92d36..30a9dca8f453 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c @@ -47,7 +47,7 @@ static u32 phy_CalculateBitShift(u32 BitMask) u32 i; for (i = 0; i <= 31; i++) { - if (((BitMask>>i) & 0x1) == 1) + if (((BitMask >> i) & 0x1) == 1) break; } return i; @@ -167,9 +167,9 @@ phy_RFSerialRead( else tmplong2 = PHY_QueryBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord); - tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset<<23) | bLSSIReadEdge; /* T65 RF */ + tmplong2 = (tmplong2 & (~bLSSIReadAddress)) | (NewOffset << 23) | bLSSIReadEdge; /* T65 RF */ - PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong&(~bLSSIReadEdge)); + PHY_SetBBReg(Adapter, rFPGA0_XA_HSSIParameter2, bMaskDWord, tmplong & (~bLSSIReadEdge)); udelay(10);/* PlatformStallExecution(10); */ PHY_SetBBReg(Adapter, pPhyReg->rfHSSIPara2, bMaskDWord, tmplong2); @@ -258,7 +258,7 @@ phy_RFSerialWrite( /* */ /* Put write addr in [5:0] and write data in [31:16] */ /* */ - DataAndAddr = ((NewOffset<<20) | (Data&0x000fffff)) & 0x0fffffff; /* T65 RF */ + DataAndAddr = ((NewOffset << 20) | (Data & 0x000fffff)) & 0x0fffffff; /* T65 RF */ /* */ /* Write Operation */ @@ -582,11 +582,11 @@ PHY_BBConfig8188E( /* Enable BB and RF */ RegVal = rtw_read16(Adapter, REG_SYS_FUNC_EN); - rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal|BIT(13)|BIT(0)|BIT(1))); + rtw_write16(Adapter, REG_SYS_FUNC_EN, (u16)(RegVal | BIT(13) | BIT(0) | BIT(1))); /* 20090923 Joseph: Advised by Steven and Jenyu. Power sequence before init RF. */ - rtw_write8(Adapter, REG_RF_CTRL, RF_EN|RF_RSTB|RF_SDMRSTB); + rtw_write8(Adapter, REG_RF_CTRL, RF_EN | RF_RSTB | RF_SDMRSTB); rtw_write8(Adapter, REG_SYS_FUNC_EN, FEN_USBA | FEN_USBD | FEN_BB_GLB_RSTn | FEN_BBRSTB); @@ -787,10 +787,10 @@ static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPower /* 1. CCK */ cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + pHalData->OFDM_24G_Diff[TxCount][RF_PATH_A]; /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]; /* 2. BW40 */ BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; @@ -798,12 +798,12 @@ static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPower /* 1. CCK */ cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_A][index] + pHalData->BW20_24G_Diff[TxCount][index]; /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[TxCount][RF_PATH_A]+ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[TxCount][RF_PATH_A] + pHalData->BW20_24G_Diff[TxCount][index]; /* 2. BW40 */ BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; @@ -811,14 +811,14 @@ static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPower /* 1. CCK */ cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_B][index] + pHalData->BW20_24G_Diff[TxCount][index]; /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_B][index] + pHalData->BW20_24G_Diff[TxCount][index]; /* 2. BW40 */ BW40PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[TxCount][index]; @@ -826,17 +826,17 @@ static void getTxPowerIndex88E(struct adapter *Adapter, u8 channel, u8 *cckPower /* 1. CCK */ cckPowerLevel[TxCount] = pHalData->Index24G_CCK_Base[TxCount][index]; /* 2. OFDM */ - ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ - pHalData->BW20_24G_Diff[RF_PATH_C][index]+ + ofdmPowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_B][index] + + pHalData->BW20_24G_Diff[RF_PATH_C][index] + pHalData->BW20_24G_Diff[TxCount][index]; /* 1. BW20 */ - BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_A][index]+ - pHalData->BW20_24G_Diff[RF_PATH_B][index]+ - pHalData->BW20_24G_Diff[RF_PATH_C][index]+ + BW20PowerLevel[TxCount] = pHalData->Index24G_BW40_Base[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_A][index] + + pHalData->BW20_24G_Diff[RF_PATH_B][index] + + pHalData->BW20_24G_Diff[RF_PATH_C][index] + pHalData->BW20_24G_Diff[TxCount][index]; /* 2. BW40 */ @@ -976,7 +976,7 @@ _PHY_SetBWMode92C( /* 3 */ regBwOpMode = rtw_read8(Adapter, REG_BWOPMODE); - regRRSR_RSC = rtw_read8(Adapter, REG_RRSR+2); + regRRSR_RSC = rtw_read8(Adapter, REG_RRSR + 2); switch (pHalData->CurrentChannelBW) { case HT_CHANNEL_WIDTH_20: @@ -988,8 +988,8 @@ _PHY_SetBWMode92C( regBwOpMode &= ~BW_OPMODE_20MHZ; /* 2007/02/07 Mark by Emily because we have not verify whether this register works */ rtw_write8(Adapter, REG_BWOPMODE, regBwOpMode); - regRRSR_RSC = (regRRSR_RSC&0x90) | (pHalData->nCur40MhzPrimeSC<<5); - rtw_write8(Adapter, REG_RRSR+2, regRRSR_RSC); + regRRSR_RSC = (regRRSR_RSC & 0x90) | (pHalData->nCur40MhzPrimeSC << 5); + rtw_write8(Adapter, REG_RRSR + 2, regRRSR_RSC); break; default: break; @@ -1009,7 +1009,7 @@ _PHY_SetBWMode92C( PHY_SetBBReg(Adapter, rFPGA0_RFMOD, bRFMOD, 0x1); PHY_SetBBReg(Adapter, rFPGA1_RFMOD, bRFMOD, 0x1); /* Set Control channel to upper or lower. These settings are required only for 40MHz */ - PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC>>1)); + PHY_SetBBReg(Adapter, rCCK0_System, bCCKSideBand, (pHalData->nCur40MhzPrimeSC >> 1)); PHY_SetBBReg(Adapter, rOFDM1_LSTF, 0xC00, pHalData->nCur40MhzPrimeSC); PHY_SetBBReg(Adapter, 0x818, (BIT(26) | BIT(27)), (pHalData->nCur40MhzPrimeSC == HAL_PRIME_CHNL_OFFSET_LOWER) ? 2 : 1); -- cgit v1.2.3 From 47a0bab3d95f6897b35eba7279441df4f4d5cc29 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 22:55:11 +0200 Subject: staging: r8188eu: clean up spacing style issues in hal dir, part 3 Clean up spacing style issues reported by checkpatch in the remaining files in the hal directory. CHECK: spaces preferred around that ... Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816205511.20068-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_rf6052.c | 66 +++++------ drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_led.c | 10 +- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 36 +++--- drivers/staging/r8188eu/hal/usb_halinit.c | 162 +++++++++++++------------- drivers/staging/r8188eu/hal/usb_ops_linux.c | 20 ++-- 7 files changed, 149 insertions(+), 149 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c index 60fa7e4f5f2c..ad0782259654 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rf6052.c @@ -147,8 +147,8 @@ rtl8188e_PHY_RF6052SetCckTxPower( if (TurboScanOff) { for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { TxAGC[idx1] = - pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | - (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) | + (pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24); /* 2010/10/18 MH For external PA module. We need to limit power index to be less than 0x20. */ if (TxAGC[idx1] > 0x20 && pHalData->ExternalPA) TxAGC[idx1] = 0x20; @@ -171,16 +171,16 @@ i * Currently, we cannot fully disable driver dynamic } else { for (idx1 = RF_PATH_A; idx1 <= RF_PATH_B; idx1++) { TxAGC[idx1] = - pPowerlevel[idx1] | (pPowerlevel[idx1]<<8) | - (pPowerlevel[idx1]<<16) | (pPowerlevel[idx1]<<24); + pPowerlevel[idx1] | (pPowerlevel[idx1] << 8) | + (pPowerlevel[idx1] << 16) | (pPowerlevel[idx1] << 24); } if (pHalData->EEPROMRegulatory == 0) { tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][6]) + - (pHalData->MCSTxPowerLevelOriginalOffset[0][7]<<8); + (pHalData->MCSTxPowerLevelOriginalOffset[0][7] << 8); TxAGC[RF_PATH_A] += tmpval; tmpval = (pHalData->MCSTxPowerLevelOriginalOffset[0][14]) + - (pHalData->MCSTxPowerLevelOriginalOffset[0][15]<<24); + (pHalData->MCSTxPowerLevelOriginalOffset[0][15] << 24); TxAGC[RF_PATH_B] += tmpval; } } @@ -206,15 +206,15 @@ i * Currently, we cannot fully disable driver dynamic } /* rf-A cck tx power */ - tmpval = TxAGC[RF_PATH_A]&0xff; + tmpval = TxAGC[RF_PATH_A] & 0xff; PHY_SetBBReg(Adapter, rTxAGC_A_CCK1_Mcs32, bMaskByte1, tmpval); - tmpval = TxAGC[RF_PATH_A]>>8; + tmpval = TxAGC[RF_PATH_A] >> 8; PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, 0xffffff00, tmpval); /* rf-B cck tx power */ - tmpval = TxAGC[RF_PATH_B]>>24; + tmpval = TxAGC[RF_PATH_B] >> 24; PHY_SetBBReg(Adapter, rTxAGC_B_CCK11_A_CCK2_11, bMaskByte0, tmpval); - tmpval = TxAGC[RF_PATH_B]&0x00ffffff; + tmpval = TxAGC[RF_PATH_B] & 0x00ffffff; PHY_SetBBReg(Adapter, rTxAGC_B_CCK1_55_Mcs32, 0xffffff00, tmpval); } /* PHY_RF6052SetCckTxPower */ @@ -232,8 +232,8 @@ static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM, for (i = 0; i < 2; i++) { powerBase0 = pPowerLevelOFDM[i]; - powerBase0 = (powerBase0<<24) | (powerBase0<<16) | (powerBase0<<8) | powerBase0; - *(OfdmBase+i) = powerBase0; + powerBase0 = (powerBase0 << 24) | (powerBase0 << 16) | (powerBase0 << 8) | powerBase0; + *(OfdmBase + i) = powerBase0; } for (i = 0; i < pHalData->NumTotalRFPath; i++) { /* Check HT20 to HT40 diff */ @@ -242,8 +242,8 @@ static void getpowerbase88e(struct adapter *Adapter, u8 *pPowerLevelOFDM, else powerlevel[i] = pPowerLevelBW40[i]; powerBase1 = powerlevel[i]; - powerBase1 = (powerBase1<<24) | (powerBase1<<16) | (powerBase1<<8) | powerBase1; - *(MCSBase+i) = powerBase1; + powerBase1 = (powerBase1 << 24) | (powerBase1 << 16) | (powerBase1 << 8) | powerBase1; + *(MCSBase + i) = powerBase1; } } static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, @@ -264,7 +264,7 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, case 0: /* Realtek better performance */ /* increase power diff defined by Realtek for large power */ chnlGroup = 0; - writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); break; case 1: /* Realtek regulatory */ @@ -285,7 +285,7 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, else if (Channel == 14) /* Channel 14 */ chnlGroup = 5; } - writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); break; case 2: /* Better regulatory */ @@ -297,14 +297,14 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, chnlGroup = 0; if (index < 2) - pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel-1]; + pwr_diff = pHalData->TxPwrLegacyHtDiff[rf][Channel - 1]; else if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_20) - pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel-1]; + pwr_diff = pHalData->TxPwrHt20Diff[rf][Channel - 1]; if (pHalData->CurrentChannelBW == HT_CHANNEL_WIDTH_40) - customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel-1]; + customer_pwr_limit = pHalData->PwrGroupHT40[rf][Channel - 1]; else - customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel-1]; + customer_pwr_limit = pHalData->PwrGroupHT20[rf][Channel - 1]; if (pwr_diff >= customer_pwr_limit) pwr_diff = 0; @@ -312,18 +312,18 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, pwr_diff = customer_pwr_limit - pwr_diff; for (i = 0; i < 4; i++) { - pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)]&(0x7f<<(i*8)))>>(i*8)); + pwr_diff_limit[i] = (u8)((pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] & (0x7f << (i * 8))) >> (i * 8)); if (pwr_diff_limit[i] > pwr_diff) pwr_diff_limit[i] = pwr_diff; } - customer_limit = (pwr_diff_limit[3]<<24) | (pwr_diff_limit[2]<<16) | - (pwr_diff_limit[1]<<8) | (pwr_diff_limit[0]); + customer_limit = (pwr_diff_limit[3] << 24) | (pwr_diff_limit[2] << 16) | + (pwr_diff_limit[1] << 8) | (pwr_diff_limit[0]); writeVal = customer_limit + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); break; default: chnlGroup = 0; - writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index+(rf ? 8 : 0)] + + writeVal = pHalData->MCSTxPowerLevelOriginalOffset[chnlGroup][index + (rf ? 8 : 0)] + ((index < 2) ? powerBase0[rf] : powerBase1[rf]); break; } @@ -340,7 +340,7 @@ static void get_rx_power_val_by_reg(struct adapter *Adapter, u8 Channel, /* This mechanism is only applied when Driver-Highpower-Mechanism is OFF. */ if (pdmpriv->DynamicTxHighPowerLvl == TxHighPwrLevel_BT1) writeVal = writeVal - 0x06060606; - *(pOutWriteVal+rf) = writeVal; + *(pOutWriteVal + rf) = writeVal; } } static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue) @@ -361,11 +361,11 @@ static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue) for (rf = 0; rf < 2; rf++) { writeVal = pValue[rf]; for (i = 0; i < 4; i++) { - pwr_val[i] = (u8)((writeVal & (0x7f<<(i*8)))>>(i*8)); + pwr_val[i] = (u8)((writeVal & (0x7f << (i * 8))) >> (i * 8)); if (pwr_val[i] > RF6052_MAX_TX_PWR) pwr_val[i] = RF6052_MAX_TX_PWR; } - writeVal = (pwr_val[3]<<24) | (pwr_val[2]<<16) | (pwr_val[1]<<8) | pwr_val[0]; + writeVal = (pwr_val[3] << 24) | (pwr_val[2] << 16) | (pwr_val[1] << 8) | pwr_val[0]; if (rf == 0) regoffset = regoffset_a[index]; @@ -386,10 +386,10 @@ static void writeOFDMPowerReg88E(struct adapter *Adapter, u8 index, u32 *pValue) regoffset = 0xc98; for (i = 0; i < 3; i++) { if (i != 2) - writeVal = (writeVal > 8) ? (writeVal-8) : 0; + writeVal = (writeVal > 8) ? (writeVal - 8) : 0; else - writeVal = (writeVal > 6) ? (writeVal-6) : 0; - rtw_write8(Adapter, (u32)(regoffset+i), (u8)writeVal); + writeVal = (writeVal > 6) ? (writeVal - 6) : 0; + rtw_write8(Adapter, (u32)(regoffset + i), (u8)writeVal); } } } @@ -475,11 +475,11 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) break; case RF_PATH_B: case RF_PATH_D: - u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16); + u4RegValue = PHY_QueryBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16); break; } /*----Set RF_ENV enable----*/ - PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV<<16, 0x1); + PHY_SetBBReg(Adapter, pPhyReg->rfintfe, bRFSI_RFENV << 16, 0x1); udelay(1);/* PlatformStallExecution(1); */ /*----Set RF_ENV output high----*/ @@ -516,7 +516,7 @@ static int phy_RF6052_Config_ParaFile(struct adapter *Adapter) break; case RF_PATH_B: case RF_PATH_D: - PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV<<16, u4RegValue); + PHY_SetBBReg(Adapter, pPhyReg->rfintfs, bRFSI_RFENV << 16, u4RegValue); break; } if (rtStatus != _SUCCESS) diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c index 8a668e96b764..b4b3c02cb13c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -177,7 +177,7 @@ void update_recvframe_phyinfo_88e(struct recv_frame *precvframe, struct phy_stat rtl8188e_process_phy_info(padapter, precvframe); } } else if (pkt_info.bPacketToSelf || pkt_info.bPacketBeacon) { - if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) { + if (check_fwstate(&padapter->mlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) { if (psta) precvframe->psta = psta; } diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_led.c b/drivers/staging/r8188eu/hal/rtl8188eu_led.c index 75ec97107add..452d4bb87aba 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_led.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_led.c @@ -20,10 +20,10 @@ void SwLedOn(struct adapter *padapter, struct LED_871x *pLed) LedCfg = rtw_read8(padapter, REG_LEDCFG2); switch (pLed->LedPin) { case LED_PIN_LED0: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0xf0)|BIT(5)|BIT(6)); /* SW control led0 on. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg & 0xf0) | BIT(5) | BIT(6)); /* SW control led0 on. */ break; case LED_PIN_LED1: - rtw_write8(padapter, REG_LEDCFG2, (LedCfg&0x0f)|BIT(5)); /* SW control led1 on. */ + rtw_write8(padapter, REG_LEDCFG2, (LedCfg & 0x0f) | BIT(5)); /* SW control led1 on. */ break; default: break; @@ -48,17 +48,17 @@ void SwLedOff(struct adapter *padapter, struct LED_871x *pLed) if (pHalData->bLedOpenDrain) { /* Open-drain arrangement for controlling the LED) */ LedCfg &= 0x90; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT(3))); + rtw_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3))); LedCfg = rtw_read8(padapter, REG_MAC_PINMUX_CFG); LedCfg &= 0xFE; rtw_write8(padapter, REG_MAC_PINMUX_CFG, LedCfg); } else { - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT(3)|BIT(5)|BIT(6))); + rtw_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3) | BIT(5) | BIT(6))); } break; case LED_PIN_LED1: LedCfg &= 0x0f; /* Set to software control. */ - rtw_write8(padapter, REG_LEDCFG2, (LedCfg|BIT(3))); + rtw_write8(padapter, REG_LEDCFG2, (LedCfg | BIT(3))); break; default: break; diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 3a169392d183..a44c9598186c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -82,7 +82,7 @@ int rtl8188eu_init_recv_priv(struct adapter *padapter) if (pskb) { pskb->dev = padapter->pnetdev; tmpaddr = (size_t)pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); skb_reserve(pskb, (RECVBUFF_ALIGN_SZ - alignment)); skb_queue_tail(&precvpriv->free_recv_skb_queue, pskb); diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index a38e10b16233..8c9a651d4f44 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -61,12 +61,12 @@ void rtl8188e_fill_fake_txdesc(struct adapter *adapt, u8 *desc, u32 BufferLen, u /* offset 0 */ ptxdesc->txdw0 |= cpu_to_le32(OWN | FSG | LSG); /* own, bFirstSeg, bLastSeg; */ - ptxdesc->txdw0 |= cpu_to_le32(((TXDESC_SIZE+OFFSET_SZ)<txdw0 |= cpu_to_le32(((TXDESC_SIZE + OFFSET_SZ) << OFFSET_SHT) & 0x00ff0000); /* 32 bytes for TX Desc */ - ptxdesc->txdw0 |= cpu_to_le32(BufferLen&0x0000ffff); /* Buffer size + command header */ + ptxdesc->txdw0 |= cpu_to_le32(BufferLen & 0x0000ffff); /* Buffer size + command header */ /* offset 4 */ - ptxdesc->txdw1 |= cpu_to_le32((QSLT_MGNT<txdw1 |= cpu_to_le32((QSLT_MGNT << QSEL_SHT) & 0x00001f00); /* Fixed queue of Mgnt queue */ /* Set NAVUSEHDR to prevent Ps-poll AId filed to be changed to error vlaue by Hw. */ if (ispspoll) { @@ -94,16 +94,16 @@ static void fill_txdesc_sectype(struct pkt_attrib *pattrib, struct tx_desc *ptxd /* SEC_TYPE : 0:NO_ENC,1:WEP40/TKIP,2:WAPI,3:AES */ case _WEP40_: case _WEP104_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c00000); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _TKIP_: case _TKIP_WTMIC_: - ptxdesc->txdw1 |= cpu_to_le32((0x01<txdw1 |= cpu_to_le32((0x01 << SEC_TYPE_SHT) & 0x00c00000); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _AES_: - ptxdesc->txdw1 |= cpu_to_le32((0x03<txdw1 |= cpu_to_le32((0x03 << SEC_TYPE_SHT) & 0x00c00000); ptxdesc->txdw2 |= cpu_to_le32(0x7 << AMPDU_DENSITY_SHT); break; case _NO_PRIVACY_: @@ -130,7 +130,7 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) *pdw |= cpu_to_le32(HW_RTS_EN); /* Set RTS BW */ if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; + *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(27)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) *pdw |= cpu_to_le32((0x01 << 28) & 0x30000000); @@ -147,7 +147,7 @@ static void fill_txdesc_vcs(struct pkt_attrib *pattrib, __le32 *pdw) static void fill_txdesc_phy(struct pkt_attrib *pattrib, __le32 *pdw) { if (pattrib->ht_en) { - *pdw |= (pattrib->bwmode&HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; + *pdw |= (pattrib->bwmode & HT_CHANNEL_WIDTH_40) ? cpu_to_le32(BIT(25)) : 0; if (pattrib->ch_offset == HAL_PRIME_CHNL_OFFSET_LOWER) *pdw |= cpu_to_le32((0x01 << DATA_SC_SHT) & 0x003f0000); @@ -175,7 +175,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag if (adapt->registrypriv.mp_mode == 0) { if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { - ptxdesc = (struct tx_desc *)(pmem+PACKET_OFFSET_SZ); + ptxdesc = (struct tx_desc *)(pmem + PACKET_OFFSET_SZ); pull = 1; } } @@ -267,11 +267,11 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw4 |= cpu_to_le32(BIT(24));/* DATA_SHORT */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); } - } else if ((pxmitframe->frame_tag&0x0f) == MGNT_FRAMETAG) { + } else if ((pxmitframe->frame_tag & 0x0f) == MGNT_FRAMETAG) { /* offset 4 */ ptxdesc->txdw1 |= cpu_to_le32(pattrib->mac_id & 0x3f); - qsel = (uint)(pattrib->qsel&0x0000001f); + qsel = (uint)(pattrib->qsel & 0x0000001f); ptxdesc->txdw1 |= cpu_to_le32((qsel << QSEL_SHT) & 0x00001f00); ptxdesc->txdw1 |= cpu_to_le32((pattrib->raid << RATE_ID_SHT) & 0x000f0000); @@ -282,7 +282,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw2 |= cpu_to_le32(BIT(19)); /* offset 12 */ - ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0FFF0000); /* offset 20 */ ptxdesc->txdw5 |= cpu_to_le32(RTY_LMT_EN);/* retry limit enable */ @@ -292,9 +292,9 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw5 |= cpu_to_le32(0x00300000);/* retry limit = 12 */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); - } else if ((pxmitframe->frame_tag&0x0f) == TXAGG_FRAMETAG) { + } else if ((pxmitframe->frame_tag & 0x0f) == TXAGG_FRAMETAG) { DBG_88E("pxmitframe->frame_tag == TXAGG_FRAMETAG\n"); - } else if (((pxmitframe->frame_tag&0x0f) == MP_FRAMETAG) && + } else if (((pxmitframe->frame_tag & 0x0f) == MP_FRAMETAG) && (adapt->registrypriv.mp_mode == 1)) { fill_txdesc_for_mp(adapt, ptxdesc); } else { @@ -308,7 +308,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag /* offset 8 */ /* offset 12 */ - ptxdesc->txdw3 |= cpu_to_le32((pattrib->seqnum<txdw3 |= cpu_to_le32((pattrib->seqnum << SEQ_SHT) & 0x0fff0000); /* offset 20 */ ptxdesc->txdw5 |= cpu_to_le32(MRateToHwRate(pmlmeext->tx_rate)); @@ -470,7 +470,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp /* 3 2. aggregate same priority and same DA(AP or STA) frames */ pfirstframe = pxmitframe; - len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset*PACKET_OFFSET_SZ); + len = xmitframe_need_length(pfirstframe) + TXDESC_SIZE + (pfirstframe->pkt_offset * PACKET_OFFSET_SZ); pbuf_tail = len; pbuf = _RND8(pbuf_tail); @@ -521,7 +521,7 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *adapt, struct xmit_priv *pxmitp pxmitframe->agg_num = 0; /* not first frame of aggregation */ pxmitframe->pkt_offset = 0; /* not first frame of aggregation, no need to reserve offset */ - len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset*PACKET_OFFSET_SZ); + len = xmitframe_need_length(pxmitframe) + TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); if (_RND8(pbuf + len) > MAX_XMITBUF_SZ) { pxmitframe->agg_num = 1; @@ -626,7 +626,7 @@ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) goto enqueue; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING) == true) goto enqueue; pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 8948c429afd7..2e0af691310a 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -188,14 +188,14 @@ static void _InitTxBufferBoundary(struct adapter *Adapter, u8 txpktbuf_bndy) rtw_write8(Adapter, REG_TXPKTBUF_MGQ_BDNY, txpktbuf_bndy); rtw_write8(Adapter, REG_TXPKTBUF_WMAC_LBK_BF_HD, txpktbuf_bndy); rtw_write8(Adapter, REG_TRXFF_BNDY, txpktbuf_bndy); - rtw_write8(Adapter, REG_TDECTRL+1, txpktbuf_bndy); + rtw_write8(Adapter, REG_TDECTRL + 1, txpktbuf_bndy); } static void _InitPageBoundary(struct adapter *Adapter) { /* RX Page Boundary */ /* */ - u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E-1; + u16 rxff_bndy = MAX_RX_DMA_BUFFER_SIZE_88E - 1; rtw_write16(Adapter, (REG_TRXFF_BNDY + 2), rxff_bndy); } @@ -529,7 +529,7 @@ usb_AggSettingRxUpdate( switch (haldata->UsbRxAggMode) { case USB_RX_AGG_DMA: rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, haldata->UsbRxAggPageTimeout); + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH + 1, haldata->UsbRxAggPageTimeout); break; case USB_RX_AGG_USB: rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); @@ -537,7 +537,7 @@ usb_AggSettingRxUpdate( break; case USB_RX_AGG_MIX: rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH, haldata->UsbRxAggPageCount); - rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH+1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ + rtw_write8(Adapter, REG_RXDMA_AGG_PG_TH + 1, (haldata->UsbRxAggPageTimeout & 0x1F));/* 0x280[12:8] */ rtw_write8(Adapter, REG_USB_AGG_TH, haldata->UsbRxAggBlockCount); rtw_write8(Adapter, REG_USB_AGG_TO, haldata->UsbRxAggBlockTimeout); break; @@ -603,9 +603,9 @@ static void _InitBeaconParameters(struct adapter *Adapter) haldata->RegBcnCtrlVal = rtw_read8(Adapter, REG_BCN_CTRL); haldata->RegTxPause = rtw_read8(Adapter, REG_TXPAUSE); - haldata->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL+2); - haldata->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT+2); - haldata->RegCR_1 = rtw_read8(Adapter, REG_CR+1); + haldata->RegFwHwTxQCtrl = rtw_read8(Adapter, REG_FWHW_TXQ_CTRL + 2); + haldata->RegReg542 = rtw_read8(Adapter, REG_TBTT_PROHIBIT + 2); + haldata->RegCR_1 = rtw_read8(Adapter, REG_CR + 1); } static void _BeaconFunctionEnable(struct adapter *Adapter, @@ -613,7 +613,7 @@ static void _BeaconFunctionEnable(struct adapter *Adapter, { rtw_write8(Adapter, REG_BCN_CTRL, (BIT(4) | BIT(3) | BIT(1))); - rtw_write8(Adapter, REG_RD_CTRL+1, 0x6F); + rtw_write8(Adapter, REG_RD_CTRL + 1, 0x6F); } /* Set CCK and OFDM Block "ON" */ @@ -636,7 +636,7 @@ static void _InitAntenna_Selection(struct adapter *Adapter) return; DBG_88E("==> %s ....\n", __func__); - rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0)|BIT(23)); + rtw_write32(Adapter, REG_LEDCFG0, rtw_read32(Adapter, REG_LEDCFG0) | BIT(23)); PHY_SetBBReg(Adapter, rFPGA0_XAB_RFParameter, BIT(13), 0x01); if (PHY_QueryBBReg(Adapter, rFPGA0_XA_RFInterfaceOE, 0x300) == Antenna_A) @@ -671,7 +671,7 @@ enum rt_rf_power_state RfOnOffDetect(struct adapter *adapt) DBG_88E("pwrdown, 0x5c(BIT(7))=%02x\n", val8); rfpowerstate = (val8 & BIT(7)) ? rf_off : rf_on; } else { /* rf on/off */ - rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG)&~(BIT(3))); + rtw_write8(adapt, REG_MAC_PINMUX_CFG, rtw_read8(adapt, REG_MAC_PINMUX_CFG) & ~(BIT(3))); val8 = rtw_read8(adapt, REG_GPIO_IO_SEL); DBG_88E("GPIO_IN=%02x\n", val8); rfpowerstate = (val8 & BIT(3)) ? rf_on : rf_off; @@ -836,9 +836,9 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) /* Enable TX Report */ /* Enable Tx Report Timer */ value8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); - rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8|BIT(1)|BIT(0))); + rtw_write8(Adapter, REG_TX_RPT_CTRL, (value8 | BIT(1) | BIT(0))); /* Set MAX RPT MACID */ - rtw_write8(Adapter, REG_TX_RPT_CTRL+1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ + rtw_write8(Adapter, REG_TX_RPT_CTRL + 1, 2);/* FOR sta mode ,0: bc/mc ,1:AP */ /* Tx RPT Timer. Unit: 32us */ rtw_write16(Adapter, REG_TX_RPT_TIME, 0xCdf0); @@ -901,10 +901,10 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) pwrctrlpriv->rf_pwrstate = rf_on; /* enable Tx report. */ - rtw_write8(Adapter, REG_FWHW_TXQ_CTRL+1, 0x0F); + rtw_write8(Adapter, REG_FWHW_TXQ_CTRL + 1, 0x0F); /* Suggested by SD1 pisa. Added by tynli. 2011.10.21. */ - rtw_write8(Adapter, REG_EARLY_MODE_CONTROL+3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ + rtw_write8(Adapter, REG_EARLY_MODE_CONTROL + 3, 0x01);/* Pretx_en, for WEP/TKIP SEC */ /* tynli_test_tx_report. */ rtw_write16(Adapter, REG_TX_RPT_TIME, 0x3DF0); @@ -936,7 +936,7 @@ static u32 rtl8188eu_hal_init(struct adapter *Adapter) rtw_write8(Adapter, REG_USB_HRPWM, 0); /* ack for xmit mgmt frames. */ - rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL)|BIT(12)); + rtw_write32(Adapter, REG_FWHW_TXQ_CTRL, rtw_read32(Adapter, REG_FWHW_TXQ_CTRL) | BIT(12)); exit: HAL_INIT_PROFILE_TAG(HAL_INIT_STAGES_END); @@ -965,7 +965,7 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) /* Stop Tx Report Timer. 0x4EC[Bit1]=b'0 */ val8 = rtw_read8(Adapter, REG_TX_RPT_CTRL); - rtw_write8(Adapter, REG_TX_RPT_CTRL, val8&(~BIT(1))); + rtw_write8(Adapter, REG_TX_RPT_CTRL, val8 & (~BIT(1))); /* stop rx */ rtw_write8(Adapter, REG_CR, 0x0); @@ -978,9 +978,9 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) val8 = rtw_read8(Adapter, REG_MCUFWDL); if ((val8 & RAM_DL_SEL) && Adapter->bFWReady) { /* 8051 RAM code */ /* Reset MCU 0x2[10]=0. */ - val8 = rtw_read8(Adapter, REG_SYS_FUNC_EN+1); + val8 = rtw_read8(Adapter, REG_SYS_FUNC_EN + 1); val8 &= ~BIT(2); /* 0x2[10], FEN_CPUEN */ - rtw_write8(Adapter, REG_SYS_FUNC_EN+1, val8); + rtw_write8(Adapter, REG_SYS_FUNC_EN + 1, val8); } /* reset MCU ready status */ @@ -989,16 +989,16 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) /* YJ,add,111212 */ /* Disable 32k */ val8 = rtw_read8(Adapter, REG_32K_CTRL); - rtw_write8(Adapter, REG_32K_CTRL, val8&(~BIT(0))); + rtw_write8(Adapter, REG_32K_CTRL, val8 & (~BIT(0))); /* Card disable power action flow */ HalPwrSeqCmdParsing(Adapter, PWR_CUT_ALL_MSK, PWR_FAB_ALL_MSK, PWR_INTF_USB_MSK, Rtl8188E_NIC_DISABLE_FLOW); /* Reset MCU IO Wrapper */ - val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); - rtw_write8(Adapter, REG_RSV_CTRL+1, (val8&(~BIT(3)))); - val8 = rtw_read8(Adapter, REG_RSV_CTRL+1); - rtw_write8(Adapter, REG_RSV_CTRL+1, val8|BIT(3)); + val8 = rtw_read8(Adapter, REG_RSV_CTRL + 1); + rtw_write8(Adapter, REG_RSV_CTRL + 1, (val8 & (~BIT(3)))); + val8 = rtw_read8(Adapter, REG_RSV_CTRL + 1); + rtw_write8(Adapter, REG_RSV_CTRL + 1, val8 | BIT(3)); /* YJ,test add, 111207. For Power Consumption. */ val8 = rtw_read8(Adapter, GPIO_IN); @@ -1006,9 +1006,9 @@ static void CardDisableRTL8188EU(struct adapter *Adapter) rtw_write8(Adapter, GPIO_IO_SEL, 0xFF);/* Reg0x46 */ val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL); - rtw_write8(Adapter, REG_GPIO_IO_SEL, (val8<<4)); - val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL+1); - rtw_write8(Adapter, REG_GPIO_IO_SEL+1, val8|0x0F);/* Reg0x43 */ + rtw_write8(Adapter, REG_GPIO_IO_SEL, (val8 << 4)); + val8 = rtw_read8(Adapter, REG_GPIO_IO_SEL + 1); + rtw_write8(Adapter, REG_GPIO_IO_SEL + 1, val8 | 0x0F);/* Reg0x43 */ rtw_write32(Adapter, REG_BB_PAD_CTRL, 0x00080808);/* set LNA ,TRSW,EX_PA Pin to output mode */ haldata->bMacPwrCtrlOn = false; Adapter->bFWReady = false; @@ -1235,11 +1235,11 @@ static void ResumeTxBeacon(struct adapter *adapt) /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) | BIT(6)); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl) | BIT(6)); haldata->RegFwHwTxQCtrl |= BIT(6); - rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0xff); + rtw_write8(adapt, REG_TBTT_PROHIBIT + 1, 0xff); haldata->RegReg542 |= BIT(0); - rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); + rtw_write8(adapt, REG_TBTT_PROHIBIT + 2, haldata->RegReg542); } static void StopTxBeacon(struct adapter *adapt) @@ -1249,11 +1249,11 @@ static void StopTxBeacon(struct adapter *adapt) /* 2010.03.01. Marked by tynli. No need to call workitem beacause we record the value */ /* which should be read from register to a global variable. */ - rtw_write8(adapt, REG_FWHW_TXQ_CTRL+2, (haldata->RegFwHwTxQCtrl) & (~BIT(6))); + rtw_write8(adapt, REG_FWHW_TXQ_CTRL + 2, (haldata->RegFwHwTxQCtrl) & (~BIT(6))); haldata->RegFwHwTxQCtrl &= (~BIT(6)); - rtw_write8(adapt, REG_TBTT_PROHIBIT+1, 0x64); + rtw_write8(adapt, REG_TBTT_PROHIBIT + 1, 0x64); haldata->RegReg542 &= ~(BIT(0)); - rtw_write8(adapt, REG_TBTT_PROHIBIT+2, haldata->RegReg542); + rtw_write8(adapt, REG_TBTT_PROHIBIT + 2, haldata->RegReg542); /* todo: CheckFwRsvdPageContent(Adapter); 2010.06.23. Added by tynli. */ } @@ -1264,10 +1264,10 @@ static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) u8 mode = *((u8 *)val); /* disable Port0 TSF update */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) | BIT(4)); /* set net_type */ - val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 = rtw_read8(Adapter, MSR) & 0x0c; val8 |= mode; rtw_write8(Adapter, MSR, val8); @@ -1308,7 +1308,7 @@ static void hw_var_set_opmode(struct adapter *Adapter, u8 variable, u8 *val) /* enable BCN0 Function for if1 */ /* don't enable update TSF0 for if1 (due to TSF update when beacon/probe rsp are received) */ - rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP|EN_BCN_FUNCTION | BIT(1))); + rtw_write8(Adapter, REG_BCN_CTRL, (DIS_TSF_UDT0_NORMAL_CHIP | EN_BCN_FUNCTION | BIT(1))); /* dis BCN1 ATIM WND if if2 is station */ rtw_write8(Adapter, REG_BCN_CTRL_1, rtw_read8(Adapter, REG_BCN_CTRL_1) | BIT(0)); @@ -1323,7 +1323,7 @@ static void hw_var_set_macaddr(struct adapter *Adapter, u8 variable, u8 *val) reg_macid = REG_MACID; for (idx = 0; idx < 6; idx++) - rtw_write8(Adapter, (reg_macid+idx), val[idx]); + rtw_write8(Adapter, (reg_macid + idx), val[idx]); } static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) @@ -1334,7 +1334,7 @@ static void hw_var_set_bssid(struct adapter *Adapter, u8 variable, u8 *val) reg_bssid = REG_BSSID; for (idx = 0; idx < 6; idx++) - rtw_write8(Adapter, (reg_bssid+idx), val[idx]); + rtw_write8(Adapter, (reg_bssid + idx), val[idx]); } static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) @@ -1346,7 +1346,7 @@ static void hw_var_set_bcn_func(struct adapter *Adapter, u8 variable, u8 *val) if (*((u8 *)val)) rtw_write8(Adapter, bcn_ctrl_reg, (EN_BCN_FUNCTION | EN_TXBCN_RPT)); else - rtw_write8(Adapter, bcn_ctrl_reg, rtw_read8(Adapter, bcn_ctrl_reg)&(~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); + rtw_write8(Adapter, bcn_ctrl_reg, rtw_read8(Adapter, bcn_ctrl_reg) & (~(EN_BCN_FUNCTION | EN_TXBCN_RPT))); } static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) @@ -1360,7 +1360,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) { u8 val8; - val8 = rtw_read8(Adapter, MSR)&0x0c; + val8 = rtw_read8(Adapter, MSR) & 0x0c; val8 |= *((u8 *)val); rtw_write8(Adapter, MSR, val8); } @@ -1406,8 +1406,8 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) BrateCfg |= 0x01; /* default enable 1M ACK rate */ /* Set RRSR rate table. */ rtw_write8(Adapter, REG_RRSR, BrateCfg & 0xff); - rtw_write8(Adapter, REG_RRSR+1, (BrateCfg >> 8) & 0xff); - rtw_write8(Adapter, REG_RRSR+2, rtw_read8(Adapter, REG_RRSR+2)&0xf0); + rtw_write8(Adapter, REG_RRSR + 1, (BrateCfg >> 8) & 0xff); + rtw_write8(Adapter, REG_RRSR + 2, rtw_read8(Adapter, REG_RRSR + 2) & 0xf0); /* Set RTS initial rate */ while (BrateCfg > 0x1) { @@ -1433,25 +1433,25 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) tsf = pmlmeext->TSFValue - do_div(pmlmeext->TSFValue, pmlmeinfo->bcn_interval * 1024) - 1024; /* us */ - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) StopTxBeacon(Adapter); /* disable related TSF function */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(3))); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) & (~BIT(3))); rtw_write32(Adapter, REG_TSFTR, tsf); - rtw_write32(Adapter, REG_TSFTR+4, tsf>>32); + rtw_write32(Adapter, REG_TSFTR + 4, tsf >> 32); /* enable related TSF function */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(3)); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) | BIT(3)); - if (((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE)) + if (((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE) || ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE)) ResumeTxBeacon(Adapter); } break; case HW_VAR_CHECK_BSSID: if (*((u8 *)val)) { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR) | RCR_CBSSID_DATA | RCR_CBSSID_BCN); } else { u32 val32; @@ -1468,10 +1468,10 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); /* reset TSF */ - rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0)|BIT(1))); + rtw_write8(Adapter, REG_DUAL_TSF_RST, (BIT(0) | BIT(1))); /* disable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) | BIT(4)); break; case HW_VAR_MLME_SITESURVEY: if (*((u8 *)val)) { /* under sitesurvey */ @@ -1483,32 +1483,32 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) rtw_write16(Adapter, REG_RXFLTMAP2, 0x00); /* disable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)|BIT(4)); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) | BIT(4)); } else { /* sitesurvey done */ struct mlme_ext_priv *pmlmeext = &Adapter->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; if ((is_client_associated_to_ap(Adapter)) || - ((pmlmeinfo->state&0x03) == WIFI_FW_ADHOC_STATE)) { + ((pmlmeinfo->state & 0x03) == WIFI_FW_ADHOC_STATE)) { /* enable to rx data frame */ rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); - } else if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) & (~BIT(4))); + } else if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { rtw_write16(Adapter, REG_RXFLTMAP2, 0xFFFF); /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) & (~BIT(4))); } - if ((pmlmeinfo->state&0x03) == WIFI_FW_AP_STATE) { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + if ((pmlmeinfo->state & 0x03) == WIFI_FW_AP_STATE) { + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR) | RCR_CBSSID_BCN); } else { if (Adapter->in_cta_test) { u32 v = rtw_read32(Adapter, REG_RCR); v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ rtw_write32(Adapter, REG_RCR, v); } else { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_BCN); + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR) | RCR_CBSSID_BCN); } } } @@ -1528,7 +1528,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) v &= ~(RCR_CBSSID_DATA | RCR_CBSSID_BCN);/* RCR_ADF */ rtw_write32(Adapter, REG_RCR, v); } else { - rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR)|RCR_CBSSID_DATA|RCR_CBSSID_BCN); + rtw_write32(Adapter, REG_RCR, rtw_read32(Adapter, REG_RCR) | RCR_CBSSID_DATA | RCR_CBSSID_BCN); } if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) @@ -1541,9 +1541,9 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) } else if (type == 2) { /* sta add event call back */ /* enable update TSF */ - rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL)&(~BIT(4))); + rtw_write8(Adapter, REG_BCN_CTRL, rtw_read8(Adapter, REG_BCN_CTRL) & (~BIT(4))); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE|WIFI_ADHOC_MASTER_STATE)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE | WIFI_ADHOC_MASTER_STATE)) RetryLimit = 0x7; } rtw_write16(Adapter, REG_RL, RetryLimit << RETRY_LIMIT_SHORT_SHIFT | RetryLimit << RETRY_LIMIT_LONG_SHIFT); @@ -1579,21 +1579,21 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) case HW_VAR_RESP_SIFS: /* RESP_SIFS for CCK */ rtw_write8(Adapter, REG_R2T_SIFS, val[0]); /* SIFS_T2T_CCK (0x08) */ - rtw_write8(Adapter, REG_R2T_SIFS+1, val[1]); /* SIFS_R2T_CCK(0x08) */ + rtw_write8(Adapter, REG_R2T_SIFS + 1, val[1]); /* SIFS_R2T_CCK(0x08) */ /* RESP_SIFS for OFDM */ rtw_write8(Adapter, REG_T2T_SIFS, val[2]); /* SIFS_T2T_OFDM (0x0a) */ - rtw_write8(Adapter, REG_T2T_SIFS+1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ + rtw_write8(Adapter, REG_T2T_SIFS + 1, val[3]); /* SIFS_R2T_OFDM(0x0a) */ break; case HW_VAR_ACK_PREAMBLE: { u8 regTmp; u8 bShortPreamble = *((bool *)val); /* Joseph marked out for Netgear 3500 TKIP channel 7 issue.(Temporarily) */ - regTmp = (haldata->nCur40MhzPrimeSC)<<5; + regTmp = (haldata->nCur40MhzPrimeSC) << 5; if (bShortPreamble) regTmp |= 0x80; - rtw_write8(Adapter, REG_RRSR+2, regTmp); + rtw_write8(Adapter, REG_RRSR + 2, regTmp); } break; case HW_VAR_SEC_CFG: @@ -1630,12 +1630,12 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) for (i = 0; i < CAM_CONTENT_COUNT; i++) { /* filled id in CAM config 2 byte */ if (i == 0) - ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo)<<2); + ulContent |= (ucIndex & 0x03) | ((u16)(ulEncAlgo) << 2); else ulContent = 0; /* polling bit, and No Write enable, and address */ - ulCommand = CAM_CONTENT_COUNT*ucIndex+i; - ulCommand = ulCommand | CAM_POLLINIG|CAM_WRITE; + ulCommand = CAM_CONTENT_COUNT * ucIndex + i; + ulCommand = ulCommand | CAM_POLLINIG | CAM_WRITE; /* write content 0 is equall to mark invalid */ rtw_write32(Adapter, WCAMI, ulContent); /* delay_ms(40); */ rtw_write32(Adapter, RWCAM, ulCommand); /* delay_ms(40); */ @@ -1643,7 +1643,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) } break; case HW_VAR_CAM_INVALID_ALL: - rtw_write32(Adapter, RWCAM, BIT(31)|BIT(30)); + rtw_write32(Adapter, RWCAM, BIT(31) | BIT(30)); break; case HW_VAR_CAM_WRITE: { @@ -1733,18 +1733,18 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) pRegToSet = RegToSet_Normal; /* 0xb972a841; */ FactorToSet = *((u8 *)val); if (FactorToSet <= 3) { - FactorToSet = (1<<(FactorToSet + 2)); + FactorToSet = (1 << (FactorToSet + 2)); if (FactorToSet > 0xf) FactorToSet = 0xf; for (index = 0; index < 4; index++) { - if ((pRegToSet[index] & 0xf0) > (FactorToSet<<4)) - pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet<<4); + if ((pRegToSet[index] & 0xf0) > (FactorToSet << 4)) + pRegToSet[index] = (pRegToSet[index] & 0x0f) | (FactorToSet << 4); if ((pRegToSet[index] & 0x0f) > FactorToSet) pRegToSet[index] = (pRegToSet[index] & 0xf0) | (FactorToSet); - rtw_write8(Adapter, (REG_AGGLEN_LMT+index), pRegToSet[index]); + rtw_write8(Adapter, (REG_AGGLEN_LMT + index), pRegToSet[index]); } } } @@ -1835,9 +1835,9 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) if (!pwrpriv->bkeepfwalive) { /* RX DMA stop */ - rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM)|RW_RELEASE_EN)); + rtw_write32(Adapter, REG_RXPKT_NUM, (rtw_read32(Adapter, REG_RXPKT_NUM) | RW_RELEASE_EN)); do { - if (!(rtw_read32(Adapter, REG_RXPKT_NUM)&RXDMA_IDLE)) + if (!(rtw_read32(Adapter, REG_RXPKT_NUM) & RXDMA_IDLE)) break; } while (trycnt--); if (trycnt == 0) @@ -1859,8 +1859,8 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) case HW_VAR_TX_RPT_MAX_MACID: { u8 maxMacid = *val; - DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n", maxMacid, maxMacid+1); - rtw_write8(Adapter, REG_TX_RPT_CTRL+1, maxMacid+1); + DBG_88E("### MacID(%d),Set Max Tx RPT MID(%d)\n", maxMacid, maxMacid + 1); + rtw_write8(Adapter, REG_TX_RPT_CTRL + 1, maxMacid + 1); } break; case HW_VAR_H2C_MEDIA_STATUS_RPT: @@ -1868,7 +1868,7 @@ static void SetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) break; case HW_VAR_BCN_VALID: /* BCN_VALID, BIT(16) of REG_TDECTRL = BIT(0) of REG_TDECTRL+2, write 1 to clear, Clear by sw */ - rtw_write8(Adapter, REG_TDECTRL+2, rtw_read8(Adapter, REG_TDECTRL+2) | BIT(0)); + rtw_write8(Adapter, REG_TDECTRL + 2, rtw_read8(Adapter, REG_TDECTRL + 2) | BIT(0)); break; default: break; @@ -1890,7 +1890,7 @@ static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) break; case HW_VAR_BCN_VALID: /* BCN_VALID, BIT(16) of REG_TDECTRL = BIT(0) of REG_TDECTRL+2 */ - val[0] = (BIT(0) & rtw_read8(Adapter, REG_TDECTRL+2)) ? true : false; + val[0] = (BIT(0) & rtw_read8(Adapter, REG_TDECTRL + 2)) ? true : false; break; case HW_VAR_DM_FLAG: val[0] = podmpriv->SupportAbility; @@ -1926,7 +1926,7 @@ static void GetHwReg8188EU(struct adapter *Adapter, u8 variable, u8 *val) *val = haldata->bMacPwrCtrlOn; break; case HW_VAR_CHK_HI_QUEUE_EMPTY: - *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION)&0x0000ff00) == 0) ? true : false; + *val = ((rtw_read32(Adapter, REG_HGQ_INFORMATION) & 0x0000ff00) == 0) ? true : false; break; default: break; @@ -2133,7 +2133,7 @@ static void UpdateHalRAMask8188EUsb(struct adapter *adapt, u32 mac_id, u8 rssi_l mask &= rate_bitmap; - init_rate = get_highest_rate_idx(mask)&0x3f; + init_rate = get_highest_rate_idx(mask) & 0x3f; if (haldata->fw_ractrl) { u8 arg; @@ -2193,7 +2193,7 @@ static void SetBeaconRelatedRegisters8188EUsb(struct adapter *adapt) ResumeTxBeacon(adapt); - rtw_write8(adapt, bcn_ctrl_reg, rtw_read8(adapt, bcn_ctrl_reg)|BIT(1)); + rtw_write8(adapt, bcn_ctrl_reg, rtw_read8(adapt, bcn_ctrl_reg) | BIT(1)); } static void rtl8188eu_init_default_value(struct adapter *adapt) diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 8fcfe73cf5b3..b4edbfda9a18 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -114,7 +114,7 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) requesttype = 0x01;/* read_in */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 1; usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); @@ -137,11 +137,11 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 2; usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); - return (u16)(le32_to_cpu(data)&0xffff); + return (u16)(le32_to_cpu(data) & 0xffff); } static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) @@ -157,7 +157,7 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) requesttype = 0x01;/* read_in */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 4; usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); @@ -179,7 +179,7 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); @@ -203,7 +203,7 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 2; data = cpu_to_le32(val & 0x0000ffff); @@ -231,7 +231,7 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = 4; data = cpu_to_le32(val); @@ -258,7 +258,7 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata requesttype = 0x00;/* write_out */ index = 0;/* n/a */ - wvalue = (u16)(addr&0x0000ffff); + wvalue = (u16)(addr & 0x0000ffff); len = length; memcpy(buf, pdata, len); @@ -438,7 +438,7 @@ static int recvbuf2recvframe(struct adapter *adapt, struct sk_buff *pskb) pkt_copy = NULL; if (transfer_len > 0 && pkt_cnt == 0) - pkt_cnt = (le32_to_cpu(prxstat->rxdw2)>>16) & 0xff; + pkt_cnt = (le32_to_cpu(prxstat->rxdw2) >> 16) & 0xff; } while ((transfer_len > 0) && (pkt_cnt > 0)); @@ -573,7 +573,7 @@ static u32 usb_read_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem) } tmpaddr = (size_t)precvbuf->pskb->data; - alignment = tmpaddr & (RECVBUFF_ALIGN_SZ-1); + alignment = tmpaddr & (RECVBUFF_ALIGN_SZ - 1); skb_reserve(precvbuf->pskb, (RECVBUFF_ALIGN_SZ - alignment)); precvbuf->phead = precvbuf->pskb->head; -- cgit v1.2.3 From 10e13123973bcde7c5d1d2a37a38e4c69a973e98 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 16 Aug 2021 23:10:53 +0200 Subject: staging: r8188eu: clean up spacing style issues in os_dep dir Clean up spacing style issues reported by checkpatch in the os_dep directory. CHECK: spaces preferred around that ... CHECK: No space is necessary after a cast WARNING: space prohibited before semicolon WARNING: space prohibited between function name and open parenthesis '(' ERROR: spaces required around that '=' (ctx:VxV) Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210816211053.31728-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 202 ++++++++++++------------- drivers/staging/r8188eu/os_dep/mlme_linux.c | 4 +- drivers/staging/r8188eu/os_dep/os_intfs.c | 8 +- drivers/staging/r8188eu/os_dep/osdep_service.c | 16 +- drivers/staging/r8188eu/os_dep/recv_linux.c | 2 +- drivers/staging/r8188eu/os_dep/rtw_android.c | 2 +- drivers/staging/r8188eu/os_dep/usb_intf.c | 2 +- drivers/staging/r8188eu/os_dep/xmit_linux.c | 8 +- 8 files changed, 122 insertions(+), 122 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index d40aaab48821..8478c0f5f285 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -181,18 +181,18 @@ static char *translate_scan(struct adapter *padapter, start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.Ssid.Ssid); /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength-12); + p = rtw_get_ie(&pnetwork->network.IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pnetwork->network.IELength - 12); if (p && ht_ielen > 0) { struct ieee80211_ht_cap *pht_capie; ht_cap = true; - pht_capie = (struct ieee80211_ht_cap *)(p+2); + pht_capie = (struct ieee80211_ht_cap *)(p + 2); memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & IEEE80211_HT_CAP_SUP_WIDTH_20_40) ? 1 : 0; short_GI = (le16_to_cpu(pht_capie->cap_info) & - (IEEE80211_HT_CAP_SGI_20|IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; + (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; } /* Add the protocol name */ @@ -265,7 +265,7 @@ static char *translate_scan(struct adapter *padapter, p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); while (pnetwork->network.SupportedRates[i] != 0) { - rate = pnetwork->network.SupportedRates[i]&0x7F; + rate = pnetwork->network.SupportedRates[i] & 0x7F; if (rate > max_rate) max_rate = rate; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), @@ -274,14 +274,14 @@ static char *translate_scan(struct adapter *padapter, } if (ht_cap) { - if (mcs_rate&0x8000)/* MCS15 */ + if (mcs_rate & 0x8000)/* MCS15 */ max_rate = (bw_40MHz) ? ((short_GI) ? 300 : 270) : ((short_GI) ? 144 : 130); - else if (mcs_rate&0x0080)/* MCS7 */ + else if (mcs_rate & 0x0080)/* MCS7 */ ; else/* default MCS7 */ max_rate = (bw_40MHz) ? ((short_GI) ? 150 : 135) : ((short_GI) ? 72 : 65); - max_rate = max_rate*2;/* Mbps/2; */ + max_rate = max_rate * 2;/* Mbps/2; */ } iwe.cmd = SIOCGIWRATE; @@ -366,7 +366,7 @@ static char *translate_scan(struct adapter *padapter, iwe.u.data.length = (u16)wps_ielen; start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); } - cnt += ie_ptr[cnt+1]+2; /* goto next */ + cnt += ie_ptr[cnt + 1] + 2; /* goto next */ } } @@ -438,7 +438,7 @@ static int wpa_set_encryption(struct net_device *dev, struct ieee_param *param, param->u.crypt.err = 0; param->u.crypt.alg[IEEE_CRYPT_ALG_NAME_LEN - 1] = '\0'; - if (param_len < (u32) ((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { + if (param_len < (u32)((u8 *)param->u.crypt.key - (u8 *)param) + param->u.crypt.key_len) { ret = -EINVAL; goto exit; } @@ -605,7 +605,7 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie int i; DBG_88E("\n wpa_ie(length:%d):\n", ielen); for (i = 0; i < ielen; i += 8) - DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i+1], buf[i+2], buf[i+3], buf[i+4], buf[i+5], buf[i+6], buf[i+7]); + DBG_88E("0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x 0x%.2x\n", buf[i], buf[i + 1], buf[i + 2], buf[i + 3], buf[i + 4], buf[i + 5], buf[i + 6], buf[i + 7]); } if (ielen < RSN_HEADER_LEN) { @@ -678,10 +678,10 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie while (cnt < ielen) { eid = buf[cnt]; - if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { + if ((eid == _VENDOR_SPECIFIC_IE_) && (!memcmp(&buf[cnt + 2], wps_oui, 4))) { DBG_88E("SET WPS_IE\n"); - padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < (MAX_WPA_IE_LEN<<2)) ? (buf[cnt+1]+2) : (MAX_WPA_IE_LEN<<2); + padapter->securitypriv.wps_ie_len = ((buf[cnt + 1] + 2) < (MAX_WPA_IE_LEN << 2)) ? (buf[cnt + 1] + 2) : (MAX_WPA_IE_LEN << 2); memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); @@ -690,10 +690,10 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie if (rtw_p2p_chk_state(pwdinfo, P2P_STATE_GONEGO_OK)) rtw_p2p_set_state(pwdinfo, P2P_STATE_PROVISIONING_ING); #endif /* CONFIG_88EU_P2P */ - cnt += buf[cnt+1]+2; + cnt += buf[cnt + 1] + 2; break; } else { - cnt += buf[cnt+1]+2; /* goto next */ + cnt += buf[cnt + 1] + 2; /* goto next */ } } } @@ -718,9 +718,9 @@ static int rtw_wx_get_name(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; NDIS_802_11_RATES_EX *prates = NULL; - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE) == true) { /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength-12); + p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength - 12); if (p && ht_ielen > 0) ht_cap = true; @@ -879,7 +879,7 @@ static int rtw_wx_set_pmkid(struct net_device *dev, DBG_88E("[rtw_wx_set_pmkid] BSSID exists in the PMKList.\n"); memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); psecuritypriv->PMKIDList[j].bUsed = true; - psecuritypriv->PMKIDIndex = j+1; + psecuritypriv->PMKIDIndex = j + 1; blInserted = true; break; } @@ -1204,7 +1204,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, goto exit; } - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING)) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) { indicate_wx_scan_complete_event(padapter); goto exit; } @@ -1222,7 +1222,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } #endif /* CONFIG_88EU_P2P */ - memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); + memset(ssid, 0, sizeof(struct ndis_802_11_ssid) * RTW_SSID_SCAN_AMOUNT); if (wrqu->data.length == sizeof(struct iw_scan_req)) { struct iw_scan_req *req = (struct iw_scan_req *)extra; @@ -1247,7 +1247,7 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE && !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; - char *pos = extra+WEXT_CSCAN_HEADER_SIZE; + char *pos = extra + WEXT_CSCAN_HEADER_SIZE; char section; char sec_len; int ssid_index = 0; @@ -1370,7 +1370,7 @@ static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, spin_unlock_bh(&pmlmepriv->scanned_queue.lock); - wrqu->data.length = ev-extra; + wrqu->data.length = ev - extra; wrqu->data.flags = 0; exit: @@ -1515,7 +1515,7 @@ static int rtw_wx_set_rate(struct net_device *dev, ratevalue = 11; goto set_rate; } - target_rate = target_rate/100000; + target_rate = target_rate / 100000; switch (target_rate) { case 10: @@ -2033,7 +2033,7 @@ static int rtw_wx_set_enc_ext(struct net_device *dev, (pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY)) param->u.crypt.set_tx = 0; - param->u.crypt.idx = (pencoding->flags&0x00FF) - 1; + param->u.crypt.idx = (pencoding->flags & 0x00FF) - 1; if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) memcpy(param->u.crypt.seq, pext->rx_seq, 8); @@ -2203,7 +2203,7 @@ static int rtw_wx_set_channel_plan(struct net_device *dev, { struct adapter *padapter = (struct adapter *)rtw_netdev_priv(dev); struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - u8 channel_plan_req = (u8) (*((int *)wrqu)); + u8 channel_plan_req = (u8)(*((int *)wrqu)); if (_SUCCESS == rtw_set_chplan_cmd(padapter, channel_plan_req, 1)) DBG_88E("%s set channel_plan = 0x%02X\n", __func__, pmlmepriv->ChannelPlan); @@ -2444,7 +2444,7 @@ static int rtw_get_ap_info(struct net_device *dev, goto exit; } - while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING)))) { + while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY | _FW_UNDER_LINKING)))) { msleep(30); cnt++; if (cnt > 100) @@ -2479,13 +2479,13 @@ static int rtw_get_ap_info(struct net_device *dev, /* BSSID match, then check if supporting wpa/wpa2 */ DBG_88E("BSSID:%pM\n", (bssid)); - pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12); if (pbuf && (wpa_ielen > 0)) { pdata->flags = 1; break; } - pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength-12); + pbuf = rtw_get_wpa2_ie(&pnetwork->network.IEs[12], &wpa_ielen, pnetwork->network.IELength - 12); if (pbuf && (wpa_ielen > 0)) { pdata->flags = 2; break; @@ -2498,7 +2498,7 @@ static int rtw_get_ap_info(struct net_device *dev, spin_unlock_bh(&pmlmepriv->scanned_queue.lock); if (pdata->length >= 34) { - if (copy_to_user(pdata->pointer+32, (u8 *)&pdata->flags, 1)) { + if (copy_to_user(pdata->pointer + 32, (u8 *)&pdata->flags, 1)) { ret = -EINVAL; goto exit; } @@ -2525,8 +2525,8 @@ static int rtw_set_pid(struct net_device *dev, selector = *pdata; if (selector < 3 && selector >= 0) { - padapter->pid[selector] = *(pdata+1); - ui_pid[selector] = *(pdata+1); + padapter->pid[selector] = *(pdata + 1); + ui_pid[selector] = *(pdata + 1); DBG_88E("%s set pid[%d] =%d\n", __func__, selector, padapter->pid[selector]); } else { DBG_88E("%s selector %d error\n", __func__, selector); @@ -2978,7 +2978,7 @@ static int rtw_p2p_get_wps_configmethod(struct net_device *dev, /* The mac address is matched. */ wpsie = rtw_get_wps_ie(&pnetwork->network.IEs[12], pnetwork->network.IELength - 12, NULL, &wpsie_len); if (wpsie) { - rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *) &be_tmp, &attr_contentlen); + rtw_get_wps_attr_content(wpsie, wpsie_len, WPS_ATTR_CONF_METHOD, (u8 *)&be_tmp, &attr_contentlen); if (attr_contentlen) { attr_content = be16_to_cpu(be_tmp); sprintf(attr_content_str, "\n\nM =%.4d", attr_content); @@ -3062,7 +3062,7 @@ static int rtw_p2p_get_go_device_address(struct net_device *dev, } /* Get the next P2P IE */ - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); } } } @@ -3279,7 +3279,7 @@ static int rtw_p2p_get_invitation_procedure(struct net_device *dev, } /* Get the next P2P IE */ - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); } } } @@ -3471,7 +3471,7 @@ static int rtw_p2p_invite_req(struct net_device *dev, /* Store the GO's ssid */ pinvite_req_info->ssidlen = wrqu->data.length - 36; - memcpy(pinvite_req_info->go_ssid, &extra[36], (u32) pinvite_req_info->ssidlen); + memcpy(pinvite_req_info->go_ssid, &extra[36], (u32)pinvite_req_info->ssidlen); pinvite_req_info->benable = true; pinvite_req_info->peer_ch = uintPeerChannel; @@ -3611,7 +3611,7 @@ static int rtw_p2p_prov_disc(struct net_device *dev, } /* Get the next P2P IE */ - p2pie = rtw_get_p2p_ie(p2pie+p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); + p2pie = rtw_get_p2p_ie(p2pie + p2pielen, pnetwork->network.IELength - 12 - (p2pie - &pnetwork->network.IEs[12] + p2pielen), NULL, &p2pielen); } } @@ -3624,7 +3624,7 @@ static int rtw_p2p_prov_disc(struct net_device *dev, DBG_88E("[%s] peer channel: %d!\n", __func__, uintPeerChannel); memcpy(pwdinfo->tx_prov_disc_info.peerIFAddr, pnetwork->network.MacAddress, ETH_ALEN); memcpy(pwdinfo->tx_prov_disc_info.peerDevAddr, peerMAC, ETH_ALEN); - pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16) uintPeerChannel; + pwdinfo->tx_prov_disc_info.peer_channel_num[0] = (u16)uintPeerChannel; pwdinfo->tx_prov_disc_info.benable = true; rtw_p2p_set_pre_state(pwdinfo, rtw_p2p_state(pwdinfo)); rtw_p2p_set_state(pwdinfo, P2P_STATE_TX_PROVISION_DIS_REQ); @@ -3842,7 +3842,7 @@ static int rtw_rereg_nd_name(struct net_device *dev, reg_ifname = padapter->registrypriv.if2name; strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ-1] = 0; + rereg_priv->old_ifname[IFNAMSIZ - 1] = 0; } if (wrqu->data.length > IFNAMSIZ) @@ -3866,7 +3866,7 @@ static int rtw_rereg_nd_name(struct net_device *dev, } strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ-1] = 0; + rereg_priv->old_ifname[IFNAMSIZ - 1] = 0; if (!memcmp(new_ifname, "disable%d", 9)) { DBG_88E("%s disable\n", __func__); @@ -3892,17 +3892,17 @@ static void mac_reg_dump(struct adapter *padapter) int i, j = 1; pr_info("\n ======= MAC REG =======\n"); for (i = 0x0; i < 0x300; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) pr_info("0x%02x", i); pr_info(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) pr_info("\n"); } for (i = 0x400; i < 0x800; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) pr_info("0x%02x", i); pr_info(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) pr_info("\n"); } } @@ -3912,11 +3912,11 @@ static void bb_reg_dump(struct adapter *padapter) int i, j = 1; pr_info("\n ======= BB REG =======\n"); for (i = 0x800; i < 0x1000; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) pr_info("0x%02x", i); pr_info(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) pr_info("\n"); } } @@ -3938,10 +3938,10 @@ static void rf_reg_dump(struct adapter *padapter) pr_info("\nRF_Path(%x)\n", path); for (i = 0; i < 0x100; i++) { value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) + if (j % 4 == 1) pr_info("0x%02x ", i); pr_info(" 0x%08x ", value); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) pr_info("\n"); } } @@ -3972,7 +3972,7 @@ static int rtw_dbg_port(struct net_device *dev, major_cmd = (u8)(val32 >> 24); minor_cmd = (u8)((val32 >> 16) & 0x00ff); - extra_arg = *(pdata+1); + extra_arg = *(pdata + 1); switch (major_cmd) { case 0x70:/* read_reg */ @@ -4071,7 +4071,7 @@ static int rtw_dbg_port(struct net_device *dev, rtw_IOL_append_WB_cmd(xmit_frame, reg, 0x08, 0xff); rtw_IOL_append_DELAY_MS_cmd(xmit_frame, blink_delay_ms); } - if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms*blink_num*2)+200, 0)) + if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, (blink_delay_ms * blink_num * 2) + 200, 0)) ret = -EPERM; } break; @@ -4092,12 +4092,12 @@ static int rtw_dbg_port(struct net_device *dev, } for (i = 0; i < write_num; i++) - rtw_IOL_append_WB_cmd(xmit_frame, reg, i+start_value, 0xFF); + rtw_IOL_append_WB_cmd(xmit_frame, reg, i + start_value, 0xFF); if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) ret = -EPERM; final = rtw_read8(padapter, reg); - if (start_value+write_num-1 == final) + if (start_value + write_num - 1 == final) DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); else DBG_88E("continuous IOL_CMD_WB_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); @@ -4121,12 +4121,12 @@ static int rtw_dbg_port(struct net_device *dev, } for (i = 0; i < write_num; i++) - rtw_IOL_append_WW_cmd(xmit_frame, reg, i+start_value, 0xFFFF); + rtw_IOL_append_WW_cmd(xmit_frame, reg, i + start_value, 0xFFFF); if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) ret = -EPERM; final = rtw_read16(padapter, reg); - if (start_value+write_num-1 == final) + if (start_value + write_num - 1 == final) DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); else DBG_88E("continuous IOL_CMD_WW_REG to 0x%x %u times Fail, start:%u, final:%u\n", reg, write_num, start_value, final); @@ -4149,12 +4149,12 @@ static int rtw_dbg_port(struct net_device *dev, } for (i = 0; i < write_num; i++) - rtw_IOL_append_WD_cmd(xmit_frame, reg, i+start_value, 0xFFFFFFFF); + rtw_IOL_append_WD_cmd(xmit_frame, reg, i + start_value, 0xFFFFFFFF); if (_SUCCESS != rtw_IOL_exec_cmds_sync(padapter, xmit_frame, 5000, 0)) ret = -EPERM; final = rtw_read32(padapter, reg); - if (start_value+write_num-1 == final) + if (start_value + write_num - 1 == final) DBG_88E("continuous IOL_CMD_WD_REG to 0x%x %u times Success, start:%u, final:%u\n", reg, write_num, start_value, final); else @@ -4238,7 +4238,7 @@ static int rtw_dbg_port(struct net_device *dev, u32 ODMFlag; rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); DBG_88E("(B)DMFlag = 0x%x, arg = 0x%x\n", ODMFlag, arg); - ODMFlag = (u32)(0x0f&arg); + ODMFlag = (u32)(0x0f & arg); DBG_88E("(A)DMFlag = 0x%x\n", ODMFlag); rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); } @@ -4541,10 +4541,10 @@ static int rtw_pm_set(struct net_device *dev, DBG_88E("[%s] extra = %s\n", __func__, extra); if (!memcmp(extra, "lps =", 4)) { - sscanf(extra+4, "%u", &mode); + sscanf(extra + 4, "%u", &mode); ret = rtw_pm_set_lps(padapter, mode); } else if (!memcmp(extra, "ips =", 4)) { - sscanf(extra+4, "%u", &mode); + sscanf(extra + 4, "%u", &mode); ret = rtw_pm_set_ips(padapter, mode); } else { ret = -EINVAL; @@ -4624,10 +4624,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { sprintf(extra + strlen(extra), "0x%02x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); + sprintf(extra + strlen(extra), "%02X ", PROMContent[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", PROMContent[i+j]); + sprintf(extra + strlen(extra), "%02X ", PROMContent[i + j]); sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "realmap") == 0) { @@ -4642,10 +4642,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { sprintf(extra + strlen(extra), "0x%02x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseInitMap[i + j]); sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "rmap") == 0) { @@ -4722,7 +4722,7 @@ static int rtw_mp_efuse_get(struct net_device *dev, *extra = 0; for (i = 0; i < cnts; i++) { sprintf(extra + strlen(extra), "%02X", data[i]); - if (i != (cnts-1)) + if (i != (cnts - 1)) sprintf(extra + strlen(extra), ":"); } } else if (strcmp(tmp[0], "vidpid") == 0) { @@ -4743,13 +4743,13 @@ static int rtw_mp_efuse_get(struct net_device *dev, *extra = 0; for (i = 0; i < cnts; i++) { sprintf(extra + strlen(extra), "0x%02X", data[i]); - if (i != (cnts-1)) + if (i != (cnts - 1)) sprintf(extra + strlen(extra), ","); } } else if (strcmp(tmp[0], "ableraw") == 0) { efuse_GetCurrentSize(padapter, &raw_cursize); raw_maxsize = efuse_GetMaxSize(padapter); - sprintf(extra, "[available raw size] = %d bytes", raw_maxsize-raw_cursize); + sprintf(extra, "[available raw size] = %d bytes", raw_maxsize - raw_cursize); } else if (strcmp(tmp[0], "btfmap") == 0) { mapLen = EFUSE_BT_MAX_MAP_LEN; if (rtw_BT_efuse_map_read(padapter, 0, mapLen, pEfuseHal->BTEfuseInitMap) == _FAIL) { @@ -4763,10 +4763,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, /* set 512 because the iwpriv's extra size have limit 0x7FF */ sprintf(extra + strlen(extra), "0x%03x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i + j]); sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "btbmap") == 0) { @@ -4781,10 +4781,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, for (i = 512; i < 1024; i += 16) { sprintf(extra + strlen(extra), "0x%03x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->BTEfuseInitMap[i + j]); sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "btrmap") == 0) { @@ -4826,10 +4826,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, for (i = 0; i < 512; i += 16) { sprintf(extra + strlen(extra), "0x%03x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i + j]); sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "btbfake") == 0) { @@ -4837,10 +4837,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, for (i = 512; i < 1024; i += 16) { sprintf(extra + strlen(extra), "0x%03x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeBTEfuseModifiedMap[i + j]); sprintf(extra + strlen(extra), "\n"); } } else if (strcmp(tmp[0], "wlrfkmap") == 0) { @@ -4848,10 +4848,10 @@ static int rtw_mp_efuse_get(struct net_device *dev, for (i = 0; i < EFUSE_MAP_SIZE; i += 16) { sprintf(extra + strlen(extra), "0x%02x\t", i); for (j = 0; j < 8; j++) - sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), "%02X ", pEfuseHal->fakeEfuseModifiedMap[i + j]); sprintf(extra + strlen(extra), "\t"); for (; j < 16; j++) - sprintf(extra + strlen(extra), " %02X", pEfuseHal->fakeEfuseModifiedMap[i+j]); + sprintf(extra + strlen(extra), " %02X", pEfuseHal->fakeEfuseModifiedMap[i + j]); sprintf(extra + strlen(extra), "\n"); } } else { @@ -4944,7 +4944,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -4962,7 +4962,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; @@ -4983,7 +4983,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -5014,7 +5014,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, /* mac, 00e04c871200 */ addr = EEPROM_MAC_ADDR_88EU; cnts = strlen(tmp[1]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -5037,7 +5037,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); /* Change to check TYPE_EFUSE_MAP_LEN, because 8188E raw 256, logic map over 256. */ EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_EFUSE_MAP_LEN, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; @@ -5057,7 +5057,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, /* pidvid, da0b7881 */ addr = EEPROM_VID_88EE; cnts = strlen(tmp[1]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -5075,7 +5075,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, setdata[jj] = key_2char2num(tmp[1][kk], tmp[1][kk + 1]); EFUSE_GetEfuseDefinition(padapter, EFUSE_WIFI, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; @@ -5096,7 +5096,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -5114,7 +5114,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, setdata[jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); EFUSE_GetEfuseDefinition(padapter, EFUSE_BT, TYPE_AVAILABLE_EFUSE_BYTES_TOTAL, (void *)&max_available_size, false); - if ((addr+cnts) > max_available_size) { + if ((addr + cnts) > max_available_size) { DBG_88E("%s: addr(0x%X)+cnts(%d) parameter error!\n", __func__, addr, cnts); err = -EFAULT; goto exit; @@ -5135,7 +5135,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -5150,7 +5150,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, DBG_88E("%s: BT tmp data =%s\n", __func__, tmp[2]); for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - pEfuseHal->fakeBTEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + pEfuseHal->fakeBTEfuseModifiedMap[addr + jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); } else if (strcmp(tmp[0], "btdumpfake") == 0) { if (rtw_BT_efuse_map_read(padapter, 0, EFUSE_BT_MAX_MAP_LEN, pEfuseHal->fakeBTEfuseModifiedMap) == _SUCCESS) { DBG_88E("%s: BT read all map success\n", __func__); @@ -5201,7 +5201,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, addr &= 0xFFF; cnts = strlen(tmp[2]); - if (cnts%2) { + if (cnts % 2) { err = -EINVAL; goto exit; } @@ -5216,7 +5216,7 @@ static int rtw_mp_efuse_set(struct net_device *dev, DBG_88E("%s: map tmp data =%s\n", __func__, tmp[2]); for (jj = 0, kk = 0; jj < cnts; jj++, kk += 2) - pEfuseHal->fakeEfuseModifiedMap[addr+jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); + pEfuseHal->fakeEfuseModifiedMap[addr + jj] = key_2char2num(tmp[2][kk], tmp[2][kk + 1]); } exit: @@ -5368,7 +5368,7 @@ static int rtw_mp_read_reg(struct net_device *dev, /* 2 bytes */ sprintf(data, "%04x\n", rtw_read16(padapter, addr)); for (i = 0; i <= strlen(data); i++) { - if (i%2 == 0) { + if (i % 2 == 0) { tmp[j] = ' '; j++; } @@ -5400,7 +5400,7 @@ static int rtw_mp_read_reg(struct net_device *dev, sprintf(data, "%08x", rtw_read32(padapter, addr)); /* add read data format blank */ for (i = 0; i <= strlen(data); i++) { - if (i%2 == 0) { + if (i % 2 == 0) { tmp[j] = ' '; j++; } @@ -5511,7 +5511,7 @@ static int rtw_mp_read_rf(struct net_device *dev, sprintf(data, "%08x", read_rfreg(padapter, path, addr)); /* add read data format blank */ for (i = 0; i <= strlen(data); i++) { - if (i%2 == 0) { + if (i % 2 == 0) { tmp[j] = ' '; j++; } @@ -5601,7 +5601,7 @@ static int rtw_mp_rate(struct net_device *dev, if (rate <= 0x7f) rate = wifirate2_ratetbl_inx((u8)rate); else - rate = (rate-0x80+MPT_RATE_MCS0); + rate = (rate - 0x80 + MPT_RATE_MCS0); if (rate >= MPT_RATE_LAST) return -EINVAL; @@ -5934,9 +5934,9 @@ static int rtw_mp_arx(struct net_device *dev, OFDM_FA = read_bbreg(padapter, 0xda4, 0x0000FFFF); OFDM_FA = read_bbreg(padapter, 0xda4, 0xFFFF0000); OFDM_FA = read_bbreg(padapter, 0xda8, 0x0000FFFF); - CCK_FA = (rtw_read8(padapter, 0xa5b)<<8) | (rtw_read8(padapter, 0xa5c)); + CCK_FA = (rtw_read8(padapter, 0xa5b) << 8) | (rtw_read8(padapter, 0xa5c)); - sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok+ofdmok+htok, cckcrc+ofdmcrc+htcrc, OFDM_FA+CCK_FA); + sprintf(extra, "Phy Received packet OK:%d CRC error:%d FA Counter: %d", cckok + ofdmok + htok, cckcrc + ofdmcrc + htcrc, OFDM_FA + CCK_FA); } wrqu->length = strlen(extra) + 1; kfree(input); @@ -5959,7 +5959,7 @@ static int rtw_mp_trx_query(struct net_device *dev, sprintf(extra, "Tx OK:%d, Tx Fail:%d, Rx OK:%d, CRC error:%d ", txok, txfail, rxok, rxfail); - wrqu->length = strlen(extra)+1; + wrqu->length = strlen(extra) + 1; return 0; } @@ -6101,17 +6101,17 @@ static int rtw_mp_dump(struct net_device *dev, if (strncmp(extra, "all", 4) == 0) { DBG_88E("\n ======= MAC REG =======\n"); for (i = 0x0; i < 0x300; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) DBG_88E("0x%02x", i); DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) DBG_88E("\n"); } for (i = 0x400; i < 0x1000; i += 4) { - if (j%4 == 1) + if (j % 4 == 1) DBG_88E("0x%02x", i); DBG_88E(" 0x%08x ", rtw_read32(padapter, i)); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) DBG_88E("\n"); } @@ -6127,10 +6127,10 @@ static int rtw_mp_dump(struct net_device *dev, for (path = 0; path < path_nums; path++) { for (i = 0; i < 0x34; i++) { value = rtw_hal_read_rfreg(padapter, path, i, 0xffffffff); - if (j%4 == 1) + if (j % 4 == 1) DBG_88E("0x%02x ", i); DBG_88E(" 0x%08x ", value); - if ((j++)%4 == 0) + if ((j++) % 4 == 0) DBG_88E("\n"); } } @@ -6348,7 +6348,7 @@ static int rtw_mp_get(struct net_device *dev, break; case MP_QueryDrvStats: DBG_88E("mp_get MP_QueryDrvStats\n"); - rtw_mp_QueryDrv (dev, info, wdata, extra); + rtw_mp_QueryDrv(dev, info, wdata, extra); break; case MP_PWRTRK: DBG_88E("set case MP_PWRTRK\n"); diff --git a/drivers/staging/r8188eu/os_dep/mlme_linux.c b/drivers/staging/r8188eu/os_dep/mlme_linux.c index be9166f2b524..e3ee9dc7ab90 100644 --- a/drivers/staging/r8188eu/os_dep/mlme_linux.c +++ b/drivers/staging/r8188eu/os_dep/mlme_linux.c @@ -119,13 +119,13 @@ void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie) return; p = buff; p += sprintf(p, "ASSOCINFO(ReqIEs ="); - len = sec_ie[1]+2; + len = sec_ie[1] + 2; len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX; for (i = 0; i < len; i++) p += sprintf(p, "%02x", sec_ie[i]); p += sprintf(p, ")"); memset(&wrqu, 0, sizeof(wrqu)); - wrqu.data.length = p-buff; + wrqu.data.length = p - buff; wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ? wrqu.data.length : IW_CUSTOM_MAX; wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff); diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index f4bf4732578a..9d7d2b94493b 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -516,7 +516,7 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) registry_par->channel = (u8)rtw_channel; registry_par->wireless_mode = (u8)rtw_wireless_mode; - registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense ; + registry_par->vrtl_carrier_sense = (u8)rtw_vrtl_carrier_sense; registry_par->vcs_type = (u8)rtw_vcs_type; registry_par->rts_thresh = (u16)rtw_rts_thresh; registry_par->frag_thresh = (u16)rtw_frag_thresh; @@ -658,11 +658,11 @@ u16 rtw_recv_select_queue(struct sk_buff *skb) u32 priority; u8 *pdata = skb->data; - memcpy(ð_type, pdata+(ETH_ALEN<<1), 2); + memcpy(ð_type, pdata + (ETH_ALEN << 1), 2); switch (eth_type) { case htons(ETH_P_IP): - piphdr = (struct iphdr *)(pdata+ETH_HLEN); + piphdr = (struct iphdr *)(pdata + ETH_HLEN); dscp = piphdr->tos & 0xfc; priority = dscp >> 5; break; @@ -716,7 +716,7 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) padapter->pnetdev = pnetdev; DBG_88E("register rtw_netdev_ops to netdev_ops\n"); pnetdev->netdev_ops = &rtw_netdev_ops; - pnetdev->watchdog_timeo = HZ*3; /* 3 second timeout */ + pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */ pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; /* step 2. */ diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index c8a15959cff3..6218a9052ee9 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -61,7 +61,7 @@ void *rtw_malloc2d(int h, int w, int size) return NULL; for (j = 0; j < h; j++) - a[j] = ((char *)(a+h)) + j*w*size; + a[j] = ((char *)(a + h)) + j * w * size; return a; } @@ -112,15 +112,15 @@ inline u32 rtw_ms_to_systime(u32 ms) /* the input parameter start use the same unit as jiffies */ inline s32 rtw_get_passing_time_ms(u32 start) { - return rtw_systime_to_ms(jiffies-start); + return rtw_systime_to_ms(jiffies - start); } void rtw_usleep_os(int us) { - if (1 < (us/1000)) + if (1 < (us / 1000)) msleep(1); else - msleep((us/1000) + 1); + msleep((us / 1000) + 1); } #define RTW_SUSPEND_LOCK_NAME "rtw_wifi" @@ -282,7 +282,7 @@ keep_ori: */ inline bool rtw_cbuf_full(struct rtw_cbuf *cbuf) { - return (cbuf->write == cbuf->read-1) ? true : false; + return (cbuf->write == cbuf->read - 1) ? true : false; } /** @@ -312,7 +312,7 @@ bool rtw_cbuf_push(struct rtw_cbuf *cbuf, void *buf) if (0) DBG_88E("%s on %u\n", __func__, cbuf->write); cbuf->bufs[cbuf->write] = buf; - cbuf->write = (cbuf->write+1)%cbuf->size; + cbuf->write = (cbuf->write + 1) % cbuf->size; return _SUCCESS; } @@ -333,7 +333,7 @@ void *rtw_cbuf_pop(struct rtw_cbuf *cbuf) if (0) DBG_88E("%s on %u\n", __func__, cbuf->read); buf = cbuf->bufs[cbuf->read]; - cbuf->read = (cbuf->read+1)%cbuf->size; + cbuf->read = (cbuf->read + 1) % cbuf->size; return buf; } @@ -348,7 +348,7 @@ struct rtw_cbuf *rtw_cbuf_alloc(u32 size) { struct rtw_cbuf *cbuf; - cbuf = kmalloc(sizeof(*cbuf) + sizeof(void *)*size, GFP_KERNEL); + cbuf = kmalloc(sizeof(*cbuf) + sizeof(void *) * size, GFP_KERNEL); if (cbuf) { cbuf->write = 0; diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index 1fb01f135741..b4c5333bfff0 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -78,7 +78,7 @@ void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup) } else { cur_time = jiffies; - if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) { + if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) { psecuritypriv->btkip_countermeasure = true; psecuritypriv->last_mic_err_time = 0; psecuritypriv->btkip_countermeasure_time = cur_time; diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index bdd381606ba6..6b0b36b956a7 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -62,7 +62,7 @@ static int g_wifi_on = true; int rtw_android_cmdstr_to_num(char *cmdstr) { int cmd_num; - for (cmd_num=0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) + for (cmd_num = 0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++) if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num], strlen(android_wifi_cmd_str[cmd_num]))) break; diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 3e5f4b5eb0fc..0f28ed77ef65 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -312,7 +312,7 @@ static void process_spec_devid(const struct usb_device_id *pdid) flags = specific_device_id_tbl[i].flags; if ((pdid->idVendor == vid) && (pdid->idProduct == pid) && - (flags&SPEC_DEV_ID_DISABLE_HT)) { + (flags & SPEC_DEV_ID_DISABLE_HT)) { rtw_ht_enable = 0; rtw_cbw40_enable = 0; rtw_ampdu_enable = 0; diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 4f1ce346b3a5..30a5da986967 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -41,7 +41,7 @@ void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile) } -uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) +uint _rtw_pktfile_read(struct pkt_file *pfile, u8 *rmem, uint rlen) { uint len = 0; @@ -49,7 +49,7 @@ uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen) len = (rlen > len) ? len : rlen; if (rmem) - skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, len); + skb_copy_bits(pfile->pkt, pfile->buf_len - pfile->pkt_len, rmem, len); pfile->cur_addr += len; pfile->pkt_len -= len; @@ -104,7 +104,7 @@ void rtw_os_xmit_resource_free(struct adapter *padapter, kfree(pxmitbuf->pallocated_buf); } -#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5) +#define WMM_XMIT_THRESHOLD (NR_XMITFRAME * 2 / 5) void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *pkt) { @@ -230,7 +230,7 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) && (IP_MCAST_MAC(pkt->data) || ICMPV6_MCAST_MAC(pkt->data)) && (padapter->registrypriv.wifi_spec == 0)) { - if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4)) { + if (pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME / 4)) { res = rtw_mlcst2unicst(padapter, pkt); if (res) goto exit; -- cgit v1.2.3 From 25bcf747bdfdb413154a3d47985113474dc8133d Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Tue, 17 Aug 2021 00:44:57 +0100 Subject: staging: r8188eu: remove set but unused variable from rtl8188e_Add_RateATid Remove set but unused variable init_rate from the rtl8188e_Add_RateATid function in hal/rtl8188eu_cmd.c, as this fixes a kernel test robot warning. Removing the call to get_highest_rate_idx has no side effects here so is safe. Reported-by: kernel test robot Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210816234459.132239-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 6afdebd4f367..43ce92434b7c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -155,7 +155,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi { struct hal_data_8188e *haldata = GET_HAL_DATA(pAdapter); - u8 macid, init_rate, raid, shortGIrate = false; + u8 macid, raid, shortGIrate = false; macid = arg & 0x1f; @@ -167,13 +167,8 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap |= ((raid << 28) & 0xf0000000); - init_rate = get_highest_rate_idx(bitmap & 0x0fffffff) & 0x3f; - shortGIrate = (arg & BIT(5)) ? true : false; - if (shortGIrate) - init_rate |= BIT(6); - raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fffffff; -- cgit v1.2.3 From 8f9172d26ca5e4892b09fa670357d195305e5541 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Tue, 17 Aug 2021 00:44:58 +0100 Subject: staging: r8188eu: remove unneeded DBG_88E call from rtl8188e_Add_RateATid Remove unneeded DBG_88E macro call from the rtl8188e_Add_RateATid function in hal/rtl8188e_cmd.c, as it is not particularly clear in my opinion, and we should strive towards use of existing kernel machinery for debugging purposes. Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210816234459.132239-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 43ce92434b7c..cc06ee07974f 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -173,9 +173,6 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap &= 0x0fffffff; - DBG_88E("%s=> mac_id:%d, raid:%d, ra_bitmap=0x%x, shortGIrate=0x%02x\n", - __func__, macid, raid, bitmap, shortGIrate); - ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, macid, raid, bitmap, shortGIrate); } -- cgit v1.2.3 From cbfa6f33e3a685c329d78e06b0cf1dcb23c9d849 Mon Sep 17 00:00:00 2001 From: Lukas Bulwahn Date: Tue, 17 Aug 2021 12:54:04 +0200 Subject: clk: staging: correct reference to config IOMEM to config HAS_IOMEM Commit 0a0a66c984b3 ("clk: staging: Specify IOMEM dependency for Xilinx Clocking Wizard driver") introduces a dependency on the non-existing config IOMEM, which basically makes it impossible to include this driver into any build. Fortunately, ./scripts/checkkconfigsymbols.py warns: IOMEM Referencing files: drivers/staging/clocking-wizard/Kconfig The config for IOMEM support is called HAS_IOMEM. Correct this reference to the intended config. Fixes: 0a0a66c984b3 ("clk: staging: Specify IOMEM dependency for Xilinx Clocking Wizard driver") Signed-off-by: Lukas Bulwahn Link: https://lore.kernel.org/r/20210817105404.13146-1-lukas.bulwahn@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/clocking-wizard/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/clocking-wizard/Kconfig b/drivers/staging/clocking-wizard/Kconfig index 69cf51445f08..2324b5d73788 100644 --- a/drivers/staging/clocking-wizard/Kconfig +++ b/drivers/staging/clocking-wizard/Kconfig @@ -5,6 +5,6 @@ config COMMON_CLK_XLNX_CLKWZRD tristate "Xilinx Clocking Wizard" - depends on COMMON_CLK && OF && IOMEM + depends on COMMON_CLK && OF && HAS_IOMEM help Support for the Xilinx Clocking Wizard IP core clock generator. -- cgit v1.2.3 From 08c63a33f34186e0e818cd625efe4f6efab03a5b Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Tue, 17 Aug 2021 20:57:23 +0200 Subject: staging: r8188eu: Remove code depending on NAT25_LOOKUP Remove all the code related to the management of the NAT25_LOOKUP method in nat25_db_handle(). The only function that used that method was the now deleted nat25_handle_frame(). Remove the NAT25_LOOKUP entry from the NAT25_METHOD enum because it is not anymore used everywhere else in the code of the driver. Remove the 'sender' pointer to integer. Remove __nat25_db_network_lookup_and_replace(). Following the deletion of the code related to the NAT25_LOOKUP method, they are no more needed. Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210817185723.15192-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 164 +-------------------------- drivers/staging/r8188eu/include/rtw_br_ext.h | 1 - 2 files changed, 1 insertion(+), 164 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index e8eea95a52e3..ee52f28a1e56 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -295,56 +295,6 @@ static void __network_hash_unlink(struct nat25_network_db_entry *ent) ent->pprev_hash = NULL; } -static int __nat25_db_network_lookup_and_replace(struct adapter *priv, - struct sk_buff *skb, unsigned char *networkAddr) -{ - struct nat25_network_db_entry *db; - - spin_lock_bh(&priv->br_ext_lock); - - db = priv->nethash[__nat25_network_hash(networkAddr)]; - while (db) { - if (!memcmp(db->networkAddr, networkAddr, MAX_NETWORK_ADDR_LEN)) { - if (!__nat25_has_expired(priv, db)) { - /* replace the destination mac address */ - memcpy(skb->data, db->macAddr, ETH_ALEN); - atomic_inc(&db->use_count); - - DEBUG_INFO("NAT25: Lookup M:%02x%02x%02x%02x%02x%02x N:%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x" - "%02x%02x%02x%02x%02x%02x\n", - db->macAddr[0], - db->macAddr[1], - db->macAddr[2], - db->macAddr[3], - db->macAddr[4], - db->macAddr[5], - db->networkAddr[0], - db->networkAddr[1], - db->networkAddr[2], - db->networkAddr[3], - db->networkAddr[4], - db->networkAddr[5], - db->networkAddr[6], - db->networkAddr[7], - db->networkAddr[8], - db->networkAddr[9], - db->networkAddr[10], - db->networkAddr[11], - db->networkAddr[12], - db->networkAddr[13], - db->networkAddr[14], - db->networkAddr[15], - db->networkAddr[16]); - } - spin_unlock_bh(&priv->br_ext_lock); - return 1; - } - db = db->next_hash; - } - spin_unlock_bh(&priv->br_ext_lock); - return 0; -} - static void __nat25_db_network_insert(struct adapter *priv, unsigned char *macAddr, unsigned char *networkAddr) { @@ -484,27 +434,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) __nat25_db_print(priv); return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup IP, SA =%08x, DA =%08x\n", iph->saddr, iph->daddr); - tmp = be32_to_cpu(iph->daddr); - __nat25_generate_ipv4_network_addr(networkAddr, &tmp); - - if (!__nat25_db_network_lookup_and_replace(priv, skb, networkAddr)) { - if (*((unsigned char *)&iph->daddr + 3) == 0xff) { - /* L2 is unicast but L3 is broadcast, make L2 bacome broadcast */ - DEBUG_INFO("NAT25: Set DA as boardcast\n"); - memset(skb->data, 0xff, ETH_ALEN); - } else { - /* forward unknow IP packet to upper TCP/IP */ - DEBUG_INFO("NAT25: Replace DA with BR's MAC\n"); - if ((*(u32 *)priv->br_mac) == 0 && (*(u16 *)(priv->br_mac+4)) == 0) { - printk("Re-init netdev_br_init() due to br_mac == 0!\n"); - netdev_br_init(priv->pnetdev); - } - memcpy(skb->data, priv->br_mac, ETH_ALEN); - } - } - return 0; default: return -1; } @@ -514,7 +443,7 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) /*---------------------------------------------------*/ struct arphdr *arp = (struct arphdr *)(skb->data + ETH_HLEN); unsigned char *arp_ptr = (unsigned char *)(arp + 1); - unsigned int *sender, *target; + unsigned int *sender; if (arp->ar_pro != __constant_htons(ETH_P_IP)) { DEBUG_WARN("NAT25: arp protocol unknown (%4x)!\n", be16_to_cpu(arp->ar_pro)); @@ -536,20 +465,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) __nat25_db_network_insert(priv, skb->data+ETH_ALEN, networkAddr); __nat25_db_print(priv); return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup ARP\n"); - - arp_ptr += arp->ar_hln; - sender = (unsigned int *)arp_ptr; - arp_ptr += (arp->ar_hln + arp->ar_pln); - target = (unsigned int *)arp_ptr; - __nat25_generate_ipv4_network_addr(networkAddr, target); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - /* change to ARP target mac address to Lookup result */ - arp_ptr = (unsigned char *)(arp + 1); - arp_ptr += (arp->ar_hln + arp->ar_pln); - memcpy(arp_ptr, skb->data, ETH_ALEN); - return 0; default: return -1; } @@ -637,70 +552,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) priv->pppoe_connection_in_progress = 0; } return 0; - case NAT25_LOOKUP: - if (ph->code == PADO_CODE || ph->code == PADS_CODE) { - if (priv->ethBrExtInfo.addPPPoETag) { - struct pppoe_tag *tag; - unsigned char *ptr; - unsigned short tagType, tagLen; - int offset = 0; - - ptr = __nat25_find_pppoe_tag(ph, ntohs(PTT_RELAY_SID)); - if (!ptr) { - DEBUG_ERR("Fail to find PTT_RELAY_SID in FADO!\n"); - return -1; - } - - tag = (struct pppoe_tag *)ptr; - tagType = (unsigned short)((ptr[0] << 8) + ptr[1]); - tagLen = (unsigned short)((ptr[2] << 8) + ptr[3]); - - if ((tagType != ntohs(PTT_RELAY_SID)) || (tagLen < (MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN))) { - DEBUG_ERR("Invalid PTT_RELAY_SID tag length [%d]!\n", tagLen); - return -1; - } - - pMagic = (unsigned short *)tag->tag_data; - if (ntohs(*pMagic) != MAGIC_CODE) { - DEBUG_ERR("Can't find MAGIC_CODE in %s packet!\n", - (ph->code == PADO_CODE ? "PADO" : "PADS")); - return -1; - } - - memcpy(skb->data, tag->tag_data+MAGIC_CODE_LEN, ETH_ALEN); - - if (tagLen > MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN) - offset = TAG_HDR_LEN; - - if (skb_pull_and_merge(skb, ptr+offset, TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset) < 0) { - DEBUG_ERR("call skb_pull_and_merge() failed in PADO packet!\n"); - return -1; - } - ph->length = htons(ntohs(ph->length)-(TAG_HDR_LEN+MAGIC_CODE_LEN+RTL_RELAY_TAG_LEN-offset)); - if (offset > 0) - tag->tag_len = htons(tagLen-MAGIC_CODE_LEN-RTL_RELAY_TAG_LEN); - - DEBUG_INFO("NAT25: Lookup PPPoE, forward %s Packet from %s\n", - (ph->code == PADO_CODE ? "PADO" : "PADS"), skb->dev->name); - } else { /* not add relay tag */ - if (!priv->pppoe_connection_in_progress) { - DEBUG_ERR("Discard PPPoE packet due to no connection in progresss!\n"); - return -1; - } - memcpy(skb->data, priv->pppoe_addr, ETH_ALEN); - priv->pppoe_connection_in_progress = WAIT_TIME_PPPOE; - } - } else { - if (ph->sid != 0) { - DEBUG_INFO("NAT25: Lookup PPPoE, lookup session packet from %s\n", skb->dev->name); - __nat25_generate_pppoe_network_addr(networkAddr, skb->data+ETH_ALEN, &ph->sid); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - __nat25_db_print(priv); - } else { - return -1; - } - } - return 0; default: return -1; } @@ -713,8 +564,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) return -1; case NAT25_INSERT: return 0; - case NAT25_LOOKUP: - return 0; default: return -1; } @@ -727,8 +576,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) return -1; case NAT25_INSERT: return 0; - case NAT25_LOOKUP: - return 0; default: return -1; } @@ -775,15 +622,6 @@ int nat25_db_handle(struct adapter *priv, struct sk_buff *skb, int method) } } return 0; - case NAT25_LOOKUP: - DEBUG_INFO("NAT25: Lookup IP, SA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x, DA =%4x:%4x:%4x:%4x:%4x:%4x:%4x:%4x\n", - iph->saddr.s6_addr16[0], iph->saddr.s6_addr16[1], iph->saddr.s6_addr16[2], iph->saddr.s6_addr16[3], - iph->saddr.s6_addr16[4], iph->saddr.s6_addr16[5], iph->saddr.s6_addr16[6], iph->saddr.s6_addr16[7], - iph->daddr.s6_addr16[0], iph->daddr.s6_addr16[1], iph->daddr.s6_addr16[2], iph->daddr.s6_addr16[3], - iph->daddr.s6_addr16[4], iph->daddr.s6_addr16[5], iph->daddr.s6_addr16[6], iph->daddr.s6_addr16[7]); - __nat25_generate_ipv6_network_addr(networkAddr, (unsigned int *)&iph->daddr); - __nat25_db_network_lookup_and_replace(priv, skb, networkAddr); - return 0; default: return -1; } diff --git a/drivers/staging/r8188eu/include/rtw_br_ext.h b/drivers/staging/r8188eu/include/rtw_br_ext.h index 00d461c4c6fa..69905d30c191 100644 --- a/drivers/staging/r8188eu/include/rtw_br_ext.h +++ b/drivers/staging/r8188eu/include/rtw_br_ext.h @@ -31,7 +31,6 @@ enum NAT25_METHOD { NAT25_MIN, NAT25_CHECK, NAT25_INSERT, - NAT25_LOOKUP, NAT25_PARSE, NAT25_MAX }; -- cgit v1.2.3 From cbe34165cc1b7d1110b268ba8b9f30843c941639 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Tue, 17 Aug 2021 21:42:52 -0700 Subject: staging: rts5208: Fix get_ms_information() heap buffer size Fix buf allocation size (it needs to be 2 bytes larger). Found when __alloc_size() annotations were added to kmalloc() interfaces. In file included from ./include/linux/string.h:253, from ./include/linux/bitmap.h:10, from ./include/linux/cpumask.h:12, from ./arch/x86/include/asm/paravirt.h:17, from ./arch/x86/include/asm/irqflags.h:63, from ./include/linux/irqflags.h:16, from ./include/linux/rcupdate.h:26, from ./include/linux/rculist.h:11, from ./include/linux/pid.h:5, from ./include/linux/sched.h:14, from ./include/linux/blkdev.h:5, from drivers/staging/rts5208/rtsx_scsi.c:12: In function 'get_ms_information', inlined from 'ms_sp_cmnd' at drivers/staging/rts5208/rtsx_scsi.c:2877:12, inlined from 'rtsx_scsi_handler' at drivers/staging/rts5208/rtsx_scsi.c:3247:12: ./include/linux/fortify-string.h:54:29: warning: '__builtin_memcpy' forming offset [106, 107] is out of the bounds [0, 106] [-Warray-bounds] 54 | #define __underlying_memcpy __builtin_memcpy | ^ ./include/linux/fortify-string.h:417:2: note: in expansion of macro '__underlying_memcpy' 417 | __underlying_##op(p, q, __fortify_size); \ | ^~~~~~~~~~~~~ ./include/linux/fortify-string.h:463:26: note: in expansion of macro '__fortify_memcpy_chk' 463 | #define memcpy(p, q, s) __fortify_memcpy_chk(p, q, s, \ | ^~~~~~~~~~~~~~~~~~~~ drivers/staging/rts5208/rtsx_scsi.c:2851:3: note: in expansion of macro 'memcpy' 2851 | memcpy(buf + i, ms_card->raw_sys_info, 96); | ^~~~~~ Cc: Greg Kroah-Hartman Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210818044252.1533634-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rts5208/rtsx_scsi.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rts5208/rtsx_scsi.c b/drivers/staging/rts5208/rtsx_scsi.c index 1deb74112ad4..11d9d9155eef 100644 --- a/drivers/staging/rts5208/rtsx_scsi.c +++ b/drivers/staging/rts5208/rtsx_scsi.c @@ -2802,10 +2802,10 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) } if (dev_info_id == 0x15) { - buf_len = 0x3A; + buf_len = 0x3C; data_len = 0x3A; } else { - buf_len = 0x6A; + buf_len = 0x6C; data_len = 0x6A; } @@ -2855,11 +2855,7 @@ static int get_ms_information(struct scsi_cmnd *srb, struct rtsx_chip *chip) } rtsx_stor_set_xfer_buf(buf, buf_len, srb); - - if (dev_info_id == 0x15) - scsi_set_resid(srb, scsi_bufflen(srb) - 0x3C); - else - scsi_set_resid(srb, scsi_bufflen(srb) - 0x6C); + scsi_set_resid(srb, scsi_bufflen(srb) - buf_len); kfree(buf); return STATUS_SUCCESS; -- cgit v1.2.3 From 0a9b92020d755c4c7a50c7b4b9a0fa047e393083 Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Wed, 18 Aug 2021 01:19:37 -0700 Subject: staging: wlan-ng: Disable buggy MIB ioctl struct hfa384x_wpa_data ends with a flexible array, but it is allocated on the stack. This means it can never hold any data. Disable the memcpy() calls in and out of the structure, since it must always be zero. This could never have worked. Cc: Greg Kroah-Hartman Cc: Igor Matheus Andrade Torrente Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210818081937.1668775-1-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/prism2mib.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/prism2mib.c b/drivers/staging/wlan-ng/prism2mib.c index 875812a391c9..d14f032a7ed6 100644 --- a/drivers/staging/wlan-ng/prism2mib.c +++ b/drivers/staging/wlan-ng/prism2mib.c @@ -668,6 +668,10 @@ static int prism2mib_priv(struct mibrec *mib, switch (mib->did) { case DIDMIB_LNX_CONFIGTABLE_RSNAIE: { + /* + * This can never work: wpa is on the stack + * and has no bytes allocated in wpa.data. + */ struct hfa384x_wpa_data wpa; if (isget) { @@ -675,11 +679,17 @@ static int prism2mib_priv(struct mibrec *mib, HFA384x_RID_CNFWPADATA, (u8 *)&wpa, sizeof(wpa)); + /* pstr->len = le16_to_cpu(wpa.datalen); memcpy(pstr->data, wpa.data, pstr->len); + */ + pstr->len = 0; } else { + /* wpa.datalen = cpu_to_le16(pstr->len); memcpy(wpa.data, pstr->data, pstr->len); + */ + wpa.datalen = 0; hfa384x_drvr_setconfig(hw, HFA384x_RID_CNFWPADATA, -- cgit v1.2.3 From 7972067ad028ed5182d2b6663396de9dc6c629a6 Mon Sep 17 00:00:00 2001 From: Cai Huoqing Date: Wed, 18 Aug 2021 17:53:31 +0800 Subject: staging: r8188eu: Remove unused including Remove including that don't need it Acked-by: Michael Straube Signed-off-by: Cai Huoqing Link: https://lore.kernel.org/r/20210818095331.3422-1-caihuoqing@baidu.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 1 - drivers/staging/r8188eu/os_dep/os_intfs.c | 1 - drivers/staging/r8188eu/os_dep/rtw_android.c | 1 - drivers/staging/r8188eu/os_dep/xmit_linux.c | 1 - 4 files changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index c0685965b436..bcef83fc3b34 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -3,7 +3,6 @@ #define _RTW_MLME_C_ -#include #include "../include/osdep_service.h" #include "../include/drv_types.h" #include "../include/recv_osdep.h" diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 9d7d2b94493b..1aa65925e1da 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -12,7 +12,6 @@ #include "../include/usb_osintf.h" #include "../include/rtw_br_ext.h" -#include MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("Realtek Wireless Lan Driver"); diff --git a/drivers/staging/r8188eu/os_dep/rtw_android.c b/drivers/staging/r8188eu/os_dep/rtw_android.c index 6b0b36b956a7..010d529c8982 100644 --- a/drivers/staging/r8188eu/os_dep/rtw_android.c +++ b/drivers/staging/r8188eu/os_dep/rtw_android.c @@ -3,7 +3,6 @@ #include #include -#include #include "../include/rtw_android.h" #include "../include/osdep_service.h" #include "../include/rtw_debug.h" diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 30a5da986967..358f58b115e3 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -3,7 +3,6 @@ #define _XMIT_OSDEP_C_ -#include #include "../include/osdep_service.h" #include "../include/drv_types.h" #include "../include/if_ether.h" -- cgit v1.2.3 From 39876a013b3e16e7c78e3638e674a18df999069f Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 18 Aug 2021 10:58:09 +0200 Subject: staging: r8188eu: remove null pointer checks before kfree kfree(NULL) is safe, so remove unnecessary null pointer checks before calls to kfree. Reported by checkpatch. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210818085809.31451-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 3 +-- drivers/staging/r8188eu/core/rtw_cmd.c | 13 +++---------- 2 files changed, 4 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 8ef0586b753f..1127e9a52458 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -1314,8 +1314,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) pnetwork->IELength = wps_offset + (wps_ielen + 2) + remainder_ielen; } - if (pbackup_remainder_ie) - kfree(pbackup_remainder_ie); + kfree(pbackup_remainder_ie); } static void update_bcn_p2p_ie(struct adapter *padapter) diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 7c640c8148f6..21a048d52b5a 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -89,13 +89,9 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) { - if (pcmdpriv) { - if (pcmdpriv->cmd_allocated_buf) - kfree(pcmdpriv->cmd_allocated_buf); - - if (pcmdpriv->rsp_allocated_buf) - kfree(pcmdpriv->rsp_allocated_buf); + kfree(pcmdpriv->cmd_allocated_buf); + kfree(pcmdpriv->rsp_allocated_buf); } } @@ -818,11 +814,8 @@ u8 rtw_joinbss_cmd(struct adapter *padapter, struct wlan_network *pnetwork) psecnetwork = (struct wlan_bssid_ex *)&psecuritypriv->sec_bss; if (!psecnetwork) { - if (pcmd) - kfree(pcmd); - + kfree(pcmd); res = _FAIL; - goto exit; } -- cgit v1.2.3 From b3cab9a174e347462795330b915ae8ddcaf36fdc Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 18 Aug 2021 10:08:53 +0200 Subject: staging: r8188eu: clean up comparsions to true Clean up comparsions to true. x == true -> x Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210818080854.15847-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 16 ++++++++-------- drivers/staging/r8188eu/core/rtw_ieee80211.c | 4 ++-- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 22 +++++++++++----------- drivers/staging/r8188eu/core/rtw_mlme.c | 24 ++++++++++++------------ drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mp_ioctl.c | 4 ++-- drivers/staging/r8188eu/core/rtw_recv.c | 22 +++++++++++----------- drivers/staging/r8188eu/core/rtw_wlan_util.c | 10 +++++----- drivers/staging/r8188eu/core/rtw_xmit.c | 4 ++-- drivers/staging/r8188eu/hal/hal_intf.c | 2 +- drivers/staging/r8188eu/hal/odm.c | 2 +- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 2 +- drivers/staging/r8188eu/include/rtw_mlme.h | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 16 ++++++++-------- 14 files changed, 67 insertions(+), 67 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 21a048d52b5a..a19535fa8db9 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -397,11 +397,11 @@ u8 rtw_sitesurvey_cmd(struct adapter *padapter, struct ndis_802_11_ssid *ssid, struct cmd_priv *pcmdpriv = &padapter->cmdpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SCAN, 1); } - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { p2p_ps_wk_cmd(padapter, P2P_PS_SCAN, 1); } @@ -1488,7 +1488,7 @@ static void dynamic_chk_wk_hdl(struct adapter *padapter, u8 *pbuf, int sz) pmlmepriv = &padapter->mlmepriv; #ifdef CONFIG_88EU_AP_MODE - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) expire_timeout_chk(padapter); #endif @@ -1506,13 +1506,13 @@ static void lps_ctrl_wk_hdl(struct adapter *padapter, u8 lps_ctrl_type) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; u8 mstatus; - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) return; switch (lps_ctrl_type) { case LPS_CTRL_SCAN: - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { /* connect */ LPS_Leave(padapter); } @@ -1913,7 +1913,7 @@ static void c2h_wk_callback(struct work_struct *work) continue; } - if (ccx_id_filter(c2h_evt->id) == true) { + if (ccx_id_filter(c2h_evt->id)) { /* Handle CCX report here */ rtw_hal_c2h_handler(adapter, c2h_evt); kfree(c2h_evt); @@ -2117,7 +2117,7 @@ void rtw_setassocsta_cmdrsp_callback(struct adapter *padapter, struct cmd_obj * spin_lock_bh(&pmlmepriv->lock); - if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true)) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); set_fwstate(pmlmepriv, _FW_LINKED); diff --git a/drivers/staging/r8188eu/core/rtw_ieee80211.c b/drivers/staging/r8188eu/core/rtw_ieee80211.c index add97664510c..b3a74198596a 100644 --- a/drivers/staging/r8188eu/core/rtw_ieee80211.c +++ b/drivers/staging/r8188eu/core/rtw_ieee80211.c @@ -100,9 +100,9 @@ int rtw_check_network_type(unsigned char *rate, int ratelen, int channel) if (channel > 14) { return WIRELESS_INVALID; } else { /* could be pure B, pure G, or B/G */ - if ((rtw_is_cckratesonly_included(rate)) == true) + if (rtw_is_cckratesonly_included(rate)) return WIRELESS_11B; - else if ((rtw_is_cckrates_included(rate)) == true) + else if (rtw_is_cckrates_included(rate)) return WIRELESS_11BG; else return WIRELESS_11G; diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index edfea5ad8259..a10b855250df 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -84,7 +84,7 @@ u8 rtw_do_join(struct adapter *padapter) pmlmepriv->to_join = false; _set_timer(&pmlmepriv->assoc_timer, MAX_JOIN_TIMEOUT); } else { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { /* submit createbss_cmd to change to a ADHOC_MASTER */ /* pmlmepriv->lock has been acquired by caller... */ @@ -149,7 +149,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) spin_lock_bh(&pmlmepriv->lock); DBG_88E("Set BSSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) goto handle_tkip_countermeasure; else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) goto release_mlme_lock; @@ -161,7 +161,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) } else { rtw_disassoc_cmd(padapter, 0, true); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); @@ -222,9 +222,9 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) spin_lock_bh(&pmlmepriv->lock); DBG_88E("Set SSID under fw_state = 0x%08x\n", get_fwstate(pmlmepriv)); - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { goto handle_tkip_countermeasure; - } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) { + } else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { goto release_mlme_lock; } @@ -236,12 +236,12 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) /* if in WIFI_ADHOC_MASTER_STATE | WIFI_ADHOC_STATE, create bss or rejoin again */ rtw_disassoc_cmd(padapter, 0, true); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } @@ -254,12 +254,12 @@ u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) } else { rtw_disassoc_cmd(padapter, 0, true); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); } @@ -283,7 +283,7 @@ handle_tkip_countermeasure: memcpy(&pmlmepriv->assoc_ssid, ssid, sizeof(struct ndis_802_11_ssid)); pmlmepriv->assoc_by_bssid = false; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) { + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) { pmlmepriv->to_join = true; } else { status = rtw_do_join(padapter); @@ -326,7 +326,7 @@ u8 rtw_set_802_11_infrastructure_mode(struct adapter *padapter, rtw_free_assoc_resources(padapter, 1); if ((*pold_state == Ndis802_11Infrastructure) || (*pold_state == Ndis802_11IBSS)) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) rtw_indicate_disconnect(padapter); /* will clr Linked_state; before this function, we must have chked whether issue dis-assoc_cmd or not */ } diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index bcef83fc3b34..1d5b0fbaded6 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -508,8 +508,8 @@ static void update_current_network(struct adapter *adapter, struct wlan_bssid_ex { struct mlme_priv *pmlmepriv = &adapter->mlmepriv; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) && - (is_same_network(&pmlmepriv->cur_network.network, pnetwork))) { + if (check_fwstate(pmlmepriv, _FW_LINKED) && + is_same_network(&pmlmepriv->cur_network.network, pnetwork)) { update_network(&pmlmepriv->cur_network.network, pnetwork, adapter, true); rtw_update_protection(adapter, (pmlmepriv->cur_network.network.IEs) + sizeof(struct ndis_802_11_fixed_ie), pmlmepriv->cur_network.network.IELength); @@ -669,7 +669,7 @@ static int rtw_is_desired_network(struct adapter *adapter, struct wlan_network * bselected = false; } - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) bselected = false; } @@ -691,7 +691,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) spin_lock_bh(&pmlmepriv->lock); /* update IBSS_network 's timestamp */ - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, pnetwork->MacAddress, ETH_ALEN)) { struct wlan_network *ibss_wlan = NULL; @@ -805,7 +805,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) spin_unlock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) + if (check_fwstate(pmlmepriv, _FW_LINKED)) p2p_ps_wk_cmd(adapter, P2P_PS_SCAN_DONE, 0); rtw_os_xmit_schedule(adapter); @@ -1127,14 +1127,14 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (ptarget_wlan) ptarget_wlan->fixed = true; } } } else { ptarget_wlan = rtw_find_network(&pmlmepriv->scanned_queue, pnetwork->network.MacAddress); - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { if (ptarget_wlan) ptarget_wlan->fixed = true; } @@ -1149,7 +1149,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } /* s3. find ptarget_sta & update ptarget_sta after update cur_network only for station mode */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { ptarget_sta = rtw_joinbss_update_stainfo(adapter, pnetwork); if (!ptarget_sta) { spin_unlock_bh(&pmlmepriv->scanned_queue.lock); @@ -1158,7 +1158,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) } /* s4. indicate connect */ - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE)) { pmlmepriv->cur_network_scanned = ptarget_wlan; rtw_indicate_connect(adapter); } @@ -1176,7 +1176,7 @@ void rtw_joinbss_event_prehandle(struct adapter *adapter, u8 *pbuf) rtw_reset_securitypriv(adapter); _set_timer(&pmlmepriv->assoc_timer, 1); - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) _clr_fwstate_(pmlmepriv, _FW_UNDER_LINKING); } else { /* if join_res < 0 (join fails), then try again */ _set_timer(&pmlmepriv->assoc_timer, 1); @@ -1499,7 +1499,7 @@ void rtw_dynamic_check_timer_handlder(struct adapter *adapter) rcu_read_lock(); if (rcu_dereference(adapter->pnetdev->rx_handler_data) && - (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) == true)) { + check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE)) { /* expire NAT2.5 entry */ nat25_db_expire(adapter); @@ -1610,7 +1610,7 @@ int rtw_select_and_join_from_scanned_queue(struct mlme_priv *pmlmepriv) } /* check for situation of _FW_LINKED */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { DBG_88E("%s: _FW_LINKED while ask_for_joinbss!!!\n", __func__); rtw_disassoc_cmd(adapter, 0, true); diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 8c044d3bb61a..bba97afcf404 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -361,11 +361,11 @@ s32 mp_start_test(struct adapter *padapter) spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) goto end_of_mp_start_test; /* init mp_start_test status */ - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED)) { rtw_disassoc_cmd(padapter, 500, true); rtw_indicate_disconnect(padapter); rtw_free_assoc_resources(padapter, 1); diff --git a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c index 36091eac0e0f..c85f8e467337 100644 --- a/drivers/staging/r8188eu/core/rtw_mp_ioctl.c +++ b/drivers/staging/r8188eu/core/rtw_mp_ioctl.c @@ -974,14 +974,14 @@ int rtl8188eu_oid_rt_pro_rw_efuse_pgpkt_hdl(struct oid_par_priv *poid_par_priv) if (poid_par_priv->type_of_oid == QUERY_OID) { Efuse_PowerSwitch(Adapter, false, true); - if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false) == true) + if (Efuse_PgPacketRead(Adapter, ppgpkt->offset, ppgpkt->data, false)) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; else status = NDIS_STATUS_FAILURE; Efuse_PowerSwitch(Adapter, false, false); } else { Efuse_PowerSwitch(Adapter, true, true); - if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false) == true) + if (Efuse_PgPacketWrite(Adapter, ppgpkt->offset, ppgpkt->word_en, ppgpkt->data, false)) *poid_par_priv->bytes_rw = poid_par_priv->information_buf_len; else status = NDIS_STATUS_FAILURE; diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index c28e0204d18b..89de409a8460 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -361,7 +361,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr if (bmic_err) { /* double check key_index for some timing issue , */ /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ - if ((IS_MCAST(prxattrib->ra) == true) && (prxattrib->key_index != pmlmeinfo->key_index)) + if (IS_MCAST(prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index) brpt_micerror = false; if ((prxattrib->bdecrypted) && (brpt_micerror)) { @@ -652,8 +652,8 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, u8 *sta_addr = NULL; int bmcast = IS_MCAST(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { ret = _FAIL; @@ -715,7 +715,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, if (!*psta) { if (adapter->registrypriv.mp_mode == 1) { - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) + if (check_fwstate(pmlmepriv, WIFI_MP_STATE)) adapter->mppriv.rx_pktloss++; } ret = _FAIL; @@ -741,9 +741,9 @@ static int ap2sta_data_frame( u8 *myhwaddr = myid(&adapter->eeprompriv); int bmcast = IS_MCAST(pattrib->dst); - if ((check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true || - check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { + if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && + (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, _FW_UNDER_LINKING))) { /* filter packets that SA is myself or multicast or broadcast */ if (!memcmp(myhwaddr, pattrib->src, ETH_ALEN)) { ret = _FAIL; @@ -788,8 +788,8 @@ static int ap2sta_data_frame( ret = RTW_RX_HANDLED; goto exit; } - } else if ((check_fwstate(pmlmepriv, WIFI_MP_STATE) == true) && - (check_fwstate(pmlmepriv, _FW_LINKED) == true)) { + } else if (check_fwstate(pmlmepriv, WIFI_MP_STATE) && + check_fwstate(pmlmepriv, _FW_LINKED)) { memcpy(pattrib->dst, GetAddr1Ptr(ptr), ETH_ALEN); memcpy(pattrib->src, GetAddr2Ptr(ptr), ETH_ALEN); memcpy(pattrib->bssid, GetAddr3Ptr(ptr), ETH_ALEN); @@ -837,7 +837,7 @@ static int sta2ap_data_frame(struct adapter *adapter, unsigned char *mybssid = get_bssid(pmlmepriv); int ret = _SUCCESS; - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { /* For AP mode, RA = BSSID, TX = STA(SRC_ADDR), A3 = DST_ADDR */ if (memcmp(pattrib->bssid, mybssid, ETH_ALEN)) { ret = _FAIL; @@ -1817,7 +1817,7 @@ void rtw_reordering_ctrl_timeout_handler(void *pcontext) spin_lock_bh(&ppending_recvframe_queue->lock); - if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true) == true) + if (recv_indicatepkts_in_order(padapter, preorder_ctrl, true)) _set_timer(&preorder_ctrl->reordering_ctrl_timer, REORDER_WAIT_TIME); spin_unlock_bh(&ppending_recvframe_queue->lock); diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 96f03e84b7e5..b8fe465c4819 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -112,9 +112,9 @@ u8 judge_network_type(struct adapter *padapter, unsigned char *rate, int ratelen if (pmlmeinfo->HT_enable) network_type = WIRELESS_11_24N; - if ((cckratesonly_included(rate, ratelen)) == true) + if (cckratesonly_included(rate, ratelen)) network_type |= WIRELESS_11B; - else if ((cckrates_included(rate, ratelen)) == true) + else if (cckrates_included(rate, ratelen)) network_type |= WIRELESS_11BG; else network_type |= WIRELESS_11G; @@ -202,7 +202,7 @@ static unsigned int ratetbl2rateset(struct adapter *padapter, unsigned char *rat default: rate = ratetbl_val_2wifirate(rate); - if (is_basicrate(padapter, rate) == true) + if (is_basicrate(padapter, rate)) rate |= IEEE80211_BASIC_RATE_MASK; rateset[len] = rate; @@ -1513,9 +1513,9 @@ void update_wireless_mode(struct adapter *padapter) if (pmlmeinfo->HT_enable) network_type = WIRELESS_11_24N; - if ((cckratesonly_included(rate, ratelen)) == true) + if (cckratesonly_included(rate, ratelen)) network_type |= WIRELESS_11B; - else if ((cckrates_included(rate, ratelen)) == true) + else if (cckrates_included(rate, ratelen)) network_type |= WIRELESS_11BG; else network_type |= WIRELESS_11G; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 41723525074d..4acc376aa413 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -490,7 +490,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p if (!psta) { /* if we cannot get psta => drrp the pkt */ res = _FAIL; goto exit; - } else if ((check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) && (!(psta->state & _FW_LINKED))) { + } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) && !(psta->state & _FW_LINKED)) { res = _FAIL; goto exit; } @@ -2154,7 +2154,7 @@ void xmit_delivery_enabled_frames(struct adapter *padapter, struct sta_info *pst pxmitframe->attrib.triggered = 1; - if (rtw_hal_xmit(padapter, pxmitframe) == true) + if (rtw_hal_xmit(padapter, pxmitframe)) rtw_os_xmit_complete(padapter, pxmitframe); if ((psta->sleepq_ac_len == 0) && (!psta->has_legacy_ac) && (wmmps_ac)) { diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 3937b65db5cc..47af081bafcd 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -250,7 +250,7 @@ void rtw_hal_update_ra_mask(struct adapter *adapt, u32 mac_id, u8 rssi_level) { struct mlme_priv *pmlmepriv = &adapt->mlmepriv; - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { #ifdef CONFIG_88EU_AP_MODE struct sta_info *psta = NULL; struct sta_priv *pstapriv = &adapt->stapriv; diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index babe37e4be8b..b5d9bafcb613 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -1345,7 +1345,7 @@ static void FindMinimumRSSI(struct adapter *pAdapter) if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) && (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) pdmpriv->MinUndecoratedPWDBForDM = 0; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) /* Default port */ + if (check_fwstate(pmlmepriv, _FW_LINKED)) /* Default port */ pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; else /* associated entry pwdb */ pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index 8c9a651d4f44..50c4b9382761 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -626,7 +626,7 @@ static s32 pre_xmitframe(struct adapter *adapt, struct xmit_frame *pxmitframe) if (rtw_txframes_sta_ac_pending(adapt, pattrib) > 0) goto enqueue; - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING) == true) + if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY | _FW_UNDER_LINKING)) goto enqueue; pxmitbuf = rtw_alloc_xmitbuf(pxmitpriv); diff --git a/drivers/staging/r8188eu/include/rtw_mlme.h b/drivers/staging/r8188eu/include/rtw_mlme.h index 11a2e176ccf7..bbb41471472d 100644 --- a/drivers/staging/r8188eu/include/rtw_mlme.h +++ b/drivers/staging/r8188eu/include/rtw_mlme.h @@ -516,7 +516,7 @@ static inline void _clr_fwstate_(struct mlme_priv *pmlmepriv, int state) static inline void clr_fwstate(struct mlme_priv *pmlmepriv, int state) { spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, state) == true) + if (check_fwstate(pmlmepriv, state)) pmlmepriv->fw_state ^= state; spin_unlock_bh(&pmlmepriv->lock); } diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 8478c0f5f285..7480c4710d7e 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -374,7 +374,7 @@ static char *translate_scan(struct adapter *padapter, iwe.cmd = IWEVQUAL; iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED | IW_QUAL_NOISE_INVALID; - if (check_fwstate(pmlmepriv, _FW_LINKED) == true && + if (check_fwstate(pmlmepriv, _FW_LINKED) && is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network)) { ss = padapter->recvpriv.signal_strength; sq = padapter->recvpriv.signal_qual; @@ -718,7 +718,7 @@ static int rtw_wx_get_name(struct net_device *dev, struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; NDIS_802_11_RATES_EX *prates = NULL; - if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE) == true) { + if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { /* parsing HT_CAP_IE */ p = rtw_get_ie(&pcur_bss->IEs[12], _HT_CAPABILITY_IE_, &ht_ielen, pcur_bss->IELength - 12); if (p && ht_ielen > 0) @@ -726,12 +726,12 @@ static int rtw_wx_get_name(struct net_device *dev, prates = &pcur_bss->SupportedRates; - if (rtw_is_cckratesonly_included((u8 *)prates) == true) { + if (rtw_is_cckratesonly_included((u8 *)prates)) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if ((rtw_is_cckrates_included((u8 *)prates)) == true) { + } else if (rtw_is_cckrates_included((u8 *)prates)) { if (ht_cap) snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); else @@ -1112,9 +1112,9 @@ static int rtw_wx_get_wap(struct net_device *dev, memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || - ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || - ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) + if (check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_AP_STATE)) memcpy(wrqu->ap_addr.sa_data, pcur_bss->MacAddress, ETH_ALEN); else memset(wrqu->ap_addr.sa_data, 0, ETH_ALEN); @@ -1445,7 +1445,7 @@ static int rtw_wx_set_essid(struct net_device *dev, if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.SsidLength)) && (pnetwork->network.Ssid.SsidLength == ndis_ssid.SsidLength)) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { + if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { if (pnetwork->network.InfrastructureMode != pmlmepriv->cur_network.network.InfrastructureMode) continue; } -- cgit v1.2.3 From ec8554b8170ac22c66b57971d72f50c0138cfb86 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 18 Aug 2021 10:08:54 +0200 Subject: staging: r8188eu: clean up comparsions to false Clean up comparsions to false. x == false -> !x Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210818080854.15847-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 4 ++-- drivers/staging/r8188eu/core/rtw_ioctl_set.c | 2 +- drivers/staging/r8188eu/core/rtw_mlme.c | 12 ++++++------ drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- drivers/staging/r8188eu/core/rtw_pwrctrl.c | 14 +++++++------- drivers/staging/r8188eu/core/rtw_recv.c | 4 ++-- drivers/staging/r8188eu/core/rtw_wlan_util.c | 2 +- drivers/staging/r8188eu/core/rtw_xmit.c | 4 ++-- drivers/staging/r8188eu/hal/odm.c | 6 +++--- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_mp.c | 2 +- drivers/staging/r8188eu/hal/usb_halinit.c | 2 +- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 8 ++++---- drivers/staging/r8188eu/os_dep/xmit_linux.c | 2 +- 14 files changed, 34 insertions(+), 34 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index a19535fa8db9..955499eb608a 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -1863,13 +1863,13 @@ static s32 c2h_evt_hdl(struct adapter *adapter, struct c2h_evt_hdr *c2h_evt, c2h if (c2h_evt_read(adapter, buf) == _SUCCESS) { c2h_evt = (struct c2h_evt_hdr *)buf; - if (filter && filter(c2h_evt->id) == false) + if (filter && !filter(c2h_evt->id)) goto exit; ret = rtw_hal_c2h_handler(adapter, c2h_evt); } } else { - if (filter && filter(c2h_evt->id) == false) + if (filter && !filter(c2h_evt->id)) goto exit; ret = rtw_hal_c2h_handler(adapter, c2h_evt); diff --git a/drivers/staging/r8188eu/core/rtw_ioctl_set.c b/drivers/staging/r8188eu/core/rtw_ioctl_set.c index a10b855250df..c187de78b4ac 100644 --- a/drivers/staging/r8188eu/core/rtw_ioctl_set.c +++ b/drivers/staging/r8188eu/core/rtw_ioctl_set.c @@ -156,7 +156,7 @@ u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) if (check_fwstate(pmlmepriv, _FW_LINKED | WIFI_ADHOC_MASTER_STATE)) { if (!memcmp(&pmlmepriv->cur_network.network.MacAddress, bssid, ETH_ALEN)) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_STATION_STATE)) goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ } else { rtw_disassoc_cmd(padapter, 0, true); diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 1d5b0fbaded6..858a582e674f 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -297,7 +297,7 @@ int rtw_if_up(struct adapter *padapter) int res; if (padapter->bDriverStopped || padapter->bSurpriseRemoved || - (check_fwstate(&padapter->mlmepriv, _FW_LINKED) == false)) + !check_fwstate(&padapter->mlmepriv, _FW_LINKED)) res = false; else res = true; @@ -708,7 +708,7 @@ void rtw_survey_event_callback(struct adapter *adapter, u8 *pbuf) } /* lock pmlmepriv->lock when you accessing network_q */ - if ((check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) == false) { + if (!check_fwstate(pmlmepriv, _FW_UNDER_LINKING)) { if (pnetwork->Ssid.Ssid[0] == 0) pnetwork->Ssid.SsidLength = 0; rtw_add_network(adapter, pnetwork); @@ -748,7 +748,7 @@ void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf) if (pmlmepriv->to_join) { if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) { - if (check_fwstate(pmlmepriv, _FW_LINKED) == false) { + if (!check_fwstate(pmlmepriv, _FW_LINKED)) { set_fwstate(pmlmepriv, _FW_UNDER_LINKING); if (rtw_select_and_join_from_scanned_queue(pmlmepriv) == _SUCCESS) { @@ -1252,7 +1252,7 @@ void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf) struct wlan_network *cur_network = &pmlmepriv->cur_network; struct wlan_network *ptarget_wlan = NULL; - if (rtw_access_ctrl(adapter, pstassoc->macaddr) == false) + if (!rtw_access_ctrl(adapter, pstassoc->macaddr)) return; #if defined(CONFIG_88EU_AP_MODE) @@ -1542,12 +1542,12 @@ static int rtw_check_join_candidate(struct mlme_priv *pmlmepriv goto exit; } - if (rtw_is_desired_network(adapter, competitor) == false) + if (!rtw_is_desired_network(adapter, competitor)) goto exit; if (rtw_to_roaming(adapter) > 0) { if (rtw_get_passing_time_ms((u32)competitor->last_scanned) >= RTW_SCAN_RESULT_EXPIRE || - is_same_ess(&competitor->network, &pmlmepriv->cur_network.network) == false) + !is_same_ess(&competitor->network, &pmlmepriv->cur_network.network)) goto exit; } diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index bba97afcf404..07d9245fa05f 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -421,7 +421,7 @@ void mp_stop_test(struct adapter *padapter) if (pmppriv->mode == MP_ON) { pmppriv->bSetTxPower = 0; spin_lock_bh(&pmlmepriv->lock); - if (check_fwstate(pmlmepriv, WIFI_MP_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_MP_STATE)) goto end_of_mp_stop_test; /* 3 1. disconnect psudo AdHoc */ @@ -866,7 +866,7 @@ u32 mp_query_psd(struct adapter *pAdapter, u8 *data) if (!netif_running(pAdapter->pnetdev)) return 0; - if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) + if (!check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE)) return 0; if (strlen(data) == 0) { /* default value */ diff --git a/drivers/staging/r8188eu/core/rtw_pwrctrl.c b/drivers/staging/r8188eu/core/rtw_pwrctrl.c index 34e4c3339b56..c3897b29121c 100644 --- a/drivers/staging/r8188eu/core/rtw_pwrctrl.c +++ b/drivers/staging/r8188eu/core/rtw_pwrctrl.c @@ -256,15 +256,15 @@ static u8 PS_RDY_CHECK(struct adapter *padapter) if (delta_time < LPS_DELAY_TIME) return false; - if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) || - (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY)) || - (check_fwstate(pmlmepriv, WIFI_AP_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE))) + if (!check_fwstate(pmlmepriv, _FW_LINKED) || + check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) || + check_fwstate(pmlmepriv, WIFI_AP_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) || + check_fwstate(pmlmepriv, WIFI_ADHOC_STATE)) return false; if (pwrpriv->bInSuspend) return false; - if ((padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) && (padapter->securitypriv.binstallGrpkey == false)) { + if (padapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X && !padapter->securitypriv.binstallGrpkey) { DBG_88E("Group handshake still in progress !!!\n"); return false; } @@ -365,7 +365,7 @@ void LPS_Enter(struct adapter *padapter) { struct pwrctrl_priv *pwrpriv = &padapter->pwrctrlpriv; - if (PS_RDY_CHECK(padapter) == false) + if (!PS_RDY_CHECK(padapter)) return; if (pwrpriv->bLeisurePs) { diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 89de409a8460..0e137aee0aa4 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -1873,7 +1873,7 @@ static int recv_func_prehandle(struct adapter *padapter, struct recv_frame *rfra else padapter->mppriv.rx_pktcount++; - if (check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE) == false) { + if (!check_fwstate(pmlmepriv, WIFI_MP_LPBK_STATE)) { ret = _FAIL; rtw_free_recvframe(rframe, pfree_recv_queue);/* free this recv_frame */ goto exit; @@ -2035,7 +2035,7 @@ void rtw_signal_stat_timer_hdl(struct timer_list *t) } /* update value of signal_strength, rssi, signal_qual */ - if (check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY) == false) { + if (!check_fwstate(&adapter->mlmepriv, _FW_UNDER_SURVEY)) { tmp_s = (avg_signal_strength + (_alpha - 1) * recvpriv->signal_strength); if (tmp_s % _alpha) tmp_s = tmp_s / _alpha + 1; diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index b8fe465c4819..0cc53781c442 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -893,7 +893,7 @@ int rtw_check_bcn_info(struct adapter *Adapter, u8 *pframe, u32 packet_len) unsigned short ht_cap_info; unsigned char ht_info_infos_0; - if (is_client_associated_to_ap(Adapter) == false) + if (!is_client_associated_to_ap(Adapter)) return true; len = packet_len - sizeof(struct rtw_ieee80211_hdr_3addr); diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 4acc376aa413..cdfcf94e4986 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -1794,7 +1794,7 @@ s32 rtw_xmit(struct adapter *padapter, struct sk_buff **ppkt) spin_unlock_bh(&pxmitpriv->lock); #endif - if (rtw_hal_xmit(padapter, pxmitframe) == false) + if (!rtw_hal_xmit(padapter, pxmitframe)) return 1; return 0; @@ -1811,7 +1811,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int bmcst = IS_MCAST(pattrib->ra); - if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == false) + if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return ret; if (pattrib->psta) diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index b5d9bafcb613..c1449fab3a95 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -606,7 +606,7 @@ void odm_DIG(struct odm_dm_struct *pDM_Odm) return; /* add by Neil Chen to avoid PSD is processing */ - if (pDM_Odm->bDMInitialGainEnable == false) + if (!pDM_Odm->bDMInitialGainEnable) return; if (pDM_Odm->SupportICType == ODM_RTL8192D) { @@ -1342,8 +1342,8 @@ static void FindMinimumRSSI(struct adapter *pAdapter) struct mlme_priv *pmlmepriv = &pAdapter->mlmepriv; /* 1 1.Determine the minimum RSSI */ - if ((check_fwstate(pmlmepriv, _FW_LINKED) == false) && - (pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0)) + if (!check_fwstate(pmlmepriv, _FW_LINKED) && + pdmpriv->EntryMinUndecoratedSmoothedPWDB == 0) pdmpriv->MinUndecoratedPWDBForDM = 0; if (check_fwstate(pmlmepriv, _FW_LINKED)) /* Default port */ pdmpriv->MinUndecoratedPWDBForDM = pdmpriv->EntryMinUndecoratedSmoothedPWDB; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index e27d8966498a..78e58f9150f3 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -1262,7 +1262,7 @@ static int hal_EfusePgPacketRead_8188e(struct adapter *pAdapter, u8 offset, u8 * bDataEmpty = false; } } - if (bDataEmpty == false) { + if (!bDataEmpty) { ReadState = PG_STATE_DATA; } else {/* read next header */ efuse_addr = efuse_addr + (word_cnts * 2) + 1; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_mp.c b/drivers/staging/r8188eu/hal/rtl8188e_mp.c index 7d412b10e6c3..fc13db705511 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_mp.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_mp.c @@ -511,7 +511,7 @@ s32 Hal_SetThermalMeter(struct adapter *pAdapter, u8 target_ther) if (!netif_running(pAdapter->pnetdev)) return _FAIL; - if (check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE) == false) + if (!check_fwstate(&pAdapter->mlmepriv, WIFI_MP_STATE)) return _FAIL; target_ther &= 0xff; diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 2e0af691310a..2cd835cb90f6 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -1065,7 +1065,7 @@ static unsigned int rtl8188eu_inirp_init(struct adapter *Adapter) /* issue Rx irp to receive data */ precvbuf = (struct recv_buf *)precvpriv->precv_buf; for (i = 0; i < NR_RECVBUFF; i++) { - if (_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf) == false) { + if (!_read_port(pintfhdl, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf)) { status = _FAIL; goto exit; } diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index 7480c4710d7e..c0e66c194952 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -820,7 +820,7 @@ static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, ret = -EINVAL; goto exit; } - if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { + if (!rtw_set_802_11_infrastructure_mode(padapter, networkType)) { ret = -EPERM; goto exit; } @@ -1088,7 +1088,7 @@ static int rtw_wx_set_wap(struct net_device *dev, rtw_set_802_11_authentication_mode(padapter, authmode); /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ - if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) { + if (!rtw_set_802_11_bssid(padapter, temp->sa_data)) { ret = -1; goto exit; } @@ -1461,7 +1461,7 @@ static int rtw_wx_set_essid(struct net_device *dev, } spin_unlock_bh(&queue->lock); rtw_set_802_11_authentication_mode(padapter, authmode); - if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { + if (!rtw_set_802_11_ssid(padapter, &ndis_ssid)) { ret = -1; goto exit; } @@ -1797,7 +1797,7 @@ static int rtw_wx_set_enc(struct net_device *dev, memcpy(wep.KeyMaterial, keybuf, wep.KeyLength); - if (rtw_set_802_11_add_wep(padapter, &wep) == false) { + if (!rtw_set_802_11_add_wep(padapter, &wep)) { if (rf_on == pwrpriv->rf_pwrstate) ret = -EOPNOTSUPP; goto exit; diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 358f58b115e3..60e0eea7ad84 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -221,7 +221,7 @@ int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; s32 res = 0; - if (rtw_if_up(padapter) == false) + if (!rtw_if_up(padapter)) goto drop_packet; rtw_check_xmit_resource(padapter, pkt); -- cgit v1.2.3 From d580fc6dbf2cca7c28c52cb37733849b67461117 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 18 Aug 2021 22:00:40 +0200 Subject: staging: r8188eu: ctrl vendor req value is always 0x05 The bRequest value for the vendor specific control requests sent by this driver is always 0x05. Replace the function parameter with the define from usb_ops.h. This patch is an adaptation of commit eeb4661560ff ("staging: rtl8188eu: ctrl vendor req value is always 0x05") for the new r8188eu driver. Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210818200041.10870-1-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 33 +++++++++-------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index b4edbfda9a18..2583e3a941fd 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -10,7 +10,7 @@ #include "../include/recv_osdep.h" #include "../include/rtl8188e_hal.h" -static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) { struct adapter *adapt = pintfhdl->padapter; struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); @@ -55,7 +55,8 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u8 request, u16 value, u memcpy(pIo_buf, pdata, len); } - status = usb_control_msg(udev, pipe, request, reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, + reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_urb_error(dvobjpriv); @@ -101,7 +102,6 @@ exit: static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -110,14 +110,13 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 1; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); @@ -127,47 +126,42 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; u16 len; __le32 data; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 2; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return (u16)(le32_to_cpu(data) & 0xffff); } static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { - u8 request; u8 requesttype; u16 wvalue; u16 index; u16 len; __le32 data; - request = 0x05; requesttype = 0x01;/* read_in */ index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 4; - usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return le32_to_cpu(data); } static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -176,20 +170,18 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) int ret; - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); return ret; } static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -199,7 +191,6 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -208,7 +199,7 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) data = cpu_to_le32(val & 0x0000ffff); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); @@ -217,7 +208,6 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -227,7 +217,6 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -235,7 +224,7 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) len = 4; data = cpu_to_le32(val); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); @@ -244,7 +233,6 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) { - u8 request; u8 requesttype; u16 wvalue; u16 index; @@ -254,7 +242,6 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata - request = 0x05; requesttype = 0x00;/* write_out */ index = 0;/* n/a */ @@ -262,7 +249,7 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata len = length; memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, request, wvalue, index, buf, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, index, buf, len, requesttype); return ret; } -- cgit v1.2.3 From 1fd6d8ffad4a6ffd38d79e42c15472c4ff6332f7 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Wed, 18 Aug 2021 22:00:41 +0200 Subject: staging: r8188eu: ctrl vendor req index is not used The index for r8188eu's vendor-specific control requests is not used. Remove the index parameter from usbctrl_vendorreq and pass index 0 to usb_control_msg. This patch is an adaptation of commit 3d0be94f62fd ("staging: rtl8188eu: ctrl vendor req index is not used") for the new r8188eu driver. Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210818200041.10870-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 33 +++++++++-------------------- 1 file changed, 10 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 2583e3a941fd..953fa05dc30c 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -10,7 +10,7 @@ #include "../include/recv_osdep.h" #include "../include/rtl8188e_hal.h" -static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, void *pdata, u16 len, u8 requesttype) +static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, u16 len, u8 requesttype) { struct adapter *adapt = pintfhdl->padapter; struct dvobj_priv *dvobjpriv = adapter_to_dvobj(adapt); @@ -56,7 +56,8 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, u16 index, vo } status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, - reqtype, value, index, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); + reqtype, value, REALTEK_USB_VENQT_CMD_IDX, + pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_urb_error(dvobjpriv); @@ -104,19 +105,17 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { u8 requesttype; u16 wvalue; - u16 index; u16 len; u8 data = 0; requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 1; - usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); @@ -128,15 +127,13 @@ static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { u8 requesttype; u16 wvalue; - u16 index; u16 len; __le32 data; requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 2; - usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); return (u16)(le32_to_cpu(data) & 0xffff); } @@ -145,17 +142,15 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { u8 requesttype; u16 wvalue; - u16 index; u16 len; __le32 data; requesttype = 0x01;/* read_in */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 4; - usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); return le32_to_cpu(data); } @@ -164,18 +159,16 @@ static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { u8 requesttype; u16 wvalue; - u16 index; u16 len; u8 data; int ret; requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); return ret; } @@ -184,7 +177,6 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { u8 requesttype; u16 wvalue; - u16 index; u16 len; __le32 data; int ret; @@ -192,14 +184,13 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 2; data = cpu_to_le32(val & 0x0000ffff); - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); @@ -210,7 +201,6 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { u8 requesttype; u16 wvalue; - u16 index; u16 len; __le32 data; int ret; @@ -218,13 +208,12 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = 4; data = cpu_to_le32(val); - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); @@ -235,7 +224,6 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata { u8 requesttype; u16 wvalue; - u16 index; u16 len; u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; int ret; @@ -243,13 +231,12 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata requesttype = 0x00;/* write_out */ - index = 0;/* n/a */ wvalue = (u16)(addr & 0x0000ffff); len = length; memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, wvalue, index, buf, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, buf, len, requesttype); return ret; } -- cgit v1.2.3 From 92791836cb7d79bba66389daed57d4d92783f01e Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Wed, 18 Aug 2021 19:08:31 +0100 Subject: staging: r8188eu: rename variable within rtl8188e_Add_RateATid Rename 'shortGIrate' within the rtl8188e_Add_RateATid function to 'short_gi_rate', to comply with kernel camel case style rules. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818180831.67581-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index cc06ee07974f..3e1a45030bc8 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -155,7 +155,7 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi { struct hal_data_8188e *haldata = GET_HAL_DATA(pAdapter); - u8 macid, raid, shortGIrate = false; + u8 macid, raid, short_gi_rate = false; macid = arg & 0x1f; @@ -167,13 +167,13 @@ void rtl8188e_Add_RateATid(struct adapter *pAdapter, u32 bitmap, u8 arg, u8 rssi bitmap |= ((raid << 28) & 0xf0000000); - shortGIrate = (arg & BIT(5)) ? true : false; + short_gi_rate = (arg & BIT(5)) ? true : false; raid = (bitmap >> 28) & 0x0f; bitmap &= 0x0fffffff; - ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, macid, raid, bitmap, shortGIrate); + ODM_RA_UpdateRateInfo_8188E(&haldata->odmpriv, macid, raid, bitmap, short_gi_rate); } void rtl8188e_set_FwPwrMode_cmd(struct adapter *adapt, u8 Mode) -- cgit v1.2.3 From e8bcb4820ac55615ffe4c9730bde75140233fbaa Mon Sep 17 00:00:00 2001 From: "Gustavo A. R. Silva" Date: Wed, 18 Aug 2021 17:14:18 -0500 Subject: staging: r8188eu: Fix fall-through warnings for Clang Fix the following fallthrough warnings: drivers/staging/r8188eu/core/rtw_mlme_ext.c:1498:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] drivers/staging/r8188eu/core/rtw_wlan_util.c:1113:4: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] drivers/staging/r8188eu/core/rtw_wlan_util.c:1147:4: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] drivers/staging/r8188eu/core/rtw_wlan_util.c:1405:3: warning: unannotated fall-through between switch labels [-Wimplicit-fallthrough] This helps with the ongoing efforts to globally enable -Wimplicit-fallthrough for Clang. Link: https://github.com/KSPP/linux/issues/115 Reviewed-by: Nathan Chancellor Signed-off-by: Gustavo A. R. Silva Link: https://lore.kernel.org/r/20210818221418.GA311735@embeddedor Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 1 + drivers/staging/r8188eu/core/rtw_wlan_util.c | 3 +++ 2 files changed, 4 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index f6ee72d5af09..5325fe41fbee 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -1495,6 +1495,7 @@ unsigned int OnAssocRsp(struct adapter *padapter, struct recv_frame *precv_frame break; case _ERPINFO_IE_: ERP_IE_handler(padapter, pIE); + break; default: break; } diff --git a/drivers/staging/r8188eu/core/rtw_wlan_util.c b/drivers/staging/r8188eu/core/rtw_wlan_util.c index 0cc53781c442..a3a5e1c64c4a 100644 --- a/drivers/staging/r8188eu/core/rtw_wlan_util.c +++ b/drivers/staging/r8188eu/core/rtw_wlan_util.c @@ -1110,6 +1110,7 @@ unsigned int is_ap_in_tkip(struct adapter *padapter) case _RSN_IE_2_: if (!memcmp((pIE->data + 8), RSN_TKIP_CIPHER, 4)) return true; + break; default: break; } @@ -1144,6 +1145,7 @@ unsigned int should_forbid_n_rate(struct adapter *padapter) if ((!memcmp((pIE->data + 8), RSN_CIPHER_SUITE_CCMP, 4)) || (!memcmp((pIE->data + 12), RSN_CIPHER_SUITE_CCMP, 4))) return false; + break; default: break; } @@ -1401,6 +1403,7 @@ unsigned char check_assoc_AP(u8 *pframe, uint len) } else { break; } + break; default: break; -- cgit v1.2.3 From 2f0f1ec2bd0d3d77c3002aac1ffbda655e3b060c Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:42:48 +0100 Subject: staging: r8188eu: remove _dbg_dump_tx_info function Remove _dbg_dump_tx_info from hal/rtl8188e_xmit.c as it is just a dumping function that contains a lot of unclear DBG_88E calls, and has no other external effect, other than calling a function that ultimately determines whether or not to dump/trigger the DBG_88E calls. Also remove its declaration and single call site. Acked-by: Fabio M. De Francesco Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234253.208271-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_xmit.c | 31 ------------------------- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 1 - drivers/staging/r8188eu/include/rtl8188e_xmit.h | 3 --- 3 files changed, 35 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c index 164ec6650dec..d2b55d581f95 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c @@ -42,34 +42,3 @@ void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) RTW_SCTX_DONE_CCX_PKT_FAIL); } } - -void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, - struct tx_desc *ptxdesc) -{ - u8 dmp_txpkt; - bool dump_txdesc = false; - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(dmp_txpkt)); - - if (dmp_txpkt == 1) {/* dump txdesc for data frame */ - DBG_88E("dump tx_desc for data frame\n"); - if ((frame_tag & 0x0f) == DATA_FRAMETAG) - dump_txdesc = true; - } else if (dmp_txpkt == 2) {/* dump txdesc for mgnt frame */ - DBG_88E("dump tx_desc for mgnt frame\n"); - if ((frame_tag & 0x0f) == MGNT_FRAMETAG) - dump_txdesc = true; - } - - if (dump_txdesc) { - DBG_88E("=====================================\n"); - DBG_88E("txdw0(0x%08x)\n", ptxdesc->txdw0); - DBG_88E("txdw1(0x%08x)\n", ptxdesc->txdw1); - DBG_88E("txdw2(0x%08x)\n", ptxdesc->txdw2); - DBG_88E("txdw3(0x%08x)\n", ptxdesc->txdw3); - DBG_88E("txdw4(0x%08x)\n", ptxdesc->txdw4); - DBG_88E("txdw5(0x%08x)\n", ptxdesc->txdw5); - DBG_88E("txdw6(0x%08x)\n", ptxdesc->txdw6); - DBG_88E("txdw7(0x%08x)\n", ptxdesc->txdw7); - DBG_88E("=====================================\n"); - } -} diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index 50c4b9382761..b279309405a2 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -330,7 +330,6 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ODM_SetTxAntByTxInfo_88E(&haldata->odmpriv, pmem, pattrib->mac_id); rtl8188eu_cal_txdesc_chksum(ptxdesc); - _dbg_dump_tx_info(adapt, pxmitframe->frame_tag, ptxdesc); return pull; } diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index ff8b73441c52..d2099da1a41a 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -153,7 +153,4 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, void dump_txrpt_ccx_88e(void *buf); void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); -void _dbg_dump_tx_info(struct adapter *padapter, int frame_tag, - struct tx_desc *ptxdesc); - #endif /* __RTL8188E_XMIT_H__ */ -- cgit v1.2.3 From ff901b60e7521d0294545dd4aa8f404efed18231 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:42:49 +0100 Subject: staging: r8188eu: remove unused function dump_txrpt_ccx_88e Remove unused function dump_txrpt_ccx_88e from hal/rtl8188e_xmit.c and remove its declaration in include/rtl8188e_xmit.h, as this function is not called from anywhere, and is thus dead code. Acked-by: Fabio M. De Francesco Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234253.208271-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188e_xmit.c | 22 ---------------------- drivers/staging/r8188eu/include/rtl8188e_xmit.h | 1 - 2 files changed, 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c index d2b55d581f95..46b871f3f631 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_xmit.c @@ -7,28 +7,6 @@ #include "../include/drv_types.h" #include "../include/rtl8188e_hal.h" -void dump_txrpt_ccx_88e(void *buf) -{ - struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; - - DBG_88E("%s:\n" - "tag1:%u, pkt_num:%u, txdma_underflow:%u, int_bt:%u, int_tri:%u, int_ccx:%u\n" - "mac_id:%u, pkt_ok:%u, bmc:%u\n" - "retry_cnt:%u, lifetime_over:%u, retry_over:%u\n" - "ccx_qtime:%u\n" - "final_data_rate:0x%02x\n" - "qsel:%u, sw:0x%03x\n", - __func__, txrpt_ccx->tag1, txrpt_ccx->pkt_num, - txrpt_ccx->txdma_underflow, txrpt_ccx->int_bt, - txrpt_ccx->int_tri, txrpt_ccx->int_ccx, - txrpt_ccx->mac_id, txrpt_ccx->pkt_ok, txrpt_ccx->bmc, - txrpt_ccx->retry_cnt, txrpt_ccx->lifetime_over, - txrpt_ccx->retry_over, txrpt_ccx_qtime_88e(txrpt_ccx), - txrpt_ccx->final_data_rate, txrpt_ccx->qsel, - txrpt_ccx_sw_88e(txrpt_ccx) - ); -} - void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf) { struct txrpt_ccx_88e *txrpt_ccx = (struct txrpt_ccx_88e *)buf; diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index d2099da1a41a..20b55e3850ba 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -150,7 +150,6 @@ s32 rtl8188eu_xmitframe_complete(struct adapter *padapter, struct xmit_priv *pxmitpriv, struct xmit_buf *pxmitbuf); -void dump_txrpt_ccx_88e(void *buf); void handle_txrpt_ccx_88e(struct adapter *adapter, u8 *buf); #endif /* __RTL8188E_XMIT_H__ */ -- cgit v1.2.3 From c05d31893f700ea508e7c82d458375456ad287dd Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:42:50 +0100 Subject: staging: r8188eu: remove txrpt_ccx_sw_88e and txrpt_ccx_qtime_88e macros Remove txrpt_ccx_sw_88e and txrpt_ccx_qtime_88e macro definitions from include/rtl8188e_xmit.h, as these were only called from the now removed dump_txrpt_ccx_88e function, which was itself not called from anywhere anyway. Acked-by: Fabio M. De Francesco Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234253.208271-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtl8188e_xmit.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index 20b55e3850ba..e7eb19c4ee9d 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -133,10 +133,6 @@ struct txrpt_ccx_88e { u8 sw0; }; -#define txrpt_ccx_sw_88e(txrpt_ccx) ((txrpt_ccx)->sw0 + ((txrpt_ccx)->sw1<<8)) -#define txrpt_ccx_qtime_88e(txrpt_ccx) \ - ((txrpt_ccx)->ccx_qtime0+((txrpt_ccx)->ccx_qtime1<<8)) - void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); -- cgit v1.2.3 From 23b752dfa305bfc98685ee288b805615ab284482 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:42:51 +0100 Subject: staging: r8188eu: remove empty function rtl8188eu_free_xmit_priv Remove empty function rtl8188eu_free_xmit_priv from hal/rtl8188eu_xmit.c and its declaration from include/rtl8188e_xmit.h, as well as the one place where it is stored in the free_xmit_priv function pointer of the HalFunc struct inside padapter. This is safe, as the wrapper function checks for NULL before calling this function via the function pointer. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234253.208271-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 4 ---- drivers/staging/r8188eu/hal/usb_halinit.c | 1 - drivers/staging/r8188eu/include/rtl8188e_xmit.h | 1 - 3 files changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index b279309405a2..d22b16cc5a30 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -19,10 +19,6 @@ s32 rtl8188eu_init_xmit_priv(struct adapter *adapt) return _SUCCESS; } -void rtl8188eu_free_xmit_priv(struct adapter *adapt) -{ -} - static u8 urb_zero_packet_chk(struct adapter *adapt, int sz) { u8 set_tx_desc_offset; diff --git a/drivers/staging/r8188eu/hal/usb_halinit.c b/drivers/staging/r8188eu/hal/usb_halinit.c index 2cd835cb90f6..5cdabf43d4fd 100644 --- a/drivers/staging/r8188eu/hal/usb_halinit.c +++ b/drivers/staging/r8188eu/hal/usb_halinit.c @@ -2243,7 +2243,6 @@ void rtl8188eu_set_hal_ops(struct adapter *adapt) halfunc->inirp_deinit = &rtl8188eu_inirp_deinit; halfunc->init_xmit_priv = &rtl8188eu_init_xmit_priv; - halfunc->free_xmit_priv = &rtl8188eu_free_xmit_priv; halfunc->init_recv_priv = &rtl8188eu_init_recv_priv; halfunc->free_recv_priv = &rtl8188eu_free_recv_priv; diff --git a/drivers/staging/r8188eu/include/rtl8188e_xmit.h b/drivers/staging/r8188eu/include/rtl8188e_xmit.h index e7eb19c4ee9d..f1f2ccfc765e 100644 --- a/drivers/staging/r8188eu/include/rtl8188e_xmit.h +++ b/drivers/staging/r8188eu/include/rtl8188e_xmit.h @@ -136,7 +136,6 @@ struct txrpt_ccx_88e { void rtl8188e_fill_fake_txdesc(struct adapter *padapter, u8 *pDesc, u32 BufferLen, u8 IsPsPoll, u8 IsBTQosNull); s32 rtl8188eu_init_xmit_priv(struct adapter *padapter); -void rtl8188eu_free_xmit_priv(struct adapter *padapter); s32 rtl8188eu_hal_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_mgnt_xmit(struct adapter *padapter, struct xmit_frame *frame); s32 rtl8188eu_xmit_buf_handler(struct adapter *padapter); -- cgit v1.2.3 From c5de6c20dd79d774a486958c582d8ef0bc211ab7 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:42:52 +0100 Subject: staging: r8188eu: remove function rtw_hal_free_xmit_priv Remove function rtw_hal_free_xmit_priv in hal/hal_intf.c and its declaration in include/hal_intf.h, as well as the single call line in core/rtw_xmit.c. This function now essentially checks a function pointer which will always be NULL (due to previous patches) and therefore will never be called. Acked-by: Fabio M. De Francesco Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234253.208271-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 2 -- drivers/staging/r8188eu/hal/hal_intf.c | 6 ------ drivers/staging/r8188eu/include/hal_intf.h | 1 - 3 files changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index cdfcf94e4986..69f997f44c07 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -220,8 +220,6 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - rtw_hal_free_xmit_priv(padapter); - rtw_mfree_xmit_priv_lock(pxmitpriv); if (!pxmitpriv->pxmit_frame_buf) diff --git a/drivers/staging/r8188eu/hal/hal_intf.c b/drivers/staging/r8188eu/hal/hal_intf.c index 47af081bafcd..a6d589e89aeb 100644 --- a/drivers/staging/r8188eu/hal/hal_intf.c +++ b/drivers/staging/r8188eu/hal/hal_intf.c @@ -226,12 +226,6 @@ s32 rtw_hal_init_xmit_priv(struct adapter *adapt) return _FAIL; } -void rtw_hal_free_xmit_priv(struct adapter *adapt) -{ - if (adapt->HalFunc.free_xmit_priv) - adapt->HalFunc.free_xmit_priv(adapt); -} - s32 rtw_hal_init_recv_priv(struct adapter *adapt) { if (adapt->HalFunc.init_recv_priv) diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index 37ddb9745350..8a2420095b84 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -356,7 +356,6 @@ s32 rtw_hal_mgnt_xmit(struct adapter *padapter, struct xmit_frame *pmgntframe); s32 rtw_hal_init_xmit_priv(struct adapter *padapter); -void rtw_hal_free_xmit_priv(struct adapter *padapter); s32 rtw_hal_init_recv_priv(struct adapter *padapter); void rtw_hal_free_recv_priv(struct adapter *padapter); -- cgit v1.2.3 From b1d0ebf2ed849635e155cc97ea024659c4b21f1a Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:42:53 +0100 Subject: staging: r8188eu: remove free_xmit_priv field from struct hal_ops Remove free_xmit_priv function pointer field from struct hal_ops definition in include/hal_intf.h, as it is now no longer used anywhere in the driver. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234253.208271-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/hal_intf.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/hal_intf.h b/drivers/staging/r8188eu/include/hal_intf.h index 8a2420095b84..fa252540e596 100644 --- a/drivers/staging/r8188eu/include/hal_intf.h +++ b/drivers/staging/r8188eu/include/hal_intf.h @@ -139,7 +139,6 @@ struct hal_ops { u32 (*inirp_deinit)(struct adapter *padapter); s32 (*init_xmit_priv)(struct adapter *padapter); - void (*free_xmit_priv)(struct adapter *padapter); s32 (*init_recv_priv)(struct adapter *padapter); void (*free_recv_priv)(struct adapter *padapter); -- cgit v1.2.3 From 5349ef4fd59f787feadc44629d4ecf6cad42e312 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:47 +0100 Subject: staging: r8188eu: convert only rtw_vmalloc call to vmalloc Convert the only call to rtw_vmalloc in os_dep/ioctl_linux.c to the kernel's existing vmalloc function, as rtw_malloc is just a preprocessor definition for _rtw_vmalloc. The _rtw_vmalloc function is defined inline and returns a u8, wrapping standard vmalloc. This behaviour is not necessary. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-2-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index c0e66c194952..ab4a9200f079 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -4481,7 +4481,7 @@ static int rtw_wx_set_priv(struct net_device *dev, return -EFAULT; len = dwrq->length; - ext = rtw_vmalloc(len); + ext = vmalloc(len); if (!ext) return -ENOMEM; -- cgit v1.2.3 From 07f1a10d30e382fcb370b1b7b98ea48af13087c5 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:48 +0100 Subject: staging: r8188eu: remove rtw_vmalloc preprocessor definition Remove rtw_vmalloc preprocessor definition from include/osdep_service.h as it now has no callers. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-3-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 157ffe46c3d2..a9f147cd42fe 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -173,7 +173,6 @@ extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) u8 *_rtw_vmalloc(u32 sz); u8 *_rtw_zvmalloc(u32 sz); -#define rtw_vmalloc(sz) _rtw_vmalloc((sz)) #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) void *rtw_malloc2d(int h, int w, int size); -- cgit v1.2.3 From c29e42afe91980f930b560dad24215569fa64f4a Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:49 +0100 Subject: staging: r8188eu: remove function _rtw_vmalloc Remove the function _rtw_vmalloc from os_dep/osdep_service.c, converting its only user (also in os_dep/osdep_service.c) to use plain vmalloc. This function is just an inline wrapper around vmalloc which returns a u8 pointer, which isn't needed. Also remove the declaration from include/osdep_service.h. It is considered generally bad practice to declare functions as inline in the majority of cases, as not only can this qualifier be ignored by the compiler but the compiler generally makes good decisions about inlining anyway. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-4-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 9 +-------- 2 files changed, 1 insertion(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index a9f147cd42fe..4c00adeb72ee 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -171,7 +171,6 @@ extern unsigned char WPA_TKIP_CIPHER[4]; extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) -u8 *_rtw_vmalloc(u32 sz); u8 *_rtw_zvmalloc(u32 sz); #define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 6218a9052ee9..800f493f1000 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -36,17 +36,10 @@ u32 rtw_atoi(u8 *s) return num; } -inline u8 *_rtw_vmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = vmalloc(sz); - return pbuf; -} - inline u8 *_rtw_zvmalloc(u32 sz) { u8 *pbuf; - pbuf = _rtw_vmalloc(sz); + pbuf = vmalloc(sz); if (pbuf) memset(pbuf, 0, sz); return pbuf; -- cgit v1.2.3 From 11d5fd313b8f99780ab631afe3b1e003028d345b Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:50 +0100 Subject: staging: r8188eu: convert all rtw_zvmalloc calls to vzalloc calls Convert all rtw_zvmalloc calls within the driver to use the existing kernel vzalloc function, which has the same semantics. Also rewrite the two places where it is mentioned in comments to say vzalloc, and remove the redundant cast to struct adapter * in ./os_dep/usb_intf.c as vzalloc returns void *. The reason for the conversion is that rtw_zvmalloc is just a preprocessor definition for _rtw_zvmalloc which itself is just an inline wrapper around vmalloc which then zeroes the memory out. As vzalloc does the same thing via usage of __GFP_ZERO, this code is redundant and can subsequently be removed. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-5-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 4 ++-- drivers/staging/r8188eu/core/rtw_mp.c | 2 +- drivers/staging/r8188eu/core/rtw_recv.c | 2 +- drivers/staging/r8188eu/core/rtw_sta_mgt.c | 2 +- drivers/staging/r8188eu/core/rtw_xmit.c | 8 ++++---- drivers/staging/r8188eu/hal/odm_interface.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/os_dep/osdep_service.c | 2 +- drivers/staging/r8188eu/os_dep/usb_intf.c | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index 858a582e674f..c41312660054 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -38,7 +38,7 @@ int _rtw_init_mlme_priv(struct adapter *padapter) struct mlme_priv *pmlmepriv = &padapter->mlmepriv; int res = _SUCCESS; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ pmlmepriv->nic_hdl = (u8 *)padapter; @@ -55,7 +55,7 @@ int _rtw_init_mlme_priv(struct adapter *padapter) memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - pbuf = rtw_zvmalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); + pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); if (!pbuf) { res = _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 07d9245fa05f..93bb683b628f 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -930,7 +930,7 @@ void _rtw_mp_xmit_priv(struct xmit_priv *pxmitpriv) /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmit_extbuf) { res = _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 0e137aee0aa4..52236bae8693 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -58,7 +58,7 @@ int _rtw_init_recv_priv(struct recv_priv *precvpriv, struct adapter *padapter) rtw_os_recv_resource_init(precvpriv, padapter); - precvpriv->pallocated_frame_buf = rtw_zvmalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); + precvpriv->pallocated_frame_buf = vzalloc(NR_RECVFRAME * sizeof(struct recv_frame) + RXFRAME_ALIGN_SZ); if (!precvpriv->pallocated_frame_buf) { res = _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_sta_mgt.c b/drivers/staging/r8188eu/core/rtw_sta_mgt.c index 9628d095a487..f6dffed53a60 100644 --- a/drivers/staging/r8188eu/core/rtw_sta_mgt.c +++ b/drivers/staging/r8188eu/core/rtw_sta_mgt.c @@ -60,7 +60,7 @@ u32 _rtw_init_sta_priv(struct sta_priv *pstapriv) struct sta_info *psta; s32 i; - pstapriv->pallocated_stainfo_buf = rtw_zvmalloc(sizeof(struct sta_info) * NUM_STA + 4); + pstapriv->pallocated_stainfo_buf = vzalloc(sizeof(struct sta_info) * NUM_STA + 4); if (!pstapriv->pallocated_stainfo_buf) return _FAIL; diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 69f997f44c07..e1de7448771c 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -46,7 +46,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - /* We don't need to memset padapter->XXX to zero, because adapter is allocated by rtw_zvmalloc(). */ + /* We don't need to memset padapter->XXX to zero, because adapter is allocated by vzalloc(). */ spin_lock_init(&pxmitpriv->lock); sema_init(&pxmitpriv->xmit_sema, 0); @@ -72,7 +72,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) Please also apply free_txobj to link_up all the xmit_frames... */ - pxmitpriv->pallocated_frame_buf = rtw_zvmalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); + pxmitpriv->pallocated_frame_buf = vzalloc(NR_XMITFRAME * sizeof(struct xmit_frame) + 4); if (!pxmitpriv->pallocated_frame_buf) { pxmitpriv->pxmit_frame_buf = NULL; @@ -109,7 +109,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) _rtw_init_queue(&pxmitpriv->free_xmitbuf_queue); _rtw_init_queue(&pxmitpriv->pending_xmitbuf_queue); - pxmitpriv->pallocated_xmitbuf = rtw_zvmalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmitbuf = vzalloc(NR_XMITBUFF * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmitbuf) { res = _FAIL; @@ -150,7 +150,7 @@ s32 _rtw_init_xmit_priv(struct xmit_priv *pxmitpriv, struct adapter *padapter) /* Init xmit extension buff */ _rtw_init_queue(&pxmitpriv->free_xmit_extbuf_queue); - pxmitpriv->pallocated_xmit_extbuf = rtw_zvmalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); + pxmitpriv->pallocated_xmit_extbuf = vzalloc(num_xmit_extbuf * sizeof(struct xmit_buf) + 4); if (!pxmitpriv->pallocated_xmit_extbuf) { res = _FAIL; diff --git a/drivers/staging/r8188eu/hal/odm_interface.c b/drivers/staging/r8188eu/hal/odm_interface.c index 239a9703bb34..5a01495d74bc 100644 --- a/drivers/staging/r8188eu/hal/odm_interface.c +++ b/drivers/staging/r8188eu/hal/odm_interface.c @@ -79,7 +79,7 @@ u32 ODM_GetRFReg(struct odm_dm_struct *pDM_Odm, enum rf_radio_path eRFPath, u32 /* ODM Memory relative API. */ void ODM_AllocateMemory(struct odm_dm_struct *pDM_Odm, void **pPtr, u32 length) { - *pPtr = rtw_zvmalloc(length); + *pPtr = vzalloc(length); } /* length could be ignored, used to detect memory leakage. */ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 78e58f9150f3..393969f51206 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -341,7 +341,7 @@ void rtw_IOL_cmd_tx_pkt_buf_dump(struct adapter *Adapter, int data_len) u32 fifo_data, reg_140; u32 addr, rstatus, loop = 0; u16 data_cnts = (data_len / 8) + 1; - u8 *pbuf = rtw_zvmalloc(data_len + 10); + u8 *pbuf = vzalloc(data_len + 10); DBG_88E("###### %s ######\n", __func__); rtw_write8(Adapter, REG_PKT_BUFF_ACCESS_CTRL, TXPKT_BUF_SELECT); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 800f493f1000..8a797bfcb7f5 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -152,7 +152,7 @@ struct net_device *rtw_alloc_etherdev(int sizeof_priv) pnpi = netdev_priv(pnetdev); - pnpi->priv = rtw_zvmalloc(sizeof_priv); + pnpi->priv = vzalloc(sizeof_priv); if (!pnpi->priv) { free_netdev(pnetdev); pnetdev = NULL; diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 0f28ed77ef65..e002070f7fba 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -569,7 +569,7 @@ static struct adapter *rtw_usb_if1_init(struct dvobj_priv *dvobj, struct net_device *pnetdev = NULL; int status = _FAIL; - padapter = (struct adapter *)rtw_zvmalloc(sizeof(*padapter)); + padapter = vzalloc(sizeof(*padapter)); if (!padapter) goto exit; padapter->dvobj = dvobj; -- cgit v1.2.3 From 00d7a5613be546f2b9d4d6d988b14851f8fe2840 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:51 +0100 Subject: staging: r8188eu: remove rtw_zvmalloc preprocessor definition Remove rtw_zvmalloc preprocessor definition from include/osdep_service.h as it now has no callers. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-6-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 - 1 file changed, 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index 4c00adeb72ee..dba7a7bec9d1 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -172,7 +172,6 @@ extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) u8 *_rtw_zvmalloc(u32 sz); -#define rtw_zvmalloc(sz) _rtw_zvmalloc((sz)) void *rtw_malloc2d(int h, int w, int size); -- cgit v1.2.3 From 41b8a938674b5bc9e57aedef9ff104dfc8deeaaf Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:52 +0100 Subject: staging: r8188eu: remove function _rtw_zvmalloc Remove the function _rtw_zvmalloc from os_dep/osdep_service.c, as this function is now unused and is just an inline wrapper around vmalloc which zeroes out the memory. All previous callers have been converted to use vzalloc. Also remove the declaration from include/osdep_service.h. It is considered generally bad practice to declare functions as inline in the majority of cases, as not only can this qualifier be ignored by the compiler but the compiler generally makes good decisions about inlining anyway. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-7-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 1 - drivers/staging/r8188eu/os_dep/osdep_service.c | 9 --------- 2 files changed, 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index dba7a7bec9d1..bda435ca9d08 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -171,7 +171,6 @@ extern unsigned char WPA_TKIP_CIPHER[4]; extern unsigned char RSN_TKIP_CIPHER[4]; #define rtw_update_mem_stat(flag, sz) do {} while (0) -u8 *_rtw_zvmalloc(u32 sz); void *rtw_malloc2d(int h, int w, int size); diff --git a/drivers/staging/r8188eu/os_dep/osdep_service.c b/drivers/staging/r8188eu/os_dep/osdep_service.c index 8a797bfcb7f5..95ac6086370b 100644 --- a/drivers/staging/r8188eu/os_dep/osdep_service.c +++ b/drivers/staging/r8188eu/os_dep/osdep_service.c @@ -36,15 +36,6 @@ u32 rtw_atoi(u8 *s) return num; } -inline u8 *_rtw_zvmalloc(u32 sz) -{ - u8 *pbuf; - pbuf = vmalloc(sz); - if (pbuf) - memset(pbuf, 0, sz); - return pbuf; -} - void *rtw_malloc2d(int h, int w, int size) { int j; -- cgit v1.2.3 From 90356e98100fb4a9eeb230bb159956ac71219335 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Thu, 19 Aug 2021 00:48:53 +0100 Subject: staging: r8188eu: remove rtw_update_mem_stat macro and associated flags Remove the unused rtw_update_mem_stat macro and the associated flags from include/osdep_service.h as this is all dead code. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210818234853.208448-8-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/osdep_service.h | 20 -------------------- 1 file changed, 20 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/osdep_service.h b/drivers/staging/r8188eu/include/osdep_service.h index bda435ca9d08..029aa4e92c9b 100644 --- a/drivers/staging/r8188eu/include/osdep_service.h +++ b/drivers/staging/r8188eu/include/osdep_service.h @@ -146,32 +146,12 @@ static inline void rtw_netif_stop_queue(struct net_device *pnetdev) extern int RTW_STATUS_CODE(int error_code); -/* flags used for rtw_update_mem_stat() */ -enum { - MEM_STAT_VIR_ALLOC_SUCCESS, - MEM_STAT_VIR_ALLOC_FAIL, - MEM_STAT_VIR_FREE, - MEM_STAT_PHY_ALLOC_SUCCESS, - MEM_STAT_PHY_ALLOC_FAIL, - MEM_STAT_PHY_FREE, - MEM_STAT_TX, /* used to distinguish TX/RX, asigned from caller */ - MEM_STAT_TX_ALLOC_SUCCESS, - MEM_STAT_TX_ALLOC_FAIL, - MEM_STAT_TX_FREE, - MEM_STAT_RX, /* used to distinguish TX/RX, asigned from caller */ - MEM_STAT_RX_ALLOC_SUCCESS, - MEM_STAT_RX_ALLOC_FAIL, - MEM_STAT_RX_FREE -}; - extern unsigned char MCS_rate_2R[16]; extern unsigned char MCS_rate_1R[16]; extern unsigned char RTW_WPA_OUI[]; extern unsigned char WPA_TKIP_CIPHER[4]; extern unsigned char RSN_TKIP_CIPHER[4]; -#define rtw_update_mem_stat(flag, sz) do {} while (0) - void *rtw_malloc2d(int h, int w, int size); u32 _rtw_down_sema(struct semaphore *sema); -- cgit v1.2.3 From 093991aaadf0fbb34184fa37a46e7a157da3f386 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Thu, 19 Aug 2021 07:08:08 +0200 Subject: staging: r8188eu: Remove empty rtw_mfree_xmit_priv_lock() Remove rtw_mfree_xmit_priv_lock() because it is empty. Remove its only call from within _rtw_free_xmit_priv(). Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210819050808.28825-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 6 ------ 1 file changed, 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index e1de7448771c..f242f3ffca70 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -207,10 +207,6 @@ exit: return res; } -static void rtw_mfree_xmit_priv_lock(struct xmit_priv *pxmitpriv) -{ -} - void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) { int i; @@ -220,8 +216,6 @@ void _rtw_free_xmit_priv(struct xmit_priv *pxmitpriv) u32 max_xmit_extbuf_size = MAX_XMIT_EXTBUF_SZ; u32 num_xmit_extbuf = NR_XMIT_EXTBUFF; - rtw_mfree_xmit_priv_lock(pxmitpriv); - if (!pxmitpriv->pxmit_frame_buf) return; -- cgit v1.2.3 From 89b9f3f39a088a7a0f833621dc62acb201a37ac5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 19 Aug 2021 11:24:23 +0200 Subject: staging: r8188eu: fix scheduling while atomic bugs These allocations are sometimes done under a spin lock so they have to be atomic. The function call tree is: -> update_beacon() <- takes a spin lock -> update_BCNTIM() -> set_tx_beacon_cmd() Fixes: 79f712ea994de ("staging: r8188eu: Remove wrappers for kalloc() and kzalloc()") Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210819092423.4349-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 5325fe41fbee..508ef1d330a1 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -8130,13 +8130,13 @@ u8 set_tx_beacon_cmd(struct adapter *padapter) u8 res = _SUCCESS; int len_diff = 0; - ph2c = kzalloc(sizeof(struct cmd_obj), GFP_KERNEL); + ph2c = kzalloc(sizeof(struct cmd_obj), GFP_ATOMIC); if (!ph2c) { res = _FAIL; goto exit; } - ptxBeacon_parm = kzalloc(sizeof(struct Tx_Beacon_param), GFP_KERNEL); + ptxBeacon_parm = kzalloc(sizeof(struct Tx_Beacon_param), GFP_ATOMIC); if (!ptxBeacon_parm) { kfree(ph2c); res = _FAIL; -- cgit v1.2.3 From 55cdf7d7b2a187d0c2bcf11ed70e2eeb192713da Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 19 Aug 2021 17:29:14 +0200 Subject: staging: r8188eu: use GFP_ATOMIC under spinlock kmalloc() in function update_bcn_wps_ie() is called under a spinlock so the allocation have to be atomic. -> update_beacon() <- takes a spinlock -> update_bcn_vendor_spec_ie() -> update_bcn_wps_ie() Fixes: 79f712ea994de ("staging: r8188eu: Remove wrappers for kalloc() and kzalloc()") Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210819152914.17482-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 1127e9a52458..9c81cd318e62 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -1293,7 +1293,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) remainder_ielen = ielen - wps_offset - wps_ielen; if (remainder_ielen > 0) { - pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); + pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_ATOMIC); if (pbackup_remainder_ie) memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); } -- cgit v1.2.3 From 6277fbfdd29ca2fbf5da33e3931087b5356c770b Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 19 Aug 2021 10:45:36 -0700 Subject: staging: wlan-ng: Remove pointless a3/a4 union There is no need for the a3/a4 union. The two structs are identical except for the addition of a4. Excepting one place, the structs are only ever used in the union, and the union is always allocated at full size. The one instance of the a3-specific struct can be replaced with the full version, as no sizing information is used. Replace the union with the a4 version of the struct. "diffoscope" reports there are no object code differences after this change. Cc: Allen Pais Cc: Romain Perier Cc: Chen Lin Cc: Ivan Safonov Cc: Arnd Bergmann Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210819174537.3499227-2-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 2 +- drivers/staging/wlan-ng/hfa384x_usb.c | 4 +-- drivers/staging/wlan-ng/p80211conv.c | 48 +++++++++++++++++----------------- drivers/staging/wlan-ng/p80211conv.h | 2 +- drivers/staging/wlan-ng/p80211hdr.h | 16 +----------- drivers/staging/wlan-ng/p80211mgmt.h | 24 ++++++++--------- drivers/staging/wlan-ng/p80211netdev.c | 6 ++--- drivers/staging/wlan-ng/p80211netdev.h | 2 +- drivers/staging/wlan-ng/prism2sta.c | 6 ++--- 9 files changed, 48 insertions(+), 62 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index 88e894dd3568..f1bc1f2816af 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -1423,7 +1423,7 @@ int hfa384x_drvr_start(struct hfa384x *hw); int hfa384x_drvr_stop(struct hfa384x *hw); int hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb, - union p80211_hdr *p80211_hdr, + struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep); void hfa384x_tx_timeout(struct wlandevice *wlandev); diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index f2a0e16b0318..0bf71f395b37 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -2472,7 +2472,7 @@ int hfa384x_drvr_stop(struct hfa384x *hw) *---------------------------------------------------------------- */ int hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb, - union p80211_hdr *p80211_hdr, + struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep) { int usbpktlen = sizeof(struct hfa384x_tx_frame); @@ -2517,7 +2517,7 @@ int hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb, /* copy the header over to the txdesc */ memcpy(&hw->txbuff.txfrm.desc.frame_control, p80211_hdr, - sizeof(union p80211_hdr)); + sizeof(struct p80211_hdr)); /* if we're using host WEP, increase size by IV+ICV */ if (p80211_wep->data) { diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 0ff5fda81b05..0b3ba03c1f1f 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -106,7 +106,7 @@ static const u8 oui_8021h[] = { 0x00, 0x00, 0xf8 }; *---------------------------------------------------------------- */ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, - struct sk_buff *skb, union p80211_hdr *p80211_hdr, + struct sk_buff *skb, struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep) { __le16 fc; @@ -175,21 +175,21 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, switch (wlandev->macmode) { case WLAN_MACMODE_IBSS_STA: - memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN); - memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN); - memcpy(p80211_hdr->a3.a3, wlandev->bssid, ETH_ALEN); + memcpy(p80211_hdr->a1, &e_hdr.daddr, ETH_ALEN); + memcpy(p80211_hdr->a2, wlandev->netdev->dev_addr, ETH_ALEN); + memcpy(p80211_hdr->a3, wlandev->bssid, ETH_ALEN); break; case WLAN_MACMODE_ESS_STA: fc |= cpu_to_le16(WLAN_SET_FC_TODS(1)); - memcpy(p80211_hdr->a3.a1, wlandev->bssid, ETH_ALEN); - memcpy(p80211_hdr->a3.a2, wlandev->netdev->dev_addr, ETH_ALEN); - memcpy(p80211_hdr->a3.a3, &e_hdr.daddr, ETH_ALEN); + memcpy(p80211_hdr->a1, wlandev->bssid, ETH_ALEN); + memcpy(p80211_hdr->a2, wlandev->netdev->dev_addr, ETH_ALEN); + memcpy(p80211_hdr->a3, &e_hdr.daddr, ETH_ALEN); break; case WLAN_MACMODE_ESS_AP: fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1)); - memcpy(p80211_hdr->a3.a1, &e_hdr.daddr, ETH_ALEN); - memcpy(p80211_hdr->a3.a2, wlandev->bssid, ETH_ALEN); - memcpy(p80211_hdr->a3.a3, &e_hdr.saddr, ETH_ALEN); + memcpy(p80211_hdr->a1, &e_hdr.daddr, ETH_ALEN); + memcpy(p80211_hdr->a2, wlandev->bssid, ETH_ALEN); + memcpy(p80211_hdr->a3, &e_hdr.saddr, ETH_ALEN); break; default: netdev_err(wlandev->netdev, @@ -222,9 +222,9 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, /* skb->nh.raw = skb->data; */ - p80211_hdr->a3.fc = fc; - p80211_hdr->a3.dur = 0; - p80211_hdr->a3.seq = 0; + p80211_hdr->fc = fc; + p80211_hdr->dur = 0; + p80211_hdr->seq = 0; return 0; } @@ -281,7 +281,7 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, unsigned int payload_offset; u8 daddr[ETH_ALEN]; u8 saddr[ETH_ALEN]; - union p80211_hdr *w_hdr; + struct p80211_hdr *w_hdr; struct wlan_ethhdr *e_hdr; struct wlan_llc *e_llc; struct wlan_snap *e_snap; @@ -291,21 +291,21 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, payload_length = skb->len - WLAN_HDR_A3_LEN - WLAN_CRC_LEN; payload_offset = WLAN_HDR_A3_LEN; - w_hdr = (union p80211_hdr *)skb->data; + w_hdr = (struct p80211_hdr *)skb->data; /* setup some vars for convenience */ - fc = le16_to_cpu(w_hdr->a3.fc); + fc = le16_to_cpu(w_hdr->fc); if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 0)) { - ether_addr_copy(daddr, w_hdr->a3.a1); - ether_addr_copy(saddr, w_hdr->a3.a2); + ether_addr_copy(daddr, w_hdr->a1); + ether_addr_copy(saddr, w_hdr->a2); } else if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 1)) { - ether_addr_copy(daddr, w_hdr->a3.a1); - ether_addr_copy(saddr, w_hdr->a3.a3); + ether_addr_copy(daddr, w_hdr->a1); + ether_addr_copy(saddr, w_hdr->a3); } else if ((WLAN_GET_FC_TODS(fc) == 1) && (WLAN_GET_FC_FROMDS(fc) == 0)) { - ether_addr_copy(daddr, w_hdr->a3.a3); - ether_addr_copy(saddr, w_hdr->a3.a2); + ether_addr_copy(daddr, w_hdr->a3); + ether_addr_copy(saddr, w_hdr->a2); } else { payload_offset = WLAN_HDR_A4_LEN; if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) { @@ -313,8 +313,8 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, return 1; } payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN); - ether_addr_copy(daddr, w_hdr->a4.a3); - ether_addr_copy(saddr, w_hdr->a4.a4); + ether_addr_copy(daddr, w_hdr->a3); + ether_addr_copy(saddr, w_hdr->a4); } /* perform de-wep if necessary.. */ diff --git a/drivers/staging/wlan-ng/p80211conv.h b/drivers/staging/wlan-ng/p80211conv.h index 15fd635d9770..63c423507fe8 100644 --- a/drivers/staging/wlan-ng/p80211conv.h +++ b/drivers/staging/wlan-ng/p80211conv.h @@ -154,7 +154,7 @@ struct wlandevice; int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, struct sk_buff *skb); int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, - struct sk_buff *skb, union p80211_hdr *p80211_hdr, + struct sk_buff *skb, struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep); int p80211_stt_findproto(u16 proto); diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index 6564810fd026..93dd8ff1940c 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -148,16 +148,7 @@ /* Generic 802.11 Header types */ -struct p80211_hdr_a3 { - __le16 fc; - u16 dur; - u8 a1[ETH_ALEN]; - u8 a2[ETH_ALEN]; - u8 a3[ETH_ALEN]; - u16 seq; -} __packed; - -struct p80211_hdr_a4 { +struct p80211_hdr { u16 fc; u16 dur; u8 a1[ETH_ALEN]; @@ -167,11 +158,6 @@ struct p80211_hdr_a4 { u8 a4[ETH_ALEN]; } __packed; -union p80211_hdr { - struct p80211_hdr_a3 a3; - struct p80211_hdr_a4 a4; -} __packed; - /* Frame and header length macros */ static inline u16 wlan_ctl_framelen(u16 fstype) diff --git a/drivers/staging/wlan-ng/p80211mgmt.h b/drivers/staging/wlan-ng/p80211mgmt.h index c045c08e1991..1457a6def5a2 100644 --- a/drivers/staging/wlan-ng/p80211mgmt.h +++ b/drivers/staging/wlan-ng/p80211mgmt.h @@ -299,7 +299,7 @@ struct wlan_fr_mgmt { u16 type; u16 len; /* DOES NOT include CRC !!!! */ u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -311,7 +311,7 @@ struct wlan_fr_beacon { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -334,7 +334,7 @@ struct wlan_fr_ibssatim { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; @@ -350,7 +350,7 @@ struct wlan_fr_disassoc { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -365,7 +365,7 @@ struct wlan_fr_assocreq { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -382,7 +382,7 @@ struct wlan_fr_assocresp { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -399,7 +399,7 @@ struct wlan_fr_reassocreq { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -417,7 +417,7 @@ struct wlan_fr_reassocresp { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -434,7 +434,7 @@ struct wlan_fr_probereq { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -449,7 +449,7 @@ struct wlan_fr_proberesp { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -470,7 +470,7 @@ struct wlan_fr_authen { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ @@ -487,7 +487,7 @@ struct wlan_fr_deauthen { u16 type; u16 len; u8 *buf; - union p80211_hdr *hdr; + struct p80211_hdr *hdr; /* used for target specific data, skb in Linux */ void *priv; /*-- fixed fields -----------*/ diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 6f470e7ba647..3a4cc0bc06db 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -235,9 +235,9 @@ void p80211netdev_rx(struct wlandevice *wlandev, struct sk_buff *skb) static int p80211_convert_to_ether(struct wlandevice *wlandev, struct sk_buff *skb) { - struct p80211_hdr_a3 *hdr; + struct p80211_hdr *hdr; - hdr = (struct p80211_hdr_a3 *)skb->data; + hdr = (struct p80211_hdr *)skb->data; if (p80211_rx_typedrop(wlandev, le16_to_cpu(hdr->fc))) return CONV_TO_ETHER_SKIPPED; @@ -327,7 +327,7 @@ static netdev_tx_t p80211knetdev_hard_start_xmit(struct sk_buff *skb, int result = 0; int txresult; struct wlandevice *wlandev = netdev->ml_priv; - union p80211_hdr p80211_hdr; + struct p80211_hdr p80211_hdr; struct p80211_metawep p80211_wep; p80211_wep.data = NULL; diff --git a/drivers/staging/wlan-ng/p80211netdev.h b/drivers/staging/wlan-ng/p80211netdev.h index d48466d943b4..25e5116b1590 100644 --- a/drivers/staging/wlan-ng/p80211netdev.h +++ b/drivers/staging/wlan-ng/p80211netdev.h @@ -180,7 +180,7 @@ struct wlandevice { int (*close)(struct wlandevice *wlandev); void (*reset)(struct wlandevice *wlandev); int (*txframe)(struct wlandevice *wlandev, struct sk_buff *skb, - union p80211_hdr *p80211_hdr, + struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep); int (*mlmerequest)(struct wlandevice *wlandev, struct p80211msg *msg); int (*set_multicast_list)(struct wlandevice *wlandev, diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index e6dcb687e7a1..1f9ba26f1f36 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -103,7 +103,7 @@ static int prism2sta_open(struct wlandevice *wlandev); static int prism2sta_close(struct wlandevice *wlandev); static void prism2sta_reset(struct wlandevice *wlandev); static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb, - union p80211_hdr *p80211_hdr, + struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep); static int prism2sta_mlmerequest(struct wlandevice *wlandev, struct p80211msg *msg); @@ -242,7 +242,7 @@ static void prism2sta_reset(struct wlandevice *wlandev) * process thread */ static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb, - union p80211_hdr *p80211_hdr, + struct p80211_hdr *p80211_hdr, struct p80211_metawep *p80211_wep) { struct hfa384x *hw = wlandev->priv; @@ -250,7 +250,7 @@ static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb, /* If necessary, set the 802.11 WEP bit */ if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { - p80211_hdr->a3.fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1)); + p80211_hdr->fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1)); } return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep); -- cgit v1.2.3 From 86a0727b096dfeb90c10e74b4d6e70c1c237b29a Mon Sep 17 00:00:00 2001 From: Kees Cook Date: Thu, 19 Aug 2021 10:45:37 -0700 Subject: staging: wlan-ng: Avoid duplicate header in tx/rx frames MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of open-coding the same header details in the tx/rx frames, directly include the actual struct. Rename associated variables to the more verbose of the two versions. This also has the benefit of being able to replace a field-spanning memcpy() with a direct assignment, helping clear the way for coming FORTIFY_SOURCE improvements. "diffoscope" reports no object code differences after this change, excepting the selection of different registers when switching from memcpy() to direct assignment: --- drivers/staging/wlan-ng/prism2usb.o.before +++ drivers/staging/wlan-ng/prism2usb.o.after ├── objdump --line-numbers --disassemble --demangle --reloc --no-show-raw-insn --section=.text {} │ @@ -4887,24 +4887,24 @@ │ sub %rdi,%rcx │ add $0x3c,%ecx │ shr $0x3,%ecx │ rep stos %rax,%es:(%rdi) │ mov $0x8,%eax │ movl $0x123,0x23e(%rbx) │ mov %ax,0x244(%rbx) │ - mov (%rdx),%rcx │ - mov %rcx,0x246(%rbx) │ - mov 0x8(%rdx),%rcx │ - mov %rcx,0x24e(%rbx) │ - mov 0x10(%rdx),%rcx │ - mov %rcx,0x256(%rbx) │ - mov 0x18(%rdx),%ecx │ - mov %ecx,0x25e(%rbx) │ - movzwl 0x1c(%rdx),%edx │ - mov %dx,0x262(%rbx) │ + mov (%rdx),%rax │ + mov %rax,0x246(%rbx) │ + mov 0x8(%rdx),%rax │ + mov %rax,0x24e(%rbx) │ + mov 0x10(%rdx),%rax │ + mov %rax,0x256(%rbx) │ + mov 0x18(%rdx),%eax │ + mov %eax,0x25e(%rbx) │ + movzwl 0x1c(%rdx),%eax │ + mov %ax,0x262(%rbx) │ cmpq $0x0,0x0(%rbp) │ movzwl 0x70(%rsi),%eax │ je 477a │ add $0x8,%eax │ mov $0x44,%r12d │ mov %ax,0x264(%rbx) │ mov 0x70(%r13),%edx Cc: Romain Perier Cc: Allen Pais Cc: Ivan Safonov Cc: Arnd Bergmann Cc: linux-staging@lists.linux.dev Signed-off-by: Kees Cook Link: https://lore.kernel.org/r/20210819174537.3499227-3-keescook@chromium.org Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/hfa384x.h | 17 ++------------ drivers/staging/wlan-ng/hfa384x_usb.c | 11 ++++----- drivers/staging/wlan-ng/p80211conv.c | 42 +++++++++++++++++----------------- drivers/staging/wlan-ng/p80211hdr.h | 14 ++++++------ drivers/staging/wlan-ng/p80211netdev.c | 6 ++--- drivers/staging/wlan-ng/prism2sta.c | 2 +- 6 files changed, 39 insertions(+), 53 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/hfa384x.h b/drivers/staging/wlan-ng/hfa384x.h index f1bc1f2816af..75ed8bc4bbc1 100644 --- a/drivers/staging/wlan-ng/hfa384x.h +++ b/drivers/staging/wlan-ng/hfa384x.h @@ -475,14 +475,7 @@ struct hfa384x_tx_frame { u16 tx_control; /*-- 802.11 Header Information --*/ - - u16 frame_control; - u16 duration_id; - u8 address1[6]; - u8 address2[6]; - u8 address3[6]; - u16 sequence_control; - u8 address4[6]; + struct p80211_hdr hdr; __le16 data_len; /* little endian format */ /*-- 802.3 Header Information --*/ @@ -541,13 +534,7 @@ struct hfa384x_rx_frame { u16 reserved2; /*-- 802.11 Header Information (802.11 byte order) --*/ - __le16 frame_control; - u16 duration_id; - u8 address1[6]; - u8 address2[6]; - u8 address3[6]; - u16 sequence_control; - u8 address4[6]; + struct p80211_hdr hdr; __le16 data_len; /* hfa384x (little endian) format */ /*-- 802.3 Header Information --*/ diff --git a/drivers/staging/wlan-ng/hfa384x_usb.c b/drivers/staging/wlan-ng/hfa384x_usb.c index 0bf71f395b37..8c8524679ba3 100644 --- a/drivers/staging/wlan-ng/hfa384x_usb.c +++ b/drivers/staging/wlan-ng/hfa384x_usb.c @@ -2516,8 +2516,7 @@ int hfa384x_drvr_txframe(struct hfa384x *hw, struct sk_buff *skb, cpu_to_le16s(&hw->txbuff.txfrm.desc.tx_control); /* copy the header over to the txdesc */ - memcpy(&hw->txbuff.txfrm.desc.frame_control, p80211_hdr, - sizeof(struct p80211_hdr)); + hw->txbuff.txfrm.desc.hdr = *p80211_hdr; /* if we're using host WEP, increase size by IV+ICV */ if (p80211_wep->data) { @@ -3258,7 +3257,7 @@ static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb) switch (status) { case 0: - fc = le16_to_cpu(usbin->rxfrm.desc.frame_control); + fc = le16_to_cpu(usbin->rxfrm.desc.hdr.frame_control); /* If exclude and we receive an unencrypted, drop it */ if ((wlandev->hostwep & HOSTWEP_EXCLUDEUNENCRYPTED) && @@ -3278,7 +3277,7 @@ static void hfa384x_usbin_rx(struct wlandevice *wlandev, struct sk_buff *skb) * with an "overlapping" copy */ memmove(skb_push(skb, hdrlen), - &usbin->rxfrm.desc.frame_control, hdrlen); + &usbin->rxfrm.desc.hdr, hdrlen); skb->dev = wlandev->netdev; @@ -3356,7 +3355,7 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev, /* Remember the status, time, and data_len fields are in host order */ /* Figure out how big the frame is */ - fc = le16_to_cpu(rxdesc->frame_control); + fc = le16_to_cpu(rxdesc->hdr.frame_control); hdrlen = p80211_headerlen(fc); datalen = le16_to_cpu(rxdesc->data_len); @@ -3404,7 +3403,7 @@ static void hfa384x_int_rxmonitor(struct wlandevice *wlandev, /* Copy the 802.11 header to the skb * (ctl frames may be less than a full header) */ - skb_put_data(skb, &rxdesc->frame_control, hdrlen); + skb_put_data(skb, &rxdesc->hdr.frame_control, hdrlen); /* If any, copy the data from the card to the skb */ if (datalen > 0) { diff --git a/drivers/staging/wlan-ng/p80211conv.c b/drivers/staging/wlan-ng/p80211conv.c index 0b3ba03c1f1f..59b25ca50d15 100644 --- a/drivers/staging/wlan-ng/p80211conv.c +++ b/drivers/staging/wlan-ng/p80211conv.c @@ -175,21 +175,21 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, switch (wlandev->macmode) { case WLAN_MACMODE_IBSS_STA: - memcpy(p80211_hdr->a1, &e_hdr.daddr, ETH_ALEN); - memcpy(p80211_hdr->a2, wlandev->netdev->dev_addr, ETH_ALEN); - memcpy(p80211_hdr->a3, wlandev->bssid, ETH_ALEN); + memcpy(p80211_hdr->address1, &e_hdr.daddr, ETH_ALEN); + memcpy(p80211_hdr->address2, wlandev->netdev->dev_addr, ETH_ALEN); + memcpy(p80211_hdr->address3, wlandev->bssid, ETH_ALEN); break; case WLAN_MACMODE_ESS_STA: fc |= cpu_to_le16(WLAN_SET_FC_TODS(1)); - memcpy(p80211_hdr->a1, wlandev->bssid, ETH_ALEN); - memcpy(p80211_hdr->a2, wlandev->netdev->dev_addr, ETH_ALEN); - memcpy(p80211_hdr->a3, &e_hdr.daddr, ETH_ALEN); + memcpy(p80211_hdr->address1, wlandev->bssid, ETH_ALEN); + memcpy(p80211_hdr->address2, wlandev->netdev->dev_addr, ETH_ALEN); + memcpy(p80211_hdr->address3, &e_hdr.daddr, ETH_ALEN); break; case WLAN_MACMODE_ESS_AP: fc |= cpu_to_le16(WLAN_SET_FC_FROMDS(1)); - memcpy(p80211_hdr->a1, &e_hdr.daddr, ETH_ALEN); - memcpy(p80211_hdr->a2, wlandev->bssid, ETH_ALEN); - memcpy(p80211_hdr->a3, &e_hdr.saddr, ETH_ALEN); + memcpy(p80211_hdr->address1, &e_hdr.daddr, ETH_ALEN); + memcpy(p80211_hdr->address2, wlandev->bssid, ETH_ALEN); + memcpy(p80211_hdr->address3, &e_hdr.saddr, ETH_ALEN); break; default: netdev_err(wlandev->netdev, @@ -222,9 +222,9 @@ int skb_ether_to_p80211(struct wlandevice *wlandev, u32 ethconv, /* skb->nh.raw = skb->data; */ - p80211_hdr->fc = fc; - p80211_hdr->dur = 0; - p80211_hdr->seq = 0; + p80211_hdr->frame_control = fc; + p80211_hdr->duration_id = 0; + p80211_hdr->sequence_control = 0; return 0; } @@ -294,18 +294,18 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, w_hdr = (struct p80211_hdr *)skb->data; /* setup some vars for convenience */ - fc = le16_to_cpu(w_hdr->fc); + fc = le16_to_cpu(w_hdr->frame_control); if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 0)) { - ether_addr_copy(daddr, w_hdr->a1); - ether_addr_copy(saddr, w_hdr->a2); + ether_addr_copy(daddr, w_hdr->address1); + ether_addr_copy(saddr, w_hdr->address2); } else if ((WLAN_GET_FC_TODS(fc) == 0) && (WLAN_GET_FC_FROMDS(fc) == 1)) { - ether_addr_copy(daddr, w_hdr->a1); - ether_addr_copy(saddr, w_hdr->a3); + ether_addr_copy(daddr, w_hdr->address1); + ether_addr_copy(saddr, w_hdr->address3); } else if ((WLAN_GET_FC_TODS(fc) == 1) && (WLAN_GET_FC_FROMDS(fc) == 0)) { - ether_addr_copy(daddr, w_hdr->a3); - ether_addr_copy(saddr, w_hdr->a2); + ether_addr_copy(daddr, w_hdr->address3); + ether_addr_copy(saddr, w_hdr->address2); } else { payload_offset = WLAN_HDR_A4_LEN; if (payload_length < WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN) { @@ -313,8 +313,8 @@ int skb_p80211_to_ether(struct wlandevice *wlandev, u32 ethconv, return 1; } payload_length -= (WLAN_HDR_A4_LEN - WLAN_HDR_A3_LEN); - ether_addr_copy(daddr, w_hdr->a3); - ether_addr_copy(saddr, w_hdr->a4); + ether_addr_copy(daddr, w_hdr->address3); + ether_addr_copy(saddr, w_hdr->address4); } /* perform de-wep if necessary.. */ diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index 93dd8ff1940c..dd1fb99bf340 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -149,13 +149,13 @@ /* Generic 802.11 Header types */ struct p80211_hdr { - u16 fc; - u16 dur; - u8 a1[ETH_ALEN]; - u8 a2[ETH_ALEN]; - u8 a3[ETH_ALEN]; - u16 seq; - u8 a4[ETH_ALEN]; + u16 frame_control; + u16 duration_id; + u8 address1[ETH_ALEN]; + u8 address2[ETH_ALEN]; + u8 address3[ETH_ALEN]; + u16 sequence_control; + u8 address4[ETH_ALEN]; } __packed; /* Frame and header length macros */ diff --git a/drivers/staging/wlan-ng/p80211netdev.c b/drivers/staging/wlan-ng/p80211netdev.c index 3a4cc0bc06db..0905602ef8ff 100644 --- a/drivers/staging/wlan-ng/p80211netdev.c +++ b/drivers/staging/wlan-ng/p80211netdev.c @@ -238,7 +238,7 @@ static int p80211_convert_to_ether(struct wlandevice *wlandev, struct p80211_hdr *hdr; hdr = (struct p80211_hdr *)skb->data; - if (p80211_rx_typedrop(wlandev, le16_to_cpu(hdr->fc))) + if (p80211_rx_typedrop(wlandev, le16_to_cpu(hdr->frame_control))) return CONV_TO_ETHER_SKIPPED; /* perform mcast filtering: allow my local address through but reject @@ -246,8 +246,8 @@ static int p80211_convert_to_ether(struct wlandevice *wlandev, */ if (wlandev->netdev->flags & IFF_ALLMULTI) { if (!ether_addr_equal_unaligned(wlandev->netdev->dev_addr, - hdr->a1)) { - if (!is_multicast_ether_addr(hdr->a1)) + hdr->address1)) { + if (!is_multicast_ether_addr(hdr->address1)) return CONV_TO_ETHER_SKIPPED; } } diff --git a/drivers/staging/wlan-ng/prism2sta.c b/drivers/staging/wlan-ng/prism2sta.c index 1f9ba26f1f36..f67b7405156a 100644 --- a/drivers/staging/wlan-ng/prism2sta.c +++ b/drivers/staging/wlan-ng/prism2sta.c @@ -250,7 +250,7 @@ static int prism2sta_txframe(struct wlandevice *wlandev, struct sk_buff *skb, /* If necessary, set the 802.11 WEP bit */ if ((wlandev->hostwep & (HOSTWEP_PRIVACYINVOKED | HOSTWEP_ENCRYPT)) == HOSTWEP_PRIVACYINVOKED) { - p80211_hdr->fc |= cpu_to_le16(WLAN_SET_FC_ISWEP(1)); + p80211_hdr->frame_control |= cpu_to_le16(WLAN_SET_FC_ISWEP(1)); } return hfa384x_drvr_txframe(hw, skb, p80211_hdr, p80211_wep); -- cgit v1.2.3 From 30e98ce81bbb51f78134dbeca232f1d4ab215434 Mon Sep 17 00:00:00 2001 From: Yang Li Date: Fri, 20 Aug 2021 17:08:25 +0800 Subject: staging: r8188eu: remove unneeded semicolon Eliminate the following coccicheck warning: ./drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c:73:66-67: Unneeded semicolon ./drivers/staging/r8188eu/hal/rtl8188e_hal_init.c:2225:68-69: Unneeded semicolon ./drivers/staging/r8188eu/core/rtw_xmit.c:615:75-76: Unneeded semicolon Reported-by: Abaci Robot Signed-off-by: Yang Li Link: https://lore.kernel.org/r/1629450505-28247-1-git-send-email-yang.lee@linux.alibaba.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_hal_init.c | 2 +- drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index f242f3ffca70..611dbfb41849 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -604,7 +604,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr else stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); - hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ);; + hw_hdr_offset = TXDESC_SIZE + (pxmitframe->pkt_offset * PACKET_OFFSET_SZ); if (pattrib->encrypt == _TKIP_) {/* if (psecuritypriv->dot11PrivacyAlgrthm == _TKIP_PRIVACY_) */ /* encode mic code */ diff --git a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c index 393969f51206..14758361960c 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_hal_init.c @@ -2222,7 +2222,7 @@ void Hal_ReadAntennaDiversity88E(struct adapter *pAdapter, u8 *PROMContent, bool if (registry_par->antdiv_cfg == 2) { /* 2:By EFUSE */ pHalData->AntDivCfg = (PROMContent[EEPROM_RF_BOARD_OPTION_88E] & 0x18) >> 3; if (PROMContent[EEPROM_RF_BOARD_OPTION_88E] == 0xFF) - pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION & 0x18) >> 3;; + pHalData->AntDivCfg = (EEPROM_DEFAULT_BOARD_OPTION & 0x18) >> 3; } else { pHalData->AntDivCfg = registry_par->antdiv_cfg; /* 0:OFF , 1:ON, 2:By EFUSE */ } diff --git a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c index b4b3c02cb13c..244286789b6d 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_rxdesc.c @@ -70,7 +70,7 @@ void update_recvframe_attrib_88e(struct recv_frame *precvframe, struct recv_stat pattrib = &precvframe->attrib; memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); - pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);;/* u8)prxreport->crc32; */ + pattrib->crc_err = (u8)((le32_to_cpu(report.rxdw0) >> 14) & 0x1);/* u8)prxreport->crc32; */ /* update rx report to recv_frame attribute */ pattrib->pkt_rpt_type = (u8)((le32_to_cpu(report.rxdw3) >> 14) & 0x3);/* prxreport->rpt_sel; */ -- cgit v1.2.3 From fbdbd861c8be66dc6d87f3bdeaec41d7a8efde9a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 19 Aug 2021 13:21:59 +0200 Subject: staging: r8188eu: remove unused function rtw_add_bcn_ie() Function rtw_add_bcn_ie() is not used anywhere, remove it. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210819112200.32030-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 63 -------------------------------- drivers/staging/r8188eu/include/rtw_ap.h | 2 - 2 files changed, 65 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 9c81cd318e62..8c35e7632fd5 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -139,69 +139,6 @@ static void update_BCNTIM(struct adapter *padapter) set_tx_beacon_cmd(padapter); } -void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index, u8 *data, u8 len) -{ - struct ndis_802_11_var_ie *pIE; - u8 bmatch = false; - u8 *pie = pnetwork->IEs; - u8 *p = NULL, *dst_ie = NULL, *premainder_ie = NULL; - u8 *pbackup_remainder_ie = NULL; - u32 i, offset, ielen = 0, ie_offset, remainder_ielen = 0; - - for (i = sizeof(struct ndis_802_11_fixed_ie); i < pnetwork->IELength;) { - pIE = (struct ndis_802_11_var_ie *)(pnetwork->IEs + i); - - if (pIE->ElementID > index) { - break; - } else if (pIE->ElementID == index) { /* already exist the same IE */ - p = (u8 *)pIE; - ielen = pIE->Length; - bmatch = true; - break; - } - p = (u8 *)pIE; - ielen = pIE->Length; - i += (pIE->Length + 2); - } - - if (p && ielen > 0) { - ielen += 2; - - premainder_ie = p + ielen; - - ie_offset = (int)(p - pie); - - remainder_ielen = pnetwork->IELength - ie_offset - ielen; - - if (bmatch) - dst_ie = p; - else - dst_ie = (p + ielen); - } - - if (remainder_ielen > 0) { - pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); - if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); - } - - *dst_ie++ = index; - *dst_ie++ = len; - - memcpy(dst_ie, data, len); - dst_ie += len; - - /* copy remainder IE */ - if (pbackup_remainder_ie) { - memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); - - kfree(pbackup_remainder_ie); - } - - offset = (uint)(dst_ie - pie); - pnetwork->IELength = offset + remainder_ielen; -} - void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index) { u8 *p, *dst_ie = NULL, *premainder_ie = NULL; diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h index b20edab3bb00..fffb6794b1ce 100644 --- a/drivers/staging/r8188eu/include/rtw_ap.h +++ b/drivers/staging/r8188eu/include/rtw_ap.h @@ -16,8 +16,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta); void init_mlme_ap_info(struct adapter *padapter); void free_mlme_ap_info(struct adapter *padapter); -void rtw_add_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, - u8 index, u8 *data, u8 len); void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index); void update_beacon(struct adapter *padapter, u8 ie_id, -- cgit v1.2.3 From a69bbd2f77a6e26b2b1c3d7fcc5c715169dc01c5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Thu, 19 Aug 2021 13:22:00 +0200 Subject: staging: r8188eu: remove unused function rtw_remove_bcn_ie() Function rtw_remove_bcn_ie() is not used anywhere, remove it. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210819112200.32030-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 38 -------------------------------- drivers/staging/r8188eu/include/rtw_ap.h | 2 -- 2 files changed, 40 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 8c35e7632fd5..41b5668d080b 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -139,44 +139,6 @@ static void update_BCNTIM(struct adapter *padapter) set_tx_beacon_cmd(padapter); } -void rtw_remove_bcn_ie(struct adapter *padapter, struct wlan_bssid_ex *pnetwork, u8 index) -{ - u8 *p, *dst_ie = NULL, *premainder_ie = NULL; - u8 *pbackup_remainder_ie = NULL; - uint offset, ielen, ie_offset, remainder_ielen = 0; - u8 *pie = pnetwork->IEs; - - p = rtw_get_ie(pie + _FIXED_IE_LENGTH_, index, &ielen, - pnetwork->IELength - _FIXED_IE_LENGTH_); - if (p && ielen > 0) { - ielen += 2; - - premainder_ie = p + ielen; - - ie_offset = (int)(p - pie); - - remainder_ielen = pnetwork->IELength - ie_offset - ielen; - - dst_ie = p; - } - - if (remainder_ielen > 0) { - pbackup_remainder_ie = kmalloc(remainder_ielen, GFP_KERNEL); - if (pbackup_remainder_ie && premainder_ie) - memcpy(pbackup_remainder_ie, premainder_ie, remainder_ielen); - } - - /* copy remainder IE */ - if (pbackup_remainder_ie) { - memcpy(dst_ie, pbackup_remainder_ie, remainder_ielen); - - kfree(pbackup_remainder_ie); - } - - offset = (uint)(dst_ie - pie); - pnetwork->IELength = offset + remainder_ielen; -} - static u8 chk_sta_is_alive(struct sta_info *psta) { u8 ret = false; diff --git a/drivers/staging/r8188eu/include/rtw_ap.h b/drivers/staging/r8188eu/include/rtw_ap.h index fffb6794b1ce..2eb556968509 100644 --- a/drivers/staging/r8188eu/include/rtw_ap.h +++ b/drivers/staging/r8188eu/include/rtw_ap.h @@ -16,8 +16,6 @@ void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta); void init_mlme_ap_info(struct adapter *padapter); void free_mlme_ap_info(struct adapter *padapter); -void rtw_remove_bcn_ie(struct adapter *padapter, - struct wlan_bssid_ex *pnetwork, u8 index); void update_beacon(struct adapter *padapter, u8 ie_id, u8 *oui, u8 tx); void add_RATid(struct adapter *padapter, struct sta_info *psta, -- cgit v1.2.3 From 7d761b084b3c785e1fbbe707fbdf7baba905c6ad Mon Sep 17 00:00:00 2001 From: Sergio Paracuellos Date: Mon, 23 Aug 2021 19:08:03 +0200 Subject: staging: mt7621-pci: fix hang when nothing is connected to pcie ports When nothing is connected to pcie ports, each port is set to reset state. When this occurs, next access result in a hang on boot as follows: mt7621-pci 1e140000.pcie: pcie0 no card, disable it (RST & CLK) mt7621-pci 1e140000.pcie: pcie1 no card, disable it (RST & CLK) mt7621-pci 1e140000.pcie: pcie2 no card, disable it (RST & CLK) [ HANGS HERE ] Fix this just detecting 'nothing is connected state' to avoid next accesses to pcie port related configuration registers. Fixes: b99cc3a2b6b6 ("staging: mt7621-pci: avoid custom 'map_irq' function") Cc: stable Reported-by: DENG Qingfang Signed-off-by: Sergio Paracuellos Link: https://lore.kernel.org/r/20210823170803.2108-1-sergio.paracuellos@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/mt7621-pci/pci-mt7621.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/mt7621-pci/pci-mt7621.c b/drivers/staging/mt7621-pci/pci-mt7621.c index f9bdf4e33134..6acfc94a16e7 100644 --- a/drivers/staging/mt7621-pci/pci-mt7621.c +++ b/drivers/staging/mt7621-pci/pci-mt7621.c @@ -56,6 +56,7 @@ #define PCIE_BAR_ENABLE BIT(0) #define PCIE_PORT_INT_EN(x) BIT(20 + (x)) #define PCIE_PORT_LINKUP BIT(0) +#define PCIE_PORT_CNT 3 #define PERST_DELAY_MS 100 @@ -388,10 +389,11 @@ static void mt7621_pcie_reset_ep_deassert(struct mt7621_pcie *pcie) msleep(PERST_DELAY_MS); } -static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) +static int mt7621_pcie_init_ports(struct mt7621_pcie *pcie) { struct device *dev = pcie->dev; struct mt7621_pcie_port *port, *tmp; + u8 num_disabled = 0; int err; mt7621_pcie_reset_assert(pcie); @@ -423,6 +425,7 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) slot); mt7621_control_assert(port); port->enabled = false; + num_disabled++; if (slot == 0) { tmp = port; @@ -433,6 +436,8 @@ static void mt7621_pcie_init_ports(struct mt7621_pcie *pcie) phy_power_off(tmp->phy); } } + + return (num_disabled != PCIE_PORT_CNT) ? 0 : -ENODEV; } static void mt7621_pcie_enable_port(struct mt7621_pcie_port *port) @@ -540,7 +545,11 @@ static int mt7621_pci_probe(struct platform_device *pdev) return err; } - mt7621_pcie_init_ports(pcie); + err = mt7621_pcie_init_ports(pcie); + if (err) { + dev_err(dev, "Nothing connected in virtual bridges\n"); + return 0; + } err = mt7621_pcie_enable_ports(bridge); if (err) { -- cgit v1.2.3 From 174ac41a7aafb31041cba3fe54ccd89b9daeef5d Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Mon, 23 Aug 2021 16:11:59 +0200 Subject: staging: rtl8723bs: remove obsolete wext support cfg80211 has been fully implemented so remove all wext and wext private handlers and their registration. Now wext userspace calls can be managed via cfg80211 wext compatibility. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/61c4bb20bbb6ce30e4ddd01aa73de3f686a99445.1629727333.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/Kconfig | 3 +- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 3170 +----------------------- drivers/staging/rtl8723bs/os_dep/os_intfs.c | 1 - 3 files changed, 37 insertions(+), 3137 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/Kconfig b/drivers/staging/rtl8723bs/Kconfig index 7eae820eae3b..f40b3021fe8a 100644 --- a/drivers/staging/rtl8723bs/Kconfig +++ b/drivers/staging/rtl8723bs/Kconfig @@ -3,8 +3,7 @@ config RTL8723BS tristate "Realtek RTL8723BS SDIO Wireless LAN NIC driver" depends on WLAN && MMC && CFG80211 depends on m - select WIRELESS_EXT - select WEXT_PRIV + select CFG80211_WEXT select CRYPTO_LIB_ARC4 help This option enables support for RTL8723BS SDIO drivers, such as diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index e2ab34463182..790e3b2454e8 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -29,9 +29,6 @@ #define WEXT_CSCAN_HOME_DWELL_SECTION 'H' #define WEXT_CSCAN_TYPE_SECTION 'T' -static u32 rtw_rates[] = {1000000, 2000000, 5500000, 11000000, - 6000000, 9000000, 12000000, 18000000, 24000000, 36000000, 48000000, 54000000}; - void indicate_wx_scan_complete_event(struct adapter *padapter) { union iwreq_data wrqu; @@ -70,272 +67,6 @@ void rtw_indicate_wx_disassoc_event(struct adapter *padapter) eth_zero_addr(wrqu.ap_addr.sa_data); } -static char *translate_scan(struct adapter *padapter, - struct iw_request_info *info, struct wlan_network *pnetwork, - char *start, char *stop) -{ - struct iw_event iwe; - u16 cap; - u32 ht_ielen = 0; - char *custom = NULL; - char *p; - u16 max_rate = 0, rate, ht_cap = false, vht_cap = false; - u32 i = 0; - u8 bw_40MHz = 0, short_GI = 0; - u16 mcs_rate = 0, vht_data_rate = 0; - u8 ie_offset = (pnetwork->network.reserved[0] == 2 ? 0 : 12); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 ss, sq; - - /* AP MAC address */ - iwe.cmd = SIOCGIWAP; - iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - - memcpy(iwe.u.ap_addr.sa_data, pnetwork->network.mac_address, ETH_ALEN); - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); - - /* Add the ESSID */ - iwe.cmd = SIOCGIWESSID; - iwe.u.data.flags = 1; - iwe.u.data.length = min((u16)pnetwork->network.ssid.ssid_length, (u16)32); - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); - - /* parsing HT_CAP_IE */ - if (pnetwork->network.reserved[0] == 2) { /* Probe Request */ - p = rtw_get_ie(&pnetwork->network.ies[0], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length); - } else { - p = rtw_get_ie(&pnetwork->network.ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pnetwork->network.ie_length-12); - } - if (p && ht_ielen > 0) { - struct ieee80211_ht_cap *pht_capie; - ht_cap = true; - pht_capie = (struct ieee80211_ht_cap *)(p+2); - memcpy(&mcs_rate, pht_capie->mcs.rx_mask, 2); - bw_40MHz = (le16_to_cpu(pht_capie->cap_info) & IEEE80211_HT_CAP_SUP_WIDTH) ? 1 : 0; - short_GI = (le16_to_cpu(pht_capie->cap_info) & (IEEE80211_HT_CAP_SGI_20 | IEEE80211_HT_CAP_SGI_40)) ? 1 : 0; - } - - /* Add the protocol name */ - iwe.cmd = SIOCGIWNAME; - if (rtw_is_cckratesonly_included((u8 *)&pnetwork->network.supported_rates)) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11b"); - } else if (rtw_is_cckrates_included((u8 *)&pnetwork->network.supported_rates)) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bgn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); - } else { - if (pnetwork->network.configuration.ds_config <= 14) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); - } - } - - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); - - /* Add mode */ - if (pnetwork->network.reserved[0] == 2) { /* Probe Request */ - cap = 0; - } else { - __le16 le_tmp; - - iwe.cmd = SIOCGIWMODE; - memcpy((u8 *)&le_tmp, rtw_get_capability_from_ie(pnetwork->network.ies), 2); - cap = le16_to_cpu(le_tmp); - } - - if (cap & (WLAN_CAPABILITY_IBSS | WLAN_CAPABILITY_ESS)) { - if (cap & WLAN_CAPABILITY_ESS) - iwe.u.mode = IW_MODE_MASTER; - else - iwe.u.mode = IW_MODE_ADHOC; - - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_UINT_LEN); - } - - if (pnetwork->network.configuration.ds_config < 1) - pnetwork->network.configuration.ds_config = 1; - - /* Add frequency/channel */ - iwe.cmd = SIOCGIWFREQ; - iwe.u.freq.m = rtw_ch2freq(pnetwork->network.configuration.ds_config) * 100000; - iwe.u.freq.e = 1; - iwe.u.freq.i = pnetwork->network.configuration.ds_config; - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_FREQ_LEN); - - /* Add encryption capability */ - iwe.cmd = SIOCGIWENCODE; - if (cap & WLAN_CAPABILITY_PRIVACY) - iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; - else - iwe.u.data.flags = IW_ENCODE_DISABLED; - iwe.u.data.length = 0; - start = iwe_stream_add_point(info, start, stop, &iwe, pnetwork->network.ssid.ssid); - - /*Add basic and extended rates */ - max_rate = 0; - custom = kzalloc(MAX_CUSTOM_LEN, GFP_ATOMIC); - if (!custom) - return start; - p = custom; - p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), " Rates (Mb/s): "); - while (pnetwork->network.supported_rates[i] != 0) { - rate = pnetwork->network.supported_rates[i]&0x7F; - if (rate > max_rate) - max_rate = rate; - p += scnprintf(p, MAX_CUSTOM_LEN - (p - custom), - "%d%s ", rate >> 1, (rate & 1) ? ".5" : ""); - i++; - } - - if (vht_cap) { - max_rate = vht_data_rate; - } else if (ht_cap) { - if (mcs_rate & 0x8000) /* MCS15 */ - max_rate = (bw_40MHz) ? ((short_GI)?300:270):((short_GI)?144:130); - else /* default MCS7 */ - max_rate = (bw_40MHz) ? ((short_GI)?150:135):((short_GI)?72:65); - - max_rate = max_rate*2;/* Mbps/2; */ - } - - iwe.cmd = SIOCGIWRATE; - iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; - iwe.u.bitrate.value = max_rate * 500000; - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_PARAM_LEN); - - /* parsing WPA/WPA2 IE */ - if (pnetwork->network.reserved[0] != 2) { /* Probe Request */ - u8 *buf; - u8 wpa_ie[255], rsn_ie[255]; - u16 wpa_len = 0, rsn_len = 0; - u8 *p; - rtw_get_sec_ie(pnetwork->network.ies, pnetwork->network.ie_length, rsn_ie, &rsn_len, wpa_ie, &wpa_len); - - buf = kzalloc(MAX_WPA_IE_LEN*2, GFP_ATOMIC); - if (!buf) - return start; - if (wpa_len > 0) { - p = buf; - p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf), "wpa_ie ="); - for (i = 0; i < wpa_len; i++) - p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf), - "%02x", wpa_ie[i]); - - if (wpa_len > 100) { - printk("-----------------Len %d----------------\n", wpa_len); - for (i = 0; i < wpa_len; i++) - printk("%02x ", wpa_ie[i]); - printk("\n"); - printk("-----------------Len %d----------------\n", wpa_len); - } - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = wpa_len; - start = iwe_stream_add_point(info, start, stop, &iwe, wpa_ie); - } - if (rsn_len > 0) { - p = buf; - memset(buf, 0, MAX_WPA_IE_LEN*2); - p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf), "rsn_ie ="); - for (i = 0; i < rsn_len; i++) - p += scnprintf(p, (MAX_WPA_IE_LEN * 2) - (p - buf), - "%02x", rsn_ie[i]); - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = strlen(buf); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVGENIE; - iwe.u.data.length = rsn_len; - start = iwe_stream_add_point(info, start, stop, &iwe, rsn_ie); - } - kfree(buf); - } - - { /* parsing WPS IE */ - uint cnt = 0, total_ielen; - u8 *wpsie_ptr = NULL; - uint wps_ielen = 0; - - u8 *ie_ptr; - total_ielen = pnetwork->network.ie_length - ie_offset; - - if (pnetwork->network.reserved[0] == 2) { /* Probe Request */ - ie_ptr = pnetwork->network.ies; - total_ielen = pnetwork->network.ie_length; - } else { /* Beacon or Probe Respones */ - ie_ptr = pnetwork->network.ies + _FIXED_IE_LENGTH_; - total_ielen = pnetwork->network.ie_length - _FIXED_IE_LENGTH_; - } - - while (cnt < total_ielen) { - if (rtw_is_wps_ie(&ie_ptr[cnt], &wps_ielen) && (wps_ielen > 2)) { - wpsie_ptr = &ie_ptr[cnt]; - iwe.cmd = IWEVGENIE; - iwe.u.data.length = (u16)wps_ielen; - start = iwe_stream_add_point(info, start, stop, &iwe, wpsie_ptr); - } - cnt += ie_ptr[cnt + 1] + 2; /* goto next */ - } - } - - /* Add quality statistics */ - iwe.cmd = IWEVQUAL; - iwe.u.qual.updated = IW_QUAL_QUAL_UPDATED | IW_QUAL_LEVEL_UPDATED - | IW_QUAL_NOISE_INVALID; - - if (check_fwstate(pmlmepriv, _FW_LINKED) == true && - is_same_network(&pmlmepriv->cur_network.network, &pnetwork->network, 0)) { - ss = padapter->recvpriv.signal_strength; - sq = padapter->recvpriv.signal_qual; - } else { - ss = pnetwork->network.phy_info.signal_strength; - sq = pnetwork->network.phy_info.signal_quality; - } - - - iwe.u.qual.level = (u8)ss;/* */ - - iwe.u.qual.qual = (u8)sq; /* signal quality */ - - iwe.u.qual.noise = 0; /* noise level */ - - start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_QUAL_LEN); - - { - u8 *buf; - u8 *pos; - - buf = kzalloc(MAX_WPA_IE_LEN, GFP_ATOMIC); - if (!buf) - goto exit; - - pos = pnetwork->network.reserved; - memset(&iwe, 0, sizeof(iwe)); - iwe.cmd = IWEVCUSTOM; - iwe.u.data.length = scnprintf(buf, MAX_WPA_IE_LEN, "fm =%02X%02X", pos[1], pos[0]); - start = iwe_stream_add_point(info, start, stop, &iwe, buf); - kfree(buf); - } -exit: - kfree(custom); - - return start; -} - static int wpa_set_auth_algs(struct net_device *dev, u32 value) { struct adapter *padapter = rtw_netdev_priv(dev); @@ -617,2126 +348,55 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie case WPA_CIPHER_TKIP: padapter->securitypriv.dot11PrivacyAlgrthm = _TKIP_; padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption2Enabled; - break; - case WPA_CIPHER_CCMP: - padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; - break; - case WPA_CIPHER_WEP104: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - break; - } - - _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); - {/* set wps_ie */ - u16 cnt = 0; - u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - while (cnt < ielen) { - eid = buf[cnt]; - - if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { - padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < MAX_WPS_IE_LEN) ? (buf[cnt+1]+2):MAX_WPS_IE_LEN; - - memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); - - set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); - - cnt += buf[cnt+1]+2; - - break; - } else { - cnt += buf[cnt+1]+2; /* goto next */ - } - } - } - } - - /* TKIP and AES disallow multicast packets until installing group key */ - if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ - || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ - || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) - /* WPS open need to enable multicast */ - /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */ - rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr); - -exit: - - kfree(buf); - - return ret; -} - -static int rtw_wx_get_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - u32 ht_ielen = 0; - char *p; - u8 ht_cap = false; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - NDIS_802_11_RATES_EX *prates = NULL; - - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { - /* parsing HT_CAP_IE */ - p = rtw_get_ie(&pcur_bss->ies[12], WLAN_EID_HT_CAPABILITY, &ht_ielen, pcur_bss->ie_length-12); - if (p && ht_ielen > 0) - ht_cap = true; - - prates = &pcur_bss->supported_rates; - - if (rtw_is_cckratesonly_included((u8 *)prates)) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11b"); - } else if (rtw_is_cckrates_included((u8 *)prates)) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bgn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); - } else { - if (pcur_bss->configuration.ds_config <= 14) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); - } - } - } else { - /* prates = &padapter->registrypriv.dev_network.supported_rates; */ - /* snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); */ - snprintf(wrqu->name, IFNAMSIZ, "unassociated"); - } - return 0; -} - -static int rtw_wx_set_freq(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -static int rtw_wx_get_freq(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) { - /* wrqu->freq.m = ieee80211_wlan_frequencies[pcur_bss->configuration.ds_config-1] * 100000; */ - wrqu->freq.m = rtw_ch2freq(pcur_bss->configuration.ds_config) * 100000; - wrqu->freq.e = 1; - wrqu->freq.i = pcur_bss->configuration.ds_config; - - } else { - wrqu->freq.m = rtw_ch2freq(padapter->mlmeextpriv.cur_channel) * 100000; - wrqu->freq.e = 1; - wrqu->freq.i = padapter->mlmeextpriv.cur_channel; - } - - return 0; -} - -static int rtw_wx_set_mode(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - enum ndis_802_11_network_infrastructure networkType; - int ret = 0; - - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = -EPERM; - goto exit; - } - - if (!padapter->hw_init_completed) { - ret = -EPERM; - goto exit; - } - - switch (wrqu->mode) { - case IW_MODE_AUTO: - networkType = Ndis802_11AutoUnknown; - break; - case IW_MODE_ADHOC: - networkType = Ndis802_11IBSS; - break; - case IW_MODE_MASTER: - networkType = Ndis802_11APMode; - /* rtw_setopmode_cmd(padapter, networkType, true); */ - break; - case IW_MODE_INFRA: - networkType = Ndis802_11Infrastructure; - break; - default: - ret = -EINVAL; - goto exit; - } - -/* - if (Ndis802_11APMode == networkType) - { - rtw_setopmode_cmd(padapter, networkType, true); - } - else - { - rtw_setopmode_cmd(padapter, Ndis802_11AutoUnknown, true); - } -*/ - - if (rtw_set_802_11_infrastructure_mode(padapter, networkType) == false) { - - ret = -EPERM; - goto exit; - - } - - rtw_setopmode_cmd(padapter, networkType, true); - -exit: - return ret; -} - -static int rtw_wx_get_mode(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == true) { - wrqu->mode = IW_MODE_INFRA; - } else if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true)) { - wrqu->mode = IW_MODE_ADHOC; - } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE) == true) { - wrqu->mode = IW_MODE_MASTER; - } else { - wrqu->mode = IW_MODE_AUTO; - } - return 0; -} - - -static int rtw_wx_set_pmkid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - u8 j, blInserted = false; - int intReturn = false; - struct security_priv *psecuritypriv = &padapter->securitypriv; - struct iw_pmksa *pPMK = (struct iw_pmksa *)extra; - u8 strZeroMacAddress[ETH_ALEN] = { 0x00 }; - u8 strIssueBssid[ETH_ALEN] = { 0x00 }; - - /* - There are the BSSID information in the bssid.sa_data array. - If cmd is IW_PMKSA_FLUSH, it means the wpa_suppplicant wants to clear all the PMKID information. - If cmd is IW_PMKSA_ADD, it means the wpa_supplicant wants to add a PMKID/BSSID to driver. - If cmd is IW_PMKSA_REMOVE, it means the wpa_supplicant wants to remove a PMKID/BSSID from driver. - */ - - memcpy(strIssueBssid, pPMK->bssid.sa_data, ETH_ALEN); - if (pPMK->cmd == IW_PMKSA_ADD) { - if (!memcmp(strIssueBssid, strZeroMacAddress, ETH_ALEN)) - return intReturn; - else - intReturn = true; - - blInserted = false; - - /* overwrite PMKID */ - for (j = 0; j < NUM_PMKID_CACHE; j++) { - if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { - - memcpy(psecuritypriv->PMKIDList[j].PMKID, pPMK->pmkid, IW_PMKID_LEN); - psecuritypriv->PMKIDList[j].bUsed = true; - psecuritypriv->PMKIDIndex = j+1; - blInserted = true; - break; - } - } - - if (!blInserted) { - - memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].Bssid, strIssueBssid, ETH_ALEN); - memcpy(psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].PMKID, pPMK->pmkid, IW_PMKID_LEN); - - psecuritypriv->PMKIDList[psecuritypriv->PMKIDIndex].bUsed = true; - psecuritypriv->PMKIDIndex++; - if (psecuritypriv->PMKIDIndex == 16) - psecuritypriv->PMKIDIndex = 0; - } - } else if (pPMK->cmd == IW_PMKSA_REMOVE) { - intReturn = true; - for (j = 0; j < NUM_PMKID_CACHE; j++) { - if (!memcmp(psecuritypriv->PMKIDList[j].Bssid, strIssueBssid, ETH_ALEN)) { - /* BSSID is matched, the same AP => Remove this PMKID information and reset it. */ - eth_zero_addr(psecuritypriv->PMKIDList[j].Bssid); - psecuritypriv->PMKIDList[j].bUsed = false; - break; - } - } - } else if (pPMK->cmd == IW_PMKSA_FLUSH) { - memset(&psecuritypriv->PMKIDList[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE); - psecuritypriv->PMKIDIndex = 0; - intReturn = true; - } - return intReturn; -} - -static int rtw_wx_get_sens(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - { - wrqu->sens.value = 0; - wrqu->sens.fixed = 0; /* no auto select */ - wrqu->sens.disabled = 1; - } - return 0; -} - -static int rtw_wx_get_range(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct iw_range *range = (struct iw_range *)extra; - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - - u16 val; - int i; - - wrqu->data.length = sizeof(*range); - memset(range, 0, sizeof(*range)); - - /* Let's try to keep this struct in the same order as in - * linux/include/wireless.h - */ - - /* TODO: See what values we can set, and remove the ones we can't - * set, or fill them with some default data. - */ - - /* ~5 Mb/s real (802.11b) */ - range->throughput = 5 * 1000 * 1000; - - /* signal level threshold range */ - - /* percent values between 0 and 100. */ - range->max_qual.qual = 100; - range->max_qual.level = 100; - range->max_qual.noise = 100; - range->max_qual.updated = 7; /* Updated all three */ - - - range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ - /* TODO: Find real 'good' to 'bad' threshol value for RSSI */ - range->avg_qual.level = 256 - 78; - range->avg_qual.noise = 0; - range->avg_qual.updated = 7; /* Updated all three */ - - range->num_bitrates = RATE_COUNT; - - for (i = 0; i < RATE_COUNT && i < IW_MAX_BITRATES; i++) - range->bitrate[i] = rtw_rates[i]; - - range->min_frag = MIN_FRAG_THRESHOLD; - range->max_frag = MAX_FRAG_THRESHOLD; - - range->pm_capa = 0; - - range->we_version_compiled = WIRELESS_EXT; - range->we_version_source = 16; - - for (i = 0, val = 0; i < MAX_CHANNEL_NUM; i++) { - - /* Include only legal frequencies for some countries */ - if (pmlmeext->channel_set[i].ChannelNum != 0) { - range->freq[val].i = pmlmeext->channel_set[i].ChannelNum; - range->freq[val].m = rtw_ch2freq(pmlmeext->channel_set[i].ChannelNum) * 100000; - range->freq[val].e = 1; - val++; - } - - if (val == IW_MAX_FREQUENCIES) - break; - } - - range->num_channels = val; - range->num_frequency = val; - -/* Commented by Albert 2009/10/13 */ -/* The following code will proivde the security capability to network manager. */ -/* If the driver doesn't provide this capability to network manager, */ -/* the WPA/WPA2 routers can't be chosen in the network manager. */ - -/* -#define IW_SCAN_CAPA_NONE 0x00 -#define IW_SCAN_CAPA_ESSID 0x01 -#define IW_SCAN_CAPA_BSSID 0x02 -#define IW_SCAN_CAPA_CHANNEL 0x04 -#define IW_SCAN_CAPA_MODE 0x08 -#define IW_SCAN_CAPA_RATE 0x10 -#define IW_SCAN_CAPA_TYPE 0x20 -#define IW_SCAN_CAPA_TIME 0x40 -*/ - - range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | - IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; - - range->scan_capa = IW_SCAN_CAPA_ESSID | IW_SCAN_CAPA_TYPE | IW_SCAN_CAPA_BSSID | - IW_SCAN_CAPA_CHANNEL | IW_SCAN_CAPA_MODE | IW_SCAN_CAPA_RATE; - - return 0; -} - -/* set bssid flow */ -/* s1. rtw_set_802_11_infrastructure_mode() */ -/* s2. rtw_set_802_11_authentication_mode() */ -/* s3. set_802_11_encryption_mode() */ -/* s4. rtw_set_802_11_bssid() */ -static int rtw_wx_set_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra) -{ - uint ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct sockaddr *temp = (struct sockaddr *)awrq; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct list_head *phead; - u8 *dst_bssid, *src_bssid; - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - enum ndis_802_11_authentication_mode authmode; - - rtw_ps_deny(padapter, PS_DENY_JOIN); - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = -1; - goto exit; - } - - if (!padapter->bup) { - ret = -1; - goto exit; - } - - - if (temp->sa_family != ARPHRD_ETHER) { - ret = -EINVAL; - goto exit; - } - - authmode = padapter->securitypriv.ndisauthtype; - spin_lock_bh(&queue->lock); - phead = get_list_head(queue); - list_for_each(pmlmepriv->pscanned, phead) { - pnetwork = list_entry(pmlmepriv->pscanned, - struct wlan_network, list); - - dst_bssid = pnetwork->network.mac_address; - - src_bssid = temp->sa_data; - - if ((!memcmp(dst_bssid, src_bssid, ETH_ALEN))) { - if (!rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.infrastructure_mode)) { - ret = -1; - spin_unlock_bh(&queue->lock); - goto exit; - } - break; - } - - } - spin_unlock_bh(&queue->lock); - - rtw_set_802_11_authentication_mode(padapter, authmode); - /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ - if (rtw_set_802_11_bssid(padapter, temp->sa_data) == false) { - ret = -1; - goto exit; - } - -exit: - - rtw_ps_deny_cancel(padapter, PS_DENY_JOIN); - - return ret; -} - -static int rtw_wx_get_wap(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - - wrqu->ap_addr.sa_family = ARPHRD_ETHER; - - eth_zero_addr(wrqu->ap_addr.sa_data); - - if (((check_fwstate(pmlmepriv, _FW_LINKED)) == true) || - ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) == true) || - ((check_fwstate(pmlmepriv, WIFI_AP_STATE)) == true)) { - memcpy(wrqu->ap_addr.sa_data, pcur_bss->mac_address, ETH_ALEN); - } else { - eth_zero_addr(wrqu->ap_addr.sa_data); - } - - return 0; -} - -static int rtw_wx_set_mlme(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct iw_mlme *mlme = (struct iw_mlme *)extra; - - - if (mlme == NULL) - return -1; - - switch (mlme->cmd) { - case IW_MLME_DEAUTH: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - case IW_MLME_DISASSOC: - if (!rtw_set_802_11_disassociate(padapter)) - ret = -1; - break; - default: - return -EOPNOTSUPP; - } - - return ret; -} - -static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - u8 _status = false; - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct ndis_802_11_ssid ssid[RTW_SSID_SCAN_AMOUNT]; - - rtw_ps_deny(padapter, PS_DENY_SCAN); - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = -1; - goto exit; - } - - if (padapter->bDriverStopped) { - ret = -1; - goto exit; - } - - if (!padapter->bup) { - ret = -1; - goto exit; - } - - if (!padapter->hw_init_completed) { - ret = -1; - goto exit; - } - - /* When Busy Traffic, driver do not site survey. So driver return success. */ - /* wpa_supplicant will not issue SIOCSIWSCAN cmd again after scan timeout. */ - /* modify by thomas 2011-02-22. */ - if (pmlmepriv->LinkDetectInfo.bBusyTraffic) { - indicate_wx_scan_complete_event(padapter); - goto exit; - } - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY|_FW_UNDER_LINKING) == true) { - indicate_wx_scan_complete_event(padapter); - goto exit; - } - - memset(ssid, 0, sizeof(struct ndis_802_11_ssid)*RTW_SSID_SCAN_AMOUNT); - - if (wrqu->data.length == sizeof(struct iw_scan_req)) { - struct iw_scan_req *req = (struct iw_scan_req *)extra; - - if (wrqu->data.flags & IW_SCAN_THIS_ESSID) { - int len = min((int)req->essid_len, IW_ESSID_MAX_SIZE); - - memcpy(ssid[0].ssid, req->essid, len); - ssid[0].ssid_length = len; - - spin_lock_bh(&pmlmepriv->lock); - - _status = rtw_sitesurvey_cmd(padapter, ssid, 1, NULL, 0); - - spin_unlock_bh(&pmlmepriv->lock); - - } - - } else if (wrqu->data.length >= WEXT_CSCAN_HEADER_SIZE - && !memcmp(extra, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { - int len = wrqu->data.length - WEXT_CSCAN_HEADER_SIZE; - char *pos = extra+WEXT_CSCAN_HEADER_SIZE; - char section; - char sec_len; - int ssid_index = 0; - - while (len >= 1) { - section = *(pos++); len -= 1; - - switch (section) { - case WEXT_CSCAN_SSID_SECTION: - if (len < 1) { - len = 0; - break; - } - - sec_len = *(pos++); len -= 1; - - if (sec_len > 0 && sec_len <= len) { - ssid[ssid_index].ssid_length = sec_len; - memcpy(ssid[ssid_index].ssid, pos, ssid[ssid_index].ssid_length); - ssid_index++; - } - - pos += sec_len; len -= sec_len; - break; - - - case WEXT_CSCAN_CHANNEL_SECTION: - pos += 1; len -= 1; - break; - case WEXT_CSCAN_ACTV_DWELL_SECTION: - pos += 2; len -= 2; - break; - case WEXT_CSCAN_PASV_DWELL_SECTION: - pos += 2; len -= 2; - break; - case WEXT_CSCAN_HOME_DWELL_SECTION: - pos += 2; len -= 2; - break; - case WEXT_CSCAN_TYPE_SECTION: - pos += 1; len -= 1; - break; - default: - len = 0; /* stop parsing */ - } - } - - /* jeff: it has still some scan parameter to parse, we only do this now... */ - _status = rtw_set_802_11_bssid_list_scan(padapter, ssid, RTW_SSID_SCAN_AMOUNT); - - } else { - _status = rtw_set_802_11_bssid_list_scan(padapter, NULL, 0); - } - - if (_status == false) - ret = -1; - -exit: - - rtw_ps_deny_cancel(padapter, PS_DENY_SCAN); - - return ret; -} - -static int rtw_wx_get_scan(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - struct list_head *plist, *phead; - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct wlan_network *pnetwork = NULL; - char *ev = extra; - char *stop = ev + wrqu->data.length; - u32 ret = 0; - signed int wait_status; - - if (adapter_to_pwrctl(padapter)->brfoffbyhw && padapter->bDriverStopped) { - ret = -EINVAL; - goto exit; - } - - wait_status = _FW_UNDER_SURVEY | _FW_UNDER_LINKING; - - if (check_fwstate(pmlmepriv, wait_status)) - return -EAGAIN; - - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); - - phead = get_list_head(queue); - list_for_each(plist, phead) { - if ((stop - ev) < SCAN_ITEM_SIZE) { - ret = -E2BIG; - break; - } - - pnetwork = list_entry(plist, struct wlan_network, list); - - /* report network only if the current channel set contains the channel to which this network belongs */ - if (rtw_ch_set_search_ch(padapter->mlmeextpriv.channel_set, pnetwork->network.configuration.ds_config) >= 0 - && true == rtw_validate_ssid(&(pnetwork->network.ssid))) { - - ev = translate_scan(padapter, a, pnetwork, ev, stop); - } - - } - - spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); - - wrqu->data.length = ev-extra; - wrqu->data.flags = 0; - -exit: - - return ret; - -} - -/* set ssid flow */ -/* s1. rtw_set_802_11_infrastructure_mode() */ -/* s2. set_802_11_authenticaion_mode() */ -/* s3. set_802_11_encryption_mode() */ -/* s4. rtw_set_802_11_ssid() */ -static int rtw_wx_set_essid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct __queue *queue = &pmlmepriv->scanned_queue; - struct list_head *phead; - struct wlan_network *pnetwork = NULL; - enum ndis_802_11_authentication_mode authmode; - struct ndis_802_11_ssid ndis_ssid; - u8 *dst_ssid, *src_ssid; - - uint ret = 0, len; - - rtw_ps_deny(padapter, PS_DENY_JOIN); - if (_FAIL == rtw_pwr_wakeup(padapter)) { - ret = -1; - goto exit; - } - - if (!padapter->bup) { - ret = -1; - goto exit; - } - - if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { - ret = -E2BIG; - goto exit; - } - - if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { - ret = -1; - goto exit; - } - - authmode = padapter->securitypriv.ndisauthtype; - if (wrqu->essid.flags && wrqu->essid.length) { - len = (wrqu->essid.length < IW_ESSID_MAX_SIZE) ? wrqu->essid.length : IW_ESSID_MAX_SIZE; - - memset(&ndis_ssid, 0, sizeof(struct ndis_802_11_ssid)); - ndis_ssid.ssid_length = len; - memcpy(ndis_ssid.ssid, extra, len); - src_ssid = ndis_ssid.ssid; - - spin_lock_bh(&queue->lock); - phead = get_list_head(queue); - list_for_each(pmlmepriv->pscanned, phead) { - pnetwork = list_entry(pmlmepriv->pscanned, - struct wlan_network, list); - - dst_ssid = pnetwork->network.ssid.ssid; - - if ((!memcmp(dst_ssid, src_ssid, ndis_ssid.ssid_length)) && - (pnetwork->network.ssid.ssid_length == ndis_ssid.ssid_length)) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) == true) { - if (pnetwork->network.infrastructure_mode != pmlmepriv->cur_network.network.infrastructure_mode) - continue; - } - - if (rtw_set_802_11_infrastructure_mode(padapter, pnetwork->network.infrastructure_mode) == false) { - ret = -1; - spin_unlock_bh(&queue->lock); - goto exit; - } - - break; - } - } - spin_unlock_bh(&queue->lock); - rtw_set_802_11_authentication_mode(padapter, authmode); - /* set_802_11_encryption_mode(padapter, padapter->securitypriv.ndisencryptstatus); */ - if (rtw_set_802_11_ssid(padapter, &ndis_ssid) == false) { - ret = -1; - goto exit; - } - } - -exit: - - rtw_ps_deny_cancel(padapter, PS_DENY_JOIN); - - return ret; -} - -static int rtw_wx_get_essid(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - u32 len, ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct wlan_bssid_ex *pcur_bss = &pmlmepriv->cur_network.network; - - if ((check_fwstate(pmlmepriv, _FW_LINKED) == true) || - (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - len = pcur_bss->ssid.ssid_length; - - wrqu->essid.length = len; - - memcpy(extra, pcur_bss->ssid.ssid, len); - - wrqu->essid.flags = 1; - } else { - ret = -1; - goto exit; - } - -exit: - return ret; -} - -static int rtw_wx_set_rate(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra) -{ - int i, ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - u8 datarates[NumRates]; - u32 target_rate = wrqu->bitrate.value; - u32 fixed = wrqu->bitrate.fixed; - u32 ratevalue = 0; - u8 mpdatarate[NumRates] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, 0xff}; - - if (target_rate == -1) { - ratevalue = 11; - goto set_rate; - } - target_rate = target_rate/100000; - - switch (target_rate) { - case 10: - ratevalue = 0; - break; - case 20: - ratevalue = 1; - break; - case 55: - ratevalue = 2; - break; - case 60: - ratevalue = 3; - break; - case 90: - ratevalue = 4; - break; - case 110: - ratevalue = 5; - break; - case 120: - ratevalue = 6; - break; - case 180: - ratevalue = 7; - break; - case 240: - ratevalue = 8; - break; - case 360: - ratevalue = 9; - break; - case 480: - ratevalue = 10; - break; - case 540: - ratevalue = 11; - break; - default: - ratevalue = 11; - break; - } - -set_rate: - - for (i = 0; i < NumRates; i++) { - if (ratevalue == mpdatarate[i]) { - datarates[i] = mpdatarate[i]; - if (fixed == 0) - break; - } else { - datarates[i] = 0xff; - } - } - - if (rtw_setdatarate_cmd(padapter, datarates) != _SUCCESS) - ret = -1; - - return ret; -} - -static int rtw_wx_get_rate(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - u16 max_rate = 0; - - max_rate = rtw_get_cur_max_rate(rtw_netdev_priv(dev)); - - if (max_rate == 0) - return -EPERM; - - wrqu->bitrate.fixed = 0; /* no auto select */ - wrqu->bitrate.value = max_rate * 100000; - - return 0; -} - -static int rtw_wx_set_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - if (wrqu->rts.disabled) - padapter->registrypriv.rts_thresh = 2347; - else { - if (wrqu->rts.value < 0 || - wrqu->rts.value > 2347) - return -EINVAL; - - padapter->registrypriv.rts_thresh = wrqu->rts.value; - } - - return 0; -} - -static int rtw_wx_get_rts(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - wrqu->rts.value = padapter->registrypriv.rts_thresh; - wrqu->rts.fixed = 0; /* no auto select */ - /* wrqu->rts.disabled = (wrqu->rts.value == DEFAULT_RTS_THRESHOLD); */ - - return 0; -} - -static int rtw_wx_set_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - if (wrqu->frag.disabled) - padapter->xmitpriv.frag_len = MAX_FRAG_THRESHOLD; - else { - if (wrqu->frag.value < MIN_FRAG_THRESHOLD || - wrqu->frag.value > MAX_FRAG_THRESHOLD) - return -EINVAL; - - padapter->xmitpriv.frag_len = wrqu->frag.value & ~0x1; - } - - return 0; - -} - -static int rtw_wx_get_frag(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - wrqu->frag.value = padapter->xmitpriv.frag_len; - wrqu->frag.fixed = 0; /* no auto select */ - /* wrqu->frag.disabled = (wrqu->frag.value == DEFAULT_FRAG_THRESHOLD); */ - - return 0; -} - -static int rtw_wx_get_retry(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - /* struct adapter *padapter = rtw_netdev_priv(dev); */ - - - wrqu->retry.value = 7; - wrqu->retry.fixed = 0; /* no auto select */ - wrqu->retry.disabled = 1; - - return 0; - -} - -static int rtw_wx_set_enc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *keybuf) -{ - u32 key, ret = 0; - u32 keyindex_provided; - struct ndis_802_11_wep wep; - enum ndis_802_11_authentication_mode authmode; - - struct iw_point *erq = &(wrqu->encoding); - struct adapter *padapter = rtw_netdev_priv(dev); - struct pwrctrl_priv *pwrpriv = adapter_to_pwrctl(padapter); - - memset(&wep, 0, sizeof(struct ndis_802_11_wep)); - - key = erq->flags & IW_ENCODE_INDEX; - - if (erq->flags & IW_ENCODE_DISABLED) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ - authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype = authmode; - - goto exit; - } - - if (key) { - if (key > WEP_KEYS) - return -EINVAL; - key--; - keyindex_provided = 1; - } else { - keyindex_provided = 0; - key = padapter->securitypriv.dot11PrivacyKeyIndex; - } - - /* set authentication mode */ - if (erq->flags & IW_ENCODE_OPEN) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ - - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; - - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype = authmode; - } else if (erq->flags & IW_ENCODE_RESTRICTED) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; - - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Shared; - - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - padapter->securitypriv.dot118021XGrpPrivacy = _WEP40_; - authmode = Ndis802_11AuthModeShared; - padapter->securitypriv.ndisauthtype = authmode; - } else { - padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled;/* Ndis802_11EncryptionDisabled; */ - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - authmode = Ndis802_11AuthModeOpen; - padapter->securitypriv.ndisauthtype = authmode; - } - - wep.key_index = key; - if (erq->length > 0) { - wep.key_length = erq->length <= 5 ? 5 : 13; - - wep.length = wep.key_length + FIELD_OFFSET(struct ndis_802_11_wep, key_material); - } else { - wep.key_length = 0; - - if (keyindex_provided == 1) { /* set key_id only, no given key_material(erq->length == 0). */ - padapter->securitypriv.dot11PrivacyKeyIndex = key; - - switch (padapter->securitypriv.dot11DefKeylen[key]) { - case 5: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP40_; - break; - case 13: - padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; - break; - default: - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - break; - } - - goto exit; - - } - - } - - wep.key_index |= 0x80000000; - - memcpy(wep.key_material, keybuf, wep.key_length); - - if (rtw_set_802_11_add_wep(padapter, &wep) == false) { - if (rf_on == pwrpriv->rf_pwrstate) - ret = -EOPNOTSUPP; - goto exit; - } - -exit: - return ret; -} - -static int rtw_wx_get_enc(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *keybuf) -{ - uint key, ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct iw_point *erq = &(wrqu->encoding); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - - if (check_fwstate(pmlmepriv, _FW_LINKED) != true) { - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) != true) { - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - return 0; - } - } - - - key = erq->flags & IW_ENCODE_INDEX; - - if (key) { - if (key > WEP_KEYS) - return -EINVAL; - key--; - } else { - key = padapter->securitypriv.dot11PrivacyKeyIndex; - } - - erq->flags = key + 1; - - /* if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) */ - /* */ - /* erq->flags |= IW_ENCODE_OPEN; */ - /* */ - - switch (padapter->securitypriv.ndisencryptstatus) { - case Ndis802_11EncryptionNotSupported: - case Ndis802_11EncryptionDisabled: - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - break; - case Ndis802_11Encryption1Enabled: - erq->length = padapter->securitypriv.dot11DefKeylen[key]; - - if (erq->length) { - memcpy(keybuf, padapter->securitypriv.dot11DefKey[key].skey, padapter->securitypriv.dot11DefKeylen[key]); - - erq->flags |= IW_ENCODE_ENABLED; - - if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeOpen) - erq->flags |= IW_ENCODE_OPEN; - else if (padapter->securitypriv.ndisauthtype == Ndis802_11AuthModeShared) - erq->flags |= IW_ENCODE_RESTRICTED; - } else { - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - } - break; - case Ndis802_11Encryption2Enabled: - case Ndis802_11Encryption3Enabled: - erq->length = 16; - erq->flags |= (IW_ENCODE_ENABLED | IW_ENCODE_OPEN | IW_ENCODE_NOKEY); - break; - default: - erq->length = 0; - erq->flags |= IW_ENCODE_DISABLED; - break; - } - return ret; -} - -static int rtw_wx_get_power(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - /* struct adapter *padapter = rtw_netdev_priv(dev); */ - - wrqu->power.value = 0; - wrqu->power.fixed = 0; /* no auto select */ - wrqu->power.disabled = 1; - - return 0; -} - -static int rtw_wx_set_gen_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - return rtw_set_wpa_ie(padapter, extra, wrqu->data.length); -} - -static int rtw_wx_set_auth(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct iw_param *param = (struct iw_param *)&(wrqu->param); - int ret = 0; - - switch (param->flags & IW_AUTH_INDEX) { - case IW_AUTH_WPA_VERSION: - break; - case IW_AUTH_CIPHER_PAIRWISE: - break; - case IW_AUTH_CIPHER_GROUP: - break; - case IW_AUTH_KEY_MGMT: - /* - * ??? does not use these parameters - */ - break; - case IW_AUTH_TKIP_COUNTERMEASURES: - /* wpa_supplicant is setting the tkip countermeasure. */ - if (param->value) /* enabling */ - padapter->securitypriv.btkip_countermeasure = true; - else /* disabling */ - padapter->securitypriv.btkip_countermeasure = false; - break; - case IW_AUTH_DROP_UNENCRYPTED: - /* HACK: - * - * wpa_supplicant calls set_wpa_enabled when the driver - * is loaded and unloaded, regardless of if WPA is being - * used. No other calls are made which can be used to - * determine if encryption will be used or not prior to - * association being expected. If encryption is not being - * used, drop_unencrypted is set to false, else true -- we - * can use this to determine if the CAP_PRIVACY_ON bit should - * be set. - */ - - /* - * This means init value, or using wep, ndisencryptstatus = - * Ndis802_11Encryption1Enabled, then it needn't reset it; - */ - if (padapter->securitypriv.ndisencryptstatus == Ndis802_11Encryption1Enabled) - break; - - if (param->value) { - padapter->securitypriv.ndisencryptstatus = Ndis802_11EncryptionDisabled; - padapter->securitypriv.dot11PrivacyAlgrthm = _NO_PRIVACY_; - padapter->securitypriv.dot118021XGrpPrivacy = _NO_PRIVACY_; - padapter->securitypriv.dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */ - padapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen; - } - - break; - case IW_AUTH_80211_AUTH_ALG: - /* - * It's the starting point of a link layer connection using wpa_supplicant - */ - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED)) { - LeaveAllPowerSaveMode(padapter); - rtw_disassoc_cmd(padapter, 500, false); - rtw_indicate_disconnect(padapter); - rtw_free_assoc_resources(padapter, 1); - } - - ret = wpa_set_auth_algs(dev, (u32)param->value); - break; - case IW_AUTH_WPA_ENABLED: - break; - case IW_AUTH_RX_UNENCRYPTED_EAPOL: - break; - case IW_AUTH_PRIVACY_INVOKED: - break; - default: - return -EOPNOTSUPP; - } - - return ret; -} - -static int rtw_wx_set_enc_ext(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - char *alg_name; - u32 param_len; - struct ieee_param *param = NULL; - struct iw_point *pencoding = &wrqu->encoding; - struct iw_encode_ext *pext = (struct iw_encode_ext *)extra; - int ret = 0; - - param_len = sizeof(struct ieee_param) + pext->key_len; - param = kzalloc(param_len, GFP_KERNEL); - if (param == NULL) - return -1; - - param->cmd = IEEE_CMD_SET_ENCRYPTION; - eth_broadcast_addr(param->sta_addr); - - - switch (pext->alg) { - case IW_ENCODE_ALG_NONE: - /* todo: remove key */ - /* remove = 1; */ - alg_name = "none"; - break; - case IW_ENCODE_ALG_WEP: - alg_name = "WEP"; - break; - case IW_ENCODE_ALG_TKIP: - alg_name = "TKIP"; - break; - case IW_ENCODE_ALG_CCMP: - alg_name = "CCMP"; - break; - case IW_ENCODE_ALG_AES_CMAC: - alg_name = "BIP"; - break; - default: - ret = -1; - goto exit; - } - - strncpy((char *)param->u.crypt.alg, alg_name, IEEE_CRYPT_ALG_NAME_LEN); - - if (pext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) - param->u.crypt.set_tx = 1; - - /* cliW: WEP does not have group key - * just not checking GROUP key setting - */ - if ((pext->alg != IW_ENCODE_ALG_WEP) && - ((pext->ext_flags & IW_ENCODE_EXT_GROUP_KEY) - || (pext->ext_flags & IW_ENCODE_ALG_AES_CMAC))) { - param->u.crypt.set_tx = 0; - } - - param->u.crypt.idx = (pencoding->flags & 0x00FF) - 1; - - if (pext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) - memcpy(param->u.crypt.seq, pext->rx_seq, 8); - - if (pext->key_len) { - param->u.crypt.key_len = pext->key_len; - /* memcpy(param + 1, pext + 1, pext->key_len); */ - memcpy(param->u.crypt.key, pext + 1, pext->key_len); - } - - if (pencoding->flags & IW_ENCODE_DISABLED) { - /* todo: remove key */ - /* remove = 1; */ - } - - ret = wpa_set_encryption(dev, param, param_len); - -exit: - kfree(param); - - return ret; -} - - -static int rtw_wx_get_nick(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - /* struct adapter *padapter = rtw_netdev_priv(dev); */ - /* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */ - /* struct security_priv *psecuritypriv = &padapter->securitypriv; */ - - if (extra) { - wrqu->data.length = 14; - wrqu->data.flags = 1; - memcpy(extra, "", 14); - } - return 0; -} - -static int rtw_wx_read32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter; - struct iw_point *p; - u16 len; - u32 addr; - u32 data32; - u32 bytes; - u8 *ptmp; - int ret; - - - ret = 0; - padapter = rtw_netdev_priv(dev); - p = &wrqu->data; - len = p->length; - if (0 == len) - return -EINVAL; - - ptmp = rtw_malloc(len); - if (NULL == ptmp) - return -ENOMEM; - - if (copy_from_user(ptmp, p->pointer, len)) { - ret = -EFAULT; - goto exit; - } - - bytes = 0; - addr = 0; - sscanf(ptmp, "%d,%x", &bytes, &addr); - - switch (bytes) { - case 1: - data32 = rtw_read8(padapter, addr); - sprintf(extra, "0x%02X", data32); - break; - case 2: - data32 = rtw_read16(padapter, addr); - sprintf(extra, "0x%04X", data32); - break; - case 4: - data32 = rtw_read32(padapter, addr); - sprintf(extra, "0x%08X", data32); - break; - default: - ret = -EINVAL; - goto exit; - } - -exit: - kfree(ptmp); - - return ret; -} - -static int rtw_wx_write32(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - - u32 addr; - u32 data32; - u32 bytes; - - - bytes = 0; - addr = 0; - data32 = 0; - sscanf(extra, "%d,%x,%x", &bytes, &addr, &data32); - - switch (bytes) { - case 1: - rtw_write8(padapter, addr, (u8)data32); - break; - case 2: - rtw_write16(padapter, addr, (u16)data32); - break; - case 4: - rtw_write32(padapter, addr, data32); - break; - default: - return -EINVAL; - } - - return 0; -} - -static int rtw_wx_read_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - u32 path, addr, data32; - - - path = *(u32 *)extra; - addr = *((u32 *)extra + 1); - data32 = rtw_hal_read_rfreg(padapter, path, addr, 0xFFFFF); - /* - * IMPORTANT!! - * Only when wireless private ioctl is at odd order, - * "extra" would be copied to user space. - */ - sprintf(extra, "0x%05x", data32); - - return 0; -} - -static int rtw_wx_write_rf(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - u32 path, addr, data32; - - - path = *(u32 *)extra; - addr = *((u32 *)extra + 1); - data32 = *((u32 *)extra + 2); - rtw_hal_write_rfreg(padapter, path, addr, 0xFFFFF, data32); - - return 0; -} - -static int rtw_wx_priv_null(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - return -1; -} - -static int dummy(struct net_device *dev, struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - /* struct adapter *padapter = rtw_netdev_priv(dev); */ - /* struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); */ - - return -1; - -} - -static int rtw_wx_set_channel_plan(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - u8 channel_plan_req = (u8)(*((int *)wrqu)); - - if (rtw_set_chplan_cmd(padapter, channel_plan_req, 1, 1) != _SUCCESS) - return -EPERM; - - return 0; -} - -static int rtw_wx_set_mtk_wps_probe_ie(struct net_device *dev, - struct iw_request_info *a, - union iwreq_data *wrqu, char *b) -{ - return 0; -} - -static int rtw_wx_get_sensitivity(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *buf) -{ - return 0; -} - -static int rtw_wx_set_mtk_wps_ie(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -/* -typedef int (*iw_handler)(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -*/ -/* - *For all data larger than 16 octets, we need to use a - *pointer to memory allocated in user space. - */ -static int rtw_drvext_hdl(struct net_device *dev, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - return 0; -} - -static int rtw_get_ap_info(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - int wpa_ielen; - u32 cnt = 0; - struct list_head *plist, *phead; - unsigned char *pbuf; - u8 bssid[ETH_ALEN]; - char data[32]; - struct wlan_network *pnetwork = NULL; - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - struct __queue *queue = &(pmlmepriv->scanned_queue); - struct iw_point *pdata = &wrqu->data; - - if ((padapter->bDriverStopped) || (pdata == NULL)) { - ret = -EINVAL; - goto exit; - } - - while ((check_fwstate(pmlmepriv, (_FW_UNDER_SURVEY|_FW_UNDER_LINKING))) == true) { - msleep(30); - cnt++; - if (cnt > 100) - break; - } - - - /* pdata->length = 0;? */ - pdata->flags = 0; - if (pdata->length >= 32) { - if (copy_from_user(data, pdata->pointer, 32)) { - ret = -EINVAL; - goto exit; - } - } else { - ret = -EINVAL; - goto exit; - } - - spin_lock_bh(&(pmlmepriv->scanned_queue.lock)); - - phead = get_list_head(queue); - list_for_each(plist, phead) { - pnetwork = list_entry(plist, struct wlan_network, list); - - if (!mac_pton(data, bssid)) { - spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); - return -EINVAL; - } - - - if (!memcmp(bssid, pnetwork->network.mac_address, ETH_ALEN)) { /* BSSID match, then check if supporting wpa/wpa2 */ - - pbuf = rtw_get_wpa_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length-12); - if (pbuf && (wpa_ielen > 0)) { - pdata->flags = 1; - break; - } - - pbuf = rtw_get_wpa2_ie(&pnetwork->network.ies[12], &wpa_ielen, pnetwork->network.ie_length-12); - if (pbuf && (wpa_ielen > 0)) { - pdata->flags = 2; - break; - } - } - - } - - spin_unlock_bh(&(pmlmepriv->scanned_queue.lock)); - - if (pdata->length >= 34) { - if (copy_to_user((u8 __force __user *)pdata->pointer+32, (u8 *)&pdata->flags, 1)) { - ret = -EINVAL; - goto exit; - } - } - -exit: - - return ret; - -} - -static int rtw_set_pid(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - int *pdata = (int *)wrqu; - int selector; - - if ((padapter->bDriverStopped) || (pdata == NULL)) { - ret = -EINVAL; - goto exit; - } - - selector = *pdata; - if (selector < 3 && selector >= 0) - padapter->pid[selector] = *(pdata+1); - -exit: - - return ret; - -} - -static int rtw_wps_start(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct iw_point *pdata = &wrqu->data; - u32 u32wps_start = 0; - - if ((true == padapter->bDriverStopped) || (true == padapter->bSurpriseRemoved) || (NULL == pdata)) { - ret = -EINVAL; - goto exit; - } - - if (copy_from_user((void *)&u32wps_start, pdata->pointer, 4)) { - ret = -EFAULT; - goto exit; - } - if (u32wps_start == 0) - u32wps_start = *extra; - -exit: - - return ret; - -} - -static int rtw_p2p_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - return 0; - -} - -static int rtw_p2p_get(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - return 0; - -} - -static int rtw_p2p_get2(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - - return 0; - -} - -static int rtw_rereg_nd_name(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - struct rereg_nd_name_data *rereg_priv = &padapter->rereg_nd_name_priv; - char new_ifname[IFNAMSIZ]; - - if (rereg_priv->old_ifname[0] == 0) { - char *reg_ifname; - reg_ifname = padapter->registrypriv.ifname; - - strncpy(rereg_priv->old_ifname, reg_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ-1] = 0; - } - - if (wrqu->data.length > IFNAMSIZ) - return -EFAULT; - - if (copy_from_user(new_ifname, wrqu->data.pointer, IFNAMSIZ)) - return -EFAULT; - - if (0 == strcmp(rereg_priv->old_ifname, new_ifname)) - return ret; - - ret = rtw_change_ifname(padapter, new_ifname); - if (ret != 0) - goto exit; - - strncpy(rereg_priv->old_ifname, new_ifname, IFNAMSIZ); - rereg_priv->old_ifname[IFNAMSIZ-1] = 0; - - if (!memcmp(new_ifname, "disable%d", 9)) { - /* free network queue for Android's timming issue */ - rtw_free_network_queue(padapter, true); - - /* the interface is being "disabled", we can do deeper IPS */ - /* rtw_ips_mode_req(&padapter->pwrctrlpriv, IPS_NORMAL); */ - } -exit: - return ret; - -} - -static int rtw_dbg_port(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - u8 major_cmd, minor_cmd; - u16 arg; - u32 extra_arg, *pdata, val32; - struct adapter *padapter = rtw_netdev_priv(dev); - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - - pdata = (u32 *)&wrqu->data; - - val32 = *pdata; - arg = (u16)(val32&0x0000ffff); - major_cmd = (u8)(val32>>24); - minor_cmd = (u8)((val32>>16)&0x00ff); - - extra_arg = *(pdata+1); - - switch (major_cmd) { - case 0x70:/* read_reg */ - switch (minor_cmd) { - case 1: - break; - case 2: - break; - case 4: - break; - } - break; - case 0x71:/* write_reg */ - switch (minor_cmd) { - case 1: - rtw_write8(padapter, arg, extra_arg); - break; - case 2: - rtw_write16(padapter, arg, extra_arg); - break; - case 4: - rtw_write32(padapter, arg, extra_arg); - break; - } - break; - case 0x72:/* read_bb */ - break; - case 0x73:/* write_bb */ - rtw_hal_write_bbreg(padapter, arg, 0xffffffff, extra_arg); - break; - case 0x74:/* read_rf */ - break; - case 0x75:/* write_rf */ - rtw_hal_write_rfreg(padapter, minor_cmd, arg, 0xffffffff, extra_arg); - break; - - case 0x76: - switch (minor_cmd) { - case 0x00: /* normal mode, */ - padapter->recvpriv.is_signal_dbg = 0; - break; - case 0x01: /* dbg mode */ - padapter->recvpriv.is_signal_dbg = 1; - extra_arg = extra_arg > 100 ? 100 : extra_arg; - padapter->recvpriv.signal_strength_dbg = extra_arg; - break; - } - break; - case 0x78: /* IOL test */ - break; - case 0x79: - { - /* - * dbg 0x79000000 [value], set RESP_TXAGC to + value, value:0~15 - * dbg 0x79010000 [value], set RESP_TXAGC to - value, value:0~15 - */ - u8 value = extra_arg & 0x0f; - u8 sign = minor_cmd; - u16 write_value = 0; - - if (sign) - value = value | 0x10; - - write_value = value | (value << 5); - rtw_write16(padapter, 0x6d9, write_value); - } - break; - case 0x7a: - receive_disconnect(padapter, pmlmeinfo->network.mac_address - , WLAN_REASON_EXPIRATION_CHK); - break; - case 0x7F: - switch (minor_cmd) { - case 0x0: - break; - case 0x01: - break; - case 0x02: - break; - case 0x03: - break; - case 0x04: - - break; - case 0x05: - break; - case 0x06: - { - u32 ODMFlag; - rtw_hal_get_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); - ODMFlag = (u32)(0x0f&arg); - rtw_hal_set_hwreg(padapter, HW_VAR_DM_FLAG, (u8 *)(&ODMFlag)); - } - break; - case 0x07: - break; - case 0x08: - { - } - break; - case 0x09: - break; - case 0x0a: - { - int max_mac_id = 0; - max_mac_id = rtw_search_max_mac_id(padapter); - printk("%s ==> max_mac_id = %d\n", __func__, max_mac_id); - } - break; - case 0x0b: /* Enable = 1, Disable = 0 driver control vrtl_carrier_sense. */ - if (arg == 0) { - padapter->driver_vcs_en = 0; - } else if (arg == 1) { - padapter->driver_vcs_en = 1; - - if (extra_arg > 2) - padapter->driver_vcs_type = 1; - else - padapter->driver_vcs_type = extra_arg; - } - break; - case 0x0c:/* dump rx/tx packet */ - { - if (arg == 0) - /* pHalData->bDumpRxPkt =extra_arg; */ - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_RXPKT, &(extra_arg)); - else if (arg == 1) - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DUMP_TXPKT, &(extra_arg)); - } - break; - case 0x0e: - { - if (arg == 0) { - padapter->driver_rx_ampdu_factor = 0xFF; - } else if (arg == 1) { - - if ((extra_arg & 0x03) > 0x03) - padapter->driver_rx_ampdu_factor = 0xFF; - else - padapter->driver_rx_ampdu_factor = extra_arg; - } - } - break; - - case 0x10:/* driver version display */ - netdev_dbg(dev, "%s %s\n", "rtl8723bs", DRIVERVERSION); - break; - case 0x11:/* dump linked status */ - { - linked_info_dump(padapter, extra_arg); - } - break; - case 0x12: /* set rx_stbc */ - { - struct registry_priv *pregpriv = &padapter->registrypriv; - /* 0: disable, bit(0):enable 2.4g */ - /* default is set to enable 2.4GHZ */ - if (extra_arg == 0 || extra_arg == 1) - pregpriv->rx_stbc = extra_arg; - } - break; - case 0x13: /* set ampdu_enable */ - { - struct registry_priv *pregpriv = &padapter->registrypriv; - /* 0: disable, 0x1:enable (but wifi_spec should be 0), 0x2: force enable (don't care wifi_spec) */ - if (extra_arg < 3) - pregpriv->ampdu_enable = extra_arg; - } - break; - case 0x14: - { - } - break; - case 0x16: - { - if (arg == 0xff) { - rtw_odm_dbg_comp_msg(padapter); - } else { - u64 dbg_comp = (u64)extra_arg; - rtw_odm_dbg_comp_set(padapter, dbg_comp); - } - } - break; -#ifdef DBG_FIXED_CHAN - case 0x17: - { - struct mlme_ext_priv *pmlmeext = &(padapter->mlmeextpriv); - printk("===> Fixed channel to %d\n", extra_arg); - pmlmeext->fixed_chan = extra_arg; - - } - break; -#endif - case 0x18: - { - printk("===> Switch USB Mode %d\n", extra_arg); - rtw_hal_set_hwreg(padapter, HW_VAR_USB_MODE, (u8 *)&extra_arg); - } - break; - case 0x19: - { - struct registry_priv *pregistrypriv = &padapter->registrypriv; - /* extra_arg : */ - /* BIT0: Enable VHT LDPC Rx, BIT1: Enable VHT LDPC Tx, */ - /* BIT4: Enable HT LDPC Rx, BIT5: Enable HT LDPC Tx */ - if (arg == 0) - pregistrypriv->ldpc_cap = 0x00; - else if (arg == 1) - pregistrypriv->ldpc_cap = (u8)(extra_arg&0x33); - } - break; - case 0x1a: - { - struct registry_priv *pregistrypriv = &padapter->registrypriv; - /* extra_arg : */ - /* BIT0: Enable VHT STBC Rx, BIT1: Enable VHT STBC Tx, */ - /* BIT4: Enable HT STBC Rx, BIT5: Enable HT STBC Tx */ - if (arg == 0) - pregistrypriv->stbc_cap = 0x00; - else if (arg == 1) - pregistrypriv->stbc_cap = (u8)(extra_arg&0x33); - } - break; - case 0x1b: - { - struct registry_priv *pregistrypriv = &padapter->registrypriv; - - if (arg == 0) { - init_mlme_default_rate_set(padapter); - pregistrypriv->ht_enable = (u8)rtw_ht_enable; - } else if (arg == 1) { - - int i; - u8 max_rx_rate; + break; + case WPA_CIPHER_CCMP: + padapter->securitypriv.dot11PrivacyAlgrthm = _AES_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption3Enabled; + break; + case WPA_CIPHER_WEP104: + padapter->securitypriv.dot11PrivacyAlgrthm = _WEP104_; + padapter->securitypriv.ndisencryptstatus = Ndis802_11Encryption1Enabled; + break; + } - max_rx_rate = (u8)extra_arg; + _clr_fwstate_(&padapter->mlmepriv, WIFI_UNDER_WPS); + {/* set wps_ie */ + u16 cnt = 0; + u8 eid, wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - if (max_rx_rate < 0xc) { /* max_rx_rate < MSC0 -> B or G -> disable HT */ - pregistrypriv->ht_enable = 0; - for (i = 0; i < NumRates; i++) { - if (pmlmeext->datarate[i] > max_rx_rate) - pmlmeext->datarate[i] = 0xff; - } + while (cnt < ielen) { + eid = buf[cnt]; - } - else if (max_rx_rate < 0x1c) { /* mcs0~mcs15 */ - u32 mcs_bitmap = 0x0; + if ((eid == WLAN_EID_VENDOR_SPECIFIC) && (!memcmp(&buf[cnt+2], wps_oui, 4))) { + padapter->securitypriv.wps_ie_len = ((buf[cnt+1]+2) < MAX_WPS_IE_LEN) ? (buf[cnt+1]+2):MAX_WPS_IE_LEN; - for (i = 0; i < ((max_rx_rate + 1) - 0xc); i++) - mcs_bitmap |= BIT(i); + memcpy(padapter->securitypriv.wps_ie, &buf[cnt], padapter->securitypriv.wps_ie_len); - set_mcs_rate_by_mask(pmlmeext->default_supported_mcs_set, mcs_bitmap); - } - } - } - break; - case 0x1c: /* enable/disable driver control AMPDU Density for peer sta's rx */ - { - if (arg == 0) { - padapter->driver_ampdu_spacing = 0xFF; - } else if (arg == 1) { - - if (extra_arg > 0x07) - padapter->driver_ampdu_spacing = 0xFF; - else - padapter->driver_ampdu_spacing = extra_arg; - } - } - break; - case 0x23: - { - padapter->bNotifyChannelChange = extra_arg; - break; - } - case 0x24: - { - break; - } - case 0xaa: - { - if ((extra_arg & 0x7F) > 0x3F) - extra_arg = 0xFF; - padapter->fix_rate = extra_arg; - } - break; - case 0xdd:/* registers dump , 0 for mac reg, 1 for bb reg, 2 for rf reg */ - { - if (extra_arg == 0) - mac_reg_dump(padapter); - else if (extra_arg == 1) - bb_reg_dump(padapter); - else if (extra_arg == 2) - rf_reg_dump(padapter); - } - break; + set_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS); - case 0xee:/* turn on/off dynamic funcs */ - { - u32 odm_flag; - - if (0xf == extra_arg) { - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); - } else { - /*extra_arg = 0 - disable all dynamic func - extra_arg = 1 - disable DIG - extra_arg = 2 - disable tx power tracking - extra_arg = 3 - turn on all dynamic func - */ - rtw_hal_set_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &(extra_arg)); - rtw_hal_get_def_var(padapter, HAL_DEF_DBG_DM_FUNC, &odm_flag); - } - } - break; + cnt += buf[cnt+1]+2; - case 0xfd: - rtw_write8(padapter, 0xc50, arg); - rtw_write8(padapter, 0xc58, arg); - break; - case 0xfe: - break; - case 0xff: - { - } break; + } else { + cnt += buf[cnt+1]+2; /* goto next */ + } } - break; - default: - break; + } } + /* TKIP and AES disallow multicast packets until installing group key */ + if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ + || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ + || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + /* WPS open need to enable multicast */ + /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */ + rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr); + +exit: - return 0; + kfree(buf); + return ret; } static int wpa_set_param(struct net_device *dev, u8 name, u32 value) @@ -3713,763 +1373,8 @@ static int rtw_hostapd_ioctl(struct net_device *dev, struct iw_point *p) return ret; } -static int rtw_wx_set_priv(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *awrq, - char *extra) -{ - -#ifdef DEBUG_RTW_WX_SET_PRIV - char *ext_dbg; -#endif - - int ret = 0; - int len = 0; - char *ext; - - struct adapter *padapter = rtw_netdev_priv(dev); - struct iw_point *dwrq = (struct iw_point *)awrq; - - if (dwrq->length == 0) - return -EFAULT; - - len = dwrq->length; - ext = vmalloc(len); - if (!ext) - return -ENOMEM; - - if (copy_from_user(ext, dwrq->pointer, len)) { - vfree(ext); - return -EFAULT; - } - - #ifdef DEBUG_RTW_WX_SET_PRIV - ext_dbg = vmalloc(len); - if (!ext_dbg) { - vfree(ext, len); - return -ENOMEM; - } - - memcpy(ext_dbg, ext, len); - #endif - - /* added for wps2.0 @20110524 */ - if (dwrq->flags == 0x8766 && len > 8) { - u32 cp_sz; - struct mlme_priv *pmlmepriv = &(padapter->mlmepriv); - u8 *probereq_wpsie = ext; - int probereq_wpsie_len = len; - u8 wps_oui[4] = {0x0, 0x50, 0xf2, 0x04}; - - if ((WLAN_EID_VENDOR_SPECIFIC == probereq_wpsie[0]) && - (!memcmp(&probereq_wpsie[2], wps_oui, 4))) { - cp_sz = probereq_wpsie_len > MAX_WPS_IE_LEN ? MAX_WPS_IE_LEN : probereq_wpsie_len; - - if (pmlmepriv->wps_probe_req_ie) { - pmlmepriv->wps_probe_req_ie_len = 0; - kfree(pmlmepriv->wps_probe_req_ie); - pmlmepriv->wps_probe_req_ie = NULL; - } - - pmlmepriv->wps_probe_req_ie = rtw_malloc(cp_sz); - if (pmlmepriv->wps_probe_req_ie == NULL) { - printk("%s()-%d: rtw_malloc() ERROR!\n", __func__, __LINE__); - ret = -EINVAL; - goto FREE_EXT; - - } - - memcpy(pmlmepriv->wps_probe_req_ie, probereq_wpsie, cp_sz); - pmlmepriv->wps_probe_req_ie_len = cp_sz; - - } - - goto FREE_EXT; - - } - - if (len >= WEXT_CSCAN_HEADER_SIZE - && !memcmp(ext, WEXT_CSCAN_HEADER, WEXT_CSCAN_HEADER_SIZE)) { - ret = rtw_wx_set_scan(dev, info, awrq, ext); - goto FREE_EXT; - } - -FREE_EXT: - - vfree(ext); - #ifdef DEBUG_RTW_WX_SET_PRIV - vfree(ext_dbg); - #endif - - return ret; - -} - -static int rtw_pm_set(struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - int ret = 0; - unsigned mode = 0; - struct adapter *padapter = rtw_netdev_priv(dev); - - if (!memcmp(extra, "lps =", 4)) { - sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_lps(padapter, mode); - } else if (!memcmp(extra, "ips =", 4)) { - sscanf(extra+4, "%u", &mode); - ret = rtw_pm_set_ips(padapter, mode); - } else { - ret = -EINVAL; - } - - return ret; -} - -static int rtw_test( - struct net_device *dev, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra) -{ - u32 len; - u8 *pbuf, *pch; - char *ptmp; - u8 *delim = ","; - struct adapter *padapter = rtw_netdev_priv(dev); - - - len = wrqu->data.length; - - pbuf = rtw_zmalloc(len); - if (!pbuf) - return -ENOMEM; - - if (copy_from_user(pbuf, wrqu->data.pointer, len)) { - kfree(pbuf); - return -EFAULT; - } - - ptmp = (char *)pbuf; - pch = strsep(&ptmp, delim); - if ((pch == NULL) || (strlen(pch) == 0)) { - kfree(pbuf); - return -EFAULT; - } - - if (strcmp(pch, "bton") == 0) - hal_btcoex_SetManualControl(padapter, false); - - if (strcmp(pch, "btoff") == 0) - hal_btcoex_SetManualControl(padapter, true); - - if (strcmp(pch, "h2c") == 0) { - u8 param[8]; - u8 count = 0; - u32 tmp; - u8 i; - u32 pos; - s32 ret; - - - do { - pch = strsep(&ptmp, delim); - if ((pch == NULL) || (strlen(pch) == 0)) - break; - - sscanf(pch, "%x", &tmp); - param[count++] = (u8)tmp; - } while (count < 8); - - if (count == 0) { - kfree(pbuf); - return -EFAULT; - } - - ret = rtw_hal_fill_h2c_cmd(padapter, param[0], count-1, ¶m[1]); - - pos = sprintf(extra, "H2C ID = 0x%02x content =", param[0]); - for (i = 1; i < count; i++) - pos += sprintf(extra+pos, "%02x,", param[i]); - extra[pos] = 0; - pos--; - pos += sprintf(extra+pos, " %s", ret == _FAIL?"FAIL":"OK"); - - wrqu->data.length = strlen(extra) + 1; - } - - kfree(pbuf); - return 0; -} - -static iw_handler rtw_handlers[] = { - NULL, /* SIOCSIWCOMMIT */ - rtw_wx_get_name, /* SIOCGIWNAME */ - dummy, /* SIOCSIWNWID */ - dummy, /* SIOCGIWNWID */ - rtw_wx_set_freq, /* SIOCSIWFREQ */ - rtw_wx_get_freq, /* SIOCGIWFREQ */ - rtw_wx_set_mode, /* SIOCSIWMODE */ - rtw_wx_get_mode, /* SIOCGIWMODE */ - dummy, /* SIOCSIWSENS */ - rtw_wx_get_sens, /* SIOCGIWSENS */ - NULL, /* SIOCSIWRANGE */ - rtw_wx_get_range, /* SIOCGIWRANGE */ - rtw_wx_set_priv, /* SIOCSIWPRIV */ - NULL, /* SIOCGIWPRIV */ - NULL, /* SIOCSIWSTATS */ - NULL, /* SIOCGIWSTATS */ - dummy, /* SIOCSIWSPY */ - dummy, /* SIOCGIWSPY */ - NULL, /* SIOCGIWTHRSPY */ - NULL, /* SIOCWIWTHRSPY */ - rtw_wx_set_wap, /* SIOCSIWAP */ - rtw_wx_get_wap, /* SIOCGIWAP */ - rtw_wx_set_mlme, /* request MLME operation; uses struct iw_mlme */ - dummy, /* SIOCGIWAPLIST -- depricated */ - rtw_wx_set_scan, /* SIOCSIWSCAN */ - rtw_wx_get_scan, /* SIOCGIWSCAN */ - rtw_wx_set_essid, /* SIOCSIWESSID */ - rtw_wx_get_essid, /* SIOCGIWESSID */ - dummy, /* SIOCSIWNICKN */ - rtw_wx_get_nick, /* SIOCGIWNICKN */ - NULL, /* -- hole -- */ - NULL, /* -- hole -- */ - rtw_wx_set_rate, /* SIOCSIWRATE */ - rtw_wx_get_rate, /* SIOCGIWRATE */ - rtw_wx_set_rts, /* SIOCSIWRTS */ - rtw_wx_get_rts, /* SIOCGIWRTS */ - rtw_wx_set_frag, /* SIOCSIWFRAG */ - rtw_wx_get_frag, /* SIOCGIWFRAG */ - dummy, /* SIOCSIWTXPOW */ - dummy, /* SIOCGIWTXPOW */ - dummy, /* SIOCSIWRETRY */ - rtw_wx_get_retry, /* SIOCGIWRETRY */ - rtw_wx_set_enc, /* SIOCSIWENCODE */ - rtw_wx_get_enc, /* SIOCGIWENCODE */ - dummy, /* SIOCSIWPOWER */ - rtw_wx_get_power, /* SIOCGIWPOWER */ - NULL, /*---hole---*/ - NULL, /*---hole---*/ - rtw_wx_set_gen_ie, /* SIOCSIWGENIE */ - NULL, /* SIOCGWGENIE */ - rtw_wx_set_auth, /* SIOCSIWAUTH */ - NULL, /* SIOCGIWAUTH */ - rtw_wx_set_enc_ext, /* SIOCSIWENCODEEXT */ - NULL, /* SIOCGIWENCODEEXT */ - rtw_wx_set_pmkid, /* SIOCSIWPMKSA */ - NULL, /*---hole---*/ -}; - -static const struct iw_priv_args rtw_private_args[] = { - { - SIOCIWFIRSTPRIV + 0x0, - IW_PRIV_TYPE_CHAR | 0x7FF, 0, "write" - }, - { - SIOCIWFIRSTPRIV + 0x1, - IW_PRIV_TYPE_CHAR | 0x7FF, - IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "read" - }, - { - SIOCIWFIRSTPRIV + 0x2, 0, 0, "driver_ext" - }, - { - SIOCIWFIRSTPRIV + 0x3, 0, 0, "mp_ioctl" - }, - { - SIOCIWFIRSTPRIV + 0x4, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "apinfo" - }, - { - SIOCIWFIRSTPRIV + 0x5, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "setpid" - }, - { - SIOCIWFIRSTPRIV + 0x6, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_start" - }, -/* for PLATFORM_MT53XX */ - { - SIOCIWFIRSTPRIV + 0x7, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "get_sensitivity" - }, - { - SIOCIWFIRSTPRIV + 0x8, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_prob_req_ie" - }, - { - SIOCIWFIRSTPRIV + 0x9, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "wps_assoc_req_ie" - }, - -/* for RTK_DMP_PLATFORM */ - { - SIOCIWFIRSTPRIV + 0xA, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 1, 0, "channel_plan" - }, - - { - SIOCIWFIRSTPRIV + 0xB, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, 0, "dbg" - }, - { - SIOCIWFIRSTPRIV + 0xC, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 3, 0, "rfw" - }, - { - SIOCIWFIRSTPRIV + 0xD, - IW_PRIV_TYPE_INT | IW_PRIV_SIZE_FIXED | 2, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_FIXED | IFNAMSIZ, "rfr" - }, - { - SIOCIWFIRSTPRIV + 0x10, - IW_PRIV_TYPE_CHAR | 1024, 0, "p2p_set" - }, - { - SIOCIWFIRSTPRIV + 0x11, - IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "p2p_get" - }, - { - SIOCIWFIRSTPRIV + 0x12, 0, 0, "NULL" - }, - { - SIOCIWFIRSTPRIV + 0x13, - IW_PRIV_TYPE_CHAR | 64, IW_PRIV_TYPE_CHAR | 64, "p2p_get2" - }, - { - SIOCIWFIRSTPRIV + 0x14, - IW_PRIV_TYPE_CHAR | 64, 0, "tdls" - }, - { - SIOCIWFIRSTPRIV + 0x15, - IW_PRIV_TYPE_CHAR | 1024, IW_PRIV_TYPE_CHAR | 1024, "tdls_get" - }, - { - SIOCIWFIRSTPRIV + 0x16, - IW_PRIV_TYPE_CHAR | 64, 0, "pm_set" - }, - - {SIOCIWFIRSTPRIV + 0x18, IW_PRIV_TYPE_CHAR | IFNAMSIZ, 0, "rereg_nd_name"}, - {SIOCIWFIRSTPRIV + 0x1A, IW_PRIV_TYPE_CHAR | 1024, 0, "efuse_set"}, - {SIOCIWFIRSTPRIV + 0x1B, IW_PRIV_TYPE_CHAR | 128, IW_PRIV_TYPE_CHAR | IW_PRIV_SIZE_MASK, "efuse_get"}, - { - SIOCIWFIRSTPRIV + 0x1D, - IW_PRIV_TYPE_CHAR | 40, IW_PRIV_TYPE_CHAR | 0x7FF, "test" - }, -}; - -static iw_handler rtw_private_handler[] = { - rtw_wx_write32, /* 0x00 */ - rtw_wx_read32, /* 0x01 */ - rtw_drvext_hdl, /* 0x02 */ - NULL, /* 0x03 */ - -/* for MM DTV platform */ - rtw_get_ap_info, /* 0x04 */ - - rtw_set_pid, /* 0x05 */ - rtw_wps_start, /* 0x06 */ - -/* for PLATFORM_MT53XX */ - rtw_wx_get_sensitivity, /* 0x07 */ - rtw_wx_set_mtk_wps_probe_ie, /* 0x08 */ - rtw_wx_set_mtk_wps_ie, /* 0x09 */ - -/* for RTK_DMP_PLATFORM */ -/* Set Channel depend on the country code */ - rtw_wx_set_channel_plan, /* 0x0A */ - - rtw_dbg_port, /* 0x0B */ - rtw_wx_write_rf, /* 0x0C */ - rtw_wx_read_rf, /* 0x0D */ - rtw_wx_priv_null, /* 0x0E */ - rtw_wx_priv_null, /* 0x0F */ - rtw_p2p_set, /* 0x10 */ - rtw_p2p_get, /* 0x11 */ - NULL, /* 0x12 */ - rtw_p2p_get2, /* 0x13 */ - - NULL, /* 0x14 */ - NULL, /* 0x15 */ - - rtw_pm_set, /* 0x16 */ - rtw_wx_priv_null, /* 0x17 */ - rtw_rereg_nd_name, /* 0x18 */ - rtw_wx_priv_null, /* 0x19 */ - NULL, /* 0x1A */ - NULL, /* 0x1B */ - NULL, /* 0x1C is reserved for hostapd */ - rtw_test, /* 0x1D */ -}; - -static struct iw_statistics *rtw_get_wireless_stats(struct net_device *dev) -{ - struct adapter *padapter = rtw_netdev_priv(dev); - struct iw_statistics *piwstats = &padapter->iwstats; - int tmp_level = 0; - int tmp_qual = 0; - int tmp_noise = 0; - - if (check_fwstate(&padapter->mlmepriv, _FW_LINKED) != true) { - piwstats->qual.qual = 0; - piwstats->qual.level = 0; - piwstats->qual.noise = 0; - } else { - tmp_level = padapter->recvpriv.signal_strength; - tmp_qual = padapter->recvpriv.signal_qual; - tmp_noise = padapter->recvpriv.noise; - - piwstats->qual.level = tmp_level; - piwstats->qual.qual = tmp_qual; - piwstats->qual.noise = tmp_noise; - } - piwstats->qual.updated = IW_QUAL_ALL_UPDATED ;/* IW_QUAL_DBM; */ - - return &padapter->iwstats; -} - -struct iw_handler_def rtw_handlers_def = { - .standard = rtw_handlers, - .num_standard = ARRAY_SIZE(rtw_handlers), -#if defined(CONFIG_WEXT_PRIV) - .private = rtw_private_handler, - .private_args = (struct iw_priv_args *)rtw_private_args, - .num_private = ARRAY_SIZE(rtw_private_handler), - .num_private_args = ARRAY_SIZE(rtw_private_args), -#endif - .get_wireless_stats = rtw_get_wireless_stats, -}; - -/* copy from net/wireless/wext.c start */ -/* ---------------------------------------------------------------- */ -/* - * Calculate size of private arguments - */ -static const char iw_priv_type_size[] = { - 0, /* IW_PRIV_TYPE_NONE */ - 1, /* IW_PRIV_TYPE_BYTE */ - 1, /* IW_PRIV_TYPE_CHAR */ - 0, /* Not defined */ - sizeof(__u32), /* IW_PRIV_TYPE_INT */ - sizeof(struct iw_freq), /* IW_PRIV_TYPE_FLOAT */ - sizeof(struct sockaddr), /* IW_PRIV_TYPE_ADDR */ - 0, /* Not defined */ -}; - -static int get_priv_size(__u16 args) -{ - int num = args & IW_PRIV_SIZE_MASK; - int type = (args & IW_PRIV_TYPE_MASK) >> 12; - - return num * iw_priv_type_size[type]; -} /* copy from net/wireless/wext.c end */ -static int rtw_ioctl_wext_private(struct net_device *dev, union iwreq_data *wrq_data) -{ - int err = 0; - u8 *input = NULL; - u32 input_len = 0; - const char delim[] = " "; - u8 *output = NULL; - u32 output_len = 0; - u32 count = 0; - u8 *buffer = NULL; - u32 buffer_len = 0; - char *ptr = NULL; - u8 cmdname[17] = {0}; /* IFNAMSIZ+1 */ - u32 cmdlen; - s32 len; - u8 *extra = NULL; - u32 extra_size = 0; - - s32 k; - const iw_handler *priv; /* Private ioctl */ - const struct iw_priv_args *priv_args; /* Private ioctl description */ - u32 num_priv_args; /* Number of descriptions */ - iw_handler handler; - int temp; - int subcmd = 0; /* sub-ioctl index */ - int offset = 0; /* Space for sub-ioctl index */ - - union iwreq_data wdata; - - - memcpy(&wdata, wrq_data, sizeof(wdata)); - - input_len = 2048; - input = rtw_zmalloc(input_len); - if (NULL == input) - return -ENOMEM; - if (copy_from_user(input, wdata.data.pointer, input_len)) { - err = -EFAULT; - goto exit; - } - ptr = input; - len = strlen(input); - - sscanf(ptr, "%16s", cmdname); - cmdlen = strlen(cmdname); - - /* skip command string */ - if (cmdlen > 0) - cmdlen += 1; /* skip one space */ - ptr += cmdlen; - len -= cmdlen; - - priv = rtw_private_handler; - priv_args = rtw_private_args; - num_priv_args = ARRAY_SIZE(rtw_private_args); - - if (num_priv_args == 0) { - err = -EOPNOTSUPP; - goto exit; - } - - /* Search the correct ioctl */ - k = -1; - while ((++k < num_priv_args) && strcmp(priv_args[k].name, cmdname)); - - /* If not found... */ - if (k == num_priv_args) { - err = -EOPNOTSUPP; - goto exit; - } - - /* Watch out for sub-ioctls ! */ - if (priv_args[k].cmd < SIOCDEVPRIVATE) { - int j = -1; - - /* Find the matching *real* ioctl */ - while ((++j < num_priv_args) && ((priv_args[j].name[0] != '\0') || - (priv_args[j].set_args != priv_args[k].set_args) || - (priv_args[j].get_args != priv_args[k].get_args))); - - /* If not found... */ - if (j == num_priv_args) { - err = -EINVAL; - goto exit; - } - - /* Save sub-ioctl number */ - subcmd = priv_args[k].cmd; - /* Reserve one int (simplify alignment issues) */ - offset = sizeof(__u32); - /* Use real ioctl definition from now on */ - k = j; - } - - buffer = rtw_zmalloc(4096); - if (NULL == buffer) { - err = -ENOMEM; - goto exit; - } - - /* If we have to set some data */ - if ((priv_args[k].set_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) { - u8 *str; - - switch (priv_args[k].set_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) - break; - sscanf(str, "%i", &temp); - buffer[count++] = (u8)temp; - } while (1); - buffer_len = count; - - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - break; - - case IW_PRIV_TYPE_INT: - /* Fetch args */ - count = 0; - do { - str = strsep(&ptr, delim); - if (NULL == str) - break; - sscanf(str, "%i", &temp); - ((s32 *)buffer)[count++] = (s32)temp; - } while (1); - buffer_len = count * sizeof(s32); - - /* Number of args to fetch */ - wdata.data.length = count; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - break; - - case IW_PRIV_TYPE_CHAR: - if (len > 0) { - /* Size of the string to fetch */ - wdata.data.length = len; - if (wdata.data.length > (priv_args[k].set_args & IW_PRIV_SIZE_MASK)) - wdata.data.length = priv_args[k].set_args & IW_PRIV_SIZE_MASK; - - /* Fetch string */ - memcpy(buffer, ptr, wdata.data.length); - } else { - wdata.data.length = 1; - buffer[0] = '\0'; - } - buffer_len = wdata.data.length; - break; - - default: - err = -1; - goto exit; - } - - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - (wdata.data.length != (priv_args[k].set_args & IW_PRIV_SIZE_MASK))) { - err = -EINVAL; - goto exit; - } - } else { /* if args to set */ - wdata.data.length = 0L; - } - - /* Those two tests are important. They define how the driver - * will have to handle the data */ - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((get_priv_size(priv_args[k].set_args) + offset) <= IFNAMSIZ)) { - /* First case : all SET args fit within wrq */ - if (offset) - wdata.mode = subcmd; - memcpy(wdata.name + offset, buffer, IFNAMSIZ - offset); - } else { - if ((priv_args[k].set_args == 0) && - (priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) { - /* Second case : no SET args, GET args fit within wrq */ - if (offset) - wdata.mode = subcmd; - } else { - /* Third case : args won't fit in wrq, or variable number of args */ - if (copy_to_user(wdata.data.pointer, buffer, buffer_len)) { - err = -EFAULT; - goto exit; - } - wdata.data.flags = subcmd; - } - } - - kfree(input); - input = NULL; - - extra_size = 0; - if (IW_IS_SET(priv_args[k].cmd)) { - /* Size of set arguments */ - extra_size = get_priv_size(priv_args[k].set_args); - - /* Does it fits in iwr ? */ - if ((priv_args[k].set_args & IW_PRIV_SIZE_FIXED) && - ((extra_size + offset) <= IFNAMSIZ)) - extra_size = 0; - } else { - /* Size of get arguments */ - extra_size = get_priv_size(priv_args[k].get_args); - - /* Does it fits in iwr ? */ - if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (extra_size <= IFNAMSIZ)) - extra_size = 0; - } - - if (extra_size == 0) { - extra = (u8 *)&wdata; - kfree(buffer); - buffer = NULL; - } else - extra = buffer; - - handler = priv[priv_args[k].cmd - SIOCIWFIRSTPRIV]; - err = handler(dev, NULL, &wdata, extra); - - /* If we have to get some data */ - if ((priv_args[k].get_args & IW_PRIV_TYPE_MASK) && - (priv_args[k].get_args & IW_PRIV_SIZE_MASK)) { - int j; - int n = 0; /* number of args */ - u8 str[20] = {0}; - - /* Check where is the returned data */ - if ((priv_args[k].get_args & IW_PRIV_SIZE_FIXED) && - (get_priv_size(priv_args[k].get_args) <= IFNAMSIZ)) - n = priv_args[k].get_args & IW_PRIV_SIZE_MASK; - else - n = wdata.data.length; - - output = rtw_zmalloc(4096); - if (NULL == output) { - err = -ENOMEM; - goto exit; - } - - switch (priv_args[k].get_args & IW_PRIV_TYPE_MASK) { - case IW_PRIV_TYPE_BYTE: - /* Display args */ - for (j = 0; j < n; j++) { - len = scnprintf(str, sizeof(str), "%d ", extra[j]); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); - } - break; - - case IW_PRIV_TYPE_INT: - /* Display args */ - for (j = 0; j < n; j++) { - len = scnprintf(str, sizeof(str), "%d ", ((__s32 *)extra)[j]); - output_len = strlen(output); - if ((output_len + len + 1) > 4096) { - err = -E2BIG; - goto exit; - } - memcpy(output+output_len, str, len); - } - break; - - case IW_PRIV_TYPE_CHAR: - /* Display args */ - memcpy(output, extra, n); - break; - - default: - err = -1; - goto exit; - } - - output_len = strlen(output) + 1; - wrq_data->data.length = output_len; - if (copy_to_user(wrq_data->data.pointer, output, output_len)) { - err = -EFAULT; - goto exit; - } - } else { /* if args to set */ - wrq_data->data.length = 0; - } - -exit: - kfree(input); - kfree(buffer); - kfree(output); - - return err; -} - int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) { struct iwreq *wrq = (struct iwreq *)rq; @@ -4482,9 +1387,6 @@ int rtw_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) case RTL_IOCTL_HOSTAPD: ret = rtw_hostapd_ioctl(dev, &wrq->u.data); break; - case SIOCDEVPRIVATE: - ret = rtw_ioctl_wext_private(dev, &wrq->u); - break; default: ret = -EOPNOTSUPP; break; diff --git a/drivers/staging/rtl8723bs/os_dep/os_intfs.c b/drivers/staging/rtl8723bs/os_dep/os_intfs.c index d772a044185d..f78bf174de8e 100644 --- a/drivers/staging/rtl8723bs/os_dep/os_intfs.c +++ b/drivers/staging/rtl8723bs/os_dep/os_intfs.c @@ -474,7 +474,6 @@ struct net_device *rtw_init_netdev(struct adapter *old_padapter) /* pnetdev->tx_timeout = NULL; */ pnetdev->watchdog_timeo = HZ * 3; /* 3 second timeout */ - pnetdev->wireless_handlers = (struct iw_handler_def *)&rtw_handlers_def; /* step 2. */ loadparam(padapter, pnetdev); -- cgit v1.2.3 From fafb8a21a5c9b899b251994332da1eae01bf44ef Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Mon, 23 Aug 2021 16:12:00 +0200 Subject: staging: rtl8723bs: fix code indent issues fix the following post commit hook checkpatch issues: ERROR: code indent should use tabs where possible 2463: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:388: + if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_$ ERROR: code indent should use tabs where possible 2464: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:389: + || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_$ ERROR: code indent should use tabs where possible 2465: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:390: + || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_)$ ERROR: code indent should use tabs where possible 2466: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:391: + /* WPS open need to enable multicast */$ ERROR: code indent should use tabs where possible 2467: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:392: + /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */$ ERROR: code indent should use tabs where possible 2468: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:393: + rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr);$ Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/aa394052c8d81b4a00356adf5f98fc3c81f8b1d9.1629727333.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 790e3b2454e8..5067c2417351 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -385,12 +385,12 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } /* TKIP and AES disallow multicast packets until installing group key */ - if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ - || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ - || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) - /* WPS open need to enable multicast */ - /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */ - rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr); + if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ + || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ + || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + /* WPS open need to enable multicast */ + /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */ + rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr); exit: -- cgit v1.2.3 From 105bc6b94f0587f1d37c5f3581f94455a2e52722 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Mon, 23 Aug 2021 16:12:01 +0200 Subject: staging: rtl8723bs: fix logical continuation issue fix the following post-commit hook checkpatch issue: CHECK: Logical continuations should be on the previous line 52: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:389: + if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ + || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ CHECK: Logical continuations should be on the previous line 53: FILE: drivers/staging/rtl8723bs/os_dep/ioctl_linux.c:390: + || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ + || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/5d4e7ab18005e69e8cc162619149d6fa93568875.1629727333.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 5067c2417351..733c6b93eb8f 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -385,9 +385,9 @@ static int rtw_set_wpa_ie(struct adapter *padapter, char *pie, unsigned short ie } /* TKIP and AES disallow multicast packets until installing group key */ - if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ - || padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ - || padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) + if (padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_ || + padapter->securitypriv.dot11PrivacyAlgrthm == _TKIP_WTMIC_ || + padapter->securitypriv.dot11PrivacyAlgrthm == _AES_) /* WPS open need to enable multicast */ /* check_fwstate(&padapter->mlmepriv, WIFI_UNDER_WPS) == true) */ rtw_hal_set_hwreg(padapter, HW_VAR_OFF_RCR_AM, null_addr); -- cgit v1.2.3 From b516456cedb66439f33c8878f73bf5dad0223471 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Mon, 23 Aug 2021 16:12:02 +0200 Subject: staging: rtl8723bs: remove functions notifying wext events remove functions that once were meant to notify wext events to userspace. Now they are donig nothing useful so just remove them. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/0d745350ff3d411dda329b8c1e2261361570db6e.1629727333.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 4 +-- drivers/staging/rtl8723bs/include/drv_types.h | 3 -- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 38 -------------------------- drivers/staging/rtl8723bs/os_dep/mlme_linux.c | 4 --- 4 files changed, 1 insertion(+), 48 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index 5f25cbf83723..eee250f12df3 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -449,10 +449,8 @@ u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_s res = true; } else { - if (rtw_is_scan_deny(padapter)) { - indicate_wx_scan_complete_event(padapter); + if (rtw_is_scan_deny(padapter)) return _SUCCESS; - } spin_lock_bh(&pmlmepriv->lock); diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index 580028d28c42..ae32963a156d 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -495,9 +495,6 @@ static inline u8 *myid(struct eeprom_priv *peepriv) #include -void rtw_indicate_wx_disassoc_event(struct adapter *padapter); -void rtw_indicate_wx_assoc_event(struct adapter *padapter); -void indicate_wx_scan_complete_event(struct adapter *padapter); int rtw_change_ifname(struct adapter *padapter, const char *ifname); extern char *rtw_initmac; diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c index 733c6b93eb8f..9d4a233a861e 100644 --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -29,44 +29,6 @@ #define WEXT_CSCAN_HOME_DWELL_SECTION 'H' #define WEXT_CSCAN_TYPE_SECTION 'T' -void indicate_wx_scan_complete_event(struct adapter *padapter) -{ - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(union iwreq_data)); -} - - -void rtw_indicate_wx_assoc_event(struct adapter *padapter) -{ - union iwreq_data wrqu; - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv; - struct mlme_ext_info *pmlmeinfo = &(pmlmeext->mlmext_info); - struct wlan_bssid_ex *pnetwork = (struct wlan_bssid_ex *)(&(pmlmeinfo->network)); - - memset(&wrqu, 0, sizeof(union iwreq_data)); - - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - - if (check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true) - memcpy(wrqu.ap_addr.sa_data, pnetwork->mac_address, ETH_ALEN); - else - memcpy(wrqu.ap_addr.sa_data, pmlmepriv->cur_network.network.mac_address, ETH_ALEN); - - netdev_dbg(padapter->pnetdev, "assoc success\n"); -} - -void rtw_indicate_wx_disassoc_event(struct adapter *padapter) -{ - union iwreq_data wrqu; - - memset(&wrqu, 0, sizeof(union iwreq_data)); - - wrqu.ap_addr.sa_family = ARPHRD_ETHER; - eth_zero_addr(wrqu.ap_addr.sa_data); -} - static int wpa_set_auth_algs(struct net_device *dev, u32 value) { struct adapter *padapter = rtw_netdev_priv(dev); diff --git a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c index a4560ba22db1..1341801e5c21 100644 --- a/drivers/staging/rtl8723bs/os_dep/mlme_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/mlme_linux.c @@ -48,7 +48,6 @@ void rtw_os_indicate_connect(struct adapter *adapter) rtw_cfg80211_indicate_connect(adapter); } - rtw_indicate_wx_assoc_event(adapter); netif_carrier_on(adapter->pnetdev); if (adapter->pid[2] != 0) @@ -58,7 +57,6 @@ void rtw_os_indicate_connect(struct adapter *adapter) void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted) { rtw_cfg80211_indicate_scan_done(padapter, aborted); - indicate_wx_scan_complete_event(padapter); } static struct rt_pmkid_list backupPMKIDList[NUM_PMKID_CACHE]; @@ -129,8 +127,6 @@ void rtw_os_indicate_disconnect(struct adapter *adapter) rtw_cfg80211_indicate_disconnect(adapter); - rtw_indicate_wx_disassoc_event(adapter); - /* modify for CONFIG_IEEE80211W, none 11w also can use the same command */ rtw_reset_securitypriv_cmd(adapter); } -- cgit v1.2.3 From 07abf8b41eaf28ea6e342730b91d5a62fa914431 Mon Sep 17 00:00:00 2001 From: Fabio Aiuto Date: Mon, 23 Aug 2021 16:12:03 +0200 Subject: staging: rtl8723bs: remove unused rtw_set_802_11_bssid() function remove rtw_set_802_11_bssid() function left unused after wext routines removal. Signed-off-by: Fabio Aiuto Link: https://lore.kernel.org/r/b3d1756b6ae4be7ca4fc50e12bd7e10587a6020c.1629727333.git.fabioaiuto83@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_ioctl_set.c | 64 ----------------------- drivers/staging/rtl8723bs/include/rtw_ioctl_set.h | 1 - 2 files changed, 65 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c index eee250f12df3..5cfde7176617 100644 --- a/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c +++ b/drivers/staging/rtl8723bs/core/rtw_ioctl_set.c @@ -134,70 +134,6 @@ exit: return ret; } -u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid) -{ - u8 status = _SUCCESS; - - struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - - netdev_dbg(padapter->pnetdev, "set bssid:%pM\n", bssid); - - if ((bssid[0] == 0x00 && bssid[1] == 0x00 && bssid[2] == 0x00 && bssid[3] == 0x00 && bssid[4] == 0x00 && bssid[5] == 0x00) || - (bssid[0] == 0xFF && bssid[1] == 0xFF && bssid[2] == 0xFF && bssid[3] == 0xFF && bssid[4] == 0xFF && bssid[5] == 0xFF)) { - status = _FAIL; - goto exit; - } - - spin_lock_bh(&pmlmepriv->lock); - - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) - goto handle_tkip_countermeasure; - else if (check_fwstate(pmlmepriv, _FW_UNDER_LINKING) == true) - goto release_mlme_lock; - - if (check_fwstate(pmlmepriv, _FW_LINKED|WIFI_ADHOC_MASTER_STATE) == true) { - if (!memcmp(&pmlmepriv->cur_network.network.mac_address, bssid, ETH_ALEN)) { - if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) == false) - goto release_mlme_lock;/* it means driver is in WIFI_ADHOC_MASTER_STATE, we needn't create bss again. */ - } else { - rtw_disassoc_cmd(padapter, 0, true); - - if (check_fwstate(pmlmepriv, _FW_LINKED) == true) - rtw_indicate_disconnect(padapter); - - rtw_free_assoc_resources(padapter, 1); - - if ((check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE) == true)) { - _clr_fwstate_(pmlmepriv, WIFI_ADHOC_MASTER_STATE); - set_fwstate(pmlmepriv, WIFI_ADHOC_STATE); - } - } - } - -handle_tkip_countermeasure: - if (rtw_handle_tkip_countermeasure(padapter, __func__) == _FAIL) { - status = _FAIL; - goto release_mlme_lock; - } - - memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(&pmlmepriv->assoc_bssid, bssid, ETH_ALEN); - pmlmepriv->assoc_by_bssid = true; - - if (check_fwstate(pmlmepriv, _FW_UNDER_SURVEY) == true) - pmlmepriv->to_join = true; - else - status = rtw_do_join(padapter); - -release_mlme_lock: - spin_unlock_bh(&pmlmepriv->lock); - -exit: - - return status; -} - u8 rtw_set_802_11_ssid(struct adapter *padapter, struct ndis_802_11_ssid *ssid) { u8 status = _SUCCESS; diff --git a/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h b/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h index 31424bf2d926..ab349de733c8 100644 --- a/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h +++ b/drivers/staging/rtl8723bs/include/rtw_ioctl_set.h @@ -11,7 +11,6 @@ typedef u8 NDIS_802_11_PMKID_VALUE[16]; u8 rtw_set_802_11_authentication_mode(struct adapter *pdapter, enum ndis_802_11_authentication_mode authmode); -u8 rtw_set_802_11_bssid(struct adapter *padapter, u8 *bssid); u8 rtw_set_802_11_add_wep(struct adapter *padapter, struct ndis_802_11_wep *wep); u8 rtw_set_802_11_disassociate(struct adapter *padapter); u8 rtw_set_802_11_bssid_list_scan(struct adapter *padapter, struct ndis_802_11_ssid *pssid, int ssid_max_num); -- cgit v1.2.3 From 7dfe9fac786769e1a49fa350158d39b4fef237ba Mon Sep 17 00:00:00 2001 From: Len Baker Date: Tue, 24 Aug 2021 09:25:43 +0200 Subject: staging/rtl8192u: Avoid CamelCase in names of variables Avoid CameCase in the names of all local variables inside the function rtl8192_phy_SwChnlStepByStep(). Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210824072545.7321-2-len.baker@gmx.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 95 +++++++++++++++++------------------ 1 file changed, 47 insertions(+), 48 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 37b82553412e..6a67708cdd89 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1185,30 +1185,30 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 *stage, u8 *step, u32 *delay) { struct r8192_priv *priv = ieee80211_priv(dev); - struct sw_chnl_cmd *PreCommonCmd; - u32 PreCommonCmdCnt; - struct sw_chnl_cmd *PostCommonCmd; - u32 PostCommonCmdCnt; - struct sw_chnl_cmd *RfDependCmd; - u32 RfDependCmdCnt; - struct sw_chnl_cmd *CurrentCmd = NULL; - u8 e_rfpath; - bool ret; - - PreCommonCmd = kzalloc(sizeof(*PreCommonCmd) * MAX_PRECMD_CNT, GFP_KERNEL); - if (!PreCommonCmd) + struct sw_chnl_cmd *pre_cmd; + u32 pre_cmd_cnt; + struct sw_chnl_cmd *post_cmd; + u32 post_cmd_cnt; + struct sw_chnl_cmd *rf_cmd; + u32 rf_cmd_cnt; + struct sw_chnl_cmd *current_cmd = NULL; + u8 e_rfpath; + bool ret; + + pre_cmd = kzalloc(sizeof(*pre_cmd) * MAX_PRECMD_CNT, GFP_KERNEL); + if (!pre_cmd) return false; - PostCommonCmd = kzalloc(sizeof(*PostCommonCmd) * MAX_POSTCMD_CNT, GFP_KERNEL); - if (!PostCommonCmd) { - kfree(PreCommonCmd); + post_cmd = kzalloc(sizeof(*post_cmd) * MAX_POSTCMD_CNT, GFP_KERNEL); + if (!post_cmd) { + kfree(pre_cmd); return false; } - RfDependCmd = kzalloc(sizeof(*RfDependCmd) * MAX_RFDEPENDCMD_CNT, GFP_KERNEL); - if (!RfDependCmd) { - kfree(PreCommonCmd); - kfree(PostCommonCmd); + rf_cmd = kzalloc(sizeof(*rf_cmd) * MAX_RFDEPENDCMD_CNT, GFP_KERNEL); + if (!rf_cmd) { + kfree(pre_cmd); + kfree(post_cmd); return false; } @@ -1225,21 +1225,20 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, /* FIXME: need to check whether channel is legal or not here */ /* <1> Fill up pre common command. */ - PreCommonCmdCnt = 0; - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + pre_cmd_cnt = 0; + rtl8192_phy_SetSwChnlCmdArray(pre_cmd, pre_cmd_cnt++, MAX_PRECMD_CNT, CMD_ID_SET_TX_PWR_LEVEL, 0, 0, 0); - rtl8192_phy_SetSwChnlCmdArray(PreCommonCmd, PreCommonCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(pre_cmd, pre_cmd_cnt++, MAX_PRECMD_CNT, CMD_ID_END, 0, 0, 0); /* <2> Fill up post common command. */ - PostCommonCmdCnt = 0; - - rtl8192_phy_SetSwChnlCmdArray(PostCommonCmd, PostCommonCmdCnt++, + post_cmd_cnt = 0; + rtl8192_phy_SetSwChnlCmdArray(post_cmd, post_cmd_cnt++, MAX_POSTCMD_CNT, CMD_ID_END, 0, 0, 0); /* <3> Fill up RF dependent command. */ - RfDependCmdCnt = 0; + rf_cmd_cnt = 0; switch (priv->rf_chip) { case RF_8225: if (!(channel >= 1 && channel <= 14)) { @@ -1249,13 +1248,13 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, ret = true; goto out; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(rf_cmd, rf_cmd_cnt++, MAX_RFDEPENDCMD_CNT, CMD_ID_RF_WRITE_REG, rZebra1_Channel, RF_CHANNEL_TABLE_ZEBRA[channel], 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(rf_cmd, rf_cmd_cnt++, MAX_RFDEPENDCMD_CNT, CMD_ID_END, 0, 0, 0); break; @@ -1269,11 +1268,11 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, ret = true; goto out; } - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(rf_cmd, rf_cmd_cnt++, MAX_RFDEPENDCMD_CNT, CMD_ID_RF_WRITE_REG, rZebra1_Channel, channel, 10); - rtl8192_phy_SetSwChnlCmdArray(RfDependCmd, RfDependCmdCnt++, + rtl8192_phy_SetSwChnlCmdArray(rf_cmd, rf_cmd_cnt++, MAX_RFDEPENDCMD_CNT, CMD_ID_END, 0, 0, 0); break; @@ -1290,19 +1289,19 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, do { switch (*stage) { case 0: - CurrentCmd = &PreCommonCmd[*step]; + current_cmd = &pre_cmd[*step]; break; case 1: - CurrentCmd = &RfDependCmd[*step]; + current_cmd = &rf_cmd[*step]; break; case 2: - CurrentCmd = &PostCommonCmd[*step]; + current_cmd = &post_cmd[*step]; break; } - if (CurrentCmd->cmd_id == CMD_ID_END) { + if (current_cmd->cmd_id == CMD_ID_END) { if ((*stage) == 2) { - (*delay) = CurrentCmd->ms_delay; + *delay = current_cmd->ms_delay; ret = true; goto out; } @@ -1311,31 +1310,31 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, continue; } - switch (CurrentCmd->cmd_id) { + switch (current_cmd->cmd_id) { case CMD_ID_SET_TX_PWR_LEVEL: if (priv->card_8192_version == VERSION_819XU_A) /* consider it later! */ rtl8192_SetTxPowerLevel(dev, channel); break; case CMD_ID_WRITE_PORT_ULONG: - write_nic_dword(dev, CurrentCmd->para_1, - CurrentCmd->para_2); + write_nic_dword(dev, current_cmd->para_1, + current_cmd->para_2); break; case CMD_ID_WRITE_PORT_USHORT: - write_nic_word(dev, CurrentCmd->para_1, - (u16)CurrentCmd->para_2); + write_nic_word(dev, current_cmd->para_1, + (u16)current_cmd->para_2); break; case CMD_ID_WRITE_PORT_UCHAR: - write_nic_byte(dev, CurrentCmd->para_1, - (u8)CurrentCmd->para_2); + write_nic_byte(dev, current_cmd->para_1, + (u8)current_cmd->para_2); break; case CMD_ID_RF_WRITE_REG: for (e_rfpath = 0; e_rfpath < RF90_PATH_MAX; e_rfpath++) { rtl8192_phy_SetRFReg(dev, (enum rf90_radio_path_e)e_rfpath, - CurrentCmd->para_1, + current_cmd->para_1, bZebra1_ChannelNum, - CurrentCmd->para_2); + current_cmd->para_2); } break; default: @@ -1345,14 +1344,14 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, break; } while (true); - (*delay) = CurrentCmd->ms_delay; + *delay = current_cmd->ms_delay; (*step)++; ret = false; out: - kfree(PreCommonCmd); - kfree(PostCommonCmd); - kfree(RfDependCmd); + kfree(pre_cmd); + kfree(post_cmd); + kfree(rf_cmd); return ret; } -- cgit v1.2.3 From c4b30776bf2941e0d17d3f164e54e553b2456888 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Tue, 24 Aug 2021 10:59:58 +0200 Subject: staging/rtl8192u: Initialize variables in the definition block Initialize the pre_cmd_cnt, post_cmd_cnt and rf_cmd_cnt variables in the definition block as it is not necessary to do this in the middle of the function. Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210824073643.GA7396@titan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index 6a67708cdd89..ff6fe2ee3349 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1186,11 +1186,11 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, { struct r8192_priv *priv = ieee80211_priv(dev); struct sw_chnl_cmd *pre_cmd; - u32 pre_cmd_cnt; + u32 pre_cmd_cnt = 0; struct sw_chnl_cmd *post_cmd; - u32 post_cmd_cnt; + u32 post_cmd_cnt = 0; struct sw_chnl_cmd *rf_cmd; - u32 rf_cmd_cnt; + u32 rf_cmd_cnt = 0; struct sw_chnl_cmd *current_cmd = NULL; u8 e_rfpath; bool ret; @@ -1225,7 +1225,6 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, /* FIXME: need to check whether channel is legal or not here */ /* <1> Fill up pre common command. */ - pre_cmd_cnt = 0; rtl8192_phy_SetSwChnlCmdArray(pre_cmd, pre_cmd_cnt++, MAX_PRECMD_CNT, CMD_ID_SET_TX_PWR_LEVEL, 0, 0, 0); @@ -1233,12 +1232,10 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, MAX_PRECMD_CNT, CMD_ID_END, 0, 0, 0); /* <2> Fill up post common command. */ - post_cmd_cnt = 0; rtl8192_phy_SetSwChnlCmdArray(post_cmd, post_cmd_cnt++, MAX_POSTCMD_CNT, CMD_ID_END, 0, 0, 0); /* <3> Fill up RF dependent command. */ - rf_cmd_cnt = 0; switch (priv->rf_chip) { case RF_8225: if (!(channel >= 1 && channel <= 14)) { -- cgit v1.2.3 From 07e7f36da8abb4563d145399270c0b92f8d79ff7 Mon Sep 17 00:00:00 2001 From: Len Baker Date: Tue, 24 Aug 2021 11:00:39 +0200 Subject: staging/rtl8192u: Prefer kcalloc over open coded arithmetic As noted in the "Deprecated Interfaces, Language Features, Attributes, and Conventions" documentation [1], size calculations (especially multiplication) should not be performed in memory allocator (or similar) function arguments due to the risk of them overflowing. This could lead to values wrapping around and a smaller allocation being made than the caller was expecting. Using those allocations could lead to linear overflows of heap memory and other misbehaviors. In this case these aren't actually dynamic sizes: both sides of the multiplication are constant values. However it is best to refactor these anyway, just to keep the open-coded math idiom out of code. So, use the purpose specific kcalloc() function instead of the argument size * count in the kzalloc() function. [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments Reviewed-by: Kees Cook Signed-off-by: Len Baker Link: https://lore.kernel.org/r/20210824090039.GA7999@titan Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8192u/r819xU_phy.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8192u/r819xU_phy.c b/drivers/staging/rtl8192u/r819xU_phy.c index ff6fe2ee3349..97f4d89500ae 100644 --- a/drivers/staging/rtl8192u/r819xU_phy.c +++ b/drivers/staging/rtl8192u/r819xU_phy.c @@ -1195,17 +1195,17 @@ static u8 rtl8192_phy_SwChnlStepByStep(struct net_device *dev, u8 channel, u8 e_rfpath; bool ret; - pre_cmd = kzalloc(sizeof(*pre_cmd) * MAX_PRECMD_CNT, GFP_KERNEL); + pre_cmd = kcalloc(MAX_PRECMD_CNT, sizeof(*pre_cmd), GFP_KERNEL); if (!pre_cmd) return false; - post_cmd = kzalloc(sizeof(*post_cmd) * MAX_POSTCMD_CNT, GFP_KERNEL); + post_cmd = kcalloc(MAX_POSTCMD_CNT, sizeof(*post_cmd), GFP_KERNEL); if (!post_cmd) { kfree(pre_cmd); return false; } - rf_cmd = kzalloc(sizeof(*rf_cmd) * MAX_RFDEPENDCMD_CNT, GFP_KERNEL); + rf_cmd = kcalloc(MAX_RFDEPENDCMD_CNT, sizeof(*rf_cmd), GFP_KERNEL); if (!rf_cmd) { kfree(pre_cmd); kfree(post_cmd); -- cgit v1.2.3 From 9bfb54a8c88e025b9ae1fe19afd6500a206dbba5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Wed, 25 Aug 2021 12:08:42 +0200 Subject: staging: rtl8723bs: remove header file ethernet.h The header file ehternet.h defines only two constants. #define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ #define LLC_HEADER_SIZE 6 /* LLC Header Length */ Both are only used in the file core/rtw_recv.c and ETHERNET_HEADER_SIZE just duplicates the in-kernel constant ETH_HLEN. Replace the usage of ETHERNET_HEADER_SIZE with ETH_HLEN, move the definition of LLC_HEADER_SIZE into rtw_rev.h (renamed to LLC_HEADER_LENGTH) and remove the now unused header file ethernet.h. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210825100842.13217-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/rtl8723bs/core/rtw_recv.c | 6 +++--- drivers/staging/rtl8723bs/include/drv_types.h | 1 - drivers/staging/rtl8723bs/include/ethernet.h | 14 -------------- drivers/staging/rtl8723bs/include/rtw_recv.h | 2 ++ 4 files changed, 5 insertions(+), 18 deletions(-) delete mode 100644 drivers/staging/rtl8723bs/include/ethernet.h (limited to 'drivers/staging') diff --git a/drivers/staging/rtl8723bs/core/rtw_recv.c b/drivers/staging/rtl8723bs/core/rtw_recv.c index d4c1725718d9..5b0a596eefb7 100644 --- a/drivers/staging/rtl8723bs/core/rtw_recv.c +++ b/drivers/staging/rtl8723bs/core/rtw_recv.c @@ -480,7 +480,7 @@ static union recv_frame *portctrl(struct adapter *adapter, union recv_frame *pre prtnframe = precv_frame; /* get ether_type */ - ptr = ptr+pfhdr->attrib.hdrlen+pfhdr->attrib.iv_len+LLC_HEADER_SIZE; + ptr = ptr + pfhdr->attrib.hdrlen + pfhdr->attrib.iv_len + LLC_HEADER_LENGTH; memcpy(&be_tmp, ptr, 2); ether_type = ntohs(be_tmp); @@ -1485,7 +1485,7 @@ static signed int validate_recv_frame(struct adapter *adapter, union recv_frame /* dump eapol */ rtw_hal_get_def_var(adapter, HAL_DEF_DBG_DUMP_RXPKT, &(bDumpRxPkt)); /* get ether_type */ - memcpy(ð_type, ptr + pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_SIZE, 2); + memcpy(ð_type, ptr + pattrib->hdrlen + pattrib->iv_len + LLC_HEADER_LENGTH, 2); eth_type = ntohs((unsigned short) eth_type); #endif } @@ -1588,7 +1588,7 @@ static int amsdu_to_msdu(struct adapter *padapter, union recv_frame *prframe) /* Offset 12 denote 2 mac address */ nSubframe_Length = get_unaligned_be16(pdata + 12); - if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) + if (a_len < ETH_HLEN + nSubframe_Length) break; sub_pkt = rtw_os_alloc_msdu_pkt(prframe, nSubframe_Length, pdata); diff --git a/drivers/staging/rtl8723bs/include/drv_types.h b/drivers/staging/rtl8723bs/include/drv_types.h index ae32963a156d..0ce08c2a0755 100644 --- a/drivers/staging/rtl8723bs/include/drv_types.h +++ b/drivers/staging/rtl8723bs/include/drv_types.h @@ -57,7 +57,6 @@ #include #include -#include #define SPEC_DEV_ID_NONE BIT(0) #define SPEC_DEV_ID_DISABLE_HT BIT(1) diff --git a/drivers/staging/rtl8723bs/include/ethernet.h b/drivers/staging/rtl8723bs/include/ethernet.h deleted file mode 100644 index 59899ab52aab..000000000000 --- a/drivers/staging/rtl8723bs/include/ethernet.h +++ /dev/null @@ -1,14 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** - * - * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved. - * - ******************************************************************************/ -/*! \file */ -#ifndef __INC_ETHERNET_H -#define __INC_ETHERNET_H - -#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ -#define LLC_HEADER_SIZE 6 /* LLC Header Length */ - -#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/rtl8723bs/include/rtw_recv.h b/drivers/staging/rtl8723bs/include/rtw_recv.h index 9c3cdcc990fa..a88b7c088a86 100644 --- a/drivers/staging/rtl8723bs/include/rtw_recv.h +++ b/drivers/staging/rtl8723bs/include/rtw_recv.h @@ -35,6 +35,8 @@ #define MAX_SUBFRAME_COUNT 64 +#define LLC_HEADER_LENGTH 6 + /* for Rx reordering buffer control */ struct recv_reorder_ctrl { struct adapter *padapter; -- cgit v1.2.3 From 65945da601e816875426b5866746ced4acbc85e6 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:50 +0200 Subject: staging: r8188eu: remove unnecessary cast name is a const char * by default. This type should be ok for r8188eu. Acked-by: Phillip Potter Acked-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-1-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index e002070f7fba..72556ac10d7d 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -61,7 +61,7 @@ struct rtw_usb_drv { }; static struct rtw_usb_drv rtl8188e_usb_drv = { - .usbdrv.name = (char *)"r8188eu", + .usbdrv.name = "r8188eu", .usbdrv.probe = rtw_drv_init, .usbdrv.disconnect = rtw_dev_remove, .usbdrv.id_table = rtw_usb_id_tbl, -- cgit v1.2.3 From 74f64654ecd22f8e29580f93435406622c90d975 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:51 +0200 Subject: staging: r8188eu: remove unused define _HCI_OPS_OS_C_ is not used in the r8188eu driver. Remove it. Acked-by: Michael Straube Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-2-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 953fa05dc30c..a11a0597e515 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -1,8 +1,6 @@ // SPDX-License-Identifier: GPL-2.0 /* Copyright(c) 2007 - 2011 Realtek Corporation. */ -#define _HCI_OPS_OS_C_ - #include "../include/osdep_service.h" #include "../include/drv_types.h" #include "../include/osdep_intf.h" -- cgit v1.2.3 From 805ac0da01f867d5b3412a77110e970063f698c0 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:52 +0200 Subject: staging: rtl8188eu: use actual request type as parameter At the moment, usbctrl_vendorreq's requesttype parameter must be set to 1 for reading and 0 for writing. It's then converted to the actual bmRequestType for the USB control request. We can simplify the code and avoid this conversion if the caller passes the actual bmRequestType. This patch is an adaptation of commit 788fde031027 ("staging: rtl8188eu: use actual request type as parameter") for the new r8188eu driver. Acked-by: Phillip Potter Acked-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-3-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 46 ++++++++--------------------- 1 file changed, 12 insertions(+), 34 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index a11a0597e515..dccb9fd34777 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -15,7 +15,6 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, struct usb_device *udev = dvobjpriv->pusbdev; unsigned int pipe; int status = 0; - u8 reqtype; u8 *pIo_buf; int vendorreq_times = 0; @@ -44,26 +43,24 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { memset(pIo_buf, 0, len); - if (requesttype == 0x01) { + if (requesttype == REALTEK_USB_VENQT_READ) { pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ - reqtype = REALTEK_USB_VENQT_READ; } else { pipe = usb_sndctrlpipe(udev, 0);/* write_out */ - reqtype = REALTEK_USB_VENQT_WRITE; memcpy(pIo_buf, pdata, len); } status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, - reqtype, value, REALTEK_USB_VENQT_CMD_IDX, + requesttype, value, REALTEK_USB_VENQT_CMD_IDX, pIo_buf, len, RTW_USB_CONTROL_MSG_TIMEOUT); if (status == len) { /* Success this control transfer. */ rtw_reset_continual_urb_error(dvobjpriv); - if (requesttype == 0x01) + if (requesttype == REALTEK_USB_VENQT_READ) memcpy(pdata, pIo_buf, len); } else { /* error cases */ DBG_88E("reg 0x%x, usb %s %u fail, status:%d value=0x%x, vendorreq_times:%d\n", - value, (requesttype == 0x01) ? "read" : "write", + value, (requesttype == REALTEK_USB_VENQT_READ) ? "read" : "write", len, status, *(u32 *)pdata, vendorreq_times); if (status < 0) { @@ -75,7 +72,7 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, } } else { /* status != len && status >= 0 */ if (status > 0) { - if (requesttype == 0x01) { + if (requesttype == REALTEK_USB_VENQT_READ) { /* For Control read transfer, we have to copy the read data from pIo_buf to pdata. */ memcpy(pdata, pIo_buf, len); } @@ -101,19 +98,16 @@ exit: static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { - u8 requesttype; u16 wvalue; u16 len; u8 data = 0; - requesttype = 0x01;/* read_in */ - wvalue = (u16)(addr & 0x0000ffff); len = 1; - usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_READ); @@ -123,57 +117,49 @@ static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { - u8 requesttype; u16 wvalue; u16 len; __le32 data; - requesttype = 0x01;/* read_in */ wvalue = (u16)(addr & 0x0000ffff); len = 2; - usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_READ); return (u16)(le32_to_cpu(data) & 0xffff); } static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { - u8 requesttype; u16 wvalue; u16 len; __le32 data; - requesttype = 0x01;/* read_in */ - wvalue = (u16)(addr & 0x0000ffff); len = 4; - usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); + usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_READ); return le32_to_cpu(data); } static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { - u8 requesttype; u16 wvalue; u16 len; u8 data; int ret; - requesttype = 0x00;/* write_out */ wvalue = (u16)(addr & 0x0000ffff); len = 1; data = val; - ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_WRITE); return ret; } static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { - u8 requesttype; u16 wvalue; u16 len; __le32 data; @@ -181,14 +167,12 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) - requesttype = 0x00;/* write_out */ - wvalue = (u16)(addr & 0x0000ffff); len = 2; data = cpu_to_le32(val & 0x0000ffff); - ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_WRITE); @@ -197,7 +181,6 @@ static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { - u8 requesttype; u16 wvalue; u16 len; __le32 data; @@ -205,13 +188,11 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) - requesttype = 0x00;/* write_out */ - wvalue = (u16)(addr & 0x0000ffff); len = 4; data = cpu_to_le32(val); - ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_WRITE); @@ -220,7 +201,6 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) { - u8 requesttype; u16 wvalue; u16 len; u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; @@ -228,13 +208,11 @@ static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata - requesttype = 0x00;/* write_out */ - wvalue = (u16)(addr & 0x0000ffff); len = length; memcpy(buf, pdata, len); - ret = usbctrl_vendorreq(pintfhdl, wvalue, buf, len, requesttype); + ret = usbctrl_vendorreq(pintfhdl, wvalue, buf, len, REALTEK_USB_VENQT_WRITE); return ret; } -- cgit v1.2.3 From f410923ad5f577d08bad22bdb11d9660a2a75d25 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:53 +0200 Subject: staging: r8188eu: rewrite usb vendor request defines Replace the numeric values with USB constants to make their meaning clearer. Acked-by: Phillip Potter Acked-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-4-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/usb_ops.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index 5d290199e37c..b6a1cd536adf 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -8,8 +8,8 @@ #include "drv_types.h" #include "osdep_intf.h" -#define REALTEK_USB_VENQT_READ 0xC0 -#define REALTEK_USB_VENQT_WRITE 0x40 +#define REALTEK_USB_VENQT_READ (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE) +#define REALTEK_USB_VENQT_WRITE (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE) #define REALTEK_USB_VENQT_CMD_REQ 0x05 #define REALTEK_USB_VENQT_CMD_IDX 0x00 -- cgit v1.2.3 From 2214ea8299f5dcf1201521ab527b750ec53fbba8 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:54 +0200 Subject: staging: r8188eu: remove an unused enum The VENDOR_READ and VENDOR_WRITE defines are not used. Acked-by: Michael Straube Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-5-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/usb_ops.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/usb_ops.h b/drivers/staging/r8188eu/include/usb_ops.h index b6a1cd536adf..c53cc54b6b87 100644 --- a/drivers/staging/r8188eu/include/usb_ops.h +++ b/drivers/staging/r8188eu/include/usb_ops.h @@ -13,10 +13,6 @@ #define REALTEK_USB_VENQT_CMD_REQ 0x05 #define REALTEK_USB_VENQT_CMD_IDX 0x00 -enum { - VENDOR_WRITE = 0x00, - VENDOR_READ = 0x01, -}; #define ALIGNMENT_UNIT 16 #define MAX_VENDOR_REQ_CMD_SIZE 254 /* 8188cu SIE Support */ #define MAX_USB_IO_CTL_SIZE (MAX_VENDOR_REQ_CMD_SIZE + ALIGNMENT_UNIT) -- cgit v1.2.3 From 0d3e1be506dda7a0a3d43fad4d943cfbfabadd39 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:55 +0200 Subject: staging: r8188eu: clean up the usb_readXY functions Remove unnecessary variables, summarize declarations and assignments. Acked-by: Phillip Potter Acked-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-6-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 30 +++++++---------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index dccb9fd34777..cb969a200681 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -98,46 +98,30 @@ exit: static u8 usb_read8(struct intf_hdl *pintfhdl, u32 addr) { - u16 wvalue; - u16 len; - u8 data = 0; - - - - wvalue = (u16)(addr & 0x0000ffff); - len = 1; - - usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_READ); - + u16 wvalue = (u16)(addr & 0x0000ffff); + u8 data; + usbctrl_vendorreq(pintfhdl, wvalue, &data, 1, REALTEK_USB_VENQT_READ); return data; - } static u16 usb_read16(struct intf_hdl *pintfhdl, u32 addr) { - u16 wvalue; - u16 len; + u16 wvalue = (u16)(addr & 0x0000ffff); __le32 data; - wvalue = (u16)(addr & 0x0000ffff); - len = 2; - usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_READ); + usbctrl_vendorreq(pintfhdl, wvalue, &data, 2, REALTEK_USB_VENQT_READ); return (u16)(le32_to_cpu(data) & 0xffff); } static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) { - u16 wvalue; - u16 len; + u16 wvalue = (u16)(addr & 0x0000ffff); __le32 data; - wvalue = (u16)(addr & 0x0000ffff); - len = 4; - - usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_READ); + usbctrl_vendorreq(pintfhdl, wvalue, &data, 4, REALTEK_USB_VENQT_READ); return le32_to_cpu(data); } -- cgit v1.2.3 From e8baed3c765e0f88f4107c52a3505f52d174b41f Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:56 +0200 Subject: staging: r8188eu: clean up the usb_writeXY functions Remove unnecessary variables, summarize declarations and assignments. Acked-by: Phillip Potter Acked-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-7-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 50 +++++------------------------ 1 file changed, 8 insertions(+), 42 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index cb969a200681..e01f1ac19596 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -128,59 +128,25 @@ static u32 usb_read32(struct intf_hdl *pintfhdl, u32 addr) static int usb_write8(struct intf_hdl *pintfhdl, u32 addr, u8 val) { - u16 wvalue; - u16 len; - u8 data; - int ret; - - - wvalue = (u16)(addr & 0x0000ffff); - len = 1; - data = val; - ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_WRITE); + u16 wvalue = (u16)(addr & 0x0000ffff); - return ret; + return usbctrl_vendorreq(pintfhdl, wvalue, &val, 1, REALTEK_USB_VENQT_WRITE); } static int usb_write16(struct intf_hdl *pintfhdl, u32 addr, u16 val) { - u16 wvalue; - u16 len; - __le32 data; - int ret; - - - - wvalue = (u16)(addr & 0x0000ffff); - len = 2; - - data = cpu_to_le32(val & 0x0000ffff); - - ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_WRITE); - - + u16 wvalue = (u16)(addr & 0x0000ffff); + __le32 data = cpu_to_le32(val & 0x0000ffff); - return ret; + return usbctrl_vendorreq(pintfhdl, wvalue, &data, 2, REALTEK_USB_VENQT_WRITE); } static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) { - u16 wvalue; - u16 len; - __le32 data; - int ret; - - - - wvalue = (u16)(addr & 0x0000ffff); - len = 4; - data = cpu_to_le32(val); - - ret = usbctrl_vendorreq(pintfhdl, wvalue, &data, len, REALTEK_USB_VENQT_WRITE); - - + u16 wvalue = (u16)(addr & 0x0000ffff); + __le32 data = cpu_to_le32(val); - return ret; + return usbctrl_vendorreq(pintfhdl, wvalue, &data, 4, REALTEK_USB_VENQT_WRITE); } static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) -- cgit v1.2.3 From 22d0d6104e4d6c7d86ade11888422762db15ab75 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:57 +0200 Subject: staging: r8188eu: clean up the usb_writeN Remove unnecessary variables, check the length. Acked-by: Michael Straube Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-8-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index e01f1ac19596..5408383ccec3 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -151,20 +151,15 @@ static int usb_write32(struct intf_hdl *pintfhdl, u32 addr, u32 val) static int usb_writeN(struct intf_hdl *pintfhdl, u32 addr, u32 length, u8 *pdata) { - u16 wvalue; - u16 len; + u16 wvalue = (u16)(addr & 0x0000ffff); u8 buf[VENDOR_CMD_MAX_DATA_LEN] = {0}; - int ret; - + if (length > VENDOR_CMD_MAX_DATA_LEN) + return -EINVAL; - wvalue = (u16)(addr & 0x0000ffff); - len = length; - memcpy(buf, pdata, len); + memcpy(buf, pdata, length); - ret = usbctrl_vendorreq(pintfhdl, wvalue, buf, len, REALTEK_USB_VENQT_WRITE); - - return ret; + return usbctrl_vendorreq(pintfhdl, wvalue, buf, (length & 0xffff), REALTEK_USB_VENQT_WRITE); } static void interrupt_handler_8188eu(struct adapter *adapt, u16 pkt_len, u8 *pbuf) -- cgit v1.2.3 From f7231a04e4f12757ca46d99dd6e7b71deea25300 Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:58 +0200 Subject: staging: r8188eu: remove unused members of struct _io_ops Remove function pointers which are not used by the r8188eu driver. Acked-by: Michael Straube Acked-by: Phillip Potter Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-9-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_io.h | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_io.h b/drivers/staging/r8188eu/include/rtw_io.h index f1b3074fa075..4b41c7b03972 100644 --- a/drivers/staging/r8188eu/include/rtw_io.h +++ b/drivers/staging/r8188eu/include/rtw_io.h @@ -100,13 +100,10 @@ struct _io_ops { u8 *pmem); void (*_write_mem)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - void (*_sync_irp_protocol_rw)(struct io_queue *pio_q); - u32 (*_read_interrupt)(struct intf_hdl *pintfhdl, u32 addr); u32 (*_read_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *pmem); - u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem); void (*_read_port_cancel)(struct intf_hdl *pintfhdl); void (*_write_port_cancel)(struct intf_hdl *pintfhdl); }; -- cgit v1.2.3 From 5598e47a79b4300ba3ff2a8c7f44a4f8ed4af20d Mon Sep 17 00:00:00 2001 From: Martin Kaiser Date: Sat, 21 Aug 2021 18:48:59 +0200 Subject: staging: r8188eu: set pipe only once Set the pipe for reading or writing in usbctrl_vendorreq only once. There's no need to set it again for every retry. This patch is an adaptation of commit 889ed8b5e374 ("staging: rtl8188eu: set pipe only once") for the new r8188eu driver. Acked-by: Phillip Potter Acked-by: Michael Straube Signed-off-by: Martin Kaiser Link: https://lore.kernel.org/r/20210821164859.4351-10-martin@kaiser.cx Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/usb_ops_linux.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 5408383ccec3..5a55ee38d7b8 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -40,15 +40,16 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, goto release_mutex; } - while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { - memset(pIo_buf, 0, len); + if (requesttype == REALTEK_USB_VENQT_READ) + pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ + else + pipe = usb_sndctrlpipe(udev, 0);/* write_out */ - if (requesttype == REALTEK_USB_VENQT_READ) { - pipe = usb_rcvctrlpipe(udev, 0);/* read_in */ - } else { - pipe = usb_sndctrlpipe(udev, 0);/* write_out */ + while (++vendorreq_times <= MAX_USBCTRL_VENDORREQ_TIMES) { + if (requesttype == REALTEK_USB_VENQT_READ) + memset(pIo_buf, 0, len); + else memcpy(pIo_buf, pdata, len); - } status = usb_control_msg(udev, pipe, REALTEK_USB_VENQT_CMD_REQ, requesttype, value, REALTEK_USB_VENQT_CMD_IDX, -- cgit v1.2.3 From 2d29f81ce82208626f4278d6aa9faa5547c5bf02 Mon Sep 17 00:00:00 2001 From: Xiangyang Zhang Date: Sat, 21 Aug 2021 16:18:24 +0800 Subject: staging: r8188eu: Fix a resource leak in update_bcn_wps_ie The "pbackup_remainder_ie" variable is not freed when "pwps_ie_src" is null Fixes: 15865124feed ("staging: r8188eu: introduce new core dir for RTL8188eu driver") Acked-by: Michael Straube Signed-off-by: Xiangyang Zhang Link: https://lore.kernel.org/r/20210821081824.14745-1-xyz.sun.ok@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_ap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_ap.c b/drivers/staging/r8188eu/core/rtw_ap.c index 41b5668d080b..1c07ad28b242 100644 --- a/drivers/staging/r8188eu/core/rtw_ap.c +++ b/drivers/staging/r8188eu/core/rtw_ap.c @@ -1199,7 +1199,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) pwps_ie_src = pmlmepriv->wps_beacon_ie; if (!pwps_ie_src) - return; + goto exit; wps_ielen = (uint)pwps_ie_src[1];/* to get ie data len */ if ((wps_offset + wps_ielen + 2 + remainder_ielen) <= MAX_IE_SZ) { @@ -1213,6 +1213,7 @@ static void update_bcn_wps_ie(struct adapter *padapter) pnetwork->IELength = wps_offset + (wps_ielen + 2) + remainder_ielen; } +exit: kfree(pbackup_remainder_ie); } -- cgit v1.2.3 From e92e5f30ad320474346bfd5884cf170ad8c88968 Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 21 Aug 2021 11:56:15 +0100 Subject: staging: r8188eu: change declaration of Efuse_Read1ByteFromFakeContent Remove forward declaration of Efuse_Read1ByteFromFakeContent function from core/rtw_efuse.c, as the function is defined in full directly after this and therefore this forward declaration is redundant. In addition, convert the storage class of the function to static, as the function is only used with rtw_efuse.c, and tidy up the signature alignment. Acked-by: Fabio M. De Francesco Acked-by: Michael Straube Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210821105615.6307-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_efuse.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_efuse.c b/drivers/staging/r8188eu/core/rtw_efuse.c index decccf7622f0..c1c70648f5bc 100644 --- a/drivers/staging/r8188eu/core/rtw_efuse.c +++ b/drivers/staging/r8188eu/core/rtw_efuse.c @@ -29,17 +29,9 @@ u8 fakeBTEfuseModifiedMap[EFUSE_BT_MAX_MAP_LEN] = {0}; #define REG_EFUSE_CTRL 0x0030 #define EFUSE_CTRL REG_EFUSE_CTRL /* E-Fuse Control. */ /* */ - -bool -Efuse_Read1ByteFromFakeContent( - struct adapter *pAdapter, - u16 Offset, - u8 *Value); -bool -Efuse_Read1ByteFromFakeContent( - struct adapter *pAdapter, - u16 Offset, - u8 *Value) +static bool Efuse_Read1ByteFromFakeContent(struct adapter *pAdapter, + u16 Offset, + u8 *Value) { if (Offset >= EFUSE_MAX_HW_SIZE) return false; -- cgit v1.2.3 From 6ca88cb5e8478e6694b4cccfb2d331435d5bb77c Mon Sep 17 00:00:00 2001 From: Larry Finger Date: Sat, 21 Aug 2021 10:14:59 -0500 Subject: staging: r8188eu: Make mult-byte entities in dhcp header be big endian The 16- and 32-bit quantities in the dhcp message definition must be big endian. Acked-by: Phillip Potter Signed-off-by: Larry Finger Link: https://lore.kernel.org/r/20210821151459.26078-1-Larry.Finger@lwfinger.net Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_br_ext.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_br_ext.c b/drivers/staging/r8188eu/core/rtw_br_ext.c index ee52f28a1e56..62a672243696 100644 --- a/drivers/staging/r8188eu/core/rtw_br_ext.c +++ b/drivers/staging/r8188eu/core/rtw_br_ext.c @@ -640,16 +640,16 @@ struct dhcpMessage { u_int8_t hlen; u_int8_t hops; u_int32_t xid; - u_int16_t secs; - u_int16_t flags; - u_int32_t ciaddr; - u_int32_t yiaddr; - u_int32_t siaddr; - u_int32_t giaddr; + __be16 secs; + __be16 flags; + __be32 ciaddr; + __be32 yiaddr; + __be32 siaddr; + __be32 giaddr; u_int8_t chaddr[16]; u_int8_t sname[64]; u_int8_t file[128]; - u_int32_t cookie; + __be32 cookie; u_int8_t options[308]; /* 312 - cookie */ }; -- cgit v1.2.3 From 8d82693b0b562086935d23b55877d007b03c532a Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sat, 21 Aug 2021 17:51:51 +0200 Subject: staging: r8188eu: remove cmd_osdep.h header file All functions declared in the cmd_osdep.h header file are only used in a single c source file. Make the functions static and remove the header file and its includes. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210821155151.25822-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_cmd.c | 11 +++++------ drivers/staging/r8188eu/hal/rtl8188e_cmd.c | 1 - drivers/staging/r8188eu/include/cmd_osdep.h | 16 ---------------- 3 files changed, 5 insertions(+), 23 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/cmd_osdep.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_cmd.c b/drivers/staging/r8188eu/core/rtw_cmd.c index 955499eb608a..ce73ac7cf973 100644 --- a/drivers/staging/r8188eu/core/rtw_cmd.c +++ b/drivers/staging/r8188eu/core/rtw_cmd.c @@ -6,7 +6,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" #include "../include/recv_osdep.h" -#include "../include/cmd_osdep.h" #include "../include/mlme_osdep.h" #include "../include/rtw_br_ext.h" #include "../include/rtw_mlme_ext.h" @@ -16,7 +15,7 @@ Caller and the rtw_cmd_thread can protect cmd_q by spin_lock. No irqsave is necessary. */ -int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) +static int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv) { int res = _SUCCESS; @@ -59,7 +58,7 @@ exit: static void c2h_wk_callback(struct work_struct *work); -int _rtw_init_evt_priv(struct evt_priv *pevtpriv) +static int _rtw_init_evt_priv(struct evt_priv *pevtpriv) { int res = _SUCCESS; @@ -87,7 +86,7 @@ void rtw_free_evt_priv(struct evt_priv *pevtpriv) } } -void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) +static void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv) { if (pcmdpriv) { kfree(pcmdpriv->cmd_allocated_buf); @@ -105,7 +104,7 @@ ISR/Call-Back functions can't call this sub-function. */ -int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) +static int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj) { unsigned long flags; @@ -123,7 +122,7 @@ exit: return _SUCCESS; } -struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) +static struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue) { struct cmd_obj *obj; unsigned long flags; diff --git a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c index 3e1a45030bc8..7d50d64cf34d 100644 --- a/drivers/staging/r8188eu/hal/rtl8188e_cmd.c +++ b/drivers/staging/r8188eu/hal/rtl8188e_cmd.c @@ -6,7 +6,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" #include "../include/recv_osdep.h" -#include "../include/cmd_osdep.h" #include "../include/mlme_osdep.h" #include "../include/rtw_ioctl_set.h" diff --git a/drivers/staging/r8188eu/include/cmd_osdep.h b/drivers/staging/r8188eu/include/cmd_osdep.h deleted file mode 100644 index 3954d6350cc6..000000000000 --- a/drivers/staging/r8188eu/include/cmd_osdep.h +++ /dev/null @@ -1,16 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __CMD_OSDEP_H_ -#define __CMD_OSDEP_H_ - -#include "osdep_service.h" -#include "drv_types.h" - -extern int _rtw_init_cmd_priv(struct cmd_priv *pcmdpriv); -extern int _rtw_init_evt_priv(struct evt_priv *pevtpriv); -extern void _rtw_free_cmd_priv(struct cmd_priv *pcmdpriv); -extern int _rtw_enqueue_cmd(struct __queue *queue, struct cmd_obj *obj); -extern struct cmd_obj *_rtw_dequeue_cmd(struct __queue *queue); - -#endif -- cgit v1.2.3 From 3eaa30d1623e109143c2e30b5738720c1816b851 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 21:30:28 +0200 Subject: staging: r8188eu: remove 5 GHz code The driver is for chips that do not operate in the 5 GHz band. Remove some 5 GHz related code. Acked-by: Phillip Potter Acked-by: Martin Kaiser Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823193028.12391-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/ioctl_linux.c | 30 ++++++++-------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/ioctl_linux.c b/drivers/staging/r8188eu/os_dep/ioctl_linux.c index ab4a9200f079..81d4255d1785 100644 --- a/drivers/staging/r8188eu/os_dep/ioctl_linux.c +++ b/drivers/staging/r8188eu/os_dep/ioctl_linux.c @@ -208,17 +208,10 @@ static char *translate_scan(struct adapter *padapter, else snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pnetwork->network.Configuration.DSConfig > 14) { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11an"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11a"); - } else { - if (ht_cap) - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); - } + if (ht_cap) + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11g"); } start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_CHAR_LEN); @@ -737,17 +730,10 @@ static int rtw_wx_get_name(struct net_device *dev, else snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11bg"); } else { - if (pcur_bss->Configuration.DSConfig > 14) { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11an"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11a"); - } else { - if (ht_cap) - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); - else - snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); - } + if (ht_cap) + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11gn"); + else + snprintf(wrqu->name, IFNAMSIZ, "IEEE 802.11g"); } } else { snprintf(wrqu->name, IFNAMSIZ, "unassociated"); -- cgit v1.2.3 From f9f72f7f722e32d8f5645e53c1ca90347dedc95c Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 22 Aug 2021 13:40:13 +0200 Subject: staging: r8188eu: remove dead code if (0) is never true, remove code that is never executed. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210822114014.21584-1-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_led.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 306862aec53a..29c48f1a4fec 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -121,10 +121,7 @@ static void SwLedBlink(struct LED_871x *pLed) } if (bStopBlinking) { - /* if (padapter->pwrctrlpriv.cpwm >= PS_STATE_S2) */ - if (0) { - SwLedOff(padapter, pLed); - } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { + if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { SwLedOn(padapter, pLed); } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) { SwLedOff(padapter, pLed); -- cgit v1.2.3 From 2a3afb168ea7002884ce7e56f5c2e061420a3bcf Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Sun, 22 Aug 2021 13:40:14 +0200 Subject: staging: r8188eu: remove unnecessary parentheses Remove unnecessary parentheses to improve readability. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210822114014.21584-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_led.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index 29c48f1a4fec..cd27873c3e63 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -121,9 +121,9 @@ static void SwLedBlink(struct LED_871x *pLed) } if (bStopBlinking) { - if ((check_fwstate(pmlmepriv, _FW_LINKED)) && (!pLed->bLedOn)) { + if (check_fwstate(pmlmepriv, _FW_LINKED) && !pLed->bLedOn) { SwLedOn(padapter, pLed); - } else if ((check_fwstate(pmlmepriv, _FW_LINKED)) && pLed->bLedOn) { + } else if (check_fwstate(pmlmepriv, _FW_LINKED) && pLed->bLedOn) { SwLedOff(padapter, pLed); } pLed->BlinkTimes = 0; -- cgit v1.2.3 From 8aa824f2ec1b66fdbf7e5b87e519bced35a35114 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:00:59 +0200 Subject: staging: r8188eu: ensure proper alignment for eth address buffers Add __aligned(2) to eth address buffers in structs rx_pkt_attrib and pkt_attrib to ensure proper alignment for usage with functions from Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/include/rtw_recv.h | 10 +++++----- drivers/staging/r8188eu/include/rtw_xmit.h | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index 81594e7aed51..1b41f8d7d079 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -109,11 +109,11 @@ struct rx_pkt_attrib { u16 eth_type; - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; - u8 ta[ETH_ALEN]; - u8 ra[ETH_ALEN]; - u8 bssid[ETH_ALEN]; + u8 dst[ETH_ALEN] __aligned(2); + u8 src[ETH_ALEN] __aligned(2); + u8 ta[ETH_ALEN] __aligned(2); + u8 ra[ETH_ALEN] __aligned(2); + u8 bssid[ETH_ALEN] __aligned(2); u8 ack_policy; diff --git a/drivers/staging/r8188eu/include/rtw_xmit.h b/drivers/staging/r8188eu/include/rtw_xmit.h index e1418a3f7ed1..5f6e2402e5c4 100644 --- a/drivers/staging/r8188eu/include/rtw_xmit.h +++ b/drivers/staging/r8188eu/include/rtw_xmit.h @@ -122,10 +122,10 @@ struct pkt_attrib { u8 ack_policy; u8 mac_id; u8 vcs_mode; /* virtual carrier sense method */ - u8 dst[ETH_ALEN]; - u8 src[ETH_ALEN]; - u8 ta[ETH_ALEN]; - u8 ra[ETH_ALEN]; + u8 dst[ETH_ALEN] __aligned(2); + u8 src[ETH_ALEN] __aligned(2); + u8 ta[ETH_ALEN] __aligned(2); + u8 ra[ETH_ALEN] __aligned(2); u8 key_idx; u8 qos_en; u8 ht_en; -- cgit v1.2.3 From 08cff18916f5a1d918a902d1f8fe1ef76c2520d4 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:00 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in core/rtw_mlme.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme.c b/drivers/staging/r8188eu/core/rtw_mlme.c index c41312660054..1115ff5d865a 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme.c +++ b/drivers/staging/r8188eu/core/rtw_mlme.c @@ -2121,9 +2121,9 @@ void rtw_issue_addbareq_cmd(struct adapter *padapter, struct xmit_frame *pxmitfr struct sta_info *psta = NULL; struct ht_priv *phtpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; - s32 bmcst = IS_MCAST(pattrib->ra); - if (bmcst || (padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100)) + if (is_multicast_ether_addr(pattrib->ra) || + padapter->mlmepriv.LinkDetectInfo.NumTxOkInPeriod < 100) return; priority = pattrib->priority; -- cgit v1.2.3 From 129f4197f22d407d47d05babb538bef7339c6cdb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:01 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in core/rtw_mp.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index 93bb683b628f..e66b7333077a 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -635,7 +635,7 @@ void SetPacketTx(struct adapter *padapter) struct tx_desc *desc; struct rtw_ieee80211_hdr *hdr; u8 payload; - s32 bmcast; + bool bmcast; struct pkt_attrib *pattrib; struct mp_priv *pmp_priv; @@ -651,7 +651,7 @@ void SetPacketTx(struct adapter *padapter) memcpy(pattrib->src, padapter->eeprompriv.mac_addr, ETH_ALEN); memcpy(pattrib->ta, pattrib->src, ETH_ALEN); memcpy(pattrib->ra, pattrib->dst, ETH_ALEN); - bmcast = IS_MCAST(pattrib->ra); + bmcast = is_multicast_ether_addr(pattrib->ra); if (bmcast) { pattrib->mac_id = 1; pattrib->psta = rtw_get_bcmc_stainfo(padapter); -- cgit v1.2.3 From d0624c3379a17b9c6c267378831cdaa60c0af835 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:02 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in core/rtw_recv.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, all buffers are properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 52236bae8693..bc452420c119 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -330,7 +330,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr if (prxattrib->encrypt == _TKIP_) { /* calculate mic code */ if (stainfo) { - if (IS_MCAST(prxattrib->ra)) { + if (is_multicast_ether_addr(prxattrib->ra)) { mickey = &psecuritypriv->dot118021XGrprxmickey[prxattrib->key_index].skey[0]; if (!psecuritypriv) { @@ -361,11 +361,11 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr if (bmic_err) { /* double check key_index for some timing issue , */ /* cannot compare with psecuritypriv->dot118021XGrpKeyid also cause timing issue */ - if (IS_MCAST(prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index) + if (is_multicast_ether_addr(prxattrib->ra) && prxattrib->key_index != pmlmeinfo->key_index) brpt_micerror = false; if ((prxattrib->bdecrypted) && (brpt_micerror)) { - rtw_handle_tkip_mic_err(adapter, (u8)IS_MCAST(prxattrib->ra)); + rtw_handle_tkip_mic_err(adapter, (u8)is_multicast_ether_addr(prxattrib->ra)); DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); } else { DBG_88E(" mic error :prxattrib->bdecrypted=%d\n", prxattrib->bdecrypted); @@ -373,7 +373,7 @@ static int recvframe_chkmic(struct adapter *adapter, struct recv_frame *precvfr res = _FAIL; } else { /* mic checked ok */ - if ((!psecuritypriv->bcheck_grpkey) && (IS_MCAST(prxattrib->ra))) + if (!psecuritypriv->bcheck_grpkey && is_multicast_ether_addr(prxattrib->ra)) psecuritypriv->bcheck_grpkey = true; } } @@ -618,7 +618,7 @@ static void count_rx_stats(struct adapter *padapter, struct recv_frame *prframe, padapter->mlmepriv.LinkDetectInfo.NumRxOkInPeriod++; - if (!is_broadcast_ether_addr(pattrib->dst) && !IS_MCAST(pattrib->dst)) + if (!is_broadcast_ether_addr(pattrib->dst) && !is_multicast_ether_addr(pattrib->dst)) padapter->mlmepriv.LinkDetectInfo.NumRxUnicastOkInPeriod++; if (sta) @@ -650,7 +650,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, u8 *mybssid = get_bssid(pmlmepriv); u8 *myhwaddr = myid(&adapter->eeprompriv); u8 *sta_addr = NULL; - int bmcast = IS_MCAST(pattrib->dst); + bool bmcast = is_multicast_ether_addr(pattrib->dst); if (check_fwstate(pmlmepriv, WIFI_ADHOC_STATE) || check_fwstate(pmlmepriv, WIFI_ADHOC_MASTER_STATE)) { @@ -683,7 +683,7 @@ int sta2sta_data_frame(struct adapter *adapter, struct recv_frame *precv_frame, } else if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) { if (bmcast) { /* For AP mode, if DA == MCAST, then BSSID should be also MCAST */ - if (!IS_MCAST(pattrib->bssid)) { + if (!is_multicast_ether_addr(pattrib->bssid)) { ret = _FAIL; goto exit; } @@ -739,7 +739,7 @@ static int ap2sta_data_frame( struct mlme_priv *pmlmepriv = &adapter->mlmepriv; u8 *mybssid = get_bssid(pmlmepriv); u8 *myhwaddr = myid(&adapter->eeprompriv); - int bmcast = IS_MCAST(pattrib->dst); + bool bmcast = is_multicast_ether_addr(pattrib->dst); if (check_fwstate(pmlmepriv, WIFI_STATION_STATE) && (check_fwstate(pmlmepriv, _FW_LINKED) || @@ -1136,7 +1136,7 @@ static int validate_recv_data_frame(struct adapter *adapter, } if (pattrib->privacy) { - GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, IS_MCAST(pattrib->ra)); + GET_ENCRY_ALGO(psecuritypriv, psta, pattrib->encrypt, is_multicast_ether_addr(pattrib->ra)); SET_ICE_IV_LEN(pattrib->iv_len, pattrib->icv_len, pattrib->encrypt); } else { @@ -1957,7 +1957,7 @@ static int recv_func(struct adapter *padapter, struct recv_frame *rframe) if (ret == _SUCCESS) { /* check if need to enqueue into uc_swdec_pending_queue*/ if (check_fwstate(mlmepriv, WIFI_STATION_STATE) && - !IS_MCAST(prxattrib->ra) && prxattrib->encrypt > 0 && + !is_multicast_ether_addr(prxattrib->ra) && prxattrib->encrypt > 0 && (prxattrib->bdecrypted == 0 || psecuritypriv->sw_decrypt) && psecuritypriv->ndisauthtype == Ndis802_11AuthModeWPAPSK && !psecuritypriv->busetkipkey) { -- cgit v1.2.3 From 2d4fe65101b5216838c1d92e6c39a150fc72c837 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:03 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in core/rtw_security.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, all buffers are properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-6-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_security.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_security.c b/drivers/staging/r8188eu/core/rtw_security.c index b9ab4b20ed8e..5aa893ab46e9 100644 --- a/drivers/staging/r8188eu/core/rtw_security.c +++ b/drivers/staging/r8188eu/core/rtw_security.c @@ -538,7 +538,7 @@ u32 rtw_tkip_encrypt(struct adapter *padapter, u8 *pxmitframe) stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); if (stainfo) { - if (IS_MCAST(pattrib->ra)) + if (is_multicast_ether_addr(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else prwskey = &stainfo->dot118021x_UncstKey.skey[0]; @@ -608,7 +608,7 @@ u32 rtw_tkip_decrypt(struct adapter *padapter, u8 *precvframe) if (prxattrib->encrypt == _TKIP_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo) { - if (IS_MCAST(prxattrib->ra)) { + if (is_multicast_ether_addr(prxattrib->ra)) { if (!psecuritypriv->binstallGrpkey) { res = _FAIL; DBG_88E("%s:rx bc/mc packets, but didn't install group key!!!!!!!!!!\n", __func__); @@ -1188,7 +1188,7 @@ u32 rtw_aes_encrypt(struct adapter *padapter, u8 *pxmitframe) stainfo = rtw_get_stainfo(&padapter->stapriv, &pattrib->ra[0]); if (stainfo) { - if (IS_MCAST(pattrib->ra)) + if (is_multicast_ether_addr(pattrib->ra)) prwskey = psecuritypriv->dot118021XGrpKey[psecuritypriv->dot118021XGrpKeyid].skey; else prwskey = &stainfo->dot118021x_UncstKey.skey[0]; @@ -1421,7 +1421,7 @@ u32 rtw_aes_decrypt(struct adapter *padapter, u8 *precvframe) if (prxattrib->encrypt == _AES_) { stainfo = rtw_get_stainfo(&padapter->stapriv, &prxattrib->ta[0]); if (stainfo) { - if (IS_MCAST(prxattrib->ra)) { + if (is_multicast_ether_addr(prxattrib->ra)) { /* in concurrent we should use sw descrypt in group key, so we remove this message */ if (!psecuritypriv->binstallGrpkey) { res = _FAIL; -- cgit v1.2.3 From 544984a774f2802c928c92358106f9863fe112ab Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:04 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in core/rtw_xmit.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, all buffers are properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-7-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_xmit.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 611dbfb41849..71d60d346662 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -411,7 +411,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p struct sta_info *psta = NULL; struct ethhdr etherhdr; - int bmcast; + bool bmcast; struct sta_priv *pstapriv = &padapter->stapriv; struct security_priv *psecuritypriv = &padapter->securitypriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -472,7 +472,7 @@ static s32 update_attrib(struct adapter *padapter, struct sk_buff *pkt, struct p if ((pattrib->ether_type == 0x0806) || (pattrib->ether_type == 0x888e) || (pattrib->dhcp_pkt == 1)) rtw_lps_ctrl_wk_cmd(padapter, LPS_CTRL_SPECIAL_PACKET, 1); - bmcast = IS_MCAST(pattrib->ra); + bmcast = is_multicast_ether_addr(pattrib->ra); /* get sta_info */ if (bmcast) { @@ -597,7 +597,6 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr struct xmit_priv *pxmitpriv = &padapter->xmitpriv; u8 priority[4] = {0x0, 0x0, 0x0, 0x0}; u8 hw_hdr_offset = 0; - int bmcst = IS_MCAST(pattrib->ra); if (pattrib->psta) stainfo = pattrib->psta; @@ -615,7 +614,7 @@ static s32 xmitframe_addmic(struct adapter *padapter, struct xmit_frame *pxmitfr pframe = pxmitframe->buf_addr + hw_hdr_offset; - if (bmcst) { + if (is_multicast_ether_addr(pattrib->ra)) { if (!memcmp(psecuritypriv->dot118021XGrptxmickey[psecuritypriv->dot118021XGrpKeyid].skey, null_key, 16)) return _FAIL; /* start to calculate the mic code */ @@ -715,12 +714,10 @@ s32 rtw_make_wlanhdr(struct adapter *padapter, u8 *hdr, struct pkt_attrib *pattr struct sta_info *psta; - int bmcst = IS_MCAST(pattrib->ra); - if (pattrib->psta) { psta = pattrib->psta; } else { - if (bmcst) { + if (is_multicast_ether_addr(pattrib->ra)) { psta = rtw_get_bcmc_stainfo(padapter); } else { psta = rtw_get_stainfo(&padapter->stapriv, pattrib->ra); @@ -907,7 +904,7 @@ s32 rtw_xmitframe_coalesce(struct adapter *padapter, struct sk_buff *pkt, struct struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; u8 *pbuf_start; - s32 bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); s32 res = _SUCCESS; if (!pkt) @@ -1801,7 +1798,7 @@ int xmitframe_enqueue_for_sleeping_sta(struct adapter *padapter, struct xmit_fra struct sta_priv *pstapriv = &padapter->stapriv; struct pkt_attrib *pattrib = &pxmitframe->attrib; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; - int bmcst = IS_MCAST(pattrib->ra); + bool bmcst = is_multicast_ether_addr(pattrib->ra); if (!check_fwstate(pmlmepriv, WIFI_AP_STATE)) return ret; -- cgit v1.2.3 From 0b704920fba990ad6d0e731f315c71a2422d02cb Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:05 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in hal/rtl8188eu_xmit.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-8-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/rtl8188eu_xmit.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c index d22b16cc5a30..17be67ac5fae 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_xmit.c @@ -167,7 +167,6 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag struct tx_desc *ptxdesc = (struct tx_desc *)pmem; struct mlme_ext_priv *pmlmeext = &adapt->mlmeextpriv; struct mlme_ext_info *pmlmeinfo = &pmlmeext->mlmext_info; - int bmcst = IS_MCAST(pattrib->ra); if (adapt->registrypriv.mp_mode == 0) { if ((!bagg_pkt) && (urb_zero_packet_chk(adapt, sz) == 0)) { @@ -186,7 +185,7 @@ static s32 update_txdesc(struct xmit_frame *pxmitframe, u8 *pmem, s32 sz, u8 bag ptxdesc->txdw0 |= cpu_to_le32(((offset) << OFFSET_SHT) & 0x00ff0000);/* 32 bytes for TX Desc */ - if (bmcst) + if (is_multicast_ether_addr(pattrib->ra)) ptxdesc->txdw0 |= cpu_to_le32(BMC); if (adapt->registrypriv.mp_mode == 0) { -- cgit v1.2.3 From bd5f258affb124a5bd9d3be94628951b0a8a14c6 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Mon, 23 Aug 2021 14:01:06 +0200 Subject: staging: r8188eu: use is_multicast_ether_addr in os_dep/recv_linux.c Use is_multicast_ether_addr instead of custom macro IS_MCAST, the buffer is properly aligned. Acked-by: Phillip Potter Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210823120106.9633-9-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/recv_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index b4c5333bfff0..dd3113b6d4f3 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -132,7 +132,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter, struct sta_info *psta = NULL; struct sta_priv *pstapriv = &padapter->stapriv; struct rx_pkt_attrib *pattrib = &precv_frame->attrib; - int bmcast = IS_MCAST(pattrib->dst); + bool bmcast = is_multicast_ether_addr(pattrib->dst); if (memcmp(pattrib->dst, myid(&padapter->eeprompriv), ETH_ALEN)) { -- cgit v1.2.3 From f228d1d50904e6a9ac91560578b935b1d853122b Mon Sep 17 00:00:00 2001 From: Pavel Skripkin Date: Mon, 23 Aug 2021 21:40:59 +0300 Subject: staging: r8188eu: make rtw_deinit_intf_priv return void rtw_deinit_intf_priv() always return success, so there is no need in return value Acked-by: Michael Straube Acked-by: Phillip Potter Acked-by: Martin Kaiser Signed-off-by: Pavel Skripkin Link: https://lore.kernel.org/r/20210823184059.19742-1-paskripkin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/usb_intf.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/usb_intf.c b/drivers/staging/r8188eu/os_dep/usb_intf.c index 72556ac10d7d..bb85ab77fd26 100644 --- a/drivers/staging/r8188eu/os_dep/usb_intf.c +++ b/drivers/staging/r8188eu/os_dep/usb_intf.c @@ -129,13 +129,10 @@ exit: return rst; } -static u8 rtw_deinit_intf_priv(struct dvobj_priv *dvobj) +static void rtw_deinit_intf_priv(struct dvobj_priv *dvobj) { - u8 rst = _SUCCESS; - kfree(dvobj->usb_alloc_vendor_req_buf); _rtw_mutex_free(&dvobj->usb_vendor_req_mutex); - return rst; } static struct dvobj_priv *usb_dvobj_init(struct usb_interface *usb_intf) -- cgit v1.2.3 From 68ad97bc5a1b9b5b2c3717ae8c5ca1071d3a88f5 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 24 Aug 2021 14:36:19 +0200 Subject: staging: r8188eu: remove if_ether.h header file All constants, declarations and macros in if_ether.h are either duplicated from or unused. Remove the file if_ether.h and its includes. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210824123621.10801-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 1 - drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/r8188eu/include/if_ether.h | 94 ---------------------------- drivers/staging/r8188eu/os_dep/xmit_linux.c | 1 - 4 files changed, 97 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/if_ether.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index bc452420c119..7d2bcd9c5f81 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -8,7 +8,6 @@ #include "../include/recv_osdep.h" #include "../include/mlme_osdep.h" #include "../include/ip.h" -#include "../include/if_ether.h" #include "../include/ethernet.h" #include "../include/usb_ops.h" #include "../include/wifi.h" diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index a44c9598186c..3a2c7090cd7b 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -7,7 +7,6 @@ #include "../include/recv_osdep.h" #include "../include/mlme_osdep.h" #include "../include/ip.h" -#include "../include/if_ether.h" #include "../include/ethernet.h" #include "../include/usb_ops.h" diff --git a/drivers/staging/r8188eu/include/if_ether.h b/drivers/staging/r8188eu/include/if_ether.h deleted file mode 100644 index 5bb79fddeec6..000000000000 --- a/drivers/staging/r8188eu/include/if_ether.h +++ /dev/null @@ -1,94 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef _LINUX_IF_ETHER_H -#define _LINUX_IF_ETHER_H - -/* - * IEEE 802.3 Ethernet magic constants. The frame sizes omit the preamble - * and FCS/CRC (frame check sequence). - */ - -#define ETH_ALEN 6 /* Octets in one ethernet addr */ -#define ETH_HLEN 14 /* Total octets in header. */ -#define ETH_ZLEN 60 /* Min. octets in frame sans FCS */ -#define ETH_DATA_LEN 1500 /* Max. octets in payload */ -#define ETH_FRAME_LEN 1514 /* Max. octets in frame sans FCS */ - -/* - * These are the defined Ethernet Protocol ID's. - */ - -#define ETH_P_LOOP 0x0060 /* Ethernet Loopback packet */ -#define ETH_P_PUP 0x0200 /* Xerox PUP packet */ -#define ETH_P_PUPAT 0x0201 /* Xerox PUP Addr Trans packet */ -#define ETH_P_IP 0x0800 /* Internet Protocol packet */ -#define ETH_P_X25 0x0805 /* CCITT X.25 */ -#define ETH_P_ARP 0x0806 /* Address Resolution packet */ -#define ETH_P_BPQ 0x08FF /* G8BPQ AX.25 Ethernet Packet */ -#define ETH_P_IEEEPUP 0x0a00 /* Xerox IEEE802.3 PUP packet */ -#define ETH_P_IEEEPUPAT 0x0a01 /* Xerox IEEE802.3 PUP */ -#define ETH_P_DEC 0x6000 /* DEC Assigned proto */ -#define ETH_P_DNA_DL 0x6001 /* DEC DNA Dump/Load */ -#define ETH_P_DNA_RC 0x6002 /* DEC DNA Remote Console */ -#define ETH_P_DNA_RT 0x6003 /* DEC DNA Routing */ -#define ETH_P_LAT 0x6004 /* DEC LAT */ -#define ETH_P_DIAG 0x6005 /* DEC Diagnostics */ -#define ETH_P_CUST 0x6006 /* DEC Customer use */ -#define ETH_P_SCA 0x6007 /* DEC Systems Comms Arch */ -#define ETH_P_RARP 0x8035 /* Reverse Addr Res packet */ -#define ETH_P_ATALK 0x809B /* Appletalk DDP */ -#define ETH_P_AARP 0x80F3 /* Appletalk AARP */ -#define ETH_P_8021Q 0x8100 /* 802.1Q VLAN Extended Header */ -#define ETH_P_IPX 0x8137 /* IPX over DIX */ -#define ETH_P_IPV6 0x86DD /* IPv6 over bluebook */ -#define ETH_P_PPP_DISC 0x8863 /* PPPoE discovery messages */ -#define ETH_P_PPP_SES 0x8864 /* PPPoE session messages */ -#define ETH_P_ATMMPOA 0x884c /* MultiProtocol Over ATM */ -#define ETH_P_ATMFATE 0x8884 /* Frame-based ATM Transport - * over Ethernet - */ - -/* - * Non DIX types. Won't clash for 1500 types. - */ - -#define ETH_P_802_3 0x0001 /* Dummy type for 802.3 frames */ -#define ETH_P_AX25 0x0002 /* Dummy protocol id for AX.25 */ -#define ETH_P_ALL 0x0003 /* Every packet (be careful!!!) */ -#define ETH_P_802_2 0x0004 /* 802.2 frames */ -#define ETH_P_SNAP 0x0005 /* Internal only */ -#define ETH_P_DDCMP 0x0006 /* DEC DDCMP: Internal only */ -#define ETH_P_WAN_PPP 0x0007 /* Dummy type for WAN PPP frames*/ -#define ETH_P_PPP_MP 0x0008 /* Dummy type for PPP MP frames */ -#define ETH_P_LOCALTALK 0x0009 /* Localtalk pseudo type */ -#define ETH_P_PPPTALK 0x0010 /* Dummy type for Atalk over PPP*/ -#define ETH_P_TR_802_2 0x0011 /* 802.2 frames */ -#define ETH_P_MOBITEX 0x0015 /* Mobitex (kaz@cafe.net) */ -#define ETH_P_CONTROL 0x0016 /* Card specific control frames */ -#define ETH_P_IRDA 0x0017 /* Linux-IrDA */ -#define ETH_P_ECONET 0x0018 /* Acorn Econet */ - -/* - * This is an Ethernet frame header. - */ - -struct ethhdr { - unsigned char h_dest[ETH_ALEN]; /* destination eth addr */ - unsigned char h_source[ETH_ALEN]; /* source ether addr */ - unsigned short h_proto; /* packet type ID field */ -}; - -struct _vlan { - unsigned short h_vlan_TCI; /* Encap prio and VLAN ID */ - unsigned short h_vlan_encapsulated_proto; -}; - -#define get_vlan_id(pvlan) \ - ((ntohs((unsigned short)pvlan->h_vlan_TCI)) & 0xfff) -#define get_vlan_priority(pvlan) \ - ((ntohs((unsigned short)pvlan->h_vlan_TCI))>>13) -#define get_vlan_encap_proto(pvlan) \ - (ntohs((unsigned short)pvlan->h_vlan_encapsulated_proto)) - -#endif /* _LINUX_IF_ETHER_H */ diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index 60e0eea7ad84..d35e92c17a5e 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -5,7 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/if_ether.h" #include "../include/ip.h" #include "../include/wifi.h" #include "../include/mlme_osdep.h" -- cgit v1.2.3 From f09dc911bd26c26bee20e349eb19eaf861c27aab Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 24 Aug 2021 14:36:20 +0200 Subject: staging: r8188eu: remove ip.h header file The struct ip_options declared in ip.h is only unsed in the optlength macro which is also defined in ip.h and not used in the driver code. All other definitions/declarations in ip.h are duplicated from . Remove the ip.h header file and its includes. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210824123621.10801-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 1 - drivers/staging/r8188eu/core/rtw_xmit.c | 1 - drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/r8188eu/include/ip.h | 109 --------------------------- drivers/staging/r8188eu/os_dep/xmit_linux.c | 1 - 5 files changed, 113 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/ip.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index 7d2bcd9c5f81..b144d63c40b5 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -7,7 +7,6 @@ #include "../include/drv_types.h" #include "../include/recv_osdep.h" #include "../include/mlme_osdep.h" -#include "../include/ip.h" #include "../include/ethernet.h" #include "../include/usb_ops.h" #include "../include/wifi.h" diff --git a/drivers/staging/r8188eu/core/rtw_xmit.c b/drivers/staging/r8188eu/core/rtw_xmit.c index 71d60d346662..46fe62c7c32c 100644 --- a/drivers/staging/r8188eu/core/rtw_xmit.c +++ b/drivers/staging/r8188eu/core/rtw_xmit.c @@ -7,7 +7,6 @@ #include "../include/drv_types.h" #include "../include/wifi.h" #include "../include/osdep_intf.h" -#include "../include/ip.h" #include "../include/usb_ops.h" #include "../include/usb_osintf.h" diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 3a2c7090cd7b..666afa69fce6 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -6,7 +6,6 @@ #include "../include/drv_types.h" #include "../include/recv_osdep.h" #include "../include/mlme_osdep.h" -#include "../include/ip.h" #include "../include/ethernet.h" #include "../include/usb_ops.h" diff --git a/drivers/staging/r8188eu/include/ip.h b/drivers/staging/r8188eu/include/ip.h deleted file mode 100644 index b7388c8c1b8a..000000000000 --- a/drivers/staging/r8188eu/include/ip.h +++ /dev/null @@ -1,109 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef _LINUX_IP_H -#define _LINUX_IP_H - -/* SOL_IP socket options */ - -#define IPTOS_TOS_MASK 0x1E -#define IPTOS_TOS(tos) ((tos)&IPTOS_TOS_MASK) -#define IPTOS_LOWDELAY 0x10 -#define IPTOS_THROUGHPUT 0x08 -#define IPTOS_RELIABILITY 0x04 -#define IPTOS_MINCOST 0x02 - -#define IPTOS_PREC_MASK 0xE0 -#define IPTOS_PREC(tos) ((tos)&IPTOS_PREC_MASK) -#define IPTOS_PREC_NETCONTROL 0xe0 -#define IPTOS_PREC_INTERNETCONTROL 0xc0 -#define IPTOS_PREC_CRITIC_ECP 0xa0 -#define IPTOS_PREC_FLASHOVERRIDE 0x80 -#define IPTOS_PREC_FLASH 0x60 -#define IPTOS_PREC_IMMEDIATE 0x40 -#define IPTOS_PREC_PRIORITY 0x20 -#define IPTOS_PREC_ROUTINE 0x00 - -/* IP options */ -#define IPOPT_COPY 0x80 -#define IPOPT_CLASS_MASK 0x60 -#define IPOPT_NUMBER_MASK 0x1f - -#define IPOPT_COPIED(o) ((o)&IPOPT_COPY) -#define IPOPT_CLASS(o) ((o)&IPOPT_CLASS_MASK) -#define IPOPT_NUMBER(o) ((o)&IPOPT_NUMBER_MASK) - -#define IPOPT_CONTROL 0x00 -#define IPOPT_RESERVED1 0x20 -#define IPOPT_MEASUREMENT 0x40 -#define IPOPT_RESERVED2 0x60 - -#define IPOPT_END (0 | IPOPT_CONTROL) -#define IPOPT_NOOP (1 | IPOPT_CONTROL) -#define IPOPT_SEC (2 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_LSRR (3 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_TIMESTAMP (4 | IPOPT_MEASUREMENT) -#define IPOPT_RR (7 | IPOPT_CONTROL) -#define IPOPT_SID (8 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_SSRR (9 | IPOPT_CONTROL | IPOPT_COPY) -#define IPOPT_RA (20 | IPOPT_CONTROL | IPOPT_COPY) - -#define IPVERSION 4 -#define MAXTTL 255 -#define IPDEFTTL 64 -#define IPOPT_OPTVAL 0 -#define IPOPT_OLEN 1 -#define IPOPT_OFFSET 2 -#define IPOPT_MINOFF 4 -#define MAX_IPOPTLEN 40 -#define IPOPT_NOP IPOPT_NOOP -#define IPOPT_EOL IPOPT_END -#define IPOPT_TS IPOPT_TIMESTAMP - -#define IPOPT_TS_TSONLY 0 /* timestamps only */ -#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */ -#define IPOPT_TS_PRESPEC 3 /* specified modules only */ - -struct ip_options { - __u32 faddr; /* Saved first hop address */ - unsigned char optlen; - unsigned char srr; - unsigned char rr; - unsigned char ts; - unsigned char is_setbyuser:1, /* Set by setsockopt? */ - is_data:1, /* Options in __data, rather than skb*/ - is_strictroute:1,/* Strict source route */ - srr_is_hit:1, /* Packet destn addr was ours */ - is_changed:1, /* IP checksum more not valid */ - rr_needaddr:1, /* Need to record addr of out dev*/ - ts_needtime:1, /* Need to record timestamp */ - ts_needaddr:1; /* Need to record addr of out dev */ - unsigned char router_alert; - unsigned char __pad1; - unsigned char __pad2; - unsigned char __data[0]; -}; - -#define optlength(opt) (sizeof(struct ip_options) + opt->optlen) - -struct iphdr { -#if defined(__LITTLE_ENDIAN_BITFIELD) - __u8 ihl:4, - version:4; -#elif defined(__BIG_ENDIAN_BITFIELD) - __u8 version:4, - ihl:4; -#endif - __u8 tos; - __u16 tot_len; - __u16 id; - __u16 frag_off; - __u8 ttl; - __u8 protocol; - __u16 check; - __u32 saddr; - __u32 daddr; - /*The options start here. */ -}; - -#endif /* _LINUX_IP_H */ diff --git a/drivers/staging/r8188eu/os_dep/xmit_linux.c b/drivers/staging/r8188eu/os_dep/xmit_linux.c index d35e92c17a5e..565ac5be7db3 100644 --- a/drivers/staging/r8188eu/os_dep/xmit_linux.c +++ b/drivers/staging/r8188eu/os_dep/xmit_linux.c @@ -5,7 +5,6 @@ #include "../include/osdep_service.h" #include "../include/drv_types.h" -#include "../include/ip.h" #include "../include/wifi.h" #include "../include/mlme_osdep.h" #include "../include/xmit_osdep.h" -- cgit v1.2.3 From f7766f1b0030e7af179a5e75df52838268102fab Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Tue, 24 Aug 2021 14:36:21 +0200 Subject: staging: r8188eu: remove ethernet.h header file There are only two definitions from ethernet.h used in the driver. Namely: #define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ #define LLC_HEADER_SIZE 6 /* LLC Header Length */ Both are only used in the file core/rtw_recv.c. Replace the usage of ETHERNET_HEADER_SIZE with ETH_HLEN, move the definition of LLC_HEADER_SIZE into rtw_recv.h and remove the now unused ethernet.h header file. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210824123621.10801-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_recv.c | 3 +-- drivers/staging/r8188eu/hal/rtl8188eu_recv.c | 1 - drivers/staging/r8188eu/include/ethernet.h | 24 ------------------------ drivers/staging/r8188eu/include/rtw_recv.h | 2 ++ drivers/staging/r8188eu/os_dep/recv_linux.c | 1 - 5 files changed, 3 insertions(+), 28 deletions(-) delete mode 100644 drivers/staging/r8188eu/include/ethernet.h (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_recv.c b/drivers/staging/r8188eu/core/rtw_recv.c index b144d63c40b5..e082edfbaad8 100644 --- a/drivers/staging/r8188eu/core/rtw_recv.c +++ b/drivers/staging/r8188eu/core/rtw_recv.c @@ -7,7 +7,6 @@ #include "../include/drv_types.h" #include "../include/recv_osdep.h" #include "../include/mlme_osdep.h" -#include "../include/ethernet.h" #include "../include/usb_ops.h" #include "../include/wifi.h" @@ -1519,7 +1518,7 @@ static int amsdu_to_msdu(struct adapter *padapter, struct recv_frame *prframe) /* Offset 12 denote 2 mac address */ nSubframe_Length = RTW_GET_BE16(pdata + 12); - if (a_len < (ETHERNET_HEADER_SIZE + nSubframe_Length)) { + if (a_len < ETH_HLEN + nSubframe_Length) { DBG_88E("nRemain_Length is %d and nSubframe_Length is : %d\n", a_len, nSubframe_Length); goto exit; } diff --git a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c index 666afa69fce6..2da7bde80cc0 100644 --- a/drivers/staging/r8188eu/hal/rtl8188eu_recv.c +++ b/drivers/staging/r8188eu/hal/rtl8188eu_recv.c @@ -6,7 +6,6 @@ #include "../include/drv_types.h" #include "../include/recv_osdep.h" #include "../include/mlme_osdep.h" -#include "../include/ethernet.h" #include "../include/usb_ops.h" #include "../include/wifi.h" diff --git a/drivers/staging/r8188eu/include/ethernet.h b/drivers/staging/r8188eu/include/ethernet.h deleted file mode 100644 index 898eb296013c..000000000000 --- a/drivers/staging/r8188eu/include/ethernet.h +++ /dev/null @@ -1,24 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ -/* Copyright(c) 2007 - 2011 Realtek Corporation. */ - -#ifndef __INC_ETHERNET_H -#define __INC_ETHERNET_H - -#define ETHERNET_ADDRESS_LENGTH 6 /* Ethernet Address Length */ -#define ETHERNET_HEADER_SIZE 14 /* Ethernet Header Length */ -#define LLC_HEADER_SIZE 6 /* LLC Header Length */ -#define TYPE_LENGTH_FIELD_SIZE 2 /* Type/Length Size */ -#define MINIMUM_ETHERNET_PACKET_SIZE 60 /* Min Ethernet Packet Size */ -#define MAXIMUM_ETHERNET_PACKET_SIZE 1514 /* Max Ethernet Packet Size */ - -/* Is Multicast Address? */ -#define RT_ETH_IS_MULTICAST(_addr) ((((u8 *)(_addr))[0]&0x01) != 0) -#define RT_ETH_IS_BROADCAST(_addr) ( \ - ((u8 *)(_addr))[0] == 0xff && \ - ((u8 *)(_addr))[1] == 0xff && \ - ((u8 *)(_addr))[2] == 0xff && \ - ((u8 *)(_addr))[3] == 0xff && \ - ((u8 *)(_addr))[4] == 0xff && \ - ((u8 *)(_addr))[5] == 0xff) /* Is Broadcast Address? */ - -#endif /* #ifndef __INC_ETHERNET_H */ diff --git a/drivers/staging/r8188eu/include/rtw_recv.h b/drivers/staging/r8188eu/include/rtw_recv.h index 1b41f8d7d079..d1d1ca0e56d6 100644 --- a/drivers/staging/r8188eu/include/rtw_recv.h +++ b/drivers/staging/r8188eu/include/rtw_recv.h @@ -20,6 +20,8 @@ #define MAX_SUBFRAME_COUNT 64 +#define LLC_HEADER_SIZE 6 + /* for Rx reordering buffer control */ struct recv_reorder_ctrl { struct adapter *padapter; diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c index dd3113b6d4f3..917a63e3e94c 100644 --- a/drivers/staging/r8188eu/os_dep/recv_linux.c +++ b/drivers/staging/r8188eu/os_dep/recv_linux.c @@ -10,7 +10,6 @@ #include "../include/recv_osdep.h" #include "../include/osdep_intf.h" -#include "../include/ethernet.h" #include "../include/usb_ops.h" /* init os related resource in struct recv_priv */ -- cgit v1.2.3 From 3f60c32f15b0d2956074d684526b128505be0bb7 Mon Sep 17 00:00:00 2001 From: Saurav Girepunje Date: Sun, 22 Aug 2021 01:53:08 +0530 Subject: staging: r8188eu: core: remove condition with no effect Remove the condition with no effect (if == else) in rtw_led.c file. Acked-by: Phillip Potter Signed-off-by: Saurav Girepunje Link: https://lore.kernel.org/r/YSFgrLUfXzgcT6k4@user Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_led.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_led.c b/drivers/staging/r8188eu/core/rtw_led.c index cd27873c3e63..b33e34cce12e 100644 --- a/drivers/staging/r8188eu/core/rtw_led.c +++ b/drivers/staging/r8188eu/core/rtw_led.c @@ -145,10 +145,7 @@ static void SwLedBlink(struct LED_871x *pLed) _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); break; case LED_BLINK_WPS: - if (pLed->BlinkingLedState == RTW_LED_ON) - _set_timer(&pLed->BlinkTimer, LED_BLINK_LONG_INTERVAL); - else - _set_timer(&pLed->BlinkTimer, LED_BLINK_LONG_INTERVAL); + _set_timer(&pLed->BlinkTimer, LED_BLINK_LONG_INTERVAL); break; default: _set_timer(&pLed->BlinkTimer, LED_BLINK_SLOWLY_INTERVAL); -- cgit v1.2.3 From ce6a7007048b0abcf263a2b43a63d18614802e53 Mon Sep 17 00:00:00 2001 From: Pavel Skripkin Date: Tue, 24 Aug 2021 10:27:13 +0300 Subject: staging: r8188eu: remove {read,write}_macreg These 2 functions are unused, so they can be simply removed Signed-off-by: Pavel Skripkin Acked-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/d591e29d77da73790c71f7a8e508a8b16fd48f65.1629789580.git.paskripkin@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mp.c | 39 -------------------------------- drivers/staging/r8188eu/include/rtw_mp.h | 2 -- 2 files changed, 41 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mp.c b/drivers/staging/r8188eu/core/rtw_mp.c index e66b7333077a..dabdd0406f30 100644 --- a/drivers/staging/r8188eu/core/rtw_mp.c +++ b/drivers/staging/r8188eu/core/rtw_mp.c @@ -7,45 +7,6 @@ #include "../include/odm_precomp.h" #include "../include/rtl8188e_hal.h" -u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz) -{ - u32 val = 0; - - switch (sz) { - case 1: - val = rtw_read8(padapter, addr); - break; - case 2: - val = rtw_read16(padapter, addr); - break; - case 4: - val = rtw_read32(padapter, addr); - break; - default: - val = 0xffffffff; - break; - } - - return val; -} - -void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz) -{ - switch (sz) { - case 1: - rtw_write8(padapter, addr, (u8)val); - break; - case 2: - rtw_write16(padapter, addr, (u16)val); - break; - case 4: - rtw_write32(padapter, addr, val); - break; - default: - break; - } -} - u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask) { return rtw_hal_read_bbreg(padapter, addr, bitmask); diff --git a/drivers/staging/r8188eu/include/rtw_mp.h b/drivers/staging/r8188eu/include/rtw_mp.h index b64b16554343..3a259d991348 100644 --- a/drivers/staging/r8188eu/include/rtw_mp.h +++ b/drivers/staging/r8188eu/include/rtw_mp.h @@ -410,8 +410,6 @@ void mp_stop_test(struct adapter *padapter); u32 _read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask); void _write_rfreg(struct adapter *padapter, u8 rfpath, u32 addr, u32 bitmask, u32 val); -u32 read_macreg(struct adapter *padapter, u32 addr, u32 sz); -void write_macreg(struct adapter *padapter, u32 addr, u32 val, u32 sz); u32 read_bbreg(struct adapter *padapter, u32 addr, u32 bitmask); void write_bbreg(struct adapter *padapter, u32 addr, u32 bitmask, u32 val); u32 read_rfreg(struct adapter *padapter, u8 rfpath, u32 addr); -- cgit v1.2.3 From 62dbd849e03ce2cb2fb605ed7a6ca93b42cc99f4 Mon Sep 17 00:00:00 2001 From: Jing Yangyang Date: Mon, 23 Aug 2021 23:34:43 -0700 Subject: staging: r8188eu: remove unneeded conversions to bool Found with scripts/coccinelle/misc/boolconv.cocci. Reported-by: Zeal Robot Reviewed-by: Pavel Skripkin Acked-by: Michael Straube Acked-by: Phillip Potter Signed-off-by: Jing Yangyang Link: https://lore.kernel.org/r/20210824063443.59724-1-deng.changcheng@zte.com.cn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_mlme_ext.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_mlme_ext.c b/drivers/staging/r8188eu/core/rtw_mlme_ext.c index 508ef1d330a1..5a472a4954b0 100644 --- a/drivers/staging/r8188eu/core/rtw_mlme_ext.c +++ b/drivers/staging/r8188eu/core/rtw_mlme_ext.c @@ -3758,7 +3758,7 @@ int issue_probereq_p2p_ex(struct adapter *adapter, u8 *da, int try_cnt, int wait u32 start = jiffies; do { - ret = _issue_probereq_p2p(adapter, da, wait_ms > 0 ? true : false); + ret = _issue_probereq_p2p(adapter, da, wait_ms > 0); i++; @@ -4890,7 +4890,7 @@ int issue_probereq_ex(struct adapter *padapter, struct ndis_802_11_ssid *pssid, u32 start = jiffies; do { - ret = _issue_probereq(padapter, pssid, da, wait_ms > 0 ? true : false); + ret = _issue_probereq(padapter, pssid, da, wait_ms > 0); i++; @@ -5605,7 +5605,7 @@ int issue_nulldata(struct adapter *padapter, unsigned char *da, unsigned int pow da = get_my_bssid(&pmlmeinfo->network); do { - ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0 ? true : false); + ret = _issue_nulldata(padapter, da, power_mode, wait_ms > 0); i++; @@ -5728,7 +5728,7 @@ int issue_qos_nulldata(struct adapter *padapter, unsigned char *da, u16 tid, int da = get_my_bssid(&pmlmeinfo->network); do { - ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0 ? true : false); + ret = _issue_qos_nulldata(padapter, da, tid, wait_ms > 0); i++; @@ -5839,7 +5839,7 @@ int issue_deauth_ex(struct adapter *padapter, u8 *da, unsigned short reason, int u32 start = jiffies; do { - ret = _issue_deauth(padapter, da, reason, wait_ms > 0 ? true : false); + ret = _issue_deauth(padapter, da, reason, wait_ms > 0); i++; -- cgit v1.2.3 From 7990b535d2987201187d750f809ed17b502eb608 Mon Sep 17 00:00:00 2001 From: Jing Yangyang Date: Tue, 24 Aug 2021 23:15:31 -0700 Subject: staging: r8188eu: remove unneeded variable Eliminate the following coccicheck warning: ./drivers/staging/r8188eu/os_dep/os_intfs.c:505:6-12: Unneeded variable "status". Return "_SUCCESS" on line 577 ./drivers/staging/r8188eu/os_dep/os_intfs.c:772: 4-7: Unneeded variable "ret". Return "_SUCCESS" on line 818 ./drivers/staging/r8188eu/os_dep/os_intfs.c:823:4-8: Unneeded variable "ret8". Return "_SUCCESS" on line 849 Reported-by: Zeal Robot Signed-off-by: Jing Yangyang Link: https://lore.kernel.org/r/20210825061531.69678-1-deng.changcheng@zte.com.cn Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/os_dep/os_intfs.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/os_dep/os_intfs.c b/drivers/staging/r8188eu/os_dep/os_intfs.c index 1aa65925e1da..8d0158f4a45d 100644 --- a/drivers/staging/r8188eu/os_dep/os_intfs.c +++ b/drivers/staging/r8188eu/os_dep/os_intfs.c @@ -501,7 +501,6 @@ void rtw_proc_remove_one(struct net_device *dev) static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) { - uint status = _SUCCESS; struct registry_priv *registry_par = &padapter->registrypriv; GlobalDebugLevel = rtw_debug; @@ -573,7 +572,7 @@ static uint loadparam(struct adapter *padapter, struct net_device *pnetdev) snprintf(registry_par->if2name, 16, "%s", if2name); registry_par->notch_filter = (u8)rtw_notch_filter; - return status; + return _SUCCESS; } static int rtw_net_set_mac_address(struct net_device *pnetdev, void *p) @@ -750,7 +749,6 @@ void rtw_stop_drv_threads(struct adapter *padapter) static u8 rtw_init_default_value(struct adapter *padapter) { - u8 ret = _SUCCESS; struct registry_priv *pregistrypriv = &padapter->registrypriv; struct xmit_priv *pxmitpriv = &padapter->xmitpriv; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; @@ -796,12 +794,11 @@ static u8 rtw_init_default_value(struct adapter *padapter) #ifdef CONFIG_88EU_P2P padapter->bShowGetP2PState = 1; #endif - return ret; + return _SUCCESS; } u8 rtw_reset_drv_sw(struct adapter *padapter) { - u8 ret8 = _SUCCESS; struct mlme_priv *pmlmepriv = &padapter->mlmepriv; struct pwrctrl_priv *pwrctrlpriv = &padapter->pwrctrlpriv; @@ -827,7 +824,7 @@ u8 rtw_reset_drv_sw(struct adapter *padapter) rtw_set_signal_stat_timer(&padapter->recvpriv); - return ret8; + return _SUCCESS; } u8 rtw_init_drv_sw(struct adapter *padapter) -- cgit v1.2.3 From 71419e03d85ff3e46b3c61238bd1e369f313c280 Mon Sep 17 00:00:00 2001 From: "Fabio M. De Francesco" Date: Fri, 27 Aug 2021 12:08:13 +0200 Subject: staging: r8188eu: Provide a TODO file for this driver Provide a TODO file that lists the tasks that should be carried out in order to move this driver off drivers/staging. Acked-by: Phillip Potter Signed-off-by: Fabio M. De Francesco Link: https://lore.kernel.org/r/20210827100813.18610-1-fmdefrancesco@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/TODO | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 drivers/staging/r8188eu/TODO (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/TODO b/drivers/staging/r8188eu/TODO new file mode 100644 index 000000000000..98f918480990 --- /dev/null +++ b/drivers/staging/r8188eu/TODO @@ -0,0 +1,13 @@ +To-do list: + +* Correct the coding style according to Linux guidelines; please read the document + at https://www.kernel.org/doc/html/latest/process/coding-style.html. +* Remove unnecessary debugging/printing macros; for those that are still needed + use the proper kernel API (pr_debug(), dev_dbg(), netdev_dbg()). +* Remove dead code such as unusued functions, variables, fields, etc.. +* Use in-kernel API and remove unnecessary wrappers where possible. +* Fix bugs due to code that sleeps in atomic context. +* Remove the HAL layer and migrate its functionality into the relevant parts of + the driver. +* Switch to use LIB80211. +* Switch to use MAC80211. -- cgit v1.2.3 From a01b0006de7632656b2711b67c1d59b76af4d6a2 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 27 Aug 2021 11:41:41 +0200 Subject: staging: r8188eu: rename struct field Wifi_Error_Status Rename struct field Wifi_Error_Status to avoid camel case. Wifi_Error_Status -> wifi_error_status Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210827094144.13290-2-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/core/rtw_sreset.c | 18 +++++++++--------- drivers/staging/r8188eu/hal/usb_ops_linux.c | 4 ++-- drivers/staging/r8188eu/include/rtw_sreset.h | 2 +- 3 files changed, 12 insertions(+), 12 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/core/rtw_sreset.c b/drivers/staging/r8188eu/core/rtw_sreset.c index 8e1bc62e74e5..c831033d20a9 100644 --- a/drivers/staging/r8188eu/core/rtw_sreset.c +++ b/drivers/staging/r8188eu/core/rtw_sreset.c @@ -10,7 +10,7 @@ void sreset_init_value(struct adapter *padapter) _rtw_mutex_init(&psrtpriv->silentreset_mutex); psrtpriv->silent_reset_inprogress = false; - psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; psrtpriv->last_tx_time = 0; psrtpriv->last_tx_complete_time = 0; } @@ -20,7 +20,7 @@ void sreset_reset_value(struct adapter *padapter) struct sreset_priv *psrtpriv = &pHalData->srestpriv; psrtpriv->silent_reset_inprogress = false; - psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; psrtpriv->last_tx_time = 0; psrtpriv->last_tx_complete_time = 0; } @@ -37,20 +37,20 @@ u8 sreset_get_wifi_status(struct adapter *padapter) return status; val32 = rtw_read32(padapter, REG_TXDMA_STATUS); if (val32 == 0xeaeaeaea) { - psrtpriv->Wifi_Error_Status = WIFI_IF_NOT_EXIST; + psrtpriv->wifi_error_status = WIFI_IF_NOT_EXIST; } else if (val32 != 0) { DBG_88E("txdmastatu(%x)\n", val32); - psrtpriv->Wifi_Error_Status = WIFI_MAC_TXDMA_ERROR; + psrtpriv->wifi_error_status = WIFI_MAC_TXDMA_ERROR; } - if (WIFI_STATUS_SUCCESS != psrtpriv->Wifi_Error_Status) { - DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->Wifi_Error_Status); - status = (psrtpriv->Wifi_Error_Status & (~(USB_READ_PORT_FAIL | USB_WRITE_PORT_FAIL))); + if (WIFI_STATUS_SUCCESS != psrtpriv->wifi_error_status) { + DBG_88E("==>%s error_status(0x%x)\n", __func__, psrtpriv->wifi_error_status); + status = (psrtpriv->wifi_error_status & (~(USB_READ_PORT_FAIL | USB_WRITE_PORT_FAIL))); } DBG_88E("==> %s wifi_status(0x%x)\n", __func__, status); /* status restore */ - psrtpriv->Wifi_Error_Status = WIFI_STATUS_SUCCESS; + psrtpriv->wifi_error_status = WIFI_STATUS_SUCCESS; return status; } @@ -58,5 +58,5 @@ u8 sreset_get_wifi_status(struct adapter *padapter) void sreset_set_wifi_error_status(struct adapter *padapter, u32 status) { struct hal_data_8188e *pHalData = GET_HAL_DATA(padapter); - pHalData->srestpriv.Wifi_Error_Status = status; + pHalData->srestpriv.wifi_error_status = status; } diff --git a/drivers/staging/r8188eu/hal/usb_ops_linux.c b/drivers/staging/r8188eu/hal/usb_ops_linux.c index 5a55ee38d7b8..0cf69033c529 100644 --- a/drivers/staging/r8188eu/hal/usb_ops_linux.c +++ b/drivers/staging/r8188eu/hal/usb_ops_linux.c @@ -69,7 +69,7 @@ static int usbctrl_vendorreq(struct intf_hdl *pintfhdl, u16 value, void *pdata, adapt->bSurpriseRemoved = true; } else { struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - haldata->srestpriv.Wifi_Error_Status = USB_VEN_REQ_CMD_FAIL; + haldata->srestpriv.wifi_error_status = USB_VEN_REQ_CMD_FAIL; } } else { /* status != len && status >= 0 */ if (status > 0) { @@ -417,7 +417,7 @@ static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) case -EOVERFLOW: { struct hal_data_8188e *haldata = GET_HAL_DATA(adapt); - haldata->srestpriv.Wifi_Error_Status = USB_READ_PORT_FAIL; + haldata->srestpriv.wifi_error_status = USB_READ_PORT_FAIL; } precvbuf->reuse = true; rtw_read_port(adapt, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); diff --git a/drivers/staging/r8188eu/include/rtw_sreset.h b/drivers/staging/r8188eu/include/rtw_sreset.h index 8fa7aa4abb3f..4e97997c305b 100644 --- a/drivers/staging/r8188eu/include/rtw_sreset.h +++ b/drivers/staging/r8188eu/include/rtw_sreset.h @@ -10,7 +10,7 @@ struct sreset_priv { struct mutex silentreset_mutex; u8 silent_reset_inprogress; - u8 Wifi_Error_Status; + u8 wifi_error_status; unsigned long last_tx_time; unsigned long last_tx_complete_time; }; -- cgit v1.2.3 From 9f30a2312c0b6d19f444903491ff794ad40b6009 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 27 Aug 2021 11:41:42 +0200 Subject: staging: r8188eu: rename fields of struct dyn_primary_cca Rename fields of struct dyn_primary_cca to avoid camel case. PriCCA_flag -> pri_cca_flag DupRTS_flag -> dup_rts_flag Monitor_flag -> monitor_flag Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210827094144.13290-3-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 8 ++++---- drivers/staging/r8188eu/include/odm.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 10fe1ecc0342..70afa0a21bf4 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -329,16 +329,16 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) { struct dyn_primary_cca *PrimaryCCA = &dm_odm->DM_PriCCA; - PrimaryCCA->DupRTS_flag = 0; + PrimaryCCA->dup_rts_flag = 0; PrimaryCCA->intf_flag = 0; PrimaryCCA->intf_type = 0; - PrimaryCCA->Monitor_flag = 0; - PrimaryCCA->PriCCA_flag = 0; + PrimaryCCA->monitor_flag = 0; + PrimaryCCA->pri_cca_flag = 0; } bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) { struct dyn_primary_cca *PrimaryCCA = &dm_odm->DM_PriCCA; - return PrimaryCCA->DupRTS_flag; + return PrimaryCCA->dup_rts_flag; } diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index 19458e66603c..ee051e053ac6 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -154,11 +154,11 @@ struct false_alarm_stats { }; struct dyn_primary_cca { - u8 PriCCA_flag; + u8 pri_cca_flag; u8 intf_flag; u8 intf_type; - u8 DupRTS_flag; - u8 Monitor_flag; + u8 dup_rts_flag; + u8 monitor_flag; }; struct rx_hpc { -- cgit v1.2.3 From 9f801ac94d8b6613174a1bafdac684a1c05646ba Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 27 Aug 2021 11:41:43 +0200 Subject: staging: r8188eu: remove ODM_DynamicPrimaryCCA_DupRTS() Function ODM_DynamicPrimaryCCA_DupRTS() is unused, remove it. Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210827094144.13290-4-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm_RTL8188E.c | 7 ------- drivers/staging/r8188eu/include/odm_RTL8188E.h | 2 -- 2 files changed, 9 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm_RTL8188E.c b/drivers/staging/r8188eu/hal/odm_RTL8188E.c index 70afa0a21bf4..c64a291f9966 100644 --- a/drivers/staging/r8188eu/hal/odm_RTL8188E.c +++ b/drivers/staging/r8188eu/hal/odm_RTL8188E.c @@ -335,10 +335,3 @@ void odm_PrimaryCCA_Init(struct odm_dm_struct *dm_odm) PrimaryCCA->monitor_flag = 0; PrimaryCCA->pri_cca_flag = 0; } - -bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *dm_odm) -{ - struct dyn_primary_cca *PrimaryCCA = &dm_odm->DM_PriCCA; - - return PrimaryCCA->dup_rts_flag; -} diff --git a/drivers/staging/r8188eu/include/odm_RTL8188E.h b/drivers/staging/r8188eu/include/odm_RTL8188E.h index 776a8a6dab68..00d2678532f8 100644 --- a/drivers/staging/r8188eu/include/odm_RTL8188E.h +++ b/drivers/staging/r8188eu/include/odm_RTL8188E.h @@ -33,6 +33,4 @@ void odm_FastAntTrainingWorkItemCallback(struct odm_dm_struct *pDM_Odm); void odm_PrimaryCCA_Init(struct odm_dm_struct *pDM_Odm); -bool ODM_DynamicPrimaryCCA_DupRTS(struct odm_dm_struct *pDM_Odm); - #endif -- cgit v1.2.3 From f6bc526accf861728d36b12fbc25ac94cd057fc9 Mon Sep 17 00:00:00 2001 From: Michael Straube Date: Fri, 27 Aug 2021 11:41:44 +0200 Subject: staging: r8188eu: rename fields of struct rtl_ps Rename fields of struct rtl_ps to avoid camel case. PreCCAState -> pre_cca_state CurCCAState -> cur_cca_state PreRFState -> pre_rf_state CurRFState -> cur_rf_state Rssi_val_min -> rssi_val_min Reg874 -> reg_874 RegC70 -> reg_c70 Reg85C -> reg_85c RegA74 -> reg_a74 Signed-off-by: Michael Straube Link: https://lore.kernel.org/r/20210827094144.13290-5-straube.linux@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/hal/odm.c | 64 +++++++++++++++++------------------ drivers/staging/r8188eu/include/odm.h | 15 ++++---- 2 files changed, 41 insertions(+), 38 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/hal/odm.c b/drivers/staging/r8188eu/hal/odm.c index c1449fab3a95..ed94f64d878d 100644 --- a/drivers/staging/r8188eu/hal/odm.c +++ b/drivers/staging/r8188eu/hal/odm.c @@ -921,11 +921,11 @@ void odm_DynamicBBPowerSavingInit(struct odm_dm_struct *pDM_Odm) { struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; - pDM_PSTable->PreCCAState = CCA_MAX; - pDM_PSTable->CurCCAState = CCA_MAX; - pDM_PSTable->PreRFState = RF_MAX; - pDM_PSTable->CurRFState = RF_MAX; - pDM_PSTable->Rssi_val_min = 0; + pDM_PSTable->pre_cca_state = CCA_MAX; + pDM_PSTable->cur_cca_state = CCA_MAX; + pDM_PSTable->pre_rf_state = RF_MAX; + pDM_PSTable->cur_rf_state = RF_MAX; + pDM_PSTable->rssi_val_min = 0; pDM_PSTable->initialize = 0; } @@ -954,23 +954,23 @@ void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) struct rtl_ps *pDM_PSTable = &pDM_Odm->DM_PSTable; if (pDM_Odm->RSSI_Min != 0xFF) { - if (pDM_PSTable->PreCCAState == CCA_2R) { + if (pDM_PSTable->pre_cca_state == CCA_2R) { if (pDM_Odm->RSSI_Min >= 35) - pDM_PSTable->CurCCAState = CCA_1R; + pDM_PSTable->cur_cca_state = CCA_1R; else - pDM_PSTable->CurCCAState = CCA_2R; + pDM_PSTable->cur_cca_state = CCA_2R; } else { if (pDM_Odm->RSSI_Min <= 30) - pDM_PSTable->CurCCAState = CCA_2R; + pDM_PSTable->cur_cca_state = CCA_2R; else - pDM_PSTable->CurCCAState = CCA_1R; + pDM_PSTable->cur_cca_state = CCA_1R; } } else { - pDM_PSTable->CurCCAState = CCA_MAX; + pDM_PSTable->cur_cca_state = CCA_MAX; } - if (pDM_PSTable->PreCCAState != pDM_PSTable->CurCCAState) { - if (pDM_PSTable->CurCCAState == CCA_1R) { + if (pDM_PSTable->pre_cca_state != pDM_PSTable->cur_cca_state) { + if (pDM_PSTable->cur_cca_state == CCA_1R) { if (pDM_Odm->RFType == ODM_2T2R) ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x13); else @@ -978,7 +978,7 @@ void odm_1R_CCA(struct odm_dm_struct *pDM_Odm) } else { ODM_SetBBReg(pDM_Odm, 0xc04, bMaskByte0, 0x33); } - pDM_PSTable->PreCCAState = pDM_PSTable->CurCCAState; + pDM_PSTable->pre_cca_state = pDM_PSTable->cur_cca_state; } } @@ -993,35 +993,35 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) Rssi_Low_bound = 45; } if (pDM_PSTable->initialize == 0) { - pDM_PSTable->Reg874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord) & 0x1CC000) >> 14; - pDM_PSTable->RegC70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord) & BIT(3)) >> 3; - pDM_PSTable->Reg85C = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord) & 0xFF000000) >> 24; - pDM_PSTable->RegA74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord) & 0xF000) >> 12; + pDM_PSTable->reg_874 = (ODM_GetBBReg(pDM_Odm, 0x874, bMaskDWord) & 0x1CC000) >> 14; + pDM_PSTable->reg_c70 = (ODM_GetBBReg(pDM_Odm, 0xc70, bMaskDWord) & BIT(3)) >> 3; + pDM_PSTable->reg_85c = (ODM_GetBBReg(pDM_Odm, 0x85c, bMaskDWord) & 0xFF000000) >> 24; + pDM_PSTable->reg_a74 = (ODM_GetBBReg(pDM_Odm, 0xa74, bMaskDWord) & 0xF000) >> 12; pDM_PSTable->initialize = 1; } if (!bForceInNormal) { if (pDM_Odm->RSSI_Min != 0xFF) { - if (pDM_PSTable->PreRFState == RF_Normal) { + if (pDM_PSTable->pre_rf_state == RF_Normal) { if (pDM_Odm->RSSI_Min >= Rssi_Up_bound) - pDM_PSTable->CurRFState = RF_Save; + pDM_PSTable->cur_rf_state = RF_Save; else - pDM_PSTable->CurRFState = RF_Normal; + pDM_PSTable->cur_rf_state = RF_Normal; } else { if (pDM_Odm->RSSI_Min <= Rssi_Low_bound) - pDM_PSTable->CurRFState = RF_Normal; + pDM_PSTable->cur_rf_state = RF_Normal; else - pDM_PSTable->CurRFState = RF_Save; + pDM_PSTable->cur_rf_state = RF_Save; } } else { - pDM_PSTable->CurRFState = RF_MAX; + pDM_PSTable->cur_rf_state = RF_MAX; } } else { - pDM_PSTable->CurRFState = RF_Normal; + pDM_PSTable->cur_rf_state = RF_Normal; } - if (pDM_PSTable->PreRFState != pDM_PSTable->CurRFState) { - if (pDM_PSTable->CurRFState == RF_Save) { + if (pDM_PSTable->pre_rf_state != pDM_PSTable->cur_rf_state) { + if (pDM_PSTable->cur_rf_state == RF_Save) { /* 8723 RSSI report will be wrong. Set 0x874[5]=1 when enter BB power saving mode. */ /* Suggested by SD3 Yu-Nan. 2011.01.20. */ if (pDM_Odm->SupportICType == ODM_RTL8723A) @@ -1034,16 +1034,16 @@ void ODM_RF_Saving(struct odm_dm_struct *pDM_Odm, u8 bForceInNormal) ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); /* Reg818[28]=1'b0 */ ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x1); /* Reg818[28]=1'b1 */ } else { - ODM_SetBBReg(pDM_Odm, 0x874, 0x1CC000, pDM_PSTable->Reg874); - ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), pDM_PSTable->RegC70); - ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->Reg85C); - ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->RegA74); + ODM_SetBBReg(pDM_Odm, 0x874, 0x1CC000, pDM_PSTable->reg_874); + ODM_SetBBReg(pDM_Odm, 0xc70, BIT(3), pDM_PSTable->reg_c70); + ODM_SetBBReg(pDM_Odm, 0x85c, 0xFF000000, pDM_PSTable->reg_85c); + ODM_SetBBReg(pDM_Odm, 0xa74, 0xF000, pDM_PSTable->reg_a74); ODM_SetBBReg(pDM_Odm, 0x818, BIT(28), 0x0); if (pDM_Odm->SupportICType == ODM_RTL8723A) ODM_SetBBReg(pDM_Odm, 0x874, BIT(5), 0x0); /* Reg874[5]=1b'0 */ } - pDM_PSTable->PreRFState = pDM_PSTable->CurRFState; + pDM_PSTable->pre_rf_state = pDM_PSTable->cur_rf_state; } } diff --git a/drivers/staging/r8188eu/include/odm.h b/drivers/staging/r8188eu/include/odm.h index ee051e053ac6..d9041ee576bb 100644 --- a/drivers/staging/r8188eu/include/odm.h +++ b/drivers/staging/r8188eu/include/odm.h @@ -123,16 +123,19 @@ struct rtw_dig { }; struct rtl_ps { - u8 PreCCAState; - u8 CurCCAState; + u8 pre_cca_state; + u8 cur_cca_state; - u8 PreRFState; - u8 CurRFState; + u8 pre_rf_state; + u8 cur_rf_state; - int Rssi_val_min; + int rssi_val_min; u8 initialize; - u32 Reg874,RegC70,Reg85C,RegA74; + u32 reg_874; + u32 reg_c70; + u32 reg_85c; + u32 reg_a74; }; -- cgit v1.2.3 From 65bbdabe2a27a4f46387a3b6976d2355d67f9706 Mon Sep 17 00:00:00 2001 From: Aakash Hemadri Date: Sat, 28 Aug 2021 09:59:49 +0530 Subject: staging: wlan-ng: fix invalid assignment warning p80211_hdr->frame_control is u16, change to __le16 to satisfy sparse warning: wlan-ng/prism2sta.c:253:43: warning: invalid assignment: |= wlan-ng/prism2sta.c:253:43: left side has type unsigned short wlan-ng/prism2sta.c:253:43: right side has type restricted __le16 Fixes: 6277fbfdd29c ("staging: wlan-ng: Remove pointless a3/a4 union") Reviewed-by: Kees Cook Signed-off-by: Aakash Hemadri Link: https://lore.kernel.org/r/20210828042949.2276341-1-aakashhemadri123@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/wlan-ng/p80211hdr.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/staging') diff --git a/drivers/staging/wlan-ng/p80211hdr.h b/drivers/staging/wlan-ng/p80211hdr.h index dd1fb99bf340..5871a55e4a61 100644 --- a/drivers/staging/wlan-ng/p80211hdr.h +++ b/drivers/staging/wlan-ng/p80211hdr.h @@ -149,7 +149,7 @@ /* Generic 802.11 Header types */ struct p80211_hdr { - u16 frame_control; + __le16 frame_control; u16 duration_id; u8 address1[ETH_ALEN]; u8 address2[ETH_ALEN]; -- cgit v1.2.3 From e1e0ee8ed2b0e95df46785a98118465de880137e Mon Sep 17 00:00:00 2001 From: Aldas Taraškevičius Date: Fri, 27 Aug 2021 19:32:03 +0300 Subject: staging: vt6656: Remove filenames in files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit checkpatch.pl warning: It's generally not useful to have the filename in the file Remove the filenames. Signed-off-by: Aldas Taraškevičius Link: https://lore.kernel.org/r/20210827163203.4100-1-aldas60@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6656/baseband.c | 2 -- drivers/staging/vt6656/baseband.h | 2 -- drivers/staging/vt6656/card.c | 1 - drivers/staging/vt6656/card.h | 2 -- drivers/staging/vt6656/channel.c | 2 -- drivers/staging/vt6656/channel.h | 2 -- drivers/staging/vt6656/desc.h | 2 -- drivers/staging/vt6656/device.h | 2 -- drivers/staging/vt6656/key.c | 2 -- drivers/staging/vt6656/key.h | 2 -- drivers/staging/vt6656/mac.c | 2 -- drivers/staging/vt6656/mac.h | 2 -- drivers/staging/vt6656/main_usb.c | 2 -- drivers/staging/vt6656/power.c | 2 -- drivers/staging/vt6656/power.h | 2 -- drivers/staging/vt6656/rf.c | 2 -- drivers/staging/vt6656/rf.h | 2 -- drivers/staging/vt6656/rxtx.c | 2 -- drivers/staging/vt6656/rxtx.h | 2 -- drivers/staging/vt6656/usbpipe.c | 2 -- drivers/staging/vt6656/usbpipe.h | 2 -- drivers/staging/vt6656/wcmd.c | 2 -- drivers/staging/vt6656/wcmd.h | 2 -- 23 files changed, 45 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6656/baseband.c b/drivers/staging/vt6656/baseband.c index 41ae779ec61f..1e1c5a7d8968 100644 --- a/drivers/staging/vt6656/baseband.c +++ b/drivers/staging/vt6656/baseband.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: baseband.c - * * Purpose: Implement functions to access baseband * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/baseband.h b/drivers/staging/vt6656/baseband.h index 12456ebc23ec..dce50a311f24 100644 --- a/drivers/staging/vt6656/baseband.h +++ b/drivers/staging/vt6656/baseband.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: baseband.h - * * Purpose: Implement functions to access baseband * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/card.c b/drivers/staging/vt6656/card.c index 396736eee690..e92ecfad26d2 100644 --- a/drivers/staging/vt6656/card.c +++ b/drivers/staging/vt6656/card.c @@ -3,7 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: card.c * Purpose: Provide functions to setup NIC operation mode * Functions: * vnt_set_rspinf - Set RSPINF diff --git a/drivers/staging/vt6656/card.h b/drivers/staging/vt6656/card.h index a524fdc60ae3..be32c25c95de 100644 --- a/drivers/staging/vt6656/card.h +++ b/drivers/staging/vt6656/card.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: card.h - * * Purpose: Provide functions to setup NIC operation mode * * Author: Tevin Chen diff --git a/drivers/staging/vt6656/channel.c b/drivers/staging/vt6656/channel.c index 7855689af7cb..eb2d52e6420b 100644 --- a/drivers/staging/vt6656/channel.c +++ b/drivers/staging/vt6656/channel.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: channel.c - * * Purpose: Channel number mapping * * Author: Lucas Lin diff --git a/drivers/staging/vt6656/channel.h b/drivers/staging/vt6656/channel.h index cca330f0daf4..723660e40310 100644 --- a/drivers/staging/vt6656/channel.h +++ b/drivers/staging/vt6656/channel.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: channel.h - * * Purpose: Country Regulation Rules header file * * Author: Lucas Lin diff --git a/drivers/staging/vt6656/desc.h b/drivers/staging/vt6656/desc.h index 703597a911f4..c13561e528db 100644 --- a/drivers/staging/vt6656/desc.h +++ b/drivers/staging/vt6656/desc.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: desc.h - * * Purpose:The header file of descriptor * * Revision History: diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h index 2c93a2e66c8a..8b6623a751f0 100644 --- a/drivers/staging/vt6656/device.h +++ b/drivers/staging/vt6656/device.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: device.h - * * Purpose: MAC Data structure * * Author: Tevin Chen diff --git a/drivers/staging/vt6656/key.c b/drivers/staging/vt6656/key.c index 70f75c5760ce..bdc5f30c4f9d 100644 --- a/drivers/staging/vt6656/key.c +++ b/drivers/staging/vt6656/key.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: key.c - * * Purpose: Implement functions for 802.11i Key management * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/key.h b/drivers/staging/vt6656/key.h index 1f3449e66143..6f1d5b4f6da7 100644 --- a/drivers/staging/vt6656/key.h +++ b/drivers/staging/vt6656/key.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: key.h - * * Purpose: Implement functions for 802.11i Key management * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/mac.c b/drivers/staging/vt6656/mac.c index da7067c34643..4f1f9b03a678 100644 --- a/drivers/staging/vt6656/mac.c +++ b/drivers/staging/vt6656/mac.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: mac.c - * * Purpose: MAC routines * * Author: Tevin Chen diff --git a/drivers/staging/vt6656/mac.h b/drivers/staging/vt6656/mac.h index dae70b5c7634..05af9ca7d69c 100644 --- a/drivers/staging/vt6656/mac.h +++ b/drivers/staging/vt6656/mac.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: mac.h - * * Purpose: MAC routines * * Author: Tevin Chen diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c index b90d3dab28b1..ae7f5916d4d6 100644 --- a/drivers/staging/vt6656/main_usb.c +++ b/drivers/staging/vt6656/main_usb.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: main_usb.c - * * Purpose: driver entry for initial, open, close, tx and rx. * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/power.c b/drivers/staging/vt6656/power.c index 2f49c870272a..e5411f6284c7 100644 --- a/drivers/staging/vt6656/power.c +++ b/drivers/staging/vt6656/power.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: power.c - * * Purpose: Handles 802.11 power management functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/power.h b/drivers/staging/vt6656/power.h index 160872026db3..9f9c70072933 100644 --- a/drivers/staging/vt6656/power.h +++ b/drivers/staging/vt6656/power.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: power.h - * * Purpose: Handles 802.11 power management functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/rf.c b/drivers/staging/vt6656/rf.c index bcd4d467e03a..b9c06b312ae1 100644 --- a/drivers/staging/vt6656/rf.c +++ b/drivers/staging/vt6656/rf.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rf.c - * * Purpose: rf function code * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/rf.h b/drivers/staging/vt6656/rf.h index 493faaf4e2b5..b47e149875d1 100644 --- a/drivers/staging/vt6656/rf.h +++ b/drivers/staging/vt6656/rf.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rf.h - * * Purpose: * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c index 5dd6b4d2bf20..a31947f2620d 100644 --- a/drivers/staging/vt6656/rxtx.c +++ b/drivers/staging/vt6656/rxtx.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rxtx.c - * * Purpose: handle WMAC/802.3/802.11 rx & tx functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/rxtx.h b/drivers/staging/vt6656/rxtx.h index f23440799443..b9df0854b4b0 100644 --- a/drivers/staging/vt6656/rxtx.h +++ b/drivers/staging/vt6656/rxtx.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rxtx.h - * * Purpose: * * Author: Jerry Chen diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c index 82b774be6485..7f45734390f6 100644 --- a/drivers/staging/vt6656/usbpipe.c +++ b/drivers/staging/vt6656/usbpipe.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: usbpipe.c - * * Purpose: Handle USB control endpoint * * Author: Warren Hsu diff --git a/drivers/staging/vt6656/usbpipe.h b/drivers/staging/vt6656/usbpipe.h index 52c2a928c9c1..922312e299bf 100644 --- a/drivers/staging/vt6656/usbpipe.h +++ b/drivers/staging/vt6656/usbpipe.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: usbpipe.h - * * Purpose: * * Author: Warren Hsu diff --git a/drivers/staging/vt6656/wcmd.c b/drivers/staging/vt6656/wcmd.c index 0ccc87da394e..e8ee2fbee76c 100644 --- a/drivers/staging/vt6656/wcmd.c +++ b/drivers/staging/vt6656/wcmd.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: wcmd.c - * * Purpose: Handles the management command interface functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6656/wcmd.h b/drivers/staging/vt6656/wcmd.h index a0d98cf74998..a62924671b17 100644 --- a/drivers/staging/vt6656/wcmd.h +++ b/drivers/staging/vt6656/wcmd.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: wcmd.h - * * Purpose: Handles the management command interface functions * * Author: Lyndon Chen -- cgit v1.2.3 From 6506cd9f3ae9c9777a581b309f2ca1a215128fbf Mon Sep 17 00:00:00 2001 From: Phillip Potter Date: Sat, 28 Aug 2021 01:02:31 +0100 Subject: staging: r8188eu: add extra TODO entries Add entry for CFG80211 to reflect that it is currently being worked on and is a desirable feature to have for this driver. Leave entries for LIB80211 and MAC80211 in case anyone else wishes to work on them - they can always be removed later, but MAC80211 in particular would certainly be good to aim for. Also, include an entry for improving error handling, as this is another goal of the cleanup effort. Signed-off-by: Phillip Potter Link: https://lore.kernel.org/r/20210828000231.1458-1-phil@philpotter.co.uk Signed-off-by: Greg Kroah-Hartman --- drivers/staging/r8188eu/TODO | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/staging') diff --git a/drivers/staging/r8188eu/TODO b/drivers/staging/r8188eu/TODO index 98f918480990..ab9d5d145b3b 100644 --- a/drivers/staging/r8188eu/TODO +++ b/drivers/staging/r8188eu/TODO @@ -11,3 +11,6 @@ To-do list: the driver. * Switch to use LIB80211. * Switch to use MAC80211. +* Switch to use CFG80211. +* Improve the error handling of various functions, particularly those that use + existing kernel APIs. -- cgit v1.2.3 From 4adb389e08c95fdf91995271932c59250ff0d561 Mon Sep 17 00:00:00 2001 From: Aldas Taraškevičius Date: Sat, 28 Aug 2021 10:21:19 +0300 Subject: staging: vt6655: Remove filenames in files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix checkpatch warnings about having filenames in the files. Signed-off-by: Aldas Taraškevičius Link: https://lore.kernel.org/r/20210828072119.1395-1-aldas60@gmail.com Signed-off-by: Greg Kroah-Hartman --- drivers/staging/vt6655/desc.h | 2 -- drivers/staging/vt6655/device.h | 2 -- drivers/staging/vt6655/power.c | 2 -- drivers/staging/vt6655/power.h | 2 -- drivers/staging/vt6655/rf.c | 2 -- drivers/staging/vt6655/rf.h | 2 -- drivers/staging/vt6655/rxtx.c | 2 -- drivers/staging/vt6655/rxtx.h | 2 -- drivers/staging/vt6655/srom.c | 2 -- drivers/staging/vt6655/srom.h | 2 -- drivers/staging/vt6655/tmacro.h | 2 -- 11 files changed, 22 deletions(-) (limited to 'drivers/staging') diff --git a/drivers/staging/vt6655/desc.h b/drivers/staging/vt6655/desc.h index d4572847b08a..17a40c53b8ff 100644 --- a/drivers/staging/vt6655/desc.h +++ b/drivers/staging/vt6655/desc.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: desc.h - * * Purpose:The header file of descriptor * * Revision History: diff --git a/drivers/staging/vt6655/device.h b/drivers/staging/vt6655/device.h index 29f354ced563..2af769174e33 100644 --- a/drivers/staging/vt6655/device.h +++ b/drivers/staging/vt6655/device.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: device.h - * * Purpose: MAC Data structure * * Author: Tevin Chen diff --git a/drivers/staging/vt6655/power.c b/drivers/staging/vt6655/power.c index 6b0407694e54..aac021e983d1 100644 --- a/drivers/staging/vt6655/power.c +++ b/drivers/staging/vt6655/power.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: power.c - * * Purpose: Handles 802.11 power management functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6655/power.h b/drivers/staging/vt6655/power.h index d1736c1cbfa8..060516f81f5b 100644 --- a/drivers/staging/vt6655/power.h +++ b/drivers/staging/vt6655/power.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: power.h - * * Purpose: Handles 802.11 power management functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6655/rf.c b/drivers/staging/vt6655/rf.c index 747d79265a7c..0dae593c6944 100644 --- a/drivers/staging/vt6655/rf.c +++ b/drivers/staging/vt6655/rf.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rf.c - * * Purpose: rf function code * * Author: Jerry Chen diff --git a/drivers/staging/vt6655/rf.h b/drivers/staging/vt6655/rf.h index affb70eba10f..d499aed45c9f 100644 --- a/drivers/staging/vt6655/rf.h +++ b/drivers/staging/vt6655/rf.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rf.h - * * Purpose: * * Author: Jerry Chen diff --git a/drivers/staging/vt6655/rxtx.c b/drivers/staging/vt6655/rxtx.c index ff452067a617..5395c3a3e35a 100644 --- a/drivers/staging/vt6655/rxtx.c +++ b/drivers/staging/vt6655/rxtx.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rxtx.c - * * Purpose: handle WMAC/802.3/802.11 rx & tx functions * * Author: Lyndon Chen diff --git a/drivers/staging/vt6655/rxtx.h b/drivers/staging/vt6655/rxtx.h index c3c2c1566882..a67757c9bb5c 100644 --- a/drivers/staging/vt6655/rxtx.h +++ b/drivers/staging/vt6655/rxtx.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: rxtx.h - * * Purpose: * * Author: Jerry Chen diff --git a/drivers/staging/vt6655/srom.c b/drivers/staging/vt6655/srom.c index df57d120ed30..5cdbc24e8c45 100644 --- a/drivers/staging/vt6655/srom.c +++ b/drivers/staging/vt6655/srom.c @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: srom.c - * * Purpose:Implement functions to access eeprom * * Author: Jerry Chen diff --git a/drivers/staging/vt6655/srom.h b/drivers/staging/vt6655/srom.h index d8aad3ff5f46..b03073ffa18a 100644 --- a/drivers/staging/vt6655/srom.h +++ b/drivers/staging/vt6655/srom.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: srom.h - * * Purpose: Implement functions to access eeprom * * Author: Jerry Chen diff --git a/drivers/staging/vt6655/tmacro.h b/drivers/staging/vt6655/tmacro.h index 8f4699f0d1f4..1582c03124c9 100644 --- a/drivers/staging/vt6655/tmacro.h +++ b/drivers/staging/vt6655/tmacro.h @@ -3,8 +3,6 @@ * Copyright (c) 1996, 2003 VIA Networking Technologies, Inc. * All rights reserved. * - * File: tmacro.h - * * Purpose: define basic common types and macros * * Author: Tevin Chen -- cgit v1.2.3