Signed-off-by: Kieran Mansley <kmansley@xxxxxxxxxxxxxx>
Add version number to API between netback and accel plugin
diff -r 330deb0c6935 drivers/xen/netback/accel.c
--- a/drivers/xen/netback/accel.c Wed Oct 03 13:30:20 2007 +0100
+++ b/drivers/xen/netback/accel.c Wed Oct 03 13:32:27 2007 +0100
@@ -103,18 +103,35 @@ static int netback_accelerator_tell_back
* Entry point for an netback accelerator plugin module. Called to
* advertise its presence, and connect to any suitable backends.
*/
-void netback_connect_accelerator(int id, const char *eth_name,
- struct netback_accel_hooks *hooks)
-{
- struct netback_accelerator *new_accelerator =
+int netback_connect_accelerator(unsigned version, int id, const char
*eth_name,
+ struct netback_accel_hooks *hooks)
+{
+ struct netback_accelerator *new_accelerator;
+ unsigned eth_name_len, flags;
+
+ if (version != NETBACK_ACCEL_VERSION) {
+ if (version > NETBACK_ACCEL_VERSION) {
+ /* Caller has higher version number, leave it
+ up to them to decide whether to continue.
+ They can recall with a lower number if
+ they're happy to be compatible with us */
+ return NETBACK_ACCEL_VERSION;
+ } else {
+ /* We have a more recent version than caller.
+ Currently reject, but may in future be able
+ to be backwardly compatible */
+ return -EPROTO;
+ }
+ }
+
+ new_accelerator =
kmalloc(sizeof(struct netback_accelerator), GFP_KERNEL);
- unsigned eth_name_len, flags;
-
if (!new_accelerator) {
DPRINTK("%s: failed to allocate memory for accelerator\n",
__FUNCTION__);
- return;
- }
+ return -ENOMEM;
+ }
+
new_accelerator->id = id;
@@ -124,7 +141,7 @@ void netback_connect_accelerator(int id,
DPRINTK("%s: failed to allocate memory for eth_name string\n",
__FUNCTION__);
kfree(new_accelerator);
- return;
+ return -ENOMEM;
}
strlcpy(new_accelerator->eth_name, eth_name, eth_name_len);
@@ -139,6 +156,8 @@ void netback_connect_accelerator(int id,
/* tell existing backends about new plugin */
xenbus_for_each_backend(new_accelerator,
netback_accelerator_tell_backend);
+
+ return 0;
}
EXPORT_SYMBOL_GPL(netback_connect_accelerator);
diff -r 330deb0c6935 drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h Wed Oct 03 13:30:20 2007 +0100
+++ b/drivers/xen/netback/common.h Wed Oct 03 13:36:10 2007 +0100
@@ -149,9 +149,16 @@ struct backend_info {
struct netback_accelerator *accelerator;
};
-/* Connect an accelerator plugin module to netback */
-extern void netback_connect_accelerator(int id, const char *eth_name,
- struct netback_accel_hooks *hooks);
+#define NETBACK_ACCEL_VERSION 0x00010000
+
+/*
+ * Connect an accelerator plugin module to netback. Returns zero on
+ * success, < 0 on error, > 0 (with highest version number supported)
+ * if version mismatch.
+ */
+extern int netback_connect_accelerator(unsigned version,
+ int id, const char *eth_name,
+ struct netback_accel_hooks *hooks);
/* Disconnect a previously connected accelerator plugin module */
extern void netback_disconnect_accelerator(int id, const char *eth_name);
netback_version
Description: Text document
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|