Skip to contentSkip to conversation

netback patches from XCP patch queue

PATCH New Ian Campbell 1 participant 5 messages Jun 11, 2010 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

cover netback patches from XCP patch queue

The following pull includes a patch from XCP to linearise fragmented packets into the receiver's buffer as well as a couple of fixes picked up from linux-2.6.18-xen.hg and the SLES11 kernel plus a small cleanup.

There were lots of merge conflicts with xen/dom0/backends/netback-tasklet so I didn't want to base on plain xen/dom0/backends/netback. Therefore I merged netback-tasklet into the netback and based my patches on that, so this pull appears to include those changes as well.

The result merges cleanly onto c2cb3df04eb3ff68d0de102b2acacc9b8616e659 which is the commit just before netback-tasklet was reverted out of xen/stable-2.6.32.x. It looks like a fix is available and I think this branch can be merged following the reintroduction of the netback-tasklet branch into the stable branch.

I will follow up with the 4 new patches, omitting the ones from the netback-tasklet branch and the merge itself.

The following changes since commit 224c3a282f9b0916eb2fc1f0278e6638cffada2c:
James Harper (1):
xen/netback: avoid null-pointer access in netback_uevent

are available in the git repository at:

git://xenbits.xensource.com/people/ianc/linux-2.6.git for-jeremy/netback

Dongxiao Xu (4):
xen/netback: Move global/static variables into struct xen_netbk. xen/netback: Introduce a new struct type page_ext. xen/netback: Multiple tasklets support.
xen/netback: Use Kernel thread to replace the tasklet.

Ian Campbell (4):
Merge branch 'xen/dom0/backend/netback-tasklet' of git://git.kernel.org/.../jeremy/xen into netback
xen: netback: handle NET_SKBUFF_DATA_USES_OFFSET correctly
xen: netback: drop frag member from struct netbk_rx_meta
xen/netback: linearise SKBs as we copy them into guest memory on guest-RX.

Keir Fraser (1):
xen: netback: Fixes for delayed copy of tx network packets.

 drivers/xen/netback/common.h    |  101 ++++-
 drivers/xen/netback/interface.c |   27 ++
 drivers/xen/netback/netback.c   |  942 +++++++++++++++++++++++++--------------
 3 files changed, 728 insertions(+), 342 deletions(-)

Ian.

#1 lore raw

PATCH 1/4 xen: netback: Fixes for delayed copy of tx network packets.

From: Keir Fraser <[email protected]>

- Should call net_tx_action_dealloc() even when dealloc ring is empty, as there may in any case be work to do on the pending_inuse list.
- Should not exit directly from the middle of the tx_action tasklet, as the tx_pending_timer should always be checked and updated at the end of the tasklet.

[picked from linux-2.6.18-xen.hg 959:1a97bd686258, ported across a43e2175 "xen/netback: move code around"]
---
 drivers/xen/netback/netback.c |   25 ++++++++++++-------------
 1 files changed, 12 insertions(+), 13 deletions(-)
drivers/xen/netback/netback.c +12 -13
index b23fab0..9e4793f 100644
@@ -1384,16 +1384,6 @@ static void net_tx_submit(struct xen_netbk *netbk)
 		netif_rx_ni(skb);
 		netif->dev->last_rx = jiffies;
 	}
-
-	if (netbk_copy_skb_mode == NETBK_DELAYED_COPY_SKB &&
-	    !list_empty(&netbk->pending_inuse_head)) {
-		struct netbk_tx_pending_inuse *oldest;
-
-		oldest = list_entry(netbk->pending_inuse_head.next,
-				    struct netbk_tx_pending_inuse, list);
-		mod_timer(&netbk->netbk_tx_pending_timer,
-				oldest->alloc_time + HZ);
-	}
 }
 
 /* Called after netfront has transmitted */
@@ -1403,19 +1393,28 @@ static void net_tx_action(unsigned long data)
 	unsigned nr_mops;
 	int ret;
 
-	if (netbk->dealloc_cons != netbk->dealloc_prod)
-		net_tx_action_dealloc(netbk);
+	net_tx_action_dealloc(netbk);
 
 	nr_mops = net_tx_build_mops(netbk);
 
 	if (nr_mops == 0)
-		return;
+		goto out;
 
 	ret = HYPERVISOR_grant_table_op(GNTTABOP_map_grant_ref,
 					netbk->tx_map_ops, nr_mops);
 	BUG_ON(ret);
 
 	net_tx_submit(netbk);
+out:
+	if (netbk_copy_skb_mode == NETBK_DELAYED_COPY_SKB &&
+	    !list_empty(&netbk->pending_inuse_head)) {
+		struct netbk_tx_pending_inuse *oldest;
+
+		oldest = list_entry(netbk->pending_inuse_head.next,
+				    struct netbk_tx_pending_inuse, list);
+		mod_timer(&netbk->netbk_tx_pending_timer,
+				oldest->alloc_time + HZ);
+	}
 }
 
 static void netif_idx_release(struct xen_netbk *netbk, u16 pending_idx)
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 2/4 xen: netback: handle NET_SKBUFF_DATA_USES_OFFSET correctly

In reply to Ian Campbell
---
 drivers/xen/netback/netback.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/xen/netback/netback.c +4 -0
