/***************************************************************************/ /*! \file dumm_accel_backend.c Dummy accelerated plugin module Copyright 2006 Solarflare Communications Inc, 9501 Jeronimo Road, Suite 250, Irvine, CA 92618, USA This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License version 2 as published by the Free Software Foundation, incorporated herein by reference. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ /***************************************************************************/ static struct netback_accel_hooks accel_hooks = { &netback_accel_probe, &netback_accel_remove }; static const char *frontend_name = "dummynetaccel"; static int netback_accel_init(void) { /* Initialise the rest of the module... */ /* Tell the netback that we're here */ netback_connect_accelerator(0, frontend_name, &accel_hooks); } module_init(netback_accel_init); static void __exit netback_accel_exit(void) { netback_disconnect_accelerator(0, frontend_name); /* ...and take down the rest of the module */ } module_exit(netback_accel_exit); int netback_accel_probe(struct xenbus_device *dev) { struct backend_info *binfo; /* Setup per-device internal state */ /* Store internal state for future access */ binfo = (struct backend_info *) dev->dev.driver_data; binfo->netback_accel_priv = my_internal_state; /* Setup watch on accel-state, so we know when frontend acceleration plugin is loaded */ setup_domu_accel_watch(dev, my_internal_state); } int netback_accel_remove(struct xenbus_device *dev) { /* Cleanup as the device is going away */ } void netback_accel_frontend_changed(struct xenbus_device *dev, XenbusState frontend_state) { switch(frontend_state) { case XenbusStateConnected: /* Frontend has loaded and is ready to go */ /* Initialise ourselves */ setup_accel_backend(); netback_accel_update_state(dev, XenbusStateConnected); } } void netback_accel_update_state(struct xenbus_device *dev, int state) { struct xenbus_transaction tr; int err; if(xenbus_exists(XBT_NIL, dev->nodename, "")) { again: err = xenbus_transaction_start(&tr); if (err == 0) err = xenbus_printf(tr, dev->nodename, "accelstate", "%d", state); if (err != 0) xenbus_transaction_end(tr, 1); else { err = xenbus_transaction_end(tr, 0); if(err == -EAGAIN) goto again; } } }