2 * Copyright 2007 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.23.
11 #include <net/compat.h>
13 /* On net/core/dev.c as of 2.6.24 */
14 int __dev_addr_delete(struct dev_addr_list **list, int *count,
15 void *addr, int alen, int glbl)
17 struct dev_addr_list *da;
19 for (; (da = *list) != NULL; list = &da->next) {
20 if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
21 alen == da->da_addrlen) {
23 int old_glbl = da->da_gusers;
39 EXPORT_SYMBOL(__dev_addr_delete);
41 /* On net/core/dev.c as of 2.6.24. This is not yet used by mac80211 but
42 * might as well add it */
43 int __dev_addr_add(struct dev_addr_list **list, int *count,
44 void *addr, int alen, int glbl)
46 struct dev_addr_list *da;
48 for (da = *list; da != NULL; da = da->next) {
49 if (memcmp(da->da_addr, addr, da->da_addrlen) == 0 &&
50 da->da_addrlen == alen) {
52 int old_glbl = da->da_gusers;
62 da = kmalloc(sizeof(*da), GFP_ATOMIC);
65 memcpy(da->da_addr, addr, alen);
66 da->da_addrlen = alen;
68 da->da_gusers = glbl ? 1 : 0;
74 EXPORT_SYMBOL(__dev_addr_add);
77 /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slightly different version.
78 * Since da->da_synced is not part of 2.6.22 we need to take longer route when
82 * dev_mc_sync - Synchronize device's multicast list to another device
83 * @to: destination device
84 * @from: source device
86 * Add newly added addresses to the destination device and release
87 * addresses that have no users left. The source device must be
88 * locked by netif_tx_lock_bh.
90 * This function is intended to be called from the dev->set_multicast_list
91 * function of layered software devices.
93 int dev_mc_sync(struct net_device *to, struct net_device *from)
95 struct dev_addr_list *da, *next, *da_to;
104 /* 2.6.22 does not have da->da_synced so lets take the long route */
105 while (da_to != NULL) {
106 if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 &&
107 da->da_addrlen == da_to->da_addrlen)
112 err = __dev_addr_add(&to->mc_list, &to->mc_count,
113 da->da_addr, da->da_addrlen, 0);
117 } else if (da->da_users == 1) {
118 __dev_addr_delete(&to->mc_list, &to->mc_count,
119 da->da_addr, da->da_addrlen, 0);
120 __dev_addr_delete(&from->mc_list, &from->mc_count,
121 da->da_addr, da->da_addrlen, 0);
126 __dev_set_rx_mode(to);
127 netif_tx_unlock_bh(to);
131 EXPORT_SYMBOL(dev_mc_sync);
134 /* Part of net/core/dev_mcast.c as of 2.6.23. This is a slighty different version.
135 * Since da->da_synced is not part of 2.6.22 we need to take longer route when
139 * dev_mc_unsync - Remove synchronized addresses from the destination
141 * @to: destination device
142 * @from: source device
144 * Remove all addresses that were added to the destination device by
145 * dev_mc_sync(). This function is intended to be called from the
146 * dev->stop function of layered software devices.
148 void dev_mc_unsync(struct net_device *to, struct net_device *from)
150 struct dev_addr_list *da, *next, *da_to;
152 netif_tx_lock_bh(from);
153 netif_tx_lock_bh(to);
160 /* 2.6.22 does not have da->da_synced so lets take the long route */
161 while (da_to != NULL) {
162 if (memcmp(da_to->da_addr, da->da_addr, da_to->da_addrlen) == 0 &&
163 da->da_addrlen == da_to->da_addrlen)
171 __dev_addr_delete(&to->mc_list, &to->mc_count,
172 da->da_addr, da->da_addrlen, 0);
173 __dev_addr_delete(&from->mc_list, &from->mc_count,
174 da->da_addr, da->da_addrlen, 0);
177 __dev_set_rx_mode(to);
179 netif_tx_unlock_bh(to);
180 netif_tx_unlock_bh(from);
182 EXPORT_SYMBOL(dev_mc_unsync);
184 /* Added as of 2.6.23 on net/core/dev.c. Slightly modifed, no dev->set_rx_mode on
185 * 2.6.22 so ignore that. */
188 * Upload unicast and multicast address lists to device and
189 * configure RX filtering. When the device doesn't support unicast
190 * filtering it is put in promiscous mode while unicast addresses
193 void __dev_set_rx_mode(struct net_device *dev)
195 /* dev_open will call this function so the list will stay sane. */
196 if (!(dev->flags&IFF_UP))
199 if (!netif_device_present(dev))
202 /* This needs to be ported to 2.6.22 framework */
204 /* Unicast addresses changes may only happen under the rtnl,
205 * therefore calling __dev_set_promiscuity here is safe.
207 if (dev->uc_count > 0 && !dev->uc_promisc) {
208 __dev_set_promiscuity(dev, 1);
210 } else if (dev->uc_count == 0 && dev->uc_promisc) {
211 __dev_set_promiscuity(dev, -1);
216 if (dev->set_multicast_list)
217 dev->set_multicast_list(dev);
221 * pci_try_set_mwi - enables memory-write-invalidate PCI transaction
222 * @dev: the PCI device for which MWI is enabled
224 * Enables the Memory-Write-Invalidate transaction in %PCI_COMMAND.
225 * Callers are not required to check the return value.
227 * RETURNS: An appropriate -ERRNO error value on error, or zero for success.
229 int pci_try_set_mwi(struct pci_dev *dev)
232 #ifdef HAVE_PCI_SET_MWI
233 rc = pci_set_mwi(dev);
237 EXPORT_SYMBOL(pci_try_set_mwi);