From patchwork Wed Jul 13 05:59:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9226857 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 9704360868 for ; Wed, 13 Jul 2016 06:03:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 87A5627813 for ; Wed, 13 Jul 2016 06:03:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7C41227BFF; Wed, 13 Jul 2016 06:03:33 +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=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 0981E27813 for ; Wed, 13 Jul 2016 06:03:33 +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 1bNDFF-0003lL-BI; Wed, 13 Jul 2016 06:02:05 +0000 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bNDE6-0002IZ-UF for linux-arm-kernel@lists.infradead.org; Wed, 13 Jul 2016 06:00:57 +0000 Received: by mail-pf0-x243.google.com with SMTP id i123so2498416pfg.3 for ; Tue, 12 Jul 2016 23:00:36 -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=BKp1u0G1bzZGnq688eYYqKA/o4F55DRvsEZyCRHTW6W4foSjxSX4M9+HI7avgcEKfD MKLrfm441EtkJm9sWXnwZRNlNd2cXWbkjdqojLJFbipALVm/BTpO27ZSZL1CGoxFZyCk uPlOv6mKvBhCug3Yqp/cKQ2HYamVnoBk4giD7cU+r/9H5n4SnGyGjRn81ygb7woqjBWR VHmP8ecxamWw1R4vhtx8YXLG0o5tFm9ohelVoblla2+tGeGCkS1AplXGlaJwsiPNHUF2 Kk7I4EXBQ8LMZQo4RSia02KeLXK+6Em1JwB8MPhcJyQZHExcs4HpxYZHiimJRuRwfTW4 MRrA== 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=fOOMeAI8t607lqzk3Es9JupCqT2VF4Hzx9Mp/sVX98M7e2QeZ6jVlW1uZADp0pBxJX iJf6+JCT00kJo58OfG76eNH20fTacShbSAoHE5f2I75avewJErgawmeOTZu1XcAvrPyS Qmq3SWycERPkR6ulIFl/faOOsBVSAtpcOEr7jhn4aIWntLKb9iq5F7v5b7EnvnpdJNJJ 6YPs7xVAyoimWR3AayNIDTDt+yMNrm1vbUMKzo+tAgTs2U/wdd9/XYNhoJLlZX2faL5n TIDOn3vdemdxqqucyMq5sd6f3IDfOW8+WBpR72gA+aivHkj8xFsRBfN2EGJTn8Xm9d9H JXRA== X-Gm-Message-State: ALyK8tKIa5YPeaTY7TLh6TI4x15OvWvS1lRnIdAxLONU0StsMpne02Gu1Qdr1kB5AMrwHw== X-Received: by 10.98.102.221 with SMTP id s90mr392490pfj.69.1468389636535; Tue, 12 Jul 2016 23:00:36 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id su7sm1634700pab.44.2016.07.12.23.00.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 12 Jul 2016 23:00:35 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 12/15] net: thunderx: Use skb_add_rx_frag() for split buffer Rx pkts Date: Wed, 13 Jul 2016 11:29:36 +0530 Message-Id: <1468389579-482-13-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468389579-482-1-git-send-email-sunil.kovvuri@gmail.com> References: <1468389579-482-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160712_230055_216625_28277B67 X-CRM114-Status: GOOD ( 13.32 ) 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 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++;