From patchwork Tue Oct 4 09:29:18 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9361535 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 90A50600C8 for ; Tue, 4 Oct 2016 09:52:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D2A1287EF for ; Tue, 4 Oct 2016 09:52:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 723582896A; Tue, 4 Oct 2016 09:52:26 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3A709287EF for ; Tue, 4 Oct 2016 09:52:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brMLS-0006Ed-Rh; Tue, 04 Oct 2016 09:49:06 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1brMLR-0006DR-PP for xen-devel@lists.xenproject.org; Tue, 04 Oct 2016 09:49:05 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 01/96-01767-11B73F75; Tue, 04 Oct 2016 09:49:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprFIsWRWlGSWpSXmKPExsXitHRDpK5A9ed wgwcvFSy+b5nM5MDocfjDFZYAxijWzLyk/IoE1owFO20LfklVrN4W1sD4S6yLkZNDQsBfYt/i r6wgNpuAjsTUp5fAbBEBO4lLmw+wg9jMAmUS06c8ZQaxhQWCJJb9mA9WwyKgInHlai8TiM0r4 C7xbukbJoiZchLnj/8Eq+cU8JD4eqqdDcQWAqp5/QbGVpFYP3UWG0SvoMTJmU9YIHZJSBx88Q KolwNoDrfE3277CYx8s5BUzUJStYCRaRWjRnFqUVlqka6RmV5SUWZ6RkluYmaOrqGBmV5uanF xYnpqTmJSsV5yfu4mRmA4MQDBDsYzCwIPMUpyMCmJ8la+/hQuxJeUn1KZkVicEV9UmpNafIhR hoNDSYJ3e+XncCHBotT01Iq0zBxgYMOkJTh4lER4H1UApXmLCxJzizPTIVKnGHU5Pky+vpZJi CUvPy9VSpx3D8gMAZCijNI8uBGwKLvEKCslzMsIdJQQT0FqUW5mCar8K0ZxDkYlYd4mkCk8mX klcJteAR3BBHRE4JYPIEeUJCKkpBoYeR+vXnV2xuPs/E3f12+/tVpe3WHh5M0FBhE77n7vreM OuGikwnZ8toSXlveFbeVdYdLuzL1HdPgP8Dit9Fl4QO7lg08sNl/8J+36G77pWLLL2tdNwpq5 v9mne3Q66RefUjDZs8b4xooFS05M+5Z949beRyvX+6/UXH11/dqW00tFn647+c+wWlGJpTgj0 VCLuag4EQCOlemorQIAAA== X-Env-Sender: prvs=0787cd24c=Paul.Durrant@citrix.com X-Msg-Ref: server-2.tower-27.messagelabs.com!1475574542!10669794!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 44546 invoked from network); 4 Oct 2016 09:49:04 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-2.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 4 Oct 2016 09:49:04 -0000 X-IronPort-AV: E=Sophos;i="5.31,442,1473120000"; d="scan'208";a="382237514" From: Paul Durrant To: , Date: Tue, 4 Oct 2016 10:29:18 +0100 Message-ID: <1475573358-32414-8-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475573358-32414-1-git-send-email-paul.durrant@citrix.com> References: <1475573358-32414-1-git-send-email-paul.durrant@citrix.com> MIME-Version: 1.0 X-DLP: MIA1 Cc: Ross Lagerwall , Paul Durrant , Wei Liu Subject: [Xen-devel] [PATCH v2 net-next 7/7] xen/netback: add fraglist support for to-guest rx X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Ross Lagerwall This allows full 64K skbuffs (with 1500 mtu ethernet, composed of 45 fragments) to be handled by netback for to-guest rx. Signed-off-by: Ross Lagerwall [re-based] Signed-off-by: Paul Durrant Reviewed-by: David Vrabel --- Cc: Wei Liu --- drivers/net/xen-netback/interface.c | 2 +- drivers/net/xen-netback/rx.c | 38 ++++++++++++++++++++++++++++--------- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c index 211d542..4af532a 100644 --- a/drivers/net/xen-netback/interface.c +++ b/drivers/net/xen-netback/interface.c @@ -467,7 +467,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid, dev->netdev_ops = &xenvif_netdev_ops; dev->hw_features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | - NETIF_F_TSO | NETIF_F_TSO6; + NETIF_F_TSO | NETIF_F_TSO6 | NETIF_F_FRAGLIST; dev->features = dev->hw_features | NETIF_F_RXCSUM; dev->ethtool_ops = &xenvif_ethtool_ops; diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c index 8c8c5b5..8e9ade6 100644 --- a/drivers/net/xen-netback/rx.c +++ b/drivers/net/xen-netback/rx.c @@ -215,7 +215,8 @@ static unsigned int xenvif_gso_type(struct sk_buff *skb) struct xenvif_pkt_state { struct sk_buff *skb; size_t remaining_len; - int frag; /* frag == -1 => skb->head */ + struct sk_buff *frag_iter; + int frag; /* frag == -1 => frag_iter->head */ unsigned int frag_offset; struct xen_netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX - 1]; unsigned int extra_count; @@ -237,6 +238,7 @@ static void xenvif_rx_next_skb(struct xenvif_queue *queue, memset(pkt, 0, sizeof(struct xenvif_pkt_state)); pkt->skb = skb; + pkt->frag_iter = skb; pkt->remaining_len = skb->len; pkt->frag = -1; @@ -293,20 +295,40 @@ static void xenvif_rx_complete(struct xenvif_queue *queue, __skb_queue_tail(queue->rx_copy.completed, pkt->skb); } +static void xenvif_rx_next_frag(struct xenvif_pkt_state *pkt) +{ + struct sk_buff *frag_iter = pkt->frag_iter; + unsigned int nr_frags = skb_shinfo(frag_iter)->nr_frags; + + pkt->frag++; + pkt->frag_offset = 0; + + if (pkt->frag >= nr_frags) { + if (frag_iter == pkt->skb) + pkt->frag_iter = skb_shinfo(frag_iter)->frag_list; + else + pkt->frag_iter = frag_iter->next; + + pkt->frag = -1; + } +} + static void xenvif_rx_next_chunk(struct xenvif_queue *queue, struct xenvif_pkt_state *pkt, unsigned int offset, void **data, size_t *len) { - struct sk_buff *skb = pkt->skb; + struct sk_buff *frag_iter = pkt->frag_iter; void *frag_data; size_t frag_len, chunk_len; + BUG_ON(!frag_iter); + if (pkt->frag == -1) { - frag_data = skb->data; - frag_len = skb_headlen(skb); + frag_data = frag_iter->data; + frag_len = skb_headlen(frag_iter); } else { - skb_frag_t *frag = &skb_shinfo(skb)->frags[pkt->frag]; + skb_frag_t *frag = &skb_shinfo(frag_iter)->frags[pkt->frag]; frag_data = skb_frag_address(frag); frag_len = skb_frag_size(frag); @@ -322,10 +344,8 @@ static void xenvif_rx_next_chunk(struct xenvif_queue *queue, pkt->frag_offset += chunk_len; /* Advance to next frag? */ - if (frag_len == chunk_len) { - pkt->frag++; - pkt->frag_offset = 0; - } + if (frag_len == chunk_len) + xenvif_rx_next_frag(pkt); *data = frag_data; *len = chunk_len;