From patchwork Mon Jun 6 14:13:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike McCormack X-Patchwork-Id: 852172 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p56EDTi6023558 for ; Mon, 6 Jun 2011 14:13:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754743Ab1FFON1 (ORCPT ); Mon, 6 Jun 2011 10:13:27 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:34210 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753989Ab1FFON1 (ORCPT ); Mon, 6 Jun 2011 10:13:27 -0400 Received: by pwi15 with SMTP id 15so2108882pwi.19 for ; Mon, 06 Jun 2011 07:13:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:sender:message-id:date:from:user-agent :mime-version:to:cc:subject:content-type:content-transfer-encoding; bh=BlW8+AhdRo2ofxZb35+K0n8/n+W9KlMStsYqCdZewQo=; b=b3h1ct9mqzcgorAkJ1rCSzGYKscPe+eiISq3JIznkL5/jUs2xF9o2jAER3l1hvjTei VzQg76EI621pYnlI7Cnz64lfpImFFye3uAY4bvNauaqp9gI6SH9tbg9ZcRlpswW1UbcD 15pZSUS7sFtDeO4S2aF7pTs5KR5j6CiqtuDb4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:user-agent:mime-version:to:cc:subject :content-type:content-transfer-encoding; b=BUgdqKfgSKGLplB4a9ukF6VkP0/qOFL9oEpQe86YPNVpAQU58KBd9swwWAyw3Vq30g +s2P4H0TyGX10J7tznjPy2i07ihpMIHt+PWSiA9+AlyuCePRkLfe0DhD5odFQoCv9YqU Lm+IGf3rV8FB6CtlwGvkjT4ceP0vHEDipkQ1M= Received: by 10.68.14.167 with SMTP id q7mr1835987pbc.430.1307369606706; Mon, 06 Jun 2011 07:13:26 -0700 (PDT) Received: from [192.168.1.166] ([118.34.145.101]) by mx.google.com with ESMTPS id y2sm3713533pbg.56.2011.06.06.07.13.23 (version=SSLv3 cipher=OTHER); Mon, 06 Jun 2011 07:13:25 -0700 (PDT) Message-ID: <4DECE072.10702@ring3k.org> Date: Mon, 06 Jun 2011 23:13:06 +0900 From: Mike McCormack User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.17) Gecko/20110424 Thunderbird/3.1.10 MIME-Version: 1.0 To: Larry.Finger@lwfinger.net, chaoming_li@realsil.com.cn CC: linville@tuxdriver.com, linux-wireless@vger.kernel.org Subject: [PATCH 5/5] rtlwifi: Factor out code to receive one packet Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Mon, 06 Jun 2011 14:13:29 +0000 (UTC) Signed-off-by: Mike McCormack --- drivers/net/wireless/rtlwifi/pci.c | 99 ++++++++++++++++++----------------- 1 files changed, 51 insertions(+), 48 deletions(-) diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c index b60c1ab..cb4e5e8 100644 --- a/drivers/net/wireless/rtlwifi/pci.c +++ b/drivers/net/wireless/rtlwifi/pci.c @@ -626,6 +626,56 @@ tx_status_ok: } } +static void _rtl_receive_one(struct ieee80211_hw *hw, struct sk_buff *skb, + struct ieee80211_rx_status rx_status) +{ + struct rtl_priv *rtlpriv = rtl_priv(hw); + struct ieee80211_hdr *hdr = rtl_get_hdr(skb); + __le16 fc = rtl_get_fc(skb); + bool unicast = false; + struct sk_buff *uskb = NULL; + u8 *pdata; + + + memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); + + if (is_broadcast_ether_addr(hdr->addr1)) { + ;/*TODO*/ + } else if (is_multicast_ether_addr(hdr->addr1)) { + ;/*TODO*/ + } else { + unicast = true; + rtlpriv->stats.rxbytesunicast += skb->len; + } + + rtl_is_special_data(hw, skb, false); + + if (ieee80211_is_data(fc)) { + rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX); + + if (unicast) + rtlpriv->link_info.num_rx_inperiod++; + } + + /* for sw lps */ + rtl_swlps_beacon(hw, (void *)skb->data, skb->len); + rtl_recognize_peer(hw, (void *)skb->data, skb->len); + if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && + (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) && + (ieee80211_is_beacon(fc) || ieee80211_is_probe_resp(fc))) + return; + + if (unlikely(!rtl_action_proc(hw, skb, false))) + return; + + uskb = dev_alloc_skb(skb->len + 128); + memcpy(IEEE80211_SKB_RXCB(uskb), &rx_status, sizeof(rx_status)); + pdata = (u8 *)skb_put(uskb, skb->len); + memcpy(pdata, skb->data, skb->len); + + ieee80211_rx_irqsafe(hw, uskb); +} + static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) { struct rtl_priv *rtlpriv = rtl_priv(hw); @@ -637,7 +687,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) u8 own; u8 tmp_one; u32 bufferaddress; - bool unicast = false; struct rtl_stats stats = { .signal = 0, @@ -654,8 +703,6 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) /*rx pkt */ struct sk_buff *skb = rtlpci->rx_ring[rx_queue_idx].rx_buf[ index]; - struct ieee80211_hdr *hdr; - __le16 fc; struct sk_buff *new_skb = NULL; own = (u8) rtlpriv->cfg->ops->get_desc((u8 *) pdesc, @@ -696,51 +743,7 @@ static void _rtl_pci_rx_interrupt(struct ieee80211_hw *hw) * skb_trim(skb, skb->len - 4); */ - hdr = rtl_get_hdr(skb); - fc = rtl_get_fc(skb); - - memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, - sizeof(rx_status)); - - if (is_broadcast_ether_addr(hdr->addr1)) { - ;/*TODO*/ - } else if (is_multicast_ether_addr(hdr->addr1)) { - ;/*TODO*/ - } else { - unicast = true; - rtlpriv->stats.rxbytesunicast += skb->len; - } - - rtl_is_special_data(hw, skb, false); - - if (ieee80211_is_data(fc)) { - rtlpriv->cfg->ops->led_control(hw, LED_CTL_RX); - - if (unicast) - rtlpriv->link_info.num_rx_inperiod++; - } - - /* for sw lps */ - rtl_swlps_beacon(hw, (void *)skb->data, skb->len); - rtl_recognize_peer(hw, (void *)skb->data, skb->len); - if ((rtlpriv->mac80211.opmode == NL80211_IFTYPE_AP) && - (rtlpriv->rtlhal.current_bandtype == BAND_ON_2_4G) && - (ieee80211_is_beacon(fc) || - ieee80211_is_probe_resp(fc))) { - ; - } else { - if (likely(rtl_action_proc(hw, skb, false))) { - struct sk_buff *uskb = NULL; - u8 *pdata; - uskb = dev_alloc_skb(skb->len + 128); - memcpy(IEEE80211_SKB_RXCB(uskb), - &rx_status, sizeof(rx_status)); - pdata = (u8 *)skb_put(uskb, skb->len); - memcpy(pdata, skb->data, skb->len); - - ieee80211_rx_irqsafe(hw, uskb); - } - } + _rtl_receive_one(hw, skb, rx_status); if (((rtlpriv->link_info.num_rx_inperiod + rtlpriv->link_info.num_tx_inperiod) > 8) ||