1 /****************************************************************************
2 * Solarflare driver for Xen network acceleration
4 * Copyright 2006-2008: Solarflare Communications Inc,
5 * 9501 Jeronimo Road, Suite 250,
6 * Irvine, CA 92618, USA
8 * Maintained by Solarflare Communications <linux-xen-drivers@solarflare.com>
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published
12 * by the Free Software Foundation, incorporated herein by reference.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 ****************************************************************************
26 #include "accel_msg_iface.h"
27 #include "accel_solarflare.h"
29 #include <linux/notifier.h>
35 static int netback_accel_netdev_event(struct notifier_block *nb,
36 unsigned long event, void *ptr)
38 struct net_device *net_dev = (struct net_device *)ptr;
39 struct netback_accel *bend;
41 if ((event == NETDEV_UP) ||
42 (event == NETDEV_DOWN) ||
43 (event == NETDEV_CHANGE)) {
44 mutex_lock(&bend_list_mutex);
46 while (bend != NULL) {
47 mutex_lock(&bend->bend_mutex);
49 * This happens when the shared pages have
50 * been unmapped, but the bend not yet removed
53 if (bend->shared_page == NULL)
56 if (bend->net_dev->ifindex == net_dev->ifindex) {
58 if (event == NETDEV_CHANGE)
59 ok = (netif_carrier_ok(net_dev) &&
60 (net_dev->flags & IFF_UP));
62 ok = (netif_carrier_ok(net_dev) &&
63 (event == NETDEV_UP));
64 netback_accel_set_interface_state(bend, ok);
68 mutex_unlock(&bend->bend_mutex);
69 bend = bend->next_bend;
71 mutex_unlock(&bend_list_mutex);
78 static struct notifier_block netback_accel_netdev_notifier = {
79 .notifier_call = netback_accel_netdev_event,
83 unsigned sfc_netback_max_pages = NETBACK_ACCEL_DEFAULT_MAX_BUF_PAGES;
84 module_param_named(max_pages, sfc_netback_max_pages, uint, 0644);
85 MODULE_PARM_DESC(max_pages,
86 "The number of buffer pages to enforce on each guest");
88 /* Initialise subsystems need for the accelerated fast path */
89 static int __init netback_accel_init(void)
94 gcov_provider_init(THIS_MODULE);
97 rc = netback_accel_init_fwd();
101 netback_accel_debugfs_init();
103 rc = netback_accel_sf_init();
107 rc = register_netdevice_notifier
108 (&netback_accel_netdev_notifier);
115 netback_accel_sf_shutdown();
117 netback_accel_debugfs_fini();
118 netback_accel_shutdown_fwd();
121 gcov_provider_fini(THIS_MODULE);
126 module_init(netback_accel_init);
128 static void __exit netback_accel_exit(void)
130 unregister_netdevice_notifier(&netback_accel_netdev_notifier);
132 netback_accel_sf_shutdown();
134 netback_accel_shutdown_bends();
136 netback_accel_debugfs_fini();
138 netback_accel_shutdown_fwd();
141 gcov_provider_fini(THIS_MODULE);
145 module_exit(netback_accel_exit);
147 MODULE_LICENSE("GPL");