index 9e4793f..8cd7875 100644
@@ -218,7 +218,11 @@ static struct sk_buff *netbk_copy_skb(struct sk_buff *skb)
 		len -= copy;
 	}
 
+#ifdef NET_SKBUFF_DATA_USES_OFFSET
+	offset = 0;
+#else
 	offset = nskb->data - skb->data;
+#endif
 
 	nskb->transport_header = skb->transport_header + offset;
 	nskb->network_header = skb->network_header + offset;
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/4 xen: netback: drop frag member from struct netbk_rx_meta

In reply to Ian Campbell

It has been unused since c3219dc "xen/netback: completely drop flip support", as has netbk_free_pages().

(Although it now has only a single member struct netbk_rx_meta will gain other members in a subsequent patch so there is no point reworking to get rid of the struct)

---
 drivers/xen/netback/common.h  |    1 -
 drivers/xen/netback/netback.c |    8 --------
 2 files changed, 0 insertions(+), 9 deletions(-)
drivers/xen/netback/common.h +0 -1
index 81050a6..84b527d 100644
@@ -232,7 +232,6 @@ struct pending_tx_info {
 typedef unsigned int pending_ring_idx_t;
 
 struct netbk_rx_meta {
-	skb_frag_t frag;
 	int id;
 };
 
drivers/xen/netback/netback.c +0 -8
index 8cd7875..6de29d2 100644
@@ -411,14 +411,6 @@ static void netbk_gop_skb(struct sk_buff *skb,
 	netif->rx.req_cons += nr_frags + extra;
 }
 
-static inline void netbk_free_pages(int nr_frags, struct netbk_rx_meta *meta)
-{
-	int i;
-
-	for (i = 0; i < nr_frags; i++)
-		put_page(meta[i].frag.page);
-}
-
 /* This is a twin to netbk_gop_skb.  Assume that netbk_gop_skb was
    used to set up the operations on the top of
    netrx_pending_operations, which have since been done.  Check that
Signature · 1 line
1.5.6.5
#4 lore raw

PATCH 4/4 xen/netback: linearise SKBs as we copy them into guest memory on guest-RX.

In reply to Ian Campbell

There's no point in sending lots of little packets to a copying receiver if we can instead arrange to copy them all into a single RX buffer. We need to copy anyway, so there's no overhead here, and this is a little bit easier on the receiving domain's network stack.

Based on a patch by Steven Smith. Fixed to not skip unnecessarily to the next buffer which could leave the head fragment of a received frame empty if the headlen of an SKB was large (which would crash netfront). Instead we only try and pack "small enough" fragments together but do not try to coalesce large or whole page fragments.

In previous iterations of this patch we also tried to only include 2048 bytes per frag because very old netfronts stored other information in the second half of the page. It has been determined that only frontends which support scatter-gather are going to come down this path and that any guest which supports scatter-gather is also new enough to allow us to use the full page size for each fragment (since this limitation which fixed as part of the SG implementation) so we do not need this restriction.

---
 drivers/xen/netback/common.h  |   15 ++-
 drivers/xen/netback/netback.c |  280 ++++++++++++++++++++++++++++++-----------
 2 files changed, 217 insertions(+), 78 deletions(-)
drivers/xen/netback/common.h +13 -2
index 84b527d..0dc1959 100644
@@ -84,7 +84,9 @@ struct xen_netif {
 	/* Internal feature information. */
 	u8 can_queue:1;	/* can queue packets for receiver? */
 
-	/* Allow netif_be_start_xmit() to peek ahead in the rx request ring. */
+	/* Allow netif_be_start_xmit() to peek ahead in the rx request
+	 * ring.  This is a prediction of what rx_req_cons will be once
+	 * all queued skbs are put on the ring. */
 	RING_IDX rx_req_cons_peek;
 
 	/* Transmit shaping: allow 'credit_bytes' every 'credit_usec'. */
@@ -233,6 +235,8 @@ typedef unsigned int pending_ring_idx_t;
 
 struct netbk_rx_meta {
 	int id;
+	int size;
+	int gso_size;
 };
 
 struct netbk_tx_pending_inuse {
@@ -242,6 +246,8 @@ struct netbk_tx_pending_inuse {
 
 #define MAX_PENDING_REQS 256
 
+#define MAX_BUFFER_OFFSET PAGE_SIZE
+
 /* extra field used in struct page */
 union page_ext {
 	struct {
@@ -303,7 +309,12 @@ struct xen_netbk {
 	struct multicall_entry rx_mcl[NET_RX_RING_SIZE+3];
 	struct mmu_update rx_mmu[NET_RX_RING_SIZE];
 	struct gnttab_transfer grant_trans_op[NET_RX_RING_SIZE];
-	struct gnttab_copy grant_copy_op[NET_RX_RING_SIZE];
+	/*
+	 * Each head or fragment can be up to 4096 bytes. Given
+	 * MAX_BUFFER_OFFSET of 4096 the worst case is that each
+	 * head/fragment uses 2 copy operation.
+	 */
+	struct gnttab_copy grant_copy_op[2*NET_RX_RING_SIZE];
 	unsigned char rx_notify[NR_IRQS];
 	u16 notify_list[NET_RX_RING_SIZE];
 	struct netbk_rx_meta meta[NET_RX_RING_SIZE];
drivers/xen/netback/netback.c +204 -76

409 lines not on this page · raw message

Signature · 1 line
1.5.6.5