ia64/linux-2.6.18-xen.hg

changeset 244:df158d6b9e57

Add version number to API between netback and accel plugin.
Signed-off-by: Kieran Mansley <kmansley@solarflare.com>
author Keir Fraser <keir@xensource.com>
date Wed Oct 03 15:00:42 2007 +0100 (2007-10-03)
parents 9c9881c9037b
children e7a3f045cb60
files drivers/xen/netback/accel.c drivers/xen/netback/common.h
line diff
     1.1 --- a/drivers/xen/netback/accel.c	Wed Oct 03 14:58:45 2007 +0100
     1.2 +++ b/drivers/xen/netback/accel.c	Wed Oct 03 15:00:42 2007 +0100
     1.3 @@ -103,19 +103,36 @@ static int netback_accelerator_tell_back
     1.4   * Entry point for an netback accelerator plugin module.  Called to
     1.5   * advertise its presence, and connect to any suitable backends.
     1.6   */
     1.7 -void netback_connect_accelerator(int id, const char *eth_name, 
     1.8 -				 struct netback_accel_hooks *hooks)
     1.9 +int netback_connect_accelerator(unsigned version, int id, const char *eth_name, 
    1.10 +				struct netback_accel_hooks *hooks)
    1.11  {
    1.12 -	struct netback_accelerator *new_accelerator = 
    1.13 -		kmalloc(sizeof(struct netback_accelerator), GFP_KERNEL);
    1.14 +	struct netback_accelerator *new_accelerator;
    1.15  	unsigned eth_name_len, flags;
    1.16  
    1.17 +	if (version != NETBACK_ACCEL_VERSION) {
    1.18 +		if (version > NETBACK_ACCEL_VERSION) {
    1.19 +			/* Caller has higher version number, leave it
    1.20 +			   up to them to decide whether to continue.
    1.21 +			   They can recall with a lower number if
    1.22 +			   they're happy to be compatible with us */
    1.23 +			return NETBACK_ACCEL_VERSION;
    1.24 +		} else {
    1.25 +			/* We have a more recent version than caller.
    1.26 +			   Currently reject, but may in future be able
    1.27 +			   to be backwardly compatible */
    1.28 +			return -EPROTO;
    1.29 +		}
    1.30 +	}
    1.31 +
    1.32 +	new_accelerator = 
    1.33 +		kmalloc(sizeof(struct netback_accelerator), GFP_KERNEL);
    1.34  	if (!new_accelerator) {
    1.35  		DPRINTK("%s: failed to allocate memory for accelerator\n",
    1.36  			__FUNCTION__);
    1.37 -		return;
    1.38 +		return -ENOMEM;
    1.39  	}
    1.40  
    1.41 +
    1.42  	new_accelerator->id = id;
    1.43  	
    1.44  	eth_name_len = strlen(eth_name)+1;
    1.45 @@ -124,7 +141,7 @@ void netback_connect_accelerator(int id,
    1.46  		DPRINTK("%s: failed to allocate memory for eth_name string\n",
    1.47  			__FUNCTION__);
    1.48  		kfree(new_accelerator);
    1.49 -		return;
    1.50 +		return -ENOMEM;
    1.51  	}
    1.52  	strlcpy(new_accelerator->eth_name, eth_name, eth_name_len);
    1.53  	
    1.54 @@ -140,6 +157,8 @@ void netback_connect_accelerator(int id,
    1.55  	xenbus_for_each_backend(new_accelerator, 
    1.56  				netback_accelerator_tell_backend);
    1.57  
    1.58 +	return 0;
    1.59 +
    1.60  }
    1.61  EXPORT_SYMBOL_GPL(netback_connect_accelerator);
    1.62  
     2.1 --- a/drivers/xen/netback/common.h	Wed Oct 03 14:58:45 2007 +0100
     2.2 +++ b/drivers/xen/netback/common.h	Wed Oct 03 15:00:42 2007 +0100
     2.3 @@ -149,9 +149,16 @@ struct backend_info {
     2.4  	struct netback_accelerator *accelerator;
     2.5  };
     2.6  
     2.7 -/* Connect an accelerator plugin module to netback */
     2.8 -extern void netback_connect_accelerator(int id, const char *eth_name, 
     2.9 -					struct netback_accel_hooks *hooks);
    2.10 +#define NETBACK_ACCEL_VERSION 0x00010000
    2.11 +
    2.12 +/* 
    2.13 + * Connect an accelerator plugin module to netback.  Returns zero on
    2.14 + * success, < 0 on error, > 0 (with highest version number supported)
    2.15 + * if version mismatch.
    2.16 + */
    2.17 +extern int netback_connect_accelerator(unsigned version,
    2.18 +				       int id, const char *eth_name, 
    2.19 +				       struct netback_accel_hooks *hooks);
    2.20  /* Disconnect a previously connected accelerator plugin module */
    2.21  extern void netback_disconnect_accelerator(int id, const char *eth_name);
    2.22