Skip to contentSkip to conversation

Network acceleration improvements

PATCH In review Kieran Mansley 1 participant 1 message Oct 3, 2007 Xen hypervisor interface

lore
Share & tools
lore
#0 lore raw

PATCH 4/6 Network acceleration improvements

Add version number to API between netfront and accel plugin

drivers/xen/netfront/accel.c +16 -1
diff -r 4d2b719d5a57 drivers/xen/netfront/accel.c
@@ -406,11 +406,26 @@ accelerator_probe_vifs_on_load(struct ne
 /* 
  * Called by the netfront accelerator plugin module when it has loaded 
  */
-int netfront_accelerator_loaded(const char *frontend, 
+int netfront_accelerator_loaded(int version, const char *frontend, 
 				struct netfront_accel_hooks *hooks)
 {
 	struct netfront_accelerator *accelerator;
 	unsigned flags;
+
+	if (version != NETFRONT_ACCEL_VERSION) {
+		if (version > NETFRONT_ACCEL_VERSION) {
+			/* Caller has higher version number, leave it
+			   up to them to decide whether to continue.
+			   They can re-call with a lower number if
+			   they're happy to be compatible with us */
+			return NETFRONT_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;
+		}
+	}
 
 	spin_lock_irqsave(&accelerators_lock, flags);
 
drivers/xen/netfront/netfront.h +11 -2
diff -r 4d2b719d5a57 drivers/xen/netfront/netfront.h
@@ -98,6 +98,11 @@ struct netfront_accel_hooks {
 	int (*check_busy)(struct net_device *dev);
 };
 
+
+/* Version of API/protocol for communication between netfront and
+   acceleration plugin supported */
+#define NETFRONT_ACCEL_VERSION 0x00010000
+
 /* 
  * Per-netfront device state for the accelerator.  This is used to
  * allow efficient per-netfront device access to the accelerator
@@ -221,8 +226,12 @@ struct netfront_info {
  *
  * frontend: the string describing the accelerator, currently the module name 
  * hooks: the hooks for netfront to use to call into the accelerator
- */
-extern int netfront_accelerator_loaded(const char *frontend, 
+ * version: the version of API between frontend and plugin requested
+ * 
+ * return: 0 on success, <0 on error, >0 (with version supported) on
+ * version mismatch
+ */
+extern int netfront_accelerator_loaded(int version, const char *frontend, 
 				       struct netfront_accel_hooks *hooks);
 
 /* 

Add version number to API between netfront and accel plugin

drivers/xen/netfront/accel.c +16 -1
diff -r 4d2b719d5a57 drivers/xen/netfront/accel.c
@@ -406,11 +406,26 @@ accelerator_probe_vifs_on_load(struct ne
 /* 
  * Called by the netfront accelerator plugin module when it has loaded 
  */
-int netfront_accelerator_loaded(const char *frontend, 
+int netfront_accelerator_loaded(int version, const char *frontend, 
 				struct netfront_accel_hooks *hooks)
 {
 	struct netfront_accelerator *accelerator;
 	unsigned flags;
+
+	if (version != NETFRONT_ACCEL_VERSION) {
+		if (version > NETFRONT_ACCEL_VERSION) {
+			/* Caller has higher version number, leave it
+			   up to them to decide whether to continue.
+			   They can re-call with a lower number if
+			   they're happy to be compatible with us */
+			return NETFRONT_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;
+		}
+	}
 
 	spin_lock_irqsave(&accelerators_lock, flags);
 
drivers/xen/netfront/netfront.h +11 -2
diff -r 4d2b719d5a57 drivers/xen/netfront/netfront.h
@@ -98,6 +98,11 @@ struct netfront_accel_hooks {
 	int (*check_busy)(struct net_device *dev);
 };
 
+
+/* Version of API/protocol for communication between netfront and
+   acceleration plugin supported */
+#define NETFRONT_ACCEL_VERSION 0x00010000
+
 /* 
  * Per-netfront device state for the accelerator.  This is used to
  * allow efficient per-netfront device access to the accelerator
@@ -221,8 +226,12 @@ struct netfront_info {
  *
  * frontend: the string describing the accelerator, currently the module name 
  * hooks: the hooks for netfront to use to call into the accelerator
- */
-extern int netfront_accelerator_loaded(const char *frontend, 
+ * version: the version of API between frontend and plugin requested
+ * 
+ * return: 0 on success, <0 on error, >0 (with version supported) on
+ * version mismatch
+ */
+extern int netfront_accelerator_loaded(int version, const char *frontend, 
 				       struct netfront_accel_hooks *hooks);
 
 /* 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel