staging: rtl8192e: Use standard functions like ieee80211_is_beacon()
v2 cover staging: rtl8192e: Use standard functions like ieee80211_is_beacon()
Remove useless equation in debug output. Use standard functions like ieee80211_is_beacon(). Optimize code for improved readability.
Tested with rtl8192e (WLL6130-D99) in Mode n (12.5 MB/s) Transferred this patch over wlan connection of rtl8192e.
---v1->v2: Only patch 4/8 was changed
Take wrongly removed definition of fc back in.
Philipp Hortmann (8):
staging: rtl8192e: Remove useless equation in debug output
staging: rtl8192e: Use standard ieee80211 function in rtllib_rx_mgt()
staging: rtl8192e: Use standard function in
rtllib_process_probe_response()
staging: rtl8192e: Use standard function in
rtllib_rx_check_duplicate()
staging: rtl8192e: Use standard function in softmac_mgmt_xmit()
staging: rtl8192e: Replace rtl92e_disable_irq with rtl92e_irq_disable
staging: rtl8192e: Replace rtl92e_enable_irq with rtl92e_irq_enable
staging: rtl8192e: Remove rtllib_get_payload()
.../staging/rtl8192e/rtl8192e/r8192E_dev.c | 6 +-- .../staging/rtl8192e/rtl8192e/r8192E_dev.h | 2 - drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 18 ------- drivers/staging/rtl8192e/rtllib.h | 24 --------- drivers/staging/rtl8192e/rtllib_rx.c | 53 ++++++------------- drivers/staging/rtl8192e/rtllib_softmac.c | 11 +--- 6 files changed, 22 insertions(+), 92 deletions(-)
Signature · 1 line
2.42.0
PATCH v2 1/8 staging: rtl8192e: Remove useless equation in debug output
When "switch (WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)))" results in "case RTLLIB_STYPE_BEACON:" there is no need to calculate this again inside "case" and when a frame is a beacon there is no need to print the frame identifier again as it is explicit.
Same for PROBE RESPONSE and PROBE REQUEST. Remove dead code.
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtllib_rx.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/staging/rtl8192e/rtllib_rx.c +3 -6
@@ -2652,8 +2652,7 @@ static void rtllib_rx_mgt(struct rtllib_device *ieee,switch (WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl))) {case RTLLIB_STYPE_BEACON : -netdev_dbg (ieee->dev,"received BEACON (%d)\n" , -WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl))); +netdev_dbg (ieee->dev,"received BEACON\n" );rtllib_process_probe_response ( ieee, (struct rtllib_probe_response *)header, stats);
@@ -2666,14 +2665,12 @@ static void rtllib_rx_mgt(struct rtllib_device *ieee,break ;case RTLLIB_STYPE_PROBE_RESP : -netdev_dbg (ieee->dev,"received PROBE RESPONSE (%d)\n" , -WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl))); +netdev_dbg (ieee->dev,"received PROBE RESPONSE\n" );rtllib_process_probe_response (ieee, (struct rtllib_probe_response *)header, stats);break ;case RTLLIB_STYPE_PROBE_REQ : -netdev_dbg (ieee->dev,"received PROBE REQUEST (%d)\n" , -WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl))); +netdev_dbg (ieee->dev,"received PROBE REQUEST\n" );if ((ieee->softmac_features &IEEE_SOFTMAC_PROBERS ) && (ieee->iw_mode ==IW_MODE_ADHOC && ieee->link_state ==MAC80211_LINKED ))
Signature · 1 line
2.42.0
PATCH v2 2/8 staging: rtl8192e: Use standard ieee80211 function in rtllib_rx_mgt()
In reply to Philipp HortmannReplace WLAN_FC_GET_STYPE(le16_to_cpu(header->frame_ctl)) and comparison with standard function to avoid proprietary code and to increase readability.
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtllib_rx.c | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-)
drivers/staging/rtl8192e/rtllib_rx.c +5 -13
@@ -2644,14 +2644,11 @@ static void rtllib_rx_mgt(struct rtllib_device *ieee, {struct rtllib_hdr_4addr *header = (struct rtllib_hdr_4addr *)skb->data; -if ((WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl)) != -RTLLIB_STYPE_PROBE_RESP ) && - (WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl)) != -RTLLIB_STYPE_BEACON )) +if (!ieee80211_is_probe_resp (header->frame_ctl) && + (!ieee80211_is_beacon (header->frame_ctl))) ieee->last_rx_ps_time = jiffies; -switch (WLAN_FC_GET_STYPE (le16_to_cpu (header->frame_ctl))) { -case RTLLIB_STYPE_BEACON : +if (ieee80211_is_beacon (header->frame_ctl)) {netdev_dbg (ieee->dev,"received BEACON\n" ); rtllib_process_probe_response( ieee, (struct rtllib_probe_response *)header,
@@ -2661,20 +2658,15 @@ static void rtllib_rx_mgt(struct rtllib_device *ieee, ieee->iw_mode == IW_MODE_INFRA && ieee->link_state == MAC80211_LINKED))schedule_work (&ieee->ps_task); - -break ; - -case RTLLIB_STYPE_PROBE_RESP : + }else if (ieee80211_is_probe_resp (header->frame_ctl)) {netdev_dbg (ieee->dev,"received PROBE RESPONSE\n" );rtllib_process_probe_response (ieee, (struct rtllib_probe_response *)header, stats); -break ; -case RTLLIB_STYPE_PROBE_REQ : + }else if (ieee80211_is_probe_req (header->frame_ctl)) {netdev_dbg (ieee->dev,"received PROBE REQUEST\n" );if ((ieee->softmac_features &IEEE_SOFTMAC_PROBERS ) && (ieee->iw_mode ==IW_MODE_ADHOC && ieee->link_state ==MAC80211_LINKED ))rtllib_rx_probe_rq (ieee, skb); -break ; } }
Signature · 1 line
2.42.0
PATCH v2 3/8 staging: rtl8192e: Use standard function in rtllib_process_probe_response()
In reply to Philipp HortmannReplace proprietary is_beacon() with ieee80211_is_beacon() and proprietary "WLAN_FC_GET_STYPE(frame_ctl) == RTLLIB_STYPE_PROBE_RESP" with standard function to increase readability.
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtllib_rx.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-)
drivers/staging/rtl8192e/rtllib_rx.c +7 -12
@@ -2448,11 +2448,6 @@ static inline void update_network(struct rtllib_device *ieee, dst->BssCcxVerNumber = src->BssCcxVerNumber; } -static inline int is_beacon (u16 fc) -{ -return (WLAN_FC_GET_STYPE (fc) ==RTLLIB_STYPE_BEACON ); -} -static int IsPassiveChannel (struct rtllib_device *rtllib,u8 channel) {if (channel >MAX_CHANNEL_NUMBER ) {
@@ -2491,7 +2486,7 @@ static inline void rtllib_process_probe_response(short renew;struct rtllib_network *network =kzalloc (sizeof (struct rtllib_network ),GFP_ATOMIC ); -u16 frame_ctl =le16_to_cpu (beacon->header.frame_ctl); +__le16 frame_ctl = beacon->header.frame_ctl;if (!network)return ;
@@ -2521,14 +2516,14 @@ static inline void rtllib_process_probe_response(netdev_dbg (ieee->dev,"Dropped '%s' ( %pM) via %s.\n" ,escape_essid (info_element->data, info_element->len), beacon->header.addr3, -is_beacon (frame_ctl) ?"BEACON" :"PROBE RESPONSE" ); +ieee80211_is_beacon (frame_ctl) ?"BEACON" :"PROBE RESPONSE" ); goto free_network; }if (!rtllib_legal_channel (ieee, network->channel)) goto free_network; -if (WLAN_FC_GET_STYPE (frame_ctl) ==RTLLIB_STYPE_PROBE_RESP ) { +if (ieee80211_is_probe_resp (frame_ctl)) {if (IsPassiveChannel (ieee, network->channel)) { netdev_info(ieee->dev, "GetScanInfo(): For Global Domain, filter probe response at channel(%d).\n",
@@ -2561,7 +2556,7 @@ static inline void rtllib_process_probe_response(else ieee->current_network.buseprotection = false; } -if (is_beacon (frame_ctl)) { +if (ieee80211_is_beacon (frame_ctl)) {if (ieee->link_state >=MAC80211_LINKED ) ieee->link_detect_info.NumRecvBcnInPeriod++; }
@@ -2597,7 +2592,7 @@ static inline void rtllib_process_probe_response(netdev_dbg (ieee->dev,"Adding '%s' ( %pM) via %s.\n" ,escape_essid (network->ssid, network->ssid_len), network->bssid, -is_beacon (frame_ctl) ?"BEACON" :"PROBE RESPONSE" ); +ieee80211_is_beacon (frame_ctl) ?"BEACON" :"PROBE RESPONSE" );memcpy (target, network,sizeof (*target));list_add_tail (&target->list, &ieee->network_list);
@@ -2607,7 +2602,7 @@ static inline void rtllib_process_probe_response(netdev_dbg (ieee->dev,"Updating '%s' ( %pM) via %s.\n" ,escape_essid (target->ssid, target->ssid_len), target->bssid, -is_beacon (frame_ctl) ?"BEACON" :"PROBE RESPONSE" ); +ieee80211_is_beacon (frame_ctl) ?"BEACON" :"PROBE RESPONSE" );/* we have an entry and we are going to update it. But this * entry may be already expired. In this case we do the same
@@ -2628,7 +2623,7 @@ static inline void rtllib_process_probe_response( }spin_unlock_irqrestore (&ieee->lock, flags); -if (is_beacon (frame_ctl) && +if (ieee80211_is_beacon (frame_ctl) &&is_same_network (&ieee->current_network, network, (network->ssid_len ?1 :0 )) && (ieee->link_state ==MAC80211_LINKED )) {
Signature · 1 line
2.42.0
PATCH v2 4/8 staging: rtl8192e: Use standard function in rtllib_rx_check_duplicate()
In reply to Philipp HortmannUse standard function ieee80211_is_beacon() to avoid proprietary code and to increase readability.
---v1->v2: Take wrongly removed definition of fc back in.
--- drivers/staging/rtl8192e/rtllib_rx.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/staging/rtl8192e/rtllib_rx.c +2 -5
@@ -904,11 +904,9 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, {struct rtllib_hdr_4addr *hdr = (struct rtllib_hdr_4addr *)skb->data;u16 fc, sc; -u8 frag, type, stype; +u8 frag; fc =le16_to_cpu (hdr->frame_ctl); - type =WLAN_FC_GET_TYPE (fc); - stype =WLAN_FC_GET_STYPE (fc); sc =le16_to_cpu (hdr->seq_ctl); frag =WLAN_GET_SEQ_FRAG (sc);
@@ -916,8 +914,7 @@ static int rtllib_rx_check_duplicate(struct rtllib_device *ieee, !ieee->current_network.qos_data.active || !IsDataFrame(skb->data) || IsLegacyDataFrame(skb->data)) { -if (!((type ==RTLLIB_FTYPE_MGMT ) && - (stype ==RTLLIB_STYPE_BEACON ))) { +if (!ieee80211_is_beacon (hdr->frame_ctl)) {if (is_duplicate_packet (ieee, hdr))return -1 ; }
Signature · 1 line
2.42.0
PATCH v2 5/8 staging: rtl8192e: Use standard function in softmac_mgmt_xmit()
In reply to Philipp HortmannUse standard function ieee80211_is_beacon() to avoid proprietary code to identify beacon and to increase readability in softmac_mgmt_xmit() and _rtl92e_translate_rx_signal_stats()
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtllib.h | 1 - drivers/staging/rtl8192e/rtllib_softmac.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +1 -1
@@ -1584,7 +1584,7 @@ static void _rtl92e_translate_rx_signal_stats(struct net_device *dev, (!pstats->bHwError) && (!pstats->bCRC) && (!pstats->bICV)); bpacket_toself = bpacket_match_bssid &&/* check this */ ether_addr_equal (praddr, priv->rtllib->dev->dev_addr); -if (WLAN_FC_GET_FRAMETYPE (fc) ==RTLLIB_STYPE_BEACON ) +if (ieee80211_is_beacon (hdr->frame_ctl)) bPacketBeacon = true;_rtl92e_process_phyinfo (priv, tmp_buf, &previous_stats, pstats); _rtl92e_query_rxphystatus(priv, pstats, pdesc, pdrvinfo,
drivers/staging/rtl8192e/rtllib.h +0 -1
@@ -459,7 +459,6 @@ enum _REG_PREAMBLE_MODE {#define WLAN_FC_GET_STYPE (fc) ((fc) & RTLLIB_FCTL_STYPE)#define WLAN_FC_MORE_DATA (fc) ((fc) & RTLLIB_FCTL_MOREDATA) -#define WLAN_FC_GET_FRAMETYPE (fc) ((fc) & RTLLIB_FCTL_FRAMETYPE)#define WLAN_GET_SEQ_FRAG (seq) ((seq) & RTLLIB_SCTL_FRAG)#define WLAN_GET_SEQ_SEQ (seq) (((seq) & RTLLIB_SCTL_SEQ) >> 4)
drivers/staging/rtl8192e/rtllib_softmac.c +1 -1
@@ -197,7 +197,7 @@ inline void softmac_mgmt_xmit(struct sk_buff *skb, struct rtllib_device *ieee)/* called with 2nd param 0, no mgmt lock required */ rtllib_sta_wakeup (ieee,0 ); -if (le16_to_cpu (header->frame_ctl) ==RTLLIB_STYPE_BEACON ) +if (ieee80211_is_beacon (header->frame_ctl)) tcb_desc->queue_index =BEACON_QUEUE ;else tcb_desc->queue_index =MGNT_QUEUE ;
Signature · 1 line
2.42.0
PATCH v2 6/8 staging: rtl8192e: Replace rtl92e_disable_irq with rtl92e_irq_disable
In reply to Philipp HortmannReplace rtl92e_disable_irq with rtl92e_irq_disable to increase readability. priv->irq_enabled = 0 was set in both functions.
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h | 1 - drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 9 --------- 3 files changed, 1 insertion(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +1 -1
@@ -1879,7 +1879,7 @@ void rtl92e_enable_irq(struct net_device *dev)rtl92e_writel (dev,INTA_MASK , priv->irq_mask[0 ]); } -void rtl92e_disable_irq (struct net_device *dev) +void rtl92e_irq_disable (struct net_device *dev) {struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv (dev);
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h +0 -1
@@ -17,7 +17,6 @@ void rtl92e_ack_irq(struct net_device *dev, u32 *p_inta);void rtl92e_enable_rx (struct net_device *dev);void rtl92e_enable_tx (struct net_device *dev);void rtl92e_enable_irq (struct net_device *dev); -void rtl92e_disable_irq (struct net_device *dev);void rtl92e_init_variables (struct net_device *dev);void rtl92e_start_beacon (struct net_device *dev);void rtl92e_set_reg (struct net_device *dev,u8 variable,u8 *val);
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +0 -9
@@ -236,15 +236,6 @@ void rtl92e_irq_enable(struct net_device *dev)rtl92e_enable_irq (dev); } -void rtl92e_irq_disable (struct net_device *dev) -{ -struct r8192_priv *priv =rtllib_priv (dev); - -rtl92e_disable_irq (dev); - - priv->irq_enabled =0 ; -} -static void _rtl92e_set_chan (struct net_device *dev,short ch) {struct r8192_priv *priv =rtllib_priv (dev);
Signature · 1 line
2.42.0
PATCH v2 7/8 staging: rtl8192e: Replace rtl92e_enable_irq with rtl92e_irq_enable
In reply to Philipp HortmannReplace rtl92e_enable_irq with rtl92e_irq_enable to increase readability. priv->irq_enabled = 1 was set in both functions.
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c | 2 +- drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h | 1 - drivers/staging/rtl8192e/rtl8192e/rtl_core.c | 9 --------- 3 files changed, 1 insertion(+), 11 deletions(-)
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.c +1 -1
@@ -1870,7 +1870,7 @@ rtl92e_init_variables(struct net_device *dev) priv->bfirst_after_down = false; } -void rtl92e_enable_irq (struct net_device *dev) +void rtl92e_irq_enable (struct net_device *dev) {struct r8192_priv *priv = (struct r8192_priv *)rtllib_priv (dev);
drivers/staging/rtl8192e/rtl8192e/r8192E_dev.h +0 -1
@@ -16,7 +16,6 @@ bool rtl92e_is_rx_stuck(struct net_device *dev);void rtl92e_ack_irq (struct net_device *dev,u32 *p_inta);void rtl92e_enable_rx (struct net_device *dev);void rtl92e_enable_tx (struct net_device *dev); -void rtl92e_enable_irq (struct net_device *dev);void rtl92e_init_variables (struct net_device *dev);void rtl92e_start_beacon (struct net_device *dev);void rtl92e_set_reg (struct net_device *dev,u8 variable,u8 *val);
drivers/staging/rtl8192e/rtl8192e/rtl_core.c +0 -9
@@ -227,15 +227,6 @@ static void _rtl92e_tx_timeout(struct net_device *dev, unsigned int txqueue)netdev_info (dev,"TXTIMEOUT" ); } -void rtl92e_irq_enable (struct net_device *dev) -{ -struct r8192_priv *priv =rtllib_priv (dev); - - priv->irq_enabled =1 ; - -rtl92e_enable_irq (dev); -} -static void _rtl92e_set_chan (struct net_device *dev,short ch) {struct r8192_priv *priv =rtllib_priv (dev);
Signature · 1 line
2.42.0
PATCH v2 8/8 staging: rtl8192e: Remove rtllib_get_payload()
In reply to Philipp Hortmannrtllib_process_action() is only called in one place with management frames. Frame is passed over to rtllib_get_payload() which passes it to rtllib_get_hdrlen(). In rtllib_get_hdrlen() all management frames return with hdrlen = RTLLIB_3ADDR_LEN. Therefore the switch in rtllib_get_payload() is useless and dead code. The condition act == NULL cannot occur and can also be removed. Then rtllib_hdr_2addr is not used anymore and can be removed as well.
---v1->v2: Unchanged
--- drivers/staging/rtl8192e/rtllib.h | 23 ----------------------- drivers/staging/rtl8192e/rtllib_softmac.c | 9 +-------- 2 files changed, 1 insertion(+), 31 deletions(-)
drivers/staging/rtl8192e/rtllib.h +0 -23
@@ -692,14 +692,6 @@ struct rtllib_hdr_1addr {u8 payload[]; } __packed; -struct rtllib_hdr_2addr { -__le16 frame_ctl; -__le16 duration_id; -u8 addr1[ETH_ALEN ]; -u8 addr2[ETH_ALEN ]; -u8 payload[]; -} __packed; -struct rtllib_hdr_3addr {__le16 frame_ctl;__le16 duration_id;
@@ -1781,21 +1773,6 @@ static inline int rtllib_get_hdrlen(u16 fc)return hdrlen; } -static inline u8 *rtllib_get_payload (struct rtllib_hdr *hdr) -{ -switch (rtllib_get_hdrlen (le16_to_cpu (hdr->frame_ctl))) { -case RTLLIB_1ADDR_LEN : -return ((struct rtllib_hdr_1addr *)hdr)->payload; -case RTLLIB_2ADDR_LEN : -return ((struct rtllib_hdr_2addr *)hdr)->payload; -case RTLLIB_3ADDR_LEN : -return ((struct rtllib_hdr_3addr *)hdr)->payload; -case RTLLIB_4ADDR_LEN : -return ((struct rtllib_hdr_4addr *)hdr)->payload; - } -return NULL ; -} -static inline int rtllib_is_ofdm_rate (u8 rate) {switch (rate & ~RTLLIB_BASIC_RATE_MASK ) {
drivers/staging/rtl8192e/rtllib_softmac.c +1 -8
@@ -1921,16 +1921,9 @@ EXPORT_SYMBOL(rtllib_ps_tx_ack);static void rtllib_process_action (struct rtllib_device *ieee,struct sk_buff *skb) { -struct rtllib_hdr_3addr *header = (struct rtllib_hdr_3addr *)skb->data; -u8 *act =rtllib_get_payload ((struct rtllib_hdr *)header); +u8 *act = skb->data +RTLLIB_3ADDR_LEN ;u8 category =0 ; -if (act ==NULL ) { -netdev_warn (ieee->dev, -"Error getting payload of action frame\n" ); -return ; - } - category = *act; act++;switch (category) {
Signature · 1 line
2.42.0