ia64/xen-unstable

changeset 11714:0d796dced5f7

[NET] front: Allow copying receive path to be selected by user at
module load time.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Mon Oct 02 16:12:41 2006 +0100 (2006-10-02)
parents 96a77ef725b8
children f426f6e646eb
files linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c xen/common/grant_table.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Oct 02 13:45:44 2006 +0100
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c	Mon Oct 02 16:12:41 2006 +0100
     1.3 @@ -63,6 +63,25 @@
     1.4  #include <xen/interface/grant_table.h>
     1.5  #include <xen/gnttab.h>
     1.6  
     1.7 +/*
     1.8 + * Mutually-exclusive module options to select receive data path:
     1.9 + *  rx_copy : Packets are copied by network backend into local memory
    1.10 + *  rx_flip : Page containing packet data is transferred to our ownership
    1.11 + * For fully-virtualised guests there is no option - copying must be used.
    1.12 + * For paravirtualised guests, flipping is the default.
    1.13 + */
    1.14 +#ifdef CONFIG_XEN
    1.15 +static int MODPARM_rx_copy = 0;
    1.16 +module_param_named(rx_copy, MODPARM_rx_copy, bool, 0);
    1.17 +MODULE_PARM_DESC(rx_copy, "Copy packets from network card (rather than flip)");
    1.18 +static int MODPARM_rx_flip = 0;
    1.19 +module_param_named(rx_flip, MODPARM_rx_flip, bool, 0);
    1.20 +MODULE_PARM_DESC(rx_flip, "Flip packets from network card (rather than copy)");
    1.21 +#else
    1.22 +static const int MODPARM_rx_copy = 1;
    1.23 +static const int MODPARM_rx_flip = 0;
    1.24 +#endif
    1.25 +
    1.26  #define RX_COPY_THRESHOLD 256
    1.27  
    1.28  /* If we don't have GSO, fake things up so that we never try to use it. */
    1.29 @@ -229,8 +248,7 @@ static int __devinit netfront_probe(stru
    1.30  	int err;
    1.31  	struct net_device *netdev;
    1.32  	struct netfront_info *info;
    1.33 -	unsigned int handle;
    1.34 -	unsigned feature_rx_copy;
    1.35 +	unsigned int handle, feature_rx_copy, feature_rx_flip, use_copy;
    1.36  
    1.37  	err = xenbus_scanf(XBT_NIL, dev->nodename, "handle", "%u", &handle);
    1.38  	if (err != 1) {
    1.39 @@ -238,22 +256,24 @@ static int __devinit netfront_probe(stru
    1.40  		return err;
    1.41  	}
    1.42  
    1.43 -#ifndef CONFIG_XEN
    1.44  	err = xenbus_scanf(XBT_NIL, dev->otherend, "feature-rx-copy", "%u",
    1.45  			   &feature_rx_copy);
    1.46 -	if (err != 1) {
    1.47 -		xenbus_dev_fatal(dev, err, "reading feature-rx-copy");
    1.48 -		return err;
    1.49 -	}
    1.50 -	if (!feature_rx_copy) {
    1.51 -		xenbus_dev_fatal(dev, 0, "need a copy-capable backend");
    1.52 -		return -EINVAL;
    1.53 -	}
    1.54 -#else
    1.55 -	feature_rx_copy = 0;
    1.56 -#endif
    1.57 +	if (err != 1)
    1.58 +		feature_rx_copy = 0;
    1.59 +	err = xenbus_scanf(XBT_NIL, dev->otherend, "feature-rx-flip", "%u",
    1.60 +			   &feature_rx_flip);
    1.61 +	if (err != 1)
    1.62 +		feature_rx_flip = 1;
    1.63  
    1.64 -	netdev = create_netdev(handle, feature_rx_copy, dev);
    1.65 +	/*
    1.66 +	 * Copy packets on receive path if:
    1.67 +	 *  (a) This was requested by user, and the backend supports it; or
    1.68 +	 *  (b) Flipping was requested, but this is unsupported by the backend.
    1.69 +	 */
    1.70 +	use_copy = (MODPARM_rx_copy && feature_rx_copy) ||
    1.71 +		(MODPARM_rx_flip && !feature_rx_flip);
    1.72 +
    1.73 +	netdev = create_netdev(handle, use_copy, dev);
    1.74  	if (IS_ERR(netdev)) {
    1.75  		err = PTR_ERR(netdev);
    1.76  		xenbus_dev_fatal(dev, err, "creating netdev");
    1.77 @@ -271,6 +291,9 @@ static int __devinit netfront_probe(stru
    1.78  	if (err)
    1.79  		goto fail_open;
    1.80  
    1.81 +	IPRINTK("Created netdev %s with %sing receive path.\n",
    1.82 +		netdev->name, info->copying_receiver ? "copy" : "flipp");
    1.83 +
    1.84  	return 0;
    1.85  
    1.86   fail_open:
    1.87 @@ -742,7 +765,7 @@ no_skb:
    1.88  		} else {
    1.89  			gnttab_grant_foreign_access_ref(ref,
    1.90  							np->xbdev->otherend_id,
    1.91 -							pfn,
    1.92 +							pfn_to_mfn(pfn),
    1.93  							0);
    1.94  		}
    1.95  
    1.96 @@ -1632,7 +1655,8 @@ static void network_connect(struct net_d
    1.97  		} else {
    1.98  			gnttab_grant_foreign_access_ref(
    1.99  				ref, np->xbdev->otherend_id,
   1.100 -				page_to_pfn(skb_shinfo(skb)->frags->page),
   1.101 +				pfn_to_mfn(page_to_pfn(skb_shinfo(skb)->
   1.102 +						       frags->page)),
   1.103  				0);
   1.104  		}
   1.105  		req->gref = ref;
   1.106 @@ -2053,6 +2077,16 @@ static int __init netif_init(void)
   1.107  	if (!is_running_on_xen())
   1.108  		return -ENODEV;
   1.109  
   1.110 +#ifdef CONFIG_XEN
   1.111 +	if (MODPARM_rx_flip && MODPARM_rx_copy) {
   1.112 +		WPRINTK("Cannot specify both rx_copy and rx_flip.\n");
   1.113 +		return -EINVAL;
   1.114 +	}
   1.115 +
   1.116 +	if (!MODPARM_rx_flip && !MODPARM_rx_copy)
   1.117 +		MODPARM_rx_flip = 1; /* Default is to flip. */
   1.118 +#endif
   1.119 +
   1.120  	if (is_initial_xendomain())
   1.121  		return 0;
   1.122  
     2.1 --- a/xen/common/grant_table.c	Mon Oct 02 13:45:44 2006 +0100
     2.2 +++ b/xen/common/grant_table.c	Mon Oct 02 16:12:41 2006 +0100
     2.3 @@ -903,7 +903,7 @@ static void
     2.4      }
     2.5      if ( !get_page_and_type(mfn_to_page(d_frame), dd, PGT_writable_page) )
     2.6          PIN_FAIL(error_out, GNTST_general_error,
     2.7 -                 "could not get source frame %lx.\n", d_frame);
     2.8 +                 "could not get destination frame %lx.\n", d_frame);
     2.9  
    2.10      sp = map_domain_page(s_frame);
    2.11      dp = map_domain_page(d_frame);