From: Joao Martins <joao.martins@neclab.eu>
To: xen-devel@lists.xenproject.org, netdev@vger.kernel.org
Cc: wei.liu2@citrix.com, ian.campbell@citrix.com,
Joao Martins <joao.martins@neclab.eu>,
david.vrabel@citrix.com, boris.ostrovsky@oracle.com
Subject: [RFC PATCH 05/13] xen-netback: refactor xenvif_rx_action
Date: Tue, 12 May 2015 19:18:29 +0200 [thread overview]
Message-ID: <1431451117-70051-6-git-send-email-joao.martins@neclab.eu> (raw)
In-Reply-To: <1431451117-70051-1-git-send-email-joao.martins@neclab.eu>
Refactor xenvif_rx_action by dividing it into build_gops and
submit, similar to what xenvif_tx_action looks like.
Signed-off-by: Joao Martins <joao.martins@neclab.eu>
---
drivers/net/xen-netback/netback.c | 180 ++++++++++++++++++++------------------
1 file changed, 96 insertions(+), 84 deletions(-)
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 738b6ee..c4f57d7 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -789,16 +789,105 @@ void xenvif_kick_thread(struct xenvif_queue *queue)
wake_up(&queue->wq);
}
-static void xenvif_rx_action(struct xenvif_queue *queue)
+static void xenvif_rx_build_gops(struct xenvif_queue *queue,
+ struct netrx_pending_operations *npo,
+ struct sk_buff *skb)
+{
+ RING_IDX old_req_cons;
+ RING_IDX ring_slots_used;
+
+ queue->last_rx_time = jiffies;
+
+ old_req_cons = queue->rx.req_cons;
+ XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, npo, queue);
+ ring_slots_used = queue->rx.req_cons - old_req_cons;
+}
+
+static bool xenvif_rx_submit(struct xenvif_queue *queue,
+ struct netrx_pending_operations *npo,
+ struct sk_buff *skb)
{
s8 status;
u16 flags;
struct xen_netif_rx_response *resp;
- struct sk_buff_head rxq;
- struct sk_buff *skb;
LIST_HEAD(notify);
int ret;
unsigned long offset;
+
+ if ((1 << queue->meta[npo->meta_cons].gso_type) &
+ queue->vif->gso_prefix_mask) {
+ resp = RING_GET_RESPONSE(&queue->rx,
+ queue->rx.rsp_prod_pvt++);
+
+ resp->flags = XEN_NETRXF_gso_prefix | XEN_NETRXF_more_data;
+
+ resp->offset = queue->meta[npo->meta_cons].gso_size;
+ resp->id = queue->meta[npo->meta_cons].id;
+ resp->status = XENVIF_RX_CB(skb)->meta_slots_used;
+
+ npo->meta_cons++;
+ XENVIF_RX_CB(skb)->meta_slots_used--;
+ }
+
+ queue->stats.tx_bytes += skb->len;
+ queue->stats.tx_packets++;
+
+ status = xenvif_check_gop(queue,
+ XENVIF_RX_CB(skb)->meta_slots_used,
+ npo);
+
+ if (XENVIF_RX_CB(skb)->meta_slots_used == 1)
+ flags = 0;
+ else
+ flags = XEN_NETRXF_more_data;
+
+ if (skb->ip_summed == CHECKSUM_PARTIAL) /* local packet? */
+ flags |= XEN_NETRXF_csum_blank | XEN_NETRXF_data_validated;
+ else if (skb->ip_summed == CHECKSUM_UNNECESSARY)
+ /* remote but checksummed. */
+ flags |= XEN_NETRXF_data_validated;
+
+ offset = 0;
+ resp = make_rx_response(queue, queue->meta[npo->meta_cons].id,
+ status, offset,
+ queue->meta[npo->meta_cons].size,
+ flags);
+
+ if ((1 << queue->meta[npo->meta_cons].gso_type) &
+ queue->vif->gso_mask) {
+ struct xen_netif_extra_info *gso =
+ (struct xen_netif_extra_info *)
+ RING_GET_RESPONSE(&queue->rx,
+ queue->rx.rsp_prod_pvt++);
+
+ resp->flags |= XEN_NETRXF_extra_info;
+
+ gso->u.gso.type = queue->meta[npo->meta_cons].gso_type;
+ gso->u.gso.size = queue->meta[npo->meta_cons].gso_size;
+ gso->u.gso.pad = 0;
+ gso->u.gso.features = 0;
+
+ gso->type = XEN_NETIF_EXTRA_TYPE_GSO;
+ gso->flags = 0;
+ }
+
+ xenvif_add_frag_responses(queue, status,
+ queue->meta + npo->meta_cons + 1,
+ XENVIF_RX_CB(skb)->meta_slots_used);
+
+ RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&queue->rx, ret);
+
+ npo->meta_cons += XENVIF_RX_CB(skb)->meta_slots_used;
+ dev_kfree_skb(skb);
+
+ return !!ret;
+}
+
+static void xenvif_rx_action(struct xenvif_queue *queue)
+{
+ int ret;
+ struct sk_buff *skb;
+ struct sk_buff_head rxq;
bool need_to_notify = false;
struct netrx_pending_operations npo = {
@@ -810,21 +899,14 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
while (xenvif_rx_ring_slots_available(queue, XEN_NETBK_RX_SLOTS_MAX)
&& (skb = xenvif_rx_dequeue(queue)) != NULL) {
- RING_IDX old_req_cons;
- RING_IDX ring_slots_used;
-
- queue->last_rx_time = jiffies;
-
- old_req_cons = queue->rx.req_cons;
- XENVIF_RX_CB(skb)->meta_slots_used = xenvif_gop_skb(skb, &npo, queue);
- ring_slots_used = queue->rx.req_cons - old_req_cons;
+ xenvif_rx_build_gops(queue, &npo, skb);
__skb_queue_tail(&rxq, skb);
}
BUG_ON(npo.meta_prod > XEN_NETIF_RX_RING_SIZE);
if (!npo.copy_done && !npo.copy_prod)
- goto done;
+ return;
BUG_ON(npo.copy_prod > MAX_GRANT_COPY_OPS);
if (npo.copy_prod)
@@ -839,79 +921,9 @@ static void xenvif_rx_action(struct xenvif_queue *queue)
BUG_ON(ret);
}
- while ((skb = __skb_dequeue(&rxq)) != NULL) {
-
- if ((1 << queue->meta[npo.meta_cons].gso_type) &
- queue->vif->gso_prefix_mask) {
- resp = RING_GET_RESPONSE(&queue->rx,
- queue->rx.rsp_prod_pvt++);
-
- resp->flags = XEN_NETRXF_gso_prefix | XEN_NETRXF_more_data;
-
- resp->offset = queue->meta[npo.meta_cons].gso_size;
- resp->id = queue->meta[npo.meta_cons].id;
- resp->status = XENVIF_RX_CB(skb)->meta_slots_used;
-
- npo.meta_cons++;
- XENVIF_RX_CB(skb)->meta_slots_used--;
- }
-
-
- queue->stats.tx_bytes += skb->len;
- queue->stats.tx_packets++;
-
- status = xenvif_check_gop(queue,
- XENVIF_RX_CB(skb)->meta_slots_used,
- &npo);
-
- if (XENVIF_RX_CB(skb)->meta_slots_used == 1)
- flags = 0;
- else
- flags = XEN_NETRXF_more_data;
-
- if (skb->ip_summed == CHECKSUM_PARTIAL) /* local packet? */
- flags |= XEN_NETRXF_csum_blank | XEN_NETRXF_data_validated;
- else if (skb->ip_summed == CHECKSUM_UNNECESSARY)
- /* remote but checksummed. */
- flags |= XEN_NETRXF_data_validated;
-
- offset = 0;
- resp = make_rx_response(queue, queue->meta[npo.meta_cons].id,
- status, offset,
- queue->meta[npo.meta_cons].size,
- flags);
-
- if ((1 << queue->meta[npo.meta_cons].gso_type) &
- queue->vif->gso_mask) {
- struct xen_netif_extra_info *gso =
- (struct xen_netif_extra_info *)
- RING_GET_RESPONSE(&queue->rx,
- queue->rx.rsp_prod_pvt++);
-
- resp->flags |= XEN_NETRXF_extra_info;
-
- gso->u.gso.type = queue->meta[npo.meta_cons].gso_type;
- gso->u.gso.size = queue->meta[npo.meta_cons].gso_size;
- gso->u.gso.pad = 0;
- gso->u.gso.features = 0;
-
- gso->type = XEN_NETIF_EXTRA_TYPE_GSO;
- gso->flags = 0;
- }
-
- xenvif_add_frag_responses(queue, status,
- queue->meta + npo.meta_cons + 1,
- XENVIF_RX_CB(skb)->meta_slots_used);
-
- RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&queue->rx, ret);
-
- need_to_notify |= !!ret;
-
- npo.meta_cons += XENVIF_RX_CB(skb)->meta_slots_used;
- dev_kfree_skb(skb);
- }
+ while ((skb = __skb_dequeue(&rxq)) != NULL)
+ need_to_notify |= xenvif_rx_submit(queue, &npo, skb);
-done:
if (need_to_notify)
notify_remote_via_irq(queue->rx_irq);
}
--
2.1.3
next prev parent reply other threads:[~2015-05-12 17:21 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-12 17:18 [RFC PATCH 00/13] Persistent grant maps for xen net drivers Joao Martins
2015-05-12 17:18 ` [RFC PATCH 01/13] xen-netback: add persistent grant tree ops Joao Martins
2015-05-12 17:18 ` [RFC PATCH 02/13] xen-netback: xenbus feature persistent support Joao Martins
2015-05-19 15:19 ` Wei Liu
[not found] ` <20150519151929.GA26335@zion.uk.xensource.com>
2015-05-22 10:24 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 03/13] xen-netback: implement TX persistent grants Joao Martins
2015-05-19 15:23 ` Wei Liu
[not found] ` <20150519152342.GB26335@zion.uk.xensource.com>
2015-05-22 10:24 ` Joao Martins
[not found] ` <30CF0FF9-3B1D-48AF-AFB4-73E20C404357@neclab.eu>
2015-06-02 14:53 ` Wei Liu
[not found] ` <20150602145359.GP19403@zion.uk.xensource.com>
2015-06-03 17:07 ` Joao Martins
[not found] ` <B1B43019-3C94-4FBA-9139-7683FEC2901E@neclab.eu>
2015-06-07 12:04 ` Wei Liu
2015-05-12 17:18 ` [RFC PATCH 04/13] xen-netback: implement RX " Joao Martins
2015-05-19 15:32 ` Wei Liu
[not found] ` <20150519153205.GC26335@zion.uk.xensource.com>
2015-05-22 10:25 ` Joao Martins
[not found] ` <65A385A5-4D11-4032-BB1B-82180AF76477@neclab.eu>
2015-06-02 15:07 ` Wei Liu
[not found] ` <20150602150704.GQ19403@zion.uk.xensource.com>
2015-06-03 17:08 ` Joao Martins
2015-05-12 17:18 ` Joao Martins [this message]
2015-05-19 15:32 ` [RFC PATCH 05/13] xen-netback: refactor xenvif_rx_action Wei Liu
2015-05-12 17:18 ` [RFC PATCH 06/13] xen-netback: copy buffer on xenvif_start_xmit() Joao Martins
2015-05-19 15:35 ` Wei Liu
[not found] ` <20150519153558.GE26335@zion.uk.xensource.com>
2015-05-22 10:26 ` Joao Martins
[not found] ` <915BCC85-25D1-4960-A1BA-0C6459ABC953@neclab.eu>
2015-06-02 15:10 ` Wei Liu
2015-05-12 17:18 ` [RFC PATCH 07/13] xen-netback: add persistent tree counters to debugfs Joao Martins
2015-05-19 15:36 ` Wei Liu
2015-05-12 17:18 ` [RFC PATCH 08/13] xen-netback: clone skb if skb->xmit_more is set Joao Martins
2015-05-19 15:36 ` Wei Liu
[not found] ` <20150519153613.GG26335@zion.uk.xensource.com>
2015-05-22 17:14 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 09/13] xen-netfront: move grant_{ref, page} to struct grant Joao Martins
2015-05-18 15:44 ` David Vrabel
[not found] ` <555A08F4.1030202@citrix.com>
2015-05-19 10:19 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 10/13] xen-netfront: refactor claim/release grant Joao Martins
2015-05-18 15:48 ` David Vrabel
[not found] ` <555A09D1.50902@citrix.com>
2015-05-19 10:19 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 11/13] xen-netfront: feature-persistent xenbus support Joao Martins
2015-05-18 15:51 ` David Vrabel
[not found] ` <555A0A95.20409@citrix.com>
2015-05-19 10:19 ` Joao Martins
2015-05-12 17:18 ` [RFC PATCH 12/13] xen-netfront: implement TX persistent grants Joao Martins
2015-05-18 15:55 ` David Vrabel
[not found] ` <555A0B5D.3090505@citrix.com>
2015-05-19 10:20 ` Joao Martins
[not found] ` <77896F5F-DC2C-4F2A-9BB3-CE5F404DCECC@neclab.eu>
2015-05-19 10:23 ` David Vrabel
2015-05-12 17:18 ` [RFC PATCH 13/13] xen-netfront: implement RX " Joao Martins
2015-05-18 16:04 ` David Vrabel
[not found] ` <555A0D8C.4020309@citrix.com>
2015-05-19 10:22 ` Joao Martins
2015-05-13 10:50 ` [RFC PATCH 00/13] Persistent grant maps for xen net drivers David Vrabel
[not found] ` <55532C86.8020409@citrix.com>
2015-05-13 13:01 ` Joao Martins
2015-05-19 15:39 ` Wei Liu
[not found] ` <20150519153901.GH26335@zion.uk.xensource.com>
2015-05-22 10:27 ` Joao Martins
[not found] ` <191EF54A-D8DE-4BAA-B15D-41B2BA35353F@neclab.eu>
2015-05-29 6:53 ` Yuzhou (C)
[not found] ` <47498F109986134D9A5B42B82F405EBBA3244CB6@SZXEMA502-MBX.china.huawei.com>
2015-05-29 14:51 ` Joao Martins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1431451117-70051-6-git-send-email-joao.martins@neclab.eu \
--to=joao.martins@neclab.eu \
--cc=boris.ostrovsky@oracle.com \
--cc=david.vrabel@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=netdev@vger.kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).