From e09b41010ba33a20a87472ee821fa407a5b8da36 Mon Sep 17 00:00:00 2001 From: José Pekkarinen Date: Mon, 11 Apr 2016 10:41:07 +0300 Subject: These changes are the raw update to linux-4.4.6-rt14. Kernel sources are taken from kernel.org, and rt patch from the rt wiki download page. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During the rebasing, the following patch collided: Force tick interrupt and get rid of softirq magic(I70131fb85). Collisions have been removed because its logic was found on the source already. Change-Id: I7f57a4081d9deaa0d9ccfc41a6c8daccdee3b769 Signed-off-by: José Pekkarinen --- .../drivers/staging/rtl8192u/ieee80211/ieee80211.h | 541 ++---- .../rtl8192u/ieee80211/ieee80211_crypt_ccmp.c | 57 +- .../rtl8192u/ieee80211/ieee80211_crypt_tkip.c | 102 +- .../rtl8192u/ieee80211/ieee80211_crypt_wep.c | 43 +- .../staging/rtl8192u/ieee80211/ieee80211_module.c | 2 +- .../staging/rtl8192u/ieee80211/ieee80211_rx.c | 99 +- .../staging/rtl8192u/ieee80211/ieee80211_softmac.c | 86 +- .../rtl8192u/ieee80211/ieee80211_softmac_wx.c | 104 +- .../staging/rtl8192u/ieee80211/ieee80211_tx.c | 20 +- .../staging/rtl8192u/ieee80211/ieee80211_wx.c | 8 - .../staging/rtl8192u/ieee80211/rtl819x_BAProc.c | 63 +- .../staging/rtl8192u/ieee80211/rtl819x_HTProc.c | 16 +- .../staging/rtl8192u/ieee80211/rtl819x_Qos.h | 49 +- .../staging/rtl8192u/ieee80211/rtl819x_TSProc.c | 4 +- kernel/drivers/staging/rtl8192u/r8190_rtl8256.h | 11 +- kernel/drivers/staging/rtl8192u/r8192U.h | 101 +- kernel/drivers/staging/rtl8192u/r8192U_core.c | 2018 +++++++++++--------- kernel/drivers/staging/rtl8192u/r8192U_dm.c | 39 +- kernel/drivers/staging/rtl8192u/r8192U_dm.h | 36 +- kernel/drivers/staging/rtl8192u/r8192U_hw.h | 145 +- kernel/drivers/staging/rtl8192u/r8192U_wx.c | 4 +- kernel/drivers/staging/rtl8192u/r8192U_wx.h | 2 +- kernel/drivers/staging/rtl8192u/r819xU_cmdpkt.h | 14 +- kernel/drivers/staging/rtl8192u/r819xU_firmware.c | 15 +- kernel/drivers/staging/rtl8192u/r819xU_firmware.h | 11 +- kernel/drivers/staging/rtl8192u/r819xU_phy.c | 4 +- kernel/drivers/staging/rtl8192u/r819xU_phy.h | 55 +- 27 files changed, 1851 insertions(+), 1798 deletions(-) (limited to 'kernel/drivers/staging/rtl8192u') diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211.h b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211.h index 0f53c6a97..967ef9a98 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211.h +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211.h @@ -24,7 +24,7 @@ #ifndef IEEE80211_H #define IEEE80211_H #include /* ETH_ALEN */ -#include /* ARRAY_SIZE */ +#include #include #include #include @@ -34,6 +34,7 @@ #include #include +#include #include "rtl819x_HT.h" #include "rtl819x_BA.h" @@ -48,21 +49,6 @@ #define IWEVCUSTOM 0x8c02 #endif - -#ifndef container_of -/** - * container_of - cast a member of a structure out to the containing structure - * - * @ptr: the pointer to the member. - * @type: the type of the container struct this is embedded in. - * @member: the name of the member within the struct. - * - */ -#define container_of(ptr, type, member) ({ \ - const typeof( ((type *)0)->member ) *__mptr = (ptr); \ - (type *)( (char *)__mptr - offsetof(type,member) );}) -#endif - #define KEY_TYPE_NA 0x0 #define KEY_TYPE_WEP40 0x1 #define KEY_TYPE_TKIP 0x2 @@ -187,54 +173,6 @@ typedef struct cb_desc { #define MGN_MCS14 0x8e #define MGN_MCS15 0x8f -//---------------------------------------------------------------------------- -// 802.11 Management frame Reason Code field -//---------------------------------------------------------------------------- -enum _ReasonCode{ - unspec_reason = 0x1, - auth_not_valid = 0x2, - deauth_lv_ss = 0x3, - inactivity = 0x4, - ap_overload = 0x5, - class2_err = 0x6, - class3_err = 0x7, - disas_lv_ss = 0x8, - asoc_not_auth = 0x9, - - //----MIC_CHECK - mic_failure = 0xe, - //----END MIC_CHECK - - // Reason code defined in 802.11i D10.0 p.28. - invalid_IE = 0x0d, - four_way_tmout = 0x0f, - two_way_tmout = 0x10, - IE_dismatch = 0x11, - invalid_Gcipher = 0x12, - invalid_Pcipher = 0x13, - invalid_AKMP = 0x14, - unsup_RSNIEver = 0x15, - invalid_RSNIE = 0x16, - auth_802_1x_fail= 0x17, - ciper_reject = 0x18, - - // Reason code defined in 7.3.1.7, 802.1e D13.0, p.42. Added by Annie, 2005-11-15. - QoS_unspec = 0x20, // 32 - QAP_bandwidth = 0x21, // 33 - poor_condition = 0x22, // 34 - no_facility = 0x23, // 35 - // Where is 36??? - req_declined = 0x25, // 37 - invalid_param = 0x26, // 38 - req_not_honored= 0x27, // 39 - TS_not_created = 0x2F, // 47 - DL_not_allowed = 0x30, // 48 - dest_not_exist = 0x31, // 49 - dest_not_QSTA = 0x32, // 50 -}; - - - #define aSifsTime ((priv->ieee80211->current_network.mode == IEEE_A || \ priv->ieee80211->current_network.mode == IEEE_N_24G || \ priv->ieee80211->current_network.mode == IEEE_N_5G) ? \ @@ -477,7 +415,7 @@ typedef struct ieee_param { /* QOS control */ #define IEEE80211_QCTL_TID 0x000F -#define FC_QOS_BIT BIT7 +#define FC_QOS_BIT BIT(7) #define IsDataFrame(pdu) ( ((pdu[0] & 0x0C)==0x08) ? true : false ) #define IsLegacyDataFrame(pdu) (IsDataFrame(pdu) && (!(pdu[0]&FC_QOS_BIT)) ) //added by wb. Is this right? @@ -646,13 +584,6 @@ struct ieee80211_snap_hdr { #define WLAN_GET_SEQ_FRAG(seq) ((seq) & IEEE80211_SCTL_FRAG) #define WLAN_GET_SEQ_SEQ(seq) (((seq) & IEEE80211_SCTL_SEQ) >> 4) -/* Authentication algorithms */ -#define WLAN_AUTH_OPEN 0 -#define WLAN_AUTH_SHARED_KEY 1 -#define WLAN_AUTH_LEAP 2 - -#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) @@ -671,69 +602,6 @@ struct ieee80211_snap_hdr { #define WLAN_ERP_USE_PROTECTION (1<<1) #define WLAN_ERP_BARKER_PREAMBLE (1<<2) -/* Status codes */ -enum ieee80211_statuscode { - WLAN_STATUS_SUCCESS = 0, - WLAN_STATUS_UNSPECIFIED_FAILURE = 1, - WLAN_STATUS_CAPS_UNSUPPORTED = 10, - WLAN_STATUS_REASSOC_NO_ASSOC = 11, - WLAN_STATUS_ASSOC_DENIED_UNSPEC = 12, - WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG = 13, - WLAN_STATUS_UNKNOWN_AUTH_TRANSACTION = 14, - WLAN_STATUS_CHALLENGE_FAIL = 15, - WLAN_STATUS_AUTH_TIMEOUT = 16, - WLAN_STATUS_AP_UNABLE_TO_HANDLE_NEW_STA = 17, - WLAN_STATUS_ASSOC_DENIED_RATES = 18, - /* 802.11b */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTPREAMBLE = 19, - WLAN_STATUS_ASSOC_DENIED_NOPBCC = 20, - WLAN_STATUS_ASSOC_DENIED_NOAGILITY = 21, - /* 802.11h */ - WLAN_STATUS_ASSOC_DENIED_NOSPECTRUM = 22, - WLAN_STATUS_ASSOC_REJECTED_BAD_POWER = 23, - WLAN_STATUS_ASSOC_REJECTED_BAD_SUPP_CHAN = 24, - /* 802.11g */ - WLAN_STATUS_ASSOC_DENIED_NOSHORTTIME = 25, - WLAN_STATUS_ASSOC_DENIED_NODSSSOFDM = 26, - /* 802.11i */ - WLAN_STATUS_INVALID_IE = 40, - WLAN_STATUS_INVALID_GROUP_CIPHER = 41, - WLAN_STATUS_INVALID_PAIRWISE_CIPHER = 42, - WLAN_STATUS_INVALID_AKMP = 43, - WLAN_STATUS_UNSUPP_RSN_VERSION = 44, - WLAN_STATUS_INVALID_RSN_IE_CAP = 45, - WLAN_STATUS_CIPHER_SUITE_REJECTED = 46, -}; - -/* Reason codes */ -enum ieee80211_reasoncode { - WLAN_REASON_UNSPECIFIED = 1, - WLAN_REASON_PREV_AUTH_NOT_VALID = 2, - WLAN_REASON_DEAUTH_LEAVING = 3, - WLAN_REASON_DISASSOC_DUE_TO_INACTIVITY = 4, - WLAN_REASON_DISASSOC_AP_BUSY = 5, - WLAN_REASON_CLASS2_FRAME_FROM_NONAUTH_STA = 6, - WLAN_REASON_CLASS3_FRAME_FROM_NONASSOC_STA = 7, - WLAN_REASON_DISASSOC_STA_HAS_LEFT = 8, - WLAN_REASON_STA_REQ_ASSOC_WITHOUT_AUTH = 9, - /* 802.11h */ - WLAN_REASON_DISASSOC_BAD_POWER = 10, - WLAN_REASON_DISASSOC_BAD_SUPP_CHAN = 11, - /* 802.11i */ - WLAN_REASON_INVALID_IE = 13, - WLAN_REASON_MIC_FAILURE = 14, - WLAN_REASON_4WAY_HANDSHAKE_TIMEOUT = 15, - WLAN_REASON_GROUP_KEY_HANDSHAKE_TIMEOUT = 16, - WLAN_REASON_IE_DIFFERENT = 17, - WLAN_REASON_INVALID_GROUP_CIPHER = 18, - WLAN_REASON_INVALID_PAIRWISE_CIPHER = 19, - WLAN_REASON_INVALID_AKMP = 20, - WLAN_REASON_UNSUPP_RSN_VERSION = 21, - WLAN_REASON_INVALID_RSN_IE_CAP = 22, - WLAN_REASON_IEEE8021X_FAILED = 23, - WLAN_REASON_CIPHER_SUITE_REJECTED = 24, -}; - #define IEEE80211_STATMASK_SIGNAL (1<<0) #define IEEE80211_STATMASK_RSSI (1<<1) #define IEEE80211_STATMASK_NOISE (1<<2) @@ -961,10 +829,10 @@ struct ieee80211_device; struct ieee80211_security { u16 active_key:2, enabled:1, - auth_mode:2, auth_algo:4, unicast_uses_group:1, encrypt:1; + u8 auth_mode; u8 key_sizes[WEP_KEYS]; u8 keys[WEP_KEYS][SCM_KEY_LEN]; u8 level; @@ -1020,20 +888,20 @@ enum ieee80211_mfie { /* Minimal header; can be used for passing 802.11 frames with sufficient * information to determine what type of underlying data type is actually * stored in the data. */ -struct ieee80211_hdr { +struct rtl_80211_hdr { __le16 frame_ctl; __le16 duration_id; u8 payload[0]; } __packed; -struct ieee80211_hdr_1addr { +struct rtl_80211_hdr_1addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; u8 payload[0]; } __packed; -struct ieee80211_hdr_2addr { +struct rtl_80211_hdr_2addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1041,7 +909,7 @@ struct ieee80211_hdr_2addr { u8 payload[0]; } __packed; -struct ieee80211_hdr_3addr { +struct rtl_80211_hdr_3addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1051,7 +919,7 @@ struct ieee80211_hdr_3addr { u8 payload[0]; } __packed; -struct ieee80211_hdr_4addr { +struct rtl_80211_hdr_4addr { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1062,7 +930,7 @@ struct ieee80211_hdr_4addr { u8 payload[0]; } __packed; -struct ieee80211_hdr_3addrqos { +struct rtl_80211_hdr_3addrqos { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1073,7 +941,7 @@ struct ieee80211_hdr_3addrqos { __le16 qos_ctl; } __packed; -struct ieee80211_hdr_4addrqos { +struct rtl_80211_hdr_4addrqos { __le16 frame_ctl; __le16 duration_id; u8 addr1[ETH_ALEN]; @@ -1092,7 +960,7 @@ struct ieee80211_info_element { } __packed; struct ieee80211_authentication { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 algorithm; __le16 transaction; __le16 status; @@ -1101,18 +969,18 @@ struct ieee80211_authentication { } __packed; struct ieee80211_disassoc { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 reason; } __packed; struct ieee80211_probe_request { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; /* SSID, supported rates */ struct ieee80211_info_element info_element[0]; } __packed; struct ieee80211_probe_response { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le32 time_stamp[2]; __le16 beacon_interval; __le16 capability; @@ -1125,7 +993,7 @@ struct ieee80211_probe_response { #define ieee80211_beacon ieee80211_probe_response struct ieee80211_assoc_request_frame { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 capability; __le16 listen_interval; /* SSID, supported rates, RSN */ @@ -1133,7 +1001,7 @@ struct ieee80211_assoc_request_frame { } __packed; struct ieee80211_reassoc_request_frame { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 capability; __le16 listen_interval; u8 current_ap[ETH_ALEN]; @@ -1142,7 +1010,7 @@ struct ieee80211_reassoc_request_frame { } __packed; struct ieee80211_assoc_response_frame { - struct ieee80211_hdr_3addr header; + struct rtl_80211_hdr_3addr header; __le16 capability; __le16 status; __le16 aid; @@ -1276,12 +1144,6 @@ struct ieee80211_tim_parameters { } __packed; //#else -struct ieee80211_wmm_ac_param { - u8 ac_aci_acm_aifsn; - u8 ac_ecwmin_ecwmax; - u16 ac_txop_limit; -}; - struct ieee80211_wmm_ts_info { u8 ac_dir_tid; u8 ac_up_psb; @@ -1329,9 +1191,9 @@ static inline const char *eap_get_type(int type) //added by amy for reorder static inline u8 Frame_QoSTID(u8 *buf) { - struct ieee80211_hdr_3addr *hdr; + struct rtl_80211_hdr_3addr *hdr; u16 fc; - hdr = (struct ieee80211_hdr_3addr *)buf; + hdr = (struct rtl_80211_hdr_3addr *)buf; fc = le16_to_cpu(hdr->frame_ctl); return (u8)((frameqos *)(buf + (((fc & IEEE80211_FCTL_TODS)&&(fc & IEEE80211_FCTL_FROMDS))? 30 : 24)))->field.tid; } @@ -1703,10 +1565,10 @@ typedef struct _RT_POWER_SAVE_CONTROL { } RT_POWER_SAVE_CONTROL, *PRT_POWER_SAVE_CONTROL; typedef u32 RT_RF_CHANGE_SOURCE; -#define RF_CHANGE_BY_SW BIT31 -#define RF_CHANGE_BY_HW BIT30 -#define RF_CHANGE_BY_PS BIT29 -#define RF_CHANGE_BY_IPS BIT28 +#define RF_CHANGE_BY_SW BIT(31) +#define RF_CHANGE_BY_HW BIT(30) +#define RF_CHANGE_BY_PS BIT(29) +#define RF_CHANGE_BY_IPS BIT(28) #define RF_CHANGE_BY_INIT 0 // Do not change the RFOff reason. Defined by Bruce, 2008-01-17. typedef enum @@ -2262,17 +2124,17 @@ static inline int ieee80211_get_hdrlen(u16 fc) return hdrlen; } -static inline u8 *ieee80211_get_payload(struct ieee80211_hdr *hdr) +static inline u8 *ieee80211_get_payload(struct rtl_80211_hdr *hdr) { switch (ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl))) { case IEEE80211_1ADDR_LEN: - return ((struct ieee80211_hdr_1addr *)hdr)->payload; + return ((struct rtl_80211_hdr_1addr *)hdr)->payload; case IEEE80211_2ADDR_LEN: - return ((struct ieee80211_hdr_2addr *)hdr)->payload; + return ((struct rtl_80211_hdr_2addr *)hdr)->payload; case IEEE80211_3ADDR_LEN: - return ((struct ieee80211_hdr_3addr *)hdr)->payload; + return ((struct rtl_80211_hdr_3addr *)hdr)->payload; case IEEE80211_4ADDR_LEN: - return ((struct ieee80211_hdr_4addr *)hdr)->payload; + return ((struct rtl_80211_hdr_4addr *)hdr)->payload; } return NULL; } @@ -2307,98 +2169,99 @@ static inline int ieee80211_is_cck_rate(u8 rate) /* ieee80211.c */ -extern void free_ieee80211(struct net_device *dev); -extern struct net_device *alloc_ieee80211(int sizeof_priv); +void free_ieee80211(struct net_device *dev); +struct net_device *alloc_ieee80211(int sizeof_priv); -extern int ieee80211_set_encryption(struct ieee80211_device *ieee); +int ieee80211_set_encryption(struct ieee80211_device *ieee); /* ieee80211_tx.c */ -extern int ieee80211_encrypt_fragment( - struct ieee80211_device *ieee, - struct sk_buff *frag, - int hdr_len); +int ieee80211_encrypt_fragment(struct ieee80211_device *ieee, + struct sk_buff *frag, int hdr_len); -extern int ieee80211_xmit(struct sk_buff *skb, - struct net_device *dev); -extern void ieee80211_txb_free(struct ieee80211_txb *); +int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev); +void ieee80211_txb_free(struct ieee80211_txb *); /* ieee80211_rx.c */ -extern int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats); -extern void ieee80211_rx_mgt(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header, - struct ieee80211_rx_stats *stats); +int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, + struct ieee80211_rx_stats *rx_stats); +void ieee80211_rx_mgt(struct ieee80211_device *ieee, + struct rtl_80211_hdr_4addr *header, + struct ieee80211_rx_stats *stats); /* ieee80211_wx.c */ -extern int ieee80211_wx_get_scan(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_set_encode(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *key); -extern int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, +int ieee80211_wx_get_scan(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *key); +int ieee80211_wx_set_encode(struct ieee80211_device *ieee, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, + union iwreq_data *wrqu, char *key); +int ieee80211_wx_get_encode(struct ieee80211_device *ieee, struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_auth(struct ieee80211_device *ieee, - struct iw_request_info *info, - struct iw_param *data, char *extra); -extern int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len); + union iwreq_data *wrqu, char *key); +int ieee80211_wx_get_encode_ext(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_auth(struct ieee80211_device *ieee, + struct iw_request_info *info, + struct iw_param *data, char *extra); +int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len); /* ieee80211_softmac.c */ -extern short ieee80211_is_54g(const struct ieee80211_network *net); -extern short ieee80211_is_shortslot(const struct ieee80211_network *net); -extern int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, - struct ieee80211_rx_stats *rx_stats, u16 type, - u16 stype); -extern void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee80211_network *net); +short ieee80211_is_54g(const struct ieee80211_network *net); +short ieee80211_is_shortslot(const struct ieee80211_network *net); +int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, + struct sk_buff *skb, + struct ieee80211_rx_stats *rx_stats, + u16 type, u16 stype); +void ieee80211_softmac_new_net(struct ieee80211_device *ieee, + struct ieee80211_network *net); void SendDisassociation(struct ieee80211_device *ieee, u8 *asSta, u8 asRsn); -extern void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee); - -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_master_bss(struct ieee80211_device *ieee); -extern void ieee80211_start_ibss(struct ieee80211_device *ieee); -extern void ieee80211_softmac_init(struct ieee80211_device *ieee); -extern void ieee80211_softmac_free(struct ieee80211_device *ieee); -extern void ieee80211_associate_abort(struct ieee80211_device *ieee); -extern void ieee80211_disassociate(struct ieee80211_device *ieee); -extern void ieee80211_stop_scan(struct ieee80211_device *ieee); -extern void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); -extern void ieee80211_check_all_nets(struct ieee80211_device *ieee); -extern void ieee80211_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); -extern void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); -extern void ieee80211_reset_queue(struct ieee80211_device *ieee); -extern void ieee80211_wake_queue(struct ieee80211_device *ieee); -extern void ieee80211_stop_queue(struct ieee80211_device *ieee); -extern struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); -extern void ieee80211_start_send_beacons(struct ieee80211_device *ieee); -extern void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); -extern int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p); -extern void notify_wx_assoc_event(struct ieee80211_device *ieee); -extern void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); - -extern void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee); +void ieee80211_softmac_xmit(struct ieee80211_txb *txb, + struct ieee80211_device *ieee); + +void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); +void notify_wx_assoc_event(struct ieee80211_device *ieee); +void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee); +void ieee80211_start_bss(struct ieee80211_device *ieee); +void ieee80211_start_master_bss(struct ieee80211_device *ieee); +void ieee80211_start_ibss(struct ieee80211_device *ieee); +void ieee80211_softmac_init(struct ieee80211_device *ieee); +void ieee80211_softmac_free(struct ieee80211_device *ieee); +void ieee80211_associate_abort(struct ieee80211_device *ieee); +void ieee80211_disassociate(struct ieee80211_device *ieee); +void ieee80211_stop_scan(struct ieee80211_device *ieee); +void ieee80211_start_scan_syncro(struct ieee80211_device *ieee); +void ieee80211_check_all_nets(struct ieee80211_device *ieee); +void ieee80211_start_protocol(struct ieee80211_device *ieee); +void ieee80211_stop_protocol(struct ieee80211_device *ieee); +void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee); +void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee); +void ieee80211_reset_queue(struct ieee80211_device *ieee); +void ieee80211_wake_queue(struct ieee80211_device *ieee); +void ieee80211_stop_queue(struct ieee80211_device *ieee); +struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee); +void ieee80211_start_send_beacons(struct ieee80211_device *ieee); +void ieee80211_stop_send_beacons(struct ieee80211_device *ieee); +int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, + struct iw_point *p); +void notify_wx_assoc_event(struct ieee80211_device *ieee); +void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success); + +void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee); /* ieee80211_crypt_ccmp&tkip&wep.c */ -extern void ieee80211_tkip_null(void); -extern void ieee80211_wep_null(void); -extern void ieee80211_ccmp_null(void); +void ieee80211_tkip_null(void); +void ieee80211_wep_null(void); +void ieee80211_ccmp_null(void); int ieee80211_crypto_init(void); void ieee80211_crypto_deinit(void); @@ -2411,116 +2274,128 @@ void ieee80211_crypto_wep_exit(void); /* ieee80211_softmac_wx.c */ -extern int ieee80211_wx_get_wap(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *ext); +int ieee80211_wx_get_wap(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *ext); -extern int ieee80211_wx_set_wap(struct ieee80211_device *ieee, +int ieee80211_wx_set_wap(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *awrq, char *extra); -extern int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b); +int ieee80211_wx_get_essid(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_rate(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rate(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_get_rate(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +int ieee80211_wx_set_mode(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_scan(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +int ieee80211_wx_set_scan(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_essid(struct ieee80211_device *ieee, - struct iw_request_info *a, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_essid(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +int ieee80211_wx_get_mode(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +int ieee80211_wx_set_freq(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); -extern int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, - union iwreq_data *wrqu, char *b); +int ieee80211_wx_get_freq(struct ieee80211_device *ieee, + struct iw_request_info *a, + union iwreq_data *wrqu, char *b); /* ieee80211_module.c */ -extern int ieee80211_debug_init(void); -extern void ieee80211_debug_exit(void); +int ieee80211_debug_init(void); +void ieee80211_debug_exit(void); //extern void ieee80211_wx_sync_scan_wq(struct ieee80211_device *ieee); -extern void ieee80211_wx_sync_scan_wq(struct work_struct *work); +void ieee80211_wx_sync_scan_wq(struct work_struct *work); -extern int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, - struct iw_request_info *info, +int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, + struct iw_request_info *info, union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_name(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_get_name(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_power(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_power(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_power(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_get_power(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_set_rts(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_set_rts(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); -extern int ieee80211_wx_get_rts(struct ieee80211_device *ieee, - struct iw_request_info *info, - union iwreq_data *wrqu, char *extra); +int ieee80211_wx_get_rts(struct ieee80211_device *ieee, + struct iw_request_info *info, + union iwreq_data *wrqu, char *extra); //HT #define MAX_RECEIVE_BUFFER_SIZE 9100 // -extern void HTDebugHTCapability(u8 *CapIE, u8 *TitleString ); -extern void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); - -void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); -extern void HTUpdateDefaultSetting(struct ieee80211_device *ieee); -extern void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, u8 *len, u8 isEncrypt); -extern void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *len, u8 isEncrypt); -extern void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, u8 *len); -extern void HTOnAssocRsp(struct ieee80211_device *ieee); -extern void HTInitializeHTInfo(struct ieee80211_device *ieee); -extern void HTInitializeBssDesc(PBSS_HT pBssHT); -extern void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork); -extern void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, struct ieee80211_network *pNetwork); -extern u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, u8 *pMCSRateSet, u8 *pMCSFilter); +void HTDebugHTCapability(u8 *CapIE, u8 *TitleString); +void HTDebugHTInfo(u8 *InfoIE, u8 *TitleString); + +void HTSetConnectBwMode(struct ieee80211_device *ieee, + HT_CHANNEL_WIDTH Bandwidth, HT_EXTCHNL_OFFSET Offset); +void HTUpdateDefaultSetting(struct ieee80211_device *ieee); +void HTConstructCapabilityElement(struct ieee80211_device *ieee, u8 *posHTCap, + u8 *len, u8 isEncrypt); +void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, + u8 *len, u8 isEncrypt); +void HTConstructRT2RTAggElement(struct ieee80211_device *ieee, u8 *posRT2RTAgg, + u8 *len); +void HTOnAssocRsp(struct ieee80211_device *ieee); +void HTInitializeHTInfo(struct ieee80211_device *ieee); +void HTInitializeBssDesc(PBSS_HT pBssHT); +void HTResetSelfAndSavePeerSetting(struct ieee80211_device *ieee, + struct ieee80211_network *pNetwork); +void HTUpdateSelfAndPeerSetting(struct ieee80211_device *ieee, + struct ieee80211_network *pNetwork); +u8 HTGetHighestMCSRate(struct ieee80211_device *ieee, + u8 *pMCSRateSet, u8 *pMCSFilter); extern u8 MCS_FILTER_ALL[]; extern u16 MCS_DATA_RATE[2][2][77] ; -extern u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame); +u8 HTCCheck(struct ieee80211_device *ieee, u8 *pFrame); //extern void HTSetConnectBwModeCallback(unsigned long data); -extern void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); -extern bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee); -extern u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); -extern u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); -extern u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate); +void HTResetIOTSetting(PRT_HIGH_THROUGHPUT pHTInfo); +bool IsHTHalfNmodeAPs(struct ieee80211_device *ieee); +u16 HTHalfMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); +u16 HTMcsToDataRate(struct ieee80211_device *ieee, u8 nMcsRate); +u16 TxCountToDataRate(struct ieee80211_device *ieee, u8 nDataRate); //function in BAPROC.c -extern int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, - struct sk_buff *skb); -extern int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, - struct sk_buff *skb); -extern int ieee80211_rx_DELBA(struct ieee80211_device *ieee,struct sk_buff *skb); -extern void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS, - u8 Policy, u8 bOverwritePending); -extern void TsInitDelBA(struct ieee80211_device *ieee, - PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); -extern void BaSetupTimeOut(unsigned long data); -extern void TxBaInactTimeout(unsigned long data); -extern void RxBaInactTimeout(unsigned long data); -extern void ResetBaEntry(PBA_RECORD pBA); +int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb); +int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb); +int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb); +void TsInitAddBA(struct ieee80211_device *ieee, PTX_TS_RECORD pTS, + u8 Policy, u8 bOverwritePending); +void TsInitDelBA(struct ieee80211_device *ieee, + PTS_COMMON_INFO pTsCommonInfo, TR_SELECT TxRxSelect); +void BaSetupTimeOut(unsigned long data); +void TxBaInactTimeout(unsigned long data); +void RxBaInactTimeout(unsigned long data); +void ResetBaEntry(PBA_RECORD pBA); //function in TS.c -extern bool GetTs( +bool GetTs( struct ieee80211_device *ieee, PTS_COMMON_INFO *ppTS, u8 *Addr, @@ -2528,10 +2403,10 @@ extern bool GetTs( TR_SELECT TxRxSelect, //Rx:1, Tx:0 bool bAddNewTs ); -extern void TSInitialize(struct ieee80211_device *ieee); -extern void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS); -extern void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr); -extern void RemoveAllTS(struct ieee80211_device *ieee); +void TSInitialize(struct ieee80211_device *ieee); +void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS); +void RemovePeerTS(struct ieee80211_device *ieee, u8 *Addr); +void RemoveAllTS(struct ieee80211_device *ieee); void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee); extern const long ieee80211_wlan_frequencies[]; @@ -2561,14 +2436,16 @@ static inline const char *escape_essid(const char *essid, u8 essid_len) { /* For the function is more related to hardware setting, it's better to use the * ieee handler to refer to it. */ -extern short check_nic_enough_desc(struct net_device *dev, int queue_index); -extern int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev); -extern int ieee80211_parse_info_param(struct ieee80211_device *ieee, - struct ieee80211_info_element *info_element, - u16 length, - struct ieee80211_network *network, - struct ieee80211_rx_stats *stats); - -void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_rxb **prxbIndicateArray,u8 index); +short check_nic_enough_desc(struct net_device *dev, int queue_index); +int ieee80211_data_xmit(struct sk_buff *skb, struct net_device *dev); +int ieee80211_parse_info_param(struct ieee80211_device *ieee, + struct ieee80211_info_element *info_element, + u16 length, + struct ieee80211_network *network, + struct ieee80211_rx_stats *stats); + +void ieee80211_indicate_packets(struct ieee80211_device *ieee, + struct ieee80211_rxb **prxbIndicateArray, + u8 index); #define RT_ASOC_RETRY_LIMIT 5 #endif /* IEEE80211_H */ diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c index 788704b80..27ce4817f 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_ccmp.c @@ -71,10 +71,9 @@ static void *ieee80211_ccmp_init(int key_idx) goto fail; priv->key_idx = key_idx; - priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); + priv->tfm = (void *)crypto_alloc_cipher("aes", 0, CRYPTO_ALG_ASYNC); if (IS_ERR(priv->tfm)) { - printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate " - "crypto API aes\n"); + printk(KERN_DEBUG "ieee80211_crypt_ccmp: could not allocate crypto API aes\n"); priv->tfm = NULL; goto fail; } @@ -105,6 +104,7 @@ static void ieee80211_ccmp_deinit(void *priv) static inline void xor_block(u8 *b, u8 *a, size_t len) { int i; + for (i = 0; i < len; i++) b[i] ^= a[i]; } @@ -112,7 +112,7 @@ static inline void xor_block(u8 *b, u8 *a, size_t len) static void ccmp_init_blocks(struct crypto_tfm *tfm, - struct ieee80211_hdr_4addr *hdr, + struct rtl_80211_hdr_4addr *hdr, u8 *pn, size_t dlen, u8 *b0, u8 *auth, u8 *s0) { @@ -125,10 +125,9 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, fc = le16_to_cpu(hdr->frame_ctl); a4_included = ((fc & (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)) == (IEEE80211_FCTL_TODS | IEEE80211_FCTL_FROMDS)); - /* - qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) && - (WLAN_FC_GET_STYPE(fc) & 0x08)); - */ + /* qc_included = ((WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) && + * (WLAN_FC_GET_STYPE(fc) & 0x08)); + */ /* fixed by David :2006.9.6 */ qc_included = (WLAN_FC_GET_TYPE(fc) == IEEE80211_FTYPE_DATA) && (WLAN_FC_GET_STYPE(fc) & 0x80); @@ -146,7 +145,8 @@ static void ccmp_init_blocks(struct crypto_tfm *tfm, * Flag (Include authentication header, M=3 (8-octet MIC), * L=1 (2-octet Dlen)) * Nonce: 0x00 | A2 | PN - * Dlen */ + * Dlen + */ b0[0] = 0x59; b0[1] = qc; memcpy(b0 + 2, hdr->addr2, ETH_ALEN); @@ -196,7 +196,7 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) struct ieee80211_ccmp_data *key = priv; int data_len, i; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); if (skb_headroom(skb) < CCMP_HDR_LEN || @@ -228,9 +228,8 @@ static int ieee80211_ccmp_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = key->tx_pn[0]; - hdr = (struct ieee80211_hdr_4addr *) skb->data; - if (!tcb_desc->bHwSec) - { + hdr = (struct rtl_80211_hdr_4addr *) skb->data; + if (!tcb_desc->bHwSec) { int blocks, last, len; u8 *mic; u8 *b0 = key->tx_b0; @@ -270,7 +269,7 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_ccmp_data *key = priv; u8 keyidx, *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); u8 pn[6]; @@ -279,28 +278,27 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return -1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet without ExtIV" - " flag from %pM\n", hdr->addr2); + printk(KERN_DEBUG "CCMP: received packet without ExtIV flag from %pM\n", + hdr->addr2); } key->dot11RSNAStatsCCMPFormatErrors++; return -2; } keyidx >>= 6; if (key->key_idx != keyidx) { - printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame " - "keyidx=%d priv=%p\n", key->key_idx, keyidx, priv); + printk(KERN_DEBUG "CCMP: RX tkey->key_idx=%d frame keyidx=%d priv=%p\n", + key->key_idx, keyidx, priv); return -6; } if (!key->key_set) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: received packet from %pM" - " with keyid=%d that does not have a configured" - " key\n", hdr->addr2, keyidx); + printk(KERN_DEBUG "CCMP: received packet from %pM with keyid=%d that does not have a configured key\n", + hdr->addr2, keyidx); } return -3; } @@ -315,15 +313,13 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(pn, key->rx_pn, CCMP_PN_LEN) <= 0) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: replay detected: STA=%pM" - " previous PN %pm received PN %pm\n", + printk(KERN_DEBUG "CCMP: replay detected: STA=%pM previous PN %pm received PN %pm\n", hdr->addr2, key->rx_pn, pn); } key->dot11RSNAStatsCCMPReplays++; return -4; } - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { size_t data_len = skb->len - hdr_len - CCMP_HDR_LEN - CCMP_MIC_LEN; u8 *mic = skb->data + skb->len - CCMP_MIC_LEN; u8 *b0 = key->rx_b0; @@ -353,8 +349,8 @@ static int ieee80211_ccmp_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(mic, a, CCMP_MIC_LEN) != 0) { if (net_ratelimit()) { - printk(KERN_DEBUG "CCMP: decrypt failed: STA=" - "%pM\n", hdr->addr2); + printk(KERN_DEBUG "CCMP: decrypt failed: STA=%pM\n", + hdr->addr2); } key->dot11RSNAStatsCCMPDecryptErrors++; return -5; @@ -429,9 +425,8 @@ static int ieee80211_ccmp_get_key(void *key, int len, u8 *seq, void *priv) static char *ieee80211_ccmp_print_stats(char *p, void *priv) { struct ieee80211_ccmp_data *ccmp = priv; - p += sprintf(p, "key[%d] alg=CCMP key_set=%d " - "tx_pn=%pm rx_pn=%pm " - "format_errors=%d replays=%d decrypt_errors=%d\n", + + p += sprintf(p, "key[%d] alg=CCMP key_set=%d tx_pn=%pm rx_pn=%pm format_errors=%d replays=%d decrypt_errors=%d\n", ccmp->key_idx, ccmp->key_set, ccmp->tx_pn, ccmp->rx_pn, ccmp->dot11RSNAStatsCCMPFormatErrors, diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c index e815c81b4..908bc2eb4 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_tkip.c @@ -185,8 +185,7 @@ static inline u16 Mk16_le(u16 *v) } -static const u16 Sbox[256] = -{ +static const u16 Sbox[256] = { 0xC6A5, 0xF884, 0xEE99, 0xF68D, 0xFF0D, 0xD6BD, 0xDEB1, 0x9154, 0x6050, 0x0203, 0xCEA9, 0x567D, 0xE719, 0xB562, 0x4DE6, 0xEC9A, 0x8F45, 0x1F9D, 0x8940, 0xFA87, 0xEF15, 0xB2EB, 0x8EC9, 0xFB0B, @@ -257,8 +256,10 @@ static void tkip_mixing_phase1(u16 *TTAK, const u8 *TK, const u8 *TA, u32 IV32) static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, u16 IV16) { - /* Make temporary area overlap WEP seed so that the final copy can be - * avoided on little endian hosts. */ + /* + * Make temporary area overlap WEP seed so that the final copy can be + * avoided on little endian hosts. + */ u16 *PPK = (u16 *) &WEPSeed[4]; /* Step 1 - make copy of TTAK and bring in TSC */ @@ -284,8 +285,10 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, PPK[4] += RotR1(PPK[3]); PPK[5] += RotR1(PPK[4]); - /* Step 3 - bring in last of TK bits, assign 24-bit WEP IV value - * WEPSeed[0..2] is transmitted as WEP IV */ + /* + * Step 3 - bring in last of TK bits, assign 24-bit WEP IV value + * WEPSeed[0..2] is transmitted as WEP IV + */ WEPSeed[0] = Hi8(IV16); WEPSeed[1] = (Hi8(IV16) | 0x20) & 0x7F; WEPSeed[2] = Lo8(IV16); @@ -294,6 +297,7 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, #ifdef __BIG_ENDIAN { int i; + for (i = 0; i < 6; i++) PPK[i] = (PPK[i] << 8) | (PPK[i] >> 8); } @@ -304,9 +308,9 @@ static void tkip_mixing_phase2(u8 *WEPSeed, const u8 *TK, const u16 *TTAK, static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; - int len; + int len; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->tx_tfm_arc4}; int ret = 0; @@ -318,19 +322,17 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) skb->len < hdr_len) return -1; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { if (!tkey->tx_phase1_done) { tkip_mixing_phase1(tkey->tx_ttak, tkey->key, hdr->addr2, - tkey->tx_iv32); + tkey->tx_iv32); tkey->tx_phase1_done = 1; } tkip_mixing_phase2(rc4key, tkey->key, tkey->tx_ttak, tkey->tx_iv16); - } - else - tkey->tx_phase1_done = 1; + } else + tkey->tx_phase1_done = 1; len = skb->len - hdr_len; @@ -338,14 +340,11 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) memmove(pos, pos + 8, hdr_len); pos += hdr_len; - if (tcb_desc->bHwSec) - { + if (tcb_desc->bHwSec) { *pos++ = Hi8(tkey->tx_iv16); *pos++ = (Hi8(tkey->tx_iv16) | 0x20) & 0x7F; *pos++ = Lo8(tkey->tx_iv16); - } - else - { + } else { *pos++ = rc4key[0]; *pos++ = rc4key[1]; *pos++ = rc4key[2]; @@ -357,8 +356,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) *pos++ = (tkey->tx_iv32 >> 16) & 0xff; *pos++ = (tkey->tx_iv32 >> 24) & 0xff; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { icv = skb_put(skb, 4); crc = ~crc32_le(~0, pos, len); icv[0] = crc; @@ -367,7 +365,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) icv[3] = crc >> 24; crypto_blkcipher_setkey(tkey->tx_tfm_arc4, rc4key, 16); sg_init_one(&sg, pos, len+4); - ret= crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); + ret = crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); } tkey->tx_iv16++; @@ -390,7 +388,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u8 keyidx, *pos; u32 iv32; u16 iv16; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); struct blkcipher_desc desc = {.tfm = tkey->rx_tfm_arc4}; u8 rc4key[16]; @@ -398,10 +396,11 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) u32 crc; struct scatterlist sg; int plen; + if (skb->len < hdr_len + 8 + 4) return -1; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; pos = skb->data + hdr_len; keyidx = pos[3]; if (!(keyidx & (1 << 5))) { @@ -429,8 +428,7 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) iv32 = pos[4] | (pos[5] << 8) | (pos[6] << 16) | (pos[7] << 24); pos += 8; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { if (iv32 < tkey->rx_iv32 || (iv32 == tkey->rx_iv32 && iv16 <= tkey->rx_iv16)) { if (net_ratelimit()) { @@ -471,8 +469,11 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) if (memcmp(icv, pos + plen, 4) != 0) { if (iv32 != tkey->rx_iv32) { - /* Previously cached Phase1 result was already lost, so - * it needs to be recalculated for the next packet. */ + /* + * Previously cached Phase1 result was already + * lost, so it needs to be recalculated for the + * next packet. + */ tkey->rx_phase1_done = 0; } if (net_ratelimit()) { @@ -485,8 +486,10 @@ static int ieee80211_tkip_decrypt(struct sk_buff *skb, int hdr_len, void *priv) } - /* Update real counters only after Michael MIC verification has - * completed */ + /* + * Update real counters only after Michael MIC verification has + * completed. + */ tkey->rx_iv32_new = iv32; tkey->rx_iv16_new = iv16; @@ -523,9 +526,9 @@ static int michael_mic(struct crypto_hash *tfm_michael, u8 *key, u8 *hdr, static void michael_mic_hdr(struct sk_buff *skb, u8 *hdr) { - struct ieee80211_hdr_4addr *hdr11; + struct rtl_80211_hdr_4addr *hdr11; - hdr11 = (struct ieee80211_hdr_4addr *) skb->data; + hdr11 = (struct rtl_80211_hdr_4addr *) skb->data; switch (le16_to_cpu(hdr11->frame_ctl) & (IEEE80211_FCTL_FROMDS | IEEE80211_FCTL_TODS)) { case IEEE80211_FCTL_TODS: @@ -556,9 +559,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri { struct ieee80211_tkip_data *tkey = priv; u8 *pos; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (skb_tailroom(skb) < 8 || skb->len < hdr_len) { printk(KERN_DEBUG "Invalid packet for Michael MIC add " @@ -571,9 +574,8 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri // { david, 2006.9.1 // fix the wpa process with wmm enabled. - if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->tx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } // } pos = skb_put(skb, 8); @@ -585,7 +587,7 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, void *pri } static void ieee80211_michael_mic_failure(struct net_device *dev, - struct ieee80211_hdr_4addr *hdr, + struct rtl_80211_hdr_4addr *hdr, int keyidx) { union iwreq_data wrqu; @@ -606,13 +608,13 @@ static void ieee80211_michael_mic_failure(struct net_device *dev, } static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, - int hdr_len, void *priv) + int hdr_len, void *priv) { struct ieee80211_tkip_data *tkey = priv; u8 mic[8]; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (!tkey->key_set) return -1; @@ -620,17 +622,17 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, michael_mic_hdr(skb, tkey->rx_hdr); // { david, 2006.9.1 // fix the wpa process with wmm enabled. - if(IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) { + if (IEEE80211_QOS_HAS_SEQ(le16_to_cpu(hdr->frame_ctl))) tkey->rx_hdr[12] = *(skb->data + hdr_len - 2) & 0x07; - } // } if (michael_mic(tkey->rx_tfm_michael, &tkey->key[24], tkey->rx_hdr, - skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) + skb->data + hdr_len, skb->len - 8 - hdr_len, mic)) return -1; if (memcmp(mic, skb->data + skb->len - 8, 8) != 0) { - struct ieee80211_hdr_4addr *hdr; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + struct rtl_80211_hdr_4addr *hdr; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; + printk(KERN_DEBUG "%s: Michael MIC verification failed for " "MSDU from %pM keyidx=%d\n", skb->dev ? skb->dev->name : "N/A", hdr->addr2, @@ -641,8 +643,10 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, return -1; } - /* Update TSC counters for RX now that the packet verification has - * completed. */ + /* + * Update TSC counters for RX now that the packet verification has + * completed. + */ tkey->rx_iv32 = tkey->rx_iv32_new; tkey->rx_iv16 = tkey->rx_iv16_new; @@ -702,6 +706,7 @@ static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) /* Return the sequence number of the last transmitted frame. */ u16 iv16 = tkey->tx_iv16; u32 iv32 = tkey->tx_iv32; + if (iv16 == 0) iv32--; iv16--; @@ -720,6 +725,7 @@ static int ieee80211_tkip_get_key(void *key, int len, u8 *seq, void *priv) static char *ieee80211_tkip_print_stats(char *p, void *priv) { struct ieee80211_tkip_data *tkip = priv; + p += sprintf(p, "key[%d] alg=TKIP key_set=%d " "tx_pn=%02x%02x%02x%02x%02x%02x " "rx_pn=%02x%02x%02x%02x%02x%02x " diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c index 0a17f84bb..681611dc9 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_crypt_wep.c @@ -19,7 +19,7 @@ #include "ieee80211.h" #include - #include +#include #include MODULE_AUTHOR("Jouni Malinen"); @@ -43,38 +43,24 @@ static void *prism2_wep_init(int keyidx) priv = kzalloc(sizeof(*priv), GFP_ATOMIC); if (priv == NULL) - goto fail; + return NULL; priv->key_idx = keyidx; priv->tx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->tx_tfm)) { - pr_debug("ieee80211_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->tx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->tx_tfm)) + goto free_priv; priv->rx_tfm = crypto_alloc_blkcipher("ecb(arc4)", 0, CRYPTO_ALG_ASYNC); - if (IS_ERR(priv->rx_tfm)) { - pr_debug("ieee80211_crypt_wep: could not allocate " - "crypto API arc4\n"); - priv->rx_tfm = NULL; - goto fail; - } + if (IS_ERR(priv->rx_tfm)) + goto free_tx; /* start WEP IV from a random value */ get_random_bytes(&priv->iv, 4); return priv; - -fail: - if (priv) { - if (priv->tx_tfm) - crypto_free_blkcipher(priv->tx_tfm); - if (priv->rx_tfm) - crypto_free_blkcipher(priv->rx_tfm); - kfree(priv); - } - +free_tx: + crypto_free_blkcipher(priv->tx_tfm); +free_priv: + kfree(priv); return NULL; } @@ -142,9 +128,7 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Copy rest of the WEP key (the secret part) */ memcpy(key + 3, wep->key, wep->key_len); - if (!tcb_desc->bHwSec) - { - + if (!tcb_desc->bHwSec) { /* Append little-endian CRC32 and encrypt it to produce ICV */ crc = ~crc32_le(~0, pos, len); icv = skb_put(skb, 4); @@ -201,8 +185,7 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) /* Apply RC4 to data and compute CRC32 over decrypted data */ plen = skb->len - hdr_len - 8; - if (!tcb_desc->bHwSec) - { + if (!tcb_desc->bHwSec) { crypto_blkcipher_setkey(wep->rx_tfm, key, klen); sg_init_one(&sg, pos, plen+4); @@ -293,6 +276,4 @@ void __exit ieee80211_crypto_wep_exit(void) void ieee80211_wep_null(void) { -// printk("============>%s()\n", __func__); - return; } diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c index 31233d895..425b2ddfc 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_module.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include "ieee80211.h" diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 9fbb53d8c..130c852ff 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c @@ -47,7 +47,7 @@ static inline void ieee80211_monitor_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { - struct ieee80211_hdr_4addr *hdr = (struct ieee80211_hdr_4addr *)skb->data; + struct rtl_80211_hdr_4addr *hdr = (struct rtl_80211_hdr_4addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); skb->dev = ieee->dev; @@ -94,7 +94,7 @@ ieee80211_frag_cache_find(struct ieee80211_device *ieee, unsigned int seq, /* Called only as a tasklet (software IRQ) */ static struct sk_buff * ieee80211_frag_cache_get(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *hdr) + struct rtl_80211_hdr_4addr *hdr) { struct sk_buff *skb = NULL; u16 fc = le16_to_cpu(hdr->frame_ctl); @@ -102,17 +102,17 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, unsigned int frag = WLAN_GET_SEQ_FRAG(sc); unsigned int seq = WLAN_GET_SEQ_SEQ(sc); struct ieee80211_frag_entry *entry; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; + struct rtl_80211_hdr_3addrqos *hdr_3addrqos; + struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; if (((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr; + hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; } else if (IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr; + hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)hdr; tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; @@ -123,7 +123,7 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, if (frag == 0) { /* Reserve enough space to fit maximum frame length */ skb = dev_alloc_skb(ieee->dev->mtu + - sizeof(struct ieee80211_hdr_4addr) + + sizeof(struct rtl_80211_hdr_4addr) + 8 /* LLC */ + 2 /* alignment */ + 8 /* WEP */ + @@ -163,23 +163,23 @@ ieee80211_frag_cache_get(struct ieee80211_device *ieee, /* Called only as a tasklet (software IRQ) */ static int ieee80211_frag_cache_invalidate(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *hdr) + struct rtl_80211_hdr_4addr *hdr) { u16 fc = le16_to_cpu(hdr->frame_ctl); u16 sc = le16_to_cpu(hdr->seq_ctl); unsigned int seq = WLAN_GET_SEQ_SEQ(sc); struct ieee80211_frag_entry *entry; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; + struct rtl_80211_hdr_3addrqos *hdr_3addrqos; + struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)hdr; + hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)hdr; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; } else if (IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)hdr; + hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)hdr; tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; @@ -217,10 +217,10 @@ ieee80211_rx_frame_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb, * this is not mandatory.... but seems that the probe * response parser uses it */ - struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)skb->data; + struct rtl_80211_hdr_3addr *hdr = (struct rtl_80211_hdr_3addr *)skb->data; rx_stats->len = skb->len; - ieee80211_rx_mgt(ieee,(struct ieee80211_hdr_4addr *)skb->data,rx_stats); + ieee80211_rx_mgt(ieee,(struct rtl_80211_hdr_4addr *)skb->data,rx_stats); /* if ((ieee->state == IEEE80211_LINKED) && (memcmp(hdr->addr3, ieee->current_network.bssid, ETH_ALEN))) */ if ((memcmp(hdr->addr1, ieee->dev->dev_addr, ETH_ALEN)))/* use ADDR1 to perform address matching for Management frames */ { @@ -298,13 +298,13 @@ static int ieee80211_is_eapol_frame(struct ieee80211_device *ieee, { struct net_device *dev = ieee->dev; u16 fc, ethertype; - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; u8 *pos; if (skb->len < 24) return 0; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; fc = le16_to_cpu(hdr->frame_ctl); /* check that the frame is unicast frame to us */ @@ -338,7 +338,7 @@ static inline int ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_crypt_data *crypt) { - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; int res, hdrlen; if (crypt == NULL || crypt->ops->decrypt_mpdu == NULL) @@ -348,7 +348,7 @@ ieee80211_rx_frame_decrypt(struct ieee80211_device *ieee, struct sk_buff *skb, cb_desc *tcb_desc = (cb_desc *)(skb->cb+ MAX_DEV_ADDR_SIZE); tcb_desc->bHwSec = 1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); if (ieee->tkip_countermeasures && @@ -385,7 +385,7 @@ static inline int ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *skb, int keyidx, struct ieee80211_crypt_data *crypt) { - struct ieee80211_hdr_4addr *hdr; + struct rtl_80211_hdr_4addr *hdr; int res, hdrlen; if (crypt == NULL || crypt->ops->decrypt_msdu == NULL) @@ -396,7 +396,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *s tcb_desc->bHwSec = 1; } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; hdrlen = ieee80211_get_hdrlen(le16_to_cpu(hdr->frame_ctl)); atomic_inc(&crypt->refcnt); @@ -416,7 +416,7 @@ ieee80211_rx_frame_decrypt_msdu(struct ieee80211_device *ieee, struct sk_buff *s /* this function is stolen from ipw2200 driver*/ #define IEEE_PACKET_RETRY_TIME (5*HZ) static int is_duplicate_packet(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header) + struct rtl_80211_hdr_4addr *header) { u16 fc = le16_to_cpu(header->frame_ctl); u16 sc = le16_to_cpu(header->seq_ctl); @@ -424,19 +424,19 @@ static int is_duplicate_packet(struct ieee80211_device *ieee, u16 frag = WLAN_GET_SEQ_FRAG(sc); u16 *last_seq, *last_frag; unsigned long *last_time; - struct ieee80211_hdr_3addrqos *hdr_3addrqos; - struct ieee80211_hdr_4addrqos *hdr_4addrqos; + struct rtl_80211_hdr_3addrqos *hdr_3addrqos; + struct rtl_80211_hdr_4addrqos *hdr_4addrqos; u8 tid; //TO2DS and QoS if(((fc & IEEE80211_FCTL_DSTODS) == IEEE80211_FCTL_DSTODS)&&IEEE80211_QOS_HAS_SEQ(fc)) { - hdr_4addrqos = (struct ieee80211_hdr_4addrqos *)header; + hdr_4addrqos = (struct rtl_80211_hdr_4addrqos *)header; tid = le16_to_cpu(hdr_4addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; } else if(IEEE80211_QOS_HAS_SEQ(fc)) { //QoS - hdr_3addrqos = (struct ieee80211_hdr_3addrqos *)header; + hdr_3addrqos = (struct rtl_80211_hdr_3addrqos *)header; tid = le16_to_cpu(hdr_3addrqos->qos_ctl) & IEEE80211_QCTL_TID; tid = UP2AC(tid); tid ++; @@ -492,14 +492,10 @@ static int is_duplicate_packet(struct ieee80211_device *ieee, // } if ((*last_seq == seq) && time_after(*last_time + IEEE_PACKET_RETRY_TIME, jiffies)) { - if (*last_frag == frag){ - //printk(KERN_WARNING "[1] go drop!\n"); + if (*last_frag == frag) goto drop; - - } if (*last_frag + 1 != frag) /* out-of-order fragment */ - //printk(KERN_WARNING "[2] go drop!\n"); goto drop; } else *last_seq = seq; @@ -510,7 +506,6 @@ static int is_duplicate_packet(struct ieee80211_device *ieee, drop: // BUG_ON(!(fc & IEEE80211_FCTL_RETRY)); -// printk("DUP\n"); return 1; } @@ -578,14 +573,12 @@ void ieee80211_indicate_packets(struct ieee80211_device *ieee, struct ieee80211_ /* Indicat the packets to upper layer */ if (sub_skb) { - //printk("0skb_len(%d)\n", skb->len); sub_skb->protocol = eth_type_trans(sub_skb, ieee->dev); memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); sub_skb->dev = ieee->dev; sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */ ieee->last_rx_ps_time = jiffies; - //printk("1skb_len(%d)\n", skb->len); netif_rx(sub_skb); } } @@ -768,10 +761,10 @@ static u8 parse_subframe(struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, struct ieee80211_rxb *rxb, u8 *src, u8 *dst) { - struct ieee80211_hdr_3addr *hdr = (struct ieee80211_hdr_3addr *)skb->data; + struct rtl_80211_hdr_3addr *hdr = (struct rtl_80211_hdr_3addr *)skb->data; u16 fc = le16_to_cpu(hdr->frame_ctl); - u16 LLCOffset= sizeof(struct ieee80211_hdr_3addr); + u16 LLCOffset= sizeof(struct rtl_80211_hdr_3addr); u16 ChkLength; bool bIsAggregateFrame = false; u16 nSubframe_Length; @@ -795,7 +788,6 @@ static u8 parse_subframe(struct sk_buff *skb, if (rx_stats->bContainHTC) { LLCOffset += sHTCLng; } - //printk("ChkLength = %d\n", LLCOffset); // Null packet, don't indicate it to upper layer ChkLength = LLCOffset;/* + (Frame_WEP(frame)!=0 ?Adapter->MgntInfo.SecurityInfo.EncryptionHeadOverhead:0);*/ @@ -888,8 +880,8 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats) { struct net_device *dev = ieee->dev; - struct ieee80211_hdr_4addr *hdr; - //struct ieee80211_hdr_3addrqos *hdr; + struct rtl_80211_hdr_4addr *hdr; + //struct rtl_80211_hdr_3addrqos *hdr; size_t hdrlen; u16 fc, type, stype, sc; @@ -907,7 +899,6 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, struct net_device *wds = NULL; struct sk_buff *skb2 = NULL; struct net_device *wds = NULL; - int frame_authorized = 0; int from_assoc_ap = 0; void *sta = NULL; #endif @@ -921,7 +912,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, int i; struct ieee80211_rxb *rxb = NULL; // cheat the the hdr type - hdr = (struct ieee80211_hdr_4addr *)skb->data; + hdr = (struct rtl_80211_hdr_4addr *)skb->data; stats = &ieee->stats; if (skb->len < 10) { @@ -1014,7 +1005,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, goto rx_dropped; // if QoS enabled, should check the sequence for each of the AC - if( (ieee->pHTInfo->bCurRxReorderEnable == false) || !ieee->current_network.qos_data.active|| !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)){ + if ((!ieee->pHTInfo->bCurRxReorderEnable) || !ieee->current_network.qos_data.active|| !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { if (is_duplicate_packet(ieee, hdr)) goto rx_dropped; @@ -1114,10 +1105,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, switch (hostap_handle_sta_rx(ieee, dev, skb, rx_stats, wds != NULL)) { case AP_RX_CONTINUE_NOT_AUTHORIZED: - frame_authorized = 0; - break; case AP_RX_CONTINUE: - frame_authorized = 1; break; case AP_RX_DROP: goto rx_dropped; @@ -1156,7 +1144,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; /* skb: hdr + (possibly fragmented) plaintext payload */ // PR: FIXME: hostap has additional conditions in the "if" below: @@ -1209,7 +1197,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, /* this was the last fragment and the frame will be * delivered, so remove skb from fragment cache */ skb = frag_skb; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; ieee80211_frag_cache_invalidate(ieee, hdr); } @@ -1226,7 +1214,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, ieee->LinkDetectInfo.NumRecvDataInPeriod++; ieee->LinkDetectInfo.NumRxOkInPeriod++; - hdr = (struct ieee80211_hdr_4addr *) skb->data; + hdr = (struct rtl_80211_hdr_4addr *) skb->data; if (crypt && !(fc & IEEE80211_FCTL_WEP) && !ieee->open_wep) { if (/*ieee->ieee802_1x &&*/ ieee80211_is_eapol_frame(ieee, skb, hdrlen)) { @@ -1307,7 +1295,7 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } //added by amy for reorder - if(ieee->pHTInfo->bCurRxReorderEnable == false ||pTS == NULL){ + if (!ieee->pHTInfo->bCurRxReorderEnable || pTS == NULL){ //added by amy for reorder for(i = 0; inr_subframes; i++) { struct sk_buff *sub_skb = rxb->subframes[i]; @@ -1340,14 +1328,12 @@ int ieee80211_rx(struct ieee80211_device *ieee, struct sk_buff *skb, } /* Indicat the packets to upper layer */ - //printk("0skb_len(%d)\n", skb->len); sub_skb->protocol = eth_type_trans(sub_skb, dev); memset(sub_skb->cb, 0, sizeof(sub_skb->cb)); sub_skb->dev = dev; sub_skb->ip_summed = CHECKSUM_NONE; /* 802.11 crc not sufficient */ //skb->ip_summed = CHECKSUM_UNNECESSARY; /* 802.11 crc not sufficient */ ieee->last_rx_ps_time = jiffies; - //printk("1skb_len(%d)\n", skb->len); netif_rx(sub_skb); } } @@ -1758,8 +1744,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, offset = (info_element->data[2] >> 1)*2; - //printk("offset1:%x aid:%x\n",offset, ieee->assoc_id); - if(ieee->assoc_id < 8*offset || ieee->assoc_id > 8*(offset + info_element->len -3)) @@ -2070,7 +2054,6 @@ int ieee80211_parse_info_param(struct ieee80211_device *ieee, case MFIE_TYPE_COUNTRY: IEEE80211_DEBUG_SCAN("MFIE_TYPE_COUNTRY: %d bytes\n", info_element->len); - //printk("=====>Receive <%s> Country IE\n",network->ssid); ieee80211_extract_country_ie(ieee, info_element, network, network->bssid);//addr2 is same as addr3 when from an AP break; /* TODO */ @@ -2366,10 +2349,10 @@ static inline void update_network(struct ieee80211_network *dst, /* dst->last_associate is not overwritten */ dst->wmm_info = src->wmm_info; //sure to exist in beacon or probe response frame. - if (src->wmm_param[0].ac_aci_acm_aifsn|| \ - src->wmm_param[1].ac_aci_acm_aifsn|| \ - src->wmm_param[2].ac_aci_acm_aifsn|| \ - src->wmm_param[3].ac_aci_acm_aifsn) { + if (src->wmm_param[0].aci_aifsn|| \ + src->wmm_param[1].aci_aifsn|| \ + src->wmm_param[2].aci_aifsn|| \ + src->wmm_param[3].aci_aifsn) { memcpy(dst->wmm_param, src->wmm_param, WME_AC_PRAM_LEN); } //dst->QoS_Enable = src->QoS_Enable; @@ -2612,7 +2595,7 @@ static inline void ieee80211_process_probe_response( } void ieee80211_rx_mgt(struct ieee80211_device *ieee, - struct ieee80211_hdr_4addr *header, + struct rtl_80211_hdr_4addr *header, struct ieee80211_rx_stats *stats) { switch (WLAN_FC_GET_STYPE(header->frame_ctl)) { diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index c2388812d..38c3eb780 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include #include "dot11d.h" @@ -222,8 +222,8 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header= - (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header= + (struct rtl_80211_hdr_3addr *) skb->data; cb_desc *tcb_desc = (cb_desc *)(skb->cb + 8); spin_lock_irqsave(&ieee->lock, flags); @@ -277,7 +277,6 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee printk("%s():insert to waitqueue!\n",__func__); skb_queue_tail(&ieee->skb_waitQ[tcb_desc->queue_index], skb); } else { - //printk("TX packet!\n"); ieee->softmac_hard_start_xmit(skb, ieee->dev); //dev_kfree_skb_any(skb);//edit by thomas } @@ -289,8 +288,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *i { short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header = - (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = + (struct rtl_80211_hdr_3addr *) skb->data; if(single){ @@ -418,7 +417,6 @@ static void ieee80211_send_probe_requests(struct ieee80211_device *ieee) ieee80211_send_probe(ieee); } } -EXPORT_SYMBOL(ieee80211_send_probe_requests); /* this performs syncro scan blocking the caller until all channels * in the allowed channel map has been checked. @@ -467,13 +465,9 @@ void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. */ - if(ieee->state < IEEE80211_LINKED) - ; - else - if (ieee->sync_scan_hurryup) + if (ieee->state >= IEEE80211_LINKED && ieee->sync_scan_hurryup) goto out; - msleep_interruptible_rsl(IEEE80211_SOFTMAC_SCAN_TIME); } @@ -660,10 +654,13 @@ inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *be auth = (struct ieee80211_authentication *) skb_put(skb, sizeof(struct ieee80211_authentication)); - auth->header.frame_ctl = IEEE80211_STYPE_AUTH; - if (challengelen) auth->header.frame_ctl |= IEEE80211_FCTL_WEP; + if (challengelen) + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH + | IEEE80211_FCTL_WEP); + else + auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); - auth->header.duration_id = 0x013a; //FIXME + auth->header.duration_id = cpu_to_le16(0x013a); memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -673,7 +670,7 @@ inline struct sk_buff *ieee80211_authentication_req(struct ieee80211_network *be if(ieee->auth_mode == 0) auth->algorithm = WLAN_AUTH_OPEN; else if(ieee->auth_mode == 1) - auth->algorithm = WLAN_AUTH_SHARED_KEY; + auth->algorithm = cpu_to_le16(WLAN_AUTH_SHARED_KEY); else if(ieee->auth_mode == 2) auth->algorithm = WLAN_AUTH_OPEN;//0x80; printk("=================>%s():auth->algorithm is %d\n",__func__,auth->algorithm); @@ -928,14 +925,14 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, short pwr) { struct sk_buff *skb; - struct ieee80211_hdr_3addr *hdr; + struct rtl_80211_hdr_3addr *hdr; - skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); + skb = dev_alloc_skb(sizeof(struct rtl_80211_hdr_3addr)); if (!skb) return NULL; - hdr = (struct ieee80211_hdr_3addr *)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); + hdr = (struct rtl_80211_hdr_3addr *)skb_put(skb,sizeof(struct rtl_80211_hdr_3addr)); memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -1084,7 +1081,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco hdr->header.frame_ctl = IEEE80211_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; //FIXME + hdr->header.duration_id = cpu_to_le16(37); memcpy(hdr->header.addr1, beacon->bssid, ETH_ALEN); memcpy(hdr->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(hdr->header.addr3, beacon->bssid, ETH_ALEN); @@ -1103,7 +1100,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco if (wmm_info_len) //QOS hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_QOS); - hdr->listen_interval = 0xa; //FIXME + hdr->listen_interval = cpu_to_le16(0xa); hdr->info_element[0].id = MFIE_TYPE_SSID; @@ -1174,7 +1171,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco tag = skb_put(skb, ht_cap_len); *tag++ = MFIE_TYPE_HT_CAP; *tag++ = ht_cap_len - 2; - memcpy(tag, ht_cap_buf,ht_cap_len -2); + memcpy(tag, ht_cap_buf, ht_cap_len - 2); tag += ht_cap_len -2; } } @@ -1211,7 +1208,7 @@ inline struct sk_buff *ieee80211_association_req(struct ieee80211_network *beaco tag = skb_put(skb, realtek_ie_len); *tag++ = MFIE_TYPE_GENERIC; *tag++ = realtek_ie_len - 2; - memcpy(tag, realtek_ie_buf,realtek_ie_len -2 ); + memcpy(tag, realtek_ie_buf, realtek_ie_len - 2); } } // printk("<=====%s(), %p, %p\n", __func__, ieee->dev, ieee->dev->dev_addr); @@ -1270,7 +1267,6 @@ static void ieee80211_associate_step1(struct ieee80211_device *ieee) else{ ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - //printk(KERN_WARNING "Sending authentication request\n"); softmac_mgmt_xmit(skb, ieee); //BUGON when you try to add_timer twice, using mod_timer may be better, john0709 if (!timer_pending(&ieee->associate_timer)) { @@ -1304,7 +1300,7 @@ static void ieee80211_auth_challenge(struct ieee80211_device *ieee, IEEE80211_DEBUG_MGMT("Sending authentication challenge response\n"); - ieee80211_encrypt_fragment(ieee, skb, sizeof(struct ieee80211_hdr_3addr )); + ieee80211_encrypt_fragment(ieee, skb, sizeof(struct rtl_80211_hdr_3addr )); softmac_mgmt_xmit(skb, ieee); mod_timer(&ieee->associate_timer, jiffies + (HZ/2)); @@ -1364,12 +1360,10 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; } ieee->link_change(ieee->dev); - if(ieee->is_silent_reset == 0){ + if (!ieee->is_silent_reset) { printk("============>normal associate\n"); - notify_wx_assoc_event(ieee); - } - else if(ieee->is_silent_reset == 1) - { + notify_wx_assoc_event(ieee); + } else { printk("==================>silent reset associate\n"); ieee->is_silent_reset = false; } @@ -1464,10 +1458,8 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, struct ieee } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - if (!ssidbroad) { - strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); - ieee->current_network.ssid_len = tmp_ssid_len; - } + strncpy(ieee->current_network.ssid, tmp_ssid, IW_ESSID_MAX_SIZE); + ieee->current_network.ssid_len = tmp_ssid_len; printk(KERN_INFO"Linking with %s,channel:%d, qos:%d, myHT:%d, networkHT:%d\n",ieee->current_network.ssid,ieee->current_network.channel, ieee->current_network.qos_data.supported, ieee->pHTInfo->bEnableHT, ieee->current_network.bssht.bdSupportHT); //ieee->pHTInfo->IOTAction = 0; @@ -1558,7 +1550,7 @@ static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) } } - return cpu_to_le16(a->status); + return le16_to_cpu(a->status); } @@ -1588,17 +1580,17 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, u8 *ssid=NULL; u8 ssidlen = 0; - struct ieee80211_hdr_3addr *header = - (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = + (struct rtl_80211_hdr_3addr *) skb->data; - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + if (skb->len < sizeof (struct rtl_80211_hdr_3addr )) return -1; /* corrupted */ memcpy(src,header->addr2, ETH_ALEN); skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); + tag = skb->data + sizeof (struct rtl_80211_hdr_3addr ); while (tag+1 < skbend){ if (*tag == 0) { @@ -1735,11 +1727,9 @@ static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, return 0; */ dtim = ieee->current_network.dtim_data; - //printk("DTIM\n"); if(!(dtim & IEEE80211_DTIM_VALID)) return 0; timeout = ieee->current_network.beacon_interval; //should we use ps_timeout value or beacon_interval - //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) @@ -1894,7 +1884,7 @@ EXPORT_SYMBOL(ieee80211_ps_tx_ack); static void ieee80211_process_action(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr *header = (struct ieee80211_hdr *)skb->data; + struct rtl_80211_hdr *header = (struct rtl_80211_hdr *)skb->data; u8 *act = ieee80211_get_payload(header); u8 tmp = 0; // IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); @@ -1963,7 +1953,7 @@ static void ieee80211_check_auth_response(struct ieee80211_device *ieee, } if (ieee->current_network.mode == IEEE_N_24G && - bHalfSupportNmode == true) { + bHalfSupportNmode) { netdev_dbg(ieee->dev, "enter half N mode\n"); ieee->bHalfWirelessN24GMode = true; } else @@ -1985,7 +1975,7 @@ ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, struct sk_buff *skb, struct ieee80211_rx_stats *rx_stats, u16 type, u16 stype) { - struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; + struct rtl_80211_hdr_3addr *header = (struct rtl_80211_hdr_3addr *) skb->data; u16 errcode; int aid; struct ieee80211_assoc_response_frame *assoc_resp; @@ -2153,7 +2143,7 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device * ieee80211_sta_wakeup(ieee, 0); /* update the tx status */ - ieee->stats.tx_bytes += txb->payload_size; + ieee->stats.tx_bytes += le16_to_cpu(txb->payload_size); ieee->stats.tx_packets++; tcb_desc = (cb_desc *)(txb->fragments[0]->cb + MAX_DEV_ADDR_SIZE); if (tcb_desc->bMulticast) { @@ -2243,7 +2233,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) unsigned long flags; struct sk_buff *skb; - struct ieee80211_hdr_3addr *header; + struct rtl_80211_hdr_3addr *header; spin_lock_irqsave(&ieee->lock, flags); if (! ieee->queue_stop) goto exit; @@ -2253,7 +2243,7 @@ void ieee80211_wake_queue(struct ieee80211_device *ieee) if (ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) { while (!ieee->queue_stop && (skb = dequeue_mgmt(ieee))){ - header = (struct ieee80211_hdr_3addr *) skb->data; + header = (struct rtl_80211_hdr_3addr *) skb->data; header->seq_ctl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -3126,7 +3116,7 @@ inline struct sk_buff *ieee80211_disassociate_skb( memcpy(disass->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memcpy(disass->header.addr3, beacon->bssid, ETH_ALEN); - disass->reason = asRsn; + disass->reason = cpu_to_le16(asRsn); return skb; } diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c index 714fbcace..aad288a1f 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac_wx.c @@ -32,7 +32,7 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info union iwreq_data *wrqu, char *b) { int ret; - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; down(&ieee->wx_sem); @@ -57,11 +57,11 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info } } - if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1 ){ + if (fwrq->e > 0 || fwrq->m > 14 || fwrq->m < 1) { ret = -EOPNOTSUPP; goto out; - }else { /* Set the channel */ + } else { /* Set the channel */ if (!(GET_DOT11D_INFO(ieee)->channel_map)[fwrq->m]) { ret = -EINVAL; @@ -70,11 +70,10 @@ int ieee80211_wx_set_freq(struct ieee80211_device *ieee, struct iw_request_info ieee->current_network.channel = fwrq->m; ieee->set_chan(ieee->dev, ieee->current_network.channel); - if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) - if(ieee->state == IEEE80211_LINKED){ - - ieee80211_stop_send_beacons(ieee); - ieee80211_start_send_beacons(ieee); + if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) + if (ieee->state == IEEE80211_LINKED) { + ieee80211_stop_send_beacons(ieee); + ieee80211_start_send_beacons(ieee); } } @@ -89,15 +88,15 @@ int ieee80211_wx_get_freq(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { - struct iw_freq *fwrq = & wrqu->freq; + struct iw_freq *fwrq = &wrqu->freq; if (ieee->current_network.channel == 0) return -1; - //NM 0.7.0 will not accept channel any more. + /* NM 0.7.0 will not accept channel any more. */ fwrq->m = ieee80211_wlan_frequencies[ieee->current_network.channel-1] * 100000; fwrq->e = 1; -// fwrq->m = ieee->current_network.channel; -// fwrq->e = 0; + /* fwrq->m = ieee->current_network.channel; */ + /* fwrq->e = 0; */ return 0; } @@ -141,7 +140,7 @@ int ieee80211_wx_set_wap(struct ieee80211_device *ieee, int ret = 0; unsigned long flags; - short ifup = ieee->proto_started;//dev->flags & IFF_UP; + short ifup = ieee->proto_started; /* dev->flags & IFF_UP; */ struct sockaddr *temp = (struct sockaddr *)awrq; ieee->sync_scan_hurryup = 1; @@ -179,7 +178,7 @@ out: } EXPORT_SYMBOL(ieee80211_wx_set_wap); - int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a,union iwreq_data *wrqu,char *b) +int ieee80211_wx_get_essid(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { int len, ret = 0; unsigned long flags; @@ -191,14 +190,14 @@ EXPORT_SYMBOL(ieee80211_wx_set_wap); spin_lock_irqsave(&ieee->lock, flags); if (ieee->current_network.ssid[0] == '\0' || - ieee->current_network.ssid_len == 0){ + ieee->current_network.ssid_len == 0) { ret = -1; goto out; } if (ieee->state != IEEE80211_LINKED && ieee->state != IEEE80211_LINKED_SCANNING && - ieee->ssid_set == 0){ + ieee->ssid_set == 0) { ret = -1; goto out; } @@ -223,7 +222,7 @@ int ieee80211_wx_set_rate(struct ieee80211_device *ieee, u32 target_rate = wrqu->bitrate.value; ieee->rate = target_rate/100000; - //FIXME: we might want to limit rate also in management protocols. + /* FIXME: we might want to limit rate also in management protocols. */ return 0; } EXPORT_SYMBOL(ieee80211_wx_set_rate); @@ -233,6 +232,7 @@ int ieee80211_wx_get_rate(struct ieee80211_device *ieee, union iwreq_data *wrqu, char *extra) { u32 tmp_rate; + tmp_rate = TxCountToDataRate(ieee, ieee->softmac_stats.CurrentShowTxate); wrqu->bitrate.value = tmp_rate * 500000; @@ -247,8 +247,7 @@ int ieee80211_wx_set_rts(struct ieee80211_device *ieee, { if (wrqu->rts.disabled || !wrqu->rts.fixed) ieee->rts = DEFAULT_RTS_THRESHOLD; - else - { + else { if (wrqu->rts.value < MIN_RTS_THRESHOLD || wrqu->rts.value > MAX_RTS_THRESHOLD) return -EINVAL; @@ -280,16 +279,14 @@ int ieee80211_wx_set_mode(struct ieee80211_device *ieee, struct iw_request_info if (wrqu->mode == ieee->iw_mode) goto out; - if (wrqu->mode == IW_MODE_MONITOR){ - + if (wrqu->mode == IW_MODE_MONITOR) ieee->dev->type = ARPHRD_IEEE80211; - }else{ + else ieee->dev->type = ARPHRD_ETHER; - } - if (!ieee->proto_started){ + if (!ieee->proto_started) { ieee->iw_mode = wrqu->mode; - }else{ + } else { ieee80211_stop_protocol(ieee); ieee->iw_mode = wrqu->mode; ieee80211_start_protocol(ieee); @@ -305,10 +302,10 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) { struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wx_sync_scan_wq); short chan; - HT_EXTCHNL_OFFSET chan_offset=0; - HT_CHANNEL_WIDTH bandwidth=0; + HT_EXTCHNL_OFFSET chan_offset = 0; + HT_CHANNEL_WIDTH bandwidth = 0; int b40M = 0; - static int count; + chan = ieee->current_network.channel; netif_carrier_off(ieee->dev); @@ -344,20 +341,18 @@ void ieee80211_wx_sync_scan_wq(struct work_struct *work) ieee->InitialGainHandler(ieee->dev, IG_Restore); ieee->state = IEEE80211_LINKED; ieee->link_change(ieee->dev); - // To prevent the immediately calling watch_dog after scan. - if (ieee->LinkDetectInfo.NumRecvBcnInPeriod==0||ieee->LinkDetectInfo.NumRecvDataInPeriod==0 ) - { + /* To prevent the immediately calling watch_dog after scan. */ + if (ieee->LinkDetectInfo.NumRecvBcnInPeriod == 0 || ieee->LinkDetectInfo.NumRecvDataInPeriod == 0) { ieee->LinkDetectInfo.NumRecvBcnInPeriod = 1; - ieee->LinkDetectInfo.NumRecvDataInPeriod= 1; + ieee->LinkDetectInfo.NumRecvDataInPeriod = 1; } if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); - if(ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) + if (ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) ieee80211_start_send_beacons(ieee); netif_carrier_on(ieee->dev); - count = 0; up(&ieee->wx_sem); } @@ -391,7 +386,7 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, union iwreq_data *wrqu, char *extra) { - int ret=0,len; + int ret = 0, len; short proto_started; unsigned long flags; @@ -401,16 +396,16 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, proto_started = ieee->proto_started; if (wrqu->essid.length > IW_ESSID_MAX_SIZE) { - ret= -E2BIG; + ret = -E2BIG; goto out; } if (ieee->iw_mode == IW_MODE_MONITOR) { - ret= -1; + ret = -1; goto out; } - if(proto_started) + if (proto_started) ieee80211_stop_protocol(ieee); @@ -420,13 +415,12 @@ int ieee80211_wx_set_essid(struct ieee80211_device *ieee, spin_lock_irqsave(&ieee->lock, flags); if (wrqu->essid.flags && wrqu->essid.length) { - //first flush current network.ssid + /* first flush current network.ssid */ len = ((wrqu->essid.length-1) < IW_ESSID_MAX_SIZE) ? (wrqu->essid.length-1) : IW_ESSID_MAX_SIZE; strncpy(ieee->current_network.ssid, extra, len+1); ieee->current_network.ssid_len = len+1; ieee->ssid_set = 1; - } - else{ + } else { ieee->ssid_set = 0; ieee->current_network.ssid[0] = '\0'; ieee->current_network.ssid_len = 0; @@ -441,7 +435,7 @@ out: } EXPORT_SYMBOL(ieee80211_wx_set_essid); - int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, +int ieee80211_wx_get_mode(struct ieee80211_device *ieee, struct iw_request_info *a, union iwreq_data *wrqu, char *b) { @@ -450,7 +444,7 @@ EXPORT_SYMBOL(ieee80211_wx_set_essid); } EXPORT_SYMBOL(ieee80211_wx_get_mode); - int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, +int ieee80211_wx_set_rawtx(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { @@ -461,7 +455,7 @@ EXPORT_SYMBOL(ieee80211_wx_get_mode); down(&ieee->wx_sem); - if(enable) + if (enable) ieee->raw_tx = 1; else ieee->raw_tx = 0; @@ -469,8 +463,7 @@ EXPORT_SYMBOL(ieee80211_wx_get_mode); printk(KERN_INFO"raw TX is %s\n", ieee->raw_tx ? "enabled" : "disabled"); - if (ieee->iw_mode == IW_MODE_MONITOR) - { + if (ieee->iw_mode == IW_MODE_MONITOR) { if (prev == 0 && ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -478,7 +471,7 @@ EXPORT_SYMBOL(ieee80211_wx_get_mode); netif_carrier_on(ieee->dev); } - if(prev && ieee->raw_tx == 1) + if (prev && ieee->raw_tx == 1) netif_carrier_off(ieee->dev); } @@ -520,6 +513,7 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee, union iwreq_data *wrqu, char *extra) { int ret = 0; + down(&ieee->wx_sem); if (wrqu->power.disabled) { @@ -527,15 +521,15 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee, goto exit; } if (wrqu->power.flags & IW_POWER_TIMEOUT) { - //ieee->ps_period = wrqu->power.value / 1000; + /* ieee->ps_period = wrqu->power.value / 1000; */ ieee->ps_timeout = wrqu->power.value / 1000; } if (wrqu->power.flags & IW_POWER_PERIOD) { - //ieee->ps_timeout = wrqu->power.value / 1000; + /* ieee->ps_timeout = wrqu->power.value / 1000; */ ieee->ps_period = wrqu->power.value / 1000; - //wrq->value / 1024; + /* wrq->value / 1024; */ } switch (wrqu->power.flags & IW_POWER_MODE) { @@ -550,7 +544,7 @@ int ieee80211_wx_set_power(struct ieee80211_device *ieee, break; case IW_POWER_ON: - // ieee->ps = IEEE80211_PS_DISABLED; + /* ieee->ps = IEEE80211_PS_DISABLED; */ break; default: @@ -583,14 +577,14 @@ int ieee80211_wx_get_power(struct ieee80211_device *ieee, wrqu->power.flags = IW_POWER_TIMEOUT; wrqu->power.value = ieee->ps_timeout * 1000; } else { -// ret = -EOPNOTSUPP; -// goto exit; + /* ret = -EOPNOTSUPP; */ + /* goto exit; */ wrqu->power.flags = IW_POWER_PERIOD; wrqu->power.value = ieee->ps_period * 1000; -//ieee->current_network.dtim_period * ieee->current_network.beacon_interval * 1024; + /* ieee->current_network.dtim_period * ieee->current_network.beacon_interval * 1024; */ } - if ((ieee->ps & (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) == (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) + if ((ieee->ps & (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) == (IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST)) wrqu->power.flags |= IW_POWER_ALL_R; else if (ieee->ps & IEEE80211_PS_MBCAST) wrqu->power.flags |= IW_POWER_MULTICAST_R; diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c index 9f68c652f..1ab0aead2 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_tx.c @@ -48,7 +48,7 @@ #include #include #include -#include +#include #include #include "ieee80211.h" @@ -194,9 +194,9 @@ int ieee80211_encrypt_fragment( if (ieee->tkip_countermeasures && crypt && crypt->ops && strcmp(crypt->ops->name, "TKIP") == 0) { if (net_ratelimit()) { - struct ieee80211_hdr_3addrqos *header; + struct rtl_80211_hdr_3addrqos *header; - header = (struct ieee80211_hdr_3addrqos *)frag->data; + header = (struct rtl_80211_hdr_3addrqos *)frag->data; printk(KERN_DEBUG "%s: TKIP countermeasures: dropped " "TX packet to %pM\n", ieee->dev->name, header->addr1); @@ -308,7 +308,7 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, { PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; PTX_TS_RECORD pTxTs = NULL; - struct ieee80211_hdr_1addr *hdr = (struct ieee80211_hdr_1addr *)skb->data; + struct rtl_80211_hdr_1addr *hdr = (struct rtl_80211_hdr_1addr *)skb->data; if (!pHTInfo->bCurrentHTSupport||!pHTInfo->bEnableHT) return; @@ -336,12 +336,12 @@ static void ieee80211_tx_query_agg_cap(struct ieee80211_device *ieee, printk("===>can't get TS\n"); return; } - if (pTxTs->TxAdmittedBARecord.bValid == false) + if (!pTxTs->TxAdmittedBARecord.bValid) { TsStartAddBaProcess(ieee, pTxTs); goto FORCED_AGG_SETTING; } - else if (pTxTs->bUsingBa == false) + else if (!pTxTs->bUsingBa) { if (SN_LESS(pTxTs->TxAdmittedBARecord.BaStartSeqCtrl.field.SeqNum, (pTxTs->TxCurSeq+1)%4096)) pTxTs->bUsingBa = true; @@ -598,14 +598,14 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { struct ieee80211_device *ieee = netdev_priv(dev); struct ieee80211_txb *txb = NULL; - struct ieee80211_hdr_3addrqos *frag_hdr; + struct rtl_80211_hdr_3addrqos *frag_hdr; int i, bytes_per_frag, nr_frags, bytes_last_frag, frag_size; unsigned long flags; struct net_device_stats *stats = &ieee->stats; int ether_type = 0, encrypt; int bytes, fc, qos_ctl = 0, hdr_len; struct sk_buff *skb_frag; - struct ieee80211_hdr_3addrqos header = { /* Ensure zero initialized */ + struct rtl_80211_hdr_3addrqos header = { /* Ensure zero initialized */ .duration_id = 0, .seq_ctl = 0, .qos_ctl = 0 @@ -787,7 +787,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) { tcb_desc->bHwSec = 0; } - frag_hdr = (struct ieee80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); + frag_hdr = (struct rtl_80211_hdr_3addrqos *)skb_put(skb_frag, hdr_len); memcpy(frag_hdr, &header, hdr_len); /* If this is not the last fragment, then add the MOREFRAGS @@ -845,7 +845,7 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) ieee->seq_ctrl[0]++; } }else{ - if (unlikely(skb->len < sizeof(struct ieee80211_hdr_3addr))) { + if (unlikely(skb->len < sizeof(struct rtl_80211_hdr_3addr))) { printk(KERN_WARNING "%s: skb too small (%d).\n", ieee->dev->name, skb->len); goto success; diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c index ae1b3cf28..208be5fc5 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c @@ -522,7 +522,6 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, struct ieee80211_security sec = { .flags = 0, }; - //printk("======>encoding flag:%x,ext flag:%x, ext alg:%d\n", encoding->flags,ext->ext_flags, ext->alg); idx = encoding->flags & IW_ENCODE_INDEX; if (idx) { if (idx < 1 || idx > WEP_KEYS) @@ -538,7 +537,6 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, group_key = 1; } else { /* some Cisco APs use idx>0 for unicast in dynamic WEP */ - //printk("not group key, flags:%x, ext->alg:%d\n", ext->ext_flags, ext->alg); if (idx != 0 && ext->alg != IW_ENCODE_ALG_WEP) return -EINVAL; if (ieee->iw_mode == IW_MODE_INFRA) @@ -567,7 +565,6 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, sec.level = SEC_LEVEL_0; sec.flags |= SEC_LEVEL; } - //printk("disabled: flag:%x\n", encoding->flags); goto done; } @@ -638,7 +635,6 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, goto done; } //skip_host_crypt: - //printk("skip_host_crypt:ext_flags:%x\n", ext->ext_flags); if (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY) { ieee->tx_keyidx = idx; sec.active_key = idx; @@ -760,7 +756,6 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, switch (data->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: /*need to support wpa2 here*/ - //printk("wpa version:%x\n", data->value); break; case IW_AUTH_CIPHER_PAIRWISE: case IW_AUTH_CIPHER_GROUP: @@ -791,16 +786,13 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, else if(data->value & IW_AUTH_ALG_LEAP){ ieee->open_wep = 1; ieee->auth_mode = 2; - //printk("hahahaa:LEAP\n"); } else return -EINVAL; - //printk("open_wep:%d\n", ieee->open_wep); break; case IW_AUTH_WPA_ENABLED: ieee->wpa_enabled = (data->value)?1:0; - //printk("enalbe wpa:%d\n", ieee->wpa_enabled); break; case IW_AUTH_RX_UNENCRYPTED_EAPOL: diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c index 618d2cbc0..3bde74460 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_BAProc.c @@ -110,7 +110,7 @@ void ResetBaEntry(PBA_RECORD pBA) static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, PBA_RECORD pBA, u16 StatusCode, u8 type) { struct sk_buff *skb = NULL; - struct ieee80211_hdr_3addr *BAReq = NULL; + struct rtl_80211_hdr_3addr *BAReq = NULL; u8 *tag = NULL; u16 len = ieee->tx_headroom + 9; //category(1) + action field(1) + Dialog Token(1) + BA Parameter Set(2) + BA Timeout Value(2) + BA Start SeqCtrl(2)(or StatusCode(2)) @@ -120,17 +120,17 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P IEEE80211_DEBUG(IEEE80211_DL_ERR, "pBA is NULL\n"); return NULL; } - skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME + skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME if (skb == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } - memset(skb->data, 0, sizeof( struct ieee80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. + memset(skb->data, 0, sizeof( struct rtl_80211_hdr_3addr)); //I wonder whether it's necessary. Apparently kernel will not do it when alloc a skb. skb_reserve(skb, ieee->tx_headroom); - BAReq = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); + BAReq = ( struct rtl_80211_hdr_3addr *) skb_put(skb,sizeof( struct rtl_80211_hdr_3addr)); memcpy(BAReq->addr1, Dst, ETH_ALEN); memcpy(BAReq->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -139,7 +139,7 @@ static struct sk_buff *ieee80211_ADDBA(struct ieee80211_device *ieee, u8 *Dst, P BAReq->frame_ctl = cpu_to_le16(IEEE80211_STYPE_MANAGE_ACT); //action frame - //tag += sizeof( struct ieee80211_hdr_3addr); //move to action field + //tag += sizeof( struct rtl_80211_hdr_3addr); //move to action field tag = (u8 *)skb_put(skb, 9); *tag ++= ACT_CAT_BA; *tag ++= type; @@ -195,7 +195,7 @@ static struct sk_buff *ieee80211_DELBA( { DELBA_PARAM_SET DelbaParamSet; struct sk_buff *skb = NULL; - struct ieee80211_hdr_3addr *Delba = NULL; + struct rtl_80211_hdr_3addr *Delba = NULL; u8 *tag = NULL; //len = head len + DELBA Parameter Set(2) + Reason Code(2) u16 len = 6 + ieee->tx_headroom; @@ -208,16 +208,16 @@ static struct sk_buff *ieee80211_DELBA( DelbaParamSet.field.Initiator = (TxRxSelect==TX_DIR)?1:0; DelbaParamSet.field.TID = pBA->BaParamSet.field.TID; - skb = dev_alloc_skb(len + sizeof( struct ieee80211_hdr_3addr)); //need to add something others? FIXME + skb = dev_alloc_skb(len + sizeof( struct rtl_80211_hdr_3addr)); //need to add something others? FIXME if (skb == NULL) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "can't alloc skb for ADDBA_REQ\n"); return NULL; } -// memset(skb->data, 0, len+sizeof( struct ieee80211_hdr_3addr)); +// memset(skb->data, 0, len+sizeof( struct rtl_80211_hdr_3addr)); skb_reserve(skb, ieee->tx_headroom); - Delba = ( struct ieee80211_hdr_3addr *) skb_put(skb,sizeof( struct ieee80211_hdr_3addr)); + Delba = ( struct rtl_80211_hdr_3addr *) skb_put(skb,sizeof( struct rtl_80211_hdr_3addr)); memcpy(Delba->addr1, dst, ETH_ALEN); memcpy(Delba->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -333,7 +333,7 @@ static void ieee80211_send_DELBA(struct ieee80211_device *ieee, u8 *dst, ********************************************************************************************************************/ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr_3addr *req = NULL; + struct rtl_80211_hdr_3addr *req = NULL; u16 rc = 0; u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; PBA_RECORD pBA = NULL; @@ -342,20 +342,20 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) PSEQUENCE_CONTROL pBaStartSeqCtrl = NULL; PRX_TS_RECORD pTS = NULL; - if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) { + if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BAREQ(%d / %zu)\n", skb->len, - (sizeof(struct ieee80211_hdr_3addr) + 9)); + (sizeof(struct rtl_80211_hdr_3addr) + 9)); return -1; } IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - req = (struct ieee80211_hdr_3addr *) skb->data; + req = (struct rtl_80211_hdr_3addr *) skb->data; tag = (u8 *)req; dst = (u8 *)(&req->addr2[0]); - tag += sizeof(struct ieee80211_hdr_3addr); + tag += sizeof(struct rtl_80211_hdr_3addr); pDialogToken = tag + 2; //category+action pBaParamSet = (PBA_PARAM_SET)(tag + 3); //+DialogToken pBaTimeoutVal = (u16 *)(tag + 5); @@ -364,8 +364,8 @@ int ieee80211_rx_ADDBAReq(struct ieee80211_device *ieee, struct sk_buff *skb) printk("====================>rx ADDBAREQ from :%pM\n", dst); //some other capability is not ready now. if ((ieee->current_network.qos_data.active == 0) || - (ieee->pHTInfo->bCurrentHTSupport == false)) //|| - // (ieee->pStaQos->bEnableRxImmBA == false) ) + (!ieee->pHTInfo->bCurrentHTSupport)) //|| + // (!ieee->pStaQos->bEnableRxImmBA) ) { rc = ADDBA_STATUS_REFUSED; IEEE80211_DEBUG(IEEE80211_DL_ERR, "Failed to reply on ADDBA_REQ as some capability is not ready(%d, %d)\n", ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); @@ -435,7 +435,7 @@ OnADDBAReq_Fail: ********************************************************************************************************************/ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr_3addr *rsp = NULL; + struct rtl_80211_hdr_3addr *rsp = NULL; PBA_RECORD pPendingBA, pAdmittedBA; PTX_TS_RECORD pTS = NULL; u8 *dst = NULL, *pDialogToken = NULL, *tag = NULL; @@ -443,17 +443,17 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) PBA_PARAM_SET pBaParamSet = NULL; u16 ReasonCode; - if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 9) { + if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 9) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in BARSP(%d / %zu)\n", skb->len, - (sizeof(struct ieee80211_hdr_3addr) + 9)); + (sizeof(struct rtl_80211_hdr_3addr) + 9)); return -1; } - rsp = (struct ieee80211_hdr_3addr *)skb->data; + rsp = (struct rtl_80211_hdr_3addr *)skb->data; tag = (u8 *)rsp; dst = (u8 *)(&rsp->addr2[0]); - tag += sizeof(struct ieee80211_hdr_3addr); + tag += sizeof(struct rtl_80211_hdr_3addr); pDialogToken = tag + 2; pStatusCode = (u16 *)(tag + 3); pBaParamSet = (PBA_PARAM_SET)(tag + 5); @@ -462,8 +462,8 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) // Check the capability // Since we can always receive A-MPDU, we just check if it is under HT mode. if (ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false || - ieee->pHTInfo->bCurrentAMPDUEnable == false) { + !ieee->pHTInfo->bCurrentHTSupport || + !ieee->pHTInfo->bCurrentAMPDUEnable) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "reject to ADDBA_RSP as some capability is not ready(%d, %d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport, ieee->pHTInfo->bCurrentAMPDUEnable); ReasonCode = DELBA_REASON_UNKNOWN_BA; goto OnADDBARsp_Reject; @@ -502,7 +502,7 @@ int ieee80211_rx_ADDBARsp(struct ieee80211_device *ieee, struct sk_buff *skb) IEEE80211_DEBUG(IEEE80211_DL_BA, "OnADDBARsp(): Recv ADDBA Rsp. Drop because already admit it! \n"); return -1; } - else if((pPendingBA->bValid == false) ||(*pDialogToken != pPendingBA->DialogToken)) + else if((!pPendingBA->bValid) ||(*pDialogToken != pPendingBA->DialogToken)) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "OnADDBARsp(): Recv ADDBA Rsp. BA invalid, DELBA! \n"); ReasonCode = DELBA_REASON_UNKNOWN_BA; @@ -569,32 +569,29 @@ OnADDBARsp_Reject: ********************************************************************************************************************/ int ieee80211_rx_DELBA(struct ieee80211_device *ieee, struct sk_buff *skb) { - struct ieee80211_hdr_3addr *delba = NULL; + struct rtl_80211_hdr_3addr *delba = NULL; PDELBA_PARAM_SET pDelBaParamSet = NULL; - u16 *pReasonCode = NULL; u8 *dst = NULL; - if (skb->len < sizeof(struct ieee80211_hdr_3addr) + 6) { + if (skb->len < sizeof(struct rtl_80211_hdr_3addr) + 6) { IEEE80211_DEBUG(IEEE80211_DL_ERR, " Invalid skb len in DELBA(%d / %zu)\n", skb->len, - (sizeof(struct ieee80211_hdr_3addr) + 6)); + (sizeof(struct rtl_80211_hdr_3addr) + 6)); return -1; } if (ieee->current_network.qos_data.active == 0 || - ieee->pHTInfo->bCurrentHTSupport == false ) + !ieee->pHTInfo->bCurrentHTSupport) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "received DELBA while QOS or HT is not supported(%d, %d)\n",ieee->current_network.qos_data.active, ieee->pHTInfo->bCurrentHTSupport); return -1; } IEEE80211_DEBUG_DATA(IEEE80211_DL_DATA|IEEE80211_DL_BA, skb->data, skb->len); - delba = (struct ieee80211_hdr_3addr *)skb->data; + delba = (struct rtl_80211_hdr_3addr *)skb->data; dst = (u8 *)(&delba->addr2[0]); - delba += sizeof(struct ieee80211_hdr_3addr); - pDelBaParamSet = (PDELBA_PARAM_SET)(delba+2); - pReasonCode = (u16 *)(delba+4); + pDelBaParamSet = (PDELBA_PARAM_SET)&delba->payload[2]; if(pDelBaParamSet->field.Initiator == 1) { diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c index c2588f806..c27397b14 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_HTProc.c @@ -224,9 +224,9 @@ static bool IsHTHalfNmode40Bandwidth(struct ieee80211_device *ieee) bool retValue = false; PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode + if(!pHTInfo->bCurrentHTSupport) // wireless is n mode retValue = false; - else if(pHTInfo->bRegBW40MHz == false) // station supports 40 bw + else if(!pHTInfo->bRegBW40MHz) // station supports 40 bw retValue = false; else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode retValue = false; @@ -243,7 +243,7 @@ static bool IsHTHalfNmodeSGI(struct ieee80211_device *ieee, bool is40MHz) bool retValue = false; PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; - if(pHTInfo->bCurrentHTSupport == false ) // wireless is n mode + if(!pHTInfo->bCurrentHTSupport) // wireless is n mode retValue = false; else if(!ieee->GetHalfNmodeSupportByAPsHandler(ieee->dev)) // station in half n mode retValue = false; @@ -675,7 +675,7 @@ void HTConstructInfoElement(struct ieee80211_device *ieee, u8 *posHTInfo, u8 *le if ( (ieee->iw_mode == IW_MODE_ADHOC) || (ieee->iw_mode == IW_MODE_MASTER)) //ap mode is not currently supported { pHTInfoEle->ControlChl = ieee->current_network.channel; - pHTInfoEle->ExtChlOffset = ((pHT->bRegBW40MHz == false)?HT_EXTCHNL_OFFSET_NO_EXT: + pHTInfoEle->ExtChlOffset = ((!pHT->bRegBW40MHz)?HT_EXTCHNL_OFFSET_NO_EXT: (ieee->current_network.channel<=6)? HT_EXTCHNL_OFFSET_UPPER:HT_EXTCHNL_OFFSET_LOWER); pHTInfoEle->RecommemdedTxWidth = pHT->bRegBW40MHz; @@ -945,7 +945,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) static u8 EWC11NHTCap[] = {0x00, 0x90, 0x4c, 0x33}; // For 11n EWC definition, 2007.07.17, by Emily static u8 EWC11NHTInfo[] = {0x00, 0x90, 0x4c, 0x34}; // For 11n EWC definition, 2007.07.17, by Emily - if (pHTInfo->bCurrentHTSupport == false) { + if (!pHTInfo->bCurrentHTSupport) { IEEE80211_DEBUG(IEEE80211_DL_ERR, "<=== HTOnAssocRsp(): HT_DISABLE\n"); return; } @@ -956,7 +956,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // HTDebugHTCapability(pHTInfo->PeerHTCapBuf,"HTOnAssocRsp_wq"); // HTDebugHTInfo(pHTInfo->PeerHTInfoBuf,"HTOnAssocRsp_wq"); // - if(!memcmp(pHTInfo->PeerHTCapBuf,EWC11NHTCap, sizeof(EWC11NHTCap))) + if (!memcmp(pHTInfo->PeerHTCapBuf, EWC11NHTCap, sizeof(EWC11NHTCap))) pPeerHTCap = (PHT_CAPABILITY_ELE)(&pHTInfo->PeerHTCapBuf[4]); else pPeerHTCap = (PHT_CAPABILITY_ELE)(pHTInfo->PeerHTCapBuf); @@ -976,7 +976,7 @@ void HTOnAssocRsp(struct ieee80211_device *ieee) // HTSetConnectBwMode(ieee, (HT_CHANNEL_WIDTH)(pPeerHTCap->ChlWidth), (HT_EXTCHNL_OFFSET)(pPeerHTInfo->ExtChlOffset)); -// if(pHTInfo->bCurBW40MHz == true) +// if (pHTInfo->bCurBW40MHz) pHTInfo->bCurTxBW40MHz = ((pPeerHTInfo->RecommemdedTxWidth == 1)?true:false); // @@ -1341,7 +1341,7 @@ void HTSetConnectBwMode(struct ieee80211_device *ieee, HT_CHANNEL_WIDTH Bandwidt PRT_HIGH_THROUGHPUT pHTInfo = ieee->pHTInfo; // u32 flags = 0; - if(pHTInfo->bRegBW40MHz == false) + if(!pHTInfo->bRegBW40MHz) return; diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h index 9fbce912a..49c23c720 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h +++ b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_Qos.h @@ -1,39 +1,6 @@ #ifndef __INC_QOS_TYPE_H #define __INC_QOS_TYPE_H -#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 MAX_WMMELE_LENGTH 64 // @@ -375,17 +342,17 @@ typedef struct _ACM{ typedef u8 AC_UAPSD, *PAC_UAPSD; -#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT0) -#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT0) +#define GET_VO_UAPSD(_apsd) ((_apsd) & BIT(0)) +#define SET_VO_UAPSD(_apsd) ((_apsd) |= BIT(0)) -#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT1) -#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT1) +#define GET_VI_UAPSD(_apsd) ((_apsd) & BIT(1)) +#define SET_VI_UAPSD(_apsd) ((_apsd) |= BIT(1)) -#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT2) -#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT2) +#define GET_BK_UAPSD(_apsd) ((_apsd) & BIT(2)) +#define SET_BK_UAPSD(_apsd) ((_apsd) |= BIT(2)) -#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT3) -#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT3) +#define GET_BE_UAPSD(_apsd) ((_apsd) & BIT(3)) +#define SET_BE_UAPSD(_apsd) ((_apsd) |= BIT(3)) //typedef struct _TCLASS{ diff --git a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c index ea92fdebe..f33c74342 100644 --- a/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c +++ b/kernel/drivers/staging/rtl8192u/ieee80211/rtl819x_TSProc.c @@ -112,7 +112,7 @@ static void TsAddBaProcess(unsigned long data) static void ResetTsCommonInfo(PTS_COMMON_INFO pTsCommonInfo) { - memset(pTsCommonInfo->Addr, 0, 6); + eth_zero_addr(pTsCommonInfo->Addr); memset(&pTsCommonInfo->TSpec, 0, sizeof(TSPEC_BODY)); memset(&pTsCommonInfo->TClass, 0, sizeof(QOS_TCLAS)*TCLAS_NUM); pTsCommonInfo->TClasProc = 0; @@ -584,7 +584,7 @@ void RemoveAllTS(struct ieee80211_device *ieee) void TsStartAddBaProcess(struct ieee80211_device *ieee, PTX_TS_RECORD pTxTS) { - if(pTxTS->bAddBaReqInProgress == false) + if(!pTxTS->bAddBaReqInProgress) { pTxTS->bAddBaReqInProgress = true; if(pTxTS->bAddBaReqDelayed) diff --git a/kernel/drivers/staging/rtl8192u/r8190_rtl8256.h b/kernel/drivers/staging/rtl8192u/r8190_rtl8256.h index 6e5662f79..1ba4f83b5 100644 --- a/kernel/drivers/staging/rtl8192u/r8190_rtl8256.h +++ b/kernel/drivers/staging/rtl8192u/r8190_rtl8256.h @@ -14,11 +14,10 @@ #define RTL8225H #define RTL819X_TOTAL_RF_PATH 2 /* for 8192U */ -extern void PHY_SetRF8256Bandwidth(struct net_device *dev, - HT_CHANNEL_WIDTH Bandwidth); -extern void PHY_RF8256_Config(struct net_device *dev); -extern void phy_RF8256_Config_ParaFile(struct net_device *dev); -extern void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel); -extern void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel); +void PHY_SetRF8256Bandwidth(struct net_device *dev, HT_CHANNEL_WIDTH Bandwidth); +void PHY_RF8256_Config(struct net_device *dev); +void phy_RF8256_Config_ParaFile(struct net_device *dev); +void PHY_SetRF8256CCKTxPower(struct net_device *dev, u8 powerlevel); +void PHY_SetRF8256OFDMTxPower(struct net_device *dev, u8 powerlevel); #endif diff --git a/kernel/drivers/staging/rtl8192u/r8192U.h b/kernel/drivers/staging/rtl8192u/r8192U.h index 6c2e438c9..ee1c72267 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U.h +++ b/kernel/drivers/staging/rtl8192u/r8192U.h @@ -43,39 +43,6 @@ #define MAX_KEY_LEN 61 #define KEY_BUF_SIZE 5 -#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 Rx_Smooth_Factor 20 #define DMESG(x, a...) #define DMESGW(x, a...) @@ -87,44 +54,44 @@ extern u32 rt_global_debug_component; pr_debug("RTL8192U: " x "\n", ##args); \ } while (0) -#define COMP_TRACE BIT0 /* Function call tracing. */ -#define COMP_DBG BIT1 -#define COMP_INIT BIT2 /* Driver initialization/halt/reset. */ +#define COMP_TRACE BIT(0) /* Function call tracing. */ +#define COMP_DBG BIT(1) +#define COMP_INIT BIT(2) /* Driver initialization/halt/reset. */ -#define COMP_RECV BIT3 /* Receive data path. */ -#define COMP_SEND BIT4 /* Send data path. */ -#define COMP_IO BIT5 +#define COMP_RECV BIT(3) /* Receive data path. */ +#define COMP_SEND BIT(4) /* Send data path. */ +#define COMP_IO BIT(5) /* 802.11 Power Save mode or System/Device Power state. */ -#define COMP_POWER BIT6 +#define COMP_POWER BIT(6) /* 802.11 link related: join/start BSS, leave BSS. */ -#define COMP_EPROM BIT7 -#define COMP_SWBW BIT8 /* Bandwidth switch. */ -#define COMP_POWER_TRACKING BIT9 /* 8190 TX Power Tracking */ -#define COMP_TURBO BIT10 /* Turbo Mode */ -#define COMP_QOS BIT11 -#define COMP_RATE BIT12 /* Rate Adaptive mechanism */ -#define COMP_RM BIT13 /* Radio Measurement */ -#define COMP_DIG BIT14 -#define COMP_PHY BIT15 -#define COMP_CH BIT16 /* Channel setting debug */ -#define COMP_TXAGC BIT17 /* Tx power */ -#define COMP_HIPWR BIT18 /* High Power Mechanism */ -#define COMP_HALDM BIT19 /* HW Dynamic Mechanism */ -#define COMP_SEC BIT20 /* Event handling */ -#define COMP_LED BIT21 -#define COMP_RF BIT22 -#define COMP_RXDESC BIT23 /* Rx desc information for SD3 debug */ +#define COMP_EPROM BIT(7) +#define COMP_SWBW BIT(8) /* Bandwidth switch. */ +#define COMP_POWER_TRACKING BIT(9) /* 8190 TX Power Tracking */ +#define COMP_TURBO BIT(10) /* Turbo Mode */ +#define COMP_QOS BIT(11) +#define COMP_RATE BIT(12) /* Rate Adaptive mechanism */ +#define COMP_RM BIT(13) /* Radio Measurement */ +#define COMP_DIG BIT(14) +#define COMP_PHY BIT(15) +#define COMP_CH BIT(16) /* Channel setting debug */ +#define COMP_TXAGC BIT(17) /* Tx power */ +#define COMP_HIPWR BIT(18) /* High Power Mechanism */ +#define COMP_HALDM BIT(19) /* HW Dynamic Mechanism */ +#define COMP_SEC BIT(20) /* Event handling */ +#define COMP_LED BIT(21) +#define COMP_RF BIT(22) +#define COMP_RXDESC BIT(23) /* Rx desc information for SD3 debug */ /* 11n or 8190 specific code */ -#define COMP_FIRMWARE BIT24 /* Firmware downloading */ -#define COMP_HT BIT25 /* 802.11n HT related information */ -#define COMP_AMSDU BIT26 /* A-MSDU Debugging */ -#define COMP_SCAN BIT27 -#define COMP_DOWN BIT29 /* rm driver module */ -#define COMP_RESET BIT30 /* Silent reset */ -#define COMP_ERR BIT31 /* Error out, always on */ +#define COMP_FIRMWARE BIT(24) /* Firmware downloading */ +#define COMP_HT BIT(25) /* 802.11n HT related information */ +#define COMP_AMSDU BIT(26) /* A-MSDU Debugging */ +#define COMP_SCAN BIT(27) +#define COMP_DOWN BIT(29) /* rm driver module */ +#define COMP_RESET BIT(30) /* Silent reset */ +#define COMP_ERR BIT(31) /* Error out, always on */ #define RTL819x_DEBUG #ifdef RTL819x_DEBUG @@ -335,11 +302,11 @@ typedef struct _tx_fwinfo_819x_usb { u32 PacketID:13; } tx_fwinfo_819x_usb, *ptx_fwinfo_819x_usb; -typedef struct rtl8192_rx_info { +struct rtl8192_rx_info { struct urb *urb; struct net_device *dev; u8 out_pipe; -} rtl8192_rx_info ; +}; typedef struct rx_desc_819x_usb { /* DOWRD 0 */ @@ -1187,7 +1154,7 @@ void write_phy_cck(struct net_device *dev, u8 adr, u32 data); void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data); void rtl8185_tx_antenna(struct net_device *dev, u8 ant); void rtl8192_set_rxconf(struct net_device *dev); -extern void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate); +void rtl819xusb_beacon_tx(struct net_device *dev, u16 tx_rate); void EnableHWSecurityConfig8192(struct net_device *dev); void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u8 *MacAddr, u8 DefaultKey, u32 *KeyContent); diff --git a/kernel/drivers/staging/rtl8192u/r8192U_core.c b/kernel/drivers/staging/rtl8192u/r8192U_core.c index a4795afee..e06864f64 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U_core.c +++ b/kernel/drivers/staging/rtl8192u/r8192U_core.c @@ -37,17 +37,17 @@ unsigned int __fixunsdfsi(double d) double __adddf3(double a, double b) { - return a+b; + return a + b; } double __addsf3(float a, float b) { - return a+b; + return a + b; } double __subdf3(double a, double b) { - return a-b; + return a - b; } double __extendsfdf2(float a) @@ -58,13 +58,13 @@ double __extendsfdf2(float a) #define CONFIG_RTL8192_IO_MAP -#include +#include #include "r8192U_hw.h" #include "r8192U.h" #include "r8190_rtl8256.h" /* RTL8225 Radio frontend */ #include "r8180_93cx6.h" /* Card EEPROM */ #include "r8192U_wx.h" -#include "r819xU_phy.h" //added by WB 4.30.2008 +#include "r819xU_phy.h" #include "r819xU_phyreg.h" #include "r819xU_cmdpkt.h" #include "r8192U_dm.h" @@ -72,13 +72,13 @@ double __extendsfdf2(float a) #include #include #include -// FIXME: check if 2.6.7 is ok +/* FIXME: check if 2.6.7 is ok */ #include "dot11d.h" -//set here to open your trace code. //WB +/* set here to open your trace code. */ u32 rt_global_debug_component = COMP_DOWN | COMP_SEC | - COMP_ERR; //always open err flags on + COMP_ERR; /* always open err flags on */ #define TOTAL_CAM_ENTRY 32 #define CAM_CONTENT_COUNT 8 @@ -109,14 +109,14 @@ MODULE_DEVICE_TABLE(usb, rtl8192_usb_id_tbl); MODULE_DESCRIPTION("Linux driver for Realtek RTL8192 USB WiFi cards"); static char *ifname = "wlan%d"; -static int hwwep = 1; //default use hw. set 0 to use software security +static int hwwep = 1; /* default use hw. set 0 to use software security */ static int channels = 0x3fff; -module_param(ifname, charp, S_IRUGO|S_IWUSR); -module_param(hwwep, int, S_IRUGO|S_IWUSR); -module_param(channels, int, S_IRUGO|S_IWUSR); +module_param(ifname, charp, S_IRUGO | S_IWUSR); +module_param(hwwep, int, S_IRUGO | S_IWUSR); +module_param(channels, int, S_IRUGO | S_IWUSR); MODULE_PARM_DESC(ifname, " Net interface name, wlan%d=default"); MODULE_PARM_DESC(hwwep, " Try to use hardware security support. "); @@ -143,23 +143,35 @@ struct CHANNEL_LIST { }; static struct CHANNEL_LIST ChannelPlan[] = { - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24}, //FCC - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, //IC - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, //ETSI - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, //Spain. Change to ETSI. - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, //France. Change to ETSI. - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, //MKK //MKK - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22},//MKK1 - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, //Israel. - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, // For 11a , TELEC - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, //MIC - {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14} //For Global Domain. 1-11:active scan, 12-14 passive scan. //+YJ, 080626 + /* FCC */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64, 149, 153, 157, 161, 165}, 24}, + /* IC */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}, 11}, + /* ETSI */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, 44, 48, 52, 56, 60, 64}, 21}, + /* Spain. Change to ETSI. */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* France. Change to ETSI. */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* MKK */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, + /* MKK1 */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, + /* Israel. */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13}, + /* For 11a , TELEC */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, + /* MIC */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 36, 40, 44, 48, 52, 56, 60, 64}, 22}, + /* For Global Domain. 1-11:active scan, 12-14 passive scan. */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14} }; static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv) { int i, max_chan = -1, min_chan = -1; struct ieee80211_device *ieee = priv->ieee80211; + switch (channel_plan) { case COUNTRY_CODE_FCC: case COUNTRY_CODE_IC: @@ -173,17 +185,20 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv) case COUNTRY_CODE_MIC: Dot11d_Init(ieee); ieee->bGlobalDomain = false; - //actually 8225 & 8256 rf chips only support B,G,24N mode + /* actually 8225 & 8256 rf chips only support B,G,24N mode */ if ((priv->rf_chip == RF_8225) || (priv->rf_chip == RF_8256)) { min_chan = 1; max_chan = 14; } else { - RT_TRACE(COMP_ERR, "unknown rf chip, can't set channel map in function:%s()\n", __func__); + RT_TRACE(COMP_ERR, + "unknown rf chip, can't set channel map in function:%s()\n", + __func__); } if (ChannelPlan[channel_plan].Len != 0) { - // Clear old channel map - memset(GET_DOT11D_INFO(ieee)->channel_map, 0, sizeof(GET_DOT11D_INFO(ieee)->channel_map)); - // Set new channel map + /* Clear old channel map */ + memset(GET_DOT11D_INFO(ieee)->channel_map, 0, + sizeof(GET_DOT11D_INFO(ieee)->channel_map)); + /* Set new channel map */ for (i = 0; i < ChannelPlan[channel_plan].Len; i++) { if (ChannelPlan[channel_plan].Channel[i] < min_chan || ChannelPlan[channel_plan].Channel[i] > max_chan) break; @@ -193,7 +208,10 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv) break; case COUNTRY_CODE_GLOBAL_DOMAIN: - GET_DOT11D_INFO(ieee)->bEnabled = 0;//this flag enabled to follow 11d country IE setting, otherwise, it shall follow global domain settings. + /* this flag enabled to follow 11d country IE setting, + * otherwise, it shall follow global domain settings. + */ + GET_DOT11D_INFO(ieee)->bEnabled = 0; Dot11d_Reset(ieee); ieee->bGlobalDomain = true; break; @@ -209,10 +227,13 @@ static void rtl819x_set_channel_map(u8 channel_plan, struct r8192_priv *priv) static void CamResetAllEntry(struct net_device *dev) { u32 ulcommand = 0; - //2004/02/11 In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA associate to AP. - // However, ResetKey is called on OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest - // In this condition, Cam can not be reset because upper layer will not set this static key again. - ulcommand |= BIT31|BIT30; + /* In static WEP, OID_ADD_KEY or OID_ADD_WEP are set before STA + * associate to AP. However, ResetKey is called on + * OID_802_11_INFRASTRUCTURE_MODE and MlmeAssociateRequest. In this + * condition, Cam can not be reset because upper layer will not set + * this static key again. + */ + ulcommand |= BIT(31) | BIT(30); write_nic_dword(dev, RWCAM, ulcommand); } @@ -221,14 +242,14 @@ static void CamResetAllEntry(struct net_device *dev) void write_cam(struct net_device *dev, u8 addr, u32 data) { write_nic_dword(dev, WCAMI, data); - write_nic_dword(dev, RWCAM, BIT31|BIT16|(addr&0xff)); + write_nic_dword(dev, RWCAM, BIT(31) | BIT(16) | (addr & 0xff)); } u32 read_cam(struct net_device *dev, u8 addr) { u32 data; - write_nic_dword(dev, RWCAM, 0x80000000|(addr&0xff)); + write_nic_dword(dev, RWCAM, 0x80000000 | (addr & 0xff)); read_nic_dword(dev, 0xa8, &data); return data; } @@ -238,13 +259,20 @@ void write_nic_byte_E(struct net_device *dev, int indx, u8 data) int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u8 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); + + if (!usbdata) + return; + *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - indx|0xfe00, 0, &data, 1, HZ / 2); + indx | 0xfe00, 0, usbdata, 1, HZ / 2); + kfree(usbdata); if (status < 0) - netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n", status); + netdev_err(dev, "write_nic_byte_E TimeOut! status: %d\n", + status); } int read_nic_byte_E(struct net_device *dev, int indx, u8 *data) @@ -252,10 +280,16 @@ int read_nic_byte_E(struct net_device *dev, int indx, u8 *data) int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u8 *usbdata = kzalloc(sizeof(u8), GFP_KERNEL); + + if (!usbdata) + return -ENOMEM; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, data, 1, HZ / 2); + indx | 0xfe00, 0, usbdata, 1, HZ / 2); + *data = *usbdata; + kfree(usbdata); if (status < 0) { netdev_err(dev, "%s failure status: %d\n", __func__, status); @@ -264,17 +298,24 @@ int read_nic_byte_E(struct net_device *dev, int indx, u8 *data) return 0; } -//as 92U has extend page from 4 to 16, so modify functions below. +/* as 92U has extend page from 4 to 16, so modify functions below. */ void write_nic_byte(struct net_device *dev, int indx, u8 data) { int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u8 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); + + if (!usbdata) + return; + *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 1, HZ / 2); + (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, + usbdata, 1, HZ / 2); + kfree(usbdata); if (status < 0) netdev_err(dev, "write_nic_byte TimeOut! status: %d\n", status); @@ -290,10 +331,17 @@ void write_nic_word(struct net_device *dev, int indx, u16 data) struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u16 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); + + if (!usbdata) + return; + *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 2, HZ / 2); + (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, + usbdata, 2, HZ / 2); + kfree(usbdata); if (status < 0) netdev_err(dev, "write_nic_word TimeOut! status: %d\n", status); @@ -308,14 +356,22 @@ void write_nic_dword(struct net_device *dev, int indx, u32 data) struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u32 *usbdata = kzalloc(sizeof(data), GFP_KERNEL); + + if (!usbdata) + return; + *usbdata = data; status = usb_control_msg(udev, usb_sndctrlpipe(udev, 0), RTL8187_REQ_SET_REGS, RTL8187_REQT_WRITE, - (indx&0xff)|0xff00, (indx>>8)&0x0f, &data, 4, HZ / 2); + (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, + usbdata, 4, HZ / 2); + kfree(usbdata); if (status < 0) - netdev_err(dev, "write_nic_dword TimeOut! status: %d\n", status); + netdev_err(dev, "write_nic_dword TimeOut! status: %d\n", + status); } @@ -326,10 +382,17 @@ int read_nic_byte(struct net_device *dev, int indx, u8 *data) int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u8 *usbdata = kzalloc(sizeof(u8), GFP_KERNEL); + + if (!usbdata) + return -ENOMEM; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - (indx&0xff)|0xff00, (indx>>8)&0x0f, data, 1, HZ / 2); + (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, + usbdata, 1, HZ / 2); + *data = *usbdata; + kfree(usbdata); if (status < 0) { netdev_err(dev, "%s failure status: %d\n", __func__, status); @@ -346,11 +409,17 @@ int read_nic_word(struct net_device *dev, int indx, u16 *data) int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u16 *usbdata = kzalloc(sizeof(u16), GFP_KERNEL); + + if (!usbdata) + return -ENOMEM; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - (indx&0xff)|0xff00, (indx>>8)&0x0f, - data, 2, HZ / 2); + (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, + usbdata, 2, HZ / 2); + *data = *usbdata; + kfree(usbdata); if (status < 0) { netdev_err(dev, "%s failure status: %d\n", __func__, status); @@ -365,10 +434,16 @@ static int read_nic_word_E(struct net_device *dev, int indx, u16 *data) int status; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u16 *usbdata = kzalloc(sizeof(u16), GFP_KERNEL); + + if (!usbdata) + return -ENOMEM; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - indx|0xfe00, 0, data, 2, HZ / 2); + indx | 0xfe00, 0, usbdata, 2, HZ / 2); + *data = *usbdata; + kfree(usbdata); if (status < 0) { netdev_err(dev, "%s failure status: %d\n", __func__, status); @@ -384,11 +459,17 @@ int read_nic_dword(struct net_device *dev, int indx, u32 *data) struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct usb_device *udev = priv->udev; + u32 *usbdata = kzalloc(sizeof(u32), GFP_KERNEL); + + if (!usbdata) + return -ENOMEM; status = usb_control_msg(udev, usb_rcvctrlpipe(udev, 0), RTL8187_REQ_GET_REGS, RTL8187_REQT_READ, - (indx&0xff)|0xff00, (indx>>8)&0x0f, - data, 4, HZ / 2); + (indx & 0xff) | 0xff00, (indx >> 8) & 0x0f, + usbdata, 4, HZ / 2); + *data = *usbdata; + kfree(usbdata); if (status < 0) { netdev_err(dev, "%s failure status: %d\n", __func__, status); @@ -427,6 +508,7 @@ static int proc_get_stats_ap(struct seq_file *m, void *v) list_for_each_entry(target, &ieee->network_list, list) { const char *wpa = "non_WPA"; + if (target->wpa_ie_len > 0 || target->rsn_ie_len > 0) wpa = "WPA"; @@ -448,7 +530,7 @@ static int proc_get_registers(struct seq_file *m, void *v) seq_printf(m, "\nD: %2x > ", n); for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x000|n, &byte_rd); + read_nic_byte(dev, 0x000 | n, &byte_rd); seq_printf(m, "%2x ", byte_rd); } } @@ -458,7 +540,7 @@ static int proc_get_registers(struct seq_file *m, void *v) seq_printf(m, "\nD: %2x > ", n); for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x100|n, &byte_rd); + read_nic_byte(dev, 0x100 | n, &byte_rd); seq_printf(m, "%2x ", byte_rd); } } @@ -468,7 +550,7 @@ static int proc_get_registers(struct seq_file *m, void *v) seq_printf(m, "\nD: %2x > ", n); for (i = 0; i < 16 && n <= max; i++, n++) { - read_nic_byte(dev, 0x300|n, &byte_rd); + read_nic_byte(dev, 0x300 | n, &byte_rd); seq_printf(m, "%2x ", byte_rd); } } @@ -600,7 +682,8 @@ static void rtl8192_proc_init_one(struct net_device *dev) if (rtl8192_proc) { dir = proc_mkdir_data(dev->name, 0, rtl8192_proc, dev); if (!dir) { - RT_TRACE(COMP_ERR, "Unable to initialize /proc/net/rtl8192/%s\n", + RT_TRACE(COMP_ERR, + "Unable to initialize /proc/net/rtl8192/%s\n", dev->name); return; } @@ -608,8 +691,8 @@ static void rtl8192_proc_init_one(struct net_device *dev) for (f = rtl8192_proc_files; f->name[0]; f++) { if (!proc_create_data(f->name, S_IFREG | S_IRUGO, dir, &rtl8192_proc_fops, f->show)) { - RT_TRACE(COMP_ERR, "Unable to initialize " - "/proc/net/rtl8192/%s/%s\n", + RT_TRACE(COMP_ERR, + "Unable to initialize /proc/net/rtl8192/%s/%s\n", dev->name, f->name); return; } @@ -657,14 +740,14 @@ void rtl8192_update_msr(struct net_device *dev) if (priv->ieee80211->state == IEEE80211_LINKED) { if (priv->ieee80211->iw_mode == IW_MODE_INFRA) - msr |= (MSR_LINK_MANAGED<ieee80211->iw_mode == IW_MODE_ADHOC) - msr |= (MSR_LINK_ADHOC<ieee80211->iw_mode == IW_MODE_MASTER) - msr |= (MSR_LINK_MASTER<%s()====ch:%d\n", __func__, ch); priv->chan = ch; /* this hack should avoid frame TX during channel setting*/ - //need to implement rf set channel here WB + /* need to implement rf set channel here */ if (priv->rf_set_chan) priv->rf_set_chan(dev, priv->chan); @@ -712,12 +796,13 @@ static int rtl8192_rx_initiate(struct net_device *dev) break; } usb_fill_bulk_urb(entry, priv->udev, - usb_rcvbulkpipe(priv->udev, 3), skb_tail_pointer(skb), + usb_rcvbulkpipe(priv->udev, 3), + skb_tail_pointer(skb), RX_URB_SIZE, rtl8192_rx_isr, skb); - info = (struct rtl8192_rx_info *) skb->cb; + info = (struct rtl8192_rx_info *)skb->cb; info->urb = entry; info->dev = dev; - info->out_pipe = 3; //denote rx normal packet queue + info->out_pipe = 3; /* denote rx normal packet queue */ skb_queue_tail(&priv->rx_queue, skb); usb_submit_urb(entry, GFP_KERNEL); } @@ -733,12 +818,13 @@ static int rtl8192_rx_initiate(struct net_device *dev) break; } usb_fill_bulk_urb(entry, priv->udev, - usb_rcvbulkpipe(priv->udev, 9), skb_tail_pointer(skb), + usb_rcvbulkpipe(priv->udev, 9), + skb_tail_pointer(skb), RX_URB_SIZE, rtl8192_rx_isr, skb); - info = (struct rtl8192_rx_info *) skb->cb; + info = (struct rtl8192_rx_info *)skb->cb; info->urb = entry; info->dev = dev; - info->out_pipe = 9; //denote rx cmd packet queue + info->out_pipe = 9; /* denote rx cmd packet queue */ skb_queue_tail(&priv->rx_queue, skb); usb_submit_urb(entry, GFP_KERNEL); } @@ -780,15 +866,15 @@ void rtl8192_set_rxconf(struct net_device *dev) rxconf = rxconf & ~RX_FIFO_THRESHOLD_MASK; - rxconf = rxconf | (RX_FIFO_THRESHOLD_NONE<rx_queue))) { - info = (struct rtl8192_rx_info *) skb->cb; + info = (struct rtl8192_rx_info *)skb->cb; if (!info->urb) continue; @@ -872,14 +958,16 @@ inline u16 rtl8192_rate2rate(short rate) /* The prototype of rx_isr has changed since one version of Linux Kernel */ static void rtl8192_rx_isr(struct urb *urb) { - struct sk_buff *skb = (struct sk_buff *) urb->context; + struct sk_buff *skb = (struct sk_buff *)urb->context; struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; struct net_device *dev = info->dev; struct r8192_priv *priv = ieee80211_priv(dev); int out_pipe = info->out_pipe; int err; + if (!priv->up) return; + if (unlikely(urb->status)) { info->urb = NULL; priv->stats.rxstaterr++; @@ -902,10 +990,11 @@ static void rtl8192_rx_isr(struct urb *urb) } usb_fill_bulk_urb(urb, priv->udev, - usb_rcvbulkpipe(priv->udev, out_pipe), skb_tail_pointer(skb), + usb_rcvbulkpipe(priv->udev, out_pipe), + skb_tail_pointer(skb), RX_URB_SIZE, rtl8192_rx_isr, skb); - info = (struct rtl8192_rx_info *) skb->cb; + info = (struct rtl8192_rx_info *)skb->cb; info->urb = urb; info->dev = dev; info->out_pipe = out_pipe; @@ -915,7 +1004,9 @@ static void rtl8192_rx_isr(struct urb *urb) skb_queue_tail(&priv->rx_queue, skb); err = usb_submit_urb(urb, GFP_ATOMIC); if (err && err != EPERM) - netdev_err(dev, "can not submit rxurb, err is %x, URB status is %x\n", err, urb->status); + netdev_err(dev, + "can not submit rxurb, err is %x, URB status is %x\n", + err, urb->status); } static u32 rtl819xusb_rx_command_packet(struct net_device *dev, @@ -933,19 +1024,20 @@ static u32 rtl819xusb_rx_command_packet(struct net_device *dev, static void rtl8192_data_hard_stop(struct net_device *dev) { - //FIXME !! + /* FIXME !! */ } static void rtl8192_data_hard_resume(struct net_device *dev) { - // FIXME !! + /* FIXME !! */ } /* this function TX data frames when the ieee80211 stack requires this. * It checks also if we need to stop the ieee tx queue, eventually do it */ -static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, int rate) +static void rtl8192_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, + int rate) { struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); int ret; @@ -987,8 +1079,6 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) skb_push(skb, USB_HWDESC_HEADER_LEN); rtl819xU_tx_cmd(dev, skb); ret = 1; - spin_unlock_irqrestore(&priv->tx_lock, flags); - return ret; } else { skb_push(skb, priv->ieee80211->tx_headroom); ret = rtl8192_tx(dev, skb); @@ -999,9 +1089,6 @@ static int rtl8192_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) return ret; } - -void rtl8192_try_wake_queue(struct net_device *dev, int pri); - static void rtl8192_tx_isr(struct urb *tx_urb) { struct sk_buff *skb = (struct sk_buff *)tx_urb->context; @@ -1017,7 +1104,8 @@ static void rtl8192_tx_isr(struct urb *tx_urb) dev->trans_start = jiffies; priv->stats.txoktotal++; priv->ieee80211->LinkDetectInfo.NumTxOkInPeriod++; - priv->stats.txbytesunicast += (skb->len - priv->ieee80211->tx_headroom); + priv->stats.txbytesunicast += + (skb->len - priv->ieee80211->tx_headroom); } else { priv->ieee80211->stats.tx_errors++; /* TODO */ @@ -1031,16 +1119,17 @@ static void rtl8192_tx_isr(struct urb *tx_urb) atomic_dec(&priv->tx_pending[queue_index]); } - // - // Handle HW Beacon: - // We had transfer our beacon frame to host controller at this moment. - // - // - // Caution: - // Handling the wait queue of command packets. - // For Tx command packets, we must not do TCB fragment because it is not handled right now. - // We must cut the packets to match the size of TX_CMD_PKT before we send it. - // + /* + * Handle HW Beacon: + * We had transfer our beacon frame to host controller at this moment. + * + * + * Caution: + * Handling the wait queue of command packets. + * For Tx command packets, we must not do TCB fragment because it is + * not handled right now. We must cut the packets to match the size of + * TX_CMD_PKT before we send it. + */ /* Handle MPDU in wait queue. */ if (queue_index != BEACON_QUEUE) { @@ -1049,9 +1138,10 @@ static void rtl8192_tx_isr(struct urb *tx_urb) (!(priv->ieee80211->queue_stop))) { skb = skb_dequeue(&(priv->ieee80211->skb_waitQ[queue_index])); if (skb) - priv->ieee80211->softmac_hard_start_xmit(skb, dev); + priv->ieee80211->softmac_hard_start_xmit(skb, + dev); - return; //modified by david to avoid further processing AMSDU + return; /* avoid further processing AMSDU */ } } @@ -1062,10 +1152,11 @@ static void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_network *net; u8 i = 0, basic_rate = 0; + net = &priv->ieee80211->current_network; for (i = 0; i < net->rates_len; i++) { - basic_rate = net->rates[i]&0x7f; + basic_rate = net->rates[i] & 0x7f; switch (basic_rate) { case MGN_1M: *rate_config |= RRSR_1M; @@ -1106,7 +1197,7 @@ static void rtl8192_config_rate(struct net_device *dev, u16 *rate_config) } } for (i = 0; i < net->rates_ex_len; i++) { - basic_rate = net->rates_ex[i]&0x7f; + basic_rate = net->rates_ex[i] & 0x7f; switch (basic_rate) { case MGN_1M: *rate_config |= RRSR_1M; @@ -1157,17 +1248,21 @@ static void rtl8192_update_cap(struct net_device *dev, u16 cap) u32 tmp = 0; struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_network *net = &priv->ieee80211->current_network; + priv->short_preamble = cap & WLAN_CAPABILITY_SHORT_PREAMBLE; tmp = priv->basic_rate; if (priv->short_preamble) tmp |= BRSR_AckShortPmb; write_nic_dword(dev, RRSR, tmp); - if (net->mode & (IEEE_G|IEEE_N_24G)) { + if (net->mode & (IEEE_G | IEEE_N_24G)) { u8 slot_time = 0; - if ((cap & WLAN_CAPABILITY_SHORT_SLOT) && (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) /* short slot time */ + + if ((cap & WLAN_CAPABILITY_SHORT_SLOT) && + (!priv->ieee80211->pHTInfo->bCurrentRT2RTLongSlotTime)) + /* short slot time */ slot_time = SHORT_SLOT_TIME; - else //long slot time + else /* long slot time */ slot_time = NON_SHORT_SLOT_TIME; priv->slot_time = slot_time; write_nic_byte(dev, SLOT_TIME, slot_time); @@ -1181,13 +1276,14 @@ static void rtl8192_net_update(struct net_device *dev) struct ieee80211_network *net; u16 BcnTimeCfg = 0, BcnCW = 6, BcnIFS = 0xf; u16 rate_config = 0; + net = &priv->ieee80211->current_network; rtl8192_config_rate(dev, &rate_config); priv->basic_rate = rate_config & 0x15f; write_nic_dword(dev, BSSIDR, ((u32 *)net->bssid)[0]); - write_nic_word(dev, BSSIDR+4, ((u16 *)net->bssid)[2]); + write_nic_word(dev, BSSIDR + 4, ((u16 *)net->bssid)[2]); rtl8192_update_msr(dev); if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) { @@ -1196,9 +1292,9 @@ static void rtl8192_net_update(struct net_device *dev) write_nic_word(dev, BCN_INTERVAL, net->beacon_interval); write_nic_word(dev, BCN_DRV_EARLY_INT, 1); write_nic_byte(dev, BCN_ERR_THRESH, 100); - BcnTimeCfg |= (BcnCW<cb */ - pdesc->FirstSeg = 1;//bFirstSeg; - pdesc->LastSeg = 1;//bLastSeg; + pdesc->FirstSeg = 1; + pdesc->LastSeg = 1; pdesc->CmdInit = tcb_desc->bCmdOrInit; pdesc->TxBufferSize = tcb_desc->txbuf_size; pdesc->OWN = 1; pdesc->LINIP = tcb_desc->bLastIniPkt; - //---------------------------------------------------------------------------- - // Fill up USB_OUT_CONTEXT. - //---------------------------------------------------------------------------- + /*--------------------------------------------------------------------- + * Fill up USB_OUT_CONTEXT. + *--------------------------------------------------------------------- + */ idx_pipe = 0x04; - usb_fill_bulk_urb(tx_urb, priv->udev, usb_sndbulkpipe(priv->udev, idx_pipe), + usb_fill_bulk_urb(tx_urb, priv->udev, + usb_sndbulkpipe(priv->udev, idx_pipe), skb->data, skb->len, rtl8192_tx_isr, skb); status = usb_submit_urb(tx_urb, GFP_ATOMIC); - if (!status) { + if (!status) return 0; - } else { - DMESGE("Error TX CMD URB, error %d", status); - return -1; - } + + DMESGE("Error TX CMD URB, error %d", status); + return -1; } /* @@ -1320,7 +1371,7 @@ short rtl819xU_tx_cmd(struct net_device *dev, struct sk_buff *skb) */ static u8 MapHwQueueToFirmwareQueue(u8 QueueID) { - u8 QueueSelect = 0x0; //defualt set to + u8 QueueSelect = 0x0; /* defualt set to */ switch (QueueID) { case BE_QUEUE: @@ -1346,8 +1397,8 @@ static u8 MapHwQueueToFirmwareQueue(u8 QueueID) QueueSelect = QSLT_BEACON; break; - // TODO: 2006.10.30 mark other queue selection until we verify it is OK - // TODO: Remove Assertions + /* TODO: mark other queue selection until we verify it is OK */ + /* TODO: Remove Assertions */ case TXCMD_QUEUE: QueueSelect = QSLT_CMD; break; @@ -1356,7 +1407,9 @@ static u8 MapHwQueueToFirmwareQueue(u8 QueueID) break; default: - RT_TRACE(COMP_ERR, "TransmitTCB(): Impossible Queue Selection: %d \n", QueueID); + RT_TRACE(COMP_ERR, + "TransmitTCB(): Impossible Queue Selection: %d\n", + QueueID); break; } return QueueSelect; @@ -1453,7 +1506,7 @@ static u8 MRateToHwRate8190Pci(u8 rate) case MGN_MCS15: ret = DESC90_RATEMCS15; break; - case (0x80|0x20): + case (0x80 | 0x20): ret = DESC90_RATEMCS32; break; @@ -1468,7 +1521,9 @@ static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) { u8 tmp_Short; - tmp_Short = (TxHT == 1) ? ((tcb_desc->bUseShortGI) ? 1 : 0) : ((tcb_desc->bUseShortPreamble) ? 1 : 0); + tmp_Short = (TxHT == 1) ? + ((tcb_desc->bUseShortGI) ? 1 : 0) : + ((tcb_desc->bUseShortPreamble) ? 1 : 0); if (TxHT == 1 && TxRate != DESC90_RATEMCS15) tmp_Short = 0; @@ -1478,7 +1533,6 @@ static u8 QueryIsShort(u8 TxHT, u8 TxRate, cb_desc *tcb_desc) static void tx_zero_isr(struct urb *tx_urb) { - return; } /* @@ -1491,12 +1545,14 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) struct r8192_priv *priv = ieee80211_priv(dev); cb_desc *tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tx_desc_819x_usb *tx_desc = (tx_desc_819x_usb *)skb->data; - tx_fwinfo_819x_usb *tx_fwinfo = (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); + tx_fwinfo_819x_usb *tx_fwinfo = + (tx_fwinfo_819x_usb *)(skb->data + USB_HWDESC_HEADER_LEN); struct usb_device *udev = priv->udev; int pend; int status; struct urb *tx_urb = NULL, *tx_urb_zero = NULL; unsigned int idx_pipe; + pend = atomic_read(&priv->tx_pending[tcb_desc->queue_index]); /* we are locked here so the two atomic_read and inc are executed * without interleaves @@ -1517,15 +1573,16 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) /* Fill Tx firmware info */ memset(tx_fwinfo, 0, sizeof(tx_fwinfo_819x_usb)); /* DWORD 0 */ - tx_fwinfo->TxHT = (tcb_desc->data_rate&0x80) ? 1 : 0; + tx_fwinfo->TxHT = (tcb_desc->data_rate & 0x80) ? 1 : 0; tx_fwinfo->TxRate = MRateToHwRate8190Pci(tcb_desc->data_rate); tx_fwinfo->EnableCPUDur = tcb_desc->bTxEnableFwCalcDur; - tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, tcb_desc); + tx_fwinfo->Short = QueryIsShort(tx_fwinfo->TxHT, tx_fwinfo->TxRate, + tcb_desc); if (tcb_desc->bAMPDUEnable) { /* AMPDU enabled */ tx_fwinfo->AllowAggregation = 1; /* DWORD 1 */ tx_fwinfo->RxMF = tcb_desc->ampdu_factor; - tx_fwinfo->RxAMD = tcb_desc->ampdu_density&0x07;//ampdudensity + tx_fwinfo->RxAMD = tcb_desc->ampdu_density & 0x07; } else { tx_fwinfo->AllowAggregation = 0; /* DWORD 1 */ @@ -1537,18 +1594,19 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) tx_fwinfo->RtsEnable = (tcb_desc->bRTSEnable) ? 1 : 0; tx_fwinfo->CtsEnable = (tcb_desc->bCTSEnable) ? 1 : 0; tx_fwinfo->RtsSTBC = (tcb_desc->bRTSSTBC) ? 1 : 0; - tx_fwinfo->RtsHT = (tcb_desc->rts_rate&0x80) ? 1 : 0; + tx_fwinfo->RtsHT = (tcb_desc->rts_rate & 0x80) ? 1 : 0; tx_fwinfo->RtsRate = MRateToHwRate8190Pci((u8)tcb_desc->rts_rate); tx_fwinfo->RtsSubcarrier = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->RTSSC) : 0; tx_fwinfo->RtsBandwidth = (tx_fwinfo->RtsHT == 1) ? ((tcb_desc->bRTSBW) ? 1 : 0) : 0; tx_fwinfo->RtsShort = (tx_fwinfo->RtsHT == 0) ? (tcb_desc->bRTSUseShortPreamble ? 1 : 0) : - (tcb_desc->bRTSUseShortGI ? 1 : 0); + (tcb_desc->bRTSUseShortGI ? 1 : 0); /* Set Bandwidth and sub-channel settings. */ if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20_40) { if (tcb_desc->bPacketBW) { tx_fwinfo->TxBandwidth = 1; - tx_fwinfo->TxSubCarrier = 0; //By SD3's Jerry suggestion, use duplicated mode + /* use duplicated mode */ + tx_fwinfo->TxSubCarrier = 0; } else { tx_fwinfo->TxBandwidth = 0; tx_fwinfo->TxSubCarrier = priv->nCur40MhzPrimeSC; @@ -1599,8 +1657,10 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) tx_desc->DISFB = tcb_desc->bTxDisableRateFallBack; tx_desc->USERATE = tcb_desc->bTxUseDriverAssingedRate; - /* Fill fields that are required to be initialized in all of the descriptors */ - //DWORD 0 + /* Fill fields that are required to be initialized in + * all of the descriptors + */ + /* DWORD 0 */ tx_desc->FirstSeg = 1; tx_desc->LastSeg = 1; tx_desc->OWN = 1; @@ -1616,9 +1676,14 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) status = usb_submit_urb(tx_urb, GFP_ATOMIC); if (!status) { - //we need to send 0 byte packet whenever 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has been transmitted. Otherwise, it will be halt to wait for another packet. WB. 2008.08.27 + /* We need to send 0 byte packet whenever + * 512N bytes/64N(HIGN SPEED/NORMAL SPEED) bytes packet has + * been transmitted. Otherwise, it will be halt to wait for + * another packet. + */ bool bSend0Byte = false; u8 zero = 0; + if (udev->speed == USB_SPEED_HIGH) { if (skb->len > 0 && skb->len % 512 == 0) bSend0Byte = true; @@ -1629,43 +1694,49 @@ short rtl8192_tx(struct net_device *dev, struct sk_buff *skb) if (bSend0Byte) { tx_urb_zero = usb_alloc_urb(0, GFP_ATOMIC); if (!tx_urb_zero) { - RT_TRACE(COMP_ERR, "can't alloc urb for zero byte\n"); + RT_TRACE(COMP_ERR, + "can't alloc urb for zero byte\n"); return -ENOMEM; } usb_fill_bulk_urb(tx_urb_zero, udev, - usb_sndbulkpipe(udev, idx_pipe), &zero, - 0, tx_zero_isr, dev); + usb_sndbulkpipe(udev, idx_pipe), + &zero, 0, tx_zero_isr, dev); status = usb_submit_urb(tx_urb_zero, GFP_ATOMIC); if (status) { - RT_TRACE(COMP_ERR, "Error TX URB for zero byte %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), status); + RT_TRACE(COMP_ERR, + "Error TX URB for zero byte %d, error %d", + atomic_read(&priv->tx_pending[tcb_desc->queue_index]), + status); return -1; } } dev->trans_start = jiffies; atomic_inc(&priv->tx_pending[tcb_desc->queue_index]); return 0; - } else { - RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", atomic_read(&priv->tx_pending[tcb_desc->queue_index]), - status); - return -1; } + + RT_TRACE(COMP_ERR, "Error TX URB %d, error %d", + atomic_read(&priv->tx_pending[tcb_desc->queue_index]), + status); + return -1; } static short rtl8192_usb_initendpoints(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB+1), + priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1), GFP_KERNEL); if (priv->rx_urb == NULL) return -ENOMEM; #ifndef JACKSON_NEW_RX - for (i = 0; i < (MAX_RX_URB+1); i++) { + for (i = 0; i < (MAX_RX_URB + 1); i++) { priv->rx_urb[i] = usb_alloc_urb(0, GFP_KERNEL); - priv->rx_urb[i]->transfer_buffer = kmalloc(RX_URB_SIZE, GFP_KERNEL); + priv->rx_urb[i]->transfer_buffer = + kmalloc(RX_URB_SIZE, GFP_KERNEL); priv->rx_urb[i]->transfer_buffer_length = RX_URB_SIZE; } @@ -1715,7 +1786,7 @@ static void rtl8192_usb_deleteendpoints(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); if (priv->rx_urb) { - for (i = 0; i < (MAX_RX_URB+1); i++) { + for (i = 0; i < (MAX_RX_URB + 1); i++) { usb_kill_urb(priv->rx_urb[i]); usb_free_urb(priv->rx_urb[i]); } @@ -1724,10 +1795,9 @@ static void rtl8192_usb_deleteendpoints(struct net_device *dev) } kfree(priv->oldaddr); priv->oldaddr = NULL; - if (priv->pp_rxskb) { - kfree(priv->pp_rxskb); - priv->pp_rxskb = NULL; - } + + kfree(priv->pp_rxskb); + priv->pp_rxskb = NULL; } #else void rtl8192_usb_deleteendpoints(struct net_device *dev) @@ -1738,7 +1808,7 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev) #ifndef JACKSON_NEW_RX if (priv->rx_urb) { - for (i = 0; i < (MAX_RX_URB+1); i++) { + for (i = 0; i < (MAX_RX_URB + 1); i++) { usb_kill_urb(priv->rx_urb[i]); kfree(priv->rx_urb[i]->transfer_buffer); usb_free_urb(priv->rx_urb[i]); @@ -1752,11 +1822,9 @@ void rtl8192_usb_deleteendpoints(struct net_device *dev) priv->rx_urb = NULL; kfree(priv->oldaddr); priv->oldaddr = NULL; - if (priv->pp_rxskb) { - kfree(priv->pp_rxskb); - priv->pp_rxskb = 0; - } + kfree(priv->pp_rxskb); + priv->pp_rxskb = 0; #endif } @@ -1767,16 +1835,22 @@ static void rtl8192_link_change(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; + if (ieee->state == IEEE80211_LINKED) { rtl8192_net_update(dev); rtl8192_update_ratr_table(dev); - //add this as in pure N mode, wep encryption will use software way, but there is no chance to set this as wep will not set group key in wext. WB.2008.07.08 - if ((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) + /* Add this as in pure N mode, wep encryption will use software + * way, but there is no chance to set this as wep will not set + * group key in wext. + */ + if (KEY_TYPE_WEP40 == ieee->pairwise_key_type || + KEY_TYPE_WEP104 == ieee->pairwise_key_type) EnableHWSecurityConfig8192(dev); } /*update timing params*/ if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { u32 reg = 0; + read_nic_dword(dev, RCR, ®); if (priv->ieee80211->state == IEEE80211_LINKED) priv->ReceiveConfig = reg |= RCR_CBSSID; @@ -1797,25 +1871,30 @@ static struct ieee80211_qos_parameters def_qos_parameters = { static void rtl8192_update_beacon(struct work_struct *work) { - struct r8192_priv *priv = container_of(work, struct r8192_priv, update_beacon_wq.work); + struct r8192_priv *priv = container_of(work, struct r8192_priv, + update_beacon_wq.work); struct net_device *dev = priv->ieee80211->dev; struct ieee80211_device *ieee = priv->ieee80211; struct ieee80211_network *net = &ieee->current_network; if (ieee->pHTInfo->bCurrentHTSupport) HTUpdateSelfAndPeerSetting(ieee, net); - ieee->pHTInfo->bCurrentRT2RTLongSlotTime = net->bssht.bdRT2RTLongSlotTime; + ieee->pHTInfo->bCurrentRT2RTLongSlotTime = + net->bssht.bdRT2RTLongSlotTime; rtl8192_update_cap(dev, net->capability); } /* * background support to run QoS activate functionality */ -static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, EDCAPARA_VI, EDCAPARA_VO}; +static int WDCAPARA_ADD[] = {EDCAPARA_BE, EDCAPARA_BK, + EDCAPARA_VI, EDCAPARA_VO}; static void rtl8192_qos_activate(struct work_struct *work) { - struct r8192_priv *priv = container_of(work, struct r8192_priv, qos_activate); + struct r8192_priv *priv = container_of(work, struct r8192_priv, + qos_activate); struct net_device *dev = priv->ieee80211->dev; - struct ieee80211_qos_parameters *qos_parameters = &priv->ieee80211->current_network.qos_data.parameters; + struct ieee80211_qos_parameters *qos_parameters = + &priv->ieee80211->current_network.qos_data.parameters; u8 mode = priv->ieee80211->current_network.mode; u32 u1bAIFS; u32 u4bAcParam; @@ -1827,13 +1906,18 @@ static void rtl8192_qos_activate(struct work_struct *work) mutex_lock(&priv->mutex); if (priv->ieee80211->state != IEEE80211_LINKED) goto success; - RT_TRACE(COMP_QOS, "qos active process with associate response received\n"); - /* It better set slot time at first */ - /* For we just support b/g mode at present, let the slot time at 9/20 selection */ - /* update the ac parameter to related registers */ + RT_TRACE(COMP_QOS, + "qos active process with associate response received\n"); + /* It better set slot time at first + * + * For we just support b/g mode at present, let the slot time at + * 9/20 selection + * + * update the ac parameter to related registers + */ for (i = 0; i < QOS_QUEUE_NUM; i++) { - //Mode G/A: slotTimeTimer = 9; Mode B: 20 - u1bAIFS = qos_parameters->aifs[i] * ((mode&(IEEE_G|IEEE_N_24G)) ? 9 : 20) + aSifsTime; + /* Mode G/A: slotTimeTimer = 9; Mode B: 20 */ + u1bAIFS = qos_parameters->aifs[i] * ((mode & (IEEE_G | IEEE_N_24G)) ? 9 : 20) + aSifsTime; u1bAIFS <<= AC_PARAM_AIFS_OFFSET; op_limit = (u32)le16_to_cpu(qos_parameters->tx_op_limit[i]); op_limit <<= AC_PARAM_TXOP_LIMIT_OFFSET; @@ -1859,7 +1943,7 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, if (priv->ieee80211->state != IEEE80211_LINKED) return ret; - if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) + if (priv->ieee80211->iw_mode != IW_MODE_INFRA) return ret; if (network->flags & NETWORK_HAS_QOS_MASK) { @@ -1874,8 +1958,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, network->qos_data.old_param_count = network->qos_data.param_count; queue_work(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS parameters change call " - "qos_activate\n"); + RT_TRACE(COMP_QOS, + "QoS parameters change call qos_activate\n"); } } else { memcpy(&priv->ieee80211->current_network.qos_data.parameters, @@ -1883,7 +1967,8 @@ static int rtl8192_qos_handle_probe_response(struct r8192_priv *priv, if ((network->qos_data.active == 1) && (active_network == 1)) { queue_work(priv->priv_wq, &priv->qos_activate); - RT_TRACE(COMP_QOS, "QoS was disabled call qos_activate \n"); + RT_TRACE(COMP_QOS, + "QoS was disabled call qos_activate\n"); } network->qos_data.active = 0; network->qos_data.supported = 0; @@ -1923,7 +2008,7 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, if (priv->ieee80211->state != IEEE80211_LINKED) return 0; - if ((priv->ieee80211->iw_mode != IW_MODE_INFRA)) + if (priv->ieee80211->iw_mode != IW_MODE_INFRA) return 0; spin_lock_irqsave(&priv->ieee80211->lock, flags); @@ -1948,7 +2033,9 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, spin_unlock_irqrestore(&priv->ieee80211->lock, flags); - RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, network->flags, priv->ieee80211->current_network.qos_data.active); + RT_TRACE(COMP_QOS, "%s: network->flags = %d,%d\n", __func__, + network->flags, + priv->ieee80211->current_network.qos_data.active); if (set_qos_param == 1) queue_work(priv->priv_wq, &priv->qos_activate); @@ -1957,11 +2044,13 @@ static int rtl8192_qos_association_resp(struct r8192_priv *priv, } -static int rtl8192_handle_assoc_response(struct net_device *dev, - struct ieee80211_assoc_response_frame *resp, - struct ieee80211_network *network) +static int rtl8192_handle_assoc_response( + struct net_device *dev, + struct ieee80211_assoc_response_frame *resp, + struct ieee80211_network *network) { struct r8192_priv *priv = ieee80211_priv(dev); + rtl8192_qos_association_resp(priv, network); return 0; } @@ -1974,6 +2063,7 @@ static void rtl8192_update_ratr_table(struct net_device *dev) u8 *pMcsRate = ieee->dot11HTOperationalRateSet; u32 ratr_value = 0; u8 rate_index = 0; + rtl8192_config_rate(dev, (u16 *)(&ratr_value)); ratr_value |= (*(u16 *)(pMcsRate)) << 12; switch (ieee->mode) { @@ -2003,9 +2093,10 @@ static void rtl8192_update_ratr_table(struct net_device *dev) ratr_value &= 0x0FFFFFFF; if (ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI40MHz) ratr_value |= 0x80000000; - else if (!ieee->pHTInfo->bCurTxBW40MHz && ieee->pHTInfo->bCurShortGI20MHz) + else if (!ieee->pHTInfo->bCurTxBW40MHz && + ieee->pHTInfo->bCurShortGI20MHz) ratr_value |= 0x80000000; - write_nic_dword(dev, RATR0+rate_index*4, ratr_value); + write_nic_dword(dev, RATR0 + rate_index * 4, ratr_value); write_nic_byte(dev, UFWP, 1); } @@ -2021,8 +2112,12 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev) int encrypt; crypt = ieee->crypt[ieee->tx_keyidx]; - //we use connecting AP's capability instead of only security config on our driver to distinguish whether it should use N mode or G mode - encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) || (ieee->host_encrypt && crypt && crypt->ops && (0 == strcmp(crypt->ops->name, "WEP"))); + /* we use connecting AP's capability instead of only security config + * on our driver to distinguish whether it should use N mode or G mode + */ + encrypt = (network->capability & WLAN_CAPABILITY_PRIVACY) || + (ieee->host_encrypt && crypt && crypt->ops && + (0 == strcmp(crypt->ops->name, "WEP"))); /* simply judge */ if (encrypt && (wpa_ie_len == 0)) { @@ -2043,24 +2138,21 @@ static bool GetNmodeSupportBySecCfg8192(struct net_device *dev) static bool GetHalfNmodeSupportByAPs819xUsb(struct net_device *dev) { - bool Reval; struct r8192_priv *priv = ieee80211_priv(dev); - struct ieee80211_device *ieee = priv->ieee80211; - - if (ieee->bHalfWirelessN24GMode == true) - Reval = true; - else - Reval = false; - return Reval; + return priv->ieee80211->bHalfWirelessN24GMode; } static void rtl8192_refresh_supportrate(struct r8192_priv *priv) { struct ieee80211_device *ieee = priv->ieee80211; - //we do not consider set support rate for ABG mode, only HT MCS rate is set here. - if (ieee->mode == WIRELESS_MODE_N_24G || ieee->mode == WIRELESS_MODE_N_5G) - memcpy(ieee->Regdot11HTOperationalRateSet, ieee->RegHTSuppRateSet, 16); + /* We do not consider set support rate for ABG mode, only + * HT MCS rate is set here. + */ + if (ieee->mode == WIRELESS_MODE_N_24G || + ieee->mode == WIRELESS_MODE_N_5G) + memcpy(ieee->Regdot11HTOperationalRateSet, + ieee->RegHTSuppRateSet, 16); else memset(ieee->Regdot11HTOperationalRateSet, 0, 16); } @@ -2069,14 +2161,15 @@ static u8 rtl8192_getSupportedWireleeMode(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); u8 ret = 0; + switch (priv->rf_chip) { case RF_8225: case RF_8256: case RF_PSEUDO_11N: - ret = WIRELESS_MODE_N_24G|WIRELESS_MODE_G|WIRELESS_MODE_B; + ret = WIRELESS_MODE_N_24G | WIRELESS_MODE_G | WIRELESS_MODE_B; break; case RF_8258: - ret = WIRELESS_MODE_A|WIRELESS_MODE_N_5G; + ret = WIRELESS_MODE_A | WIRELESS_MODE_N_5G; break; default: ret = WIRELESS_MODE_B; @@ -2089,7 +2182,8 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) struct r8192_priv *priv = ieee80211_priv(dev); u8 bSupportMode = rtl8192_getSupportedWireleeMode(dev); - if ((wireless_mode == WIRELESS_MODE_AUTO) || ((wireless_mode&bSupportMode) == 0)) { + if (wireless_mode == WIRELESS_MODE_AUTO || + (wireless_mode & bSupportMode) == 0) { if (bSupportMode & WIRELESS_MODE_N_24G) { wireless_mode = WIRELESS_MODE_N_24G; } else if (bSupportMode & WIRELESS_MODE_N_5G) { @@ -2101,16 +2195,24 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) } else if ((bSupportMode & WIRELESS_MODE_B)) { wireless_mode = WIRELESS_MODE_B; } else { - RT_TRACE(COMP_ERR, "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", __func__, bSupportMode); + RT_TRACE(COMP_ERR, + "%s(), No valid wireless mode supported, SupportedWirelessMode(%x)!!!\n", + __func__, bSupportMode); wireless_mode = WIRELESS_MODE_B; } } -#ifdef TO_DO_LIST //// TODO: this function doesn't work well at this time, we should wait for FPGA - ActUpdateChannelAccessSetting(pAdapter, pHalData->CurrentWirelessMode, &pAdapter->MgntInfo.Info8185.ChannelAccessSetting); +#ifdef TO_DO_LIST + /* TODO: this function doesn't work well at this time, + * we should wait for FPGA + */ + ActUpdateChannelAccessSetting( + pAdapter, pHalData->CurrentWirelessMode, + &pAdapter->MgntInfo.Info8185.ChannelAccessSetting); #endif priv->ieee80211->mode = wireless_mode; - if ((wireless_mode == WIRELESS_MODE_N_24G) || (wireless_mode == WIRELESS_MODE_N_5G)) + if (wireless_mode == WIRELESS_MODE_N_24G || + wireless_mode == WIRELESS_MODE_N_5G) priv->ieee80211->pHTInfo->bEnableHT = 1; else priv->ieee80211->pHTInfo->bEnableHT = 0; @@ -2118,43 +2220,47 @@ static void rtl8192_SetWirelessMode(struct net_device *dev, u8 wireless_mode) rtl8192_refresh_supportrate(priv); } -//init priv variables here. only non_zero value should be initialized here. +/* init priv variables here. only non_zero value should be initialized here. */ static void rtl8192_init_priv_variable(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); u8 i; + priv->card_8192 = NIC_8192U; - priv->chan = 1; //set to channel 1 - priv->ieee80211->mode = WIRELESS_MODE_AUTO; //SET AUTO + priv->chan = 1; /* set to channel 1 */ + priv->ieee80211->mode = WIRELESS_MODE_AUTO; /* SET AUTO */ priv->ieee80211->iw_mode = IW_MODE_INFRA; priv->ieee80211->ieee_up = 0; priv->retry_rts = DEFAULT_RETRY_RTS; priv->retry_data = DEFAULT_RETRY_DATA; priv->ieee80211->rts = DEFAULT_RTS_THRESHOLD; - priv->ieee80211->rate = 110; //11 mbps + priv->ieee80211->rate = 110; /* 11 mbps */ priv->ieee80211->short_slot = 1; priv->promisc = (dev->flags & IFF_PROMISC) ? 1 : 0; priv->CckPwEnl = 6; - //for silent reset + /* for silent reset */ priv->IrpPendingCount = 1; priv->ResetProgress = RESET_TYPE_NORESET; priv->bForcedSilentReset = false; priv->bDisableNormalResetCheck = false; priv->force_reset = false; - priv->ieee80211->FwRWRF = 0; //we don't use FW read/write RF until stable firmware is available. - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + /* we don't use FW read/write RF until stable firmware is available. */ + priv->ieee80211->FwRWRF = 0; + priv->ieee80211->current_network.beacon_interval = + DEFAULT_BEACONINTERVAL; priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | IEEE_SOFTMAC_PROBERS | IEEE_SOFTMAC_TX_QUEUE | - IEEE_SOFTMAC_BEACONS;//added by amy 080604 + IEEE_SOFTMAC_BEACONS; priv->ieee80211->active_scan = 1; - priv->ieee80211->modulation = IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; + priv->ieee80211->modulation = + IEEE80211_CCK_MODULATION | IEEE80211_OFDM_MODULATION; priv->ieee80211->host_encrypt = 1; priv->ieee80211->host_decrypt = 1; - priv->ieee80211->start_send_beacons = NULL; //-by amy 080604 - priv->ieee80211->stop_send_beacons = NULL; //-by amy 080604 + priv->ieee80211->start_send_beacons = NULL; + priv->ieee80211->stop_send_beacons = NULL; priv->ieee80211->softmac_hard_start_xmit = rtl8192_hard_start_xmit; priv->ieee80211->set_chan = rtl8192_set_chan; priv->ieee80211->link_change = rtl8192_link_change; @@ -2167,15 +2273,15 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->ieee80211->tx_headroom = TX_PACKET_SHIFT_BYTES; priv->ieee80211->qos_support = 1; - //added by WB priv->ieee80211->SetBWModeHandler = rtl8192_SetBWMode; priv->ieee80211->handle_assoc_response = rtl8192_handle_assoc_response; priv->ieee80211->handle_beacon = rtl8192_handle_beacon; - //added by david + priv->ieee80211->GetNmodeSupportBySecCfg = GetNmodeSupportBySecCfg8192; - priv->ieee80211->GetHalfNmodeSupportByAPsHandler = GetHalfNmodeSupportByAPs819xUsb; + priv->ieee80211->GetHalfNmodeSupportByAPsHandler = + GetHalfNmodeSupportByAPs819xUsb; priv->ieee80211->SetWirelessMode = rtl8192_SetWirelessMode; - //added by amy + priv->ieee80211->InitialGainHandler = InitialGain819xUsb; priv->card_type = USB; #ifdef TO_DO_LIST @@ -2189,30 +2295,55 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->EarlyRxThreshold = 7; priv->enable_gpio0 = 0; priv->TransmitConfig = - (TCR_MXDMA_2048<ShortRetryLimit<LongRetryLimit<ShortRetryLimit << TCR_SRL_OFFSET) | + /* Long retry limit */ + (priv->LongRetryLimit << TCR_LRL_OFFSET) | + /* FALSE: HW provides PLCP length and LENGEXT + * TRUE: SW provides them + */ + (false ? TCR_SAT : 0); #ifdef TO_DO_LIST if (Adapter->bInHctTest) - pHalData->ReceiveConfig = pHalData->CSMethod | - RCR_AMF | RCR_ADF | //accept management/data - //guangan200710 - RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. - RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - RCR_AICV | RCR_ACRC32 | //accept ICV/CRC error packet - ((u32)7<EarlyRxThreshold<EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0); + pHalData->ReceiveConfig = + pHalData->CSMethod | + /* accept management/data */ + RCR_AMF | RCR_ADF | + /* accept control frame for SW + * AP needs PS-poll + */ + RCR_ACF | + /* accept BC/MC/UC */ + RCR_AB | RCR_AM | RCR_APM | + /* accept ICV/CRC error + * packet + */ + RCR_AICV | RCR_ACRC32 | + /* Max DMA Burst Size per Tx + * DMA Burst, 7: unlimited. + */ + ((u32)7 << RCR_MXDMA_OFFSET) | + /* Rx FIFO Threshold, + * 7: No Rx threshold. + */ + (pHalData->EarlyRxThreshold << RCR_FIFO_OFFSET) | + (pHalData->EarlyRxThreshold == 7 ? RCR_OnlyErlPkt : 0); else #endif priv->ReceiveConfig = - RCR_AMF | RCR_ADF | //accept management/data - RCR_ACF | //accept control frame for SW AP needs PS-poll, 2005.07.07, by rcnjko. - RCR_AB | RCR_AM | RCR_APM | //accept BC/MC/UC - ((u32)7<EarlyRxThreshold<EarlyRxThreshold << RX_FIFO_THRESHOLD_SHIFT) | (priv->EarlyRxThreshold == 7 ? RCR_ONLYERLPKT : 0); priv->AcmControl = 0; @@ -2232,11 +2363,11 @@ static void rtl8192_init_priv_variable(struct net_device *dev) priv->rf_set_chan = rtl8192_phy_SwChnl; } -//init lock here +/* init lock here */ static void rtl8192_init_priv_lock(struct r8192_priv *priv) { spin_lock_init(&priv->tx_lock); - spin_lock_init(&priv->irq_lock);//added by thomas + spin_lock_init(&priv->irq_lock); sema_init(&priv->wx_sem, 1); sema_init(&priv->rf_sem, 1); mutex_init(&priv->mutex); @@ -2245,7 +2376,7 @@ static void rtl8192_init_priv_lock(struct r8192_priv *priv) static void rtl819x_watchdog_wqcallback(struct work_struct *work); static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv); -//init tasklet and wait_queue here. only 2.6 above kernel is considered +/* init tasklet and wait_queue here. only 2.6 above kernel is considered */ #define DRV_NAME "wlan0" static void rtl8192_init_priv_task(struct net_device *dev) { @@ -2255,11 +2386,16 @@ static void rtl8192_init_priv_task(struct net_device *dev) INIT_WORK(&priv->reset_wq, rtl8192_restart); - INIT_DELAYED_WORK(&priv->watch_dog_wq, rtl819x_watchdog_wqcallback); - INIT_DELAYED_WORK(&priv->txpower_tracking_wq, dm_txpower_trackingcallback); - INIT_DELAYED_WORK(&priv->rfpath_check_wq, dm_rf_pathcheck_workitemcallback); - INIT_DELAYED_WORK(&priv->update_beacon_wq, rtl8192_update_beacon); - INIT_DELAYED_WORK(&priv->initialgain_operate_wq, InitialGainOperateWorkItemCallBack); + INIT_DELAYED_WORK(&priv->watch_dog_wq, + rtl819x_watchdog_wqcallback); + INIT_DELAYED_WORK(&priv->txpower_tracking_wq, + dm_txpower_trackingcallback); + INIT_DELAYED_WORK(&priv->rfpath_check_wq, + dm_rf_pathcheck_workitemcallback); + INIT_DELAYED_WORK(&priv->update_beacon_wq, + rtl8192_update_beacon); + INIT_DELAYED_WORK(&priv->initialgain_operate_wq, + InitialGainOperateWorkItemCallBack); INIT_WORK(&priv->qos_activate, rtl8192_qos_activate); tasklet_init(&priv->irq_rx_tasklet, @@ -2271,15 +2407,21 @@ static void rtl8192_get_eeprom_size(struct net_device *dev) { u16 curCR = 0; struct r8192_priv *priv = ieee80211_priv(dev); + RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__); read_nic_word_E(dev, EPROM_CMD, &curCR); - RT_TRACE(COMP_EPROM, "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR); - //whether need I consider BIT5? - priv->epromtype = (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46; - RT_TRACE(COMP_EPROM, "<===========%s(), epromtype:%d\n", __func__, priv->epromtype); + RT_TRACE(COMP_EPROM, + "read from Reg EPROM_CMD(%x):%x\n", EPROM_CMD, curCR); + /* whether need I consider BIT(5?) */ + priv->epromtype = + (curCR & Cmd9346CR_9356SEL) ? EPROM_93c56 : EPROM_93c46; + RT_TRACE(COMP_EPROM, + "<===========%s(), epromtype:%d\n", __func__, priv->epromtype); } -//used to swap endian. as ntohl & htonl are not necessary to swap endian, so use this instead. +/* used to swap endian. as ntohl & htonl are not necessary + * to swap endian, so use this instead. + */ static inline u16 endian_swap(u16 *data) { u16 tmp = *data; @@ -2294,24 +2436,27 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); u16 tmpValue = 0; int i; + RT_TRACE(COMP_EPROM, "===========>%s()\n", __func__); - wEPROM_ID = eprom_read(dev, 0); //first read EEPROM ID out; + wEPROM_ID = eprom_read(dev, 0); /* first read EEPROM ID out; */ RT_TRACE(COMP_EPROM, "EEPROM ID is 0x%x\n", wEPROM_ID); - if (wEPROM_ID != RTL8190_EEPROM_ID) { - RT_TRACE(COMP_ERR, "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", wEPROM_ID, RTL8190_EEPROM_ID); - } else { + if (wEPROM_ID != RTL8190_EEPROM_ID) + RT_TRACE(COMP_ERR, + "EEPROM ID is invalid(is 0x%x(should be 0x%x)\n", + wEPROM_ID, RTL8190_EEPROM_ID); + else bLoad_From_EEPOM = true; - } if (bLoad_From_EEPOM) { - tmpValue = eprom_read(dev, EEPROM_VID>>1); + tmpValue = eprom_read(dev, EEPROM_VID >> 1); priv->eeprom_vid = endian_swap(&tmpValue); - priv->eeprom_pid = eprom_read(dev, EEPROM_PID>>1); - tmpValue = eprom_read(dev, EEPROM_ChannelPlan>>1); - priv->eeprom_ChannelPlan = (tmpValue & 0xff00)>>8; + priv->eeprom_pid = eprom_read(dev, EEPROM_PID >> 1); + tmpValue = eprom_read(dev, EEPROM_ChannelPlan >> 1); + priv->eeprom_ChannelPlan = (tmpValue & 0xff00) >> 8; priv->btxpowerdata_readfromEEPORM = true; - priv->eeprom_CustomerID = eprom_read(dev, (EEPROM_Customer_ID>>1)) >>8; + priv->eeprom_CustomerID = + eprom_read(dev, (EEPROM_Customer_ID >> 1)) >> 8; } else { priv->eeprom_vid = 0; priv->eeprom_pid = 0; @@ -2319,75 +2464,81 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) priv->eeprom_ChannelPlan = 0; priv->eeprom_CustomerID = 0; } - RT_TRACE(COMP_EPROM, "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID, priv->eeprom_ChannelPlan); - //set channelplan from eeprom + RT_TRACE(COMP_EPROM, + "vid:0x%4x, pid:0x%4x, CustomID:0x%2x, ChanPlan:0x%x\n", + priv->eeprom_vid, priv->eeprom_pid, priv->eeprom_CustomerID, + priv->eeprom_ChannelPlan); + /* set channelplan from eeprom */ priv->ChannelPlan = priv->eeprom_ChannelPlan; if (bLoad_From_EEPOM) { int i; + for (i = 0; i < 6; i += 2) { u16 tmp = 0; - tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i)>>1)); + + tmp = eprom_read(dev, (u16)((EEPROM_NODE_ADDRESS_BYTE_0 + i) >> 1)); *(u16 *)(&dev->dev_addr[i]) = tmp; } } else { memcpy(dev->dev_addr, bMac_Tmp_Addr, 6); - //should I set IDR0 here? + /* should I set IDR0 here? */ } RT_TRACE(COMP_EPROM, "MAC addr:%pM\n", dev->dev_addr); - priv->rf_type = RTL819X_DEFAULT_RF_TYPE; //default 1T2R + priv->rf_type = RTL819X_DEFAULT_RF_TYPE; /* default 1T2R */ priv->rf_chip = RF_8256; if (priv->card_8192_version == (u8)VERSION_819xU_A) { - //read Tx power gain offset of legacy OFDM to HT rate + /* read Tx power gain offset of legacy OFDM to HT rate */ if (bLoad_From_EEPOM) - priv->EEPROMTxPowerDiff = (eprom_read(dev, (EEPROM_TxPowerDiff>>1))&0xff00) >> 8; + priv->EEPROMTxPowerDiff = (eprom_read(dev, (EEPROM_TxPowerDiff >> 1)) & 0xff00) >> 8; else priv->EEPROMTxPowerDiff = EEPROM_Default_TxPower; RT_TRACE(COMP_EPROM, "TxPowerDiff:%d\n", priv->EEPROMTxPowerDiff); - //read ThermalMeter from EEPROM + /* read ThermalMeter from EEPROM */ if (bLoad_From_EEPOM) - priv->EEPROMThermalMeter = (u8)(eprom_read(dev, (EEPROM_ThermalMeter>>1))&0x00ff); + priv->EEPROMThermalMeter = (u8)(eprom_read(dev, (EEPROM_ThermalMeter >> 1)) & 0x00ff); else priv->EEPROMThermalMeter = EEPROM_Default_ThermalMeter; RT_TRACE(COMP_EPROM, "ThermalMeter:%d\n", priv->EEPROMThermalMeter); - //vivi, for tx power track - priv->TSSI_13dBm = priv->EEPROMThermalMeter *100; - //read antenna tx power offset of B/C/D to A from EEPROM + /* for tx power track */ + priv->TSSI_13dBm = priv->EEPROMThermalMeter * 100; + /* read antenna tx power offset of B/C/D to A from EEPROM */ if (bLoad_From_EEPOM) - priv->EEPROMPwDiff = (eprom_read(dev, (EEPROM_PwDiff>>1))&0x0f00)>>8; + priv->EEPROMPwDiff = (eprom_read(dev, (EEPROM_PwDiff >> 1)) & 0x0f00) >> 8; else priv->EEPROMPwDiff = EEPROM_Default_PwDiff; RT_TRACE(COMP_EPROM, "TxPwDiff:%d\n", priv->EEPROMPwDiff); - // Read CrystalCap from EEPROM + /* Read CrystalCap from EEPROM */ if (bLoad_From_EEPOM) - priv->EEPROMCrystalCap = (eprom_read(dev, (EEPROM_CrystalCap>>1))&0x0f); + priv->EEPROMCrystalCap = (eprom_read(dev, (EEPROM_CrystalCap >> 1)) & 0x0f); else priv->EEPROMCrystalCap = EEPROM_Default_CrystalCap; RT_TRACE(COMP_EPROM, "CrystalCap = %d\n", priv->EEPROMCrystalCap); - //get per-channel Tx power level + /* get per-channel Tx power level */ if (bLoad_From_EEPOM) - priv->EEPROM_Def_Ver = (eprom_read(dev, (EEPROM_TxPwIndex_Ver>>1))&0xff00)>>8; + priv->EEPROM_Def_Ver = (eprom_read(dev, (EEPROM_TxPwIndex_Ver >> 1)) & 0xff00) >> 8; else priv->EEPROM_Def_Ver = 1; RT_TRACE(COMP_EPROM, "EEPROM_DEF_VER:%d\n", priv->EEPROM_Def_Ver); if (priv->EEPROM_Def_Ver == 0) { /* old eeprom definition */ int i; + if (bLoad_From_EEPOM) - priv->EEPROMTxPowerLevelCCK = (eprom_read(dev, (EEPROM_TxPwIndex_CCK>>1))&0xff) >> 8; + priv->EEPROMTxPowerLevelCCK = (eprom_read(dev, (EEPROM_TxPwIndex_CCK >> 1)) & 0xff) >> 8; else priv->EEPROMTxPowerLevelCCK = 0x10; RT_TRACE(COMP_EPROM, "CCK Tx Power Levl: 0x%02x\n", priv->EEPROMTxPowerLevelCCK); for (i = 0; i < 3; i++) { if (bLoad_From_EEPOM) { - tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G+i)>>1); - if (((EEPROM_TxPwIndex_OFDM_24G+i) % 2) == 0) + tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G + i) >> 1); + if (((EEPROM_TxPwIndex_OFDM_24G + i) % 2) == 0) tmpValue = tmpValue & 0x00ff; else tmpValue = (tmpValue & 0xff00) >> 8; } else { tmpValue = 0x10; } - priv->EEPROMTxPowerLevelOFDM24G[i] = (u8) tmpValue; + priv->EEPROMTxPowerLevelOFDM24G[i] = (u8)tmpValue; RT_TRACE(COMP_EPROM, "OFDM 2.4G Tx Power Level, Index %d = 0x%02x\n", i, priv->EEPROMTxPowerLevelCCK); } } else if (priv->EEPROM_Def_Ver == 1) { @@ -2401,7 +2552,7 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) priv->EEPROMTxPowerLevelCCK_V1[0] = (u8)tmpValue; if (bLoad_From_EEPOM) - tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2)>>1); + tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_CCK_V1 + 2) >> 1); else tmpValue = 0x1010; *((u16 *)(&priv->EEPROMTxPowerLevelCCK_V1[1])) = tmpValue; @@ -2412,14 +2563,13 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) tmpValue = 0x1010; *((u16 *)(&priv->EEPROMTxPowerLevelOFDM24G[0])) = tmpValue; if (bLoad_From_EEPOM) - tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1+2)>>1); + tmpValue = eprom_read(dev, (EEPROM_TxPwIndex_OFDM_24G_V1 + 2) >> 1); else tmpValue = 0x10; priv->EEPROMTxPowerLevelOFDM24G[2] = (u8)tmpValue; - }//endif EEPROM_Def_Ver == 1 + } /* endif EEPROM_Def_Ver == 1 */ - //update HAL variables - // + /* update HAL variables */ for (i = 0; i < 14; i++) { if (i <= 3) priv->TxPowerLevelOFDM24G[i] = priv->EEPROMTxPowerLevelOFDM24G[0]; @@ -2447,18 +2597,20 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) } } priv->TxPowerDiff = priv->EEPROMPwDiff; - // Antenna B gain offset to antenna A, bit0~3 + /* Antenna B gain offset to antenna A, bit0~3 */ priv->AntennaTxPwDiff[0] = (priv->EEPROMTxPowerDiff & 0xf); - // Antenna C gain offset to antenna A, bit4~7 - priv->AntennaTxPwDiff[1] = (priv->EEPROMTxPowerDiff & 0xf0)>>4; - // CrystalCap, bit12~15 + /* Antenna C gain offset to antenna A, bit4~7 */ + priv->AntennaTxPwDiff[1] = + (priv->EEPROMTxPowerDiff & 0xf0) >> 4; + /* CrystalCap, bit12~15 */ priv->CrystalCap = priv->EEPROMCrystalCap; - // ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 - // 92U does not enable TX power tracking. + /* ThermalMeter, bit0~3 for RFIC1, bit4~7 for RFIC2 + * 92U does not enable TX power tracking. + */ priv->ThermalMeter[0] = priv->EEPROMThermalMeter; - }//end if VersionID == VERSION_819xU_A + } /* end if VersionID == VERSION_819xU_A */ - //added by vivi, for dlink led, 20080416 + /* for dlink led */ switch (priv->eeprom_CustomerID) { case EEPROM_CID_RUNTOP: priv->CustomerID = RT_CID_819x_RUNTOP; @@ -2490,16 +2642,15 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) } - if (priv->rf_type == RF_1T2R) { + if (priv->rf_type == RF_1T2R) RT_TRACE(COMP_EPROM, "\n1T2R config\n"); - } else { + else RT_TRACE(COMP_EPROM, "\n2T4R config\n"); - } - // 2008/01/16 MH We can only know RF type in the function. So we have to init - // DIG RATR table again. + /* We can only know RF type in the function. So we have to init + * DIG RATR table again. + */ init_rate_adaptive(dev); - //we need init DIG RATR table here again. RT_TRACE(COMP_EPROM, "<===========%s()\n", __func__); } @@ -2507,8 +2658,10 @@ static void rtl8192_read_eeprom_info(struct net_device *dev) static short rtl8192_get_channel_map(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); + if (priv->ChannelPlan > COUNTRY_CODE_GLOBAL_DOMAIN) { - netdev_err(dev, "rtl8180_init: Error channel plan! Set to default.\n"); + netdev_err(dev, + "rtl8180_init: Error channel plan! Set to default.\n"); priv->ChannelPlan = 0; } RT_TRACE(COMP_INIT, "Channel plan is %d\n", priv->ChannelPlan); @@ -2528,11 +2681,13 @@ static short rtl8192_init(struct net_device *dev) { int i = 0; u8 queuetopipe[] = {3, 2, 1, 0, 4, 8, 7, 6, 5}; + memcpy(priv->txqueue_to_outpipemap, queuetopipe, 9); } #else { u8 queuetopipe[] = {3, 2, 1, 0, 4, 4, 0, 4, 4}; + memcpy(priv->txqueue_to_outpipemap, queuetopipe, 9); } #endif @@ -2568,8 +2723,7 @@ static void rtl8192_hwconfig(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); u32 ratr_value = 0; - // Set RRSR, RATR, and BW_OPMODE registers - // + /* Set RRSR, RATR, and BW_OPMODE registers */ switch (priv->ieee80211->mode) { case WIRELESS_MODE_B: regBwOpMode = BW_OPMODE_20MHZ; @@ -2577,7 +2731,7 @@ static void rtl8192_hwconfig(struct net_device *dev) regRRSR = RATE_ALL_CCK; break; case WIRELESS_MODE_A: - regBwOpMode = BW_OPMODE_5G |BW_OPMODE_20MHZ; + regBwOpMode = BW_OPMODE_5G | BW_OPMODE_20MHZ; regRATR = RATE_ALL_OFDM_AG; regRRSR = RATE_ALL_OFDM_AG; break; @@ -2592,25 +2746,28 @@ static void rtl8192_hwconfig(struct net_device *dev) regBwOpMode = BW_OPMODE_20MHZ; regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; - } - else + } else #endif { regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | + RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; } break; case WIRELESS_MODE_N_24G: - // It support CCK rate by default. - // CCK rate will be filtered out only when associated AP does not support it. + /* It support CCK rate by default. CCK rate will be filtered + * out only when associated AP does not support it. + */ regBwOpMode = BW_OPMODE_20MHZ; - regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_CCK | RATE_ALL_OFDM_AG | + RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_CCK | RATE_ALL_OFDM_AG; break; case WIRELESS_MODE_N_5G: regBwOpMode = BW_OPMODE_5G; - regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | RATE_ALL_OFDM_2SS; + regRATR = RATE_ALL_OFDM_AG | RATE_ALL_OFDM_1SS | + RATE_ALL_OFDM_2SS; regRRSR = RATE_ALL_OFDM_AG; break; } @@ -2625,25 +2782,23 @@ static void rtl8192_hwconfig(struct net_device *dev) regRRSR = ((regTmp) << 24) | (regRRSR & 0x00ffffff); write_nic_dword(dev, RRSR, regRRSR); - // - // Set Retry Limit here - // + /* Set Retry Limit here */ write_nic_word(dev, RETRY_LIMIT, priv->ShortRetryLimit << RETRY_LIMIT_SHORT_SHIFT | priv->LongRetryLimit << RETRY_LIMIT_LONG_SHIFT); - // Set Contention Window here + /* Set Contention Window here */ - // Set Tx AGC + /* Set Tx AGC */ - // Set Tx Antenna including Feedback control + /* Set Tx Antenna including Feedback control */ - // Set Auto Rate fallback control + /* Set Auto Rate fallback control */ } -//InitializeAdapter and PhyCfg +/* InitializeAdapter and PhyCfg */ static bool rtl8192_adapter_start(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -2651,9 +2806,10 @@ static bool rtl8192_adapter_start(struct net_device *dev) bool init_status = true; u8 SECR_value = 0x0; u8 tmp; + RT_TRACE(COMP_INIT, "====>%s()\n", __func__); priv->Rf_Mode = RF_OP_By_SW_3wire; - //for ASIC power on sequence + /* for ASIC power on sequence */ write_nic_byte_E(dev, 0x5f, 0x80); mdelay(50); write_nic_byte_E(dev, 0x5f, 0xf0); @@ -2662,66 +2818,74 @@ static bool rtl8192_adapter_start(struct net_device *dev) write_nic_byte(dev, 0x17, 0x37); mdelay(10); priv->pFirmware->firmware_status = FW_STATUS_0_INIT; - //config CPUReset Register - //Firmware Reset or not? + /* config CPUReset Register */ + /* Firmware Reset or not? */ read_nic_dword(dev, CPU_GEN, &dwRegRead); if (priv->pFirmware->firmware_status == FW_STATUS_0_INIT) - dwRegRead |= CPU_GEN_SYSTEM_RESET; //do nothing here? + dwRegRead |= CPU_GEN_SYSTEM_RESET; /* do nothing here? */ else if (priv->pFirmware->firmware_status == FW_STATUS_5_READY) dwRegRead |= CPU_GEN_FIRMWARE_RESET; else - RT_TRACE(COMP_ERR, "ERROR in %s(): undefined firmware state(%d)\n", __func__, priv->pFirmware->firmware_status); + RT_TRACE(COMP_ERR, + "ERROR in %s(): undefined firmware state(%d)\n", + __func__, priv->pFirmware->firmware_status); write_nic_dword(dev, CPU_GEN, dwRegRead); - //config BB. + /* config BB. */ rtl8192_BBConfig(dev); - //Loopback mode or not + /* Loopback mode or not */ priv->LoopbackMode = RTL819xU_NO_LOOPBACK; read_nic_dword(dev, CPU_GEN, &dwRegRead); if (priv->LoopbackMode == RTL819xU_NO_LOOPBACK) - dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | CPU_GEN_NO_LOOPBACK_SET; + dwRegRead = (dwRegRead & CPU_GEN_NO_LOOPBACK_MSK) | + CPU_GEN_NO_LOOPBACK_SET; else if (priv->LoopbackMode == RTL819xU_MAC_LOOPBACK) dwRegRead |= CPU_CCK_LOOPBACK; else - RT_TRACE(COMP_ERR, "Serious error in %s(): wrong loopback mode setting(%d)\n", __func__, priv->LoopbackMode); + RT_TRACE(COMP_ERR, + "Serious error in %s(): wrong loopback mode setting(%d)\n", + __func__, priv->LoopbackMode); write_nic_dword(dev, CPU_GEN, dwRegRead); - //after reset cpu, we need wait for a seconds to write in register. + /* after reset cpu, we need wait for a seconds to write in register. */ udelay(500); - //xiong add for new bitfile:usb suspend reset pin set to 1. //do we need? + /* add for new bitfile:usb suspend reset pin set to 1. Do we need? */ read_nic_byte_E(dev, 0x5f, &tmp); - write_nic_byte_E(dev, 0x5f, tmp|0x20); + write_nic_byte_E(dev, 0x5f, tmp | 0x20); - //Set Hardware + /* Set Hardware */ rtl8192_hwconfig(dev); - //turn on Tx/Rx - write_nic_byte(dev, CMDR, CR_RE|CR_TE); + /* turn on Tx/Rx */ + write_nic_byte(dev, CMDR, CR_RE | CR_TE); - //set IDR0 here + /* set IDR0 here */ write_nic_dword(dev, MAC0, ((u32 *)dev->dev_addr)[0]); write_nic_word(dev, MAC4, ((u16 *)(dev->dev_addr + 4))[0]); - //set RCR + /* set RCR */ write_nic_dword(dev, RCR, priv->ReceiveConfig); - //Initialize Number of Reserved Pages in Firmware Queue - write_nic_dword(dev, RQPN1, NUM_OF_PAGE_IN_FW_QUEUE_BK << RSVD_FW_QUEUE_PAGE_BK_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_BE << RSVD_FW_QUEUE_PAGE_BE_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_VI << RSVD_FW_QUEUE_PAGE_VI_SHIFT | - NUM_OF_PAGE_IN_FW_QUEUE_VO <ResetProgress == RESET_TYPE_NORESET) @@ -2734,58 +2898,77 @@ static bool rtl8192_adapter_start(struct net_device *dev) write_nic_byte(dev, SECR, SECR_value); } - //Beacon related + /* Beacon related */ write_nic_word(dev, ATIMWND, 2); write_nic_word(dev, BCN_INTERVAL, 100); #define DEFAULT_EDCA 0x005e4332 { int i; + for (i = 0; i < QOS_QUEUE_NUM; i++) write_nic_dword(dev, WDCAPARA_ADD[i], DEFAULT_EDCA); } rtl8192_phy_configmac(dev); - if (priv->card_8192_version == (u8) VERSION_819xU_A) { + if (priv->card_8192_version == (u8)VERSION_819xU_A) { rtl8192_phy_getTxPower(dev); rtl8192_phy_setTxPower(dev, priv->chan); } - //Firmware download + /* Firmware download */ init_status = init_firmware(dev); if (!init_status) { - RT_TRACE(COMP_ERR, "ERR!!! %s(): Firmware download is failed\n", __func__); + RT_TRACE(COMP_ERR, "ERR!!! %s(): Firmware download is failed\n", + __func__); return init_status; } RT_TRACE(COMP_INIT, "%s():after firmware download\n", __func__); - // + #ifdef TO_DO_LIST if (Adapter->ResetProgress == RESET_TYPE_NORESET) { - if (pMgntInfo->RegRfOff == true) { /* User disable RF via registry. */ - RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n")); + if (pMgntInfo->RegRfOff) { /* User disable RF via registry. */ + RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, + ("InitializeAdapter819xUsb(): Turn off RF for RegRfOff ----------\n")); MgntActSet_RF_State(Adapter, eRfOff, RF_CHANGE_BY_SW); - // Those actions will be discard in MgntActSet_RF_State because of the same state + /* Those actions will be discard in MgntActSet_RF_State + * because of the same state + */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) - PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0); - } else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) { /* H/W or S/W RF OFF before sleep. */ - RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", pMgntInfo->RfOffReason)); - MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason); + PHY_SetRFReg(Adapter, + (RF90_RADIO_PATH_E)eRFPath, + 0x4, 0xC00, 0x0); + } else if (pMgntInfo->RfOffReason > RF_CHANGE_BY_PS) { + /* H/W or S/W RF OFF before sleep. */ + RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, + ("InitializeAdapter819xUsb(): Turn off RF for RfOffReason(%d) ----------\n", + pMgntInfo->RfOffReason)); + MgntActSet_RF_State(Adapter, + eRfOff, + pMgntInfo->RfOffReason); } else { pHalData->eRFPowerState = eRfOn; pMgntInfo->RfOffReason = 0; - RT_TRACE((COMP_INIT|COMP_RF), DBG_LOUD, ("InitializeAdapter819xUsb(): RF is on ----------\n")); + RT_TRACE((COMP_INIT | COMP_RF), DBG_LOUD, + ("InitializeAdapter819xUsb(): RF is on ----------\n")); } } else { if (pHalData->eRFPowerState == eRfOff) { - MgntActSet_RF_State(Adapter, eRfOff, pMgntInfo->RfOffReason); - // Those actions will be discard in MgntActSet_RF_State because of the same state + MgntActSet_RF_State(Adapter, + eRfOff, + pMgntInfo->RfOffReason); + /* Those actions will be discard in MgntActSet_RF_State + * because of the same state + */ for (eRFPath = 0; eRFPath < pHalData->NumTotalRFPath; eRFPath++) - PHY_SetRFReg(Adapter, (RF90_RADIO_PATH_E)eRFPath, 0x4, 0xC00, 0x0); + PHY_SetRFReg(Adapter, + (RF90_RADIO_PATH_E)eRFPath, + 0x4, 0xC00, 0x0); } } #endif - //config RF. + /* config RF. */ if (priv->ResetProgress == RESET_TYPE_NORESET) { rtl8192_phy_RFConfig(dev); RT_TRACE(COMP_INIT, "%s():after phy RF config\n", __func__); @@ -2793,7 +2976,7 @@ static bool rtl8192_adapter_start(struct net_device *dev) if (priv->ieee80211->FwRWRF) - // We can force firmware to do RF-R/W + /* We can force firmware to do RF-R/W */ priv->Rf_Mode = RF_OP_By_FW; else priv->Rf_Mode = RF_OP_By_SW_3wire; @@ -2805,8 +2988,9 @@ static bool rtl8192_adapter_start(struct net_device *dev) rtl8192_setBBreg(dev, rFPGA0_RFMOD, bOFDMEn, 0x1); if (priv->ResetProgress == RESET_TYPE_NORESET) { - //if D or C cut + /* if D or C cut */ u8 tmpvalue; + read_nic_byte(dev, 0x301, &tmpvalue); if (tmpvalue == 0x03) { priv->bDcut = true; @@ -2819,28 +3003,36 @@ static bool rtl8192_adapter_start(struct net_device *dev) if (priv->bDcut) { u32 i, TempCCk; - u32 tmpRegA = rtl8192_QueryBBReg(dev, rOFDM0_XATxIQImbalance, bMaskDWord); + u32 tmpRegA = rtl8192_QueryBBReg(dev, + rOFDM0_XATxIQImbalance, + bMaskDWord); + for (i = 0; i < TxBBGainTableLength; i++) { if (tmpRegA == priv->txbbgain_table[i].txbbgain_value) { priv->rfa_txpowertrackingindex = (u8)i; - priv->rfa_txpowertrackingindex_real = (u8)i; - priv->rfa_txpowertracking_default = priv->rfa_txpowertrackingindex; + priv->rfa_txpowertrackingindex_real = + (u8)i; + priv->rfa_txpowertracking_default = + priv->rfa_txpowertrackingindex; break; } } - TempCCk = rtl8192_QueryBBReg(dev, rCCK0_TxFilter1, bMaskByte2); + TempCCk = rtl8192_QueryBBReg(dev, + rCCK0_TxFilter1, + bMaskByte2); for (i = 0; i < CCKTxBBGainTableLength; i++) { if (TempCCk == priv->cck_txbbgain_table[i].ccktxbb_valuearray[0]) { - priv->cck_present_attentuation_20Mdefault = (u8) i; + priv->cck_present_attentuation_20Mdefault = (u8)i; break; } } priv->cck_present_attentuation_40Mdefault = 0; priv->cck_present_attentuation_difference = 0; - priv->cck_present_attentuation = priv->cck_present_attentuation_20Mdefault; + priv->cck_present_attentuation = + priv->cck_present_attentuation_20Mdefault; } } @@ -2870,8 +3062,11 @@ static bool HalTxCheckStuck819xUsb(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); u16 RegTxCounter; bool bStuck = false; + read_nic_word(dev, 0x128, &RegTxCounter); - RT_TRACE(COMP_RESET, "%s():RegTxCounter is %d,TxCounter is %d\n", __func__, RegTxCounter, priv->TxCounter); + RT_TRACE(COMP_RESET, + "%s():RegTxCounter is %d,TxCounter is %d\n", __func__, + RegTxCounter, priv->TxCounter); if (priv->TxCounter == RegTxCounter) bStuck = true; @@ -2890,9 +3085,7 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev) u8 QueueID; bool bCheckFwTxCnt = false; - // - // Decide such threshold according to current power save mode - // + /* Decide such threshold according to current power save mode */ for (QueueID = 0; QueueID <= BEACON_QUEUE; QueueID++) { if (QueueID == TXCMD_QUEUE) @@ -2904,7 +3097,8 @@ static RESET_TYPE TxCheckStuck(struct net_device *dev) } if (bCheckFwTxCnt) { if (HalTxCheckStuck819xUsb(dev)) { - RT_TRACE(COMP_RESET, "TxCheckStuck(): Fw indicates no Tx condition! \n"); + RT_TRACE(COMP_RESET, + "TxCheckStuck(): Fw indicates no Tx condition!\n"); return RESET_TYPE_SILENT; } } @@ -2917,32 +3111,36 @@ static bool HalRxCheckStuck819xUsb(struct net_device *dev) struct r8192_priv *priv = ieee80211_priv(dev); bool bStuck = false; static u8 rx_chk_cnt; + read_nic_word(dev, 0x130, &RegRxCounter); - RT_TRACE(COMP_RESET, "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__, RegRxCounter, priv->RxCounter); - // If rssi is small, we should check rx for long time because of bad rx. - // or maybe it will continuous silent reset every 2 seconds. + RT_TRACE(COMP_RESET, + "%s(): RegRxCounter is %d,RxCounter is %d\n", __func__, + RegRxCounter, priv->RxCounter); + /* If rssi is small, we should check rx for long time because of bad rx. + * or maybe it will continuous silent reset every 2 seconds. + */ rx_chk_cnt++; - if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High+5)) { - rx_chk_cnt = 0; //high rssi, check rx stuck right now. - } else if (priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High+5) && + if (priv->undecorated_smoothed_pwdb >= (RateAdaptiveTH_High + 5)) { + rx_chk_cnt = 0; /* high rssi, check rx stuck right now. */ + } else if (priv->undecorated_smoothed_pwdb < (RateAdaptiveTH_High + 5) && ((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_40M) || (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb >= RateAdaptiveTH_Low_20M))) { if (rx_chk_cnt < 2) return bStuck; - else - rx_chk_cnt = 0; + + rx_chk_cnt = 0; } else if (((priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_40M) || (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 && priv->undecorated_smoothed_pwdb < RateAdaptiveTH_Low_20M)) && priv->undecorated_smoothed_pwdb >= VeryLowRSSI) { if (rx_chk_cnt < 4) return bStuck; - else - rx_chk_cnt = 0; + + rx_chk_cnt = 0; } else { if (rx_chk_cnt < 8) return bStuck; - else - rx_chk_cnt = 0; + + rx_chk_cnt = 0; } if (priv->RxCounter == RegRxCounter) @@ -2972,17 +3170,18 @@ static RESET_TYPE RxCheckStuck(struct net_device *dev) /** -* This function is called by Checkforhang to check whether we should ask OS to reset driver -* -* \param pAdapter The adapter context for this miniport -* -* Note:NIC with USB interface sholud not call this function because we cannot scan descriptor -* to judge whether there is tx stuck. -* Note: This function may be required to be rewrite for Vista OS. -* <<>> -* -* 8185 and 8185b does not implement this function. This is added by Emily at 2006.11.24 -*/ + * This function is called by Checkforhang to check whether we should + * ask OS to reset driver + * + * \param pAdapter The adapter context for this miniport + * + * Note:NIC with USB interface sholud not call this function because we + * cannot scan descriptor to judge whether there is tx stuck. + * Note: This function may be required to be rewrite for Vista OS. + * <<>> + * + * 8185 and 8185b does not implement this function. + */ static RESET_TYPE rtl819x_ifcheck_resetornot(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -2995,19 +3194,25 @@ static RESET_TYPE rtl819x_ifcheck_resetornot(struct net_device *dev) TxResetType = TxCheckStuck(dev); if (rfState != eRfOff || (priv->ieee80211->iw_mode != IW_MODE_ADHOC)) { - // If driver is in the status of firmware download failure , driver skips RF initialization and RF is - // in turned off state. Driver should check whether Rx stuck and do silent reset. And - // if driver is in firmware download failure status, driver should initialize RF in the following - // silent reset procedure Emily, 2008.01.21 - - // Driver should not check RX stuck in IBSS mode because it is required to - // set Check BSSID in order to send beacon, however, if check BSSID is - // set, STA cannot hear any packet at all. Emily, 2008.04.12 + /* If driver is in the status of firmware download failure, + * driver skips RF initialization and RF is in turned off + * state. Driver should check whether Rx stuck and do silent + * reset. And if driver is in firmware download failure status, + * driver should initialize RF in the following silent reset + * procedure + * + * Driver should not check RX stuck in IBSS mode because it is + * required to set Check BSSID in order to send beacon, + * however, if check BSSID is set, STA cannot hear any packet + * at all. + */ RxResetType = RxCheckStuck(dev); } - if (TxResetType == RESET_TYPE_NORMAL || RxResetType == RESET_TYPE_NORMAL) { + if (TxResetType == RESET_TYPE_NORMAL || + RxResetType == RESET_TYPE_NORMAL) { return RESET_TYPE_NORMAL; - } else if (TxResetType == RESET_TYPE_SILENT || RxResetType == RESET_TYPE_SILENT) { + } else if (TxResetType == RESET_TYPE_SILENT || + RxResetType == RESET_TYPE_SILENT) { RT_TRACE(COMP_RESET, "%s():silent reset\n", __func__); return RESET_TYPE_SILENT; } else { @@ -3036,7 +3241,7 @@ static void CamRestoreAllEntry(struct net_device *dev) static u8 CAM_CONST_BROAD[] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; - RT_TRACE(COMP_SEC, "CamRestoreAllEntry: \n"); + RT_TRACE(COMP_SEC, "CamRestoreAllEntry:\n"); if ((priv->ieee80211->pairwise_key_type == KEY_TYPE_WEP40) || @@ -3092,12 +3297,11 @@ static void CamRestoreAllEntry(struct net_device *dev) CAM_CONST_ADDR[0], 0, NULL); } } -////////////////////////////////////////////////////////////// -// This function is used to fix Tx/Rx stop bug temporarily. -// This function will do "system reset" to NIC when Tx or Rx is stuck. -// The method checking Tx/Rx stuck of this function is supported by FW, -// which reports Tx and Rx counter to register 0x128 and 0x130. -////////////////////////////////////////////////////////////// +/* This function is used to fix Tx/Rx stop bug temporarily. + * This function will do "system reset" to NIC when Tx or Rx is stuck. + * The method checking Tx/Rx stuck of this function is supported by FW, + * which reports Tx and Rx counter to register 0x128 and 0x130. + */ static void rtl819x_ifsilentreset(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); @@ -3106,24 +3310,28 @@ static void rtl819x_ifsilentreset(struct net_device *dev) struct ieee80211_device *ieee = priv->ieee80211; - // 2007.07.20. If we need to check CCK stop, please uncomment this line. - //bStuck = Adapter->HalFunc.CheckHWStopHandler(Adapter); + /* If we need to check CCK stop, please uncomment this line. */ + /* bStuck = Adapter->HalFunc.CheckHWStopHandler(Adapter); */ if (priv->ResetProgress == RESET_TYPE_NORESET) { RESET_START: - RT_TRACE(COMP_RESET, "=========>Reset progress!! \n"); + RT_TRACE(COMP_RESET, "=========>Reset progress!!\n"); - // Set the variable for reset. + /* Set the variable for reset. */ priv->ResetProgress = RESET_TYPE_SILENT; down(&priv->wx_sem); if (priv->up == 0) { - RT_TRACE(COMP_ERR, "%s():the driver is not up! return\n", __func__); + RT_TRACE(COMP_ERR, + "%s():the driver is not up! return\n", + __func__); up(&priv->wx_sem); return; } priv->up = 0; - RT_TRACE(COMP_RESET, "%s():======>start to down the driver\n", __func__); + RT_TRACE(COMP_RESET, + "%s():======>start to down the driver\n", + __func__); rtl8192_rtx_disable(dev); rtl8192_cancel_deferred_work(priv); @@ -3145,28 +3353,40 @@ RESET_START: ieee80211_softmac_stop_protocol(priv->ieee80211); } up(&priv->wx_sem); - RT_TRACE(COMP_RESET, "%s():<==========down process is finished\n", __func__); - RT_TRACE(COMP_RESET, "%s():===========>start up the driver\n", __func__); + RT_TRACE(COMP_RESET, + "%s():<==========down process is finished\n", + __func__); + RT_TRACE(COMP_RESET, + "%s():===========>start up the driver\n", + __func__); reset_status = _rtl8192_up(dev); - RT_TRACE(COMP_RESET, "%s():<===========up process is finished\n", __func__); + RT_TRACE(COMP_RESET, + "%s():<===========up process is finished\n", + __func__); if (reset_status == -EAGAIN) { if (reset_times < 3) { reset_times++; goto RESET_START; } else { - RT_TRACE(COMP_ERR, " ERR!!! %s(): Reset Failed!!\n", __func__); + RT_TRACE(COMP_ERR, + " ERR!!! %s(): Reset Failed!!\n", + __func__); } } ieee->is_silent_reset = 1; EnableHWSecurityConfig8192(dev); - if (ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_INFRA) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + if (ieee->state == IEEE80211_LINKED && + ieee->iw_mode == IW_MODE_INFRA) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); queue_work(ieee->wq, &ieee->associate_complete_wq); - } else if (ieee->state == IEEE80211_LINKED && ieee->iw_mode == IW_MODE_ADHOC) { - ieee->set_chan(ieee->dev, ieee->current_network.channel); + } else if (ieee->state == IEEE80211_LINKED && + ieee->iw_mode == IW_MODE_ADHOC) { + ieee->set_chan(ieee->dev, + ieee->current_network.channel); ieee->link_change(ieee->dev); ieee80211_start_send_beacons(ieee); @@ -3184,9 +3404,11 @@ RESET_START: priv->bForcedSilentReset = false; priv->bResetInProgress = false; - // For test --> force write UFWP. + /* For test --> force write UFWP. */ write_nic_byte(dev, UFWP, 1); - RT_TRACE(COMP_RESET, "Reset finished!! ====>[%d]\n", priv->reset_count); + RT_TRACE(COMP_RESET, + "Reset finished!! ====>[%d]\n", + priv->reset_count); } } @@ -3199,9 +3421,12 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, *TotalRxBcnNum = 0; *TotalRxDataNum = 0; - SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++)%(priv->ieee80211->LinkDetectInfo.SlotNum); - priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; - priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; + SlotIndex = (priv->ieee80211->LinkDetectInfo.SlotIndex++) % + (priv->ieee80211->LinkDetectInfo.SlotNum); + priv->ieee80211->LinkDetectInfo.RxBcnNum[SlotIndex] = + priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod; + priv->ieee80211->LinkDetectInfo.RxDataNum[SlotIndex] = + priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod; for (i = 0; i < priv->ieee80211->LinkDetectInfo.SlotNum; i++) { *TotalRxBcnNum += priv->ieee80211->LinkDetectInfo.RxBcnNum[i]; *TotalRxDataNum += priv->ieee80211->LinkDetectInfo.RxDataNum[i]; @@ -3209,10 +3434,12 @@ static void rtl819x_update_rxcounts(struct r8192_priv *priv, u32 *TotalRxBcnNum, } -void rtl819x_watchdog_wqcallback(struct work_struct *work) +static void rtl819x_watchdog_wqcallback(struct work_struct *work) { - struct delayed_work *dwork = container_of(work, struct delayed_work, work); - struct r8192_priv *priv = container_of(dwork, struct r8192_priv, watch_dog_wq); + struct delayed_work *dwork = container_of(work, + struct delayed_work, work); + struct r8192_priv *priv = container_of(dwork, + struct r8192_priv, watch_dog_wq); struct net_device *dev = priv->ieee80211->dev; struct ieee80211_device *ieee = priv->ieee80211; RESET_TYPE ResetType = RESET_TYPE_NORESET; @@ -3225,45 +3452,55 @@ void rtl819x_watchdog_wqcallback(struct work_struct *work) return; hal_dm_watchdog(dev); - //to get busy traffic condition + /* to get busy traffic condition */ if (ieee->state == IEEE80211_LINKED) { if (ieee->LinkDetectInfo.NumRxOkInPeriod > 666 || - ieee->LinkDetectInfo.NumTxOkInPeriod > 666 ) { + ieee->LinkDetectInfo.NumTxOkInPeriod > 666) { bBusyTraffic = true; } ieee->LinkDetectInfo.NumRxOkInPeriod = 0; ieee->LinkDetectInfo.NumTxOkInPeriod = 0; ieee->LinkDetectInfo.bBusyTraffic = bBusyTraffic; } - //added by amy for AP roaming - if (priv->ieee80211->state == IEEE80211_LINKED && priv->ieee80211->iw_mode == IW_MODE_INFRA) { + /* for AP roaming */ + if (priv->ieee80211->state == IEEE80211_LINKED && + priv->ieee80211->iw_mode == IW_MODE_INFRA) { rtl819x_update_rxcounts(priv, &TotalRxBcnNum, &TotalRxDataNum); - if ((TotalRxBcnNum+TotalRxDataNum) == 0) { + if ((TotalRxBcnNum + TotalRxDataNum) == 0) { #ifdef TODO if (rfState == eRfOff) RT_TRACE(COMP_ERR, "========>%s()\n", __func__); #endif - netdev_dbg(dev, "===>%s(): AP is power off, connect another one\n", __func__); + netdev_dbg(dev, + "===>%s(): AP is power off, connect another one\n", + __func__); priv->ieee80211->state = IEEE80211_ASSOCIATING; notify_wx_assoc_event(priv->ieee80211); - RemovePeerTS(priv->ieee80211, priv->ieee80211->current_network.bssid); + RemovePeerTS(priv->ieee80211, + priv->ieee80211->current_network.bssid); priv->ieee80211->link_change(dev); - queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); + queue_work(priv->ieee80211->wq, + &priv->ieee80211->associate_procedure_wq); } } priv->ieee80211->LinkDetectInfo.NumRecvBcnInPeriod = 0; priv->ieee80211->LinkDetectInfo.NumRecvDataInPeriod = 0; - //check if reset the driver + /* check if reset the driver */ if (check_reset_cnt++ >= 3) { ResetType = rtl819x_ifcheck_resetornot(dev); check_reset_cnt = 3; } + /* This is control by OID set in Pomelo */ if ((priv->force_reset) || (priv->ResetProgress == RESET_TYPE_NORESET && (priv->bForcedSilentReset || - (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) { /* This is control by OID set in Pomelo */ - RT_TRACE(COMP_RESET, "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n", __func__, priv->force_reset, priv->ResetProgress, priv->bForcedSilentReset, priv->bDisableNormalResetCheck, ResetType); + (!priv->bDisableNormalResetCheck && ResetType == RESET_TYPE_SILENT)))) { + RT_TRACE(COMP_RESET, + "%s():priv->force_reset is %d,priv->ResetProgress is %d, priv->bForcedSilentReset is %d,priv->bDisableNormalResetCheck is %d,ResetType is %d\n", + __func__, priv->force_reset, priv->ResetProgress, + priv->bForcedSilentReset, + priv->bDisableNormalResetCheck, ResetType); rtl819x_ifsilentreset(dev); } priv->force_reset = false; @@ -3273,22 +3510,26 @@ void rtl819x_watchdog_wqcallback(struct work_struct *work) } -void watch_dog_timer_callback(unsigned long data) +static void watch_dog_timer_callback(unsigned long data) { - struct r8192_priv *priv = ieee80211_priv((struct net_device *) data); + struct r8192_priv *priv = ieee80211_priv((struct net_device *)data); + queue_delayed_work(priv->priv_wq, &priv->watch_dog_wq, 0); - mod_timer(&priv->watch_dog_timer, jiffies + MSECS(IEEE80211_WATCH_DOG_TIME)); + mod_timer(&priv->watch_dog_timer, + jiffies + msecs_to_jiffies(IEEE80211_WATCH_DOG_TIME)); } -int _rtl8192_up(struct net_device *dev) +static int _rtl8192_up(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); int init_status = 0; + priv->up = 1; priv->ieee80211->ieee_up = 1; RT_TRACE(COMP_INIT, "Bringing up iface"); init_status = rtl8192_adapter_start(dev); if (!init_status) { - RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization failed!\n", __func__); + RT_TRACE(COMP_ERR, "ERR!!! %s(): initialization failed!\n", + __func__); priv->up = priv->ieee80211->ieee_up = 0; return -EAGAIN; } @@ -3297,7 +3538,7 @@ int _rtl8192_up(struct net_device *dev) if (priv->ieee80211->state != IEEE80211_LINKED) ieee80211_softmac_start_protocol(priv->ieee80211); ieee80211_reset_queue(priv->ieee80211); - watch_dog_timer_callback((unsigned long) dev); + watch_dog_timer_callback((unsigned long)dev); if (!netif_queue_stopped(dev)) netif_start_queue(dev); else @@ -3311,6 +3552,7 @@ static int rtl8192_open(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); int ret; + down(&priv->wx_sem); ret = rtl8192_up(dev); up(&priv->wx_sem); @@ -3330,7 +3572,7 @@ int rtl8192_up(struct net_device *dev) } -int rtl8192_close(struct net_device *dev) +static int rtl8192_close(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); int ret; @@ -3371,14 +3613,17 @@ int rtl8192_down(struct net_device *dev) for (i = 0; i < MAX_QUEUE_SIZE; i++) skb_queue_purge(&priv->ieee80211->skb_drv_aggQ[i]); - //as cancel_delayed_work will del work->timer, so if work is not defined as struct delayed_work, it will corrupt + /* as cancel_delayed_work will del work->timer, so if work is not + * defined as struct delayed_work, it will corrupt + */ rtl8192_cancel_deferred_work(priv); deinit_hal_dm(dev); del_timer_sync(&priv->watch_dog_timer); ieee80211_softmac_stop_protocol(priv->ieee80211); - memset(&priv->ieee80211->current_network, 0, offsetof(struct ieee80211_network, list)); + memset(&priv->ieee80211->current_network, 0, + offsetof(struct ieee80211_network, list)); RT_TRACE(COMP_DOWN, "<==========%s()\n", __func__); return 0; @@ -3389,6 +3634,7 @@ void rtl8192_commit(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); int reset_status = 0; + if (priv->up == 0) return; priv->up = 0; @@ -3403,9 +3649,10 @@ void rtl8192_commit(struct net_device *dev) } -void rtl8192_restart(struct work_struct *work) +static void rtl8192_restart(struct work_struct *work) { - struct r8192_priv *priv = container_of(work, struct r8192_priv, reset_wq); + struct r8192_priv *priv = container_of(work, struct r8192_priv, + reset_wq); struct net_device *dev = priv->ieee80211->dev; down(&priv->wx_sem); @@ -3437,7 +3684,7 @@ static int r8192_set_mac_adr(struct net_device *dev, void *mac) down(&priv->wx_sem); - memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); + ether_addr_copy(dev->dev_addr, addr->sa_data); schedule_work(&priv->reset_wq); up(&priv->wx_sem); @@ -3473,7 +3720,7 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - //parse here for HW security + /* parse here for HW security */ if (ipw->cmd == IEEE_CMD_SET_ENCRYPTION) { if (ipw->u.crypt.set_tx) { if (strcmp(ipw->u.crypt.alg, "CCMP") == 0) { @@ -3492,11 +3739,22 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (ieee->pairwise_key_type) { memcpy((u8 *)key, ipw->u.crypt.key, 16); EnableHWSecurityConfig8192(dev); - //we fill both index entry and 4th entry for pairwise key as in IPW interface, adhoc will only get here, so we need index entry for its default key serching! - //added by WB. - setKey(dev, 4, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8 *)ieee->ap_mac_addr, 0, key); + /* We fill both index entry and 4th + * entry for pairwise key as in IPW + * interface, adhoc will only get here, + * so we need index entry for its + * default key serching! + */ + setKey(dev, 4, ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key); if (ieee->auth_mode != 2) - setKey(dev, ipw->u.crypt.idx, ipw->u.crypt.idx, ieee->pairwise_key_type, (u8 *)ieee->ap_mac_addr, 0, key); + setKey(dev, ipw->u.crypt.idx, + ipw->u.crypt.idx, + ieee->pairwise_key_type, + (u8 *)ieee->ap_mac_addr, + 0, key); } } else { memcpy((u8 *)key, ipw->u.crypt.key, 16); @@ -3515,15 +3773,21 @@ static int rtl8192_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) if (ieee->group_key_type) { setKey(dev, ipw->u.crypt.idx, - ipw->u.crypt.idx, //KeyIndex - ieee->group_key_type, //KeyType - broadcast_addr, //MacAddr - 0, //DefaultKey - key); //KeyContent + /* KeyIndex */ + ipw->u.crypt.idx, + /* KeyType */ + ieee->group_key_type, + /* MacAddr */ + broadcast_addr, + /* DefaultKey */ + 0, + /* KeyContent */ + key); } } } - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, + &wrq->u.data); break; default: @@ -3543,107 +3807,111 @@ static u8 HwRateToMRate90(bool bIsHT, u8 rate) if (!bIsHT) { switch (rate) { - case DESC90_RATE1M: - ret_rate = MGN_1M; - break; - case DESC90_RATE2M: - ret_rate = MGN_2M; - break; - case DESC90_RATE5_5M: - ret_rate = MGN_5_5M; - break; - case DESC90_RATE11M: - ret_rate = MGN_11M; - break; - case DESC90_RATE6M: - ret_rate = MGN_6M; - break; - case DESC90_RATE9M: - ret_rate = MGN_9M; - break; - case DESC90_RATE12M: - ret_rate = MGN_12M; - break; - case DESC90_RATE18M: - ret_rate = MGN_18M; - break; - case DESC90_RATE24M: - ret_rate = MGN_24M; - break; - case DESC90_RATE36M: - ret_rate = MGN_36M; - break; - case DESC90_RATE48M: - ret_rate = MGN_48M; - break; - case DESC90_RATE54M: - ret_rate = MGN_54M; - break; + case DESC90_RATE1M: + ret_rate = MGN_1M; + break; + case DESC90_RATE2M: + ret_rate = MGN_2M; + break; + case DESC90_RATE5_5M: + ret_rate = MGN_5_5M; + break; + case DESC90_RATE11M: + ret_rate = MGN_11M; + break; + case DESC90_RATE6M: + ret_rate = MGN_6M; + break; + case DESC90_RATE9M: + ret_rate = MGN_9M; + break; + case DESC90_RATE12M: + ret_rate = MGN_12M; + break; + case DESC90_RATE18M: + ret_rate = MGN_18M; + break; + case DESC90_RATE24M: + ret_rate = MGN_24M; + break; + case DESC90_RATE36M: + ret_rate = MGN_36M; + break; + case DESC90_RATE48M: + ret_rate = MGN_48M; + break; + case DESC90_RATE54M: + ret_rate = MGN_54M; + break; - default: - ret_rate = 0xff; - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; + default: + ret_rate = 0xff; + RT_TRACE(COMP_RECV, + "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", + rate, bIsHT); + break; } } else { switch (rate) { - case DESC90_RATEMCS0: - ret_rate = MGN_MCS0; - break; - case DESC90_RATEMCS1: - ret_rate = MGN_MCS1; - break; - case DESC90_RATEMCS2: - ret_rate = MGN_MCS2; - break; - case DESC90_RATEMCS3: - ret_rate = MGN_MCS3; - break; - case DESC90_RATEMCS4: - ret_rate = MGN_MCS4; - break; - case DESC90_RATEMCS5: - ret_rate = MGN_MCS5; - break; - case DESC90_RATEMCS6: - ret_rate = MGN_MCS6; - break; - case DESC90_RATEMCS7: - ret_rate = MGN_MCS7; - break; - case DESC90_RATEMCS8: - ret_rate = MGN_MCS8; - break; - case DESC90_RATEMCS9: - ret_rate = MGN_MCS9; - break; - case DESC90_RATEMCS10: - ret_rate = MGN_MCS10; - break; - case DESC90_RATEMCS11: - ret_rate = MGN_MCS11; - break; - case DESC90_RATEMCS12: - ret_rate = MGN_MCS12; - break; - case DESC90_RATEMCS13: - ret_rate = MGN_MCS13; - break; - case DESC90_RATEMCS14: - ret_rate = MGN_MCS14; - break; - case DESC90_RATEMCS15: - ret_rate = MGN_MCS15; - break; - case DESC90_RATEMCS32: - ret_rate = 0x80|0x20; - break; + case DESC90_RATEMCS0: + ret_rate = MGN_MCS0; + break; + case DESC90_RATEMCS1: + ret_rate = MGN_MCS1; + break; + case DESC90_RATEMCS2: + ret_rate = MGN_MCS2; + break; + case DESC90_RATEMCS3: + ret_rate = MGN_MCS3; + break; + case DESC90_RATEMCS4: + ret_rate = MGN_MCS4; + break; + case DESC90_RATEMCS5: + ret_rate = MGN_MCS5; + break; + case DESC90_RATEMCS6: + ret_rate = MGN_MCS6; + break; + case DESC90_RATEMCS7: + ret_rate = MGN_MCS7; + break; + case DESC90_RATEMCS8: + ret_rate = MGN_MCS8; + break; + case DESC90_RATEMCS9: + ret_rate = MGN_MCS9; + break; + case DESC90_RATEMCS10: + ret_rate = MGN_MCS10; + break; + case DESC90_RATEMCS11: + ret_rate = MGN_MCS11; + break; + case DESC90_RATEMCS12: + ret_rate = MGN_MCS12; + break; + case DESC90_RATEMCS13: + ret_rate = MGN_MCS13; + break; + case DESC90_RATEMCS14: + ret_rate = MGN_MCS14; + break; + case DESC90_RATEMCS15: + ret_rate = MGN_MCS15; + break; + case DESC90_RATEMCS32: + ret_rate = 0x80 | 0x20; + break; - default: - ret_rate = 0xff; - RT_TRACE(COMP_RECV, "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", rate, bIsHT); - break; + default: + ret_rate = 0xff; + RT_TRACE(COMP_RECV, + "HwRateToMRate90(): Non supported Rate [%x], bIsHT = %d!!!\n", + rate, bIsHT); + break; } } @@ -3679,13 +3947,12 @@ static void UpdateRxPktTimeStamp8190(struct net_device *dev, } } -//by amy 080606 - -static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. +/* 0-100 index. */ +static long rtl819x_translate_todbm(u8 signal_strength_index) { - long signal_power; // in dBm. + long signal_power; /* in dBm. */ - // Translate to dBm (x=0.5y-95). + /* Translate to dBm (x=0.5y-95). */ signal_power = (long)((signal_strength_index + 1) >> 1); signal_power -= 95; @@ -3693,10 +3960,11 @@ static long rtl819x_translate_todbm(u8 signal_strength_index)// 0-100 index. } -/* 2008/01/22 MH We can not declare RSSI/EVM total value of sliding window to - be a local static. Otherwise, it may increase when we return from S3/S4. The - value will be kept in memory or disk. Declare the value in the adaptor - and it will be reinitialized when returned from S3/S4. */ +/* We can not declare RSSI/EVM total value of sliding window to + * be a local static. Otherwise, it may increase when we return from S3/S4. The + * value will be kept in memory or disk. Declare the value in the adaptor + * and it will be reinitialized when returned from S3/S4. + */ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, struct ieee80211_rx_stats *pprevious_stats, struct ieee80211_rx_stats *pcurrent_stats) @@ -3708,23 +3976,24 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, static u32 slide_evm_index, slide_evm_statistics; static u32 last_rssi, last_evm; - static u32 slide_beacon_adc_pwdb_index, slide_beacon_adc_pwdb_statistics; + static u32 slide_beacon_adc_pwdb_index; + static u32 slide_beacon_adc_pwdb_statistics; static u32 last_beacon_adc_pwdb; - struct ieee80211_hdr_3addr *hdr; + struct rtl_80211_hdr_3addr *hdr; u16 sc; unsigned int frag, seq; - hdr = (struct ieee80211_hdr_3addr *)buffer; + + hdr = (struct rtl_80211_hdr_3addr *)buffer; sc = le16_to_cpu(hdr->seq_ctl); frag = WLAN_GET_SEQ_FRAG(sc); seq = WLAN_GET_SEQ_SEQ(sc); - //cosa add 04292008 to record the sequence number + /* to record the sequence number */ pcurrent_stats->Seq_Num = seq; - // - // Check whether we should take the previous packet into accounting - // + + /* Check whether we should take the previous packet into accounting */ if (!pprevious_stats->bIsAMPDU) { - // if previous packet is not aggregated packet + /* if previous packet is not aggregated packet */ bcheck = true; } @@ -3735,17 +4004,17 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, } priv->stats.slide_rssi_total += pprevious_stats->SignalStrength; - priv->stats.slide_signal_strength[slide_rssi_index++] = pprevious_stats->SignalStrength; + priv->stats.slide_signal_strength[slide_rssi_index++] = + pprevious_stats->SignalStrength; if (slide_rssi_index >= PHY_RSSI_SLID_WIN_MAX) slide_rssi_index = 0; - // <1> Showed on UI for user, in dbm - tmp_val = priv->stats.slide_rssi_total/slide_rssi_statistics; + /* <1> Showed on UI for user, in dbm */ + tmp_val = priv->stats.slide_rssi_total / slide_rssi_statistics; priv->stats.signal_strength = rtl819x_translate_todbm((u8)tmp_val); pcurrent_stats->rssi = priv->stats.signal_strength; - // - // If the previous packet does not match the criteria, neglect it - // + + /* If the previous packet does not match the criteria, neglect it */ if (!pprevious_stats->bPacketMatchBSSID) { if (!pprevious_stats->bToSelfBA) return; @@ -3755,44 +4024,47 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, return; - //rtl8190_process_cck_rxpathsel(priv,pprevious_stats);//only rtl8190 supported + /* only rtl8190 supported + * rtl8190_process_cck_rxpathsel(priv,pprevious_stats); + */ - // - // Check RSSI - // + /* Check RSSI */ priv->stats.num_process_phyinfo++; /* record the general signal strength to the sliding window. */ - // <2> Showed on UI for engineering - // hardware does not provide rssi information for each rf path in CCK - if (!pprevious_stats->bIsCCK && (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) { + /* <2> Showed on UI for engineering + * hardware does not provide rssi information for each rf path in CCK + */ + if (!pprevious_stats->bIsCCK && + (pprevious_stats->bPacketToSelf || pprevious_stats->bToSelfBA)) { for (rfpath = RF90_PATH_A; rfpath < priv->NumTotalRFPath; rfpath++) { - if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, rfpath)) + if (!rtl8192_phy_CheckIsLegalRFPath( + priv->ieee80211->dev, rfpath)) continue; - //Fixed by Jacken 2008-03-20 if (priv->stats.rx_rssi_percentage[rfpath] == 0) - priv->stats.rx_rssi_percentage[rfpath] = pprevious_stats->RxMIMOSignalStrength[rfpath]; + priv->stats.rx_rssi_percentage[rfpath] = + pprevious_stats->RxMIMOSignalStrength[rfpath]; if (pprevious_stats->RxMIMOSignalStrength[rfpath] > priv->stats.rx_rssi_percentage[rfpath]) { priv->stats.rx_rssi_percentage[rfpath] = - ((priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor); priv->stats.rx_rssi_percentage[rfpath] = priv->stats.rx_rssi_percentage[rfpath] + 1; } else { priv->stats.rx_rssi_percentage[rfpath] = - ((priv->stats.rx_rssi_percentage[rfpath]*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalStrength[rfpath])) /(Rx_Smooth_Factor); + ((priv->stats.rx_rssi_percentage[rfpath] * (Rx_Smooth_Factor - 1)) + + (pprevious_stats->RxMIMOSignalStrength[rfpath])) / (Rx_Smooth_Factor); } - RT_TRACE(COMP_DBG, "priv->stats.rx_rssi_percentage[rfPath] = %d \n", priv->stats.rx_rssi_percentage[rfpath]); + RT_TRACE(COMP_DBG, + "priv->stats.rx_rssi_percentage[rfPath] = %d\n", + priv->stats.rx_rssi_percentage[rfpath]); } } - // - // Check PWDB. - // + /* Check PWDB. */ RT_TRACE(COMP_RXDESC, "Smooth %s PWDB = %d\n", pprevious_stats->bIsCCK ? "CCK" : "OFDM", pprevious_stats->RxPWDBAll); @@ -3809,7 +4081,7 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, slide_beacon_adc_pwdb_index++; if (slide_beacon_adc_pwdb_index >= PHY_Beacon_RSSI_SLID_WIN_MAX) slide_beacon_adc_pwdb_index = 0; - pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total/slide_beacon_adc_pwdb_statistics; + pprevious_stats->RxPWDBAll = priv->stats.Slide_Beacon_Total / slide_beacon_adc_pwdb_statistics; if (pprevious_stats->RxPWDBAll >= 3) pprevious_stats->RxPWDBAll -= 3; } @@ -3819,56 +4091,67 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, pprevious_stats->RxPWDBAll); - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) { - if (priv->undecorated_smoothed_pwdb < 0) /* initialize */ - priv->undecorated_smoothed_pwdb = pprevious_stats->RxPWDBAll; + if (pprevious_stats->bPacketToSelf || + pprevious_stats->bPacketBeacon || + pprevious_stats->bToSelfBA) { + if (priv->undecorated_smoothed_pwdb < 0) + /* initialize */ + priv->undecorated_smoothed_pwdb = + pprevious_stats->RxPWDBAll; if (pprevious_stats->RxPWDBAll > (u32)priv->undecorated_smoothed_pwdb) { priv->undecorated_smoothed_pwdb = - (((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + (((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) + + (pprevious_stats->RxPWDBAll)) / (Rx_Smooth_Factor); priv->undecorated_smoothed_pwdb = priv->undecorated_smoothed_pwdb + 1; } else { priv->undecorated_smoothed_pwdb = - (((priv->undecorated_smoothed_pwdb)*(Rx_Smooth_Factor-1)) + - (pprevious_stats->RxPWDBAll)) /(Rx_Smooth_Factor); + (((priv->undecorated_smoothed_pwdb) * (Rx_Smooth_Factor - 1)) + + (pprevious_stats->RxPWDBAll)) / (Rx_Smooth_Factor); } } - // - // Check EVM - // + /* Check EVM */ /* record the general EVM to the sliding window. */ if (pprevious_stats->SignalQuality) { - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) { + if (pprevious_stats->bPacketToSelf || + pprevious_stats->bPacketBeacon || + pprevious_stats->bToSelfBA) { if (slide_evm_statistics++ >= PHY_RSSI_SLID_WIN_MAX) { slide_evm_statistics = PHY_RSSI_SLID_WIN_MAX; last_evm = priv->stats.slide_evm[slide_evm_index]; priv->stats.slide_evm_total -= last_evm; } - priv->stats.slide_evm_total += pprevious_stats->SignalQuality; + priv->stats.slide_evm_total += + pprevious_stats->SignalQuality; - priv->stats.slide_evm[slide_evm_index++] = pprevious_stats->SignalQuality; + priv->stats.slide_evm[slide_evm_index++] = + pprevious_stats->SignalQuality; if (slide_evm_index >= PHY_RSSI_SLID_WIN_MAX) slide_evm_index = 0; - // <1> Showed on UI for user, in percentage. - tmp_val = priv->stats.slide_evm_total/slide_evm_statistics; + /* <1> Showed on UI for user, in percentage. */ + tmp_val = priv->stats.slide_evm_total / + slide_evm_statistics; priv->stats.signal_quality = tmp_val; - //cosa add 10/11/2007, Showed on UI for user in Windows Vista, for Link quality. + /* Showed on UI for user in Windows Vista, + * for Link quality. + */ priv->stats.last_signal_strength_inpercent = tmp_val; } - // <2> Showed on UI for engineering - if (pprevious_stats->bPacketToSelf || pprevious_stats->bPacketBeacon || pprevious_stats->bToSelfBA) { + /* <2> Showed on UI for engineering */ + if (pprevious_stats->bPacketToSelf || + pprevious_stats->bPacketBeacon || + pprevious_stats->bToSelfBA) { for (nspatial_stream = 0; nspatial_stream < 2; nspatial_stream++) { /* 2 spatial stream */ if (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] != -1) { if (priv->stats.rx_evm_percentage[nspatial_stream] == 0) /* initialize */ priv->stats.rx_evm_percentage[nspatial_stream] = pprevious_stats->RxMIMOSignalQuality[nspatial_stream]; priv->stats.rx_evm_percentage[nspatial_stream] = - ((priv->stats.rx_evm_percentage[nspatial_stream]* (Rx_Smooth_Factor-1)) + - (pprevious_stats->RxMIMOSignalQuality[nspatial_stream]* 1)) / (Rx_Smooth_Factor); + ((priv->stats.rx_evm_percentage[nspatial_stream] * (Rx_Smooth_Factor - 1)) + + (pprevious_stats->RxMIMOSignalQuality[nspatial_stream] * 1)) / (Rx_Smooth_Factor); } } } @@ -3887,11 +4170,6 @@ static void rtl8192_process_phyinfo(struct r8192_priv *priv, u8 *buffer, * Output: NONE * * Return: 0-100 percentage - * - * Revised History: - * When Who Remark - * 05/26/2008 amy Create Version 0 porting from windows code. - * *---------------------------------------------------------------------------*/ static u8 rtl819x_query_rxpwrpercentage(char antpower) { @@ -3920,16 +4198,12 @@ static u8 rtl819x_evm_dbtopercentage(char value) ret_val = 100; return ret_val; } -// -// Description: -// We want good-looking for signal strength/quality -// 2007/7/19 01:09, by cosa. -// +/* We want good-looking for signal strength/quality */ static long rtl819x_signal_scale_mapping(long currsig) { long retsig; - // Step 1. Scale mapping. + /* Step 1. Scale mapping. */ if (currsig >= 61 && currsig <= 100) retsig = 90 + ((currsig - 60) / 4); else if (currsig >= 41 && currsig <= 60) @@ -3982,24 +4256,25 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, phy_sts_ofdm_819xusb_t *pofdm_buf; phy_sts_cck_819xusb_t *pcck_buf; phy_ofdm_rx_status_rxsc_sgien_exintfflag *prxsc; - u8 *prxpkt; - u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; - char rx_pwr[4], rx_pwr_all = 0; - char rx_snrX, rx_evmX; - u8 evm, pwdb_all; - u32 RSSI, total_rssi = 0; - u8 is_cck_rate = 0; - u8 rf_rx_num = 0; - u8 sq; + u8 *prxpkt; + u8 i, max_spatial_stream, tmp_rxsnr, tmp_rxevm, rxsc_sgien_exflg; + char rx_pwr[4], rx_pwr_all = 0; + char rx_snrX, rx_evmX; + u8 evm, pwdb_all; + u32 RSSI, total_rssi = 0; + u8 is_cck_rate = 0; + u8 rf_rx_num = 0; + u8 sq; priv->stats.numqry_phystatus++; is_cck_rate = rx_hal_is_cck_rate(pdrvinfo); - // Record it for next packet processing + /* Record it for next packet processing */ memset(precord_stats, 0, sizeof(struct ieee80211_rx_stats)); - pstats->bPacketMatchBSSID = precord_stats->bPacketMatchBSSID = bpacket_match_bssid; + pstats->bPacketMatchBSSID = + precord_stats->bPacketMatchBSSID = bpacket_match_bssid; pstats->bPacketToSelf = precord_stats->bPacketToSelf = bpacket_toself; pstats->bIsCCK = precord_stats->bIsCCK = is_cck_rate; pstats->bPacketBeacon = precord_stats->bPacketBeacon = bPacketBeacon; @@ -4020,13 +4295,11 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, precord_stats->RxMIMOSignalQuality[1] = -1; if (is_cck_rate) { - // - // (1)Hardware does not provide RSSI for CCK - // + /* (1)Hardware does not provide RSSI for CCK */ - // - // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) - // + /* (2)PWDB, Average PWDB cacluated by hardware + * (for rate adaptive) + */ u8 report; priv->stats.numqry_phystatusCCK++; @@ -4035,9 +4308,6 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, report = pcck_buf->cck_agc_rpt & 0xc0; report >>= 6; switch (report) { - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is -38 , -26 , -14 , -2 - //Fixed value is -35 , -23 , -11 , 6 case 0x3: rx_pwr_all = -35 - (pcck_buf->cck_agc_rpt & 0x3e); break; @@ -4056,16 +4326,16 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, report >>= 5; switch (report) { case 0x3: - rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = -35 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1); break; case 0x2: - rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = -23 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1); break; case 0x1: - rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = -11 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1); break; case 0x0: - rx_pwr_all = 6 - ((pcck_buf->cck_agc_rpt & 0x1f)<<1); + rx_pwr_all = 6 - ((pcck_buf->cck_agc_rpt & 0x1f) << 1); break; } } @@ -4074,9 +4344,7 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RecvSignalPower = pwdb_all; - // - // (3) Get Signal Quality (EVM) - // + /* (3) Get Signal Quality (EVM) */ if (pstats->RxPWDBAll > 40) { sq = 100; @@ -4088,32 +4356,33 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, else if (pcck_buf->sq_rpt < 20) sq = 100; else - sq = ((64-sq) * 100) / 44; + sq = ((64 - sq) * 100) / 44; } pstats->SignalQuality = precord_stats->SignalQuality = sq; - pstats->RxMIMOSignalQuality[0] = precord_stats->RxMIMOSignalQuality[0] = sq; - pstats->RxMIMOSignalQuality[1] = precord_stats->RxMIMOSignalQuality[1] = -1; + pstats->RxMIMOSignalQuality[0] = + precord_stats->RxMIMOSignalQuality[0] = sq; + pstats->RxMIMOSignalQuality[1] = + precord_stats->RxMIMOSignalQuality[1] = -1; } else { priv->stats.numqry_phystatusHT++; - // - // (1)Get RSSI for HT rate - // + + /* (1)Get RSSI for HT rate */ for (i = RF90_PATH_A; i < priv->NumTotalRFPath; i++) { - // 2008/01/30 MH we will judge RF RX path now. + /* We will judge RF RX path now. */ if (priv->brfpath_rxenable[i]) rf_rx_num++; else continue; - if (!rtl8192_phy_CheckIsLegalRFPath(priv->ieee80211->dev, i)) + if (!rtl8192_phy_CheckIsLegalRFPath( + priv->ieee80211->dev, i)) continue; - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is 106 - rx_pwr[i] = ((pofdm_buf->trsw_gain_X[i]&0x3F)*2) - 106; + rx_pwr[i] = + ((pofdm_buf->trsw_gain_X[i] & 0x3F) * 2) - 106; - //Get Rx snr value in DB + /* Get Rx snr value in DB */ tmp_rxsnr = pofdm_buf->rxsnr_X[i]; rx_snrX = (char)(tmp_rxsnr); rx_snrX /= 2; @@ -4124,69 +4393,87 @@ static void rtl8192_query_rxphystatus(struct r8192_priv *priv, total_rssi += RSSI; /* Record Signal Strength for next packet */ - pstats->RxMIMOSignalStrength[i] = (u8) RSSI; - precord_stats->RxMIMOSignalStrength[i] = (u8) RSSI; + pstats->RxMIMOSignalStrength[i] = (u8)RSSI; + precord_stats->RxMIMOSignalStrength[i] = (u8)RSSI; } - // - // (2)PWDB, Average PWDB cacluated by hardware (for rate adaptive) - // - //Fixed by Jacken from Bryant 2008-03-20 - //Original value is 106 - rx_pwr_all = (((pofdm_buf->pwdb_all) >> 1)& 0x7f) -106; + /* (2)PWDB, Average PWDB cacluated by hardware + * (for rate adaptive) + */ + rx_pwr_all = (((pofdm_buf->pwdb_all) >> 1) & 0x7f) - 106; pwdb_all = rtl819x_query_rxpwrpercentage(rx_pwr_all); pstats->RxPWDBAll = precord_stats->RxPWDBAll = pwdb_all; pstats->RxPower = precord_stats->RxPower = rx_pwr_all; - // - // (3)EVM of HT rate - // + /* (3)EVM of HT rate */ if (pdrvinfo->RxHT && pdrvinfo->RxRate >= DESC90_RATEMCS8 && pdrvinfo->RxRate <= DESC90_RATEMCS15) - max_spatial_stream = 2; //both spatial stream make sense + /* both spatial stream make sense */ + max_spatial_stream = 2; else - max_spatial_stream = 1; //only spatial stream 1 makes sense + /* only spatial stream 1 makes sense */ + max_spatial_stream = 1; for (i = 0; i < max_spatial_stream; i++) { tmp_rxevm = pofdm_buf->rxevm_X[i]; rx_evmX = (char)(tmp_rxevm); - // Do not use shift operation like "rx_evmX >>= 1" because the compiler of free build environment - // will set the 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. - rx_evmX /= 2; //dbm + /* Do not use shift operation like "rx_evmX >>= 1" + * because the compiler of free build environment will + * set the 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. + */ + rx_evmX /= 2; /* dbm */ evm = rtl819x_evm_dbtopercentage(rx_evmX); - if (i == 0) /* Fill value in RFD, Get the first spatial stream only */ - pstats->SignalQuality = precord_stats->SignalQuality = (u8)(evm & 0xff); - pstats->RxMIMOSignalQuality[i] = precord_stats->RxMIMOSignalQuality[i] = (u8)(evm & 0xff); + if (i == 0) + /* Fill value in RFD, Get the first spatial + * stream only + */ + pstats->SignalQuality = + precord_stats->SignalQuality = + (u8)(evm & 0xff); + pstats->RxMIMOSignalQuality[i] = + precord_stats->RxMIMOSignalQuality[i] = + (u8)(evm & 0xff); } /* record rx statistics for debug */ rxsc_sgien_exflg = pofdm_buf->rxsc_sgien_exflg; - prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *)&rxsc_sgien_exflg; + prxsc = (phy_ofdm_rx_status_rxsc_sgien_exintfflag *) + &rxsc_sgien_exflg; if (pdrvinfo->BW) /* 40M channel */ - priv->stats.received_bwtype[1+prxsc->rxsc]++; - else //20M channel + priv->stats.received_bwtype[1 + prxsc->rxsc]++; + else /* 20M channel */ priv->stats.received_bwtype[0]++; } - //UI BSS List signal strength(in percentage), make it good looking, from 0~100. - //It is assigned to the BSS List in GetValueFromBeaconOrProbeRsp(). + /* 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) { - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)pwdb_all)); + pstats->SignalStrength = + precord_stats->SignalStrength = + (u8)(rtl819x_signal_scale_mapping((long)pwdb_all)); } else { - // We can judge RX path number now. - if (rf_rx_num != 0) - pstats->SignalStrength = precord_stats->SignalStrength = (u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num))); + /* We can judge RX path number now. */ + if (rf_rx_num != 0) { + pstats->SignalStrength = + precord_stats->SignalStrength = + (u8)(rtl819x_signal_scale_mapping((long)(total_rssi /= rf_rx_num))); + } } } /* QueryRxPhyStatus8190Pci */ -static void rtl8192_record_rxdesc_forlateruse(struct ieee80211_rx_stats *psrc_stats, - struct ieee80211_rx_stats *ptarget_stats) +static void rtl8192_record_rxdesc_forlateruse( + struct ieee80211_rx_stats *psrc_stats, + struct ieee80211_rx_stats *ptarget_stats) { ptarget_stats->bIsAMPDU = psrc_stats->bIsAMPDU; ptarget_stats->bFirstMPDU = psrc_stats->bFirstMPDU; @@ -4198,17 +4485,19 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, struct ieee80211_rx_stats *pstats, rx_drvinfo_819x_usb *pdrvinfo) { - // TODO: We must only check packet for current MAC address. Not finish - rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; + /* TODO: We must only check packet for current MAC address. + * Not finish + */ + struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; struct net_device *dev = info->dev; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); bool bpacket_match_bssid, bpacket_toself; bool bPacketBeacon = false, bToSelfBA = false; static struct ieee80211_rx_stats previous_stats; - struct ieee80211_hdr_3addr *hdr;//by amy + struct rtl_80211_hdr_3addr *hdr; u16 fc, type; - // Get Signal Quality for only RX data queue (but not command queue) + /* Get Signal Quality for only RX data queue (but not command queue) */ u8 *tmp_buf; u8 *praddr; @@ -4216,7 +4505,7 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, /* Get MAC frame start address. */ tmp_buf = (u8 *)skb->data; - hdr = (struct ieee80211_hdr_3addr *)tmp_buf; + hdr = (struct rtl_80211_hdr_3addr *)tmp_buf; fc = le16_to_cpu(hdr->frame_ctl); type = WLAN_FC_GET_TYPE(fc); praddr = hdr->addr1; @@ -4225,7 +4514,8 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, bpacket_match_bssid = (IEEE80211_FTYPE_CTL != type) && (eqMacAddr(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 & (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr)); + bpacket_toself = bpacket_match_bssid & + (eqMacAddr(praddr, priv->ieee80211->dev->dev_addr)); if (WLAN_FC_GET_FRAMETYPE(fc) == IEEE80211_STYPE_BEACON) bPacketBeacon = true; @@ -4240,13 +4530,14 @@ static void TranslateRxSignalStuff819xUsb(struct sk_buff *skb, priv->stats.numpacket_matchbssid++; if (bpacket_toself) priv->stats.numpacket_toself++; - // - // Process PHY information for previous packet (RSSI/PWDB/EVM) - // - // Because phy information is contained in the last packet of AMPDU only, so driver - // should process phy information of previous packet + /* Process PHY information for previous packet (RSSI/PWDB/EVM) + * Because phy information is contained in the last packet of AMPDU + * only, so driver should process phy information of previous packet + */ rtl8192_process_phyinfo(priv, tmp_buf, &previous_stats, pstats); - rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats, bpacket_match_bssid, bpacket_toself, bPacketBeacon, bToSelfBA); + rtl8192_query_rxphystatus(priv, pstats, pdrvinfo, &previous_stats, + bpacket_match_bssid, bpacket_toself, + bPacketBeacon, bToSelfBA); rtl8192_record_rxdesc_forlateruse(pstats, &previous_stats); } @@ -4270,9 +4561,11 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev, struct ieee80211_rx_stats *stats) { struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); - u32 rcvType = 1; //0: Total, 1:OK, 2:CRC, 3:ICV + /* 0: Total, 1:OK, 2:CRC, 3:ICV */ + u32 rcvType = 1; u32 rateIndex; - u32 preamble_guardinterval; //1: short preamble/GI, 0: long preamble/GI + /* 1: short preamble/GI, 0: long preamble/GI */ + u32 preamble_guardinterval; if (stats->bCRC) @@ -4281,9 +4574,9 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev, rcvType = 3; if (stats->bShortPreamble) - preamble_guardinterval = 1;// short + preamble_guardinterval = 1; /* short */ else - preamble_guardinterval = 0;// long + preamble_guardinterval = 0; /* long */ switch (stats->rate) { /* CCK rate */ @@ -4378,7 +4671,7 @@ UpdateReceivedRateHistogramStatistics8190(struct net_device *dev, break; } priv->stats.received_preamble_GI[preamble_guardinterval][rateIndex]++; - priv->stats.received_rate_histogram[0][rateIndex]++; //total + priv->stats.received_rate_histogram[0][rateIndex]++; /* total */ priv->stats.received_rate_histogram[rcvType][rateIndex]++; } @@ -4387,14 +4680,12 @@ static void query_rxdesc_status(struct sk_buff *skb, struct ieee80211_rx_stats *stats, bool bIsRxAggrSubframe) { - rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; + struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; struct net_device *dev = info->dev; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); rx_drvinfo_819x_usb *driver_info = NULL; - // - //Get Rx Descriptor Information - // + /* Get Rx Descriptor Information */ rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data; stats->Length = desc->Length; @@ -4402,36 +4693,44 @@ static void query_rxdesc_status(struct sk_buff *skb, stats->RxBufShift = 0; stats->bICV = desc->ICV; stats->bCRC = desc->CRC32; - stats->bHwError = stats->bCRC|stats->bICV; + stats->bHwError = stats->bCRC | stats->bICV; /* RTL8190 set this bit to indicate that Hw does not decrypt packet */ stats->Decrypted = !desc->SWDec; - if ((priv->ieee80211->pHTInfo->bCurrentHTSupport == true) && (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP)) + if ((priv->ieee80211->pHTInfo->bCurrentHTSupport) && + (priv->ieee80211->pairwise_key_type == KEY_TYPE_CCMP)) stats->bHwError = false; else - stats->bHwError = stats->bCRC|stats->bICV; + stats->bHwError = stats->bCRC | stats->bICV; if (stats->Length < 24 || stats->Length > MAX_8192U_RX_SIZE) stats->bHwError |= 1; - // - //Get Driver Info - // - // TODO: Need to verify it on FGPA platform - //Driver info are written to the RxBuffer following rx desc + /* Get Driver Info */ + /* TODO: Need to verify it on FGPA platform + * Driver info are written to the RxBuffer following rx desc + */ if (stats->RxDrvInfoSize != 0) { - driver_info = (rx_drvinfo_819x_usb *)(skb->data + sizeof(rx_desc_819x_usb) + - stats->RxBufShift); + driver_info = (rx_drvinfo_819x_usb *)( + skb->data + + sizeof(rx_desc_819x_usb) + + stats->RxBufShift + ); /* unit: 0.5M */ /* TODO */ if (!stats->bHwError) { u8 ret_rate; - ret_rate = HwRateToMRate90(driver_info->RxHT, driver_info->RxRate); + + ret_rate = HwRateToMRate90(driver_info->RxHT, + driver_info->RxRate); if (ret_rate == 0xff) { - // Abnormal Case: Receive CRC OK packet with Rx descriptor indicating non supported rate. - // Special Error Handling here, 2008.05.16, by Emily + /* Abnormal Case: Receive CRC OK packet with Rx + * descriptor indicating non supported rate. + * Special Error Handling here + */ stats->bHwError = 1; - stats->rate = MGN_1M; //Set 1M rate by default + /* Set 1M rate by default */ + stats->rate = MGN_1M; } else { stats->rate = ret_rate; } @@ -4445,25 +4744,22 @@ static void query_rxdesc_status(struct sk_buff *skb, UpdateReceivedRateHistogramStatistics8190(dev, stats); stats->bIsAMPDU = (driver_info->PartAggr == 1); - stats->bFirstMPDU = (driver_info->PartAggr == 1) && (driver_info->FirstAGGR == 1); + stats->bFirstMPDU = (driver_info->PartAggr == 1) && + (driver_info->FirstAGGR == 1); stats->TimeStampLow = driver_info->TSFL; - // xiong mask it, 070514 UpdateRxPktTimeStamp8190(dev, stats); - // - // Rx A-MPDU - // + /* Rx A-MPDU */ if (driver_info->FirstAGGR == 1 || driver_info->PartAggr == 1) - RT_TRACE(COMP_RXDESC, "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n", + RT_TRACE(COMP_RXDESC, + "driver_info->FirstAGGR = %d, driver_info->PartAggr = %d\n", driver_info->FirstAGGR, driver_info->PartAggr); } skb_pull(skb, sizeof(rx_desc_819x_usb)); - // - // Get Total offset of MPDU Frame Body - // + /* Get Total offset of MPDU Frame Body */ if ((stats->RxBufShift + stats->RxDrvInfoSize) > 0) { stats->bShift = 1; skb_pull(skb, stats->RxBufShift + stats->RxDrvInfoSize); @@ -4477,17 +4773,17 @@ static void query_rxdesc_status(struct sk_buff *skb, static void rtl8192_rx_nomal(struct sk_buff *skb) { - rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; + struct rtl8192_rx_info *info = (struct rtl8192_rx_info *)skb->cb; struct net_device *dev = info->dev; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct ieee80211_rx_stats stats = { .signal = 0, - .noise = -98, + .noise = 0x100 - 98, .rate = 0, .freq = IEEE80211_24GHZ_BAND, }; u32 rx_pkt_len = 0; - struct ieee80211_hdr_1addr *ieee80211_hdr = NULL; + struct rtl_80211_hdr_1addr *ieee80211_hdr = NULL; bool unicast_packet = false; /* 20 is for ps-poll */ @@ -4500,12 +4796,12 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) skb_trim(skb, skb->len - 4/*sCrcLng*/); rx_pkt_len = skb->len; - ieee80211_hdr = (struct ieee80211_hdr_1addr *)skb->data; + ieee80211_hdr = (struct rtl_80211_hdr_1addr *)skb->data; unicast_packet = false; if (is_broadcast_ether_addr(ieee80211_hdr->addr1)) { - //TODO + /* TODO */ } else if (is_multicast_ether_addr(ieee80211_hdr->addr1)) { - //TODO + /* TODO */ } else { /* unicast packet */ unicast_packet = true; @@ -4526,28 +4822,30 @@ static void rtl8192_rx_nomal(struct sk_buff *skb) } -static void rtl819xusb_process_received_packet(struct net_device *dev, - struct ieee80211_rx_stats *pstats) +static void rtl819xusb_process_received_packet( + struct net_device *dev, + struct ieee80211_rx_stats *pstats) { u8 *frame; u16 frame_len = 0; struct r8192_priv *priv = ieee80211_priv(dev); - // Get shifted bytes of Starting address of 802.11 header. 2006.09.28, by Emily - //porting by amy 080508 + /* Get shifted bytes of Starting address of 802.11 header. */ pstats->virtual_address += get_rxpacket_shiftbytes_819xusb(pstats); frame = pstats->virtual_address; frame_len = pstats->packetlength; -#ifdef TODO // by amy about HCT +#ifdef TODO /* about HCT */ if (!Adapter->bInHctTest) CountRxErrStatistics(Adapter, pRfd); #endif -#ifdef ENABLE_PS //by amy for adding ps function in future +#ifdef ENABLE_PS /* for adding ps function in future */ RT_RF_POWER_STATE rtState; - // When RF is off, we should not count the packet for hw/sw synchronize - // reason, ie. there may be a duration while sw switch is changed and hw - // switch is being changed. 2006.12.04, by shien chang. - Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, (u8 *)(&rtState)); + /* When RF is off, we should not count the packet for hw/sw synchronize + * reason, ie. there may be a duration while sw switch is changed and + * hw switch is being changed. + */ + Adapter->HalFunc.GetHwRegHandler(Adapter, HW_VAR_RF_STATE, + (u8 *)(&rtState)); if (rtState == eRfOff) return; #endif @@ -4556,8 +4854,7 @@ static void rtl819xusb_process_received_packet(struct net_device *dev, #ifdef TODO RmMonitorSignalStrength(Adapter, pRfd); #endif - /* 2007/01/16 MH Add RX command packet handle here. */ - /* 2007/03/01 MH We have to release RFD and return if rx pkt is cmd pkt. */ + /* We have to release RFD and return if rx pkt is cmd pkt. */ if (rtl819xusb_rx_command_packet(dev, pstats)) return; @@ -4573,14 +4870,12 @@ static void query_rx_cmdpkt_desc_status(struct sk_buff *skb, { rx_desc_819x_usb *desc = (rx_desc_819x_usb *)skb->data; - // - //Get Rx Descriptor Information - // + /* Get Rx Descriptor Information */ stats->virtual_address = (u8 *)skb->data; stats->Length = desc->Length; stats->RxDrvInfoSize = 0; stats->RxBufShift = 0; - stats->packetlength = stats->Length-scrclng; + stats->packetlength = stats->Length - scrclng; stats->fraglength = stats->packetlength; stats->fragoffset = 0; stats->ntotalfrag = 1; @@ -4594,7 +4889,7 @@ static void rtl8192_rx_cmd(struct sk_buff *skb) /* TODO */ struct ieee80211_rx_stats stats = { .signal = 0, - .noise = -98, + .noise = 0x100 - 98, .rate = 0, .freq = IEEE80211_24GHZ_BAND, }; @@ -4602,12 +4897,9 @@ static void rtl8192_rx_cmd(struct sk_buff *skb) if ((skb->len >= (20 + sizeof(rx_desc_819x_usb))) && (skb->len < RX_URB_SIZE)) { query_rx_cmdpkt_desc_status(skb, &stats); - // this is to be done by amy 080508 prfd->queue_id = 1; - + /* prfd->queue_id = 1; */ - // - // Process the command packet received. - // + /* Process the command packet received. */ rtl819xusb_process_received_packet(dev, &stats); @@ -4615,7 +4907,7 @@ static void rtl8192_rx_cmd(struct sk_buff *skb) } } -void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) +static void rtl8192_irq_rx_tasklet(struct r8192_priv *priv) { struct sk_buff *skb; struct rtl8192_rx_info *info; @@ -4672,6 +4964,7 @@ static int rtl8192_usb_probe(struct usb_interface *intf, struct r8192_priv *priv = NULL; struct usb_device *udev = interface_to_usbdev(intf); int ret; + RT_TRACE(COMP_INIT, "Oops: i'm coming\n"); dev = alloc_ieee80211(sizeof(struct r8192_priv)); @@ -4686,14 +4979,16 @@ static int rtl8192_usb_probe(struct usb_interface *intf, dev->netdev_ops = &rtl8192_netdev_ops; - dev->wireless_handlers = (struct iw_handler_def *) &r8192_wx_handlers_def; + dev->wireless_handlers = + (struct iw_handler_def *)&r8192_wx_handlers_def; dev->type = ARPHRD_ETHER; - dev->watchdog_timeo = HZ*3; //modified by john, 0805 + dev->watchdog_timeo = HZ * 3; if (dev_alloc_name(dev, ifname) < 0) { - RT_TRACE(COMP_INIT, "Oops: devname already taken! Trying wlan%%d...\n"); + RT_TRACE(COMP_INIT, + "Oops: devname already taken! Trying wlan%%d...\n"); ifname = "wlan%d"; dev_alloc_name(dev, ifname); } @@ -4732,8 +5027,10 @@ fail: return ret; } -//detach all the work and timer structure declared or inititialize in r8192U_init function. -void rtl8192_cancel_deferred_work(struct r8192_priv *priv) +/* detach all the work and timer structure declared or inititialize + * in r8192U_init function. + */ +static void rtl8192_cancel_deferred_work(struct r8192_priv *priv) { cancel_work_sync(&priv->reset_wq); @@ -4746,13 +5043,13 @@ void rtl8192_cancel_deferred_work(struct r8192_priv *priv) static void rtl8192_usb_disconnect(struct usb_interface *intf) { struct net_device *dev = usb_get_intfdata(intf); - struct r8192_priv *priv = ieee80211_priv(dev); - if (dev) { + if (dev) { unregister_netdev(dev); - RT_TRACE(COMP_DOWN, "=============>wlan driver to be removed\n"); + RT_TRACE(COMP_DOWN, + "=============>wlan driver to be removed\n"); rtl8192_proc_remove_one(dev); rtl8192_down(dev); @@ -4761,7 +5058,6 @@ static void rtl8192_usb_disconnect(struct usb_interface *intf) rtl8192_usb_deleteendpoints(dev); destroy_workqueue(priv->priv_wq); mdelay(10); - } free_ieee80211(dev); RT_TRACE(COMP_DOWN, "wlan driver removed\n"); @@ -4838,6 +5134,7 @@ void EnableHWSecurityConfig8192(struct net_device *dev) u8 SECR_value = 0x0; struct r8192_priv *priv = (struct r8192_priv *)ieee80211_priv(dev); struct ieee80211_device *ieee = priv->ieee80211; + SECR_value = SCR_TxEncEnable | SCR_RxDecEnable; if (((KEY_TYPE_WEP40 == ieee->pairwise_key_type) || (KEY_TYPE_WEP104 == ieee->pairwise_key_type)) && (priv->ieee80211->auth_mode != 2)) { SECR_value |= SCR_RxUseDK; @@ -4846,17 +5143,23 @@ void EnableHWSecurityConfig8192(struct net_device *dev) SECR_value |= SCR_RxUseDK; SECR_value |= SCR_TxUseDK; } - //add HWSec active enable here. - //default using hwsec. when peer AP is in N mode only and pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates it), use software security. when peer AP is in b,g,n mode mixed and pairwise_key_type is none_aes, use g mode hw security. WB on 2008.7.4 + /* add HWSec active enable here. + * default using hwsec. when peer AP is in N mode only and + * pairwise_key_type is none_aes(which HT_IOT_ACT_PURE_N_MODE indicates + * it), use software security. when peer AP is in b,g,n mode mixed and + * pairwise_key_type is none_aes, use g mode hw security. + */ ieee->hwsec_active = 1; - if ((ieee->pHTInfo->IOTAction&HT_IOT_ACT_PURE_N_MODE) || !hwwep) { /* add hwsec_support flag to totol control hw_sec on/off */ + /* add hwsec_support flag to totol control hw_sec on/off */ + if ((ieee->pHTInfo->IOTAction & HT_IOT_ACT_PURE_N_MODE) || !hwwep) { ieee->hwsec_active = 0; SECR_value &= ~SCR_RxDecEnable; } - RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", __func__, - ieee->hwsec_active, ieee->pairwise_key_type, SECR_value); + RT_TRACE(COMP_SEC, "%s:, hwsec:%d, pairwise_key:%d, SECR_value:%x\n", + __func__, ieee->hwsec_active, ieee->pairwise_key_type, + SECR_value); write_nic_byte(dev, SECR, SECR_value); } @@ -4868,39 +5171,42 @@ void setKey(struct net_device *dev, u8 EntryNo, u8 KeyIndex, u16 KeyType, u32 TargetContent = 0; u16 usConfig = 0; u8 i; + if (EntryNo >= TOTAL_CAM_ENTRY) RT_TRACE(COMP_ERR, "cam entry exceeds in setKey()\n"); - RT_TRACE(COMP_SEC, "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", dev, EntryNo, KeyIndex, KeyType, MacAddr); + RT_TRACE(COMP_SEC, + "====>to setKey(), dev:%p, EntryNo:%d, KeyIndex:%d, KeyType:%d, MacAddr%pM\n", + dev, EntryNo, KeyIndex, KeyType, MacAddr); if (DefaultKey) - usConfig |= BIT15 | (KeyType<<2); + usConfig |= BIT(15) | (KeyType << 2); else - usConfig |= BIT15 | (KeyType<<2) | KeyIndex; + usConfig |= BIT(15) | (KeyType << 2) | KeyIndex; for (i = 0; i < CAM_CONTENT_COUNT; i++) { - TargetCommand = i+CAM_CONTENT_COUNT*EntryNo; - TargetCommand |= BIT31|BIT16; + TargetCommand = i + CAM_CONTENT_COUNT * EntryNo; + TargetCommand |= BIT(31) | BIT(16); if (i == 0) { /* MAC|Config */ - TargetContent = (u32)(*(MacAddr+0)) << 16| - (u32)(*(MacAddr+1)) << 24| + TargetContent = (u32)(*(MacAddr + 0)) << 16 | + (u32)(*(MacAddr + 1)) << 24 | (u32)usConfig; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else if (i == 1) { /* MAC */ - TargetContent = (u32)(*(MacAddr+2)) | - (u32)(*(MacAddr+3)) << 8| - (u32)(*(MacAddr+4)) << 16| - (u32)(*(MacAddr+5)) << 24; + TargetContent = (u32)(*(MacAddr + 2)) | + (u32)(*(MacAddr + 3)) << 8 | + (u32)(*(MacAddr + 4)) << 16 | + (u32)(*(MacAddr + 5)) << 24; write_nic_dword(dev, WCAMI, TargetContent); write_nic_dword(dev, RWCAM, TargetCommand); } else { - //Key Material + /* Key Material */ if (KeyContent != NULL) { - write_nic_dword(dev, WCAMI, (u32)(*(KeyContent+i-2))); + write_nic_dword(dev, WCAMI, (u32)(*(KeyContent + i - 2))); write_nic_dword(dev, RWCAM, TargetCommand); } } diff --git a/kernel/drivers/staging/rtl8192u/r8192U_dm.c b/kernel/drivers/staging/rtl8192u/r8192U_dm.c index 12dd19e11..375ec96b9 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U_dm.c +++ b/kernel/drivers/staging/rtl8192u/r8192U_dm.c @@ -120,7 +120,7 @@ static void dm_ctstoself(struct net_device *dev); * Prepare SW resource for HW dynamic mechanism. * * Assumption: - * This function is only invoked at driver intialization once. + * This function is only invoked at driver initialization once. */ void init_hal_dm(struct net_device *dev) { @@ -325,21 +325,26 @@ static void dm_check_rate_adaptive(struct net_device *dev) (!pHTInfo->bCurTxBW40MHz && pHTInfo->bCurShortGI20MHz); pra->upper_rssi_threshold_ratr = - (pra->upper_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31:0); + (pra->upper_rssi_threshold_ratr & (~BIT(31))) | + ((bshort_gi_enabled) ? BIT(31) : 0); pra->middle_rssi_threshold_ratr = - (pra->middle_rssi_threshold_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31:0); + (pra->middle_rssi_threshold_ratr & (~BIT(31))) | + ((bshort_gi_enabled) ? BIT(31) : 0); if (priv->CurrentChannelBW != HT_CHANNEL_WIDTH_20) { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_40M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31:0); + (pra->low_rssi_threshold_ratr_40M & (~BIT(31))) | + ((bshort_gi_enabled) ? BIT(31) : 0); } else { pra->low_rssi_threshold_ratr = - (pra->low_rssi_threshold_ratr_20M & (~BIT31)) | ((bshort_gi_enabled) ? BIT31:0); + (pra->low_rssi_threshold_ratr_20M & (~BIT(31))) | + ((bshort_gi_enabled) ? BIT(31) : 0); } /* cosa add for test */ pra->ping_rssi_ratr = - (pra->ping_rssi_ratr & (~BIT31)) | ((bshort_gi_enabled) ? BIT31:0); + (pra->ping_rssi_ratr & (~BIT(31))) | + ((bshort_gi_enabled) ? BIT(31) : 0); /* 2007/10/08 MH We support RA smooth scheme now. When it is the first time to link with AP. We will not change upper/lower threshold. If @@ -438,7 +443,7 @@ static void dm_bandwidth_autoswitch(struct net_device *dev) if (priv->CurrentChannelBW == HT_CHANNEL_WIDTH_20 || !priv->ieee80211->bandwidth_auto_switch.bautoswitch_enable) return; - if (priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz == false) { /* If send packets in 40 Mhz in 20/40 */ + if (!priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz) { /* If send packets in 40 Mhz in 20/40 */ if (priv->undecorated_smoothed_pwdb <= priv->ieee80211->bandwidth_auto_switch.threshold_40Mhzto20Mhz) priv->ieee80211->bandwidth_auto_switch.bforced_tx20Mhz = true; } else { /* in force send packets in 20 Mhz in 20/40 */ @@ -563,7 +568,7 @@ static void dm_TXPowerTrackingCallback_TSSI(struct net_device *dev) break; } } - if (viviflag == true) { + if (viviflag) { write_nic_byte(dev, 0x1ba, 0); viviflag = false; RT_TRACE(COMP_POWER_TRACKING, "we filtered the data\n"); @@ -766,7 +771,7 @@ void dm_txpower_trackingcallback(struct work_struct *work) struct r8192_priv *priv = container_of(dwork, struct r8192_priv, txpower_tracking_wq); struct net_device *dev = priv->ieee80211->dev; - if (priv->bDcut == true) + if (priv->bDcut) dm_TXPowerTrackingCallback_TSSI(dev); else dm_TXPowerTrackingCallback_ThermalMeter(dev); @@ -1301,7 +1306,7 @@ void dm_initialize_txpower_tracking(struct net_device *dev) { struct r8192_priv *priv = ieee80211_priv(dev); - if (priv->bDcut == true) + if (priv->bDcut) dm_InitializeTXPowerTracking_TSSI(dev); else dm_InitializeTXPowerTracking_ThermalMeter(dev); @@ -1357,7 +1362,7 @@ static void dm_check_txpower_tracking(struct net_device *dev) #ifdef RTL8190P dm_CheckTXPowerTracking_TSSI(dev); #else - if (priv->bDcut == true) + if (priv->bDcut) dm_CheckTXPowerTracking_TSSI(dev); else dm_CheckTXPowerTracking_ThermalMeter(dev); @@ -1467,7 +1472,7 @@ void dm_cck_txpower_adjust(struct net_device *dev, bool binch14) { /* dm_CCKTxPowerAdjust */ struct r8192_priv *priv = ieee80211_priv(dev); - if (priv->bDcut == true) + if (priv->bDcut) dm_CCKTxPowerAdjust_TSSI(dev, binch14); else dm_CCKTxPowerAdjust_ThermalMeter(dev, binch14); @@ -1731,7 +1736,7 @@ static void dm_dig_init(struct net_device *dev) *---------------------------------------------------------------------------*/ static void dm_ctrl_initgain_byrssi(struct net_device *dev) { - if (dm_digtable.dig_enable_flag == false) + if (!dm_digtable.dig_enable_flag) return; if (dm_digtable.dig_algorithm == DIG_ALGO_BY_FALSE_ALARM) @@ -1750,7 +1755,7 @@ static void dm_ctrl_initgain_byrssi_by_driverrssi( u8 i; static u8 fw_dig; - if (dm_digtable.dig_enable_flag == false) + if (!dm_digtable.dig_enable_flag) return; /*DbgPrint("Dig by Sw Rssi\n");*/ @@ -1792,7 +1797,7 @@ static void dm_ctrl_initgain_byrssi_by_fwfalse_alarm( static u32 reset_cnt; u8 i; - if (dm_digtable.dig_enable_flag == false) + if (!dm_digtable.dig_enable_flag) return; if (dm_digtable.dig_algorithm_switch) { @@ -2378,7 +2383,7 @@ static void dm_check_pbc_gpio(struct net_device *dev) if (tmp1byte == 0xff) return; - if (tmp1byte&BIT6 || tmp1byte&BIT0) { + if (tmp1byte & BIT(6) || tmp1byte & BIT(0)) { /* * Here we only set bPbcPressed to TRUE * After trigger PBC, the variable will be set to FALSE @@ -3062,7 +3067,7 @@ static void dm_dynamic_txpower(struct net_device *dev) priv->bDynamicTxLowPower = false; } else { /* high power state check */ - if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower == true) + if (priv->undecorated_smoothed_pwdb < txlowpower_threshold && priv->bDynamicTxHighPower) priv->bDynamicTxHighPower = false; /* low power state check */ diff --git a/kernel/drivers/staging/rtl8192u/r8192U_dm.h b/kernel/drivers/staging/rtl8192u/r8192U_dm.h index 6cd32eb44..2d0232fb3 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U_dm.h +++ b/kernel/drivers/staging/rtl8192u/r8192U_dm.h @@ -212,24 +212,24 @@ extern struct dynamic_rx_path_sel DM_RxPathSelTable; /*--------------------------Exported Function prototype---------------------*/ -extern void init_hal_dm(struct net_device *dev); -extern void deinit_hal_dm(struct net_device *dev); -extern void hal_dm_watchdog(struct net_device *dev); -extern void init_rate_adaptive(struct net_device *dev); -extern void dm_txpower_trackingcallback(struct work_struct *work); -extern void dm_restore_dynamic_mechanism_state(struct net_device *dev); -extern void dm_backup_dynamic_mechanism_state(struct net_device *dev); -extern void dm_change_dynamic_initgain_thresh(struct net_device *dev, - u32 dm_type, u32 dm_value); -extern void dm_force_tx_fw_info(struct net_device *dev, - u32 force_type, u32 force_value); -extern void dm_init_edca_turbo(struct net_device *dev); -extern void dm_rf_operation_test_callback(unsigned long data); -extern void dm_rf_pathcheck_workitemcallback(struct work_struct *work); -extern void dm_fsync_timer_callback(unsigned long data); -extern void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); -extern void dm_shadow_init(struct net_device *dev); -extern void dm_initialize_txpower_tracking(struct net_device *dev); +void init_hal_dm(struct net_device *dev); +void deinit_hal_dm(struct net_device *dev); +void hal_dm_watchdog(struct net_device *dev); +void init_rate_adaptive(struct net_device *dev); +void dm_txpower_trackingcallback(struct work_struct *work); +void dm_restore_dynamic_mechanism_state(struct net_device *dev); +void dm_backup_dynamic_mechanism_state(struct net_device *dev); +void dm_change_dynamic_initgain_thresh(struct net_device *dev, + u32 dm_type, u32 dm_value); +void dm_force_tx_fw_info(struct net_device *dev, + u32 force_type, u32 force_value); +void dm_init_edca_turbo(struct net_device *dev); +void dm_rf_operation_test_callback(unsigned long data); +void dm_rf_pathcheck_workitemcallback(struct work_struct *work); +void dm_fsync_timer_callback(unsigned long data); +void dm_cck_txpower_adjust(struct net_device *dev, bool binch14); +void dm_shadow_init(struct net_device *dev); +void dm_initialize_txpower_tracking(struct net_device *dev); /*--------------------------Exported Function prototype---------------------*/ diff --git a/kernel/drivers/staging/rtl8192u/r8192U_hw.h b/kernel/drivers/staging/rtl8192u/r8192U_hw.h index a93694ff0..e07d65d04 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U_hw.h +++ b/kernel/drivers/staging/rtl8192u/r8192U_hw.h @@ -55,17 +55,17 @@ typedef enum _BaseBand_Config_Type{ #define BB_ANTATTEN_CHAN14 0x0c #define BB_ANTENNA_B 0x40 -#define BB_HOST_BANG (1<<30) -#define BB_HOST_BANG_EN (1<<2) -#define BB_HOST_BANG_CLK (1<<1) -#define BB_HOST_BANG_RW (1<<3) +#define BB_HOST_BANG BIT(30) +#define BB_HOST_BANG_EN BIT(2) +#define BB_HOST_BANG_CLK BIT(1) +#define BB_HOST_BANG_RW BIT(3) #define BB_HOST_BANG_DATA 1 //#if (RTL819X_FPGA_VER & RTL819X_FPGA_VIVI_070920) #define AFR 0x010 -#define AFR_CardBEn (1<<0) -#define AFR_CLKRUN_SEL (1<<1) -#define AFR_FuncRegEn (1<<2) +#define AFR_CardBEn BIT(0) +#define AFR_CLKRUN_SEL BIT(1) +#define AFR_FuncRegEn BIT(2) #define RTL8190_EEPROM_ID 0x8129 #define EEPROM_VID 0x02 #define EEPROM_PID 0x04 @@ -126,38 +126,39 @@ enum _RTL8192Usb_HW { #define TCR_LRL_OFFSET 0 #define TCR_SRL_OFFSET 8 #define TCR_MXDMA_OFFSET 21 -#define TCR_SAT BIT24 // Enable Rate depedent ack timeout timer +#define TCR_SAT BIT(24) // Enable Rate depedent ack timeout timer RCR = 0x044, // Receive Configuration Register -#define MAC_FILTER_MASK ((1<<0) | (1<<1) | (1<<2) | (1<<3) | (1<<5) | \ - (1<<12) | (1<<18) | (1<<19) | (1<<20) | (1<<21) | (1<<22) | (1<<23)) -#define RX_FIFO_THRESHOLD_MASK ((1<<13) | (1<<14) | (1<<15)) +#define MAC_FILTER_MASK (BIT(0) | BIT(1) | BIT(2) | BIT(3) | BIT(5) | \ + BIT(12) | BIT(18) | BIT(19) | BIT(20) | BIT(21) | \ + BIT(22) | BIT(23)) +#define RX_FIFO_THRESHOLD_MASK (BIT(13) | BIT(14) | BIT(15)) #define RX_FIFO_THRESHOLD_SHIFT 13 #define RX_FIFO_THRESHOLD_128 3 #define RX_FIFO_THRESHOLD_256 4 #define RX_FIFO_THRESHOLD_512 5 #define RX_FIFO_THRESHOLD_1024 6 #define RX_FIFO_THRESHOLD_NONE 7 -#define MAX_RX_DMA_MASK ((1<<8) | (1<<9) | (1<<10)) +#define MAX_RX_DMA_MASK (BIT(8) | BIT(9) | BIT(10)) #define RCR_MXDMA_OFFSET 8 #define RCR_FIFO_OFFSET 13 -#define RCR_ONLYERLPKT BIT31 // Early Receiving based on Packet Size. -#define RCR_ENCS2 BIT30 // Enable Carrier Sense Detection Method 2 -#define RCR_ENCS1 BIT29 // Enable Carrier Sense Detection Method 1 -#define RCR_ENMBID BIT27 // Enable Multiple BssId. -#define RCR_ACKTXBW (BIT24|BIT25) // TXBW Setting of ACK frames -#define RCR_CBSSID BIT23 // Accept BSSID match packet -#define RCR_APWRMGT BIT22 // Accept power management packet -#define RCR_ADD3 BIT21 // Accept address 3 match packet -#define RCR_AMF BIT20 // Accept management type frame -#define RCR_ACF BIT19 // Accept control type frame -#define RCR_ADF BIT18 // Accept data type frame -#define RCR_RXFTH BIT13 // Rx FIFO Threshold -#define RCR_AICV BIT12 // Accept ICV error packet -#define RCR_ACRC32 BIT5 // Accept CRC32 error packet -#define RCR_AB BIT3 // Accept broadcast packet -#define RCR_AM BIT2 // Accept multicast packet -#define RCR_APM BIT1 // Accept physical match packet -#define RCR_AAP BIT0 // Accept all unicast packet +#define RCR_ONLYERLPKT BIT(31) // Early Receiving based on Packet Size. +#define RCR_ENCS2 BIT(30) // Enable Carrier Sense Detection Method 2 +#define RCR_ENCS1 BIT(29) // Enable Carrier Sense Detection Method 1 +#define RCR_ENMBID BIT(27) // Enable Multiple BssId. +#define RCR_ACKTXBW (BIT(24) | BIT(25)) // TXBW Setting of ACK frames +#define RCR_CBSSID BIT(23) // Accept BSSID match packet +#define RCR_APWRMGT BIT(22) // Accept power management packet +#define RCR_ADD3 BIT(21) // Accept address 3 match packet +#define RCR_AMF BIT(20) // Accept management type frame +#define RCR_ACF BIT(19) // Accept control type frame +#define RCR_ADF BIT(18) // Accept data type frame +#define RCR_RXFTH BIT(13) // Rx FIFO Threshold +#define RCR_AICV BIT(12) // Accept ICV error packet +#define RCR_ACRC32 BIT(5) // Accept CRC32 error packet +#define RCR_AB BIT(3) // Accept broadcast packet +#define RCR_AM BIT(2) // Accept multicast packet +#define RCR_APM BIT(1) // Accept physical match packet +#define RCR_AAP BIT(0) // Accept all unicast packet SLOT_TIME = 0x049, // Slot Time Register ACK_TIMEOUT = 0x04c, // Ack Timeout Register PIFS_TIME = 0x04d, // PIFS time @@ -180,12 +181,12 @@ enum _RTL8192Usb_HW { WCAMI = 0x0A4, // Software write CAM input content RCAMO = 0x0A8, // Software read/write CAM config SECR = 0x0B0, //Security Configuration Register -#define SCR_TxUseDK BIT0 //Force Tx Use Default Key -#define SCR_RxUseDK BIT1 //Force Rx Use Default Key -#define SCR_TxEncEnable BIT2 //Enable Tx Encryption -#define SCR_RxDecEnable BIT3 //Enable Rx Decryption -#define SCR_SKByA2 BIT4 //Search kEY BY A2 -#define SCR_NoSKMC BIT5 //No Key Search for Multicast +#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 for Multicast #define SCR_UseDK 0x01 #define SCR_TxSecEnable 0x02 #define SCR_RxSecEnable 0x04 @@ -226,13 +227,13 @@ enum _RTL8192Usb_HW { //// 8190 AcmHwCtrl bits (offset 0x171, 1 byte) ////---------------------------------------------------------------------------- // -#define AcmHw_HwEn BIT0 -#define AcmHw_BeqEn BIT1 -#define AcmHw_ViqEn BIT2 -#define AcmHw_VoqEn BIT3 -#define AcmHw_BeqStatus BIT4 -#define AcmHw_ViqStatus BIT5 -#define AcmHw_VoqStatus BIT6 +#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) AcmFwCtrl = 0x172, // ACM Firmware Control Register AES_11N_FIX = 0x173, @@ -281,18 +282,18 @@ enum _RTL8192Usb_HW { NHM_RPI_COUNTER5 = 0x269, // Noise Histogram RPI counter5, the fraction of signal strength in (NHM_THRESHOLD4, NHM_THRESHOLD5]. NHM_RPI_COUNTER6 = 0x26A, // Noise Histogram RPI counter6, the fraction of signal strength in (NHM_THRESHOLD5, NHM_THRESHOLD6]. NHM_RPI_COUNTER7 = 0x26B, // Noise Histogram RPI counter7, the fraction of signal strength in (NHM_THRESHOLD6, NHM_THRESHOLD7]. -#define BW_OPMODE_11J BIT0 -#define BW_OPMODE_5G BIT1 -#define BW_OPMODE_20MHZ BIT2 +#define BW_OPMODE_11J BIT(0) +#define BW_OPMODE_5G BIT(1) +#define BW_OPMODE_20MHZ BIT(2) BW_OPMODE = 0x300, // Bandwidth operation mode MSR = 0x303, // Media Status register -#define MSR_LINK_MASK ((1<<0)|(1<<1)) +#define MSR_LINK_MASK (BIT(0)|BIT(1)) #define MSR_LINK_MANAGED 2 #define MSR_LINK_NONE 0 #define MSR_LINK_SHIFT 0 #define MSR_LINK_ADHOC 1 #define MSR_LINK_MASTER 3 -#define MSR_LINK_ENEDCA (1<<4) +#define MSR_LINK_ENEDCA BIT(4) RETRY_LIMIT = 0x304, // Retry Limit [15:8]-short, [7:0]-long #define RETRY_LIMIT_SHORT_SHIFT 8 #define RETRY_LIMIT_LONG_SHIFT 0 @@ -304,27 +305,27 @@ enum _RTL8192Usb_HW { #define RRSR_RSC_LOWSUBCHNL 0x400000 #define RRSR_RSC_UPSUBCHANL 0x200000 #define RRSR_SHORT 0x800000 -#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 BRSR_AckShortPmb BIT23 // CCK ACK: use Short Preamble or not. +#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) +#define BRSR_AckShortPmb BIT(23) // CCK ACK: use Short Preamble or not. RATR0 = 0x320, // Rate Adaptive Table register1 UFWP = 0x318, DRIVER_RSSI = 0x32c, // Driver tell Firmware current RSSI @@ -380,10 +381,10 @@ enum _RTL8192Usb_HW { MacBlkCtrl = 0x403, // Mac block on/off control register EPROM_CMD = 0xfe58, -#define Cmd9346CR_9356SEL (1<<4) -#define EPROM_CMD_RESERVED_MASK (1<<5) +#define Cmd9346CR_9356SEL BIT(4) +#define EPROM_CMD_RESERVED_MASK BIT(5) #define EPROM_CMD_OPERATING_MODE_SHIFT 6 -#define EPROM_CMD_OPERATING_MODE_MASK ((1<<7)|(1<<6)) +#define EPROM_CMD_OPERATING_MODE_MASK (BIT(7) | BIT(6)) #define EPROM_CMD_CONFIG 0x3 #define EPROM_CMD_NORMAL 0 #define EPROM_CMD_LOAD 1 diff --git a/kernel/drivers/staging/rtl8192u/r8192U_wx.c b/kernel/drivers/staging/rtl8192u/r8192U_wx.c index 83597051a..4911fef2e 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U_wx.c +++ b/kernel/drivers/staging/rtl8192u/r8192U_wx.c @@ -263,12 +263,12 @@ static int rtl8180_wx_get_range(struct net_device *dev, range->max_qual.qual = 100; /* TODO: Find real max RSSI and stick here */ range->max_qual.level = 0; - range->max_qual.noise = -98; + range->max_qual.noise = 0x100 - 98; range->max_qual.updated = 7; /* Updated all three */ range->avg_qual.qual = 92; /* > 8% missed beacons is 'bad' */ /* TODO: Find real 'good' to 'bad' threshold value for RSSI */ - range->avg_qual.level = 20 + -98; + range->avg_qual.level = 0x100 - 78; range->avg_qual.noise = 0; range->avg_qual.updated = 7; /* Updated all three */ diff --git a/kernel/drivers/staging/rtl8192u/r8192U_wx.h b/kernel/drivers/staging/rtl8192u/r8192U_wx.h index d6a2d9756..fb5f80843 100644 --- a/kernel/drivers/staging/rtl8192u/r8192U_wx.h +++ b/kernel/drivers/staging/rtl8192u/r8192U_wx.h @@ -19,6 +19,6 @@ extern struct iw_handler_def r8192_wx_handlers_def; /* Enable the rtl819x_core.c to share this function, david 2008.9.22 */ -extern struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); +struct iw_statistics *r8192_get_wireless_stats(struct net_device *dev); #endif diff --git a/kernel/drivers/staging/rtl8192u/r819xU_cmdpkt.h b/kernel/drivers/staging/rtl8192u/r819xU_cmdpkt.h index 52cd437ef..f490e253e 100644 --- a/kernel/drivers/staging/rtl8192u/r819xU_cmdpkt.h +++ b/kernel/drivers/staging/rtl8192u/r819xU_cmdpkt.h @@ -9,9 +9,9 @@ #define CMPK_TX_RAHIS_SIZE sizeof(cmpk_tx_rahis_t) /* 2008/05/08 amy For USB constant. */ -#define ISR_TxBcnOk BIT27 /* Transmit Beacon OK */ -#define ISR_TxBcnErr BIT26 /* Transmit Beacon Error */ -#define ISR_BcnTimerIntr BIT13 /* Beacon Timer Interrupt */ +#define ISR_TxBcnOk BIT(27) /* Transmit Beacon OK */ +#define ISR_TxBcnErr BIT(26) /* Transmit Beacon Error */ +#define ISR_BcnTimerIntr BIT(13) /* Beacon Timer Interrupt */ /* Define element ID of command packet. */ @@ -182,10 +182,10 @@ typedef enum _rt_status { RT_STATUS_RESOURCE } rt_status, *prt_status; -extern u32 cmpk_message_handle_rx(struct net_device *dev, - struct ieee80211_rx_stats *pstats); -extern rt_status SendTxCommandPacket(struct net_device *dev, - void *pData, u32 DataLen); +u32 cmpk_message_handle_rx(struct net_device *dev, + struct ieee80211_rx_stats *pstats); +rt_status SendTxCommandPacket(struct net_device *dev, + void *pData, u32 DataLen); #endif diff --git a/kernel/drivers/staging/rtl8192u/r819xU_firmware.c b/kernel/drivers/staging/rtl8192u/r819xU_firmware.c index d27b1e24c..08302dfb0 100644 --- a/kernel/drivers/staging/rtl8192u/r819xU_firmware.c +++ b/kernel/drivers/staging/rtl8192u/r819xU_firmware.c @@ -66,7 +66,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, skb = dev_alloc_skb(USB_HWDESC_HEADER_LEN + frag_length + 4); if (!skb) return false; - memcpy((unsigned char *)(skb->cb),&dev,sizeof(dev)); + memcpy((unsigned char *)(skb->cb), &dev, sizeof(dev)); tcb_desc = (cb_desc *)(skb->cb + MAX_DEV_ADDR_SIZE); tcb_desc->queue_index = TXCMD_QUEUE; tcb_desc->bCmdOrInit = DESC_PACKET_TYPE_INIT; @@ -91,7 +91,7 @@ static bool fw_download_code(struct net_device *dev, u8 *code_virtual_address, if (!priv->ieee80211->check_nic_enough_desc(dev, index) || (!skb_queue_empty(&priv->ieee80211->skb_waitQ[index])) || (priv->ieee80211->queue_stop)) { - RT_TRACE(COMP_FIRMWARE,"=====================================================> tx full!\n"); + RT_TRACE(COMP_FIRMWARE, "=====================================================> tx full!\n"); skb_queue_tail(&priv->ieee80211->skb_waitQ[tcb_desc->queue_index], skb); } else { priv->ieee80211->softmac_hard_start_xmit(skb, dev); @@ -144,7 +144,8 @@ static bool CPUcheck_maincodeok_turnonCPU(struct net_device *dev) /* Turn On CPU */ read_nic_dword(dev, CPU_GEN, &CPU_status); - write_nic_byte(dev, CPU_GEN, (u8)((CPU_status|CPU_GEN_PWR_STB_CPU)&0xff)); + write_nic_byte(dev, CPU_GEN, + (u8)((CPU_status | CPU_GEN_PWR_STB_CPU) & 0xff)); mdelay(1000); /* Check whether CPU boot OK */ @@ -242,7 +243,7 @@ bool init_firmware(struct net_device *dev) * or read image file from array. Default load from IMG file */ if (rst_opt == OPT_SYSTEM_RESET) { - rc = request_firmware(&fw_entry, fw_name[init_step],&priv->udev->dev); + rc = request_firmware(&fw_entry, fw_name[init_step], &priv->udev->dev); if (rc < 0) { RT_TRACE(COMP_ERR, "request firmware fail!\n"); goto download_firmware_fail; @@ -254,12 +255,12 @@ bool init_firmware(struct net_device *dev) } if (init_step != FW_INIT_STEP1_MAIN) { - memcpy(pfirmware->firmware_buf,fw_entry->data,fw_entry->size); + memcpy(pfirmware->firmware_buf, fw_entry->data, fw_entry->size); mapped_file = pfirmware->firmware_buf; file_length = fw_entry->size; } else { memset(pfirmware->firmware_buf, 0, 128); - memcpy(&pfirmware->firmware_buf[128],fw_entry->data,fw_entry->size); + memcpy(&pfirmware->firmware_buf[128], fw_entry->data, fw_entry->size); mapped_file = pfirmware->firmware_buf; file_length = fw_entry->size + 128; } @@ -319,7 +320,7 @@ bool init_firmware(struct net_device *dev) rt_status = CPUcheck_firmware_ready(dev); if (!rt_status) { - RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n",rt_status); + RT_TRACE(COMP_ERR, "CPUcheck_firmware_ready fail(%d)!\n", rt_status); goto download_firmware_fail; } diff --git a/kernel/drivers/staging/rtl8192u/r819xU_firmware.h b/kernel/drivers/staging/rtl8192u/r819xU_firmware.h index cfa222350..24b63f2ec 100644 --- a/kernel/drivers/staging/rtl8192u/r819xU_firmware.h +++ b/kernel/drivers/staging/rtl8192u/r819xU_firmware.h @@ -2,15 +2,8 @@ #define __INC_FIRMWARE_H #define RTL8190_CPU_START_OFFSET 0x80 -/* TODO: this definition is TBD */ -//#define USB_HWDESC_HEADER_LEN 0 - -/* It should be double word alignment */ -//#if DEV_BUS_TYPE==PCI_INTERFACE -//#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) 4*(v/4) - 8 -//#else -#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN) -//#endif +#define GET_COMMAND_PACKET_FRAG_THRESHOLD(v) \ + (4*(v/4) - 8 - USB_HWDESC_HEADER_LEN) typedef enum _firmware_init_step { FW_INIT_STEP0_BOOT = 0, diff --git a/kernel/drivers/staging/rtl8192u/r819xU_phy.c b/kernel/drivers/staging/rtl8192u/r819xU_phy.c index e5dbaca9e..70656441c 100644 --- a/kernel/drivers/staging/rtl8192u/r819xU_phy.c +++ b/kernel/drivers/staging/rtl8192u/r819xU_phy.c @@ -1110,7 +1110,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, case eRfOn: /* RF-A, RF-B */ /* enable RF-Chip A/B - 0x860[4] */ - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT(4), 0x1); /* analog to digital on - 0x88c[9:8] */ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0x300, @@ -1135,7 +1135,7 @@ bool rtl8192_SetRFPowerState(struct net_device *dev, case eRfOff: /* RF-A, RF-B */ /* disable RF-Chip A/B - 0x860[4] */ - rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT4, + rtl8192_setBBreg(dev, rFPGA0_XA_RFInterfaceOE, BIT(4), 0x0); /* analog to digital off, for power save */ rtl8192_setBBreg(dev, rFPGA0_AnalogParameter4, 0xf00, diff --git a/kernel/drivers/staging/rtl8192u/r819xU_phy.h b/kernel/drivers/staging/rtl8192u/r819xU_phy.h index 66cbe3f9c..e67212633 100644 --- a/kernel/drivers/staging/rtl8192u/r819xU_phy.h +++ b/kernel/drivers/staging/rtl8192u/r819xU_phy.h @@ -57,36 +57,35 @@ typedef enum _RF90_RADIO_PATH { #define bMaskLWord 0x0000ffff #define bMaskDWord 0xffffffff -extern u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath); -extern void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, - u32 bitmask, u32 data); -extern u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, - u32 bitmask); -extern void rtl8192_phy_SetRFReg(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath, u32 reg_addr, u32 bitmask, u32 data); -extern u32 rtl8192_phy_QueryRFReg(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath, u32 reg_addr, u32 bitmask); -extern void rtl8192_phy_configmac(struct net_device *dev); -extern void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); -extern u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, - HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); -extern void rtl8192_BBConfig(struct net_device *dev); -extern void rtl8192_phy_getTxPower(struct net_device *dev); -extern void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); -extern void rtl8192_phy_RFConfig(struct net_device *dev); -extern void rtl8192_phy_updateInitGain(struct net_device *dev); -extern u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, - RF90_RADIO_PATH_E eRFPath); +u8 rtl8192_phy_CheckIsLegalRFPath(struct net_device *dev, u32 eRFPath); +void rtl8192_setBBreg(struct net_device *dev, u32 reg_addr, + u32 bitmask, u32 data); +u32 rtl8192_QueryBBReg(struct net_device *dev, u32 reg_addr, u32 bitmask); +void rtl8192_phy_SetRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, + u32 reg_addr, u32 bitmask, u32 data); +u32 rtl8192_phy_QueryRFReg(struct net_device *dev, RF90_RADIO_PATH_E eRFPath, + u32 reg_addr, u32 bitmask); +void rtl8192_phy_configmac(struct net_device *dev); +void rtl8192_phyConfigBB(struct net_device *dev, u8 ConfigType); +u8 rtl8192_phy_checkBBAndRF(struct net_device *dev, + HW90_BLOCK_E CheckBlock, RF90_RADIO_PATH_E eRFPath); +void rtl8192_BBConfig(struct net_device *dev); +void rtl8192_phy_getTxPower(struct net_device *dev); +void rtl8192_phy_setTxPower(struct net_device *dev, u8 channel); +void rtl8192_phy_RFConfig(struct net_device *dev); +void rtl8192_phy_updateInitGain(struct net_device *dev); +u8 rtl8192_phy_ConfigRFWithHeaderFile(struct net_device *dev, + RF90_RADIO_PATH_E eRFPath); -extern u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); -extern void rtl8192_SetBWMode(struct net_device *dev, - HT_CHANNEL_WIDTH bandwidth, HT_EXTCHNL_OFFSET offset); -extern void rtl8192_SwChnl_WorkItem(struct net_device *dev); +u8 rtl8192_phy_SwChnl(struct net_device *dev, u8 channel); +void rtl8192_SetBWMode(struct net_device *dev, HT_CHANNEL_WIDTH bandwidth, + HT_EXTCHNL_OFFSET offset); +void rtl8192_SwChnl_WorkItem(struct net_device *dev); void rtl8192_SetBWModeWorkItem(struct net_device *dev); -extern bool rtl8192_SetRFPowerState(struct net_device *dev, - RT_RF_POWER_STATE eRFPowerState); -extern void InitialGain819xUsb(struct net_device *dev, u8 Operation); +bool rtl8192_SetRFPowerState(struct net_device *dev, + RT_RF_POWER_STATE eRFPowerState); +void InitialGain819xUsb(struct net_device *dev, u8 Operation); -extern void InitialGainOperateWorkItemCallBack(struct work_struct *work); +void InitialGainOperateWorkItemCallBack(struct work_struct *work); #endif -- cgit 1.2.3-korg