ia64/xen-unstable

changeset 11220:a629952ac766

[NET] front: Fix receive path for auto-translated guests, so that
driver balloon allowance is properly accounted.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@localhost.localdomain
date Sat Aug 19 11:39:04 2006 +0100 (2006-08-19)
parents 03fd2accb4d9
children 7c9d7fc3dce5
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	Sat Aug 19 11:13:17 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Sat Aug 19 11:39:04 2006 +0100
     1.3 @@ -1018,8 +1018,10 @@ int xennet_get_extras(struct netfront_in
     1.4  				WPRINTK("Invalid extra type: %d\n",
     1.5  					extra->type);
     1.6  			err = -EINVAL;
     1.7 -		} else
     1.8 -			memcpy(&extras[extra->type - 1], extra, sizeof(*extra));
     1.9 +		} else {
    1.10 +			memcpy(&extras[extra->type - 1], extra,
    1.11 +			       sizeof(*extra));
    1.12 +		}
    1.13  
    1.14  		skb = xennet_get_rx_skb(np, cons);
    1.15  		ref = xennet_get_rx_ref(np, cons);
    1.16 @@ -1032,9 +1034,10 @@ int xennet_get_extras(struct netfront_in
    1.17  
    1.18  static int xennet_get_responses(struct netfront_info *np,
    1.19  				struct netfront_rx_info *rinfo, RING_IDX rp,
    1.20 -				struct sk_buff_head *list, int *mcl_offset_p)
    1.21 +				struct sk_buff_head *list,
    1.22 +				int *pages_flipped_p)
    1.23  {
    1.24 -	int mcl_offset = *mcl_offset_p;
    1.25 +	int pages_flipped = *pages_flipped_p;
    1.26  	struct mmu_update *mmu;
    1.27  	struct multicall_entry *mcl;
    1.28  	struct netif_rx_response *rx = &rinfo->rx;
    1.29 @@ -1080,7 +1083,8 @@ static int xennet_get_responses(struct n
    1.30  			 * headroom, ... */
    1.31  			if (!(mfn = gnttab_end_foreign_transfer_ref(ref))) {
    1.32  				if (net_ratelimit())
    1.33 -					WPRINTK("Unfulfilled rx req (id=%d, st=%d).\n",
    1.34 +					WPRINTK("Unfulfilled rx req "
    1.35 +						"(id=%d, st=%d).\n",
    1.36  						rx->id, rx->status);
    1.37  				xennet_move_rx_slot(np, skb, ref);
    1.38  				err = -ENOMEM;
    1.39 @@ -1094,8 +1098,8 @@ static int xennet_get_responses(struct n
    1.40  				unsigned long pfn = page_to_pfn(page);
    1.41  				void *vaddr = page_address(page);
    1.42  
    1.43 -				mcl = np->rx_mcl + mcl_offset;
    1.44 -				mmu = np->rx_mmu + mcl_offset;
    1.45 +				mcl = np->rx_mcl + pages_flipped;
    1.46 +				mmu = np->rx_mmu + pages_flipped;
    1.47  
    1.48  				MULTI_update_va_mapping(mcl,
    1.49  							(unsigned long)vaddr,
    1.50 @@ -1106,10 +1110,9 @@ static int xennet_get_responses(struct n
    1.51  					| MMU_MACHPHYS_UPDATE;
    1.52  				mmu->val = pfn;
    1.53  
    1.54 -				mcl_offset++;
    1.55 -
    1.56  				set_phys_to_machine(pfn, mfn);
    1.57  			}
    1.58 +			pages_flipped++;
    1.59  		} else {
    1.60  			ret = gnttab_end_foreign_access_ref(ref, 0);
    1.61  			BUG_ON(!ret);
    1.62 @@ -1142,7 +1145,7 @@ next:
    1.63  		err = -E2BIG;
    1.64  	}
    1.65  
    1.66 -	*mcl_offset_p = mcl_offset;
    1.67 +	*pages_flipped_p = pages_flipped;
    1.68  
    1.69  	return err;
    1.70  }
    1.71 @@ -1225,7 +1228,7 @@ static int netif_poll(struct net_device 
    1.72  	struct sk_buff_head tmpq;
    1.73  	unsigned long flags;
    1.74  	unsigned int len;
    1.75 -	int pages_done;
    1.76 +	int pages_flipped = 0;
    1.77  	int err;
    1.78  
    1.79  	spin_lock(&np->rx_lock);
    1.80 @@ -1244,13 +1247,14 @@ static int netif_poll(struct net_device 
    1.81  	rp = np->rx.sring->rsp_prod;
    1.82  	rmb(); /* Ensure we see queued responses up to 'rp'. */
    1.83  
    1.84 -	for (i = np->rx.rsp_cons, work_done = 0, pages_done = 0;
    1.85 +	for (i = np->rx.rsp_cons, work_done = 0;
    1.86  	     (i != rp) && (work_done < budget);
    1.87  	     np->rx.rsp_cons = ++i, work_done++) {
    1.88  		memcpy(rx, RING_GET_RESPONSE(&np->rx, i), sizeof(*rx));
    1.89  		memset(extras, 0, sizeof(extras));
    1.90  
    1.91 -		err = xennet_get_responses(np, &rinfo, rp, &tmpq, &pages_done);
    1.92 +		err = xennet_get_responses(np, &rinfo, rp, &tmpq,
    1.93 +					   &pages_flipped);
    1.94  
    1.95  		if (unlikely(err)) {
    1.96  err:
    1.97 @@ -1335,18 +1339,21 @@ err:
    1.98  		__skb_queue_tail(&rxq, skb);
    1.99  	}
   1.100  
   1.101 -	/* Some pages are no longer absent... */
   1.102 -	balloon_update_driver_allowance(-pages_done);
   1.103 +	if (pages_flipped) {
   1.104 +		/* Some pages are no longer absent... */
   1.105 +		balloon_update_driver_allowance(-pages_flipped);
   1.106  
   1.107 -	/* Do all the remapping work, and M2P updates, in one big hypercall. */
   1.108 -	if (likely(pages_done)) {
   1.109 -		mcl = np->rx_mcl + pages_done;
   1.110 -		mcl->op = __HYPERVISOR_mmu_update;
   1.111 -		mcl->args[0] = (unsigned long)np->rx_mmu;
   1.112 -		mcl->args[1] = pages_done;
   1.113 -		mcl->args[2] = 0;
   1.114 -		mcl->args[3] = DOMID_SELF;
   1.115 -		(void)HYPERVISOR_multicall(np->rx_mcl, pages_done + 1);
   1.116 +		/* Do all the remapping work and M2P updates. */
   1.117 +		if (!xen_feature(XENFEAT_auto_translated_physmap)) {
   1.118 +			mcl = np->rx_mcl + pages_flipped;
   1.119 +			mcl->op = __HYPERVISOR_mmu_update;
   1.120 +			mcl->args[0] = (unsigned long)np->rx_mmu;
   1.121 +			mcl->args[1] = pages_flipped;
   1.122 +			mcl->args[2] = 0;
   1.123 +			mcl->args[3] = DOMID_SELF;
   1.124 +			(void)HYPERVISOR_multicall(np->rx_mcl,
   1.125 +						   pages_flipped + 1);
   1.126 +		}
   1.127  	}
   1.128  
   1.129  	while ((skb = __skb_dequeue(&errq)))