From patchwork Mon Jan 23 16:59:52 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: 718679 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 whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3v6cxT6SBQz9s3T for ; Tue, 24 Jan 2017 03:59:57 +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="g6tDaPTI"; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 6DABA878B6; Mon, 23 Jan 2017 16:59:56 +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 rBLD26ocgQTC; Mon, 23 Jan 2017 16:59:55 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by whitealder.osuosl.org (Postfix) with ESMTP id A5CA087AEF; Mon, 23 Jan 2017 16:59:55 +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 73AA91C07B7 for ; Mon, 23 Jan 2017 16:59:54 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by whitealder.osuosl.org (Postfix) with ESMTP id 7006487AEF for ; Mon, 23 Jan 2017 16:59:54 +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 Q7H6yCnU8ZVG for ; Mon, 23 Jan 2017 16:59:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pf0-f193.google.com (mail-pf0-f193.google.com [209.85.192.193]) by whitealder.osuosl.org (Postfix) with ESMTPS id F0B4B878B6 for ; Mon, 23 Jan 2017 16:59:53 +0000 (UTC) Received: by mail-pf0-f193.google.com with SMTP id f144so10358624pfa.2 for ; Mon, 23 Jan 2017 08:59:53 -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=CmeFQyZvd5hId/3MhYHJ5BlOiKKY1Z4xaxLknAZ1lMM=; b=g6tDaPTI9VjxZ/u1Emf8hnHkJW8fALYH2vMtTB9i6pc+8T+wH8U2Hcomm2JPfXa7lw UlyQiqaNGJF3cQwNCFN5QsypngecFzLv7fpii0lSVZEmH+0RziVcpNKzh3jRNliyA2cv k+DitJCev7WbthJI/Xb187FSM/5hKOC5vBL9zFFr/gmI/W65Qhr9hBQS2CTLIZBD1jZz +x97C4SGQjsyC1WWgBkgsgErAOaDxx8IxCJF4/yook6C9+EuDLUGNRx0P85wdN0YHea9 B0jPO1D+h1CjNBUqPhLt59DhyRiZ9KwvA1+Mps+dhWvw1P/k+xYDEXGKja3UDR0HE8Du qetQ== 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=CmeFQyZvd5hId/3MhYHJ5BlOiKKY1Z4xaxLknAZ1lMM=; b=Y5Tj3yMFfPJ3nNQQLd9aIP2w2N8bzA8NVXL8CJpu+OPcQ3DnbZzjZCMlC76jcDx+FV F8lkg/x6Cr33ymLdw3ECnDw/zarvlJgLGbnfrxn2YftguWSA6c/R/fQvh8sYDAalAqZC 6YlePS3PkVXnmgGoNybD5Jgq1JEi7Msufj/WbmzlZ3X8uEKRm7VGXAgFbd6ettrFRWHk 7k9EqqGRNgdS1rwHbhydnD79/QXtN0705E6M7a/RO7Qzl3n+mJl5woyDvRH4F6WViEkZ AXOD+SSffdEveDipR/zJ3OMn2ZLYw6iJFSRSfumlb1Oa0vHHlOvZTEs9bNTJpxhAsDPP /FMw== X-Gm-Message-State: AIkVDXIpLpj983FEaIpQkUGm+1l7Ca7Ozm47oWc57eM0TV+vtYRKq+C1VWDtwwQb8aBAOw== X-Received: by 10.98.31.18 with SMTP id f18mr33250843pff.36.1485190793492; Mon, 23 Jan 2017 08:59:53 -0800 (PST) Received: from localhost.localdomain ([2001:470:b:9c3:9e5c:8eff:fe4f:f2d0]) by smtp.gmail.com with ESMTPSA id a2sm38478792pgn.24.2017.01.23.08.59.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Jan 2017 08:59:52 -0800 (PST) From: Alexander Duyck To: intel-wired-lan@lists.osuosl.org, jeffrey.t.kirsher@intel.com Date: Mon, 23 Jan 2017 08:59:52 -0800 Message-ID: <20170123165944.13402.33476.stgit@localhost.localdomain> In-Reply-To: <20170123165647.13402.1254.stgit@localhost.localdomain> References: <20170123165647.13402.1254.stgit@localhost.localdomain> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Subject: [Intel-wired-lan] [next PATCH v3 9/9] 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 dc70ff07a1de..a211abc8999c 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);