ia64/xen-unstable

changeset 10310:e3af1912794b

[NET] back: Add a few comments to the goriest parts of the scatter-gather patch.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Jun 05 17:03:19 2006 +0100 (2006-06-05)
parents aecdb4c52fa7
children 5e3827f7a93a
files linux-2.6-xen-sparse/drivers/xen/netback/netback.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Jun 05 16:33:49 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Mon Jun 05 17:03:19 2006 +0100
     1.3 @@ -543,17 +543,14 @@ static gnttab_map_grant_ref_t *netbk_get
     1.4  	skb_frag_t *frags = shinfo->frags;
     1.5  	netif_tx_request_t *txp;
     1.6  	unsigned long pending_idx = *((u16 *)skb->data);
     1.7 -	int nr_frags = shinfo->nr_frags;
     1.8  	RING_IDX cons = netif->tx.req_cons + 1;
     1.9 -	int i;
    1.10 +	int i, start;
    1.11  
    1.12 -	if ((unsigned long)shinfo->frags[0].page == pending_idx) {
    1.13 -		frags++;
    1.14 -		nr_frags--;
    1.15 -	}
    1.16 +	/* Skip first skb fragment if it is on same page as header fragment. */
    1.17 +	start = ((unsigned long)shinfo->frags[0].page == pending_idx);
    1.18  
    1.19 -	for (i = 0; i < nr_frags; i++) {
    1.20 -		txp = RING_GET_REQUEST(&netif->tx, cons + i);
    1.21 +	for (i = start; i < shinfo->nr_frags; i++) {
    1.22 +		txp = RING_GET_REQUEST(&netif->tx, cons++);
    1.23  		pending_idx = pending_ring[MASK_PEND_IDX(pending_cons++)];
    1.24  
    1.25  		gnttab_set_map_op(mop++, MMAP_VADDR(pending_idx),
    1.26 @@ -578,10 +575,9 @@ static int netbk_tx_check_mop(struct sk_
    1.27  	netif_tx_request_t *txp;
    1.28  	struct skb_shared_info *shinfo = skb_shinfo(skb);
    1.29  	int nr_frags = shinfo->nr_frags;
    1.30 -	int start;
    1.31 -	int err;
    1.32 -	int i;
    1.33 +	int i, err, start;
    1.34  
    1.35 +	/* Check status of header. */
    1.36  	err = mop->status;
    1.37  	if (unlikely(err)) {
    1.38  		txp = &pending_tx_info[pending_idx].req;
    1.39 @@ -595,44 +591,47 @@ static int netbk_tx_check_mop(struct sk_
    1.40  		grant_tx_handle[pending_idx] = mop->handle;
    1.41  	}
    1.42  
    1.43 -	start = 0;
    1.44 -	if ((unsigned long)shinfo->frags[0].page == pending_idx)
    1.45 -		start++;
    1.46 +	/* Skip first skb fragment if it is on same page as header fragment. */
    1.47 +	start = ((unsigned long)shinfo->frags[0].page == pending_idx);
    1.48  
    1.49  	for (i = start; i < nr_frags; i++) {
    1.50 -		int newerr;
    1.51 -		int j;
    1.52 +		int j, newerr;
    1.53  
    1.54  		pending_idx = (unsigned long)shinfo->frags[i].page;
    1.55  
    1.56 +		/* Check error status: if okay then remember grant handle. */
    1.57  		newerr = (++mop)->status;
    1.58  		if (likely(!newerr)) {
    1.59  			set_phys_to_machine(
    1.60 -				__pa(MMAP_VADDR(pending_idx)) >> PAGE_SHIFT,
    1.61 -				FOREIGN_FRAME(mop->dev_bus_addr >> PAGE_SHIFT));
    1.62 +				__pa(MMAP_VADDR(pending_idx))>>PAGE_SHIFT,
    1.63 +				FOREIGN_FRAME(mop->dev_bus_addr>>PAGE_SHIFT));
    1.64  			grant_tx_handle[pending_idx] = mop->handle;
    1.65 -
    1.66 +			/* Had a previous error? Invalidate this fragment. */
    1.67  			if (unlikely(err))
    1.68  				netif_idx_release(pending_idx);
    1.69  			continue;
    1.70  		}
    1.71  
    1.72 +		/* Error on this fragment: respond to client with an error. */
    1.73  		txp = &pending_tx_info[pending_idx].req;
    1.74  		make_tx_response(netif, txp->id, NETIF_RSP_ERROR);
    1.75  		pending_ring[MASK_PEND_IDX(pending_prod++)] = pending_idx;
    1.76  		netif_put(netif);
    1.77  
    1.78 +		/* Not the first error? Preceding frags already invalidated. */
    1.79  		if (err)
    1.80  			continue;
    1.81  
    1.82 +		/* First error: invalidate header and preceding fragments. */
    1.83  		pending_idx = *((u16 *)skb->data);
    1.84  		netif_idx_release(pending_idx);
    1.85 -
    1.86  		for (j = start; j < i; j++) {
    1.87  			pending_idx = (unsigned long)shinfo->frags[i].page;
    1.88  			netif_idx_release(pending_idx);
    1.89  		}
    1.90 -		err |= newerr;
    1.91 +
    1.92 +		/* Remember the error: invalidate all subsequent fragments. */
    1.93 +		err = newerr;
    1.94  	}
    1.95  
    1.96  	*mopp = mop + 1;