ia64/xen-unstable

changeset 10857:762ae310d878

[NET] front: Clean up rx ring recovery.
Signed-off-by: Keir Fraser <keir@xensource.com>

This is an update to c/s
10855:03c8002068d9d60c7bbfc2f41af975e09b2e2211
which should have contained the following changeset message
(rather than 'Merge.').

[NET] front: Stop using rx->id

With the current protocol for transferring packets from dom0 to domU,
the
rx->id field is useless because it can be derived from the rx request
ring
ID. In particular,

rx->id = (ring_id & NET_RX_RING_SIZE - 1) + 1;

This formula works because the rx response to each request always
occupies
the same slot that the request arrived in. This in turn is a
consequence
of the fact that each packet only occupies one slot.

The other important reason that this works for dom0=>domU but not
domU=>dom0
is that the resource associated with the rx->id is freed immediately
while
in the domU=>dom0 case the resource is held until the skb is liberated
by
dom0.

Using this formula we can essentially remove rx->id from the protocol,
freeing up space that could be instead be used by things like TSO.
The
only constraint is that the backend must obey the rule that each id
must
only be used in the response that occupies the same slot as the
request.

The actual field of rx->id is still maintained for compatibility with
older backends.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
author kfraser@localhost.localdomain
date Fri Jul 28 17:00:10 2006 +0100 (2006-07-28)
parents 1fb835267a50
children 275660d492c6
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Jul 28 16:54:17 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Fri Jul 28 17:00:10 2006 +0100
     1.3 @@ -1193,19 +1193,16 @@ static void network_connect(struct net_d
     1.4  		if (!np->rx_skbs[i])
     1.5  			continue;
     1.6  
     1.7 -		gnttab_grant_foreign_transfer_ref(
     1.8 -			np->grant_rx_ref[i], np->xbdev->otherend_id,
     1.9 -			__pa(np->rx_skbs[i]->data) >> PAGE_SHIFT);
    1.10 -		RING_GET_REQUEST(&np->rx, requeue_idx)->gref =
    1.11 -			np->grant_rx_ref[i];
    1.12 -		RING_GET_REQUEST(&np->rx, requeue_idx)->id = requeue_idx;
    1.13 +		skb = np->rx_skbs[requeue_idx] = xennet_get_rx_skb(np, i);
    1.14 +		ref = np->grant_rx_ref[requeue_idx] = xennet_get_rx_ref(np, i);
    1.15  
    1.16 -		if (requeue_idx < i) {
    1.17 -			np->rx_skbs[requeue_idx] = np->rx_skbs[i];
    1.18 -			np->grant_rx_ref[requeue_idx] = np->grant_rx_ref[i];
    1.19 -			np->rx_skbs[i] = NULL;
    1.20 -			np->grant_rx_ref[i] = GRANT_INVALID_REF;
    1.21 -		}
    1.22 +		gnttab_grant_foreign_transfer_ref(
    1.23 +			ref, np->xbdev->otherend_id,
    1.24 +			__pa(skb->data) >> PAGE_SHIFT);
    1.25 +
    1.26 +		RING_GET_REQUEST(&np->rx, requeue_idx)->gref = ref;
    1.27 +		RING_GET_REQUEST(&np->rx, requeue_idx)->id   = requeue_idx;
    1.28 +
    1.29  		requeue_idx++;
    1.30  	}
    1.31