static void accelerator_remove_hooks(struct netfront_accelerator *accelerator,
int remove_master)
{
+ struct netfront_accel_hooks *hooks;
struct netfront_accel_vif_state *vif_state, *tmp;
unsigned flags;
list_for_each_entry_safe(vif_state, tmp,
&accelerator->vif_states,
link) {
+ hooks = vif_state->hooks;
accelerator_remove_single_hook(accelerator, vif_state);
/*
* were set, must be called without lock held
*/
spin_unlock_irqrestore(&accelerator->vif_states_lock, flags);
+
+ /* Last chance to get statistics from the accelerator */
+ hooks->get_stats(vif_state->np->netdev, &vif_state->np->stats);
+
kref_put(&vif_state->vif_kref, vif_kref_release);
+
spin_lock_irqsave(&accelerator->vif_states_lock, flags);
}
kref_get(&np->accel_vif_state.vif_kref);
spin_unlock_irqrestore
(&np->accelerator->vif_states_lock, flags);
-
+ /* Last chance to get statistics from the accelerator */
+ vif_state->hooks->get_stats(np->netdev, &np->stats);
rc = np->accel_vif_state.hooks->remove(dev);
kref_put(&np->accel_vif_state.vif_kref,
spin_unlock_irqrestore
(&np->accelerator->vif_states_lock, flags);
+ /* Last chance to get stats from the accelerator */
+ np->accel_vif_state.hooks->get_stats(dev, &np->stats);
+
rc = np->accel_vif_state.hooks->suspend(dev);
kref_put(&np->accel_vif_state.vif_kref,
}
+int netfront_accelerator_call_get_stats(struct netfront_info *np,
+ struct net_device *dev)
+{
+ struct netfront_accel_hooks *hooks;
+ unsigned flags;
+ int rc = 0;
+
+ /*
+ * Call the get_stats accelerator hook. The use count for the
+ * accelerator's hooks is incremented for the duration of the
+ * call to prevent the accelerator being able to modify the
+ * hooks in the middle (by, for example, unloading)
+ */
+
+ if (np->accel_vif_state.hooks) {
+ spin_lock_irqsave(&np->accelerator->vif_states_lock, flags);
+ hooks = np->accel_vif_state.hooks;
+ if (hooks) {
+ kref_get(&np->accel_vif_state.vif_kref);
+ spin_unlock_irqrestore
+ (&np->accelerator->vif_states_lock, flags);
+
+ rc = np->accel_vif_state.hooks->get_stats(dev,
+ &np->stats);
+
+ kref_put(&np->accel_vif_state.vif_kref,
+ vif_kref_release);
+ } else {
+ spin_unlock_irqrestore
+ (&np->accelerator->vif_states_lock, flags);
+ }
+ }
+ return rc;
+}
+
+
/*
* Once all users of hooks have kref_put()'d we can signal that it's
* safe to unload
* path has slots too
*/
int (*check_busy)(struct net_device *dev);
+ /*
+ * Get the fastpath network statistics
+ */
+ int (*get_stats)(struct net_device *dev,
+ struct net_device_stats *stats);
};
/* Version of API/protocol for communication between netfront and
acceleration plugin supported */
-#define NETFRONT_ACCEL_VERSION 0x00010000
+#define NETFRONT_ACCEL_VERSION 0x00010001
/*
* Per-netfront device state for the accelerator. This is used to
extern
void netfront_accelerator_call_stop_napi_irq(struct netfront_info *np,
struct net_device *dev);
-
+extern
+int netfront_accelerator_call_get_stats(struct netfront_info *np,
+ struct net_device *dev);
extern
int netfront_load_accelerator(struct netfront_info *np,
struct xenbus_device *dev,