From patchwork Mon Feb 6 04:32:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander H Duyck X-Patchwork-Id: 724342 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vGvhZ2m7qz9s2s for ; Mon, 6 Feb 2017 15:32:30 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MZLJRT8e"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id B0F3A87952; Mon, 6 Feb 2017 04:32:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cboawgAx1VsW; Mon, 6 Feb 2017 04:32:28 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 265C687941; Mon, 6 Feb 2017 04:32:28 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 6696F1C0664 for ; Mon, 6 Feb 2017 04:32:26 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 61A0127246 for ; Mon, 6 Feb 2017 04:32:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id j7b3crasic2U for ; Mon, 6 Feb 2017 04:32:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f67.google.com (mail-pg0-f67.google.com [74.125.83.67]) by silver.osuosl.org (Postfix) with ESMTPS id 50B33271EC for ; Mon, 6 Feb 2017 04:32:25 +0000 (UTC) Received: by mail-pg0-f67.google.com with SMTP id 75so7966127pgf.3 for ; Sun, 05 Feb 2017 20:32:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:date:message-id:in-reply-to:references:user-agent :mime-version:content-transfer-encoding; bh=NxOR68w+Te/XorWFobdosxhpgNX3e7dcJbT8+EQKVWI=; b=MZLJRT8edSQu27qvrCluW0++BKtmgY+I80MUgDFW/Y41uKesKp0pebCdrcySl1qRLs SVv6mG2egrpTMyY3Woap4PAYPLg22Z9BWlfUekVCRuOFYbcc19SxCbsXWq4pl1Bx/va4 S6y+llClBbox7CJDxd0CbsI2FmUzOUSgQ/nwv2W943sqisMxVWgXkep2DZ2+v8xnHKhU lZc3NRiOhhPNkOTg5+umMkcAPctmxLPLgbAZxT5CylwglK6lLmu/t+LfQRds0WomA1X9 f/RDnBI5s+lJCYd0IVk8lqhH+Sp5qNm44RFWQ+NjlCiRWce28QMkMzK7OfYOvyKD18PO qQmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:date:message-id:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=NxOR68w+Te/XorWFobdosxhpgNX3e7dcJbT8+EQKVWI=; b=t9xHLGEOmKA9MxlAVTPiThQSvbUP5lAF5dxoTb1IjCEoyPwTXvDwwn0xvlsri2MDCq CCAKmu8ClUxzR+WwwwJ/7vpd8uQYRkr/P+fywJlfTi2RriTOuM0qR1c6BvlmMGm0n9j4 JylFtSqT7Q9gqKW6hZvKUoLren9DH9Ci2LNa2TkeGtg3+URPfm5JhoimphU3zjAlTYub oZDuB0wuo9cyk6ub0vSTV/rjeBB152YZPDZKSt4XnKmhM1FKEDTw9zz0/7NMkmNbCg25 kx4+/IlE0+tOm3WmbwPQVszNVymwgx3FvMh6CCROQ1mtuXnhiiEOLOvaYLf4QDOLLgX/ 6QsQ== X-Gm-Message-State: AIkVDXLs/ahMF4vEdmr8dsp/IYiBQszo7Pp1nZafL1w6pxroW8E9Xo4XkxeoCO4P+XDGlA== X-Received: by 10.84.131.2 with SMTP id 2mr14626193pld.45.1486355544946; Sun, 05 Feb 2017 20:32:24 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id a1sm23036975pgc.14.2017.02.05.20.32.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 05 Feb 2017 20:32:24 -0800 (PST) From: Alexander Duyck To: intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com Date: Sun, 05 Feb 2017 20:32:24 -0800 Message-ID: <20170206043210.14635.95292.stgit@localhost.localdomain> In-Reply-To: <20170206042508.14635.44702.stgit@localhost.localdomain> References: <20170206042508.14635.44702.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Intel-wired-lan] [next PATCH v4 12/12] igb: Re-add support for build_skb in igb X-BeenThere: intel-wired-lan@lists.osuosl.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Intel Wired Ethernet Linux Kernel Driver Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-wired-lan-bounces@lists.osuosl.org Sender: "Intel-wired-lan" From: Alexander Duyck This reverts commit f9d40f6a9921 ("igb: Revert support for build_skb in igb") and adds a few changes to update it to work with the latest version of igb. We are now able to revert the removal of this due to the fact that with the recent changes to the page count and the use of DMA_ATTR_SKIP_CPU_SYNC we can make the pages writable so we should not be invalidating the additional data added when we call build_skb. Signed-off-by: Alexander Duyck --- drivers/net/ethernet/intel/igb/igb_main.c | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index adb9d708aa18..95852a64de26 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -7020,6 +7020,51 @@ static struct sk_buff *igb_construct_skb(struct igb_ring *rx_ring, return skb; } +static struct sk_buff *igb_build_skb(struct igb_ring *rx_ring, + struct igb_rx_buffer *rx_buffer, + union e1000_adv_rx_desc *rx_desc, + unsigned int size) +{ + void *va = page_address(rx_buffer->page) + rx_buffer->page_offset; +#if (PAGE_SIZE < 8192) + unsigned int truesize = igb_rx_pg_size(rx_ring) / 2; +#else + unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + + SKB_DATA_ALIGN(IGB_SKB_PAD + size); +#endif + struct sk_buff *skb; + + /* prefetch first cache line of first page */ + prefetch(va); +#if L1_CACHE_BYTES < 128 + prefetch(va + L1_CACHE_BYTES); +#endif + + /* build an skb to around the page buffer */ + skb = build_skb(va - IGB_SKB_PAD, truesize); + if (unlikely(!skb)) + return NULL; + + /* update pointers within the skb to store the data */ + skb_reserve(skb, IGB_SKB_PAD); + __skb_put(skb, size); + + /* pull timestamp out of packet data */ + if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) { + igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb); + __skb_pull(skb, IGB_TS_HDR_LEN); + } + + /* update buffer offset */ +#if (PAGE_SIZE < 8192) + rx_buffer->page_offset ^= truesize; +#else + rx_buffer->page_offset += truesize; +#endif + + return skb; +} + static inline void igb_rx_checksum(struct igb_ring *ring, union e1000_adv_rx_desc *rx_desc, struct sk_buff *skb) @@ -7249,6 +7294,8 @@ static int igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget) /* retrieve a buffer from the ring */ if (skb) igb_add_rx_frag(rx_ring, rx_buffer, skb, size); + else if (ring_uses_build_skb(rx_ring)) + skb = igb_build_skb(rx_ring, rx_buffer, rx_desc, size); else skb = igb_construct_skb(rx_ring, rx_buffer, rx_desc, size);