From patchwork Mon Jul 11 10:01:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sunil Kovvuri X-Patchwork-Id: 9223165 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 D3D8C60760 for ; Mon, 11 Jul 2016 10:06:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C3B3222B1F for ; Mon, 11 Jul 2016 10:06:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B890B2793B; Mon, 11 Jul 2016 10:06:50 +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 4E84E22B1F for ; Mon, 11 Jul 2016 10:06:50 +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 1bMY4z-00058F-O5; Mon, 11 Jul 2016 10:04:45 +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 1bMY3Z-00038U-Ec for linux-arm-kernel@lists.infradead.org; Mon, 11 Jul 2016 10:03:23 +0000 Received: by mail-pf0-x243.google.com with SMTP id c74so13265436pfb.0 for ; Mon, 11 Jul 2016 03:02:56 -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=zsu4R2X0G/quj3Stz0Z9bkJVglVEUP6n6zY2dvXiObvjj4OmcyAnUUhypBmQTJQ78i ZM7gHjdVTDJ6ADj0hNsqulagxh1N7KHTpZycn/8FEkR17Y4yObWC2yW9PuAWLHd2kNBW MvT21Qs0Pslj3c62PLzH07aTHs8+MF6g4jtKsoe7KlN3gdypRVWzoaPrrqTzJjMUNNzN uTps8DvS/1/untvtg5UPoekBjY6rz958wE8Yy3ZU65FYD9AUCoTi6naikFp2vMucLmb4 0Vj9dUadQp2l9TDZQghmNG1yHwYVGyHuPhk+L4yOkz4AmEYy2dbze/9NbeBSpI+ETKKD H5mg== 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=HRhhHsz++GR+z3c8uHSkFGwOgp/2h0KI0tPvtezPK/USQMYuISllfMQqH7tBQK6wDo s9a54801FROMT0/HTJW7Fqs1mcYfa7MHDTXsnInMElM+aCAemLaN3UCzfdnC0NEa7mvb B+cGOfYSZ2pcyGliN+BfeIUhYgCAemp+MDCmEF5P1S8ew08Mn/rJdFKwzT1lQf1Xuum6 KtwKjloGeVUcT8BjNO9XrcHG3Ommu8GwCJUqRalBgoFXiPRzmRkMVkzUglCoUNPlgzNI itCL+pfa3pKFCC/byMV74LOoKd6PTwc9081hr16pKJxEgVLb2H/W8hwW9C0gQMJgNNBm k7mQ== X-Gm-Message-State: ALyK8tLWTln8Qu33ybWNc/QYClCmJ21vDk93qmGIt6cLZe1M2CWyKdCWGTHLyePpMvtOIQ== X-Received: by 10.98.9.141 with SMTP id 13mr33818637pfj.130.1468231376514; Mon, 11 Jul 2016 03:02:56 -0700 (PDT) Received: from machine421.in.caveonetworks.com ([14.140.2.178]) by smtp.googlemail.com with ESMTPSA id 15sm3602884pfz.36.2016.07.11.03.02.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jul 2016 03:02:55 -0700 (PDT) From: sunil.kovvuri@gmail.com To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 12/15] net: thunderx: Use skb_add_rx_frag() for split buffer Rx pkts Date: Mon, 11 Jul 2016 15:31:54 +0530 Message-Id: <1468231317-24023-13-git-send-email-sunil.kovvuri@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1468231317-24023-1-git-send-email-sunil.kovvuri@gmail.com> References: <1468231317-24023-1-git-send-email-sunil.kovvuri@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160711_030317_798125_CD765C6C X-CRM114-Status: GOOD ( 12.56 ) 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++;