From patchwork Wed Jul 31 08:47:56 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Kazior X-Patchwork-Id: 2836144 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0112B9F7D6 for ; Wed, 31 Jul 2013 08:48:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BC9F5201E0 for ; Wed, 31 Jul 2013 08:48:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 043ED20164 for ; Wed, 31 Jul 2013 08:48:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755898Ab3GaIsN (ORCPT ); Wed, 31 Jul 2013 04:48:13 -0400 Received: from ebb05.tieto.com ([131.207.168.36]:42466 "EHLO ebb05.tieto.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755480Ab3GaIsK (ORCPT ); Wed, 31 Jul 2013 04:48:10 -0400 X-AuditID: 83cfa824-b7f718e000000f53-dc-51f8cf456c8d Received: from FIHGA-EXHUB01.eu.tieto.com ( [131.207.136.34]) by ebb05.tieto.com (SMTP Mailer) with SMTP id 93.F1.03923.54FC8F15; Wed, 31 Jul 2013 11:48:06 +0300 (EEST) Received: from uw001058.eu.tieto.com (10.28.19.57) by inbound.tieto.com (131.207.136.49) with Microsoft SMTP Server id 8.3.298.1; Wed, 31 Jul 2013 11:48:02 +0300 From: Michal Kazior To: CC: , Michal Kazior Subject: [PATCH 1/2] ath10k: implement rx checksum offloading Date: Wed, 31 Jul 2013 10:47:56 +0200 Message-ID: <1375260477-17030-2-git-send-email-michal.kazior@tieto.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1375260477-17030-1-git-send-email-michal.kazior@tieto.com> References: <1375260477-17030-1-git-send-email-michal.kazior@tieto.com> MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrIIsWRmVeSWpSXmKPExsXSfL5DSdft/I9Ag2lPmSweXTrGbPFmxR12 i29bH7A5MHt8nnmXzWPzknqPz5vkApijuGxSUnMyy1KL9O0SuDIOvmIvmChR0f9nH2MD43/h LkYODgkBE4ljS2K7GDmBTDGJC/fWs3UxcnEICaxilDh1/TMrhLOUUWL2lENMIFVsAroSrxrP soLYIgIKEr8mfWQDsZkFfCWePVkGViMsYCtxqv87WA2LgKrEjbZWdhCbV8Bdoq9jGjPEYgWJ OZNsQExOAQ+Jt5ftQEwhoIqZ7/ghigUlTs58wgIxXELi4IsXzCC2kICKxMH1+5knMArMQlI2 C0nZAkamVYz8qUlJBqZ6JZmpJfl6yfm5mxjBobdCZQfj2QdShxgFOBiVeHg9rn8PFGJNLCuu zD3EKMnBpCTK+/v0j0AhvqT8lMqMxOKM+KLSnNTiQ4wSHMxKIrzyQUA53pTEyqrUonyYlDQH i5I4r1cO0CSB9MSS1OzU1ILUIpisDAeHkgTv6rNAjYJFqempFWmZOSUIaSYOTpDhPEDDT4HU 8BYXJOYWZ6ZD5E8x6nJ8vbzlPaMQS15+XqqUOG81SJEASFFGaR7cHFjKeMUoDvSWMO9FkCoe YLqBm/QKaAkT0JLdKt9AlpQkIqSkGhhdz7+ZcPGjqlmhztbNOT9Ki7c/SZliWrDw7YHr/++r T9rCrLenxOPgSY9Z0+WuHGpuPL74H/cavjdJZh6yvjtWmb482ZVivLM3ZdaCh1N79HtZ4iqz 1JebsEXzVLb9ezx9ddRMhmd+al2XKr/yG0l73lgil7wob/7MO/msnpq3nOapKDo0sJxTYinO SDTUYi4qTgQA/RzcRvQCAAA= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP HW supports L3/L4 rx checksum offloading. This should reduce CPU load and improve performance on slow host machines. Signed-off-by: Michal Kazior --- drivers/net/wireless/ath/ath10k/htt_rx.c | 40 ++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index 04f08d9..e784c40 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c @@ -804,6 +804,37 @@ static bool ath10k_htt_rx_has_fcs_err(struct sk_buff *skb) return false; } +static int ath10k_htt_rx_get_csum_state(struct sk_buff *skb) +{ + struct htt_rx_desc *rxd; + u32 flags, info; + bool is_ip4, is_ip6; + bool is_tcp, is_udp; + bool ip_csum_ok, tcpudp_csum_ok; + + rxd = (void *)skb->data - sizeof(*rxd); + flags = __le32_to_cpu(rxd->attention.flags); + info = __le32_to_cpu(rxd->msdu_start.info1); + + is_ip4 = !!(info & RX_MSDU_START_INFO1_IPV4_PROTO); + is_ip6 = !!(info & RX_MSDU_START_INFO1_IPV6_PROTO); + is_tcp = !!(info & RX_MSDU_START_INFO1_TCP_PROTO); + is_udp = !!(info & RX_MSDU_START_INFO1_UDP_PROTO); + ip_csum_ok = !(flags & RX_ATTENTION_FLAGS_IP_CHKSUM_FAIL); + tcpudp_csum_ok = !(flags & RX_ATTENTION_FLAGS_TCP_UDP_CHKSUM_FAIL); + + if (!is_ip4 && !is_ip6) + return CHECKSUM_NONE; + if (!is_tcp && !is_udp) + return CHECKSUM_NONE; + if (!ip_csum_ok) + return CHECKSUM_NONE; + if (!tcpudp_csum_ok) + return CHECKSUM_NONE; + + return CHECKSUM_UNNECESSARY; +} + static void ath10k_htt_rx_handler(struct ath10k_htt *htt, struct htt_rx_indication *rx) { @@ -815,6 +846,7 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt, u8 *fw_desc; int i, j; int ret; + int ip_summed; memset(&info, 0, sizeof(info)); @@ -889,6 +921,11 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt, continue; } + /* The skb is not yet processed and it may be + * reallocated. Since the offload is in the original + * skb extract the checksum now and assign it later */ + ip_summed = ath10k_htt_rx_get_csum_state(msdu_head); + info.skb = msdu_head; info.fcs_err = ath10k_htt_rx_has_fcs_err(msdu_head); info.signal = ATH10K_DEFAULT_NOISE_FLOOR; @@ -914,6 +951,8 @@ static void ath10k_htt_rx_handler(struct ath10k_htt *htt, if (ath10k_htt_rx_hdr_is_amsdu((void *)info.skb->data)) ath10k_dbg(ATH10K_DBG_HTT, "htt mpdu is amsdu\n"); + info.skb->ip_summed = ip_summed; + ath10k_dbg_dump(ATH10K_DBG_HTT_DUMP, NULL, "htt mpdu: ", info.skb->data, info.skb->len); ath10k_process_rx(htt->ar, &info); @@ -980,6 +1019,7 @@ static void ath10k_htt_rx_frag_handler(struct ath10k_htt *htt, info.status = HTT_RX_IND_MPDU_STATUS_OK; info.encrypt_type = MS(__le32_to_cpu(rxd->mpdu_start.info0), RX_MPDU_START_INFO0_ENCRYPT_TYPE); + info.skb->ip_summed = ath10k_htt_rx_get_csum_state(info.skb); if (tkip_mic_err) { ath10k_warn("tkip mic error\n");