From patchwork Wed Aug 10 06:42:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9272735 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 300ED600CA for ; Wed, 10 Aug 2016 06:53:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 11BC027FBC for ; Wed, 10 Aug 2016 06:53:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 066992832B; Wed, 10 Aug 2016 06:53:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_BL_SPAMCOP_NET,RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 9341927FBC for ; Wed, 10 Aug 2016 06:53:29 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bXNMi-00040i-3D; Wed, 10 Aug 2016 06:51:48 +0000 Received: from mail-pa0-x241.google.com ([2607:f8b0:400e:c03::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bXNGF-0004ab-2m for linux-arm-kernel@lists.infradead.org; Wed, 10 Aug 2016 06:45:10 +0000 Received: by mail-pa0-x241.google.com with SMTP id hh10so2297877pac.1 for ; Tue, 09 Aug 2016 23:44:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=df3Stj/7l+oEV6v+mtzBYGHRfudAfcl246dPcMY2BNg=; b=BFxIGig2cGKPgqO9/U7aqQN/9Ua/IiX1mjb/pEW3iHVxJ/5P94paNM7KHnMunPkHUR ckejY4Jhei8T+vNEp2UzdLD63oirhQkAKoW/3Q/c7e9JR09oFHn/bsulU8QI9yHW1eDu nu3oZ1J80Ca/5vq792PpjCk/KMtpiPmbN2L5MNXRDJYw6xaLBCMhWBYGHZ9lJzXkk3Ff S+7/0NXjfrCtLlo0eihaI6BxDded/u2yV63ApYIua0r1pvDcSr8E+7qefSkMJ8DL2rKU sIcDUVJTChXcXC/6ckw+VVgnQx4SoqVwa3a0nAbdBvzmjsul8l349HiNagfklFxMvNhx m+xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=df3Stj/7l+oEV6v+mtzBYGHRfudAfcl246dPcMY2BNg=; b=LNMvXZztw7fW/KEN11q/UKEdH5eIbpGna2pu1VTtFlsfXnNsmQQanur/Cp/+N4NJ/Y 6e2Z144CEVuBMrItyFiFDBJQPEHboT9VJ8lKSxNdfFpOnckuI1WQOQPD/rsGBz0AAZR4 EdQMmncv+ufnTCLtzWdSTwvGhwPXVjilLiaZ7UkmbzUWLXU5uz33SqzK+vPClUkySMlm 9MZd9qyChyGaXFth1FtL+mvgiHrbVh92wuHq2XrfyJgv0B+FPPpQojMxdg3joocQLFJ7 XmT6gRVMYfc8kMFh2On+U9EZutmA8/OIcLrr5lAKXVY9Mw9hG7pC0TgHP4V8GR0MW52W PNtw== X-Gm-Message-State: AEkooutcjy+Z1l17rqsXVUVg39IQzsm+yQownSvIkGlWFGJf9XsezYliELAumMU62fqXGQ== X-Received: by 10.66.219.105 with SMTP id pn9mr4271025pac.25.1470811487968; Tue, 09 Aug 2016 23:44:47 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id lf11sm60825780pab.17.2016.08.09.23.44.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 09 Aug 2016 23:44:47 -0700 (PDT) From: sunil.kovvuri@gmail.com To: netdev@vger.kernel.org Subject: [PATCH 14/21] net: thunderx: Use skb_add_rx_frag() for split buffer Rx pkts Date: Wed, 10 Aug 2016 12:12:46 +0530 Message-Id: <1470811373-28277-15-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1470811373-28277-1-git-send-email-sunil.kovvuri@gmail.com> References: <1470811373-28277-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160809_234507_346534_74B577CE X-CRM114-Status: GOOD ( 12.85 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sunil Goutham , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Sunil Goutham Instead of a round about way of converting buffers to SKBs and combining them into a frag list, use standard skb_add_rx_frag() API to merge page fragments. This code is useful when incoming packets are of size more than RCV_FRAG_LEN which is currently set to 2048bytes. Signed-off-by: Sunil Goutham --- drivers/net/ethernet/cavium/thunder/nicvf_queues.c | 24 ++++++---------------- 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index ca223aa..ed2fe72 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c @@ -1184,8 +1184,8 @@ struct sk_buff *nicvf_get_rcv_skb(struct nicvf *nic, struct cqe_rx_t *cqe_rx) int frag; int payload_len = 0; struct sk_buff *skb = NULL; - struct sk_buff *skb_frag = NULL; - struct sk_buff *prev_frag = NULL; + struct page *page; + int offset; u16 *rb_lens = NULL; u64 *rb_ptrs = NULL; @@ -1218,22 +1218,10 @@ struct sk_buff *nicvf_get_rcv_skb(struct nicvf *nic, struct cqe_rx_t *cqe_rx) skb_put(skb, payload_len); } else { /* Add fragments */ - skb_frag = nicvf_rb_ptr_to_skb(nic, *rb_ptrs, - payload_len); - if (!skb_frag) { - dev_kfree_skb(skb); - return NULL; - } - - if (!skb_shinfo(skb)->frag_list) - skb_shinfo(skb)->frag_list = skb_frag; - else - prev_frag->next = skb_frag; - - prev_frag = skb_frag; - skb->len += payload_len; - skb->data_len += payload_len; - skb_frag->len = payload_len; + page = virt_to_page(phys_to_virt(*rb_ptrs)); + offset = phys_to_virt(*rb_ptrs) - page_address(page); + skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, + offset, payload_len, RCV_FRAG_LEN); } /* Next buffer pointer */ rb_ptrs++;