2 * Copyright 2007-2010 Luis R. Rodriguez <mcgrof@winlab.rutgers.edu>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
8 * Compatibility file for Linux wireless for kernels 2.6.29.
11 #include <linux/compat.h>
13 #if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29))
15 #include <linux/usb.h>
16 #include <linux/etherdevice.h>
19 * If you don't see your net_device_ops implemented on
20 * netdev_attach_ops() then you are shit out of luck and
21 * you must do the nasty ifdef magic, unless you figure
22 * out a way to squeze your hacks into this routine :)
24 void netdev_attach_ops(struct net_device *dev,
25 const struct net_device_ops *ops)
27 dev->open = ops->ndo_open;
28 dev->stop = ops->ndo_stop;
29 dev->hard_start_xmit = ops->ndo_start_xmit;
30 dev->change_rx_flags = ops->ndo_change_rx_flags;
31 dev->set_multicast_list = ops->ndo_set_multicast_list;
32 dev->validate_addr = ops->ndo_validate_addr;
33 dev->do_ioctl = ops->ndo_do_ioctl;
34 dev->set_config = ops->ndo_set_config;
35 dev->change_mtu = ops->ndo_change_mtu;
36 dev->set_mac_address = ops->ndo_set_mac_address;
37 dev->tx_timeout = ops->ndo_tx_timeout;
38 if (ops->ndo_get_stats)
39 dev->get_stats = ops->ndo_get_stats;
40 dev->vlan_rx_register = ops->ndo_vlan_rx_register;
41 dev->vlan_rx_add_vid = ops->ndo_vlan_rx_add_vid;
42 dev->vlan_rx_kill_vid = ops->ndo_vlan_rx_kill_vid;
43 #ifdef CONFIG_NET_POLL_CONTROLLER
44 dev->poll_controller = ops->ndo_poll_controller;
47 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,27))
48 dev->select_queue = ops->ndo_select_queue;
51 EXPORT_SYMBOL(netdev_attach_ops);
53 #if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,23))
54 #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
56 * usb_unpoison_anchored_urbs - let an anchor be used successfully again
57 * @anchor: anchor the requests are bound to
59 * Reverses the effect of usb_poison_anchored_urbs
60 * the anchor can be used normally after it returns
62 void usb_unpoison_anchored_urbs(struct usb_anchor *anchor)
67 spin_lock_irqsave(&anchor->lock, flags);
68 list_for_each_entry(lazarus, &anchor->urb_list, anchor_list) {
69 usb_unpoison_urb(lazarus);
71 //anchor->poisoned = 0; /* XXX: cannot backport */
72 spin_unlock_irqrestore(&anchor->lock, flags);
74 EXPORT_SYMBOL_GPL(usb_unpoison_anchored_urbs);
75 #endif /* CONFIG_USB */
79 * eth_mac_addr - set new Ethernet hardware address
80 * @dev: network device
82 * Change hardware address of device.
84 * This doesn't change hardware matching, so needs to be overridden
85 * for most real devices.
87 int eth_mac_addr(struct net_device *dev, void *p)
89 struct sockaddr *addr = p;
91 if (netif_running(dev))
93 if (!is_valid_ether_addr(addr->sa_data))
94 return -EADDRNOTAVAIL;
95 memcpy(dev->dev_addr, addr->sa_data, ETH_ALEN);
98 EXPORT_SYMBOL(eth_mac_addr);
101 * eth_change_mtu - set new MTU size
102 * @dev: network device
103 * @new_mtu: new Maximum Transfer Unit
105 * Allow changing MTU size. Needs to be overridden for devices
106 * supporting jumbo frames.
108 int eth_change_mtu(struct net_device *dev, int new_mtu)
110 if (new_mtu < 68 || new_mtu > ETH_DATA_LEN)
115 EXPORT_SYMBOL(eth_change_mtu);
117 int eth_validate_addr(struct net_device *dev)
119 if (!is_valid_ether_addr(dev->dev_addr))
120 return -EADDRNOTAVAIL;
124 EXPORT_SYMBOL(eth_validate_addr);
125 /* Source: net/ethernet/eth.c */
127 #define NETREG_DUMMY 5
129 * init_dummy_netdev - init a dummy network device for NAPI
130 * @dev: device to init
132 * This takes a network device structure and initialize the minimum
133 * amount of fields so it can be used to schedule NAPI polls without
134 * registering a full blown interface. This is to be used by drivers
135 * that need to tie several hardware interfaces to a single NAPI
136 * poll scheduler due to HW limitations.
138 int init_dummy_netdev(struct net_device *dev)
140 /* Clear everything. Note we don't initialize spinlocks
141 * are they aren't supposed to be taken by any of the
142 * NAPI code and this dummy netdev is supposed to be
143 * only ever used for NAPI polls
145 memset(dev, 0, sizeof(struct net_device));
147 /* make sure we BUG if trying to hit standard
148 * register/unregister code path
150 dev->reg_state = NETREG_DUMMY;
152 /* initialize the ref count */
153 atomic_set(&dev->refcnt, 1);
155 /* NAPI wants this */
156 INIT_LIST_HEAD(&dev->napi_list);
158 /* a dummy interface is started by default */
159 set_bit(__LINK_STATE_PRESENT, &dev->state);
160 set_bit(__LINK_STATE_START, &dev->state);
164 EXPORT_SYMBOL_GPL(init_dummy_netdev);
165 /* Source: net/core/dev.c */
168 #endif /* LINUX_VERSION_CODE < KERNEL_VERSION(2,6,29) */