From patchwork Tue Feb 7 02:27:36 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: 724873 X-Patchwork-Delegate: jeffrey.t.kirsher@intel.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3vHSt6659Yz9s2P for ; Tue, 7 Feb 2017 13:27:42 +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="izOQ/gPw"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 5745D30A5C; Tue, 7 Feb 2017 02:27:41 +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 RN0p-BRqvWnX; Tue, 7 Feb 2017 02:27:39 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by silver.osuosl.org (Postfix) with ESMTP id 34F3330A6D; Tue, 7 Feb 2017 02:27:39 +0000 (UTC) X-Original-To: intel-wired-lan@lists.osuosl.org Delivered-To: intel-wired-lan@lists.osuosl.org Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 6CD7C1BFEC6 for ; Tue, 7 Feb 2017 02:27:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 670EC8548D for ; Tue, 7 Feb 2017 02:27:38 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from whitealder.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QIbKXjZ99Pyl for ; Tue, 7 Feb 2017 02:27:37 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pg0-f65.google.com (mail-pg0-f65.google.com [74.125.83.65]) by whitealder.osuosl.org (Postfix) with ESMTPS id C4F6D87DD0 for ; Tue, 7 Feb 2017 02:27:37 +0000 (UTC) Received: by mail-pg0-f65.google.com with SMTP id 75so10628201pgf.3 for ; Mon, 06 Feb 2017 18:27:37 -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=UINwGSOjRh+SmAy4unFrlIWqSLjq+jiRnUecZmsAtZE=; b=izOQ/gPwSURFsIdMP+PLYhHIBCwFYhjyeD9dJwshrMNjfvD7oIsHGPPx6Si+14YinG ftpFJCfUsVhiEhO88odnyVkSUocmXVCt4E5lDqa23hSe4EhEiDvh4TRuhFG9gotmzkPb TaKFzGIWZTTcClyRaCYUcJ+YrwJu2UmcvflAbgOh0FgObyv/58Lru1+769xxwob64Zxv 9zaTlukGaUb2aQa+lPR3wG0t6BHQSwI5hc0dwD6nQ9A5e4qCdVfsVKiHF/KQqEh1nsEg tArp/zLUbSDvofpQd0KdrysyMJIjzChyFjho6IDMJJR6z1N26PK3XEm3Bh4LOo7BvLjF fGAg== 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=UINwGSOjRh+SmAy4unFrlIWqSLjq+jiRnUecZmsAtZE=; b=nxSt07hdZN6nZ+me1MwBrj3kjC6KSzhRno8z6Poi2UOH3ZBoHoOhCjVXqR0cPo/83A MHVUpeOQGr0Nf/ijVgvq7jc+zoIWVMiXTiIKHA+NSEzQ+yJwcUKyevZ47zPiT+RbFyWx 40tX9PxyzznvD+XEQZmUqz7heKH4N87qGU1+4RPCTVi4IICH3IwatOqs6OeZQzuukdl1 1Qa4dpYriBhSN2qHO2ssQXmJsdGMM8ZDPCeibDOi3gZLEMovfqNYhhPMRHuJr18yc9lE DJAlxynjJL/WN/Mtm/NG+TFD65/zp+YJu5z8/eZNkTvK0oDyofSHpvmREObu5g75d8dw fBbg== X-Gm-Message-State: AIkVDXK1mDFYm1ylC9mC29VpCmawFppsF8bLWcULgP8ar5GSRewg4ja7PzWW453QCIJ5vw== X-Received: by 10.99.158.2 with SMTP id s2mr17304697pgd.116.1486434457473; Mon, 06 Feb 2017 18:27:37 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id 199sm5657733pfu.91.2017.02.06.18.27.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Feb 2017 18:27:36 -0800 (PST) From: Alexander Duyck To: intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com Date: Mon, 06 Feb 2017 18:27:36 -0800 Message-ID: <20170207022732.9864.74558.stgit@localhost.localdomain> In-Reply-To: <20170207022339.9864.87863.stgit@localhost.localdomain> References: <20170207022339.9864.87863.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Intel-wired-lan] [next PATCH v5 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 Tested-by: Aaron Brown --- 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 cadf91670061..2796e9a2361e 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -7023,6 +7023,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) @@ -7252,6 +7297,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);