From patchwork Thu Feb 27 12:01:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Pubbisetty X-Patchwork-Id: 11408417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4FFA613A4 for ; Thu, 27 Feb 2020 12:02:46 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2B20124692 for ; Thu, 27 Feb 2020 12:02:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="XNEgraEV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="DHnvuYKD" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2B20124692 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=DbvyBmVu9L+Lw2yAlLdIEHgiqJ9xYjqFFFoWh8qcqyg=; b=XNEgraEVWIDUM7z5CZ7BQY3I9Q v6K6hq0ubtcAlAKCQgJ1HyMi368IvmB6c2rcAg/2t2Vztr9ii7TU12s7VF7MoXNTADV52UJjHfWUF WmxlFsTVqXesRcjwSjVFfQsh5k45TqFErQUO37IW+EDiZ+lgcdvhpthOCbGQjYvE8HSp5Xz/PefWR zGIlgv5mxwSgX0ra4KjGxEILScN3vec90UjoOP1va49je0TAxSFOH2noTNxdc3Ovo6Ja/9adjnGIb XMDtj/KzUTUJz2bdKC4vURTrdCtWlpBESdNAiIre2MDrQhBfoN2vWoZjrveGiJ8obtjoQvN/TJ71o pQHV5rsA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7HsK-0001j2-Jo; Thu, 27 Feb 2020 12:02:44 +0000 Received: from mail27.static.mailgun.info ([104.130.122.27]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7HsG-0001ge-9B for ath11k@lists.infradead.org; Thu, 27 Feb 2020 12:02:43 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582804961; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=gZB7jIeLEsEQ6Ub4SFvKxqM6YuD1yRdIGPmm/TK4HkA=; b=DHnvuYKDXFAmpzOfeKYXmvb6ye4R580yvurwFrkgxB3pRAgkeWFqPnt08qHVIQDq3V+6/yJk W0QWfK6DyNtkGdMhYqfBlixFHca39p0ZLple+k7BTrmqFjdmhyUS2NKYnwBA+Z1o/u/3tM7i yYU9JVVO0IdAFnXMXlCzb5ZT1/E= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyJmOGQ2ZiIsICJhdGgxMWtAbGlzdHMuaW5mcmFkZWFkLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e57afb7.7f8aac19dea0-smtp-out-n02; Thu, 27 Feb 2020 12:01:59 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3D35CC433A2; Thu, 27 Feb 2020 12:01:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from vnaralas-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mpubbise) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2069AC43383; Thu, 27 Feb 2020 12:01:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2069AC43383 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mpubbise@codeaurora.org From: Manikanta Pubbisetty To: ath11k@lists.infradead.org Subject: [RFCv2 1/2] mac80211: add receive path for ethernet frame format Date: Thu, 27 Feb 2020 17:31:38 +0530 Message-Id: <1582804899-12814-2-git-send-email-mpubbise@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582804899-12814-1-git-send-email-mpubbise@codeaurora.org> References: <1582804899-12814-1-git-send-email-mpubbise@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_040241_602373_39FDD500 X-CRM114-Status: GOOD ( 24.21 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.27 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Vasanthakumar Thiagarajan , Manikanta Pubbisetty , linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org From: Vasanthakumar Thiagarajan Implement rx path which does fewer processing on the received data frame which has already gone through 802.11 header decapsulation and other functionalities which require 802.11 header in the low level driver or hardware. Currently this rx path is restricted to AP and STA mode, but can be extended for Adhoc mode as well. It is upto to the low level driver to invoke the correct API and make sure if the frame that it passes is in ethernet format and the sta pointer is valid. Co-developed-by: Manikanta Pubbisetty Signed-off-by: Manikanta Pubbisetty Signed-off-by: Vasanthakumar Thiagarajan --- include/net/mac80211.h | 20 +++++ net/mac80211/rx.c | 217 +++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 231 insertions(+), 6 deletions(-) diff --git a/include/net/mac80211.h b/include/net/mac80211.h index ce80773..5959058 100644 --- a/include/net/mac80211.h +++ b/include/net/mac80211.h @@ -1251,6 +1251,9 @@ ieee80211_tx_info_clear_status(struct ieee80211_tx_info *info) * the "0-length PSDU" field included there. The value for it is * in &struct ieee80211_rx_status. Note that if this value isn't * known the frame shouldn't be reported. + * @RX_FLAG_80211_MCAST: If the receiver address (addr1) in the frame is + * multicast. This is used with the data frames by the drivers + * supporting 802.11 hdr decap offload. */ enum mac80211_rx_flags { RX_FLAG_MMIC_ERROR = BIT(0), @@ -1283,6 +1286,7 @@ enum mac80211_rx_flags { RX_FLAG_RADIOTAP_HE_MU = BIT(27), RX_FLAG_RADIOTAP_LSIG = BIT(28), RX_FLAG_NO_PSDU = BIT(29), + RX_FLAG_80211_MCAST = BIT(30), }; /** @@ -4402,6 +4406,22 @@ static inline void ieee80211_rx_ni(struct ieee80211_hw *hw, } /** + * ieee80211_rx_decap_offl - Receive frames in 802.11 decapsulated format + * + * Low level driver capable of 802.11 header decap uses this function. The frame + * will be in ethernet format. + * This function may not be called in IRQ context. Calls to this function + * for a single hardware must be synchronized against each other. + * + * @hw: the hardware this frame came in on + * @sta : the station the frame was received from, must not be %NULL + * @skb: the buffer to receive, owned by mac80211 after this call + * @napi: the NAPI context + */ +void ieee80211_rx_decap_offl(struct ieee80211_hw *hw, struct ieee80211_sta *sta, + struct sk_buff *skb, struct napi_struct *napi); + +/** * ieee80211_sta_ps_transition - PS transition for connected sta * * When operating in AP mode with the %IEEE80211_HW_AP_LINK_PS diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c index ec3a04a..3df9fd9 100644 --- a/net/mac80211/rx.c +++ b/net/mac80211/rx.c @@ -2410,13 +2410,14 @@ __ieee80211_data_to_8023(struct ieee80211_rx_data *rx, bool *port_control) return 0; } +static const u8 pae_group_addr[ETH_ALEN] __aligned(2) = {0x01, 0x80, 0xC2, 0x00, + 0x00, 0x03}; + /* * requires that rx->skb is a frame with ethernet header */ static bool ieee80211_frame_allowed(struct ieee80211_rx_data *rx, __le16 fc) { - static const u8 pae_group_addr[ETH_ALEN] __aligned(2) - = { 0x01, 0x80, 0xC2, 0x00, 0x00, 0x03 }; struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; /* @@ -2471,21 +2472,25 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) struct sk_buff *skb, *xmit_skb; struct ethhdr *ehdr = (struct ethhdr *) rx->skb->data; struct sta_info *dsta; + struct ieee80211_sta_rx_stats *rx_stats; skb = rx->skb; xmit_skb = NULL; ieee80211_rx_stats(dev, skb->len); - if (rx->sta) { + if (rx->sta && rx->seqno_idx > 0) { /* The seqno index has the same property as needed * for the rx_msdu field, i.e. it is IEEE80211_NUM_TIDS * for non-QoS-data frames. Here we know it's a data * frame, so count MSDUs. */ - u64_stats_update_begin(&rx->sta->rx_stats.syncp); - rx->sta->rx_stats.msdu[rx->seqno_idx]++; - u64_stats_update_end(&rx->sta->rx_stats.syncp); + rx_stats = &rx->sta->rx_stats; + if (ieee80211_hw_check(&rx->local->hw, USES_RSS)) + rx_stats = this_cpu_ptr(rx->sta->pcpu_rx_stats); + u64_stats_update_begin(&rx_stats->syncp); + rx_stats->msdu[rx->seqno_idx]++; + u64_stats_update_end(&rx_stats->syncp); } if ((sdata->vif.type == NL80211_IFTYPE_AP || @@ -4658,3 +4663,203 @@ void ieee80211_rx_irqsafe(struct ieee80211_hw *hw, struct sk_buff *skb) tasklet_schedule(&local->tasklet); } EXPORT_SYMBOL(ieee80211_rx_irqsafe); + +/* Receive path for decap offloaded data frames */ + +static void +ieee80211_rx_handle_decap_offl(struct ieee80211_sub_if_data *sdata, + struct sta_info *sta, struct sk_buff *skb, + struct napi_struct *napi) +{ + struct ieee80211_local *local = sdata->local; + struct ieee80211_vif *vif = &sdata->vif; + struct net_device *dev = sdata->dev; + struct ieee80211_rx_status *status; + struct ieee80211_key *key = NULL; + struct ieee80211_rx_data rx; + int i; + struct ethhdr *ehdr; + struct ieee80211_sta_rx_stats *stats = &sta->rx_stats; + + ehdr = (struct ethhdr *)skb->data; + status = IEEE80211_SKB_RXCB(skb); + + if (ieee80211_hw_check(&local->hw, USES_RSS)) + stats = this_cpu_ptr(sta->pcpu_rx_stats); + + /* TODO: Extend ieee80211_rx_decap_offl() with bssid so that Ethernet + * encap/decap can be supported in Adhoc interface type as well. + * Adhoc interface depends on bssid to update last_rx. + */ + if (vif->type != NL80211_IFTYPE_STATION && + vif->type != NL80211_IFTYPE_AP_VLAN && + vif->type != NL80211_IFTYPE_AP) + goto drop; + + if (unlikely(!test_sta_flag(sta, WLAN_STA_AUTHORIZED))) { + if (ehdr->h_proto != sdata->control_port_protocol) + goto drop; + else if (!ether_addr_equal(ehdr->h_dest, vif->addr) && + !ether_addr_equal(ehdr->h_dest, pae_group_addr)) + goto drop; + } + + if (status->flag & RX_FLAG_80211_MCAST) { + for (i = 0; i < NUM_DEFAULT_KEYS; i++) { + key = rcu_dereference(sta->gtk[i]); + if (key) + break; + } + } else { + key = rcu_dereference(sta->ptk[sta->ptk_idx]); + } + + if (key && unlikely(key->flags & KEY_FLAG_TAINTED)) + goto drop; + + if (status->flag & RX_FLAG_MMIC_ERROR) { + if (key) + key->u.tkip.mic_failures++; + goto mic_fail; + } + +#define ETH_RX_CRYPT_FLAGS (RX_FLAG_PN_VALIDATED | RX_FLAG_DECRYPTED) + + if (key && (status->flag & ETH_RX_CRYPT_FLAGS) != ETH_RX_CRYPT_FLAGS) + goto drop; + + if (!(status->flag & RX_FLAG_DUP_VALIDATED)) + goto drop; + + I802_DEBUG_INC(local->dot11ReceivedFragmentCount); + + if (!(status->flag & RX_FLAG_80211_MCAST)) { + stats->last_rx = jiffies; + stats->last_rate = sta_stats_encode_rate(status); + } + + if (sdata->vif.type == NL80211_IFTYPE_STATION && + !(status->flag & RX_FLAG_80211_MCAST)) + ieee80211_sta_reset_conn_monitor(sdata); + + u64_stats_update_begin(&stats->syncp); + stats->fragments++; + stats->packets++; + stats->bytes += skb->len; + u64_stats_update_end(&stats->syncp); + + if (!(status->flag & RX_FLAG_NO_SIGNAL_VAL)) { + stats->last_signal = status->signal; + if (!ieee80211_hw_check(&local->hw, USES_RSS)) + ewma_signal_add(&sta->rx_stats_avg.signal, + -status->signal); + } + + if (status->chains) { + stats->chains = status->chains; + for (i = 0; i < ARRAY_SIZE(status->chain_signal); i++) { + int signal = status->chain_signal[i]; + + if (!(status->chains & BIT(i))) + continue; + + stats->chain_signal_last[i] = signal; + if (!ieee80211_hw_check(&local->hw, USES_RSS)) + ewma_signal_add(&sta->rx_stats_avg.chain_signal[i], + -signal); + } + } + + if (unlikely(ehdr->h_proto == cpu_to_be16(ETH_P_TDLS))) { + struct ieee80211_tdls_data *tf = (void *)skb->data; + + if (pskb_may_pull(skb, + offsetof(struct ieee80211_tdls_data, u)) && + tf->payload_type == WLAN_TDLS_SNAP_RFTYPE && + tf->category == WLAN_CATEGORY_TDLS && + (tf->action_code == WLAN_TDLS_CHANNEL_SWITCH_REQUEST || + tf->action_code == WLAN_TDLS_CHANNEL_SWITCH_RESPONSE)) { + skb_queue_tail(&local->skb_queue_tdls_chsw, skb); + schedule_work(&local->tdls_chsw_work); + return; + } + } + + memset(&rx, 0, sizeof(rx)); + rx.skb = skb; + rx.sdata = sdata; + rx.local = local; + rx.sta = sta; + rx.napi = napi; + + /* Forcing seqno index to -1 so that tid specific stats are + * not updated in ieee80211_deliver_skb(). + */ + rx.seqno_idx = -1; + + if (vif->type == NL80211_IFTYPE_AP_VLAN && sdata->bss && + unlikely(ehdr->h_proto == sdata->control_port_protocol)) { + sdata = container_of(sdata->bss, struct ieee80211_sub_if_data, + u.ap); + dev = sdata->dev; + rx.sdata = sdata; + } + + rx.skb->dev = dev; + + ieee80211_deliver_skb(&rx); + + return; + +mic_fail: + + cfg80211_michael_mic_failure(sdata->dev, sta->addr, + is_multicast_ether_addr(ehdr->h_dest) ? + NL80211_KEYTYPE_GROUP : + NL80211_KEYTYPE_PAIRWISE, + key ? key->conf.keyidx : -1, + NULL, GFP_ATOMIC); + +drop: + stats->dropped++; + dev_kfree_skb(skb); +} + +/* Receive path handler that a low level driver supporting 802.11 hdr decap + * offload can call. The frame is in ethernet format and the assumption is + * all necessary operations like decryption, defrag, deaggregation, etc. + * requiring 802.11 headers are already performed in the low level driver + * or hardware. + */ +void ieee80211_rx_decap_offl(struct ieee80211_hw *hw, + struct ieee80211_sta *pubsta, struct sk_buff *skb, + struct napi_struct *napi) +{ + struct ieee80211_local *local = hw_to_local(hw); + struct sta_info *sta; + + if (unlikely(local->quiescing || local->suspended)) + goto drop; + + if (unlikely(local->in_reconfig)) + goto drop; + + if (WARN_ON(!local->started)) + goto drop; + + if (!pubsta) + goto drop; + + sta = container_of(pubsta, struct sta_info, sta); + + /* TODO: Toggle Rx throughput LED */ + + rcu_read_lock(); + ieee80211_rx_handle_decap_offl(sta->sdata, sta, skb, napi); + rcu_read_unlock(); + + return; +drop: + kfree_skb(skb); +} +EXPORT_SYMBOL(ieee80211_rx_decap_offl); From patchwork Thu Feb 27 12:01:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Manikanta Pubbisetty X-Patchwork-Id: 11408411 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B66F4930 for ; Thu, 27 Feb 2020 12:02:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9219124697 for ; Thu, 27 Feb 2020 12:02:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="Oq0DvkJV"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="E2b7ZFgN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9219124697 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=dvosVGH5w8FdjKSH6zvYGhISgZ7sbOYdXH8WdQJa4iI=; b=Oq0DvkJVAdbtLf3SWrjSMMiLw6 KkyFJe3LQB9lDmBDmokN4Cj9/izkjD8oi8PEt5vnV444tG9JCuAXmnnlNNRJpgPzGEOIWrx0JB+7L mAGqkPg0zDvTnaOoVoSeBDtqOW6eh3SYcFD4EFCjvjMiDPdmOqizGoCGhbTmrPA6Uk7tMoINLRtIB 6rh8pc4X0JVt4TFQCO9vvYWn0gYYScO5wLa08R5wRz6DvUwHcY5SkgMbbtxCrgPC+w+D3ZYRFlqGL BIHkHoA/x895BMDQI5Eym2qONVvY3s+p+WpfrEMK5uUZLbALwqNcD57DnC75f5yty46IMykaRswkc /uNHMrrQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7Hrk-0001N4-2b; Thu, 27 Feb 2020 12:02:08 +0000 Received: from mail26.static.mailgun.info ([104.130.122.26]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1j7Hrg-0001MF-Cz for ath11k@lists.infradead.org; Thu, 27 Feb 2020 12:02:06 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1582804924; h=References: In-Reply-To: Message-Id: Date: Subject: Cc: To: From: Sender; bh=MdhI/9JmNIeifzX3K+y+p1IPxd9/gjBv/nyAAJXJd+I=; b=E2b7ZFgNn6ivj+moZWRhJh7xlVaziLqWK5vojyqpxL40BpzYdgoIdxlBwtwIsVkuSp8VEXjU CtUB3uq2V+Hrgxqm3yPDW4yHCyiPmPqh5vVtAXZejxwCEqI+9IP18gD8ee2aTIUPFf+i6qKd YkoiBTff71qHaYfezOdwJZdrd9Q= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyJmOGQ2ZiIsICJhdGgxMWtAbGlzdHMuaW5mcmFkZWFkLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e57afb9.7f38666f8ed8-smtp-out-n02; Thu, 27 Feb 2020 12:02:01 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9FBE4C4479F; Thu, 27 Feb 2020 12:02:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from vnaralas-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mpubbise) by smtp.codeaurora.org (Postfix) with ESMTPSA id D0227C43383; Thu, 27 Feb 2020 12:01:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D0227C43383 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=mpubbise@codeaurora.org From: Manikanta Pubbisetty To: ath11k@lists.infradead.org Subject: [RFCv2 2/2] ath11k: add 802.11 decapsulation offloading support Date: Thu, 27 Feb 2020 17:31:39 +0530 Message-Id: <1582804899-12814-3-git-send-email-mpubbise@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1582804899-12814-1-git-send-email-mpubbise@codeaurora.org> References: <1582804899-12814-1-git-send-email-mpubbise@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200227_040204_571495_90558707 X-CRM114-Status: GOOD ( 19.81 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.3 on bombadil.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [104.130.122.26 listed in list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: ath11k@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Manikanta Pubbisetty , linux-wireless@vger.kernel.org MIME-Version: 1.0 Sender: "ath11k" Errors-To: ath11k-bounces+patchwork-ath11k=patchwork.kernel.org@lists.infradead.org Adding 802.11 decapsulation offloading support to the driver. Since the packets delivered to the driver are in 802.3 format, these can be sent to the network core with minimal processing in mac80211. This helps in releasing some CPU cycles in the host processor and thereby improving the performance. Ethernet decap can be enabled by using a modparam as shown below: insmod ath11k ethernet_mode=1 Signed-off-by: Manikanta Pubbisetty --- drivers/net/wireless/ath/ath11k/core.c | 4 + drivers/net/wireless/ath/ath11k/core.h | 3 + drivers/net/wireless/ath/ath11k/dp_rx.c | 184 +++++++++++++++++------------ drivers/net/wireless/ath/ath11k/hal_desc.h | 2 + drivers/net/wireless/ath/ath11k/mac.c | 21 ++++ 5 files changed, 140 insertions(+), 74 deletions(-) diff --git a/drivers/net/wireless/ath/ath11k/core.c b/drivers/net/wireless/ath/ath11k/core.c index 6a30601..c9f784a 100644 --- a/drivers/net/wireless/ath/ath11k/core.c +++ b/drivers/net/wireless/ath/ath11k/core.c @@ -17,6 +17,10 @@ unsigned int ath11k_debug_mask; module_param_named(debug_mask, ath11k_debug_mask, uint, 0644); MODULE_PARM_DESC(debug_mask, "Debugging mask"); +unsigned int ath11k_ethernet_mode; +module_param_named(ethernet_mode, ath11k_ethernet_mode, uint, 0644); +MODULE_PARM_DESC(ethernet_mode, "Use ethernet frame datapath 0: disable, 1: enable"); + static const struct ath11k_hw_params ath11k_hw_params = { .name = "ipq8074", .fw = { diff --git a/drivers/net/wireless/ath/ath11k/core.h b/drivers/net/wireless/ath/ath11k/core.h index ce8f7fe..d3d9590 100644 --- a/drivers/net/wireless/ath/ath11k/core.h +++ b/drivers/net/wireless/ath/ath11k/core.h @@ -71,6 +71,7 @@ struct ath11k_skb_rxcb { bool is_first_msdu; bool is_last_msdu; bool is_continuation; + bool is_mcbc; struct hal_rx_desc *rx_desc; u8 err_rel_src; u8 err_code; @@ -78,6 +79,8 @@ struct ath11k_skb_rxcb { u8 unmapped; u8 is_frag; u8 tid; + u16 peer_id; + u16 seq_no; }; enum ath11k_hw_rev { diff --git a/drivers/net/wireless/ath/ath11k/dp_rx.c b/drivers/net/wireless/ath/ath11k/dp_rx.c index 5b9b457..9ffe83d 100644 --- a/drivers/net/wireless/ath/ath11k/dp_rx.c +++ b/drivers/net/wireless/ath/ath11k/dp_rx.c @@ -260,6 +260,13 @@ static u32 ath11k_dp_rxdesc_get_ppduid(struct hal_rx_desc *rx_desc) return __le16_to_cpu(rx_desc->mpdu_start.phy_ppdu_id); } +static bool ath11k_dp_rx_h_attn_is_mcbc(struct hal_rx_desc *desc) +{ + return ath11k_dp_rx_h_msdu_end_first_msdu(desc) && + (!!FIELD_GET(RX_ATTENTION_INFO1_MCAST_BCAST, + __le32_to_cpu(desc->attention.info1))); +} + /* Returns number of Rx buffers replenished */ int ath11k_dp_rxbufs_replenish(struct ath11k_base *ab, int mac_id, struct dp_rxdma_ring *rx_ring, @@ -1977,9 +1984,15 @@ static void ath11k_dp_rx_h_undecap(struct ath11k *ar, struct sk_buff *msdu, decrypted); break; case DP_RX_DECAP_TYPE_ETHERNET2_DIX: - /* TODO undecap support for middle/last msdu's of amsdu */ - ath11k_dp_rx_h_undecap_eth(ar, msdu, first_hdr, - enctype, status); + /* PN for mcast packets will be validated in mac80211; + * remove eth header and add 802.11 header. + */ + if (ATH11K_SKB_RXCB(msdu)->is_mcbc) { + status->flag |= RX_FLAG_80211_MCAST; + if (decrypted) + ath11k_dp_rx_h_undecap_eth(ar, msdu, first_hdr, + enctype, status); + } break; case DP_RX_DECAP_TYPE_8023: /* TODO: Handle undecap for these formats */ @@ -1987,38 +2000,65 @@ static void ath11k_dp_rx_h_undecap(struct ath11k *ar, struct sk_buff *msdu, } } +static struct ath11k_peer * +ath11k_dp_rx_h_find_peer(struct ath11k_base *ab, struct sk_buff *msdu) +{ + struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); + struct hal_rx_desc *rx_desc = rxcb->rx_desc; + struct ath11k_peer *peer = NULL; + + lockdep_assert_held(&ab->base_lock); + + if (rxcb->peer_id) + peer = ath11k_peer_find_by_id(ab, rxcb->peer_id); + if (peer) + return peer; + + if (!rx_desc || + !(rx_desc->mpdu_start.info1 & RX_MPDU_START_INFO1_MAC_ADDR2_VALID)) + return NULL; + + peer = ath11k_peer_find_by_addr(ab, rx_desc->mpdu_start.addr2); + + return peer; +} + static void ath11k_dp_rx_h_mpdu(struct ath11k *ar, struct sk_buff *msdu, struct hal_rx_desc *rx_desc, struct ieee80211_rx_status *rx_status) { - bool fill_crypto_hdr, mcast; + bool fill_crypto_hdr; enum hal_encrypt_type enctype; bool is_decrypted = false; + struct ath11k_skb_rxcb *rxcb; struct ieee80211_hdr *hdr; struct ath11k_peer *peer; u32 err_bitmap; - hdr = (struct ieee80211_hdr *)msdu->data; - /* PN for multicast packets will be checked in mac80211 */ + rxcb = ATH11K_SKB_RXCB(msdu); + rxcb->is_mcbc = ath11k_dp_rx_h_attn_is_mcbc(rx_desc); + fill_crypto_hdr = rxcb->is_mcbc; - mcast = fill_crypto_hdr = is_multicast_ether_addr(hdr->addr1); - - is_decrypted = ath11k_dp_rx_h_attn_is_decrypted(rx_desc); + if (rxcb->is_mcbc) { + rxcb->peer_id = ath11k_dp_rx_h_mpdu_start_peer_id(rx_desc); + rxcb->seq_no = ath11k_dp_rx_h_mpdu_start_seq_no(rx_desc); + } spin_lock_bh(&ar->ab->base_lock); - peer = ath11k_peer_find_by_addr(ar->ab, hdr->addr2); + peer = ath11k_dp_rx_h_find_peer(ar->ab, msdu); if (peer) { - if (mcast) + if (rxcb->is_mcbc) enctype = peer->sec_type_grp; else enctype = peer->sec_type; } else { - enctype = HAL_ENCRYPT_TYPE_OPEN; + enctype = ath11k_dp_rx_h_mpdu_start_enctype(rx_desc); } spin_unlock_bh(&ar->ab->base_lock); + is_decrypted = ath11k_dp_rx_h_attn_is_decrypted(rx_desc); err_bitmap = ath11k_dp_rx_h_attn_mpdu_err(rx_desc); /* Clear per-MPDU flags while leaving per-PPDU flags intact */ @@ -2051,8 +2091,11 @@ static void ath11k_dp_rx_h_mpdu(struct ath11k *ar, if (!is_decrypted || fill_crypto_hdr) return; - hdr = (void *)msdu->data; - hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED); + if (ath11k_dp_rx_h_msdu_start_decap_type(rx_desc) != + DP_RX_DECAP_TYPE_ETHERNET2_DIX) { + hdr = (void *)msdu->data; + hdr->frame_control &= ~__cpu_to_le16(IEEE80211_FCTL_PROTECTED); + } } static void ath11k_dp_rx_h_rate(struct ath11k *ar, struct hal_rx_desc *rx_desc, @@ -2153,52 +2196,47 @@ static void ath11k_dp_rx_h_ppdu(struct ath11k *ar, struct hal_rx_desc *rx_desc, ath11k_dp_rx_h_rate(ar, rx_desc, rx_status); } - -static char *ath11k_print_get_tid(struct ieee80211_hdr *hdr, char *out, - size_t size) -{ - u8 *qc; - int tid; - - if (!ieee80211_is_data_qos(hdr->frame_control)) - return ""; - - qc = ieee80211_get_qos_ctl(hdr); - tid = *qc & IEEE80211_QOS_CTL_TID_MASK; - snprintf(out, size, "tid %d", tid); - - return out; -} - static void ath11k_dp_rx_deliver_msdu(struct ath11k *ar, struct napi_struct *napi, - struct sk_buff *msdu) + struct sk_buff *msdu, + struct ieee80211_rx_status *status) { static const struct ieee80211_radiotap_he known = { - .data1 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN | - IEEE80211_RADIOTAP_HE_DATA1_BW_RU_ALLOC_KNOWN), + .data1 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA1_DATA_MCS_KNOWN), .data2 = cpu_to_le16(IEEE80211_RADIOTAP_HE_DATA2_GI_KNOWN), }; - struct ieee80211_rx_status *status; - struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)msdu->data; + struct ieee80211_rx_status *rx_status; struct ieee80211_radiotap_he *he = NULL; - char tid[32]; + struct ieee80211_sta *pubsta = NULL; + struct ath11k_peer *peer; + struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); + bool is_mcbc = rxcb->is_mcbc; + u8 decap; - status = IEEE80211_SKB_RXCB(msdu); - if (status->encoding == RX_ENC_HE) { + if (status->encoding == RX_ENC_HE && status->flag & RX_FLAG_ONLY_MONITOR) { he = skb_push(msdu, sizeof(known)); memcpy(he, &known, sizeof(known)); status->flag |= RX_FLAG_RADIOTAP_HE; } + if (!(status->flag & RX_FLAG_ONLY_MONITOR)) + decap = ath11k_dp_rx_h_msdu_start_decap_type(rxcb->rx_desc); + else + decap = DP_RX_DECAP_TYPE_RAW; + + spin_lock_bh(&ar->ab->base_lock); + peer = ath11k_dp_rx_h_find_peer(ar->ab, msdu); + if (peer && peer->sta) + pubsta = peer->sta; + spin_unlock_bh(&ar->ab->base_lock); + ath11k_dbg(ar->ab, ATH11K_DBG_DATA, - "rx skb %pK len %u peer %pM %s %s sn %u %s%s%s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i mic-err %i amsdu-more %i\n", + "rx skb %pK len %u peer %pM tid %u %s sn %u %s%s%s%s%s%s%s %srate_idx %u vht_nss %u freq %u band %u flag 0x%x fcs-err %i mic-err %i amsdu-more %i\n", msdu, msdu->len, - ieee80211_get_SA(hdr), - ath11k_print_get_tid(hdr, tid, sizeof(tid)), - is_multicast_ether_addr(ieee80211_get_DA(hdr)) ? - "mcast" : "ucast", - (__le16_to_cpu(hdr->seq_ctrl) & IEEE80211_SCTL_SEQ) >> 4, + peer ? peer->addr : NULL, + rxcb->tid, + (rxcb->rx_desc->msdu_end.info2 & RX_MSDU_END_INFO2_DA_IS_MCBC) ? "mcast" : "ucast", + rxcb->seq_no, (status->encoding == RX_ENC_LEGACY) ? "legacy" : "", (status->encoding == RX_ENC_HT) ? "ht" : "", (status->encoding == RX_ENC_VHT) ? "vht" : "", @@ -2215,20 +2253,28 @@ static void ath11k_dp_rx_deliver_msdu(struct ath11k *ar, struct napi_struct *nap !!(status->flag & RX_FLAG_MMIC_ERROR), !!(status->flag & RX_FLAG_AMSDU_MORE)); + rx_status = IEEE80211_SKB_RXCB(msdu); + *rx_status = *status; + /* TODO: trace rx packet */ - ieee80211_rx_napi(ar->hw, NULL, msdu, napi); + /* PN for multicast packets are validated in mac80211, + * so send them through ieee80211_rx_napi(). + */ + if (decap != DP_RX_DECAP_TYPE_ETHERNET2_DIX || + (is_mcbc && rx_status->flag & RX_FLAG_DECRYPTED)) + ieee80211_rx_napi(ar->hw, pubsta, msdu, napi); + else + ieee80211_rx_decap_offl(ar->hw, pubsta, msdu, napi); } static int ath11k_dp_rx_process_msdu(struct ath11k *ar, struct sk_buff *msdu, - struct sk_buff_head *msdu_list) + struct sk_buff_head *msdu_list, + struct ieee80211_rx_status *rx_status) { struct hal_rx_desc *rx_desc, *lrx_desc; - struct ieee80211_rx_status rx_status = {0}; - struct ieee80211_rx_status *status; struct ath11k_skb_rxcb *rxcb; - struct ieee80211_hdr *hdr; struct sk_buff *last_buf; u8 l3_pad_bytes; u16 msdu_len; @@ -2276,19 +2322,11 @@ static int ath11k_dp_rx_process_msdu(struct ath11k *ar, } } - hdr = (struct ieee80211_hdr *)msdu->data; - - /* Process only data frames */ - if (!ieee80211_is_data(hdr->frame_control)) - return -EINVAL; - - ath11k_dp_rx_h_ppdu(ar, rx_desc, &rx_status); - ath11k_dp_rx_h_mpdu(ar, msdu, rx_desc, &rx_status); + ath11k_dp_rx_h_ppdu(ar, rx_desc, rx_status); + ath11k_dp_rx_h_mpdu(ar, msdu, rx_desc, rx_status); - rx_status.flag |= RX_FLAG_SKIP_MONITOR | RX_FLAG_DUP_VALIDATED; + rx_status->flag |= RX_FLAG_SKIP_MONITOR | RX_FLAG_DUP_VALIDATED; - status = IEEE80211_SKB_RXCB(msdu); - *status = rx_status; return 0; free_out: @@ -2303,6 +2341,7 @@ static void ath11k_dp_rx_process_received_packets(struct ath11k_base *ab, struct ath11k_skb_rxcb *rxcb; struct sk_buff *msdu; struct ath11k *ar; + struct ieee80211_rx_status rx_status = {0}; u8 mac_id; int ret; @@ -2325,7 +2364,7 @@ static void ath11k_dp_rx_process_received_packets(struct ath11k_base *ab, continue; } - ret = ath11k_dp_rx_process_msdu(ar, msdu, msdu_list); + ret = ath11k_dp_rx_process_msdu(ar, msdu, msdu_list, &rx_status); if (ret) { ath11k_dbg(ab, ATH11K_DBG_DATA, "Unable to process msdu %d", ret); @@ -2333,7 +2372,7 @@ static void ath11k_dp_rx_process_received_packets(struct ath11k_base *ab, continue; } - ath11k_dp_rx_deliver_msdu(ar, napi, msdu); + ath11k_dp_rx_deliver_msdu(ar, napi, msdu, &rx_status); (*quota)--; } @@ -2415,9 +2454,13 @@ int ath11k_dp_process_rx(struct ath11k_base *ab, int ring_id, RX_MSDU_DESC_INFO0_LAST_MSDU_IN_MPDU); rxcb->is_continuation = !!(desc->rx_msdu_info.info0 & RX_MSDU_DESC_INFO0_MSDU_CONTINUATION); - rxcb->mac_id = mac_id; + rxcb->peer_id = FIELD_GET(RX_MPDU_DESC_META_DATA_PEER_ID, + desc->rx_mpdu_info.meta_data); + rxcb->seq_no = FIELD_GET(RX_MPDU_DESC_INFO0_SEQ_NUM, + desc->rx_mpdu_info.info0); rxcb->tid = FIELD_GET(HAL_REO_DEST_RING_INFO0_RX_QUEUE_NUM, desc->info0); + rxcb->mac_id = mac_id; __skb_queue_tail(&msdu_list, msdu); @@ -3689,7 +3732,6 @@ static void ath11k_dp_rx_wbm_err(struct ath11k *ar, { struct ath11k_skb_rxcb *rxcb = ATH11K_SKB_RXCB(msdu); struct ieee80211_rx_status rxs = {0}; - struct ieee80211_rx_status *status; bool drop = true; switch (rxcb->err_rel_src) { @@ -3709,10 +3751,7 @@ static void ath11k_dp_rx_wbm_err(struct ath11k *ar, return; } - status = IEEE80211_SKB_RXCB(msdu); - *status = rxs; - - ath11k_dp_rx_deliver_msdu(ar, napi, msdu); + ath11k_dp_rx_deliver_msdu(ar, napi, msdu, &rxs); } int ath11k_dp_rx_process_wbm_err(struct ath11k_base *ab, @@ -4539,7 +4578,7 @@ static int ath11k_dp_rx_mon_deliver(struct ath11k *ar, u32 mac_id, { struct ath11k_pdev_dp *dp = &ar->dp; struct sk_buff *mon_skb, *skb_next, *header; - struct ieee80211_rx_status *rxs = &dp->rx_status, *status; + struct ieee80211_rx_status *rxs = &dp->rx_status; mon_skb = ath11k_dp_rx_mon_merg_msdus(ar, mac_id, head_msdu, tail_msdu, rxs); @@ -4565,10 +4604,7 @@ static int ath11k_dp_rx_mon_deliver(struct ath11k *ar, u32 mac_id, } rxs->flag |= RX_FLAG_ONLY_MONITOR; - status = IEEE80211_SKB_RXCB(mon_skb); - *status = *rxs; - - ath11k_dp_rx_deliver_msdu(ar, napi, mon_skb); + ath11k_dp_rx_deliver_msdu(ar, napi, mon_skb, rxs); mon_skb = skb_next; } while (mon_skb); rxs->flag = 0; diff --git a/drivers/net/wireless/ath/ath11k/hal_desc.h b/drivers/net/wireless/ath/ath11k/hal_desc.h index 5e20038..99ca4a3 100644 --- a/drivers/net/wireless/ath/ath11k/hal_desc.h +++ b/drivers/net/wireless/ath/ath11k/hal_desc.h @@ -494,6 +494,8 @@ struct hal_tlv_hdr { #define RX_MPDU_DESC_INFO0_DA_IDX_TIMEOUT BIT(29) #define RX_MPDU_DESC_INFO0_RAW_MPDU BIT(30) +#define RX_MPDU_DESC_META_DATA_PEER_ID GENMASK(15, 0) + struct rx_mpdu_desc { u32 info0; /* %RX_MPDU_DESC_INFO */ u32 meta_data; diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c index 7f29b4d..3c7e4a9 100644 --- a/drivers/net/wireless/ath/ath11k/mac.c +++ b/drivers/net/wireless/ath/ath11k/mac.c @@ -15,6 +15,8 @@ #include "testmode.h" #include "peer.h" +extern unsigned int ath11k_ethernet_mode; + #define CHAN2G(_channel, _freq, _flags) { \ .band = NL80211_BAND_2GHZ, \ .hw_value = (_channel), \ @@ -4202,6 +4204,25 @@ static int ath11k_mac_op_add_interface(struct ieee80211_hw *hw, goto err_vdev_del; } + /* Do not enable ethernet mode for mesh vifs, packets in mesh network + * can be forwarded to other mesh nodes and mac80211 expects the packet + * in 802.11 format. Also, please note that ethernet mode shall not be + * used on interface where 4addr mode is enabled as we might not have + * 4addr related config during add_interface(). + */ + if (ath11k_ethernet_mode && vif->type != NL80211_IFTYPE_MESH_POINT) { + param_id = WMI_VDEV_PARAM_RX_DECAP_TYPE; + param_value = ATH11K_HW_TXRX_ETHERNET; + + ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, + param_id, param_value); + if (ret) { + ath11k_warn(ab, "failed to set vdev %d tx encap mode: %d\n", + arvif->vdev_id, ret); + goto err_vdev_del; + } + } + nss = get_num_chains(ar->cfg_tx_chainmask) ? : 1; ret = ath11k_wmi_vdev_set_param_cmd(ar, arvif->vdev_id, WMI_VDEV_PARAM_NSS, nss);