diff options
Diffstat (limited to 'drivers/staging/rtl8187se')
-rw-r--r-- | drivers/staging/rtl8187se/Module.symvers | 0 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/dot11d.h | 11 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/ieee80211.h | 12 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c | 2 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c | 14 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c | 15 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c | 1203 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c | 151 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180.h | 750 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180_core.c | 894 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180_dm.c | 6 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180_rtl8225.h | 21 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180_rtl8225z2.c | 59 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8180_wx.c | 10 | ||||
-rw-r--r-- | drivers/staging/rtl8187se/r8185b_init.c | 62 |
15 files changed, 1399 insertions, 1811 deletions
diff --git a/drivers/staging/rtl8187se/Module.symvers b/drivers/staging/rtl8187se/Module.symvers new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/drivers/staging/rtl8187se/Module.symvers diff --git a/drivers/staging/rtl8187se/ieee80211/dot11d.h b/drivers/staging/rtl8187se/ieee80211/dot11d.h index 63f4f3c..f996691 100644 --- a/drivers/staging/rtl8187se/ieee80211/dot11d.h +++ b/drivers/staging/rtl8187se/ieee80211/dot11d.h @@ -11,13 +11,13 @@ typedef struct _CHNL_TXPOWER_TRIPLE { u8 FirstChnl; u8 NumChnls; u8 MaxTxPowerInDbm; -}CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE; +} CHNL_TXPOWER_TRIPLE, *PCHNL_TXPOWER_TRIPLE; typedef enum _DOT11D_STATE { DOT11D_STATE_NONE = 0, DOT11D_STATE_LEARNED, DOT11D_STATE_DONE, -}DOT11D_STATE; +} DOT11D_STATE; typedef struct _RT_DOT11D_INFO { /* DECLARE_RT_OBJECT(RT_DOT12D_INFO); */ @@ -35,9 +35,10 @@ typedef struct _RT_DOT11D_INFO { u8 MaxTxPwrDbmList[MAX_CHANNEL_NUMBER+1]; DOT11D_STATE State; -}RT_DOT11D_INFO, *PRT_DOT11D_INFO; -#define eqMacAddr(a,b) ( ((a)[0]==(b)[0] && (a)[1]==(b)[1] && (a)[2]==(b)[2] && (a)[3]==(b)[3] && (a)[4]==(b)[4] && (a)[5]==(b)[5]) ? 1:0 ) -#define cpMacAddr(des,src) ((des)[0]=(src)[0],(des)[1]=(src)[1],(des)[2]=(src)[2],(des)[3]=(src)[3],(des)[4]=(src)[4],(des)[5]=(src)[5]) +} RT_DOT11D_INFO, *PRT_DOT11D_INFO; + +#define eqMacAddr(a, b) (((a)[0] == (b)[0] && (a)[1] == (b)[1] && (a)[2] == (b)[2] && (a)[3] == (b)[3] && (a)[4] == (b)[4] && (a)[5] == (b)[5]) ? 1:0) +#define cpMacAddr(des, src) ((des)[0] = (src)[0], (des)[1] = (src)[1], (des)[2] = (src)[2], (des)[3] = (src)[3], (des)[4] = (src)[4], (des)[5] = (src)[5]) #define GET_DOT11D_INFO(__pIeeeDev) ((PRT_DOT11D_INFO)((__pIeeeDev)->pDot11dInfo)) #define IS_DOT11D_ENABLE(__pIeeeDev) GET_DOT11D_INFO(__pIeeeDev)->bEnabled diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211.h b/drivers/staging/rtl8187se/ieee80211/ieee80211.h index 09ffd9b..d1763b7 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211.h +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211.h @@ -473,7 +473,7 @@ enum { }; struct ieee80211_header_data { - u16 frame_ctl; + __le16 frame_ctl; u16 duration_id; u8 addr1[6]; u8 addr2[6]; @@ -482,7 +482,7 @@ struct ieee80211_header_data { }; struct ieee80211_hdr_4addr { - u16 frame_ctl; + __le16 frame_ctl; u16 duration_id; u8 addr1[ETH_ALEN]; u8 addr2[ETH_ALEN]; @@ -709,10 +709,10 @@ enum {WMM_all_frame, WMM_two_frame, WMM_four_frame, WMM_six_frame}; #define MAX_IE_LEN 0xFF //+YJ,080625 -typedef struct _CHANNEL_LIST{ - u8 Channel[MAX_CHANNEL_NUMBER + 1]; - u8 Len; -}CHANNEL_LIST, *PCHANNEL_LIST; +struct rtl8187se_channel_list { + u8 channel[MAX_CHANNEL_NUMBER + 1]; + u8 len; +}; //by amy for ps #define IEEE80211_WATCH_DOG_TIME 2000 diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c index c8013d3..4fe2538 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_ccmp.c @@ -58,7 +58,7 @@ struct ieee80211_ccmp_data { u8 rx_b0[AES_BLOCK_LEN], rx_b[AES_BLOCK_LEN], rx_a[AES_BLOCK_LEN]; }; -void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, +static void ieee80211_ccmp_aes_encrypt(struct crypto_tfm *tfm, const u8 pt[16], u8 ct[16]) { crypto_cipher_encrypt_one((void *)tfm, ct, pt); diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c index c590796..6c1acc5 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_tkip.c @@ -187,8 +187,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, @@ -307,7 +306,7 @@ static int ieee80211_tkip_encrypt(struct sk_buff *skb, int hdr_len, void *priv) int len; u8 *pos; struct ieee80211_hdr_4addr *hdr; - u8 rc4key[16],*icv; + u8 rc4key[16], *icv; u32 crc; struct scatterlist sg; int ret; @@ -348,7 +347,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++; if (tkey->tx_iv16 == 0) { @@ -537,9 +536,9 @@ static int ieee80211_michael_mic_add(struct sk_buff *skb, int hdr_len, michael_mic_hdr(skb, tkey->tx_hdr); - 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); if (michael_mic(tkey->tx_tfm_michael, &tkey->key[16], tkey->tx_hdr, @@ -583,9 +582,8 @@ static int ieee80211_michael_mic_verify(struct sk_buff *skb, int keyidx, return -1; michael_mic_hdr(skb, tkey->rx_hdr); - 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)) diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c index f114f9a..f253672 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_crypt_wep.c @@ -11,7 +11,6 @@ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt -//#include <linux/config.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/random.h> @@ -28,8 +27,6 @@ MODULE_AUTHOR("Jouni Malinen"); MODULE_DESCRIPTION("Host AP crypt: WEP"); MODULE_LICENSE("GPL"); - - struct prism2_wep_data { u32 iv; #define WEP_KEY_LEN 13 @@ -40,7 +37,6 @@ struct prism2_wep_data { struct crypto_blkcipher *rx_tfm; }; - static void *prism2_wep_init(int keyidx) { struct prism2_wep_data *priv; @@ -79,7 +75,6 @@ fail: return NULL; } - static void prism2_wep_deinit(void *priv) { struct prism2_wep_data *_priv = priv; @@ -94,7 +89,6 @@ static void prism2_wep_deinit(void *priv) kfree(priv); } - /* Perform WEP encryption on given skb that has at least 4 bytes of headroom * for IV and 4 bytes of tailroom for ICV. Both IV and ICV will be transmitted, * so the payload length increases with 8 bytes. @@ -157,7 +151,6 @@ static int prism2_wep_encrypt(struct sk_buff *skb, int hdr_len, void *priv) return crypto_blkcipher_encrypt(&desc, &sg, &sg, len + 4); } - /* Perform WEP decryption on given buffer. Buffer includes whole WEP part of * the frame: IV (4 bytes), encrypted payload (including SNAP header), * ICV (4 bytes). len includes both IV and ICV. @@ -219,7 +212,6 @@ static int prism2_wep_decrypt(struct sk_buff *skb, int hdr_len, void *priv) return 0; } - static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -233,7 +225,6 @@ static int prism2_wep_set_key(void *key, int len, u8 *seq, void *priv) return 0; } - static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) { struct prism2_wep_data *wep = priv; @@ -246,7 +237,6 @@ static int prism2_wep_get_key(void *key, int len, u8 *seq, void *priv) return wep->key_len; } - static char *prism2_wep_print_stats(char *p, void *priv) { struct prism2_wep_data *wep = priv; @@ -255,7 +245,6 @@ static char *prism2_wep_print_stats(char *p, void *priv) return p; } - static struct ieee80211_crypto_ops ieee80211_crypt_wep = { .name = "WEP", .init = prism2_wep_init, @@ -272,21 +261,17 @@ static struct ieee80211_crypto_ops ieee80211_crypt_wep = { .owner = THIS_MODULE, }; - int ieee80211_crypto_wep_init(void) { return ieee80211_register_crypto_ops(&ieee80211_crypt_wep); } - void ieee80211_crypto_wep_exit(void) { ieee80211_unregister_crypto_ops(&ieee80211_crypt_wep); } - void ieee80211_wep_null(void) { -// printk("============>%s()\n", __func__); return; } diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c index c27392d..03eb164 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_softmac.c @@ -13,7 +13,6 @@ * released under the GPL */ - #include "ieee80211.h" #include <linux/random.h> @@ -24,14 +23,6 @@ #include <linux/etherdevice.h> #include "dot11d.h" -u8 rsn_authen_cipher_suite[16][4] = { - {0x00, 0x0F, 0xAC, 0x00}, //Use group key, //Reserved - {0x00, 0x0F, 0xAC, 0x01}, //WEP-40 //RSNA default - {0x00, 0x0F, 0xAC, 0x02}, //TKIP //NONE //{used just as default} - {0x00, 0x0F, 0xAC, 0x03}, //WRAP-historical - {0x00, 0x0F, 0xAC, 0x04}, //CCMP - {0x00, 0x0F, 0xAC, 0x05}, //WEP-104 -}; short ieee80211_is_54g(const struct ieee80211_network *net) { @@ -62,14 +53,13 @@ static unsigned int ieee80211_MFIE_rate_len(struct ieee80211_device *ieee) } /* place the MFIE rate, tag to the memory (double) poised. - * Then it updates the pointer so that - * it points after the new MFIE tag added. + * Then it updates the pointer so that it points after the new MFIE tag added. */ static void ieee80211_MFIE_Brate(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & IEEE80211_CCK_MODULATION){ + if (ieee->modulation & IEEE80211_CCK_MODULATION) { *tag++ = MFIE_TYPE_RATES; *tag++ = 4; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; @@ -86,8 +76,7 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - if (ieee->modulation & IEEE80211_OFDM_MODULATION){ - + if (ieee->modulation & IEEE80211_OFDM_MODULATION) { *tag++ = MFIE_TYPE_RATES_EX; *tag++ = 8; *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -100,22 +89,20 @@ static void ieee80211_MFIE_Grate(struct ieee80211_device *ieee, u8 **tag_p) *tag++ = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; } - /* We may add an option for custom rates that specific HW might support */ *tag_p = tag; } - static void ieee80211_WMM_Info(struct ieee80211_device *ieee, u8 **tag_p) { u8 *tag = *tag_p; - *tag++ = MFIE_TYPE_GENERIC; //0 + *tag++ = MFIE_TYPE_GENERIC; /* 0 */ *tag++ = 7; *tag++ = 0x00; *tag++ = 0x50; *tag++ = 0xf2; - *tag++ = 0x02;//5 + *tag++ = 0x02; /* 5 */ *tag++ = 0x00; *tag++ = 0x01; #ifdef SUPPORT_USPD @@ -148,32 +135,23 @@ static void ieee80211_TURBO_Info(struct ieee80211_device *ieee, u8 **tag_p) static void enqueue_mgmt(struct ieee80211_device *ieee, struct sk_buff *skb) { int nh; - nh = (ieee->mgmt_queue_head +1) % MGMT_QUEUE_NUM; + nh = (ieee->mgmt_queue_head + 1) % MGMT_QUEUE_NUM; -/* - * if the queue is full but we have newer frames then - * just overwrites the oldest. - * - * if (nh == ieee->mgmt_queue_tail) - * return -1; - */ ieee->mgmt_queue_head = nh; ieee->mgmt_queue_ring[nh] = skb; - - //return 0; } static struct sk_buff *dequeue_mgmt(struct ieee80211_device *ieee) { struct sk_buff *ret; - if(ieee->mgmt_queue_tail == ieee->mgmt_queue_head) + if (ieee->mgmt_queue_tail == ieee->mgmt_queue_head) return NULL; ret = ieee->mgmt_queue_ring[ieee->mgmt_queue_tail]; ieee->mgmt_queue_tail = - (ieee->mgmt_queue_tail+1) % MGMT_QUEUE_NUM; + (ieee->mgmt_queue_tail + 1) % MGMT_QUEUE_NUM; return ret; } @@ -183,7 +161,6 @@ static void init_mgmt_queue(struct ieee80211_device *ieee) ieee->mgmt_queue_tail = ieee->mgmt_queue_head = 0; } - void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl); inline void softmac_mgmt_xmit(struct sk_buff *skb, @@ -191,20 +168,18 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, { unsigned long flags; short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; - struct ieee80211_hdr_3addr *header= + struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd param 0, no mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); + ieee80211_sta_wakeup(ieee, 0); - if(single){ - if(ieee->queue_stop){ - - enqueue_mgmt(ieee,skb); - }else{ + if (single) { + if (ieee->queue_stop) { + enqueue_mgmt(ieee, skb); + } else { header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0]<<4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -214,11 +189,11 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); } spin_unlock_irqrestore(&ieee->lock, flags); - }else{ + } else { spin_unlock_irqrestore(&ieee->lock, flags); spin_lock_irqsave(&ieee->mgmt_tx_lock, flags); @@ -231,24 +206,20 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; - ieee->softmac_hard_start_xmit(skb,ieee->dev); + ieee->softmac_hard_start_xmit(skb, ieee->dev); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags); } } - inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, struct ieee80211_device *ieee) { - short single = ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - - if(single){ - + if (single) { header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -258,10 +229,8 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - - }else{ - + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); + } else { header->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4); if (ieee->seq_ctrl[0] == 0xFFF) @@ -271,12 +240,10 @@ inline void softmac_ps_mgmt_xmit(struct sk_buff *skb, /* avoid watchdog triggers */ ieee->dev->trans_start = jiffies; - ieee->softmac_hard_start_xmit(skb,ieee->dev); - + ieee->softmac_hard_start_xmit(skb, ieee->dev); } -// dev_kfree_skb_any(skb);//edit by thomas } -//by amy for power save + inline struct sk_buff * ieee80211_disassociate_skb(struct ieee80211_network *beacon, struct ieee80211_device *ieee, u8 asRsn) @@ -288,7 +255,7 @@ ieee80211_disassociate_skb(struct ieee80211_network *beacon, if (!skb) return NULL; - disass = (struct ieee80211_disassoc_frame *) skb_put(skb,sizeof(struct ieee80211_disassoc_frame)); + disass = (struct ieee80211_disassoc_frame *) skb_put(skb, sizeof(struct ieee80211_disassoc_frame)); disass->header.frame_control = cpu_to_le16(IEEE80211_STYPE_DISASSOC); disass->header.duration_id = 0; @@ -299,21 +266,19 @@ ieee80211_disassociate_skb(struct ieee80211_network *beacon, disass->reasoncode = asRsn; return skb; } + void SendDisassociation(struct ieee80211_device *ieee, u8 *asSta, u8 asRsn) { - struct ieee80211_network *beacon = &ieee->current_network; - struct sk_buff *skb; - skb = ieee80211_disassociate_skb(beacon,ieee,asRsn); - if (skb){ - softmac_mgmt_xmit(skb, ieee); - //dev_kfree_skb_any(skb);//edit by thomas - } + struct ieee80211_network *beacon = &ieee->current_network; + struct sk_buff *skb; + skb = ieee80211_disassociate_skb(beacon, ieee, asRsn); + if (skb) + softmac_mgmt_xmit(skb, ieee); } -//by amy for power save inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) { - unsigned int len,rate_len; + unsigned int len, rate_len; u8 *tag; struct sk_buff *skb; struct ieee80211_probe_request *req; @@ -327,75 +292,45 @@ inline struct sk_buff *ieee80211_probe_req(struct ieee80211_device *ieee) if (!skb) return NULL; - req = (struct ieee80211_probe_request *) skb_put(skb,sizeof(struct ieee80211_probe_request)); + req = (struct ieee80211_probe_request *) skb_put(skb, sizeof(struct ieee80211_probe_request)); req->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_PROBE_REQ); - req->header.duration_id = 0; //FIXME: is this OK ? + req->header.duration_id = 0; /* FIXME: is this OK ? */ memset(req->header.addr1, 0xff, ETH_ALEN); memcpy(req->header.addr2, ieee->dev->dev_addr, ETH_ALEN); memset(req->header.addr3, 0xff, ETH_ALEN); - tag = (u8 *) skb_put(skb,len+2+rate_len); + tag = (u8 *) skb_put(skb, len + 2 + rate_len); *tag++ = MFIE_TYPE_SSID; *tag++ = len; memcpy(tag, ieee->current_network.ssid, len); tag += len; - ieee80211_MFIE_Brate(ieee,&tag); - ieee80211_MFIE_Grate(ieee,&tag); + ieee80211_MFIE_Brate(ieee, &tag); + ieee80211_MFIE_Grate(ieee, &tag); return skb; } struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee); -void ext_ieee80211_send_beacon_wq(struct ieee80211_device *ieee) -{ - struct sk_buff *skb; - - //unsigned long flags; - - skb = ieee80211_get_beacon_(ieee); - - if (skb){ - softmac_mgmt_xmit(skb, ieee); - ieee->softmac_stats.tx_beacons++; - dev_kfree_skb_any(skb);//edit by thomas - } - - - //printk(KERN_WARNING "[1] beacon sending!\n"); - ieee->beacon_timer.expires = jiffies + - (MSECS( ieee->current_network.beacon_interval -5)); - - //spin_lock_irqsave(&ieee->beacon_lock,flags); - if(ieee->beacon_txing) - add_timer(&ieee->beacon_timer); - //spin_unlock_irqrestore(&ieee->beacon_lock,flags); -} - static void ieee80211_send_beacon(struct ieee80211_device *ieee) { struct sk_buff *skb; - //unsigned long flags; - skb = ieee80211_get_beacon_(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_beacons++; - dev_kfree_skb_any(skb);//edit by thomas + dev_kfree_skb_any(skb); } - //printk(KERN_WARNING "[1] beacon sending!\n"); ieee->beacon_timer.expires = jiffies + - (MSECS( ieee->current_network.beacon_interval -5)); + (MSECS(ieee->current_network.beacon_interval - 5)); - //spin_lock_irqsave(&ieee->beacon_lock,flags); - if(ieee->beacon_txing) + if (ieee->beacon_txing) add_timer(&ieee->beacon_timer); - //spin_unlock_irqrestore(&ieee->beacon_lock,flags); } @@ -415,16 +350,15 @@ static void ieee80211_send_probe(struct ieee80211_device *ieee) struct sk_buff *skb; skb = ieee80211_probe_req(ieee); - if (skb){ + if (skb) { softmac_mgmt_xmit(skb, ieee); ieee->softmac_stats.tx_probe_rq++; - //dev_kfree_skb_any(skb);//edit by thomas } } static void ieee80211_send_probe_requests(struct ieee80211_device *ieee) { - if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)){ + if (ieee->active_scan && (ieee->softmac_features & IEEE_SOFTMAC_PROBERQ)) { ieee80211_send_probe(ieee); ieee80211_send_probe(ieee); } @@ -439,17 +373,14 @@ static void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); down(&ieee->scan_sem); -// printk("==================> Sync scan\n"); - while(1) - { - - do{ + while (1) { + do { ch++; if (ch > MAX_CHANNEL_NUMBER) goto out; /* scan completed */ - }while(!channel_map[ch]); + } while (!channel_map[ch]); /* this function can be called in two situations * 1- We have switched to ad-hoc mode and we are * performing a complete syncro scan before conclude @@ -473,101 +404,74 @@ static void ieee80211_softmac_scan_syncro(struct ieee80211_device *ieee) goto out; ieee->set_chan(ieee->dev, ch); -// printk("=====>channel=%d ",ch); - if(channel_map[ch] == 1) - { -// printk("====send probe request\n"); + if (channel_map[ch] == 1) ieee80211_send_probe_requests(ieee); - } + /* this prevent excessive time wait when we * need to wait for a syncro scan to end.. */ if (ieee->sync_scan_hurryup) goto out; - msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - } out: ieee->sync_scan_hurryup = 0; up(&ieee->scan_sem); - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); } void ieee80211_softmac_ips_scan_syncro(struct ieee80211_device *ieee) { int ch; - unsigned int watch_dog = 0; + unsigned int watch_dog = 0; u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); - down(&ieee->scan_sem); + down(&ieee->scan_sem); ch = ieee->current_network.channel; -// if(ieee->sync_scan_hurryup) -// { - -// printk("stop scan sync\n"); -// goto out; -// } -// printk("=======hh===============>ips scan\n"); - while(1) - { - /* this function can be called in two situations - * 1- We have switched to ad-hoc mode and we are - * performing a complete syncro scan before conclude - * there are no interesting cell and to create a - * new one. In this case the link state is - * IEEE80211_NOLINK until we found an interesting cell. - * If so the ieee8021_new_net, called by the RX path - * will set the state to IEEE80211_LINKED, so we stop - * scanning - * 2- We are linked and the root uses run iwlist scan. - * So we switch to IEEE80211_LINKED_SCANNING to remember - * that we are still logically linked (not interested in - * new network events, despite for updating the net list, - * but we are temporarily 'unlinked' as the driver shall - * not filter RX frames and the channel is changing. - * So the only situation in witch are interested is to check - * if the state become LINKED because of the #1 situation - */ + + while (1) { + /* this function can be called in two situations + * 1- We have switched to ad-hoc mode and we are + * performing a complete syncro scan before conclude + * there are no interesting cell and to create a + * new one. In this case the link state is + * IEEE80211_NOLINK until we found an interesting cell. + * If so the ieee8021_new_net, called by the RX path + * will set the state to IEEE80211_LINKED, so we stop + * scanning + * 2- We are linked and the root uses run iwlist scan. + * So we switch to IEEE80211_LINKED_SCANNING to remember + * that we are still logically linked (not interested in + * new network events, despite for updating the net list, + * but we are temporarily 'unlinked' as the driver shall + * not filter RX frames and the channel is changing. + * So the only situation in witch are interested is to check + * if the state become LINKED because of the #1 situation + */ if (ieee->state == IEEE80211_LINKED) - { goto out; - } - if(channel_map[ieee->current_network.channel] > 0) - { + + if (channel_map[ieee->current_network.channel] > 0) ieee->set_chan(ieee->dev, ieee->current_network.channel); -// printk("======>channel=%d ",ieee->current_network.channel); - } - if(channel_map[ieee->current_network.channel] == 1) - { -// printk("====send probe request\n"); + + if (channel_map[ieee->current_network.channel] == 1) ieee80211_send_probe_requests(ieee); - } - /* this prevent excessive time wait when we - * need to wait for a syncro scan to end.. - */ -// if (ieee->sync_scan_hurryup) -// goto out; msleep_interruptible_rtl(IEEE80211_SOFTMAC_SCAN_TIME); - do{ + do { if (watch_dog++ >= MAX_CHANNEL_NUMBER) - // if (++watch_dog >= 15);//MAX_CHANNEL_NUMBER) //YJ,modified,080630 goto out; /* scan completed */ ieee->current_network.channel = (ieee->current_network.channel + 1)%MAX_CHANNEL_NUMBER; - }while(!channel_map[ieee->current_network.channel]); - } + } while (!channel_map[ieee->current_network.channel]); + } out: - //ieee->sync_scan_hurryup = 0; - //ieee->set_chan(ieee->dev, ch); - //ieee->current_network.channel = ch; ieee->actscanning = false; up(&ieee->scan_sem); - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); } @@ -575,29 +479,24 @@ static void ieee80211_softmac_scan_wq(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, softmac_scan_wq); - static short watchdog = 0; + static short watchdog; u8 channel_map[MAX_CHANNEL_NUMBER+1]; memcpy(channel_map, GET_DOT11D_INFO(ieee)->channel_map, MAX_CHANNEL_NUMBER+1); -// printk("ieee80211_softmac_scan_wq ENABLE_IPS\n"); -// printk("in %s\n",__func__); down(&ieee->scan_sem); - do{ + do { ieee->current_network.channel = (ieee->current_network.channel + 1) % MAX_CHANNEL_NUMBER; if (watchdog++ > MAX_CHANNEL_NUMBER) goto out; /* no good chans */ + } while (!channel_map[ieee->current_network.channel]); - }while(!channel_map[ieee->current_network.channel]); - - //printk("current_network.channel:%d\n", ieee->current_network.channel); - if (ieee->scanning == 0 ) - { + if (ieee->scanning == 0) { printk("error out, scanning = 0\n"); goto out; } ieee->set_chan(ieee->dev, ieee->current_network.channel); - if(channel_map[ieee->current_network.channel] == 1) + if (channel_map[ieee->current_network.channel] == 1) ieee80211_send_probe_requests(ieee); queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, IEEE80211_SOFTMAC_SCAN_TIME); @@ -609,7 +508,7 @@ out: ieee->scanning = 0; up(&ieee->scan_sem); - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) DOT11D_ScanComplete(ieee); return; } @@ -618,62 +517,51 @@ static void ieee80211_beacons_start(struct ieee80211_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 1; ieee80211_send_beacon(ieee); - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } static void ieee80211_beacons_stop(struct ieee80211_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->beacon_lock,flags); + spin_lock_irqsave(&ieee->beacon_lock, flags); ieee->beacon_txing = 0; - del_timer_sync(&ieee->beacon_timer); - - spin_unlock_irqrestore(&ieee->beacon_lock,flags); + del_timer_sync(&ieee->beacon_timer); + spin_unlock_irqrestore(&ieee->beacon_lock, flags); } - void ieee80211_stop_send_beacons(struct ieee80211_device *ieee) { - if(ieee->stop_send_beacons) + if (ieee->stop_send_beacons) ieee->stop_send_beacons(ieee->dev); if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) ieee80211_beacons_stop(ieee); } - void ieee80211_start_send_beacons(struct ieee80211_device *ieee) { - if(ieee->start_send_beacons) + if (ieee->start_send_beacons) ieee->start_send_beacons(ieee->dev); - if(ieee->softmac_features & IEEE_SOFTMAC_BEACONS) + if (ieee->softmac_features & IEEE_SOFTMAC_BEACONS) ieee80211_beacons_start(ieee); } - static void ieee80211_softmac_stop_scan(struct ieee80211_device *ieee) { -// unsigned long flags; - - //ieee->sync_scan_hurryup = 1; - down(&ieee->scan_sem); -// spin_lock_irqsave(&ieee->lock, flags); - if (ieee->scanning == 1){ + if (ieee->scanning == 1) { ieee->scanning = 0; - //del_timer_sync(&ieee->scan_timer); cancel_delayed_work(&ieee->softmac_scan_wq); } -// spin_unlock_irqrestore(&ieee->lock, flags); up(&ieee->scan_sem); } @@ -688,38 +576,28 @@ void ieee80211_stop_scan(struct ieee80211_device *ieee) /* called with ieee->lock held */ void ieee80211_rtl_start_scan(struct ieee80211_device *ieee) { - if(IS_DOT11D_ENABLE(ieee) ) - { - if(IS_COUNTRY_IE_VALID(ieee)) - { + if (IS_DOT11D_ENABLE(ieee)) { + if (IS_COUNTRY_IE_VALID(ieee)) RESET_CIE_WATCHDOG(ieee); - } } - if (ieee->softmac_features & IEEE_SOFTMAC_SCAN){ - if (ieee->scanning == 0) - { + + if (ieee->softmac_features & IEEE_SOFTMAC_SCAN) { + if (ieee->scanning == 0) { ieee->scanning = 1; - //ieee80211_softmac_scan(ieee); - // queue_work(ieee->wq, &ieee->softmac_scan_wq); - //care this,1203,2007,by lawrence #if 1 - queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq,0); + queue_delayed_work(ieee->wq, &ieee->softmac_scan_wq, 0); #endif } }else ieee->start_scan(ieee->dev); - } /* called with wx_sem held */ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) { - if(IS_DOT11D_ENABLE(ieee) ) - { - if(IS_COUNTRY_IE_VALID(ieee)) - { + if (IS_DOT11D_ENABLE(ieee)) { + if (IS_COUNTRY_IE_VALID(ieee)) RESET_CIE_WATCHDOG(ieee); - } } ieee->sync_scan_hurryup = 0; @@ -727,7 +605,6 @@ void ieee80211_start_scan_syncro(struct ieee80211_device *ieee) ieee80211_softmac_scan_syncro(ieee); else ieee->scan_syncro(ieee->dev); - } inline struct sk_buff * @@ -739,15 +616,17 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, skb = dev_alloc_skb(sizeof(struct ieee80211_authentication) + challengelen); - if (!skb) return NULL; + if (!skb) + return NULL; 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 |= IEEE80211_FCTL_WEP; - auth->header.duration_id = 0x013a; //FIXME + auth->header.duration_id = 0x013a; /* FIXME */ memcpy(auth->header.addr1, beacon->bssid, ETH_ALEN); memcpy(auth->header.addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -761,7 +640,6 @@ ieee80211_authentication_req(struct ieee80211_network *beacon, auth->status = cpu_to_le16(WLAN_STATUS_SUCCESS); return skb; - } static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, @@ -772,29 +650,30 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, struct ieee80211_probe_response *beacon_buf; struct sk_buff *skb; int encrypt; - int atim_len,erp_len; - struct ieee80211_crypt_data* crypt; + int atim_len, erp_len; + struct ieee80211_crypt_data *crypt; char *ssid = ieee->current_network.ssid; int ssid_len = ieee->current_network.ssid_len; int rate_len = ieee->current_network.rates_len+2; int rate_ex_len = ieee->current_network.rates_ex_len; int wpa_ie_len = ieee->wpa_ie_len; - if(rate_ex_len > 0) rate_ex_len+=2; + if (rate_ex_len > 0) + rate_ex_len += 2; - if(ieee->current_network.capability & WLAN_CAPABILITY_IBSS) + if (ieee->current_network.capability & WLAN_CAPABILITY_IBSS) atim_len = 4; else atim_len = 0; - if(ieee80211_is_54g(&ieee->current_network)) + if (ieee80211_is_54g(&ieee->current_network)) erp_len = 3; else erp_len = 0; beacon_size = sizeof(struct ieee80211_probe_response)+ ssid_len - +3 //channel + +3 /* channel */ +rate_len +rate_ex_len +atim_len @@ -806,19 +685,19 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, if (!skb) return NULL; - beacon_buf = (struct ieee80211_probe_response*) skb_put(skb, beacon_size); + beacon_buf = (struct ieee80211_probe_response *) skb_put(skb, beacon_size); - memcpy (beacon_buf->header.addr1, dest,ETH_ALEN); - memcpy (beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); - memcpy (beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); + memcpy(beacon_buf->header.addr1, dest, ETH_ALEN); + memcpy(beacon_buf->header.addr2, ieee->dev->dev_addr, ETH_ALEN); + memcpy(beacon_buf->header.addr3, ieee->current_network.bssid, ETH_ALEN); - beacon_buf->header.duration_id = 0; //FIXME + beacon_buf->header.duration_id = 0; /* FIXME */ beacon_buf->beacon_interval = cpu_to_le16(ieee->current_network.beacon_interval); beacon_buf->capability = cpu_to_le16(ieee->current_network.capability & WLAN_CAPABILITY_IBSS); - if(ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) + if (ieee->short_slot && (ieee->current_network.capability & WLAN_CAPABILITY_SHORT_SLOT)) beacon_buf->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); crypt = ieee->crypt[ieee->tx_keyidx]; @@ -835,51 +714,52 @@ static struct sk_buff *ieee80211_probe_resp(struct ieee80211_device *ieee, beacon_buf->info_element.id = MFIE_TYPE_SSID; beacon_buf->info_element.len = ssid_len; - tag = (u8*) beacon_buf->info_element.data; + tag = (u8 *) beacon_buf->info_element.data; memcpy(tag, ssid, ssid_len); tag += ssid_len; *(tag++) = MFIE_TYPE_RATES; - *(tag++) = rate_len-2; - memcpy(tag,ieee->current_network.rates,rate_len-2); - tag+=rate_len-2; + *(tag++) = rate_len - 2; + memcpy(tag, ieee->current_network.rates, rate_len-2); + tag += rate_len - 2; *(tag++) = MFIE_TYPE_DS_SET; *(tag++) = 1; *(tag++) = ieee->current_network.channel; - if(atim_len){ + if (atim_len) { *(tag++) = MFIE_TYPE_IBSS_SET; *(tag++) = 2; - *((u16*)(tag)) = cpu_to_le16(ieee->current_network.atim_window); - tag+=2; + *((u16 *)(tag)) = cpu_to_le16(ieee->current_network.atim_window); + tag += 2; } - if(erp_len){ + if (erp_len) { *(tag++) = MFIE_TYPE_ERP; *(tag++) = 1; *(tag++) = 0; } - if(rate_ex_len){ + if (rate_ex_len) { *(tag++) = MFIE_TYPE_RATES_EX; *(tag++) = rate_ex_len-2; - memcpy(tag,ieee->current_network.rates_ex,rate_ex_len-2); - tag+=rate_ex_len-2; + memcpy(tag, ieee->current_network.rates_ex, rate_ex_len-2); + tag += rate_ex_len - 2; } - if (wpa_ie_len) - { - if (ieee->iw_mode == IW_MODE_ADHOC) - {//as Windows will set pairwise key same as the group key which is not allowed in Linux, so set this for IOT issue. WB 2008.07.07 + if (wpa_ie_len) { + if (ieee->iw_mode == IW_MODE_ADHOC) { + /* as Windows will set pairwise key same as the group + * key which is not allowed in Linux, so set this for + * IOT issue. + */ memcpy(&ieee->wpa_ie[14], &ieee->wpa_ie[8], 4); } memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); } - skb->dev = ieee->dev; return skb; } @@ -888,9 +768,9 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *skb; - u8* tag; + u8 *tag; - struct ieee80211_crypt_data* crypt; + struct ieee80211_crypt_data *crypt; struct ieee80211_assoc_response_frame *assoc; short encrypt; @@ -903,34 +783,36 @@ static struct sk_buff *ieee80211_assoc_resp(struct ieee80211_device *ieee, return NULL; assoc = (struct ieee80211_assoc_response_frame *) - skb_put(skb,sizeof(struct ieee80211_assoc_response_frame)); + skb_put(skb, sizeof(struct ieee80211_assoc_response_frame)); assoc->header.frame_control = cpu_to_le16(IEEE80211_STYPE_ASSOC_RESP); - memcpy(assoc->header.addr1, dest,ETH_ALEN); + memcpy(assoc->header.addr1, dest, ETH_ALEN); memcpy(assoc->header.addr3, ieee->dev->dev_addr, ETH_ALEN); memcpy(assoc->header.addr2, ieee->dev->dev_addr, ETH_ALEN); assoc->capability = cpu_to_le16(ieee->iw_mode == IW_MODE_MASTER ? WLAN_CAPABILITY_BSS : WLAN_CAPABILITY_IBSS); - - if(ieee->short_slot) + if (ieee->short_slot) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); if (ieee->host_encrypt) crypt = ieee->crypt[ieee->tx_keyidx]; - else crypt = NULL; + else + crypt = NULL; - encrypt = ( crypt && crypt->ops); + encrypt = (crypt && crypt->ops); if (encrypt) assoc->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); assoc->status = 0; assoc->aid = cpu_to_le16(ieee->assoc_id); - if (ieee->assoc_id == 0x2007) ieee->assoc_id=0; - else ieee->assoc_id++; + if (ieee->assoc_id == 0x2007) + ieee->assoc_id = 0; + else + ieee->assoc_id++; - tag = (u8*) skb_put(skb, rate_len); + tag = (u8 *) skb_put(skb, rate_len); ieee80211_MFIE_Brate(ieee, &tag); ieee80211_MFIE_Grate(ieee, &tag); @@ -962,21 +844,19 @@ static struct sk_buff *ieee80211_auth_resp(struct ieee80211_device *ieee, memcpy(auth->header.addr1, dest, ETH_ALEN); auth->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_AUTH); return skb; - - } static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, short pwr) { struct sk_buff *skb; - struct ieee80211_hdr_3addr* hdr; + struct ieee80211_hdr_3addr *hdr; skb = dev_alloc_skb(sizeof(struct ieee80211_hdr_3addr)); if (!skb) return NULL; - hdr = (struct ieee80211_hdr_3addr*)skb_put(skb,sizeof(struct ieee80211_hdr_3addr)); + hdr = (struct ieee80211_hdr_3addr *)skb_put(skb, sizeof(struct ieee80211_hdr_3addr)); memcpy(hdr->addr1, ieee->current_network.bssid, ETH_ALEN); memcpy(hdr->addr2, ieee->dev->dev_addr, ETH_ALEN); @@ -987,83 +867,64 @@ static struct sk_buff *ieee80211_null_func(struct ieee80211_device *ieee, short (pwr ? IEEE80211_FCTL_PM:0)); return skb; - - } - static void ieee80211_resp_to_assoc_rq(struct ieee80211_device *ieee, u8 *dest) { struct sk_buff *buf = ieee80211_assoc_resp(ieee, dest); - if (buf){ + if (buf) { softmac_mgmt_xmit(buf, ieee); - dev_kfree_skb_any(buf);//edit by thomas + dev_kfree_skb_any(buf); } } - static void ieee80211_resp_to_auth(struct ieee80211_device *ieee, int s, u8 *dest) { struct sk_buff *buf = ieee80211_auth_resp(ieee, s, dest); - if (buf){ + if (buf) { softmac_mgmt_xmit(buf, ieee); - dev_kfree_skb_any(buf);//edit by thomas + dev_kfree_skb_any(buf); } } - static void ieee80211_resp_to_probe(struct ieee80211_device *ieee, u8 *dest) { - struct sk_buff *buf = ieee80211_probe_resp(ieee, dest); if (buf) { softmac_mgmt_xmit(buf, ieee); - dev_kfree_skb_any(buf);//edit by thomas + dev_kfree_skb_any(buf); } } - inline struct sk_buff * ieee80211_association_req(struct ieee80211_network *beacon, struct ieee80211_device *ieee) { struct sk_buff *skb; - //unsigned long flags; struct ieee80211_assoc_request_frame *hdr; u8 *tag; - //short info_addr = 0; - //int i; - //u16 suite_count = 0; - //u8 suit_select = 0; unsigned int wpa_len = beacon->wpa_ie_len; - //struct net_device *dev = ieee->dev; - //union iwreq_data wrqu; - //u8 *buff; - //u8 *p; #if 1 - // for testing purpose + /* for testing purpose */ unsigned int rsn_len = beacon->rsn_ie_len; -#else - unsigned int rsn_len = beacon->rsn_ie_len - 4; #endif unsigned int rate_len = ieee80211_MFIE_rate_len(ieee); unsigned int wmm_info_len = beacon->QoS_Enable?9:0; unsigned int turbo_info_len = beacon->Turbo_Enable?9:0; u8 encry_proto = ieee->wpax_type_notify & 0xff; - //u8 pairwise_type = (ieee->wpax_type_notify >> 8) & 0xff; - //u8 authen_type = (ieee->wpax_type_notify >> 16) & 0xff; int len = 0; - //[0] Notify type of encryption: WPA/WPA2 - //[1] pair wise type - //[2] authen type - if(ieee->wpax_type_set) { + /* [0] Notify type of encryption: WPA/WPA2 + * [1] pair wise type + * [2] authen type + */ + if (ieee->wpax_type_set) { if (IEEE_PROTO_WPA == encry_proto) { rsn_len = 0; } else if (IEEE_PROTO_RSN == encry_proto) { @@ -1071,8 +932,8 @@ ieee80211_association_req(struct ieee80211_network *beacon, } } len = sizeof(struct ieee80211_assoc_request_frame)+ - + beacon->ssid_len//essid tagged val - + rate_len//rates tagged val + + beacon->ssid_len /* essid tagged val */ + + rate_len /* rates tagged val */ + wpa_len + rsn_len + wmm_info_len @@ -1086,24 +947,23 @@ ieee80211_association_req(struct ieee80211_network *beacon, hdr = (struct ieee80211_assoc_request_frame *) skb_put(skb, sizeof(struct ieee80211_assoc_request_frame)); - hdr->header.frame_control = IEEE80211_STYPE_ASSOC_REQ; - hdr->header.duration_id= 37; //FIXME + hdr->header.duration_id = 37; /* FIXME */ 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); - memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN);//for HW security, John + memcpy(ieee->ap_mac_addr, beacon->bssid, ETH_ALEN); /* for HW security */ hdr->capability = cpu_to_le16(WLAN_CAPABILITY_BSS); - if (beacon->capability & WLAN_CAPABILITY_PRIVACY ) + if (beacon->capability & WLAN_CAPABILITY_PRIVACY) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_PRIVACY); if (beacon->capability & WLAN_CAPABILITY_SHORT_PREAMBLE) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_PREAMBLE); - if(ieee->short_slot) + if (ieee->short_slot) hdr->capability |= cpu_to_le16(WLAN_CAPABILITY_SHORT_SLOT); - hdr->listen_interval = 0xa; //FIXME + hdr->listen_interval = 0xa; /* FIXME */ hdr->info_element.id = MFIE_TYPE_SSID; @@ -1116,27 +976,26 @@ ieee80211_association_req(struct ieee80211_network *beacon, ieee80211_MFIE_Brate(ieee, &tag); ieee80211_MFIE_Grate(ieee, &tag); - //add rsn==0 condition for ap's mix security mode(wpa+wpa2), john2007.8.9 - //choose AES encryption as default algorithm while using mixed mode + /* add rsn==0 condition for ap's mix security mode(wpa+wpa2) + * choose AES encryption as default algorithm while using mixed mode. + */ - tag = skb_put(skb,ieee->wpa_ie_len); - memcpy(tag,ieee->wpa_ie,ieee->wpa_ie_len); + tag = skb_put(skb, ieee->wpa_ie_len); + memcpy(tag, ieee->wpa_ie, ieee->wpa_ie_len); - tag = skb_put(skb,wmm_info_len); - if(wmm_info_len) { + tag = skb_put(skb, wmm_info_len); + if (wmm_info_len) ieee80211_WMM_Info(ieee, &tag); - } - tag = skb_put(skb,turbo_info_len); - if(turbo_info_len) { - ieee80211_TURBO_Info(ieee, &tag); - } + + tag = skb_put(skb, turbo_info_len); + if (turbo_info_len) + ieee80211_TURBO_Info(ieee, &tag); return skb; } void ieee80211_associate_abort(struct ieee80211_device *ieee) { - unsigned long flags; spin_lock_irqsave(&ieee->lock, flags); @@ -1148,17 +1007,17 @@ void ieee80211_associate_abort(struct ieee80211_device *ieee) * Here we will check if there are good nets to associate * with, so we retry or just get back to NO_LINK and scanning */ - if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING){ + if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING) { IEEE80211_DEBUG_MGMT("Authentication failed\n"); ieee->softmac_stats.no_auth_rs++; - }else{ + } else { IEEE80211_DEBUG_MGMT("Association failed\n"); ieee->softmac_stats.no_ass_rs++; } ieee->state = IEEE80211_ASSOCIATING_RETRY; - queue_delayed_work(ieee->wq, &ieee->associate_retry_wq,IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); + queue_delayed_work(ieee->wq, &ieee->associate_retry_wq, IEEE80211_SOFTMAC_ASSOC_RETRY_TIME); spin_unlock_irqrestore(&ieee->lock, flags); } @@ -1168,7 +1027,6 @@ static void ieee80211_associate_abort_cb(unsigned long dev) ieee80211_associate_abort((struct ieee80211_device *) dev); } - static void ieee80211_associate_step1(struct ieee80211_device *ieee) { struct ieee80211_network *beacon = &ieee->current_network; @@ -1176,26 +1034,24 @@ static void ieee80211_associate_step1(struct ieee80211_device *ieee) IEEE80211_DEBUG_MGMT("Stopping scan\n"); ieee->softmac_stats.tx_auth_rq++; - skb=ieee80211_authentication_req(beacon, ieee, 0); - if (!skb){ - + skb = ieee80211_authentication_req(beacon, ieee, 0); + if (!skb) { ieee80211_associate_abort(ieee); - } - else{ - ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING ; + } else { + ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATING; IEEE80211_DEBUG_MGMT("Sending authentication request\n"); - //printk("---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)){ + /* BUGON when you try to add_timer twice, using mod_timer may + * be better. + */ + if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } - //If call dev_kfree_skb_any,a warning will ocur.... - //KERNEL: assertion (!atomic_read(&skb->users)) failed at net/core/dev.c (1708) - //So ... 1204 by lawrence. - //printk("\nIn %s,line %d call kfree skb.",__func__,__LINE__); - //dev_kfree_skb_any(skb);//edit by thomas + /* If call dev_kfree_skb_any,a warning will ocur.... + * KERNEL: assertion (!atomic_read(&skb->users)) failed at + * net/core/dev.c (1708) + */ } } @@ -1205,7 +1061,6 @@ static void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *chal u8 *c; struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; -// int hlen = sizeof(struct ieee80211_authentication); del_timer_sync(&ieee->associate_timer); ieee->associate_seq++; ieee->softmac_stats.tx_auth_rq++; @@ -1213,7 +1068,7 @@ static void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *chal skb = ieee80211_authentication_req(beacon, ieee, chlen+2); if (!skb) ieee80211_associate_abort(ieee); - else{ + else { c = skb_put(skb, chlen+2); *(c++) = MFIE_TYPE_CHALLENGE; *(c++) = chlen; @@ -1221,38 +1076,36 @@ static void ieee80211_rtl_auth_challenge(struct ieee80211_device *ieee, u8 *chal 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 ieee80211_hdr_3addr)); softmac_mgmt_xmit(skb, ieee); - if (!timer_pending(&ieee->associate_timer)){ - //printk("=========>add timer again, to crash\n"); + if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } - dev_kfree_skb_any(skb);//edit by thomas + dev_kfree_skb_any(skb); } kfree(challenge); } static void ieee80211_associate_step2(struct ieee80211_device *ieee) { - struct sk_buff* skb; + struct sk_buff *skb; struct ieee80211_network *beacon = &ieee->current_network; del_timer_sync(&ieee->associate_timer); IEEE80211_DEBUG_MGMT("Sending association request\n"); ieee->softmac_stats.tx_ass_rq++; - skb=ieee80211_association_req(beacon, ieee); + skb = ieee80211_association_req(beacon, ieee); if (!skb) ieee80211_associate_abort(ieee); - else{ + else { softmac_mgmt_xmit(skb, ieee); - if (!timer_pending(&ieee->associate_timer)){ + if (!timer_pending(&ieee->associate_timer)) { ieee->associate_timer.expires = jiffies + (HZ / 2); add_timer(&ieee->associate_timer); } - //dev_kfree_skb_any(skb);//edit by thomas } } @@ -1261,12 +1114,11 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, associate_complete_wq); printk(KERN_INFO "Associated successfully\n"); - if(ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ - + if (ieee80211_is_54g(&ieee->current_network) && + (ieee->modulation & IEEE80211_OFDM_MODULATION)) { ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); - }else{ + } else { ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } @@ -1279,12 +1131,8 @@ static void ieee80211_associate_complete_wq(struct work_struct *work) static void ieee80211_associate_complete(struct ieee80211_device *ieee) { - int i; del_timer_sync(&ieee->associate_timer); - for(i = 0; i < 6; i++) { - //ieee->seq_ctrl[i] = 0; - } ieee->state = IEEE80211_LINKED; IEEE80211_DEBUG_MGMT("Successfully associated\n"); @@ -1316,7 +1164,7 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, u8 tmp_ssid[IW_ESSID_MAX_SIZE+1]; int tmp_ssid_len = 0; - short apset,ssidset,ssidbroad,apmatch,ssidmatch; + short apset, ssidset, ssidbroad, apmatch, ssidmatch; /* we are interested in new new only if we are not associated * and we are not associating / authenticating @@ -1330,74 +1178,70 @@ inline void ieee80211_softmac_new_net(struct ieee80211_device *ieee, if ((ieee->iw_mode == IW_MODE_ADHOC) && !(net->capability & WLAN_CAPABILITY_IBSS)) return; - - if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC){ + if (ieee->iw_mode == IW_MODE_INFRA || ieee->iw_mode == IW_MODE_ADHOC) { /* if the user specified the AP MAC, we need also the essid * This could be obtained by beacons or, if the network does not * broadcast it, it can be put manually. */ - apset = ieee->wap_set;//(memcmp(ieee->current_network.bssid, zero,ETH_ALEN)!=0 ); - ssidset = ieee->ssid_set;//ieee->current_network.ssid[0] != '\0'; - ssidbroad = !(net->ssid_len == 0 || net->ssid[0]== '\0'); - apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN)==0); + apset = ieee->wap_set; + ssidset = ieee->ssid_set; + ssidbroad = !(net->ssid_len == 0 || net->ssid[0] == '\0'); + apmatch = (memcmp(ieee->current_network.bssid, net->bssid, ETH_ALEN) == 0); - if(ieee->current_network.ssid_len != net->ssid_len) + if (ieee->current_network.ssid_len != net->ssid_len) ssidmatch = 0; else - ssidmatch = (0==strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); - - //printk("cur: %s, %d, net:%s, %d\n", ieee->current_network.ssid, ieee->current_network.ssid_len, net->ssid, net->ssid_len); - //printk("apset=%d apmatch=%d ssidset=%d ssidbroad=%d ssidmatch=%d\n",apset,apmatch,ssidset,ssidbroad,ssidmatch); - - if ( /* if the user set the AP check if match. - * if the network does not broadcast essid we check the user supplied ANY essid - * if the network does broadcast and the user does not set essid it is OK - * if the network does broadcast and the user did set essid chech if essid match - */ - ( apset && apmatch && - ((ssidset && ssidbroad && ssidmatch) || (ssidbroad && !ssidset) || (!ssidbroad && ssidset)) ) || - /* if the ap is not set, check that the user set the bssid - * and the network does broadcast and that those two bssid matches - */ - (!apset && ssidset && ssidbroad && ssidmatch) - ){ - - + ssidmatch = (0 == strncmp(ieee->current_network.ssid, net->ssid, net->ssid_len)); + + /* if the user set the AP check if match. + * if the network does not broadcast essid we check the user + * supplied ANY essid + * if the network does broadcast and the user does not set essid + * it is OK + * if the network does broadcast and the user did set essid + * chech if essid match + * (apset && apmatch && ((ssidset && ssidbroad && ssidmatch) || + * (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || + * if the ap is not set, check that the user set the bssid and + * the network does broadcast and that those two bssid matches + * (!apset && ssidset && ssidbroad && ssidmatch) + */ + if ((apset && apmatch && ((ssidset && ssidbroad && ssidmatch) || + (ssidbroad && !ssidset) || (!ssidbroad && ssidset))) || + (!apset && ssidset && ssidbroad && ssidmatch)) { /* if the essid is hidden replace it with the * essid provided by the user. */ - if (!ssidbroad){ + if (!ssidbroad) { strncpy(tmp_ssid, ieee->current_network.ssid, IW_ESSID_MAX_SIZE); tmp_ssid_len = ieee->current_network.ssid_len; } memcpy(&ieee->current_network, net, sizeof(struct ieee80211_network)); - if (!ssidbroad){ + if (!ssidbroad) { 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 is %d\n",ieee->current_network.ssid,ieee->current_network.channel); + printk(KERN_INFO"Linking with %s: channel is %d\n", ieee->current_network.ssid, ieee->current_network.channel); - if (ieee->iw_mode == IW_MODE_INFRA){ + if (ieee->iw_mode == IW_MODE_INFRA) { ieee->state = IEEE80211_ASSOCIATING; ieee->beinretry = false; queue_work(ieee->wq, &ieee->associate_procedure_wq); - }else{ - if(ieee80211_is_54g(&ieee->current_network) && - (ieee->modulation & IEEE80211_OFDM_MODULATION)){ + } else { + if (ieee80211_is_54g(&ieee->current_network) && + (ieee->modulation & IEEE80211_OFDM_MODULATION)) { ieee->rate = 540; printk(KERN_INFO"Using G rates\n"); - }else{ + } else { ieee->rate = 110; printk(KERN_INFO"Using B rates\n"); } ieee->state = IEEE80211_LINKED; ieee->beinretry = false; } - } } - } void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) @@ -1407,60 +1251,52 @@ void ieee80211_softmac_check_all_nets(struct ieee80211_device *ieee) spin_lock_irqsave(&ieee->lock, flags); list_for_each_entry(target, &ieee->network_list, list) { - /* if the state become different that NOLINK means * we had found what we are searching for */ - if (ieee->state != IEEE80211_NOLINK) break; if (ieee->scan_age == 0 || time_after(target->last_scanned + ieee->scan_age, jiffies)) ieee80211_softmac_new_net(ieee, target); } - spin_unlock_irqrestore(&ieee->lock, flags); - } - static inline u16 auth_parse(struct sk_buff *skb, u8 **challenge, int *chlen) { struct ieee80211_authentication *a; u8 *t; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n",skb->len); + if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } *challenge = NULL; - a = (struct ieee80211_authentication*) skb->data; - if(skb->len > (sizeof(struct ieee80211_authentication) +3)){ + a = (struct ieee80211_authentication *) skb->data; + if (skb->len > (sizeof(struct ieee80211_authentication) + 3)) { t = skb->data + sizeof(struct ieee80211_authentication); - if(*(t++) == MFIE_TYPE_CHALLENGE){ + if (*(t++) == MFIE_TYPE_CHALLENGE) { *chlen = *(t++); *challenge = kmemdup(t, *chlen, GFP_ATOMIC); if (!*challenge) return -ENOMEM; } } - return cpu_to_le16(a->status); - } - static int auth_rq_parse(struct sk_buff *skb, u8 *dest) { struct ieee80211_authentication *a; - if (skb->len < (sizeof(struct ieee80211_authentication)-sizeof(struct ieee80211_info_element))){ - IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n",skb->len); + if (skb->len < (sizeof(struct ieee80211_authentication) - sizeof(struct ieee80211_info_element))) { + IEEE80211_DEBUG_MGMT("invalid len in auth request: %d\n", skb->len); return -1; } - a = (struct ieee80211_authentication*) skb->data; + a = (struct ieee80211_authentication *) skb->data; - memcpy(dest,a->header.addr2, ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); if (le16_to_cpu(a->algorithm) != WLAN_AUTH_OPEN) return WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG; @@ -1473,23 +1309,23 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, { u8 *tag; u8 *skbend; - u8 *ssid=NULL; + u8 *ssid = NULL; u8 ssidlen = 0; struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; - if (skb->len < sizeof (struct ieee80211_hdr_3addr )) + if (skb->len < sizeof(struct ieee80211_hdr_3addr)) return -1; /* corrupted */ - memcpy(src,header->addr2, ETH_ALEN); + memcpy(src, header->addr2, ETH_ALEN); - skbend = (u8*)skb->data + skb->len; + skbend = (u8 *)skb->data + skb->len; - tag = skb->data + sizeof (struct ieee80211_hdr_3addr ); + tag = skb->data + sizeof(struct ieee80211_hdr_3addr); - while (tag+1 < skbend){ - if (*tag == 0){ + while (tag+1 < skbend) { + if (*tag == 0) { ssid = tag+2; ssidlen = *(tag+1); break; @@ -1499,10 +1335,12 @@ static short probe_rq_parse(struct ieee80211_device *ieee, struct sk_buff *skb, tag++; /* point to the next tag */ } - //IEEE80211DMESG("Card MAC address is "MACSTR, MAC2STR(src)); - if (ssidlen == 0) return 1; + if (ssidlen == 0) + return 1; + + if (!ssid) + return 1; /* ssid not found in tagged param */ - if (!ssid) return 1; /* ssid not found in tagged param */ return (!strncmp(ssid, ieee->current_network.ssid, ssidlen)); } @@ -1514,13 +1352,13 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) if (skb->len < (sizeof(struct ieee80211_assoc_request_frame) - sizeof(struct ieee80211_info_element))) { - IEEE80211_DEBUG_MGMT("invalid len in auth request:%d \n", skb->len); + IEEE80211_DEBUG_MGMT("invalid len in auth request:%d\n", skb->len); return -1; } - a = (struct ieee80211_assoc_request_frame*) skb->data; + a = (struct ieee80211_assoc_request_frame *) skb->data; - memcpy(dest,a->header.addr2,ETH_ALEN); + memcpy(dest, a->header.addr2, ETH_ALEN); return 0; } @@ -1528,12 +1366,12 @@ static int assoc_rq_parse(struct sk_buff *skb, u8 *dest) static inline u16 assoc_parse(struct sk_buff *skb, int *aid) { struct ieee80211_assoc_response_frame *a; - if (skb->len < sizeof(struct ieee80211_assoc_response_frame)){ + if (skb->len < sizeof(struct ieee80211_assoc_response_frame)) { IEEE80211_DEBUG_MGMT("invalid len in auth resp: %d\n", skb->len); return 0xcafe; } - a = (struct ieee80211_assoc_response_frame*) skb->data; + a = (struct ieee80211_assoc_response_frame *) skb->data; *aid = le16_to_cpu(a->aid) & 0x3fff; return le16_to_cpu(a->status); } @@ -1543,11 +1381,8 @@ static inline void ieee80211_rx_probe_rq(struct ieee80211_device *ieee, { u8 dest[ETH_ALEN]; - //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_probe_rq++; - //DMESG("Dest is "MACSTR, MAC2STR(dest)); - if (probe_rq_parse(ieee, skb, dest)){ - //IEEE80211DMESG("Was for me!"); + if (probe_rq_parse(ieee, skb, dest)) { ieee->softmac_stats.tx_probe_rs++; ieee80211_resp_to_probe(ieee, dest); } @@ -1558,115 +1393,92 @@ inline void ieee80211_rx_auth_rq(struct ieee80211_device *ieee, { u8 dest[ETH_ALEN]; int status; - //IEEE80211DMESG("Rx probe"); ieee->softmac_stats.rx_auth_rq++; status = auth_rq_parse(skb, dest); - if (status != -1) { + if (status != -1) ieee80211_resp_to_auth(ieee, status, dest); - } - //DMESG("Dest is "MACSTR, MAC2STR(dest)); - } - inline void +inline void ieee80211_rx_assoc_rq(struct ieee80211_device *ieee, struct sk_buff *skb) { u8 dest[ETH_ALEN]; - //unsigned long flags; ieee->softmac_stats.rx_ass_rq++; - if (assoc_rq_parse(skb,dest) != -1){ + if (assoc_rq_parse(skb, dest) != -1) ieee80211_resp_to_assoc_rq(ieee, dest); - } + printk(KERN_INFO"New client associated: %pM\n", dest); } - - void ieee80211_sta_ps_send_null_frame(struct ieee80211_device *ieee, short pwr) { - struct sk_buff *buf = ieee80211_null_func(ieee, pwr); if (buf) softmac_ps_mgmt_xmit(buf, ieee); - } - static short ieee80211_sta_ps_sleep(struct ieee80211_device *ieee, u32 *time_h, u32 *time_l) { - int timeout = 0; + int timeout = 0; u8 dtim; - /*if(ieee->ps == IEEE80211_PS_DISABLED || - ieee->iw_mode != IW_MODE_INFRA || - ieee->state != IEEE80211_LINKED) - - return 0; - */ dtim = ieee->current_network.dtim_data; - //printk("DTIM\n"); - if(!(dtim & IEEE80211_DTIM_VALID)) + if (!(dtim & IEEE80211_DTIM_VALID)) return 0; - else - timeout = ieee->current_network.beacon_interval; + else + timeout = ieee->current_network.beacon_interval; - //printk("VALID\n"); ieee->current_network.dtim_data = IEEE80211_DTIM_INVALID; - if(dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST)& ieee->ps)) + if (dtim & ((IEEE80211_DTIM_UCAST | IEEE80211_DTIM_MBCAST) & ieee->ps)) return 2; - if(!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) + if (!time_after(jiffies, ieee->dev->trans_start + MSECS(timeout))) return 0; - if(!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) + if (!time_after(jiffies, ieee->last_rx_ps_time + MSECS(timeout))) return 0; - if((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE ) && + if ((ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE) && (ieee->mgmt_queue_tail != ieee->mgmt_queue_head)) return 0; - if(time_l){ + if (time_l) { *time_l = ieee->current_network.last_dtim_sta_time[0] + MSECS((ieee->current_network.beacon_interval)); - //* ieee->current_network.dtim_period)); - //printk("beacon_interval:%x, dtim_period:%x, totol to Msecs:%x, HZ:%x\n", ieee->current_network.beacon_interval, ieee->current_network.dtim_period, MSECS(((ieee->current_network.beacon_interval * ieee->current_network.dtim_period))), HZ); } - if(time_h){ + if (time_h) { *time_h = ieee->current_network.last_dtim_sta_time[1]; - if(time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) + if (time_l && *time_l < ieee->current_network.last_dtim_sta_time[0]) *time_h += 1; } return 1; - - } static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) { - u32 th,tl; + u32 th, tl; short sleep; - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); - if((ieee->ps == IEEE80211_PS_DISABLED || - + if ((ieee->ps == IEEE80211_PS_DISABLED || ieee->iw_mode != IW_MODE_INFRA || - ieee->state != IEEE80211_LINKED)){ + ieee->state != IEEE80211_LINKED)) { - //#warning CHECK_LOCK_HERE + /* #warning CHECK_LOCK_HERE */ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); ieee80211_sta_wakeup(ieee, 1); @@ -1674,71 +1486,57 @@ static inline void ieee80211_sta_ps(struct ieee80211_device *ieee) spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - sleep = ieee80211_sta_ps_sleep(ieee,&th, &tl); -// printk("===>%s,%d[2 wake, 1 sleep, 0 do nothing], ieee->sta_sleep = %d\n",__func__, sleep,ieee->sta_sleep); + sleep = ieee80211_sta_ps_sleep(ieee, &th, &tl); /* 2 wake, 1 sleep, 0 do nothing */ - if(sleep == 0) + if (sleep == 0) goto out; - if(sleep == 1){ - - if(ieee->sta_sleep == 1) - ieee->enter_sleep_state(ieee->dev,th,tl); + if (sleep == 1) { + if (ieee->sta_sleep == 1) + ieee->enter_sleep_state(ieee->dev, th, tl); - else if(ieee->sta_sleep == 0){ - // printk("send null 1\n"); + else if (ieee->sta_sleep == 0) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - - if(ieee->ps_is_queue_empty(ieee->dev)){ - - + if (ieee->ps_is_queue_empty(ieee->dev)) { ieee->sta_sleep = 2; ieee->ps_request_tx_ack(ieee->dev); - ieee80211_sta_ps_send_null_frame(ieee,1); + ieee80211_sta_ps_send_null_frame(ieee, 1); ieee->ps_th = th; ieee->ps_tl = tl; } spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); - } - - - }else if(sleep == 2){ -//#warning CHECK_LOCK_HERE + } else if (sleep == 2) { + /* #warning CHECK_LOCK_HERE */ spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); - // printk("send wakeup packet\n"); - ieee80211_sta_wakeup(ieee,1); + ieee80211_sta_wakeup(ieee, 1); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); } - out: spin_unlock_irqrestore(&ieee->lock, flags); - } void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) { - if(ieee->sta_sleep == 0){ - if(nl){ - // printk("Warning: driver is probably failing to report TX ps error\n"); + if (ieee->sta_sleep == 0) { + if (nl) { ieee->ps_request_tx_ack(ieee->dev); ieee80211_sta_ps_send_null_frame(ieee, 0); } return; - } - if(ieee->sta_sleep == 1) + if (ieee->sta_sleep == 1) ieee->sta_wake_up(ieee->dev); ieee->sta_sleep = 0; - if(nl){ + if (nl) { ieee->ps_request_tx_ack(ieee->dev); ieee80211_sta_ps_send_null_frame(ieee, 0); } @@ -1746,25 +1544,20 @@ void ieee80211_sta_wakeup(struct ieee80211_device *ieee, short nl) void ieee80211_ps_tx_ack(struct ieee80211_device *ieee, short success) { - unsigned long flags,flags2; + unsigned long flags, flags2; spin_lock_irqsave(&ieee->lock, flags); - if(ieee->sta_sleep == 2){ + if (ieee->sta_sleep == 2) { /* Null frame with PS bit set */ - if(success){ - - // printk("==================> %s::enter sleep state\n",__func__); + if (success) { ieee->sta_sleep = 1; - ieee->enter_sleep_state(ieee->dev,ieee->ps_th,ieee->ps_tl); + ieee->enter_sleep_state(ieee->dev, ieee->ps_th, ieee->ps_tl); } /* if the card report not success we can't be sure the AP * has not RXed so we can't assume the AP believe us awake */ - } - /* 21112005 - tx again null without PS bit if lost */ - else { - - if((ieee->sta_sleep == 0) && !success){ + } else { + if ((ieee->sta_sleep == 0) && !success) { spin_lock_irqsave(&ieee->mgmt_tx_lock, flags2); ieee80211_sta_ps_send_null_frame(ieee, 0); spin_unlock_irqrestore(&ieee->mgmt_tx_lock, flags2); @@ -1780,16 +1573,16 @@ inline int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, { struct ieee80211_hdr_3addr *header = (struct ieee80211_hdr_3addr *) skb->data; u16 errcode; - u8* challenge=NULL; - int chlen=0; - int aid=0; + u8 *challenge = NULL; + int chlen = 0; + int aid = 0; struct ieee80211_assoc_response_frame *assoc_resp; struct ieee80211_info_element *info_element; - if(!ieee->proto_started) + if (!ieee->proto_started) return 0; - if(ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && + if (ieee->sta_sleep || (ieee->ps != IEEE80211_PS_DISABLED && ieee->iw_mode == IW_MODE_INFRA && ieee->state == IEEE80211_LINKED)) @@ -1800,30 +1593,27 @@ inline int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, ieee->last_rx_ps_time = jiffies; switch (WLAN_FC_GET_STYPE(header->frame_control)) { - case IEEE80211_STYPE_ASSOC_RESP: case IEEE80211_STYPE_REASSOC_RESP: - IEEE80211_DEBUG_MGMT("received [RE]ASSOCIATION RESPONSE (%d)\n", WLAN_FC_GET_STYPE(header->frame_ctl)); if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATED && - ieee->iw_mode == IW_MODE_INFRA){ - if (0 == (errcode=assoc_parse(skb, &aid))){ + ieee->iw_mode == IW_MODE_INFRA) { + errcode = assoc_parse(skb, &aid); + if (0 == errcode) { u16 left; - ieee->state=IEEE80211_LINKED; + ieee->state = IEEE80211_LINKED; ieee->assoc_id = aid; ieee->softmac_stats.rx_ass_ok++; - - //printk(KERN_WARNING "nic_type = %s", (rx_stats->nic_type == 1)?"rtl8187":"rtl8187B"); - if(1 == rx_stats->nic_type) //card type is 8187 - { + /* card type is 8187 */ + if (1 == rx_stats->nic_type) goto associate_complete; - } - assoc_resp = (struct ieee80211_assoc_response_frame*)skb->data; - info_element = &assoc_resp->info_element; - left = skb->len - ((void*)info_element - (void*)assoc_resp); + + assoc_resp = (struct ieee80211_assoc_response_frame *)skb->data; + info_element = &assoc_resp->info_element; + left = skb->len - ((void *)info_element - (void *)assoc_resp); while (left >= sizeof(struct ieee80211_info_element_hdr)) { if (sizeof(struct ieee80211_info_element_hdr) + info_element->len > left) { @@ -1832,32 +1622,33 @@ inline int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, } switch (info_element->id) { case MFIE_TYPE_GENERIC: - IEEE80211_DEBUG_SCAN("MFIE_TYPE_GENERIC: %d bytes\n", info_element->len); + IEEE80211_DEBUG_SCAN("MFIE_TYPE_GENERIC: %d bytes\n", info_element->len); if (info_element->len >= 8 && info_element->data[0] == 0x00 && info_element->data[1] == 0x50 && info_element->data[2] == 0xf2 && info_element->data[3] == 0x02 && info_element->data[4] == 0x01) { - // Not care about version at present. - //WMM Parameter Element - memcpy(ieee->current_network.wmm_param,(u8*)(info_element->data\ - + 8),(info_element->len - 8)); - - if (((ieee->current_network.wmm_info^info_element->data[6])& \ - 0x0f)||(!ieee->init_wmmparam_flag)) { - // refresh parameter element for current network - // update the register parameter for hardware - ieee->init_wmmparam_flag = 1; - queue_work(ieee->wq, &ieee->wmm_param_update_wq); - - } - //update info_element for current network - ieee->current_network.wmm_info = info_element->data[6]; + /* Not care about version at present. + * WMM Parameter Element. + */ + memcpy(ieee->current_network.wmm_param, (u8 *)(info_element->data\ + + 8), (info_element->len - 8)); + + if (((ieee->current_network.wmm_info^info_element->data[6])& \ + 0x0f) || (!ieee->init_wmmparam_flag)) { + /* refresh parameter element for current network + * update the register parameter for hardware. + */ + ieee->init_wmmparam_flag = 1; + queue_work(ieee->wq, &ieee->wmm_param_update_wq); + } + /* update info_element for current network */ + ieee->current_network.wmm_info = info_element->data[6]; } break; default: - //nothing to do at present!!! + /* nothing to do at present!!! */ break; } @@ -1866,14 +1657,14 @@ inline int ieee80211_rx_frame_softmac(struct ieee80211_device *ieee, info_element = (struct ieee80211_info_element *) &info_element->data[info_element->len]; } - if(!ieee->init_wmmparam_flag) //legacy AP, reset the AC_xx_param register - { - queue_work(ieee->wq,&ieee->wmm_param_update_wq); - ieee->init_wmmparam_flag = 1;//indicate AC_xx_param upated since last associate + /* legacy AP, reset the AC_xx_param register */ + if (!ieee->init_wmmparam_flag) { + queue_work(ieee->wq, &ieee->wmm_param_update_wq); + ieee->init_wmmparam_flag = 1; /* indicate AC_xx_param upated since last associate */ } associate_complete: ieee80211_associate_complete(ieee); - }else{ + } else { ieee->softmac_stats.rx_ass_err++; IEEE80211_DEBUG_MGMT( "Association response status code 0x%x\n", @@ -1882,47 +1673,41 @@ associate_complete: } } break; - case IEEE80211_STYPE_ASSOC_REQ: case IEEE80211_STYPE_REASSOC_REQ: - if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && ieee->iw_mode == IW_MODE_MASTER) ieee80211_rx_assoc_rq(ieee, skb); break; - case IEEE80211_STYPE_AUTH: - - if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE){ + if (ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) { if (ieee->state == IEEE80211_ASSOCIATING_AUTHENTICATING && ieee->iw_mode == IW_MODE_INFRA){ - IEEE80211_DEBUG_MGMT("Received authentication response"); - if (0 == (errcode=auth_parse(skb, &challenge, &chlen))){ - if(ieee->open_wep || !challenge){ + errcode = auth_parse(skb, &challenge, &chlen); + if (0 == errcode) { + if (ieee->open_wep || !challenge) { ieee->state = IEEE80211_ASSOCIATING_AUTHENTICATED; ieee->softmac_stats.rx_auth_rs_ok++; ieee80211_associate_step2(ieee); - }else{ + } else { ieee80211_rtl_auth_challenge(ieee, challenge, chlen); } - }else{ + } else { ieee->softmac_stats.rx_auth_rs_err++; - IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x",errcode); + IEEE80211_DEBUG_MGMT("Authentication response status code 0x%x", errcode); ieee80211_associate_abort(ieee); } - }else if (ieee->iw_mode == IW_MODE_MASTER){ + } else if (ieee->iw_mode == IW_MODE_MASTER) { ieee80211_rx_auth_rq(ieee, skb); } } break; - case IEEE80211_STYPE_PROBE_REQ: - if ((ieee->softmac_features & IEEE_SOFTMAC_PROBERS) && ((ieee->iw_mode == IW_MODE_ADHOC || ieee->iw_mode == IW_MODE_MASTER) && @@ -1930,36 +1715,28 @@ associate_complete: ieee80211_rx_probe_rq(ieee, skb); break; - case IEEE80211_STYPE_DISASSOC: case IEEE80211_STYPE_DEAUTH: /* FIXME for now repeat all the association procedure - * both for disassociation and deauthentication - */ + * both for disassociation and deauthentication + */ if ((ieee->softmac_features & IEEE_SOFTMAC_ASSOCIATE) && (ieee->state == IEEE80211_LINKED) && (ieee->iw_mode == IW_MODE_INFRA) && - (!memcmp(header->addr2,ieee->current_network.bssid,ETH_ALEN))){ + (!memcmp(header->addr2, ieee->current_network.bssid, ETH_ALEN))) { ieee->state = IEEE80211_ASSOCIATING; ieee->softmac_stats.reassoc++; - //notify_wx_assoc_event(ieee); //YJ,del,080828, do not notify os here queue_work(ieee->wq, &ieee->associate_procedure_wq); } - break; - default: return -1; break; } - - //dev_kfree_skb_any(skb); return 0; } - - /* following are for a simpler TX queue management. * Instead of using netif_[stop/wake]_queue the driver * will uses these two function (plus a reset one), that @@ -1982,27 +1759,23 @@ associate_complete: void ieee80211_softmac_xmit(struct ieee80211_txb *txb, struct ieee80211_device *ieee) { - - unsigned long flags; int i; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); /* called with 2nd parm 0, no tx mgmt lock required */ - ieee80211_sta_wakeup(ieee,0); - - for(i = 0; i < txb->nr_frags; i++) { + ieee80211_sta_wakeup(ieee, 0); - if (ieee->queue_stop){ + for (i = 0; i < txb->nr_frags; i++) { + if (ieee->queue_stop) { ieee->tx_pending.txb = txb; ieee->tx_pending.frag = i; goto exit; - }else{ + } else { ieee->softmac_data_hard_start_xmit( txb->fragments[i], - ieee->dev,ieee->rate); - //(i+1)<txb->nr_frags); + ieee->dev, ieee->rate); ieee->stats.tx_packets++; ieee->stats.tx_bytes += txb->fragments[i]->len; ieee->dev->trans_start = jiffies; @@ -2012,66 +1785,59 @@ void ieee80211_softmac_xmit(struct ieee80211_txb *txb, ieee80211_txb_free(txb); exit: - spin_unlock_irqrestore(&ieee->lock,flags); - + spin_unlock_irqrestore(&ieee->lock, flags); } /* called with ieee->lock acquired */ static void ieee80211_resume_tx(struct ieee80211_device *ieee) { int i; - for(i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { + for (i = ieee->tx_pending.frag; i < ieee->tx_pending.txb->nr_frags; i++) { - if (ieee->queue_stop){ + if (ieee->queue_stop) { ieee->tx_pending.frag = i; return; - }else{ - + } else { ieee->softmac_data_hard_start_xmit( ieee->tx_pending.txb->fragments[i], - ieee->dev,ieee->rate); - //(i+1)<ieee->tx_pending.txb->nr_frags); + ieee->dev, ieee->rate); ieee->stats.tx_packets++; ieee->dev->trans_start = jiffies; } } - ieee80211_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } - void ieee80211_reset_queue(struct ieee80211_device *ieee) { unsigned long flags; - spin_lock_irqsave(&ieee->lock,flags); + spin_lock_irqsave(&ieee->lock, flags); init_mgmt_queue(ieee); - if (ieee->tx_pending.txb){ + if (ieee->tx_pending.txb) { ieee80211_txb_free(ieee->tx_pending.txb); ieee->tx_pending.txb = NULL; } ieee->queue_stop = 0; - spin_unlock_irqrestore(&ieee->lock,flags); - + spin_unlock_irqrestore(&ieee->lock, flags); } void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee) { - unsigned long flags; struct sk_buff *skb; struct ieee80211_hdr_3addr *header; - spin_lock_irqsave(&ieee->lock,flags); - if (! ieee->queue_stop) goto exit; + spin_lock_irqsave(&ieee->lock, flags); + if (!ieee->queue_stop) + goto exit; ieee->queue_stop = 0; - if(ieee->softmac_features & IEEE_SOFTMAC_SINGLE_QUEUE){ - while (!ieee->queue_stop && (skb = dequeue_mgmt(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->seq_ctrl = cpu_to_le16(ieee->seq_ctrl[0] << 4); @@ -2081,42 +1847,32 @@ void ieee80211_rtl_wake_queue(struct ieee80211_device *ieee) else ieee->seq_ctrl[0]++; - //printk(KERN_ALERT "ieee80211_wake_queue \n"); - ieee->softmac_data_hard_start_xmit(skb,ieee->dev,ieee->basic_rate); - dev_kfree_skb_any(skb);//edit by thomas + ieee->softmac_data_hard_start_xmit(skb, ieee->dev, ieee->basic_rate); + dev_kfree_skb_any(skb); } } if (!ieee->queue_stop && ieee->tx_pending.txb) ieee80211_resume_tx(ieee); - if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)){ + if (!ieee->queue_stop && netif_queue_stopped(ieee->dev)) { ieee->softmac_stats.swtxawake++; netif_wake_queue(ieee->dev); } - -exit : - spin_unlock_irqrestore(&ieee->lock,flags); +exit: + spin_unlock_irqrestore(&ieee->lock, flags); } - void ieee80211_rtl_stop_queue(struct ieee80211_device *ieee) { - //unsigned long flags; - //spin_lock_irqsave(&ieee->lock,flags); - - if (! netif_queue_stopped(ieee->dev)){ + if (!netif_queue_stopped(ieee->dev)) { netif_stop_queue(ieee->dev); ieee->softmac_stats.swtxstop++; } ieee->queue_stop = 1; - //spin_unlock_irqrestore(&ieee->lock,flags); - } - inline void ieee80211_randomize_cell(struct ieee80211_device *ieee) { - random_ether_addr(ieee->current_network.bssid); } @@ -2125,7 +1881,7 @@ void ieee80211_start_master_bss(struct ieee80211_device *ieee) { ieee->assoc_id = 1; - if (ieee->current_network.ssid_len == 0){ + if (ieee->current_network.ssid_len == 0) { strncpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID, IW_ESSID_MAX_SIZE); @@ -2149,7 +1905,7 @@ void ieee80211_start_master_bss(struct ieee80211_device *ieee) static void ieee80211_start_monitor_mode(struct ieee80211_device *ieee) { - if(ieee->raw_tx){ + if (ieee->raw_tx) { if (ieee->data_hard_resume) ieee->data_hard_resume(ieee->dev); @@ -2173,9 +1929,8 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) down(&ieee->wx_sem); - - if (ieee->current_network.ssid_len == 0){ - strcpy(ieee->current_network.ssid,IEEE80211_DEFAULT_TX_ESSID); + if (ieee->current_network.ssid_len == 0) { + strcpy(ieee->current_network.ssid, IEEE80211_DEFAULT_TX_ESSID); ieee->current_network.ssid_len = strlen(IEEE80211_DEFAULT_TX_ESSID); ieee->ssid_set = 1; } @@ -2183,7 +1938,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) /* check if we have this cell in our network list */ ieee80211_softmac_check_all_nets(ieee); - if(ieee->state == IEEE80211_NOLINK) + if (ieee->state == IEEE80211_NOLINK) ieee->current_network.channel = 10; /* if not then the state is not linked. Maybe the user switched to * ad-hoc mode just after being in monitor mode, or just after @@ -2203,13 +1958,12 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee80211_start_scan_syncro(ieee); /* the network definitively is not here.. create a new cell */ - if (ieee->state == IEEE80211_NOLINK){ + if (ieee->state == IEEE80211_NOLINK) { printk("creating new IBSS cell\n"); - if(!ieee->wap_set) + if (!ieee->wap_set) ieee80211_randomize_cell(ieee); - if(ieee->modulation & IEEE80211_CCK_MODULATION){ - + if (ieee->modulation & IEEE80211_CCK_MODULATION) { ieee->current_network.rates_len = 4; ieee->current_network.rates[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_1MB; @@ -2217,10 +1971,10 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->current_network.rates[2] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_5MB; ieee->current_network.rates[3] = IEEE80211_BASIC_RATE_MASK | IEEE80211_CCK_RATE_11MB; - }else + } else ieee->current_network.rates_len = 0; - if(ieee->modulation & IEEE80211_OFDM_MODULATION){ + if (ieee->modulation & IEEE80211_OFDM_MODULATION) { ieee->current_network.rates_ex_len = 8; ieee->current_network.rates_ex[0] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_6MB; @@ -2233,19 +1987,18 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) ieee->current_network.rates_ex[7] = IEEE80211_BASIC_RATE_MASK | IEEE80211_OFDM_RATE_54MB; ieee->rate = 540; - }else{ + } else { ieee->current_network.rates_ex_len = 0; ieee->rate = 110; } - // By default, WMM function will be disabled in IBSS mode + /* By default, WMM function will be disabled in IBSS mode */ ieee->current_network.QoS_Enable = 0; ieee->current_network.atim_window = 0; ieee->current_network.capability = WLAN_CAPABILITY_IBSS; - if(ieee->short_slot) + if (ieee->short_slot) ieee->current_network.capability |= WLAN_CAPABILITY_SHORT_SLOT; - } ieee->state = IEEE80211_LINKED; @@ -2264,6 +2017,7 @@ static void ieee80211_start_ibss_wq(struct work_struct *work) up(&ieee->wx_sem); } + inline void ieee80211_start_ibss(struct ieee80211_device *ieee) { queue_delayed_work(ieee->wq, &ieee->start_ibss_wq, 100); @@ -2273,19 +2027,15 @@ inline void ieee80211_start_ibss(struct ieee80211_device *ieee) void ieee80211_start_bss(struct ieee80211_device *ieee) { unsigned long flags; - // - // Ref: 802.11d 11.1.3.3 - // STA shall not start a BSS unless properly formed Beacon frame including a Country IE. - // - if(IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) - { - if(! ieee->bGlobalDomain) - { + /* Ref: 802.11d 11.1.3.3 + * STA shall not start a BSS unless properly formed Beacon frame + * including a Country IE. + */ + if (IS_DOT11D_ENABLE(ieee) && !IS_COUNTRY_IE_VALID(ieee)) { + if (!ieee->bGlobalDomain) return; - } } - /* check if we have already found the net we - * are interested in (if any). + /* check if we have already found the net we are interested in (if any). * if not (we are disassociated and we are not * in associating / authenticating phase) start the background scanning. */ @@ -2300,14 +2050,10 @@ void ieee80211_start_bss(struct ieee80211_device *ieee) */ spin_lock_irqsave(&ieee->lock, flags); -//#ifdef ENABLE_IPS -// printk("start bss ENABLE_IPS\n"); -//#else - if (ieee->state == IEEE80211_NOLINK){ + if (ieee->state == IEEE80211_NOLINK) { ieee->actscanning = true; ieee80211_rtl_start_scan(ieee); } -//#endif spin_unlock_irqrestore(&ieee->lock, flags); } @@ -2322,7 +2068,7 @@ void ieee80211_disassociate(struct ieee80211_device *ieee) if (ieee->data_hard_stop) ieee->data_hard_stop(ieee->dev); - if(IS_DOT11D_ENABLE(ieee)) + if (IS_DOT11D_ENABLE(ieee)) Dot11d_Reset(ieee); ieee->link_change(ieee->dev); @@ -2337,9 +2083,9 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, associate_retry_wq); unsigned long flags; down(&ieee->wx_sem); - if(!ieee->proto_started) + if (!ieee->proto_started) goto exit; - if(ieee->state != IEEE80211_ASSOCIATING_RETRY) + if (ieee->state != IEEE80211_ASSOCIATING_RETRY) goto exit; /* until we do not set the state to IEEE80211_NOLINK * there are no possibility to have someone else trying @@ -2360,17 +2106,13 @@ static void ieee80211_associate_retry_wq(struct work_struct *work) spin_lock_irqsave(&ieee->lock, flags); - if(ieee->state == IEEE80211_NOLINK){ + if (ieee->state == IEEE80211_NOLINK) { ieee->beinretry = false; ieee->actscanning = true; ieee80211_rtl_start_scan(ieee); } - //YJ,add,080828, notify os here - if(ieee->state == IEEE80211_NOLINK) - { + if (ieee->state == IEEE80211_NOLINK) notify_wx_assoc_event(ieee); - } - //YJ,add,080828,end spin_unlock_irqrestore(&ieee->lock, flags); exit: @@ -2379,7 +2121,7 @@ exit: struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) { - u8 broadcast_addr[] = {0xff,0xff,0xff,0xff,0xff,0xff}; + u8 broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; struct sk_buff *skb = NULL; struct ieee80211_probe_response *b; @@ -2392,7 +2134,6 @@ struct sk_buff *ieee80211_get_beacon_(struct ieee80211_device *ieee) b->header.frame_ctl = cpu_to_le16(IEEE80211_STYPE_BEACON); return skb; - } struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) @@ -2401,7 +2142,7 @@ struct sk_buff *ieee80211_get_beacon(struct ieee80211_device *ieee) struct ieee80211_probe_response *b; skb = ieee80211_get_beacon_(ieee); - if(!skb) + if (!skb) return NULL; b = (struct ieee80211_probe_response *) skb->data; @@ -2423,7 +2164,6 @@ void ieee80211_softmac_stop_protocol(struct ieee80211_device *ieee) up(&ieee->wx_sem); } - void ieee80211_stop_protocol(struct ieee80211_device *ieee) { if (!ieee->proto_started) @@ -2432,9 +2172,9 @@ void ieee80211_stop_protocol(struct ieee80211_device *ieee) ieee->proto_started = 0; ieee80211_stop_send_beacons(ieee); - if((ieee->iw_mode == IW_MODE_INFRA)&&(ieee->state == IEEE80211_LINKED)) { - SendDisassociation(ieee,NULL,WLAN_REASON_DISASSOC_STA_HAS_LEFT); - } + if ((ieee->iw_mode == IW_MODE_INFRA) && (ieee->state == IEEE80211_LINKED)) + SendDisassociation(ieee, NULL, WLAN_REASON_DISASSOC_STA_HAS_LEFT); + del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); cancel_delayed_work(&ieee->start_ibss_wq); @@ -2454,36 +2194,35 @@ void ieee80211_softmac_start_protocol(struct ieee80211_device *ieee) void ieee80211_start_protocol(struct ieee80211_device *ieee) { short ch = 0; - int i = 0; + int i = 0; if (ieee->proto_started) return; ieee->proto_started = 1; - if (ieee->current_network.channel == 0){ - do{ + if (ieee->current_network.channel == 0) { + do { ch++; if (ch > MAX_CHANNEL_NUMBER) return; /* no channel found */ - }while(!GET_DOT11D_INFO(ieee)->channel_map[ch]); + } while (!GET_DOT11D_INFO(ieee)->channel_map[ch]); ieee->current_network.channel = ch; } if (ieee->current_network.beacon_interval == 0) ieee->current_network.beacon_interval = 100; - ieee->set_chan(ieee->dev,ieee->current_network.channel); + ieee->set_chan(ieee->dev, ieee->current_network.channel); - for(i = 0; i < 17; i++) { - ieee->last_rxseq_num[i] = -1; - ieee->last_rxfrag_num[i] = -1; - ieee->last_packet_time[i] = 0; + for (i = 0; i < 17; i++) { + ieee->last_rxseq_num[i] = -1; + ieee->last_rxfrag_num[i] = -1; + ieee->last_packet_time[i] = 0; } - ieee->init_wmmparam_flag = 0;//reinitialize AC_xx_PARAM registers. - + ieee->init_wmmparam_flag = 0; /* reinitialize AC_xx_PARAM registers. */ /* if the user set the MAC of the ad-hoc cell and then * switch to managed mode, shall we make sure that association @@ -2493,7 +2232,7 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) switch (ieee->iw_mode) { case IW_MODE_AUTO: ieee->iw_mode = IW_MODE_INFRA; - //not set break here intentionly + /* not set break here intentionly */ case IW_MODE_INFRA: ieee80211_start_bss(ieee); break; @@ -2517,7 +2256,6 @@ void ieee80211_start_protocol(struct ieee80211_device *ieee) } } - #define DRV_NAME "Ieee80211" void ieee80211_softmac_init(struct ieee80211_device *ieee) { @@ -2526,36 +2264,29 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) ieee->state = IEEE80211_NOLINK; ieee->sync_scan_hurryup = 0; - for(i = 0; i < 5; i++) { - ieee->seq_ctrl[i] = 0; - } + for (i = 0; i < 5; i++) + ieee->seq_ctrl[i] = 0; ieee->assoc_id = 0; ieee->queue_stop = 0; ieee->scanning = 0; - ieee->softmac_features = 0; //so IEEE2100-like driver are happy + ieee->softmac_features = 0; /* so IEEE2100-like driver are happy */ ieee->wap_set = 0; ieee->ssid_set = 0; ieee->proto_started = 0; ieee->basic_rate = IEEE80211_DEFAULT_BASIC_RATE; ieee->rate = 3; -//#ifdef ENABLE_LPS ieee->ps = IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST; -//#else -// ieee->ps = IEEE80211_PS_DISABLED; -//#endif ieee->sta_sleep = 0; -//by amy ieee->bInactivePs = false; ieee->actscanning = false; ieee->ListenInterval = 2; - ieee->NumRxDataInPeriod = 0; //YJ,add,080828 - ieee->NumRxBcnInPeriod = 0; //YJ,add,080828 - ieee->NumRxOkTotal = 0;//+by amy 080312 - ieee->NumRxUnicast = 0;//YJ,add,080828,for keep alive + ieee->NumRxDataInPeriod = 0; + ieee->NumRxBcnInPeriod = 0; + ieee->NumRxOkTotal = 0; + ieee->NumRxUnicast = 0; /* for keep alive */ ieee->beinretry = false; ieee->bHwRadioOff = false; -//by amy init_mgmt_queue(ieee); @@ -2571,13 +2302,12 @@ void ieee80211_softmac_init(struct ieee80211_device *ieee) ieee->wq = create_workqueue(DRV_NAME); - INIT_DELAYED_WORK(&ieee->start_ibss_wq,(void*) ieee80211_start_ibss_wq); - INIT_WORK(&ieee->associate_complete_wq,(void*) ieee80211_associate_complete_wq); - INIT_WORK(&ieee->associate_procedure_wq,(void*) ieee80211_associate_procedure_wq); - INIT_DELAYED_WORK(&ieee->softmac_scan_wq,(void*) ieee80211_softmac_scan_wq); - INIT_DELAYED_WORK(&ieee->associate_retry_wq,(void*) ieee80211_associate_retry_wq); - INIT_WORK(&ieee->wx_sync_scan_wq,(void*) ieee80211_wx_sync_scan_wq); -// INIT_WORK(&ieee->watch_dog_wq,(void*) ieee80211_watch_dog_wq); + INIT_DELAYED_WORK(&ieee->start_ibss_wq, (void *) ieee80211_start_ibss_wq); + INIT_WORK(&ieee->associate_complete_wq, (void *) ieee80211_associate_complete_wq); + INIT_WORK(&ieee->associate_procedure_wq, (void *) ieee80211_associate_procedure_wq); + INIT_DELAYED_WORK(&ieee->softmac_scan_wq, (void *) ieee80211_softmac_scan_wq); + INIT_DELAYED_WORK(&ieee->associate_retry_wq, (void *) ieee80211_associate_retry_wq); + INIT_WORK(&ieee->wx_sync_scan_wq, (void *) ieee80211_wx_sync_scan_wq); sema_init(&ieee->wx_sem, 1); sema_init(&ieee->scan_sem, 1); @@ -2598,8 +2328,7 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee) del_timer_sync(&ieee->associate_timer); cancel_delayed_work(&ieee->associate_retry_wq); - - //add for RF power on power of by lizhaoming 080512 + /* add for RF power on power of */ cancel_delayed_work(&ieee->GPIOChangeRFWorkItem); destroy_workqueue(ieee->wq); @@ -2607,22 +2336,16 @@ void ieee80211_softmac_free(struct ieee80211_device *ieee) up(&ieee->wx_sem); } -/******************************************************** - * Start of WPA code. * - * this is stolen from the ipw2200 driver * - ********************************************************/ - - +/* Start of WPA code. This is stolen from the ipw2200 driver */ static int ieee80211_wpa_enable(struct ieee80211_device *ieee, int value) { /* This is called when wpa_supplicant loads and closes the driver * interface. */ - printk("%s WPA\n",value ? "enabling" : "disabling"); + printk("%s WPA\n", value ? "enabling" : "disabling"); ieee->wpa_enabled = value; return 0; } - static void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_ie, int wpa_ie_len) { @@ -2632,16 +2355,14 @@ static void ieee80211_wpa_assoc_frame(struct ieee80211_device *ieee, char *wpa_i ieee80211_disassociate(ieee); } - static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, int reason) { - int ret = 0; switch (command) { case IEEE_MLME_STA_DEAUTH: - // silently ignore + /* silently ignore */ break; case IEEE_MLME_STA_DISASSOC: @@ -2656,7 +2377,6 @@ static int ieee80211_wpa_mlme(struct ieee80211_device *ieee, int command, return ret; } - static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, struct ieee_param *param, int plen) { @@ -2690,7 +2410,6 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) { - struct ieee80211_security sec = { .flags = SEC_AUTH_MODE, }; @@ -2715,7 +2434,7 @@ static int ieee80211_wpa_set_auth_algs(struct ieee80211_device *ieee, int value) static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, u32 value) { - int ret=0; + int ret = 0; unsigned long flags; switch (name) { @@ -2724,7 +2443,7 @@ static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, break; case IEEE_PARAM_TKIP_COUNTERMEASURES: - ieee->tkip_countermeasures=value; + ieee->tkip_countermeasures = value; break; case IEEE_PARAM_DROP_UNENCRYPTED: { @@ -2743,15 +2462,14 @@ static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, .flags = SEC_ENABLED, .enabled = value, }; - ieee->drop_unencrypted = value; + ieee->drop_unencrypted = value; /* We only change SEC_LEVEL for open mode. Others * are set by ipw_wpa_set_encryption. */ if (!value) { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_0; - } - else { + } else { sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } @@ -2761,27 +2479,22 @@ static int ieee80211_wpa_set_param(struct ieee80211_device *ieee, u8 name, } case IEEE_PARAM_PRIVACY_INVOKED: - ieee->privacy_invoked=value; + ieee->privacy_invoked = value; break; - case IEEE_PARAM_AUTH_ALGS: ret = ieee80211_wpa_set_auth_algs(ieee, value); break; - case IEEE_PARAM_IEEE_802_1X: - ieee->ieee802_1x=value; + ieee->ieee802_1x = value; break; case IEEE_PARAM_WPAX_SELECT: - // added for WPA2 mixed mode - //printk(KERN_WARNING "------------------------>wpax value = %x\n", value); - spin_lock_irqsave(&ieee->wpax_suitlist_lock,flags); + spin_lock_irqsave(&ieee->wpax_suitlist_lock, flags); ieee->wpax_type_set = 1; ieee->wpax_type_notify = value; - spin_unlock_irqrestore(&ieee->wpax_suitlist_lock,flags); + spin_unlock_irqrestore(&ieee->wpax_suitlist_lock, flags); break; - default: - printk("Unknown WPA param: %d\n",name); + printk("Unknown WPA param: %d\n", name); ret = -EOPNOTSUPP; } @@ -2823,8 +2536,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, if (strcmp(param->u.crypt.alg, "none") == 0) { if (crypt) { sec.enabled = 0; - // FIXME FIXME - //sec.encrypt = 0; + /* FIXME FIXME */ sec.level = SEC_LEVEL_0; sec.flags |= SEC_ENABLED | SEC_LEVEL; ieee80211_crypt_delayed_deinit(ieee, crypt); @@ -2832,8 +2544,7 @@ static int ieee80211_wpa_set_encryption(struct ieee80211_device *ieee, goto done; } sec.enabled = 1; -// FIXME FIXME -// sec.encrypt = 1; + /* FIXME FIXME */ sec.flags |= SEC_ENABLED; /* IPW HW cannot build TKIP MIC, host decryption still needed. */ @@ -2942,12 +2653,11 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, struct iw_point *p) { struct ieee_param *param; - int ret=0; + int ret = 0; down(&ieee->wx_sem); - //IEEE_DEBUG_INFO("wpa_supplicant: len=%d\n", p->length); - if (p->length < sizeof(struct ieee_param) || !p->pointer){ + if (p->length < sizeof(struct ieee_param) || !p->pointer) { ret = -EINVAL; goto out; } @@ -2959,27 +2669,22 @@ int ieee80211_wpa_supplicant_ioctl(struct ieee80211_device *ieee, } switch (param->cmd) { - case IEEE_CMD_SET_WPA_PARAM: ret = ieee80211_wpa_set_param(ieee, param->u.wpa_param.name, param->u.wpa_param.value); break; - case IEEE_CMD_SET_WPA_IE: ret = ieee80211_wpa_set_wpa_ie(ieee, param, p->length); break; - case IEEE_CMD_SET_ENCRYPTION: ret = ieee80211_wpa_set_encryption(ieee, param, p->length); break; - case IEEE_CMD_MLME: ret = ieee80211_wpa_mlme(ieee, param->u.mlme.command, param->u.mlme.reason_code); break; - default: - printk("Unknown WPA supplicant request: %d\n",param->cmd); + printk("Unknown WPA supplicant request: %d\n", param->cmd); ret = -EOPNOTSUPP; break; } diff --git a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c index 3b7955f..07c3f71 100644 --- a/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c +++ b/drivers/staging/rtl8187se/ieee80211/ieee80211_wx.c @@ -1,38 +1,38 @@ -/****************************************************************************** - - Copyright(c) 2004 Intel Corporation. All rights reserved. - - Portions of this file are based on the WEP enablement code provided by the - Host AP project hostap-drivers v0.1.3 - Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen - <jkmaline@cc.hut.fi> - Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> - - This program is free software; you can redistribute it and/or modify it - under the terms of version 2 of the GNU General Public License as - published by the Free Software Foundation. - - This program is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for - more details. - - You should have received a copy of the GNU General Public License along with - this program; if not, write to the Free Software Foundation, Inc., 59 - Temple Place - Suite 330, Boston, MA 02111-1307, USA. - - The full GNU General Public License is included in this distribution in the - file called LICENSE. - - Contact Information: - James P. Ketrenos <ipw2100-admin@linux.intel.com> - Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 +/* + * Copyright(c) 2004 Intel Corporation. All rights reserved. + * + * Portions of this file are based on the WEP enablement code provided by the + * Host AP project hostap-drivers v0.1.3 + * Copyright (c) 2001-2002, SSH Communications Security Corp and Jouni Malinen + * <jkmaline@cc.hut.fi> + * Copyright (c) 2002-2003, Jouni Malinen <jkmaline@cc.hut.fi> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along with + * this program; if not, write to the Free Software Foundation, Inc., 59 + * Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + * The full GNU General Public License is included in this distribution in the + * file called LICENSE. + * + * Contact Information: + * James P. Ketrenos <ipw2100-admin@linux.intel.com> + * Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + */ -******************************************************************************/ #include <linux/wireless.h> #include <linux/kmod.h> #include <linux/slab.h> #include <linux/module.h> +#include <linux/etherdevice.h> #include "ieee80211.h" static const char *ieee80211_modes[] = { @@ -54,7 +54,7 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, /* First entry *MUST* be the AP MAC address */ iwe.cmd = SIOCGIWAP; iwe.u.ap_addr.sa_family = ARPHRD_ETHER; - memcpy(iwe.u.ap_addr.sa_data, network->bssid, ETH_ALEN); + ether_addr_copy(iwe.u.ap_addr.sa_data, network->bssid); start = iwe_stream_add_event(info, start, stop, &iwe, IW_EV_ADDR_LEN); /* Remaining entries will be displayed in the order we provide them */ @@ -62,17 +62,13 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, /* Add the ESSID */ iwe.cmd = SIOCGIWESSID; iwe.u.data.flags = 1; - //YJ,modified,080903,for hidden ap - //if (network->flags & NETWORK_EMPTY_ESSID) { if (network->ssid_len == 0) { - //YJ,modified,080903,end iwe.u.data.length = sizeof("<hidden>"); start = iwe_stream_add_point(info, start, stop, &iwe, "<hidden>"); } else { - iwe.u.data.length = min(network->ssid_len, (u8)32); + iwe.u.data.length = min_t(u8, network->ssid_len, 32); start = iwe_stream_add_point(info, start, stop, &iwe, network->ssid); } - //printk("ESSID: %s\n",network->ssid); /* Add the protocol name */ iwe.cmd = SIOCGIWNAME; snprintf(iwe.u.name, IFNAMSIZ, "IEEE 802.11%s", ieee80211_modes[network->mode]); @@ -92,8 +88,6 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, /* Add frequency/channel */ iwe.cmd = SIOCGIWFREQ; -/* iwe.u.freq.m = ieee80211_frequency(network->channel, network->mode); - iwe.u.freq.e = 3; */ iwe.u.freq.m = network->channel; iwe.u.freq.e = 0; iwe.u.freq.i = 0; @@ -145,10 +139,9 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, /* Add quality statistics */ /* TODO: Fix these values... */ if (network->stats.signal == 0 || network->stats.rssi == 0) - printk("========>signal:%d, rssi:%d\n", network->stats.signal, - network->stats.rssi); + netdev_info(ieee->dev, "========>signal:%d, rssi:%d\n", + network->stats.signal, network->stats.rssi); iwe.cmd = IWEVQUAL; -// printk("SIGNAL: %d,RSSI: %d,NOISE: %d\n",network->stats.signal,network->stats.rssi,network->stats.noise); iwe.u.qual.qual = network->stats.signalstrength; iwe.u.qual.level = network->stats.signal; iwe.u.qual.noise = network->stats.noise; @@ -171,7 +164,6 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, memset(&iwe, 0, sizeof(iwe)); if (network->wpa_ie_len) { - // printk("wpa_ie_len:%d\n", network->wpa_ie_len); char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->wpa_ie, network->wpa_ie_len); iwe.cmd = IWEVGENIE; @@ -181,7 +173,6 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, memset(&iwe, 0, sizeof(iwe)); if (network->rsn_ie_len) { - // printk("=====>rsn_ie_len:\n", network->rsn_ie_len); char buf[MAX_WPA_IE_LEN]; memcpy(buf, network->rsn_ie, network->rsn_ie_len); iwe.cmd = IWEVGENIE; @@ -190,7 +181,8 @@ static inline char *rtl818x_translate_scan(struct ieee80211_device *ieee, } /* Add EXTRA: Age to display seconds since last beacon/probe response - * for given network. */ + * for given network. + */ iwe.cmd = IWEVCUSTOM; p = custom; p += snprintf(p, MAX_CUSTOM_LEN - (p - custom), @@ -210,8 +202,7 @@ int ieee80211_wx_get_scan(struct ieee80211_device *ieee, unsigned long flags; int err = 0; char *ev = extra; - char *stop = ev + wrqu->data.length;//IW_SCAN_MAX_DATA; - //char *stop = ev + IW_SCAN_MAX_DATA; + char *stop = ev + wrqu->data.length; int i = 0; IEEE80211_DEBUG_WX("Getting scan\n"); @@ -287,7 +278,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, IEEE80211_DEBUG_WX("Disabling encryption.\n"); /* Check all the keys to see if any are still configured, - * and if no key index was provided, de-init them all */ + * and if no key index was provided, de-init them all. + */ for (i = 0; i < WEP_KEYS; i++) { if (ieee->crypt[i] != NULL) { if (key_provided) @@ -306,15 +298,14 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, goto done; } - - sec.enabled = 1; sec.flags |= SEC_ENABLED; if (*crypt != NULL && (*crypt)->ops != NULL && strcmp((*crypt)->ops->name, "WEP") != 0) { /* changing to use WEP; deinit previously used algorithm - * on this key */ + * on this key. + */ ieee80211_crypt_delayed_deinit(ieee, crypt); } @@ -359,10 +350,11 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, (*crypt)->priv); sec.flags |= (1 << key); /* This ensures a key will be activated if no key is - * explicitly set */ + * explicitly set. + */ if (key == sec.active_key) sec.flags |= SEC_ACTIVE_KEY; - ieee->tx_keyidx = key;//by wb 080312 + ieee->tx_keyidx = key; } else { len = (*crypt)->ops->get_key(sec.keys[key], WEP_KEY_LEN, NULL, (*crypt)->priv); @@ -395,7 +387,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, "OPEN" : "SHARED KEY"); /* For now we just support WEP, so only set that security level... - * TODO: When WPA is added this is one place that needs to change */ + * TODO: When WPA is added this is one place that needs to change + */ sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; /* 40 and 104 bit WEP */ @@ -406,7 +399,8 @@ int ieee80211_wx_set_encode(struct ieee80211_device *ieee, * generate new IEEE 802.11 authentication which may end up in looping * with IEEE 802.1X. If your hardware requires a reset after WEP * configuration (for example... Prism2), implement the reset_port in - * the callbacks structures used to initialize the 802.11 stack. */ + * the callbacks structures used to initialize the 802.11 stack. + */ if (ieee->reset_on_keychange && ieee->iw_mode != IW_MODE_INFRA && ieee->reset_port && ieee->reset_port(dev)) { @@ -448,7 +442,8 @@ int ieee80211_wx_get_encode(struct ieee80211_device *ieee, if (strcmp(crypt->ops->name, "WEP") != 0) { /* only WEP is supported with wireless extensions, so just - * report that encryption is used */ + * report that encryption is used. + */ erq->length = 0; erq->flags |= IW_ENCODE_ENABLED; return 0; @@ -483,7 +478,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) @@ -497,7 +491,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) @@ -506,7 +499,7 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, return -EINVAL; } - sec.flags |= SEC_ENABLED;// | SEC_ENCRYPT; + sec.flags |= SEC_ENABLED; if ((encoding->flags & IW_ENCODE_DISABLED) || ext->alg == IW_ENCODE_ALG_NONE) { if (*crypt) @@ -518,16 +511,13 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, if (i == WEP_KEYS) { sec.enabled = 0; - // sec.encrypt = 0; sec.level = SEC_LEVEL_0; sec.flags |= SEC_LEVEL; } - //printk("disabled: flag:%x\n", encoding->flags); goto done; } sec.enabled = 1; - // sec.encrypt = 1; switch (ext->alg) { case IW_ENCODE_ALG_WEP: @@ -545,7 +535,6 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, ret = -EINVAL; goto done; } -// printk("8-09-08-9=====>%s, alg name:%s\n",__func__, alg); ops = ieee80211_get_crypto_ops(alg); if (ops == NULL) @@ -553,7 +542,8 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, if (ops == NULL) { IEEE80211_DEBUG_WX("%s: unknown crypto alg %d\n", dev->name, ext->alg); - printk("========>unknown crypto alg %d\n", ext->alg); + netdev_err(ieee->dev, "========>unknown crypto alg %d\n", + ext->alg); ret = -EINVAL; goto done; } @@ -584,13 +574,11 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, (*crypt)->ops->set_key(ext->key, ext->key_len, ext->rx_seq, (*crypt)->priv) < 0) { IEEE80211_DEBUG_WX("%s: key setting failed\n", dev->name); - printk("key setting failed\n"); + netdev_err(ieee->dev, "key setting failed\n"); ret = -EINVAL; goto done; } #if 1 - //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; @@ -602,15 +590,12 @@ int ieee80211_wx_set_encode_ext(struct ieee80211_device *ieee, sec.key_sizes[idx] = ext->key_len; sec.flags |= (1 << idx); if (ext->alg == IW_ENCODE_ALG_WEP) { - // sec.encode_alg[idx] = SEC_ALG_WEP; sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_1; } else if (ext->alg == IW_ENCODE_ALG_TKIP) { - // sec.encode_alg[idx] = SEC_ALG_TKIP; sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_2; } else if (ext->alg == IW_ENCODE_ALG_CCMP) { - // sec.encode_alg[idx] = SEC_ALG_CCMP; sec.flags |= SEC_LEVEL; sec.level = SEC_LEVEL_3; } @@ -632,20 +617,19 @@ done: return ret; } + int ieee80211_wx_set_mlme(struct ieee80211_device *ieee, struct iw_request_info *info, union iwreq_data *wrqu, char *extra) { struct iw_mlme *mlme = (struct iw_mlme *) extra; -// printk("\ndkgadfslkdjgalskdf===============>%s(), cmd:%x\n", __func__, mlme->cmd); #if 1 switch (mlme->cmd) { case IW_MLME_DEAUTH: case IW_MLME_DISASSOC: - // printk("disassoc now\n"); ieee80211_disassociate(ieee); break; - default: + default: return -EOPNOTSUPP; } #endif @@ -656,24 +640,16 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, struct iw_request_info *info, struct iw_param *data, char *extra) { -/* - struct ieee80211_security sec = { - .flags = SEC_AUTH_MODE, - } -*/ - //printk("set auth:flag:%x, data value:%x\n", data->flags, data->value); switch (data->flags & IW_AUTH_INDEX) { case IW_AUTH_WPA_VERSION: - /*need to support wpa2 here*/ - //printk("wpa version:%x\n", data->value); + /* need to support wpa2 here */ break; case IW_AUTH_CIPHER_PAIRWISE: case IW_AUTH_CIPHER_GROUP: case IW_AUTH_KEY_MGMT: - /* - * * Host AP driver does not use these parameters and allows - * * wpa_supplicant to control them internally. - * */ + /* Host AP driver does not use these parameters and allows + * wpa_supplicant to control them internally. + */ break; case IW_AUTH_TKIP_COUNTERMEASURES: ieee->tkip_countermeasures = data->value; @@ -684,13 +660,11 @@ int ieee80211_wx_set_auth(struct ieee80211_device *ieee, case IW_AUTH_80211_AUTH_ALG: ieee->open_wep = (data->value&IW_AUTH_ALG_OPEN_SYSTEM) ? 1 : 0; - //printk("open_wep:%d\n", ieee->open_wep); break; #if 1 case IW_AUTH_WPA_ENABLED: ieee->wpa_enabled = (data->value) ? 1 : 0; - //printk("enable wpa:%d\n", ieee->wpa_enabled); break; #endif @@ -712,13 +686,13 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) u8 *buf = NULL; if (len > MAX_WPA_IE_LEN || (len && ie == NULL)) { - printk("return error out, len:%zu\n", len); + netdev_err(ieee->dev, "return error out, len:%zu\n", len); return -EINVAL; } if (len) { if (len != ie[1]+2) { - printk("len:%zu, ie:%d\n", len, ie[1]); + netdev_err(ieee->dev, "len:%zu, ie:%d\n", len, ie[1]); return -EINVAL; } buf = kmemdup(ie, len, GFP_KERNEL); @@ -732,7 +706,6 @@ int ieee80211_wx_set_gen_ie(struct ieee80211_device *ieee, u8 *ie, size_t len) ieee->wpa_ie = NULL; ieee->wpa_ie_len = 0; } -// printk("<=====out %s()\n", __func__); return 0; diff --git a/drivers/staging/rtl8187se/r8180.h b/drivers/staging/rtl8187se/r8180.h index 8999ec6..9f931db 100644 --- a/drivers/staging/rtl8187se/r8180.h +++ b/drivers/staging/rtl8187se/r8180.h @@ -1,19 +1,18 @@ /* - This is part of rtl8180 OpenSource driver. - Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> - Released under the terms of GPL (General Public Licence) - - Parts of this driver are based on the GPL part of the - official realtek driver - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver - - We want to thanks the Authors of those projects and the Ndiswrapper - project Authors. -*/ + * This is part of rtl8180 OpenSource driver. + * Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> + * Released under the terms of GPL (General Public Licence) + * + * Parts of this driver are based on the GPL part of the official realtek driver + * + * Parts of this driver are based on the rtl8180 driver skeleton from Patric + * Schenke & Andres Salomon + * + * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver + * + * We want to thanks the Authors of those projects and the Ndiswrapper project + * Authors. + */ #ifndef R8180H #define R8180H @@ -21,13 +20,12 @@ #include <linux/interrupt.h> #define RTL8180_MODULE_NAME "r8180" -#define DMESG(x,a...) printk(KERN_INFO RTL8180_MODULE_NAME ": " x "\n", ## a) -#define DMESGW(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": WW:" x "\n", ## a) -#define DMESGE(x,a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": EE:" x "\n", ## a) +#define DMESG(x, a...) printk(KERN_INFO RTL8180_MODULE_NAME ": " x "\n", ## a) +#define DMESGW(x, a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": WW:" x "\n", ## a) +#define DMESGE(x, a...) printk(KERN_WARNING RTL8180_MODULE_NAME ": EE:" x "\n", ## a) #include <linux/module.h> #include <linux/kernel.h> -//#include <linux/config.h> #include <linux/ioport.h> #include <linux/sched.h> #include <linux/types.h> @@ -36,22 +34,21 @@ #include <linux/pci.h> #include <linux/etherdevice.h> #include <linux/delay.h> -#include <linux/rtnetlink.h> //for rtnl_lock() +#include <linux/rtnetlink.h> /* for rtnl_lock() */ #include <linux/wireless.h> #include <linux/timer.h> -#include <linux/proc_fs.h> // Necessary because we use the proc fs +#include <linux/proc_fs.h> /* Necessary because we use the proc fs. */ #include <linux/if_arp.h> #include "ieee80211/ieee80211.h" #include <asm/io.h> -//#include <asm/semaphore.h> #define EPROM_93c46 0 #define EPROM_93c56 1 -#define RTL_IOCTL_WPA_SUPPLICANT SIOCIWFIRSTPRIV+30 +#define RTL_IOCTL_WPA_SUPPLICANT (SIOCIWFIRSTPRIV + 30) #define DEFAULT_FRAG_THRESHOLD 2342U -#define MIN_FRAG_THRESHOLD 256U +#define MIN_FRAG_THRESHOLD 256U #define DEFAULT_RTS_THRESHOLD 2342U #define MIN_RTS_THRESHOLD 0U #define MAX_RTS_THRESHOLD 2342U @@ -60,132 +57,99 @@ #define DEFAULT_RETRY_RTS 7 #define DEFAULT_RETRY_DATA 7 -#define BEACON_QUEUE 6 +#define BEACON_QUEUE 6 -#define aSifsTime 10 +#define aSifsTime 10 -#define sCrcLng 4 -#define sAckCtsLng 112 // bits in ACK and CTS frames -//+by amy 080312 -#define RATE_ADAPTIVE_TIMER_PERIOD 300 +#define sCrcLng 4 +#define sAckCtsLng 112 /* bits in ACK and CTS frames. */ +/* +by amy 080312. */ +#define RATE_ADAPTIVE_TIMER_PERIOD 300 -typedef enum _WIRELESS_MODE { +enum wireless_mode { WIRELESS_MODE_UNKNOWN = 0x00, WIRELESS_MODE_A = 0x01, WIRELESS_MODE_B = 0x02, WIRELESS_MODE_G = 0x04, WIRELESS_MODE_AUTO = 0x08, -} WIRELESS_MODE; - -typedef struct ChnlAccessSetting { - u16 SIFS_Timer; - u16 DIFS_Timer; - u16 SlotTimeTimer; - u16 EIFS_Timer; - u16 CWminIndex; - u16 CWmaxIndex; -}*PCHANNEL_ACCESS_SETTING,CHANNEL_ACCESS_SETTING; - -typedef enum{ - NIC_8185 = 1, - NIC_8185B - } nic_t; +}; + +struct chnl_access_setting { + u16 sifs_timer; + u16 difs_timer; + u16 slot_time_timer; + u16 eifs_timer; + u16 cwmin_index; + u16 cwmax_index; +}; + +enum nic_t { + NIC_8185 = 1, + NIC_8185B +}; typedef u32 AC_CODING; -#define AC0_BE 0 // ACI: 0x00 // Best Effort -#define AC1_BK 1 // ACI: 0x01 // Background -#define AC2_VI 2 // ACI: 0x10 // Video -#define AC3_VO 3 // ACI: 0x11 // Voice -#define AC_MAX 4 // Max: define total number; Should not to be used as a real enum. - -// -// ECWmin/ECWmax field. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.13. -// -typedef union _ECW{ - u8 charData; - struct - { - u8 ECWmin:4; - u8 ECWmax:4; - }f; // Field -}ECW, *PECW; - -// -// ACI/AIFSN Field. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.12. -// -typedef union _ACI_AIFSN{ - u8 charData; - - struct - { - u8 AIFSN:4; - u8 ACM:1; - u8 ACI:2; - u8 Reserved:1; - }f; // Field -}ACI_AIFSN, *PACI_AIFSN; - -// -// AC Parameters Record Format. -// Ref: WMM spec 2.2.2: WME Parameter Element, p.12. -// -typedef union _AC_PARAM{ - u32 longData; - u8 charData[4]; - - struct - { - ACI_AIFSN AciAifsn; - ECW Ecw; - u16 TXOPLimit; - }f; // Field -}AC_PARAM, *PAC_PARAM; - -/* it is a wrong definition. -xiong-2006-11-17 -typedef struct ThreeWireReg { - u16 longData; +#define AC0_BE 0 /* ACI: 0x00 */ /* Best Effort. */ +#define AC1_BK 1 /* ACI: 0x01 */ /* Background. */ +#define AC2_VI 2 /* ACI: 0x10 */ /* Video. */ +#define AC3_VO 3 /* ACI: 0x11 */ /* Voice. */ +#define AC_MAX 4 /* Max: define total number; Should not to be used as a real + * enum. + */ + +/* + * ECWmin/ECWmax field. + * Ref: WMM spec 2.2.2: WME Parameter Element, p.13. + */ +typedef union _ECW { + u8 charData; + struct { + u8 ECWmin:4; + u8 ECWmax:4; + } f; /* Field */ +} ECW, *PECW; + +/* + * ACI/AIFSN Field. Ref: WMM spec 2.2.2: WME Parameter Element, p.12. + */ +typedef union _ACI_AIFSN { + u8 charData; + struct { - u8 enableB; - u8 data; - u8 clk; - u8 read_write; - } struc; -} ThreeWireReg; -*/ - -typedef union _ThreeWire{ - struct _ThreeWireStruc{ - u16 data:1; - u16 clk:1; - u16 enableB:1; - u16 read_write:1; - u16 resv1:12; -// u2Byte resv2:14; -// u2Byte ThreeWireEnable:1; -// u2Byte resv3:1; - }struc; - u16 longData; -}ThreeWireReg; - - -typedef struct buffer -{ + u8 AIFSN:4; + u8 ACM:1; + u8 ACI:2; + u8 Reserved:1; + } f; /* Field */ +} ACI_AIFSN, *PACI_AIFSN; + +/* + * AC Parameters Record Format. + * Ref: WMM spec 2.2.2: WME Parameter Element, p.12. + */ +typedef union _AC_PARAM { + u32 longData; + u8 charData[4]; + + struct { + ACI_AIFSN AciAifsn; + ECW Ecw; + u16 TXOPLimit; + } f; /* Field */ +} AC_PARAM, *PAC_PARAM; + +struct buffer { struct buffer *next; u32 *buf; dma_addr_t dma; -} buffer; +}; -//YJ,modified,080828 -typedef struct Stats -{ +/* YJ,modified,080828. */ +struct stats { unsigned long txrdu; unsigned long rxrdu; unsigned long rxnolast; unsigned long rxnodata; -// unsigned long rxreset; -// unsigned long rxwrkaround; unsigned long rxnopointer; unsigned long txnperr; unsigned long txresumed; @@ -207,126 +171,123 @@ typedef struct Stats unsigned long txbeaconerr; unsigned long txlpokint; unsigned long txlperr; - unsigned long txretry;//retry number tony 20060601 - unsigned long rxcrcerrmin;//crc error (0-500) - unsigned long rxcrcerrmid;//crc error (500-1000) - unsigned long rxcrcerrmax;//crc error (>1000) - unsigned long rxicverr;//ICV error -} Stats; + unsigned long txretry; /* retry number tony 20060601 */ + unsigned long rxcrcerrmin; /* crc error (0-500) */ + unsigned long rxcrcerrmid; /* crc error (500-1000) */ + unsigned long rxcrcerrmax; /* crc error (>1000) */ + unsigned long rxicverr; /* ICV error */ +}; #define MAX_LD_SLOT_NUM 10 -#define KEEP_ALIVE_INTERVAL 20 // in seconds. -#define CHECK_FOR_HANG_PERIOD 2 //be equal to watchdog check time -#define DEFAULT_KEEP_ALIVE_LEVEL 1 -#define DEFAULT_SLOT_NUM 2 -#define POWER_PROFILE_AC 0 -#define POWER_PROFILE_BATTERY 1 - -typedef struct _link_detect_t -{ - u32 RxFrameNum[MAX_LD_SLOT_NUM]; // number of Rx Frame / CheckForHang_period to determine link status - u16 SlotNum; // number of CheckForHang period to determine link status, default is 2 - u16 SlotIndex; - - u32 NumTxOkInPeriod; //number of packet transmitted during CheckForHang - u32 NumRxOkInPeriod; //number of packet received during CheckForHang - - u8 IdleCount; // (KEEP_ALIVE_INTERVAL / CHECK_FOR_HANG_PERIOD) - u32 LastNumTxUnicast; - u32 LastNumRxUnicast; - - bool bBusyTraffic; //when it is set to 1, UI cann't scan at will. -}link_detect_t, *plink_detect_t; - -//YJ,modified,080828,end - -//by amy for led -//================================================================================ -// LED customization. -//================================================================================ - -typedef enum _LED_STRATEGY_8185{ - SW_LED_MODE0, // - SW_LED_MODE1, // - HW_LED, // HW control 2 LEDs, LED0 and LED1 (there are 4 different control modes) -}LED_STRATEGY_8185, *PLED_STRATEGY_8185; -//by amy for led -//by amy for power save -typedef enum _LED_CTL_MODE{ - LED_CTL_POWER_ON = 1, - LED_CTL_LINK = 2, - LED_CTL_NO_LINK = 3, - LED_CTL_TX = 4, - LED_CTL_RX = 5, - LED_CTL_SITE_SURVEY = 6, - LED_CTL_POWER_OFF = 7 -}LED_CTL_MODE; - -typedef enum _RT_RF_POWER_STATE -{ - eRfOn, - eRfSleep, - eRfOff -}RT_RF_POWER_STATE; - -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, +#define KEEP_ALIVE_INTERVAL 20 /* in seconds. */ +#define CHECK_FOR_HANG_PERIOD 2 /* be equal to watchdog check time. */ +#define DEFAULT_KEEP_ALIVE_LEVEL 1 +#define DEFAULT_SLOT_NUM 2 +#define POWER_PROFILE_AC 0 +#define POWER_PROFILE_BATTERY 1 + +struct link_detect_t { + u32 rx_frame_num[MAX_LD_SLOT_NUM]; /* number of Rx Frame. + * CheckForHang_period to determine + * link status. + */ + u16 slot_num; /* number of CheckForHang period to determine link status, + * default is 2. + */ + u16 slot_index; + u32 num_tx_ok_in_period; /* number of packet transmitted during + * CheckForHang. + */ + u32 num_rx_ok_in_period; /* number of packet received during + * CheckForHang. + */ + u8 idle_count; /* (KEEP_ALIVE_INTERVAL / CHECK_FOR_HANG_PERIOD) */ + u32 last_num_tx_unicast; + u32 last_num_rx_unicast; + + bool b_busy_traffic; /* when it is set to 1, UI cann't scan at will. */ +}; + +/* YJ,modified,080828,end */ + +/* by amy for led + * ========================================================================== + * LED customization. + * ========================================================================== + */ +enum led_strategy_8185 { + SW_LED_MODE0, + SW_LED_MODE1, + HW_LED, /* HW control 2 LEDs, LED0 and LED1 (there are 4 different + * control modes). */ +}; + +enum rt_rf_power_state { + RF_ON, + RF_SLEEP, + RF_OFF +}; + +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, + 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 + 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 */ +}; + +enum rt_ps_mode { + ACTIVE, /* Active/Continuous access. */ + MAX_PS, /* Max power save mode. */ + FAST_PS /* Fast power save mode. */ }; -typedef enum _RT_PS_MODE -{ - eActive, // Active/Continuous access. - eMaxPs, // Max power save mode. - eFastPs // Fast power save mode. -}RT_PS_MODE; -//by amy for power save -typedef struct r8180_priv -{ + +/* by amy for power save. */ +struct r8180_priv { struct pci_dev *pdev; short epromtype; int irq; struct ieee80211_device *ieee80211; - short plcp_preamble_mode; // 0:auto 1:short 2:long + short plcp_preamble_mode; /* 0:auto 1:short 2:long */ spinlock_t irq_th_lock; spinlock_t tx_lock; @@ -339,19 +300,15 @@ typedef struct r8180_priv short chan; short sens; short max_sens; - u8 chtxpwr[15]; //channels from 1 to 14, 0 not used - u8 chtxpwr_ofdm[15]; //channels from 1 to 14, 0 not used - //u8 challow[15]; //channels from 1 to 14, 0 not used - u8 channel_plan; // it's the channel plan index + u8 chtxpwr[15]; /* channels from 1 to 14, 0 not used. */ + u8 chtxpwr_ofdm[15]; /* channels from 1 to 14, 0 not used. */ + u8 channel_plan; /* it's the channel plan index. */ short up; - short crcmon; //if 1 allow bad crc frame reception in monitor mode + short crcmon; /* if 1 allow bad crc frame reception in monitor mode. */ struct timer_list scan_timer; - /*short scanpending; - short stopscan;*/ spinlock_t scan_lock; u8 active_probe; - //u8 active_scan_num; struct semaphore wx_sem; short hw_wep; @@ -359,20 +316,20 @@ typedef struct r8180_priv short antb; short diversity; u32 key0[4]; - short (*rf_set_sens)(struct net_device *dev,short sens); - void (*rf_set_chan)(struct net_device *dev,short ch); + short (*rf_set_sens)(struct net_device *dev, short sens); + void (*rf_set_chan)(struct net_device *dev, short ch); void (*rf_close)(struct net_device *dev); void (*rf_init)(struct net_device *dev); void (*rf_sleep)(struct net_device *dev); void (*rf_wakeup)(struct net_device *dev); - //short rate; + /* short rate; */ short promisc; - /*stats*/ - struct Stats stats; - struct _link_detect_t link_detect; //YJ,add,080828 + /* stats */ + struct stats stats; + struct link_detect_t link_detect; /* YJ,add,080828 */ struct iw_statistics wstats; - /*RX stuff*/ + /* RX stuff. */ u32 *rxring; u32 *rxringtail; dma_addr_t rxringdma; @@ -387,27 +344,6 @@ typedef struct r8180_priv u32 rx_prevlen; - /*TX stuff*/ -/* - u32 *txlpring; - u32 *txhpring; - u32 *txnpring; - dma_addr_t txlpringdma; - dma_addr_t txhpringdma; - dma_addr_t txnpringdma; - u32 *txlpringtail; - u32 *txhpringtail; - u32 *txnpringtail; - u32 *txlpringhead; - u32 *txhpringhead; - u32 *txnpringhead; - struct buffer *txlpbufs; - struct buffer *txhpbufs; - struct buffer *txnpbufs; - struct buffer *txlpbufstail; - struct buffer *txhpbufstail; - struct buffer *txnpbufstail; -*/ u32 *txmapring; u32 *txbkpring; u32 *txbepring; @@ -447,54 +383,47 @@ typedef struct r8180_priv int txringcount; int txbuffsize; - //struct tx_pendingbuf txnp_pending; - //struct tasklet_struct irq_tx_tasklet; struct tasklet_struct irq_rx_tasklet; u8 dma_poll_mask; - //short tx_suspend; - /* adhoc/master mode stuff */ + /* adhoc/master mode stuff. */ u32 *txbeaconringtail; dma_addr_t txbeaconringdma; u32 *txbeaconring; int txbeaconcount; struct buffer *txbeaconbufs; struct buffer *txbeaconbufstail; - //char *master_essid; - //u16 master_beaconinterval; - //u32 master_beaconsize; - //u16 beacon_interval; u8 retry_data; u8 retry_rts; u16 rts; -//by amy for led - LED_STRATEGY_8185 LedStrategy; -//by amy for led + /* by amy for led. */ + enum led_strategy_8185 led_strategy; + /* by amy for led. */ -//by amy for power save + /* by amy for power save. */ struct timer_list watch_dog_timer; bool bInactivePs; bool bSwRfProcessing; - RT_RF_POWER_STATE eInactivePowerState; - RT_RF_POWER_STATE eRFPowerState; + enum rt_rf_power_state eInactivePowerState; + enum rt_rf_power_state eRFPowerState; u32 RfOffReason; bool RFChangeInProgress; bool SetRFPowerStateInProgress; - u8 RFProgType; + u8 RFProgType; bool bLeisurePs; - RT_PS_MODE dot11PowerSaveMode; - //u32 NumRxOkInPeriod; //YJ,del,080828 - //u32 NumTxOkInPeriod; //YJ,del,080828 - u8 TxPollingTimes; + enum rt_ps_mode dot11PowerSaveMode; + u8 TxPollingTimes; - bool bApBufOurFrame;// TRUE if AP buffer our unicast data , we will keep eAwake until receive data or timeout. - u8 WaitBufDataBcnCount; - u8 WaitBufDataTimeOut; + bool bApBufOurFrame; /* TRUE if AP buffer our unicast data , we will + * keep eAwake until receive data or timeout. + */ + u8 WaitBufDataBcnCount; + u8 WaitBufDataTimeOut; -//by amy for power save -//by amy for antenna + /* by amy for power save. */ + /* by amy for antenna. */ u8 EEPROMSwAntennaDiversity; bool EEPROMDefaultAntenna1; u8 RegSwAntennaDiversityMechanism; @@ -503,115 +432,128 @@ typedef struct r8180_priv bool bDefaultAntenna1; u8 SignalStrength; long Stats_SignalStrength; - long LastSignalStrengthInPercent; // In percentage, used for smoothing, e.g. Moving Average. - u8 SignalQuality; // in 0-100 index. + long LastSignalStrengthInPercent; /* In percentage, used for smoothing, + * e.g. Moving Average. + */ + u8 SignalQuality; /* in 0-100 index. */ long Stats_SignalQuality; - long RecvSignalPower; // in dBm. + long RecvSignalPower; /* in dBm. */ long Stats_RecvSignalPower; - u8 LastRxPktAntenna; // +by amy 080312 Antenna which received the lasted packet. 0: Aux, 1:Main. Added by Roger, 2008.01.25. + u8 LastRxPktAntenna; /* +by amy 080312 Antenna which received the lasted + * packet. 0: Aux, 1:Main. Added by Roger, + * 2008.01.25. + */ u32 AdRxOkCnt; long AdRxSignalStrength; - u8 CurrAntennaIndex; // Index to current Antenna (both Tx and Rx). - u8 AdTickCount; // Times of SwAntennaDiversityTimer happened. - u8 AdCheckPeriod; // # of period SwAntennaDiversityTimer to check Rx signal strength for SW Antenna Diversity. - u8 AdMinCheckPeriod; // Min value of AdCheckPeriod. - u8 AdMaxCheckPeriod; // Max value of AdCheckPeriod. - long AdRxSsThreshold; // Signal strength threshold to switch antenna. - long AdMaxRxSsThreshold; // Max value of AdRxSsThreshold. - bool bAdSwitchedChecking; // TRUE if we shall shall check Rx signal strength for last time switching antenna. - long AdRxSsBeforeSwitched; // Rx signal strength before we switched antenna. + u8 CurrAntennaIndex; /* Index to current Antenna (both Tx and Rx). */ + u8 AdTickCount; /* Times of SwAntennaDiversityTimer happened. */ + u8 AdCheckPeriod; /* # of period SwAntennaDiversityTimer to check Rx + * signal strength for SW Antenna Diversity. + */ + u8 AdMinCheckPeriod; /* Min value of AdCheckPeriod. */ + u8 AdMaxCheckPeriod; /* Max value of AdCheckPeriod. */ + long AdRxSsThreshold; /* Signal strength threshold to switch antenna. */ + long AdMaxRxSsThreshold; /* Max value of AdRxSsThreshold. */ + bool bAdSwitchedChecking; /* TRUE if we shall shall check Rx signal + * strength for last time switching antenna. + */ + long AdRxSsBeforeSwitched; /* Rx signal strength before we switched + * antenna. + */ struct timer_list SwAntennaDiversityTimer; -//by amy for antenna -//{by amy 080312 -// - // Crystal calibration. - // Added by Roger, 2007.12.11. - // - bool bXtalCalibration; // Crystal calibration. - u8 XtalCal_Xin; // Crystal calibration for Xin. 0~7.5pF - u8 XtalCal_Xout; // Crystal calibration for Xout. 0~7.5pF - // - // Tx power tracking with thermal meter indication. - // Added by Roger, 2007.12.11. - // - bool bTxPowerTrack; // Tx Power tracking. - u8 ThermalMeter; // Thermal meter reference indication. - // - // Dynamic Initial Gain Adjustment Mechanism. Added by Bruce, 2007-02-14. - // - bool bDigMechanism; // TRUE if DIG is enabled, FALSE ow. - bool bRegHighPowerMechanism; // For High Power Mechanism. 061010, by rcnjko. - u32 FalseAlarmRegValue; - u8 RegDigOfdmFaUpTh; // Upper threshold of OFDM false alarm, which is used in DIG. - u8 DIG_NumberFallbackVote; - u8 DIG_NumberUpgradeVote; - // For HW antenna diversity, added by Roger, 2008.01.30. - u32 AdMainAntennaRxOkCnt; // Main antenna Rx OK count. - u32 AdAuxAntennaRxOkCnt; // Aux antenna Rx OK count. - bool bHWAdSwitched; // TRUE if we has switched default antenna by HW evaluation. - // RF High Power upper/lower threshold. - u8 RegHiPwrUpperTh; - u8 RegHiPwrLowerTh; - // RF RSSI High Power upper/lower Threshold. - u8 RegRSSIHiPwrUpperTh; - u8 RegRSSIHiPwrLowerTh; - // Current CCK RSSI value to determine CCK high power, asked by SD3 DZ, by Bruce, 2007-04-12. - u8 CurCCKRSSI; - bool bCurCCKPkt; - // - // High Power Mechanism. Added by amy, 080312. - // - bool bToUpdateTxPwr; - long UndecoratedSmoothedSS; - long UndercorateSmoothedRxPower; - u8 RSSI; - char RxPower; - u8 InitialGain; - //For adjust Dig Threshold during Legacy/Leisure Power Save Mode - u32 DozePeriodInPast2Sec; - // Don't access BB/RF under disable PLL situation. - u8 InitialGainBackUp; - u8 RegBModeGainStage; -//by amy for rate adaptive - struct timer_list rateadapter_timer; - u32 RateAdaptivePeriod; - bool bEnhanceTxPwr; - bool bUpdateARFR; - int ForcedDataRate; // Force Data Rate. 0: Auto, 0x02: 1M ~ 0x6C: 54M.) - u32 NumTxUnicast; //YJ,add,080828,for keep alive - u8 keepAliveLevel; //YJ,add,080828,for KeepAlive - unsigned long NumTxOkTotal; - u16 LastRetryCnt; - u16 LastRetryRate; - unsigned long LastTxokCnt; - unsigned long LastRxokCnt; - u16 CurrRetryCnt; - unsigned long LastTxOKBytes; - unsigned long NumTxOkBytesTotal; - u8 LastFailTxRate; - long LastFailTxRateSS; - u8 FailTxRateCount; - u32 LastTxThroughput; - //for up rate - unsigned short bTryuping; - u8 CurrTxRate; //the rate before up - u16 CurrRetryRate; - u16 TryupingCount; - u8 TryDownCountLowData; - u8 TryupingCountNoData; - - u8 CurrentOperaRate; -//by amy for rate adaptive -//by amy 080312} -// short wq_hurryup; -// struct workqueue_struct *workqueue; + /* by amy for antenna {by amy 080312 */ + + /* Crystal calibration. Added by Roger, 2007.12.11. */ + + bool bXtalCalibration; /* Crystal calibration.*/ + u8 XtalCal_Xin; /* Crystal calibration for Xin. 0~7.5pF */ + u8 XtalCal_Xout; /* Crystal calibration for Xout. 0~7.5pF */ + + /* Tx power tracking with thermal meter indication. + * Added by Roger, 2007.12.11. + */ + + bool bTxPowerTrack; /* Tx Power tracking. */ + u8 ThermalMeter; /* Thermal meter reference indication. */ + + /* Dynamic Initial Gain Adjustment Mechanism. Added by Bruce, + * 2007-02-14. + */ + bool bDigMechanism; /* TRUE if DIG is enabled, FALSE ow. */ + bool bRegHighPowerMechanism; /* For High Power Mechanism. 061010, + * by rcnjko. + */ + u32 FalseAlarmRegValue; + u8 RegDigOfdmFaUpTh; /* Upper threshold of OFDM false alarm, which is + * used in DIG. + */ + u8 DIG_NumberFallbackVote; + u8 DIG_NumberUpgradeVote; + /* For HW antenna diversity, added by Roger, 2008.01.30. */ + u32 AdMainAntennaRxOkCnt; /* Main antenna Rx OK count. */ + u32 AdAuxAntennaRxOkCnt; /* Aux antenna Rx OK count. */ + bool bHWAdSwitched; /* TRUE if we has switched default antenna by HW + * evaluation. + */ + /* RF High Power upper/lower threshold. */ + u8 RegHiPwrUpperTh; + u8 RegHiPwrLowerTh; + /* RF RSSI High Power upper/lower Threshold. */ + u8 RegRSSIHiPwrUpperTh; + u8 RegRSSIHiPwrLowerTh; + /* Current CCK RSSI value to determine CCK high power, asked by SD3 DZ, + * by Bruce, 2007-04-12. + */ + u8 CurCCKRSSI; + bool bCurCCKPkt; + /* High Power Mechanism. Added by amy, 080312. */ + bool bToUpdateTxPwr; + long UndecoratedSmoothedSS; + long UndecoratedSmoothedRxPower; + u8 RSSI; + char RxPower; + u8 InitialGain; + /* For adjust Dig Threshold during Legacy/Leisure Power Save Mode. */ + u32 DozePeriodInPast2Sec; + /* Don't access BB/RF under disable PLL situation. */ + u8 InitialGainBackUp; + u8 RegBModeGainStage; + /* by amy for rate adaptive */ + struct timer_list rateadapter_timer; + u32 RateAdaptivePeriod; + bool bEnhanceTxPwr; + bool bUpdateARFR; + int ForcedDataRate; /* Force Data Rate. 0: Auto, 0x02: 1M ~ 0x6C: 54M.) + */ + u32 NumTxUnicast; /* YJ,add,080828,for keep alive. */ + u8 keepAliveLevel; /*YJ,add,080828,for KeepAlive. */ + unsigned long NumTxOkTotal; + u16 LastRetryCnt; + u16 LastRetryRate; + unsigned long LastTxokCnt; + unsigned long LastRxokCnt; + u16 CurrRetryCnt; + unsigned long LastTxOKBytes; + unsigned long NumTxOkBytesTotal; + u8 LastFailTxRate; + long LastFailTxRateSS; + u8 FailTxRateCount; + u32 LastTxThroughput; + /* for up rate. */ + unsigned short bTryuping; + u8 CurrTxRate; /* the rate before up. */ + u16 CurrRetryRate; + u16 TryupingCount; + u8 TryDownCountLowData; + u8 TryupingCountNoData; + + u8 CurrentOperaRate; struct work_struct reset_wq; struct work_struct watch_dog_wq; short ack_tx_to_ieee; u8 dma_poll_stop_mask; - //u8 RegThreeWireMode; u16 ShortRetryLimit; u16 LongRetryLimit; u16 EarlyRxThreshold; @@ -619,8 +561,8 @@ typedef struct r8180_priv u32 ReceiveConfig; u32 IntrMask; - struct ChnlAccessSetting ChannelAccessSetting; -}r8180_priv; + struct chnl_access_setting ChannelAccessSetting; +}; #define MANAGE_PRIORITY 0 #define BK_PRIORITY 1 @@ -632,14 +574,14 @@ typedef struct r8180_priv #define LOW_PRIORITY VI_PRIORITY #define NORM_PRIORITY VO_PRIORITY -//AC2Queue mapping +/* AC2Queue mapping. */ #define AC2Q(_ac) (((_ac) == WME_AC_VO) ? VO_PRIORITY : \ ((_ac) == WME_AC_VI) ? VI_PRIORITY : \ ((_ac) == WME_AC_BK) ? BK_PRIORITY : \ BE_PRIORITY) short rtl8180_tx(struct net_device *dev, u8 *skbuf, int len, int priority, - short morefrag, short fragdesc, int rate); + bool morefrag, short fragdesc, int rate); u8 read_nic_byte(struct net_device *dev, int x); u32 read_nic_dword(struct net_device *dev, int x); @@ -673,7 +615,6 @@ void UpdateInitialGain(struct net_device *dev); bool SetAntennaConfig87SE(struct net_device *dev, u8 DefaultAnt, bool bAntDiversity); -//#ifdef CONFIG_RTL8185B void rtl8185b_adapter_start(struct net_device *dev); void rtl8185b_rx_enable(struct net_device *dev); void rtl8185b_tx_enable(struct net_device *dev); @@ -682,9 +623,8 @@ void rtl8185b_irq_enable(struct net_device *dev); void fix_rx_fifo(struct net_device *dev); void fix_tx_fifo(struct net_device *dev); void rtl8225z2_SetTXPowerLevel(struct net_device *dev, short ch); -void rtl8180_rate_adapter(struct work_struct * work); -//#endif -bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, +void rtl8180_rate_adapter(struct work_struct *work); +bool MgntActSet_RF_State(struct net_device *dev, enum rt_rf_power_state StateToSet, u32 ChangeSource); #endif diff --git a/drivers/staging/rtl8187se/r8180_core.c b/drivers/staging/rtl8187se/r8180_core.c index 6cafee2..a6022d4 100644 --- a/drivers/staging/rtl8187se/r8180_core.c +++ b/drivers/staging/rtl8187se/r8180_core.c @@ -1,31 +1,31 @@ /* - This is part of rtl818x pci OpenSource driver - v 0.1 - Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> - Released under the terms of GPL (General Public License) - - Parts of this driver are based on the GPL part of the official - Realtek driver. - - Parts of this driver are based on the rtl8180 driver skeleton - from Patric Schenke & Andres Salomon. - - Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. - - Parts of BB/RF code are derived from David Young rtl8180 netbsd driver. - - RSSI calc function from 'The Deuce' - - Some ideas borrowed from the 8139too.c driver included in linux kernel. - - We (I?) want to thanks the Authors of those projecs and also the - Ndiswrapper's project Authors. - - A big big thanks goes also to Realtek corp. for their help in my attempt to - add RTL8185 and RTL8225 support, and to David Young also. - - Power management interface routines. - Written by Mariusz Matuszek. -*/ + * This is part of rtl818x pci OpenSource driver - v 0.1 + * Copyright (C) Andrea Merello 2004-2005 <andrea.merello@gmail.com> + * Released under the terms of GPL (General Public License) + * + * Parts of this driver are based on the GPL part of the official + * Realtek driver. + * + * Parts of this driver are based on the rtl8180 driver skeleton + * from Patric Schenke & Andres Salomon. + * + * Parts of this driver are based on the Intel Pro Wireless 2100 GPL driver. + * + * Parts of BB/RF code are derived from David Young rtl8180 netbsd driver. + * + * RSSI calc function from 'The Deuce' + * + * Some ideas borrowed from the 8139too.c driver included in linux kernel. + * + * We (I?) want to thanks the Authors of those projecs and also the + * Ndiswrapper's project Authors. + * + * A big big thanks goes also to Realtek corp. for their help in my attempt to + * add RTL8185 and RTL8225 support, and to David Young also. + * + * Power management interface routines. + * Written by Mariusz Matuszek. + */ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt @@ -258,7 +258,9 @@ static int proc_get_stats_tx(struct seq_file *m, void *v) struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); unsigned long totalOK; - totalOK = priv->stats.txnpokint+priv->stats.txhpokint+priv->stats.txlpokint; + totalOK = priv->stats.txnpokint + priv->stats.txhpokint + + priv->stats.txlpokint; + seq_printf(m, "TX OK: %lu\n" "TX Error: %lu\n" @@ -347,9 +349,9 @@ static void rtl8180_proc_init_one(struct net_device *dev) } /* - FIXME: check if we can use some standard already-existent - data type+functions in kernel -*/ + * FIXME: check if we can use some standard already-existent + * data type+functions in kernel. + */ static short buffer_add(struct buffer **buffer, u32 *buf, dma_addr_t dma, struct buffer **bufferhead) @@ -468,9 +470,11 @@ static short check_nic_enought_desc(struct net_device *dev, int priority) { struct r8180_priv *priv = ieee80211_priv(dev); struct ieee80211_device *ieee = netdev_priv(dev); - int requiredbyte, required; + int requiredbyte; + int required; - requiredbyte = priv->ieee80211->fts + sizeof(struct ieee80211_header_data); + requiredbyte = priv->ieee80211->fts + + sizeof(struct ieee80211_header_data); if (ieee->current_network.QoS_Enable) requiredbyte += 2; @@ -484,7 +488,7 @@ static short check_nic_enought_desc(struct net_device *dev, int priority) * between the tail and the head */ - return (required+2 < get_curr_tx_free_desc(dev, priority)); + return required + 2 < get_curr_tx_free_desc(dev, priority); } void fix_tx_fifo(struct net_device *dev) @@ -649,7 +653,7 @@ void rtl8180_set_chan(struct net_device *dev, short ch) struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); if ((ch > 14) || (ch < 1)) { - printk("In %s: Invalid chnanel %d\n", __func__, ch); + netdev_err(dev, "In %s: Invalid channel %d\n", __func__, ch); return; } @@ -742,43 +746,50 @@ static short alloc_tx_desc_ring(struct net_device *dev, int bufsize, int count, switch (addr) { case TX_MANAGEPRIORITY_RING_ADDR: - if (-1 == buffer_add(&(priv->txmapbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txmapbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer NP"); return -ENOMEM; } break; case TX_BKPRIORITY_RING_ADDR: - if (-1 == buffer_add(&(priv->txbkpbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txbkpbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer LP"); return -ENOMEM; } break; case TX_BEPRIORITY_RING_ADDR: - if (-1 == buffer_add(&(priv->txbepbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txbepbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer NP"); return -ENOMEM; } break; case TX_VIPRIORITY_RING_ADDR: - if (-1 == buffer_add(&(priv->txvipbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txvipbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer LP"); return -ENOMEM; } break; case TX_VOPRIORITY_RING_ADDR: - if (-1 == buffer_add(&(priv->txvopbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txvopbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer NP"); return -ENOMEM; } break; case TX_HIGHPRIORITY_RING_ADDR: - if (-1 == buffer_add(&(priv->txhpbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txhpbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer HP"); return -ENOMEM; } break; case TX_BEACON_RING_ADDR: - if (-1 == buffer_add(&(priv->txbeaconbufs), buf, dma_tmp, NULL)) { + if (-1 == buffer_add(&priv->txbeaconbufs, + buf, dma_tmp, NULL)) { DMESGE("Unable to allocate mem for buffer BP"); return -ENOMEM; } @@ -897,8 +908,8 @@ static short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) return -1; } - desc = (u32 *)pci_alloc_consistent(pdev, sizeof(u32)*rx_desc_size*count+256, - &dma_desc); + desc = (u32 *)pci_alloc_consistent(pdev, + sizeof(u32) * rx_desc_size * count + 256, &dma_desc); if (dma_desc & 0xff) /* @@ -935,7 +946,8 @@ static short alloc_rx_desc_ring(struct net_device *dev, u16 bufsize, int count) tmp = tmp+rx_desc_size; } - *(tmp-rx_desc_size) = *(tmp-rx_desc_size) | (1<<30); /* this is the last descriptor */ + /* this is the last descriptor */ + *(tmp - rx_desc_size) = *(tmp - rx_desc_size) | (1 << 30); return 0; } @@ -1009,7 +1021,8 @@ inline u16 ieeerate2rtlrate(int rate) } } -static u16 rtl_rate[] = {10, 20, 55, 110, 60, 90, 120, 180, 240, 360, 480, 540, 720}; +static u16 rtl_rate[] = {10, 20, 55, 110, 60, + 90, 120, 180, 240, 360, 480, 540, 720}; inline u16 rtl8180_rate2rate(short rate) { @@ -1143,23 +1156,30 @@ static long TranslateToDbm8185(u8 SignalStrengthIndex) /* * Perform signal smoothing for dynamic mechanism. * This is different with PerformSignalSmoothing8185 in smoothing formula. - * No dramatic adjustion is apply because dynamic mechanism need some degree - * of correctness. Ported from 8187B. + * No dramatic adjustment is applied because dynamic mechanism need some + * degree of correctness. Ported from 8187B. */ static void PerformUndecoratedSignalSmoothing8185(struct r8180_priv *priv, bool bCckRate) { - /* Determin the current packet is CCK rate. */ + long smoothedSS; + long smoothedRx; + + /* Determine the current packet is CCK rate. */ priv->bCurCCKPkt = bCckRate; + smoothedSS = priv->SignalStrength * 10; + if (priv->UndecoratedSmoothedSS >= 0) - priv->UndecoratedSmoothedSS = ((priv->UndecoratedSmoothedSS * 5) + - (priv->SignalStrength * 10)) / 6; - else - priv->UndecoratedSmoothedSS = priv->SignalStrength * 10; + smoothedSS = ((priv->UndecoratedSmoothedSS * 5) + + smoothedSS) / 6; - priv->UndercorateSmoothedRxPower = ((priv->UndercorateSmoothedRxPower * 50) + - (priv->RxPower * 11)) / 60; + priv->UndecoratedSmoothedSS = smoothedSS; + + smoothedRx = ((priv->UndecoratedSmoothedRxPower * 50) + + (priv->RxPower * 11)) / 60; + + priv->UndecoratedSmoothedRxPower = smoothedRx; if (bCckRate) priv->CurCCKRSSI = priv->RSSI; @@ -1206,8 +1226,9 @@ static void rtl8180_rx(struct net_device *dev) rx_desc_size = 8; if ((*(priv->rxringtail)) & (1<<31)) { - /* we have got an RX int, but the descriptor - * we are pointing is empty */ + /* we have got an RX int, but the descriptor. we are pointing + * is empty. + */ priv->stats.rxnodata++; priv->ieee80211->stats.rx_errors++; @@ -1216,7 +1237,8 @@ static void rtl8180_rx(struct net_device *dev) tmp = priv->rxringtail; do { if (tmp == priv->rxring) - tmp = priv->rxring + (priv->rxringcount - 1)*rx_desc_size; + tmp = priv->rxring + (priv->rxringcount - 1) * + rx_desc_size; else tmp -= rx_desc_size; @@ -1237,7 +1259,6 @@ static void rtl8180_rx(struct net_device *dev) if (*(priv->rxringtail) & (1<<27)) { priv->stats.rxdmafail++; - /* DMESG("EE: RX DMA FAILED at buffer pointed by descriptor %x",(u32)priv->rxringtail); */ goto drop; } @@ -1254,10 +1275,9 @@ static void rtl8180_rx(struct net_device *dev) if (last) { lastlen = ((*priv->rxringtail) & 0xfff); - /* if the last descriptor (that should - * tell us the total packet len) tell - * us something less than the descriptors - * len we had until now, then there is some + /* if the last descriptor (that should tell us the total + * packet len) tell us something less than the + * descriptors len we had until now, then there is some * problem.. * workaround to prevent kernel panic */ @@ -1293,31 +1313,36 @@ static void rtl8180_rx(struct net_device *dev) priv->rx_prevlen += len; if (priv->rx_prevlen > MAX_FRAG_THRESHOLD + 100) { - /* HW is probably passing several buggy frames - * without FD or LD flag set. - * Throw this garbage away to prevent skb - * memory exhausting - */ + /* HW is probably passing several buggy frames without + * FD or LD flag set. + * Throw this garbage away to prevent skb memory + * exhausting + */ if (!priv->rx_skb_complete) dev_kfree_skb_any(priv->rx_skb); priv->rx_skb_complete = 1; } - signal = (unsigned char)(((*(priv->rxringtail+3)) & (0x00ff0000))>>16); + signal = (unsigned char)((*(priv->rxringtail + 3) & + 0x00ff0000) >> 16); signal = (signal & 0xfe) >> 1; quality = (unsigned char)((*(priv->rxringtail+3)) & (0xff)); stats.mac_time[0] = *(priv->rxringtail+1); stats.mac_time[1] = *(priv->rxringtail+2); - rxpower = ((char)(((*(priv->rxringtail+4)) & (0x00ff0000))>>16))/2 - 42; - RSSI = ((u8)(((*(priv->rxringtail+3)) & (0x0000ff00))>>8)) & (0x7f); + + rxpower = ((char)((*(priv->rxringtail + 4) & + 0x00ff0000) >> 16)) / 2 - 42; + + RSSI = ((u8)((*(priv->rxringtail + 3) & + 0x0000ff00) >> 8)) & 0x7f; rate = ((*(priv->rxringtail)) & ((1<<23)|(1<<22)|(1<<21)|(1<<20)))>>20; stats.rate = rtl8180_rate2rate(rate); - Antenna = (((*(priv->rxringtail+3)) & (0x00008000)) == 0) ? 0 : 1; + Antenna = (*(priv->rxringtail + 3) & 0x00008000) == 0 ? 0 : 1; if (!rtl8180_IsWirelessBMode(stats.rate)) { /* OFDM rate. */ RxAGC_dBm = rxpower+1; /* bias */ } else { /* CCK rate. */ @@ -1326,7 +1351,8 @@ static void rtl8180_rx(struct net_device *dev) LNA = (u8) (RxAGC_dBm & 0x60) >> 5; /* bit 6~ bit 5 */ BB = (u8) (RxAGC_dBm & 0x1F); /* bit 4 ~ bit 0 */ - RxAGC_dBm = -(LNA_gain[LNA] + (BB*2)); /* Pin_11b=-(LNA_gain+BB_gain) (dBm) */ + /* Pin_11b=-(LNA_gain+BB_gain) (dBm) */ + RxAGC_dBm = -(LNA_gain[LNA] + (BB * 2)); RxAGC_dBm += 4; /* bias */ } @@ -1354,21 +1380,23 @@ static void rtl8180_rx(struct net_device *dev) priv->RSSI = RSSI; /* SQ translation formula is provided by SD3 DZ. 2006.06.27 */ if (quality >= 127) - quality = 1; /*0; */ /* 0 will cause epc to show signal zero , walk around now; */ + /* 0 causes epc to show signal zero, walk around now */ + quality = 1; else if (quality < 27) quality = 100; else quality = 127 - quality; priv->SignalQuality = quality; - stats.signal = (u8)quality; /*priv->wstats.qual.level = priv->SignalStrength; */ + stats.signal = (u8) quality; + stats.signalstrength = RXAGC; if (stats.signalstrength > 100) stats.signalstrength = 100; - stats.signalstrength = (stats.signalstrength * 70)/100 + 30; - /* printk("==========================>rx : RXAGC is %d,signalstrength is %d\n",RXAGC,stats.signalstrength); */ + stats.signalstrength = (stats.signalstrength * 70) / 100 + 30; stats.rssi = priv->wstats.qual.qual = priv->SignalQuality; - stats.noise = priv->wstats.qual.noise = 100 - priv->wstats.qual.qual; + stats.noise = priv->wstats.qual.noise = + 100 - priv->wstats.qual.qual; bHwError = (((*(priv->rxringtail)) & (0x00000fff)) == 4080) | (((*(priv->rxringtail)) & (0x04000000)) != 0) | (((*(priv->rxringtail)) & (0x08000000)) != 0) | @@ -1397,27 +1425,40 @@ static void rtl8180_rx(struct net_device *dev) /* For good-looking singal strength. */ SignalStrengthIndex = NetgearSignalStrengthTranslate( - priv->LastSignalStrengthInPercent, - priv->SignalStrength); + priv->LastSignalStrengthInPercent, + priv->SignalStrength); priv->LastSignalStrengthInPercent = SignalStrengthIndex; - priv->Stats_SignalStrength = TranslateToDbm8185((u8)SignalStrengthIndex); - /* - * We need more correct power of received packets and the "SignalStrength" of RxStats is beautified, - * so we record the correct power here. - */ - priv->Stats_SignalQuality = (long)(priv->Stats_SignalQuality * 5 + (long)priv->SignalQuality + 5) / 6; - priv->Stats_RecvSignalPower = (long)(priv->Stats_RecvSignalPower * 5 + priv->RecvSignalPower - 1) / 6; + priv->Stats_SignalStrength = + TranslateToDbm8185((u8)SignalStrengthIndex); + + /* + * We need more correct power of received packets and + * the "SignalStrength" of RxStats is beautified, so we + * record the correct power here. + */ - /* Figure out which antenna that received the last packet. */ - priv->LastRxPktAntenna = Antenna ? 1 : 0; /* 0: aux, 1: main. */ + priv->Stats_SignalQuality = (long)( + priv->Stats_SignalQuality * 5 + + (long)priv->SignalQuality + 5) / 6; + + priv->Stats_RecvSignalPower = (long)( + priv->Stats_RecvSignalPower * 5 + + priv->RecvSignalPower - 1) / 6; + + /* + * Figure out which antenna received the last packet. + * 0: aux, 1: main + */ + priv->LastRxPktAntenna = Antenna ? 1 : 0; SwAntennaDiversityRxOk8185(dev, priv->SignalStrength); } if (first) { if (!priv->rx_skb_complete) { /* seems that HW sometimes fails to receive and - doesn't provide the last descriptor */ + * doesn't provide the last descriptor. + */ dev_kfree_skb_any(priv->rx_skb); priv->stats.rxnolast++; } @@ -1428,15 +1469,16 @@ static void rtl8180_rx(struct net_device *dev) priv->rx_skb_complete = 0; priv->rx_skb->dev = dev; } else { - /* if we are here we should have already RXed - * the first frame. - * If we get here and the skb is not allocated then - * we have just throw out garbage (skb not allocated) - * and we are still rxing garbage.... - */ + /* if we are here we should have already RXed the first + * frame. + * If we get here and the skb is not allocated then + * we have just throw out garbage (skb not allocated) + * and we are still rxing garbage.... + */ if (!priv->rx_skb_complete) { - tmp_skb = dev_alloc_skb(priv->rx_skb->len+len+2); + tmp_skb = dev_alloc_skb( + priv->rx_skb->len + len + 2); if (!tmp_skb) goto drop; @@ -1454,13 +1496,8 @@ static void rtl8180_rx(struct net_device *dev) } if (!priv->rx_skb_complete) { - if (padding) { - memcpy(skb_put(priv->rx_skb, len), - (((unsigned char *)priv->rxbuffer->buf) + 2), len); - } else { - memcpy(skb_put(priv->rx_skb, len), - priv->rxbuffer->buf, len); - } + memcpy(skb_put(priv->rx_skb, len), ((unsigned char *) + priv->rxbuffer->buf) + (padding ? 2 : 0), len); } if (last && !priv->rx_skb_complete) { @@ -1538,8 +1575,8 @@ static void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); int mode; - struct ieee80211_hdr_3addr *h = (struct ieee80211_hdr_3addr *) skb->data; - short morefrag = (h->frame_control) & IEEE80211_FCTL_MOREFRAGS; + struct ieee80211_hdr_3addr *h = (struct ieee80211_hdr_3addr *)skb->data; + bool morefrag = le16_to_cpu(h->frame_control) & IEEE80211_FCTL_MOREFRAGS; unsigned long flags; int priority; @@ -1547,11 +1584,10 @@ static void rtl8180_hard_data_xmit(struct sk_buff *skb, struct net_device *dev, rate = ieeerate2rtlrate(rate); /* - * This function doesn't require lock because we make - * sure it's called with the tx_lock already acquired. - * this come from the kernel's hard_xmit callback (through - * the ieee stack, or from the try_wake_queue (again through - * the ieee stack. + * This function doesn't require lock because we make sure it's called + * with the tx_lock already acquired. + * This come from the kernel's hard_xmit callback (through the ieee + * stack, or from the try_wake_queue (again through the ieee stack. */ priority = AC2Q(skb->priority); spin_lock_irqsave(&priv->tx_lock, flags); @@ -1613,55 +1649,6 @@ static int rtl8180_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) return NETDEV_TX_OK; } -/* longpre 144+48 shortpre 72+24 */ -u16 rtl8180_len2duration(u32 len, short rate, short *ext) -{ - u16 duration; - u16 drift; - *ext = 0; - - switch (rate) { - case 0: /* 1mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0x2; - drift = ((len+4)<<4) % 0x2; - if (drift == 0) - break; - duration++; - break; - case 1: /* 2mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0x4; - drift = ((len+4)<<4) % 0x4; - if (drift == 0) - break; - duration++; - break; - case 2: /* 5.5mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0xb; - drift = ((len+4)<<4) % 0xb; - if (drift == 0) - break; - duration++; - break; - default: - case 3: /* 11mbps */ - *ext = 0; - duration = ((len+4)<<4) / 0x16; - drift = ((len+4)<<4) % 0x16; - if (drift == 0) - break; - duration++; - if (drift > 6) - break; - *ext = 1; - break; - } - - return duration; -} - static void rtl8180_prepare_beacon(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); @@ -1669,7 +1656,10 @@ static void rtl8180_prepare_beacon(struct net_device *dev) u16 word = read_nic_word(dev, BcnItv); word &= ~BcnItv_BcnItv; /* clear Bcn_Itv */ - word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval); /* 0x64; */ + + /* word |= 0x64; */ + word |= cpu_to_le16(priv->ieee80211->current_network.beacon_interval); + write_nic_word(dev, BcnItv, word); skb = ieee80211_get_beacon(priv->ieee80211); @@ -1681,12 +1671,12 @@ static void rtl8180_prepare_beacon(struct net_device *dev) } /* - * This function do the real dirty work: it enqueues a TX command - * descriptor in the ring buffer, copyes the frame in a TX buffer - * and kicks the NIC to ensure it does the DMA transfer. + * This function do the real dirty work: it enqueues a TX command descriptor in + * the ring buffer, copyes the frame in a TX buffer and kicks the NIC to ensure + * it does the DMA transfer. */ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, - short morefrag, short descfrag, int rate) + bool morefrag, short descfrag, int rate) { struct r8180_priv *priv = ieee80211_priv(dev); u32 *tail, *temp_tail; @@ -1697,16 +1687,17 @@ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, int buflen; int count; struct buffer *buflist; - struct ieee80211_hdr_3addr *frag_hdr = (struct ieee80211_hdr_3addr *)txbuf; + struct ieee80211_hdr_3addr *frag_hdr = + (struct ieee80211_hdr_3addr *)txbuf; u8 dest[ETH_ALEN]; - u8 bUseShortPreamble = 0; - u8 bCTSEnable = 0; - u8 bRTSEnable = 0; - u16 Duration = 0; - u16 RtsDur = 0; - u16 ThisFrameTime = 0; - u16 TxDescDuration = 0; - bool ownbit_flag = false; + u8 bUseShortPreamble = 0; + u8 bCTSEnable = 0; + u8 bRTSEnable = 0; + u16 Duration = 0; + u16 RtsDur = 0; + u16 ThisFrameTime = 0; + u16 TxDescDuration = 0; + bool ownbit_flag = false; switch (priority) { case MANAGE_PRIORITY: @@ -1756,74 +1747,79 @@ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, break; } - memcpy(&dest, frag_hdr->addr1, ETH_ALEN); - if (is_multicast_ether_addr(dest)) { - Duration = 0; - RtsDur = 0; - bRTSEnable = 0; + memcpy(&dest, frag_hdr->addr1, ETH_ALEN); + if (is_multicast_ether_addr(dest)) { + Duration = 0; + RtsDur = 0; + bRTSEnable = 0; + bCTSEnable = 0; + + ThisFrameTime = ComputeTxTime(len + sCrcLng, + rtl8180_rate2rate(rate), 0, bUseShortPreamble); + TxDescDuration = ThisFrameTime; + } else { /* Unicast packet */ + u16 AckTime; + + /* for Keep alive */ + priv->NumTxUnicast++; + + /* Figure out ACK rate according to BSS basic rate + * and Tx rate. + * AckCTSLng = 14 use 1M bps send + */ + AckTime = ComputeTxTime(14, 10, 0, 0); + + if (((len + sCrcLng) > priv->rts) && priv->rts) { /* RTS/CTS. */ + u16 RtsTime, CtsTime; + bRTSEnable = 1; bCTSEnable = 0; - ThisFrameTime = ComputeTxTime(len + sCrcLng, rtl8180_rate2rate(rate), - 0, bUseShortPreamble); - TxDescDuration = ThisFrameTime; - } else { /* Unicast packet */ - u16 AckTime; - - /* YJ,add,080828,for Keep alive */ - priv->NumTxUnicast++; - - /* Figure out ACK rate according to BSS basic rate - * and Tx rate. */ - AckTime = ComputeTxTime(14, 10, 0, 0); /* AckCTSLng = 14 use 1M bps send */ - - if (((len + sCrcLng) > priv->rts) && priv->rts) { /* RTS/CTS. */ - u16 RtsTime, CtsTime; - /* u16 CtsRate; */ - bRTSEnable = 1; - bCTSEnable = 0; - - /* Rate and time required for RTS. */ - RtsTime = ComputeTxTime(sAckCtsLng/8, priv->ieee80211->basic_rate, 0, 0); - /* Rate and time required for CTS. */ - CtsTime = ComputeTxTime(14, 10, 0, 0); /* AckCTSLng = 14 use 1M bps send */ - - /* Figure out time required to transmit this frame. */ - ThisFrameTime = ComputeTxTime(len + sCrcLng, - rtl8180_rate2rate(rate), - 0, - bUseShortPreamble); - - /* RTS-CTS-ThisFrame-ACK. */ - RtsDur = CtsTime + ThisFrameTime + AckTime + 3*aSifsTime; - - TxDescDuration = RtsTime + RtsDur; - } else { /* Normal case. */ - bCTSEnable = 0; - bRTSEnable = 0; - RtsDur = 0; - - ThisFrameTime = ComputeTxTime(len + sCrcLng, rtl8180_rate2rate(rate), - 0, bUseShortPreamble); - TxDescDuration = ThisFrameTime + aSifsTime + AckTime; - } + /* Rate and time required for RTS. */ + RtsTime = ComputeTxTime(sAckCtsLng / 8, + priv->ieee80211->basic_rate, 0, 0); - if (!(frag_hdr->frame_control & IEEE80211_FCTL_MOREFRAGS)) { - /* ThisFrame-ACK. */ - Duration = aSifsTime + AckTime; - } else { /* One or more fragments remained. */ - u16 NextFragTime; - NextFragTime = ComputeTxTime(len + sCrcLng, /* pretend following packet length equal current packet */ - rtl8180_rate2rate(rate), - 0, - bUseShortPreamble); - - /* ThisFrag-ACk-NextFrag-ACK. */ - Duration = NextFragTime + 3*aSifsTime + 2*AckTime; - } + /* Rate and time required for CTS. + * AckCTSLng = 14 use 1M bps send + */ + CtsTime = ComputeTxTime(14, 10, 0, 0); + + /* Figure out time required to transmit this frame. */ + ThisFrameTime = ComputeTxTime(len + sCrcLng, + rtl8180_rate2rate(rate), 0, + bUseShortPreamble); + + /* RTS-CTS-ThisFrame-ACK. */ + RtsDur = CtsTime + ThisFrameTime + + AckTime + 3 * aSifsTime; + + TxDescDuration = RtsTime + RtsDur; + } else { /* Normal case. */ + bCTSEnable = 0; + bRTSEnable = 0; + RtsDur = 0; - } /* End of Unicast packet */ + ThisFrameTime = ComputeTxTime(len + sCrcLng, + rtl8180_rate2rate(rate), 0, bUseShortPreamble); + TxDescDuration = ThisFrameTime + aSifsTime + AckTime; + } + + if (!(le16_to_cpu(frag_hdr->frame_control) & IEEE80211_FCTL_MOREFRAGS)) { + /* ThisFrame-ACK. */ + Duration = aSifsTime + AckTime; + } else { /* One or more fragments remained. */ + u16 NextFragTime; + + /* pretend following packet length = current packet */ + NextFragTime = ComputeTxTime(len + sCrcLng, + rtl8180_rate2rate(rate), 0, bUseShortPreamble); + + /* ThisFrag-ACk-NextFrag-ACK. */ + Duration = NextFragTime + 3 * aSifsTime + 2 * AckTime; + } + + } /* End of Unicast packet */ - frag_hdr->duration_id = Duration; + frag_hdr->duration_id = Duration; buflen = priv->txbuffsize; remain = len; @@ -1832,7 +1828,8 @@ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, while (remain != 0) { mb(); if (!buflist) { - DMESGE("TX buffer error, cannot TX frames. pri %d.", priority); + DMESGE("TX buffer error, cannot TX frames. pri %d.", + priority); return -1; } buf = buflist->buf; @@ -1851,43 +1848,43 @@ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, *(tail+6) = 0; *(tail+7) = 0; - /* FIXME: this should be triggered by HW encryption parameters.*/ + /* FIXME: should be triggered by HW encryption parameters.*/ *tail |= (1<<15); /* no encrypt */ if (remain == len && !descfrag) { ownbit_flag = false; - *tail = *tail | (1<<29); /* fist segment of the packet */ + *tail = *tail | (1 << 29); /* first segment of packet */ *tail = *tail | (len); } else { ownbit_flag = true; } for (i = 0; i < buflen && remain > 0; i++, remain--) { - ((u8 *)buf)[i] = txbuf[i]; /* copy data into descriptor pointed DMAble buffer */ + /* copy data into descriptor pointed DMAble buffer */ + ((u8 *)buf)[i] = txbuf[i]; + if (remain == 4 && i+4 >= buflen) break; /* ensure the last desc has at least 4 bytes payload */ - } txbuf = txbuf + i; *(tail+3) = *(tail+3) & ~0xfff; *(tail+3) = *(tail+3) | i; /* buffer length */ - /* Use short preamble or not */ - if (priv->ieee80211->current_network.capability&WLAN_CAPABILITY_SHORT_PREAMBLE) - if (priv->plcp_preamble_mode == 1 && rate != 0) /* short mode now, not long! */ - ; /* *tail |= (1<<16); */ /* enable short preamble mode. */ if (bCTSEnable) *tail |= (1<<18); if (bRTSEnable) { /* rts enable */ - *tail |= ((ieeerate2rtlrate(priv->ieee80211->basic_rate))<<19); /* RTS RATE */ + /* RTS RATE */ + *tail |= (ieeerate2rtlrate( + priv->ieee80211->basic_rate) << 19); + *tail |= (1<<23); /* rts enable */ *(tail+1) |= (RtsDur&0xffff); /* RTS Duration */ } *(tail+3) |= ((TxDescDuration&0xffff)<<16); /* DURATION */ - /* *(tail+3) |= (0xe6<<16); */ - *(tail+5) |= (11<<8); /* (priv->retry_data<<8); */ /* retry lim; */ + + *(tail + 5) |= (11 << 8); /* retry lim; */ *tail = *tail | ((rate&0xf) << 24); @@ -1901,7 +1898,8 @@ short rtl8180_tx(struct net_device *dev, u8 *txbuf, int len, int priority, wmb(); if (ownbit_flag) - *tail = *tail | (1<<31); /* descriptor ready to be txed */ + /* descriptor ready to be txed */ + *tail |= (1 << 31); if ((tail - begin)/8 == count-1) tail = begin; @@ -1983,7 +1981,8 @@ static void rtl8180_rq_tx_ack(struct net_device *dev) struct r8180_priv *priv = ieee80211_priv(dev); - write_nic_byte(dev, CONFIG4, read_nic_byte(dev, CONFIG4) | CONFIG4_PWRMGT); + write_nic_byte(dev, CONFIG4, + read_nic_byte(dev, CONFIG4) | CONFIG4_PWRMGT); priv->ack_tx_to_ieee = 1; } @@ -2031,7 +2030,8 @@ static void rtl8180_hw_wakeup(struct net_device *dev) struct r8180_priv *priv = ieee80211_priv(dev); spin_lock_irqsave(&priv->ps_lock, flags); - write_nic_byte(dev, CONFIG4, read_nic_byte(dev, CONFIG4) & ~CONFIG4_PWRMGT); + write_nic_byte(dev, CONFIG4, + read_nic_byte(dev, CONFIG4) & ~CONFIG4_PWRMGT); if (priv->rf_wakeup) priv->rf_wakeup(dev); spin_unlock_irqrestore(&priv->ps_lock, flags); @@ -2063,13 +2063,13 @@ static void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) tl -= MSECS(4+16+7); /* - * If the interval in witch we are requested to sleep is too + * If the interval in which we are requested to sleep is too * short then give up and remain awake */ if (((tl >= rb) && (tl-rb) <= MSECS(MIN_SLEEP_TIME)) || ((rb > tl) && (rb-tl) < MSECS(MIN_SLEEP_TIME))) { spin_unlock_irqrestore(&priv->ps_lock, flags); - printk("too short to sleep\n"); + netdev_warn(dev, "too short to sleep\n"); return; } @@ -2078,7 +2078,8 @@ static void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) priv->DozePeriodInPast2Sec += jiffies_to_msecs(tmp); /* as tl may be less than rb */ - queue_delayed_work(priv->ieee80211->wq, &priv->ieee80211->hw_wakeup_wq, tmp); + queue_delayed_work(priv->ieee80211->wq, + &priv->ieee80211->hw_wakeup_wq, tmp); } /* * If we suspect the TimerInt is gone beyond tl @@ -2095,16 +2096,49 @@ static void rtl8180_hw_sleep(struct net_device *dev, u32 th, u32 tl) spin_unlock_irqrestore(&priv->ps_lock, flags); } +static void rtl8180_wmm_single_param_update(struct net_device *dev, + u8 mode, AC_CODING eACI, PAC_PARAM param) +{ + u8 u1bAIFS; + u32 u4bAcParam; + + /* Retrieve parameters to update. */ + /* Mode G/A: slotTimeTimer = 9; Mode B: 20 */ + u1bAIFS = param->f.AciAifsn.f.AIFSN * ((mode & IEEE_G) == IEEE_G ? + 9 : 20) + aSifsTime; + u4bAcParam = (((u32)param->f.TXOPLimit << AC_PARAM_TXOP_LIMIT_OFFSET) | + ((u32)param->f.Ecw.f.ECWmax << AC_PARAM_ECW_MAX_OFFSET) | + ((u32)param->f.Ecw.f.ECWmin << AC_PARAM_ECW_MIN_OFFSET) | + ((u32)u1bAIFS << AC_PARAM_AIFS_OFFSET)); + + switch (eACI) { + case AC1_BK: + write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); + return; + case AC0_BE: + write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); + return; + case AC2_VI: + write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); + return; + case AC3_VO: + write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); + return; + default: + pr_warn("SetHwReg8185(): invalid ACI: %d!\n", eACI); + return; + } +} + static void rtl8180_wmm_param_update(struct work_struct *work) { - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, wmm_param_update_wq); + struct ieee80211_device *ieee = container_of(work, + struct ieee80211_device, wmm_param_update_wq); struct net_device *dev = ieee->dev; u8 *ac_param = (u8 *)(ieee->current_network.wmm_param); u8 mode = ieee->current_network.mode; - AC_CODING eACI; - AC_PARAM AcParam; - PAC_PARAM pAcParam; - u8 i; + AC_CODING eACI; + AC_PARAM AcParam; if (!ieee->current_network.QoS_Enable) { /* legacy ac_xx_param update */ @@ -2114,83 +2148,26 @@ static void rtl8180_wmm_param_update(struct work_struct *work) AcParam.f.Ecw.f.ECWmin = 3; /* Follow 802.11 CWmin. */ AcParam.f.Ecw.f.ECWmax = 7; /* Follow 802.11 CWmax. */ AcParam.f.TXOPLimit = 0; + for (eACI = 0; eACI < AC_MAX; eACI++) { AcParam.f.AciAifsn.f.ACI = (u8)eACI; - { - u8 u1bAIFS; - u32 u4bAcParam; - pAcParam = (PAC_PARAM)(&AcParam); - /* Retrieve parameters to update. */ - u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime; - u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit))<<AC_PARAM_TXOP_LIMIT_OFFSET)| - (((u32)(pAcParam->f.Ecw.f.ECWmax))<<AC_PARAM_ECW_MAX_OFFSET)| - (((u32)(pAcParam->f.Ecw.f.ECWmin))<<AC_PARAM_ECW_MIN_OFFSET)| - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); - switch (eACI) { - case AC1_BK: - write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); - break; - case AC0_BE: - write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); - break; - case AC2_VI: - write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); - break; - case AC3_VO: - write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); - break; - default: - pr_warn("SetHwReg8185():invalid ACI: %d!\n", - eACI); - break; - } - } + + rtl8180_wmm_single_param_update(dev, mode, eACI, + (PAC_PARAM)&AcParam); } return; } - for (i = 0; i < AC_MAX; i++) { - /* AcParam.longData = 0; */ - pAcParam = (AC_PARAM *)ac_param; - { - AC_CODING eACI; - u8 u1bAIFS; - u32 u4bAcParam; - - /* Retrieve parameters to update. */ - eACI = pAcParam->f.AciAifsn.f.ACI; - /* Mode G/A: slotTimeTimer = 9; Mode B: 20 */ - u1bAIFS = pAcParam->f.AciAifsn.f.AIFSN * (((mode&IEEE_G) == IEEE_G) ? 9 : 20) + aSifsTime; - u4bAcParam = ((((u32)(pAcParam->f.TXOPLimit)) << AC_PARAM_TXOP_LIMIT_OFFSET) | - (((u32)(pAcParam->f.Ecw.f.ECWmax)) << AC_PARAM_ECW_MAX_OFFSET) | - (((u32)(pAcParam->f.Ecw.f.ECWmin)) << AC_PARAM_ECW_MIN_OFFSET) | - (((u32)u1bAIFS) << AC_PARAM_AIFS_OFFSET)); - - switch (eACI) { - case AC1_BK: - write_nic_dword(dev, AC_BK_PARAM, u4bAcParam); - break; - case AC0_BE: - write_nic_dword(dev, AC_BE_PARAM, u4bAcParam); - break; - case AC2_VI: - write_nic_dword(dev, AC_VI_PARAM, u4bAcParam); - break; - case AC3_VO: - write_nic_dword(dev, AC_VO_PARAM, u4bAcParam); - break; - default: - pr_warn("SetHwReg8185(): invalid ACI: %d !\n", - eACI); - break; - } - } - ac_param += (sizeof(AC_PARAM)); + for (eACI = 0; eACI < AC_MAX; eACI++) { + rtl8180_wmm_single_param_update(dev, mode, + ((PAC_PARAM)ac_param)->f.AciAifsn.f.ACI, + (PAC_PARAM)ac_param); + + ac_param += sizeof(AC_PARAM); } } void rtl8180_restart_wq(struct work_struct *work); -/* void rtl8180_rq_tx_ack(struct work_struct *work); */ void rtl8180_watch_dog_wq(struct work_struct *work); void rtl8180_hw_wakeup_wq(struct work_struct *work); void rtl8180_hw_sleep_wq(struct work_struct *work); @@ -2208,7 +2185,8 @@ static void watch_dog_adaptive(unsigned long data) /* Tx High Power Mechanism. */ if (CheckHighPower((struct net_device *)data)) - queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->tx_pw_wq); + queue_work(priv->ieee80211->wq, + (void *)&priv->ieee80211->tx_pw_wq); /* Tx Power Tracking on 87SE. */ if (CheckTxPwrTracking((struct net_device *)data)) @@ -2216,27 +2194,59 @@ static void watch_dog_adaptive(unsigned long data) /* Perform DIG immediately. */ if (CheckDig((struct net_device *)data)) - queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->hw_dig_wq); + queue_work(priv->ieee80211->wq, + (void *)&priv->ieee80211->hw_dig_wq); + rtl8180_watch_dog((struct net_device *)data); - queue_work(priv->ieee80211->wq, (void *)&priv->ieee80211->GPIOChangeRFWorkItem); + queue_work(priv->ieee80211->wq, + (void *)&priv->ieee80211->GPIOChangeRFWorkItem); + + priv->watch_dog_timer.expires = jiffies + + MSECS(IEEE80211_WATCH_DOG_TIME); - priv->watch_dog_timer.expires = jiffies + MSECS(IEEE80211_WATCH_DOG_TIME); add_timer(&priv->watch_dog_timer); } -static CHANNEL_LIST ChannelPlan[] = { - {{1,2,3,4,5,6,7,8,9,10,11,36,40,44,48,52,56,60,64},19}, /* 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,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,36,40,44,48,52,56,60,64},21}, /* France. Change to ETSI. */ - {{14,36,40,44,48,52,56,60,64},9}, /* 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,36,40,44,48,52,56,60,64},21}, /* Israel. */ - {{1,2,3,4,5,6,7,8,9,10,11,12,13,34,38,42,46},17}, /* For 11a , TELEC */ - {{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 */ - {{1,2,3,4,5,6,7,8,9,10,11,12,13},13} /* world wide 13: ch1~ch11 active scan, ch12~13 passive //lzm add 080826 */ +static struct rtl8187se_channel_list channel_plan_list[] = { + /* FCC */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, + 44, 48, 52, 56, 60, 64}, 19}, + + /* 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, 36, 40, + 44, 48, 52, 56, 60, 64}, 21}, + + /* France. Change to ETSI. */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 36, 40, + 44, 48, 52, 56, 60, 64}, 21}, + + /* MKK */ + {{14, 36, 40, 44, 48, 52, 56, 60, 64}, 9}, + + /* 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, 36, 40, + 44, 48, 52, 56, 60, 64}, 21}, + + /* For 11a , TELEC */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 34, 38, 42, 46}, 17}, + + /* For Global Domain. 1-11 active, 12-14 passive. */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14}, 14}, + + /* world wide 13: ch1~ch11 active, ch12~13 passive */ + {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13}, 13} }; static void rtl8180_set_channel_map(u8 channel_plan, @@ -2244,7 +2254,6 @@ static void rtl8180_set_channel_map(u8 channel_plan, { int i; - /* lzm add 080826 */ ieee->MinPassiveChnlNum = MAX_CHANNEL_NUMBER+1; ieee->IbssStartChnl = 0; @@ -2261,13 +2270,13 @@ static void rtl8180_set_channel_map(u8 channel_plan, { Dot11d_Init(ieee); ieee->bGlobalDomain = false; - if (ChannelPlan[channel_plan].Len != 0) { + if (channel_plan_list[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 */ - for (i = 0; i < ChannelPlan[channel_plan].Len; i++) { - if (ChannelPlan[channel_plan].Channel[i] <= 14) - GET_DOT11D_INFO(ieee)->channel_map[ChannelPlan[channel_plan].Channel[i]] = 1; + for (i = 0; i < channel_plan_list[channel_plan].len; i++) { + if (channel_plan_list[channel_plan].channel[i] <= 14) + GET_DOT11D_INFO(ieee)->channel_map[channel_plan_list[channel_plan].channel[i]] = 1; } } break; @@ -2279,7 +2288,7 @@ static void rtl8180_set_channel_map(u8 channel_plan, ieee->bGlobalDomain = true; break; } - case COUNTRY_CODE_WORLD_WIDE_13_INDEX:/* lzm add 080826 */ + case COUNTRY_CODE_WORLD_WIDE_13_INDEX: { ieee->MinPassiveChnlNum = 12; ieee->IbssStartChnl = 10; @@ -2299,19 +2308,17 @@ static void rtl8180_set_channel_map(u8 channel_plan, void GPIOChangeRFWorkItemCallBack(struct work_struct *work); -/* YJ,add,080828 */ -static void rtl8180_statistics_init(struct Stats *pstats) +static void rtl8180_statistics_init(struct stats *pstats) { - memset(pstats, 0, sizeof(struct Stats)); + memset(pstats, 0, sizeof(struct stats)); } -static void rtl8180_link_detect_init(plink_detect_t plink_detect) +static void rtl8180_link_detect_init(struct link_detect_t *plink_detect) { - memset(plink_detect, 0, sizeof(link_detect_t)); - plink_detect->SlotNum = DEFAULT_SLOT_NUM; + memset(plink_detect, 0, sizeof(struct link_detect_t)); + plink_detect->slot_num = DEFAULT_SLOT_NUM; } -/* YJ,add,080828,end */ static void rtl8187se_eeprom_register_read(struct eeprom_93cx6 *eeprom) { struct net_device *dev = eeprom->data; @@ -2360,7 +2367,7 @@ static short rtl8180_init(struct net_device *dev) eeprom_93cx6_read(&eeprom, EEPROM_COUNTRY_CODE>>1, &eeprom_val); priv->channel_plan = eeprom_val & 0xFF; if (priv->channel_plan > COUNTRY_CODE_GLOBAL_DOMAIN) { - printk("rtl8180_init:Error channel plan! Set to default.\n"); + netdev_err(dev, "rtl8180_init: Invalid channel plan! Set to default.\n"); priv->channel_plan = 0; } @@ -2385,7 +2392,8 @@ static short rtl8180_init(struct net_device *dev) rtl8180_link_detect_init(&priv->link_detect); priv->ack_tx_to_ieee = 0; - priv->ieee80211->current_network.beacon_interval = DEFAULT_BEACONINTERVAL; + priv->ieee80211->current_network.beacon_interval = + DEFAULT_BEACONINTERVAL; priv->ieee80211->iw_mode = IW_MODE_INFRA; priv->ieee80211->softmac_features = IEEE_SOFTMAC_SCAN | IEEE_SOFTMAC_ASSOCIATE | IEEE_SOFTMAC_PROBERQ | @@ -2410,12 +2418,12 @@ static short rtl8180_init(struct net_device *dev) priv->bInactivePs = true; /* false; */ priv->ieee80211->bInactivePs = priv->bInactivePs; priv->bSwRfProcessing = false; - priv->eRFPowerState = eRfOff; + priv->eRFPowerState = RF_OFF; priv->RfOffReason = 0; - priv->LedStrategy = SW_LED_MODE0; - priv->TxPollingTimes = 0; /* lzm add 080826 */ + priv->led_strategy = SW_LED_MODE0; + priv->TxPollingTimes = 0; priv->bLeisurePs = true; - priv->dot11PowerSaveMode = eActive; + priv->dot11PowerSaveMode = ACTIVE; priv->AdMinCheckPeriod = 5; priv->AdMaxCheckPeriod = 10; priv->AdMaxRxSsThreshold = 30; /* 60->30 */ @@ -2431,7 +2439,8 @@ static short rtl8180_init(struct net_device *dev) priv->AdRxSsBeforeSwitched = 0; init_timer(&priv->SwAntennaDiversityTimer); priv->SwAntennaDiversityTimer.data = (unsigned long)dev; - priv->SwAntennaDiversityTimer.function = (void *)SwAntennaDiversityTimerCallback; + priv->SwAntennaDiversityTimer.function = + (void *)SwAntennaDiversityTimerCallback; priv->bDigMechanism = true; priv->InitialGain = 6; priv->bXtalCalibration = false; @@ -2440,7 +2449,8 @@ static short rtl8180_init(struct net_device *dev) priv->bTxPowerTrack = false; priv->ThermalMeter = 0; priv->FalseAlarmRegValue = 0; - priv->RegDigOfdmFaUpTh = 0xc; /* Upper threshold of OFDM false alarm, which is used in DIG. */ + priv->RegDigOfdmFaUpTh = 0xc; /* Upper threshold of OFDM false alarm, + which is used in DIG. */ priv->DIG_NumberFallbackVote = 0; priv->DIG_NumberUpgradeVote = 0; priv->LastSignalStrengthInPercent = 0; @@ -2585,7 +2595,8 @@ static short rtl8180_init(struct net_device *dev) priv->bSwAntennaDiverity = priv->EEPROMSwAntennaDiversity; else /* 1:disable antenna diversity, 2: enable antenna diversity. */ - priv->bSwAntennaDiverity = priv->RegSwAntennaDiversityMechanism == 2; + priv->bSwAntennaDiverity = + priv->RegSwAntennaDiversityMechanism == 2; if (priv->RegDefaultAntenna == 0) /* 0: default from EEPROM. */ @@ -2669,7 +2680,8 @@ static short rtl8180_init(struct net_device *dev) TX_BEACON_RING_ADDR)) return -ENOMEM; - if (request_irq(dev->irq, rtl8180_interrupt, IRQF_SHARED, dev->name, dev)) { + if (request_irq(dev->irq, rtl8180_interrupt, + IRQF_SHARED, dev->name, dev)) { DMESGE("Error allocating IRQ %d", dev->irq); return -1; } else { @@ -2718,8 +2730,6 @@ void rtl8180_set_hw_wep(struct net_device *dev) void rtl8185_rf_pins_enable(struct net_device *dev) { - /* u16 tmp; */ - /* tmp = read_nic_word(dev, RFPinsEnable); */ write_nic_word(dev, RFPinsEnable, 0x1fff); /* | tmp); */ } @@ -2768,16 +2778,11 @@ static void rtl8185_write_phy(struct net_device *dev, u8 adr, u32 data) phyw = ((data<<8) | adr); - /* Note that, we must write 0xff7c after 0x7d-0x7f to write BB register. */ + /* Note: we must write 0xff7c after 0x7d-0x7f to write BB register. */ write_nic_byte(dev, 0x7f, ((phyw & 0xff000000) >> 24)); write_nic_byte(dev, 0x7e, ((phyw & 0x00ff0000) >> 16)); write_nic_byte(dev, 0x7d, ((phyw & 0x0000ff00) >> 8)); write_nic_byte(dev, 0x7c, ((phyw & 0x000000ff))); - - /* this is ok to fail when we write AGC table. check for AGC table might be - * done by masking with 0x7f instead of 0xff - */ - /* if (phyr != (data&0xff)) DMESGW("Phy write timeout %x %x %x", phyr, data, adr); */ } inline void write_phy_ofdm(struct net_device *dev, u8 adr, u32 data) @@ -2812,9 +2817,9 @@ void rtl8180_start_tx_beacon(struct net_device *dev) word = read_nic_word(dev, BintrItv); word &= ~BintrItv_BintrItv; word |= 1000; /* priv->ieee80211->current_network.beacon_interval * - ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); - // FIXME: check if correct ^^ worked with 0x3e8; - */ + * ((priv->txbeaconcount > 1)?(priv->txbeaconcount-1):1); + * FIXME: check if correct ^^ worked with 0x3e8; + */ write_nic_word(dev, BintrItv, word); rtl8180_set_mode(dev, EPROM_CMD_NORMAL); @@ -2833,7 +2838,7 @@ static struct net_device_stats *rtl8180_stats(struct net_device *dev) * Change current and default preamble mode. */ static bool MgntActSet_802_11_PowerSaveMode(struct r8180_priv *priv, - RT_PS_MODE rtPsMode) + enum rt_ps_mode rtPsMode) { /* Currently, we do not change power save mode on IBSS mode. */ if (priv->ieee80211->iw_mode == IW_MODE_ADHOC) @@ -2846,25 +2851,26 @@ static bool MgntActSet_802_11_PowerSaveMode(struct r8180_priv *priv, static void LeisurePSEnter(struct r8180_priv *priv) { - if (priv->bLeisurePs) { + if (priv->bLeisurePs) if (priv->ieee80211->ps == IEEE80211_PS_DISABLED) /* IEEE80211_PS_ENABLE */ - MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_MBCAST|IEEE80211_PS_UNICAST); - } + MgntActSet_802_11_PowerSaveMode(priv, + IEEE80211_PS_MBCAST | IEEE80211_PS_UNICAST); } static void LeisurePSLeave(struct r8180_priv *priv) { - if (priv->bLeisurePs) { + if (priv->bLeisurePs) if (priv->ieee80211->ps != IEEE80211_PS_DISABLED) - MgntActSet_802_11_PowerSaveMode(priv, IEEE80211_PS_DISABLED); - } + MgntActSet_802_11_PowerSaveMode( + priv, IEEE80211_PS_DISABLED); } void rtl8180_hw_wakeup_wq(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); - struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, hw_wakeup_wq); + struct ieee80211_device *ieee = container_of( + dwork, struct ieee80211_device, hw_wakeup_wq); struct net_device *dev = ieee->dev; rtl8180_hw_wakeup(dev); @@ -2873,7 +2879,8 @@ void rtl8180_hw_wakeup_wq(struct work_struct *work) void rtl8180_hw_sleep_wq(struct work_struct *work) { struct delayed_work *dwork = to_delayed_work(work); - struct ieee80211_device *ieee = container_of(dwork, struct ieee80211_device, hw_sleep_wq); + struct ieee80211_device *ieee = container_of( + dwork, struct ieee80211_device, hw_sleep_wq); struct net_device *dev = ieee->dev; rtl8180_hw_sleep_down(dev); @@ -2890,23 +2897,30 @@ static void MgntLinkKeepAlive(struct r8180_priv *priv) */ if ((priv->keepAliveLevel == 2) || - (priv->link_detect.LastNumTxUnicast == priv->NumTxUnicast && - priv->link_detect.LastNumRxUnicast == priv->ieee80211->NumRxUnicast) + (priv->link_detect.last_num_tx_unicast == + priv->NumTxUnicast && + priv->link_detect.last_num_rx_unicast == + priv->ieee80211->NumRxUnicast) ) { - priv->link_detect.IdleCount++; + priv->link_detect.idle_count++; /* - * Send a Keep-Alive packet packet to AP if we had been idle for a while. + * Send a Keep-Alive packet packet to AP if we had + * been idle for a while. */ - if (priv->link_detect.IdleCount >= ((KEEP_ALIVE_INTERVAL / CHECK_FOR_HANG_PERIOD)-1)) { - priv->link_detect.IdleCount = 0; - ieee80211_sta_ps_send_null_frame(priv->ieee80211, false); + if (priv->link_detect.idle_count >= + KEEP_ALIVE_INTERVAL / + CHECK_FOR_HANG_PERIOD - 1) { + priv->link_detect.idle_count = 0; + ieee80211_sta_ps_send_null_frame( + priv->ieee80211, false); } } else { - priv->link_detect.IdleCount = 0; + priv->link_detect.idle_count = 0; } - priv->link_detect.LastNumTxUnicast = priv->NumTxUnicast; - priv->link_detect.LastNumRxUnicast = priv->ieee80211->NumRxUnicast; + priv->link_detect.last_num_tx_unicast = priv->NumTxUnicast; + priv->link_detect.last_num_rx_unicast = + priv->ieee80211->NumRxUnicast; } } @@ -2922,36 +2936,42 @@ void rtl8180_watch_dog(struct net_device *dev) if ((priv->ieee80211->iw_mode != IW_MODE_ADHOC) && (priv->ieee80211->state == IEEE80211_NOLINK) && (priv->ieee80211->beinretry == false) && - (priv->eRFPowerState == eRfOn)) + (priv->eRFPowerState == RF_ON)) IPSEnter(dev); } - /* YJ,add,080828,for link state check */ - if ((priv->ieee80211->state == IEEE80211_LINKED) && (priv->ieee80211->iw_mode == IW_MODE_INFRA)) { - SlotIndex = (priv->link_detect.SlotIndex++) % priv->link_detect.SlotNum; - priv->link_detect.RxFrameNum[SlotIndex] = priv->ieee80211->NumRxDataInPeriod + priv->ieee80211->NumRxBcnInPeriod; - for (i = 0; i < priv->link_detect.SlotNum; i++) - TotalRxNum += priv->link_detect.RxFrameNum[i]; + if ((priv->ieee80211->state == IEEE80211_LINKED) && + (priv->ieee80211->iw_mode == IW_MODE_INFRA)) { + SlotIndex = (priv->link_detect.slot_index++) % + priv->link_detect.slot_num; + + priv->link_detect.rx_frame_num[SlotIndex] = + priv->ieee80211->NumRxDataInPeriod + + priv->ieee80211->NumRxBcnInPeriod; + + for (i = 0; i < priv->link_detect.slot_num; i++) + TotalRxNum += priv->link_detect.rx_frame_num[i]; if (TotalRxNum == 0) { priv->ieee80211->state = IEEE80211_ASSOCIATING; - queue_work(priv->ieee80211->wq, &priv->ieee80211->associate_procedure_wq); + queue_work(priv->ieee80211->wq, + &priv->ieee80211->associate_procedure_wq); } } - /* YJ,add,080828,for KeepAlive */ MgntLinkKeepAlive(priv); - /* YJ,add,080828,for LPS */ LeisurePSLeave(priv); if (priv->ieee80211->state == IEEE80211_LINKED) { - priv->link_detect.NumRxOkInPeriod = priv->ieee80211->NumRxDataInPeriod; - if (priv->link_detect.NumRxOkInPeriod > 666 || - priv->link_detect.NumTxOkInPeriod > 666) { + priv->link_detect.num_rx_ok_in_period = + priv->ieee80211->NumRxDataInPeriod; + if (priv->link_detect.num_rx_ok_in_period > 666 || + priv->link_detect.num_tx_ok_in_period > 666) { bBusyTraffic = true; } - if (((priv->link_detect.NumRxOkInPeriod + priv->link_detect.NumTxOkInPeriod) > 8) - || (priv->link_detect.NumRxOkInPeriod > 2)) { + if ((priv->link_detect.num_rx_ok_in_period + + priv->link_detect.num_tx_ok_in_period > 8) + || (priv->link_detect.num_rx_ok_in_period > 2)) { bEnterPS = false; } else bEnterPS = true; @@ -2962,9 +2982,9 @@ void rtl8180_watch_dog(struct net_device *dev) LeisurePSLeave(priv); } else LeisurePSLeave(priv); - priv->link_detect.bBusyTraffic = bBusyTraffic; - priv->link_detect.NumRxOkInPeriod = 0; - priv->link_detect.NumTxOkInPeriod = 0; + priv->link_detect.b_busy_traffic = bBusyTraffic; + priv->link_detect.num_rx_ok_in_period = 0; + priv->link_detect.num_tx_ok_in_period = 0; priv->ieee80211->NumRxDataInPeriod = 0; priv->ieee80211->NumRxBcnInPeriod = 0; } @@ -3047,15 +3067,17 @@ int rtl8180_down(struct net_device *dev) cancel_delayed_work(&priv->ieee80211->hw_dig_wq); cancel_delayed_work(&priv->ieee80211->tx_pw_wq); del_timer_sync(&priv->SwAntennaDiversityTimer); - SetZebraRFPowerState8185(dev, eRfOff); - memset(&(priv->ieee80211->current_network), 0, sizeof(struct ieee80211_network)); + SetZebraRFPowerState8185(dev, RF_OFF); + memset(&priv->ieee80211->current_network, + 0, sizeof(struct ieee80211_network)); priv->ieee80211->state = IEEE80211_NOLINK; return 0; } void rtl8180_restart_wq(struct work_struct *work) { - struct r8180_priv *priv = container_of(work, struct r8180_priv, reset_wq); + struct r8180_priv *priv = container_of( + work, struct r8180_priv, reset_wq); struct net_device *dev = priv->dev; down(&priv->wx_sem); @@ -3116,7 +3138,8 @@ static int r8180_set_mac_adr(struct net_device *dev, void *mac) memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN); if (priv->ieee80211->iw_mode == IW_MODE_MASTER) - memcpy(priv->ieee80211->current_network.bssid, dev->dev_addr, ETH_ALEN); + memcpy(priv->ieee80211->current_network.bssid, + dev->dev_addr, ETH_ALEN); if (priv->up) { rtl8180_down(dev); @@ -3137,7 +3160,8 @@ static int rtl8180_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) switch (cmd) { case RTL_IOCTL_WPA_SUPPLICANT: - ret = ieee80211_wpa_supplicant_ioctl(priv->ieee80211, &wrq->u.data); + ret = ieee80211_wpa_supplicant_ioctl( + priv->ieee80211, &wrq->u.data); return ret; default: return -EOPNOTSUPP; @@ -3387,7 +3411,7 @@ static void rtl8180_tx_isr(struct net_device *dev, int pri, short error) int j, i; int hd; if (error) - priv->stats.txretry++; /* tony 20060601 */ + priv->stats.txretry++; spin_lock_irqsave(&priv->tx_lock, flag); switch (pri) { case MANAGE_PRIORITY: @@ -3540,7 +3564,7 @@ static irqreturn_t rtl8180_interrupt(int irq, void *netdev) spin_lock_irqsave(&priv->irq_th_lock, flags); /* ISR: 4bytes */ - inta = read_nic_dword(dev, ISR); /* & priv->IntrMask; */ + inta = read_nic_dword(dev, ISR); write_nic_dword(dev, ISR, inta); /* reset int situation */ priv->stats.shints++; @@ -3586,7 +3610,7 @@ static irqreturn_t rtl8180_interrupt(int irq, void *netdev) } if (inta & ISR_THPDOK) { /* High priority tx ok */ - priv->link_detect.NumTxOkInPeriod++; /* YJ,add,080828 */ + priv->link_detect.num_tx_ok_in_period++; priv->stats.txhpokint++; rtl8180_tx_isr(dev, HI_PRIORITY, 0); } @@ -3649,14 +3673,14 @@ static irqreturn_t rtl8180_interrupt(int irq, void *netdev) priv->stats.txoverflow++; if (inta & ISR_TNPDOK) { /* Normal priority tx ok */ - priv->link_detect.NumTxOkInPeriod++; /* YJ,add,080828 */ + priv->link_detect.num_tx_ok_in_period++; priv->stats.txnpokint++; rtl8180_tx_isr(dev, NORM_PRIORITY, 0); rtl8180_try_wake_queue(dev, NORM_PRIORITY); } if (inta & ISR_TLPDOK) { /* Low priority tx ok */ - priv->link_detect.NumTxOkInPeriod++; /* YJ,add,080828 */ + priv->link_detect.num_tx_ok_in_period++; priv->stats.txlpokint++; rtl8180_tx_isr(dev, LOW_PRIORITY, 0); rtl8180_try_wake_queue(dev, LOW_PRIORITY); @@ -3664,14 +3688,14 @@ static irqreturn_t rtl8180_interrupt(int irq, void *netdev) if (inta & ISR_TBKDOK) { /* corresponding to BK_PRIORITY */ priv->stats.txbkpokint++; - priv->link_detect.NumTxOkInPeriod++; /* YJ,add,080828 */ + priv->link_detect.num_tx_ok_in_period++; rtl8180_tx_isr(dev, BK_PRIORITY, 0); rtl8180_try_wake_queue(dev, BE_PRIORITY); } if (inta & ISR_TBEDOK) { /* corresponding to BE_PRIORITY */ priv->stats.txbeperr++; - priv->link_detect.NumTxOkInPeriod++; /* YJ,add,080828 */ + priv->link_detect.num_tx_ok_in_period++; rtl8180_tx_isr(dev, BE_PRIORITY, 0); rtl8180_try_wake_queue(dev, BE_PRIORITY); } @@ -3688,17 +3712,19 @@ void rtl8180_irq_rx_tasklet(struct r8180_priv *priv) void GPIOChangeRFWorkItemCallBack(struct work_struct *work) { - struct ieee80211_device *ieee = container_of(work, struct ieee80211_device, GPIOChangeRFWorkItem.work); + struct ieee80211_device *ieee = container_of( + work, struct ieee80211_device, GPIOChangeRFWorkItem.work); struct net_device *dev = ieee->dev; struct r8180_priv *priv = ieee80211_priv(dev); u8 btPSR; u8 btConfig0; - RT_RF_POWER_STATE eRfPowerStateToSet; + enum rt_rf_power_state eRfPowerStateToSet; bool bActuallySet = false; char *argv[3]; static char *RadioPowerPath = "/etc/acpi/events/RadioPower.sh"; - static char *envp[] = {"HOME=/", "TERM=linux", "PATH=/usr/bin:/bin", NULL}; + static char *envp[] = {"HOME=/", "TERM=linux", + "PATH=/usr/bin:/bin", NULL}; static int readf_count; readf_count = (readf_count+1)%0xffff; @@ -3708,24 +3734,24 @@ void GPIOChangeRFWorkItemCallBack(struct work_struct *work) btPSR = read_nic_byte(dev, PSR); write_nic_byte(dev, PSR, (btPSR & ~BIT3)); - /* It need to delay 4us suggested by Jong, 2008-01-16 */ + /* It need to delay 4us suggested */ udelay(4); /* HW radio On/Off according to the value of FF51[4](config0) */ btConfig0 = btPSR = read_nic_byte(dev, CONFIG0); - eRfPowerStateToSet = (btConfig0 & BIT4) ? eRfOn : eRfOff; + eRfPowerStateToSet = (btConfig0 & BIT4) ? RF_ON : RF_OFF; /* Turn LED back on when radio enabled */ - if (eRfPowerStateToSet == eRfOn) + if (eRfPowerStateToSet == RF_ON) write_nic_byte(dev, PSR, btPSR | BIT3); if ((priv->ieee80211->bHwRadioOff == true) && - (eRfPowerStateToSet == eRfOn)) { + (eRfPowerStateToSet == RF_ON)) { priv->ieee80211->bHwRadioOff = false; bActuallySet = true; } else if ((priv->ieee80211->bHwRadioOff == false) && - (eRfPowerStateToSet == eRfOff)) { + (eRfPowerStateToSet == RF_OFF)) { priv->ieee80211->bHwRadioOff = true; bActuallySet = true; } diff --git a/drivers/staging/rtl8187se/r8180_dm.c b/drivers/staging/rtl8187se/r8180_dm.c index 2ccd2cb..8c020e0 100644 --- a/drivers/staging/rtl8187se/r8180_dm.c +++ b/drivers/staging/rtl8187se/r8180_dm.c @@ -1116,14 +1116,14 @@ bool CheckTxPwrTracking(struct net_device *dev) void SwAntennaDiversityTimerCallback(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; /* We do NOT need to switch antenna while RF is off. */ rtState = priv->eRFPowerState; do { - if (rtState == eRfOff) { + if (rtState == RF_OFF) { break; - } else if (rtState == eRfSleep) { + } else if (rtState == RF_SLEEP) { /* Don't access BB/RF under Disable PLL situation. */ break; } diff --git a/drivers/staging/rtl8187se/r8180_rtl8225.h b/drivers/staging/rtl8187se/r8180_rtl8225.h index de084f0..7df7392 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225.h +++ b/drivers/staging/rtl8187se/r8180_rtl8225.h @@ -1,14 +1,13 @@ /* - This is part of the rtl8180-sa2400 driver - released under the GPL (See file COPYING for details). - Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> - - This files contains programming code for the rtl8225 - radio frontend. - - *Many* thanks to Realtek Corp. for their great support! - -*/ + * This is part of the rtl8180-sa2400 driver released under the GPL (See file + * COPYING for details). + * + * Copyright (c) 2005 Andrea Merello <andrea.merello@gmail.com> + * + * This files contains programming code for the rtl8225 radio frontend. + * + * *Many* thanks to Realtek Corp. for their great support! + */ #include "r8180.h" @@ -29,7 +28,7 @@ u16 RF_ReadReg(struct net_device *dev, u8 offset); void rtl8180_set_mode(struct net_device *dev, int mode); void rtl8180_set_mode(struct net_device *dev, int mode); bool SetZebraRFPowerState8185(struct net_device *dev, - RT_RF_POWER_STATE eRFPowerState); + enum rt_rf_power_state eRFPowerState); void rtl8225z4_rf_sleep(struct net_device *dev); void rtl8225z4_rf_wakeup(struct net_device *dev); diff --git a/drivers/staging/rtl8187se/r8180_rtl8225z2.c b/drivers/staging/rtl8187se/r8180_rtl8225z2.c index 7c9a8bf..47104fa 100644 --- a/drivers/staging/rtl8187se/r8180_rtl8225z2.c +++ b/drivers/staging/rtl8187se/r8180_rtl8225z2.c @@ -279,8 +279,8 @@ void rtl8225z2_rf_close(struct net_device *dev) * Map dBm into Tx power index according to current HW model, for example, * RF and PA, and current wireless mode. */ -static s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode, - s32 PowerInDbm) +static s8 DbmToTxPwrIdx(struct r8180_priv *priv, + enum wireless_mode mode, s32 PowerInDbm) { bool bUseDefault = true; s8 TxPwrIdx = 0; @@ -291,7 +291,7 @@ static s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode, */ s32 tmp = 0; - if (WirelessMode == WIRELESS_MODE_G) { + if (mode == WIRELESS_MODE_G) { bUseDefault = false; tmp = (2 * PowerInDbm); @@ -301,7 +301,7 @@ static s8 DbmToTxPwrIdx(struct r8180_priv *priv, WIRELESS_MODE WirelessMode, TxPwrIdx = 40; else TxPwrIdx = (s8)tmp; - } else if (WirelessMode == WIRELESS_MODE_B) { + } else if (mode == WIRELESS_MODE_B) { bUseDefault = false; tmp = (4 * PowerInDbm) - 52; @@ -606,51 +606,12 @@ void rtl8225z2_rf_init(struct net_device *dev) rtl8225z2_rf_set_chan(dev, priv->chan); } -void rtl8225z2_rf_set_mode(struct net_device *dev) -{ - struct r8180_priv *priv = ieee80211_priv(dev); - - if (priv->ieee80211->mode == IEEE_A) { - write_rtl8225(dev, 0x5, 0x1865); - write_nic_dword(dev, RF_PARA, 0x10084); - write_nic_dword(dev, RF_TIMING, 0xa8008); - write_phy_ofdm(dev, 0x0, 0x0); - write_phy_ofdm(dev, 0xa, 0x6); - write_phy_ofdm(dev, 0xb, 0x99); - write_phy_ofdm(dev, 0xf, 0x20); - write_phy_ofdm(dev, 0x11, 0x7); - - rtl8225z2_set_gain(dev, 4); - - write_phy_ofdm(dev, 0x15, 0x40); - write_phy_ofdm(dev, 0x17, 0x40); - - write_nic_dword(dev, 0x94, 0x10000000); - } else { - write_rtl8225(dev, 0x5, 0x1864); - write_nic_dword(dev, RF_PARA, 0x10044); - write_nic_dword(dev, RF_TIMING, 0xa8008); - write_phy_ofdm(dev, 0x0, 0x1); - write_phy_ofdm(dev, 0xa, 0x6); - write_phy_ofdm(dev, 0xb, 0x99); - write_phy_ofdm(dev, 0xf, 0x20); - write_phy_ofdm(dev, 0x11, 0x7); - - rtl8225z2_set_gain(dev, 4); - - write_phy_ofdm(dev, 0x15, 0x40); - write_phy_ofdm(dev, 0x17, 0x40); - - write_nic_dword(dev, 0x94, 0x04000002); - } -} - #define MAX_DOZE_WAITING_TIMES_85B 20 #define MAX_POLLING_24F_TIMES_87SE 10 #define LPS_MAX_SLEEP_WAITING_TIMES_87SE 5 bool SetZebraRFPowerState8185(struct net_device *dev, - RT_RF_POWER_STATE eRFPowerState) + enum rt_rf_power_state eRFPowerState) { struct r8180_priv *priv = ieee80211_priv(dev); u8 btCR9346, btConfig3; @@ -672,7 +633,7 @@ bool SetZebraRFPowerState8185(struct net_device *dev, write_nic_byte(dev, CONFIG3, (btConfig3 | CONFIG3_PARM_En)); switch (eRFPowerState) { - case eRfOn: + case RF_ON: write_nic_word(dev, 0x37C, 0x00EC); /* turn on AFE */ @@ -697,7 +658,7 @@ bool SetZebraRFPowerState8185(struct net_device *dev, u1bTmp = read_nic_byte(dev, 0x24E); write_nic_byte(dev, 0x24E, (u1bTmp & (~(BIT5 | BIT6)))); break; - case eRfSleep: + case RF_SLEEP: for (QueueID = 0, i = 0; QueueID < 6;) { if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { @@ -764,7 +725,7 @@ bool SetZebraRFPowerState8185(struct net_device *dev, } } break; - case eRfOff: + case RF_OFF: for (QueueID = 0, i = 0; QueueID < 6;) { if (get_curr_tx_free_desc(dev, QueueID) == priv->txringcount) { @@ -841,10 +802,10 @@ bool SetZebraRFPowerState8185(struct net_device *dev, void rtl8225z4_rf_sleep(struct net_device *dev) { - MgntActSet_RF_State(dev, eRfSleep, RF_CHANGE_BY_PS); + MgntActSet_RF_State(dev, RF_SLEEP, RF_CHANGE_BY_PS); } void rtl8225z4_rf_wakeup(struct net_device *dev) { - MgntActSet_RF_State(dev, eRfOn, RF_CHANGE_BY_PS); + MgntActSet_RF_State(dev, RF_ON, RF_CHANGE_BY_PS); } diff --git a/drivers/staging/rtl8187se/r8180_wx.c b/drivers/staging/rtl8187se/r8180_wx.c index 9b676e0..b552491 100644 --- a/drivers/staging/rtl8187se/r8180_wx.c +++ b/drivers/staging/rtl8187se/r8180_wx.c @@ -29,7 +29,7 @@ static u32 rtl8180_rates[] = {1000000, 2000000, 5500000, 11000000, #define RATE_COUNT ARRAY_SIZE(rtl8180_rates) -static CHANNEL_LIST DefaultChannelPlan[] = { +static struct rtl8187se_channel_list default_channel_plan[] = { {{1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 36, 40, 44, 48, 52, 56, 60, 64}, 19}, /* 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 */ @@ -337,7 +337,7 @@ static int r8180_wx_set_scan(struct net_device *dev, struct iw_request_info *a, } else { /* prevent scan in BusyTraffic */ /* FIXME: Need to consider last scan time */ - if ((priv->link_detect.bBusyTraffic) && (true)) { + if ((priv->link_detect.b_busy_traffic) && (true)) { ret = 0; printk("Now traffic is busy, please try later!\n"); } else @@ -1030,15 +1030,15 @@ static int r8180_wx_set_channelplan(struct net_device *dev, /* unsigned long flags; */ down(&priv->wx_sem); - if (DefaultChannelPlan[*val].Len != 0) { + if (default_channel_plan[*val].len != 0) { priv->channel_plan = *val; /* Clear old channel map 8 */ for (i = 1; i <= MAX_CHANNEL_NUMBER; i++) GET_DOT11D_INFO(priv->ieee80211)->channel_map[i] = 0; /* Set new channel map */ - for (i = 1; i <= DefaultChannelPlan[*val].Len; i++) - GET_DOT11D_INFO(priv->ieee80211)->channel_map[DefaultChannelPlan[*val].Channel[i-1]] = 1; + for (i = 1; i <= default_channel_plan[*val].len; i++) + GET_DOT11D_INFO(priv->ieee80211)->channel_map[default_channel_plan[*val].channel[i-1]] = 1; } up(&priv->wx_sem); diff --git a/drivers/staging/rtl8187se/r8185b_init.c b/drivers/staging/rtl8187se/r8185b_init.c index c8b9baf..cc6f100 100644 --- a/drivers/staging/rtl8187se/r8185b_init.c +++ b/drivers/staging/rtl8187se/r8185b_init.c @@ -619,10 +619,10 @@ void UpdateInitialGain(struct net_device *dev) struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); /* lzm add 080826 */ - if (priv->eRFPowerState != eRfOn) { + if (priv->eRFPowerState != RF_ON) { /* Don't access BB/RF under disable PLL situation. * RT_TRACE(COMP_DIG, DBG_LOUD, ("UpdateInitialGain - - * pHalData->eRFPowerState!=eRfOn\n")); + * pHalData->eRFPowerState!=RF_ON\n")); * Back to the original state */ priv->InitialGain = priv->InitialGainBackUp; @@ -872,8 +872,8 @@ static u8 GetSupportedWirelessMode8185(struct net_device *dev) static void ActUpdateChannelAccessSetting(struct net_device *dev, - WIRELESS_MODE WirelessMode, - PCHANNEL_ACCESS_SETTING ChnlAccessSetting) + enum wireless_mode mode, + struct chnl_access_setting *chnl_access_setting) { AC_CODING eACI; @@ -890,25 +890,25 @@ ActUpdateChannelAccessSetting(struct net_device *dev, */ /* Suggested by Jong, 2005.12.08. */ - ChnlAccessSetting->SIFS_Timer = 0x22; - ChnlAccessSetting->DIFS_Timer = 0x1C; /* 2006.06.02, by rcnjko. */ - ChnlAccessSetting->SlotTimeTimer = 9; /* 2006.06.02, by rcnjko. */ + chnl_access_setting->sifs_timer = 0x22; + chnl_access_setting->difs_timer = 0x1C; /* 2006.06.02, by rcnjko. */ + chnl_access_setting->slot_time_timer = 9; /* 2006.06.02, by rcnjko. */ /* * Suggested by wcchu, it is the default value of EIFS register, * 2005.12.08. */ - ChnlAccessSetting->EIFS_Timer = 0x5B; - ChnlAccessSetting->CWminIndex = 3; /* 2006.06.02, by rcnjko. */ - ChnlAccessSetting->CWmaxIndex = 7; /* 2006.06.02, by rcnjko. */ + chnl_access_setting->eifs_timer = 0x5B; + chnl_access_setting->cwmin_index = 3; /* 2006.06.02, by rcnjko. */ + chnl_access_setting->cwmax_index = 7; /* 2006.06.02, by rcnjko. */ - write_nic_byte(dev, SIFS, ChnlAccessSetting->SIFS_Timer); + write_nic_byte(dev, SIFS, chnl_access_setting->sifs_timer); /* * Rewrited from directly use PlatformEFIOWrite1Byte(), * by Annie, 2006-03-29. */ - write_nic_byte(dev, SLOT, ChnlAccessSetting->SlotTimeTimer); + write_nic_byte(dev, SLOT, chnl_access_setting->slot_time_timer); - write_nic_byte(dev, EIFS, ChnlAccessSetting->EIFS_Timer); + write_nic_byte(dev, EIFS, chnl_access_setting->eifs_timer); /* * <RJ_EXPR_QOS> Suggested by wcchu, it is the default value of EIFS @@ -959,7 +959,7 @@ static void ActSetWirelessMode8185(struct net_device *dev, u8 btWirelessMode) * wireless mode if we switch to specified band successfully. */ - ieee->mode = (WIRELESS_MODE)btWirelessMode; + ieee->mode = (enum wireless_mode)btWirelessMode; /* 3. Change related setting. */ if (ieee->mode == WIRELESS_MODE_A) @@ -1085,7 +1085,7 @@ static bool MgntDisconnect(struct net_device *dev, u8 asRsn) * PASSIVE LEVEL. */ static bool SetRFPowerState(struct net_device *dev, - RT_RF_POWER_STATE eRFPowerState) + enum rt_rf_power_state eRFPowerState) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); bool bResult = false; @@ -1098,13 +1098,13 @@ static bool SetRFPowerState(struct net_device *dev, return bResult; } -bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, +bool MgntActSet_RF_State(struct net_device *dev, enum rt_rf_power_state StateToSet, u32 ChangeSource) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); bool bActionAllowed = false; bool bConnectBySSID = false; - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; u16 RFWaitCounter = 0; unsigned long flag; /* @@ -1140,7 +1140,7 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, rtState = priv->eRFPowerState; switch (StateToSet) { - case eRfOn: + case RF_ON: /* * Turn On RF no matter the IPS setting because we need to * update the RF state to Ndis under Vista, or the Windows @@ -1153,13 +1153,13 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, priv->RfOffReason = 0; bActionAllowed = true; - if (rtState == eRfOff && + if (rtState == RF_OFF && ChangeSource >= RF_CHANGE_BY_HW) bConnectBySSID = true; } break; - case eRfOff: + case RF_OFF: /* 070125, rcnjko: we always keep connected in AP mode. */ if (priv->RfOffReason > RF_CHANGE_BY_IPS) { @@ -1182,7 +1182,7 @@ bool MgntActSet_RF_State(struct net_device *dev, RT_RF_POWER_STATE StateToSet, priv->RfOffReason |= ChangeSource; bActionAllowed = true; break; - case eRfSleep: + case RF_SLEEP: priv->RfOffReason |= ChangeSource; bActionAllowed = true; break; @@ -1233,7 +1233,7 @@ static void InactivePowerSave(struct net_device *dev) void IPSEnter(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; if (priv->bInactivePs) { rtState = priv->eRFPowerState; @@ -1245,9 +1245,9 @@ void IPSEnter(struct net_device *dev) * trigger IPS)(4) IBSS (send Beacon) * (5) AP mode (send Beacon) */ - if (rtState == eRfOn && !priv->bSwRfProcessing + if (rtState == RF_ON && !priv->bSwRfProcessing && (priv->ieee80211->state != IEEE80211_LINKED)) { - priv->eInactivePowerState = eRfOff; + priv->eInactivePowerState = RF_OFF; InactivePowerSave(dev); } } @@ -1255,13 +1255,13 @@ void IPSEnter(struct net_device *dev) void IPSLeave(struct net_device *dev) { struct r8180_priv *priv = (struct r8180_priv *)ieee80211_priv(dev); - RT_RF_POWER_STATE rtState; + enum rt_rf_power_state rtState; if (priv->bInactivePs) { rtState = priv->eRFPowerState; - if ((rtState == eRfOff || rtState == eRfSleep) && + if ((rtState == RF_OFF || rtState == RF_SLEEP) && !priv->bSwRfProcessing && priv->RfOffReason <= RF_CHANGE_BY_IPS) { - priv->eInactivePowerState = eRfOn; + priv->eInactivePowerState = RF_ON; InactivePowerSave(dev); } } @@ -1385,23 +1385,23 @@ void rtl8185b_adapter_start(struct net_device *dev) /* Initialize RegWirelessMode if it is not a valid one. */ if (bInvalidWirelessMode) - ieee->mode = (WIRELESS_MODE)InitWirelessMode; + ieee->mode = (enum wireless_mode)InitWirelessMode; } else { /* One of B, G, A. */ InitWirelessMode = ieee->mode; } - priv->eRFPowerState = eRfOff; + priv->eRFPowerState = RF_OFF; priv->RfOffReason = 0; { - MgntActSet_RF_State(dev, eRfOn, 0); + MgntActSet_RF_State(dev, RF_ON, 0); } /* * If inactive power mode is enabled, disable rf while in * disconnected state. */ if (priv->bInactivePs) - MgntActSet_RF_State(dev , eRfOff, RF_CHANGE_BY_IPS); + MgntActSet_RF_State(dev , RF_OFF, RF_CHANGE_BY_IPS); ActSetWirelessMode8185(dev, (u8)(InitWirelessMode)); |